Skip to content

feat(cli): validate all flat record-scoped predicates at build time - #2187

Merged
os-zhuang merged 1 commit into
mainfrom
feat/validate-all-predicates
Jun 22, 2026
Merged

feat(cli): validate all flat record-scoped predicates at build time#2187
os-zhuang merged 1 commit into
mainfrom
feat/validate-all-predicates

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Follow-up to framework#2185 (action predicates). Extends the ADR-0032 build-time check to the remaining flat record-scoped predicate sites — the same "bare field ref silently mis-behaves at runtime" class, in higher-stakes places.

Now validated (record-scoped, bare-ref → build error)

SiteWhereWhy it matters
field requiredWhen / readonlyWhen / conditionalRequired / visibleWhenobj.fields[]server-enforced; a broken predicate is fail-open — the required/readonly rule silently never fires
sharing-rule conditionstack.sharingRules[]security — decides which rows a principal sees
lifecycle hook conditionstack.hooks[]skips the handler when false; broken → runs on every record or none
nested when on conditional validation rulesobj.validations[]previously only the top-level rule predicate was checked

(Already covered before this PR: flows, validation-rule predicates, field formulas, action visible/disabled.)

@objectstack/formula

Adds parent to the record-scope namespace roots. Master-detail inline grids inject the header record as parent for a child field's readonlyWhen/requiredWhen (ADR-0036, #1581) — so parent.status == 'paid' is legitimate, not a bare ref. (Caught as a "false positive" by the first build run; this is the correct resolution.)

Verification

  • Full monorepo build (turbo build, 76 tasks): clean — zero false positives across every example + platform bundle.
  • cli validator suite: 25 cases (5 new: field rule bare-ref flagged + record./parent. accepted; sharing bare-ref; hook bare-ref; nested when bare-ref).

Deferred (separate follow-up)

Deeply-nested UI visibility predicates — view element/section visibleOn/condition, page component visibility, object field-group visibleOn, app-nav visible. These need a recursive view/page tree walker plus per-node scope classification (app-nav is user/feature-scoped not record-scoped; object field-group visibleOn examples use bare fields by design). Rushing record-scope onto them would false-positive platform-wide, so they warrant their own design rather than a mechanical add.

🤖 Generated with Claude Code

…ADR-0032)
Extends the action-predicate guard to the remaining flat record-scoped sites,
catching bare field references that silently mis-behave at runtime:
- field conditional rules (requiredWhen/readonlyWhen/conditionalRequired/visibleWhen) — fail-open when broken
- sharing-rule condition (security: which rows a principal sees)
- lifecycle hook condition (skips handler when false)
- nested `when` on conditional validation rules
formula: add `parent` to record-scope namespace roots — master-detail inline
grids inject the header record as `parent` for a child field's readonlyWhen
(ADR-0036, #1581), so `parent.status` is legitimate, not a bare ref.
Verified: full monorepo build 76 tasks clean (zero false positives across all
examples + platform bundles); cli validator suite 25 cases (5 new).
Deeply-nested UI visibility (view/page tree, object field-group visibleOn,
app-nav) is deferred — it needs a recursive walker + per-node scope rules.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercelBot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
specBuildingBuildingPreview, CommentJun 22, 2026 8:17am

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tests tooling size/m labels Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/cli, @objectstack/formula.

18 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/cloud-artifact-api.mdx(via packages/cli)
  • content/docs/concepts/implementation-status.mdx(via @objectstack/cli)
  • content/docs/concepts/packages.mdx(via @objectstack/cli, @objectstack/formula)
  • content/docs/getting-started/cli.mdx(via @objectstack/cli)
  • content/docs/getting-started/quick-start.mdx(via @objectstack/cli)
  • content/docs/guides/authentication.mdx(via @objectstack/cli)
  • content/docs/guides/client-sdk.mdx(via @objectstack/cli)
  • content/docs/guides/formula.mdx(via @objectstack/formula)
  • content/docs/guides/hook-bodies.mdx(via packages/cli)
  • content/docs/guides/metadata/validation.mdx(via @objectstack/formula)
  • content/docs/guides/packages.mdx(via @objectstack/cli, @objectstack/formula)
  • content/docs/guides/project-scoping.mdx(via @objectstack/cli)
  • content/docs/guides/runtime-services/data-service.mdx(via packages/cli)
  • content/docs/guides/runtime-services/index.mdx(via packages/cli)
  • content/docs/guides/skills.mdx(via packages/cli)
  • content/docs/protocol/objectos/plugin-spec.mdx(via @objectstack/cli)
  • content/docs/protocol/objectos/realtime-protocol.mdx(via @objectstack/cli)
  • content/docs/protocol/objectui/record-alert.mdx(via @objectstack/formula)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang
os-zhuang merged commit 25fc0e4 into mainJun 22, 2026
15 of 16 checks passed
@os-zhuang
os-zhuang deleted the feat/validate-all-predicates branch June 22, 2026 08:27
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/mteststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@xuyushun441-sys@os-zhuang