Extract PRISM coordinator core owners - #74
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f5ed20809
ℹ️ 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".
5f5ed20 to
e3b3e6d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3b3e6dbb7
ℹ️ 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".
e3b3e6d to
0cdd951
Compare
0cdd951 to
afedf8e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: afedf8ef98
ℹ️ 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".
afedf8e to
aa0257e
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit aa0257e. Configure here.
aa0257e to
efe2122
Compare
920a2e6 to
d8a99b5
Compare
efe2122 to
0438c70
Compare

Position in the stack
PR 2 of 9. Base:
prism-test-shards. Depends on PR 73. Next: PR 75.Review this PR against its configured base so the diff contains only the core-owner extraction. See the stack guide for the complete order.
Why this slice exists
PrismCoordinatorhad accumulated configuration, lifecycle, payout, template, refresh, Stratum, delivery, and persistence state machines. That made lock ownership, cancellation, queue bounds, and shutdown ordering difficult to reason about. This slice establishes the target architecture: the coordinator remains the composition root and stable facade, while each domain owns its mutable state and worker lifecycle.What changes
Why the diff is large
This is the widest ownership boundary in the stack: about 33,300 additions and 14,600 deletions across 52 files. More than 12,600 lines leave
prism_coordinator.py; the corresponding logic is reorganized into cohesive owner modules, explicit port adapters, and direct owner tests. GitHub therefore counts moved-and-reshaped logic, new boundary types, and test coverage as additions rather than recognizing a simple move.The size does not represent 33,000 lines of new product behavior. A useful review order is:
_ensure_*factories, ports, and facade delegates;Behavior and risk
This is a high-risk structural change because it touches mining liveness, share durability, payout state, and shutdown. Environment names/defaults and public behavior are preserved. Owners now hold their own locks, queues, counters, and cancellation; leaf services do not import the coordinator.
The current
1.x.xtip contains later retry-throttling commite2aba4a, which is outside this reviewed slice. Final integration must port that behavior into the extracted refresh/candidate/finalization owners rather than restoring it to the coordinator.Validation
Operator impact
No migration is required in this slice. Existing configuration names and defaults remain valid, including
PRISM_PUBLIC_REWARD_WINDOW_CACHE_SECONDS.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
High Risk
Large refactor of coordinator mining liveness, share durability, payout publication, and shutdown paths; incorrect ownership or ordering could cause stuck jobs, lost shares, or unsafe lease release.
Overview
Pulls mining, payout, refresh, delivery, and shutdown logic out of
PrismCoordinatorinto dedicated owner modules, with the coordinator staying the composition root and exposing thin_ensure_*facades plus compatibility re-exports.New infrastructure includes immutable env loading (
coordinator_config), a writer barrier and phased shutdown (coordinator_shutdown), named background thread registration (background_services), a bounded priority job-delivery executor (bounded_executor), and a cancelable audit-bundle subprocess adapter (bundle_compiler).Job construction moves into
JobBundleService: shared bundle cache, latest-wins scheduler (publication-critical vs routine/collection), subprocess cancellation, and metrics. CTV fanout gets a runtime wrapper (ctv_runtime) with its own loop, writer admission, and Prometheus lines. Benchmarks now read tip-refresh and job-bundle metrics from those services instead of coordinator fields.Behavior and env contracts are intended to stay the same; risk is in lock ordering, cancellation, queue bounds, and shutdown sequencing across the new boundaries.
Reviewed by Cursor Bugbot for commit 0438c70. Bugbot is set up for automated code reviews on this repo. Configure here.