refactor(storage): delete dead session_links cycle-quarantine engine - #3655
Conversation
Ref polylogue-4ts.10 Problem: #3643 ported cycle detection + quarantine into the live session_links writer (write.py's _resolve_outbound_session_links / _resolve_session_graph), leaving storage/sqlite/queries/session_links.py's equivalent async engine (upsert_session_links, resolve_session_links_for_ session, resolve_unresolved_links_for_child, _would_create_cycle, _quarantine_link, count_quarantined_session_links) with zero production callers. Three tests exercised only that dead engine while claiming to certify production behavior: tests/unit/insights/test_topology_cycle_ rejection.py (a dedicated 621-line file), test_delegation_direction_ matches_real_link_resolver in test_delegations_view.py (explicitly docstring-labeled "the ACTUAL production write path"), and test_session_link_resolver_quarantines_cycle in the property write-path state machine -- all wrong-oracle tests per the 2026-08-03 structural audit referenced on the bead. Solution: - Deleted the dead write engine from queries/session_links.py, keeping only list_session_links_for_session (a genuine production read path via query_store_archive.py). - Deleted tests/unit/insights/test_topology_cycle_rejection.py outright: its scenarios (two-node cycle, self-loop, diamond DAG) are already covered against the live path by test_topology_cycle_quarantine_live.py (landed with #3643). - Retargeted test_delegation_direction_matches_real_link_resolver to drive write_parsed_session_to_archive directly instead of the dead engine's upsert_session_links/resolve_session_links_for_session. - Retargeted test_session_link_resolver_quarantines_cycle to reproduce the cycle via a real re-ingest through write_parsed_session_to_archive (matching the pattern in test_topology_cycle_quarantine_live.py) instead of manually inserting a session_links row and calling the dead engine's resolve_unresolved_links_for_child. - Removed now-unused imports/helpers (_AsyncSqliteAdapter/_AsyncCursorAdapter in test_delegations_view.py, aiosqlite/configure_connection/asyncio in the other two files). This completes the remaining polylogue-4ts.10 scope noted as follow-up in #3643: AC1 (every write carries TopologyEdgeStatus/method -- satisfied by #3643, unaffected here), AC2 (existing rows converge via ordinary derived-tier rebuild -- unaffected, no migration added), AC3 (a reader can filter by status -- list_session_links_for_session already returns status; downstream consumers already read it: storage/insights/topology/ derivation.py excludes quarantined edges from unresolved-edge composition, insights/transforms.py threads child_link_status including "quarantined" onto SubagentReport). Composition already degrades visibly on a quarantined edge: the child's sessions.parent_session_id stays NULL, so it surfaces as its own root rather than silently composing through the rejected parent. Not done here (explicitly out of scope for this change): AC4's live- archive re-measure requires rebuilding the production index, which is a separate operator action (polylogue ops reset --index && polylogued run), not a code change. Verification: - devtools test tests/unit/storage/test_delegations_view.py tests/unit/storage/test_topology_cycle_quarantine_live.py tests/unit/storage/test_unread_wire_batch_v46.py tests/unit/storage/test_archive_tiers_write.py tests/unit/storage/test_lineage_normalization.py tests/unit/storage/test_session_topology.py tests/unit/storage/test_topology_edges.py -- 164 passed - devtools test tests/property/test_write_path_state_machine.py -- 4 passed - devtools verify --quick -- exit 0 (ruff format/check, mypy --strict, render all --check, all lab policy gates) Co-Authored-By: Claude <noreply@anthropic.com>
Ref polylogue-4ts.10 Companion to 8d1d068 (which deleted the dead engine itself from storage/sqlite/queries/session_links.py) -- this commit was meant to land atomically with that one but the staging command silently dropped these three modified files when git add hit a missing pathspec earlier in the same invocation. - queries/session_links.py: slim module docstring explaining the deletion and narrowed __all__ (list_session_links_for_session only). - test_delegations_view.py: test_delegation_direction_matches_real_link_ resolver now drives write_parsed_session_to_archive directly; removed the now-unused _AsyncSqliteAdapter/_AsyncCursorAdapter shim and its imports. - test_write_path_state_machine.py: test_session_link_resolver_ quarantines_cycle now reproduces the cycle via a real re-ingest through write_parsed_session_to_archive instead of manually inserting a session_links row and calling the dead engine's resolve_unresolved_links_for_child; removed now-unused aiosqlite/ configure_connection imports. Verification: same as 8d1d068 (devtools test across the touched files, devtools verify --quick exit 0) -- rerun after this fix to confirm the combined diff is what was actually tested: - devtools test tests/unit/storage/test_delegations_view.py tests/property/test_write_path_state_machine.py -- all passed - devtools verify --quick -- exit 0 Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 51 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
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 |
Summary
Completes the remaining polylogue-4ts.10 scope left as follow-up by #3643: deletes the dead async cycle-detection/quarantine engine in
storage/sqlite/queries/session_links.py(zero production callers since #3643 ported the equivalent logic into the live writer), and retargets the three wrong-oracle tests that exercised only that dead engine at the real production write path (write_parsed_session_to_archive).Problem
#3643 ported cycle detection + quarantine into the live
session_linkswriter (write.py's_resolve_outbound_session_links/_resolve_session_graph), but leftstorage/sqlite/queries/session_links.py's equivalent async engine (upsert_session_links,resolve_session_links_for_session,resolve_unresolved_links_for_child,_would_create_cycle,_quarantine_link,count_quarantined_session_links) in place with zero production callers. Three tests exercised only that dead engine while implicitly or explicitly claiming to certify production behavior:tests/unit/insights/test_topology_cycle_rejection.py(a dedicated 621-line file bootstrapping a raw sqlite3 connection and calling the dead engine directly).test_delegation_direction_matches_real_link_resolverintest_delegations_view.py, whose docstring explicitly claimed to drive "the ACTUAL production write path" via the dead engine's functions.test_session_link_resolver_quarantines_cyclein the property write-path state machine, which manually inserted asession_linksrow and called the dead engine'sresolve_unresolved_links_for_childto simulate a cycle.This is exactly the wrong-oracle pattern flagged by the 2026-08-03 structural audit referenced on the bead: tests certifying behavior production code cannot exhibit.
Solution
queries/session_links.py, keeping onlylist_session_links_for_session(a genuine production read path reached viaquery_store_archive.py).tests/unit/insights/test_topology_cycle_rejection.pyoutright: its scenarios (two-node cycle, self-loop, diamond DAG) are already covered against the live path bytest_topology_cycle_quarantine_live.py(landed with fix(storage): quarantine real cycles in the live session_links resolver #3643).test_delegation_direction_matches_real_link_resolverto drivewrite_parsed_session_to_archivedirectly instead of the dead engine'supsert_session_links/resolve_session_links_for_session. Removed the now-unused_AsyncSqliteAdapter/_AsyncCursorAdaptershim built specifically to run the dead engine.test_session_link_resolver_quarantines_cycleto reproduce the cycle via a real re-ingest throughwrite_parsed_session_to_archive(matching the pattern intest_topology_cycle_quarantine_live.py) instead of manually inserting a row and calling the dead engine.aiosqlite,configure_connection,asynciowhere no longer needed).AC status (polylogue-4ts.10)
TopologyEdgeStatus/method, no empty-status writes): satisfied by fix(storage): quarantine real cycles in the live session_links resolver #3643, unaffected by this PR.list_session_links_for_sessionalready returnsstatus; downstream consumers already read it --storage/insights/topology/derivation.pyexcludes quarantined edges from unresolved-edge composition, andinsights/transforms.pythreadschild_link_status(including"quarantined") ontoSubagentReport. Composition already degrades visibly: a quarantined edge's child never getssessions.parent_session_idset, so it surfaces as its own root rather than silently composing through the rejected parent. No new reader surface was needed beyond confirming these existing paths.polylogue ops reset --index && polylogued run), a separate operator action, not a code change.Verification
devtools test tests/unit/storage/test_delegations_view.py tests/unit/storage/test_topology_cycle_quarantine_live.py tests/unit/storage/test_unread_wire_batch_v46.py tests/unit/storage/test_archive_tiers_write.py tests/property/test_write_path_state_machine.py-- 120 passeddevtools verify --quick-- exit 0 (ruff format/check, mypy --strict,render all --check, all lab policy gates)Ref polylogue-4ts.10