Skip to content

feat: add nucleus engine crate - #18

Open
bmuddha wants to merge 3 commits into
svmfrom
nucleus
Open

feat: add nucleus engine crate#18
bmuddha wants to merge 3 commits into
svmfrom
nucleus

Conversation

@bmuddha

@bmuddha bmuddha commented May 12, 2026

Copy link
Copy Markdown
Collaborator

What changed

Added the nucleus crate with feature-gated primitives shared across the engine stack.

Why

Ledger, runtime, storage, and orchestration crates need common types and lifecycle
coordination without assigning storage or execution policy to the shared dependency.

Closes #28.

Impact

  • Introduces shared slot and byte-size types, ledger positions, runtime messages,
    metrics helpers, thread-local runtime state, and test support.
  • Keeps Heed, ledger, metrics, runtime, shutdown, testkit, and TLS support behind
    narrow crate features.
  • Provides ShutdownManager, service handles, ordered cancellation tiers, and
    bounded termination reporting.

Reviewer notes

Shutdown cancels the replication client, pacemaker, sequencer, and remaining
services in order. Each tier receives its own bounded window to report completion
before shutdown advances.

Follow-up

Ledger, keeper, processor, engine, and replication services consume these
feature-gated primitives upstack.

@bmuddha
bmuddha force-pushed the nucleus branch 2 times, most recently from 410f558 to d323e3a Compare May 14, 2026 14:46
@bmuddha
bmuddha changed the base branch from solana-account to graphite-base/18 May 28, 2026 13:20
@bmuddha
bmuddha changed the base branch from graphite-base/18 to svm May 28, 2026 13:20
@bmuddha
bmuddha force-pushed the nucleus branch 4 times, most recently from fddd6f0 to c01202f Compare May 28, 2026 14:42
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: da3a0fb7-2fa9-4079-a9a2-cc1c40ee952a

📥 Commits

Reviewing files that changed from the base of the PR and between 432362c and 53b01af.

📒 Files selected for processing (5)
  • Cargo.toml
  • nucleus/Cargo.toml
  • nucleus/README.md
  • nucleus/src/heed.rs
  • nucleus/src/testkit.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • nucleus/README.md
  • nucleus/Cargo.toml
  • nucleus/src/testkit.rs
  • Cargo.toml

📝 Walkthrough

Walkthrough

The workspace adds the feature-gated nucleus crate and the v42-calculator-interface crate. Nucleus provides shared configuration, ledger, runtime, storage, metrics, notification, TLS, shutdown, and test-support APIs. The calculator crate defines RPN instructions and expression builders.

Changes

Engine primitives and calculator interface

Layer / File(s) Summary
Workspace and crate manifests
Cargo.toml, nucleus/Cargo.toml, programs/v42-calculator-interface/Cargo.toml
The workspace adds both crates, shared dependencies, feature flags, optional integrations, and lint configuration.
Nucleus shared contracts
nucleus/README.md, nucleus/src/lib.rs, nucleus/src/config.rs, nucleus/src/ledger.rs, nucleus/src/runtime.rs
Nucleus adds shared configuration, ledger, runtime, slot, size, and time APIs with feature-gated modules.
Storage, notification, TLS, and shutdown
nucleus/src/heed.rs, nucleus/src/notifier.rs, nucleus/src/tls.rs, nucleus/src/shutdown.rs
Nucleus adds transaction helpers, asynchronous notification, thread-local message state, and ordered service shutdown.
Metrics and execution fixtures
nucleus/src/metrics.rs, nucleus/src/testkit.rs
Nucleus adds Prometheus and tracing helpers, deterministic fixtures, transaction signing, and calculator test instructions.
Calculator opcodes and expression builder
programs/v42-calculator-interface/README.md, programs/v42-calculator-interface/src/lib.rs, programs/v42-calculator-interface/src/opcodes.rs, programs/v42-calculator-interface/src/builder.rs
The calculator interface adds RPN opcode definitions, transfer encoding, expression composition, arithmetic lowering, and recursive CPI serialization.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OS
  participant ShutdownManager
  participant ShutdownHandle
  participant Service
  OS->>ShutdownManager: Send shutdown signal
  ShutdownManager->>ShutdownHandle: Cancel service tier
  ShutdownHandle->>Service: Notify cancellation
  Service->>ShutdownManager: Report termination reason
  ShutdownManager->>ShutdownManager: Drain tier with timeout
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The pull request also adds a standalone v42 calculator interface and workspace members not explicitly required by issue #28. Move the v42 calculator interface and unrelated workspace-member additions to a separate pull request, unless they are required dependencies with documented scope.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: adding the nucleus engine crate.
Description check ✅ Passed The description directly explains the nucleus crate, its feature-gated primitives, shutdown coordination, and intended engine integration.
Linked Issues check ✅ Passed The changes implement the linked issue objectives, including shared primitives, feature gates, test support, and ordered shutdown coordination [#28].
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nucleus

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.

@bmuddha
bmuddha force-pushed the nucleus branch 2 times, most recently from 02c3fc8 to 5400e0f Compare May 29, 2026 15:49
@bmuddha

bmuddha commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nucleus/src/heed.rs`:
- Around line 27-45: Remove the lifetime-extending transmute calls from
DatabaseIndex::write_txn and DatabaseIndex::read_txn. Bind newly opened
transactions to the borrow of self.env(), or adopt an owner that keeps the Env
alive, while preserving supplied transactions and caller-owned storage without
requiring unsafe lifetime assumptions.

In `@nucleus/src/testkit.rs`:
- Around line 60-66: Update the block function’s hash construction so all bits
of Slot contribute to a deterministic hash, avoiding collisions between slots
that differ beyond the lowest byte. Preserve the existing block fields and
ensure distinct Slot values produce distinct hashes within the supported Slot
range.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ac2e5c95-96a6-453e-a119-976b7e354a00

📥 Commits

Reviewing files that changed from the base of the PR and between 1f187f7 and 432362c.

📒 Files selected for processing (18)
  • Cargo.toml
  • nucleus/Cargo.toml
  • nucleus/README.md
  • nucleus/src/config.rs
  • nucleus/src/heed.rs
  • nucleus/src/ledger.rs
  • nucleus/src/lib.rs
  • nucleus/src/metrics.rs
  • nucleus/src/notifier.rs
  • nucleus/src/runtime.rs
  • nucleus/src/shutdown.rs
  • nucleus/src/testkit.rs
  • nucleus/src/tls.rs
  • programs/v42-calculator-interface/Cargo.toml
  • programs/v42-calculator-interface/README.md
  • programs/v42-calculator-interface/src/builder.rs
  • programs/v42-calculator-interface/src/lib.rs
  • programs/v42-calculator-interface/src/opcodes.rs

Comment thread nucleus/src/heed.rs Outdated
Comment thread nucleus/src/testkit.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coderabbit Trigger coderabbit review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add nucleus crate for shared engine primitives

1 participant