Repository navigation
feat(topology): resolve hook-vs-inference parent conflicts on the write path - #4022
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…te path Ref polylogue-hook-authority-conflict-proof, polylogue-foee
Ref polylogue-hook-authority-conflict-proof
…class Ref polylogue-hook-authority-conflict-proof
…g-state gaps Convert the three remaining composability sites to the shared exclusion predicate, supersede a stale authoritative edge when hook evidence revises itself, project the real status through the delegation mapping vocabulary, and pin composition exclusion at the resolver that actually enforces it. Ref polylogue-hook-authority-conflict-proof, polylogue-foee, polylogue-0ai7p
Sinity
force-pushed
the
feature/topology/hook-authority-conflict
branch
from
August 19, 2026 06:54
69e84cf to
656968d
Compare
Sinity
added a commit
that referenced
this pull request
Aug 19, 2026
…k-authority mechanism note Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HWcPJJJvuF25CqVwTFgSQC
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.
Summary
Topology edges now resolve a disagreement between acquired Codex hook evidence and transcript inference instead of letting both claims coexist unmarked. Hook evidence wins, the overruled inference is retained under a new typed exclusion status rather than deleted, an inference-only re-parse can no longer overwrite or erase the authoritative result, and an archive-verification check censuses the outcome. Absent hook evidence, every edge is byte-identical to today.
Problem
polylogue-foeeacquired Codexthread_spawn_edgesinto the durablesource.dbhook spool ascodex_thread_spawn_edgeevents (3,055 title + 1,030 spawn-edge rows live). Nothing consumed them for topology. The only artifact wascontext/codex_spawn_edge_correlation.reconcile_codex_spawn_edges— a read-only counter reachable solely through the API facade.That counter cannot express the problem it appears to address. It computes set differences over
(parent, child)pairs, so a genuine contradiction — hook evidence and inference naming different parents for the same child — surfaces as one entry ininferred_onlyand one inauthoritative_only, losing the fact that the two claims compete.authoritative-hook-evidence, the method tokenpolylogue-4ts.10's design doc anticipated, had zero occurrences anywhere in the tree.Three structural facts made this worse than a missing feature:
session_links' primary key is(src_session_id, dst_origin, dst_native_id, link_type), so two contradictory parents are two rows, not an overwrite. Both resolved, and_refresh_session_projectionthen picked one byobserved_at_msordering — an arbitrary, arrival-order-dependent parent with no recorded decision._write_session_linkused a bareINSERT OR REPLACE, which rewrites every column of a matching key, resettingmethodandstatus.DELETE FROM session_links WHERE src_session_id = ?unconditionally, so an ordinary re-parse deleted an authoritative edge and — with no source handle to re-derive it — silently reinstated the inferred parent. This is the most destructive form of the hole and the one a write guard alone would not have caught; it surfaced only when a red twin failed.Design
Where authority is applied: the write path, because of tier durability. I evaluated a post-ingest reconciliation pass — where
reconcile_codex_spawn_edgesalready lives, holding both connections — and rejected it.session_linksis in the rebuildable index tier while hook evidence is in the durable source tier, so every reindex reconstructs these rows from scratch. Only a derivation running insidewrite_parsed_session_to_archive— the choke point shared by live incremental ingest and full raw replay — survives a rebuild by construction. A convergence-stage applier would silently lose the marking on the next reindex, which is disqualifying for a reindex-readiness campaign.source_connis threaded in as an optional parameter, mirroringrevision_authority_refuses_write(conn, source_conn, ...)(ingest_precedence.py:145) including itsNonecase for index-only harnesses.ArchiveStoresupplies it via a new_optional_source_conn()that degrades toNonerather than failing a session write.What "conflict" precisely is. Scoped to
(src_session_id, link_type), not to the primary key — because the PK carriesdst_native_id, keying conflict to it would define the contradiction out of existence. Given child C and link type T: the hook claim is theparent_thread_idwhosecodex_thread_spawn_edgepayload names C as child; the parser claim issession.parent_session_provider_id. Agreement upgrades the single edge toauthoritative-hook-evidence. Disagreement is a conflict. Hook silence is not a conflict — absent evidence is silence, which is why the no-evidence path is provably unchanged.Note the child-side lookup cannot use
list_hook_events(session_native_id=...):codex_state_evidence.pykeys these events bysession_native_id = parent_thread_id, so the query matches the payload's ownchild_thread_id.What the durable conflict state looks like.
TopologyEdgeStatusgains a member,AUTHORITY_CONTRADICTED("authority-contradicted"). The losing edge is retained with that status andmethod = 'contradicted-by-hook-evidence', itsevidence_jsoncarrying both parents; the winner is written withmethod = 'authoritative-hook-evidence'.A distinct member rather than reusing
QUARANTINEDis the point, not an accident. Both statuses exclude an edge from composition, but they are different defects and must stay tellable apart forever: a quarantine is a structural cycle-break (the graph SHAPE is wrong), while an authority contradiction is a provenance verdict (the shape is fine; this particular claim was overruled). An operator triaging a live archive needs that distinction, andmethodis an unconstrainedTEXTcolumn that cannot carry it safely — exactly the hand-written-vocabulary drift this repo warns against. Both members are documented beside each other inTopologyEdgeStatus.The obstacle a new member normally creates, removed rather than accepted. Eleven exclusion sites across seven modules each hardcoded
'quarantined'. Adding an exclusion class to that arrangement means finding and updating every one, and any miss silently readmits an excluded edge into lineage. The predicate is now generated:COMPOSITION_EXCLUDED_TOPOLOGY_STATUSESis the single definition, rendered bytopology_status_composes_sql()/topology_status_excluded_sql()for SQL andstatus_excludes_composition()for the Python-side filter that has no query to attach to.Amended claim. An earlier revision of this body said eight sites and that a future exclusion class is "picked up by every consumer for free". Both were wrong, and I found the first one myself before review by re-running my own sweep with the scope I should have used originally — my search covered
polylogue/storage/**and misseddevtools/andpolylogue/operations/. Cold review then found two more I had still missed. The corrected set is eleven, and the "for free" claim only holds for consumers that read the shared definition — which is now all of them, but was not when the sentence was written. The three sites added in this revision:storage/insights/topology/derivation.py:80— a Python-sidestatus == "quarantined"filter. Because a contradicted edge is unresolved by construction, 100% of them were readmitted here.insights/transforms.py:77,1791—SubagentChildLinkStatus' four-value allowlist mapped every contradicted edge toNone("no link status") rather than to a reason.operations/daemon_workload_probe.py:1925-1942— theCASEbuckets by raw status, so contradicted edges already had their own bucket; it was simply never read out, so census counts stopped summing to the table.REPAIREDis deliberately absent from the excluded set: a repaired edge was fixed, so it composes.4ts.10anticipatedauthoritative-hook-evidenceas a method token only; that is implemented, plus the contradiction token and status member it did not anticipate, because a method alone can neither exclude an edge from composition nor be constrained.Schema. The
CHECKonsession_links.statusis generated from the enum (nullable_check("status", TopologyEdgeStatus)), so the new member is a DDL change:INDEX_SCHEMA_VERSION67 → 69 with anIndexDeltaDeclarationofSEMANTIC_REPARSE. Widening the CHECK is inert for existing rows, but the new state is only produced by re-deriving edges against the durable hook spool during raw replay — an existing generation cannot fast-forward into it, and its lineage projections would keep composing through parents the hook evidence overrules.CONSTRAINT_ONLYwould have been the cheap and dishonest call.What does NOT change: lineage composition semantics, prefix-dedup,
branch_point_message_id/inheritance(including the deliberate non-FK), cycle quarantine, and every edge in an archive with no hook evidence.Surfacing. A new
hook-authority-topology-conflictregistry check censuses contradictions. Contradictions themselves are reported as observability, not errors — recording them is the mechanism working. The single error condition is a contradicted edge with no authoritative sibling for the same child, which would mean inference was demoted by nothing.Verification
Lane
/realm/worktrees/hook-authority-conflict, guard-verified;devtools testreportedpolylogue package → /realm/worktrees/hook-authority-conflict/polylogue/__init__.py.Red twins
Each guard was mutated and shown to fail the test that claims it.
INSERT OR REPLACE(authority downgradable in place)test_reparse_cannot_downgrade_authoritative_evidence| Two authoritative parents for one child | 1 failed —
test_two_authoritative_parents_for_one_child_trips_the_check|Retracted row, and what replaced it. An earlier revision of this table claimed that dropping
AUTHORITY_CONTRADICTEDfromCOMPOSITION_EXCLUDED_TOPOLOGY_STATUSESproduced "1 failed, 6 errors". Cold review could not reproduce it; I re-ran the identical mutation and got 7 passed, after dumping the generated predicate to confirm the mutation genuinely reached it (NOT IN ('quarantined')). The original figure was almost certainly captured mid-edit, before the enum member existed —1 + 6equals the file's test count, which is the signature of a collection failure, not a detection. The row is withdrawn.The reviewer's mechanical explanation is correct and is now documented in the code:
_resolve_outbound_session_links' pre-existingstatus IS NULLgate is the operative mechanism. A contradicted edge never acquiresresolved_dst_session_id, so composition cannot traverse it regardless of the exclusion set; membership in that set is defense-in-depth for an edge that resolved before acquiring a status (the cycle-quarantine path does exactly that). No test can distinguish its presence from absence today, so no twin should claim otherwise.The genuine pin is
test_contradicted_edge_is_excluded_from_composition, which asserts the invariant at the layer that enforces it: the contradicted edge stays unresolved and the child's composed parent is the hook's parent.The registry check carries its own red twins,
test_contradiction_without_authoritative_winner_trips_the_checkand the multi-authoritative one above, plus a positive control asserting a properly resolved contradiction reports OK.The third mutation is the one worth noting: it was not a planned twin.
test_reparse_cannot_downgrade_authoritative_evidencefailed on first run withKeyError, because the authoritative row was gone rather than downgraded — which is how the unconditional purge was found. The fix mirrors the exemption three lines above it in the same function, wherecapture_gapevents are already spared as "archive-generated ingest evidence, not projections owned by whichever parser payload currently wins source precedence." Hook evidence is the same category.Gate substitution
Per coordinator policy, the plain full
devtools verifywas not run. Checked rather than assumed: this lane's testmon environment digest ispolylogue-a8fac865...and the graphlane-initseeded from the main checkout carries five environments, none matching — a plain verify would have been abootstrap (absent)full run. Notably this is the same digest a previous lane computed, so the mismatch is systematic across lanes rather than per-lane. The focused runs above cover every changed module, and--quickgates format, lint, strict mypy, layering, schema-versioning, and all generated surfaces.Bead disposition
This PR closes no bead and mutates no bead record; the carrier below is the typed
self_containedscope.polylogue-hook-authority-conflict-proofpolylogue-foee(closed)contradicted_count/authoritative_countevidence. The title-ladder wiring (AC1) and live UUID-title census (AC3) are untouched.Ref polylogue-hook-authority-conflict-proof, polylogue-foee, polylogue-4ts.10
Not in scope
codex_thread_spawn_edge; no other origin currently acquires authoritative topology evidence. The guard generalizes, but claiming provider-neutrality would overstate what is wired.reconcile_codex_spawn_edgesis untouched by deliberate scope guard; its disposition is later bookkeeping. It remains a useful read-only correlation counter, and its inability to detect same-child contradictions is documented above rather than fixed, since the write path now records that state directly.polylogue-foeeAC1).