Allow disjoint glossary overrides alongside shared files
This commit is contained in:
@@ -26,9 +26,12 @@ Explicit `--glossary-file` inputs use the shared `glossary@0.2.0` contract from
|
|||||||
schemas distribution `2026.11.1` and the `maximumdirect.glossary.v1` marker.
|
schemas distribution `2026.11.1` and the `maximumdirect.glossary.v1` marker.
|
||||||
The files are ordered native layers; imports within a file are native peers and
|
The files are ordered native layers; imports within a file are native peers and
|
||||||
resolve beside their declaring file. Audita validates the completed envelope,
|
resolve beside their declaring file. Audita validates the completed envelope,
|
||||||
then projects collection entries as one CLI assignment to
|
then projects collection entries through native CLI assignments to
|
||||||
`glossary_collections`. Supplied entry lists replace configured lists at that
|
`glossary_collections`. When other CLI overrides target that namespace, file
|
||||||
boundary; unrelated configured collections remain. ConfigKit governs native
|
assignments are scoped to their supplied entry lists so disjoint overrides can
|
||||||
|
coexist. An empty collection map adds no assignment. Native override budgets and
|
||||||
|
genuine overlap checks still apply. Supplied entry lists replace configured lists
|
||||||
|
at that boundary; unrelated configured collections remain. ConfigKit governs native
|
||||||
composition and assignment. Final explanation records the CLI assignment;
|
composition and assignment. Final explanation records the CLI assignment;
|
||||||
runtime files and imports remain recorded for collision protection. See the
|
runtime files and imports remain recorded for collision protection. See the
|
||||||
[shared file contract](integrations/transcript-glossary-files.md#glossary-collections).
|
[shared file contract](integrations/transcript-glossary-files.md#glossary-collections).
|
||||||
|
|||||||
@@ -45,9 +45,12 @@ without running processing readiness checks.
|
|||||||
Explicit shared glossary files use a preliminary ConfigKit load with ordered
|
Explicit shared glossary files use a preliminary ConfigKit load with ordered
|
||||||
layers, native imports, and entry identities. The shared-glossary adapter
|
layers, native imports, and entry identities. The shared-glossary adapter
|
||||||
validates the completed envelope against the bundled offline schema before
|
validates the completed envelope against the bundled offline schema before
|
||||||
projecting entries into the application load. Processing retains acquired source
|
projecting entries into the application load. Entry assignments share the
|
||||||
paths for output collision checks; inspection receives the final native result
|
glossary namespace with disjoint caller overrides; ordinary loads retain a
|
||||||
and CLI origin. Both sides of comparison use the same invocation file list.
|
single batch contribution to avoid consuming a native override record per
|
||||||
|
collection, and empty maps contribute no override. Processing retains acquired
|
||||||
|
source paths for output collision checks; inspection receives the final native
|
||||||
|
result and CLI origin. Both sides of comparison use the same invocation file list.
|
||||||
Automatic prompt companions remain; glossary companions are not discovered.
|
Automatic prompt companions remain; glossary companions are not discovered.
|
||||||
|
|
||||||
## Validating Examples
|
## Validating Examples
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Shared Glossary Remediation
|
# Shared Glossary Remediation
|
||||||
|
|
||||||
**Status:** Open.
|
**Status:** Complete.
|
||||||
|
|
||||||
Review covers all seven stages of [the implementation plan](implementation.md),
|
Review covers all seven stages of [the implementation plan](implementation.md),
|
||||||
including the pinned assets, native composition, application projection, retired
|
including the pinned assets, native composition, application projection, retired
|
||||||
@@ -91,7 +91,15 @@ on complete diagnostic wording or generated source IDs.
|
|||||||
|
|
||||||
## R2: Shared-file assignment conflicts with disjoint native glossary overrides
|
## R2: Shared-file assignment conflicts with disjoint native glossary overrides
|
||||||
|
|
||||||
**Priority:** P2. **Status:** Open. **Plan stages:** 3 and 5.
|
**Priority:** P2. **Status:** Complete. **Plan stages:** 3 and 5.
|
||||||
|
|
||||||
|
**Completion:** File contributions use entry-level native assignments when caller
|
||||||
|
overrides share the glossary namespace; empty collection maps add no assignment.
|
||||||
|
Ordinary loads retain one batch assignment to avoid consuming an override record
|
||||||
|
per collection. Regression coverage verifies disjoint populated/empty inputs,
|
||||||
|
native CLI origins, genuine overlap rejection, and a large collection batch.
|
||||||
|
Existing list-replacement tests, the full Go 1.27.4 offline suite, and the
|
||||||
|
application build passed.
|
||||||
|
|
||||||
**Locations:** [application acquisition](../../internal/appconfig/config.go),
|
**Locations:** [application acquisition](../../internal/appconfig/config.go),
|
||||||
lines 94 and 116–122; [native command wiring](../../internal/cli/app_wiring.go).
|
lines 94 and 116–122; [native command wiring](../../internal/cli/app_wiring.go).
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"gitea.maximumdirect.net/eric/audita/v4/internal/appconfig/sharedglossary"
|
"gitea.maximumdirect.net/eric/audita/v4/internal/appconfig/sharedglossary"
|
||||||
"gitea.maximumdirect.net/eric/audita/v4/internal/core/config"
|
"gitea.maximumdirect.net/eric/audita/v4/internal/core/config"
|
||||||
@@ -119,7 +121,7 @@ func Load(ctx context.Context, input ck.Input, options Options) (*Acquisition, *
|
|||||||
collection := value.(map[string]any)
|
collection := value.(map[string]any)
|
||||||
projected[name] = map[string]any{"entries": collection["entries"]}
|
projected[name] = map[string]any{"entries": collection["entries"]}
|
||||||
}
|
}
|
||||||
overrides = append(overrides, ck.Override{Path: ck.Keys("glossary_collections"), Value: projected, Flag: "--glossary-file"})
|
overrides = append(overrides, glossaryOverrides(projected, options.Overrides)...)
|
||||||
}
|
}
|
||||||
embedded, err := pk.FilesystemInputs("Audita embedded prompts", prompts.Filesystem(), prompts.AssetRoot)
|
embedded, err := pk.FilesystemInputs("Audita embedded prompts", prompts.Filesystem(), prompts.AssetRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -155,3 +157,30 @@ func Load(ctx context.Context, input ck.Input, options Options) (*Acquisition, *
|
|||||||
}
|
}
|
||||||
return &Acquisition{Result: result, GlossarySources: glossarySources}, report, nil
|
return &Acquisition{Result: result, GlossarySources: glossarySources}, report, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func glossaryOverrides(projected map[string]any, supplied []ck.Override) []ck.Override {
|
||||||
|
if len(projected) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
root := ck.Keys("glossary_collections")
|
||||||
|
for _, override := range supplied {
|
||||||
|
path := override.Path.String()
|
||||||
|
if path != root.String() && !strings.HasPrefix(path, root.String()+"/") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// Only split when caller overrides need to share this namespace. The
|
||||||
|
// usual batch keeps one native record regardless of collection count.
|
||||||
|
names := make([]string, 0, len(projected))
|
||||||
|
for name := range projected {
|
||||||
|
names = append(names, name)
|
||||||
|
}
|
||||||
|
sort.Strings(names)
|
||||||
|
result := make([]ck.Override, 0, len(names))
|
||||||
|
for _, name := range names {
|
||||||
|
entries := projected[name].(map[string]any)["entries"]
|
||||||
|
result = append(result, ck.Override{Path: root.Key(name).Key("entries"), Value: entries, Flag: "--glossary-file"})
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
return []ck.Override{{Path: root, Value: projected, Flag: "--glossary-file"}}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package appconfig
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
@@ -109,6 +111,31 @@ func TestRuntimeGlossaryLoadErrors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRuntimeGlossaryLargeCollectionBatch(t *testing.T) {
|
||||||
|
collections := make(map[string]any)
|
||||||
|
for i := range 1100 {
|
||||||
|
collections[fmt.Sprintf("collection-%d", i)] = map[string]any{"entries": []any{}}
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(map[string]any{"schema_version": "maximumdirect.glossary.v1", "collections": collections})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
file := filepath.Join(t.TempDir(), "shared.json")
|
||||||
|
if err := os.WriteFile(file, data, 0600); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got, _, err := Load(context.Background(), ck.Input{Source: ck.NoSource()}, Options{
|
||||||
|
GlossaryFiles: []string{file},
|
||||||
|
Overrides: []ck.Override{{Path: ck.Keys("context", "description"), Value: "batch", Flag: "--set"}},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(got.Config.Application.GlossaryCollections) != len(collections) {
|
||||||
|
t.Fatalf("loaded %d collections, want %d", len(got.Config.Application.GlossaryCollections), len(collections))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRuntimeGlossaryPresence(t *testing.T) {
|
func TestRuntimeGlossaryPresence(t *testing.T) {
|
||||||
for _, tc := range []struct {
|
for _, tc := range []struct {
|
||||||
name, body string
|
name, body string
|
||||||
|
|||||||
@@ -247,3 +247,51 @@ func TestSharedGlossaryReadinessBeforeRequests(t *testing.T) {
|
|||||||
t.Fatalf("local preflight: status=%d calls=%d stderr=%s", status, calls.Load(), stderr.String())
|
t.Fatalf("local preflight: status=%d calls=%d stderr=%s", status, calls.Load(), stderr.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSharedGlossaryWithDisjointNativeOverrides(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
main := filepath.Join(dir, "config.yml")
|
||||||
|
if err := os.WriteFile(main, []byte("version: 3\nglossary_collections:\n people:\n entries: [{id: configured, name: Configured, category: person}]\n"), 0600); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, tc := range []struct{ name, collections, wantName string }{
|
||||||
|
{"populated", "{people: {entries: [{id: a, name: Alice, category: person}]}}", "Alice"},
|
||||||
|
{"empty", "{}", "Configured"},
|
||||||
|
} {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
file := filepath.Join(dir, tc.name+".yml")
|
||||||
|
if err := os.WriteFile(file, []byte("schema_version: maximumdirect.glossary.v1\ncollections: "+tc.collections+"\n"), 0600); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
common := []string{"--scope=app", "--config", main, "--glossary-file", file, "--set", `/glossary_collections/other/entries=[{"id":"b","name":"Bob","category":"person"}]`}
|
||||||
|
var out, stderr bytes.Buffer
|
||||||
|
if code := Run(context.Background(), append([]string{"config", "show"}, common...), &out, &stderr); code != 0 || !strings.Contains(out.String(), "name: "+tc.wantName) || !strings.Contains(out.String(), "name: Bob") {
|
||||||
|
t.Fatalf("show: code=%d out=%s stderr=%s", code, out.String(), stderr.String())
|
||||||
|
}
|
||||||
|
for _, origin := range []struct{ path, flag string }{
|
||||||
|
{"/glossary_collections/other/entries", "--set"},
|
||||||
|
{"/glossary_collections/people/entries", "--glossary-file"},
|
||||||
|
} {
|
||||||
|
if tc.name == "empty" && origin.flag == "--glossary-file" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
out.Reset()
|
||||||
|
stderr.Reset()
|
||||||
|
args := append([]string{"config", "explain"}, common...)
|
||||||
|
args = append(args, "--path", origin.path)
|
||||||
|
if code := Run(context.Background(), args, &out, &stderr); code != 0 || !strings.Contains(out.String(), origin.flag) {
|
||||||
|
t.Fatalf("explain: code=%d out=%s stderr=%s", code, out.String(), stderr.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if tc.name == "populated" {
|
||||||
|
out.Reset()
|
||||||
|
stderr.Reset()
|
||||||
|
args := append([]string{"config", "show"}, common...)
|
||||||
|
args = append(args, "--set", `/glossary_collections/people={"entries":[]}`)
|
||||||
|
if code := Run(context.Background(), args, &out, &stderr); code != 2 || !strings.Contains(stderr.String(), "override.overlap") {
|
||||||
|
t.Fatalf("overlap: code=%d stderr=%s", code, stderr.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user