Skip to content

feat(objectql): a validation rule's refusal fills its message's {{ }} holes with the judged record's values - #38736

Merged
os-zhuang merged 8 commits into
mainfrom
claude/project-thread-h25bs8
Nov 30, 2026
Merged

os-zhuang merged 8 commits into
mainfrom
claude/project-thread-h25bs8

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Part of #37909 — PR 2 of the ruling's sequencing (domain:server: render in authoredRuleMessage, currency and readable-field handover, the empty-on-unreadable pins). PR 1 (#38687, spec + lint, merged as 9cbb41b) is the doors; PR 3 (skills and docs) stays on the card.

Clause-②: yes (widening)
Metadata-protocol: semantic
Skills-docs: follow-up #37909 (PR 3 of the ruling's sequencing: skills and docs)

维护者速读

  • 用户能看到什么变化:校验规则拦下保存时,提示语里的 {{ record.字段 }} 会填上被拦记录的真实值(比如「总价 ¥1,200.00 低于已收 ¥1,500.00」),金额按组织默认币种、按用户语言格式化;看不到或被遮罩的字段一律留空。系统身份替某人执行的写(如该人触发的系统流程)按该人的权限判定,没有安全服务时全部留空并记日志。
  • 为什么做:维护者已裁(P3);这是第二步,让第一步定下的写法真正生效,HotCRM 的改单拦截才能说出差多少钱。
  • 出错会怎样:最坏是某个洞该显示的值显示成空;规则拦不拦不受影响,值也不会写进错误的其它字段;撤回这次合并即回到「原样显示」。
  • 要你做什么:组织没设默认币种时,提示语里不带币种的金额占位怎么处理,正等你在决策卡上定;本 PR 暂按席位推荐的 A(该占位留空、日志提醒设置默认币种)实现,你选别的方案只改一个函数,改完再请你审批。

What changes

Ruling P3 (card comment 7239726323), parameters 5–8, and the forward flags of PR 1's contract review (7269393846).

  • @objectstack/objectql — authoredRuleMessage (validation/rule-validator.ts) now fills the sentence it picks:
    • translation first (parameter 7): the translated template is picked and filled; if it does not render, the authored template is filled instead and the write's logger names the translation (objects.O._validations.R.message, the locale); an authored message that does not render (one stored before the doors) is shown as written and the logger names the rule;
    • the fill is renderRuleMessage (new validation/rule-message-render.ts) through the formula templateEngine — no second engine — over the merged record (record) and the stored row (previous, null on an insert), in the refusal's negotiated locale, with the tenant default currency and the reference timezone. Every rule kind that emits an authored message fills it: script / cross_field, format, json_schema, state_machine, and a conditional branch. A script rule's holes read the record as judged before related rows are hydrated into reference fields, so {{ record.account }} is the stored id, never the related row;
    • what a hole may show (parameter 6) is ValidationMessageContext.rendering, computed once per write by the new engine-rule-message-rendering.ts (attachRuleMessageRendering), called beside validationMessageContext on the three paths that build it: engine-insert.ts, engine-update.ts (the by-id and bulk legs share it) and engine-validate.ts (the dry run). It is computed only when the object's rule messages or their translations carry a {{, so no other write asks the security service anything new.
  • The showable fields — getReadableFields ∩ getQueryableFields of the registered security service (the contract: "the difference between the two is exactly the fields this caller sees masked"); with no getQueryableFields, or undefined from it, every maskingRule field counts as masked (the contract's prescribed fallback). Every field the engine masks or omits on a read (secret, generic password, internal) is never showable. A hole is empty twice over: blanked before the render, and absent from the scope the engine evaluates.
  • Whose read (contract review M1, fix (a)) — both projections are asked under the write's own context, except on an elevated write (isSystem) that names a person (userId): a runAs: 'system' flow, an action body ({ ...caller, isSystem: true }), the approvals mirror. There they are asked for that person: the same context with isSystem: false, carrying the positions and permission sets it carries, or, where it carries none (the flow's and the approvals mirror's context), the person's own grants resolved through resolveUserAuthzGrants (@objectstack/core), as a runAs: 'user' hook fired by the same write seeds them. Grants that cannot be read: every hole empty. A user-less system write (a schedule, a platform sweep) keeps the system's answer; its sentence reaches the server log alone.
  • Fail closed, and say why (S1) — no security service registered (the kernel throws on an unregistered name; a bare engine's slot is empty), a service that cannot be asked (no function in the slot, no getReadableFields), one that answers undefined or throws, and unreadable grants of the person an elevated write was made for: nothing is showable, every hole renders empty, and the write's logger gets one line naming the cause (RuleMessageRendering.unanswered), once per write.
  • What the log is told (S2) — a hole no reader could ever see filled (another root, a bare root, a read through a field, a field the object does not declare: a message stored before the doors) is named with its rule and the hole. A hole empty only for this reader (unreadable, masked) is never logged. Each distinct line is written once per write, so a bulk refusal does not repeat it (N1).
  • The currency (parameter 5) — the write's ExecutionContext.currency (the organization's localization.currency, which the request context already resolves), when it is a three-capital ISO 4217 code. Pending the maintainer's ruling (parameter 8 fork, put to the maintainer as a decision card by the seat): with no tenant default, a currency hole with no argument passes the doors but cannot render. Provisionally (option A, the seat's recommendation) that hole renders empty and the write's logger names the rule, the hole and the setting, saying the organization has none set or the write carried none (N1) (Setup → Localization, localization.currency); the rest of the sentence renders. It is isolated in one function, tenantCurrencyHole (validation/rule-message-render.ts), and pinned by one test; a different ruling changes those two and the changeset's sentence, nothing else. ⛔ The amount is never formatted in a currency nobody chose, nor shown unformatted.
  • @objectstack/spec + @objectstack/lint — the roots export is renamed before its first release, VALIDATION_MESSAGE_TEMPLATE_ROOTS → VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS (contract review N2: @objectstack/spec/system already has a VALIDATION_MESSAGE_* field-constraint family that binds no roots), with its lint importer, the translation describe that names it, and the regenerated api-surface/data.json, export-origins/data.json and docs/references/system/translation.md. PR 1's changeset is edited to name the final export (both ship in one release).

Decisions this PR takes

  • N5, previous.FIELD on an insert-only rule: the doors keep accepting it and it renders empty, as on every insert (parameter 1 allows it; a rule with events: ['insert', 'update'] reads it on one leg only). Pinned.
  • A hole over a root other than record / previous, a bare root, a read through a field, an undeclared field: the doors refuse each (PR 1); a rule stored before them renders each empty, never the built-in sentence's own parameters.

Deliberate correction of a pending release note

.changeset/37909-rule-message-template-holes.md (PR 1's, pending, not yet released) is edited in one sentence: its Exports bullet named VALIDATION_MESSAGE_TEMPLATE_ROOTS, which this PR renames, so it now reads "@objectstack/spec/data gains VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS (['record', 'previous'])". Restoring it would publish a release note naming an export the release does not carry. check-empty-changeset stays red on that file by design; the dispatching seat confirms the correction by its own record.

Outside the claimed file surface

  • packages/services/service-automation/src/flow-rule-message-reader.integration.test.ts (new, test only): contract review M1 asks for the flow path pinned end to end (runAs: 'system' → innerRefusal), which only a test composing the automation engine reaches. No service-automation source changes.
  • content/docs/permissions/system-context.mdx (one register row, 29g, and the regenerated register): the new readerContext reads isSystem to de-elevate, and pnpm check:system-context-census requires every such read to be owned by a row naming its symbol.

Tests forced to change

  • packages/objectql/src/validation/rule-validator.state-machine-option-labels.test.ts — "leaves an author-written message exactly as written — no holes are filled in it" pinned the contract this card changes (ruling P3). Its intent stays: the built-in sentence's {{from}} / {{to}} never fill an authored message. Those are holes over another root, so they now render empty; the code and constraint assertions are unchanged.

Tests

  • packages/objectql/src/validation/rule-message-render.test.ts (19, through evaluateValidationRules): formatters and locale, the tenant currency, previous on update and on insert, plain text and a single brace as written; the field floor (outside showable, never logged; no rendering at all; read-through / bare root / other root / undeclared, each logged with its rule; the stored id of a hydrated reference; no value in the machine fields); the scope floor on its own, a hole the blanking builds (N5); an unanswered field security, its cause logged; every rule kind (conditional branch, format, state_machine); translation first, its fallback with the warning, a pre-door authored message as written; and the provisional no-currency arm (that hole empty, the rest rendered, the rule and the setting named).
  • packages/objectql/src/engine-rule-message-rendering.test.ts (15, a real engine with the security service as a double in its source slot): readable and unmasked shows, masked / password / internal empty; unreadable empty; no getQueryableFields → maskingRule empty; a lifted mask shows; undefined, a throw from either projection, a throwing source, a service without getReadableFields → every hole empty, the write still refused, one log line naming each cause; no service registered → every hole empty and the line; a reader-only blank never logged; stored structural holes logged once per write across a bulk insert. Elevated writes (M1): { ...caller, isSystem: true } asked for the caller with their sets, never as the system; { isSystem: true, userId } with no sets on an engine with no permission store → grants unreadable, every hole empty, the cause logged; CONTROL a user-less system write keeps the system answer; CONTROL the same person's own write reads the same. | currency in the context's currency and locale; previous on a real update; the dry run fills the same sentence.
  • packages/services/service-automation/src/flow-rule-message-reader.integration.test.ts (4, ObjectKernel + ObjectQLPlugin + driver-sql on better-sqlite3 + identity objects + the real SecurityPlugin + the real AutomationEngine): a member profile withholds margin; a runAs: 'system' flow started by that member, refused by the rule, carries Amount -1 is below the margin on Acme. in innerRefusal.message (run against the previous head's build it carried … the margin 30 …); runAs: 'user' and the member's own request read the same; CONTROL a user-less system write shows 30.
  • Ablations: dropping the masked-field judgement reds 2 engine tests; building the scope from the whole row instead of the showable values reds the N5 pin (SSN 123-45-6789 end).

Acceptance notes

  • The render ships in the same release as PR 1 (feat(lint)!: a validation rule's message is a {{ }} template over the judged record, and a single brace there is refused #38687, merged): PR 1 alone teaches holes that render as written. This branch was restarted from main after PR 1 merged and its four commits rebased onto it.
  • The rendered sentence is written to the server log by the engine's existing Insert operation failed warning, as the authored message was; it carries only fields the person the refusal is worded for may read.
  • Out of scope, from contract review 7273883345: N2 (an Intl RangeError for a locale tag or time zone Intl does not know shows the template as written; whether such a tag reaches a write's context is not established), N3 (objectstack validate's seed-row refusal, packages/lint/src/seed-row-refusals.ts, now prints blank holes; a follow-up hands it a rendering over the seed row's declared fields, or prints the template), N7 (the projections are asked on every write to an object whose messages carry a hole, refused or not; asking at the first refusal needs an async render). Each goes to PR 3 or a follow-up card, as the seat files it.

Verification

  • pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/validation/rule-message-render.test.ts src/engine-rule-message-rendering.test.ts: 34 passed; pnpm --filter @objectstack/service-automation exec vitest run src/flow-rule-message-reader.integration.test.ts: 4 passed.
  • Two-minute check: in examples/app-showcase, give a validation rule the message Total {{ record.total_price | currency }} is too low., set Setup → Localization → Default currency, and save a record the rule refuses: the refusal names the amount.
Local gates at head 331b47d
  • node scripts/pm/dispatch-gates.mjs --commands (derived after the last commit): 125 commands, each run with stdin closed through the verify lock; 124 exit 0, and node scripts/check-empty-changeset.mjs --base origin/main :: exit 1, the deliberate correction above. --ran reconciliation: 125 derived, 125 run, 0 NOT-MEASURED, 0 UNRUN.
  • The run at 8f25796 (104 derived) had one other red, pnpm check:system-context-census (the readerContext read had no owning row); 331b47d adds row 29g and the census passes in the 125.
  • pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 on the tree committed as 6a49759 + 8f25796: 643 files, 14602 tests, all passed (lock VERDICT command-exit 0).
  • Dogfood battery (pnpm --filter @objectstack/dogfood test) at 331b47d: lock VERDICT command-exit 0; Test Files 495 passed, 3 skipped; Tests 4187 passed, 68 skipped; no failure.
  • pnpm build --concurrency=2 (whole workspace) on the rebased head 9b716a3: lock VERDICT command-exit 0; @objectstack/objectql rebuilt at the fix (exit 0) before the service-automation test ran against it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs

…EMPLATE_ROOTS before their first release

The export added by the previous change read as part of the system
subpath's VALIDATION_MESSAGE_* field-constraint catalog, which binds no
roots. Renamed with its lint importer, the generated ledgers and the
translation describe that names it.

Claude-Session: https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs
Co-authored-by: Claude <noreply@anthropic.com>
…d record's values

authoredRuleMessage picks the translation, fills it, falls back to the
authored message (filled) with a warning naming the translation, and shows
an authored message that does not render as written. A hole shows a field
only when the caller may read it unmasked, per the security service the
engine computes once per write; every other hole renders empty. The tenant
default currency is the write's ExecutionContext.currency.

Claude-Session: https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs
Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation protocol:data protocol:system tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/lint, @objectstack/objectql, @objectstack/spec, touching 46 documentable anchor(s). ⚠️ 3 changed file(s) yielded no anchor (packages/spec/api-surface/data.json, packages/spec/docs/references/system/translation.md, packages/spec/export-origins/data.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/api/error-catalog.mdx (via invalid_format (literal, a string literal in formatViolation), invalid_json (literal, a string literal in checkJsonSchema), json_schema_violation (literal, a string literal in checkJsonSchema))
  • content/docs/kernel/runtime-services/settings-service.mdx (via invalid_format (literal, a string literal in formatViolation))
  • content/docs/kernel/runtime-services/sharing-service.mdx (via evaluateRule (symbol, a top-level function))
  • content/docs/permissions/sharing-rules.mdx (via /sharing/rules/:idOrName/evaluate (route, bridged from symbol evaluateRule — its route source's handler names it))
  • content/docs/permissions/system-context.mdx (via getReadableFields (symbol, a field of interface RuleMessageFieldSecurity), readerContext (symbol, a top-level function))
  • content/docs/protocol/knowledge.mdx (via getQueryableFields (symbol, a field of interface RuleMessageFieldSecurity), getReadableFields (symbol, a field of interface RuleMessageFieldSecurity))

⛔ 1 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-6.mdx (via getQueryableFields (symbol, a field of interface RuleMessageFieldSecurity), getReadableFields (symbol, a field of interface RuleMessageFieldSecurity))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 3 changed file(s) yielded no anchor (packages/spec/api-surface/data.json, packages/spec/docs/references/system/translation.md, packages/spec/export-origins/data.json) — pages documenting those are invisible to this run
  • 11 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 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.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 184 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 f782a12033e3c0ace069291ce4dac467e8056d49 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from ecfe1944a8e732830259cbaaac8253fe4fbfe178 — the merge of head 331b47d5b7567a39935574d234e78927def74b2e into base f782a12033e3c0ace069291ce4dac467e8056d49, 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 ecfe1944a8e732830259cbaaac8253fe4fbfe178 && git checkout ecfe1944a8e732830259cbaaac8253fe4fbfe178
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f782a12033e3c0ace069291ce4dac467e8056d49 331b47d5b7567a39935574d234e78927def74b2e && git checkout -B drift-repro f782a12033e3c0ace069291ce4dac467e8056d49 && git merge --no-ff 331b47d5b7567a39935574d234e78927def74b2e

node scripts/docs-audit/affected-docs.mjs --json f782a12033e3c0ace069291ce4dac467e8056d49

⚠️ 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 f782a12033e3c0ace069291ce4dac467e8056d49 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

Contract-review-claim: session_01ADHkmSAjFEZHRpRq3WCj6z · head 9b716a3 · 2026-11-30T08:59Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB
L1-b, the seat's L1 thread · 2026-11-30T09:07Z · first review

席位核对

REWORK @ 9b716a3 (card #37909, PR 2 of ruling P3; draft; 18 files, +932/−39)

Must-fix

  1. The release note leaves out the one behaviour a deployer has to act on, and the body says it is there. .changeset/37909-rule-message-render.md line 15 says "| currency with no argument formats in the organization's default currency (Setup → Localization, localization.currency)", and says nothing of an organization that has none. In that case the build renders the hole empty and warns in the server log (tenantCurrencyHole, rule-message-render.ts, provisional option A of the parameter-8 fork). The PR body's currency bullet says "a different ruling changes those two and the changeset's sentence, nothing else", but no such sentence exists. Add one sentence to the Formatting bullet, for example: "With no default currency set, such a hole renders empty and the server log names the setting to fill; the rest of the sentence renders." It is the sentence the maintainer's ruling on the fork will rewrite, if it goes another way. On the delta I re-read only the changeset and the body's currency bullet.

Everything else passed

  • Shape. Draft on main; first line Part of #37909, right: PR 3 (skills and docs) stays on the card, and Skills-docs: follow-up #37909 names it. Clause-②: yes (widening) and Metadata-protocol: semantic are the honest pair (a rule message now renders; an authored {{from}} that used to show as written now renders empty, which the forced test change records), and minor on the three packages follows ruling A.
  • The render. authoredRuleMessage picks the translation first and fills it; a translation that does not render falls back to the authored message with a warning naming objects.O._validations.R.message; an authored message that does not render is shown as written with a warning naming the rule; no {{, no change. Every emitting rule kind passes values (script/cross_field before hydration, format, json_schema, state_machine, a conditional branch through evaluateRule). One engine only (templateEngine from @objectstack/formula).
  • The human floor (parameter 6). showableFields is getReadableFields ∩ getQueryableFields, with the maskingRule fallback when the service has no getQueryableFields or answers undefined; credential and internal fields are never showable; a source that throws, a service without getReadableFields, an undefined answer or a throw make nothing showable. A hole is blanked before the render and absent from the scope (prototype-less container). It is attached on all three builders that feed rule evaluation (engine-insert.ts:1193, engine-update.ts:1254 shared by the by-id and bulk legs, engine-validate.ts:372); I grepped every evaluateValidationRules( caller and every validationMessageContext( builder, and the others (engine-defaults-and-autonumbers.ts, engine-delete-cascade.ts) render no rule message. Only objects whose rule messages or translations carry {{ ask the security service anything new.
  • The rename VALIDATION_MESSAGE_TEMPLATE_ROOTS → VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS before its first release: PR 1's changeset is still pending on main, so no released version carries the old name; the lint importer, the translation describe, api-surface/data.json, export-origins/data.json and the generated reference move with it; no other reference to the old name is left outside the new changeset's own FROM → TO sentence.
  • My runs (fresh worktree, @objectstack/objectql^... built): the three pin files, 32/32. Ablations of my own, each restored: dropping the credential/internal exclusion from showableFields reds 2; skipping the translation (authored first) reds 2; dropping the blanking layer's showable check alone stays green (32/32), because the scope layer still withholds the value. That is the "empty twice over" design working; neither layer is pinned on its own. Nit, no change asked.

For the seat (not L1 must-fix)

  • Check Changeset is red by design (check-empty-changeset: .changeset/37909-rule-message-template-holes.md exists on the merge base). It is a DELIBERATE CORRECTION: the one changed sentence renames the export the pending note names (before: "@objectstack/spec/data gains VALIDATION_MESSAGE_TEMPLATE_ROOTS (['record', 'previous'])"; after: "… gains VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS (['record', 'previous'])"). The after-sentence is true at this head. This PR also changes code, so under landing-operations.md the confirmation is the same-head at-tier contract-review PASS judging that sentence, not this ACCEPT alone.
  • The parameter-8 fork is pending the maintainer (no-default currency, provisional A). Ruling P3's parameter 8 required a fork report and forbids raw values; option A renders empty and never shows an unformatted amount, so the code stays inside the ruling. Landing waits on the maintainer's answer on that card, or on his explicit acceptance of A at the Tier H hand-off.
  • Security-touching for L2: record values now enter a user-visible sentence. One path to look at: a write made under a system context (isSystem) is answered by the security service for that context, so a message rendered there may carry fields the human behind an automation cannot read, if the refusal is later surfaced to that human. I did not measure such a surface; it is a question for the contract review, not a finding.

Checks at this head (read before writing, latest per name): 22 success, 13 skipped, 1 failure (Check Changeset, the deliberate correction above), 34 in progress (Test Core 1–12, Test UI 1–16, type checks, builds, E2E). Landing waits for every other check green.
L2: owed at CONTRACT_REVIEW_TIER (faces schema + declaration), claim live. Dogfood: not owed (no !, no (narrowing) arm).

…o tenant default

Claude-Session: https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 9b716a377c106de3c8232a16b562093808dfb5ba
Local-runs: none
Scope: packages/spec/src/data/validation.zod.ts, packages/spec/src/system/translation.zod.ts, packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts + packages/objectql/src/validation/rule-message-render.ts, packages/objectql/src/engine-rule-message-rendering.ts, packages/objectql/src/validation/rule-validator.ts, packages/objectql/src/validation/record-validator.ts, packages/objectql/src/engine-insert.ts, packages/objectql/src/engine-update.ts, packages/objectql/src/engine-validate.ts, packages/lint/src/validate-rule-message-templates.ts
Security-touching: yes
Rule-change-verified: none

PR 2 of 3 of card #37909, judged against ruling 7239726323 (P3) and the parameters PR 2 owns: 5 (explicit formatters, tenant currency), 6 (field security), 7 (translation first), 8 (the fork rule), plus PR 1's forward flags and nits N2 and N5 (record 7269393846). Read: the card body and all twelve comments, PR 1's records on #38687, the PR body, the 18-file net diff against merge base e130fd43b6, the os-dev report 7273571534, and the check-runs on this head. Cited code was read at the PR head through git show; nothing was built or run.

Security-touching: yes because the changed hunks implement which fields a refusal sentence may disclose to a caller; no hits path is under skills/**, so the line asks for no label. No path is under .claude/**. The semantic entry (19.validation-rule-message-template-holes.ts) is named in the brief's hits but is not in this PR's file list: it was read at head and is unchanged.

Gate verdicts (check-runs on this head, read 2026-11-30T09:06Z): 70 runs, 22 success, 1 failure, 13 skipped, 34 still in progress. Not yet answered: Build Core, Type Check · workspace, Type Check · consumer gates, Type Check UI, Test Core 1–12, Test UI 1–16, Build & E2E UI, Live E2E UI. Success so far includes Type Check · source gates, Type Check · debt ledger, Spec property liveness, Lint · PM dispatch-gates, Lint · ESLint, PR-body guards and Governed Surface Queue Guard. The one failure is Check Changeset, and inside it only the step that carries the foreign-changeset rule, on .changeset/37909-rule-message-template-holes.md; its other steps (a changeset is present, the ADR-0087 disposition step, the major-bump guard) are green. The verdict below does not rest on them.

① Derived judgments

  • Accept set (unchanged) — right. No schema, door or parse moves. message stays z.string(); every string accepted before is accepted now.
  • What a refusal's message carries (widened in meaning) — right. authoredRuleMessage now fills the sentence it picks, on every rule kind that emits an authored message: script / cross_field, format, json_schema (both arms), state_machine, and a conditional branch (through evaluateRule). Advisory (warning) hits take the same function. The machine fields (code, field, constraint, value) are not touched.
  • Stored messages that the doors would now refuse (changed, silently) — see S2. A stored message with a hole over another root, a bare root, a read through a field or an undeclared field was shown as written; from this head each such hole renders empty. The repository's own pinned example moves from Cannot move a quote from {{from}} to {{to}}. to Cannot move a quote from to ..
  • Callers that hand no rendering (changed) — see N3. evaluateValidationRules is called outside the three engine paths by packages/lint/src/seed-row-refusals.ts; with no messages.rendering every hole renders empty, so that reader's sentence changes from the template as written to a sentence with blanks.
  • Public surface, @objectstack/spec/data (one name replaced, unreleased) — right. VALIDATION_MESSAGE_TEMPLATE_ROOTS leaves and VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS enters; api-surface/data.json and export-origins/data.json each move exactly that row. Against the last release (19.0.0-next.2) the net is one gained name.
  • Public surface, @objectstack/objectql (widened) — right. ValidationMessageContext gains the optional rendering; a caller that omits it gets empty holes, never values.
  • The rename — right while PR 1 is unreleased, and complete. packages/spec is still 19.0.0-next.2 on main (0d68ce2db3), no version commit follows PR 1's merge (9cbb41b1), and .changeset/pre.json lists no consumed note. On main, the old name is read in exactly seven files (validation.zod.ts, translation.zod.ts, validate-rule-message-templates.ts, api-surface/data.json, export-origins/data.json, docs/references/system/translation.md, PR 1's changeset), and this diff edits all seven. At the PR head the old name survives only in the new changeset's sentence that announces the rename. No other reader remains.

② Semver level

  • @objectstack/objectql minor: right, a refusal's sentence gains values and a public type gains an optional member.
  • @objectstack/spec minor: right as a floor; PR 1's pending note already takes it to minor and the two fold in one release.
  • @objectstack/lint minor: the lint diff is an import rename and publishes nothing new. Harmless, because PR 1's pending note already takes lint to minor.
  • Clause-②: yes (widening) as declared, on the PR body and in the changeset, and the two agree. The value is right: nothing narrows, and what a stored hole means widens. Metadata-protocol: semantic is right; the ADR-0087 step is green, and entry 19 (same release) already names "a {{ }} hole" in its surface.
  • Skills-docs: follow-up #37909 names PR 3 of the ruling's sequencing; the card is open.
  • The red gate, check-empty-changeset (foreign-changeset rule): the seat may accept it as a DELIBERATE CORRECTION, not a collision. One note is modified, .changeset/37909-rule-message-template-holes.md, written by this same card's PR 1 on this same branch, in one sentence. Before: "Exports. @objectstack/spec/data gains VALIDATION_MESSAGE_TEMPLATE_ROOTS (['record', 'previous'])." After: "Exports. @objectstack/spec/data gains VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS (['record', 'previous'])." The rewritten sentence is true of the tree at this head, and the sentence it replaces would announce an export the release does not carry. Nothing else in that note moves, and the frontmatter is unchanged. Sentence by sentence: the note has one changed sentence and it is judged right; every other sentence of the note is byte-identical to main, including "Filling the holes at run time is the next change on this card; until it lands, a hole that passes the doors is returned as written", which stays true of PR 1 alone and is superseded in the same release by the new note. Because this diff also changes code, the seat's confirmation is a same-head at-tier PASS record, and this record is a FAIL: the correction is judged sound here, and it is confirmed by the delta record on the head that lands, which re-reads this one sentence.
  • Three sentences of the new note, for the next head: "A hole shows a field only when the person whose write was refused may read it unmasked" is false on an elevated write (M1); "Nothing to rewrite" omits the S2 class; and the Formatting bullet does not say what a currency hole with no argument does when no default currency reaches the render (the provisional arm, or whatever the maintainer rules), which L1 raised as its own must-fix (7273784971) and which the PR body says is there.

③ Boundary flags

Dev deviations (report 7273571534):

  • PR 1's pending changeset edited: answered in ②.
  • The rewritten state_machine test: the old pin was the contract this card replaces; the kept assertions (code, constraint) are the ones parameter 6 protects. Accepted, and it is the evidence for S2.
  • service-automation/src/engine.ts untouched: confirmed, it does not call authoredRuleMessage.

Dev decisions:

  • N5, previous.FIELD on an insert-only rule renders empty, the doors keep accepting it. Parameter 1 allows it; pinned. Accepted.
  • Showable = getReadableFields ∩ getQueryableFields, less secret / masked password / internal. Agrees with the security contract (packages/spec/src/contracts/security-service.ts): the difference of the two answers is exactly the fields this caller sees masked, and absence or undefined of the second makes every maskingRule field masked. This also answers parameter 8's second fork condition: the readable answer alone cannot tell masked fields apart, and the dev did not fall back to it. Right.
  • No security service registered → declared fields show. Not what the kernel composition does. See S1.

The ruling's parameters, one by one:

  • 5, explicit formatters only — holds. One engine (templateEngine), its whitelist, no formatting by field type. currency reads ExecutionContext.currency only when it is three capitals; datetime reads ExecutionContext.timezone.
  • 6, a field the reader cannot read renders empty — holds where the write's context is the reader; does not hold on an elevated write made for a person (M1). Empty twice: the hole is blanked in the template, and the scope the engine evaluates holds showable fields only, in a prototype-less container. A computed field that reads a withheld field is already out of getReadableFields. Registered-but-silent, undefined, a throw from either method, a throwing source and a service without getReadableFields all give the empty set; each is pinned.
  • 6, record visibility — holds. On a write, the row is admitted by the middleware's write gates before the body that evaluates the rules runs. On the dry run, engine-validate.ts reads the stored row only after the caller's own findOne returns it, and keeps a stored column only where the read door served that same value.
  • 6, the verdict never depends on rendering; no value in the machine fields — holds. The message is built after the verdict; pinned.
  • 7, translation first, then the authored message — holds. The translated template is picked and filled; on a failed render the authored template is filled and the warning names objects.O._validations.R.message and the locale. A tenant's rewrite of a packaged rule still skips the catalog.
  • previous. on insert — holds. null on insert, the hole is blanked before the engine sees it.
  • An unknown or unreadable value — holds. null, an absent key and an unshowable field all render as nothing.
  • 8, the fork rule — one fork reported (currency), handled below. Not reported: the readable-field answer for an elevated write cannot say what the person behind it may read (M1), which is the second fork condition in substance; and two door-passing templates that do not render as authored (S1, N2).

Break attempts, and what happened:

  • A hole over a field the caller cannot read, or wrote but cannot read back: empty. Held.
  • A lookup display reading another record: {{ record.account }} shows the stored id; checkPredicate captures the values before resolveTraversalScope hydrates related rows, and a read through the field is blanked. No other record is read. Held.
  • A bulk write leaking one row's value into another row's error: the shared rendering holds only the showable set, the currency, the zone and the logger; the values come from each row's own evaluateValidationRules call. The message context is built per write, not cached. Held.
  • A hole built by blanking: {{ record.secret }{{ record.x }}} becomes {{ record.secret }}} once the inner hole is blanked, and the engine then evaluates it. It reads nothing, because the scope holds showable fields only. The second floor is what holds here; worth a pin (N5).
  • Markup injection through a rendered value: the engine does not escape, and the sentence stays a plain string. Until this head the sentence was author-written only; from this head it can carry record text, including previous.* text another user stored. Whether any surface renders fields[].message as markup was not audited (outside the diff). For the seat: PR 3's docs should say the sentence is text, and one grep of the console's error renderers is cheap.
  • A formatter with no tenant currency: below.

The currency fork (parameter 8), option A in tenantCurrencyHole():

  • A is safe to land before the maintainer's answer, taken alone (M1 is what holds this head). The hole renders empty, the rest of the sentence renders, no amount is shown in a currency nobody chose, nothing is disclosed, and the rule's verdict is untouched. It is the same reading parameter 6 gives a field that cannot be shown.
  • What changes if he picks otherwise. A per-hole alternative (for example the plain number) is a change to that one function, whose return value is spliced into the template before the engine runs, plus its one test and a changeset sentence. An alternative that replaces the whole sentence is not: blankUnshowableHoles returns a string and has no way to refuse the sentence, so renderRuleMessage and authoredRuleMessage move too. A refusal at the doors is PR 1's lint surface and a narrowing with its own ADR-0087 disposition. The PR body's "only one function" is true of the first class only.
  • Two facts for the decision card, both escalated to the seat, neither a finding on this head:
    • E1 — the blank arm is met more often than "the organization has none". The currency is read from the write's ExecutionContext.currency, which the request context resolves; a write whose context carries none (a system or automation write, a job) takes the same arm although the organization has a default, and the log line then names the wrong cause (N1).
    • E2 — a currency field can carry its own currency (currencyConfig.currencyMode: 'record' with a currencyField, or 'fixed' with defaultCurrency). {{ record.total_price | currency }} formats in the tenant default whatever the field's own currency is, so a EUR amount in a USD organization reads $1,200.00. That follows parameter 5 as ruled (no formatting by field type) and exists whichever option is picked, and it is the case where the sentence states a wrong amount of money. The maintainer should see it beside the fork; PR 3 must teach | currency:CODE or | number for such fields at the least.

The elevated write (L1's question, comment 7273784971), measured by reading only:

  • Whose visibility the render reads: the system's, never the triggering person's. attachRuleMessageRendering hands the write's own ExecutionContext to getReadableFields and getQueryableFields. In plugin-security, resolveProjectionFieldMask (security-plugin-field-readers.ts) returns the object's whole field set on context?.isSystem, before it resolves any permission set and before the delegator intersection; the contract says the same of both projections ("A system context bypasses field-level security and yields the full field set"). So on an isSystem write the showable set is every declared field less secret, masked password and internal. A field the person cannot read shows, and a maskingRule field shows unmasked, because the queryable answer is also the full set. The userId such a context carries is not consulted.
  • Which elevated writes have a person behind them. A runAs: 'system' flow writes under { isSystem: true, actor, userId: <trigger user>, tenantId, locale } (resolveRunDataContext, service-automation/src/runtime-identity.ts), and its docblock states the purpose of the carried locale: "so a refused write is worded for the person who started the run, as their own record save would be". An action body writes under { ...caller, isSystem: true } (buildActionExecutionContext, runtime/src/action-execution.ts). Hook bodies fall back to { isSystem: true }, and the approvals mirror writes as { isSystem: true, userId: actor }.
  • Whether the sentence reaches that person: yes, by a declared carrier. ValidationError's top-level message is the field messages joined (record-validator.ts), so it is the rendered sentence. A flow's data node catches it and returns error: "update_record(OBJECT) failed: <message>" plus refusalCarriedBy(err) (builtin/crud-nodes.ts, inner-refusal.ts), which for any declared 4xx yields innerRefusal: { code, message }, "the refusal itself, for the run's CALLER". The spec declares that member on AutomationResult and on every flow door's 400 FLOW_FAILED details (spec/src/api/automation-api.zod.ts), so that a flow runner renders it as a record form renders a refused save. The flow path is measured end to end. For an action body the elevated context is measured; how each action door words a thrown ValidationError was not traced line by line.
  • So: a rule on object X whose message carries {{ record.margin }} renders the margin to a person who cannot read margin, whenever their click runs a system flow or an action that writes X and the rule refuses. Before this head the same path carried the author's fixed words. This is M1 below. It also bears on the consumer: HotCRM's re-confirm refusal is the kind of write an action or flow makes.

SQL push-down: the diff adds no query, no id materialisation and no in-app join. The two security projections are computed from schema and context. Nothing to flag.

④ Design judgment

M1 (must-fix) — on an isSystem write made for a person, every hole shows, and the sentence is carried to that person. Measured in ③. Parameter 6 is headed "Field security (human floor)" and the card's ask is "A missing or masked field (no read permission) renders empty, never its raw value". The new changeset promises it in so many words: "A hole shows a field only when the person whose write was refused may read it unmasked", and the PR body says the logged sentence "carries only fields the person whose write was refused may read". Both sentences are false on a system flow or an action body, where the security service is asked as the system and answers every field, masked ones unmasked, while innerRefusal exists to hand that sentence to the run's caller. The module header of engine-rule-message-rendering.ts says "the caller" throughout and never names this case, and no test reaches it with a meaning: every engine test runs under isSystem: true against a double. The rule's author and the flow's or action's author are in general different people, so "the flow author chose elevation" does not answer for the object's rule. The fix is one of two, and the second is not the seat's to choose: (a) when the write's context is elevated and names a person (userId), ask both projections for that person, not for the system, and render every hole empty where that answer cannot be had; a user-less system write has no reader but the log and may keep the system answer; pin both. Or (b) the maintainer rules that an elevated write renders as the system, and the changeset, the header and PR 3's docs say so in those words. Until one of them, the head discloses what the ruling's floor withholds. Under parameter 8 this was a fork to report, not to build over.

packages/spec/src/data/validation.zod.ts — holds. The rename is the whole change; the const's docblock and the shared message describe were read against the render and stay true: the describe's present-tense "template over the judged record" is now what authoredRuleMessage does. The describe is silent on parameter 6 (a field the reader cannot read renders empty) and on the tenant currency; that is PR 3's teaching, and a describe that names neither states nothing false.

packages/spec/src/system/translation.zod.ts — holds. Two mentions renamed, the generated reference page regenerated to match. "The same template the authored message is" is now true at run time too: one function fills both.

packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts — unchanged; still true with the render in the tree. PR 1's N3 (its example renames the field between FROM and TO) is still open and stays with PR 3.

packages/lint/src/validate-rule-message-templates.ts — agrees. Four mentions renamed; the judge is otherwise untouched.

packages/objectql/src/validation/rule-message-render.ts — agrees with parameters 5 to 7, with S2 and N2. The hole reader matches the engine's (HOLE_RE, PATH_ONLY_RE, [i] read as .i), and the no-argument currency test matches the engine's own (filter.arg === undefined), so a hole the blanker keeps is one the engine formats. A failed render returns the engine's reason, which quotes template text and never a value, so the warning carries no record data.

packages/objectql/src/engine-rule-message-rendering.ts — asks the security contract correctly for the context it is given, and that is the defect on an elevated write (M1); also S1. Computed once per write, on the insert, update (by-id and bulk legs) and dry-run paths.

packages/objectql/src/validation/rule-validator.ts — agrees. Every authoredRuleMessage call site hands the merged record and the previous binding of that row; checkPredicate's default captures the record before hydration, as its comment says.

packages/objectql/src/validation/record-validator.ts — agrees, with N4.

engine-insert.ts, engine-update.ts, engine-validate.ts — agree: one call each, beside the message context, under the write's own context.

S1 (should-fix) — in a kernel-hosted engine with no security plugin, every hole renders empty, silently, and the module says the opposite. ObjectQLPlugin fills the slot with () => ctx.getService('security') (packages/objectql/src/plugin.ts), and the kernel's getService throws for a name nothing registered (packages/core/src/kernel-base.ts; the engine's own resolveReadableIdsSecurity says so in its docblock). fieldSecurityOf reads that throw as 'unusable', so the showable set is empty. objectstack serve treats the security plugin as optional. In that composition a template that passed the doors renders Total is below what was received () on every refusal and nothing in the log says why. The module header ("With no security service registered at all … every declared field the engine serves on a read is showable") and the dev's reported decision describe the bare engine with an empty slot, which is the only place the test pins it; the test even pins the kernel's shape as empty (boot(() => { throw new Error('no security service') })). Either reading is defensible; an undeclared one is not. The fix is one of: keep fail-closed, and say so in the header and the changeset, with one rendering.warn line naming the cause (it is the write's logger, already in hand); or tell "not registered" from "registered and broken" and show. The same warn line is owed for the registered-but-unanswering arms (undefined, a throw), which are silent today: an operator facing blank holes has no line to read. If "shows" is wanted in the kernel, that choice goes to the maintainer; fail-closed with the log line does not.

S2 (should-fix) — a stored message the doors would refuse is blanked without a word. A hole over another root, a bare root, a read through a field or an undeclared field returns '' from blankUnshowableHoles and the render reports ok: true, so no warning is written. A stored message that does not compile takes the other arm: shown as written, and the log names the rule and objectstack validate. So the same class of message, one stored before the doors judged it, is repaired loudly in one shape and degraded silently in the other, and the changeset tells a deployed app "Nothing to rewrite". Stored rules keep loading until their next save (parameter 3), so a deployed …from {{from}} to {{to}}. now reads …from to . until someone finds it. The fix: warn through rendering.warn, naming the rule and the hole, for a hole that is structurally unshowable (root, depth, undeclared field), and never for one that is unshowable for this caller (unreadable, masked), which must stay silent; and add the sentence to the changeset. Keeping such a hole as written instead would be a different product answer and is not asked for here.

Nits (none affects correctness or the contract):

  • N1 (nit) — tenantCurrencyHole's warning says "the organization has none", where the engine's own sentence says "has none set, or the caller did not supply it". For a context-less write the first is wrong (E1). It is also written once per refused row per hole, so a bulk refusal repeats it.
  • N2 (nit) — the header's "A template that passes the doors always renders" is not quite true. Intl throws a RangeError for a locale tag or a time zone it does not know; attachRuleMessageRendering checks the currency's shape but hands timezone through on typeof === 'string'. The catch then shows the template as written and tells the operator to run objectstack validate, which will find nothing. No value is shown. Whether an invalid tag or zone can reach a write's context was not established; if it can, this is a third parameter-8 case.
  • N3 (nit) — packages/lint/src/seed-row-refusals.ts calls evaluateValidationRules with no message context, so objectstack validate's seed-row refusal now prints the rule's sentence with blank holes where it printed the template. A follow-up hands that caller a rendering over the seed row's declared fields (no caller, no field security at build), or prints the template.
  • N4 (nit) — record-validator.ts says of labelTranslation: "A thunk, asked only when a refusal names something". translationCarriesHole now calls it on every write to an object that has a rule and no hole in an authored message. The cost is a map read per locale; the sentence should gain the second caller.
  • N5 (nit) — no test pins the scope floor on its own (the blanking-built hole above). One case in rule-message-render.test.ts would.
  • N6 (nit) — the new note's Exports bullet announces a rename from a name no release carried, beside PR 1's note that already names the final export. The bullet can go.
  • N7 (nit) — the two security projections are asked on every write to an object whose messages carry a hole, refused or not. Computing them at the first refusal would need an async render; noted, not asked for.
  • Outside the diff, for PR 3: @object-ui/core's deprecated ObjectValidationEngine still returns rule.message as written; whether a live surface still reaches it was not established.

Carried from PR 1's record: N2 (the export name) closed by this diff; N5 (previous.* on an insert-only rule) decided and pinned; N3 (the entry's example) open for PR 3; N4 (a private copy of the hole grammar) open, and this diff adds a fourth copy in rule-message-render.ts.

FAIL on M1. S1 and S2 are open beside it; each of the three earns a delta review of its fix, and 34 check-runs had not answered at the read. The delta record re-reads the corrected changeset sentence in ②.

Implemented-by: claude/project-thread-h25bs8
Reviewed-by: session_01ADHkmSAjFEZHRpRq3WCj6z

VERDICT: FAIL

…son it was made for may read

An isSystem write that names a person (a runAs: 'system' flow, an action
body, the approvals mirror) asks both field projections for that person,
with the sets the context carries or their own grants resolved through
resolveUserAuthzGrants; unreadable grants render every hole empty. A
user-less system write keeps the system's answer.

No security service registered, or one that cannot answer, renders every
hole empty and logs the cause once per write. A stored hole no reader could
see filled (another root, a bare root, a read through a field, an
undeclared field) is logged with its rule; a hole empty only for this
reader is never logged.

Claude-Session: https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs
Co-authored-by: Claude <noreply@anthropic.com>
…og is told

The flow path end to end: a runAs: 'system' flow started by a member who
cannot read a field carries that field's hole empty in innerRefusal.

Claude-Session: https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/xl and removed size/l labels Nov 30, 2026
…he system-context page

Claude-Session: https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 331b47d5b7567a39935574d234e78927def74b2e
Local-runs: none
Scope: packages/spec/src/data/validation.zod.ts, packages/spec/src/system/translation.zod.ts, packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts + packages/objectql/src/validation/rule-message-render.ts, packages/objectql/src/engine-rule-message-rendering.ts, packages/objectql/src/validation/rule-validator.ts, packages/objectql/src/validation/record-validator.ts, packages/objectql/src/engine-insert.ts, packages/objectql/src/engine-update.ts, packages/objectql/src/engine-validate.ts, packages/lint/src/validate-rule-message-templates.ts
Security-touching: yes
Rule-change-verified: none

Delta review of record 7273883345 (FAIL at 9b716a377c), on the fix round the dev reports in card comment 7276925080. Read: the four commits 9b716a377c..331b47d5b7 (9 files, +509/−101), the whole new note, the net diff of PR 1's note against merge base e130fd43b6, and the check-runs on this head. The three hits files and the lint importer are unchanged since the first record; what that record says of them stands. Cited code was read at this head through git show; nothing was built or run.

Gate verdicts (check-runs on this head, read 2026-11-30T11:25Z, none in progress): 78 runs, 62 success, 14 skipped, 2 failure. Both failures are Check Changeset (two runs of the same job), and in each the only red step is the one that carries the foreign-changeset rule, annotated on .changeset/37909-rule-message-template-holes.md. The skipped runs are the opt-in and matrix-placeholder ones (18.x upgrade harness, packed-tarball smoke, dogfood battery, Temporal conformance, Dogfood Verify CLI, Lint UI, UI Published Artifacts, the queue verdicts, the schedule gate, Auto Label, Check PR Size). No other gate is red.

① Derived judgments

  • Accept set, public surface, the rename — unchanged since the first record, right. The round adds no export and moves no schema. RuleMessageRendering gains two optional members (declared, unanswered); both are read only by the render.
  • Whose read a hole stands for (changed) — right. On an isSystem write that carries a userId, both projections are asked under that context with isSystem off (readerContext). On every other write they are asked under the write's own context, as before.
  • No security service (changed) — right, and now one answer. An empty slot, a slot that holds no function, a source that throws (the kernel's answer for an unregistered name), a null service and a service without getReadableFields all give the empty set with a named cause. The first head showed every field on a bare engine and nothing in a kernel; this head shows nothing in both and says so.
  • What the log is told (new) — right. One line per distinct cause per write: a structural hole (named with its rule and the hole), an unanswered field security, a currency hole with no default. A hole empty for this reader only writes nothing.

② Semver level

  • Levels unchanged and right: objectql, spec, lint minor; Clause-②: yes (widening); Metadata-protocol: semantic. The fix round narrows what an elevated write shows relative to the first head, which no release carried.
  • The red gate, check-empty-changeset (foreign-changeset rule): confirmed as a DELIBERATE CORRECTION, sentence by sentence. One foreign note is modified, .changeset/37909-rule-message-template-holes.md (this card's PR 1, pending, unreleased). Its diff against the merge base is one line:
    • Before: "Exports. @objectstack/spec/data gains VALIDATION_MESSAGE_TEMPLATE_ROOTS (['record', 'previous']). The message describe of the six validation-rule variants and of the _validations translation entry now state the template."
    • After: "Exports. @objectstack/spec/data gains VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS (['record', 'previous']). The message describe of the six validation-rule variants and of the _validations translation entry now state the template."
    • First sentence: true of this head. packages/spec/src/data/validation.zod.ts exports VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS = ['record', 'previous'], api-surface/data.json and export-origins/data.json carry that row and no other, and no file at this head reads the old name. The sentence it replaces would announce an export the release does not carry.
    • Second sentence: unchanged, and still true.
    • Every other sentence of that note and its frontmatter are identical to main. It is not a collision: same card, same branch, same seat.
  • The new note (.changeset/37909-rule-message-render.md, added by this PR, so not under the foreign rule), read against the tree:
    • What a hole may show — true of readerContext and showableFields, with the one qualification in N8 ("with their own permission sets").
    • "If no security service is registered, or the one registered cannot answer, answers nothing or fails, every hole renders empty and the server log says why, once per write" — true; the line is written when a hole renders empty for that cause.
    • Formatting, the no-default sentence — true of tenantCurrencyHole; it is the sentence the maintainer's answer on the fork rewrites if he picks otherwise.
    • Translations first — unchanged, true.
    • "What changes for a deployed app" — true of structuralBlank and its warning; it replaces "Nothing to rewrite".
    • The Exports bullet is gone, which closes N6.

③ Boundary flags

  • The currency fork (parameter 8) still waits on the maintainer. This head builds option A: a currency hole with no argument and no default currency on the write renders empty, the rest of the sentence renders, and the log names the rule, the hole and the setting. A as built is safe: no amount in a currency nobody chose, nothing disclosed, the verdict untouched. Landing depends on his answer or on his explicit acceptance of A at the Tier H hand-off. If he picks a per-hole alternative, tenantCurrencyHole, its one test and the note's one sentence move; a whole-sentence alternative also moves renderRuleMessage and authoredRuleMessage; a refusal at the doors is lint surface and a narrowing. E1 and E2 of the first record (a write whose context carries no currency; a currency field with its own currency formatted in the tenant default) still belong beside the decision card. The warning's wording now covers E1.
  • The census row (content/docs/permissions/system-context.mdx, 29g, and the regenerated ledger line for readerContext) is outside the claimed file surface and declared in the PR body. Its sentence agrees with the code: the system answer only for a write that names no person; a write that names one is asked for that person. It is prose and a generated ledger, the seat's to accept; the docs and code guards are green on it.
  • Elevated-write convention, for the seat (N8). readerContext keeps the positions and permission sets an elevated context already carries and resolves the person's grants only when it carries none. That is the platform's existing de-elevation rule for a runAs: 'user' hook (runtime-identity.ts, "keeps any arrays it carries verbatim"), so the two cannot disagree. See N8 for the shape where it is wider than the person.
  • SQL push-down: the round adds one read path, resolveUserAuthzGrants, the platform's one grants resolver, called at most once per write and only on an elevated write that names a person and carries no sets. No id materialisation, no in-app join. Nothing to flag.

④ Design judgment

No must-fix, no should-fix.

M1: closed. readerContext (engine-rule-message-rendering.ts) turns isSystem off for an elevated write that names a person and asks both projections as that person. The two paths the first record measured are covered: a runAs: 'system' flow's context carries userId and no sets (resolveRunDataContext drops the empty arrays when it names a user), so the person's grants are resolved through resolveUserAuthzGrants; an action body and a hook body spread the caller's envelope, so the caller's own sets are asked. A failed grants read gives the empty set with its cause, since that resolver throws on a store read that fails. A user-less system write keeps the system answer. Pinned in the engine tests (the action shape, the unreadable-grants shape, two controls) and end to end in service-automation/src/flow-rule-message-reader.integration.test.ts: a system flow started by a member who cannot read the margin answers innerRefusal.message with that hole empty, the same sentence as the member's own write and as a runAs: 'user' run. The header, the changeset and the PR body now say whose read it is.

S1: closed. Fail closed in every composition, declared in the module header and the note, and the cause reaches the write's logger once per write. Choosing fail-closed needed no ruling.

S2: closed. A hole over another root, a bare root, a read through a field or an undeclared field is reported with its rule and the hole and still renders empty; a hole empty for this reader alone is silent, pinned both ways. The note's deployed-app paragraph states it.

The first record's nits: N1 closed (the sentence names both causes and the rule; each distinct line is written once per write). N4 closed (the labelTranslation docblock names its second caller). N5 closed (the scope floor is pinned on its own). N6 closed. N2, N3 and N7 stand as they were: the header still says a template that passes the doors always renders, while an Intl refusal of a locale tag or a time zone would show the template as written; seed-row-refusals.ts still prints blank holes; the projections are still asked on every write to an object whose messages carry a hole.

packages/objectql/src/engine-rule-message-rendering.ts — agrees with its header, sentence by sentence, with N8. fieldSecurityOf names each way the service cannot be asked; showableFields returns the cause beside the empty set; the warn closure de-duplicates per write.

packages/objectql/src/validation/rule-message-render.ts — agrees. structuralBlank runs before the showable test, so a structural hole is reported whoever reads and a reader-specific one never is. The warnings quote template text and causes, never a record value.

packages/objectql/src/validation/rule-validator.ts, record-validator.ts — agree: the subject each warning names is built once per message, and the translation's subject carries its bundle path.

New nit (no effect on the paths this card ships, no effect on the contract's measured cases):

  • N8 (nit) — an elevated context that names a person and already carries an array is asked with that array, whatever it holds. The platform also builds { isSystem: true, positions: [], permissions: [], userId } as a grant-less system context with an attribution user (flow-definitions.ts flowActivationWriteOptions, approval-service.ts { ...SYSTEM_CTX, userId: person }, the connector stores). For that shape the reader is the person with the member baseline alone, and field permissions merge most-permissive with an unnamed field passing through (permission-evaluator.ts getFieldPermissions), so a field hidden from the person only by one of their own sets would show. Every first-party producer of that shape that I found writes a platform object, where a rule message with a hole is not expected, so no shipped path is affected; app code that hand-builds the shape would be. The note's "with their own permission sets" and "its sentence reaches the server log alone" are both slightly wider than the code for hand-built contexts. A follow-up card decides it for the hook de-elevation and this reader together: resolve the person's grants whenever the carried sets are empty.

Still open from PR 1's record, for PR 3: N3 (the semantic entry's example) and N4 (private copies of the hole grammar).

Implemented-by: claude/project-thread-h25bs8
Reviewed-by: session_01ADHkmSAjFEZHRpRq3WCj6z

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmT9HTWLMN33WUVxVWB
L1-b, the seat's L1 thread · 2026-11-30T11:32Z · delta review

席位核对

ACCEPT @ 331b47d (card #37909, PR 2; delta from 9b716a3 and REWORK 7273784971, plus contract review 7273883345: 5cf57ec2 the changeset, 6a497592 the M1 fix, 8f257963 the pins, 331b47d5 the register row)

  • My must-fix is resolved. The Formatting bullet now carries the no-default-currency sentence. It reads: with none set, or none on the write, a | currency hole with no argument renders empty, the rest of the sentence renders, the log names the rule and the setting, and no amount is formatted in a currency nobody chose. That matches tenantCurrencyHole. The body's currency bullet ("a different ruling changes those two and the changeset's sentence, nothing else") is now true, because that sentence exists.
  • The other changeset moves, read against the code.
    • "What a hole may show" now says whose read is asked. That matches readerContext in engine-rule-message-rendering.ts:
      • not elevated, or elevated with no userId: the write's own context;
      • elevated for a person: isSystem: false, with the context's sets, else resolveUserAuthzGrants;
      • grants that cannot be read: unanswered, so every hole is empty.
    • The "server log says why, once per write" sentence matches RuleMessageRendering.unanswered.
    • The new "What changes for a deployed app" sentences (a stored structural hole now renders empty and is logged; run objectstack validate) are true. They name the move I recorded in the first review.
    • Dropping the Exports bullet follows L2's N6: no release carried the old name, and PR 1's corrected note names the final export.
    • @objectstack/spec and @objectstack/lint stay minor through PR 1's pending note, which L2 judged harmless.
  • The out-of-surface files are declared and right.
    • flow-rule-message-reader.integration.test.ts is test only, and is the end-to-end pin M1 asked for (runAs: 'system' → innerRefusal).
    • system-context.mdx row 29g, with its register line, is what check:system-context-census requires for a new isSystem read.
  • My runs (fresh worktree at this head; @objectstack/objectql^... and @objectstack/service-automation^... built):
    • engine-rule-message-rendering.test.ts + rule-message-render.test.ts: 34/34.
    • flow-rule-message-reader.integration.test.ts: 4/4.
    • My ablation: with readerContext's de-elevation removed, so an elevated write is always read as the system, the engine file turns 2 red (the two M1 elevated cases). Restored.

For the seat

  • Check Changeset is red (×2, the same job) by design. It is the DELIBERATE CORRECTION recorded in the first review: PR 1's pending note gets one sentence naming the final export. Code also changed, so the confirmation is L2's same-head PASS on this head. That is still running; this ACCEPT does not stand in for it.
  • The parameter-8 currency fork still waits for the maintainer (provisional option A). Landing waits on his answer, or on his explicit acceptance of A at the Tier H hand-off.
  • L2's out-of-scope N2, N3 and N7 are recorded in the body's Acceptance notes, each with its follow-up path.

Checks at this head (read before writing, latest per name): 62 success, 14 skipped, 2 failure (Check Changeset, above), unstable. L2: owed at CONTRACT_REVIEW_TIER, delta running. Dogfood: not owed.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 30, 2026 11:59
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 30, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z

维护者速读

Seat opinion: land as is.

席位核对

ACCEPT at head 331b47d5b7567a39935574d234e78927def74b2e · Tier H by the queue guard's narrowed-spec arm (the PR corrects PR 1's pending changeset, which carries Clause-②: no (narrowing)); not a governed surface; 1383 lines · Part of #37909

  1. Shape. objectql renders a validation rule's message holes (rule-message-render.ts, engine-rule-message-rendering.ts, the validators and engine call sites). spec and lint carry only the renamed export.
  2. Premise. PR 1 (feat(lint)!: a validation rule's message is a {{ }} template over the judged record, and a single brace there is refused #38687, 9cbb41b1) is on main. The maintainer ruled the currency fork A at 2026-11-30T11:26:17Z, recorded on Validation rules: an authored rule message cannot name record values, so a refusal cannot say "total 8,000 is below received 10,000" #37909.
  3. Gates. On this head, every check is success or skipped except Check Changeset. That one is red by design: it is a deliberate correction of the unreleased PR 1 note, and L2 confirmed it sentence by sentence. On the merge group, CI, Lint & Type Check, Spec Liveness and PR-Body Guards are green, and the Queue Guard asks only for this approval.
  4. Accepted deviations.
    • N2, N3 and N7 (first L2 record) stand as recorded.
    • The census row 29g in system-context.mdx is outside the claimed surface and declared in the body.
  5. Out of scope and where it went.
  6. Landing. L1 delta ACCEPT 7277179783 and L2 delta PASS 7277073583 are on this head. It re-enters the queue after os-zhuang approves.

ACCEPT → comment 7277179783 · Contract review → comment 7277073583

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 30, 2026
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 49c09ed Nov 30, 2026
83 of 86 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-h25bs8 branch November 30, 2026 13:06
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 30, 2026
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…ack-ai#38787)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9SNzk6FfxPPrxLwCB5BftuN)_

Part of objectstack-ai#37909 — PR 3 of the ruling's sequencing (skills and docs),
claim amendment 5 (7279412658). PR 1 (objectstack-ai#38687, merged as 9cbb41b) is the
doors; PR 2 (objectstack-ai#38736, merged as 49c09ed) is the render. This PR
teaches what the merged tree does.

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 用户能看到什么变化:没有运行时变化;技能 objectstack-data 与文档「Validation
metadata」页开始教规则提示语里的 `{{ record.字段 }}` 占位、格式化器、币种规则(你选的
A)、看不到的字段留空、译文先填、提示语是纯文本。
- 为什么做:维护者已裁(P3);前两步已合入,这是第三步,让写元数据的 AI 和人知道怎么写、写了会显示什么。
- 出错会怎样:最坏是教错一句,AI 写出的提示语被发布校验拒(会点名正确写法)或某个占位显示为空;不影响任何保存是否被拒。
- 要你做什么:skills 是受管面,请 os-zhuang 审批;ratchet 行按「A:先削重复,余额按实测提高」抬了 235 个
token(先删了 699 字节重复)。

## What changes

Ruling P3 (card comment 7239726323), the currency ruling A (7277046538),
and the items PR 1's and PR 2's contract records left to this PR.

- **`skills/objectstack-data/rules/validation.md`** gains § Messages —
Record Values in Holes: the `record` / `previous` roots (`previous`
empty on insert), one segment, own fields; the formatter whitelist with
`| currency:EUR`; what the doors refuse (a single brace, a read through
a field, another root, logic); a bare `| currency` in the organization's
default currency, and with none set that hole empty while the server log
names the setting (ruling A); a field holding its own currency names the
code or uses `| number:2` (PR 2 contract record, E2); a field the person
whose write was refused cannot read, or sees masked, renders empty,
`default:` included; the translation takes the same holes and is filled
first; the sentence is plain text (PR 2 contract record: "PR 3's docs
should say the sentence is text").
- **`content/docs/data-modeling/validation.mdx`** — the `message` row of
Common Properties points at a new § Messages with a worked example, the
two roots, the formatter table, currency, the field floor (including
writes an automation makes on someone's behalf, and a person-less system
write), translations and plain text.
- **`content/docs/ui/translations.mdx`** — the one bullet that said a
validation message is "substituted whole — there is no interpolation …
`{variable}` placeholders in it are not filled", false since PR 2, now
says a translation fills the same `{{ }}` holes, translation first, the
fallback, and that a single brace is refused at publish.
-
**`packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts`**
— PR 1's contract record N3: the example renamed the field between FROM
(`{received}`) and TO (`record.received_amount`); FROM now reads
`{received_amount}`. One word; nothing else in the entry moves.

### Token ratchet (`scripts/check-skills-token-ratchet.mjs`)

`skills/objectstack-data/rules/validation.md` had no headroom (3862 /
3862). Paid down first inside the file: § Incorrect vs Correct and its
table-of-contents entry are deleted, since its one example (a rule with
no `events` runs on insert and update; scope it with `events:
['update']`) restates § Events, which stays. -699 bytes cut, +1638
added: 15448 -> 16387 bytes (+939) -> `ceil(16387 / 4)` = 4097 tokens;
the row moves 3862 -> 4097, the measured remainder, pinned at the
measurement. Raise path: the standing maintainer ruling 2026-10-27
「A:先削重复,余额按实测提高」 (ruling record 6513306068). `SKILL.md` gains no byte.
No other row moves.

### Outside the original claimed file surface

The seat widened the surface by its relay of 2026-11-30T13:21Z:
`content/docs/ui/translations.mdx` (that one bullet), the ratchet row,
the `.changeset` note, and the one word in the semantic entry.

## Acceptance notes

- Read before writing: the merged `rule-message-render.ts`,
`engine-rule-message-rendering.ts`, the formula `templateEngine`
formatters (`TEMPLATE_FORMATTERS`, `splitHoleFormatter`) and
`ExecutionContext.timezone`.
- Plain text: no console error or toast renderer in `ui/packages` puts a
message through `dangerouslySetInnerHTML` (the files that use it are
page HTML, rich text, charts, markdown and code blocks).
`@object-ui/core`'s deprecated `ObjectValidationEngine` was not audited
(PR 2 contract record, outside the diff).
- Out of scope: PR 1's N4 (private copies of the hole grammar, a code
dedupe) and PR 2's N3 (`packages/lint/src/seed-row-refusals.ts` prints
blank holes), as the seat agreed; PR 2's N2 and N7 stand as recorded; N8
is objectstack-ai#38759.
- No eval case: the file surface holds no eval file.

## Verification

Head `17319d01f6c6dfc2eb9b7c9ef0daebf764eed391`, on main `49c09ed902`.

- Full build: `bash scripts/pm/os-verify-lock.sh -c 'pnpm build
--concurrency=2'` → VERDICT command-exit 0 (123/123 tasks).
- Derived gates (`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`, re-derived after the last commit, same
133): each run with stdin closed, recorded `cmd :: exit N`. All 133 exit
0.
- First round on `995a1318c6`: 132 green, `pnpm check:skill-links` red —
the table-of-contents link `#messages--record-values-in-holes` did not
match the heading, whose code span slugs to
`messages--record-values-in---holes`. Root fix in `17319d01f6`: the
heading drops the code span (its body shows the holes), the link now
resolves, and the ratchet row is pinned at the new measurement (4097).
The 15 skills / changeset / ratchet gates were re-run on the new head,
all exit 0; no other file changed.
- `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--ran=FILE` → 133 derived, 133 run, 0 NOT-MEASURED, 0 UNRUN.
- `node scripts/check-skills-token-ratchet.mjs` and `--self-test` → exit
0; `node scripts/check-skill-links.mjs` → 290 links, 161 fragments
resolve.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs

<!-- signed: repo:objectstack@os-steve · os-steve ·
session_01ADHkmQ6vV3YvhJWKF1gSDs -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
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:data protocol:system size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants