Skip to content

impl(033): increment 4, runtime origin and CLI output - #123

Merged
bartekus merged 1 commit into
mainfrom
impl/033-cli
Oct 20, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/033-cli

Conversation

@bartekus

@bartekus bartekus commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Spec 033, increment 4 of 5: the runtime origin (3.9) and the CLI output (3.11, amending 006). Stacked on #122.

  • RuntimeBuilder::host_backend registers a host-implemented backend (origin host); backend stays upstream, the default. Before supplying a failure, the runtime notes the last attempt's backend to the core (Evaluation::note_failure, FailureContext: origin and declared determinism), which the backend cause and invalid_backend_output's transience use. Plans without actionability read neither; run records keep their bytes. rustev_core::transient exposes 3.6.4's table.
  • CLI: categories 16 and 17 named; plan show adds caller_controlled, checks with each branch's classes, consequence and static party, groups, remediations and question ids (other plans unchanged); run prints rustev.judgment/2 whole with top-level addressed_to/transient (status judged, exit 0 for every outcome). The record file sink accepts rustev.run/3 so a plan 3 runs; capture of a plan 3 decision is refused before any decision runs (spec 032 3.11 defers it to 036).
  • Tests: core origin/transience (section 5 backend rows, full transience table), runtime origin wiring, CLI goldens refusal-16.json, refusal-17.json, actionable.show.json, actionable.run-{propose,refused,needs,unresolved}.json. Existing CLI goldens unchanged.

Review round 1 (2 findings): both comments made precise: addressing lists each outcome (an unresolved or needs_input outcome's action, a refusal's party with false, null for a proposal or an escalate, which carries no action); the capture comment says the runtime refuses capturing a plan 3 decision whatever the sink accepts, and execute refuses the combination first.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Looking at the changed files, I'll trace through the key logic paths: the FailureContext plumbing from runtime through core to CLI output, the plan-3 capture guard, the addressing function, and the sink changes.

crates/rustev-core/src/evaluate.rs

failed_request returns (step, vec![]) for SemState::Unresolved and (step, instance_key) for SemState::Instances. The note_failure key is (step.to_string(), instance.to_vec()). In the runtime, out.instance for a non-instances step is the empty vec, so the map keys match in both cases. No bug.

failure_context uses failed_request to find the first failing step, then looks up the noted context. Because note_failure is called for every failed supply in the runtime (not just the first), the context for the first-in-order step will be present. No bug.

crates/rustev-runtime/src/driver.rs

if let rustev_core::Supplied::Failed(_) = &s
    && let Some(r) = out.record.attempts.last()
        .and_then(|a| cx.rt.backends.get(&a.backend_id))
{
    ev.note_failure(...);
}
ev.supply(...)

Note is always before supply. If no attempts exist or the backend_id isn't registered, the context falls back to Origin::Upstream gracefully. No bug.

crates/rustev-cli/src/run.rs — addressing

Matches on Outcome::UnresolvedAction, NeedsInput, Refused, and _ (proposal, escalation → null/null). The goldens confirm:

  • propose: addressed_to:null, transient:null ✓
  • refused: addressed_to:"caller", transient:false ✓
  • needs: addressed_to:"caller", transient:false ✓
  • unresolved: addressed_to:"upstream", transient:false ✓

crates/rustev-cli/src/run.rs — plan-3 capture guard

Guard is placed after load_plan but before mismatches and decide, so no decision runs before the rejection. The test confirms c.record.json is not written. No bug.

crates/rustev-cli/src/sink.rs

accepts now allows both RUN and RUN_V3, consistent with the runtime test sink and the spec requirement for plan-3 runs.

crates/rustev-cli/src/plan.rs — actionability

Requires both plan.definition.actionability and plan.actionability to be Some; either absent returns the unchanged out. The golden actionable.show.json matches the serialised fields (caller_controlled, checks, constraint_groups, remediations, questions).

crates/rustev-core/tests/actionability_origin.rs — transience table

BackendUnavailable is tested as true for all determinisms in the loop (line 160–166 of the test), and InvalidBackendOutput with Bitwise is false, consistent with spec 3.6.4. No inconsistency.

Everything looks correct and internally consistent.

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

Subject: da5b8a5...10b2ec7, diff digest 8dd00b8c15ae57170eae776404a3b7f7aee68096bff123794a17221bfd508ca5, 1 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Looking at the changed files carefully:

crates/rustev-core/src/evaluate.rs -- failed_request refactor

The old Instances branch used a guard if values.values().any(...) → Some(id.clone()). The new version uses values.iter().find(...).map(|(k, _)| (id.clone(), k.clone())). Both return None when no instance matches, so failed_step behavior is preserved. The new instance key is then used to look up in self.failures, which the runtime populates with the same out.instance slice -- internally consistent.

crates/rustev-runtime/src/driver.rs -- note_failure call site

if let rustev_core::Supplied::Failed(_) = &s
    && let Some(r) = out.record.attempts.last()
        .and_then(|a| cx.rt.backends.get(&a.backend_id))

If attempts is empty for some reason (edge case), note_failure is not called and failure_context returns None, so the origin safely defaults to Upstream. The call precedes ev.supply(...), which is required since finish() reads failures.

crates/rustev-cli/src/run.rs -- addressing function

NeedsInput and UnresolvedAction both carry an action field with addressed_to/transient -- these are read directly. Refused hardcodes transient: false per spec 3.11.3. The _ arm (proposals, escalations) emits null/null. The goldens confirm each path.

The plan-3 capture guard fires before the mismatches loop and before any decision runs; the test asserts the record file is absent, which is consistent.

crates/rustev-cli/src/sink.rs

accepts now returns true for both RUN (rustev.run/1) and RUN_V3 (rustev.run/3). This is needed so plan-3 decisions can write their record file; capture (bundle) is separately blocked in execute.

crates/rustev-cli/src/plan.rs -- actionability output

Correctly gates on both plan.definition.actionability and plan.actionability being Some before adding the new fields; every other plan falls through unchanged.

Tests and goldens

The four run goldens are internally self-consistent: propose → null/null, refused → caller/false, needs → caller/false, unresolved → upstream/false. The actionable.show.json golden matches the actionability function's field order and content.

No bugs, security problems, or spec inconsistencies found.

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

Subject: 717316e...fc4a328, diff digest b724628d8954333cd43603aadf2cf9f98cd3ffc6a9d500db21d41bc562eda7c9, 1 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reading through the diff carefully, focusing on correctness, consistency, and security.

crates/rustev-core/src/evaluate.rs - failed_request refactor

The old Instances arm had an explicit guard (if values.values().any(...)) before returning Some(id). The new code drops the guard but the find_map still returns None when no instance matches because values.iter().find(...).map(...) produces None. Behavior is equivalent. ✓

crates/rustev-runtime/src/driver.rs - note_failure ordering

note_failure is called before ev.supply(...). Since failure_context is only read during ev.finish() (not during supply), the ordering is correct. ✓

crates/rustev-cli/src/run.rs - Plan 3 capture guard

The guard s.capture.is_some() && compiled.plan.schema == PLAN_V3 is placed before the decision loop, which correctly ensures c.record.json is never created. The test a_plan_3_decision_is_not_captured validates this by asserting !s.exists("c.record.json"). ✓

crates/rustev-cli/src/run.rs - addressing function

The _ arm emitting (null, null) covers Proposed and any Escalated outcome, matching the spec's "null for a proposal or escalation." The Refused arm hardcodes transient: false per spec. The NeedsInput arm reads n.action.transient (always false in practice, confirmed by golden). ✓

crates/rustev-cli/src/sink.rs - accepts

The new explicit accepts returning true for both RUN and RUN_V3 is coherent with the plan 3 guard moved from the sink to execute. Previously the sink's default (implicitly rejecting plan 3) enforced the invariant; now the CLI guard does. ✓

crates/rustev-cli/src/plan.rs - actionability function

The function returns the value of the final .set("questions", ...) call without a semicolon, which is the Out return value. The simultaneous requirement for both plan.definition.actionability and plan.actionability is a correct safety guard. ✓

crates/rustev-runtime/src/lib.rs - RuntimeBuilder field change

The tuple change from (Arc<...>, usize) to (Arc<...>, usize, Origin) is applied consistently in backend, host_backend, and the build loop. No call sites for the old 2-tuple form remain. ✓

Golden files

All four actionable.run-*.json goldens are consistent with the addressing logic: propose → null/null, refused → "caller"/false, needs → "caller"/false (action's transient), unresolved → "upstream"/false. ✓

No bugs, security problems, or inconsistencies found.

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

Subject: 2a0fedd...6c9ab67, diff digest c7295095a9e3aa8562a4d561df7d44c5b3b49a169f9f14900b6ba089c34bb497, 1 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff carefully across all changed files.

crates/rustev-core/src/evaluate.rs — failed_request refactoring

The old failed_step used any() with a guard on the Instances arm; the new failed_request uses find().map(). Both correctly skip a step when no instance matches — semantically equivalent. The new variant also returns the instance key for failure_context lookup, which is consistent with how note_failure stores keys.

crates/rustev-runtime/src/driver.rs — note_failure before supply

The context is noted before supply, so the failures map is populated by the time finish() calls failure_context. All failing supplies get context noted, so failed_request's "first by step order" lookup will find an entry in failures. Borrow lifetimes are sound — r is dropped before ev.supply().

crates/rustev-cli/src/run.rs — addressing() and capture guard

Schema guard (JUDGMENT_V2) prevents modifying v1 output. The catch-all _ => (json!(null), json!(null)) correctly handles proposals and any future variants. Early capture refusal (s.capture.is_some() && PLAN_V3) is placed before any decision runs; the test asserts c.record.json doesn't exist. ✓

crates/rustev-cli/src/sink.rs — accepts() now includes RUN_V3

Correct — a plan with actionability runs as v3 and writes a rustev.run/3 record. The capture guard independently prevents the capture path for plan v3. ✓

crates/rustev-cli/src/plan.rs — actionability() helper

let (Some(a), Some(table)) = ... requires both actionability fields present, failing safe if only one is populated (defensive, correct). The final chained .set("questions", ...) is the implicit return. ✓

Golden files

  • actionable.run-propose.json: addressed_to: null, transient: null — correct for a proposal.
  • actionable.run-refused.json: addressed_to: "caller", transient: false — correct; refusals are never transient.
  • actionable.run-needs.json / actionable.run-unresolved.json: non-null addressing from action fields — correct.
  • refusal-16.json / refusal-17.json: categories 16 and 17 printed correctly.

No bugs, security issues, or inconsistencies found.

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

Subject: 02e21fb...e1dacd6, diff digest 3d4acb80b0d4c3976e9ea684ece9043e2e4d3375324351f8a44139eadc881d20, 1 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

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

crates/rustev-cli/src/run.rs — addressing function

The function maps each Outcome variant to (addressed_to, transient). For NeedsInput, it reads n.action.transient from the struct rather than hardcoding false as it does for Refused. The doc comment says "null for a proposal or an escalation," which is ambiguous about whether NeedsInput should be null or addressed. The goldens and test assertions confirm the current behavior (addressed_to: "caller", transient: false) is intentional — n.action.transient correctly evaluates to false for needs-input actions — so this is not a bug, but the doc comment is misleading if read as "NeedsInput → null."

crates/rustev-runtime/src/driver.rs — note_failure before supply

note_failure is called before ev.supply(...), which is the correct order (the step must be pending when the context is noted). If out.record.attempts is empty (no attempts made before a failure is supplied), note_failure is skipped and the origin falls back to Upstream — a safe default.

crates/rustev-core/src/evaluate.rs — failed_request refactoring

The original code returned Some(id.clone()) for SemState::Instances, ignoring which instance failed. The new code returns the actual instance key via .find(...). This is strictly more precise and needed for failure_context to look up the right (step, instance) pair in failures. No regression risk — the single-step case still returns vec![] for SemState::Unresolved.

crates/rustev-cli/src/run.rs — plan 3 capture guard

The check s.capture.is_some() && compiled.plan.schema == PLAN_V3 fires before the mismatch checks, returning invalid_input (exit code 4) without running any decision. The test confirms c.record.json is never written.

crates/rustev-cli/src/sink.rs — accepts returning true for RUN_V3

Without --capture-bytes, a plan 3 can legitimately run and write a record file. Accepting RUN_V3 is required for that path; the capture guard in run.rs blocks the unsupported capture path. Consistent.

crates/rustev-core/src/lib.rs — visibility of transient and FailureContext

transient is promoted from pub(crate) to pub and re-exported at crate root. FailureContext is newly public. Both are needed by the runtime and CLI. No over-exposure beyond what the spec requires.

Golden files

The four actionable.run-*.json goldens are consistent with the assertions in actionability.rs: proposal → null/null, refused → caller/false, needs → caller/false, unresolved → upstream/false. The actionable.show.json matches the field ordering in the actionability helper in plan.rs.

No bugs, security problems, or inconsistencies found.

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

Subject: cb0bdcd...9444b88, diff digest a5279e73785e74e532faa442b883f4dfc474c0a851264f43fcd3043ffcacf0be, 1 call(s). An AI comment is not an approval.

Base automatically changed from impl/033-eval to main October 20, 2026 13:40
@bartekus
bartekus enabled auto-merge (squash) October 20, 2026 14:10
@github-actions

Copy link
Copy Markdown

AI review (findings)

Looking at the changed files, I'll work through each area of the diff.

crates/rustev-cli/src/run.rs -- addressing function and spec consistency

The function comment (and the spec.md increment 4 paragraph) both say:

null for a proposal or an escalation

But Outcome::UnresolvedAction returns action.addressed_to and action.transient (non-null), and the golden actionable.run-unresolved.json confirms "addressed_to":"upstream","transient":false. If "escalation" in spec 3.11.3 means UnresolvedAction, the implementation contradicts the spec; if it means a different outcome variant, the spec wording is misleading. The tests and goldens are internally consistent, but the terminology ambiguity is real.

crates/rustev-cli/src/run.rs -- updated comment in decide (~line 372-374)

The replacement comment reads:

// The configuration was checked with the flags, and a plan 3,
// whose capture the runtime refuses, was refused in `execute`.

But FileSink::accepts was updated in this very PR to accept rustev.run/3, so the runtime's sink no longer refuses plan 3. The actual guard is the early return added to the CLI's own execute function. Saying "the runtime refuses" is now inaccurate and will confuse future readers of the decide_with_capture call site.

crates/rustev-runtime/src/driver.rs -- note_failure ordering

note_failure is called before ev.supply, which is correct since supply is the state-mutating step and note_failure only records context. No issue.

crates/rustev-core/src/evaluate.rs -- failed_request for instanced steps

When multiple instances of the same step fail, failed_request iterates the BTreeMap and returns the first key in sorted (not execution) order. This determines which instance's FailureContext is fetched. In the common case all instances share one backend, so no practical difference; but in a multi-backend instanced setup the wrong origin could be selected. Low severity given current use patterns.

crates/rustev-runtime/src/lib.rs -- host_backend API

Origin::Upstream default for backend() and Origin::Host for host_backend() are symmetric and backward-compatible. The Registered.origin field and the builder tuple change look correct.

crates/rustev-cli/src/sink.rs -- accepts now includes RUN_V3

Needed so a plan 3 can write its record. Consistent with the early capture-refusal guard in execute (the runtime itself no longer blocks it).

Golden files

All four new run goldens are consistent with test assertions. The actionable.show.json correctly serialises only question IDs (["ask_tier"]), check branch fields, and remediation for party.


{"head": "fc880435e84b4996847277af3768ce2ed89a9910", "verdict": "findings", "findings": [{"path": "crates/rustev-cli/src/run.rs", "line": 196, "summary": "The `addressing` doc comment says 'null for a proposal or an escalation', but `Outcome::UnresolvedAction` returns actual (non-null) `addressed_to` and `transient` values; if 'escalation' maps to `UnresolvedAction` per spec 3.11.3, the implementation contradicts the spec text."}, {"path": "crates/rustev-cli/src/run.rs", "line": 372, "summary": "Updated comment says 'whose capture the runtime refuses' but the runtime's FileSink now accepts rustev.run/3 after this PR; the capture refusal is performed solely by the CLI's own `execute` guard, so the comment is inaccurate."}]}

Subject: 4af0b63...fc88043, diff digest a5279e73785e74e532faa442b883f4dfc474c0a851264f43fcd3043ffcacf0be, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 20, 2026 14:14 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff against the spec, golden files, and internal consistency.

crates/rustev-cli/src/plan.rs — actionability return

The function ends with an implicit return (no trailing ;) on the .set("questions", ...) chain. Rust is fine with that; the function return type is Out. No issue.

crates/rustev-cli/src/run.rs — addressing wildcard arm

_ => (json!(null), json!(null)),

The _ arm covers Propose, Escalate, and any future variants. The spec and the function's doc comment both say "null for a proposal or escalation". Golden actionable.run-propose.json shows "addressed_to":null,"transient":null. Correct.

crates/rustev-runtime/src/driver.rs — note_failure before supply

note_failure is written and supply is called in the same sequential block. finish is called only after all requests complete, so there is no window where finish could race between the two calls.

crates/rustev-core/src/evaluate.rs — double-call of failed_request

reason_action calls both failed_step(u) (which calls failed_request) and failure_context(u) (which also calls failed_request). This is a minor inefficiency but not a bug; evaluation steps are small in number.

Instance key alignment

failed_request returns (step, vec![]) for non-instanced steps and (step, k.clone()) for instanced steps. The runtime calls note_failure(&out.step, &out.instance, ...) using the same keys. Types and conventions are consistent.

Sink accepting RUN_V3

FileSink::accepts now accepts RUN_V3. The plan-3 capture guard in execute (s.capture.is_some() && compiled.plan.schema == PLAN_V3 → invalid_input) ensures captured bundles are still refused; accepting RUN_V3 only enables non-captured record writes for plan-3 runs. Consistent with spec 033 §3.11.3.

Golden consistency

  • actionable.run-propose.json: addressed_to:null, transient:null ✓
  • actionable.run-refused.json: addressed_to:"caller", transient:false ✓
  • actionable.run-needs.json: addressed_to:"caller", transient:false (action's transient is false for an authenticated-app-field missing input) ✓
  • actionable.run-unresolved.json: addressed_to:"upstream", transient:false (missing system-of-record field is not transient) ✓
  • refusal-16.json / refusal-17.json: categories match the test's expected (16, "uncovered_provenance") / (17, "caller_cannot_act") ✓

transient_is_true_only_for_the_three_reasons_of_3_6_4 test

InvalidBackendOutput with Determinism::Bitwise → false; with Unspecified/Tolerance → true. BackendUnavailable is always true regardless of determinism. DeadlineExceeded is always true. All other variants are false. The table and assertions are self-consistent and match the spec.

No bugs, security problems, or inconsistencies found.

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

Subject: 4af0b63...480d38c, diff digest 8504eda930b2ac18f06a0fdb23861b91968eb83f645fe545c69debd501b2384a, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus merged commit e91ff92 into main Oct 20, 2026
7 checks passed
@bartekus
bartekus deleted the impl/033-cli branch October 20, 2026 14:53
bartekus added a commit that referenced this pull request Oct 20, 2026
Spec 033, increment 5 of 5: remaining coverage, mutation seeds,
Verification and `implementation: complete`. Stacked on #123.

- `crates/rustev-core/tests/actionability_rows.rs`: the computed party
of every cause class as the golden `actionability.addressing.json` (each
provenance class declared/not declared caller-controlled,
observed/accepted, mixed accepted, `backend` per origin, budget,
deadline, capability, policy, no cause, mixed combinations) via the
now-public `rustev_core::computed_party`; `downgrade_grade` over spec
032 fixtures (authoritative to estimated, a `hint` stays `hint`, a pass
changes nothing); `provenance_within` on a step value; `relax` and
`relaxed{by}`; `escalate`; third-party plus user-supplied missing fields
computed `upstream`; a terminal check issuing no semantic request on
support routing; the future-window example as judgment 2 and evidence 2
goldens.
- Mutation harness: the seven seeds of the Acceptance section, each
detected by a named test failing. The harness's 120 s timeout counted
all seven as detected on macOS (binary launch stalls), so each was also
applied in place and run to completion; that exposed the terminal-check
seed surviving, fixed by the support-routing test above.
- Verification section declares the acceptance commands; `make verify`
runs 033.
- Node binding conformance remains externally blocked on spec 027 and is
not claimed.
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