Files
audita/docs/roadmap/implementation.md

326 lines
20 KiB
Markdown

# Runtime Glossary Inputs: Implementation Plan
Status: Ready for implementation.
Implement the target defined in [Runtime Glossary Inputs and Overlay Recipes](runtime-glossary-inputs.md).
That roadmap owns product intent, precedence, instruction semantics, and external
recipe contracts. This document owns the ordered implementation work for a Luna
coding agent.
## Scope and execution
Implement the stages in order as one end-to-end Audita sprint. Intermediate
stages may leave callers or tests temporarily uncompilable. Update callers
directly; temporary compatibility wrappers, duplicate loaders, and migration
scaffolding are unnecessary. Run focused checks when the affected path is wired,
and perform final validation in Stage 6. Follow `docs/development.md` and the
applicable agent, architecture, testing, and documentation policies.
The sprint delivers the domain-neutral Audita feature. D&D overlay implementation
and Narratio's adapter migration are independent companion work, described under
Delivery boundaries below. Do not change sibling repositories in this sprint.
No dependency upgrade, release publication, legacy flag restoration, application
configuration version bump, or new output schema is required.
Use ConfigKit v1.4.0 for native composition and CLI assignment, CommandKit and
its integrations for typed flag binding, and the existing proposal/repair path.
Do not add a local merge engine, provenance reconstruction, instruction renderer,
validator policy, or additional size limit. Retain existing library limits and
Audita validation rather than inventing restrictions on runtime inputs.
## Baseline and code map
The reviewed baseline is `f85a07c14d209b7e1f0c1a6f7a111bcfb148887a`;
subsequent planning commits may change documentation. Recheck the named code
before editing and use the graph-first discovery instructions in `AGENTS.md`.
| Responsibility | Starting points |
| --- | --- |
| Collection fields, registered entry identities, resolution and validation | `internal/core/config/config.go` and configuration tests |
| Main-source bootstrap, companions and shared native load | `internal/appconfig/config.go`, `glossary_test.go`, `secrets_test.go` |
| Processing flags and acquisition | `internal/cli/process_command.go`, `process_inputs.go` |
| Native application/prompt acquisition and invocation caching | `internal/cli/app_wiring.go`, `bootstrap.go`, `app_wiring_test.go` |
| Stage glossary selection and reuse | `internal/framework/contracts/contracts.go`, `internal/framework/preflight/preflight.go` |
| Shared proposal context and variable construction | `internal/framework/promptcontext/glossary.go`, `internal/framework/proposal_generation/variables.go` |
| Prompt definitions and omitted preview defaults | `internal/prompts/registry.go` and embedded proposal assets |
| Source protection | `internal/framework/llm/source_paths.go`, `internal/cli/process_inputs.go`, existing collision tests |
## Stage 1: Add collection instructions and retain selected context
Status: Complete.
Work:
1. Add `Instruction string` with YAML key `instruction` to
`config.GlossaryCollection`. Keep application schema version 3 and existing
entry fields, extensions, validation, and identity rules.
2. Extract the existing glossary entry sequence-identity declaration into a
small reusable definition if needed by Stage 2. The application declaration
still identifies `/glossary_collections/*/entries` by `id`; the preliminary
wrapperless load will identify `/*/entries` by the same key. Share this
definition without importing the application lifecycle into a generic loader.
3. In `ResolveModuleRunSpecs`, retain selected collection instructions alongside
the existing flattened entries and protected spellings. A small ordered
collection-name/text representation on `ModuleRunSpec` is sufficient.
Select from the stage's effective `Glossaries`, in their existing order;
definitions selected only for protection contribute no instructions.
4. Include the retained instructions when reusing a prior spec's selected
glossary data. The current `GlossarySelectionKey` already includes ordered
glossary names, protected names, and exemption behavior within one resolved
configuration. Preserve that reuse; no cross-invocation content cache is needed.
5. Add focused configuration/selection coverage for a collection instruction,
ordering, a stage-specific selection, and a protection-only collection.
Acceptance:
- Collection instructions survive native decoding and ordinary inheritance.
- Selected instructions remain available even when glossary entries are
flattened or cached; existing glossary and protection behavior is retained.
- No new entry selection, emptiness requirement, instruction validation rule,
or validator-context field is introduced.
## Stage 2: Implement the shared runtime-file acquisition bridge
Status: Complete.
Work:
1. Extend `internal/appconfig.Load` with a small options value containing the
selected overlay, existing overrides, and ordered glossary file paths. Update
internal callers to the new signature rather than retaining a second API.
Return acquisition bookkeeping containing the final native result and the
preliminary load's host-file paths; retain the separate secrets report/error
channel so existing bootstrap diagnostics work on failure as well as success.
Keep the native `*ck.Result[Config]` available unchanged to its consumers.
2. Preserve the current main-source secrets bootstrap and prepared-main reuse.
Perform preliminary glossary loading after that bootstrap and before the
final shared application load. Do not bootstrap from glossary files or use
them as the application's selected main source.
3. If the file list is empty, skip the preliminary load and glossary override.
Otherwise resolve CLI-relative paths against the invocation working directory
and load each argument as a required local file with native imports enabled.
4. Use `ck.LoadLayered` with a raw `map[string]any` configuration and only the
wrapperless glossary identity registration. Earlier arguments are individual
underlay groups in argument order; the last argument is the main input of
this preliminary load. Each group has one CLI file with its native imports.
This gives each argument a precedence tier while leaving its imports as peers.
Do not use Audita's application defaults, companion discovery, version rule,
domain resolver, or PromptKit catalog for this preliminary load.
5. Use the preliminary result's resolved native mapping directly as the value
of one `ck.Override{Path: ck.Keys("glossary_collections"),
Flag: "--glossary-file"}`. Combine it with the invocation's existing overrides
for the final application load. Do not construct one override per file or
serialize/reparse the mapping. Keep native override conflict handling for any
explicitly overlapping native overrides; add no custom ordering policy.
6. Preserve omission, explicit nulls, empty lists, entry extensions, collection
instructions and resolved native inheritance in the handoff. In particular,
do not decode incoming collections into a typed struct and then manufacture
zero-valued fields: an omitted instruction must remain omitted, allowing an
entries-only contribution to retain its configured instruction.
7. Collect acquired host file paths, including imports, from the preliminary
result's native source records. Return them as acquisition bookkeeping;
do not inject those records into the final result's provenance. Final
explanation records the single CLI override, while preliminary failures retain
the library's available file/source diagnostics.
8. Keep context cancellation checks and error causes consistent with existing
acquisition. Preliminary input failures should use the existing input-error
handling; do not classify every application/bootstrap failure as an input error.
9. Add package-level tests with real ConfigKit for both composition boundaries:
two files and an import, matching-ID whole-record replacement, retention of
unmatched entries between CLI files, and final configured-list replacement.
Include configured main/overlay values, an unrelated collection, and an
entries-only contribution retaining an instruction. Add representative
omitted/empty/null cases where they exercise the handoff, without recreating
ConfigKit's complete native test matrix.
Acceptance:
- CLI files compose natively first, then replace supplied configured sequences
through CLI assignment; unrelated configured mappings remain available.
- Existing final application resolution, validation and preflight remain the
domain owners. Earlier native parsing/decoding errors are not masked.
- Main selection, companions, overlays, bootstrap and final-result provenance
retain the boundaries specified by the feature roadmap.
## Stage 3: Connect processing flags and protect acquired source files
Work:
1. Add repeatable `--glossary-file PATH` to `processInput`/`processCommand` using
CommandKit's native repeated-string flag. Each occurrence contributes one
path in order; filenames are not JSON lists or comma-separated collection
selectors. Preserve the existing `--glossaries` and `--protected-terms` flags.
2. Introduce a small CLI acquisition input for the ordered paths, shared with
native commands in Stage 4. Centralize selected-main construction,
`appconfig.Load` invocation and bootstrap reporting in one CLI helper.
The native adapter can extract its result, while processing also receives
the acquired glossary source paths. Keep loading out of flag parsing.
3. Route `loadProcessInputs` through that helper. Build the PromptKit runtime
from the final application result, then add preliminary host-file paths to
the existing `ProtectedPaths` set alongside runtime/configuration sources.
Reuse existing collision checking and path comparison; no independent scanner
of import declarations or new filesystem protection system is needed.
4. Test a supplied glossary file and an imported file as conflicting transcript
or report destinations using the existing output-session boundary. Verify
the source remains unchanged and no model work occurs. Exercise a distinct
destination as the successful counterpart without duplicating all collision
combinations already covered by existing tests.
5. Cover a missing/malformed runtime input and an empty selected glossary stage
as input failures before model work/output preparation. Preserve quiet-mode
destination validation and cancellation behavior.
Acceptance:
- Processing accepts ordered runtime files without automatically selecting
their collections or changing the configured pipeline.
- Acquired files and imports participate in existing output collision protection,
even though their provenance is not copied into the final configuration result.
- Invocations without the new flag continue to use the established acquisition path.
## Stage 4: Wire native inspection, comparison and prompt commands
Work:
1. Replace the currently empty `struct{}` acquisition input in
`app_wiring.go` with the shared typed glossary-file input. Update loader
callbacks, factories, request callbacks and generic type arguments together.
Keep bootstrap wrappers generic and retain the native result/engine adapters.
2. Bind the repeatable selector to both application and PromptKit configuration
scopes using `ckconfig.Suite.Selectors`. Leave `Selector.AgainstName` empty:
both comparison acquisitions receive the invocation's same ordered file list,
and this feature adds no independent right-side glossary-file selector.
3. Bind the same input to configuration-consuming ckprompt resource/request
commands using that suite's native selector support. Preserve existing native
namespaces, request validation/preparation, smoke behavior and bootstrap
reporting. Help, version and discovery that do not acquire configuration
must not open these files.
4. Ensure `capturePromptEngine` reuse is scoped to the acquisition input as well
as the native selection, or otherwise relies explicitly on immutable shared
invocation input. Do not let engine reuse cross different file lists. Keep
independent native configuration comparison acquisitions independent.
5. Add behavioral tests for effective values, CLI-origin explanation, and
comparison applying files to both sides. Exercise the PromptKit configuration
scope and one resource/request path so propagation is not tested only through
the application scope. Use existing native rendering rather than custom output.
6. With a working directory different from the selected main, verify relative
CLI files resolve there, their imports resolve beside their sources, and main
companions/overlay/bootstrap still resolve from the selected main. Reuse the
existing synthetic secrets setup; no real credentials or provider are needed.
Acceptance:
- Processing and native inspection obtain equivalent final collections.
- Native inspection remains usable without processing-ready profiles or entries.
- Final explanation shows CLI assignment; load errors retain useful native
diagnostics. Source evidence does not falsely claim imported-file provenance
for the final overridden values.
## Stage 5: Render instructions in proposals and retain them during repair
Work:
1. Extend shared stage glossary variables with an instruction block prepared
from the retained ordered collection-name/text pairs. Label each nonempty
instruction with its collection name and separate blocks visibly. Preserve
the supplied text literally; do not template it, trim its content, interpret
file references, impose a new length cap, or concatenate superseded sources.
Omitted/empty strings contribute no block; the roadmap adds no whitespace-only
rejection rule. The exact separator typography is an implementation detail.
2. Populate the block in `ModuleRunSpec.PrepareGlossary` and preserve it through
`ProcessingPlan`'s prepared-context reuse. Do not change validator
`GlossaryView` or its acceptance logic to consume these instructions.
3. Expose the block through proposal variable construction as
`GlossaryInstructionsBlock`. Keep `GlossaryJSON`, `ProtectedTermsJSON`,
`SectionJSON`, and existing operator prompt expectations usable.
4. Add `GlossaryInstructionsBlock` to the empty preview defaults supplied by
`prompts.WithSharedVariables`, without overwriting a caller-provided value.
Update all four bundled proposal definitions to include the block as
glossary-use guidance alongside their existing assignments and validation
rules. Operators remain free to choose whether replacement templates use it.
5. Retain instructions through the original proposal conversation already used
by correction repair. Inspect the actual retained messages; do not introduce
another instruction load or separately regenerate guidance for repair.
6. Test ordered labeled content, empty omission, protection-only exclusion, and
reuse across repeated stages. At the rendered-message boundary, prove a
supplied instruction reaches a proposal and a subsequent correction-repair
exchange. Reuse a controlled model collaborator. Check preview preparation
when the new variable is omitted and when explicitly supplied. Assert data
visibility and relationships, not exact bundled prose or separator snapshots.
Acceptance:
- Every bundled proposal module can receive the selected collection guidance.
- Repairs retain that guidance through existing conversation history.
- Validator context, protection rules, output schemas, and repair budgets remain
unchanged; glossary instructions are generation guidance rather than new rules
for deterministic acceptance.
## Stage 6: Complete integration evidence and canonical documentation
Work:
1. Add a domain-neutral copyable runtime glossary example under `examples/`,
reusing an existing example project/overlay where practical. Demonstrate a
configured reference collection plus an incoming replacement collection and
a collection instruction. Keep data synthetic and credentials absent.
2. Add one end-to-end workflow with controlled provider responses that supplies
runtime files and selects an overlay, inspects the resulting values, runs
processing and verifies the prompt receives the selected data/instruction.
Use the coverage from earlier stages for detailed composition, errors,
collisions and repair; do not repeat the full matrix at subprocess level.
3. Update canonical owners with the delivered behavior:
- `docs/cli.md`: repeatability, commands accepting the flag and shared
comparison inputs; link to native command documentation.
- `docs/config.md`: Audita's two composition boundaries, collection
instruction setting, selection and inheritance boundary.
- `docs/integrations/transcript-glossary-files.md`: wrapperless input shape,
entry extension retention and instruction field; link the complete example.
- `docs/integrations/subprocess.md`: the supported prepared-input handoff,
existing outcomes, and links to the CLI/input owners.
- `docs/internal/prompts.md`: new proposal variable, omitted preview default
and retained repair guidance. Update focused CLI/config internals and the
example guide only where the implementation changes their descriptions.
Keep each contract in its owner; link upstream for ConfigKit/PromptKit features
rather than copying their documentation. Keep D&D examples outside Audita.
4. Run focused package tests as paths become complete, then run `go test ./...`
and `go build -o ./bin/audita ./cmd/audita` with the documented supported Go
toolchain. Keep default tests offline and use no live inference. Run formatting,
affected Markdown link/example checks, and `git diff --check`. Run additional
checks only where a concrete change warrants them; this sprint is not a release.
5. Review the full diff for accidental contract expansion: unchanged entry
eligibility, no automatic selections, no additional file/instruction limits,
no new validator rules, no promises of complete final file provenance, and
no D&D assumptions in application code. Update roadmap status to the actual
implemented Audita boundary, retaining the separate recipe contracts until
companion work owns them canonically. Commit completed work under agent policy.
Acceptance:
- The complete offline suite and source build pass for the final sprint state.
- The examples and canonical docs describe actual implemented behavior and the
native-library integration without duplicating upstream reference material.
- The feature roadmap's Audita target is delivered; external work is accurately
distinguished from completed application work.
## Delivery boundaries
The separate `audita-pipelines-dnd` checkout currently has scaffolding and stale
provisional descriptions of its recipes. Its subsequent implementation should
use the agreed contracts in the feature roadmap: the four named roles, empty
defaults that preserve supplied vocabulary, both full stage sequences, and the
two native inherited profile aliases with their selected reasoning effort.
Its README and agent guidance should then reflect those agreed contracts and
link to the delivered Audita interface. Its own offline checks and synthetic
examples belong there. Publishing that repository or selecting its release tag
is separate work and is not a gate for completing this Audita sprint.
Narratio separately replaces its legacy glossary handoff and reviews remaining
CLI/output assumptions, including `--modules`. This plan does not modify its
adapter. No Audita release number is selected here; future release preparation
follows the release policy and does not reuse an earlier versioning exception.
## Open Questions
None. The feature roadmap resolves the decisions needed for this Audita sprint;
the companion deliveries above do not require further application design choices.