Repository navigation
fix: Decide one topology outcome at the operation boundary - #5063
Conversation
|
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 59 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 (8)
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 |
…ty (#5065) ## Summary `devtools gate patterns` is **red on master**, blocking every PR opened since, including ones that touch neither implicated file. This restores it and makes the baselines honest. ## Problem Two PRs, each green on its own, red once both had landed: - **#5056** (error paths) added `logger = logging.getLogger(__name__)` to `polylogue/sources/retained_acquisition.py` for the ZIP-member-skip warning. - **#5059** (structured logging) recorded the `legacy-stdlib-logger` ratchet baseline at 23 entries. Neither PR's CI ever saw the other's change. After both merged, master scanned 24 matches against a 23-entry baseline, so the gate reported a new match and set `blocking: true`. PRs #5061, #5062, #5063 and #5064 all failed for this inherited reason. Separately, the baselines carried **22 stale entries** whose sites no longer exist — several naming `polylogue/storage/repair.py`, a file deleted some time ago. ## Solution Convert the one blocking site to a structured event, `source.zip.members_refused`. No new allowlist field was needed: `path` and `skipped` are already registered, and the refused-member list rides in `error_detail`, the single existing quarantined field. Prune the 22 stale entries. Pruning **shrinks** the ratchet, which is the permitted direction; adding an entry to silence the gate is the forbidden one. ## Verification ``` devtools gate patterns -> blocking: false, new_matches: 0, stale_matches: 0 ``` Baselines now match the scan exactly in both directions. Before this change the same command reported 1 new match and 22 stale entries. No test asserts on the old warning text, so no test changes were required. ## Note for the ratchet's owner — not addressed here A structural gap surfaced while fixing this. `legacy-stdlib-logger` matches `logging.getLogger(...)`, but the form most of the tree actually uses is the `polylogue.logging.get_logger` wrapper, which the rule does not match. A concurrent conversion of 90 prose sites across `daemon/cli.py` and `daemon/http.py` therefore eliminated **zero** baseline entries — the gate meant to enforce "no legacy logging" is blind to the dominant legacy form. Widening the existing rule would grow its baseline by roughly 140 modules, which the ratchet forbids. The coherent route is a second rule with its own baseline at the true remaining count: a new ratchet may start wherever reality is, while an existing one may only shrink. That is a deliberate decision and belongs in its own change. 🤖 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]>
session_links is the edge authority and one graph engine derives the topology, but no operation boundary turned that answer into a terminal outcome. Every surface re-inferred completeness from the payload shape, so a topology behind a named gap could report a clean scope. SessionTopology.degraded_gaps() names the structural facts the engine already holds -- unresolved parent, edge excluded from composition, missing session, cycle, conflicting parent, truncated page -- as a declared, ordered vocabulary. analysis stays substrate and does not import the terminal-outcome contract. polylogue/operations/topology_envelope.py is the one boundary above the engine: it produces the canonical envelope and decides the one outcome from those gaps, so degraded outranks empty. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
The three public routes disagreed on the same session. HTTP dropped the ancestors/descendants/siblings/thread lists and silently discarded any resolved edge whose parent fell outside the page, so an edge could vanish from the answer without being reported; it also published a second readiness vocabulary instead of the terminal outcome. MCP re-decided the outcome itself with no named gaps. The CLI emitted no outcome at all and could not page topology, because the view registered no options and hard -coded a node limit from the generic --limit param. All three now serialize topology_public_envelope. HTTP keeps readiness as a reader chip only and bounds through the shared helper, so a narrowed page reports truncation instead of claiming completeness. The CLI accepts node_offset/node_limit/edge_limit, which are Click params the lineage view already declares -- no new param is added and no positional shift. Also fixes the MCP topology tool, which raised ValidationError on every real topology: its node model reused the bare session-ref payload, which forbids the is_root field the canonical envelope always emits. No test had passed it a non-None topology. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
Each test names the mutation that turns it red. Verified by reverting the production change, not by assertion: dropping the degraded= argument from topology_outcome, leaving nodes_complete true after bounding, and removing a field from the canonical edge projection each produced a failing run. Covers cross-route key parity, a field-completeness oracle over the public edge envelope, the absence of any provider token on public topology fields, and the outcome decision for complete, unresolved, truncated and cyclic topologies. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
Replace scattered type-ignore comments with typed helpers over the untyped public envelope so the parity assertions type-check. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
980203e to
9b2edc5
Compare
…events (#5072) ## Summary All 34 remaining daemon modules converted to structured events. **Zero legacy loggers remain anywhere in `polylogue/daemon/` outside `cli.py`/`http.py`**, which landed separately in #5067. Ratchet baseline 23 → 20 — exactly the three eliminated. Largest: `judgment_automation` 23 sites, `convergence_stages` 17, `metrics` 12, `status` 11, `embedding_backlog` 11, `write_coordinator` 10, `derivation` 8. A dead logger in `backup.py` was removed outright. ## What this makes legible ``` INFO daemon.stage.executed duration_ms=0.0 outcome=ok path=claude-code/a.jsonl stage=acquire WARNI daemon.stage.execute.degraded attempts=44 calls=40 gaps=2 outcome=degraded path=claude-code/a.jsonl reason=unresolved_workflow_gaps runs=12 stage=claude_workflow WARNI daemon.stage.drained action=batch attempted=3 confirmed=1 debt=1 failed=2 outcome=degraded payload_failures=0 reason=transport_failures rejected=0 remaining=2 transport_failures=2 ``` The old code logged `gaps=2` inside an **INFO** sentence — a degraded stage reported at the same level as a healthy one. And prose collapsed transport failures, payload failures and rejections into a single line; they now have separate counted lanes with a reason naming the dominant one. `convergence_stages.py` carries `make_default_convergence_stages`, the stage list that drives the entire from-scratch rebuild, so this is the module that decides whether a multi-hour build's degradation is visible without reading source. ## `propagate()` — verified, not assumed `BoundedComputeAdapter.__init__` builds the `ThreadPoolExecutor` eagerly and `_run_task` submits a bare closure. Measured with the pool pre-warmed: bare submit → `{}`, wrapped → `{'run_id': 'rebuild01'}`. Added at both `operation_runtime.py` submit sites. ## Fields 46 new, all count/token/identifier/duration/flag; three registered but never emitted were dropped. `error_detail` remains the only `text`-kind field, asserted by its pinning test. One deliberate omission: a failed Apprise `add()` used to interpolate the notification URL with `%r`, and those URLs embed tokens. The **position** is logged instead of the URL. ## Verification ``` devtools test tests/unit/daemon -> PASSED 2233/2233, exit 0 (429s) devtools verify --quick -> exit 0, all 15 gates devtools gate layering -> exit 0 devtools gate patterns -> passed, 20 matches, 0 prunable devtools render all --check -> exit 0, "out of sync" -> 0 ``` The tip was checked before **and** after that run (`3b342d756`, clean both times), because a green belonging to a different tree than the one reported has already bitten this campaign twice today in both directions. The count is 2233 rather than an earlier 2230 because the rebase brought three more daemon tests in with #5063/#5064 — both numbers are real measurements of different trees. Seven tests pinned the old prose through `caplog` or subprocess stderr; each now asserts on the event and its fields and names its anti-vacuity condition. The raw-authority-cache test is strictly stronger than before: it now requires the first pass to report `degraded` with cohorts pending and the second `ok`, a distinction a single INFO line could not express. ## Landing order `polylogue/daemon/write_coordinator.py` and `polylogue/logging_fields.py` are **IN** the derived-schema closure; the other 35 changed files are `out`. The index identity moves, ops does not. **This must land before a from-scratch rebuild starts, never during one** — encountered for real during development, where editing mid-run produced 133 `SchemaSkewError` failures because the seeded-artifact cache keys on `derived_schema_identity`. Note `write_coordinator.py` now carries both #5062's lease-delegation imports and this change's event imports, so both feed the index identity. The interim identity hashes measured during development are superseded by each rebase; only the finally-landed identity is worth recording. 🤖 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
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_payloadraisedValidationErrorfor any non-empty topology: its node model reusedMCPSessionRefPayload, which forbids extras, while the canonical envelope always emitsis_root. This survived because no test ever passed it a non-Nonetopology — it appears in the MCP suite only asAsyncMock(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_envelopediscarded the resolved edge entirely (topology_http.py:128-138) and omittedancestors/descendants/siblings/thread. Same session, materially different answer than CLI or MCP — well past transport framing.3.
outcomeexisted on MCP only, and could never bedegraded.decide_outcome(matched=len(topology.nodes))was called with nodegraded=, so a truncated, cyclic, or unresolved-parent topology reportedok. An orphan session reported a clean scope behind a real gap — the exact thing the terminal-outcome contract exists to prevent. CLI emitted nooutcomeat 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_limitfrom the generic--limit, never passingnode_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.analysisstays 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.pyis the single operation boundary: it builds the canonical envelope and decides the one outcome, sodegradedoutranksempty. CLI, MCP and HTTP all serialize it. HTTP keepsreadinessas a reader chip only and bounds through a shared helper that downgrades honestly.originthroughout; noprovidertoken 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
Anti-vacuity verified by reverting, with four mutants each producing a failing run: dropping
degraded=fromtopology_outcome; leavingnodes_completetrue after bounding; HTTP dropping the four ref lists; removingmethodfrom 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
coordination/envelope.py:2091(builds fromsessions.parent_session_id, the lastunresolved_nativeproducer) andstorage/derived/lineage/compact.py:501(synthesizes edges withmethod="sessions.parent_session_id").evidence_jsonis 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:322iterates edges without checkingcomposable, so it reports quarantined edges as real children.devtools gate atlasexits 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.ai/code/session_01DYUNBGoE652b3nfmq3CtqK