Centralize generic LLM schema assets

This commit is contained in:
2026-08-05 00:34:56 +00:00
parent f4c05c34ef
commit a57f83e30d
6 changed files with 1089 additions and 5 deletions

View File

@@ -1,31 +0,0 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "notarius.test_artifact",
"type": "object",
"additionalProperties": false,
"required": ["value"],
"properties": {
"value": {
"type": "string",
"minLength": 1
},
"source_refs": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["source_id", "unit_id"],
"properties": {
"source_id": {
"type": "string",
"minLength": 1
},
"unit_id": {
"type": "string",
"minLength": 1
}
}
}
}
}
}

View File

@@ -1,21 +0,0 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "notarius.test_validator_decision",
"type": "object",
"additionalProperties": false,
"required": ["accepted", "reason"],
"properties": {
"accepted": {
"type": "boolean"
},
"reason": {
"type": "string",
"minLength": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
}
}

View File

@@ -2,17 +2,17 @@ package llm
import (
"crypto/sha256"
"embed"
"encoding/hex"
"encoding/json"
"fmt"
"io/fs"
"sort"
"strings"
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
)
//go:embed assets/schemas/*.json
var schemaAssets embed.FS
var schemaAssets = mustSubFS(rootassets.FS(), "generic")
// ResponseSchemaKey identifies one structured response schema.
type ResponseSchemaKey string
@@ -49,17 +49,25 @@ var responseSchemaRegistry = map[ResponseSchemaKey]ResponseSchema{
ID: "notarius.test_artifact",
Version: schemaVersionV1,
Name: "notarius_test_artifact_v1",
AssetPath: "assets/schemas/test_artifact.v1.json",
AssetPath: "schemas/test_artifact.v1.json",
}),
TestValidatorDecisionSchemaKey: mustLoadResponseSchema(schemaAssets, ResponseSchemaDefinition{
Key: TestValidatorDecisionSchemaKey,
ID: "notarius.test_validator_decision",
Version: schemaVersionV1,
Name: "notarius_test_validator_decision_v1",
AssetPath: "assets/schemas/test_validator_decision.v1.json",
AssetPath: "schemas/test_validator_decision.v1.json",
}),
}
func mustSubFS(fsys fs.FS, dir string) fs.FS {
sub, err := fs.Sub(fsys, dir)
if err != nil {
panic(fmt.Errorf("scope embedded assets to %s: %w", dir, err))
}
return sub
}
// RegisteredResponseSchemas returns all registered response schemas sorted by key.
func RegisteredResponseSchemas() []ResponseSchema {
keys := make([]string, 0, len(responseSchemaRegistry))