Complete Phase 13 glossary module
This commit is contained in:
@@ -34,19 +34,22 @@ Implemented today:
|
||||
- Proposal-generation diagnostics artifacts with secret redaction.
|
||||
- Production module registry scaffolding with known-key recognition and explicit unsupported/unimplemented errors.
|
||||
- Production `grammar` module implementation in `internal/modules/grammar`.
|
||||
- Production `glossary` module implementation in `internal/modules/glossary`.
|
||||
- Explicit runtime support for `--modules grammar` through the production runner path.
|
||||
- Explicit runtime support for `--modules glossary`, including repeated stages such as `--modules glossary,glossary`.
|
||||
|
||||
Not implemented in CLI runtime path today:
|
||||
- Real module execution pipeline for `glossary`, `homophones`, and `spoken_word`.
|
||||
- Real domain proposal prompts for production modules.
|
||||
- End-to-end transcript polishing with real module behavior.
|
||||
- Real module execution pipeline for `homophones` and `spoken_word`.
|
||||
- Real domain proposal prompts for remaining production modules.
|
||||
- End-to-end transcript polishing with the full default module sequence.
|
||||
|
||||
Phase sequencing note:
|
||||
- Phase 9 LLM infrastructure is complete (structured client, scheduler, effective config resolution, diagnostics primitives);
|
||||
- Phase 10 LLM-backed validator runtime integration is complete;
|
||||
- Phase 11 shared proposal-generation framework and module-registry scaffolding are complete;
|
||||
- Phase 12 grammar module implementation and explicit runtime wiring are complete;
|
||||
- next recommended phase is Phase 13 (glossary module and protected-term behavior).
|
||||
- Phase 13 glossary module and protected-term behavior are complete;
|
||||
- next recommended phase is Phase 14 (homophones module).
|
||||
|
||||
## Actual Go package layout
|
||||
|
||||
@@ -109,6 +112,10 @@ internal/modules/grammar/
|
||||
module.go
|
||||
prompt.go
|
||||
|
||||
internal/modules/glossary/
|
||||
module.go
|
||||
prompt.go
|
||||
|
||||
internal/framework/validators/
|
||||
models.go
|
||||
deterministic.go
|
||||
@@ -144,17 +151,17 @@ Current runtime flow (`internal/cli/run.go`):
|
||||
10. Chunk normalized transcript and compute chunk summaries.
|
||||
11. Write chunking summary artifact.
|
||||
12. Execute runner modules sequentially when:
|
||||
- `--modules` is explicitly provided (production grammar path); or
|
||||
- `--modules` is explicitly provided (production grammar/glossary paths); or
|
||||
- a test/injected module factory is provided.
|
||||
13. Output working transcript to `--output` file or stdout.
|
||||
14. Build process report (`phase` currently set to `phase12-grammar-module`).
|
||||
14. Build process report (`phase` currently set to `phase13-glossary-module`).
|
||||
15. Optionally write `--report-json`; always write run-dir `report.json`.
|
||||
16. Apply work-dir retention.
|
||||
|
||||
Important behavior details:
|
||||
- Glossary is validated but not yet used for real correction module logic.
|
||||
- Glossary is validated and is used for explicit glossary/grammar module correction paths.
|
||||
- Default production CLI behavior remains deterministic normalization/chunking/reporting unless modules are explicitly selected with `--modules`.
|
||||
- Explicit `--modules grammar` runs the production grammar module path with LLM-backed proposal generation and validator-chain execution.
|
||||
- Explicit `--modules grammar` and `--modules glossary` run production module paths with LLM-backed proposal generation and validator-chain execution.
|
||||
- Default runs (without explicit module selection) do not perform LLM calls.
|
||||
- Success path is generally quiet on stderr.
|
||||
- Source IDs are preserved into a canonical transcript before normalization; normalization then reassigns output IDs sequentially from `1`.
|
||||
@@ -203,7 +210,7 @@ Implemented config surfaces include:
|
||||
- work-dir and retention mode
|
||||
|
||||
Current caveat:
|
||||
- LLM/module-related settings are active for explicit grammar runs; the default non-explicit path remains deterministic.
|
||||
- LLM/module-related settings are active for explicit grammar/glossary runs; the default non-explicit path remains deterministic.
|
||||
|
||||
## Implemented structured LLM infrastructure
|
||||
`internal/framework/contracts` now defines a typed structured-completion contract:
|
||||
@@ -220,7 +227,7 @@ Current caveat:
|
||||
|
||||
Current runtime boundary:
|
||||
- the default CLI runtime path (without explicit module selection) still does not instantiate the full production module sequence.
|
||||
- LLM calls are exercised in production when `--modules grammar` is explicitly requested and in tests when fake/injected clients are used.
|
||||
- LLM calls are exercised in production when `--modules grammar` or `--modules glossary` is explicitly requested and in tests when fake/injected clients are used.
|
||||
|
||||
`internal/framework/llm` also provides:
|
||||
- a bounded `Scheduler` for controlled concurrent LLM calls with reliable permit release;
|
||||
@@ -262,7 +269,7 @@ Current behavior details:
|
||||
|
||||
`internal/framework/contracts` provides interfaces and run-spec metadata scaffolding, including deterministic repeated module instance naming (`ResolveModuleRunSpecs`).
|
||||
|
||||
These primitives are wired into the production runner and report model. The grammar module is implemented; other production modules remain pending.
|
||||
These primitives are wired into the production runner and report model. The grammar and glossary modules are implemented; other production modules remain pending.
|
||||
|
||||
## Implemented validator runtime infrastructure
|
||||
`internal/framework/validators` provides deterministic validator infrastructure:
|
||||
@@ -327,7 +334,7 @@ This helper only produces candidate proposals; validator-chain execution and pro
|
||||
- diagnostics directory context
|
||||
- returns explicit errors for unknown keys (`unsupported_module`) and recognized-but-unimplemented keys (`unimplemented_module`).
|
||||
|
||||
The `grammar` module key is now registered and constructible. `glossary`, `homophones`, and `spoken_word` remain recognized-but-unimplemented.
|
||||
The `grammar` and `glossary` module keys are now registered and constructible. `homophones` and `spoken_word` remain recognized-but-unimplemented.
|
||||
|
||||
## Implemented grammar production module
|
||||
`internal/modules/grammar` now provides the first production module:
|
||||
@@ -340,6 +347,27 @@ The `grammar` module key is now registered and constructible. `glossary`, `homop
|
||||
- grammar confidence threshold enforcement through existing validator/config infrastructure;
|
||||
- module-level reporting and diagnostics capture through existing runner/reporting paths.
|
||||
|
||||
## Implemented glossary production module
|
||||
`internal/modules/glossary` now provides the second production module:
|
||||
- prompt builder aligned to Python glossary-module intent, constrained to glossary-backed domain/acoustic corrections;
|
||||
- prompt context includes glossary names, aliases, categories, summaries, and plural forms where available;
|
||||
- guardrails against broad style rewriting and against replacing unrelated terms simply because they appear in glossary entries;
|
||||
- proposal generation through `internal/framework/proposal_generation` and `contracts.StructuredLLMClient`;
|
||||
- scheduler-aware proposal calls through existing `contracts.LLMScheduler` hooks;
|
||||
- replacement policy `replace_all` (matching Python glossary behavior);
|
||||
- validator chain integration using existing deterministic + LLM-backed validators;
|
||||
- glossary confidence threshold enforcement through existing validator/config infrastructure;
|
||||
- module-level reporting and diagnostics capture through existing runner/reporting paths;
|
||||
- explicit support for repeated glossary stages with deterministic instance names (`glossary_1`, `glossary_2`, ...), where later stages see prior-stage working transcript changes.
|
||||
|
||||
## Implemented protected-term behavior
|
||||
`internal/framework/validators/protected_terms.go` provides deterministic glossary-derived protected vocabulary:
|
||||
- extracts protected terms from glossary names and aliases;
|
||||
- includes explicit plural fields and synthetic plural forms where safe;
|
||||
- deduplicates and returns stable ordering for repeatable behavior/tests.
|
||||
|
||||
This vocabulary is used by deterministic validators for both glossary-stage and non-glossary-stage protection checks, keeping protected-term guardrails active across modules.
|
||||
|
||||
## Reports and diagnostics (implemented)
|
||||
Current per-run artifacts include:
|
||||
- `source-transcript.json`
|
||||
@@ -379,7 +407,7 @@ Retention modes implemented in `ApplyRetention`:
|
||||
|
||||
Current runtime note:
|
||||
- default non-explicit runs usually have no module-level skipped corrections, so `auto` commonly removes clean successful run directories.
|
||||
- explicit grammar runs can produce validator rejections and application skips, which are reflected in reports and retention input.
|
||||
- explicit grammar/glossary runs can produce validator rejections and application skips, which are reflected in reports and retention input.
|
||||
|
||||
Intentionally deferred to module/LLM phases:
|
||||
- real domain proposal prompts and production module implementations remain tied to later module phases.
|
||||
@@ -401,13 +429,15 @@ Implemented tests currently cover:
|
||||
- shared proposal-generation request/response parsing, deterministic indexing, scheduler hooks, and diagnostics redaction (`internal/framework/proposal_generation/*_test.go`, `internal/framework/runner/*_test.go`)
|
||||
- production module-registry known-key recognition and unsupported/unimplemented error behavior (`internal/framework/modules/*_test.go`, `internal/cli/run_test.go`)
|
||||
- production grammar module prompt constraints, proposal mapping, validator-chain behavior, confidence-threshold enforcement, diagnostics redaction, and explicit CLI/runtime integration (`internal/modules/grammar/*_test.go`, `internal/cli/run_test.go`, `internal/framework/runner/*_test.go`)
|
||||
- production glossary module prompt constraints, proposal mapping, validator-chain behavior, confidence-threshold enforcement, diagnostics redaction, repeated-stage behavior, and explicit CLI/runtime integration (`internal/modules/glossary/*_test.go`, `internal/cli/run_test.go`, `internal/framework/runner/*_test.go`)
|
||||
- glossary-derived protected-term extraction and stable behavior (`internal/framework/validators/protected_terms_test.go`)
|
||||
|
||||
Not covered yet (because not implemented): production `glossary`, `homophones`, and `spoken_word` modules plus full default-sequence transcript-polishing runtime behavior.
|
||||
Not covered yet (because not implemented): production `homophones` and `spoken_word` modules plus full default-sequence transcript-polishing runtime behavior.
|
||||
|
||||
## Intended final architecture (not yet implemented)
|
||||
The intended end-state still matches the rewrite plan:
|
||||
- sequential module pipeline over a mutable working transcript
|
||||
- real module implementations (`glossary`, `homophones`, `spoken_word`, `grammar`)
|
||||
- real module implementations (`homophones`, `spoken_word`)
|
||||
- structured LLM proposal generation
|
||||
- deterministic and LLM validators
|
||||
- validator cardinality enforcement in pipeline execution
|
||||
|
||||
@@ -61,6 +61,10 @@ Implemented:
|
||||
- Production module-registry scaffolding with known key recognition and explicit unsupported/unimplemented errors.
|
||||
- Production grammar module package with Python-aligned prompt intent and guardrails.
|
||||
- Explicit `--modules grammar` runtime path through runner, shared proposal generation, validators, application, reporting, and diagnostics.
|
||||
- Production glossary module package with Python-aligned prompt intent and guardrails.
|
||||
- Glossary-derived deterministic protected-term extraction and validator integration.
|
||||
- Explicit `--modules glossary` runtime path through runner, shared proposal generation, validators, application, reporting, and diagnostics.
|
||||
- Repeated glossary stage support with deterministic instance names (`glossary_1`, `glossary_2`), including mutable working-transcript handoff.
|
||||
- Broad deterministic and CLI/subprocess test coverage for implemented phases through `go test ./...`.
|
||||
- Internal typed structured LLM contract (`StructuredLLMClient.CompleteStructured(ctx, req, out)`).
|
||||
- `internal/framework/llm` instructor-go-backed adapter with:
|
||||
@@ -76,9 +80,9 @@ Implemented:
|
||||
- Generic JSON diagnostics primitives for LLM interactions (request metadata, request payload, response payload, optional error payload) with secret redaction.
|
||||
|
||||
Not yet implemented in runtime pipeline:
|
||||
- Real correction modules for `glossary`, `homophones`, and `spoken_word`.
|
||||
- Real correction modules for `homophones` and `spoken_word`.
|
||||
- Domain proposal prompts for remaining real modules.
|
||||
- End-to-end transcript polishing behavior.
|
||||
- End-to-end transcript polishing behavior with the full default module sequence.
|
||||
|
||||
## Completed phases
|
||||
|
||||
@@ -216,7 +220,7 @@ Not implemented in Phase 8 (by design):
|
||||
|
||||
## Remaining work plan
|
||||
|
||||
Next recommended phase: **Phase 13 (glossary module and protected-term behavior)**.
|
||||
Next recommended phase: **Phase 14 (homophones module)**.
|
||||
|
||||
## Phase 9: Structured LLM client and scheduler infrastructure
|
||||
|
||||
@@ -362,44 +366,28 @@ Not implemented in Phase 12 (by design):
|
||||
|
||||
## Phase 13: Glossary module and protected-term behavior
|
||||
|
||||
### Purpose
|
||||
Completed.
|
||||
|
||||
Implement the glossary correction module and the glossary-derived protection behavior needed by downstream modules.
|
||||
Implemented:
|
||||
- Production glossary module package in `internal/modules/glossary`.
|
||||
- Glossary prompt builder aligned to Python intent and constrained to glossary-supported domain/acoustic corrections.
|
||||
- Prompt context using glossary names, aliases, categories, summaries, and plural forms where available.
|
||||
- Glossary proposal generation through shared `internal/framework/proposal_generation` using `contracts.StructuredLLMClient`.
|
||||
- Scheduler-aware glossary proposal generation through existing scheduler hooks.
|
||||
- Glossary replacement policy `replace_all` (matching Python behavior).
|
||||
- Glossary validator chain using existing deterministic and LLM-backed validators.
|
||||
- Glossary confidence threshold enforcement through existing config + confidence-threshold validator behavior.
|
||||
- Deterministic glossary-derived protected-term extraction (`internal/framework/validators/protected_terms.go`) from names, aliases, and plural forms, with stable deduplicated ordering.
|
||||
- Protected-term validator behavior remaining available to non-glossary modules via existing deterministic validators.
|
||||
- Explicit runtime support for `--modules glossary` through normalization, chunking, runner, proposal generation, validation, application, and reporting.
|
||||
- Repeated glossary-stage support (`--modules glossary,glossary`) with deterministic instance naming and mutable working-transcript handoff across stages.
|
||||
- Prompt/response diagnostics artifacts for glossary proposal + validator interactions with secret redaction.
|
||||
- Module-level reports for glossary including generated proposals, validator decisions/rejections, applied changes, and application skips.
|
||||
- CLI/runtime fake-client tests for approved proposals, validator rejection, application skips, repeated stages, diagnostics, failure/error.log behavior, and report outputs (`--report-json` and run-dir `report.json`).
|
||||
|
||||
### Scope
|
||||
|
||||
Implement:
|
||||
- `glossary` module package.
|
||||
- Glossary prompt builder ported from Python.
|
||||
- Glossary structured response model.
|
||||
- Glossary replacement policy.
|
||||
- Glossary confidence threshold handling.
|
||||
- Glossary validator chain.
|
||||
- Protected-term extraction from parsed glossary.
|
||||
- Protected-term validator behavior used by other modules where applicable.
|
||||
- Prompt/response diagnostics.
|
||||
- CLI support for `--modules glossary`.
|
||||
- Fake LLM tests.
|
||||
- Tests for repeated glossary stages using `glossary,glossary`.
|
||||
|
||||
Do not implement:
|
||||
- Homophones module.
|
||||
- Spoken-word module.
|
||||
- Default full pipeline parity claim.
|
||||
|
||||
### Expected behavior at end of phase
|
||||
|
||||
Running `audita process ... --modules glossary` should perform real glossary-supported corrections. Repeated glossary stages should work and be reported as separate module instances.
|
||||
|
||||
### Definition of done
|
||||
|
||||
- Glossary module runs in the production runner.
|
||||
- Glossary terms and aliases are used in prompts and validators.
|
||||
- Protected-term behavior is implemented and tested.
|
||||
- Repeated glossary module instances are reported correctly.
|
||||
- Applied/skipped glossary changes appear in reports.
|
||||
- Prompt/response diagnostics are written.
|
||||
- `go test ./...` passes without requiring external LLM credentials.
|
||||
Not implemented in Phase 13 (by design):
|
||||
- Production `homophones` and `spoken_word` modules.
|
||||
- Full default module sequence execution as a feature-complete claim.
|
||||
|
||||
## Phase 14: Homophones module
|
||||
|
||||
|
||||
Reference in New Issue
Block a user