Repository navigation
fix(lineage): Repair or name the children a full replace strands - #5376
Conversation
A parent full-replace that drops or relocates a branch-point message left its already-resolved prefix-sharing children composing to their own divergent tail, with no corrector of any kind. PR #5372 made that state VISIBLE -- the daemon startup census reports it -- but nothing fixed it. WHY THE PRODUCER MISSED IT impacted_session_ids in _resolve_session_graph is {session_id} U resolved_child_ids U reextract_invalidated_ids U invalidated_session_ids. Identity resolution only ever revisits UNRESOLVED edges, so an already-resolved child is in none of those sets and the in-write repair skipped exactly the child the write had just stranded. A replaced parent that dropped a branch-point message has no outbound link, no unresolved inbound edge and a current root projection, so the write took the fast path. THE ANCHOR IS THE RIGHT KEY, NOT THE EDGE'S PARENT branch_points_anchored_in_session looks children up by the branch point's own namespace rather than by resolved_dst_session_id. A child that branched inside its parent's INHERITED prefix pins an ancestor-owned message id, so keying on "this parent's inbound children" -- the obvious reading -- never names it. Whatever the repair can re-resolve is repaired in the same write. Whatever it cannot is a real loss: the branch-point message has no counterpart anywhere in the replacement transcript, so no edge rewrite recovers the child's inherited prefix. Those children are recorded as retryable convergence debt. The edge KEEPS its composing status on purpose -- that is what keeps the read reporting dangling_branch_point and the census counting it. Quarantining would drop the edge out of composition and the child would read as a COMPLETE bare tail, which is the silent-truncation failure this campaign has been removing. THE LOOKUP RUNS ON EVERY SESSION WRITE, SO IT IS INDEXED Measured on the live index shape (23,496 sessions, 9,497 edges): 0.617 ms per write as a session_links scan -- 14.5 s of full-corpus replay, growing as sessions x edges -- against 0.0053 ms as an indexed range probe over the new partial index idx_session_links_branch_point, or 0.12 s across the replay. VERIFICATION: devtools verify --quick exit 0, all gates. devtools render all --check exit 0, zero "out of sync". devtools test tests/unit/storage/test_lineage_normalization.py -- 53 passed. CLOSURE: write.py and index.py are both IN, so the derived index identity moves and this must land before a fresh rebuild starts, never during one. The index addition is index-only on the rebuildable index tier, so it needs no migration. RESIDUAL, reproduced and NOT fixed: a grandparent re-parse that relocates an anchor THROUGH an intermediate parent. Writing ggp/gp/parent/child where child branches at gp:n:m1, then re-acquiring gp with a parent claim, leaves the child composing ['x2'] instead of ['m0','m1','x2']. Every piece resolves correctly in isolation -- the anchor lookup finds the child, the identity suffix is n:m1, and the replacement resolves to ggp:n:m1 -- but the in-write repair does not apply it. Two candidate causes were implemented and both REVERTED because neither made the case pass: deriving the suffix from the anchor's own owner rather than the resolved parent, and clearing the composed-signature memo before the repair. Landing untested speculative code would be worse than naming the gap. The case belongs to polylogue-gy2yu and the reproduction is recorded there. Advances polylogue-gy2yu. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
|
Warning Review limit reachedNext included review available in 12 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (3)
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 95c25cecc1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
## Summary - `mark --tag-remove` through the daemon was refused on every route. `mutate-remove-tag` now admits the `api` and `cli` surfaces, matching its add counterpart. - Adds an end-to-end test proving that a child stranded by a parent re-parse is recomposed by the `lineage_prefix_recompose` debt stage. ## Problem `mutate-remove-tag` declared no `allowed_surfaces`. `_declare_executor_authority` therefore back-filled it as API-only, and `MutationTransaction.prepare_bound` raised `SurfaceDeniedError` for the `cli` principal. The CLI removal payload of `mutation.session.tag` lowers onto exactly that per-target actuator, so every CLI tag removal failed. The add payload lowers onto `mutate-bulk-tag-sessions`, which admits `api` and `cli`. That asymmetry survived because the daemon write test drove only the add payload. The lineage half of this PR adds no production code. A parent full replace that drops a child's branch-point message has, since #5376, recorded `lineage_prefix_recompose` debt, and the stage re-derives the child from its retained raw. No test drove that debt through the drain for this loss, only for the identity-alias loss. ## Solution - `polylogue/operations/specs.py`: `mutate-remove-tag` declares `allowed_surfaces=("api", "cli")`. - `tests/unit/daemon/test_http_write_coordination.py`: a real-daemon test adds a tag and then removes it through `mutation.session.tag`. It asserts two `mutate-remove-tag` operation runs under the `cli` surface. Anti-vacuity: deleting the declaration makes the removal fail with `SurfaceDeniedError`. - `tests/unit/daemon/test_convergence_debt.py`: seeds a two-link Codex lineage and replaces the parent through the writer with its branch-point message under a new native id. It asserts that the child is stranded with one debt row, drains once, and asserts that the child's composed transcript is complete again and the row is cleared. ## Verification - `devtools test tests/unit/daemon/test_http_write_coordination.py tests/unit/daemon/test_convergence_debt.py tests/unit/operations/test_specs.py tests/unit/api/test_facade_mutation_census.py tests/unit/mcp/test_privileged_tools.py` → 82 passed, 35 failed. - All 35 failures are in `test_privileged_tools.py` and `test_facade_mutation_census.py`. The same two files on clean `origin/master` give 41 passed, 35 failed, so none come from this PR. They are the facade's `FacadeDaemonRequiredError` route and the pinned facade inventory. - `devtools verify --quick` → `verify: PASSED exit=0` ## Residuals - `polylogue/operations/specs.py` is inside the derived schema-identity closure, so this must land before a fresh rebuild starts. - The 35 pre-existing failures above are not addressed here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4 --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 64a9bd0):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 0914f89):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
fix(lineage): Repair or name the children a full replace strands
A parent full-replace that drops or relocates a branch-point message left its
already-resolved prefix-sharing children composing to their own divergent tail,
with no corrector of any kind. PR #5372 made that state VISIBLE -- the daemon
startup census reports it -- but nothing fixed it.
WHY THE PRODUCER MISSED IT
impacted_session_ids in _resolve_session_graph is {session_id} U
resolved_child_ids U reextract_invalidated_ids U invalidated_session_ids.
Identity resolution only ever revisits UNRESOLVED edges, so an already-resolved
child is in none of those sets and the in-write repair skipped exactly the
child the write had just stranded. A replaced parent that dropped a
branch-point message has no outbound link, no unresolved inbound edge and a
current root projection, so the write took the fast path.
THE ANCHOR IS THE RIGHT KEY, NOT THE EDGE'S PARENT
branch_points_anchored_in_session looks children up by the branch point's own
namespace rather than by resolved_dst_session_id. A child that branched inside
its parent's INHERITED prefix pins an ancestor-owned message id, so keying on
"this parent's inbound children" -- the obvious reading -- never names it.
Whatever the repair can re-resolve is repaired in the same write. Whatever it
cannot is a real loss: the branch-point message has no counterpart anywhere in
the replacement transcript, so no edge rewrite recovers the child's inherited
prefix. Those children are recorded as retryable convergence debt. The edge
KEEPS its composing status on purpose -- that is what keeps the read reporting
dangling_branch_point and the census counting it. Quarantining would drop the
edge out of composition and the child would read as a COMPLETE bare tail, which
is the silent-truncation failure this campaign has been removing.
THE LOOKUP RUNS ON EVERY SESSION WRITE, SO IT IS INDEXED
Measured on the live index shape (23,496 sessions, 9,497 edges): 0.617 ms per
write as a session_links scan -- 14.5 s of full-corpus replay, growing as
sessions x edges -- against 0.0053 ms as an indexed range probe over the new
partial index idx_session_links_branch_point, or 0.12 s across the replay.
VERIFICATION: devtools verify --quick exit 0, all gates. devtools render all
--check exit 0, zero "out of sync". devtools test
tests/unit/storage/test_lineage_normalization.py -- 53 passed.
CLOSURE: write.py and index.py are both IN, so the derived index identity moves
and this must land before a fresh rebuild starts, never during one. The index
addition is index-only on the rebuildable index tier, so it needs no migration.
RESIDUAL, reproduced and NOT fixed: a grandparent re-parse that relocates an
anchor THROUGH an intermediate parent. Writing ggp/gp/parent/child where child
branches at gp:n:m1, then re-acquiring gp with a parent claim, leaves the child
composing ['x2'] instead of ['m0','m1','x2']. Every piece resolves correctly in
isolation -- the anchor lookup finds the child, the identity suffix is n:m1, and
the replacement resolves to ggp:n:m1 -- but the in-write repair does not apply
it. Two candidate causes were implemented and both REVERTED because neither made
the case pass: deriving the suffix from the anchor's own owner rather than the
resolved parent, and clearing the composed-signature memo before the repair.
Landing untested speculative code would be worse than naming the gap. The case
belongs to polylogue-gy2yu and the reproduction is recorded there.
Advances polylogue-gy2yu.
Co-Authored-By: Claude Opus 5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy