v0.48.0 — SLICE-2: collection field schema + central validation (§22.4a)
Collections declare a `fields:` schema in `.collection.yaml`; entries carry typed metadata (enum/tags/text). New central `metadata_schema` module parses the schema leniently (INV-3) and validates entry values — advisory at read (corpus mirror flags violations as `metadata_malformed` without hard-failing), the enforcement point for the write boundary (edit endpoints land SLICE-4/5). - app/metadata_schema.py: parse_fields (lenient/normalizing) + validate - registry.parse_collection_manifest reads `fields:` into collection config - collections.get_collection unpacks `fields`; served by the collection API - cache._refresh_collection_corpus validates each entry advisory-only Non-breaking, opt-in: no `fields:` → unchanged (INV-5); default `document` collection declares none (N=1 unchanged). No DB migration — schema rides in collections.config_json. SLICE-2 of docs/design/2026-06-06-configurable-collection-metadata.md §7.2. Backend suite green (601 passed). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ from dataclasses import dataclass, field
|
||||
import yaml
|
||||
|
||||
from . import db
|
||||
from . import metadata_schema
|
||||
from .config import Config
|
||||
from .gitea import Gitea
|
||||
|
||||
@@ -159,6 +160,13 @@ def parse_collection_manifest(text: str) -> CollectionEntry:
|
||||
if not isinstance(em, list):
|
||||
raise RegistryError("collection enabled_models must be a list")
|
||||
cfg["enabled_models"] = [str(m) for m in em]
|
||||
# §22.4a SLICE-2: the collection's metadata field schema. Parsed leniently —
|
||||
# a bad field def is skipped with a warning, never fatal (INV-3), so a typo
|
||||
# in one field can't drop the whole collection from the mirror. Stored only
|
||||
# when at least one valid field survives.
|
||||
fields = metadata_schema.parse_fields(raw.get("fields"))
|
||||
if fields:
|
||||
cfg["fields"] = fields
|
||||
return CollectionEntry(ctype, vis, initial_state, name, cfg)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user