Skip to content

Complete PRISM coordinator ownership cleanup - #80

Open
kiwidream wants to merge 1 commit into
prism-observability-httpfrom
prism-final-ownership-cleanup
Open

Complete PRISM coordinator ownership cleanup#80
kiwidream wants to merge 1 commit into
prism-observability-httpfrom
prism-final-ownership-cleanup

Conversation

@kiwidream

@kiwidream kiwidream commented Jul 20, 2026

Copy link
Copy Markdown
Member

Position in the stack

PR 8 of 9. Base: prism-observability-http. Depends on PR 79. Next: PR 81.

Review this PR against its configured base. See the stack guide for the complete order.

Why this slice exists

The earlier slices establish domain owners, but temporary mirrors, magic forwarding, inline metrics rendering, reorg bodies, and the watchdog loop would leave ambiguous ownership if retained. This slice completes the boundary and removes scaffolding that was useful only during extraction.

What changes

  • Move reorg reconciliation and chain-trust state into reorg_reconciler.
  • Move complete Prometheus document assembly into metrics.
  • Move the publication-progress/liveness watchdog loop into the lifecycle owner.
  • Replace block-finalization magic attribute passthrough with an explicit runtime port.
  • Remove drifting state mirrors, unused exports, and compatibility seams without demonstrated callers.
  • Retain narrow facade methods, descriptors, and the bounded-executor alias where in-repository callers prove compatibility is still required.

Why the diff is sizeable

The roughly 1,880 additions and 1,370 deletions are dominated by extracting metrics and reorg owners while deleting more than 1,160 coordinator lines. Explicit ports add some wiring, but they replace implicit __getattr__/__setattr__ behavior and make dependency direction reviewable.

Review the reorg owner, metrics renderer, and watchdog ports first. Then inspect coordinator deletions and the remaining compatibility surface to verify that mutable state has exactly one owner.

Structural result

  • prism_coordinator.py falls from 19,165 to 8,630 lines across the complete refactor.
  • No leaf service imports the coordinator.
  • No PRISM module uses magic __getattr__ or __setattr__ forwarding.
  • Remaining coordinator methods are construction, startup, shutdown, signal handling, listener setup, or demonstrated facade calls rather than large domain state machines.

Validation

  • 68 focused reorg, metrics, lifecycle, observability, and hot-path tests passed at this boundary.
  • Structural import, ownership, magic-forwarding, and compatibility audits passed.
  • Docker Python compile, Docker Ruff, and the PRISM image build passed.

Operator impact

No schema or required configuration change is introduced by this cleanup slice.


Note

Medium Risk
Large structural refactor on accepted-block finalization and process-exit watchdog paths; behavior is intended to be equivalent but explicit port wiring increases review surface for subtle delegation bugs.

Overview
This slice finishes PRISM coordinator boundary cleanup by moving process supervision, metrics assembly, and finalization wiring into dedicated owners instead of inline coordinator logic.

Watchdog — The publication-progress and liveness loops now live in WatchdogService in background_services.py, driven by injectable WatchdogPorts (stop wait, budgets, heartbeats, exit_process). The coordinator wires ports and registers the loop like other background services.

Block finalizationBlockFinalizationService no longer forwards unknown attributes to the coordinator via __getattr__/__setattr__. It takes a BlockFinalizationPort protocol and calls self.runtime.* for RPC, ledger, payout, reorg, and shutdown hooks. Finalization behavior is unchanged; dependencies are explicit.

Metrics — Full Prometheus document generation moves to new lab/prism/metrics.py: MetricsPort lists read capabilities and MetricsRenderer.render() assembles the scrape body (coordinator delegates via _ensure_metrics_renderer()).

Smaller cleanupsjob_build_benchmark imports default_prism_coinbase_tag_hex from coordinator_config. Observability drops generic “compatibility” setters in favor of *_for_test helpers on health snapshot and loop state.

Reviewed by Cursor Bugbot for commit 867781e. Bugbot is set up for automated code reviews on this repo. Configure here.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

@blacksmith-sh

This comment has been minimized.

@kiwidream
kiwidream force-pushed the prism-final-ownership-cleanup branch from ffb0ff8 to 7a18a8b Compare July 20, 2026 14:42
@kiwidream
kiwidream force-pushed the prism-observability-http branch 2 times, most recently from 132e880 to 4bb1f0b Compare July 20, 2026 15:28
@kiwidream
kiwidream force-pushed the prism-final-ownership-cleanup branch 2 times, most recently from 2410870 to 8453bc5 Compare July 20, 2026 15:34
@kiwidream
kiwidream force-pushed the prism-observability-http branch 2 times, most recently from 7711ebb to 3172e85 Compare July 20, 2026 16:02
@kiwidream
kiwidream force-pushed the prism-final-ownership-cleanup branch 2 times, most recently from 020f800 to f71730b Compare July 20, 2026 16:58
@kiwidream
kiwidream force-pushed the prism-observability-http branch from 3172e85 to e801c57 Compare July 20, 2026 16:58
@kiwidream
kiwidream force-pushed the prism-observability-http branch from e801c57 to bccba5a Compare July 22, 2026 13:50
@kiwidream
kiwidream force-pushed the prism-final-ownership-cleanup branch from f71730b to 59913ce Compare July 22, 2026 13:50
@kiwidream
kiwidream force-pushed the prism-final-ownership-cleanup branch from 59913ce to 867781e Compare July 22, 2026 14:05
@kiwidream
kiwidream force-pushed the prism-observability-http branch from bccba5a to 584a1f1 Compare July 22, 2026 14:05

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 867781e. Configure here.

except Exception:
inactive_blocks_total += inactive_blocks
reactivated_blocks_total += reactivated_blocks
matured_payouts_total += matured_payouts

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reorg error path double-counts

Medium Severity

When reconciliation uses reorg_watch_blocks, a successful pass adds the attempt’s inactive, reactivated, and matured counts to the running totals, then any exception afterward (for example from prepared_candidate) adds the same attempt counts again before updating service counters and re-raising. Reorg error metrics can be overstated even though ledger work ran once.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 867781e. Configure here.

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