Skip to content

fix(tests): seed the document lineage the memory_v1 views require - #253

Merged
fazpu merged 5 commits into
mainfrom
fix/surfaces-provenance
Aug 11, 2026
Merged

fix(tests): seed the document lineage the memory_v1 views require#253
fazpu merged 5 commits into
mainfrom
fix/surfaces-provenance

Conversation

@fazpu

@fazpu fazpu commented Aug 10, 2026

Copy link
Copy Markdown
Member

Finishes making main green. Companion to #249, which fixes the Integration (workers)
half. Tests only — no production code is touched.

Root cause

a6ba50ff ("refactor(queryspace): make clean pre-release cut") repointed the query surface
at the memory_v1 invariant views. Those views require a complete document lineage.
Several fixtures predate that cut and seed only leaf rows, so the views correctly return
nothing and the assertions collapse to empty tuples — assert 0 == 2,
assert () == (UUID(...),), IndexError: tuple index out of range.

Two predicates do the work (p9_01_0022_memory_v1_query_space.py):

  • Entity membership (entities_current): mentions → real chunks row →
    document_versions_visible (matching version_id and doc_id) → a non-superseded
    resolution_decisions row.
  • Claim visibility (claims_visible_history): claimschunks
    document_versions_visibledocuments_live.

This is a fixture gap, not a shipped defect. Verified independently by running the real
E0–E3 chain and confirming its entities appear in both entities_current and
entity_aliases_current — genuinely ingested corpora satisfy the contract.

Per file

File Cause
test_retrieval_batch_b.py Both Sam fixtures had aliases but no live-lineage association
test_retrieval_batch_e.py Claims pointed at orphan chunk_ids — no version/representation/chunk chain, so testimony hydration was empty
test_retrieval_batch_d.py Ambiguous Alex entities lacked mention provenance
test_envelope_contract.py Co-members come from contradiction_members_currentfacts_current, needing entities_current endpoints plus evidence bound to a visible claim
test_surfaces_parity.py Alice lacked mention provenance, so resolve_entity returned nothing
test_retrieval_api.py (s51) Entities lacked mention provenance; relations lacked claim/evidence lineage for graph_edges_current scoring
test_retrieval_api.py (search_claims) Probe drift only — confirmation moved to memory_v1.claims_live and the fake index still sniffed for "FROM claims", so its batch counter never incremented. Assertions unchanged.
test_s58_consumption.py Seeded Acme lacked mention provenance, so S39's "known empty" arm could not resolve it

The mention arm, deliberately

New fixtures gain membership through mentions and resolution decisions, never through
documents.document_entity_id. That column is the bridge to a Document-typed registry
entity; using it for a Person, Organization, or Concept opens the gate while leaving real
mention-based provenance unguarded, so a regression there would keep these suites green.
Both reviewers rejected that shortcut on an earlier attempt (#252).

src/tests/surfaces/lineage_seed.py factors the two helpers so this is not copied per
file.

Known, deliberately not fixed here

  • test_retrieval_batch_d.py still uses the document_entity_id bridge for its
    pre-existing green fixtures. Changing them would mix causes; tracked in Query-space fixtures gain entity membership via document_entity_id instead of mentions #252.
  • _LOOKUP_RELATIONS reads the base relations table rather than facts_current, which is
    why an envelope can carry a fact with empty co-members. That is a production
    asymmetry, out of scope for a tests-only change, and worth its own look.

No money, cost, or provider-call path is touched.

Contributor agreement

Signing on behalf of a legal entity (leave blank if accepting individually):

WriteIt AI

🤖 Generated with Claude Code

https://claude.ai/code/session_01C1b5hSkMXhw7MNGqQbRcFD

fazpu and others added 5 commits August 11, 2026 00:00
memory_v1.entities_current only publishes an entity with SURVIVING PROVENANCE.
The two Sam fixtures had entities and aliases but no association to a live
lineage, so resolution correctly answered unknown_entity and the ambiguity
assertions collapsed to empty.

They now gain membership the way a real extracted Person does: a mention on a
live chunk plus its resolution decision. The other membership arm — the
documents.document_entity_id bridge — is deliberately not used, because that
column belongs to Document-typed registry entities; seeding it here would let a
regression in real mention-based provenance leave this suite green.
memory_v1.claims_visible_history only publishes a claim whose chunk sits on a
complete live document lineage. Batch E seeded documents and claims but no
content_objects / document_versions / representations / chunks, so testimony
hydration returned an empty envelope and every assertion collapsed.

Factor the full lineage seed into a shared helper and wire each Batch E
document through it so claims confirm against the same gate production uses.
memory_v1.entities_current only publishes an entity with SURVIVING PROVENANCE.
Ambiguity and resolve fixtures (Alex Alpha/Beta, Alice for surface parity, Acme
for S39) had entities and aliases but no association to a live lineage, so
resolution correctly answered unknown_entity.

They now gain membership the way a real extracted Person/Organization does: a
mention on a live chunk plus its resolution decision. The document-entity
bridge is deliberately not used for these types.
contradiction_members_current and graph_edges_current inherit facts_current,
which requires every endpoint in entities_current and at least one
relation_evidence row bound to a claim on a complete live lineage. Envelope
and S51 fixtures seeded bare relations, so co-members and context hits were
empty while the raw relations table still answered lookups.

Seed the full claim lineage, mention membership, and relation_evidence for
those facts. Also re-express the claim-confirmation probe to match
memory_v1.claims_live after the query surface was repointed.
…igrations

The test passed alone and failed in the full suite. Alembic's `fileConfig` runs
with `disable_existing_loggers` at its default of True, and surface fixtures
migrate in-process, so by the time this test ran the tool module's logger was
disabled and caplog captured nothing.

Production applies migrations in a separate `setup` container that exits before
the API starts (compose.yaml), so the side effect is test-order-only. The logger
is re-enabled rather than the assertions dropped: the logged traceback is how an
operator finds a programmer defect that reached an MCP client.
@fazpu
fazpu merged commit f913858 into main Aug 11, 2026
10 checks passed
@fazpu fazpu mentioned this pull request Aug 11, 2026
1 task
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