fix(tests): seed the document lineage the memory_v1 views require - #253
Merged
Conversation
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.
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.
Finishes making
maingreen. Companion to #249, which fixes theIntegration (workers)half. Tests only — no production code is touched.
Root cause
a6ba50ff("refactor(queryspace): make clean pre-release cut") repointed the query surfaceat the
memory_v1invariant 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):entities_current):mentions→ realchunksrow →document_versions_visible(matchingversion_idanddoc_id) → a non-supersededresolution_decisionsrow.claims_visible_history):claims→chunks→document_versions_visible→documents_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_currentandentity_aliases_current— genuinely ingested corpora satisfy the contract.Per file
test_retrieval_batch_b.pytest_retrieval_batch_e.pychunk_ids — no version/representation/chunk chain, so testimony hydration was emptytest_retrieval_batch_d.pytest_envelope_contract.pycontradiction_members_current→facts_current, needingentities_currentendpoints plus evidence bound to a visible claimtest_surfaces_parity.pyresolve_entityreturned nothingtest_retrieval_api.py(s51)graph_edges_currentscoringtest_retrieval_api.py(search_claims)memory_v1.claims_liveand the fake index still sniffed for"FROM claims", so its batch counter never incremented. Assertions unchanged.test_s58_consumption.pyThe 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 registryentity; 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.pyfactors the two helpers so this is not copied perfile.
Known, deliberately not fixed here
test_retrieval_batch_d.pystill uses thedocument_entity_idbridge for itspre-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_RELATIONSreads the baserelationstable rather thanfacts_current, which iswhy 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