From 889ac766a5a95014fd55f811a6aac56c423fc3e3 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Thu, 26 Nov 2026 18:25:43 +0000 Subject: [PATCH] Document and verify runtime glossary workflows --- docs/cli.md | 9 +++ docs/config.md | 17 ++++- docs/integrations/subprocess.md | 8 ++ .../integrations/transcript-glossary-files.md | 20 +++++ docs/internal/cli-config.md | 5 ++ docs/internal/prompts.md | 6 +- docs/roadmap/implementation.md | 4 +- docs/roadmap/runtime-glossary-inputs.md | 15 ++-- examples/README.md | 21 ++++++ .../service/overlays/runtime-glossary.yml | 12 +++ examples/service/runtime-glossary.yml | 8 ++ internal/cli/examples_integration_test.go | 73 +++++++++++++++++++ internal/framework/llm/conversation_test.go | 10 ++- 13 files changed, 196 insertions(+), 12 deletions(-) create mode 100644 examples/service/overlays/runtime-glossary.yml create mode 100644 examples/service/runtime-glossary.yml diff --git a/docs/cli.md b/docs/cli.md index 8558862..b9727f8 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -41,6 +41,15 @@ work directory. `audita process --help` lists the available flags. An omitted fl does not contribute an override. [Configuration](config.md) defines their values and inheritance. +`--glossary-file PATH` supplies a wrapperless runtime glossary file. Repeat it +to compose files in argument order. Each occurrence is a single path resolved +from the invocation working directory. This flag does not select collections: +use configured selections or `--glossaries`. It is also accepted by configuration +inspection and configuration-consuming PromptKit resource, request, and smoke +commands. Configuration comparison applies the same ordered files to both sides. +See the [input format](integrations/transcript-glossary-files.md) and native +command help for the available operations. + ## Inspection and outcomes The application configuration scope uses ConfigKit's native effective values, diff --git a/docs/config.md b/docs/config.md index c6e7b18..b44bde4 100644 --- a/docs/config.md +++ b/docs/config.md @@ -22,6 +22,17 @@ inheritance, applies explicit overrides, records derived defaults, and validates the result. Its [configuration reference](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.4.0/docs/config.md) owns native composition and provenance semantics. +Runtime files supplied with `--glossary-file` are first composed separately in +argument order using native imports and entry identities. Imports are resolved +beside their declaring files. The resolved wrapperless mapping is then assigned +to `glossary_collections` as one CLI override in the application load. Supplied +entry lists replace configured lists at that boundary; unrelated configured +collections remain. Omitted fields retain configured values, while explicit +empty and null values follow native assignment and decoding. Application and +overlay parsing and validation still apply. Final explanation records the CLI +assignment, while original runtime file and import source records belong to the +preliminary load rather than final provenance. See the [runtime file contract](integrations/transcript-glossary-files.md). + Before shared configuration loading, Audita runs configured ConfigKit secrets bootstrap against the selected main source. This can populate the process environment for processing and native inspection; help and version do not load @@ -51,7 +62,11 @@ invocation to pick up changes. Inspection does not require model credentials. ## Pipeline and glossary selections -`glossary_collections` maps names to collections with an ordered `entries` list. +`glossary_collections` maps names to collections with an ordered `entries` list +and optional `instruction` string. Instructions from the effective selected +glossaries, in selection order, guide proposal generation and remain in the +proposal conversation during repair. Protection-only collections do not add +guidance, and instructions do not add deterministic validation rules. Each entry has an `id`, `name`, and `category`; `description`, `aliases`, and `plural` provide optional context. Entries are identified within their collection by `id`. Root `glossaries` and `protected_terms` select collection names. If root diff --git a/docs/integrations/subprocess.md b/docs/integrations/subprocess.md index 200ca79..b5510c1 100644 --- a/docs/integrations/subprocess.md +++ b/docs/integrations/subprocess.md @@ -19,6 +19,14 @@ Supplying a configuration path also makes file selection predictable. Configured secrets bootstrap can populate the child environment before the shared load; see [configuration](../config.md#loading-and-composition). +For prepared vocabulary, write one or more wrapperless collection files and +pass each path as a separate `--glossary-file` argument. Select the main +configuration and overlay that define the desired pipeline and collection +selections; supplying files does not select them. The same arguments can be +used to inspect the effective configuration before processing. See the +[input format](transcript-glossary-files.md#glossary-collections) and +[CLI reference](../cli.md#processing) for composition and error outcomes. + Choose a trusted configuration bundle. An explicit main path still allows its configured imports and automatic overlay, glossary, and prompt companions. Without a main path, Audita uses the configured discovery locations. The diff --git a/docs/integrations/transcript-glossary-files.md b/docs/integrations/transcript-glossary-files.md index 220f15f..039cc97 100644 --- a/docs/integrations/transcript-glossary-files.md +++ b/docs/integrations/transcript-glossary-files.md @@ -36,3 +36,23 @@ The [local example](../../examples/local/glossary.yml) provides a complete collection. Configuration may contain empty collections; processing preflight requires every glossary-correction entry to select at least one glossary entry. The previous standalone `glossary` file format is not a processing input. + +Runtime files supplied with `--glossary-file` are YAML mappings keyed directly +by collection name, without a `glossary_collections` wrapper. Each collection +may contain `instruction` and `entries`; entries retain additional fields as +extensions. For example: + +```yaml +people: + instruction: Prefer the speaker's stated name when supported by context. + entries: + - id: speaker + name: Mira Chen + category: person + aliases: [Mira] + source_note: Prepared for this recording +``` + +See the [complete runtime glossary example](../../examples/README.md#runtime-glossary-input) +and [composition and selection rules](../config.md#loading-and-composition). +Files and their imports are protected by the existing output collision checks. diff --git a/docs/internal/cli-config.md b/docs/internal/cli-config.md index 84fedf0..1a3a610 100644 --- a/docs/internal/cli-config.md +++ b/docs/internal/cli-config.md @@ -39,6 +39,11 @@ profile and backend inspections and equivalent glossary views within the invocation. Native inspection commands continue to inspect configuration without running processing readiness checks. +Runtime glossary files use a preliminary ConfigKit load before the shared +application load. Processing retains its acquired source paths for output +collision checks; inspection receives the final native result and CLI origin. +Both sides of a native comparison use the same invocation file list. + ## Validating Examples Keep complete copyable files in [examples](../../examples/) and link to them from diff --git a/docs/internal/prompts.md b/docs/internal/prompts.md index 150d9fe..137d52d 100644 --- a/docs/internal/prompts.md +++ b/docs/internal/prompts.md @@ -34,7 +34,11 @@ these roles, including the transition from a correction set to one repair result For a standard request preview or validation, select a native PromptKit profile and supply the template variables used by the selected prompt. The shipped proposal definitions use `TranscriptDescriptionBlock`, `GlossaryJSON`, -`ProtectedTermsJSON`, and `SectionJSON`. Glossary entries provide context, +`ProtectedTermsJSON`, `GlossaryInstructionsBlock`, and `SectionJSON`. Selected +collection instructions are labeled and ordered in the guidance block; empty +instructions are omitted. The block defaults to empty in previews when omitted, +and caller-provided values are retained. The original proposal conversation +retains that guidance during correction repair. Glossary entries provide context, and the separate spelling list defines protection. Preview defaults the spelling list to `[]` when omitted. The validator definitions use `TranscriptDescriptionBlock` and `PayloadJSON`. The latter is supplied candidate JSON and does not require a diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 3eae679..100ae36 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -1,6 +1,6 @@ # Runtime Glossary Inputs: Implementation Plan -Status: Ready for implementation. +Status: Complete for Audita. Companion deliveries remain separate as described below. 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 @@ -263,6 +263,8 @@ Acceptance: ## Stage 6: Complete integration evidence and canonical documentation +Status: Complete. + Work: 1. Add a domain-neutral copyable runtime glossary example under `examples/`, diff --git a/docs/roadmap/runtime-glossary-inputs.md b/docs/roadmap/runtime-glossary-inputs.md index 935550c..eff7c31 100644 --- a/docs/roadmap/runtime-glossary-inputs.md +++ b/docs/roadmap/runtime-glossary-inputs.md @@ -1,15 +1,14 @@ # Runtime Glossary Inputs and Overlay Recipes -Status: Target design and initial recipe contracts agreed. The Audita implementation -sequence is defined in [the implementation plan](implementation.md). These features -and external overlays are not yet implemented; the external repository has -development scaffolding. +Status: The Audita runtime glossary feature is implemented; see the +[implementation plan](implementation.md). The external overlays and Narratio +adapter migration remain separate companion work. This roadmap records Audita's response to Narratio's runtime glossary input request. It targets a supported handoff for prepared session vocabulary while retaining Audita configuration as the owner of transcript processing behavior. -## Current Baseline +## Baseline Before Implementation Audita v4.1 uses version 3 application configuration and ConfigKit v1.4.0. Named `glossary_collections` already support root and per-stage selections, @@ -19,8 +18,8 @@ are anchored to the selected main configuration. See the [configuration contract](../config.md) and [input contract](../integrations/transcript-glossary-files.md). -Collections currently contain entries but no collection-level instruction field. -Stage preparation flattens selected collections into entry context for proposals. +Collections contained entries but no collection-level instruction field. +Stage preparation flattened selected collections into entry context for proposals. Repair retains the original proposal conversation; validators prepare separate context from matched entries. @@ -29,7 +28,7 @@ and composes application and PromptKit settings. Processing and native inspectio use this shared configuration path. Processing preflight checks resolved glossary selections and execution readiness separately from inspection. -The CLI can select collections but cannot accept glossary files at invocation +The CLI could select collections but could not accept glossary files at invocation time. Narratio still uses the former standalone glossary flag and format. Its adapter also has other legacy CLI assumptions, including optional `--modules`; adding this feature alone will not complete Narratio's migration. diff --git a/examples/README.md b/examples/README.md index 19ad0bc..5111af3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -49,6 +49,27 @@ audita promptkit show profile service-test --config config.yml The example does not promise a provider's model availability, price, or quality. +## Runtime glossary input + +From `examples/service`, the `runtime-glossary` overlay selects a configured +reference collection and an incoming collection. The runtime file replaces the +incoming entries and supplies its instruction. Inspect the combined settings: + +```sh +audita config show --scope app --config config.yml --overlay runtime-glossary \ + --glossary-file runtime-glossary.yml +``` + +After configuring the example service and credential, run: + +```sh +audita process --config config.yml --overlay runtime-glossary \ + --glossary-file runtime-glossary.yml --output corrected.json transcript.json +``` + +The [runtime file](service/runtime-glossary.yml) and +[overlay](service/overlays/runtime-glossary.yml) contain synthetic data. + ## Edit a prompt and run again From `examples/prompt-edit`, inspect the operator replacement: diff --git a/examples/service/overlays/runtime-glossary.yml b/examples/service/overlays/runtime-glossary.yml new file mode 100644 index 0000000..8543db2 --- /dev/null +++ b/examples/service/overlays/runtime-glossary.yml @@ -0,0 +1,12 @@ +glossaries: [reference, incoming] +glossary_collections: + reference: + instruction: Preserve established place names. + entries: + - {id: observatory, name: North Observatory, category: place} + incoming: + entries: + - {id: speaker, name: Placeholder Speaker, category: person} +llm: + proposal_profile: service-test + validation_profile: service-test diff --git a/examples/service/runtime-glossary.yml b/examples/service/runtime-glossary.yml new file mode 100644 index 0000000..8cad0c3 --- /dev/null +++ b/examples/service/runtime-glossary.yml @@ -0,0 +1,8 @@ +incoming: + instruction: Use the speaker's preferred spelling when supported by context. + entries: + - id: speaker + name: Mira Chen + category: person + aliases: [Mira] + source_note: Prepared for this recording diff --git a/internal/cli/examples_integration_test.go b/internal/cli/examples_integration_test.go index ba2634f..9287c9e 100644 --- a/internal/cli/examples_integration_test.go +++ b/internal/cli/examples_integration_test.go @@ -6,6 +6,7 @@ import ( "encoding/json" "io" "net/http" + "net/http/httptest" "os" "path/filepath" "runtime" @@ -18,6 +19,7 @@ import ( "gitea.maximumdirect.net/eric/audita/v4/internal/core/schema" "gitea.maximumdirect.net/eric/audita/v4/internal/framework/llm" auditaprompts "gitea.maximumdirect.net/eric/audita/v4/internal/prompts" + commandkit "go.maximumdirect.net/commandkit" ck "go.maximumdirect.net/configkit" pk "go.maximumdirect.net/promptkit" ) @@ -185,3 +187,74 @@ func TestExamplePromptEditIsCapturedOnNextLoad(t *testing.T) { t.Fatalf("before=%q after=%q", before, after) } } + +func TestRuntimeGlossaryExampleWorkflow(t *testing.T) { + _, file, _, ok := runtime.Caller(0) + if !ok { + t.Fatal("cannot locate examples") + } + source := filepath.Join(filepath.Dir(file), "..", "..", "examples", "service") + dir := t.TempDir() + for _, name := range []string{"config.yml", "prompts.yml", "transcript.json", "runtime-glossary.yml", "overlays/runtime-glossary.yml"} { + data, err := os.ReadFile(filepath.Join(source, name)) + if err != nil { + t.Fatal(err) + } + dest := filepath.Join(dir, name) + if err := os.MkdirAll(filepath.Dir(dest), 0700); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(dest, data, 0600); err != nil { + t.Fatal(err) + } + } + t.Setenv("AUDITA_EXAMPLE_KEY", "synthetic") + var seen string + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + var request struct { + Messages []struct { + Content string `json:"content"` + } `json:"messages"` + } + if err := json.NewDecoder(r.Body).Decode(&request); err != nil { + t.Error(err) + return + } + for _, message := range request.Messages { + seen += message.Content + } + io.WriteString(w, `{"model":"fixture","choices":[{"message":{"role":"assistant","content":"{\"corrections\":[]}"}}]}`) + })) + defer server.Close() + promptsPath := filepath.Join(dir, "prompts.yml") + promptsData, err := os.ReadFile(promptsPath) + if err != nil { + t.Fatal(err) + } + promptsData = bytes.ReplaceAll(promptsData, []byte("https://example.invalid/v1"), []byte(server.URL+"/v1")) + if err := os.WriteFile(promptsPath, promptsData, 0600); err != nil { + t.Fatal(err) + } + app, err := buildApplication() + if err != nil { + t.Fatal(err) + } + common := []string{"--config", filepath.Join(dir, "config.yml"), "--overlay", "runtime-glossary", "--glossary-file", filepath.Join(dir, "runtime-glossary.yml")} + var out, stderr bytes.Buffer + args := append([]string{"config", "show", "--scope=app"}, common...) + result := app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &stderr}) + if result.Status != 0 || !strings.Contains(out.String(), "Mira Chen") || !strings.Contains(out.String(), "North Observatory") || strings.Contains(out.String(), "Placeholder Speaker") { + t.Fatalf("inspection %d %s %s", result.Status, out.String(), stderr.String()) + } + out.Reset() + stderr.Reset() + args = append([]string{"process"}, common...) + args = append(args, "--output", filepath.Join(dir, "output.json"), filepath.Join(dir, "transcript.json")) + result = app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &stderr}) + if result.Status != 0 || !strings.Contains(seen, "Mira Chen") || !strings.Contains(seen, "North Observatory") || !strings.Contains(seen, "speaker's preferred spelling") || !strings.Contains(seen, "Preserve established place names") { + t.Fatalf("processing %d seen=%s stderr=%s", result.Status, seen, stderr.String()) + } + if _, err := os.Stat(filepath.Join(dir, "output.json")); err != nil { + t.Fatal(err) + } +} diff --git a/internal/framework/llm/conversation_test.go b/internal/framework/llm/conversation_test.go index 81704af..d8c1936 100644 --- a/internal/framework/llm/conversation_test.go +++ b/internal/framework/llm/conversation_test.go @@ -16,6 +16,7 @@ import ( "gitea.maximumdirect.net/eric/audita/v4/internal/appconfig" "gitea.maximumdirect.net/eric/audita/v4/internal/core/config" + "gitea.maximumdirect.net/eric/audita/v4/internal/framework/contracts" "gitea.maximumdirect.net/eric/audita/v4/internal/framework/structuredoutput" "gitea.maximumdirect.net/eric/audita/v4/internal/prompts" ck "go.maximumdirect.net/configkit" @@ -69,7 +70,14 @@ func TestRoleClientCoordinatesIndependentRepairConversations(t *testing.T) { if err != nil { t.Fatal(err) } - vars := map[string]string{"TranscriptDescriptionBlock": "", "GlossaryJSON": "[]", "SectionJSON": "[]", "GlossaryInstructionsBlock": "party:\nKeep {{literal}} names"} + selected := contracts.ResolveModuleRunSpecs(&config.Config{ + GlossaryCollections: map[string]config.GlossaryCollection{"party": {Instruction: "Keep {{literal}} names"}}, + Pipeline: config.Pipeline{Stages: []config.Stage{{Module: "grammar", Glossaries: []string{"party"}}}}, + }) + if err := selected[0].PrepareGlossary(); err != nil { + t.Fatal(err) + } + vars := map[string]string{"TranscriptDescriptionBlock": "", "GlossaryJSON": "[]", "SectionJSON": "[]", "GlossaryInstructionsBlock": selected[0].GlossaryVariables.InstructionsBlock} initial, err := proposal.CompleteStructured(context.Background(), structuredoutput.Request{PromptID: prompts.PromptIDModuleGrammarProposal, Variables: vars, CaptureExchange: true}, &map[string]any{}) if err != nil || initial.Exchange == nil { t.Fatalf("capture: %+v %v", initial, err)