Skip to content

impl(067): Node binding live preconditions: cost checks, rule authorizer, journal by path (increment 1b) - #546

Merged
bartekus merged 1 commit into
mainfrom
impl/067-inc1b
Nov 7, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/067-inc1b

Conversation

@bartekus

@bartekus bartekus commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Spec 067 increment 1b (half of increment 1; the manifest change landed alone in #547 under the policy-isolation guard; increment 1a carries the journal identity and --require-existing-journal in rustev-live and the CLI). rustev-node gains a normal dependency on rustev-live and a crate-private module src/live.rs with the binding's live preconditions as Rust functions; no JavaScript method yet (engine.liveRun is increment 2):

  • LiveRefusal: outcomes as values (3.2.4), invalid_input code 4, I/O code 3, same split as the CLI's live_error.
  • check_config: LiveConfig::check with Mode::Cli, so the binding requires authorize (live-config, 3.5.2, A-86 decision 3).
  • RuleAuthorizer: the CLI's rule authorizer logic (043 3.12, 067 3.5.1), first matching rule, operation and max_exposure_units, reference <LiveConfigId>#<index>; not exported, no permission value (2.1).
  • check_backends: 3.3.3 against the engine's registered backends before any journal is opened (I-1): unknown cost model spend-unit; unregistered backend, descriptor artifact differing from the binding entry, reached-without-entry or entry-not-reached live-config; cost_unit: none accepted (3.3.4; rustev-live already records declared_no_spend).
  • open_journal: by path, testing budget, injected SpendClock, CLI error mapping (journal-budget 4, journal-locked 3, other I/O 3; 3.4.1). Uses the existing SpendJournal::open; increment 1a's identity-aware opening and requireExistingJournal are wired in increment 2.
  • check_durable_paths: memory host refused InvalidDocument durable-paths-required (3.4.2).

The lib's unit tests run outside Node, so a napi dev-dependency enables dyn-symbols for test builds only (resolver 2 does not unify dev-dependency features into normal builds); the shipped addon is unchanged.

Spec: specs/067-node-live-repeat-runs/spec.md 3.2.4, 3.3, 3.4.1, 3.4.2, 3.5; implementation record paragraph added, implementation: pending kept, no acceptance item claimed.

Tests

Unit tests in integrations/rustev-node/src/live.rs with scripted Rust DecisionBackends, a temp dir and SetClock; no network, no live or paid call. Local: cargo test -p rustev-node --locked (9 tests), cargo clippy --workspace --all-targets --locked -- -D warnings, cargo fmt --all --check, cargo build -p rustev-node --features local-embed --locked, make gate.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for bugs, security issues, and governance inconsistencies.

integrations/rustev-node/src/live.rs

  • RuleAuthorizer::authorize (lines 76-110): First-match semantics via .find(), correct. No-match returns reference: None, matched-but-refused returns reference: Some(...). Aligns with the test at the bottom of the file.
  • check_backends iteration order (registration → unknown cost → identity) matches the doc comment and the test backend_refusals_and_configuration_order.
  • open_journal error mapping (Mismatch → code 4 / "journal-budget", Locked → code 3 / "journal-locked", fallthrough → code 3 / "journal") is consistent with the implementation record and the journal test.
  • check_durable_paths returns napi::Result<()> from production (non-cfg-test) code. napi must already be in [dependencies] for this Node.js addon crate (not shown in the diff because unchanged); the new dev-dependency only adds the dyn-symbols feature for test builds, which is a valid Cargo feature-union pattern. No compilation hazard.
  • The Dir test helper avoids collisions with process::id() + AtomicU64. Cleanup on drop. Fine.
  • check_durable_paths test accesses error.reason on a napi::Error; crate::errors::fail is not in the diff, but the test is consistent with how the rest of the codebase presumably constructs napi errors. Not a concrete defect from supplied evidence.

specs/067-node-live-repeat-runs/spec.md

  • New extends entry claims spec 001-boundaries-and-authority owns Cargo.lock with nature: additive - correct, since adding rustev-live appends lines to that file.
  • Implementation record names this "Increment 1b" while the prior state was "None yet", so there is no preceding "1a" recorded in this corpus. This could mean 1a landed elsewhere, or the sub-increment naming was chosen without a prior sibling. This is a naming oddity but not a contradiction the supplied evidence proves is a defect.
  • Spec lifecycle state is not visible in the diff (frontmatter status unchanged); no finding possible.

integrations/rustev-node/Cargo.toml

  • rustev-live added to [dependencies]. napi dev-dependency with dyn-symbols added to [dev-dependencies]. Both are consistent with the stated intent.

No concrete bugs, security issues, or governance violations found.

{"head": "f14c99411e5f2aa80914ade88264a6fc3c4639a4", "verdict": "no-findings", "findings": []}

Subject: 78dfabd...f14c994, diff digest 3c4bad082d2e2086f0b9b8ea81e1359a22ed97b740b418e1d03cc6816a111bba, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the three changed files: a new live.rs module implementing live preconditions for the Node binding, a one-line lib.rs addition wiring it in, and a spec implementation record update.

integrations/rustev-node/src/lib.rs

The #[cfg_attr(not(test), allow(dead_code))] attribute on mod live is intentional: the module is compiled in all builds but suppresses dead-code warnings outside tests because Increment 2 wires up the entry point. This is documented and not a defect.

integrations/rustev-node/src/live.rs

RuleAuthorizer::authorize: First-match semantics via .find() are correct. The reference is Some only when a matching rule is found but conditions fail, None when no rule matches at all — consistent with the test assertions and the spec's audit intent. The valid_for_ms is set to request.remaining_ms, matching spec 3.5.1.

check_backends ordering: registration → CostModel::Unknown → descriptor identity → check_config. The spec (3.3.3 and the implementation record) requires exactly this order, and the backend_refusals_and_configuration_order test verifies it by inserting an "absent" binding before/after "synthetic" and swapping to confirm the error subject changes from live-config to spend-unit.

open_journal: Always opens with BudgetKind::Testing (spec 3.4.1). Error mapping — Mismatch → code 4, Locked → code 3, other I/O → code 3 — matches the implementation record and is confirmed by journal_creation_budget_lock_and_io_mapping.

check_durable_paths: Memory host throws a napi error immediately (spec 3.4.2); Filesystem is Ok(()). Straightforward.

The Dir test helper uses process::id() plus an atomic counter for unique temp paths across parallel tests. The SpendJournal returned by the second open_journal call in the journal test drops immediately (not bound), releasing the lock before std::fs::write overwrites the file — the subsequent mismatch checks are correct.

specs/067-node-live-repeat-runs/spec.md

The implementation record accurately describes what the code does. It explicitly states "No acceptance item is claimed yet," which is correct — the spec's status/implementation fields are not touched in this diff.

No concrete defects found.

{"head": "9e3a158f8d419f8d826512bc94e74fec0a1cba27", "verdict": "no-findings", "findings": []}

Subject: b409354...9e3a158, diff digest 83f60a0b082d8e49ea086baec5d03032559f9d7a20c21665e27e3885f8102e26, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit a52d38b Nov 7, 2026
32 of 40 checks passed
@bartekus
bartekus deleted the impl/067-inc1b branch November 7, 2026 21:11
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