315 lines
16 KiB
Markdown
315 lines
16 KiB
Markdown
# Audit Remediation Discussion
|
||
|
||
## Purpose And Status
|
||
|
||
This document consolidates the review recommendations for the
|
||
[audit catalog](catalog.md) into an ordered discussion for maintainers. The
|
||
catalog owns the finding inventory and prioritization; its linked audit reports
|
||
own detailed evidence and qualifications. This document owns the open choices
|
||
and subsequent discussion decisions, not another audit or a completed
|
||
implementation plan.
|
||
|
||
Prepared on 2026-11-24 against catalog revision
|
||
`5a0650250686353cf34fbbbf0e780b04f60e70c1`. All recommendations below remain
|
||
proposals. No remediation or policy change is approved merely by its inclusion
|
||
here. Record decisions in the corresponding item as discussion proceeds.
|
||
|
||
The review supports the existing typed pipeline and native-kit architecture.
|
||
The strongest opportunities are removing repeated interpretation, unnecessary
|
||
work, and retained state. No replacement workflow, retry, configuration, or
|
||
resource-management framework is indicated. Smaller files and more helpers are
|
||
useful only when they make ownership and callers clearer.
|
||
|
||
Work through Items 1–10 in order. Items 1–3 contain explicit behavior choices;
|
||
Items 4–8 principally need bounded implementation analysis. Items 9–10 settle
|
||
scope and sequencing. This discussion order is not a mandatory implementation
|
||
order, and unresolved choices need not delay independent fixes.
|
||
|
||
## 1. Diagnostic Capacity And Pipeline Success
|
||
|
||
**Findings:** CAT-009; related CAT-008 and CAT-022.
|
||
**Status:** Open behavior decision.
|
||
|
||
CAT-009 identifies a real loss of aggregation errors and available diagnostics.
|
||
Its suggested remediation also preserves the existing policy that exceeding the
|
||
warning-group bound can fail an otherwise successful pipeline. These are separate
|
||
issues: fixing error loss does not require endorsing that policy indefinitely.
|
||
|
||
The recommendation is to reconsider whether diagnostic volume alone should
|
||
invalidate acceptable artifacts. This is particularly relevant to the
|
||
artifact-first direction. Possible designs include bounded presentation with an
|
||
explicit overflow indication, or removing an unnecessary group-count cap. Neither
|
||
should conceal fallback/degradation or suppress genuine execution and diagnostic
|
||
contract errors.
|
||
|
||
Questions to settle:
|
||
|
||
- Should exceeding a diagnostic capacity limit fail the pipeline?
|
||
- If not, should the collection retain all groups or retain a bounded summary
|
||
with explicit omitted-information reporting?
|
||
- What information must remain available on failure, and how should an incomplete
|
||
diagnostic collection be identified without adding another report protocol?
|
||
|
||
The initial preference is against failing acceptable artifact production solely
|
||
because diagnostic volume exceeds a reporting limit. This is a proposed policy
|
||
change, not authority to silently truncate actionable warnings. Existing bounded
|
||
aggregation is retained by [ADR-0015](../../adr/0015-separate-process-warnings-from-quality-diagnostics.md)
|
||
and [ADR-0024](../../adr/0024-publish-artifacts-with-native-reports-and-debug-evidence.md).
|
||
Any selected change must be reconciled with those decisions and canonical
|
||
documentation when implemented.
|
||
|
||
**Decision:** Pending.
|
||
|
||
## 2. Convenient Debug Evidence And Repeated Full-Source Capture
|
||
|
||
**Findings:** CAT-024; distinguish the independent CAT-003 fix.
|
||
**Status:** Open representation decision.
|
||
|
||
Repeating a full source for every chunk and lane has a credible capacity cost,
|
||
including on cache hits. Self-contained operation evidence also serves the
|
||
deliberate convenience goal recorded in
|
||
[ADR-0024](../../adr/0024-publish-artifacts-with-native-reports-and-debug-evidence.md).
|
||
|
||
Choose the most convenient representation, not automatically the most concise,
|
||
complete, or deduplicated one. Consider sharing bulky immutable whole-source
|
||
material while keeping operation-specific inputs, prepared messages, and native
|
||
exchanges directly inspectable. Evaluate that proposal through a concrete task:
|
||
opening the evidence for one failed extraction and understanding its actual input.
|
||
|
||
Questions to settle:
|
||
|
||
- Which repeated material is useful at each operation, and which would be just
|
||
as convenient through a clear bundle-local reference?
|
||
- Can an operator inspect a failure without assembling inputs manually or needing
|
||
a new reconstruction tool?
|
||
- How would direct `EvidenceWriter` consumers retain useful evidence when they
|
||
do not have a CLI filesystem bundle containing shared material?
|
||
|
||
Preserve actual inputs and available native evidence, secret-aware omissions,
|
||
and requested-capture failure behavior. No silent truncation, quotas, automatic
|
||
deletion, or new scrubbing machinery is proposed. CAT-003 can independently guard
|
||
expensive evidence construction when capture is disabled without changing any
|
||
enabled-capture representation.
|
||
|
||
**Decision:** Pending.
|
||
|
||
## 3. Process Signals And Cooperative Cancellation
|
||
|
||
**Finding:** CAT-010.
|
||
**Status:** Open, narrowly scoped behavior decision.
|
||
|
||
Connect supported process signals to the existing cancellation path at the
|
||
executable boundary. The recommendation is for the first SIGINT or SIGTERM to
|
||
request cooperative cancellation and normal cleanup, with a subsequent signal
|
||
permitting ordinary process termination. Preserve caller-owned contexts for
|
||
embedded execution.
|
||
|
||
Settle the repeated-signal behavior before implementation. A focused subprocess
|
||
test with a local fake backend can verify cancellation and available terminal
|
||
capture evidence. This does not require a shutdown framework, a new deadline,
|
||
SIGKILL handling, or guarantees for collaborators that ignore cancellation.
|
||
|
||
**Decision:** Pending.
|
||
|
||
## 4. One Owner For Pipeline Interpretation And Pure Copying
|
||
|
||
**Findings:** CAT-014, CAT-017, CAT-018; coordinate CAT-012 where files overlap.
|
||
**Status:** Open technical design review.
|
||
|
||
These are high-value consolidations. Sketch small shared operations for structural
|
||
layout, selected-target inventory, and pure copying of pipeline-owned values.
|
||
Keep full compatibility resolution distinct from inventory: CLI reference
|
||
selection must work before its bindings satisfy required references.
|
||
|
||
Before implementation:
|
||
|
||
- Identify the reusable layout and selection results and their callers. Keep raw
|
||
ConfigKit presence/provenance checks and CLI grammar/precedence with their owners.
|
||
- Inventory supported mutable option representations. Preserve established
|
||
omission, explicit-empty, and explicit-zero behavior and detached ownership.
|
||
- Separate identifier trimming/defaulting from copying; copying must not silently
|
||
change the configuration being inspected.
|
||
- Decompose resolution around these owners rather than organizing three cleaner
|
||
copies of the same interpretation.
|
||
|
||
A short API sketch and representative callers should be sufficient. No new
|
||
configuration framework, general intermediate representation, arbitrary reflection
|
||
copier, or package split is presumed necessary. The generated-key correctness fix
|
||
does not depend on completing this broader consolidation.
|
||
|
||
**Decision:** Pending.
|
||
|
||
## 5. Producer State And Shared Reconciliation Lifecycle
|
||
|
||
**Findings:** CAT-015 and CAT-016; coordinate CAT-007.
|
||
**Status:** Open technical design review.
|
||
|
||
Make delivered-candidate state, invalidation, assessment, and terminal disposition
|
||
explicit. Small private phase results may make the producer clearer than coupled
|
||
mutable closure variables. Keep native execution, continuation history, structural
|
||
repair, and admission with PromptKit.
|
||
|
||
For NPC, item, and location normalization, share only the demonstrated common
|
||
reconciliation lifecycle. Families retain preprocessing, identity, typed proposal
|
||
application, fallback validity, prompts, and diagnostic meaning. Every proposal
|
||
continues to apply afresh to fixed originals.
|
||
|
||
Before committing to a helper, show how a representative family caller becomes
|
||
easier to follow. Avoid replacing readable procedures with an elaborate callback
|
||
framework. Verify final-turn assessment, candidate invalidation, cancellation,
|
||
capture errors, cache hits, and strict/permissive outcomes through existing
|
||
behavioral boundaries.
|
||
|
||
CAT-007 is a narrower correction: retain native failed-validation details and
|
||
distinguish a completed failed content check from an operational native error.
|
||
A small shared usability check should suffice. Preserve producer disposition and
|
||
validator unavailability as distinct caller outcomes. Correct the misleading test
|
||
oracle without introducing another validation protocol or extending repair budgets.
|
||
That fix need not wait for the broader producer refactor.
|
||
|
||
**Decision:** Pending.
|
||
|
||
## 6. Finalization, Completed Diagnostics, And Intermediate Lifetimes
|
||
|
||
**Findings:** CAT-006, CAT-008, CAT-009, CAT-022; coordinate CAT-023 at the CLI boundary.
|
||
**Status:** Open technical design review; overflow policy depends on Item 1.
|
||
|
||
Design diagnostic collection and lifetime reduction together. Completed work's
|
||
diagnostics must survive a later failure before its intermediate values are
|
||
released. Diagnostic availability must not depend on whether an incomplete lane
|
||
became eligible for continuation or publication.
|
||
|
||
Prefer one clear finalization boundary and, where practical, separate private
|
||
execution accumulators from the returned public result. This may be simpler than
|
||
clearing a growing list of fields at many exits. Release owner references after
|
||
their last consumers; do not clear shared backing storage or discard information
|
||
still needed for handoffs, evidence, or encoding.
|
||
|
||
Preserve stable diagnostic order without double counting, primary and relevant
|
||
finalization causes, and existing cancellation precedence. Do not repeat failed
|
||
aggregation. Keep incomplete-lane artifacts ineligible for publication.
|
||
|
||
The runner and CLI have different lifecycle responsibilities. Simplify each
|
||
locally: runner phase control and logical results; CLI configuration, capture,
|
||
physical publication, and terminal presentation. Preserve distinct execution,
|
||
publication, and report-delivery outcomes without a new command framework or
|
||
result envelope. Related defects remain independently testable even when their
|
||
implementation shares a finalization path.
|
||
|
||
**Decision:** Pending.
|
||
|
||
## 7. Shared Domain Rules And Exact-Duplicate Bookkeeping
|
||
|
||
**Findings:** CAT-020 and CAT-021; coordinate CAT-019 where normalization changes overlap.
|
||
**Status:** Open technical scope review.
|
||
|
||
Share genuinely identical rules and mechanics, with domain behavior remaining
|
||
family-owned. For scenes, separate reusable pure predicates from selectable
|
||
validator assessment and corrective prose. Codec acceptance and optional shape
|
||
validation differ; sharing the whole validator would strengthen the codec contract.
|
||
|
||
For exact duplicates, start with the families whose bookkeeping demonstrably
|
||
matches. Keep eligibility, identity keys, ordering, cloning, and diagnostics local.
|
||
Item occurrences' bucket-plus-equality check must remain intact; keeping that
|
||
variant separate is preferable to weakening equality or complicating all callers.
|
||
|
||
Review representative callers and independent expected outputs before expanding
|
||
the shared surface. No universal normalizer or repository-wide movement of every
|
||
shape check is proposed. CAT-019's invariant sort-key preparation can proceed
|
||
locally while preserving tie and invalid-reference ordering.
|
||
|
||
**Decision:** Pending.
|
||
|
||
## 8. Extension And Capture Concurrency Obligations
|
||
|
||
**Finding:** CAT-025.
|
||
**Status:** Proposed documentation clarification; optional support choice remains open.
|
||
|
||
Document the actual shared-instance, immutable-source, callback, and operation
|
||
lifetime model in canonical internals and interface comments. Current default
|
||
implementations were not found to race; this is clarity for extension authors
|
||
and direct framework consumers.
|
||
|
||
The recommendation is to state existing caller-side concurrency obligations for
|
||
explicit capture writers and point to the safe recorder. Supporting serial-only
|
||
writers would be a separate choice. If needed, serialization must wrap the shared
|
||
writer at the appropriate lifetime; separate operation mutexes do not serialize
|
||
one shared sink. No general addition of locks or serialization of extraction is
|
||
proposed. Upstream-owned callback/client rules should remain linked upstream.
|
||
|
||
**Decision:** Pending.
|
||
|
||
## 9. Cleanup Scope And Optional Improvements
|
||
|
||
**Findings:** CAT-026 through CAT-033.
|
||
**Status:** Proposed scope; confirm before treating every entry as required work.
|
||
|
||
- Remove the confirmed private dead helpers and obsolete policy labels
|
||
(CAT-030/CAT-031), preserving live identity bytes and behavior. No new tests of
|
||
declaration counts or absence are needed.
|
||
- Give the six exported `NormalizationPolicy` aliases a short intended-use check.
|
||
They reside under `internal/`; capitalization alone does not establish a
|
||
supported external API. Do not turn unused internal metadata removal into a
|
||
broad compatibility project, or recreate cache fingerprints to give it a use.
|
||
- Remove incidental prompt-prose/run-ID assertions, use controlled scheduling in
|
||
concurrency tests, and separate order-dependent example fixtures
|
||
(CAT-026–CAT-029). Preserve genuine schema, routing, ownership, worker-limit,
|
||
and maintained-example contracts. Do not replace fragile assertions with
|
||
snapshots or add tests for every private helper.
|
||
- Treat native-capture package extraction (CAT-032) as optional. Proceed only if
|
||
a small direct API improves ownership and callers; a package move alone is not
|
||
a demonstrated behavior improvement.
|
||
- Treat a KMP token matcher (CAT-033) as optional. Ordinary short entity names
|
||
make the current matcher effectively linear. Assess representative workloads
|
||
before paying additional algorithm maintenance cost; no benchmark gate or
|
||
name-length restriction is proposed.
|
||
|
||
Deferral or declining a refactoring opportunity can be a valid outcome. Closing
|
||
every catalog entry through code changes is not itself the goal.
|
||
|
||
**Decision:** Pending.
|
||
|
||
## 10. Remediation Sequence And Verification
|
||
|
||
**Scope:** Incorporate the preceding decisions into a focused implementation plan.
|
||
**Status:** Proposed sequence, not implementation authorization or new release gates.
|
||
|
||
Recommended approach:
|
||
|
||
1. Fix narrow correctness defects with focused regressions: CAT-001/CAT-002,
|
||
CAT-011–CAT-013, and native classification/test-oracle handling in CAT-007.
|
||
Preserve supported inputs rather than imposing new restrictions. Reproduce
|
||
static counterexamples at their real boundaries when implementing the fixes.
|
||
2. Prioritize ordinary-run costs in CAT-003–CAT-005 alongside failure visibility
|
||
in CAT-008/CAT-009. Keep disabled capture cheap, avoid full-document scans for
|
||
sparse citations, and share one immutable source index at the appropriate
|
||
run/source lifetime. Preserve standalone use and current-source cache checks;
|
||
no process-global cache or new cache-key dimensions are needed.
|
||
3. Add signal cancellation after Item 3, then undertake coherent ownership work
|
||
in the composition/copying, producer/reconciliation, and finalization clusters.
|
||
Shorten intermediate lifetimes only after their remaining consumers are clear.
|
||
Keep correctness changes distinguishable from broader readability refactors.
|
||
4. Apply local sort-key improvements and useful domain sharing. Fold confirmed
|
||
dead-code and test cleanup into focused work where convenient. Reassess the
|
||
optional package and token-matcher changes last.
|
||
|
||
This is an ordering guide, not a serial dependency chain. Cheap independent fixes
|
||
can proceed without waiting for broader discussion. Practical reachability and
|
||
maintenance benefit matter alongside severity; exotic boundary cases can be easy
|
||
to correct without displacing ordinary-run improvements.
|
||
|
||
Use focused behavioral regressions and existing independent family/boundary tests.
|
||
Run broader offline checks and relevant race tests according to
|
||
[testing policy](../../policy/testing.md) when shared behavior changes. Do not
|
||
duplicate the upstream libraries' test suites or turn audit coverage/complexity
|
||
metrics into new targets. Source analysis establishes avoidable work, but measured
|
||
end-to-end speedups should be claimed only if measured.
|
||
|
||
Update canonical behavior documentation when implementation lands. Record any
|
||
significant changed architectural decision without rewriting accepted ADR bodies.
|
||
Keep the catalog's evidence and qualifications linked rather than duplicating
|
||
all ten reports in an implementation plan. CAT-034 is already resolved and
|
||
requires no further remediation.
|
||
|
||
**Decision:** Pending.
|