Repository navigation
Project the coordination session tree from canonical session_links - #5161
Conversation
The coordination context envelope built its own session graph: edges were synthesized from sessions.parent_session_id + branch_type, a private mapper flattened an unresolved link's declared type to a generic "unresolved_native" kind, cycle_detected was hard-coded False, and edges[:limit] truncated silently while the payload still read as a whole tree. It now discovers candidate nodes through the parent/root accelerator columns and hands the canonical session_links rows to compose_session_topology -- the one graph classification engine -- so every edge, its declared type, composability and provenance comes from session_links. Truncation and exclusion are reported on the payload instead of being hidden. compose_session_topology is narrowed to TopologyNodeInput (session_id, origin, title) so a caller holding raw `sessions` rows can reach the engine without a second graph construction, and a resolved edge whose parent falls outside the bounded scope is now excluded as "parent-out-of-scope" rather than raising KeyError. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 43 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 (5)
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. |
## Summary Two public read paths still built the session graph by walking `sessions.parent_session_id` / `root_session_id`. They now project from canonical `session_links`, which this bead (polylogue-27ezu) makes the edge authority. ## Problem `polylogue-27ezu` decides that `session_links` is the edge authority: the session parent/root columns may accelerate lookup but must never synthesize an edge or replace its provenance. Two constructions at head contradicted AC2: - `archive_tiers/archive.py::get_session_tree` resolved the root via `_root_session_id_for_tree` and scanned `sessions.root_session_id`. - **Found by census during the work**, in the same file and therefore inside the declared target: `session_lineage_edges` — public through the daemon lineage list rows (`operations/daemon_reads.py::_lineage_edges_payload`) — materialized one-hop edges from `parent_session_id` / `parent_session_id IN (...)`, and ignored composability entirely. The repository read path (`storage/repository/archive/tree.py`) walked the parent column in a loop for `get_parent` / `get_children` / `get_root` / `get_session_tree`. ## Solution `get_session_tree` collects the link-connected neighbourhood (`_topology_closure` over `_incident_session_links`, both directions) and composes it through the single engine `compose_session_topology`; node order is the engine's BFS-from-root order, matching the facade's declared `stable_order="depth,session_id"`. `_root_session_id_for_tree` is deleted. `session_lineage_edges` selects composing `session_links` rows (`resolved_dst_session_id IS NOT NULL AND topology_status_composes_sql()`). A child with contradictory composable parents reports no parent and is dropped from the parent's child tuple — an excluded edge stays visible as evidence but is never traversed (AC5, which this route previously ignored). `repository/archive/tree.py` projects from `derive_session_topology_async` over canonical link reads; the walk loop is gone. `queries/session_links.py` extracts `SESSION_LINK_COLUMNS` so the new sync reader and existing async readers select the same provenance columns — a divergence there would silently drop fields on one surface. `storage/repository/archive/reads.py` was inspected and needed no change: it is a 22-line mixin composition, and the residual lived in the mixin it composes. ## On the modified test `tests/unit/storage/test_query_unit_time_expression.py::test_get_session_tree_does_not_epoch_collide_timeless_sibling` seeded **only** the accelerator columns and asserted the child appeared in the tree — so it could only pass while the implementation walked `parent_session_id`. It asserted the mechanism being removed. The fixture now also seeds the canonical `session_links` row; **the assertion is unchanged**, so the test keeps its own invariant (a timeless sibling is not dropped by a NULL ordering key) and its anti-vacuity condition is documented in place. The code was not weakened to satisfy it. New anti-vacuity tests prove authority in both directions: nulling the accelerator keeps the tree and the lineage edge; deleting the canonical row while the accelerator still claims "child of root" removes both. ## Verification ``` devtools test tests/unit/storage/test_session_topology.py tests/unit/storage/test_tree_laws.py \ tests/unit/api/test_topology_api.py → PASSED exit 0 (receipt 20260915T141703Z-…) devtools test tests/unit/storage tests/unit/api tests/unit/mcp tests/unit/pipeline \ tests/unit/daemon tests/unit/operations → PASSED exit 0, 7472 passed in 41:03 devtools verify --quick → exit 0, all 17 gates devtools render all --check → exit 0, grep "out of sync" = 0 ``` ## ⚠ Landing order **`archive_tiers/archive.py` and `queries/session_links.py` are both IN the derived-schema identity closure** (`devtools schema closure`, independently confirmed). This change moves the stamped derived identity and must land **before** a production rebuild starts; a mid-run landing silently invalidates it. `repository/archive/tree.py` is `out`. This confirms the bead's most recent note and refutes an earlier note claiming all four files were outside the closure. ## Residuals - **AC8 unsatisfied**: provider-shaped production-route coverage across clean / incremental / parent-first / child-first / resumed builds needs the rebuilt archive. - **AC9 unsatisfied**: the every-link-classifies census needs the rebuilt corpus; the bead's 9,497 links / 1,426 unresolved are discovery denominators, not fixtures. - AC1 is met for this residual; it was not re-proven for routes already closed by #5007 / #5012 / #5161. A grep at head finds no other session-graph walk (`delegations` hits are a different relation). - AC4 unchanged: `UNRESOLVED_NATIVE` stays read-compat only and is never emitted by the canonical mapper. Codex's structurally-absent `parent_dispatch` still yields child-side-only edges resolving as `edge_only`, which is correct and was left alone. - The bead's 28-entry `write_scope` remains broader than what was touched; the widening to `session_lineage_edges` and the shared column constant is evidenced above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Summary
The coordination context envelope was a second source of truth for session topology. It now composes through the one canonical
session_links-owned graph engine, and reports its own bound instead of hiding it.Problem
polylogue-27ezudecided onesession_links-owned topology projection. PR #5007/#5012 landed that spine —_archive_session_topologyis gone, andapi/cli/mcp/daemonall reachstorage/derived/topology/derivation.pythroughrepository.get_session_topology. But the census that produced the bead'swrite_scopemissedpolylogue/coordination/envelope.py::_session_tree_payload, which is reachable from the public MCPcontextsurface and was still building its own graph:sessions.parent_session_id+branch_type— the exact red condition in AC2.tests/unit/coordination/test_envelope.pyasserted this as correct: its fixture carried a singlesession_linksrow, and the two "resolved edges" it expected had no canonical row behind them at all.link_typeto a generic"unresolved_native"kind, collapsing resolvedness into type (AC4 red).cycle_detected=Falsewas hard-coded, and quarantined/contradicted edges were invisible (AC5 red).edges[:limit]truncated silently, and the compact projection trimmednodes[:3]/edges[:3]again — a partial tree was indistinguishable from a whole one (AC6 red).Separately,
compose_session_topologyraisedKeyErrorwhen a composable edge resolved to a parent outside the bounded node scope.Solution
compose_session_topology(was_compose) is now the public, single graph classification engine, narrowed to aTopologyNodeInput(session_id,origin,title) so a caller holding rawsessionsrows reaches it without constructing aSessionRecord.parent-out-of-scopeinstead of crashing or vanishing._session_tree_payloaduses the parent/root columns for node discovery only and projects every edge fromsession_links. The target sorts first in discovery so a tight bound can never trim away the session the tree was requested for.CoordinationSessionTreeEdgePayloadgainscomposable/composability_reason;CoordinationSessionTreePayloadgainsconflicting_parent_detected,nodes_complete,edges_complete,truncated_node_count,truncated_edge_count,generation_id. The compact projection folds its own trim into those fields.write_parsed_session_to_archivemints, so the existing assertions prove edges come fromsession_links.Two anti-vacuity tests:
test_coordination_tree_edges_come_only_from_session_linksdeletes the resolved link rows while leavingparent_session_idfully intact — red for any route that synthesizes from the accelerator columns;test_coordination_tree_reports_its_own_truncationis red if the completeness fields are dropped or the silent trim returns.Verification
devtools test: PASSED exit=0 diagnosis=pytest_passed— 127 passed.devtools verify --quick→ exit 0.devtools render all --check→ exit 0, noout of synclines.devtools gate layering→"violations":[],"count":0.Schema closure
devtools schema closurereportsoutfor all four source files touched (coordination/envelope.py,coordination/payloads.py,storage/derived/topology/derivation.py,storage/derived/topology/__init__.py). This change does not move the derived-schema identity and does not invalidate a seeded fixture cache or an in-flight rebuild.Residuals
Not fixed here, reported as remaining
polylogue-27ezuscope:storage/sqlite/archive_tiers/archive.py::get_session_tree+_root_session_id_for_treestill walkparent_session_id/root_session_idwith nosession_linksread. Public reach:Polylogue.get_session_tree(api/archive.py:7104), the sync wrapper (api/sync/sessions.py:168), and the MCP resourcepolylogue://session-tree/{conv_id}(mcp/server_resources.py:289). All four consumers are list-shaped (membership only, no edge traversal), so this is a scoping rather than an edge-provenance defect — but AC2 is not met until it reads canonical rows.storage/repository/archive/tree.py(get_root/get_children/get_parent/get_session_tree) is a third parent-walk implementation with zero callers in production or tests apart from one incidentalSessionRepository.get_session_treecall attests/unit/pipeline/test_branching.py:423. Left in place pending an explicit retirement decision.derive_session_topology_syncstill describes itself as a test adapter and has no production callers.read_archive_session_envelopestill returns a truncated transcript with no completeness flag (Repair branch points invalidated by deferred prefix re-extraction #5090's recorded residual). This PR does not touch that path.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK