Record the audit remediation review finding

This commit is contained in:
2026-11-26 03:27:00 +00:00
parent c5d8697d9f
commit cc3628e231

View File

@@ -1,118 +1,136 @@
# Core Integration API Review Remediation # Audit Remediation Review
## Review Scope ## Scope And Result
Reviewed all 24 stages of [the implementation plan](implementation.md) against Reviewed all 36 stages of [the implementation plan](implementation.md) against
commit `ab3a1f742d19ad635faceaac572ac3a2357c06fb`, including the production `c5d8697d9f645a7b3b9041769da02704bd495b7a`, including the changes since planning
changes since planning commit `c9624c4`, relevant tests, internal guides, commit `cecd68f`, their tests, the accepted
architecture policy, ADR-0026, and audit-status updates. [feature roadmap](audit-remediation.md), and current canonical
architecture/internal documentation. This is a review, not implementation.
The targeted ownership migration is implemented: typed stage preparation feeds The targeted architecture is substantially in place. Core retains typed operation
one core executor, candidate-associated information travels with its evaluation, execution; a separate capture package serves operations and one-shot validators.
and the neutral reconciliation facility prepares operations for the same The runner shares a whole-source index, separates working state from logical
executor. Domain families retain interpretation, identity, compatibility, and results, retains completed diagnostics independently of lane eligibility, and
fallback construction. One-shot model validation remains separate. The native finalizes diagnostics once. Configuration, CLI, and resolution reuse pipeline-owned
usability correction and test-oracle repair are present. No additional required layout, target selection, and pure copying. Families own scene rules, duplicate
architecture/documentation gap or inadvertently strengthened requirement was eligibility/identity, and prepared ordering keys. The executable owns cooperative
identified. Unrelated outstanding audit findings remain separate work. signals; embedded callers retain context ownership.
The correctness regression below has been addressed. The review evidence is One required failure-cause retention gap remains. No other required correctness,
retained as the historical explanation of the fix. code-quality, architectural/documentation gap, or inadvertently strengthened
requirement was substantiated in the inspected changes. The previously resolved
standalone native-executor cancellation finding remains fixed; the issue below
is at the enclosing runner's error-selection boundary.
## Finding 1 — Recheck Cancellation After Native Evaluation Evidence ## Finding 1 — Retain Drained Capture Failures Alongside Caller Cancellation
**Status:** Resolved. Core rechecks caller cancellation after initial evaluation **Priority:** P2, error integrity; requires concurrent cancellation and a capture
and deferred recording, retaining any concurrent capture failure. The focused failure, not an ordinary successful run.
`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 plan scope:** Stage 17's primary/capture/finalization cause retention,
with Stage 21's cancellation path. The aggregation finalizer itself works; the
loss occurs before that boundary receives the operation error.
**Affected stages:** 4, 6, 21, and 24. **Location:** [selectRunError](../../internal/framework/pipeline/runner_concurrent.go),
lines 402–405 at the reviewed revision; also inspect the extraction outcome
capture defer in the same file and the analogous continuation completion path.
**Location:** [executeNative](../../internal/framework/pipeline/operation_native.go), ### Behavior And Evidence
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 After started work drains, `selectRunError` immediately returns `parent.Err()`
when the caller context is canceled. This discards the recorded job errors,
including a `contracts.CaptureError` joined by operation outcome recording.
The runner's finalizer can preserve the error it receives, but cannot recover a
cause already removed by selection.
`evaluate` checks the caller context after interpretation and assessment, then A temporary offline Go test overlay exercised the real `Runner.Run` boundary:
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 1. Prepare the existing small concurrent-pipeline fixture, use one worker, and
`completeOperation` and return an accepted value with a nil error despite the supply a cancelable caller context plus an explicit evidence writer.
already-canceled context. The former `RunProducer` checked cancellation after 2. When the writer receives an extraction operation's `outcome.json`, cancel
evaluation returned; the new deterministic path also checks it after evidence that caller context and return a distinct sentinel capture error.
recording. This missing check is a regression at the new standalone core API. 3. Assert that the returned error retains `context.Canceled`, the capture
sentinel, and the typed `contracts.CaptureError`.
A deterministic offline diagnostic using a temporary Go test overlay reproduced The writer reached the boundary once. The diagnostic failed with:
the problem:
1. Execute a native operation in strict mode with no cache store and cache bypass, ```text
a fake provider returning `{"value":1}`, and an approving assessor. capture cause present=false, want=true: execute pipeline step "default": context canceled (capture writes=1)
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 The expanded diagnostic repeated this at extraction, merge, and normalization
`accepted`, and `err == nil`. Cancellation injected through the lazy evaluation outcome recording. All three combined-failure cases failed; cancellation-only
evidence projection reproduced the same result. and capture-only controls passed for each stage (six passing controls).
Cancellation remains observable, but `errors.Is(err, captureCause)` and
`errors.As(err, &captureError)` fail in the combined cases. No timing-dependent
sleep or provider call is needed. The diagnostic exists only in a temporary
overlay, not a committed production or test change.
The enclosing runner has additional cancellation handling. This review does not The selection branch predates this work set; this is an incomplete end-state
establish that the CLI publishes a successful run after cancellation; the requirement, not a newly introduced regression. Existing tests cover capture
confirmed defect is the executor's accepted return. Cache writes can mask the failure and caller cancellation separately, and cancellation plus aggregation
gap because their helper checks the context, so the regression must not depend failure, but do not cover capture failure in a drained job alongside caller
on a cache store being enabled to pass. cancellation.
### Required Change This finding does not establish successful publication after cancellation, loss
of available files, or that the standard CLI recorder forgets its own retained
write error. The confirmed issue is loss from the runner's returned error chain,
particularly relevant to explicit writer/direct framework consumers.
- Restore a caller-context check after initial evaluation and its deferred ### Required Remediation
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 - Preserve caller cancellation as the primary terminal classification, while
retaining required capture-failure causes from drained operations. Joining the
relevant typed capture failures with that primary error is sufficient.
- Keep canonical operation-error selection and sibling-cancellation suppression
for ordinary execution errors. Do not indiscriminately expose every sibling
error, add a ledger/schema, change retry/fallback behavior, or introduce shutdown
deadlines. Required capture failures are not just harmless sibling cancellation.
- Add a focused permanent runner regression at the controlled writer boundary
above. Assert cancellation and capture cause/type, no deliverable files or
successful completion, and normal drain. Exercise extraction and continuation
capture boundaries using a small table. Retain the existing core cancellation,
aggregation-prefix, native-local timeout, and capture-error tests.
The focused regression fails on the reviewed commit and passes after the fix. **Acceptance:** `Runner.Run` preserves both cancellation and the supplied capture
An ordinary successful evidence write cannot hide cancellation already observed cause/type after started work drains, without acceptance/fallback or another model
before native evaluation returns to its caller. Existing success, native-local call. Ordinary cancellation still returns cancellation; uncanceled failures retain
timeout, required-capture failure, and continuation behavior remain unchanged. their established canonical selection. Available diagnostics and capture remain
under the existing lifecycle.
Run focused operation/capture/cancellation tests and then: ## Stage-By-Stage Review Coverage
| Stages | Evidence inspected / result |
| --- | --- |
| 1–4 | Safe chunk/window arithmetic, exact rational negativity, structured producer keys, slice-view cycle tracking, and boundary regressions are present. |
| 5–9 | Citation union traversal and all ten extraction index paths match the target; run/step sharing, standalone fallback, same-ID changed layouts, grounding, scene reuse, and cache checks have focused coverage. |
| 10 | Worker tests use controlled overlap, bounded cancellation-safe handshakes, and joining; repeated focused checks pass. |
| 11–13 | Native capture is a reusable framework owner; disabled projections are guarded; shared source and operation records reach the selected sink, including explicit writers and failure/cache paths. |
| 14 | Group caps and collection truncation are removed; samples, grouping, checked counts, and selected diagnostic classification remain. Successor ADR scope is narrow. |
| 15–19 | Private working state, completed diagnostics, one aggregation pass/prefix retention, last-consumer release, and runner phases are present. Finding 1 qualifies composed cancellation/capture error retention. |
| 20–21 | Invocation-local CLI state and executable signal handling are present. Subprocess tests exercise first-signal drain and subsequent-signal termination. Finding 1 concerns the runner error chain, not signal registration. |
| 22–26 | Pure copies preserve supported containers/absence distinctions; layout and inventory are reused by config, CLI, and complete resolution. Reference/type/capability/selection boundaries remain explicit. |
| 27–31 | Scene facts have family ownership with codec differences preserved; grouping is shared across selected families, including spells, with item equality kept separate; prepared sort keys retain family ordering premises. |
| 32–35 | Prose-based assertions and private run-ID regex are removed, useful prompt/session contracts remain, example tests are independent, concurrency/lifetimes are documented, and dead declarations/alias dispositions are recorded. |
| 36 | Canonical docs and narrow ADR status updates reflect the changes. Broad checks pass, but the completion claim needs the composed failure-path correction in Finding 1. CAT-033 remains deliberately deferred. |
## Validation
Passed on the reviewed state:
```sh ```sh
go test ./... go test ./...
go vet ./... go vet ./...
go build ./cmd/notarius go build ./cmd/notarius
go test -race ./internal/framework/pipeline ./internal/framework/semanticreconcile ./internal/modules/dnd/validate/scenedescriptions/combat_semantics go test -race ./internal/framework/pipeline ./internal/framework/capture ./internal/framework/semanticreconcile ./internal/modules/dnd/shared ./internal/modules/dnd/validate/scenedescriptions/combat_semantics
go test ./internal/framework/pipeline -run 'Concurrent|Concurrency|ReverseCompletion|ReadyJobs|Cancellation|RetainsDiagnostic|Finalization' -count=10
go test ./internal/cli -run '^TestExecutableSignalsCancelAndDrainProviderWork$' -count=3
git diff --check
``` ```
## Review Validation Go reused cached results where applicable; the repeated checks ran afresh. The
additional cancellation/capture overlay failed as described. No API credentials,
The repository's full offline tests, vet, build, and the focused race command production inference, application fixes, or permanent test edits were used.
above passed on the reviewed state. `git diff --check` also passed. Go reused Local link checks found no missing targets among 199 distinct paths referenced
cached results where applicable. The additional temporary cancellation regression by the 15 changed canonical documentation files inspected.
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.