Skip to content

fix(spec): FormField constraint keys converge on the landed value shapes (int lengths >= 1, digit counts >= 0) - #12458

Merged
huangyiirene merged 3 commits into
mainfrom
claude/issue-12174-formfield-constraint-shape
Aug 26, 2026
Merged

huangyiirene merged 3 commits into
mainfrom
claude/issue-12174-formfield-constraint-shape

Conversation

@huangyiirene

Copy link
Copy Markdown
Collaborator

Fixes #12174

What

FormFieldBaseSchema's count-shaped constraint keys (packages/spec/src/ui/view.zod.ts) converge on the value shapes the object-field surface already landed:

key before after template
maxLength z.number().optional() z.number().int().min(1).optional() #11566
minLength z.number().optional() z.number().int().min(1).optional() #11949 (maintainer ruling 2026-08-25: minLength: 0 is a vacuous always-true declaration, refused loudly; "no minimum" = omit the key)
precision z.number().optional() z.number().int().min(0).optional() #8321
scale z.number().optional() z.number().int().min(0).optional() #8321
min / max z.number().optional() unchanged they are values, not counts — bare numbers on the object-field surface too

Mirrored from what LANDED on origin/main (data/field.zod.ts at af56546), not the card's snapshot.

Step 1 — reader measurement (the triage-mandated fork decider)

Population: objectui @ f7c52e2 (origin/main, fetched 2026-08-26) — full repo (apps/ + packages/); objectstack @ af56546 — public-form resolve path (packages/rest).

key reader evidence
all six objectui spec bridge packages/react/src/spec-bridge/bridges/form-view.ts mapField (objectui#5898) copies maxLength/minLength/min/max/precision/scale same-name onto the runtime field
all six objectui plugin-form packages/plugin-form/src/sectionFields.ts normalizeSectionField copies the same six (fd.maxLength … fd.scale)
maxLength console FormPage apps/console/src/components/FormPage.tsx:548 override.maxLength ?? def.maxLength (objectui#5595 — the form ceiling wins), passed to the input at :1373/:1481
minLength/maxLength/min/max validation rules packages/fields/src/index.tsx buildValidationRules → react-hook-form rules (validation.minLength etc.)
precision number widget step packages/plugin-form/src/ObjectForm.tsx:691 Math.pow(10, -field.precision)
scale number widget packages/fields/src/widgets/NumberField.tsx:21
all six (conduit) public-form resolve packages/rest/src/rest-server.ts GET /forms/:slug serves section field rows verbatim ({ ...sec, fields } — filter-only) to anonymous renderers; no key-level read or strip server-side

Controls (a zero without a control probe is not a reading): placeholder/required/readonly — known-live FormField keys — are found by the same grep at the same three merge sites (FormPage.tsx:538-548, sectionFields.ts, mapField); and the first grep pass (git grep -- 'packages/*/src') returned zero for both target and control, exposing a pathspec fault, and was re-run with corrected paths before any zero was believed.

Verdict: fork (a) — keys are live ⇒ shape-tighten in place. The concrete defect: maxLength: 0 on a form row reached the DOM as an input that accepts nothing (0 ?? def — 0 is not nullish, so it beat the object field's own bound).

Why no type-conditional gate (the applicability nuance argued, per the card)

The object-field twins refuse the length keys outside BOUNDED_STRING_FIELD_TYPES via superRefine. That gate has no analogue here: a form row references its object field by name and usually omits type, so the referenced field's type is invisible to this schema at parse time. A gate firing only when the optional presentational type override happens to be authored would make validation strictness depend on an unrelated key — a trap, not a contract. Value shape is checkable on this surface; key placement stays the object field's own schema's job. (Misplaced-but-well-formed row keys are inert-and-harmless pass-throughs; malformed values are what measurably corrupted rendering.)

ADR-0087

Two semantic 18 entries registered in the same PR (the #11949 lesson — #11566's deferred entry needed a follow-up card): ui-form-field-length-malformed-refused, ui-form-field-precision-scale-integer-refused (entry files under entries/semantic/, registry region regenerated by gen:migration-registry). Changeset '@objectstack/spec': minor carries the registered disposition marker, following the #11949 changeset verbatim in structure. No stored-row conversion, matching the #11566/#11949 length-pair precedent (the data-surface scale/precision conversion predates it and was not extended to lengths); a stored form view carrying a malformed row value is refused on its next authoring-path save, as the entries' acceptance criteria state.

Liveness ledger

packages/spec/liveness/view.json FormField subtree row (sections): the blanket undrilled verdict is drilled for the six constraint keys with the measurement above (per the file's own convention — one drill level, sub-key detail in the parent note, as publicPicker did).

Scope notes

Verification

All at final head c8d99bb (post origin/main merge at 8515954; main lands PRs continuously, so CI's merge-ref build is the joint validator):

  • pnpm --filter @objectstack/spec build + check:generated — "All 14 generated artifacts are up to date."
  • Targeted tests: vitest run src/ui/view.test.ts src/migrations src/conversions — 6 files, 602 passed (includes the new #12174 refusal/acceptance block).
  • Reverse verification (ablation): schema file reverted to base af56546, mutation proven on disk by anchored grep counts (marker 1→0, old shape 0→1), then the #12174 block re-run: 10 refusal tests red, 2 acceptance tests green — the predicted direction; restore proven by empty git diff HEAD + matching blob hash vs the HEAD blob. No rebuild needed on either leg: view.test.ts imports ./view.zod from src, no dist in the resolution path.
  • pnpm typecheck (spec) — tsc clean; gate's own line: "check:test-typecheck: OK — @objectstack/spec's test layer compiles under packages/spec/tsconfig.test.json".
  • Implicated-gate union at c8d99bb, all exit 0 with exits captured pre-pipe: check:nul-bytes, check:entry-nameability (new gate the merge brought, directly covering the added entry files), check:liveness, check-adr-0087-registration ("adds no declared-breaking changeset (1 non-breaking changeset(s) seen)"), check-changeset-no-major, check-empty-changeset, check:merge-driver, check:spec-parsed-alias, check:where-matcher (convention-triggered: test edit), check:test-source-alias, check:cross-package-test-inputs.
  • dispatch-gates.mjs re-derived at c8d99bb (stderr names this tree/commit): derived list identical to the pre-merge derivation; repo-wide scans (pnpm lint et al.) are CI-owned.

Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/spec, touching 3 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/spec/liveness/view.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

6 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/protocol/objectui/actions.mdx (via /forms/:slug (route))
  • content/docs/protocol/objectui/layout-dsl.mdx (via /forms/:slug (route))
  • content/docs/ui/actions.mdx (via /forms/:slug (route))
  • content/docs/ui/forms.mdx (via /forms/:slug (route))
  • content/docs/ui/public-data-collection.mdx (via /forms/:slug (route))
  • content/docs/ui/views.mdx (via /forms/:slug (route))
What this run could not see
  • 1 changed file(s) yielded no anchor (packages/spec/liveness/view.json) — pages documenting those are invisible to this run
  • 4 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 47 of 219 client-bound route-ledger rows — the other 172 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 172: 14 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 56 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 102 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.

Coarse fallback — 126 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 68c5dbaab2ecbc031e7342c9f2fc9efd6ad8bd08 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from fa202656092ca4817863d154c0257c438406f01c — the merge of head c8d99bb7318a9e538aab87e44dbbdb31d33b5df6 into base 68c5dbaab2ecbc031e7342c9f2fc9efd6ad8bd08, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin fa202656092ca4817863d154c0257c438406f01c && git checkout fa202656092ca4817863d154c0257c438406f01c
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 68c5dbaab2ecbc031e7342c9f2fc9efd6ad8bd08 c8d99bb7318a9e538aab87e44dbbdb31d33b5df6 && git checkout -B drift-repro 68c5dbaab2ecbc031e7342c9f2fc9efd6ad8bd08 && git merge --no-ff c8d99bb7318a9e538aab87e44dbbdb31d33b5df6

node scripts/docs-audit/affected-docs.mjs --json 68c5dbaab2ecbc031e7342c9f2fc9efd6ad8bd08

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 68c5dbaab2ecbc031e7342c9f2fc9efd6ad8bd08 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions github-actions Bot added documentation Improvements or additions to documentation protocol:ui tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Aug 26, 2026
@huangyiirene
huangyiirene marked this pull request as ready for review August 26, 2026 04:43
@huangyiirene
huangyiirene added this pull request to the merge queue Aug 26, 2026
Merged via the queue into main with commit e914733 Aug 26, 2026
34 checks passed
@huangyiirene
huangyiirene deleted the claude/issue-12174-formfield-constraint-shape branch August 26, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:ui size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants