Skip to content

perf(formula): the expression type checks build each typed check environment once per input, not once per call - #35000

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-34756-field-reorder-dogfood-timeout
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-34756-field-reorder-dogfood-timeout

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #34756

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:表达式类型检查(firstTypeMismatch、firstDateTextVerdict、firstDateTextCall)以前每调用一次就重建一个带类型的 CEL 环境(克隆注册表、重新注册整套标准库)。现在按输入(作用域、日期类型、字段类型)缓存复用,最多 512 个,按最近最少使用淘汰。
  • 为什么改:发布任何一个元数据时,运行时校验会把整个应用的每条表达式都检查一遍。实测在 showcase 上发布一个对象,要建 903 个环境(只有 97 种不同输入),光这一项就占约 0.5 秒。dogfood 的字段重排用例因此在繁忙的合并队列分片上超过 5 秒时限,把无关 PR 踢出了队列。
  • 风险与回滚:检查只做解析和类型检查,共用环境与新建环境给出相同结论,报告内容不变;回滚即 revert。
  • 先看:packages/formula/src/cel-engine.ts(缓存键与淘汰)、packages/formula/src/cel-env-reuse.test.ts。
  • 两分钟验证:pnpm --filter @objectstack/formula exec vitest run src/cel-env-reuse.test.ts,预期全部通过。
  • 需要你做的:无,席位落地。

What changes

The type checks behind the authoring rules built a new typed CEL environment on every call. Each build clones cel-js's registry and registers the whole stdlib again. The runtime authoring gate runs these checks over every expression in the stack each time a metadata item is published, so the cost grows with the size of the stack, not with the size of the item.

  • packages/formula/src/cel-engine.ts: the environments are kept per input (scope, date typing and field types), up to 512, least recently used first. The checks only parse and type-check against these environments, so a shared one gives the same verdicts as a fresh one.

Tests

  • packages/formula/src/cel-env-reuse.test.ts (an existing harness; a new #34756 describe): repeated checks of one field map build no new environment; the field types are part of the key, so the same source keeps each map's own verdict; the scope and temporal typing are part of the key too. The 512-entry cap and its eviction order have no pin of their own: noted for the L1 review.

Acceptance notes

Verification

Measured by the dev on the showcase (from the changeset): one object publish built 903 environments for 97 distinct inputs; the publish request went from about 1.6–1.8 s to about 1.0–1.3 s on an idle machine. CI on this PR, and a dogfood run of object-designer-field-reorder.dogfood.test.ts under load, are the seat's to read before landing.


Generated by Claude Code

… once per call

The runtime authoring gate type-checks every expression in the stack on each
metadata publish, and each check built a fresh typed cel-js environment
(registry clone + whole stdlib). Measured on the showcase: 903 builds for 97
distinct inputs per object publish, about 0.5 s of the request idle. This is
the slow path that pushed the two field-reorder dogfood cases past the 5 s
per-case default on a loaded merge-group shard.

Claude-Session: https://claude.ai/code/session_012MmDsP9M4FjNJxrUMf7ESW
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m 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

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

4 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
  • 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 4443014630c094cde840f9dd0b0b45ade45b48d9 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 4443014630c094cde840f9dd0b0b45ade45b48d9

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

席位核对 · L1 ACCEPT · Head-sha: 6329e84 · 2026-11-17T22:40Z

Card #34756, claim 6950257045. Opened by the seat on the maintainer's order (card comment). The seat read the diff itself.

Item Reading
Shape Draft, base main, Fixes #34756; Clause-②: no, Metadata-protocol: none. Three files: packages/formula/src/cel-engine.ts (+52 −1), cel-env-reuse.test.ts (+58), changeset (@objectstack/formula patch).
Root cause Measured by the dev on the showcase: 903 typed-env builds for 97 distinct inputs per object publish (about 0.5 s on an idle box). The publish path paid it inside the two dogfood cases. No timeout was raised or added, per the card's fence.
Soundness buildTypedEnv is memoized on [scope, temporal, fieldCelTypes, recordRootTypes], LRU, cap 512. Checked on this head: every register* on a typed env happens inside createTypedEnv (lines ~1150–1214, plus registerNullComparisons and registerDateText* it calls) before the env enters the cache. No caller registers on a returned env (the other register* sites are in buildScopedEnv, a separate env). A key built from a differently ordered but equal map only misses the cache, which is safe. The docblock states the ⛔ for any future caller.
Tests New #34756 describe in the existing harness: repeated checks build no new env; field types, scope and temporal typing are each part of the key. The 512 cap and eviction order have no pin of their own: accepted (a bound, not a verdict).
Overlap git merge-tree with origin/main: clean. With PR #34935's branch (also cel-engine.ts): clean.
Gates CI on this head is read before landing. The dogfood shards run in the merge queue, and they are where the card's flake lived.
Landing Not governed; no contract face, so no L2. The seat lands it once every check on this head is green.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C

Landing · Head-sha: 6329e84 · 2026-11-17T23:05Z

Probe Reading
Check-runs on 6329e84 success 57 · skipped 11 · in progress 0 · failure 0. Lint & Repo Gates and TypeScript Type Check both success; Test Core, Test UI and Type Check UI all success. The skips are path-gated or merge-group-only (the dogfood shards, where the card's flake lived, run in the queue).
Mergeable · governed mergeable_state clean. check-governed-merges.mjs --pr 35000: not governed. git merge-tree with PR #34935's branch (also cel-engine.ts): clean.

State: ready + auto-merge now (L1 ACCEPT 6963109194). #34756 closes on merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 23:05
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit b846710 Nov 17, 2026
69 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34756-field-reorder-dogfood-timeout branch November 17, 2026 23:48
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/m 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.

dogfood: object-designer-field-reorder cases time out at 5000 ms on a loaded merge-group shard and kick unrelated PRs from the queue

2 participants