Tag Service
Relevant source files
The following files were used as context for generating this wiki page:
The Tag Service (referred to in the architectural documentation as a discovery service) is responsible for handling and persisting metadata tags emitted during the snapshot extraction process. Within the abx-dl ecosystem, tags are used to categorize or label snapshots based on content discovered by various plugins. The service operates by listening to structured event streams produced by plugin hooks and translating them into persistent records.
Architecture and Data Flow
The Tag Service operates as part of the asynchronous abxbus event system. When a plugin hook runs during the Snapshot phase, it may output JSONL records to stdout. The ProcessService captures this output and emits a ProcessStdoutEvent. A routing layer then parses these lines; if a line contains a JSON object with "type": "Tag", it is converted into a TagEvent.
Event Lifecycle
The following diagram illustrates the flow from a plugin hook emitting a tag to its representation in the system:
The system relies on specific event types to decouple the discovery of tags from their eventual persistence in the index.jsonl manifest.
Sources: abx_dl/events.py:10-45, abx_dl/events.py:270-285, README.md:50-70
Data Models
The service utilizes a specific data structure to represent tags. Tags are primarily linked to a Snapshot via a unique ID.
The Tag Model
| Field | Type | Description |
|---|---|---|
name | str | The string label for the tag (e.g., "article", "video"). |
snapshot_id | str | The unique identifier of the snapshot this tag belongs to. |
Sources: abx_dl/models.py:240-250
Tag Events
The TagEvent is the primary vehicle for tag data within the bus. It inherits from BaseEvent and is configured to ignore extra fields during Pydantic validation to remain robust against plugin output variations.
class TagEvent(BaseEvent):
"""A hook emitted a tag to attach to the current snapshot."""
model_config = ConfigDict(extra="ignore")
name: str
snapshot_id: str = ""
event_timeout: float | None = 10.0
Sources: abx_dl/events.py:328-336
Persistence and Integration
Tags are persisted to the filesystem as part of the index.jsonl file created in the output directory. This file serves as the primary manifest for the run and is compatible with the broader ArchiveBox ecosystem.
Output Manifest
When write_jsonl is called for a Tag record, it produces a JSON line formatted as follows:
{"name": "example_tag", "snapshot_id": "12345", "type": "Tag"}
This allows external tools and the web UI to reconstruct the metadata associated with a specific download session.
Sources: abx_dl/models.py:252-258, README.md:140-160
UI Representation
In the web interface and CLI, tags contribute to the "Progress" and "Metadata" views. The LiveBusUI handles ArchiveResult and Snapshot events which, while distinct, are often augmented by the presence of tags in the event history.
Sources: server/server.py:220-240, abx_dl/cli.py:550-600
Conclusion
The Tag Service provides a standardized mechanism for plugins to attach arbitrary metadata to archived content. By leveraging the abxbus and structured JSONL output, it ensures that discovery data is captured in real-time and remains available for downstream indexing or search services.