Skip to content

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

Merged
objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/project-thread-mn9za6
Nov 14, 2026
Merged

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

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Fixes #33154

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 an extension whose validation rule carries a condition or when that the same rule declared on the object is refused for. No exported type or signature changes. Measured first-party exposure: 0 extension entries carry a validation rule (examples/app-showcase and packages/plugins/plugin-auth extensions add fields only; HotCRM origin/main 92519d8 has no objectExtensions in code), so nothing first-party is newly refused. Two repository test fixtures carried the refused shape and are repaired here (see Acceptance notes).
Metadata-protocol: narrowed
Skills-docs: none owed — this PR edits content/docs/deployment/validating-metadata.mdx (the object extension door paragraph names the rule pass); skills/objectstack-data teaches validation rules and defineObjectExtension({ extend, fields }) without saying an extension's rules are exempt, so the build and the door now give the verdict the object's own rules already get.

Precedent followed: #33072 (PR #33119), which declared the same no (narrowing) / narrowed pair for the computed fields an extension adds.

维护者速读

What changes

Lint: one rule pass, two walks.

  • packages/lint/src/validate-expressions.ts.
    • The per-rule body of the object walk is hoisted into one closure, judgeValidationRule(rule, { objectName, locus, rulePath }). It covers the condition and when (with the one-hop checks the rule validator serves), every nested then / otherwise predicate, the parent root verdict and the null-guard gate. The object walk's loop now calls it, and its findings, order and key paths are byte for byte what they were.
    • lint: a stored computed field added by an object extension is never judged by the field-formula pass (stored-expression warnings and expression errors skip it) #32875's extension walk calls the same closure for each validations[] rule of each entry that objectExtensionsByTarget keeps (the fold already carried them). A record.FIELD read resolves against the target's fields as served (fieldIndex, over objectsAsServed), so a field this extension or a sibling package's extension adds resolves, and a field nothing serves is unknown. An undeclared target is judged on what does not depend on its fields, as its formulas are. The hop checks (refuseUndeclaredHopField, storedMetadataBodyReferencesFor) read the declared objects, so the leaf of a one-hop read through a reference an extension adds is not judged (see Acceptance notes).
    • The locator is object 'TARGET' · objectExtensions[i] · validation 'RULE', and the key path is ENTRY.validations[k].SLOT. The door's 422 carries that path as is (objectExtensions[0].validations[0].condition); only a draft read's _diagnostics re-spell it item-relative (validations.0.condition).
    • On an object_extension write the door's live objects are read through stripInjectedSystemColumns (@objectstack/metadata-core), as authored-site-expression.ts reads served objects. The registry serves an object with the system columns it injects (created_at, owner_id, …) declared, required: false and no default, so the null-guard gate judged record.created_at > … as an unguarded nullable operand and refused at the door what os build accepts. Stripped, the indexes re-derive those columns as the build does: known fields, never judged nullable.
    • On an object_extension write the door still runs ONE pass, the extension walk, and returns after it (lint: the object_extension publish door runs no field-formula judgment, so a computed field os build refuses still publishes through PUT /meta/object_extension #33072's extensionWrite). The rules join that one pass.
  • packages/lint/src/authoring-rules.ts. Comment only (surface amendment 6868654518), on the expression rule's runtimeTypes.

Docs, migration and changeset.

  • content/docs/deployment/validating-metadata.mdx. One sentence in the object extension door paragraph. The CEL row's columns do not change: the ᵒˣ mark landed with lint: the object_extension publish door runs no field-formula judgment, so a computed field os build refuses still publishes through PUT /meta/object_extension #33072.
  • packages/spec/src/migrations/entries/semantic/18.object-extension-validation-rule-expression-judged.ts. The ADR-0087 D3 entry. Its printed guidance carries no tracker id. There is no D2 conversion, because how a refused rule is repaired is a fact only the author holds.
  • .changeset/33154-object-extension-validation-rules-judged.md. @objectstack/lint minor and @objectstack/spec minor, with both declaration lines, a BREAKING banner (Before / Now / Unchanged / Fix) that names the null-guard refusal and its fix, and the ADR-0087 disposition marker.

Tests

  1. packages/lint/src/runtime-gate.object-formula-writes.test.ts, a new top-level describe #33154 with 9 cases, at the real gate (runRuntimeAuthoringRules) and the build (runAuthoringRules('build', …)):
    • LIT: a misspelt field is refused at the entry, with its key path.
    • LIT: an unregistered function in a nested then branch is refused at the branch.
    • PARITY: on one shared input set (a typo, sqrt, a bare reference), the door's findings deep-equal the build's.
    • PARITY: with the objects as the registry serves them (applyInjectedSystemColumns), an unguarded ordering over record.created_at is accepted at the door as at the build, and one over a declared nullable field (record.amount > 0) is refused at both, the findings deep-equal.
    • CONTROL: a valid rule, a rule reading a field the same extension adds, and a gated one-hop read are clean at both doors.
    • SIBLING: a rule reading a field a sibling package's extension adds resolves at the build, and a misspelling of it is refused at packages[2].manifest.objectExtensions[0].
    • An undeclared target is judged on what does not depend on its fields.
    • One pass: the extension write does not judge the target's own broken rule.
    • CONTROL: the object save door still judges the object's own rule at its own location.
  2. packages/runtime/src/domains/meta-object-extension-item.test.ts, a new describe [#33154] with 4 cases, through the real saveMetaItem + publishMetaItem:
    • LIT: a rule reading record.nmae gets 422 INVALID_METADATA with issue expression-invalid at the build's location and path. The rule is not served, and the row stays a draft.
    • CONTROL: a valid rule publishes and is served on the account.
    • PARITY: record.created_at > timestamp(…) with no guard publishes and is served (the account as served declares created_at), and os build (runAuthoringRules('build', …) on the account as authored and the same entry) reports nothing; an unguarded record.bonus__c > 100 on a field the same entry adds is refused at both, with the same rule, location and path.
    • LIT (republish, lint: the object_extension publish door runs no field-formula judgment, so a computed field os build refuses still publishes through PUT /meta/object_extension #33072's S1 shape): dropping a field that the extension's own rule still reads is refused, because the stored self lends it nothing.
  3. Repaired by this change (stale fixtures, each the refused shape):
    • meta-object-extension-item.test.ts: a bare region__c == null becomes record.region__c == null.
    • packages-disable-module-extension-fields.test.ts (surface amendment 6869487624): an unguarded record.qx_credit > 5000000 gains record.qx_credit != null &&.
    • authored-site-expression.test.ts: the validate_expression enumeration's source regions now read the hoisted rule pass. indexOf and isArray moved out of the region with the object loop's own index, so they leave the member-call table.

Ablation (one-shot; nothing permanent): node scripts/ablation-replace.mjs replaced the extension walk's for (const rule of rules) { with an empty loop (anchor x1 → x0, blob a3c3164d → 1bba8602). Then pnpm --filter @objectstack/lint build ran, and ablation-dist-preflight found the marker in 4 built files.

  • Lint pins: 5 of 8 red. The 3 controls stayed green.
  • Runtime pins, read through dist/: 2 of 3 red. The control stayed green.
  • Restore: the blob equals HEAD and git diff HEAD is empty. Lint was rebuilt, and ablation-dist-preflight --absent passes on all 20 built files with a clean tree.
  • The mutate leg's tree reading first exited 3, because the source spells the marker [] as typeof rules. The dist reading passed on that run, and the restore leg passed --source-marker.

Ablation of the strip (r1, one-shot): ablation-replace.mjs replaced if (extensionWrite) stack = { with if (extensionWrite && String('ablated-strip') === 'off') stack = { (anchor x1 → x0, blob 72951696 → e6b23d5a). Lint was rebuilt, and ablation-dist-preflight found the marker in 4 built files.

  • Lint pins: 1 of 9 red, the injected-column PARITY case (the door reported the null-guard finding on record.created_at, the build none).
  • Runtime door pins: 1 of 4 red, the PARITY case (422 on record.created_at).
  • Restore: blob equals HEAD and git diff HEAD is empty. Lint was rebuilt, and ablation-dist-preflight --absent passes on all 20 built files with a clean tree.

Acceptance notes

  • Out of scope, as the seat ruled (filed as An object extension's format and json_schema validation rules skip the regex and JSON-schema checks the object's own rules get #33217): two rules still judge an object's own rules only.
    • validate-rule-compilability checks a format rule's regex.
    • validate-rule-schema-formats checks a json_schema rule's formats.
    • Both read obj.validations, so a regex or schema format in an extension's rule is judged at neither door. Neither is an expression pass. The changeset's Unchanged line says so.
  • Not judged, at either door: the leaf of a one-hop read through a reference an extension ADDS. refuseUndeclaredHopField and storedMetadataBodyReferencesFor read the declared objects, so with manager__c (a lookup to staff) added by the extension, record.manager__c.daly_hours > 12 passes the build and the door alike (measured), while the same misspelling through a reference the target declares is refused. The changeset's Unchanged line says so. Filed as A one-hop read through a lookup an object extension adds is accepted with a misspelt target field, then refuses every save #33216.
  • Filed from the contract review (record 6878859677, ③): the flow and hook publish doors read the same unstripped nullable index, so an unguarded ordering over record.created_at in a record-triggered flow or a hook condition is refused at the door while os build accepts it. It is out of this card's scope: those walks are not in this diff. Filed as A flow or hook condition ordering record.created_at with no guard is refused at the publish door while os build accepts it #33246.
  • A rule an extension adds under the same name as one of the target's own rules replaces it in the registry (merged by name). Both are judged, each where it is authored.
  • Module packages registered at boot (defineStack({ objectExtensions }) through registerApp) are not gated, as an object's own rules are not. packages-disable-module-extension-fields.test.ts still registers unguarded module rules that way, untouched.

Verification

Head 9d07ffa06 (rework r1 on 15d074782: the strip, its pins, and the prose fixes). origin/main was merged twice before r1 (1169d64 before opening, then after #33168 landed on authored-site-expression.test.ts); r1 merges nothing, and git merge-tree against origin/main at push time is clean. Everything below ran at 9d07ffa06 unless it names another head.

Package tests
  • @objectstack/lint at 9d07ffa06: 208/208 files, 8879/8879 tests. Typecheck exit 0.
  • Runtime door files at 9d07ffa06 (meta-object-extension-item.test.ts + packages-disable-module-extension-fields.test.ts): 74/74.
  • Every other test file that publishes an object_extension, at 9d07ffa06: metadata-protocol protocol-extension-redeclared-owner-field, protocol-stored-item-conversion.notice-name, protocol-authoring-gate.extension-write-fold, protocol.packaged-base-refusal, protocol.unknown-picklist-binding-refusal (129/129); runtime meta-picklist-binding-door, packages-export-base-showcase-boot.integration, meta-object-extension-item-door-fit (22/22).
  • At e4ee8af8e (before r1; r1 changes only the extension door's object read and prose): @objectstack/metadata-protocol 22810 tests passed, @objectstack/objectql 12874, @objectstack/platform-objects 1955, @objectstack/mcp 1145, @objectstack/cloud-connection 1206, @objectstack/plugin-approvals 1632, @objectstack/service-mailbox 152, @objectstack/rest 8346 (332 skipped), @objectstack/cli unit 5934 and integration test/migrate-meta-engine-guidance.test.ts 3/3, @objectstack/runtime 597 files after the fixture repair.
Gates (dispatch-gates --commands, 109 lines)

The derivation at 9d07ffa06 is the same 109 lines as before r1. Every line ran with stdin closed and its exit code captured before any pipe. 103 exited 0 on the first pass; six @objectstack/spec lines (check:api-surface, check:browser-reachable-entries, check:dual-source-exports, check:entry-nameability, check:exported-any, check:skill-examples) exited 3 (refused, nothing measured) because the spec build predated the edited semantic entry. After pnpm --filter @objectstack/spec build all six exited 0. dispatch-gates --ran: 109 derived, 109 run, 0 NOT-MEASURED.

Dogfood (the title carries !), full battery, the CI command, no shard, on head 9d07ffa06. The closure was built first. Result: VERDICT command-exit 0, Test Files 463 passed and 3 skipped (466), Tests 3918 passed and 42 skipped (3960), no failures.


Generated by Claude Code

…extension adds, by the object walk's own rule pass

WIP: pins, changeset and migration entry follow.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibyToDkPxCjvNiWsv6e
… the object_extension gate and the real publish door

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibyToDkPxCjvNiWsv6e
…ild and the object_extension door

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibyToDkPxCjvNiWsv6e
…s a rule declared on the object must

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibyToDkPxCjvNiWsv6e
…; the extension rule loop adds no receiver

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibyToDkPxCjvNiWsv6e
…its nullable operand

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibyToDkPxCjvNiWsv6e
…now meets, and its fix

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibyToDkPxCjvNiWsv6e
…-mn9za6

# Conflicts:
#	packages/lint/src/authored-site-expression.test.ts
@github-actions github-actions Bot added size/l 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 2 package(s): @objectstack/lint, @objectstack/spec, touching 5 documentable anchor(s).

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

  • content/docs/deployment/validating-metadata.mdx (via AUTHORING_RULES (symbol, a top-level const object))
What this run could not see
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • 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 — 172 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 6e1ab9b286655c5476312ae563ab531f3f36cf38 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 6e1ab9b286655c5476312ae563ab531f3f36cf38

⚠️ 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 6e1ab9b286655c5476312ae563ab531f3f36cf38 → 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#2 · os-tesla · session_01L9qibvfX5bawZKtfa6u7j9

Contract-review-claim: session_01L9qibvfX5bawZKtfa6u7j9 · head 15d0747 · 2026-11-14T03:07Z

Face: schema + narrowing (CONTRACT_REVIEW_TIER); the seat runs it through an isolated subagent.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#2 · os-tesla · session_01L9qibvfX5bawZKtfa6u7j9

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 15d074782c704e5b016436ec2ac8102d5d18411c
Local-runs: none
Scope: packages/spec/src/migrations/entries/semantic/18.object-extension-validation-rule-expression-judged.ts + packages/lint/src/validate-expressions.ts, packages/lint/src/authoring-rules.ts, packages/lint/src/runtime-gate.object-formula-writes.test.ts, packages/lint/src/authored-site-expression.test.ts, packages/runtime/src/domains/meta-object-extension-item.test.ts, packages/runtime/src/domains/packages-disable-module-extension-fields.test.ts

PR #33205 for card #33154, on the schema face (the semantic entry) and the declared narrowing. Read: the card body and its five comments (6865785642, 6868572380, 6868654518, 6869487624, 6870691534), the PR body and its nine-path file list, the net diff against main, and the head's check-runs at 2026-11-14T03:27Z: 68 runs, 58 success, 10 skipped, none failed or pending, the last completed 2026-11-14T03:05Z. Every statement about behaviour below is read from the tree at the head. Nothing was built or run.

One must-fix (F1), one should-fix (F2), three nits (N1 to N3).

① Derived judgments

  1. os build, os validate and os lint refuse a stack whose objectExtensions[].validations[] rule fails the rule pass. Right, and a narrowing. The rule's registry entry is commands: ALL (authoring-rules.ts:648), so os lint is a third CLI door. The changeset and the entry name the first two only.
  2. The runtime object_extension publish door refuses the same rule with 422 INVALID_METADATA, issue expression-invalid. Right as declared, except that the door also refuses one shape the declaration does not cover (F1).
  3. The newly refused shapes. An unknown field, a bare reference, an unregistered function, an unguarded nullable ordering or arithmetic operand, a parent root, a type mismatch, and the hop shapes a declared rule is refused for. Each is a verdict the object's own rules already get. The changeset spells four of them and covers the rest by "the same rule on the object". Right. One refused shape is not named, and is wrong: F1. One declared judgment is not delivered: F2.
  4. No exported type or signature moves in @objectstack/lint. Right. judgeValidationRule is a closure inside runStackExpressionPasses, and StackExpressionOptions changes in its docblock only.
  5. @objectstack/spec gains one semantic entry in the protocol 18 step, so os migrate meta prints one more block. Right, additive.
  6. A new locator. object 'T' · ENTRY · validation 'N' (nested: validation rule 'N' then → 'M'), key path ENTRY.validations[k].SLOT, under the object's own rule id. Right.
  7. The object walk is unchanged. Right. Compared line by line, the hoisted body differs from the inline one on main in three places, each object '${objectName}' becoming ${locus}, and the object call site passes locus as that same string.
  8. Not gated, as before: a module package registered at boot, and the package-wide draft publish limit the options docblock already states. As declared.

② Semver level

The changeset moves @objectstack/lint and @objectstack/spec at minor. Both are released packages the diff moves (lint source, one spec migration entry), and the kind narrowed takes at least minor, so the level is right. packages/runtime changes in tests only and publishes nothing, so it owes no entry.

The Clause-②: no (narrowing) line and Metadata-protocol: narrowed stand line-initial on the PR body and on the changeset body. The changeset carries the BREAKING banner, the fix, and exactly one ADR-0087 marker, registered object-extension-validation-rule-expression-judged, which is the entry's id. Check Changeset and Lint · CI, release & engine gates are green on the head. The arm is the right arm. The bound it states, "a condition or when the same rule on the object itself is refused for", is exceeded at the door (F1).

③ Boundary flags

  • Dev report open_questions: empty.
  • Dev report deviations: the attribution line links the card thread, and the ablation's mutate leg needed --source-marker. Neither touches the contract. Accepted.
  • Dev report out-of-scope finding (a format rule's regex and a json_schema rule's formats in an extension's validations are judged at neither door): confirmed by reading. Both rules walk obj.validations only (validate-rule-compilability.ts:429). It is a trap of this card's own class, so a card is owed. Escalated to seat 2, the carrier the report names. The changeset's Unchanged line states it.
  • The claim's provisional Metadata-protocol: narrowed: stands.
  • Amendment 6868654518 (comment only in authoring-rules.ts): held. Seven comment lines; runtimeTypes and the adapter are untouched.
  • Amendment 6869487624 (the repaired fixture; the banner and the entry must name the null-guard refusal and its fix): held. Both name it, with the guard.
  • File surface: the nine paths are the claimed surface plus the two amendments. No breach.
  • New from this review, escalated to seat 2: F2 needs a follow-up card. The flow and hook passes read the same nullable index at their own doors (validate-expressions.ts:3045, :4255). That is outside this diff and not measured; if F1's measurement confirms the served form there, it is a card too.

④ Design judgment

What was tried against the design, and held:

  • A rule reading a field another extension adds. It resolves at the build through fieldIndex over objectsAsServed, and at the door through the live target. packages-disable-module-extension-fields.test.ts is a real-door instance: the tenant pair's rule reads qx_credit, which the module's extension adds.
  • A republish judged without the package's stored self. objectExtensionWriteFold takes the written package's extension off the target, and the republish case pins it: dropping bonus__c while the rule still reads it is refused.
  • The one-pass rule. The object walk and the flow walk read an empty list on an extension write, and the function returns at validate-expressions.ts:4136. Pinned by the case where the target's own broken rule is not charged to the extension write.
  • Rule id and locator. expression-invalid, located at the entry, pinned at both doors.
  • Tracker ids in printed guidance. None (see the entry below).

packages/spec/src/migrations/entries/semantic/18.object-extension-validation-rule-expression-judged.ts (hits)

  • The four printed fields, surface, replacement, reason and acceptanceCriteria, hold no # followed by digits. The one id sits in the leading comment, which is not printed. That is the line packages/cli/test/migrate-meta-engine-guidance.test.ts holds every entry to.
  • No D2 conversion and no relevantWhen: both right. The repair is a fact only the author holds, and the surface also lives in stored object_extension rows a stack does not show.
  • Its premise holds against the registry: mergeValidationsByName (packages/objectql/src/registry.ts:1160) merges an extension's rules onto the target by name.
  • It does not hold against the door for one input: its replacement (lines 23 to 28) and acceptanceCriteria (lines 38 to 41) are false there. See F1.
  • N3 below.

packages/lint/src/validate-expressions.ts (implementing)

The hoist is faithful (① item 7). The extension loop passes the target, the entry locator and the rule's key path, and the return after the walk is intact. Two findings on the contract, two nits.

F1, must-fix. At the real object_extension door the null-guard gate reads the registry's injected system columns as nullable declared fields, so the door refuses a rule that os build and the object's own rule pass accept.

  • Mechanism. The door hands the walk its live objects: registry.listItems('object') folded with the stored rows (packages/metadata-protocol/src/protocol-authoring-gate.ts:437-474). A registered base layer carries its injected columns in fields, because applySystemFields runs before contributor storage (packages/objectql/src/registry.ts:5890-5895). Each is defined required: false with no defaultValue (packages/spec/src/data/injected-system-column-provenance.ts:61-97). Nothing between the registry and the walk strips them. nullableIndex is built from those objects (validate-expressions.ts:2379, isNullableField at :493), and the new loop sends each extension rule through checkNullGuards for the target (:3641, :4126).
  • Effect. An extension rule with an unguarded ordering or arithmetic operand over record.created_at or record.updated_at (or any other injected column) is refused 422 at the door.
    • os build accepts the same entry, because the declared target carries no injected column. The index's own docblock (:508) says it holds declared fields only, so that a record.created_at comparison does not become an error.
    • The object save door accepts the same rule declared on the object, because its subject is the body stripped at protocol-save.ts:582.
  • The tree already states this. packages/lint/src/authored-site-expression.ts:105-111 strips the injected columns off registry-served definitions before this same pass, and says why: unstripped, the null-guard gate would judge created_at as a declared nullable field. The extension door does not strip. One consequence is that the MCP validate_expression tool answers clean for a rule the extension publish then refuses.
  • Why it is a contract fault. On an update the stored row always holds created_at (the index's docblock: the driver always populates it), so for a rule that runs on update the refusal is false. Whether the column is already bound when an insert rule runs was not traced; if it is not, the door is right there and the build under-covers. Either way the door and the build disagree, and three shipped sentences are false for this input:
    • the entry's replacement ("A rule the expression rule accepts on a declared rule of the same object") and its acceptanceCriteria (a clean os build, then a 200);
    • the declared bound on the changeset and the PR body;
    • the docs sentence "at the door and in os build alike".
  • Why the pins do not see it. The lint PARITY case gives the door an authored-shaped target, and the three real-door cases read name, nmae and a field the extension adds. The type index (:2378) has the same served-form difference, there in the truthful direction.
  • Basis. Read, not run. One real-door case settles it: an extension rule with an unguarded ordering operand over record.created_at, published through saveMetaItem and publishMetaItem, beside os build of the same entry.
  • Remedy, the dev's choice. Either judge the door's objects as authored on an extension write (the strip judgeAuthoredSiteExpression uses), so the door gives the build's verdict; or keep the door's verdict and name it in the entry, the changeset and the docs sentence. Either way, pin it at the real door.

F2, should-fix. A one-hop read through a reference field an extension adds has its leaf unjudged, so the card's trap stays open in that corner.

  • refuseUndeclaredHopField (:2447, the loop at :2458) and storedMetadataBodyReferencesFor (:2386) read the reference field's definition off the declared objects, not off the served fold.
  • So an extension that adds a lookup, and a rule that reads a misspelt column through it and is otherwise well formed, is accepted at the build. At the door it is accepted when the lookup is the written entry's own. By the helper's own docblock, such a rule then "has no verdict and refuses every write it judges".
  • The helper predates this PR and a formula has the same gap. But the new comment at :4111-4114 and the changeset say the rule is judged "against the target as served, through the same indexes", which is wider than what is enforced. A lookup and a rule in one extension is the natural shape on this surface.
  • Remedy without moving a reviewed file: add this to the changeset's Unchanged line, and file a follow-up card. No case pins it today.

N1, nit. The key path's index is a counter over recordsOf(ext.validations) (:4123-4129, object-graph.ts:451). On input ObjectExtensionSchema refuses, the path is wrong: a non-record member ahead of the rule shifts the index, and a map-form validations gets an index where the object walk spells no path. This is reachable only on an unparsed stack (os lint). The locator and the verdict are unaffected. Accepted deviation or a follow-up.

N2, nit. The comment at :4116-4118 says the door re-spells the path item-relative (validations.0.condition). The door's 422 keeps objectExtensions[0].validations[0].condition, as this PR's own real-door case pins. The item-relative spelling is itemRelativeIssuePath's, where a draft read reports the publish verdict. The hoisted docblock at :3576-3580 says it correctly.

N3, nit, in the hits file. Two loose sentences in the entry's reason:

  • It locates the finding at objectExtensions[0] for the build and the door alike. The build locates at the entry's own index, under packages[J].manifest. in an artifact, as the lint sibling case pins. acceptanceCriteria already spells [N].
  • "a rule reading a nullable field with no guard aborted" is wider than the gate, which judges ordering and arithmetic operands only. An equality read is accepted: record.region__c == null is this PR's own repaired fixture.

Fix both with F1's edit to the entry, or leave them as accepted deviations.

packages/lint/src/authoring-rules.ts (implementing)

Comment only, as amended. Its measured sentence holds on reading: examples/app-showcase ships one entry with three plain fields, plugin-auth one entry with fields only, and neither carries a rule.

The four test files (implementing)

  • runtime-gate.object-formula-writes.test.ts: the eight cases assert what the PR body says. Two blind spots: no door case over a registry-shaped target (F1), and no hop through a reference the extension adds (F2).
  • authored-site-expression.test.ts: the regions follow the hoist. indexOf and isArray stay in the object loop, outside the rule pass, so they rightly leave the table.
  • meta-object-extension-item.test.ts: three real-door cases, and the bare region__c fixture repaired to record.region__c.
  • packages-disable-module-extension-fields.test.ts: the tenant rule guarded, as the amendment says.

Outside the diff, read only: the object_extension row comment in packages/lint/src/runtime-gate.ts:293-296 still describes the crossing as the extension walk over the written entry's fields. A follow-up.

Implemented-by: claude/project-thread-mn9za6
Reviewed-by: session_01L9qibvfX5bawZKtfa6u7j9

VERDICT: FAIL


Generated by Claude Code

…columns

The object_extension door hands the objects as the registry serves them,
with the injected system columns (created_at, owner_id, ...) declared, so
the null-guard gate judged record.created_at as a declared nullable field
and refused an extension rule os build accepts. On that write each object
is now read through stripInjectedSystemColumns, as the authored-site
expression judge does. Pinned at the gate and the real door (accepted at
both; a declared nullable field still refused at both).

Comments, the changeset and the semantic entry now say that the leaf of a
one-hop read through an extension-added reference is not judged, that the
door's 422 keeps the stack path, that os lint narrows too, and that the
null-guard gate judges ordering and arithmetic operands only.

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

Copy link
Copy Markdown
Contributor Author

domain:spec#2 · os-tesla · session_01L9qibvfX5bawZKtfa6u7j9

Contract-review-hold: session_01L9qibvfX5bawZKtfa6u7j9 · head 9d07ffa · the maintainer paused lane seats' own contract reviews; reviews go to the new review agent · until a review agent is seated and takes this head

Handover · PR #33205 (card #33154) · 2026-11-14T04:39Z

The seat signs off by the maintainer's instruction. The PR stays a draft and is not accepted. Nothing is armed.

  • Review state: record 6870963898 FAILED head 15d07478 with one must-fix (F1), one should-fix (F2) and three nits (N1 to N3). The claim on 15d07478 lapses with the head. The delta review of 15d07478..9d07ffa0 was started and then stopped under the pause. It produced no record, so a delta review of 6870963898 is owed on 9d07ffa0. The face is schema + narrowing at CONTRACT_REVIEW_TIER.
  • What r1 says it did (the implementer's account, not a verdict):
    • F1 was measured real: the door returned 422 on an unguarded record.created_at ordering read while build returned []. The fix reads the door's objects through stripInjectedSystemColumns, as authored-site-expression.ts does. It adds PARITY pins in lint and on the real door; ablating the strip turns lint 1/9 and runtime 1/4 red.
    • F2 was measured real and fixed on the prose faces only.
    • N2 and N3 are fixed. N1 stays as an accepted deviation.
    • The PR body was patched to r2 by the seat; the read-back is identical.
  • Check-runs on 9d07ffa0 at hand-over: 56 success, 12 skipped, 2 in progress, and Test Core (2/8) + the Test Core aggregate failed. The failures are 4 tests in packages/spec/scripts/build-schemas-check-mode.{deletion-proofs,git-topology}.test.ts, each Hook timed out in 10000ms in a beforeEach (:224). No file in this diff is in those tests' path. One re-run is owed before reading it as this PR's; the seat did not re-run it.
  • Follow-up cards filed from the review: A one-hop read through a lookup an object extension adds is accepted with a misspelt target field, then refuses every save #33216 (F2: a one-hop leaf through an extension-added lookup is unjudged) and An object extension's format and json_schema validation rules skip the regex and JSON-schema checks the object's own rules get #33217 (an extension's format / json_schema rules skip the regex and schema checks). One more is not filed because it is unmeasured: the flow and hook passes may read the same unstripped nullable index at their own doors (validate-expressions.ts:3045, :4255, per 6870963898). The next reviewer measures it or files it.
  • Landing after a PASS: the lane seat's ACCEPT (the changeset and mdx prose at TIER_DEFAULT), then label-write --land. Not governed: 504 lines at 15d07478.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#2 · os-tesla · session_01L9qibyToDkPxCjvNiWsv6e

Contract-review-claim: session_01L9qibyToDkPxCjvNiWsv6e · head 9d07ffa · 2026-11-14T14:19Z

Face: schema + narrowing (CONTRACT_REVIEW_TIER). The hold 6871853372 is lifted: the maintainer restored seats' own contract reviews ("你现在可以自己契约复审了", project chat, 2026-11-14 14:17Z). This session implemented the PR, so the review runs in an isolated subagent at CONTRACT_REVIEW_TIER that is fed the diff and record 6870963898, not the implementer's conclusions.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#2 · os-tesla · session_01L9qibyToDkPxCjvNiWsv6e

Re-run, once: Test Core (2/8) on head 9d07ffa069baf93055b4da43e19fccbf9237159c (run 43554881417, job 132325981683) failed in 4 tests of packages/spec/scripts/build-schemas-check-mode.deletion-proofs.test.ts and build-schemas-check-mode.git-topology.test.ts. Each failure is Hook timed out in 10000ms in a beforeEach, with no assertion failing. The failures measured nothing. Neither file reads a path this PR changes: the diff touches packages/lint/src, the runtime door tests, one semantic migration entry, a changeset and one mdx page, and these tests build throwaway git repositories under packages/spec/scripts. The @objectstack/spec unit project in the same job passed 839 of 840 files, with 1 skipped. I judge it a flake and re-run the failed jobs once through rerun-failed.mjs. A second failure counts as real.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#2 · os-tesla · session_01L9qibyToDkPxCjvNiWsv6e

The brief handed to the isolated reviewer at CONTRACT_REVIEW_TIER for the record below it, posted beside the record per references/contract-review.md.

Contract review brief — PR #33205 @ 9d07ffa069baf93055b4da43e19fccbf9237159c (card #33154)

You review at CONTRACT_REVIEW_TIER. Render ONE ## Contract review record on this head — its shape is
node scripts/pm/record-recognisers.mjs --template --paths packages/spec/src/migrations/entries/semantic/18.object-extension-validation-rule-expression-judged.ts — with a PASS or FAIL verdict, and post it as ONE comment
on the PR or its card.

Inputs — these and nothing else:
· card #33154: its body and EVERY comment (rulings and earlier records included)
· PR #33205: its body, its file list, and the net diff against main at 9d07ffa069baf93055b4da43e19fccbf9237159c
· the check-runs on 9d07ffa069baf93055b4da43e19fccbf9237159c: their conclusions ARE the gate verdicts
⛔ Not the dispatch order, ⛔ not the dispatching seat's own conclusions — this brief is adversarial by design.

Scope — the paths reviewFace returns as hits on this PR's file list: packages/spec/src/migrations/entries/semantic/18.object-extension-validation-rule-expression-judged.ts;
plus every file IN THIS DIFF that directly implements or enforces them — the gate that enforces a rule, the code
a jsdoc or schema line describes, the validator a skill teaches — reviewed for agreement with the contract.
Widen it freely, ⛔ never below hits; the record's Scope: line names the implementing files apart from hits.
The rest of the diff (tests, unrelated modules, lockfiles, generated output, changesets) is the lane seat's
ACCEPT at TIER_DEFAULT, exactly as a standalone PR of those files.
④ judges the hits files and those implementing files ONLY:
lockfiles, generated output, changesets and prose elsewhere in the PR are not reviewed;
code outside the diff is READ to judge them, never reviewed.

⛔ READ-ONLY. No worktree, no checkout, no build, no test run, no gate re-run, no ablation: the check-runs
on the head already answered every derived gate family, and a local run costs more than it returns.
If ONE probe is unavoidable, the record's Local-runs: line says probe — REASON; otherwise none.
Scratch space is /tmp/claude-0/-home-user/f1414190-0e98-53df-b144-bdabf7a7b94d/scratchpad/issue-33154/review/pr-33205/ alone; nothing there you did not write this round is read.

Judge, in the record's own sections:
① Derived judgments — every accept-set and public-surface change the diff implies, each named right or wrong.
② Semver level — the changeset (or skip-changeset) matches what the diff publishes, and the Clause-②: line.
③ Boundary flags — every dev flag and every open_questions entry answered, or escalated.
④ Design judgment — for EVERY hits file: does the change hold against the code it cites and the
scenario it is accepted against? A skill file against the card's eval prompt and the spec it teaches
on main; a schema file against the ruling or ADR it implements and its first consumer; an ADR
against its first consumer and its execution plan. For EVERY implementing file in the diff: does the
code agree with the contract, sentence by sentence? Read the cited code in the live tree, and try to
break the design.
Grade each finding must-fix, should-fix or nit — a nit has no effect on correctness or the contract.
A must-fix is a FAIL; a must-fix or should-fix earns a delta review of its fix; nits alone end the round.
A nit is fixed only on the prose faces, or left as an accepted deviation or a follow-up card: a fix
anywhere else moves the head, and this record no longer covers it.
⛔ Judge the tree, never the PR body's account of it.
Sign Implemented-by: with the dev's branch and Reviewed-by: with your session id — the value is the FIRST
thing after each colon.

Card-thread notes (this round's context; inputs, not conclusions):
· The PR body and changeset also declare Clause-②: no (narrowing), so the narrowing face applies too: the scope floor is every path of the diff outside the prose faces (.changeset/**, content/docs/**), as the earlier record's Scope: line had it.
· This head is a rework. The earlier full review of head 15d074782c704e5b016436ec2ac8102d5d18411c is PR #33205 comment 6870963898 (VERDICT: FAIL; F1 must-fix, F2 should-fix, N1 to N3 nits). Its author is no longer seated, so this round is a full review of the new head that also judges, finding by finding, whether F1, F2, N2 and N3 are resolved in the TREE (N1 was left as an accepted deviation). Read every PR #33205 comment as well as the card's: the record, the seat's hand-over 6871853372 and the claim and re-run notes.
· The hand-over 6871853372 names one unmeasured question: whether the flow and hook passes read the same unstripped nullable index at their own doors (validate-expressions.ts near the flow and hook walks). Judge it by reading the tree. Say whether it is in this PR's scope, and if it is not, whether it warrants a follow-up card.
· The follow-up cards #33216 and #33217 exist; read them.
· Read GitHub with gh api (read-only GET calls only) and the tree with git show 9d07ffa069baf93055b4da43e19fccbf9237159c:PATH / git diff origin/main...9d07ffa069baf93055b4da43e19fccbf9237159c in /home/user/objectstack-issue-33154 (read only; do not check out, build or edit anything there).
· Do NOT post anything to GitHub. Write the finished record (the template's shape, from ## Contract review down to the VERDICT line) to /tmp/claude-0/-home-user/f1414190-0e98-53df-b144-bdabf7a7b94d/scratchpad/issue-33154/review/record.md, and return it in full as your final message. The adopting session posts it. Sign Implemented-by: with claude/project-thread-mn9za6 and Reviewed-by: with session_01L9qibyToDkPxCjvNiWsv6e (the session that adopts and posts your verdict); the record states, under ③, that the session which implemented the PR adopts a verdict rendered by an isolated subagent at this tier, by the maintainer's word of 2026-11-14 14:17Z that seats may run their own contract reviews again.
· Write every finding so a reader with no context can act on it: file and line, the input, what happens, what should.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#2 · os-tesla · session_01L9qibyToDkPxCjvNiWsv6e

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 9d07ffa069baf93055b4da43e19fccbf9237159c
Local-runs: none
Scope: packages/spec/src/migrations/entries/semantic/18.object-extension-validation-rule-expression-judged.ts + packages/lint/src/validate-expressions.ts, packages/lint/src/authoring-rules.ts, packages/lint/src/runtime-gate.object-formula-writes.test.ts, packages/lint/src/authored-site-expression.test.ts, packages/runtime/src/domains/meta-object-extension-item.test.ts, packages/runtime/src/domains/packages-disable-module-extension-fields.test.ts

PR #33205 for card #33154, on the schema face (the semantic entry) and the declared narrowing. This is a full review of the rework head. It also judges, finding by finding, whether F1, F2, N2 and N3 of the earlier record 6870963898 (head 15d07478, FAIL) are resolved in the tree.

Read: the card body and its six comments; the PR body, its nine-path file list and its six comments (the earlier record, the hand-over 6871853372, the two claims and the re-run note among them); the net diff against main; cards #33216 and #33217; and the head's check-runs. Every statement about behaviour below is read from the tree at the head with git show. Nothing was built or run.

No must-fix and no should-fix. Four nits (N4 to N7). One follow-up card is owed (the flow and hook doors, under ③).

Check-runs at 2026-11-14T14:28Z: 71 runs: 58 success, 12 skipped, 1 in progress. The one without a conclusion is Test Core (2/8), attempt 2 (job 132475937503, started 14:21Z). Attempt 1 (job 132325981683) failed. Its log, read for this record, shows 4 failed tests, each Hook timed out in 10000ms in a beforeEach of packages/spec/scripts/build-schemas-check-mode.deletion-proofs.test.ts (:224) and build-schemas-check-mode.git-topology.test.ts (:104). Those hooks write files into a throwaway git sandbox and read no path of this diff. In the same job the @objectstack/spec unit project, which holds the migration-entry tests, passed 839 of 840 files with 1 skipped. No lint or runtime test runs in that shard, and the other seven shards are green. So no gate that judges this contract is red. ⛔ This verdict does not stand in for that shard: landing waits for its conclusion, and a second failure is real and is not covered by this record.

① Derived judgments

  1. os build, os validate and os lint refuse a stack whose objectExtensions[].validations[] rule fails the rule pass. Right, and a narrowing. The rule's registry row is commands: ALL (authoring-rules.ts:648). The changeset now names all three commands.

  2. The runtime object_extension publish door refuses the same rule with 422 INVALID_METADATA, issue expression-invalid. Right, and now within the declared bound (F1 below).

  3. The newly refused shapes: an unknown field, a bare reference, an unregistered function, an unguarded nullable operand of an ordering or arithmetic operator, a parent root, a type mismatch, and the hop shapes a declared rule is refused for. Each is the verdict the object's own rule gets, because both walks call one closure. Right.

  4. New on this head: on an object_extension write the door's objects are read through stripInjectedSystemColumns (validate-expressions.ts:2377). This moves door verdicts in three places, each to the build's verdict:

    • The null-guard gate no longer judges an injected column (created_at, owner_id, ...) as a declared nullable field. This is the F1 fix, and a widening of what the door refused on 15d07478.
    • The type index no longer types an injected column at the door (buildFieldTypeIndex, :432, declared fields only). A type verdict over record.created_at that the door gave since lint: the object_extension publish door runs no field-formula judgment, so a computed field os build refuses still publishes through PUT /meta/object_extension #33072 on an extension's formula field, and that the build never gave, is gone. A widening at the door.
    • The hop-leaf check (refuseUndeclaredHopField, :2474) no longer treats an injected lookup (created_by, owner_id) as a declared reference of the target, so the leaf of record.created_by.FIELD is unjudged at the door as it is at the build. A widening at the door.

    All three are right against the contract, which is "the build's verdict" in this entry and in lint: the object_extension publish door runs no field-formula judgment, so a computed field os build refuses still publishes through PUT /meta/object_extension #33072's entry. The changeset names the first. The other two are covered by its sentence that the door reads the objects "as the build does" (N6).

  5. No exported type or signature moves in @objectstack/lint. Right. judgeValidationRule is a closure inside runStackExpressionPasses. StackExpressionOptions changes in its docblock only. The new import, @objectstack/metadata-core, is already a dependency of the package (packages/lint/package.json:54) and is already imported by authored-site-expression.ts:45 and runtime-gate.ts:666.

  6. @objectstack/spec gains one semantic entry in the protocol 18 step. Right, additive. Entries are concatenated from the directory, so the file needs no index edit.

  7. The object walk is unchanged. Right. The hoisted body (:3583 to :3660) differs from the inline body on main in three places, each object '${objectName}' becoming ${locus}, and the object call site (:3686) passes locus as that same string and the same rulePath.

  8. Not gated, as before: a module package registered at boot, and the package-wide draft publish limit the options docblock states. As declared.

② Semver level

The changeset moves @objectstack/lint and @objectstack/spec at minor. Both are released packages the diff moves (lint source, one spec migration entry). The kind narrowed takes at least minor, so the level is right. packages/runtime changes in tests only and owes no entry.

Clause-②: no (narrowing) and Metadata-protocol: narrowed stand line-initial on the PR body and on the changeset body. The changeset carries the BREAKING banner (Before, Now, Unchanged, Fix) and exactly one ADR-0087 marker, registered object-extension-validation-rule-expression-judged, which is the entry's id. Check Changeset (both runs) and Lint · CI, release & engine gates are green on the head. The arm is the right arm, and the bound it states ("a condition or when the same rule on the object itself is refused for") now holds at the door for the input that broke it on 15d07478.

③ Boundary flags

  • Who renders and who adopts. The session that implemented this PR (session_01L9qibyToDkPxCjvNiWsv6e) adopts and posts this verdict. It was rendered by an isolated subagent at CONTRACT_REVIEW_TIER, fed the brief, the diff, the threads and record 6870963898, and not the implementer's conclusions. This rests on the maintainer's word of 2026-11-14 14:17Z that seats may run their own contract reviews again (claim 6878678135, which lifts the hold 6871853372).
  • Dev report open_questions: empty.
  • Dev report deviations: the attribution line links the card thread, and the ablation's mutate leg needed --source-marker. Neither touches the contract. Accepted.
  • Dev report out-of-scope finding (an extension's format regex and json_schema formats are judged at neither door): filed as An object extension's format and json_schema validation rules skip the regex and JSON-schema checks the object's own rules get #33217, read, triaged p2. The changeset's Unchanged line states it. Closed here.
  • Record 6870963898 F2 (the leaf of a one-hop read through a reference an extension adds): filed as A one-hop read through a lookup an object extension adds is accepted with a misspelt target field, then refuses every save #33216, read, triaged p2. See ④ for the tree side.
  • The claim's provisional Metadata-protocol: narrowed: stands.
  • Amendment 6868654518 (comment only in authoring-rules.ts): held. Seven comment lines; runtimeTypes and the adapter are untouched.
  • Amendment 6869487624 (the repaired fixture; the banner and the entry name the null-guard refusal and its fix): held.
  • File surface: the nine paths are the claimed surface plus the two amendments. The rework commit touches five of them and adds none. No breach.
  • The hand-over's unmeasured question: do the flow and hook passes read the same unstripped nullable index at their own doors? By reading the tree: yes. It is not in this PR's scope. It warrants a follow-up card. Escalated to the adopting seat to file.
    • Mechanism. On every runtime write the gate hands the rules registry.listItems('object') folded with the stored rows (packages/metadata-protocol/src/protocol-authoring-gate.ts:437 to :474). A registered object carries its injected columns in fields (applySystemFields, packages/objectql/src/registry.ts:5890), each required: false with no defaultValue (packages/spec/src/data/injected-system-column-provenance.ts:61). packages/lint/src/runtime-gate.ts strips nothing. This head strips only under extensionWrite (validate-expressions.ts:2377). So on a flow or hook write nullableIndex (:2395) holds created_at, updated_at, created_by, updated_by, owner_id and organization_id as nullable fields.
    • Flow door. On a record-triggered flow the start, edge and decision conditions go through checkNullGuards (:3061), and every name in that index also joins the bare-name set (:3047 to :3053). Input: a record-triggered flow whose condition is record.updated_at > record.created_at, or the bare created_at > timestamp('2020-01-01T00:00:00Z'). What happens, by reading: the publish door refuses it with the null-guard error, and os build of the same flow reports nothing, because the build's index holds declared fields only (the index's own docblock, :509). What should happen: one verdict at both.
    • Hook door. A hook condition goes through checkNullGuards at :4278 and :4310. Same input shape, same split.
    • A second consumer disagrees with the door. judgeAuthoredSiteExpression (authored-site-expression.ts:235) strips before it judges a flow_condition site as "a flow write at the runtime publish gate". So the MCP validate_expression tool answers clean for a condition the flow publish then refuses.
    • Why it is out of scope. The flow and hook walks, their doors and runtimeTypes are not in this diff, and the card is about an extension's validation rules. The split predates this PR.
    • Basis and the card's first step. Read, not run. One real-door case settles each: publish a record-triggered flow, and a hook, whose condition applies an ordering operator to record.created_at with no guard, beside os build of the same item. The card's remedy question is which side is right per column: the index's docblock says the driver always populates created_at while owner_id really can be NULL.
  • Carried from record 6870963898, still open, outside the diff: the object_extension row comment in packages/lint/src/runtime-gate.ts:293 to :296 still says the crossing is the extension walk "over the written entry's fields". It now judges the entry's rules too. A follow-up edit; it can ride A one-hop read through a lookup an object extension adds is accepted with a misspelt target field, then refuses every save #33216 or An object extension's format and json_schema validation rules skip the regex and JSON-schema checks the object's own rules get #33217, which touch the same walk.

④ Design judgment

The earlier record's findings, judged in the tree at this head.

  • F1 (must-fix): resolved.
    • The fix is the first remedy the record offered: validate-expressions.ts:2377 reads each object through stripInjectedSystemColumns on an extension write, before any index is built. buildFieldIndex (:247) then re-adds the injected names through injectedColumnsFor, as it does at the build, so record.created_at stays a known field. buildNullableFieldIndex (:570) sees declared fields only, so the gate gives no verdict on it. The walk's fieldDefs re-derive the injected definitions through injectedColumnDefsFor(base) (:4105).
    • The strip is exact by construction. stripInjectedSystemColumns removes a field only when it is identical, key for key, to the platform's definition (isInjectedColumnDefinition, injected-system-column-provenance.ts:237), and applySystemFields spreads those definitions unchanged (its docblock at registry.ts:1458 forbids adding keys). A created_at the author declared in any other shape stays the author's field at the door and at the build alike.
    • It is pinned where the record asked. Lint: the PARITY case that feeds the door applyInjectedSystemColumns(target) and deep-equals its findings with the build's, for record.created_at > timestamp(...) (accepted at both) and record.amount > 0 (refused at both). Real door: the PARITY case in meta-object-extension-item.test.ts asserts the registry serves created_at, publishes the rule through saveMetaItem and publishMetaItem, and compares a refused record.bonus__c > 100 with the build's rule, location and path. Both files run in green shards.
    • The three sentences that were false for this input are now true: the entry's replacement and acceptanceCriteria, the declared bound, and the docs sentence "at the door and in os build alike".
    • What the record left untraced stays untraced and is not this PR's: whether created_at is bound when an insert rule runs. If it is not, the build under-covers for an object's own rules exactly as for an extension's. The contract here is parity with the object's own rule, and parity holds.
  • F2 (should-fix): resolved on the faces the record named. The tree does not judge the leaf, and says so in three places: the walk's comment (:4132 to :4136), the options docblock (:2275), and the changeset's Unchanged line, with the example record.manager__c.nmae. Card A one-hop read through a lookup an object extension adds is accepted with a misspelt target field, then refuses every save #33216 carries the fix. The sentence the record called too wide ("against the target as served, through the same indexes") is gone. No case pins the gap; A one-hop read through a lookup an object extension adds is accepted with a misspelt target field, then refuses every save #33216 owns that.
  • N1 (nit): left as an accepted deviation, as the hand-over says. Unchanged at :4146 to :4154. It is reachable only on an unparsed stack, and the verdict and locator are unaffected.
  • N2 (nit): resolved. The comment at :4139 to :4141 now says the door's 422 carries the path as is and only a draft read's _diagnostics re-spell it item-relative. That agrees with itemRelativeIssuePath (packages/metadata-protocol/src/metadata-diagnostics.ts:401) and with the real-door LIT case, which pins objectExtensions[0].validations[0].condition on the 422.
  • N3 (nit, in the hits file): resolved. The reason now gives objectExtensions[N] with N the entry's own index, the packages[J].manifest. prefix in a built artifact, and objectExtensions[0] at the door. The null-guard sentence is narrowed to "an ordering or arithmetic operator" and says an equality such as == null is accepted.

packages/spec/src/migrations/entries/semantic/18.object-extension-validation-rule-expression-judged.ts (hits)

Read sentence by sentence against the tree.

  • surface: defineObjectExtension exists (packages/spec/src/data/object.zod.ts:5781) and the fold reads ext.validations (packages/lint/src/object-graph.ts:451). Right.
  • replacement: every clause is a verdict of judgeValidationRule, and "a rule the expression rule accepts on a declared rule of the same object" now holds at both doors. The clause "reads one hop through a reference only as a declared rule may" does not promise the leaf check F2 names. Right.
  • reason: the premise holds (mergeValidationsByName, packages/objectql/src/registry.ts:1160). The locator matches object-graph.ts:448 and the walk's locus. A nested branch is located objectExtensions[N] · validation rule 'R' then → 'M', which the acceptance sentence's prefix objectExtensions[N] · validation still matches.
  • acceptanceCriteria: a clean os build and then a 200 at the door. Right for every input I could construct. Attempts that did not break it: an injected column (F1, fixed); a field a sibling extension adds (resolved at both, pinned); a target outside the door's package closure (judged only on what does not depend on its fields, the accepting direction); a republish that drops a field its own rule reads (refused, pinned).
  • The four printed fields hold no tracker id. No D2 conversion and no relevantWhen: right, for the reasons its leading comment gives.
  • N5 below.

packages/lint/src/validate-expressions.ts (implementing)

The code agrees with the contract. The hoist is faithful (① item 7). The extension loop (:4146 to :4154) passes the target, the entry locator and the rule's key path. The return after the walk (:4159) keeps the door at one pass. The strip sits after the view and page early returns and before the first index, and it is fenced to extensionWrite, so the build and every other door read stack.objects as before.

Tried against the strip, and held:

  • A served object whose fields is not a record: the strip returns it untouched, and the door's objects are registry-shaped records.
  • A stored (overlay-backed) target, which may arrive without injected columns: the strip is a no-op on it.
  • The written extension's own fields: they are folded in by objectsAsServed after the strip, so a nullable field the extension adds is still judged (pinned at the real door with bonus__c).
  • A deployment that declares the target platform-global: the registry injects no organization_id, and the one-argument plan the strip and injectedColumnsFor use would still call the name known. That is the accepting direction, it predates this PR, and no ordering or arithmetic rule plausibly reads that column. Not a finding.

N4, nit. validate-expressions.ts:3683. The comment reads "The object's index in the authored list, for the finding's key path", but the line under it computes the rule's index in the object's validations (ruleIndex). The object's index is the comment at :3671. No effect on behaviour. Accepted deviation, or fixed with the next edit of the walk (#33216 or #33217).

N5, nit, in the hits file. The entry's leading comment (lines 5 to 6) names os build, os validate and the door. The rule is commands: ALL, so os lint refuses too, as the changeset says. The comment is not printed. Accepted deviation.

N6, nit, prose face (changeset). The Now paragraph names one effect of the strip: created_at is not judged nullable. It does not name the other two in ① item 4, which also move #33072's door verdict on an extension's formula field (no type verdict on an injected column; no leaf verdict through an injected lookup). Both are widenings to the build's verdict, so nothing an author must do follows from them. One clause would cover it. A changeset edit moves the head, so it is the lane seat's call: accepted deviation is enough.

N7, nit, prose face (PR body). The PR body's Clause-②: line names os build and os validate; the changeset's names os lint as well. Fix the PR body to match, which moves no head.

packages/lint/src/authoring-rules.ts (implementing)

Comment only, as amended. Its measured sentence holds on reading: examples/app-showcase/src/data/extensions/account.extension.ts and packages/plugins/plugin-auth carry extensions with fields only, and no non-test source under examples/ or packages/plugins/ declares a rule on an extension.

The four test files (implementing)

  • runtime-gate.object-formula-writes.test.ts: nine cases, each asserting what its title says. The new PARITY case closes the blind spot the earlier record named for F1. Still unpinned, by design: a hop through a reference the extension adds (A one-hop read through a lookup an object extension adds is accepted with a misspelt target field, then refuses every save #33216).
  • meta-object-extension-item.test.ts: four real-door cases, and the bare region__c fixture repaired to record.region__c. The PARITY case first asserts the precondition (the registry serves created_at), so it cannot pass vacuously.
  • authored-site-expression.test.ts: the source regions follow the hoist. judgeFieldFormula (:3486) precedes judgeValidationRule (:3583), so the formula region's new end marker is right, and indexOf and isArray stay in the object loop, outside the rule pass.
  • packages-disable-module-extension-fields.test.ts: the tenant rule is guarded, as the amendment says.

Implemented-by: claude/project-thread-mn9za6
Reviewed-by: session_01L9qibyToDkPxCjvNiWsv6e

VERDICT: PASS


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#2 · os-tesla · session_01L9qibyToDkPxCjvNiWsv6e

维护者速读 · PR #33205 @ 9d07ffa0 · 2026-11-14T14:37Z

  • 改了什么:对象扩展(objectExtensions / Studio 发布的 object_extension)新增的校验规则,现在在 os build、os validate、os lint 和运行时发布口都用对象自身校验规则的同一套检查判定(judgeValidationRule,规则 id expression-invalid),位置为 object '对象' · objectExtensions[N] · validation '规则'。扩展发布口读对象时会先去掉平台注入的系统列,与 build 读法一致。
  • 为什么改:An object extension's validations are judged at neither the publish door nor os build, yet the registry registers them on the target object #33154。注册表按名字把扩展的规则合并到目标对象上,每次保存记录都会执行,但此前两道门都不判;字段拼错、函数不存在、可空字段没加守卫,都要等最终用户保存时才失败。
  • 风险与回滚:收窄。第一方实测 0 处扩展校验规则受影响;仓库里 2 个测试夹具正是被拒的形状,已修正。草稿保存不受影响,已存的行要等再次发布才判。回滚就是 revert。
  • 先看:packages/lint/src/validate-expressions.ts 里的 judgeValidationRule、扩展遍历新增的循环,以及 extensionWrite 下去掉注入列的那一行(:2377)。
  • 需要你做的:无,席位落地。
  • 席位意见:落地。现 head 契约复审 PASS(6878859677),无 must-fix / should-fix;CI 全绿;非受管面,579 行。

席位核对


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#2 · sunhaolin · session_017xRBcSbLCxEmyHf9upz3pz

维护者速读 · PR #33205 @ 9d07ffa0 · 2026-11-14T15:28Z

  • 改了什么:对象扩展新增的校验规则,现在在 os build / os validate / os lint 和运行时发布口,都按对象自身规则的同一套检查判定。扩展发布口读对象时先去掉平台注入的系统列,与 build 的读法一致。
  • 为什么改:An object extension's validations are judged at neither the publish door nor os build, yet the registry registers them on the target object #33154。扩展的规则每次保存记录都会执行,但此前两道门都不判,写错要等最终用户保存时才暴露。
  • 风险与回滚:收窄。第一方实测 0 处受影响;草稿保存不受影响。回滚即 revert。
  • 先看:packages/lint/src/validate-expressions.ts 的 judgeValidationRule 与扩展遍历循环。
  • 需要你做的:无,本席落地。
  • 席位意见:落地。契约复审 PASS 在现 head 上;CI 全绿;非受管面;579 行。

席位核对

ACCEPT. This is the seated domain:spec#2's verdict; the card thread's ACCEPT 6878959095 is an input and is not repeated here.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 14, 2026 15:28
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 14, 2026
Merged via the queue into main with commit 27d042f Nov 14, 2026
118 of 120 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-mn9za6 branch November 14, 2026 15:57
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…a flow condition (objectstack-ai#33255)

Fixes objectstack-ai#33176

Clause-②: yes (widening) — `validate_expression` gains an optional
input, `variables`, carrying the flow's declared variables at `site:
'flow_condition'`, so the tool accepts a call it refuses today
(`strictToolInput`); with no variables the answer is unchanged.
Metadata-protocol: none
Skills-docs: follow-up objectstack-ai#33272

## 维护者速读

- 改了什么:MCP `validate_expression` 在 `flow_condition` 位点新增可选入参
`variables`(流程声明的变量,形状即 spec 的
`FlowVariableSchema`)。给了它,探针流程声明这些变量,运行时流程门禁自己的"变量遮蔽同名字段"告警会回来;共享校验器把这些裸名当变量,不再按字段判类型。
-
为什么改:流程运行时先绑定声明的变量、再平铺记录字段,所以与字段同名的裸名读到的是变量;工具此前拿不到变量,会按字段给出类型判定,也给不出门禁的遮蔽告警,代理保存流程时才看到不同的答案。
- 风险与回滚:只加一个可选入参;不传时每个调用的答案与之前逐字相同(既有 72 个工具级用例不改动即为对照);门禁接受集不变。回滚即
revert 本 PR。
- 先看:`packages/lint/src/authored-site-expression.ts`(`authoredFlowProbe`
声明变量)、`packages/mcp/src/mcp-http-tools.ts`(`variables`
入参、非流程位点拒收、`flowVariables` 提示、`gatePassFindings` 传参)。
- 两分钟验证:`pnpm --filter @objectstack/mcp exec vitest run
src/mcp-validate-expression.test.ts`,预期 77 个测试全过,其中 `title * 2 > 10` 带
`variables` 时无类型错误且得到门禁的遮蔽告警,不带时报 `type-mismatch-run-fails`。
- 需要你做的:无,席位落地。

## What changes

**Input shape: an optional `variables` input, not "read from a named
served flow".** I chose the input. At a flow condition the tool reads
only the subject object's served definition. Reading a named flow would
need a new bridge member on both doors (the runtime bridge and the stdio
bridge), a permission fence for flow metadata, and an answer for a flow
that is not saved yet, which is the usual case while an agent authors
one. That is outside this claim's file surface. The input takes the
flow's own shape, `z.array(FlowVariableSchema)` from
`@objectstack/spec/automation`, so an agent can hand over a flow's
`variables` array as it stands. A malformed variable gets the spec's own
refusal (a missing `type`, a `$` name, an alias key such as `input`). No
new shape is written by hand, which follows the `AggregationNodeSchema`
precedent on `aggregate_records`.

With `variables` at `site: 'flow_condition'`:
- **Gate half.** `gatePassFindings` hands the variables to
`judgeAuthoredSiteExpression`, and `authoredFlowProbe` declares them on
the one-flow probe. The gate's own walk then runs
`warnShadowedFieldReads` on the probe's edge and gives its warning for a
variable named like a field of `objectName` that is read bare. ⛔ Nothing
is re-implemented: the probe only declares what the flow declares.
- **Validator half.** The shared validator gets the names through its
existing option `ExprSchemaHint.flowVariables`, the key the gate hands
it on the same flow. A bare read of a declared variable is therefore not
typed as the field. "Typed as the variable" means what it means at the
gate: the bare name stays `dyn`. Neither the gate nor the validator
types a variable by its declared `type`, so the tool does not either.
- `record.FIELD` still reads the field and is judged as before.

Without `variables` nothing changes. The probe carries no `variables`
key and the hint carries no `flowVariables` key, so every call answers
byte for byte as before. The tool description and the input description
say that the shadowed-read warning needs the variables.

`variables` on any other site is refused, as `startCondition` is: ``
`variables` describes a flow; it applies only with site "flow_condition"
``.

**stdio.** Measured: both transports register one tool definition
through `wireBridgeTools`, and the stdio bridge already serves
`servedObjectDefinitionOf`. So `stdio-data-bridge.ts` needs no change. A
parity pin drives a real `StdioServerTransport` and the HTTP door with
the same arguments.

**Measured against the dispatch's mechanism notes** (on `origin/main`
`295ce127`):
- The input schema took `objectName, expression, site, severity,
triggerKind, sweepObject, startCondition, field`. Holds.
- The probe declared no variables. Holds; the module header said so.
- Does the validator have an option for extra bindings? Yes:
`flowVariables`, names only. It does not type a variable at all, so a
bare variable is left untyped rather than typed by the variable's
`type`.
- Does stdio serve the same definition? Yes, as described above.

## Tests

- `packages/lint/src/authored-site-expression.test.ts` (50 → 57)
- **The flow-condition table.** `warnShadowedFieldReads` moves from
`pass-silent-here` to `pass`. Its fixture now carries `variables`, and
the entry is pinned equal to the runtime gate at the start, `decision`
and edge slots of a hand-written flow that declares the same variables
(+2 slot cases).
  - **New block `with the flow's declared variables (objectstack-ai#33176)`** (+5):
- the probe declares the variables as handed, and has no `variables` key
without them;
- CONTROL: without variables the gate and the entry both say nothing;
    - a variable that shadows no field gets no warning;
    - only the bare read is warned, and `record.title` is not;
- every trigger kind, and a condition after a start condition, answers
as the gate.
- `packages/mcp/src/mcp-validate-expression.test.ts` (72 → 77)
- (a) Variable `title` shadows the text field `title`, read bare in
`title * 2 > 10`. The tool's whole verdict, validator half included,
equals the gate's verdict on a flow declaring it: one shadowed-read
warning, no errors, `ok: true`. The finding names `title` and `gp_req`.
- (b) CONTROL, the same call without `variables`: `ok: false` with
`type-mismatch-run-fails`, the bare name typed as the field, equal to
the definition-less bridge's answer.
  - The warning is the gate's after a `startCondition` too.
- (d) A variable that shadows no field (`threshold`) gets `[true, [],
[]]`, as at the gate.
- The spec's own variable refusals: a missing `type`, `$record`, the
alias `input`.
- (c) The refusal table gains three rows: `variables` at `validation`,
at `template` and at the default site.
- `packages/mcp/src/mcp-stdio-tools.test.ts` (18 → 20): the same
`variables` input schema is advertised on stdio and HTTP. The shadowed
call, the CONTROL call and the off-site refusal each give the same
`tools/call` result on both transports, and the three answers differ as
the input says they should.

## Acceptance notes

- **The validator half is handed the declared variables, not every name
the run binds.** On a real flow the gate also leaves node ids, `screen`
field names and the engine's own names (`record`, `previous`, `vars`,
`current_user`) untyped. The tool is handed what the flow declares under
`variables`, so a bare name that one of those others holds is still
typed as the field here. The gate's shadowed-read warning reads declared
variables only, so that warning is exact.
- **`type` is required by the spec's shape and read by neither half**,
the same as at the gate.
- **Ruling grep** (`ruling|Ruling-ref|maintainer|⛔|objectstack-ai#33147|objectstack-ai#32872`) in
the touched functions:
- `authored-site-expression.ts`: one binding line, "⛔ Nothing here
re-implements a pass", which this change keeps. Every other hit is a
provenance tag.
- The `validate_expression` handler and `gatePassFindings` in
`mcp-http-tools.ts`: no ruling, maintainer or ⛔ line, and 10 provenance
tags.
  - No maintainer ruling on objectstack-ai#33176.
- **Serial constraint with objectstack-ai#33205** (draft, objectstack-ai#33154). I read its diff at
head `9d07ffa0`. It touches `authored-site-expression.test.ts` at lines
103–153 (`walkPushes`, `CYCLE`) and `validate-expressions.ts`. This PR
touches that test file only at lines 455–780 and does not touch
`validate-expressions.ts`, so no hunk is shared.
- The header of `authored-site-expression.ts` said the shadowed-read
warning never fires through the entry. It now says the warning fires
when the variables are given, and does not fire, as before, when they
are not.

## Verification

Head `4cae1f45ab` (`origin/main` `295ce127` plus two commits). Every
reading below was taken at that head.

<details><summary>Package suites, typecheck and lint</summary>

```
os-verify-lock: pnpm --filter @objectstack/lint --filter @objectstack/mcp run test
packages/lint test:  Test Files  208 passed (208)   Tests  8877 passed (8877)
packages/mcp test:   Test Files  64 passed (64)     Tests  1174 passed (1174)
VERDICT command-exit 0
os-verify-lock: pnpm --filter @objectstack/lint --filter @objectstack/mcp run typecheck
packages/lint typecheck$ tsc --noEmit && pnpm check:test-typecheck
packages/mcp typecheck$ tsc --noEmit && pnpm check:test-typecheck
VERDICT command-exit 0
pnpm lint (eslint . --no-inline-config) :: exit 0
```

</details>

<details><summary>Ablations (each through scripts/ablation-replace.mjs;
each restored with blob == HEAD and git diff HEAD empty)</summary>

```
L1  lint: the probe declares no variables (the `variables` spread in authoredFlowProbe deleted)
      lint suite reads src: 6 failed | 51 passed (57) — the 3 warnShadowedFieldReads slot cases,
      the probe read-back, the bare-read-only case, the trigger-kind/start-condition case
A1  mcp: the validator hint loses `flowVariables`
      1 failed | 96 passed (97) — "given the flow's variables, a bare read of one is the variable"
A2  mcp: `variables` not handed to the gate
      3 failed | 94 passed (97) — the whole-verdict pin, the start-condition pin, the stdio parity pin
A3  first attempt void: deleting the `if` line alone left a syntax error, no tests ran. Re-done as A3b:
A3b mcp: the off-site refusal disabled (`if (false)`)
      2 failed | 95 passed (97) — the refusal table, the stdio parity pin
```

The MCP suites read `@objectstack/lint` through its `dist/` (no vitest
alias). L1 was read on the lint suite, which imports `src`. The MCP leg
of the probe is covered by A2.

</details>

<details><summary>Derived gate families (dispatch-gates --commands, 67
families; --ran reconciliation)</summary>

```
dispatch-gates: gate list derived from the tree of 'objectstack-ai/objectstack' at commit 4cae1f4
65 families :: exit 0
pnpm check:dual-build-cjs-loads :: exit 3   PREREQUISITE NOT MET (no full build here) — NOT MEASURED, CI's Lint & Repo Gates runs it
pnpm check:lean-entry-closure   :: exit 3   PREREQUISITE NOT MET (objectql dist absent) — NOT MEASURED, same
✓ dispatch-gates --ran: 67 derived famil(ies) accounted for — 65 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3).
```

`test:repo` and the full farm are CI's. No export was renamed or
removed, so `check-platform-checklist` is not owed. Full dogfood is not
owed: the title has no `!` and the Clause-② arm is `(widening)`.

</details>

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

<!-- signed: domain:server#7 · sunhaolin ·
session_017xRBcSZ51q2s3nMfakhdJ3 -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…one-hop leaf through an extension-added lookup, and the regex and JSON-schema checks of an extension's validation rules (objectstack-ai#33398)

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

Fixes objectstack-ai#33216
Fixes objectstack-ai#33217

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 two shapes an object extension could carry before: a
validation rule or formula reading `record.REF.LEAF` through a lookup an
extension adds where the lookup's target serves no `LEAF`, and a
`format` / `json_schema` validation rule an extension adds whose regex
or schema does not compile or names an unregistered format. No exported
type or signature changes. Measured first-party exposure: 0
`objectExtensions` entries add a lookup or a validation rule
(`examples/app-showcase` one entry, three plain fields;
`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 rule-table row
marks the extension door, and the object extension paragraph names both
checks); `skills/objectstack-data` teaches one-hop reads, `format` /
`json_schema` rules and `defineObjectExtension({ extend, fields })`
without saying an extension is exempt from either check, so the build
and the door now give the verdict the object's own declarations already
get.

Precedent followed: objectstack-ai#33154 (PR objectstack-ai#33205), which built the extension walk
these two cards extend and declared the same `no (narrowing)` /
`narrowed` pair.

## 维护者速读

- **改了什么**:对象扩展(`objectExtensions` / Studio 发布的
`object_extension`)补上两项对象自身早已有的检查。①
通过“扩展新增的查找字段”做一跳读取(`record.manager__c.字段`)时,目标字段名现在按“对象实际提供的结构”判定,拼错即拒,和通过对象自身声明的查找字段一样(同一规则
id `expression-invalid`、同一句提示)。② 扩展里 `format` 规则的正则、`json_schema` 规则的
schema 及其 format 名,现在和对象自身规则一样检查(同三个规则 id),位置为 `object '对象' ·
objectExtensions[0] · validation '规则'`。两项在 `os build` 与运行时发布口结论一致。
-
**为什么改**:注册表把扩展字段和扩展校验规则合并到目标对象上,每次保存都会执行;此前拼错的一跳字段让公式恒为空、让校验规则拒绝每次保存,写错的正则或
schema 则在每次写入时被跳过,规则形同虚设,都要等最终用户保存时才暴露。
- **风险与回滚**:收窄;第一方实测 0
处扩展新增查找字段或校验规则,无既有元数据被新拒。对象自身的规则、公式与一跳读取的位置和结论不变;草稿保存不受影响,已存的行再次发布时才判。回滚即
revert。
-
**先看**:`packages/lint/src/validate-expressions.ts`(`refuseUndeclaredHopField`
与 `storedMetadataBodyReferencesFor` 改读
`typedObjects`)、`packages/lint/src/validate-rule-compilability.ts`(`walkObjectValidationRules`
新增的扩展循环)、`packages/lint/src/authoring-rules.ts`(两条规则的 `runtimeTypes` 加
`object_extension`)。
- **两分钟验证**:`pnpm --filter @objectstack/lint exec vitest run
src/runtime-gate.object-formula-writes.test.ts
src/validate-rule-compilability.test.ts -t "33216|33217"`,预期 16
条全过:扩展查找字段后拼错的叶子字段、扩展的坏正则/坏 schema/拼错的 format 名在 build
与发布口都被拒且结论逐条相同,正确写法通过,对象自身的用例不变。
- **需要你做的**:无,席位落地。

## What changes

Two commits, one per card.

**objectstack-ai#33216 — `packages/lint/src/validate-expressions.ts` (hop-index region
only).**

- `refuseUndeclaredHopField` looked the hopping reference up on the
declared `objects`, so a lookup an `objectExtensions` entry adds was
never found and its leaf never judged. It now reads `typedObjects`, the
served fold objectstack-ai#30471 already builds (every extension field folded in, a
field two packages tie on left out), the same fold `fieldIndex` reads
for the leaf. A hop through a declared lookup reads the same definition
as before, so the object's own verdicts and locations do not move.
- `storedMetadataBodyReferencesFor` takes a `served` flag. The hop
refusal (`refuseStoredMetadataBodyHop`) asks for the served reading, so
a hop through an added lookup into a stored-metadata-body table is
refused as through a declared one. The object walk's objectstack-ai#24677
field-reference verdict keeps the declared reading, so a field an
extension adds is never charged to the object's own location. One map
holds both readings (a served reading is keyed `served:NAME`), so the
objectstack-ai#5017 receiver scan sees no new receiver.
- Both sites serve the build and every door that runs the expression
passes; at the `object_extension` door the written entry is folded into
the door's live objects by the same fold, so the verdict is the build's.
-
`packages/spec/src/migrations/entries/semantic/18.object-extension-added-lookup-hop-leaf-judged.ts`:
the ADR-0087 D3 entry. No D2 conversion: which field the author meant is
a fact only the author holds.

**objectstack-ai#33217 — `packages/lint/src/validate-rule-compilability.ts`,
`validate-rule-schema-formats.ts`, `authoring-rules.ts`.**

- `walkObjectValidationRules` (the one walk both rules share, so they
cannot disagree about which rules exist) also walks each rule an
extension adds, through `objectExtensionsByTarget` (the fold objectstack-ai#33205's
extension walk reads: one entry per package per target, as the registry
keeps them), `conditional` branches flattened in. Located at the entry:
`where` `object 'T' · objectExtensions[i] · validation 'N'` (the locus
objectstack-ai#33205 uses), `path` `objectExtensions[i].validations.N.regex` /
`.schema` (the entry's path in place of the object's `objects.T`),
`packages[j].manifest.` prefixed in a built artifact. The rule ids are
unchanged. An undeclared target is judged all the same: a regex or
schema needs no field of the target.
- `validateRuleCompilability` and `validateRuleSchemaFormats` cross onto
the `object_extension` door (`runtimeTypes: ['object',
'object_extension']`), together, as their objectstack-ai#7220 family discipline
requires. On that write the snapshot carries the written entry as its
sole extension; the target's own rules the door's live objects carry are
judged in the gate's baseline as well, so the differential charges the
write with its entry's findings only.
-
`packages/spec/src/migrations/entries/semantic/18.object-extension-validation-rule-artifacts-judged.ts`:
the ADR-0087 D3 entry.
- `content/docs/deployment/validating-metadata.mdx`: the "Declared
enforcement that cannot run, declared on the object being written" row's
runtime column now reads `✓ᵒᵒˣ`, and the object extension paragraph
names both checks. Both statements were made false by this change
(os-dev rule 4).
- `.changeset/33216-extension-lookup-hop-and-rule-artifacts.md`:
`@objectstack/lint` minor and `@objectstack/spec` minor, both
declaration lines, a BREAKING banner (Before / Now / Unchanged / Fix)
and `adr-0087: registered` naming both entries.

## Tests

1. **`packages/lint/src/runtime-gate.object-formula-writes.test.ts`**,
new describe `objectstack-ai#33216` (7 cases), at the real gate
(`runRuntimeAuthoringRules`) and the build (`runAuthoringRules('build',
…)`):
- LIT: a rule reading `record.manager__c.daly_hours` through the added
lookup is refused at the door at
`objectExtensions[0].validations[0].then.condition`, the build's
findings deep-equal the door's, and the message equals the
declared-lookup case's with the reference name taken out.
   - LIT: the same for a formula field the extension adds.
- LIT: the object's OWN formula reading through a lookup a package's
extension adds is refused at the build, at the object; its control (the
declared leaf) is clean.
- LIT: a hop through an added lookup to `sys_metadata` is refused as a
stored-metadata-body hop.
- CONTROL: the correct leaf through the added lookup is clean at both
doors, rule and formula.
   - A lookup two packages add at the same priority is left unjudged.
- CONTROL: the object's own hop through a declared lookup is refused at
the object save door and the build, at its own location, as before.
2. **`packages/lint/src/validate-rule-compilability.test.ts`**, new
describe `objectstack-ai#33217` (9 cases): both rules on both doors; an invalid regex,
an uncompilable schema and a misspelt format name an extension adds each
refused at the build with rule id, `where` and `path`; each refused at
the door with the build's finding byte for byte; a `conditional` branch
located at the branch; the same rule ids as the object's own (whose
locations are pinned unchanged); valid rules clean at both; a sibling
package's entry located at its body and an undeclared target judged; the
target's own broken rule not charged to the extension write; the object
save door unchanged.
3.
**`packages/runtime/src/domains/meta-object-extension-item.test.ts`**,
through the real `saveMetaItem` + `publishMetaItem`: `[objectstack-ai#33216]` 4 cases
(rule and formula: a misspelt leaf through the added lookup gets 422
`INVALID_METADATA` with the build's rule id, location and path, the
field is not served and the row stays a draft; the correct leaf
publishes and is served); `[objectstack-ai#33217]` 3 cases (an invalid regex and an
uncompilable schema each get 422 with the build's rule id and locator,
the rule is not served; valid ones publish and are served).
4. **Roster pins moved with objectstack-ai#33217** (each lists the `object_extension`
door's rules exactly): two in
`runtime-gate.object-formula-writes.test.ts` (objectstack-ai#33072), two in
`validate-security-posture.runtime-surface.test.ts` (objectstack-ai#31998; surface
amendment 6881180427).

**Ablations** (one-shot, nothing permanent; each through `node
scripts/ablation-replace.mjs` on the committed head, then `pnpm --filter
@objectstack/lint build`, then `ablation-dist-preflight` found the
marker in 4 built files; runtime pins read lint through `dist/`):

- A1, the served hop reference (`for (const obj of typedObjects)` →
declared `objects`): lint 3 of 94 red, runtime 2 of 40 red, exactly the
five objectstack-ai#33216 LIT cases (rule and formula at both doors, the object's own
formula); every control green.
- A1b, the served stored-metadata-body reading
(`storedMetadataBodyReferencesFor(objectName, true)` → declared): lint 1
red, the stored-metadata-body LIT; runtime 40/40.
- A2a, the extension loop of the shared walk (entries filtered to none):
lint 6 red (the five objectstack-ai#33217 build and door LITs and the sibling case,
plus the objectstack-ai#5096 receiver meta-test, which reds on the marker's own
`entries.filter` spelling, not on behaviour), runtime 2 red (the regex
and schema door LITs); the controls, the differential case and the
object door green.
- A2b, the door crossing (`validateRuleCompilability`'s `runtimeTypes`
back to `['object']`): lint 7 red (the door LITs, the roster pins, the
`rulesRun` controls), runtime 2 red (the door LITs).
- Restore after each: the blob equals HEAD and `git diff HEAD` is empty
(the tool's verdict). Lint was rebuilt after the last leg; no marker
remains in `packages/lint/dist` (`grep` 0 files for each of the four)
and `git status --porcelain` is empty.

## Acceptance notes

- **Exposure measured:** `git grep` of `objectExtensions` /
`defineObjectExtension` over `examples/`, `packages/` (non-test) and
HotCRM `origin/main`: two entries, neither adds a lookup or a validation
rule. Every test file in `packages/metadata-protocol` (7 files, 251
tests) and `packages/runtime` (7 files, 136 tests) that publishes or
reads an `object_extension` passes at the head.
- **Not changed, by the order's fence:** the null-guard index
(`buildNullableFieldIndex`) and the `extensionWrite` strip, which are
objectstack-ai#33246's; objectstack-ai#33153 (a formula cycle an extension adds) and objectstack-ai#33101 are not
folded.
- **A reference an extension redeclares on the target** (the same field
name, a different `reference`) is now read as served at a hop site,
which is what the engine plans. The object walk's own field-reference
verdict still reads the declared field, so such a field is not charged
to the object's location.
- **Boot-registered module packages** (`defineStack({ objectExtensions
})` through `registerApp`) are not gated, as an object's own rules are
not.

## Verification

Head `d190a7f0` (base `87330e89`); `git diff --stat 87330e8
origin/main` over every touched file is empty at hand-over time, so no
merge was needed.

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

- `@objectstack/lint`: 208/208 files, 8902/8902 tests; typecheck exit 0.
- Runtime door files (`meta-object-extension-item.test.ts` +
`packages-disable-module-extension-fields.test.ts`): 81/81.
- Every other test file that publishes an `object_extension`:
`@objectstack/metadata-protocol` 7 files 251/251; `@objectstack/runtime`
7 files 136/136.

</details>

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

The derivation at `d190a7f0` is 109 lines. Every line ran with stdin
closed and its exit code captured before any pipe. 107 exited 0 on the
first pass. Two exited 3 (refused, nothing measured) on a missing build:
`pnpm --filter @objectstack/spec run check:skill-examples` (no
`@objectstack/client-react` dist) and `pnpm check:dual-build-cjs-loads`
(needs every package's dist). After a whole-repo `pnpm build` both
exited 0. `dispatch-gates --ran`: `109 derived, 109 run, 0 NOT-MEASURED,
0 UNRUN`. The record is `pm-orders/spec/33216-gates-ran.txt` in the
project share.

</details>

Dogfood (the title carries `!` and `Clause-②:` the `(narrowing)` arm):
full battery, the CI command (`pnpm --filter @objectstack/dogfood test`
under the verify lock), no shard, on head `d190a7f0` after a whole-repo
build. Result: `VERDICT command-exit 0`, Test Files 464 passed and 3
skipped (467), Tests 3927 passed and 42 skipped (3969), no failures.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…d on the current row's created_at and updated_at in an ordering comparison (objectstack-ai#33434)

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

Fixes objectstack-ai#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: objectstack-ai#33154 (PR objectstack-ai#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`、读事件钩子上的差异留给 objectstack-ai#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`(objectstack-ai#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 objectstack-ai#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 objectstack-ai#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 `objectstack-ai#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 `objectstack-ai#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 `objectstack-ai#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 `objectstack-ai#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 (objectstack-ai#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 (objectstack-ai#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

- **Door versus build, still split:** the door judges `owner_id`,
`created_by`, `updated_by`, `owning_business_unit_id`, `queue` and
`organization_id` nullable, and judges `created_at` / `updated_at` in a
`beforeInsert` or read-event hook; the build judges no injected column.
objectstack-ai#33435 owns that verdict; the changeset says so.
- **Type verdicts:** the build's type index has no injected column
(`dyn`), the door's has them. Unchanged by this PR.
- A record-triggered flow's `record.created_at + 1 > 0` is not
type-checked at the door on `main` or here (only the bare spelling is);
the null guard refuses it, on `main` and here (M1).
- A flow on `record-before-create` binds a `beforeInsert` hook at the
default priority (100), after the stamp (10), so the flow sites are not
excepted.
- The door has no general gate against a `record.` read in a read-event
hook condition (the engine rejects such a read at run time, objectstack-ai#4775); S2
only keeps this PR's skip off those hooks. Reported to the seat for a
card.
- **Out of scope, unchanged:** a hop leaf through an injected lookup
(`record.owner_id.nmae`) is judged at neither door.

## 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 fc283d6 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`.

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

- `@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.

</details>

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

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.

</details>

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

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

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

---------

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.

An object extension's validations are judged at neither the publish door nor os build, yet the registry registers them on the target object

2 participants