From 3ef55f4668a918bd18b67787a05b220b42dbce64 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Sun, 22 Nov 2026 05:37:15 +0000 Subject: [PATCH] Finish native migration cleanup and restore whole-tree compilation --- docs/oss/attribution.md | 79 -------- docs/roadmap/implementation.md | 118 ++++-------- go.mod | 4 - go.sum | 18 -- internal/cli/configkit_load.go | 24 --- internal/cli/configkit_load_test.go | 15 +- internal/cli/example_contract_test.go | 174 ++++++------------ internal/cli/pipeline_run_test.go | 3 +- .../dnd/locations/registry/registry.go | 62 ++----- .../dnd/locations/registry/registry_test.go | 23 +-- .../modules/dnd/npcs/registry/registry.go | 34 ---- .../dnd/npcs/registry/registry_test.go | 14 +- 12 files changed, 123 insertions(+), 445 deletions(-) diff --git a/docs/oss/attribution.md b/docs/oss/attribution.md index 8435e3d0..1ef9aa36 100644 --- a/docs/oss/attribution.md +++ b/docs/oss/attribution.md @@ -31,64 +31,6 @@ License and notices: [LGPL 3.0](licenses/LGPL-3.0.txt) | [Source](https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3). -## ConfigKit (old module path) - -Selected module: `gitea.maximumdirect.net/eric/ConfigKit` at `v0.5.0`. - -Copyright (C) 2026 Eric Rakestraw - -SPDX-License-Identifier: LGPL-3.0-or-later - -License and notices: [LGPL 3.0](licenses/LGPL-3.0.txt) | -[GPL 3.0](licenses/GPL-3.0.txt) | -[COPYRIGHT](https://gitea.maximumdirect.net/eric/ConfigKit/src/commit/dc09959cca4e105f49ec316c6d4ba585bd2340bd/COPYRIGHT) | -[LICENSE](https://gitea.maximumdirect.net/eric/ConfigKit/src/commit/dc09959cca4e105f49ec316c6d4ba585bd2340bd/LICENSE). - -[Source](https://gitea.maximumdirect.net/eric/ConfigKit/src/commit/dc09959cca4e105f49ec316c6d4ba585bd2340bd). - -## PromptKit (old module path) - -Selected module: `gitea.maximumdirect.net/eric/promptkit` at `v0.12.0`. - -Copyright (C) 2026 Eric Rakestraw - -SPDX-License-Identifier: LGPL-3.0-or-later - -License and notices: [LGPL 3.0](licenses/LGPL-3.0.txt) | -[GPL 3.0](licenses/GPL-3.0.txt) | -[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit/src/commit/4b8169da286917fde7875425bb32b799b12c6af3/COPYRIGHT) | -[LICENSE](https://gitea.maximumdirect.net/eric/promptkit/src/commit/4b8169da286917fde7875425bb32b799b12c6af3/LICENSE). - -[Source](https://gitea.maximumdirect.net/eric/promptkit/src/commit/4b8169da286917fde7875425bb32b799b12c6af3). - -## PromptKit OpenRouter Catalog - -Selected module: `gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3` at `v3.20260930.0`. - -Copyright (C) 2026 Eric Rakestraw - -SPDX-License-Identifier: MIT - -License and notices: [MIT](licenses/MIT.txt) | -[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/f17d208cb7ad1fb043cda2266cd3011d11b40aa0/COPYRIGHT) | -[LICENSE](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/f17d208cb7ad1fb043cda2266cd3011d11b40aa0/LICENSE). - -[Source](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/f17d208cb7ad1fb043cda2266cd3011d11b40aa0). - -## PromptKit Rakestrawhome Catalog - -Selected module: `gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3` at `v3.20260930.0`. - -Copyright (C) 2026 Eric Rakestraw - -SPDX-License-Identifier: MIT - -License and notices: [MIT](licenses/MIT.txt) | -[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/993443d88c451901f4c917fa00c204fd3b54d28d/COPYRIGHT) | -[LICENSE](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/993443d88c451901f4c917fa00c204fd3b54d28d/LICENSE). - -[Source](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/993443d88c451901f4c917fa00c204fd3b54d28d). - ## jsonschema Selected module: `github.com/santhosh-tekuri/jsonschema/v6` at `v6.0.3`. @@ -114,27 +56,6 @@ License and notices: [BSD 3-Clause](licenses/BSD-3-Clause.txt) | [Source](https://github.com/golang/text/commit/6070ac32abcdd1670599eeb3ee4d513c8184a513). -## go-yaml v3 - -Selected module: `gopkg.in/yaml.v3` at `v3.0.1`. - -Copyright (c) 2006-2010 Kirill Simonov - -Copyright (c) 2006-2011 Kirill Simonov - -Copyright (c) 2011-2019 Canonical Ltd - -Copyright 2011-2016 Canonical Ltd. - -SPDX-License-Identifier: MIT AND Apache-2.0 - -License and notices: [MIT](licenses/MIT-Kirill-Simonov.txt) | -[Apache 2.0](licenses/Apache-2.0.txt) | -[LICENSE](https://github.com/go-yaml/yaml/blob/f6f7691b1fdeb513f56608cd2c32c51f8194bf51/LICENSE) | -[NOTICE](https://github.com/go-yaml/yaml/blob/f6f7691b1fdeb513f56608cd2c32c51f8194bf51/NOTICE). - -[Source](https://github.com/go-yaml/yaml/commit/f6f7691b1fdeb513f56608cd2c32c51f8194bf51). - ## go-yaml v4 Selected module: `go.yaml.in/yaml/v4` at `v4.0.0`. diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 4578b813..22a3deee 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -1662,94 +1662,46 @@ publication then capture failure, useful exit categories, and no reporting sidec ## Stage 35: Remove Superseded Machinery And Restore Whole-Tree Compilation -**Status:** In progress. Removed the retired LLM wrapper, asset/schema registries, +**Status:** Complete. Removed the retired LLM wrapper, asset/schema registries, prompt filesystem/mount helpers, copied completion/correction/debug contracts, -old checkpoint/chunk-plan source packages, and reporting-only module fingerprint -methods. No runtime output/cache/debug files were removed. Preserved typed -validation-result checks, intrinsic artifact schemas, domain codecs, reference -compatibility, and source/identity rules. Corrected stale source/JSON fixture -expectations and the configuration NUL/resolved-control assertions. +checkpoint/chunk-plan source packages, manual diagnostic renderer, reporting +models, and reporting-only module fingerprint methods. No runtime output/cache/ +debug data was deleted. Production has one native execution path; no compatibility +adapter or empty legacy package remains. -All framework, module (including the complete integration package), and -configuration tests now compile and pass. Migrated retained resolution, -construction, reference materialization, typed handoff, codec, source/annotation -isolation, diagnostics, and session coverage. Cross-family contracts live in the -black-box module integration package and use real production registration and -native provider fakes; the unchanged import-boundary tests pass. Published domain -and evidence files replace retired manifests and intermediate-output ledgers. -Spell, NPC, location, occurrence, combat, and grounded-pipeline fixtures retain -canonical identity, contextual selection, source chronology, scene eligibility, -complete correction/revalidation, and evidence-union behavior. Invalid combat -enums fail at the native structural boundary rather than bypassing its schema. -Removed tests tied solely to superseded outer retries, checkpoint provenance, -manifests, and attempt-debug wrappers; native producer/cache/assessment/capture -tests own the replacement behavior. Complete pipeline and integration repeated -race checks pass, as do framework/integration vet checks. +Migrated retained framework, module integration, and CLI fixtures to real native +loaders, engines, provider requests, typed codecs, and published domain artifacts. +Preserved catalog/registration and validator-chain checks, source/annotation +isolation, contextual identity, chronology, generated-reference compatibility, +catalog semantics, evidence union, scene eligibility, complete assessment and +correction, diagnostics, sessions, and intrinsic codec rejection despite validator +overrides. Cross-family contracts retain their black-box integration boundary. +Removed only superseded retry, checkpoint, manifest/index, synthetic completion, +and reporting-ledger assertions; native producer/cache/assessment/capture tests +own replacement behavior. -The production executable builds. Real executable route and text/JSON/YAML/ -fallback checks passed with a local fake HTTP provider after removal of the old -runtime wrapper. Focused native CLI tests pass, but the full CLI suite and -whole-tree compilation remain blocked by legacy CLI fixtures/imports. +Native command/configuration fixtures retain discovery/import/overlay origins, +inheritance, supplied overrides, secret-aware inspection, partial profiles, +offline preflight, and explicit smoke work. Run/state fixtures retain independent +roots, cache modes, group-accessible reuse, narrow identities, collision protection, +selected-data capture, and failure retention without checkpoint/resume machinery. +Maintained-example tests now compile against native commands/reporting; actual +example files are deliberately unchanged until Stage 36. -Migrated the shared production CLI fixture to the real native application loader, -engine, provider requests, version 6 test inputs, and native pipeline validation. -Retained catalog/typed registration, validator-chain replacement, reference -materialization/limits, configured backend selection, scene description profile -selection, source ranges, and published chunk-map provenance. Provider observations -and codec-decoded files replace profile manifests and normalized-output ledgers. -Oversized references prevent model work/publication without requiring the retired -runtime-factory construction order. Removed only tests of deleted asset/fingerprint -factories; native captured-loading tests cover shared configuration ownership. -Focused production CLI tests, vet, and repeated race checks pass. Whole CLI setup now stops at -remaining fixtures importing the removed reporting package, rather than the -legacy ConfigKit YAML import. Remaining CLI test migration, dependency tidy/ -old-path removal, notice reconciliation, and whole-tree validation are required -before completion. This stage is not marked finished. +`GOWORK=off go mod tidy`, `go list -m all`, whole-tree test compilation +(`go test ./... -run '^$'`), whole-tree vet, production executable build, and +`git diff --check` pass. Removed old-path kits/catalog dependencies and their +notices; retained notices for actual native/runtime dependencies and the Go +minimum of `1.27.0`, without replacements. Scoped removal searches find no current +legacy consumers; remaining fingerprint terminology concerns intrinsic domain +identity, and old-cache names in tests verify legacy data is left untouched. -Assembled spell tests now exercise the real native extractor and continuation -history rather than a synthetic model-candidate/correction protocol. Retained -merged-cast ordering, canonicalization, evidence, explicit validator overrides, -and process/advisory distinctions. Native catalog correction tests cover selected -turn exhaustion and corrected overlay acceptance; strict terminal rejection -publishes no artifact. Catalog materialization retains raw-reference provenance -and semantic recognition across reordered overlay bytes, and the native CLI -publishes the grounded overlay spell. Deleted only superseded checkpoint-identity/ -resume and manifest/sidecar assertions and their helpers. Focused assembled spell/ -catalog tests, vet, and repeated race checks pass; remaining CLI fixtures and final -compilation are still required. - -Configuration/discovery/inspection fixtures now use native scopes, rooted paths, -overlays, supplied overrides, pipeline validation, and profile inspection. -Retained source-relative discovery, inherited pipeline composition, source -diagnostics, secret-aware configuration views, no implicit provider work, and -presentation failures. Native validation may report failed scopes on stdout; -tests no longer impose the retired application's empty-error-output convention. -Fixed stale fixtures to include bundled profiles and use PromptKit's native -smoke-test kind rather than a command spelling. Focused native command/configuration -tests, vet, and repeated race checks pass. Whole CLI compilation still awaits -the remaining run/state, enemy-event, reference, and example fixture cleanup. - -Run/state contracts now use real native execution, domain files, and the unified -accepted-artifact cache rather than a synthetic completion/checkpoint harness. -Retained root independence, all cache modes, group-accessible reuse, narrow run -identities, output/debug collision protection, selected-data capture, failure -retention, discovery, and overlay origins. Reference-selector contracts retain -scope/specificity, unbinding, type variants, and generated-reference protection -without constructing modules. Moved the complete-example selector contract beside -the other example tests; maintained example migration remains Stage 36. -Focused native run/state/reference tests and vet pass; repeated race checks for -the run/state and command/configuration set pass. Remaining enemy-event/example -fixtures, dependency tidy/notices, and whole-tree compilation are still required. - -The ordered multi-family CLI fixture now uses a native version 6 test composition -and provider requests, preserving contextual registry identities, independently -grounded occurrences, combat-only enemy work, source-free reference projections, -session routing, and evidence self-references/deduplication. Domain file paths and -the small native completion replace the removed output index. The deterministic -enemy codec contract still rejects an intrinsically invalid range despite explicit -validator overrides. Focused native tests, vet, and repeated race checks pass. -The maintained example configuration files are unchanged and remain assigned to -Stage 36; their remaining test API migration is still required for compilation. +All framework, module/integration, configuration, and non-example CLI tests pass, +including real executable route/format/fallback checks with a local fake HTTP +provider. Focused complete pipeline/integration and CLI run/state/command/domain +race checks pass. The full runtime suite is not claimed passing: maintained +example tests still reject the version 5 files, whose relocation/native migration +belongs to Stage 36. Final assembled and whole-roadmap verification remain required. **Goal:** delete the old architecture rather than leave dormant alternatives. diff --git a/go.mod b/go.mod index 3611ef9c..0e697c4f 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,6 @@ module gitea.maximumdirect.net/eric/notarius go 1.27.0 require ( - gitea.maximumdirect.net/eric/ConfigKit v0.5.0 - gitea.maximumdirect.net/eric/promptkit v0.12.0 github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 go.maximumdirect.net/ckconfig v0.10.0 go.maximumdirect.net/ckprompt v0.11.0 @@ -16,8 +14,6 @@ require ( ) require ( - gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3 v3.20260930.0 // indirect - gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3 v3.20260930.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/spf13/cobra v1.10.2 // indirect github.com/spf13/pflag v1.1.0 // indirect diff --git a/go.sum b/go.sum index eecea805..53920863 100644 --- a/go.sum +++ b/go.sum @@ -1,19 +1,9 @@ -gitea.maximumdirect.net/eric/ConfigKit v0.5.0 h1:2KwG10+kApWM3avOoYA+p768xcbHUp7tQ2rqizBNpyg= -gitea.maximumdirect.net/eric/ConfigKit v0.5.0/go.mod h1:tYWpsrbLyu05r8+1MapWp5fN6ZrX9I8hU2xEPedYmYk= -gitea.maximumdirect.net/eric/promptkit v0.12.0 h1:oIFWEg6GPxtmX3Plqv0euP+FnK1LCk/t4xDy6oKCpP4= -gitea.maximumdirect.net/eric/promptkit v0.12.0/go.mod h1:pFOOy5v1zH17stEi9rmHYmfbuLjnfVMcUhfmk+4VtJY= -gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3 v3.20260930.0 h1:lzfCDbzJQRGzIlRPRprnAV9hVVL5zUQy80VMQ0kbYa0= -gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3 v3.20260930.0/go.mod h1:HjS0f+3q0IdHCTEz+VVAEgIwIWJFAZUjuKdAtvtqKdg= -gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3 v3.20260930.0 h1:h12ZTRldAmpLAomj0oQRGteFxHLN1LPE6XDl9zJNbm8= -gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3 v3.20260930.0/go.mod h1:OEFBeKdjTsLzqJwLmXI2O5gG3r64FktcVJVb3mBrRfg= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ= -github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28= github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= @@ -27,21 +17,13 @@ go.maximumdirect.net/ckprompt v0.11.0 h1:4EK1O/FBF3sydvIOzv4cD8bGRb3HMGa+qCrWmPR go.maximumdirect.net/ckprompt v0.11.0/go.mod h1:4f//FLRtOQfZzC9olhI6AcoXhQMav7NFVBnM53gr5NM= go.maximumdirect.net/commandkit v0.7.0 h1:toLDGhHoVe6gBX5HWuzQ/Joz0cBqEhJXolW21m3axBk= go.maximumdirect.net/commandkit v0.7.0/go.mod h1:sVp3JXKpm2YrP4Ie8Q3nWmQgwBdPN8uO+wQU72erDns= -go.maximumdirect.net/configkit v1.2.0 h1:c4tDJ6Xeh/Jg90UZplLxsnf500lvrZBVj0E3i1ysir8= -go.maximumdirect.net/configkit v1.2.0/go.mod h1:s1zLJ9GGB/1Q4a+aOHMLISonJxWFgNWpA6SpPlOafeA= go.maximumdirect.net/configkit v1.4.0 h1:TfOupZbQ23/ZMs+xt5lmyukCF11ekqKep8KbmFQD63o= go.maximumdirect.net/configkit v1.4.0/go.mod h1:ewu6blSokUDCMovy8JBXAdXRikGmlHXAQpFghnPWRfs= go.maximumdirect.net/promptkit v0.24.0 h1:C6UFY8WgW10PIEuXQN2Z0qi0at5mD3/GQoPul6alYHo= go.maximumdirect.net/promptkit v0.24.0/go.mod h1:o2axdkV11KTPDgk81i2vrJ66dtcedXRhau/Ko3YSZ4A= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4= -go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= go.yaml.in/yaml/v4 v4.0.0 h1:/LG1pNO84Z4l603j/xMn69CcS5OYhMQ/f7l2LoQUGuw= go.yaml.in/yaml/v4 v4.0.0/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= -golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= -golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo= golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/cli/configkit_load.go b/internal/cli/configkit_load.go index c13749d8..e06203d9 100644 --- a/internal/cli/configkit_load.go +++ b/internal/cli/configkit_load.go @@ -2,9 +2,7 @@ package cli import ( "context" - "errors" "fmt" - "io" "os" "reflect" "strings" @@ -162,25 +160,3 @@ func captureOverrideValue(value any) any { return value } } - -func writeConfigLoadError(output io.Writer, err error) { - var loadError *configkit.LoadError - if errors.As(err, &loadError) { - if writeErr := configkit.WriteDiagnostics(output, loadError.Diagnostics()); writeErr == nil { - // ConfigKit's locations contain source IDs. Keep its renderer and - // supply the acquired-source legend so imported/overlay errors can - // be traced to a file. Quoting also escapes terminal controls. - for _, source := range loadError.Sources() { - label := source.Path - if label == "" { - label = source.Label - } - if _, err := fmt.Fprintf(output, "source %q: %q\n", source.ID, label); err != nil { - return - } - } - return - } - } - fmt.Fprintf(output, "notarius: %v\n", err) -} diff --git a/internal/cli/configkit_load_test.go b/internal/cli/configkit_load_test.go index 55da3a95..b53247c9 100644 --- a/internal/cli/configkit_load_test.go +++ b/internal/cli/configkit_load_test.go @@ -137,19 +137,14 @@ func TestNativeDiscoverySelectionAndTerminalFailures(t *testing.T) { assertSelection(workingYAML, "yaml") } -func TestWriteConfigLoadErrorUsesSafeDiagnostics(t *testing.T) { +func TestUnsupportedConfigurationUsesNativeDiagnostics(t *testing.T) { t.Parallel() path := filepath.Join(t.TempDir(), "invalid.yml") writeConfigKitFile(t, path, "version: 5\n") - loaders := &nativeLoaders{lookupEnv: emptyLookup} - _, err := loaders.application(context.Background(), productionSelection(path)) - if err == nil { - t.Fatal("unsupported version loaded") - } - var output bytes.Buffer - writeConfigLoadError(&output, err) - if !strings.Contains(output.String(), "version") || !strings.Contains(output.String(), path) { - t.Fatalf("diagnostics=%q", output.String()) + var stdout, stderr bytes.Buffer + code := RunWithOptions([]string{"pipeline", "list", "--config", path}, &stdout, &stderr, Options{}) + if code != 2 || !strings.Contains(stderr.String(), "version") || !strings.Contains(stderr.String(), path) { + t.Fatalf("status=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String()) } } diff --git a/internal/cli/example_contract_test.go b/internal/cli/example_contract_test.go index b8f5ac34..ef5e4857 100644 --- a/internal/cli/example_contract_test.go +++ b/internal/cli/example_contract_test.go @@ -10,9 +10,7 @@ import ( "strings" "testing" - "gitea.maximumdirect.net/eric/notarius/internal/core/artifacts" "gitea.maximumdirect.net/eric/notarius/internal/core/config" - "gitea.maximumdirect.net/eric/notarius/internal/core/debugbundle" "gitea.maximumdirect.net/eric/notarius/internal/framework/contracts" "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd" @@ -30,8 +28,8 @@ func TestMaintainedExamplesLoadResolveAndList(t *testing.T) { for _, example := range maintainedExampleFiles(t) { t.Run(example.name, func(t *testing.T) { cfg := loadMaintainedExample(t, example.path) - if example.name == "complete" && (cfg.Concurrency.TotalLLM != 2 || cfg.Concurrency.StageWorkers["extract"] != 2) { - t.Fatalf("complete example concurrency = %#v, want explicit limits of 2", cfg.Concurrency) + if example.name == "complete" && cfg.Concurrency.Workers != 2 { + t.Fatalf("complete example concurrency = %#v, want an explicit shared worker limit of 2", cfg.Concurrency) } raw, err := os.ReadFile(example.transcriptPath) if err != nil { @@ -71,40 +69,17 @@ func TestMaintainedExamplesLoadResolveAndList(t *testing.T) { if got, want := strings.Join(generatedReferenceBindingDescriptions(materialized), "|"), strings.Join(generatedReferenceBindingDescriptions(parent), "|"); got != want { t.Fatalf("development generated reference bindings = %q, want parent bindings %q", got, want) } - eligibleBindings := 0 - for _, step := range materialized.Steps { - for _, lane := range step.ArtifactLanes { - for _, binding := range []struct { - module pipeline.ModuleBinding - executionClass contracts.ExecutionClass - }{ - {module: lane.Extract, executionClass: lane.ExtractExecutionClass}, - {module: lane.Normalize, executionClass: lane.NormalizeExecutionClass}, - } { - if binding.executionClass != "llm_backed" { - continue - } - eligibleBindings++ - if got := binding.module.StructuredOutputRepairAttempts; got == nil || *got != 0 { - t.Fatalf("development %s repair attempts = %v, want explicit zero", binding.module.Module, got) - } - } - } - } - if eligibleBindings == 0 { - t.Fatal("development variant had no eligible LLM bindings for repair policy") - } } if got := exampleStepLaneIDs(materialized); strings.Join(got, "|") != "describe-session:item-registry,location-registry,npc-registry,scene-descriptions|extract-events:combat-turns,item-occurrences,location-occurrences,npc-occurrences,spells|track-enemies:enemy-events" { t.Fatalf("complete example steps and lanes = %v, want the documented D&D extractor composition", got) } completePipelines[pipelineID] = materialized locationLane := referenceContractLane(t, materialized, "location-registry") - if locationLane.ArtifactKind != dnd.LocationRegistryKind || locationLane.Extract.Module != locationextract.Key || locationLane.Extract.Retries != 2 || locationLane.Merge.Module != pipeline.DefaultMergeModule || locationLane.Normalize.Module != locationnormalize.Key || locationLane.Normalize.Retries != 2 { + if locationLane.ArtifactKind != dnd.LocationRegistryKind || locationLane.Extract.Module != locationextract.Key || locationLane.Merge.Module != pipeline.DefaultMergeModule || locationLane.Normalize.Module != locationnormalize.Key { t.Fatalf("location lane = %#v, want typed registry composition", locationLane) } occurrenceLane := referenceContractLane(t, materialized, "location-occurrences") - if occurrenceLane.ArtifactKind != dnd.LocationOccurrenceListKind || occurrenceLane.Extract.Module != locationoccurrenceextract.Key || occurrenceLane.Extract.Retries != 2 || occurrenceLane.Merge.Module != pipeline.DefaultMergeModule || occurrenceLane.Normalize.Module != locationoccurrencenormalize.Key { + if occurrenceLane.ArtifactKind != dnd.LocationOccurrenceListKind || occurrenceLane.Extract.Module != locationoccurrenceextract.Key || occurrenceLane.Merge.Module != pipeline.DefaultMergeModule || occurrenceLane.Normalize.Module != locationoccurrencenormalize.Key { t.Fatalf("location occurrence lane = %#v, want typed occurrence composition", occurrenceLane) } for _, target := range []pipeline.ResolvedReferenceTarget{occurrenceLane.ExtractReferences, occurrenceLane.NormalizeReferences} { @@ -150,8 +125,12 @@ func TestMaintainedExamplesLoadResolveAndList(t *testing.T) { } } var stdout, stderr strings.Builder - code := RunWithOptions([]string{"pipelines", "list", "--config", example.path}, &stdout, &stderr, productionOptionsFromComponents(components)) - if code != 0 || stdout.String() != strings.Join(example.pipelineIDs, "\n")+"\n" || stderr.Len() != 0 { + code := RunWithOptions([]string{"pipeline", "list", "--config", example.path, "--format", "json"}, &stdout, &stderr, productionOptionsFromComponents(components)) + var ids []string + if err := json.Unmarshal([]byte(stdout.String()), &ids); err != nil { + t.Fatal(err) + } + if code != 0 || strings.Join(ids, ",") != strings.Join(example.pipelineIDs, ",") || stderr.Len() != 0 { t.Fatalf("pipelines list: code=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String()) } }) @@ -206,9 +185,9 @@ func TestMaintainedExamplesValidateEffectiveProfilesOffline(t *testing.T) { t.Run(pipelineID, func(t *testing.T) { var stdout, stderr strings.Builder code := RunWithOptions([]string{ - "config", "validate", "--config", example.path, "--pipeline", pipelineID, + "pipeline", "validate", pipelineID, "--config", example.path, }, &stdout, &stderr, Options{}) - if code != 0 || stderr.Len() != 0 || !strings.Contains(stdout.String(), `valid for pipeline "`+pipelineID+`"`) { + if code != 0 || stderr.Len() != 0 || !strings.Contains(stdout.String(), pipelineID) { t.Fatalf("code=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String()) } }) @@ -218,21 +197,11 @@ func TestMaintainedExamplesValidateEffectiveProfilesOffline(t *testing.T) { var stdout, stderr strings.Builder code := RunWithOptions([]string{ - "config", "profile", "--config", repositoryPath("examples", "dnd-complete.config.yml"), "dnd-extraction-development", + "promptkit", "show", "profile", "notarius/dnd-extraction-development", + "--config", repositoryPath("examples", "dnd-complete.config.yml"), "--format", "json", }, &stdout, &stderr, Options{}) - var profile struct { - ProfileID string `json:"profile_id"` - Target struct { - BackendID string `json:"backend_id"` - Model string `json:"model"` - Temperature float64 `json:"temperature"` - } `json:"effective_model_params"` - } - if err := json.Unmarshal([]byte(stdout.String()), &profile); err != nil { - t.Fatalf("development profile JSON = %q: %v", stdout.String(), err) - } - if code != 0 || stderr.Len() != 0 || profile.ProfileID != "dnd-extraction-development" || profile.Target.BackendID != "openrouter" || profile.Target.Model != "openai/gpt-5.6-luna" || profile.Target.Temperature != 0.2 { - t.Fatalf("development profile inspection = code %d, %q, %q, %#v", code, stdout.String(), stderr.String(), profile) + if code != 0 || stderr.Len() != 0 || !json.Valid([]byte(stdout.String())) || !strings.Contains(stdout.String(), "dnd-extraction-development") { + t.Fatalf("development profile inspection: status=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String()) } } @@ -274,7 +243,16 @@ func generatedReferenceBindingDescriptions(resolved pipeline.ResolvedPipeline) [ return descriptions } -func TestMaintainedMinimalInvocationProducesJSONBundle(t *testing.T) { +func TestMaintainedMinimalInvocationPublishesDomainArtifacts(t *testing.T) { + cfg := loadMaintainedExample(t, repositoryPath("examples", "dnd-minimal.config.yml")) + resolved, err := cfg.Resolve(resolveInputForMaintainedExample(productionTestComponents(t), "dnd-session")) + if err != nil { + t.Fatal(err) + } + lane := referenceContractLane(t, resolved.ResolvedPipeline, "spells") + if lane.Extract.Module != "dnd/spells" || lane.Normalize.Module != spellnormalize.Key || len(lane.ExtractReferences.Bindings) != 0 || len(lane.NormalizeReferences.Bindings) != 0 { + t.Fatalf("minimal spell composition=%#v, want embedded catalog without overlay references", lane) + } outputRoot := filepath.Join(t.TempDir(), "output") fake := &productionFakeLLMClient{} options := productionRunOptions(t, fake) @@ -282,60 +260,27 @@ func TestMaintainedMinimalInvocationProducesJSONBundle(t *testing.T) { code := RunWithOptions([]string{ "run", "dnd-session", "--config", repositoryPath("examples", "dnd-minimal.config.yml"), - "--input", repositoryPath("examples", "seriatim-minimal-transcript.json"), - "--only", "spells", "--chunk_cache", "bypass", "--output-dir", outputRoot, + "--input-file", repositoryPath("examples", "seriatim-minimal-transcript.json"), + "--lane", "spells", "--cache", "bypass", "--output-dir", outputRoot, "--format", "json", }, &stdout, &stderr, options) if code != 0 { - t.Fatalf("code=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String()) + t.Fatalf("status=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String()) } - if !strings.Contains(stdout.String(), `pipeline "dnd-session"`) || !strings.Contains(stdout.String(), "outputs=1 rejected=0") { - t.Fatalf("stdout=%q, want completed pipeline and counts", stdout.String()) + var report runResult + if err := json.Unmarshal([]byte(stdout.String()), &report); err != nil { + t.Fatal(err) } - runRoot := filepath.Join(outputRoot, productionRunID) - index := readProductionJSON[exampleOutputIndex](t, filepath.Join(runRoot, "index.json")) - if index.ManifestFile != "manifest.json" || index.RejectedFile != "rejected.json" || index.WarningsFile != "warnings.json" || len(index.OutputFiles) != 1 { - t.Fatalf("index = %#v, want one spells output and fixed companion files", index) + if report.Pipeline != "dnd-session" || report.ArtifactCount != 1 || report.OutputDirectory != runRoot || report.FallbackCount != 0 { + t.Fatalf("completion=%#v", report) } - entry := index.OutputFiles[0] - if entry.LaneID != "spells" || entry.File != "lanes/spells.json" || entry.MediaType != "application/json" || entry.SchemaID != "notarius.dnd.spells" || entry.SchemaVersion != "v1" { - t.Fatalf("index output entry = %#v, want spells JSON contract", entry) + files := readTree(t, runRoot) + if len(files) != 1 || files["lanes/spells.json"] == nil { + t.Fatalf("published files=%v, want only the spell artifact", files) } - - manifest := readProductionJSON[artifacts.RunManifest](t, filepath.Join(runRoot, "manifest.json")) - if manifest.PipelineID != "dnd-session" || manifest.InputModule != "seriatim" || manifest.Chunker != "generic" || manifest.OutputEncoder != "json" || manifest.ValidationStatus != "approved" || manifest.ChunkPlan == nil || manifest.ChunkPlan.Action != "bypassed" { - t.Fatalf("manifest = %#v, want approved minimal run", manifest) - } - if len(manifest.ArtifactLanes) != 1 { - t.Fatalf("manifest lanes = %#v, want exactly spells", manifest.ArtifactLanes) - } - lane := manifest.ArtifactLanes[0] - if lane.ID != "spells" || lane.Extractor != "dnd/spells" || lane.Merger != "appendorder" || lane.Normalizer != spellnormalize.Key { - t.Fatalf("manifest lane = %#v, want production spells composition", lane) - } - if len(manifest.References) != 0 { - t.Fatalf("base-only manifest references = %#v, want no overlay provenance", manifest.References) - } - extractorMetadata, ok := lane.Metadata["extractor"].(map[string]any) - if !ok || len(stringValues(extractorMetadata["catalog_overlay_ids"])) != 0 { - t.Fatalf("base-only extractor metadata = %#v, want no overlay IDs", lane.Metadata) - } - - artifact := readProductionJSON[dnd.SpellList](t, filepath.Join(runRoot, entry.File)) - if len(artifact.SpellCasts) != 1 || artifact.SpellCasts[0].Spell != "Cure Wounds" || artifact.SpellCasts[0].SourceRefs[0].SourceID != "session-alpha" { - t.Fatalf("artifact = %#v, want one source-linked Cure Wounds cast", artifact) - } - rejected := readProductionJSON[struct { - Rejected []json.RawMessage `json:"rejected"` - }](t, filepath.Join(runRoot, "rejected.json")) - if len(rejected.Rejected) != 0 { - t.Fatalf("rejected = %#v, want empty rejection list", rejected.Rejected) - } - warnings := readProductionJSON[struct { - Groups []json.RawMessage `json:"groups"` - }](t, filepath.Join(runRoot, "warnings.json")) - if len(warnings.Groups) != 0 { - t.Fatalf("warnings = %#v, want empty warning list", warnings.Groups) + artifact := readProductionJSON[dnd.SpellList](t, filepath.Join(runRoot, "lanes/spells.json")) + if len(artifact.SpellCasts) != 1 || artifact.SpellCasts[0].Spell != "Cure Wounds" || len(artifact.SpellCasts[0].SourceRefs) != 1 || artifact.SpellCasts[0].SourceRefs[0].SourceID != "session-alpha" { + t.Fatalf("artifact=%#v, want one source-linked Cure Wounds cast", artifact) } } @@ -352,11 +297,12 @@ func TestMaintainedMalformedInputOnlyRecordsDebugFailureWhenRequested(t *testing t.Run(name, func(t *testing.T) { outputRoot := filepath.Join(t.TempDir(), "output") debugRoot := filepath.Join(t.TempDir(), "debug") - options := productionRunOptions(t, &productionFakeLLMClient{}) + client := &productionFakeLLMClient{} + options := productionRunOptions(t, client) args := []string{ "run", "dnd-session", "--config", repositoryPath("examples", "dnd-minimal.config.yml"), - "--input", malformed, "--chunk_cache", "bypass", "--output-dir", outputRoot, + "--input-file", malformed, "--cache", "bypass", "--output-dir", outputRoot, } if debug { args = append(args, "--debug", "--debug-dir", debugRoot) @@ -372,35 +318,23 @@ func TestMaintainedMalformedInputOnlyRecordsDebugFailureWhenRequested(t *testing return } bundle := onlyChildDir(t, debugRoot) - report := readProductionJSON[debugbundle.RunReport](t, filepath.Join(bundle, "summary", "run-report.json")) - if report.Succeeded || report.PipelineID != "dnd-session" { - t.Fatalf("failure report = %#v, want failed dnd-session report", report) + outcome := readProductionJSON[struct { + Error string `json:"error"` + Outcome struct { + Pipeline string `json:"pipeline"` + Published bool `json:"published"` + } `json:"outcome"` + }](t, filepath.Join(bundle, "outcome.json")) + if !strings.Contains(outcome.Error, "parse input") || outcome.Outcome.Pipeline != "dnd-session" || outcome.Outcome.Published { + t.Fatalf("failure evidence=%#v", outcome) } - invocation := readProductionJSON[debugbundle.Invocation](t, filepath.Join(bundle, "summary", "invocation.json")) - manifest := readProductionJSON[artifacts.RunManifest](t, filepath.Join(bundle, "summary", "run-manifest.json")) - manifestSession, found := manifest.Metadata["session_id"] - if invocation.SessionID == "" || !found || manifestSession != invocation.SessionID { - t.Fatalf("failed run sessions: invocation=%q manifest=%#v metadata=%#v", invocation.SessionID, manifestSession, manifest.Metadata) + if len(client.requestsSnapshot()) != 0 { + t.Fatal("malformed input reached provider") } }) } } -type exampleOutputIndex struct { - ManifestFile string `json:"manifest_file"` - OutputFiles []exampleOutputIndexEntry `json:"output_files"` - RejectedFile string `json:"rejected_file"` - WarningsFile string `json:"warnings_file"` -} - -type exampleOutputIndexEntry struct { - LaneID string `json:"lane_id"` - MediaType string `json:"media_type"` - File string `json:"file"` - SchemaID string `json:"schema_id"` - SchemaVersion string `json:"schema_version"` -} - func resolveInputForMaintainedExample(components productionComponents, pipelineID string) config.ResolveInput { return config.ResolveInput{PipelineID: pipelineID, Catalog: catalogFromRegistries(components.registries)} } diff --git a/internal/cli/pipeline_run_test.go b/internal/cli/pipeline_run_test.go index 64502f9d..118a5799 100644 --- a/internal/cli/pipeline_run_test.go +++ b/internal/cli/pipeline_run_test.go @@ -216,8 +216,7 @@ func executeRunFixture(t *testing.T, app *commandkit.App, args ...string) comman var out, diagnostics bytes.Buffer outcome := app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &diagnostics}) if outcome.Status != 0 { - writeConfigLoadError(&diagnostics, outcome.Cause) - t.Fatalf("%v: %#v stderr=%s", args, outcome, diagnostics.String()) + t.Fatalf("%v: %#v cause=%v stderr=%s", args, outcome, outcome.Cause, diagnostics.String()) } return outcome } diff --git a/internal/modules/dnd/locations/registry/registry.go b/internal/modules/dnd/locations/registry/registry.go index b81b3726..6aec345c 100644 --- a/internal/modules/dnd/locations/registry/registry.go +++ b/internal/modules/dnd/locations/registry/registry.go @@ -5,7 +5,6 @@ package registry import ( "crypto/sha256" "encoding/hex" - "encoding/json" "fmt" "gitea.maximumdirect.net/eric/notarius/internal/core/source" @@ -26,12 +25,11 @@ const ( // Registry is an immutable, validated location registry prepared for prompt // grounding. All accessors return defensive copies. type Registry struct { - bound bool - list dnd.LocationRegistry - canonical []byte - digest string - identityDigest string - lookupByID map[string]int + bound bool + list dnd.LocationRegistry + canonical []byte + digest string + lookupByID map[string]int } // Resolver selects and memoizes immutable location registry views. @@ -99,12 +97,10 @@ func locationReferenceSpec() registryresolver.ReferenceSpec { func emptyRegistry() *Registry { content := []byte(emptyRegistryContent) - identityDigest := semanticDigest(content) return &Registry{ - list: dnd.LocationRegistry{Locations: []dnd.Location{}}, - canonical: append([]byte(nil), content...), - identityDigest: identityDigest, - lookupByID: map[string]int{}, + list: dnd.LocationRegistry{Locations: []dnd.Location{}}, + canonical: append([]byte(nil), content...), + lookupByID: map[string]int{}, } } @@ -127,19 +123,13 @@ func loadRegistry(referenceContent []byte) (*Registry, error) { for index, location := range list.Locations { lookupByID[location.ID] = index } - projection, err := identityProjection(list) - if err != nil { - return nil, fmt.Errorf("encode location prompt projection: %w", err) - } digest := semanticDigest(content) - identityDigest := semanticDigest(projection) return &Registry{ - bound: true, - list: list, - canonical: append([]byte(nil), content...), - digest: digest, - identityDigest: identityDigest, - lookupByID: lookupByID, + bound: true, + list: list, + canonical: append([]byte(nil), content...), + digest: digest, + lookupByID: lookupByID, }, nil } @@ -179,15 +169,6 @@ func (r *Registry) Digest() string { return r.digest } -// IdentityDigest returns the digest of the ordered ID/name identity projection -// used by deterministic consumers. -func (r *Registry) IdentityDigest() string { - if r == nil { - return "" - } - return r.identityDigest -} - // Count returns the number of validated location records. func (r *Registry) Count() int { if r == nil { @@ -219,23 +200,6 @@ func semanticDigest(content []byte) string { return "sha256:" + hex.EncodeToString(sum[:]) } -type identityProjectedLocation struct { - ID string `json:"id"` - Name string `json:"name"` -} - -type identityProjectedLocationRegistry struct { - Locations []identityProjectedLocation `json:"locations"` -} - -func identityProjection(list dnd.LocationRegistry) ([]byte, error) { - projection := identityProjectedLocationRegistry{Locations: make([]identityProjectedLocation, len(list.Locations))} - for index, location := range list.Locations { - projection.Locations[index] = identityProjectedLocation{ID: location.ID, Name: location.Name} - } - return json.Marshal(projection) -} - func formatIdentityIssues(issues []identity.Issue) string { parts := make([]string, len(issues)) for index, issue := range issues { diff --git a/internal/modules/dnd/locations/registry/registry_test.go b/internal/modules/dnd/locations/registry/registry_test.go index 5d48b336..5769f4ce 100644 --- a/internal/modules/dnd/locations/registry/registry_test.go +++ b/internal/modules/dnd/locations/registry/registry_test.go @@ -22,18 +22,19 @@ func TestResolveUnboundRegistryHasEmptyIdentity(t *testing.T) { if registry.Bound() || registry.Digest() != "" || registry.Count() != 0 || string(registry.CanonicalBytes()) != emptyRegistryContent { t.Fatalf("unbound registry = %#v", registry) } - if registry.IdentityDigest() == "" { - t.Fatal("unbound registry identity digest is empty") - } } -func TestResolveRetainsSeparateDurableAndIdentityDigests(t *testing.T) { +func TestResolveRetainsCanonicalDurableRegistry(t *testing.T) { registry := resolveList(t, registryFixture()) if !registry.Bound() || registry.Count() != 2 || registry.Digest() == "" { t.Fatalf("registry identity = bound %t count %d digest %q", registry.Bound(), registry.Count(), registry.Digest()) } - if registry.IdentityDigest() == "" || registry.Digest() == registry.IdentityDigest() { - t.Fatalf("full/identity digests = %q/%q", registry.Digest(), registry.IdentityDigest()) + content, err := locationcodec.New().Encode(registryFixture()) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(content, registry.CanonicalBytes()) { + t.Fatalf("canonical registry=%s, want %s", registry.CanonicalBytes(), content) } } @@ -228,8 +229,8 @@ func TestGroundingProjectsAndResolvesUniqueAndSameNameLocations(t *testing.T) { if bytes.Contains(grounding.PromptInput().Content, []byte("location:sha256:")) || bytes.Contains(grounding.PromptInput().Content, []byte(`"source_id"`)) { t.Fatalf("grounding projection exposed durable identity: %s", grounding.PromptInput().Content) } - if grounding.PromptInput().Digest == "" || grounding.PromptInput().Digest == registry.IdentityDigest() { - t.Fatalf("grounding/identity digests = %q/%q", grounding.PromptInput().Digest, registry.IdentityDigest()) + if grounding.PromptInput().Digest == "" { + t.Fatal("grounding projection has no content digest") } resolved, ok := grounding.Resolve(Selector{Name: " the tavern ", RegistryRefs: []RegistryRef{{StartUnitID: 30, EndUnitID: 30}, {StartUnitID: 20, EndUnitID: 20}}}) @@ -262,7 +263,7 @@ func TestGroundingProjectsAndResolvesUniqueAndSameNameLocations(t *testing.T) { } } -func TestGroundingHandlesEmptyRegistriesAndIdentityFingerprints(t *testing.T) { +func TestGroundingHandlesEmptyRegistriesAndStableUniqueNameProjection(t *testing.T) { doc := groundingDocument() empty := resolveList(t, dnd.LocationRegistry{Locations: []dnd.Location{}}) grounding, err := NewGrounding(empty, doc) @@ -288,8 +289,8 @@ func TestGroundingHandlesEmptyRegistriesAndIdentityFingerprints(t *testing.T) { if err != nil { t.Fatal(err) } - if base.IdentityDigest() != expanded.IdentityDigest() || baseGrounding.PromptInput().Digest != expandedGrounding.PromptInput().Digest { - t.Fatalf("identity/model fingerprints = %q/%q and %q/%q", base.IdentityDigest(), expanded.IdentityDigest(), baseGrounding.PromptInput().Digest, expandedGrounding.PromptInput().Digest) + if base.Locations()[0].ID != expanded.Locations()[0].ID || !bytes.Equal(baseGrounding.PromptInput().Content, expandedGrounding.PromptInput().Content) { + t.Fatalf("additional evidence changed unique location identity or projection: %#v %#v", base.Locations(), expanded.Locations()) } } diff --git a/internal/modules/dnd/npcs/registry/registry.go b/internal/modules/dnd/npcs/registry/registry.go index 8f329720..8ffe40c0 100644 --- a/internal/modules/dnd/npcs/registry/registry.go +++ b/internal/modules/dnd/npcs/registry/registry.go @@ -31,7 +31,6 @@ type Registry struct { canonical []byte digest string projectionDigest string - identityDigest string promptInput contracts.LLMInputMaterial lookupByKey map[string]int lookupByID map[string]int @@ -110,7 +109,6 @@ func emptyRegistry() *Registry { list: dnd.NPCRegistry{NPCs: []dnd.NPC{}}, canonical: append([]byte(nil), content...), projectionDigest: projectionDigest, - identityDigest: projectionDigest, promptInput: contracts.NewLLMInputMaterial(ReferenceSlot, npccodec.MediaType, content, projectionDigest, ""), lookupByKey: map[string]int{}, lookupByID: map[string]int{}, @@ -144,18 +142,12 @@ func loadRegistry(referenceContent []byte) (*Registry, error) { return nil, fmt.Errorf("encode NPC name projection: %w", err) } projectionDigest := semanticDigest(projection) - identityProjection, err := identityProjection(list) - if err != nil { - return nil, fmt.Errorf("encode NPC identity projection: %w", err) - } - identityProjectionDigest := semanticDigest(identityProjection) return &Registry{ bound: true, list: list, canonical: append([]byte(nil), content...), digest: digest, projectionDigest: projectionDigest, - identityDigest: identityProjectionDigest, promptInput: contracts.NewLLMInputMaterial(ReferenceSlot, npccodec.MediaType, projection, projectionDigest, ""), lookupByKey: lookupByKey, lookupByID: lookupByID, @@ -207,15 +199,6 @@ func (r *Registry) ProjectionDigest() string { return r.projectionDigest } -// IdentityDigest returns the SHA-256 digest of the ordered ID/name identity -// projection. It binds durable identities without exposing them to the model. -func (r *Registry) IdentityDigest() string { - if r == nil { - return "" - } - return r.identityDigest -} - // Count returns the number of validated NPC records. func (r *Registry) Count() int { if r == nil { @@ -267,19 +250,10 @@ type projectedNPC struct { Name string `json:"name"` } -type identityProjectedNPC struct { - ID string `json:"id"` - Name string `json:"name"` -} - type projectedNPCRegistry struct { NPCs []projectedNPC `json:"npcs"` } -type identityProjectedNPCRegistry struct { - NPCs []identityProjectedNPC `json:"npcs"` -} - func nameProjection(list dnd.NPCRegistry) ([]byte, error) { projection := projectedNPCRegistry{NPCs: make([]projectedNPC, len(list.NPCs))} for index, npc := range list.NPCs { @@ -288,14 +262,6 @@ func nameProjection(list dnd.NPCRegistry) ([]byte, error) { return json.Marshal(projection) } -func identityProjection(list dnd.NPCRegistry) ([]byte, error) { - projection := identityProjectedNPCRegistry{NPCs: make([]identityProjectedNPC, len(list.NPCs))} - for index, npc := range list.NPCs { - projection.NPCs[index] = identityProjectedNPC{ID: npc.ID, Name: npc.Name} - } - return json.Marshal(projection) -} - func formatIdentityIssues(issues []identity.Issue) string { parts := make([]string, len(issues)) for index, issue := range issues { diff --git a/internal/modules/dnd/npcs/registry/registry_test.go b/internal/modules/dnd/npcs/registry/registry_test.go index 06ff5be0..2954f018 100644 --- a/internal/modules/dnd/npcs/registry/registry_test.go +++ b/internal/modules/dnd/npcs/registry/registry_test.go @@ -19,7 +19,7 @@ func TestResolveUnboundRegistryHasExactEmptyProjection(t *testing.T) { t.Fatalf("Resolve() error = %v", err) } input := registry.PromptInput() - if registry.Bound() || registry.Digest() != "" || registry.Count() != 0 || string(input.Content) != emptyPrompt || registry.IdentityDigest() != registry.ProjectionDigest() { + if registry.Bound() || registry.Digest() != "" || registry.Count() != 0 || string(input.Content) != emptyPrompt { t.Fatalf("registry = %#v input = %#v, want unbound empty registry", registry, input) } if registry.ProjectionDigest() == "" || input.Digest != registry.ProjectionDigest() || input.OriginURI != "" { @@ -46,16 +46,8 @@ func TestResolveKeepsDurableProvenanceAndProjectsOnlyOrderedNames(t *testing.T) } } -func TestIdentityDigestTracksOrderedIDsAndNames(t *testing.T) { +func TestRegistryLookupByID(t *testing.T) { registry := resolveList(t, registryFixture()) - projection, err := identityProjection(registryFixture()) - if err != nil { - t.Fatal(err) - } - want := `{"npcs":[{"id":"` + identity.DeriveID("Mira Thorn") + `","name":"Mira Thorn"},{"id":"` + identity.DeriveID("Captain Vale") + `","name":"Captain Vale"}]}` - if string(projection) != want || registry.IdentityDigest() != semanticDigest(projection) || registry.IdentityDigest() == registry.ProjectionDigest() { - t.Fatalf("identity digest = %q, want digest for %s", registry.IdentityDigest(), want) - } if npc, ok := registry.LookupID(identity.DeriveID("Mira Thorn")); !ok || npc.Name != "Mira Thorn" { t.Fatalf("LookupID() = %#v, %t", npc, ok) } @@ -228,7 +220,7 @@ func TestProjectionIsStableForEquivalentNormalizedRegistries(t *testing.T) { secondList := registryFixture() secondList.NPCs[0].SourceRefs = append(secondList.NPCs[0].SourceRefs, source.SourceRef{SourceID: "session-beta", StartUnitID: 8, EndUnitID: 8}) second := resolveList(t, secondList) - if !reflect.DeepEqual(first.PromptInput().Content, second.PromptInput().Content) || first.ProjectionDigest() != second.ProjectionDigest() || first.IdentityDigest() != second.IdentityDigest() || first.Digest() == second.Digest() { + if !reflect.DeepEqual(first.PromptInput().Content, second.PromptInput().Content) || first.ProjectionDigest() != second.ProjectionDigest() || first.Digest() == second.Digest() { t.Fatalf("projection/full identity mismatch: %#v %#v", first, second) } }