Skip to content

fix(lint): the flow and hook publish doors stop requiring a null guard on the current row's created_at and updated_at in an ordering comparison - #33434

Merged
objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/project-thread-7g7khi
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/project-thread-7g7khi

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #33246

Clause-②: yes (widening) — the flow and hook publish doors (Studio, /api/v1/meta, the MCP and AI authoring doors) now accept a condition they refused and os build accepted: created_at or updated_at (as the registry injects them, on an object whose storage the platform provisions) read off the current row (bare in a flow, or record.) as an operand of <, <=, > or >= with no != null guard, in a record-triggered flow or in a hook whose every event is afterInsert, beforeUpdate, afterUpdate, beforeDelete or afterDelete. Nothing that published before is refused, and no other verdict moves: arithmetic over either column, a previous. read, a beforeInsert or read-event hook, and the other six injected columns keep their verdicts (measured below). os build, os validate, os lint and MCP validate_expression are unchanged. No exported type or signature changes.
Metadata-protocol: added
Skills-docs: none owed — no skill teaches that created_at or updated_at needs a null guard in a flow or hook condition, or that the door refuses one; the door now gives the verdict os build already gives on those two columns under an ordering comparison.

Precedent followed: #33154 (PR #33205) for the door-versus-build reading. Round 2 answered contract review 6884221427 under seat rulings 6884227999 (F1, F2, F3, N2; N1 declarations kept). Round 3 answered delta review 6884875891 under seat rulings 6884884180 (M1, S1, N3, N4, N5). Round 4 answers review 6885550922 under seat rulings 6885555312 (M2, S2, N6).

维护者速读

  • 改了什么:运行时发布口(流、钩子)做“空值守卫”判定时,created_at、updated_at 作为比较运算(< <= > >=)的操作数不再报可空;仅限当前记录的这两列(流里的裸名或 record.,不含 previous.)、平台自己注入的定义、对象的存储由平台建表(外部对象不算),且钩子的每个事件都在 afterInsert、beforeUpdate、afterUpdate、beforeDelete、afterDelete 之内。算术运算(+ - * / %)、previous. 读取照旧判定;其它六个注入列(owner_id、created_by、updated_by、owning_business_unit_id、queue、organization_id)照旧按可空判定;所有注入列的类型判定照旧。
  • 为什么改:在 Studio 发布记录触发流或钩子时,条件 record.created_at > timestamp(...) 没加空值守卫会被发布口拒绝(422),而 os build 通过、MCP validate_expression 也说没问题。平台在 beforeInsert(sys_stamp_audit_insert,优先级 10)里给每条记录写这两列,之后读到的都有值,拒绝是误报。
  • 风险与回滚:放宽,只影响流和钩子发布口对这两列在比较运算中的空值判定。不变且有测试钉住的:流里 record.created_at + 1 > 0 与 record.updated_at - record.created_at > duration('1h') 照旧拒绝;beforeInsert 钩子照旧拒绝(可能先于平台写入运行);读事件(beforeFind、afterFind)钩子照旧拒绝(没有记录);afterInsert 钩子或新建流里的 record.updated_at > previous.updated_at 照旧拒绝(新建时 previous 为空);其它六个注入列、作者自己声明的 created_at、外部对象照旧。发布口与 build 在六列及 beforeInsert、读事件钩子上的差异留给 lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435。回滚即 revert。
  • 先看:packages/lint/src/validate-expressions.ts(PLATFORM_STAMPED_COLUMNS、isPlatformStampedColumn、buildPlatformStampedIndex、isStampedComparisonFinding、hookReadsStampedRow)、packages/runtime/src/domains/meta-flow-hook-injected-column-null-guard.test.ts(真实发布口)、packages/lint/src/validate-expressions.flow-null-guards.test.ts(A flow or hook condition ordering record.created_at with no guard is refused at the publish door while os build accepts it #33246 一节)。
  • 两分钟验证:pnpm --filter @objectstack/lint exec vitest run src/validate-expressions.flow-null-guards.test.ts -t 33246,预期 10 条全过:两列无守卫比较在流三处与钩子都通过;五个可空注入列照旧拒绝;日期运算照旧拒绝(钩子、流裸写、动作);流里 record. 写法的算术照旧拒绝;beforeInsert 钩子照旧拒绝;previous. 读取照旧拒绝;读事件钩子照旧拒绝;作者声明与外部对象的 created_at 照旧判定;声明的可空字段照旧拒绝。
  • 需要你做的:无,席位落地。

What changes

  • packages/lint/src/validate-expressions.ts.
    • PLATFORM_STAMPED_COLUMNS (created_at, updated_at) and isPlatformStampedColumn(obj, field, def): true only when the field is one of the two, its definition is the platform's own (isInjectedColumnDefinition against injectedSystemColumnDefs(obj)), and the platform provisions the object's storage (platformProvisionsStorage, so not an ADR-0015 external object). The two names are the ones @objectstack/objectql stamps on every row (sys_stamp_audit_insert, a beforeInsert hook at priority 10, writes both unconditionally). This package may not import a runtime, so they are spelled here, with that reference in the docblock.
    • buildPlatformStampedIndex(objects) (object → its stamped columns) is built on every runtime write (options.runtimeWriteType !== undefined); the build gets an empty index. buildNullableFieldIndex is back to main's signature and body: the nullable index still holds both columns.
    • checkNullGuards takes { stampedComparisons } (default true) and drops a finding only when isStampedComparisonFinding holds: the operand is a stamped column of that object read off the current row (bare, as a record-triggered flow flattens its trigger record, or record.<column>), and the operator is <, <=, > or >=. A previous.<column> operand keeps its finding and PREVIOUS_GUARD_CLAUSE (M2): an insert binds previous itself to null. An arithmetic operand (+ - * / %) keeps its finding (M1): at a record-triggered flow's record. read the null guard is the door's only refusal of date arithmetic, because the flattened site type-checks only the bare spelling.
    • The hook loop passes stampedComparisons: hookReadsStampedRow(hook.events): true only when events is a non-empty list and every event is afterInsert, beforeUpdate, afterUpdate, beforeDelete or afterDelete. A beforeInsert hook (S1) can run before the stamp, at any priority, and read either column as null; a beforeFind / afterFind hook (S2) carries no record.
    • The object_extension strip is main's (only that write reads the objects stripped). Every other door keeps the served objects, so fieldTypeIndex and every other reader still see the injected columns' types.
    • Effect at the door: an unguarded ordering over created_at / updated_at at the three record-triggered flow sites and in a hook condition whose every event reads a stamped stored row publishes, when the read is the current row's. Everything else is judged as on main.
  • packages/lint/src/validate-expressions.test.ts: the validate-expressions / validate-security-posture 也有同形的 spec 不声明键的 ?? 别名读法(#5009 建议 3 的核对结果) #5017 declared-key meta-test's hook row now lists events (a declared ObjectStackSchema.hooks[] key), and its plumbing set names platformStampedIndex / stamped / hookEvents (Map / Set / Array locals). The meta-test forces that visit for any new read.
  • .changeset/33246-door-skips-stamped-timestamps-in-comparisons.md (renamed from round 1's 33246-door-reads-objects-as-authored.md): @objectstack/lint minor, both declaration lines, Before / Now / Unchanged. Unchanged names arithmetic at every door (the flow record. spelling included), the author-declared and external created_at, a previous. read, a beforeInsert or read-event hook, the six injected columns still judged nullable (organization_id included), and the door/build difference on those six and on a beforeInsert or read-event hook until lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435. Its Now paragraph gives the stamp as the warrant (N6).
  • content/docs/deployment/validating-metadata.mdx does not describe the door's null-guard reading, so it is not edited.

Tests

  1. packages/lint/src/validate-expressions.flow-null-guards.test.ts, top-level describe #33246 (10 cases), at the gate (runRuntimeAuthoringRules, the account as the registry serves it via applyInjectedSystemColumns) and at the build (runAuthoringRules('build', …)). Five writes per condition: a flow with it at the start node, an edge and a decision branch; a hook on 'crm_account' and on ['crm_account'].
    • The served account declares the injected columns.
    • LIT: record.created_at > timestamp('2025-01-01T00:00:00Z') and record.updated_at > record.created_at: no expression finding at the door or the build.
    • LIT: record.COLUMN > 'a' for each of owner_id, created_by, updated_by, owning_business_unit_id, queue: one null-guard finding naming the column at the door.
    • LIT (type verdict): record.created_at + 1 > 0 and record.updated_at - record.created_at > duration('1h') at a hook, bare created_at + 1 > 0 at a flow start and edge, and record.created_at + 1 > 0 as an action visible: each refused with date arithmetic.
    • LIT (M1): record.created_at + 1 > 0 and record.updated_at - record.created_at > duration('1h') at a flow start condition: each refused with a null-guard finding on the column.
    • LIT (S1): record.created_at > timestamp(…) on a hook with events: ['beforeInsert'] and ['beforeInsert', 'beforeUpdate'], on a string and a list object: refused with a null-guard finding; the same condition on an afterInsert hook: no finding.
    • LIT (M2): record.updated_at > previous.updated_at in an afterInsert hook and at a record-after-create flow start: one finding each, on previous.updated_at, whose message names previous != null && previous.updated_at != null.
    • LIT (S2): record.created_at > timestamp(…) on a hook with events ['beforeFind'], ['afterFind'] and ['afterFind', 'afterUpdate']: refused with a null-guard finding.
    • CONTROL: a created_at the author declares (own label) is judged at the door as at the build (deep-equal findings); the one on an external object is still judged at the door.
    • CONTROL: record.amount > 0 (declared nullable) refused at the door with one finding, deep-equal to the build's.
  2. packages/runtime/src/domains/meta-flow-hook-injected-column-null-guard.test.ts (new; surface amendment 6884227999), the real door: better-sqlite3 behind the real ObjectQL, the real sys_metadata* objects and ObjectStackProtocolImplementation, the account registered through registerApp, each item saved as a draft in a writable package and published through publishMetaItem (6 cases):
    • The registry serves the account with created_at, updated_at, owner_id, created_by declared required: false; a system-context insert stores both timestamps and null in owner_id and created_by.
    • LIT, flow and hook: both created_at / updated_at conditions publish (row active), and os build reports nothing on the same item.
    • LIT, flow and hook: record.owner_id > 'a' gets 422 INVALID_METADATA with one expression-invalid issue naming record.owner_id; the row stays draft.
    • LIT (S1): a beforeInsert hook with record.created_at > timestamp(…) gets 422 INVALID_METADATA with one expression-invalid issue naming record.created_at; the row stays draft.
  3. Ablations (one-shot; nothing permanent; each through node scripts/ablation-replace.mjs, restore verified blob == HEAD and git diff HEAD empty):
    • Round 4, at df63888d (lint #33246 10 cases):
      • M2, the current-row test off (finding.operand === finding.field || finding.operand === 'record.' + finding.field replaced by an always-true opaque guard): lint 1 of 10 red, the M2 LIT; a throwaway probe (deleted) split it per site: the afterInsert hook and the record-after-create flow each red.
      • S2, beforeFind / afterFind added to STAMPED_ROW_HOOK_EVENTS: lint 1 of 10 red, the S2 LIT.
      • S1 again on the new mechanism, beforeInsert added to STAMPED_ROW_HOOK_EVENTS: lint 1 of 10 red, the S1 LIT.
    • Round 3, at efc8003b:
      • M1, the skip on arithmetic operands too (STAMPED_COMPARISON_OPERATORS.has(finding.operator) replaced by an always-true opaque guard): lint 1 of 8 #33246 cases red, the M1 LIT.
      • S1, the beforeInsert exception off (includes('beforeInsert') → includes('ABL_33246S1')): lint 1 of 8 red, the S1 LIT; runtime, after pnpm --filter @objectstack/lint build and ablation-dist-preflight finding the marker in dist/, 1 of 6 red, the S1 LIT. Lint rebuilt after restore; ablation-dist-preflight --absent passes on all 20 built files with a clean tree.
    • Round 2, at ddd834f5 (6 #33246 lint cases then, 5 runtime cases):
      • A, main's reading (the stamped skip guarded off by an opaque global): lint 1 of 6 red (the created_at / updated_at LIT); runtime via dist/ 2 of 5 red (the flow and hook LIT).
      • B, the round-1 reading (strip on every runtime write): lint 3 of 6 red (the five-column LIT, the date-arithmetic LIT, the external CONTROL).

Measurement

Round 1's probe (deleted, not committed) over the real door at origin/main fc283d6d:

Condition Site Door on main os build (real CLI) validate_expression gate half Door at this head
record.created_at > timestamp('2025-01-01T00:00:00Z') flow start / edge / branch, hook (every event a stamped-row event) 422 expression-invalid (nullable created_at) exit 0 clean published
record.updated_at > record.created_at flow start / edge / branch, hook (every event a stamped-row event) 422, two findings exit 0 clean published
record.created_at > timestamp(…) beforeInsert hook 422 accepted clean 422, unchanged (#33435)
record.created_at > timestamp(…) beforeFind / afterFind hook 422 accepted clean 422, unchanged
record.updated_at > previous.updated_at afterInsert hook, record-after-create flow 422 (previous.updated_at) accepted — 422, unchanged
record.owner_id > 'a' flow, hook 422 (nullable owner_id) exit 0 clean 422, unchanged (#33435)
record.created_at + 1 > 0 hook, action 422 date arithmetic accepted (runAuthoringRules('build'): no type for an injected column) — 422, unchanged
record.created_at + 1 > 0 flow start 422 (nullable created_at) accepted — 422, unchanged
record.amount > 0 (control) flow edge, hook 422 exit 1, the same finding finding 422, unchanged
  • os build is the real CLI (packages/cli/bin/run.js build) on a defineStack config with the same object, flows and hooks. os lint on it exits 0. The beforeInsert, read-event, previous. and flow-arithmetic build rows are runAuthoringRules('build'), which judges no injected column.
  • validate_expression's gate half is judgeAuthoredSiteExpression (site flow_condition) over the served definition, the call the MCP tool makes; it strips the injected columns, so it stays as it was.
  • Engine fact: a system-context insert stores created_at and updated_at and null in owner_id, created_by, updated_by, owning_business_unit_id, queue (pinned in the runtime file for owner_id and created_by). organization_id's injected definition says org scoping stamps it on insert; the door still judges it nullable, as on main.

Acceptance notes

Verification

Head df63888d (round 3 10f6d63a, round 2 ddd834f5, round 1 533eb60b; base fc283d6d). Round 4 pushes one commit on the same branch, no rebase, no merge: git diff --stat fc283d6d origin/main (e3f0cfd4 at hand-over) over every touched file is empty, and git merge-tree with origin/main is clean. Everything below ran at df63888d.

Package tests
  • @objectstack/lint: 210/210 files, 8981/8981 tests. Typecheck (tsc --noEmit && check:test-typecheck) exit 0.
  • @objectstack/runtime: the door file 6/6; typecheck (tsc --noEmit && check:test-typecheck) exit 0.
  • @objectstack/metadata-protocol (every save, draft-diagnostics and publish door test, lint read through dist/ rebuilt at this head): 339 files passed, 9 skipped; 22850 tests passed, 43 skipped.
Gates (dispatch-gates --commands, 63 lines)

Every line ran with stdin closed and its exit code captured before any pipe. All 63 exited 0 (check:dual-build-cjs-loads included). dispatch-gates --ran: 63 derived, 63 run, 0 NOT-MEASURED, 0 UNRUN.

Dogfood: not run. The title carries no ! and Clause-② carries no (narrowing) arm.


Generated by Claude Code

…njected system columns, as os build does

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
…injected system column as os build does

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
…n a flow or hook condition as os build does

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/lint, touching 14 documentable anchor(s).

39 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 4c32b9694b7b248646b2053b6eafea2cc212693b.

⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: created_at (literal, 43 pages)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 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; 123 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 — 4 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 4c32b9694b7b248646b2053b6eafea2cc212693b → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 4c32b9694b7b248646b2053b6eafea2cc212693b

⚠️ 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 4c32b9694b7b248646b2053b6eafea2cc212693b → 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

domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 533eb60bdb742250584353fba3e50d5d17dccf13
Local-runs: none

PR #33434 for card #33246, on the declaration face. Read: the card body and its seven comments (6879098956, 6879740792, 6880234097, 6880862710, 6883467822, 6884094895, 6884116702), the PR body, its three-path file list, the net diff against main (2797f81d, merge base fc283d6d), merged PR #33205 and its two records (6870963898, 6878859677) for the reading this PR extends, and the head's check-runs. Every statement about behaviour below is read from the tree. Nothing was built or run.

Check-runs on the head, read on 2026-11-14: 63 runs: 22 success, 11 skipped, 30 in progress, none failed. Check Changeset, PR-body guards, Governed Surface Queue Guard, Lint · PM dispatch-gates and Check PR Size are green. Every Test Core shard, Build Core, the three Type Check jobs and most Lint jobs had no conclusion yet. ⛔ This record does not stand in for them.

One must-fix (F1), two should-fix (F2, F3), two nits (N1, N2).

① Derived judgments

  1. The flow and hook publish doors stop refusing an unguarded ordering or arithmetic operand over an injected column the object does not declare. Right as declared, and a widening. The strip (validate-expressions.ts:2385) runs before every index, buildNullableFieldIndex (:570) then sees declared fields only, and the three flow sites and both hook forms reach checkNullGuards against that index.
  2. Nothing that published before is refused. Right, by reading.
    • Names: buildFieldIndex (:221) re-adds every stripped name through injectedColumnsFor, which reads the same plan the strip reads (injectedSystemColumnDefs), so no injected column becomes an unknown field. A column the registry injects outside that plan is not stripped and stays as it was.
    • Types and nullability: a missing type is dyn and a missing nullable entry is no verdict. Both only remove findings.
    • The other readers of the stripped objects: storedMetadataBodyReferencesOf (the injected lookups point at sys_user, sys_organization and sys_business_unit, none a stored-metadata-body table), unprovisionedInjectedColumnsFor (an absent anchor and an identical one get the same provenance, so the external advisory is unchanged), buildAttachedOnReadIndex, bulkConfirmTextIssues and actionCopyTemplateIssues (neither reads fields). The view and page early returns sit before the strip.
    • The differential: baseline, candidate and stored universe run the same function with the same write type, so findings on context objects still cancel.
  3. "The only verdicts that move are the flow and hook null-guard findings" and "type verdicts are the same before and after" (PR body, Measurement and 速读). Wrong. See F1.
  4. os build, os validate, os lint and MCP validate_expression are unchanged. Right. The build passes no write type, and judgeAuthoredSiteExpression already stripped (authored-site-expression.ts:235).
  5. No exported type or signature changes. Right. One statement inside runStackExpressionPasses and one docblock sentence.
  6. Metadata-protocol: added. Defensible. See N1.

F1, must-fix. The strip also empties the type index of the injected columns at every runtime door, so the hook, flow, action and object doors stop giving type verdicts they gave on main. These were true refusals, and the PR states that none moves.

  • Mechanism. buildFieldTypeIndex (:432) reads declared fields only; its docblock says an injected column is left dyn. On main the door's objects are served, so created_at and updated_at are in that index as datetime and queue as text (AUDIT_FIELD_DEFS, QUEUE_FIELD_DEF). check (:2716) hands the index to validateExpression, where datetime is typed timestamp (packages/formula/src/validate.ts:372) and date arithmetic is a hard error (typeSoundnessIssue, dateTextIssue). After the strip the index holds none of them, and firstTypeMismatch returns early on an all-dyn record.
  • Inputs, by reading.
  • Why it matters. Unlike the null-guard on created_at, these door verdicts were correct: the runtime holds a date as text and the arithmetic faults, so the flow run fails or the hook condition faults. os build never gave them only because its type index does not cover injected columns. A Studio author has no build step, so the door was the only gate that told them.
  • What is false as written. The PR body's Measurement ("type verdicts ... are the same before and after", "the only verdicts that move"), the 速读 risk line, and the dev report's summary. The changeset's Clause-② line and Now paragraph name the null-guard only. Record 6878859677 ① item 4 named this same effect for the extension door, so it was known for this strip.
  • Why the pins and the measurement miss it. The eight measured conditions hold a type mismatch on created_at that is an ordering, which a date tolerates. No case holds date arithmetic or a text column.
  • Basis. Read, not run. One case settles it: at the gate, a hook write with record.created_at + 1 > 0 over applyInjectedSystemColumns(account), on main and at the head.
  • Remedy, the dev's choice.

② Semver level

  • The changeset moves @objectstack/lint at minor. packages/lint is the only released package the diff moves, and the kind added takes at least minor. The level follows the declared kind. Check Changeset is green.
  • Clause-②: yes (widening) and Metadata-protocol: added stand line-initial on the PR body and the changeset body. The arm is right: nothing is newly refused (① item 2). No BREAKING banner or ADR-0087 marker is owed for a widening.
  • The bound the Clause-② line states is exceeded: the door also accepts conditions it refused for a type fault (F1). The line must name what the diff publishes.
  • skip-changeset is not used. Right: the diff publishes.

N1, nit. Metadata-protocol: added against AGENTS.md Post-Task Checklist 3. The checklist calls a newly accepted value added. The schema and os build accepted this value already; only the publish door changes. added with minor is the reading that follows the door author, and none with patch (a bug fix in a released package) is the reading that follows the authorable language. No changeset on main is a door-only widening of this kind, so there is no precedent either way, and the gates pass both. added is the wider declaration and costs nothing here: @objectstack/lint is in the fixed group, which other pending changesets already move at minor. Accepted as declared.

③ Boundary flags

F2, should-fix, escalated to the seat. The door newly accepts five columns the dev measured NULL on a stored row, and the follow-up will refuse them again.

F3, should-fix. No committed case reads the object as the registry serves it at the real door.

  • The new describe feeds the gate applyInjectedSystemColumns(account). The strip matches a column only when it is key for key the platform's definition (isInjectedColumnDefinition). If applySystemFields ever adds a key, the strip stops matching at the real door, the refusal returns, and these pins stay green.
  • PR fix(lint)!: os build and the object_extension publish door judge each validation rule an object extension adds by the object's own rule pass #33205 answered the same gap with real-door cases in packages/runtime. Here packages/runtime is outside the claimed surface, so the dev disclosed the deviation.
  • Remedy: one real-door case (a flow and a hook over a registered object, saveMetaItem then publishMetaItem), in this PR with a surface amendment or as a follow-up card. The seat's call.

N2, nit. The PARITY case on owner_id, created_by and owning_business_unit_id asserts the door equals the build, whatever the build says. It will stay green through #33435 in either direction, which is its stated purpose, and it pins no verdict of its own.

Implemented-by: claude/project-thread-7g7khi
Reviewed-by: session_01FEkQ5mswnWm181XgYcCUag

VERDICT: FAIL

…ps out of its nullable index, and keeps every served type

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
…dering over the stamped timestamps and refuse one over owner_id

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
…he five it still judges

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
@objectstack-fleet objectstack-fleet Bot changed the title fix(lint): the flow and hook publish doors judge an unguarded comparison over an injected system column as os build does fix(lint): the flow and hook publish doors stop judging created_at and updated_at nullable, the two columns the platform stamps on every row Nov 14, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag

Contract review

Served-tier: TIER_DEFAULT
Head-sha: ddd834f5bddc6cce244fc3d162c99d4ecdb76015
Local-runs: none

Round 2 on PR #33434 for card #33246, on the declaration face. Round 1 is record 6884221427 at 533eb60b (FAIL); the seat's rulings and the surface amendment are 6884227999; the dev's round-2 report is 6884768478. Read: the card body and its nine comments, the PR body and its two comments, the four-path file list, the net diff against main (7e61983e, merge base fc283d6d; no file the diff or this record cites moved between the two), and the head's check-runs. Every statement about behaviour below is read from the tree. Nothing was built or run.

Check-runs on the head, read on 2026-11-14: 70 runs: 57 success, 13 skipped, none failed, none pending. Every Test Core shard, Build Core, the Type Check jobs, Check Changeset, PR-body guards, Governed Surface Queue Guard, Lint · PM dispatch-gates and Check PR Size are green. The new runtime door file and the lint describe are inside Test Core.

One must-fix (M1), one should-fix (S1), three nits (N3, N4, N5).

Round-1 findings at this head:

① Derived judgments

  1. The type index is back on the served objects at every door but the extension door. Right. The strip statement (validate-expressions.ts:2429) is byte for byte main's (extensionWrite only); the diff adds a comment sentence there and nothing else. buildFieldTypeIndex(typedObjects) (:2446) therefore reads what it read on main, so the hook and action doors keep date arithmetic on record.created_at + 1 > 0, and the flow door keeps it on the bare created_at + 1 > 0. Pinned at the gate (the third LIT of the lint describe).
  2. Only the nullable index changes, and only for the two stamped columns. Right. buildNullableFieldIndex(typedObjects, { platformStamped }) (:2447) is the one call; platformStamped is options.runtimeWriteType !== undefined. The skip (isPlatformStampedColumn, :601) needs all of: the name is created_at or updated_at; platformProvisionsStorage(obj); the object's own plan holds the column (injectedSystemColumnDefs(obj)[fname]); the served definition is key for key the platform's (isInjectedColumnDefinition).
    • owner_id, created_by, updated_by, owning_business_unit_id, queue (and organization_id, see N3) stay in the index as on main.
    • id is in the ruling's list and not in the code's set. Right: injectedSystemColumnDefs never puts id in a field map, so there is no entry to skip.
  3. The skip cannot be spoofed into dropping a guard that is owed. Right, by reading each way an author could reach it:
    • A created_at declared with any key that differs (own label, a missing key, an extra key): the equality fails, the column stays judged. Pinned (CONTROL, "Opened").
    • A created_at declared key for key as the platform's, on an object whose plan holds the audit family: it is the platform's column. The save path strips it (stripServedSystemColumns, before the gate) and the registry injects it back; the audit stamp writes it by name. No guard is wrongly dropped.
    • The same declaration on an object that opts the audit family out (systemFields: false, systemFields.audit: false, managedBy: 'better-auth'): the plan has no entry, so injected === undefined and the column stays judged.
    • An external object: platformProvisionsStorage is false, the column stays judged. Pinned (CONTROL).
    • An array-shaped fields: each definition carries name, the key count differs, the column stays judged. The conservative direction.
    • A field two packages tie on is not in typedObjects at all, as on main.
  4. Nothing that published before is refused. Right. The skip only removes names from a set. checkNullGuards (:2647) and the flow's nullGuardBare (:3122) read that set, and a shorter set only removes findings; a start condition's proofs for the other fields are unchanged.
  5. The verdicts that move are the flow and hook null-guard findings on the two columns. Right for the site kinds: the index's other readers are a validation rule (:3730) and a field requiredWhen (:4075), both on an object write, where the written body arrives stripped (protocol-save.ts, the strip precedes the gate), and where flows and hooks are not walked. Context objects cancel in the differential, as before. Wrong for what moves inside the flow door: see M1.
  6. os build, os validate, os lint and MCP validate_expression are unchanged. Right. The build passes no write type, so its index is what it was. judgeAuthoredSiteExpression does pass a write type, and strips first with the same identity test, so the skip finds nothing there.
  7. No exported type or signature changes. Right. One private constant, one private function, one optional parameter on a private function, three more named imports from @objectstack/spec/data.
  8. The runtime file goes through the real door. Right. better-sqlite3 behind the real ObjectQL, the real sys_metadata objects, ObjectStackProtocolImplementation, the account registered through registerApp, each item saved as a draft and published through publishMetaItem. It asserts the row state (active / draft), the 422 INVALID_METADATA and the one expression-invalid issue naming record.owner_id, and that the registry's served definition and a stored row are what the lint pins assume. One case per site kind, as ruled.

M1, must-fix. At the flow door a record.-rooted date arithmetic on created_at / updated_at is now published. main refused it, ruling F1 names it, and the changeset says it is still refused.

  • Input. A record-triggered flow whose start condition, edge condition or decision branch is record.created_at + 1 > 0 or record.updated_at - record.created_at > duration('1h') (the two F1 spellings, with record.).
  • On main. Refused, by the null-guard alone: + and - are in FAULTING_BINARY_OPS (validate-null-guards.ts), record.created_at is in the served object's nullable set, and checkFlowNullGuards reports it. The type verdict does not see it: at a flattened site the record-root pass is for the text and boolean mismatch only ("The date verdicts stay the bare name's alone", packages/formula/src/cel-engine.ts:1361), and firstDateTextVerdict types no record root there (:1489).
  • At this head. The null-guard finding is gone and nothing replaces it, so the flow publishes. The runtime holds the column as its ISO text and the arithmetic faults, so the run fails (the same fault the hook door still refuses).
  • Ruling F1 (6884227999): those conditions "stay refused at the hook, flow and action doors exactly as on main". Held at the hook and the action. At the flow it holds for the bare spelling only.
  • What is false as written.
    • The changeset's Unchanged paragraph: "date arithmetic such as record.created_at + 1 > 0 is still refused". False at the flow door, for the spelling it quotes.
    • The changeset's and the PR body's Clause-② line: "no other verdict moves". And its "ordering or arithmetic operator": at a hook or an action the arithmetic is still refused by the type verdict, so the one place the arithmetic acceptance is real is this one.
    • The PR body's Acceptance note and the report's out-of-scope note ("not type-checked at the door on main or here ... noted, not changed"). True about the type verdict, and it leaves out that the door's verdict on the input moves from refused to published.
  • Why the pins miss it. The flow rows of the F1 pin use the bare spelling; the record. spelling is pinned at the hook and the action only. The Measurement table's arithmetic row lists hook and action.
  • Basis. Read, not run. One case settles it: at the gate, the describe's flowAt('start', 'record.created_at + 1 > 0') over the served account, on main and at the head.
  • Remedy, the dev's choice within the ruling.
    • Keep the refusal: the skip applies to an ordering operand only, so an arithmetic operand on the two columns keeps its null-guard finding at every site. Nothing true is lost: arithmetic on a date column is refused at the hook and the action already. Pin the record. spelling at a flow slot, red against this head.
    • Or the seat rules the loss accepted: the changeset and the PR body then say that a flow's record.-rooted date arithmetic on the two columns is no longer refused, and a card carries the flattened record-root date verdict in packages/formula (a narrowing, outside this surface).

② Semver level

  • The changeset moves @objectstack/lint at minor, the only released package the diff moves (packages/runtime gains a test file only). The level follows the declared kind added. Check Changeset is green.
  • Clause-②: yes (widening) and Metadata-protocol: added stand line-initial on the PR body and the changeset body. The arm is right: nothing is newly refused (① item 4). No BREAKING banner or ADR-0087 marker is owed.
  • The bound the Clause-② line states is not what the diff publishes at the flow door (M1). The line and the Unchanged paragraph must say what is true.
  • The door/build note is true as far as it goes: on the five named columns the door refuses an unguarded ordering and the build judges none, and lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435 is named. It is one column short (N3).
  • Metadata-protocol: added: as ruled under N1; the F2 change does not alter it.
  • skip-changeset is not used. Right: the diff publishes.

③ Boundary flags

  • Report 6884768478 open_questions: empty. Round 1's question was answered in 6884116702 (option B, lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435).
  • Out-of-scope note (a flow's record.created_at + 1 > 0 is not type-checked): not accepted as noted. It is M1.
  • Deviation: the PR body and title handed to the seat. The body on the PR is the round-2 body and carries both declaration lines. Not a contract matter.
  • Deviation: the two stamped names spelled in lint. Accepted. Lint may not import @objectstack/objectql; the docblock names sys_stamp_audit_insert and PLATFORM_PROVISIONED_COLUMNS, both read on main and both agree; the runtime file pins the stored row against the real engine.
  • File surface: four paths, all inside the claim as amended by 6884227999. No breach. content/docs/deployment/validating-metadata.mdx is not edited; the body says why.
  • Gate not measured by the dev (check:dual-build-cjs-loads): CI's. No check-run on this head failed; which job carries it was not traced.

S1, should-fix, escalated to the seat. "Never null" holds for a stored row; a beforeInsert hook ordered ahead of the stamp reads null.

N3, nit. organization_id is a sixth injected column the door still judges nullable (required: false, no default) and the build does not judge. The changeset's "On those five the door and os build still differ" is true of the five and leaves this one out; its own definition says it is never NULL. For the seat: #33435's reach is six columns, not five.

N4, nit. The PR body and the report count seven cases in the lint describe (and "1 of 7", "3 of 7" red under ablation). The describe at this head holds six it cases. The runtime count (five) is right.

N5, nit. The CONTROL case's title says no stamp is behind an author's own created_at. The stamp writes the column by name whatever declares it; the column stays judged there because the build judges it, which is what the assertion checks. The changeset file name (door-reads-objects-as-authored) is round 1's mechanism.

Implemented-by: claude/project-thread-7g7khi
Reviewed-by: session_01FEkQ5mswnWm181XgYcCUag

VERDICT: FAIL

…tamped timestamps, and not on a beforeInsert hook

The null-guard skip at a runtime publish door now applies to an operand
of `<`, `<=`, `>` or `>=` only. Arithmetic over created_at / updated_at
keeps its verdict, so a flow's `record.created_at + 1 > 0` stays refused
as on main. A hook whose events include beforeInsert can run before the
platform's stamp, so it keeps the verdict too. The changeset is renamed
for the mechanism and names the six injected columns still judged.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
…nd the stamped-column index locals

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 10f6d63a53a6d58a88bc5028795ba6a92e89075d
Local-runs: none

Round 3 on PR #33434 for card #33246, on the declaration face. Round 1 is record 6884221427 at 533eb60b (FAIL), round 2 is record 6884875891 at ddd834f5 (FAIL). The seat's rulings are 6884227999 and 6884884180; the dev's round-3 report is 6885448636. Read: the card body and its eleven comments, the PR body and its comments, the five-path file list, the net diff against main (merge base fc283d6d), the round delta from ddd834f5, and the head's check-runs. Every statement about behaviour below is read from the tree. Nothing was built or run.

Check-runs on the head, read on 2026-11-14: 69 runs in the latest attempt: 55 success, 13 skipped, 1 in progress, none failed.

  • The one in progress is Test Core (4/8) (job 132617058771), the seat's re-run. It had not finished when this record was written, so that shard has no verdict yet on this head.
  • Its first attempt (job 132608010780) failed on one case in @objectstack/plugin-approvals ("GET renders the confirm page for a live token ...", 5388 ms against a 5000 ms limit). The diff touches no file in that package, so that failure is not this PR's.
  • Every other Test Core shard, Build Core, the Type Check jobs, Check Changeset, PR-body guards, Governed Surface Queue Guard, Lint · PM dispatch-gates and Check PR Size are green.

One must-fix (M2), one should-fix (S2), one nit (N6). The verdict is FAIL on M2 alone; it does not rest on the shard still running.

Round-2 findings at this head:

  • M1 (must-fix): resolved. The skip drops a finding only when its operator is one of the four ordering operators (STAMPED_COMPARISON_OPERATORS). An arithmetic operand keeps its finding, so a flow's record.created_at + 1 > 0 and record.updated_at - record.created_at > duration('1h') are refused as on main. Pinned at a flow start condition.
  • S1 (should-fix): resolved. A hook whose events include beforeInsert passes stampedComparisons: false on both the string and the list object path, whatever its priority and whatever other events it lists. Pinned at the gate and at the real door.
  • N3 (nit): resolved. The changeset names six columns, organization_id included. The eight injected definitions on main are the two stamped ones and these six.
  • N4 (nit): resolved. The lint describe holds eight cases and the runtime file six, as the PR body and the report now say.
  • N5 (nit): resolved. The CONTROL title no longer says there is no stamp behind an author's column. The changeset file is 33246-door-skips-stamped-timestamps-in-comparisons.md; the old name is not in the file list.

① Derived judgments

  1. Only a null-guard finding with an ordering operator can be dropped. Right. findUnguardedNullableOperands on main reports for nine operators only (the four ordering ones and + - * / %, with unary minus reported as -). It keys each finding on operand and operator, so an ordering finding and an arithmetic finding on the same column are separate entries and dropping the first leaves the second.
    • Equality, !=, in, a function argument, a ternary branch and a has() call produce no finding on main, so there is nothing for the skip to remove there. Ruling 6884884180 said "ordering and equality"; ordering alone gives the same result.
    • record.created_at + 1 > 0: the one finding is on +. The > has the sum as its operand, which is no field. Kept.
    • A second operand of the same comparison that is not a stamped column (record.created_at > record.amount) keeps its own finding.
  2. Bare and record.-rooted spellings are treated alike. Right. The flow's bare-name set is still built from the unchanged nullable index, so a bare created_at > ... yields a finding with field created_at and is dropped like the record. one; the bare created_at + 1 > 0 keeps its + finding and its type verdict.
  3. buildNullableFieldIndex is main's again. Right. The diff adds nothing to it; the type index and the strip statement are also main's. The hook and action doors keep date arithmetic on the two columns.
  4. The sites the skip reaches are the flow's three slots and the hook condition. Right. checkNullGuards has two other callers, the validation rule and the field requiredWhen. They are walked on an object write, where the written body arrives stripped, and on other writes they sit on context objects, which the baseline and the candidate pass hold alike. No action site calls the null-guard.
  5. os build, os validate, os lint and validate_expression are unchanged. Right. The stamped index is empty unless a write type is passed; the extension door and judgeAuthoredSiteExpression strip first, so the index finds no injected definition there.
  6. A flow on record-before-create needs no exception for a record. read. Right. The flow's hook is registered with no priority (record-change-trigger.ts), which the engine reads as 100 (engine-hooks-and-functions.ts, lower first), after the stamp at 10.
  7. Nothing that published before is refused. Right. The change only removes findings.
  8. The validate-expressions / validate-security-posture 也有同形的 spec 不声明键的 ?? 别名读法(#5009 建议 3 的核对结果) #5017 meta-test table change is forced and minimal. Right. hook.events is a new read off a tabled receiver and events is a declared HookSchema key. platformStampedIndex and stamped are a Map and a Set local, added to the plumbing list in the same form as its existing entries (nullGuardBare, attachedOnReadIndex). No expected key is removed and no other row moves.
  9. The pins say what they assert. Right. Lint: ordering accepted at five writes; five columns refused; type verdict at hook, flow bare and action; M1 at a flow start; S1 on two event lists and two object shapes, with afterInsert clean; the two controls. Runtime: the real door, with the 422, the one issue and the row state.
  10. "No other verdict moves" holds only for a record. or bare read on a write event. Wrong for a previous. read: see M2. Wrong for a read event: see S2.

M2, must-fix. An unguarded ordering over previous.created_at or previous.updated_at now publishes on a site with a create leg. main refused it, with the guard that fixes it, and the runtime faults on every create.

  • Input. record.updated_at > previous.updated_at, or previous.created_at > timestamp(...), in either of:
    • a hook whose events include afterInsert and not beforeInsert (for example ['afterInsert', 'afterUpdate']);
    • a record-triggered flow on record-after-create, record-after-write, record-before-create or record-before-write, at the start, an edge or a decision branch.
  • On main. Refused. The gate's default roots are record and previous (DEFAULT_RECORD_ROOTS), the served object's nullable set holds both columns, and the finding names previous.updated_at. The message carries the clause written for this case (PREVIOUS_GUARD_CLAUSE): on an insert previous is itself null, guard with previous != null && previous.updated_at != null.
  • At this head. isStampedComparisonFinding tests finding.field and finding.operator only. The field of previous.updated_at is updated_at, so the finding is dropped and the item publishes.
  • At runtime. On an insert event previous is bound to null (pickPreviousPayload in hook-wrappers.ts; the flow's create leg likewise). A column read off it faults. A hook condition that faults aborts the write (hook 的 condition 求不出值时:全局 fail loud —— 抛错并中断该次操作(方案 B 已拍板;Blocked-by #4770) #4775), so every create on the object is refused. A flow's run fails at the condition on every create.
  • Why it is this PR's. The skip's stated warrant, in the isStampedComparisonFinding docblock and in the changeset's Now paragraph, is that a stored row never holds null in the column. previous on a create is not a stored row. Ruling S1 kept main's verdict where a read can come before the stamp; this is the same case on the other root.
  • Why the pins miss it. Every pinned condition reads record.. The flow pins use record-after-update.
  • Basis. Read, not run. One case settles it: at the gate, the describe's hookOn('crm_account', 'record.updated_at > previous.updated_at') with events: ['afterInsert', 'afterUpdate'] over the served account, on main and at the head.
  • Remedy, the dev's choice. The simplest is to drop a finding only when its operand is not previous.-rooted (finding.operand), so every previous. read keeps main's verdict. Narrower: keep it only where the site has a create leg. Either way, pin one hook and one flow case, red against this head.

② Semver level

  • The changeset moves @objectstack/lint at minor, the only released package the diff moves (packages/runtime gains a test file only). Check Changeset is green.
  • Clause-②: yes (widening) and Metadata-protocol: added stand line-initial on the PR body and the changeset body. The arm is right: nothing is newly refused. No BREAKING banner is owed.
  • The Clause-② line names the accepted set as the two columns under an ordering operator "in a record-triggered flow or in a hook that does not run on beforeInsert". That is what the diff publishes, M2 and S2 included, so the line is not false; it is wider than the warrant given for it.
  • The changeset's Now paragraph ("the platform writes both on every stored row before any later hook reads it") is false for a previous. read on a create and for a read-event hook. It must say what is true once M2 is fixed.
  • The Unchanged list is true as written: arithmetic at every door in the spellings it names, the author-declared and external column, the six columns, the door and build difference with lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435 named, the extension door.
  • skip-changeset is not used. Right: the diff publishes.

③ Boundary flags

  • Report 6885448636 open_questions: empty.
  • Out-of-scope note, organization_id carried by lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435: accepted. The changeset names it.
  • Out-of-scope note, a flow's record.created_at + 1 > 0 has no type verdict: accepted as noted. The null-guard refuses it and the M1 pin holds it.
  • Deviation, packages/lint/src/validate-expressions.test.ts outside the ruled surface: accepted (① item 8). The alternative the dev names, reading hook.events through an untabled alias, would have hidden the read from the guard.
  • Deviation, flow sites not excepted for record-before-create: accepted for a record. read (① item 6). It does not cover a previous. read (M2).
  • File surface: five paths: the four of ruling 6884884180 with the changeset renamed, plus the meta-test file above. No other breach.

S2, should-fix, escalated to the seat. A hook on a read event with the same ordering now publishes; it rejects every read.

  • A hook with events: ['beforeFind'] (or afterFind) and record.created_at > timestamp(...). On main the door refused it through the null-guard. At this head it publishes.
  • A read event carries no record: pickRecordPayload returns the query envelope, record.created_at is no key of it, the condition faults, and since hook 的 condition 求不出值时:全局 fail loud —— 抛错并中断该次操作(方案 B 已拍板;Blocked-by #4770) #4775 the read is rejected.
  • main's refusal was incidental. The door has no gate on a record. condition for a read event, so the same hook over a required field publishes on main, and main's != null remedy would not have fixed this one. The build accepts it on both.
  • Read, not run. Narrow, and not this card's gap to close in full. The seat's call: pass stampedComparisons: false for a hook whose events include a read event as well, or carry the missing read-event gate on a card.

N6, nit. Two texts still describe round 2's mechanism. The comment above the lint describe says the door's null-guard gate "does not judge" the two columns, "as os build does not"; the door still judges them under arithmetic and on a beforeInsert hook. The PR title says the doors "stop judging created_at and updated_at nullable". The title is the seat's to patch.

Implemented-by: claude/project-thread-7g7khi
Reviewed-by: session_01FEkQ5mswnWm181XgYcCUag

VERDICT: FAIL

@objectstack-fleet objectstack-fleet Bot changed the title fix(lint): the flow and hook publish doors stop judging created_at and updated_at nullable, the two columns the platform stamps on every row fix(lint): the flow and hook publish doors stop requiring a null guard on the current row's created_at and updated_at in an ordering comparison Nov 14, 2026
…mp, and only on a hook whose every event reads a stamped row

An ordering over previous.created_at / previous.updated_at keeps its
verdict: an insert binds previous to null. A hook on beforeFind or
afterFind carries no record, so it keeps the verdict too; the skip now
applies only when every event is afterInsert, beforeUpdate, afterUpdate,
beforeDelete or afterDelete. The changeset and the test docblocks state
this mechanism.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mnBkyQ4d2mXNVg3Fd
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag

Contract review

Served-tier: TIER_DEFAULT
Head-sha: df63888de1f086750170942ae50e2af2b3063756
Local-runs: none

Round 4 on PR #33434 for card #33246, on the declaration face. Rounds 1 to 3 were FAIL: records 6884221427 (533eb60b), 6884875891 (ddd834f5) and 6885550922 (10f6d63a). The seat's rulings are 6884227999, 6884884180 and 6885555312; the dev's round-4 report is 6886033779. Read: the card body and its thirteen comments, the PR body and its comments, the five-path file list, the net diff against main (merge base fc283d6d), the round delta from 10f6d63a, and the head's check-runs. Every statement about behaviour below is read from the tree on main and at the head. Nothing was built or run.

Check-runs on the head, read on 2026-11-14: 70 runs in the latest listing: 56 success, 13 skipped, 1 in progress, none failed.

  • The one in progress is a second Check Changeset run (job 132630037913), started by the PR-body edit. The first Check Changeset run on this same head (job 132619981160) is success, and the changeset file has not changed since.
  • Build Core, all eight Test Core shards, the Type Check jobs, Lint & Repo Gates, Lint · PM dispatch-gates, PR-body guards (both runs), Governed Surface Queue Guard and Check PR Size are green.

No must-fix, no should-fix, one nit (N7, no change owed). The verdict is PASS.

Round-3 findings at this head:

  • M2 (must-fix): resolved. isStampedComparisonFinding now also requires finding.operand to equal the field name (the flow's bare spelling) or record. plus the field name. The null-guard pass on main resolves an operand against two roots only, record and previous, and the gate passes no other root, so the one remaining spelling, previous.created_at / previous.updated_at, keeps its finding at every site. The message is built from the kept finding, so PREVIOUS_GUARD_CLAUSE is in it. Pinned on an afterInsert hook and at a record-after-create flow start: exactly one finding, on previous.updated_at, naming previous != null && previous.updated_at != null.
  • S2 (should-fix): resolved. The hook loop passes stampedComparisons: hookReadsStampedRow(hook.events) on both the string and the list object path. It is true only for a non-empty array whose every member is afterInsert, beforeUpdate, afterUpdate, beforeDelete or afterDelete. HookEvent on main has eight members; the three left out are beforeInsert, beforeFind and afterFind. A hook with no events, an empty list or an unknown event gets no skip. Pinned on ['beforeFind'], ['afterFind'] and ['afterFind', 'afterUpdate']. The door's general read-event gap is reported to the seat (③).
  • N6 (nit): resolved. The comment above the lint describe, the runtime file's docblock, the isStampedComparisonFinding and hookReadsStampedRow docblocks and the changeset's Now paragraph all state the round-4 mechanism. The PR title no longer says the doors "stop judging" the columns.

① Derived judgments

  1. Only a current-row operand under an ordering operator loses its finding. Right. Three tests must all hold: the field is in the object's stamped set, the operator is one of the four ordering operators, and the operand is bare or record.-rooted. An arithmetic finding (+ - * / %, unary minus), a previous. finding and a finding on any other column are pushed as on main. A record.?created_at read resolves to the operand record.created_at on main and is treated the same.
  2. The stamped set is the two columns, as the platform injects them, on platform-provisioned storage. Right. isPlatformStampedColumn requires the name, platformProvisionsStorage(obj), and isInjectedColumnDefinition against the object's own injection plan. An author-declared created_at and an external object's column stay judged (pinned).
  3. The index is empty unless a write type is passed. Right. os build, os validate and os lint pass none. The object_extension door and judgeAuthoredSiteExpression read stripped objects, so no injected definition reaches the index there. buildNullableFieldIndex, the type index and the strip statement are main's.
  4. The five hook events each read a stamped current row on the engine. Right, read in hook-wrappers.ts, plugin.ts, engine-insert.ts, engine-update.ts and engine-delete-and-aggregate.ts on main:
    • afterInsert: the record is the insert payload made total. sys_stamp_audit_insert (beforeInsert, priority 10, registered in code so skipAutomations does not skip it) has written both columns on that same per-row payload: now, or ?? now under preserveAudit or a seed replay, so never null. The static read-only strip spares a hook-written key.
    • beforeUpdate / afterUpdate: the record is the prior row overlaid with the payload. A by-id update reads the prior row unconditionally and answers 404 before any hook if there is none; a predicate update dispatches per matched row with that row's prior state. The injected definitions are readonly: true, and the engine withholds a caller-supplied read-only value from beforeUpdate for every caller that is not a system context, so the overlay cannot put null over the stored value. A beforeUpdate hook ordered ahead of the update stamp (priority below 10) still reads the stored updated_at.
    • beforeDelete / afterDelete: the record is the bound pre-image; a by-id delete gates on it, a predicate delete dispatches per row.
    • driver-sql creates both columns with a now default on every table it provisions, so a row written past the engine holds a value too.
  5. A prior row not in hand does not make the update skip publish something main protected. Right. This is the dev's second out-of-scope note, checked:
    • On the engine, a metadata-bound hook is not dispatched on an update without a prior row: the by-id path 404s first, the predicate path is per row, and the one whole-operation dispatch (dispatchUnscopedMultiWriteHooks) reaches only registrations carrying a flag no metadata binding can set (its own comment). What is left is a hand-built context.
    • There pickRecordPayload returns the bare payload, not made total, so record.created_at is a missing key and faults with No such key. The guard main prescribes, record.created_at != null, reads the same missing key and faults the same way (hook-wrappers.ts and record-change-trigger.ts both document that fault). main's refusal therefore prevented nothing in that case, and a required declared field, which main publishes unguarded, has the same exposure. No verdict that protected an author is lost.
  6. Every record-triggered flow gets the skip, and its current row is stamped. Right. The flow null-guard runs only when the trigger kind is record_change (a time-relative or scheduled flow has no null-guard pass on main or here). triggerTypeToHookEvents maps those triggers to the six write events:
    • after-create / after-update / after-write / before-update / before-write (update leg) / both delete triggers: the trigger record is prior row, payload and after-row overlaid, each holding the stamped columns.
    • before-create and the create leg of before-write: the flow's hook is registered with no priority, which the engine reads as 100 and sorts after the stamp at 10, so the payload it reads is already stamped. Unlike an authored hook, a flow cannot set a priority.
    • previous is a separate binding (null on a create leg); M2 keeps its finding.
  7. Validation-rule and requiredWhen sites move no verdict. Right. They call checkNullGuards with the default, but an object write's body reaches the gate without injected columns (protocol-meta-type-schema.ts strips an object item), and on any other write those sites sit on context objects that the baseline and candidate passes hold alike.
  8. Nothing that published before is refused. Right. The change only removes findings.
  9. The validate-expressions / validate-security-posture 也有同形的 spec 不声明键的 ?? 别名读法(#5009 建议 3 的核对结果) #5017 table change is forced and minimal. Right. hook.events is a declared HookSchema key read off a tabled receiver; platformStampedIndex, stamped and hookEvents are a Map, a Set and an array handed whole. No expected key is removed.
  10. The pins say what they assert. Right. Lint, ten cases: served shape; ordering accepted at five writes and at the build; five columns refused; type verdict at hook, bare flow and action; M1 at a flow start; S1 on two event lists and two object shapes with afterInsert clean; M2 on a hook and a create-leg flow; S2 on three event lists; the two controls. The base hook fixture uses beforeUpdate, so the accept pins exercise a listed event. Runtime, six cases at the real door, unchanged apart from the docblock.

N7, nit, no change owed. The warrant "a read of the current row after the stamp is never null" has one exception outside any transport caller: an update made in a system context (the read-only hide pass is skipped for isSystem) whose own payload carries created_at: null. The overlay then reads null, and the write would also store it. That is server code nulling an audit column, not an authoring case the door's verdict was protecting, so it does not move the judgment. Read, not run.

② Semver level

  • The changeset moves @objectstack/lint at minor, the only released package the diff moves (packages/runtime gains a test file only). The first Check Changeset run on this head is green.
  • Clause-②: yes (widening) and Metadata-protocol: added stand line-initial on the PR body and the changeset. The arm is right: findings are only removed. No BREAKING banner is owed, and skip-changeset is rightly not used.
  • The Clause-② line is true. It names the accepted set as the two columns, as the registry injects them on platform-provisioned storage, read off the current row (bare in a flow, or record.), under the four ordering operators, in a record-triggered flow or a hook whose every event is one of the five. That is exactly what the three tests and hookReadsStampedRow publish (① 1, 2, 4, 6). "No other verdict moves" holds (① 3, 7, 8).
  • The Now warrant is true for every write a caller can make (① 4, 6); the one exception is N7.
  • The Unchanged list is true as written: the previous. read with its full guard; a beforeInsert or read-event hook; arithmetic at every door in the spellings named; the author-declared and external column; the six columns still judged nullable, organization_id included; the door and build difference on those six and on a beforeInsert or read-event hook, with lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435 named; the object_extension door.
  • "No exported type or signature changes": right. The additions are module-private; NullGuardFinding is a type import.

③ Boundary flags

Implemented-by: claude/project-thread-7g7khi
Reviewed-by: session_01FEkQ5mswnWm181XgYcCUag

VERDICT: PASS

Seat note: the read-event gate card the record escalates is #33529 (p3, spec lane), filed before this record was posted.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag

ACCEPT · PR #33434 (#33246) · head 4593c1d0df206e3833da00e4278177b6f2cf634a · 2026-11-15T04:09Z

席位核对

  • 形态: 5 files (read from the PR's file list): packages/lint/src/validate-expressions.ts (the flow/hook door's null-guard index: created_at / updated_at as the registry injects them, on a provisioned object, read off the current row under < <= > >=, in a record-triggered flow or a hook whose every event runs after the stamp), two new test files (lint flow null guards; metadata-protocol flow/hook injected-column null guard), one edited lint test, one changeset (@objectstack/lint minor). +554 −4. No governed path, under 3000 lines: Tier S, seat lands.
  • 前提实测: head 4593c1d0 is a merge of origin/main 1cf2a5a9 into round 4's df63888d (no rebase, clean). The seat diffed the net change against main at both heads, hunk headers aside: identical. So round 4's PASS stands on this head. Dev reran lint (8994/8994, typecheck 0) and metadata-protocol (22877 passed, 43 skipped) at 4593c1d0.
  • 门禁 check-runs: latest attempt on this head 66 runs: 55 success, 11 skipped, 0 failed.
  • 契约复审: CONTRACT_REVIEW_TIER (declaration face) PASS, record 6886130852 on df63888d (round 4; rounds 1–3 FAIL 6884221427, 6884875891, 6885550922, all resolved). The net diff is unchanged on this head. Isolated reviewer; Ruling-ref 「你有 fable ,车道契约复审可以自己做」 2026-11-07. One nit (N7, no change owed).
  • 接受的偏差: N7: an update in a system context whose own payload nulls created_at reads null after the stamp. That is server code nulling an audit column, not an authoring case; no change owed. Clause-②: yes (widening) / Metadata-protocol: added on the PR body and changeset, as reviewed.
  • 范围外去向: organization_id and the other injected columns → lint: an unguarded condition on owner_id, created_by, updated_by, owning_business_unit_id or queue is accepted though the column can be NULL on a stored row #33435 (p3, spec lane, queued). A record. read in a read-event hook condition (beforeFind / afterFind) → hook publish door: a record.* read in a beforeFind / afterFind hook condition is not refused, though a read event carries no record and the engine rejects the read at run time #33529 (p3, spec lane, queued), the card review 6886130852 asked the seat to file. An update whose prior row is not in hand, and a flow record.created_at + 1 > 0 type verdict: no carrier, accepted in review.
  • 落地条款: ready + auto-merge now under the maintainer's standing order 「按照 pm-dispatch 规则复核过的都授权」 (2026-10-25T11:35Z) and 「你应该使用 pm-dispatch 技能审核和落地pr」 (2026-11-07T16:59Z). K = 2 commits on main past this head's affected-set base 4c32b969 (< 15, no further merge of main needed). PR object_extension door: the gate's served snapshot carries a sibling package's extension field with no priority, so the door's formula-cycle verdict differs from os build on ties and outranked entries #33494's card thread shares validate-expressions.ts in another region and merges main after this lands.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 04:10
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit a674877 Nov 15, 2026
67 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-7g7khi branch November 15, 2026 05:07
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…ormula cycle an object extension adds (objectstack-ai#33442)

<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XH2axL4s7aEsVfT4UcgVK1P)_

Fixes objectstack-ai#33153

Clause-②: no (narrowing) — `os build`, `os validate`, `os lint` and the
runtime `object_extension` publish door (Studio, `PUT
/api/v1/meta/object_extension/TARGET`, the MCP and AI authoring doors)
now refuse one shape an object extension could carry before: a `formula`
field an extension adds that sits on a cycle of formulas (it reads
itself, two added formulas read each other, or the cycle closes through
a formula the target declares). No exported type or signature changes.
Measured first-party exposure: 0 `objectExtensions` entries add a
`formula` field (`examples/app-showcase` one entry, a `select`, a `url`
and a `number` field; `packages/plugins/plugin-auth` one, a `secret`
field; HotCRM `origin/main` ac4dd3d has no `objectExtensions` in code),
so nothing first-party is newly refused.
Metadata-protocol: narrowed
Skills-docs: none owed — this PR edits
`content/docs/deployment/validating-metadata.mdx` (the object extension
paragraph names the cycle check); `skills/objectstack-formula` and
`skills/objectstack-data` teach formula fields and
`defineObjectExtension({ extend, fields })` without saying an extension
is exempt from the cycle check, so the build and the door now give the
verdict the object's own formulas already get.

Precedent followed: objectstack-ai#33216/objectstack-ai#33217 (PR objectstack-ai#33398), which widened the same
extension walk and declared the same `no (narrowing)` / `narrowed` pair.

## 维护者速读

- **改了什么**:对象扩展(`objectExtensions` / Studio 发布的
`object_extension`)新增的公式字段,如果引用自己,或两个互相引用,或经由对象自身声明的公式绕回来,现在在 `os build`
和运行时发布口都会被拒(规则 id `expression-invalid`,和对象自身公式循环同一句提示),位置为 `object '对象'
· objectExtensions[0] · field '字段' expression`。
-
**为什么改**:引擎按依赖顺序计算公式,循环里的公式永远不会被计算、每行都读到空值。此前循环检查只看对象自身声明的公式,扩展加的循环在两个入口都放行,要到读记录时才暴露。
- **风险与回滚**:收窄;第一方实测 0
处扩展新增公式字段,无既有元数据被新拒。对象自身公式循环的结论与位置不变;对象声明的公式与扩展公式构成的循环,声明那一侧仍报在对象上、只报一次;发布口不会把目标对象自身已有的循环算到扩展这次写入上。草稿保存不受影响。回滚即
revert。
- **先看**:`packages/lint/src/validate-expressions.ts`(扩展遍历末尾新增的一次
`formulaCycleIssues`
调用)、`packages/lint/src/formula-cycle-issues.ts`(`extensionFormulaLoci` 与
map 形式的
`report`)、`packages/lint/src/runtime-gate.object-formula-cycle.test.ts`。
- **两分钟验证**:`pnpm --filter @objectstack/lint exec vitest run
src/runtime-gate.object-formula-cycle.test.ts`,预期 16
条全过:扩展自引用、互相引用、经声明公式绕回的循环在 build
与发布口都被拒且位置一致,链式公式和读对象公式的扩展公式通过;发布口按写入条目自身的定义判定同名字段(含与其他包同优先级或被更高优先级覆盖的情形,build
此时放行,后续卡 objectstack-ai#33494)。
- **需要你做的**:无,席位落地。

## What changes

**`packages/lint/src/validate-expressions.ts` (the extension walk only;
the gate-setup region objectstack-ai#33246 edits is untouched).** After each target's
entries are judged, the walk runs the formula-cycle pass (objectstack-ai#33100's
`formulaCycleIssues`) over the `fieldDefs` it already builds for that
target: the target as served (its declared fields with every kept
entry's fields folded in through `objectsAsServed`, a tie between two
packages left out), its declared fields and injected columns behind it;
for a target the stack does not declare, the entries' own fields. No
second fold. Each cycle member an entry adds gets a finding located at
that entry, and in the build a member the authored target declares is
left to the object walk, so a cycle closing through a declared formula
keeps that member's location at the object and names it once. On the
door's one pass the object walk does not run and the written entry is
folded over the target as served before the write, so every name the
entry adds is served from the entry's own record and none is left out, a
name the target already serves included (review round 1).

**`packages/lint/src/formula-cycle-issues.ts`.** `formulaCycleIssues`'
`report` also takes a map from field name to location. The new
`extensionFormulaLoci(target, entries, left)` builds it: each name an
entry adds, located `object 'T' · objectExtensions[i] · field 'F'
expression` (the location the field-formula pass gives the same field),
a name two entries add located at the later entry in fold order (the
definition the registry serves), the caller's `left` names left out (the
authored target's declared names in the build, none at the door). Kept
in this module so the walk gains no new receiver for the objectstack-ai#5017 key scan.

**Door.** `validateStackExpressions` is already on the
`object_extension` door (objectstack-ai#33072), so the roster and its pins do not
move. The door's one pass reads only the written entry, and only names
the entry adds are reported members there, so a cycle the target or a
sibling package already carries, and a formula that only reads a cycle,
are not charged to the extension write.


**`packages/spec/src/migrations/entries/semantic/18.object-extension-formula-cycle-refused.ts`**:
the ADR-0087 D3 entry, its one exception stated (in `os build` on a
declared target, a field two packages add at the priority that decides
it is not judged; the door judges the written entry's own definition,
see objectstack-ai#33494). No D2 conversion: which read breaks the cycle is a fact
only the author holds.

**`content/docs/deployment/validating-metadata.mdx`**: the object
extension paragraph names the cycle check, its location in the build,
and the door's reading of a name the target already serves.

**`.changeset/33153-extension-formula-cycle.md`**: `@objectstack/lint`
minor and `@objectstack/spec` minor, both declaration lines, a BREAKING
banner (Before / Now / Unchanged / Fix) and `adr-0087: registered
object-extension-formula-cycle-refused`.

## Why

The engine computes an object's formulas, an extension's included, in
dependency order; a formula on a cycle has no order, is never evaluated
and reads null on every row. The cycle check named the object's declared
formulas only, so the card's probe (an extension adding `a__c =
record.a__c`, or `a__c` and `b__c` reading each other) got 0 findings at
both the build and the door.

## Tests

1. **`packages/lint/src/runtime-gate.object-formula-cycle.test.ts`**,
new top-level describe `objectstack-ai#33153` (11 cases) in the objectstack-ai#33100 harness file,
at the real gate (`runRuntimeAuthoringRules` with `type:
'object_extension'`) and the build (`runAuthoringRules('build', …)`):
- LIT: an extension formula reading itself is refused at the door at the
entry, in the engine's sentence (`formulaCycleMessage`); the build's
finding equals the door's (where and message).
- LIT: two extension formulas reading each other are refused on each,
door and build equal.
- LIT: a cycle closing through a declared formula: the door refuses the
added member at the entry; the build names the declared member at the
object (its objectstack-ai#33100 location) and the added member at the entry, once
each.
- A cycle across two packages' extensions is named at each entry
(`packages[j].manifest.objectExtensions[0]`).
- LIT (review round 1, shape a): an extension re-declaring a field the
target declares as a formula reading itself is refused at the door at
the entry; the build names it once, at the object.
- LIT (review round 1, shape b): an entry adding, as a self-reading
formula, a name a sibling package's published extension already serves
is refused at the door at the entry; the build over both packages
(sibling priority 100, written entry 300) refuses it at the later entry.
- Review round 2: the door judges the written entry's own definition
whatever a sibling package's priority. A tie (both 200) and an outranked
entry (sibling 300, written 200) are each refused at the door at the
entry, while the build lets both through (it drops the tied name on a
declared target and serves the outranking sibling's definition). The pin
names follow-up objectstack-ai#33494, which makes the door read the build's winner.
- A sibling package's stored cycle, and an extension formula that only
reads it, are not charged to the extension write.
- An extension of an object the door does not carry is judged on its own
fields.
- The target's own stored cycle is not the extension write's to answer
for (the differential).
- CONTROL: an extension formula over a declared formula, and a chain
inside the extension, are clean at both.
2.
**`packages/runtime/src/domains/meta-object-extension-item.test.ts`**,
new describe `[objectstack-ai#33153]` (3 cases) through the real `saveMetaItem` +
`publishMetaItem`: a self-reading formula and a two-formula cycle each
get 422 `INVALID_METADATA` with the build's rule id, `where` and `path`
on each member, the field is not served and the row stays a draft; a
chain publishes and is served.

**Red at base:** the round-0 head tests over the base sources (`git
restore --source=fc283d6d` of the two lint files): 5 of 12 red (the file
then held 12 cases), every LIT plus the sibling and undeclared-target
cases; controls and the differential green. Restored with `git checkout
HEAD --`, `git status --porcelain` empty.

**Ablations** (one-shot, through `node scripts/ablation-replace.mjs` on
the committed head; the tool's restore verdict each time: blob equals
HEAD, `git diff HEAD` empty):

- A1, the report scoping in `formulaCycleIssues` (`!report.has(field)`
dropped, so every served member is reported): 5 of 12 red (round 0),
including the differential case (the target's own cycle charged to the
extension write) and the declared-member case (named twice). Lint tests
read `src/`.
- A3 (review round 1), the door guard (`base && !extensionWrite` back to
`base`, the round-0 reading): 2 of 15 red, exactly shapes a and b; and
the build-side exclusion (`ownNames` emptied in the build too, behind an
opaque `globalThis` marker): 1 red, shape a's build assertion (the
member named twice). Both restored by the tool's verdict.
- A4 (review round 2), the same door-guard mutation at `bfa139ba`: 3 of
16 red, shapes a and b and the tie/outranked pin; restored by the tool's
verdict.
- A2, the extension loci (entries read as none, behind an opaque
`globalThis` marker), for the runtime pins that read lint through
`dist/`: `pnpm --filter @objectstack/lint build`,
`ablation-dist-preflight` found the marker in 4 built files, runtime `-t
33153`: 2 red (both LITs), the control green. Restore leg: lint rebuilt,
`--absent` found the marker in 0 of 20 built files, tree clean, 3/3
green.

## Acceptance notes

- **Exposure measured:** `git grep` of `objectExtensions` /
`defineObjectExtension` over `examples/`, `packages/` (non-test) and
HotCRM `origin/main`: two entries, neither adds a `formula` field.
- **A field an extension redeclares under a name the target already
serves** is served as the written definition. In the build the object
walk judges a re-declared declared field under its name, at the object,
so the extension walk leaves the authored target's declared names out
rather than naming one twice. At the door, whose one pass skips the
object walk and whose target is served before the write (other packages'
published extension fields included), no name is left out, so both a
package re-declaring a field of an object it owns and an entry re-adding
a name a sibling package's extension serves are refused at the entry
(review round 1, finding 1;
`protocol-extension-redeclared-owner-field.ts` does not judge an
extension of an object its own package owns, so nothing else refused
that shape).
- **A field two packages add at the same priority**, in `os build` on a
declared target, is left out of the served body
(`objectsWithoutTiedFields`) and so out of the cycle pass, as objectstack-ai#33398
leaves its hops unjudged: which definition is served is registration
order. On an undeclared target the build takes the later entry's
definition of a shared name and judges it.
- **The door's reading of a shared name** (review round 2): the door
snapshot carries a sibling package's published extension field as a
plain field with no priority, and folds the written entry over it, so
the door judges the written entry's own definition of every name it
adds. On a tie, or where a sibling outranks the written entry, the door
can refuse a cycle the build lets through. Ruled text plus a pin, no
code change here; follow-up objectstack-ai#33494 makes the door read the build's
winner. The semantic entry, the changeset's Unchanged list, the
call-site comment and the docs sentence state both readings.
- **Not changed, by the order's fence:** the gate-setup region of
`validate-expressions.ts` (objectstack-ai#33246's), `authoring-rules.ts` and the door
roster pins (the rule already runs on the door).

## Verification

Head `bfa139ba` (base `fc283d6d`; review round 1 adds `88b22a14` and
`7c2eeb88` over `67ff848e`, round 2 adds `bfa139ba`). `origin/main` has
moved to `811b976a`; `git diff --stat fc283d6 811b976` over every file
this PR touches is empty, so no merge was needed. objectstack-ai#33246 (PR objectstack-ai#33434) had
not merged.

<details><summary>Package tests</summary>

- `@objectstack/lint`: 210/210 files, 8982/8982 tests; `pnpm --filter
@objectstack/lint typecheck` (tsc + test typecheck) exit 0.
- `@objectstack/runtime`
`src/domains/meta-object-extension-item.test.ts`: 46/46; `pnpm --filter
@objectstack/runtime typecheck` exit 0.
- `@objectstack/spec` `src/migrations`: 5 files, 198/198.

</details>

<details><summary>Gates (dispatch-gates --commands, 109 lines)</summary>

The derivation at `bfa139ba` is 109 lines, the same list as at
`67ff848e` and `7c2eeb88`. Every line ran after a whole-repo `pnpm
build` of `bfa139ba`, its exit code captured before any pipe, and all
109 exited 0. `dispatch-gates --ran`: `109 derived, 109 run, 0
NOT-MEASURED`. The record is `pm-orders/spec/33153-gates-ran-r2.txt` in
the project share (earlier rounds: `33153-gates-ran.txt`,
`33153-gates-ran-r1.txt`).

</details>

Dogfood (`Clause-②:` carries the `(narrowing)` arm and the title `!`):
full battery, the CI command (`pnpm --filter @objectstack/dogfood test`
under the verify lock), no shard, on head `bfa139ba` after a whole-repo
build. Result: `VERDICT command-exit 0`, Test Files 465 passed and 3
skipped (468), Tests 3932 passed and 42 skipped (3974), no failures (the
same counts as on `67ff848e` and `7c2eeb88`).

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5mAXtyZgMs9QwfQzXE)_

<!-- signed: domain:spec#1 · os-project-manager ·
session_01FEkQ5mswnWm181XgYcCUag -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…s the written entry among other packages' extensions by priority, as os build does (objectstack-ai#33702)

<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X5DTB6H6vWGj3p1JFrKB58W)_

Fixes objectstack-ai#33494

Clause-②: no (narrowing) — at the runtime `object_extension` publish
door (Studio, `PUT /api/v1/meta/object_extension/TARGET`, the MCP and AI
authoring doors) the expression rule now reads each field of the target
as `os build` serves it when another package's published extension adds
the same field. One shape it accepted is now refused (shape 3: a
higher-priority package's formula for a field the written entry also
adds closes a cycle through another field of the entry), and two it
refused now publish (shape 1, a tie at the priority that decides the
field; shape 2, the written entry outranked there). `os build`, `os
validate` and `os lint` are unchanged. The new gate input
(`storedObjectExtensions` on `runRuntimeAuthoringRules` and
`evaluateRuntimeAuthoringGate`, the `StoredObjectExtension` type from
`@objectstack/lint/runtime`) is optional and additive. Measured
first-party exposure: no two first-party packages extend the same object
(`examples/app-showcase` one entry on `showcase_account`;
`packages/plugins/plugin-auth` one on `sys_sso_provider`; HotCRM
`origin/main` 2492ac6 one module, o2c, extending `crm_contract` and
`crm_account`), so no first-party write changes verdict.
Metadata-protocol: narrowed
Skills-docs: none owed — this PR edits
`content/docs/deployment/validating-metadata.mdx` (the object extension
paragraph states the door's fold); the skills teach
`defineObjectExtension({ extend, fields, priority })` and formula fields
and say nothing of how the door read a field two packages add.

## 维护者速读

- **改了什么**:运行时 `object_extension`
发布口在判断扩展字段(如公式循环)时,现在把其他软件包已发布的同目标扩展连同其优先级一起折叠,用的是 `os build`
的同一个折叠函数,所以发布口看到的字段定义与 build 一致:同优先级冲突的字段两边都不判,被更高优先级覆盖的字段按覆盖者的定义判。
- **为什么改**:此前发布口拿到的目标对象里,其他包加的字段是没有优先级的普通字段,写入条目总是盖在上面。结果有两种情况发布口拒绝而
build 放行(同优先级、被更高优先级覆盖),一种情况发布口放行而 build 拒绝(更高优先级的兄弟公式经由本条目的另一个字段构成循环)。
- **风险与回滚**:发布口一处收窄、两处放宽,build
不变。需要两个软件包扩展同一对象的同名字段并带公式循环才会触发;第一方实测没有两个包扩展同一对象。新输入是可选的,宿主不提供时行为与之前相同。回滚即
revert。
- **先看**:`packages/lint/src/validate-expressions.ts`(扩展遍历:stored
条目只折叠不判定、回填跳过 stored
名称)、`packages/lint/src/object-graph.ts`(`objectExtensionsByTarget` /
`objectsAsServed` 的 `stored`
参数)、`packages/metadata-protocol/src/protocol-authoring-gate.ts`(`otherPackagesExtensionsOf`)。
- **两分钟验证**:`pnpm --filter @objectstack/lint exec vitest run
src/runtime-gate.object-formula-cycle.test.ts`,预期 20 条全过,其中 `objectstack-ai#33494` 一组
5 条:同优先级与被覆盖两种情形发布口与 build 都放行,更高优先级兄弟公式构成的循环在发布口按本条目的字段拒绝。
- **需要你做的**:无,席位落地。

## What changes

**`packages/lint/src/object-graph.ts`.**
`objectExtensionsByTarget(stack, stored = [])` and
`objectsAsServed(stack, stored = [])` take an optional list of
`StoredObjectExtension` (an extension the host's registry already holds
for another package: `extend`, `priority`, `fields`, `packageId`). Each
is collected by the fold's own `collect`, one carrier per entry below 0
(registered before the stack's own entries), marked `stored: true` on
its `VisibleObjectExtension`. They sort and fold exactly as any entry:
ascending priority, a later writer replacing the whole field, a name
whose deciding writers share a priority put in `tied`. The build never
passes the list, so every build verdict is what it was.

**`packages/lint/src/validate-expressions.ts`.**
`StackExpressionOptions.storedObjectExtensions`, read on an
`object_extension` write only (`storedExtensions`). It reaches the
top-of-pass fold (`objectsAsServed(stack, storedExtensions)`, so the
field, type and nullable indexes see the build's winner and leave a tie
out) and the extension walk (`objectExtensionsByTarget(stack,
storedExtensions)`). In the walk a stored entry is folded in and never
judged or located; the fill-back from `base` (the target as served
before the write, which carries the stored entries' fields as plain
fields) skips the names they add, so a tied name is not served again as
one sibling's definition. The call-site comment is rewritten to this
reading. Neither edit touches the gate-setup region PR objectstack-ai#33434 edits (its
hunks at ~:2374-2380 and after ~:2396; this PR changes the one fold call
between them, as the seat's surface amendment allows).

**`packages/lint/src/formula-cycle-issues.ts`.** `extensionFormulaLoci`
reads `stored`: a stored entry locates nothing, and a name it adds later
in fold order than the written entry removes the written entry's locus
(the sibling's definition is the one served). So a cycle a higher
sibling closes through another field of the written entry is named on
that field alone, and the sibling's member is never charged to the
write.

**`packages/lint/src/runtime-gate.ts`, `authoring-rules.ts`,
`runtime.ts`.** `runRuntimeAuthoringRules({ storedObjectExtensions })`
(optional) hands the list to
`AuthoringRuleContext.storedObjectExtensions` on an `object_extension`
write only, the same value in every pass; the expression rule passes it
to `runStackExpressionPasses`. `@objectstack/lint/runtime` exports the
`StoredObjectExtension` type.

**`packages/metadata-protocol/src/protocol-authoring-gate.ts`,
`runtime-authoring-gate.ts`.** New `otherPackagesExtensionsOf(registry,
target, writtenPackage)`: each `extend` contributor of the target
(`getObjectContributors`) of a package other than the written one, with
its priority and fields, in the registry's order; a disabled package's
left out (`isPackageDisabled`, as every served fold withholds it); `[]`
for a registry that cannot answer. `judgeRuntimeAuthoringRules` states
it on an `object_extension` write (the target and package
`objectExtensionWriteFold` already names) and
`evaluateRuntimeAuthoringGate` passes it through (optional
`storedObjectExtensions`). No `packages/spec` schema moves: the registry
already held each sibling's package and priority.


**`packages/spec/src/migrations/entries/semantic/18.object-extension-formula-cycle-refused.ts`**
(PR objectstack-ai#33442's entry, not yet released): `reason` and `acceptanceCriteria`
now state the door's fold, "at the priority that decides it" in place of
"at the same priority", and the tie exception for both the build and the
door on a declared object.

**`content/docs/deployment/validating-metadata.mdx`**: the object
extension paragraph's last sentence states the door's fold and "at the
priority that decides it".

**`.changeset/33494-extension-door-priority-fold.md`**:
`@objectstack/lint`, `@objectstack/metadata-protocol` and
`@objectstack/spec` minor, both declaration lines, the `Skills-docs:`
line, a BREAKING banner (Before / Now / Unchanged / Fix) and `adr-0087:
not-required (already-registered
object-extension-formula-cycle-refused)` (this PR updates that
unreleased entry rather than registering a new one). Its **Now**
paragraph corrects, by quotation, the pending
`.changeset/33153-extension-formula-cycle.md` Now clause and Unchanged
sentence the carry note 6886038545 names, and "at the same priority"
there. That changeset is not edited (it is another PR's).

## Why

Card objectstack-ai#33494 (from PR objectstack-ai#33442's contract review, record 6885259034 finding
1 and its observation): the door's snapshot (objectstack-ai#33072) carried every other
package's extension field on the target as a plain field with no
priority, so the gate folded the written entry over all of them. `os
build` folds every package's entry by priority and serves the winner.
The door refused a tie and an outranked entry the build accepts, and
accepted a higher sibling's cycle through another field of the entry
that the build refuses.

## Tests

1. **`packages/lint/src/runtime-gate.object-formula-cycle.test.ts`**:
the objectstack-ai#33153 pin "the door judges the written entry's own definition
whatever a sibling's priority" is replaced by a `objectstack-ai#33494` describe (5
cases) at the real gate (`runRuntimeAuthoringRules`, `type:
'object_extension'`, with `storedObjectExtensions`) and the build
(`runAuthoringRules('build', …)` over both packages):
- ⭐ shapes 1 and 2: a tie (200/200) and an outranked entry (sibling 300,
written 200), the written `s__c` reading itself: no cycle finding at the
door, none in the build.
- ⭐ LIT shape 3: the sibling (300) serves `s__c = record.a__c + 1`, the
written entry (200) adds `s__c` (number) and `a__c = record.s__c * 2`:
refused at the door on `a__c` only, in the engine's sentence
(`formulaCycleMessage('a__c', ['a__c', 's__c'])`); the build names the
sibling's `s__c` at the sibling's entry and `a__c` at the written entry.
- the entry that outranks the sibling (300 over 200) is still refused at
the door at the entry, and by the build at the same entry.
- a tied name the sibling stored as a self-reading formula is not served
back from the target and not charged to the write (door and build both
clean).
- a host that states no extensions leaves the door as it was (the
written entry folded over the served target).
2.
**`packages/runtime/src/domains/meta-object-extension-item.test.ts`**,
new describe `[objectstack-ai#33494]` (4 cases) through the real `saveMetaItem` +
`publishMetaItem`, with a third package registered as an extender of the
account (`registerObjectExtension`, priority 200 or 300): ⭐ the tie and
the outranked self-reading formula publish (the row goes active), as `os
build` accepts each; ⭐ shape 3 gets 422 `INVALID_METADATA` with
`expression-invalid` at `object 'crm_account' · objectExtensions[0] ·
field 'a__c' expression` and the row stays a draft; CONTROL: an entry
outranking the sibling with a self-reading formula is still refused.
3.
**`packages/metadata-protocol/src/protocol-authoring-gate.extension-write-fold.test.ts`**,
new describe `[objectstack-ai#33494]` (2 cases): `otherPackagesExtensionsOf` lists
every other package's `extend` contributor in the registry's order with
its priority and fields, leaving out the owner, the written package and
a disabled package; a registry with no contributors member, or one that
throws, states none.
4. **Meta-tests** (`validate-expressions.test.ts`,
`validate-security-posture.test.ts`, objectstack-ai#5017 receiver scans):
`storedNames` (a Set of names) and `stored` (the fold's list parameter)
tabled as plumbing receivers, each with its reason.

**Red at base:** the head's lint test file over the base lint sources
(`git restore --source=41b64bb0` of the six lint source files): 2 of 20
red, the shapes 1/2 case and the shape 3 LIT; restored with `git
checkout HEAD --`, `git diff HEAD` empty.

**Ablations** (one-shot through `node scripts/ablation-replace.mjs` on
committed head `e681d49f`; each restore verdict "blob == HEAD and `git
diff HEAD` is empty"; lint tests read `src/`):

- A1, the fill-back skip (`&& !storedNames.has(n)` dropped): 1 of 20
red, the tied-name case.
- A2, stored entries locating (`if (entry.stored) loci.delete(name)`
made unreachable behind a `globalThis` marker): 1 of 20 red, the shape 3
LIT (the sibling's `s__c` charged to the write). A first attempt was a
no-op (its replacement kept the anchor text; the tool refused and
restored), so it was rerun with the marker.
- A3, the top fold without the stored list (`objectsAsServed(stack)`): 2
of 20 red, shapes 1/2 and shape 3.
- R1, the host carry, for the runtime pins that read metadata-protocol
through `dist/`: the registry handed as `globalThis.__ablationR1`
(undefined) in `judgeRuntimeAuthoringRules`, `pnpm --filter
@objectstack/metadata-protocol run build`, `ablation-dist-preflight`
found the marker in `dist/`, runtime `-t 33494`: 3 red (both publish
LITs and the shape 3 LIT), the CONTROL green. Restore leg: rebuilt,
`--absent` found no marker, 4/4 green. (A first R1 attempt was also a
no-op for the same reason and is not counted.)

## Acceptance notes

- **Where the snapshot is built** (measured):
`packages/metadata-protocol/src/protocol-authoring-gate.ts`
(`judgeRuntimeAuthoringRules`), not `packages/runtime/src/domains/`; the
seat amended the claim's surface (6888588670).
- **No second fold.** The door's fold is `objectsAsServed` /
`objectExtensionsByTarget` with the host's entries added to their input;
the tie set and the ordering are the build's.
- **A tied name the target's owner also declares**: in the build the
tied name is filled back from the authored object (the object walk's);
at the door the target's base layer is not carried (only the served
target), so the walk leaves every name a stored entry adds to the fold,
and such a name is absent there. It needs an owner field re-declared by
two packages at the priority that decides it, plus a formula cycle
through it; the verdict charged to the write can only differ by a member
under that name. Noted, not filed.
- **A disabled package's extension** is left out (`isPackageDisabled`),
as the served fold leaves it out; an enable door's `asEnabled` reading
is not this write's.
- **The legacy `NS__NAME` filing** (`extensionTargetKey`, objectstack-ai#28858) is not
mirrored: the host reads the contributors under the target the body
names, as the gate folds it.
- **Other as-served checks on this door** read the same fold now (the
field-formula and validation-rule passes' field, type and nullable
indexes), so a type or null-guard verdict on a field another package
outranks is the build's too.
- **Not changed, by the order's fence:** `packages/spec` schemas; the
door roster and its pins; PR objectstack-ai#33434's hunks.

## Verification

Head `763105ec`: the fix `e681d49f`, the meta-test tabling `78ad84f3`,
the ADR-0087 marker `dd37779e`, and a merge of `origin/main` `e9884e19`
(base `41b64bb0`). PR objectstack-ai#33434 landed before the merge; it merged clean,
and both its stamped-column index and this PR's `objectsAsServed(stack,
storedExtensions)` are on the merged line.

<details><summary>Package tests</summary>

Run on head `763105ec` (the merge of `origin/main` `e9884e19`, which
brought PR objectstack-ai#33434) after a whole-repo `pnpm -r run build` (`VERDICT
command-exit 0`):

- `@objectstack/lint` `pnpm test`: 210/210 files, 8998/8998 tests; `pnpm
--filter @objectstack/lint typecheck` (tsc + test typecheck) exit 0.
- `@objectstack/metadata-protocol` `pnpm test`: 340 files passed and 9
skipped, 22883 tests passed and 43 skipped; `typecheck` exit 0.
- `@objectstack/runtime`
`src/domains/meta-object-extension-item.test.ts`: 50/50; `pnpm --filter
@objectstack/runtime typecheck` exit 0.
- `@objectstack/spec` `src/migrations`: 198/198 (round 0, on `e681d49f`;
the entry's text has not moved since).

</details>

<details><summary>Gates (dispatch-gates --commands)</summary>

The derivation at `763105ec` is 114 lines. Every line ran after the
whole-repo build of `763105ec`, its exit code captured before any pipe,
and all 114 exited 0. `dispatch-gates --ran`: `114 derived, 114 run, 0
NOT-MEASURED, 0 UNRUN`. The record is
`pm-orders/spec/33494-gates-ran.txt` in the project share.

Round 0 (head `78ad84f3`, before the merge): the same 114 lines, 112
exit 0 and 2 red, each fixed and rerun green:
`check-adr-0087-registration` (the changeset said `registered` for an
entry that already existed; now `not-required (already-registered …)`,
commit `dd37779e`) and `check-plugin-teardown-shape --self-test` exit 3
(the shallow clone lacked the pinned fixture commit; `git fetch
--depth=1 origin 621a487…`). Record:
`pm-orders/spec/33494-gates-ran-r0.txt`.

</details>

Dogfood (`Clause-②:` carries the `(narrowing)` arm and the title `!`):
full battery, the CI command (`pnpm --filter @objectstack/dogfood test`
under the verify lock), no shard, on head `763105ec` after a whole-repo
build. Result: `VERDICT command-exit 0`, Test Files 467 passed and 3
skipped (470), Tests 3958 passed and 42 skipped (4000), no failures.
(Round 0 on `dd37779e`, before the merge: 467/3 files, 3953 passed and
42 skipped, no failures.)

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5pZiFTTaXqbY34YRcV)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…injected column a stored row can hold null in, as the publish gate does (objectstack-ai#34129)

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

Fixes objectstack-ai#33435

Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — no skill under `skills/**` teaches a condition over
an injected column or the null guard on one;
`content/docs/automation/flows.mdx` and
`content/docs/automation/hooks.mdx` gain the rule in this change.

> **BREAKING** for a stack whose record-triggered flow condition or hook
`condition` orders or does arithmetic on an injected system column the
object does not declare (`owner_id`, `created_by`, `updated_by`,
`owning_business_unit_id`, `queue`, `organization_id`; `created_at` /
`updated_at` at a `beforeInsert` hook) with no `!= null` guard: `os
build` now refuses it, as the runtime publish gate already did.
ADR-0087: `registered
flow-hook-condition-injected-column-null-guard-at-build`.

## 维护者速读

- 改了什么:`os build` 在 flow 条件和 hook
条件里,对平台注入列(负责人、创建人、修改人、业务单元、队列、组织)做大小比较或算术而没先判空时,现在会报错,和发布时的服务端检查给出同一条结论;`beforeInsert`
钩子里的创建/修改时间也一样。
- 为什么改:实测这些列在系统写入、种子数据、访客写入的行上是空的,条件一碰就出错:flow 跑失败(触发它的写入照样落库),hook
条件直接让写入失败。以前本地构建放行、发布才拒,作者在发布时才第一次看到错误。
- 风险与回滚:只收紧构建期检查,运行时与发布检查不变;四个示例应用和平台对象零命中。回滚即还原
`validate-expressions.ts` 的这次改动。
-
先看:`packages/lint/src/validate-expressions.ts`(`buildInjectedNullableIndex`
/ `buildPreStampIndex` 和 `checkNullGuards` 的 `nullable`
选项),`packages/lint/src/validate-expressions.flow-null-guards.test.ts`
新增的对齐用例。
- 两分钟验证:`pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2
src/validate-expressions.flow-null-guards.test.ts`,应见 29 passed,其中
objectstack-ai#33435 的用例逐列断言构建与发布检查结论相同。
- 需要你做的:无,席位落地。

## What changes

- `packages/lint/src/validate-expressions.ts`: the flow condition sites
(start, edge, `decision` branch; `record.` and bare spellings) and the
hook condition site now judge the null guard over the declared fields
**plus** the injected system columns the object as read does not carry
(`buildInjectedNullableIndex`). At `os build` that is every injected
column the author did not declare; at a single-item runtime door the
objects are served with those columns declared, so the index adds
nothing there and its verdicts do not move. Two runtime readers hand the
walk authored objects and so narrow with the build, inside the declared
narrowing: the MCP `validate_expression` tool at site `flow_condition`
(`judgeAuthoredSiteExpression` strips the injected columns and runs the
walk as a flow write) now returns the null-guard finding for the six
columns, and a `publish-drafts` batch that carries a draft of the flow's
or hook's own object (`mergePendingDeclarations` replaces the served
object with the draft body, which holds no injected column) now refuses
what it published before, as the single-item publish already refused it.
A hook whose `events` include `beforeInsert` also judges `created_at` /
`updated_at` (`buildPreStampIndex`), the card's S1 case. Validation
rules and `requiredWhen` keep the declared-field index: both doors judge
those over the authored object (measured below), so they already agree.
- The `PLATFORM_STAMPED_COLUMNS` docblock records the per-column
measurement; the orphaned `buildNullableFieldIndex` docblock (it said
leaving the injected columns out "costs coverage, never a false error")
moves above its function and says what the index is now.
- `packages/spec/src/migrations/entries/semantic/18.…` `reason`: a
`beforeInsert` hook reads `created_at` / `updated_at` as null only when
it runs before the stamp (priority below 10); the rule stays the door's
(objectstack-ai#33434), a priority-aware rule at both doors is the seat's follow-up.
- `content/docs/automation/flows.mdx` (rule 5) and
`content/docs/automation/hooks.mdx` (the `condition` gate) state that
the injected columns need the guard and the two timestamps do not,
except at `beforeInsert`.
- ADR-0087 semantic entry
`flow-hook-condition-injected-column-null-guard-at-build`; root
changeset `33435-injected-column-null-guard-at-build.md`
(`@objectstack/lint` and `@objectstack/spec` minor).

## Measurement (card step 1)

<details><summary>Per column, per ownership tier, per writer (showcase,
real REST door + engine, driver-sqlite-wasm, single posture)</summary>

Throwaway probe (deleted): the showcase stack plus three objects, one
per ownership tier (default/user, `business_unit`, `org`), a REST `POST
/data/OBJECT` as the platform admin and as a signed-up member, then
`ql.insert` under `{ isSystem: true }` with and without `tenantId`, a
system update and an admin REST update of each system row; hooks
registered at priority 1 recorded what each event saw; three
record-after-create flows on the user-tier object.

| column | REST create (admin, member) | system insert | after a user
REST update of a system row | seeded `showcase_task` |
|---|---|---|---|---|
| `organization_id` | set | set (Default Organization) | set | set |
| `owner_id` (user tier) | stamped to the caller | NULL | NULL | claimed
by the admin |
| `queue` (user tier) | NULL | NULL | NULL | NULL |
| `owning_business_unit_id` (user, business_unit tiers) | NULL | NULL |
NULL | NULL |
| `created_by` | stamped | NULL | NULL | NULL |
| `updated_by` | stamped | NULL (a system update leaves it NULL) |
stamped | NULL |
| `created_at`, `updated_at` | set | set | set | set |

- A `beforeInsert` hook at priority 1 saw a payload with no
`organization_id`, `created_at`, `updated_at`, `created_by` for every
writer (REST and system); `afterInsert` saw them stamped.
`organization_id` is filled by the driver after the hook chain.
- Reach: system inserts fire record-triggered flows and every hook.
`record.owner_id > 'a'` and `record.created_by > 'a'` start conditions:
each system insert's run `failed` with `condition failed to evaluate as
CEL: no such overload: dyn<null> > string`; the REST create's run
`completed`; the guarded `record.owner_id != null && record.owner_id >
'a'` flow never failed.
- `posture-only` (isolated) boot: a system-context insert with no
organization is refused (`SystemWriteOrganizationRequiredError`,
ADR-0131 D9), so no NULL row there.
- By design, not re-measured: a guest/public-form write leaves
`owner_id` unset (ADR-0138 D1 item 5), a queue park or release writes
`owner_id: null` (ADR-0142 D3,
`content/docs/automation/queues-and-assignment-rules.mdx`), and
driver-memory never stamps a tenant column
(`packages/drivers/driver-memory/src/memory-tenancy-guard.ts` header).

Decision (card step 2): no column is stamped for some ownership tiers
only, so no STOP. `owner_id`, `created_by`, `updated_by`,
`owning_business_unit_id`, `queue` hold NULL on reachable stored rows ⇒
nullable at both. `organization_id` is set on every stored row on the
SQL family but read NULL at `beforeInsert` and never stamped by
driver-memory ⇒ not every reachable row, so it stays nullable at the
door and is now nullable at the build (the door already judged it so).
`created_at` / `updated_at` stay never-null except at a `beforeInsert`
hook (S1).

Gate-level reading before/after (lint functions, same object, every
tier): base `f81e4b6c` — flow/hook sites door=1 build=0 for each of the
six columns, `beforeInsert` hook on `created_at`/`updated_at` door=1
build=0, validation rule door=0 build=0; head — build equals door in
every cell.

</details>

## First-party exposure (card step 3)

`objectstack build` at head in `examples/app-todo`, `app-crm`,
`app-multi-package`, `app-showcase`: exit 0 each, zero null-guard
findings. Positive control: `examples/app-todo`'s `todo_task_completion`
start condition with `&& record.created_by > "a"` appended (via
`scripts/ablation-replace.mjs`, restored, `git diff HEAD` empty) ⇒ exit
1 with `applies \`>\` to \`record.created_by\``. Platform packages: `git
grep` finds no flow or hook condition ordering an injected column
(`examples/app-showcase/src/ui/actions/predicate-matrix.action.ts` uses
`owner_id ==` in an action `visible`, not a judged site). No hit to
guard.

## Tests

- `packages/lint/src/validate-expressions.flow-null-guards.test.ts`: the
objectstack-ai#33246 describe is renamed to cover both cards and gains seven cases: os
build refuses each of the six columns at every flow slot and at a hook
with the door's exact finding; a flow's bare spelling (judged as a
declared nullable field's, the door judges no bare name of either kind);
per ownership tier the build judges exactly the columns the tier
carries; the S1 `beforeInsert` case and its afterInsert/flow controls;
the guarded spelling; an author-declared `owner_id` keeps its own
verdict; a validation rule keeps its verdict at both.
- `packages/lint/src/authored-site-expression.test.ts`: the MCP
`flow_condition` entry over a served object returns the gate's
null-guard finding for `record.owner_id > 'a'`, and nothing for the
guarded spelling.
-
`packages/metadata-protocol/src/runtime-authoring-gate.injected-column-null-guard.test.ts`
(new): `evaluateRuntimeAuthoringGate` with the object's draft in
`pending.objects` refuses a flow over `owner_id` and a `beforeInsert`
hook over `created_at` exactly as the single-item publish does; the
guarded spelling publishes. Ablation: with base
`validate-expressions.ts` (lint rebuilt) both batch cases and the MCP
case fail; restored, they pass.
- Forced test edit: `packages/lint/src/validate-expressions.test.ts` —
the objectstack-ai#5017 declared-keys meta-test's `PLUMBING` table gains the five new
non-metadata receivers (`flowHookNullableIndex`, `preStampIndex`,
`carriedFieldNames`, `joinedNullable`, `joinedFields`).

## Acceptance notes

- Out of scope, named for the seat: a hop leaf through an injected
lookup (`record.owner_id.nmae != null`) is judged at neither the build
nor the door.
- Residual build/door difference left on purpose (the order scoped
`created_at` / `updated_at` to the S1 case): the door also refuses, and
the build accepts, arithmetic on `record.created_at` in a flow, a
`previous.created_at` read, a read-event hook (`beforeFind` /
`afterFind`) on the two timestamps, and every timestamp read on an
`external` object.
- Validation rules and `requiredWhen` over an injected column are judged
at neither door (the object door judges the authored object); a stored
row with NULL there faults the rule. Same class, not this card's sites.
- The null-guard message names the object as declaring the column
nullable ("'todo_task' declares as nullable (no `required: true`, no
`defaultValue`)") for an injected column the author never declared; it
is the door's existing wording, kept identical for parity.

## Verification

All readings at head `f1e07bac` (the final commit), worktree on
`origin/main` `f81e4b6c`.

<details><summary>Tests, consumers, dogfood, gates</summary>

- `pnpm --filter @objectstack/lint test`: Test Files 212 passed (212),
Tests 9033 passed (9033); `pnpm --filter @objectstack/lint typecheck`:
exit 0 (lock VERDICT command-exit 0).
- Consumers of the build verdict (the contract face is `os build` / `os
validate`; the single-item door's verdicts do not move; the MCP
`flow_condition` entry and `publish-drafts` batches move as "What
changes" says): `pnpm --filter @objectstack/cli exec vitest run
--project unit` 423/423 files, 6010/6010 tests;
`@objectstack/metadata-protocol` 342 passed, 9 skipped files, 22926
passed, 45 skipped tests; `@objectstack/mcp` 65/65 files, 1185/1185;
`@objectstack/platform-objects` 122/122 files, 2007/2007. All exit 0.
- Full dogfood battery (`(narrowing)` arm), `pnpm --filter
@objectstack/dogfood test` under the verify lock: VERDICT command-exit
0, Test Files 467 passed, 3 skipped (470), Tests 3962 passed, 42 skipped
(4004).
- `objectstack build` in the four examples: exit 0 each; positive
control exit 1 (see First-party exposure).
- `node scripts/pm/dispatch-gates.mjs --commands` (no paths): 109
commands, each run with stdin closed and the exit captured before any
pipe; `--ran`: 109 derived, 108 run, 1 NOT-MEASURED, 0 UNRUN. NOT
MEASURED: `pnpm check:dual-build-cjs-loads`, reason: exit 3 PREREQUISITE
NOT MET (not every package has a `dist/`), CI runs it. Three first-pass
exit 3 refusals re-run green after their prerequisite:
`check-plugin-teardown-shape.mjs --self-test` (shallow clone; `git fetch
--depth=1 origin 621a487`, 48 cases), `check:skill-examples` (built
`@objectstack/client-react...`; 346 prose examples),
`check:type-check-debt` (lock wait behind the dogfood run; re-run with a
slot, OK).

</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmS2qjQvEgMBSBQpeea)_

<!-- signed: domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC
-->

---------

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 size/l 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.

A flow or hook condition ordering record.created_at with no guard is refused at the publish door while os build accepts it

1 participant