Skip to content

chore: Gate repair-shaped declarations against the routes that exist - #5061

Merged
Sinity merged 4 commits into
masterfrom
work/repair-concept
Sep 14, 2026
Merged

Sinity merged 4 commits into
masterfrom
work/repair-concept

Conversation

@Sinity

@Sinity Sinity commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Summary

The repair-as-product implementation program was already complete at master. What remained was declarative residue, and every instance shared one root cause: a declaration describing a route the code no longer has, with no gate resolving the declaration against the real route. This removes the residue and adds the missing gates.

Problem

storage/repair.py (7,534 lines) is gone, FtsSurfaceRepairResult / repair_fts_surface have no definitions anywhere in the tree, and the raw census scanner was retired through successor 3sd53. The bead's own 2026-09-13 note reclassifies it as a verification-only gate.

But the declarations outlived the code:

  • Three scenario families still compiled ops doctor --repair [--cleanup] [--target ...]. Those flags were deleted from check_options.py. The declarations were reachable only from their own unit test — which asserted the exact dead argument vectors, so the test proved the declarations matched themselves.
  • The agent-manual maintenance tool contract advertised a generic "preview, authorize, execute, reconcile administrative maintenance" umbrella with ten phantom arguments, and a typed operation="preview", targets=["index"] example that the live 5-argument, 3-operation handler rejects.
  • status_diagnostics.py told an operator facing a locked database to run polylogue ops doctor --repair, which fails on paste.
  • doctor's short help promised "health checks and repairs" for a read-only report.
  • Three OperationSpecs declared a repair surface token nothing consumes.

Solution

Delete the dead declarations, align the tool contract to the live signature, and add four gates so the class cannot recur:

  1. ops doctor surface families resolved through the production Click app.
  2. Generated tool contracts checked against live MCP signatures. This logic previously existed only inside a lane gated behind --require-live, which is exactly why the manual rotted; it now runs unconditionally. It immediately caught two unrelated pre-existing drifts — query.session_operation and context.offset were live but undocumented. Both are now documented.
  3. Literal next_action recommendations resolved through the Click app.
  4. No operation may declare a repair surface.

Verification

Each gate confirmed red by reintroducing the exact defect and then restoring: reinstating the --repair family, adding phantom targets/dry_run, restoring the --repair recommendation, re-adding the surface token.

devtools test <four affected contracts, individually and combined>   # PASSED
devtools verify --quick                                             # 15/15 gates ok
devtools render all --check                                         # sync OK

render agent-manual and render cli-reference regenerated and committed.

Landing order

polylogue/operations/specs.py is IN the derived-schema closure, so that commit moves the identity and must land before a fresh rebuild starts, never during one. It is deliberately isolated in its own commit so it can be dropped if a rebuild has already begun. The other five changed files are out.

Deliberately kept

maintenance/raw_authority.py plus raw_convergence.py/raw_reconciler.py (5,533 lines) are typed, named, campaign-scoped historical incident actuators — apply_frontier refuses without the daemon writer lease. They are polylogue-6kur.4's scope, not this one's, and need a named deletion trigger tied to source sealing.

The FTS repair_message_fts_* and lineage_startup.repair_stale_prefix_branch_points routes are already canonical derivations running through write-effects and daemon startup. Renaming them is pure vocabulary across storage internals that are IN the schema closure — identity movement for zero behavioral value, and a partial rename is worse than none.

Residuals

devtools gate atlas fails — identically at the base commit, on inherited staleness in docs/atlas/storage.md over blob_gc.py, blob_liveness.py, bootstrap.py and archive_tiers_specs.py, none of which this branch touches. Reported rather than masked.

6kur.3's remaining acceptance criteria are integration acceptance, not implementation: broad verification, replay/incremental equivalence, restart/fault evidence, and an archive-scale workload. Those need the full suite and a managed archive-scale run, and are not claimed here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 4ed17e97-104a-45fa-83ac-704e57c167b5

📥 Commits

Reviewing files that changed from the base of the PR and between 4daf176 and 6f16efc.

📒 Files selected for processing (14)
  • docs/agent-integration-reference.md
  • docs/cli-reference.md
  • polylogue/agent_integration/data/deep-reference.md
  • polylogue/agent_integration/data/tool-contracts.json
  • polylogue/agent_integration/spec.py
  • polylogue/cli/click_command_registration.py
  • polylogue/cli/commands/status_diagnostics.py
  • polylogue/mcp/declarations/registry.py
  • polylogue/operations/specs.py
  • polylogue/scenarios/operational_surfaces.py
  • tests/unit/agent_integration/test_manual_contract.py
  • tests/unit/cli/test_status_diagnostics.py
  • tests/unit/operations/test_specs.py
  • tests/unit/scenarios/test_operational_surfaces.py

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 added a commit that referenced this pull request Sep 14, 2026
…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]>
Sinity and others added 4 commits September 14, 2026 12:38
`polylogue ops doctor` is a read-only report; `--repair`, `--cleanup` and
`--target` were removed from it, but three declared CLI surface families
still compiled those flags and a unit test asserted the exact argument
vectors. Nothing resolved the declarations against the real Click app, so
the dead repair product survived as a certified surface.

Delete the three families and replace the assertions with a test that
resolves every declared `ops doctor` family through the production Click
app and rejects any option the command does not declare.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
…rella

The generated agent manual described the privileged `maintenance` tool as a
generic "preview, authorize, execute, inspect, and reconcile administrative
maintenance" product with ten arguments the live handler never accepted
(targets, dry_run, session_ids, origin, source_family, source_root, since,
until, failure_kind, parser_version) and a typed `operation="preview"`
example the tool rejects. The real tool takes one of rebuild_insights,
recovery_status or recovery_adjudicate.

The only signature comparison lived in a lane gated behind --require-live,
so the drift was never checked. Promote that comparison into an always-run
contract test; it also caught two unrelated live-but-undocumented
arguments, `query.session_operation` and `context.offset`, now documented.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
The locked-database diagnostic told operators to run `polylogue ops doctor
--repair`, and the doctor command's short help promised it ran "health
checks and repairs". Both options were deleted; the command is a read-only
report, so the advice fails on paste and the generic repair product
survived as operator-facing text.

Add a test that resolves every literal `next_action` recommendation through
the production Click app and rejects options the resolved command does not
declare.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
Three operation specs still declared a `repair` surface (and one described
itself as repairing FTS rows) after the generic repair product was deleted.
Nothing consumes `OperationSpec.surfaces` beyond serialization, so the token
survived only as a catalog claim that Polylogue has a repair surface.

Note: polylogue/operations/specs.py is IN the derived-schema closure
(`devtools schema closure`), so this moves the derived schema identity and
must land before a fresh rebuild starts, never during one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
@Sinity
Sinity force-pushed the work/repair-concept branch from c5f51a7 to 6f16efc Compare September 14, 2026 10:38
@Sinity
Sinity merged commit ca5ba28 into master Sep 14, 2026
3 checks passed
@Sinity
Sinity deleted the work/repair-concept branch September 14, 2026 10:47
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