Skip to content

Extract PRISM share submission - #77

Open
kiwidream wants to merge 1 commit into
prism-block-candidate-submissionfrom
prism-share-submission
Open

Extract PRISM share submission#77
kiwidream wants to merge 1 commit into
prism-block-candidate-submissionfrom
prism-share-submission

Conversation

@kiwidream

@kiwidream kiwidream commented Jul 20, 2026

Copy link
Copy Markdown
Member

Position in the stack

PR 5 of 9. Base: prism-block-candidate-submission. Depends on PR 76. Next: PR 78.

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

Why this slice exists

Stratum submit handling combines parsing, job/tip classification, duplicate identity, difficulty checks, durable share acceptance, and block-candidate routing. Moving those decisions into a dedicated service makes the acknowledgement boundary and rejection reasons testable without coordinator-wide state.

What changes

  • Move submit parsing, context classification, rejection decisions, durable share routing, and block-candidate routing into share_submission.
  • Introduce ShareSubmissionService with explicit ports for jobs, rejection, ledger append, and candidate enqueue.
  • Preserve current-tip, retained-job, stale, stale-grace, duplicate, low-difficulty, normal-share, and block-candidate outcomes.
  • Replace the unbounded/coarse-reset duplicate set with a thread-safe RecentShareIndex capped at 50,000 entries.
  • Keep coordinator entry points as lazy initialization and thin delegation.

Reading the diff

The roughly 970 additions and 310 deletions consist of the new service, a direct 244-line owner test suite, and coordinator rewiring. The decision logic is relocated rather than duplicated. Review the pure parser/classifier helpers first, then the service acknowledgement path, duplicate index, ports, and coordinator delegate.

Intentional bounded change

At capacity, duplicate tracking now evicts the oldest entries instead of clearing the entire set. This bounds memory while avoiding the large retry-safety gap created by an all-at-once reset. Duplicate identity still uses immutable job worker and header information.

Validation

  • 120 focused submission, vardiff, and candidate tests passed at this boundary.
  • Share acknowledgement, rejection reason, stale-grace, duplicate, and candidate regressions pass in cumulative PRISM discovery.
  • git diff --check passed.

Operator impact

No schema or configuration action is introduced by this slice.


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


Note

Medium Risk
Touches the mining hot path (ack/reject, stale-grace, ledger append, block-candidate routing); behavior is intended to be preserved but duplicate-window eviction changed from full clear to LRU-style eviction at capacity.

Overview
Stratum submit handling moves out of PrismCoordinator into new lab/prism/share_submission.py. handle_submit becomes a one-line delegate to lazily built ShareSubmissionService, which wires coordinator behavior through explicit ports (reject, control snapshot, ledger, share writer, block-candidate enqueue, etc.).

Pure helpers (parse_submit_request, validate_submit_request, classify_submit_context, classify_submit_work) own wire parsing, job/tip/stale-grace classification, difficulty routing, and share vs async vs synchronous block paths—same rejection reasons and outcomes as before, now unit-tested in tests/test_prism_share_submission.py.

Duplicate detection shifts from coordinator _recent_share_lock + a set that cleared entirely past 50k entries to RecentShareIndex: thread-safe, insertion-ordered, 50k cap with oldest-entry eviction. Reserve/release go through the service; recent_share_keys is a compatibility descriptor over the index.

Share-related rejection string constants are centralized in share_submission and re-imported by the coordinator.

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

@blacksmith-sh

This comment has been minimized.

@kiwidream
kiwidream force-pushed the prism-block-candidate-submission branch from ff16f0f to eb1743c Compare July 20, 2026 14:42
@kiwidream
kiwidream force-pushed the prism-share-submission branch from cdf110a to 3eafe82 Compare July 20, 2026 14:42
@kiwidream
kiwidream force-pushed the prism-block-candidate-submission branch from eb1743c to 8a9d23f Compare July 20, 2026 15:28
@kiwidream
kiwidream force-pushed the prism-share-submission branch from 3eafe82 to 4b369f0 Compare July 20, 2026 15:28

@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 4b369f0. Configure here.

Comment thread lab/prism/prism_coordinator.py Outdated
@kiwidream
kiwidream force-pushed the prism-block-candidate-submission branch from 8a9d23f to b668e77 Compare July 20, 2026 15:34
@kiwidream
kiwidream force-pushed the prism-share-submission branch 2 times, most recently from 44e43cc to af51efe Compare July 20, 2026 16:02
@kiwidream
kiwidream force-pushed the prism-block-candidate-submission branch 2 times, most recently from 894d810 to c621599 Compare July 20, 2026 16:58
@kiwidream
kiwidream force-pushed the prism-share-submission branch from af51efe to 60b212e Compare July 20, 2026 16:58
@kiwidream
kiwidream force-pushed the prism-share-submission branch from 60b212e to a87052f Compare July 22, 2026 13:50
@kiwidream
kiwidream force-pushed the prism-block-candidate-submission branch from c621599 to 76e54d9 Compare July 22, 2026 13:50
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