Skip to content

impl(042): increment 5 part 2, serve surfaces and runtime cases through the service - #418

Merged
bartekus merged 1 commit into
mainfrom
impl/042-surfaces
Oct 30, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/042-surfaces

Conversation

@bartekus

@bartekus bartekus commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Spec 042, increment 5 part 2 (3.17.1, 3.17.2): the decision service joins the shared conformance suite as the surfaces serve-http and serve-grpc, and runs the runtime cases through the service.

  • Manifest: every run case (CLI harvest) and every runtime case names serve-grpc and serve-http; case files and cases/manifest.json rebuilt.
  • rustev_conformance::runtime::Scripted is public (constructor, backend, gated, release_all) with result_line, so the service's runner binds the same scripted backends as the Rust runner. The Rust runner's outputs are unchanged.
  • integrations/rustev-serve/tests/conformance/runner.rs selects cases by surface. A runtime case runs with its runtime bounds (max_in_flight, max_queued, max_parallel_requests, per-backend concurrency, fail_decision timeout) on the manual clock; the driver's steps go through the service (decide requests, the cancel operation), and each decision's result and delivered record must equal the case's bytes. HTTP and gRPC answers are compared byte for byte per listener.
  • Spec 042: one dated implementation record paragraph, and an extends edge on crates/rustev-cli/tests/common/ (spec 006) for the harvest change.

Checks

  • cargo test -p rustev-serve --lib conformance::
  • cargo test -p rustev-conformance
  • make gate, scripts/check-authored-content.sh, spec-spine couple

@github-actions

Copy link
Copy Markdown

AI review (findings)

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

registration() — wrong execution-policy extraction for non-"none" plans

In integrations/rustev-serve/tests/conformance/runner.rs (new registration() function):

let execution = match &json["execution"] {
    Json::String(s) if s == "none" => json!("none"),
    e => json!({ "some": e["declared"]["policy"] }),
};

When json["execution"] is not the string "none" — i.e., the plan has an actual execution policy — e holds the entire json["execution"] value. Following the standard Option-like enum serialisation used throughout this codebase, that value would be shaped like {"some": {"declared": {"policy": …}}}. Indexing e["declared"] on that object yields Json::Null (no "declared" key at the top level of e), so the produced execution is {"some": null}, which is a malformed bundle that will fail schema validation or silently register the wrong policy.

The spec narrative says "the plan is registered with its declared execution policy and calibrations," so the intent is correct but the path is one level short. The correct extraction would navigate through the "some" wrapper first (e.g. e["some"]["declared"]["policy"] or simply forward the whole "some" object). This affects runtime cases that carry real execution policies (deadline timeouts, etc.).

drive() — panic when an "inert" descriptor has no scripted backend and rc.backends is empty

let mut s = script.cloned().unwrap_or_else(|| rc.backends[0].clone());

If a descriptor in rc.descriptors has no matching entry in rc.backends (script.is_none()) and rc.backends itself is empty, this panics. Runtime cases must have at least one backend in practice, but the fallback is undocumented and fragile.

No other concrete defects found in the remaining changes (the Scripted visibility promotion, result_line extraction, differential, surface-filtering helpers, and harvest annotation all look correct for their stated purposes).

{"head": "268480ce8330c790f7252dd24df9a27933a18cf1", "verdict": "findings", "findings": [{"path": "integrations/rustev-serve/tests/conformance/runner.rs", "line": 491, "summary": "registration() extracts the execution policy one level too shallow: for a non-\"none\" plan, e[\"declared\"][\"policy\"] evaluates to null because e is the entire {\"some\": {\"declared\": ...}} object, producing a null policy in the registered bundle."}, {"path": "integrations/rustev-serve/tests/conformance/runner.rs", "line": 616, "summary": "drive() panics if rc.backends is empty and a descriptor has no matching backend script, because the inert-backend fallback unconditionally indexes rc.backends[0]."}]}

Subject: 1d5fd7e...268480c, diff digest 84f258db70172ddc77e6f83493cfc8804cd97da11d56ab8a576d7dc7859fc9f6, 1 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (findings)

Reviewing the six changed files. The PR extends the conformance runner to drive runtime cases through the decision service's HTTP/gRPC surfaces, refactors registration and start, and makes Scripted/result_line public so the service runner can share them.

integrations/rustev-serve/tests/conformance/runner.rs

The refactor is structurally sound. setup is always passed by reference to start, so setup.backends[0] remains accessible in decide. running.len() as the Start index is correct because each Start step adds exactly one task. The differential function's else { continue } branch correctly handles cases that name only one transport. tokio::time::sleep inside until is fine because the test uses flavor = "multi_thread" without start_paused, so real time advances. The gRPC refusal trailer is decoded to raw bytes before returning, so byte-for-byte comparison against the HTTP body refusal document should hold if the service encodes them identically (which the spec requires at 3.17.2).

tools/rustev-conformance/src/runtime.rs

Extracting result_line and making Scripted public are clean. The refactored run function produces byte-identical output to the original because serde_json preserves json!-macro key insertion order and result_line inserts decision_id → status → (optional) rejection in the same order as the old inline json! literals.

crates/rustev-cli/tests/common/harvest.rs and tools/rustev-conformance/tests/runtime.rs

Surfaces added correctly; pure run cases also get the serve surfaces, which is appropriate because run_setup always binds the rules backend.

Concrete defect – spec text contradicts code

specs/042-decision-service-and-remote-seams/spec.md line ~1308 (new hunk, ~19 lines into the + block starting at offset 1289) reads:

a refusal overloaded, queue_deadline or cancelled_before_admission is the rejection of that kind

But the runner maps RefusalCode::CancelledBeforeAdmission to the string "cancelled" (not "cancelled_before_admission"), consistent with the non-service runner's Rejection::Cancelled => "cancelled". The golden files therefore contain "rejection": "cancelled", and the description names a string that never appears in any output file.

{"head": "96d52ee9cf497c14185657da9b3a371a3c31cea1", "verdict": "findings", "findings": [{"path": "specs/042-decision-service-and-remote-seams/spec.md", "line": 1308, "summary": "Spec text says the cancelled-before-admission refusal maps to the rejection kind string 'cancelled_before_admission', but the runner and golden files use 'cancelled', consistent with the non-service runtime runner."}]}

Subject: 90dcc79...96d52ee, diff digest b9f7a4c06f9df947a33503d319ded53b3a533df0f7554d9b468cd267b68653c9, 1 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (findings)

Review

crates/rustev-cli/tests/common/harvest.rs

The guard !(repeat || parameterized) mirrors the existing condition used to gate the original surface selection. Correct.

tools/rustev-conformance/src/runtime.rs

Scripted, result_line, gated, release_all are made public and extracted for reuse. The refactor replaces inline JSON-plus-map_err with result_line (which uses expect); serialising a json! literal never fails, so the changed error contract is benign. The output format is byte-identical to what the cases record.

tools/rustev-conformance/tests/runtime.rs

Adding serve-grpc and serve-http to the runtime case surfaces, with runtime.cancel-stop kept off native for the same reason as before, is consistent with the spec text and the runner.

integrations/rustev-serve/tests/conformance/runner.rs — ordering defect in drive

In the reference implementation (runtime.rs → run), the scripted vector is populated in rc.backends order:

for b in &case.backends {          // order: rc.backends
    let s = Scripted::new(...);
    scripted.push(s);
}

Step indices (WaitGated { backend: N }, ReleaseAll { backend: N }) are defined to be indices into that vector, i.e. into rc.backends.

In the new drive function the vector is populated in rc.descriptors order (filtered for entries that have a matching script):

for name in &rc.descriptors {      // order: rc.descriptors
    ...
    if script.is_some() {
        scripted.push(backend.clone());
    }
}

The assertion scripted.len() == rc.backends.len() checks count but not order. If a runtime case has two scripted backends and their descriptors appear in a different relative order in rc.descriptors than in rc.backends, step indices address the wrong backend (e.g. WaitGated { backend: 0 } waits on backend B instead of backend A). The run function must remain the authoritative reference for how step indices bind.

specs/042-decision-service-and-remote-seams/spec.md

The new extends edge on crates/rustev-cli/tests/common/ is required because harvest.rs now names the service surfaces on run cases. The increment prose accurately describes the implementation.


{"head": "d6f5965ce775127a7fb1875fddb4f82a48e3d26c", "verdict": "findings", "findings": [{"path": "integrations/rustev-serve/tests/conformance/runner.rs", "line": null, "summary": "In `drive`, the `scripted` vector is built in `rc.descriptors` order (filtered for entries with a script), but step backend indices (e.g. `WaitGated { backend: N }`) are defined relative to `rc.backends` order as in the reference `run` function; a case whose scripted descriptors appear in a different relative order in `rc.descriptors` vs `rc.backends` will apply steps to the wrong backend."}]}

Subject: 90dcc79...d6f5965, diff digest 32acb30e43c2eaae8cd51201bbb648ac10c522c3ae72838698028bd281d14ac9, 1 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (findings)

Review

Overview

This PR adds two capabilities to the conformance runner: (1) marking every run case with serve-http/serve-grpc surfaces in the CLI harvest, and (2) a new drive function to execute runtime cases against the live decision service, with the Scripted backend made public for reuse.

Findings

source_id collision — integrations/rustev-serve/tests/conformance/runner.rs

The helper introduced to derive a context-source ID from a snapshot filename is not injective:

fn source_id(snapshot: &str) -> String {
    snapshot.trim_end_matches(".json").replace('.', "-")
}

"a.b.json" and "a-b.json" both produce "a-b". The deduplication block immediately below uses this ID as a map key:

let n = match sources.iter().position(|(id, _)| *id == source_id(&r.snapshot)) {
    Some(n) => n,           // reuses the slot for the first snapshot
    None => { ... }         // only reached on a genuinely new id
};
source_of.push(sources[n].0.clone());

If two requests in a runtime case reference different snapshot files whose source_id values collide, the second request silently receives the first snapshot, producing wrong evidence without any error. The current conformance suite may use simple, non-colliding names, but the defect is structural: any future case with snapshot names that differ only by . vs - will mis-route context fetches.

A safe fix is to use the raw snapshot filename (after stripping .json) as the source ID, or to use a hash/index instead of a derivation.


All other changes — the refactored start/registration/decide/register helpers, the drive function's step driver, Target's new Clone derive, the differential factoring, the execution-policy extraction in registration, and the Scripted/result_line visibility changes — appear correct and consistent with the spec narrative and with the runtime test logic they mirror.

{"head": "5963c66842e4b2119fd86b3c7e61295ad56dad4e", "verdict": "findings", "findings": [{"path": "integrations/rustev-serve/tests/conformance/runner.rs", "line": null, "summary": "source_id strips .json then replaces '.' with '-', making distinct filenames like a.b.json and a-b.json indistinguishable; the deduplication silently reuses the first snapshot for any later request whose snapshot name maps to the same id, causing the service to be fed wrong evidence without any error."}]}

Subject: 90dcc79...5963c66, diff digest 5ec82d91b0e75419dc00a1fcdb15b452a84479dd7474856e2216f5491ad7b631, 1 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (findings)

Reviewing the PR for concrete defects in the changed files.

integrations/rustev-serve/tests/conformance/runner.rs — drive function, task-result loop

In the block that processes each completed task, has_record is set to true for every ServeDecision response regardless of its status:

} else {
    let decision = ServeDecision::parse(&answer)…;
    …
    let status = serde_json::to_value(decision.status).unwrap();
    (result_line(id, status.as_str().unwrap(), None), true)   // ← always true
};
…
if has_record {
    let kept = r.sink.0.lock().unwrap();
    let mut record = kept
        .iter()
        .find(|rec| rec.decision_id == *id)
        .unwrap_or_else(|| panic!("{}: {id}: no delivered record", case.id))

DecisionStatus::EvidenceNotDelivered is a valid service outcome (the fail_decision sink policy, which every runtime case configures via rc.config.sink_timeout_ms, causes it when sink delivery times out). For that status, no record reaches the callback sink — the whole point of the status is that delivery failed. The find therefore returns None and the test panics unconditionally instead of producing a comparable result. The fix is to gate has_record on decision.status != DecisionStatus::EvidenceNotDelivered, mirroring how the run function in tools/rustev-conformance/src/runtime.rs handles the same outcome (it still emits record.json, because the runtime returns the record even on delivery failure; the service runner cannot do the same).

No other concrete defects found. The registration refactor (reading the actual execution policy rather than hardcoding "none"), the Scripted visibility changes, the result_line extraction, and the spec governance edits are all consistent with the rest of the diff and the governing documents.

{"head": "1dbcd329bccc8e1a3462d69c21c1465ae60197ce", "verdict": "findings", "findings": [{"path": "integrations/rustev-serve/tests/conformance/runner.rs", "line": null, "summary": "In `drive`, `has_record` is always `true` for any `ServeDecision` response, including `EvidenceNotDelivered`; the code then searches `r.sink` for the record, but `EvidenceNotDelivered` means delivery failed so the record is absent, causing an unconditional panic instead of a verifiable test assertion."}]}

Subject: 90dcc79...1dbcd32, diff digest ab3d4471e3f9b92513132f6bbb0a3ef9b14ff43349d5fc00b627aac25a2944a6, 1 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across the five changed files.

tools/rustev-conformance/src/runtime.rs — The refactor making Scripted and its helpers public is clean. The result_line extraction is mechanically equivalent to the inlined code it replaces. Scripted::new returns Arc<Self> and backend() wraps it in a Handle; callers that previously did Arc::new(Handle(s.clone())) now call s.backend(), which produces the same value. The gated / release_all promotions to pub are straightforward.

crates/rustev-cli/tests/common/harvest.rs — Adds serve-grpc and serve-http only to non-repeat, non-parameterized run cases. Condition matches what the runner filters on. Fine.

tools/rustev-conformance/tests/runtime.rs — Surface lists updated to include both serve surfaces; runtime.cancel-stop correctly omits native. Fine.

specs/042-decision-service-and-remote-seams/spec.md — Adds the extends edge on crates/rustev-cli/tests/common/ (owned by spec 006) to cover the harvest change. Increment text is consistent with the code. Status/implementation fields are not shown in the hunk but no violation is visible from what is supplied.

integrations/rustev-serve/tests/conformance/runner.rs — This is the main change. Several items examined:

  • transports() always emits HTTP (false) before gRPC (true), so the positional destructuring let [http, grpc] = per.as_slice() is consistent with the insertion order.
  • source_of de-duplication logic: after names.push, names.len()-1 gives the new index; sources.push adds at that same index; the return value indexes the just-pushed entry. Correct.
  • registration now extracts the compiled plan's execution policy. Plans with "execution": "none" emit json!("none"); plans with "declared" emit {"some": policy}. A plan with a missing or non-object execution field panics with a clear message. Acceptable for test infrastructure.
  • Backend binding names equal backend ids in the drive path: cfg["backend_bindings"][backend_id] and the bundle's bindings[backend_id] = backend_id are mutually consistent.
  • The Step::Start handler reads running.len() as the request index and waits on task.is_finished() || admission(&r.service) > before, correctly handling both immediate rejections and normal admissions.
  • The differential helper applies to both run and runtime cases, comparing per-listener HTTP vs gRPC answer bytes. The spec claims byte identity (3.17.2); the gRPC path decodes the binary trailer via .to_bytes(), yielding raw bytes that must equal the HTTP body bytes. This is a specification claim enforced at runtime, not a code defect.
  • #[derive(Clone)] on Target is required for the spawned async move blocks that capture a cloned target.

No concrete defects found.

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

Subject: 90dcc79...17680bd, diff digest 0a98628bbcd5b6262ac2ea925c2beceb54a7dbc4805aa8e9ed693b031b14123d, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 8517df9 Oct 30, 2026
30 checks passed
@bartekus
bartekus deleted the impl/042-surfaces branch October 30, 2026 22:09
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