Skip to content

docs(export): document the RDF export contract - #836

Closed
ansonnmm wants to merge 4 commits into
deeplethe:devfrom
ansonnmm:upstream-pr-export-contract-docs
Closed

ansonnmm wants to merge 4 commits into
deeplethe:devfrom
ansonnmm:upstream-pr-export-contract-docs

Conversation

@ansonnmm

Copy link
Copy Markdown

PROBLEM

The documented RDF export contract describes entities, facts and documents — but not the serialized rule, version, chunk and evidence families, the reference-resolution guarantees, or the single-snapshot and fail-closed semantics the route now provides. It also says nothing about the ledger surfaces newer migrations added.

WHY THIS IS A GENERIC UTOPIA BUG OR CONTRACT GAP

The public contract documentation lagged the implementation: consumers cannot rely on guarantees that were never written down, and the documented subset understates what an export actually contains.

FIX

Document the whole emitted contract in web/src/docs/mcp.md: open statements and their qualifier/time-mention nodes, typed-fact fromStatement provenance, validity grades, evidence origin/offsets, chunk producer metadata, document reading context, vocabulary updatedAt, the single-snapshot read and fail-closed semantics, and the explicit non-claims.

REGRESSION EVIDENCE

Documentation only; the documented behavior is covered by the tests in the underlying PRs.

COMPATIBILITY RISK

None — docs only. The doc declares the export a compatibility boundary: new predicates are additive, while omission or renaming becomes contract-sensitive.


Stacked on #832#833#834 — this PR's diff includes those commits until they merge.

南慶麟 and others added 4 commits September 20, 2026 21:46
Install a schema-level invariant: every reference an export can resolve
must join rows that live in the same knowledge base. A column foreign
key proves the target exists, not that it is the same KB's — the
exporter would otherwise mint local IRIs naming foreign rows, or
silently drop vocabulary references that resolve to nothing.

Three layers: a precondition scan that refuses the migration on a
dirty ledger, row triggers on every edge (deferred constraint triggers
on same-table self-references so COPY and multi-row inserts are judged
at commit), and kb-ownership immutability on every owned table.
The export read model moves from "open a pool connection per page" to a
caller-provided transaction: a route can now pin one REPEATABLE READ
snapshot across the preflight check, the vocabulary reads, and every
page. A mid-stream commit can no longer leak half a rule or a dangling
wasGeneratedBy into a finished file.

Integrity is checked on the rows that survive, not on a second look.
Every page query selects the referenced row's kb atomically with the
row itself; a foreign, dangling, or merged-out reference refuses the
whole export rather than minting a local IRI that names another KB's
row or silently dropping a vocabulary link. The scan covers the
provenance chain, derivation premises, edge qualifiers, vocabulary
references, and the open-statement / time-mention / binding edges the
schema has grown since — the same families migration 0070 guards on
the write side.

Read-model additions carried by the same pages: statement qualifiers,
time mentions, typed-fact sources, fact layer/phrase/validity grade,
evidence quote offsets, chunk origin metadata, entity descriptions,
document reader/time-context fields, and vocabulary updated_at.
Rules, attribute rules, document versions, chunks and evidence were
read from the same snapshot but never serialized; their facts'
prov:wasGeneratedBy, prov:wasDerivedFrom and locator references
dangled in the file. Serialize them in snapshot order so every
emitted reference resolves.

New upstream ledger surfaces serialize too: class/relation updatedAt,
entity descriptions, document reader/time-context, chunk origin
metadata, evidence quote offsets, open-statement layer/phrase/
qualifiers/time mentions, typed-fact fromStatement provenance,
validFromGrade, and evidenceOrigin.
The RDF export section documented entities, facts and documents but
not the serialized rule, version, chunk and evidence families, the
reference-resolution guarantees, or the single-snapshot and
fail-closed semantics the route now provides — and nothing about the
ledger surfaces newer migrations added. Document the whole emitted
contract: open statements and their qualifier/time-mention nodes,
typed-fact fromStatement provenance, validity grades, evidence
origin/offsets, chunk producer metadata, document reading context,
vocabulary updatedAt, and the explicit non-claims.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@ansonnmm

Copy link
Copy Markdown
Author

Closing pending author's final review of the PR set — will reopen once the series is finalized.

@ansonnmm ansonnmm closed this Sep 20, 2026
@ansonnmm ansonnmm changed the title The export contract documents the whole ledger docs(export): document the RDF export contract Sep 20, 2026
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