Repository navigation
docs(spec): guard the nullable amount in the docs examples and the validation condition example - #31358
Conversation
The publish-time null-guard rule refuses an ordering or arithmetic operator on a nullable field unless a `!= null` test guards it. Seven docs pages and the ValidationRule condition example compared `record.amount` unguarded in a gated position (flow start/edge, hook condition, requiredWhen, validation condition). - Guard with `record.amount != null && …` where the example does not declare the field; a flow is guarded at its start condition. - common-patterns: declare the expense report's `amount` `required: true`, since the approval flow branches on it. - Regenerate content/docs/references/data/validation.mdx with gen:docs. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kcxM8mwtPqSQpzbVT
…mple Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kcxM8mwtPqSQpzbVT
📓 Docs Drift Check1 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 171 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 7d9b9b47f4798aa2d819f64be13459afcef25d38 && git checkout 7d9b9b47f4798aa2d819f64be13459afcef25d38
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin d0512c2fbec9e0abd2f7fbd09986e4fdab73211d c4bbb0adeae3326cd6975f0a2c891df974607c45 && git checkout -B drift-repro d0512c2fbec9e0abd2f7fbd09986e4fdab73211d && git merge --no-ff c4bbb0adeae3326cd6975f0a2c891df974607c45
node scripts/docs-audit/affected-docs.mjs --json d0512c2fbec9e0abd2f7fbd09986e4fdab73211d |
|
domain:devx#3 · os-project-manager · session_01FEkQ5njkh3xbcDN6EtSfw7 席位核对Verdict: ACCEPT · head
|
|
domain:devx#3 · os-project-manager · session_01FEkQ5njkh3xbcDN6EtSfw7 Contract reviewServed-tier: ① Derived judgmentsInputs: card #31334 (body, triage audit 6716403823, the seat's claim 6716759332, the os-dev report 6717074863), the PR body and file list (9 files, +31 / −16), the net diff against the merge base, PR #31322 and its record 6715980957 for context, and the check-runs on the head. Nothing was built, run or re-run: this container has no installed dependencies (empty
② Semver level
On the spec-lane question: the card's suggested shape says the spec example "rides with a spec-lane note"; the triage ruling (6716403823) says only that it "rides the same PR as a spec doc-example change". No rule in AGENTS.md or os-dev.md owes a note of that name, the PR body states the spec-file change and the regeneration in both languages, and the ③ Boundary flags
④ Design judgmentNo must-fix. No should-fix inside the PR.
Implemented-by: VERDICT: PASS |
|
domain:devx#3 · os-project-manager · session_01FEkQ5njkh3xbcDN6EtSfw7 Order-of-acts note 2026-11-08T04:37Z · The seat's ACCEPT (6717291997) and the enqueue went out before the contract-review record. The record's first post was refused for two future-dated stamps, and the seat's script did not stop on that refusal. The record is now posted as 6717305815: PASS, the same head |
Requested by Leehom · project thread
Fixes #31334
Clause-②: no
Metadata-protocol: none
维护者速读
ValidationRule.condition的 spec 示例里,对可空amount的比较补上record.amount != null && …守卫;common-patterns的报销单把amount改为required: true;用gen:docs重新生成references/data/validation.mdx(只变 4 行)。requiredWhen静默失效(什么都不强制)。@objectstack/specpatch;回滚即 revert。content/docs/getting-started/common-patterns.mdx(唯一选了required: true而非守卫的一处);packages/spec/src/data/validation.zod.tsL180;content/docs/data-modeling/formulas.mdxL394 起的说明文字。pnpm --filter @objectstack/spec run check:docs,预期 exit 0(生成页与源一致);下方表格是每处表达式经真实规则validateStackExpressions的前后读数。What changes
The publish-time null-guard rule (
packages/lint/src/validate-null-guards.ts, wired byvalidateStackExpressions, whichos build,os validate,os lintand the runtime publish gate all run) refuses an ordering or arithmetic operator on a declared-nullable field unless a!= null/== null/isBlank()test guards it. Every site in the card comparedrecord.amountunguarded in a gated position. Each is fixed with the shape the formula skill teaches (skills/objectstack-formula/SKILL.mdL112-L122, L404).content/docs/getting-started/common-patterns.mdxL312, flow edgese2/e3record_changeflow onexpense_reportamountdeclaredrequired: trueamount(< 100auto-approves,>= 100asks). Guarding the start condition instead would let a submitted report with no amount launch no flow at all, so it would skip approval silently. An expense report always has an amount, sorequired: trueis the honest fix. The edges stay as written.content/docs/automation/approvals.mdxL145, startconditionrecord_changeflow start onopportunityrecord.amount != null && record.amount >= 50000 && …validate-expressions.tsL2967-L2976).content/docs/automation/hook-bodies.mdxL74conditioncontent/docs/data-modeling/formulas.mdxL119requiredWhenInvoiceexample declares fields, but notamount(norsubtotal,tax_rate,invoice_no,customer); it is a fragment foramount, so it is guarded rather than given arequireddeclaration it does not have.content/docs/data-modeling/formulas.mdxL356requiredWhencontent/docs/data-modeling/formulas.mdxL394condition!= nulltestcontent/docs/data-modeling/validation.mdxL329condition(avalidations:fragment)content/docs/automation/flows.mdxL2473condition(syntax table)packages/spec/src/data/validation.zod.tsL180.describe()conditionP`record.amount != null && record.amount < 0`content/docs/references/data/validation.mdxL170/L291/L505/L571 regenerated withpnpm --filter @objectstack/spec gen:schema && gen:docs, never hand-edited.packages/spec/src/data/validation.zod.tsL257 and L532 (doc comments)cross_fieldandconditionalrule examplesBounded in-place fix (same file, outside the card's table). The two doc-comment examples in
validation.zod.ts(thecross_fielddiscount_limitat L257, and theconditionalenterprise_high_valuethenat L532) have the same defect, and the rule refuses both (table below). All four conditions hold: the same defect class, the same mechanical guard shape, no other claim on the file (PR #31322 toucheshook.zod.ts, not this file), and the same gate families. The doc comments ship in@objectstack/spec's.d.ts, where an author or agent reads them. They do not reach the generated reference page.Not changed (out of scope by ruling):
validation.mdxL51 (amountisrequired: trueat L31), theui/SchemaForm test constant, release notes and CHANGELOGs.Tests
Each changed expression was run, in its declared context, through the real gating rule:
validateStackExpressionsfrom the built@objectstack/lintdist/(built on this branch's basedc7f5c4b4). The fixture object declaresamountas{ type: 'currency' }, which is nullable (norequired, no default), as on the CRM example'sopportunity. Counts are error-severity null-guard findings; every row had 0 other errors.e2/e3e2, edgee3)amountrequired: true)requiredWhencross_fielddiscount,amount)conditionalthenProbe output
No test file changes: this is docs and description text. No test pins the old describe string (
git grepoverpackages/**).Acceptance notes
packages/spec/src/automation/flow.zod.tsL1070-L1071, theFlowSchema@example, has the samerecord.amount < 500/>= 500edges. As written its start node carries noconfig.objectName, so the rule has no object to resolve and does not refuse it (probe: 0 findings as written, 2 once the start is bound to anorderwith a nullableamount). Outside this card's surface and not refused at a public door today, so it is noted, not filed.skills/objectstack-data/rules/validation.mdL164 (discount_limit) is already guarded.Verification
On head
c4bbb0ad(merge basedc7f5c4b4), after building the@objectstack/lintclosure, then@objectstack/specand the@objectstack/client-reactclosure, underNODE_OPTIONS=--max-old-space-size=8192: 98 of the 99 commands fromnode scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackexit 0.pnpm check:dual-build-cjs-loadsexits 3 (PREREQUISITE NOT MET: it needs every workspace package'sdist/), so it is NOT MEASURED locally and CI reads it.dispatch-gates --ran: 99 derived, 98 run, 1 NOT-MEASURED, 0 UNRUN (exit 0). Changed lines: 35 + the changeset, 9 files.Also run:
packages/specsrc/data/validation.test.ts+validation-boundary-description.test.ts(2 files, 90 / 90 passed, lock VERDICT command-exit 0); eslint onvalidation.zod.ts(exit 0);node scripts/check-commit-card-trailers.mjs --range origin/main..HEAD(exit 0);pnpm check:skill-frame-freshness(exit 0).pnpm check:dev-prereqsexits 1 on local state only (65 of 107 packages have nodist/in this worktree, since only the needed closures were built); its self-test passes, and it is not a finding about this diff.The NOT MEASURED families
dispatch-gatesnames outside the derived list (CI-only steps, type-check lanes, the dogfood and build jobs) run in CI.Each command with its exit code (head c4bbb0a)
Generated by Claude Code