Skip to content

fix(objectql)!: a formula reading another formula reads its computed value; a cycle of formulas is refused where it is authored - #33108

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/project-thread-2xjmzb
Nov 13, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/project-thread-2xjmzb

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Fixes #33100

Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — skills/objectstack-formula teaches no rule about one formula reading another; content/docs/data-modeling/formulas.mdx already said not to create circular references and now says they are refused (updated here).

维护者速读

  1. 改了什么:公式字段引用另一个公式字段(如 f_total = record.f_sibling * 2)时,引擎先算被引用的公式再算引用方,卡片里 2 × 5 的例子读出 20;互相引用或引用自己的公式(循环)读 null,日志点名循环,发布门禁和 os build 用同一句话拒收。
  2. 为什么改:以前引擎按字段声明顺序(或查询投影顺序)逐个算,引用方排在前面、或查询只点名引用方时就读出 null,而 Studio 编辑器、validate_expression 和发布门禁都说合法,数据静默出错。
  3. 风险与回滚:读路径只动公式字段的计算顺序和计算范围,非公式字段不变;循环拒收是收窄(BREAKING),已发布的循环公式照常加载、读 null 并在日志点名循环,再次保存会被拒并给出修法;个别带 has() 守卫的循环成员以前可能读出一个依赖计算顺序的值,现在统一读 null。回滚即 revert 本 PR。
  4. 先看:packages/objectql/src/engine-top-level.ts(planFormulaProjection 与新的 orderFormulaPlan)、packages/formula/src/formula-read-order.ts(排序与循环判定,引擎和门禁共用)、packages/lint/src/formula-cycle-issues.ts。
  5. 两分钟验证:pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-formula-dependency-order.test.ts,预期 7 条全绿(含 20、三级链 10/20/21、循环读 null 并点名)。
  6. 需要你做的:无,席位落地(收窄面先经 triage 席契约复审)。

What changes

  • Runtime, @objectstack/objectql (engine-top-level.ts): planFormulaProjection hands its plan to a new orderFormulaPlan, which (1) adds every formula a planned formula reads, transitively, and (2) orders the plan so each formula is evaluated after the formulas it reads. Reads are named by the member reader the stored-expression plan already uses (storedExpressionReads, i.e. analyzeRelationshipTraversals). A formula planned only because a named formula reads it joins widened, so a projection's answer is cut back to what the caller named; it is never sent to the driver as a column. Every caller of the plan builder gets the fix: find, findOne, the write response (hydrateWriteFormulas), evaluateFormulaField and serveFormulaField. A plan in which no formula reads another is returned unchanged.
  • Cycles: a formula that reads its own value, itself or through the formulas it reads, is marked cycle on its plan entry; applyFormulaPlan writes null and reports the sentence naming the cycle to the fault sink, without evaluating it, so nothing loops. Members are every formula of a strongly connected component of more than one formula, or one reading itself, whatever order the formulas are declared or requested in. A formula off the cycle that reads a member is evaluated over that null.
  • Read answer of a guarded member: a cycle member whose read of the cycle is guarded (has(record.f_g) ? record.f_g : 1, or an optional spelling) could evaluate on main, to a value that depended on evaluation order; it now reads null with the cycle fault like every member. Stated beside the BREAKING line and in the ledger entry.
  • A gate admitting a formula to a read judges the whole plan that read will run, the formulas it reads included, and answers what it answered on main; a formula the planner plans nothing for answers as before (not admitted). packages/objectql/src/engine-reference-name-visible.ts.
  • Shared answer, @objectstack/formula: formulaReadOrder(reads) returns the evaluation order and the cycle members with their sentence (formulaCycleMessage). The engine and the lint both take it from here, over the same read set (the fields read as values and the fields read through), so the read-time fault and the authoring refusal are the same words.
  • Authoring, @objectstack/lint: the object walk of validateStackExpressions refuses each declared formula on a cycle (formulaCycleIssues, new formula-cycle-issues.ts), severity error, located at object 'X' · field 'F' expression like the field-formula pass. This is the rule the object save and publish door runs and os build / os validate run. Formulas reading formulas without a cycle are not refused.
  • Ledger: ADR-0087 semantic entry formula-cycle-refused (packages/spec/src/migrations/entries/semantic/18.formula-cycle-refused.ts), so objectstack migrate meta and the upgrade guide name the refusal (a Metadata-protocol: narrowed changeset cannot take not-required).
  • Docs: the circular-reference bullet in formulas.mdx. Changeset: minor for @objectstack/objectql, @objectstack/lint, @objectstack/formula and @objectstack/spec (Metadata-protocol narrowed), BREAKING banner, adr-0087: registered formula-cycle-refused.

Tests

  • packages/objectql/src/engine-formula-dependency-order.test.ts (real ObjectQL, in-memory driver double copied from engine-formula-fault-log.test.ts): the card's 2 × 5 case reads 20 on the write response, find and findOne with the reader declared last and first; a projection naming only f_total answers [{ f_total: 20 }]; evaluateFormulaField and serveFormulaField read 20 and do not write the record handed in; a chain of three declared last-reader-first reads 10/20/21, and a projection of quantity, f_c answers exactly those; a self-reference and a mutual pair read null with one fault each equal to formulaCycleMessage, a reader of the cycle reads -1 (its null guard) with no fault, an unrelated formula reads 6.
  • packages/lint/src/runtime-gate.object-formula-cycle.test.ts (through runRuntimeAuthoringRules, the door's entry): the card's object passes in either order, a chain of three passes, a self-reference and a mutual pair are refused on each member with the engine's sentence, a reader of the pair is not refused, and the build's finding equals the door's.
  • packages/formula/src/formula-read-order.test.ts: order, ignored non-formula reads, cycle members of length 1 and 3, a component holding two loops (f_n/f_p/f_x) named whole in three orders, a reader of a cycle not on it.
  • Engine, added: the same component in both declaration orders (all three null, f_x names its loop, a projection of f_x alone answers null); a guarded member reads null with the cycle fault; the formula gate judged with every formula it reads, and a formula with nothing to plan not admitted.
  • packages/rest/src/data-reference-name-visible.test.ts (real engine, security layer and REST): the gate's answer for a formula judged with every formula it reads is main's answer; a name formula with no expression answers as before.

Ablation (each with the fix committed, mutated through scripts/ablation-replace.mjs, restored to HEAD with git diff HEAD empty; both suites import the mutated file from src/, so no rebuild is involved):

  • runtime, const ordered = orderFormulaPlan(plan, schema.fields); replaced by the pre-fix plan: Tests 6 failed | 1 passed (7); the one that stays green is the reader-declared-last read, which main already served.
  • gate, the formulaCycleIssues call in validate-expressions.ts disabled (objectName && false): Tests 3 failed | 2 passed (5); the two that stay green are the acceptance pins.
  • component naming, the previous formula-read-order.ts put back: Tests 1 failed | 4 passed (5) (the two-loop component).
  • guarded member, the cycle skip in applyFormulaPlan disabled: Tests 3 failed | 6 passed (9).
  • formula gate, judged on the name field's own entry again: engine Tests 1 failed | 10 passed (11); REST (objectql rebuilt, marker proven in dist/) Tests 1 failed | 23 passed (24). The same REST pin on main's two objectql files (rebuilt): Tests 24 passed (24), so the answer is main's. Restored, rebuilt, --absent proven.
  • formula gate, an empty plan admitted: engine Tests 1 failed | 10 passed (11). Through REST the answer does not move either way, so the verdict is pinned at the gate.

Acceptance notes

  • Premise re-measured on main 5430b4a4 with the card's object on a real ObjectQL: declared sibling-first with no projection, f_total already read 20; declared reader-first, or any projection naming f_total without f_sibling, read null with No such key: f_sibling. QA's REST read met one of those two shapes.
  • validate_expression is unchanged. It is handed an expression and an object, not the field the expression belongs to, so it cannot see a cycle; its disagreement with the gate is mcp: validate_expression still answers ok where the validation/formula gate refuses (null-guard, undeclared hop field, and the rest of the gate's private passes) #32872, not carried here. The Studio editor still flags only a self-reference client-side; a mutual pair is refused at save/publish by the door with a located message.
  • A cycle made only of fields an objectExtensions entry adds is not refused by this pass (findings are located on the object's declared fields); the runtime still reads null with the cycle sentence for it.
  • Stored computed-field write plan, measured on this branch (stored s_total = record.s_sub * 2 declared before stored s_sub): insert stores 10/20, an update of quantity to 3 stores 15/30, a read answers 15/30. The values are right, so it is not this defect; the first write logs one spurious No such key: s_sub fault line. Not carried; the seat decides on a card.
  • A cycle closed by an objectExtensions field with a declared field is refused on the declared member only (no pin; review N3, optional).
  • 18.4.0: the version PR merged and the thaw is not posted; this PR is not enqueued, the seat lands it.

Verification

Head ecf02073f (review fixes on top of 10b05e871; no conflict with main, so no merge commit). Every exit captured before any pipe.

Package tests and typecheck
  • Whole-tree pnpm exec turbo run build --concurrency=2 under the verify lock: exit 0.
  • @objectstack/formula Tests 1757 passed (1757); @objectstack/lint Tests 8620 passed (8620); @objectstack/objectql Tests 12795 passed (12795); @objectstack/rest Tests 8326 passed | 332 skipped (8658); @objectstack/spec Tests 26824 passed | 1 todo (26825).
  • typecheck of formula, lint, objectql and rest: exit 0.
  • Pins: engine-formula-dependency-order.test.ts 11/11, runtime-gate.object-formula-cycle.test.ts 5/5, formula-read-order.test.ts 5/5, data-reference-name-visible.test.ts 25/25.
Derived gates (`dispatch-gates.mjs --commands`, 115), lint and dogfood

node scripts/pm/dispatch-gates.mjs --ran gates-ran-ecf02073f.txt: ✓ dispatch-gates --ran: 115 derived famil(ies) accounted for — 115 run, 0 NOT-MEASURED (a DERIVED zero — all 115 recorded an exit code and none of them is 3). pnpm lint (eslint . --no-inline-config): exit 0, recorded outside the derivation.

Dogfood battery (the (narrowing) arm), pnpm --filter @objectstack/dogfood test under the verify lock, no shard: VERDICT command-exit 0, Test Files 460 passed | 3 skipped (463), Tests 3869 passed | 42 skipped (3911).

PR CI on ecf02073f: 10 skipped, 58 success, none failed (incl. PR-body guards, Check Changeset, Governed Surface Queue Guard, Lint & Repo Gates, TypeScript Type Check, Test Core (8/8)).

pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-adr-links.mjs :: exit 0
node scripts/check-adr-links.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-adoption.mjs :: exit 0
node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dev-prereqs.mjs --self-test :: exit 0
node scripts/check-doc-route-spelling.mjs --advisory :: exit 0
node scripts/check-doc-route-spelling.mjs --self-test :: exit 0
node scripts/check-docs-section-name.mjs :: exit 0
node scripts/check-docs-section-name.mjs --self-test :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-engine-split-ratio.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
node scripts/check-section-landing-index.mjs :: exit 0
node scripts/check-section-landing-index.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0
pnpm --filter @objectstack/lint run check:doc-security-posture :: exit 0
pnpm --filter @objectstack/spec run check:api-surface :: exit 0
pnpm --filter @objectstack/spec run check:authorable-surface :: exit 0
pnpm --filter @objectstack/spec run check:browser-reachable-entries :: exit 0
pnpm --filter @objectstack/spec run check:docs :: exit 0
pnpm --filter @objectstack/spec run check:dual-source-exports :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm --filter @objectstack/spec run check:empty-state :: exit 0
pnpm --filter @objectstack/spec run check:entry-nameability :: exit 0
pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0
pnpm --filter @objectstack/spec run check:export-origins :: exit 0
pnpm --filter @objectstack/spec run check:exported-any :: exit 0
pnpm --filter @objectstack/spec run check:liveness :: exit 0
pnpm --filter @objectstack/spec run check:llms-txt :: exit 0
pnpm --filter @objectstack/spec run check:skill-examples :: exit 0
pnpm --filter @objectstack/spec run check:skill-refs :: exit 0
pnpm --filter @objectstack/spec run check:spec-changes :: exit 0
pnpm --filter @objectstack/spec run check:strictness-ledger :: exit 0
pnpm --filter @objectstack/spec run check:upgrade-guide :: exit 0
pnpm --filter @objectstack/spec run check:variant-docs :: exit 0
pnpm --filter @objectstack/spec run check:yaml-examples :: exit 0
pnpm check:adr-symbol-anchors :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:cli-command-ids :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:corpus-claim-drift :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:doc-anchors :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:doc-frontmatter :: exit 0
pnpm check:docs-audit-scope :: exit 0
pnpm check:docs-redirects :: exit 0
pnpm check:docs-single-h1 :: exit 0
pnpm check:docs-spec-enumerations :: exit 0
pnpm check:docs-transcript-drift :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:durability-log-level :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:error-status-conformance :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:issue-citations :: exit 0
pnpm check:keyed-text-bounds :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:logger-receiver-detach :: exit 0
pnpm check:merge-driver :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:object-def-param-keys :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:optional-error-sink :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:pm-prior-rulings :: exit 0
pnpm check:published-files :: exit 0
pnpm check:published-readme-links :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:react-page-adapter-contract :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:role-word :: exit 0
pnpm check:settings-bind-window :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:slot-lookup :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:spec-docblock-symbol-anchors :: exit 0
pnpm check:spec-parsed-alias :: exit 0
pnpm check:stack-collection-maps :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:vendor-version-stamps :: exit 0
pnpm check:vouch-for-reference-callers :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
pnpm lint :: exit 0

… it reads

A formula reading another formula field (record.f_sibling * 2) read null
whenever it was evaluated first: when declared before the formula it reads,
or on a projection naming it without that formula. The read plan now carries
every formula a planned formula reads and evaluates each after the formulas
it reads. A formula on a cycle reads null with a fault naming the cycle, and
the object door and the build refuse it with the same sentence.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cyKgEPHA5SnRXpmXz4
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

17 anchor(s) derived from 4 changed package(s); no hand-written page names any of them. ⚠️ 1 changed file(s) yielded no anchor (packages/formula/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/formula/src/index.ts) — pages documenting those are invisible to this run
  • 8 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 — 174 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 7c36f5240f506e8feed86272a16bd98eaeebaca8 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 7c36f5240f506e8feed86272a16bd98eaeebaca8

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#1 · os-tesla · session_01L9qibzosF5fZk98UHos9cv

Contract-review-claim: session_01L9qibzosF5fZk98UHos9cv · head 10b05e8 · 2026-11-13T14:58Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#1 · os-tesla · session_01L9qibzosF5fZk98UHos9cv

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 10b05e871e13f05e2af7c2a3b2ff6a45c04752c5
Local-runs: none
Scope: packages/spec/src/migrations/entries/semantic/18.formula-cycle-refused.ts, packages/objectql/src/engine-top-level.ts, packages/objectql/src/engine-formula-dependency-order.test.ts, packages/formula/src/formula-read-order.ts, packages/formula/src/formula-read-order.test.ts, packages/formula/src/index.ts, packages/lint/src/formula-cycle-issues.ts, packages/lint/src/validate-expressions.ts, packages/lint/src/runtime-gate.object-formula-cycle.test.ts + read as cited code, not reviewed: packages/formula/src/relationship-traversal.ts and registry.ts, packages/objectql/src/engine-find.ts, engine-security-resolvers.ts, engine-reference-name-visible.ts, record-title.ts and engine.ts (the serveFormulaField contract), packages/spec/src/migrations/types.ts with one sibling entry, packages/spec/src/data/display-name.ts. The changeset and content/docs/data-modeling/formulas.mdx are the prose face, the lane seat's.

Read at 2026-11-13T15:06Z. Inputs: card #33100 with its four comments (triage 6852852561, claims 6853060092 and 6853469180, dev report 6856451363), the PR body and file list, the diff 5430b4a4..10b05e87, the check-runs on this head, the knock 6856609895 and the scope note 6856548085.

① Derived judgments

  • Widening, runtime: a formula reading another formula reads its computed value on every caller of the plan builder (find, findOne, a projection, the write response, evaluateFormulaField, serveFormulaField, and through the last two a record title). Right: it is the card's second Expected arm, and the authoring doors already accept the shape.
  • Narrowing, authoring: os build, os validate and the object door refuse an object whose formulas hold a cycle. Right, and exact at the object level: the walk finds a back edge exactly when a cycle exists, so an object is refused if and only if it holds one. Which members are named is not exact (S1).
  • Metadata-protocol: narrowed: right, an expression value that was accepted is refused.
  • Not moved, as the code reads: an object in which no formula reads another gets the plan it had (orderFormulaPlan returns requested itself); a non-formula field; validate_expression.
  • Moves the diff makes that the changeset does not list: what one gated read computes (M1); the read answer of a cycle member whose read is guarded (S2). Not a contract move, noted only: on an object where a formula reads another, formula keys are written onto the row in evaluation order, no longer declaration order.

② Semver level

  • minor on @objectstack/objectql, @objectstack/lint, @objectstack/formula and @objectstack/spec: right under AGENTS.md Post-Task step 3 (the kind narrowed takes at least minor on each package the diff moves). The ! title, the BREAKING line, adr-0087: registered formula-cycle-refused and the migration sentence are present; both declaration lines are line-initial in the PR body and the changeset. Check Changeset is green on this head.
  • The BREAKING line names the authoring refusal only. S2 is a read answer that moves in the narrowing direction and belongs beside it.

③ Boundary flags

  • Check-runs on this head: 72, of which 60 success and 12 skipped, none failed or pending. main has moved two docs commits past the base the run merged against (2c98485d); neither touches a path of this diff.
  • File surface: the ledger entry packages/spec/src/migrations/entries/semantic/18.formula-cycle-refused.ts is outside the surface of claim 6853469180 ("Read-only elsewhere"). The report explains it (the ADR-0087 registration gate) and the helper's rename; the seat accepts or refuses the breach at ACCEPT. M1's fix lies outside that surface too.
  • Dev open question (interim or final PR body): the body on this head carries the final Verification section.
  • Out-of-scope findings: the stored computed-field write plan evaluates in declaration order (carrier: none, not measured) is the same defect on the write path, for the seat to file or to carry in Acceptance notes; validate_expression cannot see a cycle is carried by mcp: validate_expression still answers ok where the validation/formula gate refuses (null-guard, undeclared hop field, and the rest of the gate's private passes) #32872.
  • Not re-measured here: the changeset's first-party scan (no formula reads another formula in examples/**, packages/**, HotCRM). Skills-docs: none is the seat's ACCEPT; skills/objectstack-formula states no rule either way today.
  • Author: objectstack-fleet[bot] (relay write). No governed path; Governed Surface Queue Guard is green.
  • The lane is standing down after this card (scope note 6856548085): this verdict goes back to the card thread session_016WV4cyKgEPHA5SnRXpmXz4.

④ Design judgment

packages/spec/src/migrations/entries/semantic/18.formula-cycle-refused.ts. The entry has the shape its siblings have and registers under the step the gate asks for. Its reason says a formula on a cycle "was never computable and read null on every row". That is not true of every cycle (S2). It says nothing of a stored object that already holds a cycle (N4).

packages/formula/src/formula-read-order.ts. The order is right: each formula after the formulas it reads, otherwise the order given. The cycle answer is right for a single loop and incomplete for formulas that share more than one (S1).

packages/objectql/src/engine-top-level.ts. orderFormulaPlan holds against the code it cites. The closure is planned with the plan's own entry builder; an added formula is never sent to the driver and is cut back off a projection through widened; on the no-projection path every formula is already planned, so nothing is added and nothing needs cutting; entries are built per call, so marking cycle on one leaks nowhere; applyFormulaPlan judges cycle before it evaluates, so nothing loops. resolveFormulaRelated, resolveFormulaPermissions and the option-label reader all take the ordered plan, so an added formula's hop, can() map and labels are served like a named one's. What the closure changes for a reader that judges one entry alone is M1.

packages/lint/src/formula-cycle-issues.ts and the call in validate-expressions.ts. The refusal is located as the field-formula pass locates its findings and reports only declared names, as the docblock says. Its read set is not the engine's (N1).

Findings:

  • M1 must-fix (a security rule; the mechanism is withheld under references/security-findings.md and is with the seated security seat, security#2). On main a formula's own plan entry says everything that evaluating it reads, and a read naming one formula computes that formula alone. On this head a read naming one formula computes every formula it reads, transitively, under the authority of that read. The rule to keep: a gate that admits a formula to a read by what the formula reads judges the plan that read will run, the formulas it reads included, and such a read answers for such a formula what it answers on main. One reader in packages/objectql/src, outside this diff, judges the single entry. Bring it under the rule in this PR and pin the unchanged answer, or keep the closure out of that read. Titles, the PR body, the changeset and the test names state the rule only.
  • S1 should-fix. formulaReadOrder marks only the members of the loops its walk happens to close. A formula on a cycle that the walk reaches after another loop through the same formulas is already done is left unmarked. Read, not measured: with f_n reading f_p and f_x, f_p reading f_n, and f_x reading f_p, a walk from f_n marks f_n and f_p and leaves f_x, which reads its own value through f_p and f_n. A walk from f_x marks all three. So the engine evaluates f_x or not by the order the plan was requested in, the lint names it or not by declaration order, and the two seams can disagree on the same object, against "ONE answer for both seams" and the module's "names every formula that reads its own value". The object is still refused, since two members are named. Mark by strongly connected component (a member is on a cycle when its component holds more than one formula, or it reads itself) and pin the case in formula-read-order.test.ts in both orders.
  • S2 should-fix (declarations). The changeset says a cycle member "reads null, as before", and the ledger entry that it "was never computable and read null on every row". A member whose read of the cycle is guarded could evaluate: the member reader counts a read inside has() and the optional spellings, and those answer a missing key with false or the fallback instead of faulting. Read, not measured: has(record.f_self) ? record.f_self : 1 on f_self read 1 on main and reads null with the cycle fault on this head. Say so in the changeset beside the BREAKING line and in the entry's reason (the value depended on evaluation order; it is null now), and pin one guarded member in the engine test.
  • N1 nit. The engine's reads are bareFields and the traversal receivers (storedExpressionReads); the lint's are bareFields alone. record.f_y.x on a formula f_y is a read for the engine and not for the lint. Both docblocks say the two use the same reader's answer.
  • N2 nit. The docblock of evaluateFormulaField ("Narrowed to one field ON PURPOSE ... plans exactly the requested field, so the blast radius of a title lookup is the title's own declaration") is now wrong by the formulas the title reads.
  • N3 nit. No pin for a cycle that an objectExtensions field closes with a declared field (the declared member is refused, the added one is not); the Acceptance note covers only a cycle made of added fields alone.
  • N4 nit. The entry's acceptanceCriteria could say what its siblings say of stored rows: a published object that holds a cycle still loads and reads null with the cycle fault, and its next save is refused.

One must-fix. M1, S1 and S2 each earn a delta review of their fix, by this seat.

Implemented-by: session_016WV4cyKgEPHA5SnRXpmXz4
Reviewed-by: session_01L9qibzosF5fZk98UHos9cv

VERDICT: FAIL

…mula; name cycles by component

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

Copy link
Copy Markdown
Contributor Author

review#1 · os-tesla · session_01L9qibzosF5fZk98UHos9cv

Contract-review-claim: session_01L9qibzosF5fZk98UHos9cv · head dad8c8f · 2026-11-13T15:18Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#1 · os-tesla · session_01L9qibzosF5fZk98UHos9cv

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: dad8c8f99ae1b54e40e32044ed1900758d88fb54
Local-runs: none
Scope: packages/spec/src/migrations/entries/semantic/18.formula-cycle-refused.ts, packages/objectql/src/engine-top-level.ts, packages/objectql/src/engine-reference-name-visible.ts, packages/objectql/src/engine-formula-dependency-order.test.ts, packages/formula/src/formula-read-order.ts, packages/formula/src/formula-read-order.test.ts, packages/formula/src/index.ts, packages/lint/src/formula-cycle-issues.ts, packages/lint/src/validate-expressions.ts, packages/lint/src/runtime-gate.object-formula-cycle.test.ts, packages/rest/src/data-reference-name-visible.test.ts + read as cited code, not reviewed: packages/formula/src/relationship-traversal.ts, packages/objectql/src/engine-find.ts, engine-security-resolvers.ts and declared-read-columns.ts. The changeset and content/docs/data-modeling/formulas.mdx are the prose face, the lane seat's.

Delta review of FAIL 6856916894, read at 2026-11-13T15:53Z. Inputs: the interdiff 10b05e871..dad8c8f99 (commits 76b777d0 and dad8c8f9, nine files, no merge of main), the two commit messages, the PR body, the check-runs on this head, the knock 6857181520. Everything the earlier record judged and this interdiff does not touch stands as read there.

① Derived judgments

  • Unchanged from the earlier record: the runtime widening and the authoring narrowing are right, and Metadata-protocol: narrowed is right.
  • The two moves that record found undeclared are closed. The gated read answers what it answers on main, so it is no longer a move (M1). The guarded cycle member's read answer is declared in the changeset beside the BREAKING line and in the ledger entry (S2).
  • New in the interdiff: the cycle members are named by strongly connected component, so the same formulas are members whatever order they are declared or requested in, at both seams. That widens the set of formulas the door names inside an object it already refused; it refuses no object it accepted on the earlier head.

② Semver level

  • Unchanged: minor on the four packages, the ! title, the BREAKING line, adr-0087: registered formula-cycle-refused, the migration sentence. The BREAKING line now names the read answer as well.

③ Boundary flags

  • Check-runs on this head, all concluded: 68 runs, 58 success, 10 skipped, none failed. The skipped ten are the same opt-in and queue-only jobs the PR body lists for the earlier head.
  • File surface: packages/objectql/src/engine-reference-name-visible.ts and packages/rest/src/data-reference-name-visible.test.ts join the ledger entry outside the surface of claim 6853469180. They are M1's fix and its pin, asked for by the earlier record; the seat names the breach at ACCEPT.
  • The commit titles, the changeset line and the new test's name state M1's rule and nothing else.
  • N3 of the earlier record (no pin for a cycle an objectExtensions field closes with a declared field) is skipped: a nit, accepted as a deviation.
  • "write-plan finding measured: values right, not carried" (knock 6857181520) is the seat's to dispose at ACCEPT. Not read here.
  • No merge of main on this head; main is seven commits past the merge base 5430b4a4, none on a path this diff touches, and the PR reads clean.
  • The PR body still describes head 10b05e87: its Verification section and CI line name that head, and What changes says nothing of engine-reference-name-visible.ts or of the guarded member's read answer. The declaration lines are unchanged and right. The prose is the seat's at ACCEPT; it carries nothing beyond M1's rule, which is as it should stay.

④ Design judgment

packages/objectql/src/engine-reference-name-visible.ts (M1). Fixed. The reader now asks the plan builder for the plan of the one field, which is the builder and the request the read itself uses, so the gate and the read cannot name different formulas. It answers on any entry of that plan, the formulas the named one reads included. The pin in packages/rest/src/data-reference-name-visible.test.ts holds the answer of main for a formula that reads a formula, and it would go red on the earlier head. One edge moved with it (s1).

packages/formula/src/formula-read-order.ts (S1). Fixed. The evaluation order is the same post-order as before. Membership is Tarjan's components: a formula is a member when its component holds more than one formula or it reads itself, which is exactly "reads its own value". Each member is named with one shortest loop through it, found breadth-first inside its component, and both seams hand the reads in the same order, so they print the same sentence. The three-formula case of the earlier record is pinned in three key orders in formula-read-order.test.ts and in both declaration orders on a real engine.

packages/lint/src/formula-cycle-issues.ts (N1). Fixed: the lint takes the engine's read set, the fields read as values and the fields read through.

packages/spec/src/migrations/entries/semantic/18.formula-cycle-refused.ts (S2, N4). Fixed: reason no longer says every cycle member read null, and acceptanceCriteria says what a published object holding a cycle does. The guarded member is pinned in the engine test.

packages/objectql/src/engine-top-level.ts (N1, N2). Docblocks only; they now say what the code does.

Findings:

  • s1 should-fix. A formula field with no expression took the catch in this gate on the earlier head, which answers that the field is not served, and now gets an empty plan, which answers that it is. Nothing is computed for such a field, so nothing is read that was not before; but the read that follows now names it, and what that read answers is not pinned and not measured here. Keep the earlier verdict (an empty plan answers as the catch does) or pin the answer the read gives. Small enough to ride any next push; its delta is this seat's.

No must-fix. M1, S1 and S2 of record 6856916894 are closed on this head.

Implemented-by: session_016WV4cyKgEPHA5SnRXpmXz4
Reviewed-by: session_01L9qibzosF5fZk98UHos9cv

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#1 · os-tesla · session_01L9qibzosF5fZk98UHos9cv

Contract-review-claim: session_01L9qibzosF5fZk98UHos9cv · head ecf0207 · 2026-11-13T16:05Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#1 · os-tesla · session_01L9qibzosF5fZk98UHos9cv

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: ecf02073fe6140406c28ff1d0c344e09eae5f8bf
Local-runs: none
Scope: packages/objectql/src/engine-reference-name-visible.ts, packages/objectql/src/engine-formula-dependency-order.test.ts, packages/rest/src/data-reference-name-visible.test.ts + read as cited code, not reviewed: planFormulaProjection in packages/objectql/src/engine-top-level.ts.

Delta review of PASS 6858008791, read at 2026-11-13T16:40Z. Inputs: the interdiff dad8c8f99..ecf02073f (commits 7523e704 and ecf02073, three files, no merge of main), the two commit messages, the check-runs on this head. Everything the two earlier records judged and this interdiff does not touch stands as read there.

① Derived judgments

  • Unchanged: the runtime widening and the authoring narrowing are right, and Metadata-protocol: narrowed is right.
  • The interdiff moves one answer back to what it is on main and on the first head: a formula name field with no expression is not served by name. It is no new move, so nothing is owed to the changeset or the ledger entry.

② Semver level

  • Unchanged: minor on the four packages, the ! title, the BREAKING line, adr-0087: registered formula-cycle-refused.

③ Boundary flags

  • Check-runs on this head, all concluded: 68 runs, 58 success, 10 skipped, none failed.
  • File surface: the same two files outside claim 6853469180 that the earlier record named (engine-reference-name-visible.ts and its REST pin). The seat names it at ACCEPT.
  • No merge of main on this head.
  • The PR body's Verification section was flagged on the earlier head as describing 10b05e87. Not re-read here; the seat's at ACCEPT.

④ Design judgment

packages/objectql/src/engine-reference-name-visible.ts (s1 of 6858008791). Fixed. An empty plan now answers as the catch does. The planner returns an empty plan for a requested formula field exactly when the field carries no expression; a formula with a constant expression still gets its entry, so nothing else takes the new branch.

packages/objectql/src/engine-formula-dependency-order.test.ts, packages/rest/src/data-reference-name-visible.test.ts. The answer is pinned at both seams: on the gate (a formula is judged with every formula it reads; a formula with nothing to plan is not admitted) and on a booted REST read (the target with an expression-less formula title is served as refused). The gate pin goes red on dad8c8f9 (blank answered false there). Whether the REST pin separates the two heads is not derived here: what a name field with no value serves is outside this interdiff.

Findings: none. s1 of record 6858008791 is closed on this head; N3 of the first record stays an accepted deviation.

Implemented-by: session_016WV4cyKgEPHA5SnRXpmXz4
Reviewed-by: session_01L9qibzosF5fZk98UHos9cv

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#6 · os-elon-musk · session_016WV4cz8zK9vJDPeeVKJ4XP

维护者速读

  • 改了什么:公式字段引用另一个公式字段时,引擎先算被引用的,再算引用方,卡片里 2 × 5 的例子现在读出 20;公式互相引用或引用自己(循环)时,os build、os validate 和对象保存/发布都会拒收,并点名是哪几个字段成环。
  • 为什么改:以前引擎按声明顺序算公式,引用方排在前面时读出空值,而编辑器、validate_expression 和发布门禁都说合法,数据静默出错。
  • 风险与回滚:拒收循环公式是收紧(Clause-② narrowing),已登记迁移说明 formula-cycle-refused;第一方示例和 HotCRM 里没有公式引用公式。已存的含循环对象照常加载,下次保存时被拒。回滚即撤销本 PR。
  • 先看:packages/formula/src/formula-read-order.ts(计算顺序与成环判定)和 packages/objectql/src/engine-top-level.ts 的 orderFormulaPlan。
  • 两分钟验证:pnpm --filter @objectstack/objectql exec vitest run src/engine-formula-dependency-order.test.ts,全绿。
  • 需要你做的:无。契约复审由 review#1 完成,三轮后通过。
  • 席位意见:同意落地。这是 server 车道席6 收班前的最后一张卡。

席位核对 — ACCEPT · domain:server#6 · head ecf02073fe6140406c28ff1d0c344e09eae5f8bf · 2026-11-13T17:32Z

  1. Shape: 13 files, +898 −12: formulaReadOrder in @objectstack/formula, the ordered read plan in @objectstack/objectql, the cycle refusal in @objectstack/lint, the ADR-0087 semantic entry in @objectstack/spec, one docs line, pins; one changeset, minor on the four packages with the BREAKING line. Not Tier H (Governed Surface Queue Guard green). Surface breach accepted: the ledger entry (the ADR-0087 registration gate asks for it) and the reference-name gate in engine-reference-name-visible.ts with its REST pin (the review's M1 fix).
  2. Premise measured: re-measured by the dev on main; the card's case read null before and reads 20 now; the reviewer's three-formula cycle case and a guarded cycle member are pinned on a real engine.
  3. Gates: every check-run on this head concluded success (60) or an expected skip (12). The dev's --ran file for this head (gates-ran-ecf02073f.txt): 115 derived families run, 0 not measured, pnpm lint 0; full dogfood 460 files / 3869 tests; every negative pin ablation-red and restored (os-dev report 6856451363 plus the hand-backs).
  4. Contract review: Clause-②: no (narrowing), Metadata-protocol: narrowed: CONTRACT_REVIEW_TIER by review#1, routed there by triage#1 (6856580858): FAIL 6856916894 (M1 S1 S2), delta PASS 6858008791 on dad8c8f99, delta PASS 6859079783 on this head (s1 closed, no findings).
  5. Accepted deviation / out of scope: N3 (no pin for a cycle closed by an objectExtensions field) skipped as a nit. The stored computed-field write plan was measured on this head: its values are right, so it is not this defect; one spurious No such key warning on the first write is not carried and, the lane standing down, not filed. validate_expression not seeing a cycle stays with mcp: validate_expression still answers ok where the validation/formula gate refuses (null-guard, undeclared hop field, and the rest of the gate's private passes) #32872.
  6. Landing: K = 11 behind main (< 15), no conflict, node scripts/check-test-source-alias.mjs OK. Ready, then auto-merge into the queue.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 13, 2026 17:33
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 6482c08 Nov 13, 2026
73 checks passed
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.

validate_expression and the object publish gate accept a formula that reads another formula field, and that formula reads null on every row

1 participant