Output Manifests
Relevant source files
The following files were used as context for generating this wiki page:
Output Manifests in abx-dl represent the structured collection of metadata and files generated during a URL download session. The system primarily uses a JSONL-formatted index file (index.jsonl) to track snapshots, tags, and archive results, providing a machine-readable audit trail of every plugin's execution and output.
These manifests ensure that the results are ArchiveBox-compatible and easily consumable by both the Command Line Interface (CLI) and the Web Download Server. By decoupling the actual file storage from the metadata registry, the system can track file sizes, mimetypes, and execution status without needing to parse the content of the downloaded files themselves.
Architecture and Data Models
The output system is built around several Pydantic models that define the structure of manifest entries. Every run creates an index.jsonl file in the output directory, which acts as the primary manifest.
Core Manifest Entities
The manifest consists of three primary record types:
- Snapshot: Represents the top-level URL being archived.
- ArchiveResult: Captures the specific output of an individual plugin hook, including file paths and success/failure status.
- Tag: Stores metadata labels associated with a snapshot.
Sources: abx_dl/models.py:277-338, README.md:167-175
Output File Metadata
The OutputFile model is used to track individual files generated by hooks. It avoids reading file contents by using filesystem stat calls and mimetype guessing.
The diagram shows the relationship between a result record and the files it references.
Sources: abx_dl/output_files.py:19-25, abx_dl/models.py:321-338
Manifest Generation Flow
Manifests are generated reactively based on events emitted during the lifecycle of a download. The ProcessService and ArchiveResultService collaborate to transform subprocess outputs into manifest records.
Process to Manifest Transition
- Execution: A hook runs and potentially emits JSONL lines to
stdout. - Detection:
ProcessStdoutEventcaptures these lines. - Validation: The system scans for specific types (e.g.,
ArchiveResult). - Enrichment: If a hook completes without explicit JSONL output, a synthetic
ArchiveResultis created from the process exit code and file system changes.
This flowchart illustrates how raw process output is converted into persistent manifest entries.
Sources: abx_dl/events.py:273-310, abx_dl/cli.py:539-605, abx_dl/models.py:341-347
File Scanning and Mimetypes
The system includes a specialized module for identifying output files and assigning them correct mimetypes without opening them. This is critical for maintaining performance when handling large datasets or numerous small files.
Metadata Filtering
When scanning the output directory, the manifest system explicitly excludes internal process artifacts to keep the manifest clean. The following suffixes are ignored:
.stdout.log.stderr.log.log.pid.sh
Sources: abx_dl/output_files.py:16-17, abx_dl/output_files.py:61-82
Mimetype Resolution Logic
| Feature | Implementation Detail |
|---|---|
| Gzip Support | If a file is .gz, the system strips the suffix and guesses based on the inner extension. |
| Custom Types | Explicitly adds application/warc for .warc files. |
| Non-Standard | Uses mimetypes.guess_type(strict=False) to capture common web formats. |
Sources: abx_dl/output_files.py:11-13, abx_dl/output_files.py:28-44
Manifest Consumption
Manifests are used by different interfaces to present the results of a download.
CLI Display
The CLI parses index.jsonl (or the equivalent events) to build a Live table. It humanizes output sizes and color-codes statuses.
- Success: Rendered in green.
- Failure: Rendered in red with error details.
- Sizes: Humanized (e.g.,
2KB,1MB) with color thresholds (Green < 2MB, Yellow < 50MB, etc.).
Sources: abx_dl/cli.py:59-75, abx_dl/cli.py:385-430
Web Server API
The Web Download Server provides endpoints to interact with the manifests:
GET /api/session/<id>: Returns a merged view of thesession.jsonmetadata and parsedindex.jsonlrecords.GET /download/<id>/zip: Compiles all files listed in the manifest into a single archive.
Sources: server/server.py:377-408, server/server.py:428-449
Conclusion
Output Manifests serve as the glue between diverse plugin executions and a unified storage format. By utilizing JSONL and standard metadata models, abx-dl provides a robust, ArchiveBox-compatible record of web archival activities.