Skip to content

feat(maintenance): persistent op registry + status surface (#1197) - #1366

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/maintenance-op-registry-1197-v2
May 19, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/maintenance-op-registry-1197-v2

Conversation

@Sinity

@Sinity Sinity commented May 19, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a persistent maintenance operation registry plus matching CLI,
daemon HTTP, and MCP status surfaces, so operators can list in-flight
and recent backfill operations and tail a specific one by id.

Problem

polylogue/maintenance/replay.py already checkpointed per-operation
resume state to <archive_root>/.maintenance-state/<op_id>.json, but
there was no surface that could list those files, retrieve one by id,
or prune the completed ones. GET /api/maintenance/status/<op_id> was
called out in the #871 reconnaissance and #996 AC #4 ("Progress and
outcomes are surfaced in CLI/daemon/MCP"); none of the three surfaces
exposed it. The state payload also only carried
{cursor, results, repaired_count, failure_count}, which was not
enough to reconstruct the shared MaintenanceOperationEnvelope.

Solution

Substrate:

  • polylogue/maintenance/registry.py — new
    MaintenanceOperationRegistry over the state directory.
    list_operations() returns one OperationRecord per persisted
    snapshot (newest-first), get_operation(op_id) returns one or
    None, prune_completed(older_than=DEFAULT_COMPLETED_TTL=7d)
    removes only completed-successful operations past the TTL; failed
    operations are retained for diagnosis.
  • polylogue/maintenance/planner.py — BackfillOperation.from_dict
    so persisted snapshots rehydrate, plus _coerce_float /
    _coerce_int helpers so the rehydration path avoids scattering
    bracketed mypy suppressions.
  • polylogue/maintenance/replay.py — state payload upgraded to carry
    the full BackfillOperation.to_dict() under a new operation key
    (legacy top-level fields preserved for the existing resume code
    path). Failed runs now persist a final snapshot so operators can
    inspect them via the registry; successful runs still clear the
    file.

Surfaces:

  • CLI: polylogue maintenance status [--operation-id ID] [--all] [--output-format plain|json] (registered in
    polylogue/cli/commands/maintenance.py).
  • Daemon HTTP: GET /api/maintenance/status/<op_id> and
    GET /api/maintenance/operations. Handlers delegated to a new
    polylogue/daemon/maintenance_registry_http.py to keep
    daemon/http.py within its file-size budget; the budget reason is
    updated to record the delegation.
  • MCP: maintenance_status(operation_id) and maintenance_list()
    return the shared MaintenanceOperationEnvelope plus state-file
    metadata (updated_at, state_path). The envelope classification
    matrix and MCP tool wire-schema witness are updated accordingly.

Topology / budgets:

  • docs/plans/topology-target.yaml regenerated.
  • docs/plans/file-size-budgets.yaml reason updated for
    polylogue/daemon/http.py to record the new delegation.

Verification

  • devtools verify --quick — exit 0 (format, lint, mypy, render-all
    check, all five static lints pass).
  • devtools verify --seed-testmon --skip-slow — exit 0 (8345
    passed, 2 xfailed, 0 failed).
  • New tests:
    • tests/unit/maintenance/test_registry.py — round-trip,
      newest-first listing, TTL pruning, failure-sample round-trip,
      scope round-trip, end-to-end replay-writes-readable-state.
    • tests/unit/daemon/test_maintenance_endpoints.py — extended
      with TestMaintenanceRegistryEndpoints covering the two new
      GET routes (route dispatch, 404 on missing, envelope shape).
    • tests/unit/cli/test_maintenance_registration.py — extended
      for the status subcommand (registration + help).
    • tests/unit/mcp/test_envelope_contracts.py +
      tests/infra/mcp.py — classify maintenance_status and
      maintenance_list.

Closes #1197

🤖 Generated with Claude Code

@Sinity
Sinity enabled auto-merge (squash) May 19, 2026 07:24
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 43 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9a4c4178-3896-44d3-9487-ca6525401b7b

📥 Commits

Reviewing files that changed from the base of the PR and between be5acac and 447706d.

📒 Files selected for processing (18)
  • docs/plans/file-size-budgets.yaml
  • docs/plans/topology-target.yaml
  • docs/test-quality-workflows.md
  • docs/topology-status.md
  • docs/verification-catalog.md
  • polylogue/cli/commands/maintenance.py
  • polylogue/daemon/http.py
  • polylogue/daemon/maintenance_registry_http.py
  • polylogue/maintenance/planner.py
  • polylogue/maintenance/registry.py
  • polylogue/maintenance/replay.py
  • polylogue/mcp/server_maintenance_tools.py
  • tests/data/witnesses/mcp-tool-schemas.json
  • tests/infra/mcp.py
  • tests/unit/cli/test_maintenance_registration.py
  • tests/unit/daemon/test_maintenance_endpoints.py
  • tests/unit/maintenance/test_registry.py
  • tests/unit/mcp/test_envelope_contracts.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/maintenance-op-registry-1197-v2

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 and usage tips.

@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: a976268ff9

ℹ️ 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/maintenance/replay.py Resolved
Comment thread polylogue/maintenance/replay.py Resolved
Adds a read surface over the replay state directory so CLI, daemon
HTTP, and MCP can list and tail in-flight or recent maintenance
operations.

Substrate:
- polylogue/maintenance/registry.py: MaintenanceOperationRegistry over
  ``<archive_root>/.maintenance-state/`` with list_operations(),
  get_operation(), prune_completed(older_than=7d default). Failed
  operations are retained until manually cleared.
- BackfillOperation.from_dict() so persisted snapshots rehydrate.
- replay.py: state payload upgraded to carry the full
  BackfillOperation.to_dict() under the ``operation`` key; failed
  runs now persist a final snapshot (success continues to clear).

Surfaces:
- CLI: ``polylogue maintenance status [--operation-id ID] [--all]
  [--output-format plain|json]``.
- Daemon HTTP: ``GET /api/maintenance/status/<op_id>`` and
  ``GET /api/maintenance/operations`` (handlers delegated to
  daemon/maintenance_registry_http.py to keep daemon/http.py within
  budget).
- MCP: ``maintenance_status(operation_id)`` and ``maintenance_list()``
  return the shared MaintenanceOperationEnvelope plus the state-file
  metadata.

Tests:
- tests/unit/maintenance/test_registry.py — round-trip, ordering,
  TTL pruning, failure-sample persistence, scope round-trip.
- tests/unit/daemon/test_maintenance_endpoints.py — extended for the
  new GET routes.
- tests/unit/cli/test_maintenance_registration.py — extended for
  the status subcommand.
- tests/unit/mcp/test_envelope_contracts.py + tests/infra/mcp.py —
  classify the two new MCP tools.
- MCP tool wire-schema witness regenerated.

Closes #1197

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@Sinity
Sinity force-pushed the feature/feat/maintenance-op-registry-1197-v2 branch from a976268 to 447706d Compare May 19, 2026 11:51
@Sinity
Sinity merged commit 8662416 into master May 19, 2026
2 of 4 checks passed
@Sinity
Sinity deleted the feature/feat/maintenance-op-registry-1197-v2 branch May 19, 2026 11:51
@Sinity

Sinity commented Sep 30, 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.

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.

feat(maintenance): persistent operation registry + status surface (CLI/HTTP/MCP)

1 participant