Skip to content

fix(formula)!: a flow condition's record. / previous. read of a date field takes the date-text verdicts, so timestamp(record.DATE_FIELD) is refused as its bare name is - #34935

Merged
objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/issue-34662-flow-record-date-text
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/issue-34662-flow-record-date-text

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Fixes #34662

Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — skills/objectstack-formula/SKILL.md already states the date-text-call rule (a date / datetime field handed to a timestamp-only call, and timestamp() over a date field) with record.FIELD spellings and names no site it is limited to, so it now holds for a flow condition's root reads as written

维护者速读

  • 改了什么:flow 条件(start / edge / decision 分支)里通过 record.FIELD / previous.FIELD 读日期字段时,现在与裸字段名一样接受 date-text 这一族校验;timestamp(record.borrow_date) < now()(borrow_date 为 date 字段)在 os validate 和 flow 发布门被拒,错误码、措辞、结果分支(date-text-call-run-fails 等)与裸名写法相同,提示改写为 date(record.borrow_date) 或 isoDate(addDays(record.borrow_date, N))。
  • 为什么改:运行时 date 字段是 YYYY-MM-DD 文本,timestamp() 解析不了,这条 flow 每次运行都失败;裸名写法早已被拒,record. 写法却零告警通过。
  • 风险与回滚:收窄(BREAKING,按 minor 发布):以前能通过 os validate 和发布的 flow 条件,若经 record. / previous. 把 date 字段交给 timestamp()(或交给 isoDate()、做文本日期运算),现在被拒,直到改写为 date(record.FIELD);registerFlow 仍只记 advisory 日志、照常注册,已存的 flow 在下次发布前继续运行。datetime 字段、date(...) 改写、Timestamp 类型已判的形状(record.due_date + 1)不受影响。回滚即 revert 本 PR。
  • 先看:packages/formula/src/validate.ts(recordRootDateTextIssue 与 typeSoundnessIssue 的接入点)、packages/formula/src/cel-engine.ts(firstDateTextCall / firstDateTextVerdict 新增的 recordRootTypes 参数与 recordRootReadsFaultTimestampTyping)、.changeset/34662-flow-record-date-text.md。
  • 两分钟验证:pnpm --filter @objectstack/formula exec vitest run --maxWorkers=2 src/validate-date-text-arithmetic.test.ts -t 34662,预期 6 个用例全部通过。
  • 需要你做的:无,席位落地(受管面未触及);本 PR 是收窄,落地前需一次契约复审记录,由席位路由。

What changes

A flow condition is evaluated over a scope where the run's row is bound twice: its fields flattened to bare names, and the row itself as record (with the row before the write as previous). The date-text family (date-text-call*, date-text-arithmetic*) typed the bare names only. Measured on origin/main fc5913e through validateStackExpressions, with the card's fixture (library_loan, borrow_date: date, picked_up_at: datetime, start record-after-update):

start condition findings before findings after
timestamp(record.borrow_date) < now() 0 1 error, record.borrow_date named
timestamp(borrow_date) < now() 1 error 1 error (unchanged)
timestamp(previous.borrow_date) < now() 0 1 error, previous.borrow_date named
timestamp(record.picked_up_at) < now() (CONTROL) 0 0

The same holds on an edge condition and on a decision branch. The other members of the family missed root reads the same way and are covered by the same change: isoDate(record.picked_up_at) == '...' (0 findings before; the bare isoDate(picked_up_at) was refused) and record.due_date - record.borrow_date > duration('24h') (no date-text finding before).

  • packages/formula/src/validate.ts: typeSoundnessIssue runs a record-root pass after the bare-name date-text pass, at flattened scope only: recordRootDateTextIssue. It types record.FIELD / previous.FIELD with every field's type (a flow variable shadows a bare name, never a root member), leaves every bare name dyn, and keeps only date-text-call* / date-text-arithmetic*. This is the record-root pass firstTypeMismatch already runs for the text/boolean mismatch, applied to the date-text family. The outcome arm is the row's (dateArm with bareNamesUnproven false), as a root read keeps its outcome for type-mismatch. A shape the Timestamp typing of the roots already faults on (record.due_date + 1) belongs to the date-arithmetic family and stands down, the same order the flow value envelope uses. dateTextIssue / dateTextCallIssue take the optional root typing, and the message names the read as written (verdict.root).
  • packages/formula/src/cel-engine.ts: firstDateTextVerdict and firstDateTextCall take an optional recordRootTypes (flattened scope only) and pass it to buildTypedEnv. On that pass a root read qualifies by the root typing alone, so an input.FIELD read does not qualify. Without the argument every call is unchanged. DateTextVerdict gains the optional root. recordRootReadsFaultTimestampTyping is the stand-down probe. None of these is on the package's public entry.
  • .changeset/34662-flow-record-date-text.md: minor for @objectstack/formula (the kind narrowed takes at least minor), with the declaration lines, the BREAKING banner, a FROM to TO table and the ADR-0087 disposition already-registered naming the three semantic entries (formula-timestamp-date-only-refused, formula-date-text-call-refused, formula-date-subtraction-refused). Their surface text already names flow conditions among the predicates judged with field types, spelled with record.FIELD, so it is left as is: this change makes that text true for a root read. No entry, generated file or registry changes.

No producer change was needed outside packages/formula. @objectstack/lint (os validate, and the runtime publish gate that runs the same runStackExpressionPasses body) and @objectstack/service-automation (registerFlow) already hand flow conditions the flattened hint with field types and the declared outcome. The fix reaches all three through the shared validator.

Tests

  • packages/formula/src/validate-date-text-arithmetic.test.ts: new top-level describe in the date-text harness. record. and previous. over a date field are refused under date-text-call-run-fails with full params (call, reference, rewrite, shift), and the evaluator faults on them over the run's scope. CONTROL: datetime and the prescribed date(...) parse are clean and evaluate to true. Arm pins: run-may-fail with no declared outcome; run-fails kept on a root read when bare names are unproven. A flow variable shadowing the bare name leaves the root read judged. isoDate(record.picked_up_at) and root-read date-text arithmetic are refused. The stand-downs (record.due_date + 1, an input. read) take no date-text code.
  • packages/lint/src/validate-expressions.test.ts: new top-level describe. Start, edge and decision conditions refuse record. / previous. at the bare name's path and severity, with the shift text. Rule id expression-invalid through runAuthoringRules('build', ...). CONTROL: datetime stays clean through either root at all three sites.
  • packages/runtime/src/domains/meta-flow-condition-record-date-text.test.ts (new; the flow publish door, saveMetaItem then publishMetaItem over the real engine): the bare name, record. and previous. are each refused with { code: 'INVALID_METADATA', status: 422 }, one expression-invalid date-text issue each, and the item left draft. CONTROL: datetime through either root publishes (active).
  • packages/services/service-automation/src/flow-registration-schema-e2e.test.ts: new describe. registerFlow logs the date-text advisory for record. / previous. as for the bare name and registers the flow. CONTROL: datetime is not advised.

Ablation, after the fix was committed (scripts/ablation-replace.mjs --hold, trap restore): the record-root pass was disabled in validate.ts (call guarded by a literal that never equals the source), @objectstack/formula rebuilt, and ablation-dist-preflight.mjs confirmed the marker in dist/index.js and dist/index.mjs. Result: formula 4 failed / 83 passed, lint 4 failed / 1 passed, service-automation 1 failed / 4 passed, runtime 1 failed / 1 passed. Every refusal pin went red and every CONTROL stayed green. Restore: blob equal to HEAD, git diff HEAD empty, rebuilt, --absent preflight clean, git status --porcelain empty.

Acceptance notes

  • Declaration (seat ruling, L1 REWORK round 1). Clause-②: no (narrowing), Metadata-protocol: narrowed: a pure narrowing, since the new recordRootTypes parameter is on non-exported functions and nothing published widens. A contract-review-tier L2 review is owed before the queue; the seat routes it.
  • The publish door for a flow condition is publishMetaItem (seat: accepted as landed). registerFlow logs a condition's schema-aware findings as an advisory and never throws, by contract (Formula guardrail: cel-js arithmetic silently returns null (double × int + bare identifiers) #1928, flow-registration-checks.ts); it does not refuse the bare spelling either. The refusal with code / status is the metadata publish gate (INVALID_METADATA / 422), pinned in packages/runtime; registerFlow is pinned for advisory parity.
  • Test placement. The dispatch asked for a new test file named after the card. AGENTS.md (ruling record 6583487846) puts a new pin for a component that already has a shared harness into that file as a top-level describe. So the formula, lint and registerFlow pins went into their existing harnesses. The publish-door pin is a new file, because no harness pins a flow condition's date verdict at that door.
  • The record root is typed even when a flow declares a variable named record. The type-mismatch record-root pass has always done the same, and this change does not alter it.
  • Same-shape gap outside this family, not fixed here: the date-arithmetic verdict (Timestamp typing, due_date + 1 > 5) refuses the bare name in a flow condition but not record.due_date + 1 > 5 / previous.due_date + 1 > 5. Measured on this branch with a required date field: 1 error and 0 / 0 findings. The seat files it; this family stands down on that shape so as not to change its code.

Verification

Final head 60d4e1c. Dogfood battery on it (the (narrowing) arm): pnpm --filter '@objectstack/dogfood^...' build then pnpm --filter @objectstack/dogfood test under the lock, VERDICT command-exit 0, Test Files 479 passed / 3 skipped (482), Tests 4072 passed / 68 skipped (4140). Merged-head (653f1fb) package tests and typechecks: formula 68 files / 1878 tests, lint validate-expressions.test.ts 505/505, service-automation e2e 5/5, runtime publish-door 2/2, all four typechecks green. Gate readings and CI: the os-dev-report comments on the card.

Premise table on origin/main fc5913e (built lint dist)
[start] timestamp(record.borrow_date) LT now() -> 0
[start] timestamp(borrow_date) LT now() -> 1 (error, `borrow_date` is a date field ...)
[start] timestamp(record.picked_up_at) LT now() -> 0
[start] timestamp(previous.borrow_date) LT now() -> 0
[edge]  same three rows: 0 / 1 / 0

(LT spells the less-than operator.)

After the fix (same probe)
[start] timestamp(record.borrow_date) LT now() -> 1 error, `record.borrow_date` is a date field
[start] timestamp(borrow_date) LT now() -> 1 error
[start] timestamp(record.picked_up_at) LT now() -> 0
[start] timestamp(previous.borrow_date) LT now() -> 1 error, `previous.borrow_date` is a date field
[start] timestamp(previous.picked_up_at) LT now() -> 0
[edge]  identical

Generated by Claude Code

@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 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

11 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • 1 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 — 12 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 e8a78c4bdf0ec079cdb56e6e6c6f32d6f4ac8e42 → packageMentionDocs.

Which tree this was computed on

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

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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

…rdict a narrowing

Claude-Session: https://claude.ai/code/session_012MmDsS4GoHCgYwA2uv3n3C
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet objectstack-fleet Bot changed the title fix(formula): a flow condition's record. / previous. read of a date field takes the date-text verdicts, so timestamp(record.DATE_FIELD) is refused as its bare name is fix(formula)!: a flow condition's record. / previous. read of a date field takes the date-text verdicts, so timestamp(record.DATE_FIELD) is refused as its bare name is Nov 17, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

席位核对 · L1 ACCEPT · Head-sha: 60d4e1c · 2026-11-17T19:12Z

Card #34662, revised claim 6955917834, dev reports 6955879892 and 6958060011. The seat read the source diff itself.

Item Reading
Shape Base main, Fixes #34662 first line; ! title. Line-leading in the PR body and the changeset: Clause-②: no (narrowing), Metadata-protocol: narrowed, Skills-docs: none — …. The PR body was patched by the seat from the dev's staged text: os-dev.md:66 says a subagent writes the body only at pr_create and the seat writes it afterwards. Read back identical. Seven files (+525 −24): source only in packages/formula/src/{validate,cel-engine}.ts; pins in formula, lint, service-automation and runtime.
Premise measured Holds (re-measured on fc5913e): record. and previous. gave 0 findings, the bare name 1, the datetime CONTROL 0. After the fix, both roots are refused like the bare name, and the CONTROL stays clean.
Diff read The record-root pass runs only at flattened scope and only for the date-text family (date-text-call*, date-text-arithmetic*). It types record./previous. reads with every field's type and leaves bare names dyn. The new recordRootTypes parameter is optional, so every existing call is unchanged without it. Shapes the Timestamp typing already faults (record.due_date + 1) stand down to the date-arithmetic family. Same rule ids and message shape as the bare name and #34363/#34451; no new verdict. None of the touched functions is on the package's public entry.
Assertions Pins at the formula harness, validateStackExpressions (start, edge, decision × record, previous), the publish door ({ code: 'INVALID_METADATA', status: 422 }, item left draft) and registerFlow (advisory parity). CONTROLs green. Ablation: every refusal pin red, every CONTROL green, restore proven.
Gates Dogfood battery on 60d4e1c: VERDICT command-exit 0, 479 / 482 files, 4072 / 4140 tests, no failures. Local derived families: 70 of 72 exit 0. Two are NOT MEASURED because of the shared lock (check:dual-build-cjs-loads, check:type-check-debt); both exit 0 at 653f1fb, and CI's Lint & Repo Gates is green on this head. CI: Check Changeset re-runs on the patched body. Type Check UI (a 20-minute history-fetch timeout) and Test UI (7/16) (cancelled) were re-run once through the relay. The diff touches no ui/**.
Accepted deviations Pins went into the existing harnesses (ruling record 6583487846), plus one new publish-door file. The door that refuses is publishMetaItem; registerFlow stays advisory by contract #1928 (seat ruling, revised claim). Skills-docs: none: the formula skill already teaches the rule with record.FIELD spellings.
Out of scope record.DATE + 1 passes where the bare name is refused (date-arithmetic family): filed #34946.
Changeset @objectstack/formula minor, with the BREAKING banner, a FROM-to-TO table and the ADR-0087 disposition already-registered (three semantic entries named). Read against the diff: the refused shapes, the rewrite and the unaffected shapes match the code.
Landing Not governed. Owed before the queue: a contract-review-tier L2 record (narrowing), and every check green on this head.

Contract-review-handoff: l2-review#3 — CONTRACT_REVIEW_TIER not taken in this seat; seat 4 routes contract reviews to the seated L2 seat by mailbox (2026-11-17T19:12Z) · head 60d4e1c

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

Contract-review-claim: session_012MmDsS4GoHCgYwA2uv3n3C · head 60d4e1c · 2026-11-17T20:09Z

The request to l2-review#3 (mailbox #34476) has waited about an hour with no answer, so this lane reviews at tier itself (contract-review.md (b)). The record is written by an isolated reviewer sub-agent at CONTRACT_REVIEW_TIER.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

Contract-review-claim: session_012MmDsS4GoHCgYwA2uv3n3C · head 60d4e1c · 2026-11-17T22:29Z

Renewed: the 20:1x claim lapsed (2 hours, no record) while the reviewer sub-agent was stopped by a usage limit. It resumes now at CONTRACT_REVIEW_TIER.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

L2 round on head 60d4e1c: finding S1 sent back · 2026-11-17T22:46Z

The seat's at-tier reviewer sub-agent read this head and found no must-fix, one should-fix, and three nits. Its record is NOT posted as the record of this head: verify-review-tier.mjs refused its transcript, because one turn is a synthetic usage-limit error turn (every model turn is CONTRACT_REVIEW_TIER). The rule is a fresh at-tier run, never a renamed tier. S1 moves the head anyway, so the fresh record is rendered on the fixed head.

S1 (should-fix). The record-root date-text pass stands down on any operator fault of the roots' Timestamp typing (recordRootReadsFaultTimestampTyping matches UNSOUND_OVERLOAD_RE), not only on the date-arith shape it defers to. So, read from the tree and the cel-js 8.0.0 checker (not run):

  • (a) record.due_date - record.borrow_date GT 3 gives 0 findings, while the bare spelling is refused (date-text-arithmetic-run-fails, the registered formula-date-subtraction-refused shape).
  • (b) record.due_date GE "2026-01-01" && timestamp(record.borrow_date) LT now() gives 0 findings, but is refused with the conjuncts swapped, so the answer depends on operand order. The bare spelling is refused in both orders.
    Fix sent to the dev: route (i), stand down only where the roots' Timestamp-typing fault is date-arith. Pin (a), and (b) in both orders, and keep the record.due_date + 1 control.

Nits sent along: N1, one shared constant for the root-read gate (RECORD_ROOT_READ_RE) and firstTypeMismatch's inline one. N2, firstTypeMismatch's comment "The date verdicts stay the bare name's alone" is now true of date-arith only. N3, a -run-may-fail root-read pin at the lint or door layer is optional.
Also noted by the reviewer, for a follow-up card: the index spelling timestamp(record['borrow_date']) reaches neither pass.

Contract-review-hold: session_012MmDsS4GoHCgYwA2uv3n3C · head 60d4e1c · S1 fix in progress · until the fixed head is pushed

… arithmetic against a number

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

席位核对 · L1 delta ACCEPT · Head-sha: 1ce9b68 · 2026-11-18T00:26Z

Delta from 60d4e1c (ACCEPT 6958189274); dev report 6965070044. The seat read the delta itself.

Item Reading
S1 Route (i). recordRootReadsFaultTimestampTyping becomes recordRootReadsFaultDateArith: true only when the roots' first Timestamp-typing fault matches isDateArith. Both docblocks now say so. Measured red before the edit on 60d4e1c: shape (a) gave [] against the bare [date-text-arithmetic-run-fails], and shape (b) gave [] while the swapped order and the bare spelling were refused. After: (a) gives date-text-arithmetic-run-fails and (b) gives date-text-call-run-fails in both orders, pinned. The record.due_date + 1 stand-down control is kept. Ablation (widen back to any operator fault): exactly the S1 case red, 1 / 88.
Nits N1: one exported RECORD_ROOT_READ_RE, used by firstTypeMismatch and validate.ts. N2: the comment corrected. N3: a lint pin for the run-may-fail sentence on an untriggered flow.
Gates Dogfood battery on 1ce9b68: VERDICT exit 0, 479 / 482 files, 4072 / 4140 tests. Formula 1879 tests, lint 506 / 506. CI: Lint & Repo Gates, TypeScript Type Check, Build Core and Check Changeset success. Two reds are outside this diff and were re-run once through the relay: Test Core (3/10) (packages/qa/scenarios skill-evals.test.ts timed out at 5000 ms) and Test UI (13/16) (cancelled).
Overlap origin/main and PR #35000 (merged) are clean. Draft PR #34978 conflicts in packages/lint/src/validate-expressions.test.ts: two appends to a shared test file, and whichever lands second merges. Accepted. The dev's pipe hid the overlap-check exit before the push; the push went out before the verdict was read. Noted.
Owed A fresh contract-review-tier L2 record on 1ce9b68; the previous round's record was refused by the tier check (synthetic turn).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

Contract-review-claim: session_012MmDsS4GoHCgYwA2uv3n3C · head 1ce9b68 · 2026-11-18T00:27Z

The S1 fix head. A fresh isolated reviewer sub-agent at CONTRACT_REVIEW_TIER renders the record.

…ow-record-date-text

# Conflicts:
#	packages/lint/src/validate-expressions.test.ts
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

席位核对 · L1 delta ACCEPT · Head-sha: 36a9089 · 2026-11-19T02:30Z

Delta from 1ce9b68 (delta ACCEPT 6965140367): one merge of origin/main (e8a78c4bdf). The dev has not reported this round yet; the seat read the merge itself (direct-accept: the head has stood for about two hours with CI green).

Item Reading
Merge Against the main parent the PR still changes exactly its seven files (+583 −27). Nothing else rode in. No conflict marker remains. The one conflict, in packages/lint/src/validate-expressions.test.ts (main had gained other appended cases), is resolved by keeping both sides. cel-engine.ts auto-merged with PR #35000's cache (now on main).
Gates CI on 36a9089: 57 success, 11 skipped, 0 failed. Lint & Repo Gates, TypeScript Type Check and Test Core (all shards) success; the earlier skill-evals timeout and the UI cancel did not recur. Mergeable clean.
Owed A fresh contract-review-tier L2 record on this head.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

Contract-review-claim: session_012MmDsS4GoHCgYwA2uv3n3C · head 36a9089 · 2026-11-19T02:30Z

The merge head. A fresh isolated reviewer sub-agent at CONTRACT_REVIEW_TIER renders the record.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 36a9089a809745c2a0e02ee245a643ae73db07c8
Local-runs: none
Scope: packages/formula/src/validate.ts, packages/formula/src/cel-engine.ts, .changeset/34662-flow-record-date-text.md, packages/formula/src/validate-date-text-arithmetic.test.ts, packages/lint/src/validate-expressions.test.ts, packages/runtime/src/domains/meta-flow-condition-record-date-text.test.ts, packages/services/service-automation/src/flow-registration-schema-e2e.test.ts + packages/formula/src/index.ts, packages/lint/src/validate-expressions.ts, packages/mcp/src/mcp-http-tools.ts, packages/services/service-automation/src/flow-registration-checks.ts, packages/spec/src/migrations/entries/semantic/18.formula-date-subtraction-refused.ts, packages/spec/src/migrations/entries/semantic/18.formula-date-text-call-refused.ts, packages/spec/src/migrations/entries/semantic/18.formula-timestamp-date-only-refused.ts, skills/objectstack-formula/SKILL.md
Security-touching: no

PR #34935 (card #34662), face narrowing: reviewFace returns no hits on this file list, so the floor is the diff itself. ④ grades the two implementing files and the changeset's declaration text; the four test files were read as the pins of those sentences and stay the lane seat's ACCEPT at TIER_DEFAULT (6997857940). The files after + are outside the diff: read to judge, not reviewed. Inputs: the card body and all eight card comments, the PR body, file list and comments, the net diff origin/main...36a9089a80 (merge base e8a78c4bdf, seven files, +583 −27), the merged blobs of validate.ts and cel-engine.ts at the head, and the 68 check-runs on the head. Nothing was built or run; every "gives N findings" below that is not a CI-pinned case is read off the tree and says so.

① Derived judgments

  • Flow condition accept-set (start, edge, decision branch), os validate / os build: narrowed. Right. typeSoundnessIssue now returns bare ?? recordRootDateTextIssue(...) at flattened scope only (validate.ts:556). In @objectstack/lint the only check(...) calls that reach the flattened default with an objectName (hence fieldTypes) are the three flow sites (validate-expressions.ts:3097, 3511, 3749); app landing visible (4653) hands no object. So "in a flow condition" in the changeset is the true extent in lint.
  • Flow publish door (publishMetaItem): narrowed to INVALID_METADATA / 422. Right, through the shared pass; pinned in the new runtime test, item left draft.
  • registerFlow: accept-set unchanged, advisory text gains the root read. Right. flow-registration-checks.ts:745 hands the flattened hint with fieldTypes and no faultOutcome, so the arm there is run-may-fail; registration stays additive (Formula guardrail: cel-js arithmetic silently returns null (double × int + bare identifiers) #1928).
  • MCP expression tool, kind flow_condition: its answer narrows the same way. Right, and not named in the changeset. mcp-http-tools.ts:2693 declares the kind at scope: 'flattened' and hands fieldTypes (3577 to 3607), so the tool now answers the refusal the gate gives. That is the tool's contract ("answers what the gate will"); the changeset's "Where" bullet omits it (N6).
  • Record-scoped sites and the flow value envelope: unchanged. Right. firstDateTextVerdict and firstDateTextCall drop recordRootTypes unless scope === 'flattened'; flowValueEnvelopeDateTextIssue passes none.
  • Refusals only where nothing was reported before. Right. The root pass runs only when firstTypeMismatch answered null and the bare date-text pass answered null, and keeps only date-text-call* / date-text-arithmetic*. No existing verdict changes code, grade or words.
  • Verdict surface: no new code, no new param key. Right. reference, call, rewrite, shift carry the read as written (record.borrow_date); the arm is dateArm('flattened', faultOutcome, false), the lint: a flow condition's bare-name type verdict ignores names a screen node or an open binder (script, connector_action, wait, subflow, map) binds, so a record-triggered flow can be refused type-mismatch-run-fails on a name that holds the bound value #30025 precedent for a root read.
  • Package public surface: nothing added. Right. packages/formula/src/index.ts at the head re-exports neither RECORD_ROOT_READ_RE, recordRootReadsFaultDateArith, firstDateTextVerdict, firstDateTextCall nor DateTextVerdict; the package has one export path (.). The new export keywords are module-level only.
  • Run-time evaluator: unchanged. Right. No hunk outside the check-only paths.
  • Typed-env cache (main's dogfood: object-designer-field-reorder cases time out at 5000 ms on a loaded merge-group shard and kick unrelated PRs from the queue #34756 / PR perf(formula): the expression type checks build each typed check environment once per input, not once per call #35000, auto-merged): the key covers every input. Right. buildTypedEnv keys on JSON.stringify([scope, temporal, fieldCelTypes, recordRootTypes ?? null]) (cel-engine.ts:1108) and createTypedEnv reads exactly those four plus module constants. The three shapes this PR asks for are distinct keys: ({}, flattened, timestamp, roots) for the stand-down probe, ({}, flattened, date-text, roots) and ({}, flattened, text, textTyping(roots)) for the root pass; {} with roots never collides with roots as the bare map and null. dateOnlyFields is not an env input (read after the check), so it rightly is not in the key. No code in this diff registers on a returned env: all three callers only parse and check, the condition the cache's docblock sets.

② Semver level

.changeset/34662-flow-record-date-text.md: '@objectstack/formula': minor, fix(formula)!: heading, BREAKING banner, FROM-to-TO table, line-leading Clause-②: no (narrowing) and Metadata-protocol: narrowed, identical in the PR body. Matches what the diff publishes: a refusal where a publish was admitted, and no widening (① public surface). minor is the level the repo gives a narrowed change; Check Changeset and Governed Surface Queue Guard are success on this head. The only source change is in @objectstack/formula; lint, runtime, service-automation and mcp change by dependency alone and carry test files only, so one package in the changeset is right.

ADR-0087 disposition not-required (already-registered ...): the three ids exist under packages/spec/src/migrations/entries/semantic/, and each surface already names flow conditions and the record (or previous) read. No entry moved. Skills-docs: none holds: SKILL.md:164 to 166 states the date-text-call rule with record.FIELD spellings and no site limit.

③ Boundary flags

  • open_question 1 (which declaration lines stand): answered by the seat's revised claim 6955917834, no (narrowing) / narrowed. Agreed, on ① and ②.
  • open_question 2 (registerFlow named as the door): answered there too, accepted as landed. Agreed: publishMetaItem refuses, registerFlow advises, and it does not refuse the bare name either.
  • Dev flag, record.due_date + 1 passes while the bare name is refused (date-arithmetic family): filed as a flow condition passes record.<date field> + 1 while the same arithmetic over the bare name is refused: the date-arithmetic verdict is not applied to record./previous. reads #34946 (card comment 6958215971). The stand-down in this PR is what keeps that shape for that card. Answered.
  • Dev flag, a flow variable named record is still typed as the row: accepted deviation; the type-mismatch root pass has the same behaviour and this diff does not alter it.
  • Earlier reviewer's note, the index spelling timestamp(record['borrow_date']) reaches neither pass: the seat's hold comment 6963236571 and the dev report say "the seat files it"; no card number appears in the inputs I was given. Escalated to the seat: name the card, or file it together with N5 below.
  • Dev deviation, local suite and typecheck NOT MEASURED at the merge head: the check-runs are the verdict here. On 36a9089a80: 57 success, 11 skipped, none failed; Test Core and its ten shards, TypeScript Type Check, Type Check · workspace, Lint & Repo Gates, Build Core, Dogfood Regression Gate, Check Changeset, Governed Surface Queue Guard all success.
  • SQL push-down (Prime Directive 5): not applicable. No hunk reads data, materialises ids or joins; the diff is a type check over expression source.

④ Design judgment

No must-fix, no should-fix.

Earlier graded findings (round on 60d4e1c6c7, comment 6963236571), state on this head:

  • S1: closed. recordRootReadsFaultDateArith (cel-engine.ts:1601) returns true only when the roots' first Timestamp-typing fault matches isDateArith; the merge left it intact. Both S1 shapes are pinned in the formula harness (root and bare, (b) in both orders) and Test Core is green on this head.
  • N1: closed. One RECORD_ROOT_READ_RE (cel-engine.ts:1264) gates firstTypeMismatch's root pass and recordRootDateTextIssue.
  • N2: closed. The firstTypeMismatch comment (1416 to 1421) now says the date-arith verdict alone stays the bare name's.
  • N3: closed. The lint harness pins the run-may-fail sentence on an untriggered flow for the bare name and both roots.

packages/formula/src/validate.ts — agrees with the contract.

  • Order. The docblock says the pass follows the bare name's own order. Read against the tree: for the bare name firstTypeMismatch answers date-arith when the first Timestamp-typing fault is date or duration arithmetic against a number, a text or boolean mismatch when the date-text re-check confirms it, and null otherwise; only null reaches the date-text check. The root pass is entered only on null (the type-mismatch root verdict already won at 534 to 548), and stands down on exactly the one remaining shape. Tried against it: timestamp(record.borrow_date) LT now() && record.due_date + 1 GT 5 (the call faults the Timestamp typing first, not an operator fault, so it is judged, as the bare spelling is); the reverse order stands down, where the bare spelling gets date-arithmetic: the a flow condition passes record.<date field> + 1 while the same arithmetic over the bare name is refused: the date-arithmetic verdict is not applied to record./previous. reads #34946 gap, not a new one. record.due_date LT 5 && timestamp(record.borrow_date) LT now() is judged on both spellings.
  • Typing. Roots get every field's type and dateOnly is built from all fields, not the shadow-filtered set: right, a flow variable shadows a bare name and never a root member (pinned). Bare names are passed as {}, so the root pass can only fault on a root read and can never attach the row's arm to a bare-name fault.
  • Arm. dateArm('flattened', faultOutcome, false): run-fails only where the producer declared it, else run-may-fail; the grade is error on both, as for the bare name. An untriggered flow whose caller hands a full instant under record.borrow_date is refused although it would run; the bare name has had that grade since expression gate: a date-arithmetic verdict in a flow condition still says the value "silently evaluates to null", though the run fails #30016, so this is parity, not a new false refusal.
  • Filter. DATE_TEXT_FAMILY_RE drops date-duration-value, which a flattened value role could otherwise surface through the root pass. Right.
  • False refusals looked for and not found: datetime under timestamp() (not in dateOnly; pinned CONTROL at four layers), date(record.FIELD) (pinned, evaluates true), input.FIELD (typingOf answers undefined for any root but record / previous on this pass; pinned), ordering against a text literal or a Timestamp and today() - record.FIELD in a predicate (declared date-text overloads, check clean).

packages/formula/src/cel-engine.ts — agrees with the contract.

  • firstDateTextVerdict: rootTypes reaches buildTypedEnv only at flattened scope; naming prefers the member-wise root read and falls back to the bare name, best-effort like offendingField (first declared date field read, which is what the pins show: reference: record.borrow_date for record.due_date - record.borrow_date).
  • firstDateTextCall: without recordRootTypes, typingOf returns dateFields for every reference, so dateRef and the timestamp() arm are what they were on main, as the docblock claims. With it, a root read qualifies by the root typing alone.
  • recordRootReadsFaultDateArith: parses through the same two rewrites as every other check, answers false on a parse failure (the pass then proceeds, and dateTextIssue answers null on the same failure), and reads only the first fault, which is the sentence it documents.
  • Merge: the auto-merge with the cache changed no line of the three functions' logic; see ① for the key.

.changeset/34662-flow-record-date-text.md — the declaration lines, the level, the FROM-to-TO rows and the three refused examples agree with the code. Two sentences are looser than the code (N5, N6); neither hides a refusal an author is not told about elsewhere in the same file.

Nits (no effect on correctness or on the declared contract; none needs the head to move):

  • N4 (nit) — PR body, prose face: it still names recordRootReadsFaultTimestampTyping (now recordRootReadsFaultDateArith), still says the pass stands down on "a shape the Timestamp typing of the roots already faults on ... the same order the flow value envelope uses" (the pre-S1 rule), gives "6 cases" for the two-minute check and "Final head 60d4e1c" under Verification. The dev's report 6965070044, deviation (3), already carries the replacement wording. Fix in the PR body.
  • N5 (nit) — changeset "Not refused" bullet and "The verdicts" bullet. (a) "A shape the Timestamp typing already faults on (record.due_date + 1)" is the pre-S1 wording: since S1 only date or duration arithmetic against a number stands down, and record.due_date - record.borrow_date GT 3 (which the Timestamp typing also faults on) IS refused. The example is right and the verdicts bullet declares arithmetic on the text as refused, so no refusal is undeclared. (b) "A record.FIELD / previous.FIELD read ... now gets the date-text checks its bare name gets" is wider than the code for arithmetic whose operands mix spellings: read off the tree, not run, due_date - record.borrow_date GT duration('24h') gets no finding on either pass (the bare pass leaves the root dyn, the root pass leaves the bare name dyn, and a dyn operand does not fault the check), while both same-spelling forms are refused and the run faults on text minus text. It got no finding before this PR either, it is outside the card's "Done when", and closing it needs an arm decision (which outcome when the bare operand is unproven). Accepted deviation on this head; follow-up card with the index spelling (③). If the head moves for any other reason, reword (a) to "date or duration arithmetic against a number (record.due_date + 1)".
  • N6 (nit) — changeset "Where" bullet omits the MCP expression tool's flow_condition kind, which now answers the same refusal (①); and the parenthetical after "the calls the text cannot take" lists timestamp() and isoDate() only, while a timestamp-only method on a root read (record.picked_up_at.getFullYear()) is refused the same way, as the registered formula-date-text-call-refused entry already says. Accepted deviation.

Implemented-by: claude/issue-34662-flow-record-date-text
Reviewed-by: session_012MmDsS4GoHCgYwA2uv3n3C

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

Landing · Head-sha: 36a9089 · 2026-11-19T02:43Z

Probe Reading
Check-runs on 36a9089 57 success, 11 skipped, 0 in progress, 0 failed. Lint & Repo Gates, TypeScript Type Check, Test Core (all shards), Test UI and Type Check UI: all success.
Contract review The record on this head (just above), served at CONTRACT_REVIEW_TIER and checked by verify-review-tier: PASS. No must-fix, no should-fix. S1, N1, N2 and N3 closed. N4–N6 are nits, accepted as deviations on this head.
Narrowing arm Clause-②: no (narrowing). The dev's report 6998059203 on #34662 (a re-post of 6997874346 with the sha first) records the dogfood battery on 36a9089: command exit 0, 482 test files passed and 3 skipped, 0 failed.
Mergeable · governed mergeable_state clean. check-governed-merges.mjs --pr 34935: not governed (0 of 7 paths). The other open PRs of this seat (#34910, #34999) touch none of these files.

State: ready + auto-merge now (L1 delta ACCEPT above). #34662 closes on merge. The reviewer escalated the index spelling timestamp(record['borrow_date']) and the mixed bare/root operand arithmetic (N5 b); the seat files them as one follow-up card.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 19, 2026 02:44
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit c809deb Nov 19, 2026
69 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34662-flow-record-date-text branch November 19, 2026 03:11
247257110 pushed a commit to 247257110/objectstack that referenced this pull request Nov 22, 2026
… is refused as its bare name is (objectstack-ai#36333)

<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X8UqWLrzTYpuat8L5eLdf2c)_
Fixes objectstack-ai#34946
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — `skills/objectstack-formula/SKILL.md` already states
"No date arithmetic. The build refuses `date + n` and `end - start`" and
names no site it is limited to, so it now holds for a flow condition's
`record.FIELD` / `previous.FIELD` reads as written

repo:objectstack#4 · os-project-manager ·
session_01FEkQ5pb2t8Z8C64PkPyVt1

## 维护者速读

-
用户能看到什么变化:作者在校验或发布流程时,若流程条件通过「当前记录」或「修改前记录」读取日期字段并直接加减数字,现在会和直接写字段名一样被拒,并提示改用按天计算的函数;以前这种写法能通过校验,运行时却每次失败。
- 为什么做:属于「表达式校验与作者护栏」,替编写流程的管理员和代写流程的 AI
助手解决「校验通过、流程每次运行都出错」的问题,与已修好的日期文本同类问题是同一族。
- 出错会怎样:若误判,作者在校验或发布流程时会看到一条拒绝;已保存的流程照常加载、照常注册,只在下次发布时要求改写;本改动可整体撤回。
- 要你做什么:这是收紧已接受写法的破坏性变更,需要你本人审阅、批准并亲手合并。L1 ACCEPT 7076562103,全量测试 0 失败
7076550688,契约 PASS 7076631700(座位 7,head f278fec);一个不阻塞的遗留写法(main
上同样存在,不是回归)和三个小问题另立 objectstack-ai#36377 跟进。

## What changes

A flow condition (start, edge, `decision` branch) is evaluated over a
scope where the run's row is bound twice: its fields flattened to bare
names, and the row itself as `record` (with the row before the write as
`previous`). The date-arithmetic verdict typed the bare names only.
`firstTypeMismatch`'s flattened record-root pass typed `record.FIELD` /
`previous.FIELD` but kept only the text/boolean mismatch, so
`record.due_date + 1 > 5` passed while `due_date + 1 > 5` was refused,
and both fault at run time on the `YYYY-MM-DD` text on every run.

Measured through `validateStackExpressions` (the `os validate` body) on
a record-triggered flow (`record-after-update`), object `library_loan`
with `due_date: date` and `picked_up_at: datetime` (both `required`),
start condition:

| start condition | before (`origin/main` 28ba01f) | after (this
head) |
|:---|:---|:---|
| `due_date + 1 > 5` | 1 error, date arithmetic
`google.protobuf.Timestamp + int`, `due_date` | 1 error (unchanged) |
| `record.due_date + 1 > 5` | 0 | 1 error, same verdict,
`record.due_date` named |
| `previous.due_date + 1 > 5` | 0 | 1 error, same verdict,
`previous.due_date` named |
| `picked_up_at + 1 > 5` (CONTROL, datetime) | 1 error, `picked_up_at` |
1 error (unchanged) |
| `record.picked_up_at + 1 > 5` (CONTROL) | 0 | 1 error, matching the
bare name |
| `previous.picked_up_at + 1 > 5` (CONTROL) | 0 | 1 error, matching the
bare name |
| `record.due_date < today()` (CONTROL) | 0 | 0 |
| `timestamp(record.due_date) < now()` (CONTROL, date-text) | 1 error,
date-text call | 1 error (unchanged, no second finding) |

The datetime control: a `datetime` field is a Timestamp in the type
check exactly as a `date` field is, and its bare name already took the
date-arithmetic verdict, so its root reads now take that verdict too,
word for word with the reference swapped. That is the dispatch's control
("keep whatever verdict the bare name gets for a datetime").

- `packages/formula/src/cel-engine.ts`, `firstTypeMismatch`: the
record-root pass now answers `category: 'date-arith'` when its first
operator fault is date/duration arithmetic against a number
(`isDateArith`), with `field` and `root` from `offendingRecordRead(…,
'timestamp')`. The text/boolean branch is unchanged. The comment that
said the `date-arith` verdict "stays the bare name's alone" is
corrected, and the `root` field's doc and
`recordRootReadsFaultDateArith`'s doc say the root read is answered
there too.
- `packages/formula/src/validate.ts`, `typeSoundnessIssue`: a root
read's date verdict takes the row's arm (`dateArm` with
`bareNamesUnproven` false), as the root read's type mismatch (objectstack-ai#30025)
and date-text verdicts (`recordRootDateTextIssue`) already do. So
`record.due_date + 1 > 5` stays `date-arithmetic-run-fails` where bare
names are unproven or a flow variable shadows `due_date`. The bare
name's arm is unchanged.
- No double report: `recordRootDateTextIssue` runs only when
`firstTypeMismatch` answers null, and it already stood down on this
exact shape (`recordRootReadsFaultDateArith`). The objectstack-ai#34662 date-text pins
are green and unchanged.
-
`packages/spec/src/migrations/entries/semantic/18.flow-condition-record-date-arithmetic-refused.ts`:
the ADR-0087 semantic entry (a structured TODO; no mechanical rewrite,
since a span in days and a shifted date are different intents), modelled
on `18.cel-list-equality-refused.ts`.
- `.changeset/34946-flow-record-date-arithmetic.md`: `minor` for
`@objectstack/formula` and `@objectstack/spec` (`Metadata-protocol:
narrowed` grades `minor`; spec ships the new ADR-0087 entry in its
generated migration registry), the declaration lines, the **BREAKING**
banner, a FROM to TO table, and `adr-0087: registered
flow-condition-record-date-arithmetic-refused`.

Reach (the dispatch asked to stop if the narrowing reached beyond flow
conditions): the flattened scope is used only by flow conditions.
`@objectstack/lint` passes it for start, edge and `decision` conditions,
`@objectstack/service-automation`'s `registerFlow` (advisory only) and
the MCP `validate_expression` tool's `flow_condition` site. Formula
fields, validation rules, hooks and actions are `record`-scoped, where
`record.due_date + 1` was already refused (`date-arithmetic`,
`-fail-closed`, `-fail-open`). No widening was needed.

## Tests

- `packages/formula/src/validate.test.ts`, new top-level describe
(objectstack-ai#34946): `record.` and `previous.` date arithmetic refused under
`date-arithmetic-run-fails` with full params (`operands`, `reference`
naming the read), and the evaluator faults on them over the run's scope.
CONTROL: the datetime field's root reads equal the bare name's verdict.
Arms: `run-may-fail` with no declared outcome, `run-fails` kept on a
root read when bare names are unproven or shadowed. CONTROL:
`record.due_date < today()`, `previous.due_date < today()`,
`date(record.due_date) < now()` and the prescribed rewrites
(`daysBetween(record.due_date, today()) > 5`, `addDays(record.due_date,
1) < today()`, `addDays(previous.due_date, -7) < today()`) are clean.
The date-text shapes keep their one finding (`date-text-call-run-fails`,
`date-text-arithmetic-run-fails`) and `record.title > 5` keeps
`type-mismatch-run-fails`.
- `packages/lint/src/validate-expressions.test.ts`, new top-level
describe: start, edge and `decision` conditions refuse `record.` /
`previous.` at the bare name's path and severity, with the bare name's
message and the reference swapped. Reported under `expression-invalid`
through `runAuthoringRules('build', …)`, the rule body the runtime
publish door runs. CONTROL: datetime root reads equal the bare name's
findings at all three sites; `record.due_date < today()` stays clean;
`timestamp(record.due_date) < now()` keeps exactly one date-text
finding.
-
`packages/services/service-automation/src/flow-registration-schema-e2e.test.ts`,
new top-level describe: `registerFlow` logs the date-arithmetic advisory
for `record.` / `previous.` as for the bare name and still registers.
CONTROL: an ordering against `today()` is not advised.

-
`packages/runtime/src/domains/meta-flow-condition-record-date-text.test.ts`,
new top-level describe (objectstack-ai#34946, added at `f278fece6f`): the publish door
(`publishMetaItem` over the real `ObjectQL` engine) refuses the bare
name, `record.due_date` and `previous.due_date` date arithmetic with
`INVALID_METADATA` / 422 and one date-arithmetic issue naming the read,
leaving the item draft. CONTROL: a datetime field's root reads take the
same refusal; `record.due_date < today()` publishes and goes active. The
loan fixture gains one required `date` field `due_date`. Runs at
`f278fece6f`: 4/4 passed; ablating the cel-engine record-root
`isDateArith` branch turns exactly the 2 new tests red, restored to the
HEAD blob with `git diff HEAD` empty and `ablation-dist-preflight
--absent` clean.

Publish door, first measured on head 4426723 as a scratch copy of the
same rig (now committed as the pin above):

| start condition | publish | date-arithmetic finding | row state |
|:---|:---|:---|:---|
| `due_date + 1 > 5` | `INVALID_METADATA` / 422 | `expression-invalid`,
`due_date` | draft |
| `record.due_date + 1 > 5` | `INVALID_METADATA` / 422 |
`expression-invalid`, `record.due_date` | draft |
| `previous.due_date + 1 > 5` | `INVALID_METADATA` / 422 |
`expression-invalid`, `previous.due_date` | draft |
| `picked_up_at + 1 > 5` (CONTROL) | `INVALID_METADATA` / 422 |
`expression-invalid`, `picked_up_at` | draft |
| `record.picked_up_at + 1 > 5` (CONTROL) | `INVALID_METADATA` / 422 |
`expression-invalid`, `record.picked_up_at` | draft |
| `previous.picked_up_at + 1 > 5` (CONTROL) | `INVALID_METADATA` / 422 |
`expression-invalid`, `previous.picked_up_at` | draft |
| `record.due_date < today()` (CONTROL) | published | none | active |

At `f278fece6f` (the patch round: changeset regrade and the runtime
pin): runtime pin 4/4 and its ablation as above; `dispatch-gates
--commands` 98 families derived (one more than at 4426723:
`check:route-envelope`); the families for the changed paths
(`check-adr-0087-registration`, `check-changeset-no-major`,
`check-empty-changeset`, `check:cross-package-test-inputs`,
`check:test-source-alias`, `check:tier-file-adoption`,
`check:route-envelope`) exit 0; `overlap-check` clean. The runs below
and the dogfood battery are from 4426723; the patch round changed
only the changeset and a runtime test file.

<details><summary>Local runs (head 4426723)</summary>

All under `scripts/pm/os-verify-lock.sh`, exit codes captured before any
pipe:

- `pnpm --filter @objectstack/formula build` exit 0; `pnpm --filter
@objectstack/formula test` exit 0, Test Files 70 passed (70), Tests 2067
passed (2067); `pnpm --filter @objectstack/formula typecheck` exit 0
(test layer: 7 errors held in `test-typecheck-debt.json`, unchanged).
- `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2
src/validate-expressions.test.ts` exit 0, Tests 529 passed (529).
- `pnpm --filter @objectstack/service-automation exec vitest run
--maxWorkers=2 src/flow-registration-schema-e2e.test.ts` exit 0, Tests 7
passed (7).
- `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2
src/migrations` exit 0, Test Files 5 passed (5), Tests 198 passed (198)
(spec built with the new entry; `gen:migration-registry` runs in its
build).
- `node scripts/pm/dispatch-gates.mjs --commands` derived 97 families
for this diff; all 97 run locally, reconciled with `--ran`: "97 derived,
97 run, 0 NOT-MEASURED, 0 UNRUN". `pnpm check:dual-build-cjs-loads`
first answered PREREQUISITE NOT MET (exit 3, no full build yet), then
exit 0 after `check:type-check-debt` built the tree; every other family
exit 0 on the first run.
- Dogfood battery (the `!` title), on head 4426723: `pnpm --filter
@objectstack/dogfood test` under the lock, VERDICT command-exit 0, Test
Files 484 passed, 3 skipped (487), Tests 4107 passed, 68 skipped (4175),
no failure.
- `test:repo` (vitest `repo` project) not run locally: the diff touches
none of its tests; it is CI's (`Test Core`).

</details>

<details><summary>Ablations (each committed first, mutated through
scripts/ablation-replace.mjs, restored to the HEAD blob)</summary>

1. Subject: the new `isDateArith` branch of the record-root pass
(`packages/formula/src/cel-engine.ts`). Anchor `if (rootTyped &&
isDateArith(rootTyped)) {` replaced by a never-true guard carrying
`ABLATED_34946` (anchor 1 to 0, blob `8eb099d83f32` to `4975d5dd3077`),
formula rebuilt, `ablation-dist-preflight.mjs @objectstack/formula
ABLATED_34946` exit 0 (the marker reached `dist/`, which the lint and
service-automation suites read). Red: formula `validate.test.ts` 3
failed / 236 passed (the three objectstack-ai#34946 verdict tests; the CONTROL for
orderings and date-text stayed green), lint 5 failed / 524 passed (all
five non-ordering objectstack-ai#34946 tests), service-automation 1 failed / 6 passed
(the advisory test). Restored: blob back to `8eb099d83f32` =
`HEAD:packages/formula/src/cel-engine.ts`, `git diff HEAD` empty,
rebuilt, preflight `--absent` exit 0, lint 529/529 again.
2. Subject: the root read's arm in `typeSoundnessIssue`
(`packages/formula/src/validate.ts`). Anchor `dateArm(scope,
faultOutcome, mismatch.root !== undefined ? false : bareNamesUnproven)`
replaced by `dateArm(scope, faultOutcome, bareNamesUnproven ...)` (blob
`aeedf005910e` to `b35d7d64bb2a`). Red: formula `validate.test.ts` 1
failed / 146 passed, the arm test (`record.due_date + 1 > 5` under
unproven bare names). Restored: blob `aeedf005910e` = HEAD, `git diff
HEAD` empty, 147/147.

</details>

## Acceptance notes

- Kept as before, deliberately: where bare names are unproven and a
source holds both a bare-name date-arithmetic fault and a root-read one
(`due_date + 1 > 5 && record.due_date + 1 > 5`), the first (bare)
verdict is reported, at `date-arithmetic-run-may-fail`. Still an error;
the swap-to-the-root-read step `typeSoundnessIssue` does for a bare type
mismatch was not extended to the date verdict.
- The field a multi-date expression names is best effort, as for the
bare name: `offendingRecordRead` names the first `timestamp` field read
through a root, in field-map order.
- Declarations follow the two closest precedents in this family (objectstack-ai#34935,
objectstack-ai#36207): `Metadata-protocol: narrowed` with a `minor` changeset
(regraded at `f278fece6f`).
- Carried by objectstack-ai#36377: contract review 7076631700 S1 (a bare date ordering
against text AND-ed before a `record.` date arithmetic still passes;
measured first on that card) and nits N1–N3.

## Verification

Read first, by risk:
1. `packages/formula/src/cel-engine.ts`, the new `isDateArith` branch of
`firstTypeMismatch`'s record-root pass (the narrowing itself).
2. `packages/formula/src/validate.ts`, the `dateArm` call in
`typeSoundnessIssue` (the root read's arm).
3.
`packages/spec/src/migrations/entries/semantic/18.flow-condition-record-date-arithmetic-refused.ts`
(the upgrade-guide text).

Two-minute check: `pnpm --filter @objectstack/formula exec vitest run
--maxWorkers=2 src/validate.test.ts -t 34946` shows 4 passing tests.

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

<!-- signed: repo:objectstack#4 · os-project-manager ·
session_01FEkQ5krBqrrgxCYgjXmfbv -->

---------

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

2 participants