Skip to content

chore: Unify session topology as one complete session_links-owned publi… - #5007

Merged
Sinity merged 2 commits into
masterfrom
batch/polylogue-20260913-051111-55e8790f/integration
Sep 13, 2026
Merged

Sinity merged 2 commits into
masterfrom
batch/polylogue-20260913-051111-55e8790f/integration

Conversation

@Sinity

@Sinity Sinity commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Batch polylogue-20260913-051111-55e8790f on base e0a219b1fe56.

polylogue-27ezu Unify session topology as one complete session_links-owned public read preset

  • 1. One domain graph engine and one declared topology envelope own session topology. API, repository, CLI, MCP, and HTTP contain no independent graph construction or edge-field mapping (red if a route

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-13T05:58:31.827605Z 77c1b0f New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 7df4bbec-b250-4766-919d-b5028e81f1a5


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity force-pushed the batch/polylogue-20260913-051111-55e8790f/integration branch from 5bec743 to 73873fa Compare September 13, 2026 05:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5bec743ada

ℹ️ 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".

Comment thread polylogue/mcp/payloads.py Resolved
Comment thread polylogue/daemon/topology_http.py Resolved
Comment thread polylogue/cli/read_views/lineage.py Resolved
Comment thread polylogue/cli/read_views/lineage.py Resolved
Comment thread polylogue/archive/viewport/profiles.py Resolved
@Sinity
Sinity force-pushed the batch/polylogue-20260913-051111-55e8790f/integration branch 2 times, most recently from c0fca36 to 2f490f9 Compare September 13, 2026 05:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f490f9386

ℹ️ 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".

Comment thread polylogue/api/insights.py Resolved
Comment thread polylogue/daemon/topology_http.py Resolved
Comment thread polylogue/api/insights.py Resolved
Comment thread polylogue/api/insights.py Resolved
…u' into batch/polylogue-20260913-051111-55e8790f/integration
@Sinity
Sinity force-pushed the batch/polylogue-20260913-051111-55e8790f/integration branch from 2f490f9 to 77c1b0f Compare September 13, 2026 05:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 77c1b0fef4

ℹ️ 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".

Comment thread polylogue/daemon/topology_http.py Resolved
Comment thread polylogue/mcp/payloads.py Resolved
Comment thread polylogue/daemon/topology_http.py Resolved
Comment thread polylogue/api/insights.py Resolved
@Sinity
Sinity merged commit 6dd72b0 into master Sep 13, 2026
3 checks passed
@Sinity
Sinity deleted the batch/polylogue-20260913-051111-55e8790f/integration branch September 13, 2026 05:58
Sinity added a commit that referenced this pull request Sep 14, 2026
## Summary

`polylogue-27ezu`'s core unification landed earlier as PR #5007 and the
bead was left open as a verification gate. Auditing the acceptance
criteria against HEAD found four real divergences rather than a clean
gate. This fixes them.

## Problem — concrete divergences

**1. The MCP topology tool was broken outright on every real input.**
`session_topology_payload` raised `ValidationError` for *any* non-empty
topology: its node model reused `MCPSessionRefPayload`, which forbids
extras, while the canonical envelope always emits `is_root`. This
survived because no test ever passed it a non-`None` topology — it
appears in the MCP suite only as `AsyncMock(return_value=None)`. A
parity test hit it on the first run.

**2. HTTP silently dropped edges and four reference lists.** For a
session whose parent fell outside the page, `build_topology_envelope`
discarded the resolved edge entirely (`topology_http.py:128-138`) and
omitted `ancestors`/`descendants`/`siblings`/`thread`. Same session,
materially different answer than CLI or MCP — well past transport
framing.

**3. `outcome` existed on MCP only, and could never be `degraded`.**
`decide_outcome(matched=len(topology.nodes))` was called with no
`degraded=`, so a truncated, cyclic, or unresolved-parent topology
reported `ok`. An orphan session reported a clean scope behind a real
gap — the exact thing the terminal-outcome contract exists to prevent.
CLI emitted no `outcome` at all, and HTTP published a second vocabulary
(`readiness: ok/partial/empty`) outside `{ok, empty, degraded, error}`.

**4. CLI could not page topology** — the view registered no options and
hard-coded `node_limit` from the generic `--limit`, never passing
`node_offset`, while MCP and HTTP both could page.

## Solution

`SessionTopology.degraded_gaps()` names the structural facts the engine
already holds as a declared, ordered vocabulary. `analysis` stays
substrate and does **not** import the terminal-outcome contract — that
would have grown the layering baseline, which may only shrink.

New `polylogue/operations/topology_envelope.py` is the single operation
boundary: it builds the canonical envelope and decides the one outcome,
so `degraded` outranks `empty`. CLI, MCP and HTTP all serialize it. HTTP
keeps `readiness` as a reader chip only and bounds through a shared
helper that downgrades honestly. `origin` throughout; no `provider`
token on any public topology field.

Pagination uses `node_offset`/`node_limit`/`edge_limit` — Click params
the lineage view **already declares**, so no new param is added and
there is no positional shift to reason about.

## Verification

```
devtools test <10 topology files>   # 96/96 passed, exit 0
devtools verify --quick             # exit 0, 15/15 gates, mypy clean
devtools render all --check         # exit 0, no "out of sync"
```

Anti-vacuity verified by reverting, with four mutants each producing a
failing run: dropping `degraded=` from `topology_outcome`; leaving
`nodes_complete` true after bounding; HTTP dropping the four ref lists;
removing `method` from the canonical edge projection.

**Schema closure: no impact.** All seven changed files report `out`, so
nothing here forces reconvergence — which matters with a from-scratch
rebuild imminent.

## Residuals — the bead should stay open

- **Cancellation was not cross-checked.** There is no cancellation
handling in the topology derivation path and no topology cancellation
test, at HEAD or now. This change adds no new await points (both new
functions are pure and synchronous over an already-materialized
topology), so semantics are unchanged — but that is not a verification,
and it is not claimed as one.
- **AC1 is not green repo-wide.** Two other graph engines survive on
public routes, both outside this write scope:
`coordination/envelope.py:2091` (builds from
`sessions.parent_session_id`, the last `unresolved_native` producer) and
`storage/derived/lineage/compact.py:501` (synthesizes edges with
`method="sessions.parent_session_id"`).
- **AC3 open:** `evidence_json` is decoded but inlined raw and unbounded
into every public envelope; the design wants a bounded sanitized summary
with raw evidence behind an explicit projection.
- `orchestration_evidence.py:322` iterates edges without checking
`composable`, so it reports quarantined edges as real children.
- Excluded edges to an unreached child are dropped from the envelope
rather than staying visible as evidence.
- AC9's corpus-wide classification census is still unevidenced.

`devtools gate atlas` exits 1, but **identically on the clean base** —
every stale section is a blob/storage file this branch never touches,
with zero citations of any changed file.

🤖 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 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]>
Sinity added a commit that referenced this pull request Sep 22, 2026
The writer admits a parent chain up to `_CYCLE_WALK_BUDGET` (1024), but the
topology classifier walked it with a recursive depth-first search, so a lineage
the writer accepted raised `RecursionError` when any topology read classified
it. Because the classifier runs over every link in scope, reading an unrelated
session in the same scope failed with it.

The traversal now carries its own stack. It is the same walk frame for frame: a
node enters `visiting` on push and moves to `visited` on pop, a child
already in `visiting` marks the whole current ancestry, and roots are still
taken in sorted order.

Executed anti-vacuity at 9f450db: `compose_session_topology` over a
1100-session accepted lineage raises `RecursionError: maximum recursion depth
exceeded`; with the iterative walk it returns 1100 nodes and quarantines no
edge. 3000 random graphs produce identical cycle sets under both
implementations, and a real 3-cycle is still quarantined. Raised by PR #5007
review.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

(cherry picked from commit a65dca5)
Sinity added a commit that referenced this pull request Sep 22, 2026
The writer admits a parent chain up to `_CYCLE_WALK_BUDGET` (1024), but the
topology classifier walked it with a recursive depth-first search, so a lineage
the writer accepted raised `RecursionError` when any topology read classified
it. Because the classifier runs over every link in scope, reading an unrelated
session in the same scope failed with it.

The traversal now carries its own stack. It is the same walk frame for frame: a
node enters `visiting` on push and moves to `visited` on pop, a child
already in `visiting` marks the whole current ancestry, and roots are still
taken in sorted order.

Executed anti-vacuity at 9f450db: `compose_session_topology` over a
1100-session accepted lineage raises `RecursionError: maximum recursion depth
exceeded`; with the iterative walk it returns 1100 nodes and quarantines no
edge. 3000 random graphs produce identical cycle sets under both
implementations, and a real 3-cycle is still quarantined. Raised by PR #5007
review.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

(cherry picked from commit a65dca5)
Sinity added a commit that referenced this pull request Sep 29, 2026
…#5785)

## Summary

This PR salvages ChatGPT fleet worker 12's Codex-debt batch (beads
`polylogue-1tyq5.55`, `.56`, `.60`, `.62`; 72 findings) and turns it
into verified changes. Five fixes land with regression tests that fail
on master. The worker's sixth fix (a negative completion cache) was
dropped, and its health-check fix was replaced with a stricter version.

## Problem

- **55.05** `health_check()` raises `SchemaSkew` when a tier is on
another version. The tier probe opened the file with schema admission
but caught only `sqlite3.Error`, so the probe crashed instead of
reporting an error check.
- **55.10** `list_assertion_candidate_reviews(limit=10)` computed
`total` with a second, unbounded review read. That read ran the
per-candidate judgment lookup (N+1) across the whole candidate history.
- **60.01** `--stream --limit N` followed continuations with no limit.
The final page could therefore fetch rows past N, and the resulting
`result_too_large` refusal was re-raised for continuations instead of
narrowing the page.
- **60.20** `raw-authority-frontier` printed the all-state `plan_count`
as `obligations=`, including terminal `superseded` plans.
- **62.01** Named `analyze postmortem|portfolio|cost-outlook` computed
the inherited root format but rendered from the local `None` format, so
they printed text when JSON was requested.

## Solution

- `_archive_tier_readiness_check` keeps admission, passes `tier=`, and
reports any `SchemaRefusalError` as an ERROR check. The worker's
`validate_schema=False` version was replaced because it compared only
`user_version`, so a derived tier with a stale identity at the right
version was reported OK.
`test_health_check_reports_derived_identity_skew` fails on the worker's
version.
- `_archive_list_assertion_candidate_reviews` returns `(page, count)`
from one read transaction. The count comes from
`count_assertion_claims`, which now accepts `target_ref` and
`statuses=None`. The count includes expired claims, matching the review
read model.
- `_read_session_windows` sends the remaining bound with every
continuation. An oversized resumed page halves in place, and later pages
keep the narrowed bound, because `session.read` refuses a continuation
that widens its window.
- The plain frontier line says `plans=` (the neutral label the finding
offered).
- `analyze_verb` renders every branch from the effective format: the
local format if given, otherwise the root format, normalized with
`normalize_output_dialect`. An explicit local `--format` still wins.
- **62.16 dropped.** The deleted-candidate case was already fixed on
master in 8cb1133 (#5722): each successful answer, empty or not,
removes the cached matches for the refreshed prefix. The worker added a
cache of empty answers that offline completion would treat as
authoritative. Nothing invalidated it except a later contradicting
daemon answer or the 24h TTL, and an offline reader cannot tell whether
the archive changed without opening it. The cold-cache message on a miss
is displayed rather than inserted, and it is accurate.
- Two stale tests in `test_archive_query.py` expected `_emit_stats` to
exit 0 over a converging archive. #5700 made that outcome degraded with
a nonzero exit, so the tests now expect that. They failed on master
before this PR.

## Verification

- `agentctl job start polylogue verify_quick --workspace
/realm/worktrees/salvage-w12 --wait` → job 2374: `verify: PASSED exit=0`
(head 331a204ddd, pre-rebase; the rebase onto 4501f13 touched none of
these files). Earlier job 2368 failed on format and mypy in the worker's
commit; commit 3561647 fixes both.
- `agentctl job start polylogue pytest_focused --workspace
/realm/worktrees/salvage-w12 --wait --
tests/unit/api/test_archive_health_tier_skew.py
tests/unit/api/test_assertion_candidate_review_count.py
tests/unit/cli/test_analyze_named_projection_format.py
tests/unit/cli/test_raw_authority_frontier_output.py
tests/unit/cli/test_session_window_continuation_bounds.py
tests/unit/cli/test_analyze_projections.py
tests/unit/cli/test_archive_query.py
tests/unit/cli/test_completion_daemon_boundary.py
tests/unit/api/test_assertion_candidate_queue_health.py` → job 2405 at
head 3561647: `devtools test: PASSED exit=0 diagnosis=pytest_passed`,
168 passed.
- Anti-vacuity: the new tests were run on an origin/master checkout (job
2351). Every fix test failed there (11 failures, plus the 2 stale stats
tests). The one exception is
`test_named_analysis_local_format_overrides_inherited_json`, a
precedence guard that should pass on both. Job 2355 ran the health tests
against the worker's `validate_schema=False` variant, and the
derived-identity case failed (status OK instead of ERROR).
- Inherited, not addressed here:
`tests/unit/api/test_facade_contracts.py::test_archive_facet_buckets_count_unique_sessions_for_duplicate_hits`
and `::test_no_undiscovered_async_methods` fail identically on master
4501f13 (job 2401).

## Self-review

- **Sibling sites.** The review count had one caller, and `judge.py`
consumes the facade's `total`. The daemon health endpoint has its own
tier checks and is out of scope. The other `validate_schema=False` opens
are reset, paths and export tools, not health reporting.
- **Cancellation and loops.** The window retry loop is bounded by
halving to 1 and then re-raising. No new loop reads without a bound.
- **Unbounded reads.** This PR removes one, the unbounded review read,
and adds none.
- **Fail-open fallbacks.** The health probe now reports refusals instead
of hiding them. The dropped completion change would have turned a cache
miss into an authoritative empty answer.
- **Compatibility shims.** None. `count_assertion_claims` gained
optional parameters, and its existing `annotations/join.py` callers are
unchanged.
- **Removed symbols.** No production symbol was removed. The
`test_codex_debt_w12.py` files were renamed by behaviour.
- **Production route.** The API tests go through
`Polylogue.health_check` and `list_assertion_candidate_reviews` on
bootstrapped archives. The CLI tests go through `cli` or the real
command with a mocked transport (`dispatch_read`) and the real
`lower_session_read`.

## Derived-identity closure

`polylogue/storage/sqlite/archive_tiers/user_write.py` is a member of
`docs/plans/schema-closure-baseline.json`, so this PR moves the
candidate derived identity. Closure membership does not grow (the
`schema-closure` gate passed). No other changed production file is a
member.

## Per-finding dispositions

Counts: 5 fixed, 60 fixed-already, 2 stale, 1 refuted, 4 not reached.
The not-reached findings (55.18, 55.22, 60.12, 62.08) stay open on their
beads.

| key | disposition | evidence | test |
| --- | --- | --- | --- |
| 55.01 #4326 `polylogue/api/__init__.py:51` | refuted |
`polylogue/api/parity.py:472–491`: The explicit context-pack exclusion
includes topic_pack; composed builders do not own a separate operation
identity under this contract. | — |
| 55.02 #5381 `polylogue/api/archive.py:410` | fixed-already |
`polylogue/api/archive.py::_read_session_transcript_page`: The
normalized offset is used for both the read and returned page
coordinates. | — |
| 55.03 #4287 `polylogue/api/archive.py:818` | fixed-already |
`polylogue/api/archive.py::_archive_list_summaries_with_post_filters`:
Effective specification pagination is restored after content filtering.
| — |
| 55.04 #4295 `polylogue/api/archive.py:871` | fixed-already |
`polylogue/api/archive.py::_archive_aggregate_facet_families / keyed`:
Repeated facet bucket counts are added across chunks rather than
overwritten. | — |
| 55.05 #4871 `polylogue/api/archive.py:1114` | fixed |
`_archive_tier_readiness_check` keeps admission and reports
`SchemaRefusalError` as ERROR | `api/test_archive_health_tier_skew.py` |
| 55.06 #4192 `polylogue/api/archive.py:1152` | fixed-already |
`polylogue/api/archive.py::_archive_list_assertion_claims`: Uses
_readable_user_tier rather than an index-backed query runner. | — |
| 55.07 #4794 `polylogue/api/archive.py:1546` | fixed-already |
`polylogue/storage/sqlite/connection_profile.py::_install_progress_handler`:
Read frames install an expiry/cancellation-aware SQLite progress
handler, including work using the bound connection. | — |
| 55.08 #4552 `polylogue/api/archive.py:1691` | fixed-already |
`polylogue/api/archive.py::_archive_list_assertion_candidates`: Calls
the canonical actionable queue reader rather than the expiry-retaining
review reader. | — |
| 55.09 #4295 `polylogue/api/archive.py:3066` | fixed-already |
`polylogue/api/archive.py::pathology_report`: replace(spec, limit=None,
offset=0) removes query pagination from the scope denominator. | — |
| 55.10 #4295 `polylogue/api/archive.py:3448` | fixed | one read
transaction; scalar `count_assertion_claims` replaces the second
unbounded review read | `api/test_assertion_candidate_review_count.py` |
| 55.11 #4552 `polylogue/api/archive.py:3453` | fixed-already |
`polylogue/api/archive.py::_readable_user_tier`: Missing/non-file and
unreadable durable-tier failures retain typed unavailability rather than
returning an empty list. | — |
| 55.12 #4295 `polylogue/api/archive.py:3503` | fixed-already |
`polylogue/cli/commands/judge.py::judge_command`: Preserves
authoritative review totals; additional client-side time filtering reads
the complete selection before recounting. | — |
| 55.13 #5302 `polylogue/api/archive.py:4021` | fixed-already |
`polylogue/operations/facade_writers.py::record_manual_continuation_product`:
Invokes _resolve_session_graph before committing the manual link,
refreshing topology projections. | — |
| 55.14 #5302 `polylogue/api/archive.py:4021` | fixed-already |
`polylogue/operations/facade_writers.py::record_manual_continuation_product`:
Invokes the canonical cycle/quarantine pass instead of leaving the
direct insert unchecked. | — |
| 55.15 #4180 `polylogue/api/archive.py:5081` | fixed-already |
`polylogue/api/archive.py::search_session_hits`: Passes unresolved
spec.to_plan() to failure-classifying search_hits_for_plan. | — |
| 55.16 #4180 `polylogue/api/archive.py:5512` | fixed-already |
`polylogue/api/archive.py::filter`: Constructs SessionFilter without
vector-provider initialization. | — |
| 55.17 #5362 `polylogue/api/archive.py:5557` | fixed-already |
`polylogue/api/archive.py::query_sessions`: Includes
title_is_synthesized from display_label_source. | — |
| 55.18 #5370 `polylogue/api/archive.py:5561` | not reached |
`polylogue/api/archive.py::read_transcript_window`: Anchor lookup and
transcript-window reading still have separate read lifetimes.
Single-snapshot implementation remains necessary; no fix written. | — |
| 55.19 #5370 `polylogue/api/archive.py:5563` | fixed-already |
`polylogue/api/archive.py::read_transcript_window`: Explicitly rejects
around combined with transcript filters. | — |
| 55.20 #4357 `polylogue/api/archive.py:6330` | fixed-already |
`polylogue/api/archive.py::get_effective_context`: Canonical ID
resolution plus read_summary replaces full transcript hydration for the
existence check. | — |
| 55.21 #4261 `polylogue/api/insights.py:753` | fixed-already |
`polylogue/api/insights.py::cost_outlook`: Restricts the cost query to
the selected cycle's since/until rather than the whole archive. | — |
| 55.22 #5007 `polylogue/api/insights.py:916` | not reached |
`polylogue/api/insights.py::get_ancestors/get_descendants/get_siblings/get_thread/get_logical_session`:
Exhaustive relationship helpers still consume the default topology page
without exhaustion. No implementation written. | — |
| 55.23 #5007 `polylogue/api/insights.py:927` | fixed-already |
`polylogue/api/insights.py::_resolve_for_topology`: Uses canonical
archive resolve_session_id, preserving native-ID resolution. | — |
| 55.24 #4799 `polylogue/api/insights.py:1030` | fixed-already |
`polylogue/api/insights.py::compact_lineage`: Both public page defaults
use DEFAULT_LINEAGE_PAGE_LIMIT. | — |
| 55.25 #4539 `polylogue/api/search_envelope_builder.py:138` |
fixed-already |
`polylogue/api/search_envelope_builder.py::build_search_envelope_for_spec;
polylogue/operations/authority.py::authority_for_config`: The envelope
delegates authority resolution to the owner that resolves the active
archive root. | — |
| 56.01 #4603 `polylogue/api/search_envelope_builder.py:148` |
fixed-already |
`polylogue/api/search_envelope_builder.py::build_search_envelope_for_spec`:
Reports matched=total and analyzed=len(hits). | — |
| 60.01 #5337 `polylogue/cli/archive_query.py:360` | fixed |
continuations carry the remaining bound; resumed pages halve in place,
never widen | `cli/test_session_window_continuation_bounds.py` |
| 60.02 #4402 `polylogue/cli/archive_query.py:390` | fixed-already |
`polylogue/surfaces/cursor_identity.py::search_cursor_request_identity`:
Presentation-only parameters are excluded from cursor identity. | — |
| 60.03 #4987 `polylogue/cli/archive_query.py:1913` | fixed-already |
`polylogue/cli/render/rows.py::project_payload`: Outcome is preserved
independently of selected result fields. | — |
| 60.04 #5249 `polylogue/cli/click_app.py:479` | fixed-already |
`polylogue/cli/query_contracts.py::QueryOutputSpec.from_params`:
Explicit file destination and path retain typed FILE identity even for
reserved-looking filenames. | — |
| 60.05 #4337 `polylogue/cli/click_app.py:554` | fixed-already |
`polylogue/cli/query_group.py::_asks_for_query_workflow_help`: The
advertised find help route is handled while respecting option arity. | —
|
| 60.06 #4340 `polylogue/cli/click_app.py:628` | fixed-already |
`polylogue/cli/click_app.py::main`: Runtime checks run inside
guarded_entry passed to run_machine_entry. | — |
| 60.07 #4651 `polylogue/cli/click_command_registration.py:192` |
fixed-already | `polylogue/cli/commands/insights_alias.py`: The existing
root group exposes only Fable, not the entire operational group. No
alias is introduced by this batch. | — |
| 60.08 #4580 `polylogue/cli/click_command_registration.py:192` |
fixed-already | `polylogue/cli/commands/insights_alias.py`: The existing
narrow route preserves the promised Fable-packet command. No alias is
introduced by this batch. | — |
| 60.09 #4550 `polylogue/cli/click_command_registration.py:192` |
fixed-already |
`polylogue/cli/commands/insights_alias.py::_register_fable_packet`:
Registers only the intended Fable command rather than the entire
operational group. | — |
| 60.10 #4698 `polylogue/cli/commands/check.py:41` | fixed-already |
`polylogue/scenarios/operational_surfaces.py`: Authored doctor scenarios
use current routes without the retired repair flags. | — |
| 60.11 #5349 `polylogue/cli/commands/diagnostics.py:992` |
fixed-already |
`polylogue/cli/commands/diagnostics.py::latency_command`: The
empty-bucket branch still renders incomplete-drop accounting. | — |
| 60.12 #5639 `polylogue/cli/commands/import_command.py:117` | not
reached |
`polylogue/cli/commands/import_command.py::_wait_for_demo_ingest`: Owner
completion accounting improved, but a degraded receipt still causes
immediate failure instead of waiting through the remaining convergence
budget. No implementation written. | — |
| 60.13 #5314 `polylogue/cli/commands/insights.py:147` | fixed-already |
`polylogue/scenarios/insight_surfaces.py;
tests/unit/cli/test_stdout_stderr_split.py`: Inventories use current
rather than retired commands. | — |
| 60.14 #4678 `polylogue/cli/commands/insights.py:224` | fixed-already |
`polylogue/cli/commands/insights.py::_render_status_plain`: Plain output
includes degraded counts and fallback reasons. | — |
| 60.15 #4292 `polylogue/cli/commands/insights.py:450` | fixed-already |
`polylogue/cli/commands/insights.py::_packet_json_document`: Dataclass
tuples are lowered to JSON-native arrays. | — |
| 60.16 #5311 `polylogue/cli/commands/judge.py:417` | fixed-already |
`polylogue/cli/commands/judge.py::judge_command`: Interactive approval
forwards the evidence digest and checks failed counts before printing
success. | — |
| 60.17 #4133 `polylogue/cli/commands/maintenance/_blob_gc.py:81` |
fixed-already |
`polylogue/cli/commands/maintenance/_blob_gc.py::blob_gc_command`:
Blocked previews set ok=false and exit nonzero in both formats. | — |
| 60.18 #4955 `polylogue/cli/commands/maintenance/_blob_gc.py:211` |
stale | `polylogue/cli/commands/maintenance/_blob_gc.py`:
gc_recover_command is gone; the remaining command is preview-only. | — |
| 60.19 #5345 `polylogue/cli/commands/maintenance/_blob_integrity.py:52`
| stale | `polylogue/cli/commands/maintenance/_blob_integrity.py`:
_submit_replace_from_source and its cited relative-output forwarding
route are gone. | — |
| 60.20 #5350 `polylogue/cli/commands/maintenance/_raw_identity.py:47` |
fixed | plain line labels the all-state count `plans=` |
`cli/test_raw_authority_frontier_output.py` |
| 60.21 #5301 `polylogue/cli/commands/maintenance/_raw_identity.py:59` |
fixed-already |
`polylogue/cli/commands/maintenance/_raw_identity.py::raw_authority_blockers_command`:
Paginated public blocker inspection exposes expected/observed evidence.
| — |
| 60.22 #4955 `polylogue/cli/commands/maintenance/_raw_identity.py:247`
| fixed-already |
`polylogue/cli/commands/maintenance/_raw_identity.py::raw_authority_blocker_resolve_command`:
Checks the affected count rather than presenting no-op resolution as an
applied mutation. | — |
| 60.23 #4824 `polylogue/cli/commands/maintenance/_verify_archive.py:85`
| fixed-already |
`polylogue/cli/commands/maintenance/_verify_archive.py::verify_archive_command`:
Source-frontier construction is conditional on selected
source-conservation work. | — |
| 60.24 #5491 `polylogue/cli/commands/paths.py:75` | fixed-already |
`polylogue/cli/commands/paths.py::_raw_materialization_readiness`:
Propagates the selected index path through
archive_debt_list(index_db_path=...). | — |
| 60.25 #5353 `polylogue/cli/commands/status.py:342` | fixed-already |
`polylogue/operations/daemon_status.py::produce_operation_status`:
Merges runtime collection metadata into pinned readiness components. | —
|
| 62.01 #5422 `polylogue/cli/query_verbs.py:2434` | fixed |
`analyze_verb` renders from the effective (normalized, inherited) format
| `cli/test_analyze_named_projection_format.py` |
| 62.02 #5007 `polylogue/cli/read_views/lineage.py:78` | fixed-already |
`polylogue/cli/read_views/lineage.py`: The replacement operation-backed
route uses the resolved target; the old _run path is gone. | — |
| 62.03 #5407 `polylogue/cli/read_views/messages.py:226` | fixed-already
| `polylogue/cli/read_views/messages.py::_write_messages_file`: Resolves
symlink output before choosing the staging sibling. | — |
| 62.04 #5407 `polylogue/cli/read_views/messages.py:227` | fixed-already
| `polylogue/cli/read_views/messages.py::_write_messages_file`: Flushes
and fsyncs the staged descriptor before replacement and synchronizes the
directory. | — |
| 62.05 #4291 `polylogue/cli/read_views/query_set.py:196` |
fixed-already |
`polylogue/cli/read_views/correlation.py::run_read_correlation`: Renders
a string and delivers it through deliver_content instead of an
uncaptured console-only renderer. | — |
| 62.06 #5374 `polylogue/cli/read_views/session_evidence.py:180` |
fixed-already |
`polylogue/cli/read_views/session_evidence.py::_read_evidence_window`:
Projection body coordinates take precedence before operation lowering. |
— |
| 62.07 #5520 `polylogue/cli/read_views/standard.py:99` | fixed-already
| `polylogue/cli/query_output.py::deliver_query_output`: File delivery
retains secret-candidate scanning. | — |
| 62.08 #5520 `polylogue/cli/read_views/standard.py:99` | not reached |
`polylogue/cli/read_views/standard.py::run_read_summary_or_transcript;
polylogue/cli/archive_query.py::_read_session_windows`: The standard
file path still accumulates the transcript and buffers its rendered
document. End-to-end operation-backed streaming is not implemented. | —
|
| 62.09 #5520 `polylogue/cli/read_views/standard.py:99` | fixed-already
|
`polylogue/cli/read_views/standard.py::run_read_summary_or_transcript`:
Forwards a typed FILE QueryDeliveryTarget, preserving reserved-looking
filenames. | — |
| 62.10 #5520 `polylogue/cli/read_views/standard.py:99` | fixed-already
| `polylogue/operations/daemon_reads.py::_session_identity_projection;
polylogue/cli/archive_query.py::_session_message_text`: The operation
preserves tool_input; rendering includes structured tool input and omits
reasoning blocks. | — |
| 62.11 #5520 `polylogue/cli/read_views/standard.py:99` | fixed-already
| `polylogue/cli/archive_query.py::_read_session_windows`: Initial
oversized pages already halve their bound at the inspected base. This
batch additionally fixes resumed-page narrowing under 60.01. | — |
| 62.12 #5266 `polylogue/cli/session_rows.py:141` | fixed-already |
`polylogue/cli/session_rows.py::_query_page_with_authority`: Synthetic
missing-session selections explicitly include next_offset=None. | — |
| 62.13 #5426 `polylogue/cli/shared/machine_errors.py:233` |
fixed-already |
`polylogue/cli/shared/machine_errors.py::error_archive_writer_ownership`:
Undecidable ownership has a separate remedy that does not assert an
observed resident daemon. | — |
| 62.14 #5426 `polylogue/cli/shared/machine_errors.py:285` |
fixed-already |
`polylogue/cli/shared/machine_errors.py::extract_command`: Recognizes
--output-format as a value-bearing option. | — |
| 62.15 #5545 `polylogue/cli/shell_completion_values.py:117` |
fixed-already |
`polylogue/cli/shell_completion_values.py::_cached_value_matches`:
Session IDs match native-ID and title substrings. | — |
| 62.16 #5545 `polylogue/cli/shell_completion_values.py:135` |
fixed-already | deleted-candidate case fixed by 8cb1133 (#5722):
every successful answer prunes the refreshed prefix; negative-answer
cache declined (see Solution) | — |
| 62.17 #5545 `polylogue/cli/shell_completion_values.py:145` |
fixed-already |
`polylogue/cli/shell_completion_values.py::_remember_completion_values`:
A per-archive map retains more than the most recent archive. | — |
| 62.18 #5545 `polylogue/cli/shell_completion_values.py:157` |
fixed-already |
`polylogue/cli/shell_completion_values.py::_remember_completion_values`:
Removes an existing value before reinsertion at the retention tail. | —
|
| 62.19 #5545 `polylogue/cli/shell_completion_values.py:178` |
fixed-already |
`polylogue/cli/shell_completion_values.py::_remember_completion_values`:
Global serialized-byte eviction precedes publication. This batch
includes new empty observations in that accounting. | — |
| 62.20 #5545 `polylogue/cli/shell_completion_values.py:181` |
fixed-already |
`polylogue/cli/shell_completion_values.py::_remember_completion_values`:
flock serializes the full cache read-modify-write sequence. | — |
| 62.21 #5382 `polylogue/cli/write_authority.py:104` | fixed-already |
`polylogue/storage/sqlite/write_lease.py::arm_write_lease_enforcement`:
Locked process-wide user/suppressor counts make arming overlap-safe. | —
|

## Residuals

- The four not-reached findings remain open.
- Changing `user_write.py` moves the derived identity, so this PR has to
land before a rebuild starts.
- The two `test_facade_contracts.py` failures are inherited from master.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

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.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 64a9bd0):

  • P1 polylogue/daemon/topology_http.py:153: Fixed on master (checked at 64a9bd0): truncated_count is at least 1 whenever nodes_complete is false (polylogue/daemon/topology_http.py:134), and _readiness returns partial for any truncation (polylogue/daemon/topology_http.py:102).

Resolving every thread listed; confirmed defects are fixed under the named bead.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

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.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at f88b4a6):

  • P1 polylogue/mcp/payloads.py:641: Fixed on master (checked at f88b4a6): The shared envelope decides the outcome with the topology's gaps (polylogue/operations/topology_envelope.py:72), and bounding marks an incomplete source or dropped nodes as truncated and re-decides the outcome (topology_envelope.py:107-108).

Resolving every thread listed; confirmed defects are fixed under the named bead.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 5d56c3a):

Resolving every thread listed; confirmed defects are fixed under the named bead.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 5ebcfe5):

Resolving every thread listed; confirmed defects are fixed under the named bead.

@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 68.F009 / P1: fixed-already at the checked revision: polylogue/mcp/payloads.py:359 declares is_root on MCPTopologyNodePayload, and line 403 types topology.nodes as that node model rather than MCPSessionRefPayload. The public node field therefore passes the closed MCP topology validator.

Only the rows listed above are dispositioned. Held findings remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant