Finish native migration cleanup and restore whole-tree compilation
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user