Skip to content

Under Postgres, knowledge.inspect says which document commits ClickHouse does not hold and lists only documents knowledge.get serves - #439

Merged
zlareb1 merged 12 commits into
mainfrom
feat/i160-doc-pg
Nov 9, 2026
Merged

zlareb1 merged 12 commits into
mainfrom
feat/i160-doc-pg

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Related: #160

Changelog category (leave one):

  • Improvement

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):

Under the Postgres storage authority, knowledge.inspect says in skipped how many document commits have not finished publishing to ClickHouse (owed and parked). It lists a document only while knowledge.get serves it at the listed version, so listed_complete is false whenever the document sections may be short.

Why

knowledge.inspect's document sections (totals by format and scheme, chunks, the listed documents) read ClickHouse's loom.documents. Under the Postgres authority, document heads are committed in Postgres first (loom.knowledge_heads). They reach ClickHouse through a delivery, which a writer publishes in its request or the knowledge_pg_delivery worker publishes later, or which parks after repeated refusals.

Until a commit is published, the report counted and listed ClickHouse's older row as current, and said nothing. A document rewritten or deleted in Postgres was still listed at its old version, and listed_complete could be true while committed documents were missing.

What changes

  • pg_documents.unpublished(org, namespace) gives the namespace's unsettled deliveries as (owed, parked). It is one indexed count over loom.knowledge_deliveries. A delivery whose row landed but whose older chunk versions are not retired yet counts too, so the line says the publication has not finished rather than that the row is missing.
  • Under Postgres, knowledge.inspect reads that count once, before the document sections:
    • Any owed or parked commit adds documents.projection: <n> document commit(s) whose publication to ClickHouse has not finished, <m> of them parked … to skipped.
    • A Postgres that does not answer adds documents.projection: POSTGRES_UNAVAILABLE: … (covering the memory sections too), and the report reads on from ClickHouse without trying Postgres again in the same call: neither the listing check nor the memory sections' wait (pg_validation.published_reads(..., down=True) waits no time and adds no second line).
  • Each listed ClickHouse row is checked with documents.get_many_by_uris, the read knowledge.get serves from. A row that is not live at the version ClickHouse listed (rewritten, deleted, or gone in the authority) leaves the listing, its chunks and jobs are not read, and skipped counts it (listed.heads: …; the dashboard reads a listed: … line as a failed listing). If that read fails, the rows are listed as ClickHouse holds them and listed.heads appears in skipped.
  • listed_complete is false when either of these applies.
  • On the ClickHouse authority nothing changes: no Postgres read is made.
  • Dashboard: when skipped names unpublished document commits or a dropped listed document, the Documents inspection says some documents may be missing, in place of "Newest N of M listed." (which reads as a sample-limit cut) and of "No live document to list.". A memory section's projection line does not trigger it.

This report does not wait for publication the way memory's diagnostic reports do (pg_validation.published_reads). The knowledge plane has no publication barrier, so the report states what it may be missing and does not add a wait.

Docs: docs/architecture/storage-authority.md ("Knowledge documents"), docs/features/knowledge.md, and the listed_complete field comment, whose regenerated reference is docs/reference/operations/knowledge.md.

Ingestion job state (the ingestions section) still reads ClickHouse. It moves when ingestion jobs move to Postgres.

Scope and risk

  • Read-only, apart from what get_many_by_uris already does on a knowledge.get. That read deletes a head that an older build purged from ClickHouse, and the module docstring says so.
  • Under Postgres the report makes two more Postgres reads: the count, and the heads of at most sample_limit listed sources.
  • No wire field added or removed. skipped can now carry documents.projection: … and listed.heads: … lines; the dashboard keys on those two names (DOCUMENTS_PROJECTION, LISTED_HEADS).

Tests

  • Unit (tests/unit/test_knowledge_inspect.py):
    • A published namespace reads as on ClickHouse.
    • Owed and parked commits are counted in skipped, and listed_complete is false.
    • With Postgres down, the report still answers and says why.
    • A listed document that was rewritten, deleted or is gone in the authority leaves the listing, and its chunks are not read.
  • Integration (tests/integration/test_knowledge_pg_heads.py, run by CI's Postgres jobs): a newer version is committed in Postgres with its delivery parked. The report counts the parked commit, drops the older ClickHouse row from the listing and is not complete, and knowledge.get serves the newer content.
    • Run locally on a ClickHouse and a Postgres primary with a synchronous standby, against a server with LOOM_STORAGE_AUTHORITY=postgres: the file's 27 tests passed. tests/integration/*inspect*.py gave 3 passed and 3 skipped; the skips need auth enforced or a reference extractor.
  • Unit (tests/unit/test_pg_authority.py): published_reads(down=True) waits no time, says nothing and nests.
  • Frontend: src/views/Assistant.test.tsx (92 passed: every document listed, one dropped, the only one dropped, a failed check, and a memory projection line that must not trigger the note), npm run build, npm run budget, Biome.
  • Gates: ruff format and check, mypy over server/knowledge, and the touched unit files plus tests/analyzer, doc links, public copy, docs reference and package contracts (349 passed).

🤖 Generated with Claude Code

@zlareb1
zlareb1 force-pushed the feat/i160-doc-pg branch 2 times, most recently from b9751ca to 7c14e8e Compare November 9, 2026 08:58
zlareb1 and others added 12 commits November 9, 2026 09:10
…use does not hold and lists only documents knowledge.get serves

knowledge.inspect's document sections read ClickHouse's loom.documents. Under
the Postgres authority it now reads the namespace's unpublished deliveries
once and names owed and parked commits in `skipped`, and keeps a listed row
only while knowledge.get serves it at the version ClickHouse listed. Either
makes `listed_complete` false; a Postgres that does not answer is said too.

Related: #160

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…oard does not read as a failed listing; the count says publication has not finished; one Postgres outage is not waited out twice

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…tgres it found down; the dashboard says documents may be missing whenever the server names a short listing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…asked again; the dashboard reads only the dropped-row count as a short listing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…storage-authority paragraph is wrapped

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… dashboard comment names every dropped row

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ys on, pinned by a test; the dashboard hedges an unchecked listing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…d reads its one row directly; listed_complete names the listing check

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…r produced

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…stated two constants is gone

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant