ZDDC/zddc/internal/zddc/schema.go
ZDDC 9b9d823a67 feat(zddc): .zddc JSON Schema (machine grammar) with structure/option tiers
Authoritative machine form of the GRAMMAR.md grammar: zddc.schema.json
(draft 2020-12) describes every .zddc key with type, enum, description, and
x-zddc-tier — "structure" (the project shape an end user shouldn't change:
paths, worm, *_tool, views, available_tools, auto_own*, party_source, history*,
records, acl, created_by) vs "option" (the blanks an operator fills: roles
members, field_codes, convert, display, admins, title, planned dates). This is
the contract a future .zddc form view uses to render option fields editable and
structure fields read-only.

Embedded (ZddcSchemaBytes) and served at GET /.api/zddc-schema for the client.
Test locks the tier classification.

Scope note: the schema uses $ref (recursive paths:) + patternProperties, which
the in-tree internal/jsonschema validator doesn't support — so it drives the
form/client now; wiring it as the SERVER validator (replacing validate.go's
hand-rolled checks) needs a $ref-capable validator and is a separate decision.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 14:54:07 -05:00

20 lines
681 B
Go

package zddc
import _ "embed"
// schemaBytes is the embedded .zddc JSON Schema (draft 2020-12). The
// authoritative machine grammar: it drives the form view (per-property
// x-zddc-tier: structure|option decides editable vs read-only) and client
// validation. Server-side structural validation still lives in validate.go —
// this schema uses $ref + patternProperties, which the in-tree
// internal/jsonschema validator does not yet support.
//
//go:embed zddc.schema.json
var schemaBytes []byte
// ZddcSchemaBytes returns a copy of the embedded .zddc JSON Schema.
func ZddcSchemaBytes() []byte {
out := make([]byte, len(schemaBytes))
copy(out, schemaBytes)
return out
}