Skip to content

impl(022): production acceptance, stage 3 records and production construction - #439

Merged
bartekus merged 1 commit into
mainfrom
impl/022-production-accept
Nov 1, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/022-production-accept

Conversation

@bartekus

@bartekus bartekus commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Spec 022 3.7.5 (A-69): accepting a stage 3 record and constructing a production binding. No network, no live call.

  • Qualification gains estimated_units and digest() (rustev.jev-qualification/1); check validates only the record: exact binding identity (3.6.2), a calls fact that is not stale, owner authorization, report and spend-journal references, and the dataset's admission or stated limitation.
  • ProductionBinding::production_eligible takes the accepted Qualification: 3.4's facts for the day, production use, direct transport, mapping and decision mapping version rustev-jev-mapping/2, and the record's check. Gateway bindings stay ineligible.
  • JevBackend::new_production(backend_id, binding, credential, qualification, sink, journal, today) refuses before any credential lookup unless eligibility holds, the journal is the production journal, and batching is off (3.7.5.4, until spec 044 increment 8). It then constructs as new_qualification does, recording the accepted record's digest and keeping no request or response bytes.
  • check_production_plan takes the accepted qualifications and refuses a reached binding with none or with two.
  • The stage 3 record of A-68 is not accepted here; that stays the owner's act in its own decision row.

Spec: a dated "Production acceptance implemented" paragraph in 022's implementation record; implementation: unchanged.

Verification

  • cargo test -p rustev-jev --locked (all targets, including tests/production.rs with six new tests), clippy -D warnings on rustev-jev, cargo fmt --all --check, the 3.8.1 environment-variable grep, cargo run -p rustev-boundaries, make gate, scripts/check-authored-content.sh.

Review note (fadcd08): style nit, not a defect. new_production takes Option<&Qualification> to mirror production_eligible and check_production_plan, where an absent record is a refusal reason reported as "accepted qualification is missing"; the second ok_or is a defensive repeat of the same refusal and changes no behavior.

…truction

JevBackend::new_production constructs only with an accepted, checked
Qualification for the exact binding, the production journal and batching
off; check_production_plan takes the accepted qualifications (3.7.5).
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the PR for bugs, security issues, and spec inconsistencies.

integrations/rustev-jev/src/production.rs — mutual-recursion removal is correct

Old Qualification::check ended with binding.production_eligible(today, 5_000). New production_eligible calls qualification?.check(self, false, today), and check now ends with Ok(()). This breaks what would have been a mutual-recursion once both sides were wired together. The restructuring is correct.

adapter.rs — redundant Option guard after production_eligible

After binding.production_eligible(qualification, today, 5_000) returns Ok (which already requires qualification to be Some), the code does:

let digest = qualification
    .ok_or(SetupError::Production(Unresolved("accepted qualification is missing")))?
    .digest()

The ok_or arm is unreachable: if qualification were None, production_eligible would have returned Err and the ? would have exited already. This is harmless but the new_production signature accepting Option<&Qualification> where a plain &Qualification would enforce the invariant at the call site is a concrete API weakening. The spec (spec.md, added text line ~572) says the function "takes… the accepted Qualification" — unconditionally — yet callers can pass None and get a runtime error instead of a compile-time one.

Order of checks — credential safety holds

The ordering is: production_eligible → journal budget → batching → digest → over_production_binding (where the credential callback is first invoked). Tests count callback invocations and assert 0 for every failure case. No credential is read before all guards pass. This is correct.

estimated_units field — no validation in check

Qualification::check validates observed_units implicitly (through spend totals), unresolved_liability_units, references, and dates, but estimated_units (new in this PR) is included in the digest and not range-validated (e.g., not checked to be ≥ observed_units or nonzero). No spec constraint for this is visible in the diff, so this is a design choice rather than a defect.

Backward-compatibility of Qualification deserialization

estimated_units: u64 is added without #[serde(default)] to a struct already decorated #[serde(deny_unknown_fields)]. This would break deserialization of any serialized Qualification records missing the field. The spec note confirms no stage 3 records are accepted by this change, so no stored records exist yet; this is safe in context.

Spec amendment vs. implementation — check_production_plan budget_ms

adapter.rs hard-codes 5_000 ms in new_production; check_production_plan threads its budget_ms parameter through. The spec amendment does not specify what check_production_plan should use; no inconsistency is visible.

Qualification::check is now callable without binding-eligibility checks

check is public and validates only the record's own fields (identity, calls, authorization, references, dataset). A caller can invoke it on a development binding and get Ok(()) if all record fields are valid. Eligibility enforcement is solely in production_eligible and new_production. This is intentional separation; check is described as checking "only the record." Not a bug.

Overall: the implementation is internally consistent. The one concrete, actionable issue is the Option<&Qualification> parameter that silently weakens the type-level invariant the spec states as unconditional.

{"head": "fadcd0843bf6e462daac0de3d44cdc8a9e2ec6a7", "verdict": "findings", "findings": [{"path": "integrations/rustev-jev/src/adapter.rs", "line": 449, "summary": "new_production accepts Option<&Qualification> where &Qualification would enforce the spec's unconditional requirement at the call site; after production_eligible already validates Some, the second ok_or guard is unreachable dead code."}]}

Subject: 09c3c1b...fadcd08, diff digest fba362a5eedd186b16c19cfa47958bb979ed95cec32eff43a298901969d4e0e7, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 1, 2026 01:21 — with GitHub Actions Inactive
@bartekus
bartekus enabled auto-merge November 1, 2026 05:32
@bartekus
bartekus added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit 4bfa9f9 Nov 1, 2026
58 of 60 checks passed
@bartekus
bartekus deleted the impl/022-production-accept branch November 1, 2026 06:34

This branch was previously deployed

1 inactive deployment
statecraft-review-exception — fadcd084 Deployed Nov 1, 2026 by bartekus via review-exception #2950
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