Repository navigation
knowledge.inspect reports each source's ingestion jobs and what its extraction kept - #254
Merged
Merged
Conversation
…xtraction kept Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/i160-doc-ingest-state
branch
from
November 4, 2026 06:52
91d667a to
3b0eb17
Compare
…ite in the job's last second resource_limit is the extractor passing its own memory or output limit, or its artifact over LOOM_DOCUMENT_EXTRACTOR_MAX_ARTIFACT_BYTES; the remedy names the limit to raise for each. A SQL case stores a document row at second S beside a job that failed at S.400 and checks the job is not replaced. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
8 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #160
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
knowledge.inspectnow reports a namespace'sknowledge.ingestjobs and what each extraction kept: jobs by state, sources with a job and no live document (a first ingest, or one after a delete, queued or failed), each listed document's coverage and jobs (with the open job'singestion_idforknowledge.ingest_status), and findings that tell a backlog, an unavailable extractor, missing access, a rejected file, a job that failed on the server's side and an extraction that lost structure apart.Why
knowledge.inspectsaid which documents search serves, but not why a document is missing or stale. A source can wait in the ingest queue, fail because no extractor takes its format or the extractor is down, fail on access (its original is gone, or the extractor refuses the server's token), fail on the file itself, or publish with part of its structure lost. Each has a different fix, and only the first one fixes itself. A caller also had no way to find a source's open job unless it had started the ingest itself, becauseknowledge.ingest_statustakes a job id and nothing listed one.Scope and risk
knowledge.inspectgains four reads:extraction_healthover the live documents'coverage,ingestion_health,source_jobsfor the listed documents, andsources_without_document. Each of the three job reads is a per-sourceGROUP BYoverloom.knowledge_ingestions FINAL, joined to the namespace's document rows (only the listed ones forsource_jobs). The job reads also check the namespace'sloom.knowledge_ingest_cancelsrows, so a pending job with a cancel requested readscancelledin the counts, the backlog,open_ingestion_idand the job's state. That is the stateknowledge.ingest_statusanswers, though the row stays pending until a worker takes it. The job's other fields,updated_atamong them, are its row's, asknowledge.ingest_statusserves them. Each one filters on(org, namespace), the sort-key prefix, binds every value as a parameter, caps its samples at 100 and its lost-capability list at the cap + 1, and is guarded intoskippedlike the report's other sections. It usesFINALonly on the two ReplacingMergeTree tables.failedunits are counted, never named, because a failed unit can be one of the source's own TOML keys.extractor_unavailable, not as backlog. A retried job that a worker is running again staysprocessingand keeps the last attempt'sretryingcode and message until the run ends, so it counts as backlog, whatever stopped the last attempt. A job that published withallow_partialcounts asextraction_incomplete, not as rejected content.knowledge.add,knowledge.upsert, a source sync) and deletes write no job row, so a failed job could otherwise keep a source in a finding for the 30 days its row is kept, after a text write fixed it or a delete removed it. A metadata edit withoutreindexkeeps the row'singested_at, so it replaces nothing and the failure still counts. A reindex rewrites the document, so it counts as a write. A source counts asreplacedwhen none of its jobs is open and its document row was written (ingested_at) or deleted (superseded_at) after its newest job ended. Both columns count whole seconds, so a write stored in the second the job ended is not told apart from one before it and does not replace the job. Replaced sources are counted iningestions.replacedand flagged onlisted[].jobs.replaced. They are left out of every finding and ofwithout_document.retryingmeans an open job only.invalid_artifact(the extractor answered an artifact that breaks the contract) isextractor_unavailable, not bad content: the fix is a working extractor, not a different file. A failed job whose outage used upknowledge_ingest_max_attempts(a store or embedder outage, or runs cut off before they finished) isretries_exhausted. Together withinternal, it makes up theingest_failed_on_serverfinding.resource_limitstays in bad content. It has two sources: the extractor passed its own memory or output limit, or its artifact was overLOOM_DOCUMENT_EXTRACTOR_MAX_ARTIFACT_BYTES. The finding's remedy names the limit to raise for each: the extractor'sLOOM_EXTRACTOR_MEMORY_MB/LOOM_EXTRACTOR_MAX_ARTIFACT_BYTES, the server'sLOOM_DOCUMENT_EXTRACTOR_MAX_ARTIFACT_BYTES, orLOOM_KNOWLEDGE_INGEST_MAX_CHUNKS. Arevision_conflict(a later write landed first, orexpected_revisiondid not hold) has no finding by design: it counts iningestions.failed, and the revision that landed is what search serves. The docs say so.ingest_backlog,extractor_unavailable,ingest_missing_accessandingest_failed_on_serveraresystem_state.ingest_content_rejectediscontract_violation, because the extractor refused the file against its format.extraction_incompleteisusage_heuristic, because another extractor may keep what this one lost.knowledge.ingest_statusalready serves any job of the namespace to its viewers by id, and a job'suser_idrecords authorship (theknowledge.group's reason in the read-scope classification). The op stays VIEWER, read-only and inSCOPED_OPS, with its comment updated.worker_enabledandextractor_configuredcome from this server's settings. Another replica may be configured differently, so the job rows remain the evidence. Nothing calls an extractor. ParsingLOOM_DOCUMENT_EXTRACTORS_JSONraises on a value that is not a JSON object of strings, soextractor_configuredis read as its own guarded section: on a malformed value it is null and named inskipped, and the rest of the report is still read.server/knowledge/app/extractors.pyraises. A unit test reads that module and checks that everyExtractorUnavailable/FormatUnavailablemessage matches the classifier's prefix, so a reworded message fails the test.Compatibility, rollout and rollback
knowledge.inspectoutput gainsingestions,extractionandingest_findings.listed[]gainsextractionandjobs. Nothing is removed or renamed. The op is still experimental.Tests
Unit tests on fakes (
tests/unit/test_knowledge_inspect.py) cover job totals with the server's settings, each ingest finding with its kind, samples, aligned job ids and remedy, cleaninfofindings, lost-capability totals and their cap, a listed document's extraction and jobs (current vs. latest, stalled, ended, next attempt), a skip path for each of the four new reads, and the classifier against the extractor client's messages.clickhouse-local SQL tests (
tests/unit/test_knowledge_inspect_ingest_sql.py) run each new statement on the real table definitions. One source sits in each state: queued, published with a stalled run and a later job queued behind it, format unavailable, extractor unreachable and retrying, token refused, original gone, encoding refused, revision conflict, store outage retried, and cancelled. They also cover an outage that used up its attempts (retries_exhausted, "earlier runs stopped before they finished"), aninternalfailure, a retried job running again withretryingand the extractor's message, a pending job with a cancel row, another namespace's cancel of the same id, a failed job followed by a newer document row and one followed by a delete (both replaced, in no finding), a failed job that ended after its document was written (not replaced), a failed job followed by a metadata edit (not replaced, still in its finding), a failed file ingest over a text document followed by a reindex (replaced), a job that failed at S.400 with its document row stored at second S (not replaced; the case fails if the comparison is made non-strict), aninvalid_artifactfailure (extractor_unavailable), a job row written twice and folded byFINAL, another namespace's job, and a coverage withoutcomplete.Integration (
tests/integration/test_knowledge_inspect_ingest.py) uses knowledge.upload, knowledge.ingest and a worker pass in the test process, against the reference extractor (python -m loom_extractor):format_unavailable), another such PDF that aknowledge.addof text then replaced (in no finding, counted iningestions.replaced), and a SQL file with the extractor URL pointed at a closed port (pending,retrying);original_gone), and the extractor refusing a wrong token (retries_exhaustedafter one attempt);incomplete_extraction; the earlier revision stays live);allow_partial, withsql_structurelost.The test retries a call the per-namespace rate limit refuses. The second test skips when no extractor is configured (
LOOM_DOCUMENT_EXTRACTOR_URLunset). The first needs none. The first test cancels and drains the jobs it leaves open, so a later test's single worker pass does not pick them up.make format,make lintandmake typecheckpass and print success.Suites:
test_knowledge_inspect*.py,test_tunable_constants.py,test_namespace_audit.py,test_knowledge_ingest.py,test_package_contracts.py,test_op_reach_census.py,test_public_copy.py,test_doc_links.py,test_sdk_surface_contract.py,test_mcp_listing_budget.py,test_docs_reference.py,test_op_budgets.py,test_read_scope.pyand the SDK generation checks all pass (767 tests). A malformedLOOM_DOCUMENT_EXTRACTORS_JSONskips onlyextractor_configured; a unit test covers it.tests/analyzerpasses, andpython -m tests.analyzer.corpus --checkreports 0 rejected against a migrated ClickHouse.Cost: measured on a namespace of 2,000 documents with 8,000 chunks, 1,000 extraction coverages, 2,500 job rows across 1,300 sources and 100 cancel rows, read from
system.query_log. Each figure is the same over three runs.The whole call took 0.33–0.34 s wall time, inside the op's 4,000 ms budget, which stays as it is. Only its comment changes, to count the new reads. Job rows expire after 30 days, which bounds the job reads.
AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. The author checks the statements against clickhouse-local and a live ClickHouse, the failure-class mapping against
ingest_run.pyandextractors.py, and each state end to end with the reference extractor.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed. (Format, lint, typecheck and the affected suites pass; the full unit suite is still to run.)docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code