Skip to content

impl(042): the runtime's optional progress observer - #189

Merged
bartekus merged 1 commit into
mainfrom
impl/010-runtime-observer
Oct 23, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/010-runtime-observer

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Split from #186 (its AI review timed out repeatedly). Spec 042 3.7.3: ProgressObserver and Runtime::decide_observed; events carry step id, instance ids, outcome and the derivation class the compiled step determines, never a value; observer panics are contained and counted. With no observer, every runtime test, golden and conformance case is byte-identical. Checks: rustev-runtime tests and clippy, rustev-release archives, make gate, couple.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Looking at the diff: new progress.rs module with ProgressObserver trait and StepProgress struct, wired into Runtime::decide_observed; remaining() emits callbacks for non-remote steps after ev.finish(); panics are caught with AssertUnwindSafe and counted in observer_panics.

driver.rs – progress is constructed from &s before ev.supply(s) moves s; the borrow ends when the map closure completes, so the move is safe. Dropping the MutexGuard before the observer callback is correct.

progress.rs remaining() – the filter requests.iter().any(|r| r.step == step.step && r.instance == step.instance) deduplicates against steps already reported by run_requests. This relies on the invariant that every remote-backend response in out has a matching entry in requests; if that invariant holds (it is enforced by the driver loop's structure), no step is double-reported or silently skipped.

catch_unwind(AssertUnwindSafe(…)) – acceptable for containing external callbacks, consistent with the documented constraint that observers must not hold contended locks.

Spec change (specs/042-decision-service-and-remote-seams/spec.md) – the appended note describes the feature and parenthetically cites (3.7.3). No section 3.7.3 is added by this diff, and the surrounding visible spec text does not establish one. The note is appended as a freestanding paragraph outside the numbered section structure, so the (3.7.3) label is a dangling reference: either the section was never written or it was meant to be written here as a proper ### 3.7.3 heading. Either way, the cited section number is not present in the spec as changed.

No other concrete defects: the observer_panics counter arithmetic in the test is correct (1 admitted panic + one panic per step call), lifetime annotations on DecisionCtx::observing are consistent with the enclosing run() scope, live.rs correctly passes None for the new parameter, and archive-policy.json is consistently updated.

{"head": "637a8f5d790c2dc75e4a31aff9138328a41c7066", "verdict": "findings", "findings": [{"path": "specs/042-decision-service-and-remote-seams/spec.md", "line": null, "summary": "The appended note references section '(3.7.3)' for the progress observer API, but no section 3.7.3 is created anywhere in this diff, leaving the citation dangling."}]}

Subject: 4dd5a76...637a8f5, diff digest e9a96d5e40ce35a3ea5252798b4cc96e6f9491c7cdf0633b44efcf2a20d42f64, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 23, 2026 08:18 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/010-runtime-observer branch from 637a8f5 to f1ade4e Compare October 23, 2026 08:18
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reading through the diff carefully, examining the new progress.rs module, its integration into driver.rs and lib.rs, and the tests.

progress.rs correctness

The Observing::call wraps observer calls in catch_unwind(AssertUnwindSafe(...)). The runtime ensures the evidence mutex is already released (drop(ev) in driver.rs) before calling the observer, so catching a panic here does not leave the runtime in a torn state. The AssertUnwindSafe assertion is sound.

remaining() step deduplication

Steps supplied by semantic backends appear in requests and are observed at supply time in driver.rs; remaining() skips them via the requests.iter().any(...) check. Exact steps that never enter requests are reported only by remaining(). No double-observation.

drop(ev) before observer callback

In driver.rs, drop(ev) releases the evidence MutexGuard before o.call(...). This prevents a deadlock if an observer tried to re-enter the mutex, and it is the correct pattern.

Derivation sources

Supply-time events in driver.rs always read derivation from plan.steps. remaining() reads derivation from StepStatus::Resolved { derivation } for resolved steps and from plan.steps for unresolved steps. Both values are set by the compiler, so they are identical. The split is a style difference, not a defect.

admitted() / remaining() on failure

admitted() fires after admission is acquired; remaining() is only called on the success path after ev.finish(). A cancelled decision will get admitted() but no remaining() sweep. Exact steps computed before cancellation are not reported. This is a design choice, not a code defect; the spec text does not mandate reporting on failure.

Panic counter scope

observer_panics is shared across the Runtime instance. The test accumulates counts across three decisions and the final assert_eq!(rig.rt.observer_panics(), 1 + core.steps.len() as u64) is reached after the plain (no observer) and observed (non-panicking observer) runs contribute zero, so the count is entirely from the panicking run. This is correct.

Test timing assertion

assert!(!task.is_finished(), "progress arrives while other steps are pending") is safe because the remaining backend steps remain gated; the task cannot complete until release_all is called later.

Spec update

The implementation notes added to spec 042 accurately describe the code. The (3.7.3, ...) back-reference is to a section in the unchanged part of the spec that I was not given, so I cannot confirm or deny its existence, but per the review rules this alone is not a reportable finding.

No concrete defects found.

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

Subject: 4dd5a76...f1ade4e, diff digest 27275b11b130c550d7c5c05d5906dac24f7df9a494009d87c1b752ca8d1738da, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus merged commit a5d8dc4 into main Oct 23, 2026
31 checks passed
@bartekus
bartekus deleted the impl/010-runtime-observer branch October 23, 2026 08:44
bartekus added a commit that referenced this pull request Oct 23, 2026
Split from #186, stacked on #189. The rustev-serve crate sources under
the approved binding record (A-47): HTTP/1.1 and HTTP/2 over TLS 1.3
with required client certificates, Unix sockets, the handler layer,
signed plan registration (Ed25519, offline Sigstore), decisions, the 042
3.5.1 refusal table, idempotency, lookup, cancellation, SSE streaming,
health/readiness/metrics, shutdown and standalone sinks. Every review
finding raised on #186 is already fixed here. Tests and fixtures follow
in the next PR. Checks: build, clippy, make gate, couple.
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