Feat v0.9.5 typed forms SDK primitive

Extract typed form system from models/workflow.go into standalone
server/forms/ package. Any package can now declare and validate
forms, not just workflow stages.

- New server/forms/ package (types + validation + condition evaluator)
- REST POST /api/v1/forms/validate endpoint
- Starlark forms.validate(template, data) module
- Frontend sw.forms.render(), .validate(), .validateRemote()
- Manifest form_template accepted at package level
- 16 new tests (12 forms + 4 Starlark module)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 16:54:02 +00:00
parent 6b9ce92103
commit 89d64ab2aa
16 changed files with 1415 additions and 323 deletions

View File

@@ -5,6 +5,8 @@ import (
"fmt"
"regexp"
"strings"
"armature/forms"
)
// validManifestID matches lowercase alphanumeric slugs with optional hyphens.
@@ -35,6 +37,7 @@ type ManifestInfo struct {
GatePermission string // if set, checks this user permission before calling on_request
RequiresRoles []string // team roles needed to access this package (advisory, OR semantics)
Adoptable bool // if true, teams can adopt this package to get a team-scoped copy
HasFormTemplate bool // if true, package declares a form_template at the top level
}
// ValidateManifest parses a manifest map and validates all required fields,
@@ -184,6 +187,18 @@ func ValidateManifest(manifest map[string]any) (*ManifestInfo, error) {
info.Adoptable = v
}
// v0.9.5: form_template — any package can declare a typed form template
if manifest["form_template"] != nil {
raw, err := json.Marshal(manifest["form_template"])
if err != nil {
return nil, fmt.Errorf("form_template is invalid JSON")
}
if tpl := forms.ParseTypedFormTemplate(raw); tpl == nil {
return nil, fmt.Errorf("form_template is invalid or empty")
}
info.HasFormTemplate = true
}
info.SchemaVersion = ParseSchemaVersion(manifest)
// ── Type-specific constraints ────────────────────────────────