119 lines
6.0 KiB
Markdown
119 lines
6.0 KiB
Markdown
# 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.
|
||
|
||
The correctness regression below has been addressed. The review evidence is
|
||
retained as the historical explanation of the fix.
|
||
|
||
## Finding 1 — Recheck Cancellation After Native Evaluation Evidence
|
||
|
||
**Status:** Resolved. Core rechecks caller cancellation after initial evaluation
|
||
and deferred recording, retaining any concurrent capture failure. The focused
|
||
`TestNativeProducerOperationCancellationDuringEvaluationCapture` regression
|
||
covers both successful recording and recording failure, without cache writes,
|
||
correction, fallback, or an accepted result. Both cases failed before the fix.
|
||
|
||
**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 (lines 191–196 at the reviewed baseline), and
|
||
the accepted return (lines 277–284 at that baseline).
|
||
|
||
### 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.
|
||
|
||
## Remediation Validation
|
||
|
||
Both permanent regression cases failed before the fix and pass afterward. The
|
||
focused operation/capture/cancellation tests, full offline test suite, vet,
|
||
build, and focused race command above passed after the fix. `git diff --check`
|
||
also passed. No production inference or API credentials were used.
|