Finish native migration cleanup and restore whole-tree compilation

This commit is contained in:
2026-11-22 05:37:15 +00:00
parent 4fa437aee8
commit 3ef55f4668
12 changed files with 123 additions and 445 deletions

View File

@@ -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). [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 ## jsonschema
Selected module: `github.com/santhosh-tekuri/jsonschema/v6` at `v6.0.3`. 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). [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 ## go-yaml v4
Selected module: `go.yaml.in/yaml/v4` at `v4.0.0`. Selected module: `go.yaml.in/yaml/v4` at `v4.0.0`.

View File

@@ -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 ## 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, prompt filesystem/mount helpers, copied completion/correction/debug contracts,
old checkpoint/chunk-plan source packages, and reporting-only module fingerprint checkpoint/chunk-plan source packages, manual diagnostic renderer, reporting
methods. No runtime output/cache/debug files were removed. Preserved typed models, and reporting-only module fingerprint methods. No runtime output/cache/
validation-result checks, intrinsic artifact schemas, domain codecs, reference debug data was deleted. Production has one native execution path; no compatibility
compatibility, and source/identity rules. Corrected stale source/JSON fixture adapter or empty legacy package remains.
expectations and the configuration NUL/resolved-control assertions.
All framework, module (including the complete integration package), and Migrated retained framework, module integration, and CLI fixtures to real native
configuration tests now compile and pass. Migrated retained resolution, loaders, engines, provider requests, typed codecs, and published domain artifacts.
construction, reference materialization, typed handoff, codec, source/annotation Preserved catalog/registration and validator-chain checks, source/annotation
isolation, diagnostics, and session coverage. Cross-family contracts live in the isolation, contextual identity, chronology, generated-reference compatibility,
black-box module integration package and use real production registration and catalog semantics, evidence union, scene eligibility, complete assessment and
native provider fakes; the unchanged import-boundary tests pass. Published domain correction, diagnostics, sessions, and intrinsic codec rejection despite validator
and evidence files replace retired manifests and intermediate-output ledgers. overrides. Cross-family contracts retain their black-box integration boundary.
Spell, NPC, location, occurrence, combat, and grounded-pipeline fixtures retain Removed only superseded retry, checkpoint, manifest/index, synthetic completion,
canonical identity, contextual selection, source chronology, scene eligibility, and reporting-ledger assertions; native producer/cache/assessment/capture tests
complete correction/revalidation, and evidence-union behavior. Invalid combat own replacement behavior.
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.
The production executable builds. Real executable route and text/JSON/YAML/ Native command/configuration fixtures retain discovery/import/overlay origins,
fallback checks passed with a local fake HTTP provider after removal of the old inheritance, supplied overrides, secret-aware inspection, partial profiles,
runtime wrapper. Focused native CLI tests pass, but the full CLI suite and offline preflight, and explicit smoke work. Run/state fixtures retain independent
whole-tree compilation remain blocked by legacy CLI fixtures/imports. 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, `GOWORK=off go mod tidy`, `go list -m all`, whole-tree test compilation
engine, provider requests, version 6 test inputs, and native pipeline validation. (`go test ./... -run '^$'`), whole-tree vet, production executable build, and
Retained catalog/typed registration, validator-chain replacement, reference `git diff --check` pass. Removed old-path kits/catalog dependencies and their
materialization/limits, configured backend selection, scene description profile notices; retained notices for actual native/runtime dependencies and the Go
selection, source ranges, and published chunk-map provenance. Provider observations minimum of `1.27.0`, without replacements. Scoped removal searches find no current
and codec-decoded files replace profile manifests and normalized-output ledgers. legacy consumers; remaining fingerprint terminology concerns intrinsic domain
Oversized references prevent model work/publication without requiring the retired identity, and old-cache names in tests verify legacy data is left untouched.
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.
Assembled spell tests now exercise the real native extractor and continuation All framework, module/integration, configuration, and non-example CLI tests pass,
history rather than a synthetic model-candidate/correction protocol. Retained including real executable route/format/fallback checks with a local fake HTTP
merged-cast ordering, canonicalization, evidence, explicit validator overrides, provider. Focused complete pipeline/integration and CLI run/state/command/domain
and process/advisory distinctions. Native catalog correction tests cover selected race checks pass. The full runtime suite is not claimed passing: maintained
turn exhaustion and corrected overlay acceptance; strict terminal rejection example tests still reject the version 5 files, whose relocation/native migration
publishes no artifact. Catalog materialization retains raw-reference provenance belongs to Stage 36. Final assembled and whole-roadmap verification remain required.
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.
**Goal:** delete the old architecture rather than leave dormant alternatives. **Goal:** delete the old architecture rather than leave dormant alternatives.

4
go.mod
View File

@@ -3,8 +3,6 @@ module gitea.maximumdirect.net/eric/notarius
go 1.27.0 go 1.27.0
require ( 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 github.com/santhosh-tekuri/jsonschema/v6 v6.0.3
go.maximumdirect.net/ckconfig v0.10.0 go.maximumdirect.net/ckconfig v0.10.0
go.maximumdirect.net/ckprompt v0.11.0 go.maximumdirect.net/ckprompt v0.11.0
@@ -16,8 +14,6 @@ require (
) )
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/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/cobra v1.10.2 // indirect github.com/spf13/cobra v1.10.2 // indirect
github.com/spf13/pflag v1.1.0 // indirect github.com/spf13/pflag v1.1.0 // indirect

18
go.sum
View File

@@ -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/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 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= 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 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= 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/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 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= 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/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 h1:toLDGhHoVe6gBX5HWuzQ/Joz0cBqEhJXolW21m3axBk=
go.maximumdirect.net/commandkit v0.7.0/go.mod h1:sVp3JXKpm2YrP4Ie8Q3nWmQgwBdPN8uO+wQU72erDns= 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 h1:TfOupZbQ23/ZMs+xt5lmyukCF11ekqKep8KbmFQD63o=
go.maximumdirect.net/configkit v1.4.0/go.mod h1:ewu6blSokUDCMovy8JBXAdXRikGmlHXAQpFghnPWRfs= 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 h1:C6UFY8WgW10PIEuXQN2Z0qi0at5mD3/GQoPul6alYHo=
go.maximumdirect.net/promptkit v0.24.0/go.mod h1:o2axdkV11KTPDgk81i2vrJ66dtcedXRhau/Ko3YSZ4A= 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/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 h1:/LG1pNO84Z4l603j/xMn69CcS5OYhMQ/f7l2LoQUGuw=
go.yaml.in/yaml/v4 v4.0.0/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= 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 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY= 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/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=

View File

@@ -2,9 +2,7 @@ package cli
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io"
"os" "os"
"reflect" "reflect"
"strings" "strings"
@@ -162,25 +160,3 @@ func captureOverrideValue(value any) any {
return value 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)
}

View File

@@ -137,19 +137,14 @@ func TestNativeDiscoverySelectionAndTerminalFailures(t *testing.T) {
assertSelection(workingYAML, "yaml") assertSelection(workingYAML, "yaml")
} }
func TestWriteConfigLoadErrorUsesSafeDiagnostics(t *testing.T) { func TestUnsupportedConfigurationUsesNativeDiagnostics(t *testing.T) {
t.Parallel() t.Parallel()
path := filepath.Join(t.TempDir(), "invalid.yml") path := filepath.Join(t.TempDir(), "invalid.yml")
writeConfigKitFile(t, path, "version: 5\n") writeConfigKitFile(t, path, "version: 5\n")
loaders := &nativeLoaders{lookupEnv: emptyLookup} var stdout, stderr bytes.Buffer
_, err := loaders.application(context.Background(), productionSelection(path)) code := RunWithOptions([]string{"pipeline", "list", "--config", path}, &stdout, &stderr, Options{})
if err == nil { if code != 2 || !strings.Contains(stderr.String(), "version") || !strings.Contains(stderr.String(), path) {
t.Fatal("unsupported version loaded") t.Fatalf("status=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String())
}
var output bytes.Buffer
writeConfigLoadError(&output, err)
if !strings.Contains(output.String(), "version") || !strings.Contains(output.String(), path) {
t.Fatalf("diagnostics=%q", output.String())
} }
} }

View File

@@ -10,9 +10,7 @@ import (
"strings" "strings"
"testing" "testing"
"gitea.maximumdirect.net/eric/notarius/internal/core/artifacts"
"gitea.maximumdirect.net/eric/notarius/internal/core/config" "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/contracts"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd" "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
@@ -30,8 +28,8 @@ func TestMaintainedExamplesLoadResolveAndList(t *testing.T) {
for _, example := range maintainedExampleFiles(t) { for _, example := range maintainedExampleFiles(t) {
t.Run(example.name, func(t *testing.T) { t.Run(example.name, func(t *testing.T) {
cfg := loadMaintainedExample(t, example.path) cfg := loadMaintainedExample(t, example.path)
if example.name == "complete" && (cfg.Concurrency.TotalLLM != 2 || cfg.Concurrency.StageWorkers["extract"] != 2) { if example.name == "complete" && cfg.Concurrency.Workers != 2 {
t.Fatalf("complete example concurrency = %#v, want explicit limits of 2", cfg.Concurrency) t.Fatalf("complete example concurrency = %#v, want an explicit shared worker limit of 2", cfg.Concurrency)
} }
raw, err := os.ReadFile(example.transcriptPath) raw, err := os.ReadFile(example.transcriptPath)
if err != nil { 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 { 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) 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" { 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) t.Fatalf("complete example steps and lanes = %v, want the documented D&D extractor composition", got)
} }
completePipelines[pipelineID] = materialized completePipelines[pipelineID] = materialized
locationLane := referenceContractLane(t, materialized, "location-registry") 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) t.Fatalf("location lane = %#v, want typed registry composition", locationLane)
} }
occurrenceLane := referenceContractLane(t, materialized, "location-occurrences") 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) t.Fatalf("location occurrence lane = %#v, want typed occurrence composition", occurrenceLane)
} }
for _, target := range []pipeline.ResolvedReferenceTarget{occurrenceLane.ExtractReferences, occurrenceLane.NormalizeReferences} { for _, target := range []pipeline.ResolvedReferenceTarget{occurrenceLane.ExtractReferences, occurrenceLane.NormalizeReferences} {
@@ -150,8 +125,12 @@ func TestMaintainedExamplesLoadResolveAndList(t *testing.T) {
} }
} }
var stdout, stderr strings.Builder var stdout, stderr strings.Builder
code := RunWithOptions([]string{"pipelines", "list", "--config", example.path}, &stdout, &stderr, productionOptionsFromComponents(components)) code := RunWithOptions([]string{"pipeline", "list", "--config", example.path, "--format", "json"}, &stdout, &stderr, productionOptionsFromComponents(components))
if code != 0 || stdout.String() != strings.Join(example.pipelineIDs, "\n")+"\n" || stderr.Len() != 0 { 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()) 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) { t.Run(pipelineID, func(t *testing.T) {
var stdout, stderr strings.Builder var stdout, stderr strings.Builder
code := RunWithOptions([]string{ code := RunWithOptions([]string{
"config", "validate", "--config", example.path, "--pipeline", pipelineID, "pipeline", "validate", pipelineID, "--config", example.path,
}, &stdout, &stderr, Options{}) }, &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()) 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 var stdout, stderr strings.Builder
code := RunWithOptions([]string{ 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{}) }, &stdout, &stderr, Options{})
var profile struct { if code != 0 || stderr.Len() != 0 || !json.Valid([]byte(stdout.String())) || !strings.Contains(stdout.String(), "dnd-extraction-development") {
ProfileID string `json:"profile_id"` t.Fatalf("development profile inspection: status=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String())
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)
} }
} }
@@ -274,7 +243,16 @@ func generatedReferenceBindingDescriptions(resolved pipeline.ResolvedPipeline) [
return descriptions 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") outputRoot := filepath.Join(t.TempDir(), "output")
fake := &productionFakeLLMClient{} fake := &productionFakeLLMClient{}
options := productionRunOptions(t, fake) options := productionRunOptions(t, fake)
@@ -282,60 +260,27 @@ func TestMaintainedMinimalInvocationProducesJSONBundle(t *testing.T) {
code := RunWithOptions([]string{ code := RunWithOptions([]string{
"run", "dnd-session", "run", "dnd-session",
"--config", repositoryPath("examples", "dnd-minimal.config.yml"), "--config", repositoryPath("examples", "dnd-minimal.config.yml"),
"--input", repositoryPath("examples", "seriatim-minimal-transcript.json"), "--input-file", repositoryPath("examples", "seriatim-minimal-transcript.json"),
"--only", "spells", "--chunk_cache", "bypass", "--output-dir", outputRoot, "--lane", "spells", "--cache", "bypass", "--output-dir", outputRoot, "--format", "json",
}, &stdout, &stderr, options) }, &stdout, &stderr, options)
if code != 0 { 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") { var report runResult
t.Fatalf("stdout=%q, want completed pipeline and counts", stdout.String()) if err := json.Unmarshal([]byte(stdout.String()), &report); err != nil {
t.Fatal(err)
} }
runRoot := filepath.Join(outputRoot, productionRunID) runRoot := filepath.Join(outputRoot, productionRunID)
index := readProductionJSON[exampleOutputIndex](t, filepath.Join(runRoot, "index.json")) if report.Pipeline != "dnd-session" || report.ArtifactCount != 1 || report.OutputDirectory != runRoot || report.FallbackCount != 0 {
if index.ManifestFile != "manifest.json" || index.RejectedFile != "rejected.json" || index.WarningsFile != "warnings.json" || len(index.OutputFiles) != 1 { t.Fatalf("completion=%#v", report)
t.Fatalf("index = %#v, want one spells output and fixed companion files", index)
} }
entry := index.OutputFiles[0] files := readTree(t, runRoot)
if entry.LaneID != "spells" || entry.File != "lanes/spells.json" || entry.MediaType != "application/json" || entry.SchemaID != "notarius.dnd.spells" || entry.SchemaVersion != "v1" { if len(files) != 1 || files["lanes/spells.json"] == nil {
t.Fatalf("index output entry = %#v, want spells JSON contract", entry) t.Fatalf("published files=%v, want only the spell artifact", files)
} }
artifact := readProductionJSON[dnd.SpellList](t, filepath.Join(runRoot, "lanes/spells.json"))
manifest := readProductionJSON[artifacts.RunManifest](t, filepath.Join(runRoot, "manifest.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" {
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("artifact=%#v, want one source-linked Cure Wounds cast", artifact)
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)
} }
} }
@@ -352,11 +297,12 @@ func TestMaintainedMalformedInputOnlyRecordsDebugFailureWhenRequested(t *testing
t.Run(name, func(t *testing.T) { t.Run(name, func(t *testing.T) {
outputRoot := filepath.Join(t.TempDir(), "output") outputRoot := filepath.Join(t.TempDir(), "output")
debugRoot := filepath.Join(t.TempDir(), "debug") debugRoot := filepath.Join(t.TempDir(), "debug")
options := productionRunOptions(t, &productionFakeLLMClient{}) client := &productionFakeLLMClient{}
options := productionRunOptions(t, client)
args := []string{ args := []string{
"run", "dnd-session", "run", "dnd-session",
"--config", repositoryPath("examples", "dnd-minimal.config.yml"), "--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 { if debug {
args = append(args, "--debug", "--debug-dir", debugRoot) args = append(args, "--debug", "--debug-dir", debugRoot)
@@ -372,35 +318,23 @@ func TestMaintainedMalformedInputOnlyRecordsDebugFailureWhenRequested(t *testing
return return
} }
bundle := onlyChildDir(t, debugRoot) bundle := onlyChildDir(t, debugRoot)
report := readProductionJSON[debugbundle.RunReport](t, filepath.Join(bundle, "summary", "run-report.json")) outcome := readProductionJSON[struct {
if report.Succeeded || report.PipelineID != "dnd-session" { Error string `json:"error"`
t.Fatalf("failure report = %#v, want failed dnd-session report", report) 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")) if len(client.requestsSnapshot()) != 0 {
manifest := readProductionJSON[artifacts.RunManifest](t, filepath.Join(bundle, "summary", "run-manifest.json")) t.Fatal("malformed input reached provider")
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)
} }
}) })
} }
} }
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 { func resolveInputForMaintainedExample(components productionComponents, pipelineID string) config.ResolveInput {
return config.ResolveInput{PipelineID: pipelineID, Catalog: catalogFromRegistries(components.registries)} return config.ResolveInput{PipelineID: pipelineID, Catalog: catalogFromRegistries(components.registries)}
} }

View File

@@ -216,8 +216,7 @@ func executeRunFixture(t *testing.T, app *commandkit.App, args ...string) comman
var out, diagnostics bytes.Buffer var out, diagnostics bytes.Buffer
outcome := app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &diagnostics}) outcome := app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &diagnostics})
if outcome.Status != 0 { if outcome.Status != 0 {
writeConfigLoadError(&diagnostics, outcome.Cause) t.Fatalf("%v: %#v cause=%v stderr=%s", args, outcome, outcome.Cause, diagnostics.String())
t.Fatalf("%v: %#v stderr=%s", args, outcome, diagnostics.String())
} }
return outcome return outcome
} }

View File

@@ -5,7 +5,6 @@ package registry
import ( import (
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"encoding/json"
"fmt" "fmt"
"gitea.maximumdirect.net/eric/notarius/internal/core/source" "gitea.maximumdirect.net/eric/notarius/internal/core/source"
@@ -26,12 +25,11 @@ const (
// Registry is an immutable, validated location registry prepared for prompt // Registry is an immutable, validated location registry prepared for prompt
// grounding. All accessors return defensive copies. // grounding. All accessors return defensive copies.
type Registry struct { type Registry struct {
bound bool bound bool
list dnd.LocationRegistry list dnd.LocationRegistry
canonical []byte canonical []byte
digest string digest string
identityDigest string lookupByID map[string]int
lookupByID map[string]int
} }
// Resolver selects and memoizes immutable location registry views. // Resolver selects and memoizes immutable location registry views.
@@ -99,12 +97,10 @@ func locationReferenceSpec() registryresolver.ReferenceSpec {
func emptyRegistry() *Registry { func emptyRegistry() *Registry {
content := []byte(emptyRegistryContent) content := []byte(emptyRegistryContent)
identityDigest := semanticDigest(content)
return &Registry{ return &Registry{
list: dnd.LocationRegistry{Locations: []dnd.Location{}}, list: dnd.LocationRegistry{Locations: []dnd.Location{}},
canonical: append([]byte(nil), content...), canonical: append([]byte(nil), content...),
identityDigest: identityDigest, lookupByID: map[string]int{},
lookupByID: map[string]int{},
} }
} }
@@ -127,19 +123,13 @@ func loadRegistry(referenceContent []byte) (*Registry, error) {
for index, location := range list.Locations { for index, location := range list.Locations {
lookupByID[location.ID] = index lookupByID[location.ID] = index
} }
projection, err := identityProjection(list)
if err != nil {
return nil, fmt.Errorf("encode location prompt projection: %w", err)
}
digest := semanticDigest(content) digest := semanticDigest(content)
identityDigest := semanticDigest(projection)
return &Registry{ return &Registry{
bound: true, bound: true,
list: list, list: list,
canonical: append([]byte(nil), content...), canonical: append([]byte(nil), content...),
digest: digest, digest: digest,
identityDigest: identityDigest, lookupByID: lookupByID,
lookupByID: lookupByID,
}, nil }, nil
} }
@@ -179,15 +169,6 @@ func (r *Registry) Digest() string {
return r.digest 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. // Count returns the number of validated location records.
func (r *Registry) Count() int { func (r *Registry) Count() int {
if r == nil { if r == nil {
@@ -219,23 +200,6 @@ func semanticDigest(content []byte) string {
return "sha256:" + hex.EncodeToString(sum[:]) 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 { func formatIdentityIssues(issues []identity.Issue) string {
parts := make([]string, len(issues)) parts := make([]string, len(issues))
for index, issue := range issues { for index, issue := range issues {

View File

@@ -22,18 +22,19 @@ func TestResolveUnboundRegistryHasEmptyIdentity(t *testing.T) {
if registry.Bound() || registry.Digest() != "" || registry.Count() != 0 || string(registry.CanonicalBytes()) != emptyRegistryContent { if registry.Bound() || registry.Digest() != "" || registry.Count() != 0 || string(registry.CanonicalBytes()) != emptyRegistryContent {
t.Fatalf("unbound registry = %#v", registry) 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()) registry := resolveList(t, registryFixture())
if !registry.Bound() || registry.Count() != 2 || registry.Digest() == "" { if !registry.Bound() || registry.Count() != 2 || registry.Digest() == "" {
t.Fatalf("registry identity = bound %t count %d digest %q", registry.Bound(), registry.Count(), 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() { content, err := locationcodec.New().Encode(registryFixture())
t.Fatalf("full/identity digests = %q/%q", registry.Digest(), registry.IdentityDigest()) 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"`)) { 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) t.Fatalf("grounding projection exposed durable identity: %s", grounding.PromptInput().Content)
} }
if grounding.PromptInput().Digest == "" || grounding.PromptInput().Digest == registry.IdentityDigest() { if grounding.PromptInput().Digest == "" {
t.Fatalf("grounding/identity digests = %q/%q", grounding.PromptInput().Digest, registry.IdentityDigest()) 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}}}) 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() doc := groundingDocument()
empty := resolveList(t, dnd.LocationRegistry{Locations: []dnd.Location{}}) empty := resolveList(t, dnd.LocationRegistry{Locations: []dnd.Location{}})
grounding, err := NewGrounding(empty, doc) grounding, err := NewGrounding(empty, doc)
@@ -288,8 +289,8 @@ func TestGroundingHandlesEmptyRegistriesAndIdentityFingerprints(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if 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("identity/model fingerprints = %q/%q and %q/%q", base.IdentityDigest(), expanded.IdentityDigest(), baseGrounding.PromptInput().Digest, expandedGrounding.PromptInput().Digest) t.Fatalf("additional evidence changed unique location identity or projection: %#v %#v", base.Locations(), expanded.Locations())
} }
} }

View File

@@ -31,7 +31,6 @@ type Registry struct {
canonical []byte canonical []byte
digest string digest string
projectionDigest string projectionDigest string
identityDigest string
promptInput contracts.LLMInputMaterial promptInput contracts.LLMInputMaterial
lookupByKey map[string]int lookupByKey map[string]int
lookupByID map[string]int lookupByID map[string]int
@@ -110,7 +109,6 @@ func emptyRegistry() *Registry {
list: dnd.NPCRegistry{NPCs: []dnd.NPC{}}, list: dnd.NPCRegistry{NPCs: []dnd.NPC{}},
canonical: append([]byte(nil), content...), canonical: append([]byte(nil), content...),
projectionDigest: projectionDigest, projectionDigest: projectionDigest,
identityDigest: projectionDigest,
promptInput: contracts.NewLLMInputMaterial(ReferenceSlot, npccodec.MediaType, content, projectionDigest, ""), promptInput: contracts.NewLLMInputMaterial(ReferenceSlot, npccodec.MediaType, content, projectionDigest, ""),
lookupByKey: map[string]int{}, lookupByKey: map[string]int{},
lookupByID: 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) return nil, fmt.Errorf("encode NPC name projection: %w", err)
} }
projectionDigest := semanticDigest(projection) 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{ return &Registry{
bound: true, bound: true,
list: list, list: list,
canonical: append([]byte(nil), content...), canonical: append([]byte(nil), content...),
digest: digest, digest: digest,
projectionDigest: projectionDigest, projectionDigest: projectionDigest,
identityDigest: identityProjectionDigest,
promptInput: contracts.NewLLMInputMaterial(ReferenceSlot, npccodec.MediaType, projection, projectionDigest, ""), promptInput: contracts.NewLLMInputMaterial(ReferenceSlot, npccodec.MediaType, projection, projectionDigest, ""),
lookupByKey: lookupByKey, lookupByKey: lookupByKey,
lookupByID: lookupByID, lookupByID: lookupByID,
@@ -207,15 +199,6 @@ func (r *Registry) ProjectionDigest() string {
return r.projectionDigest 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. // Count returns the number of validated NPC records.
func (r *Registry) Count() int { func (r *Registry) Count() int {
if r == nil { if r == nil {
@@ -267,19 +250,10 @@ type projectedNPC struct {
Name string `json:"name"` Name string `json:"name"`
} }
type identityProjectedNPC struct {
ID string `json:"id"`
Name string `json:"name"`
}
type projectedNPCRegistry struct { type projectedNPCRegistry struct {
NPCs []projectedNPC `json:"npcs"` NPCs []projectedNPC `json:"npcs"`
} }
type identityProjectedNPCRegistry struct {
NPCs []identityProjectedNPC `json:"npcs"`
}
func nameProjection(list dnd.NPCRegistry) ([]byte, error) { func nameProjection(list dnd.NPCRegistry) ([]byte, error) {
projection := projectedNPCRegistry{NPCs: make([]projectedNPC, len(list.NPCs))} projection := projectedNPCRegistry{NPCs: make([]projectedNPC, len(list.NPCs))}
for index, npc := range list.NPCs { for index, npc := range list.NPCs {
@@ -288,14 +262,6 @@ func nameProjection(list dnd.NPCRegistry) ([]byte, error) {
return json.Marshal(projection) 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 { func formatIdentityIssues(issues []identity.Issue) string {
parts := make([]string, len(issues)) parts := make([]string, len(issues))
for index, issue := range issues { for index, issue := range issues {

View File

@@ -19,7 +19,7 @@ func TestResolveUnboundRegistryHasExactEmptyProjection(t *testing.T) {
t.Fatalf("Resolve() error = %v", err) t.Fatalf("Resolve() error = %v", err)
} }
input := registry.PromptInput() 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) t.Fatalf("registry = %#v input = %#v, want unbound empty registry", registry, input)
} }
if registry.ProjectionDigest() == "" || input.Digest != registry.ProjectionDigest() || input.OriginURI != "" { 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()) 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" { if npc, ok := registry.LookupID(identity.DeriveID("Mira Thorn")); !ok || npc.Name != "Mira Thorn" {
t.Fatalf("LookupID() = %#v, %t", npc, ok) t.Fatalf("LookupID() = %#v, %t", npc, ok)
} }
@@ -228,7 +220,7 @@ func TestProjectionIsStableForEquivalentNormalizedRegistries(t *testing.T) {
secondList := registryFixture() secondList := registryFixture()
secondList.NPCs[0].SourceRefs = append(secondList.NPCs[0].SourceRefs, source.SourceRef{SourceID: "session-beta", StartUnitID: 8, EndUnitID: 8}) secondList.NPCs[0].SourceRefs = append(secondList.NPCs[0].SourceRefs, source.SourceRef{SourceID: "session-beta", StartUnitID: 8, EndUnitID: 8})
second := resolveList(t, secondList) 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) t.Fatalf("projection/full identity mismatch: %#v %#v", first, second)
} }
} }