#1 [high] PR #692 correctness/contracts findings
Lens: Correctness, Contracts & System-Level Consequences. Head 7f298698, 7 files.
VERIFIED SOUND (state plainly, do not invent issues):
- runtime.rs:109-207 RequestOutcome: six states; transition() (:138-156) CAS with Acquire load / AcqRel-Acquire CAS / Relaxed fetch_add only on successful CAS. record_generated :158-168, record_completed :170-177, record_cancelled :179-186, record_failed :188-195, on_reader_drop :197-206. All terminal states absorbing -> at most one counter increment per outcome object, no decrements.
- Orderings: fail_output (runtime.rs:263-268) records FAILED before cancel(); finish_error (:502-513) records FAILED before notify_admission/first_token/try_send. emit_finished (:465-492) uses try_reserve() and records GENERATED before permit.send, so overflow (Full) routes to event_budget_exceeded (:493-501) and cannot record completion. emit (:531-549) shares event_budget_exceeded. finish_cancelled (:434-444) records before emitting Finished.
- No hot-path blocking introduced: only uncontended atomic load+CAS; no new locks; try_reserve on the existing bounded channel (same footprint as try_send). No memory amplification (AtomicU8 + Arc clone per request).
- http.rs settle sites all covered: :402-410 first-token failure, :426-434 echo apply failure, :438-452 zero-token finish (correctly no Generation held), :520-591 Finished->complete_output/fail_output (:561-566) plus generic Err arm (:582-590) which runs after generations[index] was taken so no double settle; :650 Delivery::Failed in non-streaming path. decisions/mod.rs:830-893 settles every exit; the token is moved into
promptat :836-841 so no double-settle on drop. - abort() is idempotent; Termination::ExecutionError on the decoder is additive.
FINDING 1 (Major, contracts/docs accuracy): docs/api.md:349-354 claim "Each request increments at most one of flare_requests_completed_total, flare_requests_cancelled_total, or flare_requests_failed_total." Contradicted by the PR's own n=2 test: phase_tests.rs:8896-8898 asserts failed==1 AND cancelled==1 for a single HTTP request; same at :8952-8954. Multi-choice output failure records the failing choice failed and undelivered siblings cancelled — 2 increments, 2 counters, one served request. metrics.rs:1088 repeats the per-request wording. Fix: say "each choice/model request increments at most one counter; multi-choice responses may increment failed for the rejected choice and cancelled for undelivered siblings."
FINDING 2 (Major, formal conformance / charter mandatory): docs/design-review.md:234-246 requires updating TLA+/conformance when behavior/transitions change. The ResponseLifecycle observed-edge harness still admits through runtime.generate_many (response_lifecycle_tests.rs:120-141) = defer_completion=false, so GENERATED, READER_DROPPED, and the consumer settle path (runtime.rs:158-206, 259-268, 289-294) are unreachable in ResponseLifecycle.tla despite the 365,508-transition claim and the switch of both terminal sites to emit_finished (:155, :372). Only the Rust unit tests (runtime.rs:4383-4560) cover the deferred half, and those exercise RequestOutcome directly, not Worker/HTTP. Fix: add a deferred (generate_for_output) harness/fixture or explicitly scope the TLA+ model's coverage.
FINDING 3 (Minor, behavioral/contract edge): http.rs:303-316 excludes zero-token choices from the enqueue set, so generations[i] is None for them (http.rs:346-348) and no RequestOutcome exists. A request where every choice has max_new_tokens==0 is fully served yet increments none of completed/cancelled/failed, while docs/api.md:330 now states served HTTP requests whose output validation completed are counted completed. Fix: state the exclusion in docs/api.md:330 (and the Snapshot doc metrics.rs:91) or settle a synthetic completed.
FINDING 4 (Minor, honest limitation of suppression): emit_finished suppresses only when Incoming.failure is set (runtime.rs:465-473). A consumer-side fail_output() records FAILED in the shared state but leaves Incoming.failure None, so when the worker later reaches emit_finished it still records GENERATED (no-op, state already FAILED) and still sends the Finished event. Correct for counters, but the PR's "suppresses Finished if a prior worker failure is already recorded" wording is exact; a reviewer should not read it as suppressing after consumer failure.
FINDING 5 (Minor, tests): python counter suites encode pre-change semantics and are gated off CI: tests/server/test_protocols.py:676 (n=4 disconnect => cancelled rises) and tests/server/test_decisions.py:230,257 (decision disconnect => cancelled rises). I traced the paths: cancelled is still recorded (runtime.rs:179-186 via on_reader_drop, :197-206), so no assertion is broken, but nothing exercises the new deferred expectations in-repo python/server tests.
FINDING 6 (Minor, known divergence still live): docs/api.md:706-709 still documents that parallel_tool_calls:false reports cancelled on a successful API response; http.rs:571-575 calls generation.cancel() on tool_limit_reached, and with defer_completion=true the subsequent Finished -> complete_output() records COMPLETED, then Drop's on_reader_drop() is a no-op because GENERATED was already replaced. So the documented "counted cancelled rather than completed" is now stale for this path — the docs sentence and the new deferred semantics disagree. Fix: re-check that paragraph against defer_completion before merge.
Evidence status: 1,884/254/245 counts self-reported and byte-identical to the pre-fix run; no CI on head; check.py --mutations is not invoked by .github/workflows/helios-lifecycle.yml. Not re-verified by me beyond reading code.