python -m tools.intake.cli --root ROOT operates one private installed instance.
Initialize the intake ledger explicitly; stage exact UTF-8 JSON, then run only a
named stage. The ledger is operational recovery state, never corpus authority.
- Request v1:
version,correlation_id, nullablecorrection_of,policy(version,sha256),retry(max_attempts,backoff_seconds), andstages. Each stage hasid,kind,operation,arguments. Closed fields, duplicate key refusal, 1 MiB request limit, 16 stages, 1–10 attempts, 0–86400s backoff. - Fixed adapters: receipt/catalog-submit; extraction/docling-prepare,
docling-verify, docling-register; extraction/extract-prepare, extract-register
(strict UTF-8
text,gemini-txt,mhtml,odt); review/review-append; publication/index-build; review/standing-review, publication/standing-select, publication/standing-publish; return/await-ack. Seetools/intake/contracts.pyfor argument fields. Preserve native attribution and original concurrency tokens. - Intake stores exact requests before effects. Prepared intent commits before
an execution attempt. Restart reconciles unfinished attempts without charging
another attempt. Catalog/review retries use original request IDs and daily
verified native snapshots (a retry or same-day write reports
backup: null); evidence records original committed revisions, not current unrelated revisions. Docling reruns the offline native lifecycle, binding source/runtime/rendition identity; no auto-review or selection. Intake passes the pinned identity to the native lifecycle asexpected_identity, so a source or runtime change refuses before any rendition or registration is published and each attempt converts once. - Review-event reads (
qualify, standing review, progress,event_store status) trust a validation while the events database file identity (device, inode, size, mtime, ctime, SQLite change counter), the contract hash and the validator code are unchanged and the chain heads re-read from the file still match. The validation is held in process memory and persisted as<review events home>/.local/read-validation.json, so a new process (every MCP call) replays nothing, and after a commit verifies only the events past the remembered head. There is no daily expiry;event_store.py auditandpython -m tools.store_auditreplay everything. An edit that restores identity and leaves the chain heads alone is seen only then (the catalog receipt's residual). Usage and evidence: design. - Concurrent intake agents may share one instance (design).
The catalog writer lock waits up to 10s across processes. A catalog write
validates only its delta when the database file identity (device, inode, size,
mtime, ctime, SQLite change counter) matches a prior full validation
(design), and replays all history otherwise
and under
status --audit. There is no daily expiry (Kata 91h5): the first write of a UTC day holds the writer lock for the daily snapshot only (about 2 s at 132k revisions), not for a replay. The full replay is the scheduledpython -m tools.store_audit --root ROOT(catalog, review events, intake ledger, newest backups; JSON report, exit 1 when any store is flagged; design). A lost race is a retryablecatalog-stale-state(another writer committed after the pin) orcatalog-busy(lock wait exceeded) attempt, nevernative-input. Such an attempt wrote nothing, so it does not spendmax_attempts(design): it counts against a separate bound of 30 lost races per stage cycle, and onesettlecall retries at most 6 in a row (about 60 s at the 10 s catalog wait) before it returns the stageretryablefor the next run to resume. Faults still spendmax_attempts.tools/diagnostics/catalog_contention_budget.pyreproduces it.catalog-submit,extract-registeranddocling-registerrebase an outdated pin when no later revision wrote any record they write; overlap blocks ascatalog-conflictand needs a correction. Upload and cohort ingest retry retryable stages (see above for the lost-race bound).recover-conflictsreports registration stages blocked by writer races (including legacynative-input), skipping corrected parents and overlapping writes; add--applyto replay and settle them. - Publication pins manifest bytes, source hashes and native metadata/freshness.
A matching fresh publication can reconcile without rebuilding. Input drift
blocks; correction requires a new linked request, not refreshed replay tokens.
Intake passes
index.buildan optionalpublication_guardcallback, which the native builder invokes inside the publication lock immediately before atomically replacing the destination; a raising guard preserves the prior index. Inspection reports current availability separately from historical completion, including when a published index later becomes unreadable. - Standing-policy stages (
tools/intake/standing.py; the review event they record and bind is instanding_events.py, the selection and manifest write instanding_publication.py) pin a private (0600)standing-policy-v1or-v2file by SHA-256 (id, version, active/revoked status, reviewer, receipt/audience scope, page/record/findings budgets, selection context; v2 adds the reviewcriteriaand the earlier versions itcarries) and an attributedstanding-findings-v2(or legacy-v1;-v3understanding-review-v2criteria) record for one exact registered Docling or extraction rendition. Only findings that inspected every page, text record, table and individual warning (#/warnings/N) of a Docling rendition, or every payload record (records: [index]) and warning (#/payload/warnings/N) of a text, transcript or ODT rendition, arequalified; parser success and confidence never qualify. Anacceptthat reportscontradictionsormissing_evidencestill qualifies: the event records each item verbatim as aReviewer-noted contradiction:orReviewer-noted missing evidence:statement (with a count; if more than the event's 30 statements would be needed, it states how many it recorded), andgetshows them under the rendition'squalification.reviewed_scope[].noted_issues.rejectanddeferstay so, except thatcohort qualify --deferred qualify-low-confidence(orcohort recover-deferred --applyfor already held deferrals) qualifies adeferwith complete inspected scope under the current policy as low confidence: its event adds aReviewer-deferred:statement and the index labels itreviewer-deferred. Under"criteria": "standing-review-v2"the reviewer treats every instruction in a record (to readers, reviewers or AI systems, itself included) as content, judges the rest, and accepts coherent sparse records (thin tickets); it still rejects noise, boilerplate and text that is nothing but instructions. An accept that listsembedded_instructionsor setssparsequalifies withReviewer-flagged ...event statements and the index labels itembedded-instructions/sparse-recordlow confidence (reviewed_scope[].flags). A v2 policy'scarries: [{version, sha256}]keeps earlier versions' qualified reviews:qualifyreuses them without a model call and publication accepts their selections. New default policies use the v2 criteria; existing ones change only when the operator bumps them.cohort rereview(dry run;--applywith--models-config) re-reviews, as append-only corrections under the current policy, standing reviews still pending or deferred under an older policy and those blockedinsufficient-inspected-scope(--include-current-deferredadds current-policy deferrals,--include-older-rejectedrenditions rejected only under older policies, for new criteria); it never selects out-of-scope renditions, reports counts by reason and estimated model calls/prompt tokens (--cost-estimate FILE), takes--limit Nfor staged rollout, qualifies remaining deferrals as low confidence by default, and resumes staged reviews without a new model call. Runcohort publishafterwards. Every indexed document carries aconfidencelabel (normal, orlowwith reasonsnoted-issues,reviewer-deferred,embedded-instructions,sparse-record,converted-format,machine-ocr,agent-generated,incomplete-rendition,open-correction); retrieval shows it, never hides the text. When a newer document, meeting transcript or answered question contradicts or settles a claim, record it withpython -m tools.review_events.corrections record|resolveorintake FILE(aclaim-corrections-v1JSON file beside the newer document); an open correct/dispute marks the text containing the quoted claimopen-correctionat read time, without a rebuild. An upload can declare agent-written content withsubmit-file --agent-generator NAME [--agent-generated-on DATE] [--agent-source-commit SHA](a version 2 descriptor). The v2 advisoryunverifiable_referenceslist (claims depending on material the document cites but does not contain) never blocks; a qualified event states only its count. Other outcomes (pending-review,rejected,deferred,exception) block visibly with a reason code and write nothing. Missing findings are a retryablereview-route-unavailable. Corrections, new mappings or existing independent reviews of the rendition require independent review. A qualified review appends one deterministic event under its request ID (idempotent after a lost acknowledgment); selection re-evaluates, marks the catalog child indexed and atomically adds the manifest entry; publication pins the policy, and current availability is false once the policy is revoked/changed or sources drift. Qualification compares the rendition's full source identity (artifact, source IDs, path, hash, bytes, audience, handling refs) with the current catalog registration. Publication and availability refuse a manifest whose standing-reviewed selections were authorized by a different policy or fall outside the publishing policy's receipt/audience scope (standing-selection-unauthorized). - Undecodable or invalid native inputs block durably with a recorded attempt outcome instead of surfacing a traceback, and ledger write failures after validation report an unavailable ledger rather than claiming corruption.
- A writer checks the ledger's structure, not every row: application ID and schema version on each
lock, SQLite
integrity_checkandforeign_key_checkonce per process for each ledger file (design). Digests and the request, stage, attempt and replay rules are verified bypython -m tools.intake.cli --root ROOT audit(read-only, no writer lock, safe beside a live run; about 1 s per 36,000 requests) and by everyprogressread. A request or artifact digest edited while the ledger stays structurally sound is therefore not seen by a running writer: runauditbefore an upgrade or backup and after any unexplained failure.writer.lockcarries no hand-off; a read-only refusal such asunknown_requestfrom a cohort existence probe costs the next writer nothing. - The ledger writer lock wait is bounded (default 30s, set
LIBRARIAN_INTAKE_LOCK_WAIT_SECONDSor passwait; the same value is the SQLite busy timeout). Exceeding it, or a transient SQLite BUSY/LOCKED during a stage, raises retryableledger_busy(CLI:{"error":"ledger_busy","retryable":true}), neverledger_unavailableor a hang.runner.settleandcohort ingestretry it up to three times; an entry still busy fails visibly asledger/ledger_busyand the run continues, so the next run resumes it. A stage whose run reports busy while recording a failure is a retryable attempt, not blocked.ledger_unavailableremains for non-transient SQLite failures after validation. - Retryable failures record eligibility time; nothing sleeps or schedules itself.
replayexplicitly resets a blocked/dead-letter stage's bounded cycle while retaining exact request, intent and all attempt/replay history. Other requests remain runnable. Unfinished work is resumed withrun/resume, not replay. - Return requires a complete root-relative disposition artifact and its SHA-256.
runrecordsreturn-pending.acknowledgeaccepts only matchingdelivery_correlation,disposition_sha256,transport_receipt; exact repeats are idempotent and changed receipts conflict.deliveredis a supplied transport acknowledgment claim, not independent remote or business acceptance. .local/intakeis 0700; database/lock are 0600, symlink-free, LINT schema 1, FULL synchronous SQLite with process serialization. Missing/incompatible or corrupt ledgers refuse operation; never rebuild corpus authority from this ledger. Protect operational request bodies like other private instance data.
submit-file FILE --submission-id ID --format {text,gemini-txt,mhtml,odt,pdf,image} --actor A --reason R stages one explicitly supplied file. Optional
--name, --correction-of, --expected-sha256 and declared
--origin-system/--origin-locator/--origin-version.
- The file is read once through a symlink-free, regular-file-only descriptor and refused if it changes during the read, exceeds the existing extractor limit, or fails the extension/signature check for an already supported format.
- Bytes and a hash-bound
submission.jsonprovenance sidecar are atomically published (0600 in 0700 directories) under<first original root>/intake/<submission-id>/, then registered as source, receipt, original and preserved-metadata records through a durablecatalog-submitstage with correlationupload-<submission-id>. - The acknowledgment reports
receipt(committed, pending, retryable, blocked, dead-letter) separately fromprocessing; upload never extracts, reviews, selects or qualifies anything. - A filename never supplies a remote identity or version; only declared origin
fields do (
identity_basis). Equal bytes under distinct submissions remain distinct sources and receipts. - An exact retry returns the existing acknowledgment and resumes unfinished
work. Changed bytes or descriptor under one submission ID are a
submission_conflict; send a new submission with--correction-of, which reuses the parent source and adds aversion-ofrelationship. A parent whose receipt durably blocked or dead-lettered without committing (for example a stale catalog state after an interruption) may also be replaced this way: the replacement plans fresh records against the current catalog, links the ledger requests, and leaves the stranded request visible. A parent that can still commit iscorrection_parent_pending; retry it exactly instead. --origin-kind local-pathrecords a copy of a local file: a system label and a relative locator (identity_basis: local-path-copy), never a remote identity or version.drop-scan --drop DIRis discovery only.drop-submit --drop DIRsubmits eachNAMEpaired withNAME.submission.json(the v1 descriptor fields). The drop must exist and contain.librarian-drop; a missing or unmarked mount isdrop_unavailable, never an empty success. Drop contents are never modified.
Reference target for a large cohort on an instance of production size (about 100 MB
catalog, 25,000 revisions, about 130 MB ledger, 35,000 requests), on a host that is not
otherwise saturated: at least 10 files/min sustained on the instance (a 5,000-file
cohort in under 8.5 hours), at least 20 files/min on the synthetic production-size harness
(ledger_scale_benchmark.py, which measured about 28), p95 per-file latency under 10 s,
and the last decile of a run no more than 2x the first decile (measured 1.7x at 1,600
synthetic files). Each file is two catalog commits. The model behind it is, per file, at this size:
about 14 whole-file catalog bindings (serialize + SHA-256, about 0.11 s each at 100 MB),
at most one full ledger validation per process, two delta commits (about 0.1 s each), and
extraction. Measure with the synthetic harnesses; never point them at a real instance:
python3 tools/diagnostics/ingest_benchmark.py --sizes 100,200,400 --resume
python3 tools/diagnostics/catalog_lock_benchmark.py --sizes 400,1600,6400,16000 --samples 3
python3 tools/diagnostics/catalog_commit_ceiling.py --size 1600 --workers 1,2,4
python3 tools/diagnostics/ledger_scale_benchmark.py --ledger 36000 --catalog 25600 --files 40Planning a submission (upload.records_for) no longer scans history (design):
the next S/D numbers come from the highest current ID per prefix in the catalog's primary-key index plus
the highest promised by any upload-* request in the ledger, read incrementally (only requests added since the
previous call, by row id, each decoded once per process; a different or smaller ledger resets it);
staged, retrying, blocked and dead-letter requests keep their IDs reserved. Profile it with
python3 tools/diagnostics/upload_planning_benchmark.py --catalog 1600,6400,25600 --ledger 36000, and use
ledger_scale_benchmark.py --matched --warm (a ledger with one committed upload request per registration, and
the one-off daily replay excluded) for per-file figures.
Replaying an unchanged inbox (ingest, and the ingest inside every qualify) re-checks every file:
classify reads and hashes each admitted file once and parses MIME HTML and Gemini transcripts for the
disposition, submit re-reads it against expected_sha256 and the retained copy, and the ledger decides
what is already received and extracted. Hashing is about 1% of the cost. The rest was repeated ledger opens
(about nine per file, each re-validating the storage roots and walking the path for symlinks) and the same
receipt request read several times. A replay now opens the ledger three times per entry (the receipt request
with its summary, then the correction-chain head of the extraction and of the registration) and
reuses only a receipt stage that has succeeded, and the storage-root check is reused for an identical policy,
with the symlink walk done once per path component. A modified file is still detected (a new content-salted
submission superseding the old, or changed-since-intake). Measure it with
python3 tools/diagnostics/ingest_benchmark.py --sizes 2000 --replay --fixture mixed --padding 1800 --reuse DIR
(wall and CPU seconds, bytes read from /proc/self/io, and a digest of the whole report so two --tree
checkouts can be compared): about 11 to 5 ms per file at 2,000 and 10,000 synthetic files of about 133 KiB.
A MIME HTML file costs about 8 ms more in its parser during classify; that is the remaining floor.
Batched catalog registration. ingest processes admitted files in chunks (--batch-size, default 50; 1 is the
old path of two catalog revisions per document). A chunk's receipts commit as ONE catalog revision and its extraction
registrations as ONE more, so a document costs about 2/N revisions instead of 2, and the writer lock, fsyncs
and per-commit validation are paid once per chunk. What stays per document: the retained copy, the ledger
request, stage, attempt, intent and evidence of every receipt and extraction stage, and every changed-input check.
Each document is judged on its own inside the chunk:
- Idempotency is per document. A document's receipt is identified by its
A-upload-<submission>-originalrecord, its registration byA-extract-<run>. A re-run builds its chunk from the documents whose marker record is not yet in the catalog; one that is (committed by any earlier revision, batched or not) is reported at the revision that wrote it and not written again. A marker that exists with different content refuses that document. - Conflicts. Each document keeps its own pin and is rebased on its own: refused with
catalog-conflictwhen a later revision wrote one of its records, otherwise accepted. Two documents of one chunk may not write the same record; the later is refused. A refused or failing document is recorded on its own stage and never blocks the rest. - Atomic. The accepted documents are validated together and written in one SQLite transaction: all or none. If the union does not validate, documents are validated one at a time in order to find the refused ones.
- Ledger. Each stage keeps its own attempt and status; evidence names the revision the document committed in
(documents of one chunk share it) and a chunk's stages settle together. A chunk commits its receipt requests,
its prepare requests (text-family documents) and its registration requests once each, and each stage settlement
twice (intent and running attempt, then evidence), so ledger commits per document fall toward zero as the chunk
grows (12 per document at
--batch-size 1before, 6 at the default 50, under 0.2 now).
A process killed at any point leaves a catalog at a revision boundary (a killed writer's rollback journal needs the
usual explicit recovery, migrate-indexes --recover) and a ledger whose unfinished attempts the next run reuses; run
ingest again with any batch size and it completes with no duplicate and no lost document. The revision hash chain,
state tokens and schema are unchanged, so existing instances and history written one document per revision stay
valid, and daily-snapshot and validation-receipt behavior is per commit as before (a chunk is one commit). Measure
it on synthetic seeds, never a real instance:
python3 tools/diagnostics/batch_ingest_benchmark.py --seed 2000 --files 60 --padding 1800 --batch-sizes 1,10,25,50
python3 tools/diagnostics/batch_ingest_benchmark.py --tree PATH_TO_OTHER_CHECKOUT --seed 2000 --files 60 --batch-sizes 1Extraction work per document. Each extract stage reads the catalog snapshot, the original and the extractor
identity afresh (extract.bundle) and parses the original; a first ingest used to do that six times per document
and now does it four times and parses once (the newest parse is kept, keyed by format, source SHA-256 and extractor
SHA-256). A source or extractor change between prepare and register still blocks: each stage re-reads and
compares the pinned identity before publishing or submitting (changed-extraction-identity), and extract.run
re-reads and re-hashes the original and recomputes the extractor identity under the catalog writer lock before and
after publication and before and after registration (Source changed during extraction/registration). See the
design document for why each check remains. Measure it with tools/diagnostics/ingest_benchmark.py (the
tools.extraction.extract.run and upload.reserved_ids timers) on a seeded instance.
Parse worker processes. Reading, hashing and parsing a text-family file (strict UTF-8, MIME HTML, transcripts,
ODT) are pure functions of its bytes, so ingest and qualify do them in --parse-workers processes while the one
writer commits (default: the CPUs, at most 4, and none until an inbox has more than 32 files; 1 is the old
single-process path). classify reads and hashes each file in this process and has a worker judge it (format, strict
decoding, MIME and transcript parsing), and each chunk's documents are parsed ahead of its ledger stages while the
previous chunk commits; the prepare stage and its guards find the parse remembered by (format, source SHA-256,
extractor SHA-256), exactly the key they already re-check, so a parse of other bytes is never used and every
changed-input check is unchanged. Results return in input order, so the report, ledger and catalog are the same at 1
and N workers (tests/test_intake_parse_workers.py). A worker receives bytes, a bare file name and the policy
settings, never a path to read, and has no network, ledger or catalog handle (spawned, not forked); a worker that
dies (killed, out of memory, a parser crash) fails only its file (classify: unreadable/parse-worker-died;
chunk parse: failed prepare/parse-worker-died) and a rerun reads it afresh. Memory is bounded by the queue: at most
a few chunks of documents and 64 MiB of source in flight, and 32 MiB of remembered parses beyond the chunk. PDFs,
images and converted office documents keep their own bounded child processes (--extract-concurrency). A script that
calls cohort.ingest with workers must guard its entry point with if __name__ == "__main__" (spawned workers re-import
it); without the guard the workers die and their files report parse-worker-died. Measure it
on synthetic seeds:
python3 tools/diagnostics/batch_ingest_benchmark.py --seed 2000 --files 600 --padding 1700 --batch-sizes 50 --parse-workers 1,4,8Catalog lookup indexes. Every write probes the committed catalog for records that reference a record it
rewrites and for artifacts that already hold a path it moves. Catalogs created now have lookup indexes and a
refs table for that, so those probes no longer scan the catalog; first ingest into a large catalog was about
4x faster at 40,000 synthetic documents. An older catalog keeps working without them (slower, same decisions)
until the operator runs, once and with no other writer in the way:
python -m tools.initialize --migrate-catalog-indexes # idempotent; verifies and takes a snapshot first
python -m tools.catalog.catalog_store migrate-indexes --check # report "legacy" or "indexed"; writes nothingIf audit reports "Catalog lookup structures are incomplete or differ", run
python -m tools.catalog.catalog_store migrate-indexes --rebuild: it recreates them only when the rest of the catalog
verifies. Restoring a snapshot taken before the migration yields a working catalog without them; run the migration again.
If a migration process was killed it can leave SQLite's rollback journal, which every command refuses as an unsupported
sidecar: confirm no catalog process is running, then run migrate-indexes --recover, which (under the writer lock) lets
SQLite roll the journal back, verifies the catalog in full and migrates.
ledger_scale_benchmark.py reports full_ledger_validations; it should be about 1 per
process, not about 2 per file. Timings come from a shared host: compare shapes, CPU and
counts rather than third digits.
progress and progress-serve are read-only, body-free observation of a run;
they never stage, run, replay, repair or initialize anything, and a missing,
locked, public or corrupt ledger, catalog, review-event store or index is
reported as that source being unavailable with its error class, never a crash.
tools/intake/progress.py reads the sources into one report, progress_render.py
renders it as text or HTML and progress_serve.py serves it.
.venv/bin/python -m tools.intake.cli --root . progress [--format text] [--run bulk=upload-bulk-]
.venv/bin/python -m tools.intake.cli --root . progress-serve [--port 8765]- The ledger is opened
mode=rowithout the writer lock and walked in keyset pages of 5,000 requests, each in its own short read transaction (SQLite's identity, integrity and foreign-key checks run first). Digest and shape verification of a page runs after its transaction ends, so a large ledger cannot starve a writer's commit, and it applies the same rules asstore.verify(one sharedstore.check_request). Memory is a page plus counters, not the ledger: the report is reduced to counts per distinct request signature (stage layout, statuses, last attempt code) and only the newest--limititems per list are expanded. Each page is consistent; the pass as a whole is not one global snapshot, so a request staged mid-pass is counted or not, never torn. The page still reportsledger_unavailableif a writer holds the database past its read timeout. The catalog uses its validated read path without writing a receipt: a read-validation receipt that covers this exact file (0017) or this process's own full inspection of the identical binding today vouches for it, otherwise the whole history is inspected. Review events are validated in full on a miss of the in-process memo (design), so a render after any review-event commit, restart or new UTC day replays them; the index check reuses an unchanged freshness proof and reports freshness, stale reasons, indexed documents/sections and selected documents/renditions. - Nothing is re-verified while the ledger is unchanged. The finished summary is kept in
memory keyed by the ledger's file identity (device, inode, size, mtime, ctime, SQLite change
counter, as in 0014/0017),
--limit,--runset and UTC date, and is stored only when the identity is the same before the first and after the last page. Any commit, rewritten row or new UTC day misses and verifies in full, so a tampered ledger is reportedunavailableon the next render; the same residual as 0017 applies (an edit that restores size, times and counter is seen at the next UTC-day check). Digests of requests and artifacts already proven are kept (32-byte keys, never raw bytes, never failures) and a hit still hashes the bytes in hand and compares the stored digest. Nothing is written to disk. - The report says whether the run is moving:
ratescounts attempts finished in the last 1, 5 and 15 minutes by outcome,attention_groupscounts blocked, dead-letter and retryable requests by state and error code, and the attention list is filled round-robin across those groups so one repeated code cannot use the whole limit.render.ledger_secondsandrender.ledger_cachedshow what the last read cost. progress-serveruns at most one render at a time: requests that arrive while one is running share its result, and a result younger than one second is served again, so any number of open tabs cost one render per second at most. Measure withpython3 tools/diagnostics/progress_benchmark.py(synthetic fixtures only).- The headline is per document: each
upload-receipt chain head is one document in exactly one state, so thedocumentsfunnel sums to the document count. The receipt decides until the document isreceived; then its extraction and registration (extractingwhile either is missing or staged, else their block orextracted), then the standing review of its current rendition under the newest policy (pending-review,qualified,selected,rejected,deferred,exception...).selectedis the furthest document state: publication requests do not name their documents, so publication is shown bypublicationsand the index panel. With the deriveddocstable its extraction and registration heads (by exact ID, however a correction is named) and current rendition are used andmismatch/ambiguousrows keep that state; without it the source isrequests(the newest request by first attempt) and rendition changes are not detected. Document attention groups (group:) count documents by state, funnel and code. Publication requests are not documents and are reported underpublications. - Superseded requests are verified but not counted, and reported in
superseded_by:correction(named by another request'scorrection_of),policy(a standing review of a rendition that also has a review under a policy first attempted later),rendition(a standing review of a rendition that is no longer the document's current one) andsubmission(requests of a corrected receipt). - Each remaining request still maps to one funnel state from its ordered stage statuses and
last attempt (the request-level
overallline andrequest group:lines):staged,received(receipt committed),extracting,extracted,pending-review,reviewed,qualified,selected,published, or the exceptionsrejected,deferred,exception(blockedstanding-<outcome>-*codes),skipped-by-format(unsupported-type,type-mismatch,unsupported-format,skipped-by-format),needs-reader(needs-reader*),blockedanddead-letter. Per kind, stage counts by ledger status are also shown. - Recent and needs-attention items carry correlation ID, current stage,
operation, status, funnel state and last attempt outcome/category/code and
times only; request arguments, intents, evidence and document text are never
read into the report.
--run NAME=PREFIXgroups correlation IDs by prefix. progress-serveserves/(HTML that re-renders only when reloaded, no external assets, and one inline script that shows times in local time) and/progress.json, GET/HEAD only, withCache-Control: no-storeand adefault-src 'none'CSP that allows only that script by its SHA-256 hash. It binds127.0.0.1by default, rejects non-loopbackHostheaders, and refuses any non-loopback--hostwithnon_loopback_bindunless--allow-non-loopbackrecords explicit approval.
No acquisition, connector, scheduler, unauthorized review/selection, migration, model service or return transport is supplied by this interface.
python -m tools.intake.cohort classify --root ROOT --inbox DIR [--report FILE]
gives every file below a read-only inbox exactly one disposition and prints
body-free counts: admit (with format text, gemini-txt, mhtml, odt, or a converter
format docx, xlsx, pptx, vsdx, rtf or office-legacy; a .txt
that parses as a Gemini transcript is gemini-txt; a text-suffix file whose
content starts with MIME headers, such as a Confluence "Exported From Confluence"
.doc, is mhtml; strict UTF-8 text under any other suffix or none, such as .sql, .xml
or .198, is text and is kept as <name>.txt; Office packages and RTF are recognised by
content and converted, see Converted documents), needs-runtime (PDF and
images while the instance has no provisioned Docling runtime, code
docling-not-provisioned; once provisioned they are admit with format pdf or
image, and an image whose header declares more than 32,000,000 pixels is
over-limit with code pixel-limit), needs-reader (no existing
reader, or content that cannot be read strictly; the
report carries a code such as needs-converter-runtime (legacy .doc/.xls/.ppt/.vsd
without LibreOffice), encrypted-document, unsupported-container, container-invalid,
suffix-mismatch, not-utf8-text, binary-content, control-characters,
unsupported-encoding, mime-malformed, mime-no-html, mime-encoding,
mime-charset or mime-empty, and raw encoded text is never admitted instead), archive-expanded (a zip or tar
archive whose sibling _extracted/<name>/ is classified instead, or whose members were expanded
into instance storage; see Archives), skipped-asset (web site assets),
skipped-artifact (alternate-data-stream sidecars such as :Zone.Identifier),
unreadable (fails strict UTF-8 or signature checks), empty, over-limit and
unsafe-path (symlinks and non-regular files). Suffix is never format proof.
mhtml extraction (tools/extraction/mhtml.py, stdlib email + html.parser)
recognises MIME by content, reads only non-attachment text/html parts with
strict transfer-encoding and charset decoding, converts them to plain-text lines
and never follows links, scripts or images. The payload records
method {name: "mhtml-html-text", version} and the parts read; the extractor
identity covers the reader code, and a stored rendition must equal a fresh
conversion of the original bytes. A file earlier ingested as plain text gets a
new mhtml submission that is recorded as a correction of the old one
(correction_of), so it is extracted again rather than kept. Bump
mhtml.METHOD_VERSION when conversion output changes.
ingest ... --system LABEL --actor A [--limit N] [--batch-size N] [--parse-workers N] [--extract-concurrency N] submits each admitted file as
a local-path upload (stable inbox-<hash> submission ID, ASCII-safe name,
percent-encoded inbox-relative locator, pinned SHA-256) and runs
extract-prepare then extract-register through the ledger. When an inbox
file's bytes change after intake, a content-salted submission ID is derived and
submitted as a correction of the prior submission (correction_of). Outcomes are
counted as received, extracted, failed, changed-since-intake and
not-processed; reruns are idempotent. retried_after_conflict counts entries
(and attempts) that lost a writer race and were retried, separately from
failures; failed_by_code groups failures by stage/code, and each failed
entry carries body-free stage, status, category, code and attempts. The inbox is never written.
Extraction and registration are read through the head of their correction_of chain, resolved by
the store (store.Heads), never by request name: a registration repaired by a correction is
extracted with the head's rendition and hash, a blocked, dead-lettered or still staged head is
settled and reported as itself, and an entry with no correction produces the report and ledger
effects it always did. A head must be a single stage with the entry's operation, receipt and
format, else the entry fails as correction_mismatch (ambiguous_correction for a chain with
two children); neither aborts the run. The
optional --report (0600) lists per-file paths, hashes and outcomes and is
private instance data. Extraction never reviews, selects or qualifies. PDFs and images are converted
before each chunk's ledger stages, --extract-concurrency (default 2) child processes at a time. A
PDF is read page by page (text layer or OCR of that page), each OCR page retried once and otherwise
kept as a placeholder with its code; an image is one bounded child. A refused file is a blocked
extract-prepare with an extract-<code> code and is not converted again on rerun (limits, codes
and the pdf-pages/ocr rendition marker:
tools/extraction/README.md).
qualify ... --system LABEL --actor A --policy PATH --manifest PATH --models-config FILE --model M --context LOCATOR [--context LOCATOR ...] [--index DB] [--concurrency N] runs ingest (so there is no need to run ingest first, and doing
so only pays the replay twice), ensures the private standing policy and
selection manifest exist (--context names maintained documents under the
policy's markdown_roots and is required; nothing is written without it), and
runs model_review.review then stages standing-review + standing-select
(standing-<submission-id>-<rendition-hash>-<policy-hash>) for each extracted rendition that
has no saved review. A changed rendition gets a new review; an unchanged one
reuses its ledger stages with no model call. The
cohort's manifest entries are first pruned to its current renditions, then reconciled
to exactly the qualified ones, adding any that are missing. The cohort is the --system label: an
entry is the cohort's when its rendition was extracted by this run or its receipt's pinned
local-path submission sidecar names that system. Every other entry (another cohort's, an
operator's, or one whose submission cannot be proven) is left byte-identical and in place, so
several inboxes can share one catalog, manifest and index (design).
Only an orphan (receipt missing from the catalog, or retained rendition file gone) is dropped. The
read-modify-write of the manifest holds the ledger writer lock, so cohorts qualified in parallel
processes keep each other's writes, and replacement is atomic (a new selection is appended in place
in constant time; if a run is killed mid-append, the next qualify, publish or select finishes it
from .<manifest>.append-intent and removes that file). The manifest holds at most 50,000
selections across all cohorts (a 36,000-document cohort needs about 13,000 at a 37% acceptance rate). When the manifest has no room for an in-scope rendition that has no
saved review, qualify makes no model call for it: it stays pending-review (selection-capacity)
with nothing saved, and a later run with room reviews it once. A rendition whose review is saved is
selected without a call once room appears. counts.selection_capacity (entries,
model_calls_skipped) reports what was held back and the calls avoided; free room is read just
before each call, and standing-select remains the check at write time. With --concurrency,
reviews run ahead only while there is room for every entry in flight, so near the cap the run
proceeds more serially. To qualify a cohort larger than the free room, free space (retire entries
of other cohorts) or expect the rest to wait; they cost nothing until room appears. counts.other_cohorts (selections, unattributed, orphaned) is
present when other entries exist. Policy, manifest and context paths are validated (instance-relative, no
symlinks, existing maintained sections) before anything is ingested or written;
manifest and policy files are replaced atomically. qualify always processes the whole inbox
(--limit exists only on ingest). Changing an active policy's content does not
requalify old evidence: renditions already reviewed under another policy stay
pending-review until an explicit policy-change review correction is made. standing-publish builds the context index;
a saved publication is reused only while the index is present and fresh,
otherwise a new revision is staged. A review an operator later superseded is reported pending-review (review-superseded) and its saved selection is not restored; the operator's corrected selection is kept.
Bumping the standing policy version re-reviews every rendition; a new-version review that qualifies supersedes the same policy's earlier-version standing review of that rendition (same source and scope) and replaces its manifest selection, (recorded at least a second after it); operator corrections, reviews from any other policy and independent reviews still block as conflicting-review.
A standing review blocked as changed-standing-inputs (its saved intent no longer matches current inputs, e.g. after a replay) is restaged as a correction request <correlation>-c<n> with the same review arguments and event and fresh request IDs; later runs follow the correction_of chain to its newest request.
The policy (permissions, reviewer match), manifest and index destination are preflighted before ingest. Incomplete or failing reviews remain visibly
pending-review, rejected, deferred or exception without indexing.
publish --root R --policy PATH --manifest PATH [--index DB] runs only the standing-publish
stage of qualify (same correlation scheme publish-<policy>-<manifest-hash>-<destination>,
guards, checks, availability and ledger evidence) for the manifest as it is now, with no ingest,
no review and no model call. qualify publishes once, after reconciling the manifest, so a run
that stops early leaves its saved reviews and selections unpublished and the index stale (the
index pins the manifest bytes and the review-event store state, so it stays stale from the first
review a run appends until the next publish); publish recovers that at the cost of one
publication instead of a re-run's whole ingest and entry walk. It is idempotent: a saved success
is reused while the index is present and fresh, otherwise a new revision is staged. Output is
body-free counts (published, selections) and publication (status, available, and the
blocking code when refused); exit status 0 only when published. Publication re-validates every selection, so its cost is linear in selections: about 2.6 ms per selection on a shared development host (a first publish of 20,000 selections about 53 s and about 1.4 GB of memory, an unchanged re-publish about 8 s; at the current 50,000 cap a first publish of 50,000 about 220 s and about 3.6 GB, an unchanged re-publish about 32 s; tools/diagnostics/publish_benchmark.py measures it on synthetic selections). Raising the cap makes every existing index stale once, because the engine fingerprint changed; the next publish rebuilds it. A run's entries not yet
reviewed are not selected, so what is served is exactly the selections made so far. Qualification
is not published during a run on purpose: while reviews are still being appended an interim index
is stale again at the next review, so it could not serve progress.
Restoring cohorts an earlier toolkit pruned. Before the cohort-scoped reconciliation change (Kata xc2j), qualify for one cohort
removed every other cohort's selections from a shared manifest. The reviews are still in the
ledger and review store, so re-run qualify once per cohort with its own --system, --inbox
and the same policy, manifest and index; saved reviews are reused (0 model calls, 0 tokens) and
each cohort's selections return, while the others stay. After a standing-policy version bump,
requalify every cohort before expecting a publication: a selection citing an older version's
review is refused until its cohort is requalified.
Standing scope. The policy's scope.receipts and scope.audiences decide which renditions
qualify may review. A rendition outside the scope costs no model call: qualify reads its
receipt_id and audience from the pinned rendition (the check the adapter makes) before
scheduling a call, stages the request, and the standing-review adapter ends it as the blocked
exception prohibited-scope by its own unchanged scope rule. counts.out_of_scope reports
entries refused and model_calls_skipped. With no policy file, qualify generates
scope.receipts: ["D*"] (any upload receipt D<number>, audience source), so it covers the
cohort without a list of IDs; a policy that exists is never rewritten. A hand-written policy lists
receipt IDs (at most 50,000) or may include "D*".
Operator note: widening an existing instance's scope. Edit the scope and raise version
in the private policy file, then re-run qualify once per cohort with the same --system,
--inbox, policy, manifest and index. Because the policy hash is part of every standing request, the
re-run reviews every in-scope entry again under the new version: one model call (and its tokens)
per entry, including entries already qualified under the old version, and the first review of
entries previously refused. Entries still refused cost nothing. A later re-run with the policy
unchanged costs 0 calls. Do not edit the scope without raising version: the new-hash reviews
then block as conflicting-review. Requalify every cohort afterwards, since publication refuses a
selection citing an older version. Estimate the cost first from counts.out_of_scope.entries
plus the already-qualified count times the sample's tokens per document.
--concurrency N (default 6) is the most model calls ever in flight, each for a
rendition with no saved standing-<...> request; staging, runs, selection,
manifest writes and usage accounting stay on one thread in inbox order, so
results match --concurrency 1, which is fully serial.
The run is adaptive (AIMD, tools/intake/throttle.py): it starts at
--initial-concurrency (default N), halves the calls in flight (minimum 1) when the
provider answers 429 or 503 (including a call the transport then retries), and adds one back
per window of clean replies (a window is as many clean replies as the current limit), never
above N. A burst of simultaneous 429s from one overload costs one halving. Other errors (500,
network, 4xx) do not change it. --no-adaptive holds N fixed. Every HTTP attempt of the run, including each retry after a
backoff wait (no slot is held while waiting), takes a slot under the current limit, so N bounds the
provider load whatever the retry behavior; the limiter decides only how
many calls overlap, never what is reviewed, so counts, entries, findings, events, selections,
ledger and token usage match a serial run. Stdout and the report carry throughput:
cap, initial (always N for --no-adaptive), final, lowest, backoffs, throttle_signals, max_in_flight, calls,
seconds, mean_in_flight and calls_per_minute (calls counts HTTP attempts, retries included; the effective rate of this run's model traffic;
it varies with timing and is kept out of counts). A restarted run reuses every saved review
without a call. Start below N with --initial-concurrency 1 against a provider whose limits are
unknown and watch lowest and retries; set N to what the operator will allow.
--inspected-form ranges asks the reviewer to write inspected_records as inclusive
"first-last" strings and lone integers ([0, "2-86", 90]) instead of every index, which cuts
completion tokens roughly in proportion to record count. A reply in either form is accepted
and is expanded to the same explicit, sorted list before it is pinned, so findings, the standing
check and standing.evaluate see no difference: a gap in the ranges is an uninspected record and
the review stays incomplete, and overlaps, backwards or out-of-range items, or a range longer than
the rendition's record count make the reply invalid. The inspection list is self-attested in both
forms, so a range carries no less assurance than a list. The default stays list until the owner has
run python -m tools.diagnostics.inspection_form_ab (below) and chosen otherwise.
Owner-run A/B of the inspected-records forms (calls the real model; run it deliberately on about 20 representative renditions, a mix of short, median and long, including some the policy rejects or defers):
python -m tools.diagnostics.inspection_form_ab --root ROOT --models-config FILE \
--model MODEL --rendition-list renditions.txt [--repeat 2] [--order alternate]
It asks each rendition both ways and prints body-free counts only: per form tokens, seconds,
complete inspections, failed replies and decisions, and across forms decision_agreement,
identical_inspection, completion_tokens_saved(_pct) and seconds_saved. It records
nothing in the instance. Keep the report privately; it is a measurement before choosing a default,
not a gate. Use --repeat 2 to see how much of any disagreement is ordinary model variance.
Stdout prints body-free counts, token usage and retries: per-code counts
(http-429, http-503, network, ...) of transport retries during the run.
Archives (.zip, .tar, .tar.gz/.tgz, .tar.bz2, .tar.xz) are never expanded
during classify, ingest or qualify. A 0-byte archive is empty. An archive with a
sibling _extracted/<stem>/ folder is archive-expanded and that folder's files are
classified as before. Any other archive is needs-reader (archive-not-expanded) until an
operator expands it:
python -m tools.intake.cohort expand-archives --root ROOT --inbox DIR [--apply] [--report FILE]
Without --apply this is a dry run. It reads every member with the stdlib zipfile/tarfile
readers, hashes it and prints body-free counts, and it writes nothing. With --apply, each
archive is expanded into <intake home>/archives/<archive sha256>/members/, never into the inbox.
A manifest.json (librarian-archive-manifest/1) is published atomically with the expansion.
It lists the archive's relative path, size and sha256, and each member's name, normalized path,
size, sha256, disposition and code. A sibling folder is not copied. Instead, each member is
compared by sha256 with the sibling file: pre-expanded if equal, otherwise refused as
pre-expanded-missing or pre-expanded-differs.
Members are checked before any byte is written:
- Refused names: absolute paths,
.., drive letters or any:, backslashes, control characters, components longer than 255 bytes or ending in!. These are refused asunsafe-name. - Name normalization: names are NFC-normalized and must stay unique. Clashes are refused as
duplicate-name,case-collisionorpath-conflict. - Skipped members: symlinks, hardlinks, devices and fifos are
skipped(link,special). - Unreadable members: encrypted members (
encrypted), unknown compression and bad CRCs are refused (unsupported-compression,corrupt-member). - Archive-level limits: an archive over 100,000 members, 16 GiB expanded, or a 200:1
expansion ratio (counted once 64 MiB is expanded; for compressed tars every decompressed byte
counts, including skipped or refused payloads) is refused as a whole (
too-many-members,expanded-size-cap,ratio-cap). An unreadable archive is refused asarchive-unreadable. The refused manifest is kept and no members are stored.classifyreports the archive asneeds-readerwith codearchive-<code>. To retry, remove that<sha256>/directory.
A nested archive is stored as a member. The next expand-archives --apply run expands it, one
level per run.
Once an archives store exists, classify hashes each inbox archive that has no sibling folder to
find its manifest. Each member then gets its own disposition under the name
<archive>!/<member>. Members refused at expansion are unreadable or unsafe-path. A stored
member whose bytes no longer match the manifest is unsafe-path (archive-member-changed).
ingest reads admitted members from instance storage, and their upload locator (! encoded as
%21) traces catalog receipts and search results back to the archive.
python -m tools.intake.cohort delete-archive-original --root ROOT --inbox DIR \
--archive RELATIVE [--actor A --apply] [--report FILE]
This is the only command that writes the inbox, and only with --apply. A dry run reports
verified or blocked with blockers (member, code, current disposition). It is blocked when
any of these hold:
- The archive's bytes no longer match an
expandedorpre-expandedmanifest. - A member was refused, or its stored or sibling bytes changed.
- A nested archive has no verified expansion of its own.
- A member that is not
empty,skipped-assetorskipped-artifact(for example stillneeds-readerorneeds-runtime) has no catalog original whose sha256 equals the member's.
There is no override. --apply (with --actor) re-checks all of this and appends a record (path,
size, sha256, manifest sha256, actor, time) to archives/deletions.jsonl. It fsyncs that record,
then unlinks the archive and fsyncs the directory. A rerun reports already-deleted. Exit status
is 0 for verified, deleted and already-deleted, and 1 when blocked.
classify, ingest and qualify accept --agent-origin FILE: a private origin file
(version 1, at most 64 KiB; template config/agent-origin.example.json, keep the instance copy in
an ignored config/*.local.json) declaring that the inbox, or the part of it the file selects,
was written by an AI agent. Fields: version (1), generator (printable ASCII, at most 200
characters, e.g. the_librarian (previous version)), optional source_repository (a label such as
falcon-docs), provenance (git or none, default none), optional include (inbox-relative
paths walked instead of the whole inbox; a missing one refuses the run as
agent_origin_include_missing, a symlinked one or one below a symlink is unsafe-path) and
exclude (paths below which files are reported excluded, unread). A malformed file is
invalid_agent_origin. Files outside include are not part of the cohort and are not listed.
Each admitted file is submitted with a version-2 descriptor whose origin.agent_generated is
{generator, generated_on, source_commit, source_repository?}. With git provenance the inbox must
be the top level of a git work tree (agent_origin_not_repository_root, and
agent_origin_git_unavailable when git fails); git runs read-only (no optional locks, fsmonitor,
signatures or pager). A tracked, unmodified file is declared with the last commit that touched it
and its author date (committed); a modified, untracked or ignored file has neither
(uncommitted), since its bytes are in no commit. A member of an expanded archive is declared like the archive file it came from, and an exclude may name a member (ARCHIVE!/MEMBER) or a nested archive. A run with --agent-origin does not take the --trust-stat fast path, so every file's declaration is checked against its submission. Reports count them in
counts.agent_origin.declared (committed, uncommitted, none) with the work tree's head;
classify also counts admitted formats and admitted_bytes, so it is the dry run.
The declaration never admits or withholds anything: the cohort is reviewed, selected and published
by the same standing review as any other (the review checks that the rendition is complete and
faithful to the file, not that the file is true), and whatever qualifies is indexed low confidence
with reason agent-generated whose detail names the generator, date and
REPO@COMMIT:PATH. Search hits carry it as origin: "agent-generated (...)"; get pieces carry it
in their confidence label; --low-confidence last|exclude ranks them last or leaves them out.
Reviewer deferrals of agent-written context can qualify as low confidence with --deferred qualify-low-confidence like any other.
The declaration is part of the submission record, so give the cohort its own --system label and
keep the origin file and the tree's commits as they were: re-running with a different declaration
for unchanged bytes (another generator, or a file committed after it was ingested uncommitted) is
refused visibly as receipt/submission_conflict, never silently relabelled; as for any failed
entry, the next qualify of that cohort then drops those files' earlier selections. Decide
whether to commit the source tree before the first ingest. Changed bytes are a
correction as for any inbox file.
tools/intake/model_review.py turns one model's review of one exact extraction
rendition into a private standing-findings-v2 record under
<intake_home>/findings/, exactly as the model reported it: partial inspection
is never filled in, and replies that do not parse, name an unknown record or
warning, or exceed the prompt or record budget write no findings. The standing
policy's reviewer must be usai:<model>. Prompts mark document text as
untrusted. The reply lists internal contradictions, missing_evidence the
rendition itself needs (truncated sections, absent tables or figures), and
advisory unverifiable_references to cited outside material; replies without
the advisory list still parse. The transport is restricted to models configured
for the usai provider in a Pi models.json and sends only to that provider's
baseUrl (redirects are refused). HTTP 429, 500, 502, 503, 504 and network or
timeout errors are retried up to 5 calls in total, waiting a numeric
Retry-After or exponential backoff with jitter (2 s, 4 s, ...), each wait
capped at 60 s and all waits within 600 s; other HTTP errors and invalid replies
fail at once and the rendition stays pending-review.
python -m tools.intake.model_review evaluate --root ROOT --models-config FILE --model M ... --rendition PATH ... [--controls] scores candidate models on a
sample (complete inspections, failed replies, decisions, token usage, time, and
whether a synthetic garbled/injection control was rejected) and prints a
body-free report with the selected model and rule. estimate() extrapolates
sample token usage to the admitted count and bytes. Record the chosen model,
rationale and estimate privately before any bulk review (and a budget ceiling, if
the owner sets one), and actual usage after it.
Per-document state (docs). The ledger keeps a derived row per cohort document, written in the
same transaction as the stage updates that change it. Requests stay authoritative; the table can be
dropped and rebuilt. For an existing ledger:
python -m tools.intake.cohort backfill-docs --root ROOT # dry run: rows that would be added
python -m tools.intake.cohort backfill-docs --root ROOT --apply # create the table, add missing rows
python -m tools.intake.cohort audit-docs --root ROOT # recompute from requests; report differences
python -m tools.intake.cohort docs-status --root ROOT # documents per state, one indexed query
audit-docs reports body-free missing, extra and differing row counts (and each path under
differences) and never writes; a nonzero count means rebuild (drop docs, backfill-docs --apply)
or investigate. ingest and qualify never create the table by themselves. By default every
replay still reads and hashes every file. ingest --trust-stat skips the read and hash of an
extracted file whose stat identity equals its row (the first replay after a backfill fills the
identities), so use it only where no tool resets ctime; any other change is caught either way.
Recovering a registration blocked as changed-extraction-identity. The extractor's identity
is a hash of its code (tools/extraction/extract.py, plus mhtml.py for MIME HTML, and the
instance policy) and is pinned in the stage's saved intent when the stage first prepares. A
toolkit upgrade that edits those files, between a stage's first attempt and its replay, makes
prepare != intent: the stage blocks as changed-extraction-identity, and replay and
recover-conflicts cannot clear it because replay keeps the saved pin (an example is a
registration that lost a writer race recorded as native-input before concurrent writers were retried, replayed by
recover-conflicts after the upgrade). Do not edit the ledger or stage corrections by hand. Run
python -m tools.intake.cohort recover-identity --root ROOT # dry run
python -m tools.intake.cohort recover-identity --root ROOT --apply
The dry run prints body-free counts: candidates (chains whose head is a blocked extract-register
whose last attempt was changed-extraction-identity) and skipped: prepare-mismatch (the paired
extract- request is missing or does not match the receipt and format), prepare-blocked, or
source-unavailable (the source no longer prepares, for example a changed or removed original).
--apply stages a correction request <root>-c<n> of the paired extract-prepare (when its head
prepared under a different extractor) and of the registration (with a fresh catalog pin), and settles
both. A correction goes through the store's validation like any request, so the identity check, the
source-hash check, catalog pinning and rebase apply to it unchanged, and a source or extractor that
moves again blocks it again. The next ingest or qualify follows the chain to the corrected
registration and reports the entry extracted with no new extraction work; it is then reviewed and
selected like any other rendition. Repaired chains are not candidates again. Run it while no ingest is
writing, as with recover-conflicts.
Recovering extractions blocked by a since-fixed toolkit. A PDF/image (or other) extraction that
a toolkit defect blocked, for example extract-mutation when the conversion child's file-size limit
refused the private model-asset copy, keeps its pinned extractor identity, so after the fix a replay
can only block again. Run
python -m tools.intake.cohort recover-blocked-extractions --root ROOT --code CODE # dry run
python -m tools.intake.cohort recover-blocked-extractions --root ROOT --code CODE --apply
The dry run counts candidates: chain heads that are a blocked extract-prepare whose last attempt
failed with CODE. --apply stages a correction <root>-c<n> repeating each one's operation and
arguments and runs nothing (a multi-stage request is counted in skipped); the next ingest (or qualify) follows correction_of to it, converts it
with the other open extractions (--extract-concurrency), registers it, and it is then reviewed and
selected like any other rendition. A source or toolkit that still fails blocks the correction again.
Repaired chains are not candidates again. Run it while no ingest is writing.
Recovering reviews blocked as unresolved-evidence. Before accepted reviews with reported
contradictions or missing evidence qualified, they ended standing-pending-review-unresolved-evidence.
Run
python -m tools.intake.cohort recover-unresolved-evidence --root ROOT # dry run
python -m tools.intake.cohort recover-unresolved-evidence --root ROOT --apply
python -m tools.intake.cohort publish --root ROOT --policy POLICY --manifest MANIFEST
The dry run counts candidates (chain heads blocked that way whose saved, hash-verified findings
now evaluate as qualified) and skipped.not-qualified (blocked that way but still failing another
gate, for example a conflicting review). --apply makes no model call: it stages a correction
<id>-c<n> of each candidate with the same arguments, records the review and selects the rendition
under the shared manifest's capacity (results.selection-capacity leaves the select staged for a
later qualify). Qualified, rejected, deferred, exception and other pending reviews are not touched,
and a rerun finds nothing further. publish then makes the selections retrievable. Run it while no
qualify is writing.
Model calls made by qualify and model_review evaluate are recorded body-free (model and token
counts only, never prompts, documents or replies) as one session file per run in
$AGENTSVIEW_DIRECT_API_DIR, default ~/.agentsview/direct-api, for AgentsView's Direct API agent.
A failure to write them never affects the run; it prints one stderr line naming only the exception type.