All checks were successful
Build + deploy releases / build-and-deploy (push) Successful in 8s
Schema-driven form renderer plus zddc-server endpoints that turn any
<name>.form.yaml into a working data-collection form at <path>/<name>.form.html.
Submissions land in <path>/<name>/<YYYY-MM-DD>-<email-sanitized>.yaml,
ACL-gated by the existing .zddc cascade. The form posts back to its own URL;
the server strips ".html" and routes by what's underneath, so create and
update use the same client-side code path.
Form spec dialect: JSON Schema 2020-12 + RJSF-style ui:* hints, written in
YAML. Chosen for LLM authorability — it's the canonical structured-output
target for OpenAI/Anthropic, and the ui:* convention is the most-trained UI
hint vocabulary. Supported subset for v0: type (string/number/integer/boolean/
array/object), enum, min/max, minLength/maxLength, required, additionalProperties:
false, properties, items, format (date, email). Round-trip mode is form-as-truth:
submission YAML is regenerated each save, comments are not preserved (the v1
file-as-truth mode for hand-edited files like .zddc itself is deferred).
New components:
* form/ — sixth single-file HTML tool, vanilla JS renderer (~760 LoC)
* zddc/internal/jsonschema/ — focused JSON Schema validator covering only
the v0 keyword subset. Match-implementation-cost-to-surface-used: a full
library brings 70%+ surface we don't use; revisit when v1 adds $ref +
oneOf + if/then/else.
* zddc/internal/handler/formhandler.go — RecognizeFormRequest / ServeForm,
capability-URL re-edit, atomic submission writes via the new
zddc.WriteAtomic helper extracted from writer.go.
* dispatch() in zddc-server/main.go now intercepts *.form.html and
*.yaml.html before the static-file path; spec existence is the trigger.
Build pipeline: form joins ZDDC_RELEASE_TOOLS in lockstep, gets its own
embedded copy in handler/form.html (separate from the apps cascade —
the form renderer is fixed, not subject to per-folder version overrides).
Tests: 5 new Playwright specs (form-safety) + 14 new Go tests across the
validator and handler. All 172 Playwright tests + 10 Go packages green.
End-to-end manual verification: GET empty → POST 201 + capability URL →
GET re-edit (pre-filled) → POST update → 200, raw YAML browsable, ACL
deny → 403.
Docs: form/ section added to AGENTS.md and ARCHITECTURE.md. AGENTS.md
also documents the implementation-vs-dependency policy. CLAUDE.md repo-shape
list extended.
Deferred (v1+): .zddc editor migration onto this system, file-as-truth
lossless YAML round-trip, ui:show-when conditional visibility, oneOf/anyOf,
apps-cascade preview hook, cascade-fetched form definitions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
2.9 KiB
Go
49 lines
2.9 KiB
Go
// Package jsonschema is a focused JSON Schema 2020-12 validator covering only
|
|
// the subset of keywords used by the form-data system. See validate.go for the
|
|
// supported keyword list. Unsupported keywords are silently ignored — the
|
|
// form-spec meta-schema enforces that authors only use the supported subset.
|
|
//
|
|
// This package is intentionally smaller than a full JSON Schema implementation
|
|
// (e.g. github.com/santhosh-tekuri/jsonschema). Match-implementation-cost-to-
|
|
// surface-used: the form system never needs $ref, oneOf/anyOf, if/then/else,
|
|
// or remote schema fetch in v0; reimplementing that machinery would be more
|
|
// code than the entire validator we ship here.
|
|
//
|
|
// When the v1+ form-spec adds those features, revisit this trade-off.
|
|
package jsonschema
|
|
|
|
// Schema is the in-memory representation of a JSON Schema. Fields use both
|
|
// YAML and JSON tags so the same struct round-trips through either encoding —
|
|
// form specs are authored in YAML, but data submissions arrive as JSON.
|
|
//
|
|
// Pointer-typed fields (Minimum, Maximum, MinLength, MaxLength) distinguish
|
|
// "unset" from "set to zero", which matters because zero is a valid bound.
|
|
//
|
|
// AdditionalProperties is `any` to accept either a bool (the v0-supported
|
|
// shape — only `false` is enforced; `true` and unset are both "allow") or a
|
|
// nested schema (parsed but not enforced in v0).
|
|
type Schema struct {
|
|
Type string `yaml:"type" json:"type,omitempty"`
|
|
Properties map[string]*Schema `yaml:"properties" json:"properties,omitempty"`
|
|
Required []string `yaml:"required" json:"required,omitempty"`
|
|
Items *Schema `yaml:"items" json:"items,omitempty"`
|
|
Enum []any `yaml:"enum" json:"enum,omitempty"`
|
|
Minimum *float64 `yaml:"minimum" json:"minimum,omitempty"`
|
|
Maximum *float64 `yaml:"maximum" json:"maximum,omitempty"`
|
|
MinLength *int `yaml:"minLength" json:"minLength,omitempty"`
|
|
MaxLength *int `yaml:"maxLength" json:"maxLength,omitempty"`
|
|
Format string `yaml:"format" json:"format,omitempty"`
|
|
AdditionalProperties any `yaml:"additionalProperties" json:"additionalProperties,omitempty"`
|
|
Title string `yaml:"title" json:"title,omitempty"`
|
|
Description string `yaml:"description" json:"description,omitempty"`
|
|
Default any `yaml:"default" json:"default,omitempty"`
|
|
}
|
|
|
|
// Error reports a single validation failure. Path is a JSON Pointer (RFC 6901)
|
|
// pointing at the offending value within the validated document. Both fields
|
|
// flow through the form handler unchanged into the JSON response, so the
|
|
// browser-side renderer can locate and highlight the right widget.
|
|
type Error struct {
|
|
Path string `json:"path"`
|
|
Message string `json:"message"`
|
|
}
|