Files
audita/docs/roadmap/implementation.md

297 lines
18 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Shared Glossary Implementation Plan
**Status:** Planning only. 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 automatic-companion acquisition choice in **Open Questions** must be resolved
before Stage 4. Do not silently replace that part of the roadmap with a different
workflow. Stages 1–3 have independent, concrete scope.
## 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.
- 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
**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
**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 so the helper can be reused for other acquired file groups.
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
**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: Adapt Automatic Glossary Companions
**Work**
Implement the approach approved in Open Questions, retaining the roadmap's
automatic-companion outcome unless the user explicitly revises it.
1. Handle optional `glossary.yml` and recursive `glossary/` YAML companions beside
the selected main source. With no selected main, do not discover companions
from the invocation directory. Preserve native main selection and failure
behavior; do not implement a parallel configuration search algorithm.
2. Load complete companion envelopes using the Stage 2 adapter as native ordered
inputs, not strict peers. Use `glossary.yml` first, followed by recursive YAML
files in deterministic relative-path order. Imports remain relative to their
declaring files. Missing optional locations are allowed; acquired-file failures
remain failures.
3. Validate the completed companion contribution, then project entries with the
same helper as Stage 3. Apply it below main/overlay vocabulary and runtime CLI
vocabulary. Main/overlay composition remains native, including identified-list
operations; do not hand-merge glossary records.
4. Remove the old wrapperless `glossaryImports` mounting once replacement loading
is wired. Retain original companion/import paths for output collision checks.
Keep native source/explanation evidence truthful; do not invent per-file native
provenance where a preliminary result is represented by a synthetic source.
**Evidence**
Update `internal/appconfig/glossary_test.go` and source/discovery tests. Exercise
several complete companion documents, main and overlay overrides, absent main,
relative imports, extensions and invalid shared inputs. Verify source protection
and useful inspection evidence. Do not add a custom filesystem sandbox or a
universal source-snapshot guarantee.
## 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 companion glossary files, including
`examples/local/glossary.yml`, to shared envelopes. 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 companion order. 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,
companion changes and any explicitly approved configuration changes. Include
no legacy reader, automatic converter, or glossary-instruction migration.
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.
## Open Questions
### Automatic companion acquisition before typed application binding
The runtime path is straightforward: it already has explicit ordered file paths.
Automatic companions currently use `MainRelative` imports in the final native
load. Multiple complete envelopes cannot simply replace those peer imports:
their equal scalar markers conflict. ConfigKit v1.4.0's prepared source retains
the selected main context privately, but its public bootstrap report does not
expose that context for independent directory enumeration before loading.
Duplicating configuration discovery or flattening the whole application through
a generic map would add risk to source-relative PromptKit resources and metadata.
**Recommendation:** Retain automatic companions and use native sequence-item
placement to acquire complete envelopes as separate records in an additive
acquisition field, with `MainRelative` retaining native source discovery and
relative-import context. Resolve/validate the documents through the common
adapter and integrate their projected contribution at native underlay priority.
Before committing to the sprint's concrete implementation, confirm a small
public-API prototype can preserve main/overlay priority, omission semantics and
native inspection without a serialization round trip or a duplicate merge
engine. If that integration needs substantial machinery, revisit this choice
with the user rather than silently weakening Stage 4. This preserves the existing
operator workflow, at the cost of a more involved acquisition integration than
the explicit runtime path.
**Viable alternative:** For this release, use explicit shared glossary paths as
the file-loading mechanism and retire automatic glossary companion discovery,
with operator configuration/launch commands supplying those paths. This gives
one small native ordered-file loader and avoids acquisition-only fields or a
new upstream API. It requires a deliberate revision of the roadmap and migration
guidance because automatic companions are currently supported and used by
maintained examples. The user's fixed v4.3.0 release choice permits deliberate
workflow changes, but does not itself approve removing this workflow.