From feb83b29b3362b092e6981a6af9aaa4166c8243b Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Wed, 25 Nov 2026 17:00:25 +0000 Subject: [PATCH] Record the core API review cancellation finding --- docs/roadmap/remediation.md | 104 ++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 docs/roadmap/remediation.md diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md new file mode 100644 index 00000000..90a876db --- /dev/null +++ b/docs/roadmap/remediation.md @@ -0,0 +1,104 @@ +# Core Integration API Review Remediation + +## Review Scope + +Reviewed all 24 stages of [the implementation plan](implementation.md) against +commit `ab3a1f742d19ad635faceaac572ac3a2357c06fb`, including the production +changes since planning commit `c9624c4`, relevant tests, internal guides, +architecture policy, ADR-0026, and audit-status updates. + +The targeted ownership migration is implemented: typed stage preparation feeds +one core executor, candidate-associated information travels with its evaluation, +and the neutral reconciliation facility prepares operations for the same +executor. Domain families retain interpretation, identity, compatibility, and +fallback construction. One-shot model validation remains separate. The native +usability correction and test-oracle repair are present. No additional required +architecture/documentation gap or inadvertently strengthened requirement was +identified. Unrelated outstanding audit findings remain separate work. + +One correctness regression needs remediation before closing this work set. + +## Finding 1 — Recheck Cancellation After Native Evaluation Evidence + +**Priority:** P2, correctness; a narrow capture-enabled cancellation edge case. + +**Affected stages:** 4, 6, 21, and 24. + +**Location:** [executeNative](../../internal/framework/pipeline/operation_native.go), +particularly its deferred `captureEvaluation` call, the initial +`evaluate(result)` return boundary (currently lines 191–196), and the accepted +return (currently lines 277–284). + +### Defect And Evidence + +`evaluate` checks the caller context after interpretation and assessment, then +records evaluation evidence in a deferred function. Cancellation can become +observable during that recording even when the writer succeeds. After +`evaluate(result)` returns, the initial-execution path checks `fatal` but does +not recheck `ctx.Err()`. + +When no cache write is needed, execution can proceed directly to +`completeOperation` and return an accepted value with a nil error despite the +already-canceled context. The former `RunProducer` checked cancellation after +evaluation returned; the new deterministic path also checks it after evidence +recording. This missing check is a regression at the new standalone core API. + +A deterministic offline diagnostic using a temporary Go test overlay reproduced +the problem: + +1. Execute a native operation in strict mode with no cache store and cache bypass, + a fake provider returning `{"value":1}`, and an approving assessor. +2. Supply an evidence writer that calls the test's cancel function when recording + an `interpretations/` record, then returns nil. This injects cancellation at + the recording boundary without a timing-dependent sleep or capture failure. +3. Expect `context.Canceled` and no accepted result. + +Actual result: `ctx.Err() == context.Canceled`, `Value == 1`, disposition +`accepted`, and `err == nil`. Cancellation injected through the lazy evaluation +evidence projection reproduced the same result. + +The enclosing runner has additional cancellation handling. This review does not +establish that the CLI publishes a successful run after cancellation; the +confirmed defect is the executor's accepted return. Cache writes can mask the +gap because their helper checks the context, so the regression must not depend +on a cache store being enabled to pass. + +### Required Change + +- Restore a caller-context check after initial evaluation and its deferred + recording have completed, before acceptance or continuation is selected. + Keep cancellation fatal, without correction, fallback, or an accepted result. +- Preserve required-capture failure causes and existing native timeout + classification. Do not infer caller cancellation from an upstream timeout's + error text or sentinel when the caller context is still active. +- Add a focused core regression test using the controlled writer cancellation + above, with no cache write to supply an incidental context check. Assert + cancellation, absence of an accepted outcome, and no fallback/correction. +- Retain the existing continuation, capture-error, and cancellation tests. No + new cancellation subsystem, timeout, retry, or guarantee about the instant + after a final context check is needed. + +### Acceptance And Verification + +The focused regression fails on the reviewed commit and passes after the fix. +An ordinary successful evidence write cannot hide cancellation already observed +before native evaluation returns to its caller. Existing success, native-local +timeout, required-capture failure, and continuation behavior remain unchanged. + +Run focused operation/capture/cancellation tests and then: + +```sh +go test ./... +go vet ./... +go build ./cmd/notarius +go test -race ./internal/framework/pipeline ./internal/framework/semanticreconcile ./internal/modules/dnd/validate/scenedescriptions/combat_semantics +``` + +## Review Validation + +The repository's full offline tests, vet, build, and the focused race command +above passed on the reviewed state. `git diff --check` also passed. Go reused +cached results where applicable. The additional temporary cancellation regression +failed as described; it is diagnostic evidence, not a committed test or a code +fix. No production inference or API credentials were used, and no application +code was changed during this review.