Define the remaining audit remediation roadmap
This commit is contained in:
378
docs/roadmap/audit-remediation.md
Normal file
378
docs/roadmap/audit-remediation.md
Normal file
@@ -0,0 +1,378 @@
|
||||
# Audit Remediation Roadmap
|
||||
|
||||
## Status, Purpose, And Ownership
|
||||
|
||||
**Status:** Target design and scope accepted; detailed implementation planning
|
||||
and implementation pending.
|
||||
|
||||
This roadmap defines the end state and required work for the remaining
|
||||
[audit catalog](audit/catalog.md) findings, incorporating the accepted decisions
|
||||
in the [discussion record](audit/discussion.md). It is the feature/design handoff
|
||||
to a planning agent, not the worker's detailed execution plan. No application
|
||||
changes are implemented by this document.
|
||||
|
||||
The catalog owns finding inventory, evidence links, and implementation status.
|
||||
The discussion preserves decision rationale. This roadmap owns the consolidated
|
||||
target and scope; a subsequent implementation plan will own ordered worker
|
||||
stages, concrete dependencies, verification, and progress. Original audit reports
|
||||
describe their historical baseline and are not instructions to restore superseded
|
||||
behavior, particularly diagnostic group caps.
|
||||
|
||||
Planning baseline: `f1b62bdf532118ffc62d0e2bdaefc429bb495df2`. The
|
||||
[core/integration API migration](core-integration-api.md) and its
|
||||
[review remediation](remediation.md) are complete. CAT-007, CAT-015, CAT-016, and
|
||||
CAT-034 are resolved. Of the 30 remaining catalog entries, 29 are in scope here;
|
||||
CAT-033 is deliberately deferred. Recheck affected callers against current source
|
||||
when planning, since the core migration partially addressed several findings.
|
||||
|
||||
## Goals And Preserved Boundaries
|
||||
|
||||
The resulting application has clear owners for composition, operation execution,
|
||||
capture, run finalization, and reusable domain mechanics. Ordinary execution avoids
|
||||
unnecessary source-scale work. Failure preserves completed-work diagnostics and
|
||||
error causes without retaining obsolete intermediates. Tests protect meaningful
|
||||
contracts while permitting legitimate changes to prose and private structure.
|
||||
|
||||
Continue the fixed typed pipeline and native ConfigKit, PromptKit, and CommandKit
|
||||
architecture. Core retains the implemented operation lifecycle; integrations own
|
||||
domain interpretation, identity, prompts, correction assignments, and fallback
|
||||
construction. Generic framework changes must remain usable by non-D&D integrations.
|
||||
No upstream dependency upgrade is required by this roadmap.
|
||||
|
||||
Preserve configured validation, strict/permissive disposition, cache identity and
|
||||
reuse controls, generated-reference eligibility, domain schemas, durable identity
|
||||
bytes, and artifact-first output. PromptKit continues to own native structural
|
||||
validation/repair, continuation mechanics, and backend admission. Maintain the
|
||||
bounded worker pool without adding another scheduler or retry mechanism.
|
||||
|
||||
The selected behavior changes are diagnostic group-cap removal, whole-source
|
||||
capture sharing, cooperative process signals, and correction of cataloged defects.
|
||||
Refactoring elsewhere preserves established configuration, CLI, acceptance,
|
||||
ordering, and output contracts. Debug layout remains private. No new result
|
||||
envelope, durable report sidecar, configuration interpreter, resource-management
|
||||
framework, or generalized normalization engine is selected.
|
||||
|
||||
## Target Design And Required Work
|
||||
|
||||
### 1. Correct Accepted Boundary Inputs
|
||||
|
||||
**Findings:** CAT-001, CAT-002, CAT-011, CAT-012, CAT-013.
|
||||
|
||||
Correct the documented edge cases at their existing owners without narrowing
|
||||
accepted inputs to make the implementation easier:
|
||||
|
||||
- Generic chunking handles extreme accepted sizes without overflowing allocation
|
||||
arithmetic or endpoints; ordinary overlap behavior remains intact.
|
||||
- Timestamp validation checks exact negativity even when float conversion
|
||||
underflows. Preserve finiteness, precision, zero/negative-zero handling, and
|
||||
ordering without a new magnitude limit.
|
||||
- Reconciliation context expansion handles extreme nonnegative radii using
|
||||
source-distance-aware arithmetic, retaining the existing material budget.
|
||||
- Generated producer lookup uses distinct structured step/lane keys rather than
|
||||
delimiter encodings that collide for accepted identifiers. Do not prohibit NUL
|
||||
characters as a substitute for fixing lookup identity.
|
||||
- Metadata copying distinguishes finite shared-prefix slice views from real
|
||||
cycles. Preserve detached concrete containers, cycle rejection, and useful
|
||||
error paths; do not ban shared backing arrays or use a JSON round trip.
|
||||
|
||||
Reproduce static counterexamples at their actual boundaries and retain focused
|
||||
regressions alongside ordinary cases. These fixes do not depend on the broader
|
||||
composition/copying refactor.
|
||||
|
||||
### 2. Source Work Proportional To What Is Needed
|
||||
|
||||
**Findings:** CAT-004, CAT-005.
|
||||
|
||||
Citation text resolution resolves, sorts, and coalesces selected source ranges,
|
||||
then visits selected units rather than allocating a document-wide bitmap and
|
||||
scanning the entire document per record. Preserve source order, errors, one
|
||||
inclusion of overlapping evidence, and newline joining, including empty, sparse,
|
||||
disjoint, invalid, and non-monotonic-ID cases.
|
||||
|
||||
Prepare one immutable whole-source position index at the run/source lifetime for
|
||||
sharing by applicable extraction jobs. Retain local construction for standalone
|
||||
callers. Preserve whole-document resolution, current-source checks on cache hits,
|
||||
and isolation between runs and sources. A chunk-only index or process-global cache
|
||||
does not satisfy this target. Select the small passing/ownership API during
|
||||
planning; do not introduce a generalized caching facility.
|
||||
|
||||
### 3. A Reusable Native Capture Owner And Convenient Evidence
|
||||
|
||||
**Findings:** CAT-003, CAT-024, CAT-032.
|
||||
|
||||
Extract native request capture into a focused framework package. It owns prepared
|
||||
request hooks/snapshots, native result and exchange evidence, and capture-error
|
||||
retention, using PromptKit types and the existing `EvidenceWriter` directly.
|
||||
Core operations and independently executing validators use the same implementation.
|
||||
This is required ownership work, independent of any performance improvement.
|
||||
|
||||
Pipeline retains operation identity and step/lane/chunk evidence paths. CLI and
|
||||
recorder retain filesystem allocation, run-level capture lifecycle, and finalization.
|
||||
Prefer a dedicated capture package over expanding storage-oriented debug; exact
|
||||
names remain implementation choices. Preserve prepared-value ownership,
|
||||
cancellation and capture causes, admission behavior, cache-hit evidence, and
|
||||
existing observations without duplicate preparation or model calls. Do not add
|
||||
a telemetry service, replacement execution interface, or synchronized writer wrapper.
|
||||
|
||||
Finish guarding expensive debug-only construction at its owning boundaries when
|
||||
capture is disabled, including deferred chunk outcomes and run-wide envelopes.
|
||||
The core migration's lazy operation projections are a starting point, not proof
|
||||
that all CAT-003 work is complete. Required artifact encoding still runs normally.
|
||||
|
||||
For enabled capture, use the most convenient representation:
|
||||
|
||||
- Record original input and complete parsed source once per run. Operation inputs
|
||||
reference them using clear logical bundle paths through the same capture sink.
|
||||
Explicit writer consumers receive shared and operation records alike, without
|
||||
an assumed CLI filesystem root or records written to another destination.
|
||||
- Keep particular chunks, operation selections, selected reference contents, and
|
||||
incoming artifacts directly readable within operation evidence initially.
|
||||
- Keep convenient native prepared messages, responses, and exchanges, including
|
||||
useful duplication. Reading a prepared request needs no reconstruction tool.
|
||||
- A complete bundle preserves whole-source context; an isolated operation directory
|
||||
need not carry a whole transcript. Logical references require no symlink scheme.
|
||||
|
||||
Keep requested capture required and its failures visible. Retain secret-aware
|
||||
omissions and actual available evidence. No generalized deduplication, capture
|
||||
modes, silent truncation, quotas, automatic deletion, or heuristic scrubbing is
|
||||
included. Private filenames remain implementation choices.
|
||||
|
||||
### 4. Completed Diagnostics And One Runner Finalization Boundary
|
||||
|
||||
**Findings:** CAT-006, CAT-008, CAT-009, CAT-022; CLI coordination in CAT-023.
|
||||
|
||||
Use private working state and one clear runner finalization boundary across
|
||||
success, failure, and cancellation. The returned logical result does not retain
|
||||
private execution accumulators, normalized working bytes, or reuse bookkeeping
|
||||
after their last consumers. Extract cohesive source, chunk/map, and output phases
|
||||
so stage ordering and failure boundaries are readable without a generic dispatcher.
|
||||
|
||||
Collect completed-operation diagnostics independently of lane continuation or
|
||||
publication eligibility, including after draining work on failure. Preserve
|
||||
canonical lane/chunk ordering with sparse and out-of-order completions, without
|
||||
double counting. Incomplete lanes produce no artifacts or generated handoffs.
|
||||
|
||||
Diagnostic volume alone cannot fail an otherwise successful pipeline. Remove the
|
||||
local producer group-count cap and final warning/non-warning group-count caps,
|
||||
including collection-level truncation/omission machinery used solely by those
|
||||
caps. Retain every distinct group, occurrence counts, and representative sampling
|
||||
within each group, initially the existing three examples and omitted-sample counts.
|
||||
Do not replace removed caps with configuration or an exhaustive diagnostic ledger.
|
||||
|
||||
Genuine diagnostic-contract, arithmetic-overflow, reporting, and requested-capture
|
||||
failures remain failures. Preserve the primary and relevant finalization causes
|
||||
alongside available valid diagnostics, without repeating a failed aggregation.
|
||||
Preserve cancellation precedence. Existing errors can describe incompleteness;
|
||||
no new report schema is needed. Keep completion reporting and fallback disclosure.
|
||||
|
||||
Release references to reorder maps, extraction values, and other intermediates
|
||||
after their final consumers on success and failure, including while slower sibling
|
||||
lanes continue. Do not clear shared backing storage or discard data needed for
|
||||
handoff, capture, encoding, or completed-work diagnostics.
|
||||
|
||||
### 5. Clear CLI Lifecycle And Cooperative Signals
|
||||
|
||||
**Findings:** CAT-010, CAT-023.
|
||||
|
||||
Keep the native command declaration small, with a cohesive private invocation and
|
||||
finalization owner. Preserve one configuration/engine, supplied-value semantics,
|
||||
capture allocation before preparation, cause retention, and distinct execution,
|
||||
physical publication, and report-delivery outcomes. The runner returns logical
|
||||
results; CLI publishes artifacts, completes capture, and presents native reports.
|
||||
This is separate from runner phase control and introduces no new command framework.
|
||||
|
||||
At the executable boundary, the first SIGINT or SIGTERM cancels the invocation
|
||||
context so dispatch stops, native requests cancel, started jobs drain, and ordinary
|
||||
failure/capture finalization runs. A subsequent signal permits ordinary process
|
||||
termination and may interrupt finalization. Add no shutdown deadline/configuration
|
||||
or SIGKILL guarantee. Embedded callers retain ownership of their contexts and
|
||||
receive no process-wide signal handlers from application invocation.
|
||||
|
||||
Cancellation initiates no fallback or model retry and makes no successful completion
|
||||
claim. Retain existing cache entries, published artifacts, and available debug
|
||||
evidence under the established lifecycle. Use a small standard-library adapter and
|
||||
focused offline subprocess coverage with a local fake backend; do not promise
|
||||
cooperation from collaborators that ignore cancellation.
|
||||
|
||||
### 6. Pipeline Interpretation And Pure Copying At Their Owner
|
||||
|
||||
**Findings:** CAT-014, CAT-017, CAT-018.
|
||||
|
||||
Within the existing pipeline package, provide shared catalog-independent structural
|
||||
layout and catalog-aware selected-target inventory. Layout establishes ordered
|
||||
steps/lanes and identities; inventory selects modules/defaults/variants and reference
|
||||
slots without requiring them to be populated. Complete resolution reuses these
|
||||
operations. CLI discovers targets, supplies bindings, then checks completeness;
|
||||
do not introduce a partial/allow-missing mode in the full resolver.
|
||||
|
||||
ConfigKit and its application integration retain loading, imports, inheritance,
|
||||
source presence, and provenance. CLI retains selector grammar and precedence.
|
||||
Pipeline resolution/preparation retains complete binding, capabilities, exact type
|
||||
compatibility, validator selection/order, and generated-dependency checks.
|
||||
|
||||
Place pure copying beside pipeline-owned types. Preserve values and distinguish
|
||||
copying from trimming, defaults, and normalization. Inventory supported mutable
|
||||
option containers before consolidating copies; preserve omission, explicit empty,
|
||||
explicit zero, and detached ownership. Remove redundant copies where ownership
|
||||
permits, without imposing universal immutability or a reflection-based copier.
|
||||
Source-metadata cycle handling remains a separate responsibility.
|
||||
|
||||
Decompose resolution into cohesive same-package helpers and per-binding checks
|
||||
while retaining useful error context. Demonstrate reuse through configuration,
|
||||
resolver, and CLI callers and independent selection/isolation tests, rather than
|
||||
moving duplicated logic into smaller files.
|
||||
|
||||
### 7. Family-Owned Rules And Shared Deterministic Mechanics
|
||||
|
||||
**Findings:** CAT-019, CAT-020, CAT-021.
|
||||
|
||||
Put reusable scene checks with a small scene-family domain owner; tiny predicates
|
||||
may live beside domain types. Normalizers and validators use it. Validator adapters
|
||||
retain extraction-specific cardinality, assessment classification, and corrective
|
||||
prose. Codec acceptance shares only identical primitives, preserving differences
|
||||
such as trimmedness and the optional nature of selectable checks.
|
||||
|
||||
Introduce a pure duplicate-grouping helper returning retained positions and groups.
|
||||
Start with NPC occurrences, location occurrences, and combat turns. Families supply
|
||||
eligibility and identity keys, and own sorting, cloning, original-input-index
|
||||
mapping, and diagnostics. Include spells only if its nil/allocation behavior fits
|
||||
cleanly. Leave item occurrences separate initially, preserving its bucket-plus-
|
||||
exact-equality check. Do not collapse distinct evidence, combine evidence ranges,
|
||||
or make domain eligibility rules uniform to simplify the helper.
|
||||
|
||||
Calculate invariant sorting keys once per normalized record using the existing
|
||||
combat approach. Preserve ties, invalid-reference ordering, and defensive comparison
|
||||
for inputs whose canonical form is not established. Genuine evidence tie comparison
|
||||
may still require linear work. This improvement is independent of duplicate sharing.
|
||||
Use independent family expectations; no universal normalizer or sorting framework.
|
||||
|
||||
### 8. Explicit Extension Contracts And Maintainable Tests
|
||||
|
||||
**Findings:** CAT-025, CAT-026, CAT-027, CAT-028, CAT-029.
|
||||
|
||||
Document sharing and lifetimes in module internals and interface comments:
|
||||
prepared extractors, extraction validators, and shared codecs can receive overlapping
|
||||
calls; per-operation mutable state stays local/operation-owned, intentionally shared
|
||||
mutable state is synchronized, and shared source is read-only. Describe each stage's
|
||||
actual call pattern rather than claiming every module method runs concurrently.
|
||||
The runner waits for dispatched operations, not arbitrary extension goroutines;
|
||||
extensions own their background work's lifetime relative to borrowed collaborators.
|
||||
|
||||
Custom writers shared across concurrent operations must support concurrent calls;
|
||||
point to the standard synchronized recorder. Defer a synchronized wrapper until
|
||||
a concrete serial-only consumer needs one. Link native client/observer/callback
|
||||
contracts upstream and explain where Notarius shares them. Add no automatic writer
|
||||
serialization, per-job module construction, or blanket locking.
|
||||
|
||||
Include these test improvements explicitly:
|
||||
|
||||
- Replace incidental production-English assertions and message-location markers
|
||||
with test-controlled content and behavioral preparation/binding checks. Preserve
|
||||
schemas, input/default selection, required properties, cache hints, and follow-up
|
||||
routing. Prompt quality remains a human review concern, not a prose snapshot.
|
||||
- Replace sleep-induced overlap and unbounded handshakes with explicit start/release
|
||||
gates, bounded cancellation-safe failure handling, and joining started work.
|
||||
Preserve worker limits and ordering; test watchdogs create no runtime deadline.
|
||||
- Separate maintained-example checks and independent resolved fixtures, retaining
|
||||
useful integration coverage without shared-map execution-order dependence.
|
||||
- Remove the private run-ID format regex while preserving uniqueness, safe paths,
|
||||
collision/allocation behavior, and partial-write protection. Keep the separate
|
||||
versioned session-ID contract and its exact-value protection.
|
||||
|
||||
### 9. Remove Obsolete Metadata And Helpers
|
||||
|
||||
**Findings:** CAT-030, CAT-031.
|
||||
|
||||
Recheck and delete the audit's confirmed unused private policy labels and three
|
||||
private helpers. Preserve live identity constants/bytes, keys, reason codes,
|
||||
schemas, guidance, and similarly named live helpers. Do not resurrect policy
|
||||
fingerprints or alter cache keys to give dead labels a purpose.
|
||||
|
||||
Give the six exported internal `NormalizationPolicy` aliases a short intended-use
|
||||
review. Remove those without a supported purpose; explicitly defer any whose
|
||||
purpose remains unclear. Capitalization alone establishes no external API, and
|
||||
this review requires no broad compatibility initiative. Existing behavioral tests
|
||||
suffice for declaration deletion; add no count/absence tests.
|
||||
|
||||
## Coverage And Disposition
|
||||
|
||||
All catalog entries have the following disposition; section numbers identify the
|
||||
target above, not mandatory worker stage numbers.
|
||||
|
||||
| Catalog entries | Disposition / target |
|
||||
| --- | --- |
|
||||
| CAT-001, CAT-002, CAT-011, CAT-012, CAT-013 | Required: section 1 boundary correctness |
|
||||
| CAT-004, CAT-005 | Required: section 2 source work |
|
||||
| CAT-003, CAT-024, CAT-032 | Required: section 3 capture |
|
||||
| CAT-006, CAT-008, CAT-009, CAT-022 | Required: section 4 finalization and lifetimes |
|
||||
| CAT-010 | Required: section 5 signals |
|
||||
| CAT-023 | Required: sections 4–5 CLI/runner separation |
|
||||
| CAT-014, CAT-017, CAT-018 | Required: section 6 composition and copying |
|
||||
| CAT-019, CAT-020, CAT-021 | Required: section 7 domain mechanics |
|
||||
| CAT-025, CAT-026, CAT-027, CAT-028, CAT-029 | Required: section 8 contracts and tests |
|
||||
| CAT-030, CAT-031 | Required: section 9 cleanup; aliases have the stated conditional disposition |
|
||||
| CAT-007, CAT-015, CAT-016, CAT-034 | Already resolved; preserve established behavior |
|
||||
| CAT-033 | Deferred; retain the matcher until representative workloads justify optimization |
|
||||
|
||||
Deferral does not mean a defect was fixed. No token-matching algorithm replacement,
|
||||
name-length cap, or new benchmark gate is part of acceptance. Future email/NWS
|
||||
integrations, broader domain/package migration, release publication, and upstream
|
||||
feature work are outside this remediation.
|
||||
|
||||
## Planning Handoff And Sequencing
|
||||
|
||||
Prepare one detailed implementation plan for a worker to execute in order. Keep
|
||||
the completed core migration's plan/history intact. Use this roadmap as the target;
|
||||
the planner selects concrete Go signatures, files, and independently reviewable
|
||||
stages, without reopening accepted policy choices or treating historical audit
|
||||
recommendations as stronger authority than the decisions here.
|
||||
|
||||
Recommended ordering is narrow correctness fixes, ordinary-run source efficiency,
|
||||
capture ownership/representation, finalization and shutdown, composition/domain
|
||||
helpers, and remaining cleanup/final acceptance. This is dependency guidance, not
|
||||
an artificial serial dependency between independent fixes. Improve fragile tests
|
||||
before relying on them, and update interface documentation with affected changes.
|
||||
Keep package extraction distinguishable from evidence behavior changes and narrow
|
||||
bug fixes distinguishable from readability refactors.
|
||||
|
||||
For each worker stage, identify the catalog coverage, scope, prerequisites,
|
||||
observable completion criteria, relevant validation, and documentation updates.
|
||||
Verify current callers and partial fixes before prescribing changes. Ensure no
|
||||
required finding disappears inside a broad refactor and no resolved finding becomes
|
||||
a second migration. Report any newly discovered conflict rather than silently
|
||||
strengthening inputs, acceptance, or compatibility requirements.
|
||||
|
||||
The planner should specify a usable intermediate state and focused commits. Detailed
|
||||
test commands and exact stage boundaries belong in that plan; no new framework or
|
||||
mandatory test matrix is needed to express them. Handing off or executing that plan
|
||||
is subsequent work, not part of creating this roadmap.
|
||||
|
||||
## Verification And Completion
|
||||
|
||||
Use [testing policy](../policy/testing.md) to select focused, offline behavior tests.
|
||||
Correctness regressions must demonstrate the defect at the relevant boundary.
|
||||
Retain independent domain-output expectations for ordering, identity, and acceptance;
|
||||
exercise cancellation, capture failure, and completed-diagnostic retention where
|
||||
lifecycle changes affect them. Run relevant race checks for changed concurrent
|
||||
paths and repository-wide `go test ./...`, `go vet ./...`, and
|
||||
`go build ./cmd/notarius` at shared-contract milestones and final acceptance.
|
||||
Reuse successful checks for unchanged content; default tests need no credentials
|
||||
or paid model calls. Claim measured speedups only when measured, without a new
|
||||
coverage, benchmark, complexity, or broad-audit gate.
|
||||
|
||||
Update canonical internal, architecture, authoring, and operator documents when
|
||||
their behavior lands. Reconcile diagnostic cap removal and whole-source sharing
|
||||
with ADR-0015/ADR-0024 through successor decisions/status links as appropriate,
|
||||
preserving accepted ADR bodies. Keep configuration/CLI references unchanged unless
|
||||
an implemented selected behavior actually requires an update.
|
||||
|
||||
Completion requires all required coverage rows to have implemented target behavior
|
||||
and appropriate verification, including capture extraction, ordinary-run costs,
|
||||
failure paths, source/option isolation, family output preservation, and explicit
|
||||
test cleanup. Record alias-review dispositions. Catalog statuses must identify
|
||||
what was actually resolved; CAT-033 remains deferred. Canonical documentation,
|
||||
implementation status, and code must agree. A smaller file, green happy-path test,
|
||||
or closed finding count alone is not evidence of completion.
|
||||
|
||||
There are no unresolved product or scope decisions. Remaining API details and
|
||||
stage decomposition are implementation planning choices within these boundaries.
|
||||
Reference in New Issue
Block a user