Move location registry modules to canonical namespace
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
|
||||
locationcodec "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/codec/locations"
|
||||
locationcodec "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/codec/locationregistry"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/locations/identity"
|
||||
)
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestRegisterPromptAssetsPreparesLocationOccurrencePrompt(t *testing.T) {
|
||||
PromptID: PromptID, PromptVersion: SchemaVersion, ProfileID: "location-occurrences-test",
|
||||
Inputs: map[string]promptkit.ArtifactRef{
|
||||
"transcript": promptkit.Inline(`{"units":[{"sentinel":"location-occurrence-transcript"}]}`), "players": promptkit.Inline("location-occurrence-player"), "party": promptkit.Inline(" "), "glossary": promptkit.Inline(" "),
|
||||
"locations": promptkit.Inline(`{"locations":[{"id":"location:sha256:test","name":"location-occurrence-registry"}]}`),
|
||||
"location_registry": promptkit.Inline(`{"locations":[{"id":"location:sha256:test","name":"location-occurrence-registry"}]}`),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -48,4 +48,13 @@ func TestRegisterPromptAssetsPreparesLocationOccurrencePrompt(t *testing.T) {
|
||||
if !strings.Contains(registryMessage, "location:sha256:test") || !strings.Contains(registryMessage, "location-occurrence-registry") || strings.Contains(registryMessage, "source_refs") {
|
||||
t.Fatalf("rendered prompt did not preserve source-free registry grounding: %s", registryMessage)
|
||||
}
|
||||
content := make([]string, len(prepared.Messages))
|
||||
for index, message := range prepared.Messages {
|
||||
content[index] = message.Content
|
||||
}
|
||||
rendered := strings.Join(content, "\n")
|
||||
policy := strings.ReplaceAll(rendered, "\n", " ")
|
||||
if !strings.Contains(policy, "context supports that coreference") || !strings.Contains(policy, "must not create a registry location") || !strings.Contains(policy, "provenance must never replace current-chunk evidence") {
|
||||
t.Fatalf("rendered prompt = %q, want contextual coreference without registry-derived evidence", rendered)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package locations
|
||||
package locationregistry
|
||||
|
||||
import (
|
||||
"sort"
|
||||
@@ -1,5 +1,5 @@
|
||||
// Package locations extracts source-grounded D&D physical location candidates.
|
||||
package locations
|
||||
// Package locationregistry extracts source-grounded D&D location-registry candidates.
|
||||
package locationregistry
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -13,12 +13,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
Key = "dnd/locations"
|
||||
mappingPolicy = "dnd.locations.extract_mapping.v1"
|
||||
Key = "dnd/location-registry"
|
||||
mappingPolicy = "dnd.location_registry.extract_mapping.v1"
|
||||
)
|
||||
|
||||
var requiredCapabilities = []string{"chunks", "source.transcript"}
|
||||
var providedCapabilities = []string{"dnd.locations"}
|
||||
var providedCapabilities = []string{"dnd.location_registry"}
|
||||
|
||||
var referenceSlotDescriptions = shared.ReferenceSlotDescriptions{
|
||||
Glossary: "Optional campaign glossary reference material used only for location disambiguation.",
|
||||
@@ -148,5 +148,5 @@ func DecodeOptions(options map[string]any) (Options, error) {
|
||||
}
|
||||
|
||||
func extractorErrorf(format string, args ...any) error {
|
||||
return fmt.Errorf("dnd locations extractor: "+format, args...)
|
||||
return fmt.Errorf("dnd location registry extractor: "+format, args...)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package locations
|
||||
package locationregistry
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -113,13 +113,13 @@ func TestExtractHandlesEmptyOutputAndLocalFailures(t *testing.T) {
|
||||
{name: "preflight", extractor: newExtractor(t, &fakeLocationsLLMClient{}), req: mismatchedSourceInputRequest(request), want: "must match chunk"},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if _, err := test.extractor.Extract(context.Background(), test.req); err == nil || !strings.Contains(err.Error(), "dnd locations") || !strings.Contains(err.Error(), test.want) {
|
||||
if _, err := test.extractor.Extract(context.Background(), test.req); err == nil || !strings.Contains(err.Error(), "dnd location registry") || !strings.Contains(err.Error(), test.want) {
|
||||
t.Fatalf("Extract() error = %v, want local context", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
_, err = newExtractor(t, &fakeLocationsLLMClient{err: errors.New("provider unavailable")}).Extract(context.Background(), request)
|
||||
if err == nil || !strings.Contains(err.Error(), "dnd locations") || !strings.Contains(err.Error(), "provider unavailable") {
|
||||
if err == nil || !strings.Contains(err.Error(), "dnd location registry") || !strings.Contains(err.Error(), "provider unavailable") {
|
||||
t.Fatalf("provider error = %v, want contextual provider error", err)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package locations
|
||||
package locationregistry
|
||||
|
||||
type extractionResponse struct {
|
||||
Locations []locationResponse `json:"locations"`
|
||||
@@ -1,4 +1,4 @@
|
||||
package locations
|
||||
package locationregistry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -29,7 +29,7 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
||||
}
|
||||
|
||||
func moduleAssetFS() (fs.FS, error) {
|
||||
assets, err := fs.Sub(rootassets.FS(), "dnd/locations/extract")
|
||||
assets, err := fs.Sub(rootassets.FS(), "dnd/location-registry/extract")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("scope location extraction assets: %w", err)
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package locations
|
||||
package locationregistry
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -29,7 +30,15 @@ func TestRegisterPromptAssetsPreparesLocationPrompt(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Prepare() error = %v", err)
|
||||
}
|
||||
if prepared.PromptID != PromptID || prepared.OutputContract.SchemaPath != "dnd_locations_llm.v1.json" {
|
||||
if prepared.PromptID != PromptID || prepared.OutputContract.SchemaPath != "dnd_location_registry_llm.v1.json" {
|
||||
t.Fatalf("prepared prompt = %#v, want location prompt identity and schema wiring", prepared)
|
||||
}
|
||||
content := make([]string, len(prepared.Messages))
|
||||
for index, message := range prepared.Messages {
|
||||
content[index] = message.Content
|
||||
}
|
||||
rendered := strings.Join(content, "\n")
|
||||
if !strings.Contains(rendered, "stable proper name or unique in-world designation") || !strings.Contains(rendered, "the room") || !strings.Contains(rendered, "Do not use capitalization as an eligibility test") {
|
||||
t.Fatalf("rendered prompt = %q, want named-or-unique location eligibility rules", rendered)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package locations
|
||||
package locationregistry
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
@@ -18,7 +18,7 @@ func TestModuleRegistrationAndMetadata(t *testing.T) {
|
||||
if _, err := New(&fakeLocationsLLMClient{}, Options{}, contracts.ReferenceSet{}, contracts.ReferenceSet{}); err == nil || !strings.Contains(err.Error(), "at most one") {
|
||||
t.Fatalf("New() error = %v, want reference-set rejection", err)
|
||||
}
|
||||
want := pipeline.ModuleSpec{Key: Key, Stage: pipeline.StageExtract, ExecutionClass: contracts.ExecutionClassLLMBacked, Requires: []string{"chunks", "source.transcript"}, Provides: []string{"dnd.locations"}, ArtifactKind: dnd.LocationRegistryKind, ReferenceSlots: referenceSlots()}
|
||||
want := pipeline.ModuleSpec{Key: Key, Stage: pipeline.StageExtract, ExecutionClass: contracts.ExecutionClassLLMBacked, Requires: []string{"chunks", "source.transcript"}, Provides: []string{"dnd.location_registry"}, ArtifactKind: dnd.LocationRegistryKind, ReferenceSlots: referenceSlots()}
|
||||
if got := ModuleSpec(); !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("ModuleSpec() = %#v, want %#v", got, want)
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package locations
|
||||
package locationregistry
|
||||
|
||||
import "gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||
|
||||
const (
|
||||
PromptID = "dnd.locations"
|
||||
ResponseSchemaKey = llm.ResponseSchemaKey("dnd_locations_llm")
|
||||
ResponseSchemaID = "notarius.dnd.locations.llm"
|
||||
ResponseSchemaName = "notarius_dnd_locations_llm_v1"
|
||||
PromptID = "dnd.location_registry"
|
||||
ResponseSchemaKey = llm.ResponseSchemaKey("dnd_location_registry_llm")
|
||||
ResponseSchemaID = "notarius.dnd.location_registry.llm"
|
||||
ResponseSchemaName = "notarius_dnd_location_registry_llm_v1"
|
||||
SchemaVersion = "v1"
|
||||
)
|
||||
|
||||
@@ -20,6 +20,6 @@ func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||
ID: ResponseSchemaID,
|
||||
Version: SchemaVersion,
|
||||
Name: ResponseSchemaName,
|
||||
AssetPath: "schemas/dnd_locations_llm.v1.json",
|
||||
AssetPath: "schemas/dnd_location_registry_llm.v1.json",
|
||||
})
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package locations
|
||||
package locationregistry
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@@ -1,4 +1,4 @@
|
||||
package locations
|
||||
package locationregistry
|
||||
|
||||
import (
|
||||
"context"
|
||||
Reference in New Issue
Block a user