Files
audita/docs/roadmap/implementation.md

280 lines
16 KiB
Markdown

# Shared Glossary Implementation Plan
**Status:** In progress. Target release: Audita v4.3.0.
Implement the [shared glossary roadmap](shared-glossary.md). It owns the desired
behavior and user decisions. This plan owns implementation order and validation.
The source baseline is `1ded570`; subsequent planning commits contain no
application changes.
Read `docs/development.md` and the applicable policies before implementation.
Follow the agent, architecture, testing, documentation, OSS, and release policies;
the user's explicit selection of v4.3.0 takes precedence over ordinary version
selection. Keep application configuration version 3 and the `/v4` module path.
The stages are sized for sequential Luna prompts in one end-to-end sprint.
Intermediate stages need not compile or pass the suite. Do not introduce temporary
readers, compatibility wrappers, feature switches, or duplicate implementations
to make intermediate commits independently runnable. Run focused checks when
their dependencies are ready, then validate the integrated end state once.
The user selected explicit-file loading and retirement of automatic glossary
companion discovery. No companion-acquisition prototype or open product decision
remains. Stage 4 removes the old discovery path.
## Implementation Decisions
- Pin `glossary@0.2.0` from schemas distribution `2026.11.1`, commit
`f7e3cedeca11ed903311cdf29ca4d81fb1f216b7`. The marker remains
`maximumdirect.glossary.v1`. No schema discovery, old-format reader, upstream
validator executable, or dependency upgrade is needed.
- Keep the public runtime interface: repeated `--glossary-file PATH`, with paths
relative to the invocation working directory. Each complete document can
contain any number of collections permitted by the contract. Loading does not
select collections. Existing root/stage selections and protection behavior stay.
- Retire automatic `glossary.yml` and recursive `glossary/` discovery. Callers use
explicit `--glossary-file` arguments, including for files at those locations.
Keep native main configuration discovery, inline application vocabulary, and
automatic prompt companions. No glossary acquisition-only configuration field,
replacement scan, or new file-list configuration API is needed.
- Use ConfigKit v1.4.0 for acquisition, imports, inheritance, layers, and identity
checks. Use the existing jsonschema/v6 dependency for structural validation.
Audita supplies processing-readiness checks, not another native parser or
duplicate ID validator.
- Validate completed shared inputs before projecting away fields or distinctions.
Imported authoring fragments need not independently satisfy the root schema.
Complete runtime arguments are ordered native layers; imports within each
argument remain native peers. Repeated schema markers therefore do not collide.
- Preserve runtime CLI precedence: supplied collection entry lists replace
configured lists at the assignment boundary; unrelated configured collections
remain. ConfigKit governs omitted/null/empty assignments and record composition.
Do not introduce cross-source inheritance beyond the existing supported model.
- Keep a small one-way projection into application vocabulary: project `entries`
from shared collections. Collection provenance and unrelated extensions need
not enter prompts. In particular, a collection extension named `instruction`
must not be copied into the application's executable instruction setting.
Entry extensions remain inert. No replacement instruction API or preservation
workflow is part of this sprint.
- Preserve ordinary native inspection, diagnostics, secrets bootstrap, source
collision protection, and preflight responsibilities. Do not redesign the
runner, providers, reports, transcript formats, or correction validators.
## Stage 1: Bundle and Validate the Selected Contract
**Completed.**
**Work**
1. Add an internal `internal/appconfig/sharedglossary` package for the file-boundary
adapter. Keep ConfigKit and schema-library details out of modules and the runner.
2. Copy the unmodified `glossary/v0.2.0/` directory from the pinned distribution
into its `assets/glossary/v0.2.0/` tree, including the semantic document and
synthetic examples. Embed the schema and register it under its canonical ID.
Retain copied documents' relative references through source-distribution links
or supporting upstream documents as appropriate; do not rewrite the contract.
3. Compile the selected schema once per adapter instance and reuse it within an
acquisition. Register local resources and disable unresolved network resource
loading. Follow the repository's existing response-schema compiler patterns
where useful, without combining glossary and LLM-response registries.
4. Expose validation of a resolved `map[string]any` envelope. Preserve the original
map; schema validation must not coerce, default, or mutate values. Return errors
retaining useful field locations and caller-supplied file/source context.
5. Add the schema component to `docs/oss/attribution.md`, with pinned source,
material scope, copyright and CC0-1.0 identification, and the verbatim license
text under `docs/oss/licenses/`, following the OSS House Format. Review the
project third-party statement for any required reference update.
**Evidence**
At the adapter boundary, test an ordinary valid envelope, missing/wrong marker,
missing entries, invalid known field types, nullable aliases/plural, and permitted
extensions. Include upstream synthetic examples without copying its complete
test suite. Demonstrate offline compilation/validation. ID uniqueness belongs to
the native-loading tests in Stage 2, not a new handwritten validator here.
## Stage 2: Compose Runtime Shared Documents Natively
**Completed.**
**Work**
1. Move the runtime-file composition block from `internal/appconfig.Load` into the
shared-glossary adapter. Accept `context.Context` and an ordered list of
`ck.Input` sources for explicitly supplied glossary files.
2. Keep imports enabled. Load earlier arguments as separate underlay groups and
the final argument as the main input through `ck.LoadLayered[map[string]any]`,
preserving existing relative-import behavior and native ordered precedence.
3. Register entry identities at `collections/<any mapping key>/entries` using
`SequenceIdentityMatching` with identity field `id`. Do not register at the
old wrapperless root. Reuse/adapt `config.GlossaryEntryIdentity` rather than
writing a second identity algorithm.
4. Apply Stage 1 structural validation to the completed native result. Keep the
distinction between legal layering of an identity and duplicate identities
within a final collection. Do not require each imported contribution to carry
a marker, and do not synthesize missing markers to repair supplied data.
5. Return the completed envelope plus native source records needed by acquisition
and collision protection. Propagate cancellation and native errors. No files
means no shared input contribution; it does not mean an invalid empty document.
**Evidence**
Use real temporary files and native loading. Cover one multi-collection document,
multiple single-collection documents, mixed arrangements, ordered identity
updates, relative imported fragments, duplicate IDs, and repeated equal markers
across layers. One focused failure case is enough to establish propagation of a
native unsupported input; do not reproduce upstream parser tests or freeze its
current restrictions as permanent Audita behavior.
## Stage 3: Integrate Runtime Vocabulary with Application Loading
**Completed.**
**Work**
1. Replace the old wrapperless runtime-load block in `internal/appconfig.Load`
with Stage 2 acquisition. Retain the existing secrets-bootstrap ordering and
prepared main source, embedded PromptKit resources, overlay, and CLI overrides.
2. Project each validated shared collection to an application contribution
containing its `entries` only. Preserve entry values accepted by the contract;
the existing native typed binding can produce `config.GlossaryEntry` records.
Do not YAML/JSON round-trip maps to obtain a typed projection.
3. Assign projected collections through the existing native
`ck.Override{Path: ck.Keys("glossary_collections"), Flag: "--glossary-file"}`
boundary. This preserves list replacement, unrelated configured collections,
and the current effective-config CLI origin without recreating precedence.
4. Keep `GlossarySources` evidence for runtime files and imports. Preserve
`GlossaryInputError` wrapping and `errors.As`/cancellation behavior so the CLI
continues to use native error formatting and existing input/runtime outcomes.
5. Use the same acquisition from `acquireApplication`, `loadApplication`,
`loadPromptEngine`, and `loadProcessInputs`. Do not add per-command parsers.
Configuration comparison continues to apply the same files to both sides.
**Evidence**
Update `internal/appconfig/runtime_glossary_test.go` and its error/presence cases
for shared envelopes. Verify effective selected vocabulary and native origins,
runtime replacement of configured entry lists, retention of unrelated collections,
and source paths for imports. A shared collection's `instruction` extension must
be accepted even when its value is not an application instruction string, and
must not be bound as executable guidance. No legacy instruction-preservation
assertions are required.
## Stage 4: Retire Automatic Glossary Companion Discovery
**Completed.**
**Work**
1. Delete the `glossaryImports` synthetic import manifest and its underlay input
from `internal/appconfig/config.go`. Remove glossary-discovery-only helpers or
wiring that become unused. Do not replace them with another scan or discovery
mechanism.
2. Retain the automatic PromptKit import manifest and its native `MainRelative`
binding, embedded resources, configuration search/selection, secrets bootstrap,
overlays, and normal application imports. Inline `glossary_collections` remain
supported. Removing glossary discovery does not remove other companion types.
3. Files named `glossary.yml` or located in `glossary/` are ordinary explicit
inputs when supplied with `--glossary-file`. Native imports from those selected
inputs still work, and all selected/imported source paths stay protected
against output collisions.
4. Keep runtime precedence unchanged. There is no remaining automatic glossary
underlay: callers migrating to explicit files now receive CLI assignment
priority over main/overlay vocabulary and whole-list replacement at that
boundary. No lower-priority compatibility mode or precedence switch is needed.
**Evidence**
Retire assertions that require automatic glossary discovery in
`internal/appconfig/glossary_test.go` and source/discovery tests; retain coverage
of ordinary inline/imported application vocabulary and unrelated acquisition.
Add a focused regression showing that invalid nearby `glossary.yml` and nested
`glossary/` content do not affect loading when unselected. Show that the same
locations work as explicit shared inputs, and selected imports remain protected.
Retain automatic-prompt and main-discovery checks. No filesystem access trace or
custom sandbox is needed to establish removal of the discovery path.
## Stage 5: Verify Selection, Preflight, and CLI Integration
**Work**
1. Keep `glossary.Select`, protected vocabulary, root/stage selection resolution,
and `framework/preflight.ProcessingPlan` on their current semantics. Change
types or helper boundaries only where needed to consume the adopted data.
2. Preserve empty-schema-data versus processing-readiness distinctions: inspection
can accept empty collections; glossary correction needs at least one selected
entry; nonexistent selected collections fail. Loading never selects everything.
3. Update CLI help for the shared file format while retaining argument grammar.
Adapt fixtures across CLI acquisition, native inspection/comparison, subprocess
processing, and example integration tests. Preserve existing exit/stream rules.
4. Retain ordinary preflight local planning and optional provider smoke checks.
Use controlled HTTP responses for representative processing verification;
real providers, Narratio installations, and external recipe repositories are
not required to complete the sprint.
**Evidence**
Prove a representative shared multi-collection file reaches the intended
correction/protection views, and repeated files work through native inspection
and comparison. Verify preflight and processing reject malformed data or missing
required selections before correction requests. Retain a local-only preflight
case using real glossary inputs and a synthetic transcript. Existing collision
tests should cover a glossary import as a protected source. Avoid duplicating
format-validation matrices at every CLI boundary.
## Stage 6: Update Examples and Canonical Documentation
**Work**
1. Convert maintained runtime and former companion glossary files, including
`examples/local/glossary.yml`, to shared envelopes. Update example commands
and integration fixtures to pass those files explicitly with `--glossary-file`.
Keep inline application `glossary_collections` examples in the application
format. Include a generic domain and a synthetic Narratio-style
multi-collection/spell example, plus an
equivalent separate-file invocation. No application-specific vocabulary copy
should be needed to use a shared spell input.
2. Update `docs/integrations/transcript-glossary-files.md`, `docs/config.md`,
`docs/cli.md`, `examples/README.md`, and affected internal acquisition guides.
Identify the exact selected contract, marker, native composition and assignment
boundaries, selections, and retirement of automatic glossary discovery.
Distinguish retained automatic prompt companions. Link upstream for shared
fields and ConfigKit behavior rather than reproduce their manuals.
3. Add `docs/migrations/v4.3.md` explaining the envelope cutover, file arrangements,
explicit arguments replacing automatic companion discovery, and the move from
companion underlay priority to runtime CLI priority. Explain list replacement
and retained collection selection. Include no legacy reader, automatic
converter, glossary-instruction migration, or new configuration field for
file selection.
4. Draft `docs/releases/v4.3.0.md` and update the release index with the exact
release title, migration impact, and required tag-specific licensing footer.
This is preparation only; do not push or publish a release.
5. Update the deferred Narratio adoption entry in `docs/roadmap/future.md` to
reference the delivered shared boundary. Do not implement Narratio or modify
its adapter/recipe repositories in this sprint.
**Evidence**
Validate maintained examples through the application integration tests and check
affected links and `git diff --check`. Preserve upstream contract assets verbatim
and verify their selected source/licensing record. Do not retire this plan as
completed until the integrated sprint has actually passed its acceptance checks.
## Stage 7: Complete Integrated Validation and Cleanup
Use Go 1.27.4 as documented in `docs/release.md`. Prepare dependencies if needed
before running the offline suite; dependency upgrades are not part of adoption.
1. Run focused tests for `internal/appconfig/...`, `internal/core/config`,
`internal/core/glossary`, `internal/framework/preflight`, and `internal/cli`
after their respective implementations become runnable. Reuse unchanged
passing checks rather than repeat them at each stage.
2. Run `go test ./...` and `go build -o ./bin/audita ./cmd/audita` with
`GOWORK=off GOTOOLCHAIN=local GOPROXY=off GOSUMDB=off` for the final integrated
implementation. Keep inference/network boundaries controlled by existing tests.
3. Review the final diff for wrapperless file readers, redundant validators,
instruction compatibility work, serialization round trips, or temporary
scaffolding. Remove only obsolete code and assertions belonging to this change.
4. Check all feature-roadmap acceptance outcomes against evidence. Record any
remaining gap rather than changing tests to conceal it. Follow ordinary agent
commit discipline; publication remains a separate authorized task.