Repository navigation
fix: preserve topology page truncation signal - #5012
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced 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 |
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. |
Sinity
added a commit
that referenced
this pull request
Sep 14, 2026
…5161) ## 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-27ezu` decided one `session_links`-owned topology projection. PR #5007/#5012 landed that spine — `_archive_session_topology` is gone, and `api`/`cli`/`mcp`/`daemon` all reach `storage/derived/topology/derivation.py` through `repository.get_session_topology`. But the census that produced the bead's `write_scope` missed `polylogue/coordination/envelope.py::_session_tree_payload`, which is reachable from the public MCP `context` surface and was still building its own graph: - Resolved edges were synthesized from `sessions.parent_session_id` + `branch_type` — the exact red condition in AC2. `tests/unit/coordination/test_envelope.py` asserted this as correct: its fixture carried a single `session_links` row, and the two "resolved edges" it expected had **no** canonical row behind them at all. - A private edge mapper flattened an unresolved link's declared `link_type` to a generic `"unresolved_native"` kind, collapsing resolvedness into type (AC4 red). - `cycle_detected=False` was hard-coded, and quarantined/contradicted edges were invisible (AC5 red). - `edges[:limit]` truncated silently, and the compact projection trimmed `nodes[:3]`/`edges[:3]` again — a partial tree was indistinguishable from a whole one (AC6 red). Separately, `compose_session_topology` raised `KeyError` when 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 a `TopologyNodeInput` (`session_id`, `origin`, `title`) so a caller holding raw `sessions` rows reaches it without constructing a `SessionRecord`. - A resolved edge whose parent is out of scope is excluded with the named reason `parent-out-of-scope` instead of crashing or vanishing. - `_session_tree_payload` uses the parent/root columns for **node discovery only** and projects every edge from `session_links`. The target sorts first in discovery so a tight bound can never trim away the session the tree was requested for. - `CoordinationSessionTreeEdgePayload` gains `composable` / `composability_reason`; `CoordinationSessionTreePayload` gains `conflicting_parent_detected`, `nodes_complete`, `edges_complete`, `truncated_node_count`, `truncated_edge_count`, `generation_id`. The compact projection folds its own trim into those fields. - The fixture now carries the canonical link rows production's `write_parsed_session_to_archive` mints, so the existing assertions prove edges come from `session_links`. Two anti-vacuity tests: `test_coordination_tree_edges_come_only_from_session_links` deletes the resolved link rows while leaving `parent_session_id` fully intact — red for any route that synthesizes from the accelerator columns; `test_coordination_tree_reports_its_own_truncation` is red if the completeness fields are dropped or the silent trim returns. ## Verification ``` devtools test tests/unit/coordination/test_envelope.py tests/unit/storage/test_session_topology.py \ tests/unit/storage/test_topology_edges.py tests/unit/api/test_topology_api.py \ tests/unit/daemon/test_topology_endpoint.py tests/unit/daemon/test_topology_stack.py \ tests/unit/mcp/test_envelope_contracts.py tests/unit/storage/test_tree_laws.py \ tests/unit/pipeline/test_branching.py ``` `devtools test: PASSED exit=0 diagnosis=pytest_passed` — 127 passed. `devtools verify --quick` → exit 0. `devtools render all --check` → exit 0, no `out of sync` lines. `devtools gate layering` → `"violations":[],"count":0`. ## Schema closure `devtools schema closure` reports **`out`** for 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-27ezu` scope: - `storage/sqlite/archive_tiers/archive.py::get_session_tree` + `_root_session_id_for_tree` still walk `parent_session_id`/`root_session_id` with no `session_links` read. Public reach: `Polylogue.get_session_tree` (`api/archive.py:7104`), the sync wrapper (`api/sync/sessions.py:168`), and the MCP resource `polylogue://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 incidental `SessionRepository.get_session_tree` call at `tests/unit/pipeline/test_branching.py:423`. Left in place pending an explicit retirement decision. - `derive_session_topology_sync` still describes itself as a test adapter and has no production callers. - `read_archive_session_envelope` still returns a truncated transcript with no completeness flag (#5090's recorded residual). This PR does not touch that path. 🤖 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]>
Sinity
added a commit
that referenced
this pull request
Sep 15, 2026
## 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]>
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
Problem
Solution
Verification
agentctl job start polylogue pytest_focused --workspace <candidate> -- tests/unit/daemon/test_topology_endpoint.py::TestTopologyEndpointDispatch::test_node_limit_clamps_payload_size(job 46: passed).agentctl job start polylogue verify_quick --workspace <candidate>(job 42: all 14 static gates passed before the identical repair was rebased onto current master).