Repository navigation
perf(formula): the expression type checks build each typed check environment once per input, not once per call - #35000
Conversation
… 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>
📓 Docs Drift Check4 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
Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # 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 |
|
repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C 席位核对 · L1 ACCEPT · Head-sha: 6329e84 · 2026-11-17T22:40ZCard #34756, claim 6950257045. Opened by the seat on the maintainer's order (card comment). The seat read the diff itself.
|
|
repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C Landing · Head-sha: 6329e84 · 2026-11-17T23:05Z
State: ready + auto-merge now (L1 ACCEPT 6963109194). #34756 closes on merge. |
Fixes #34756
Clause-②: no
Metadata-protocol: none
维护者速读
firstTypeMismatch、firstDateTextVerdict、firstDateTextCall)以前每调用一次就重建一个带类型的 CEL 环境(克隆注册表、重新注册整套标准库)。现在按输入(作用域、日期类型、字段类型)缓存复用,最多 512 个,按最近最少使用淘汰。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#34756describe): 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
session_012MmDsP9M4FjNJxrUMf7ESWpushed this branch, and its own permission classifier refused its relaypr_create. This body is the seat's, written from the pushed commit and changeset.packages/formula/src/cel-engine.tsis also edited by PR 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 (a flow condition passes timestamp(record.<date field>) while the same call over the bare name is refused: record.FIELD reads are not typed for the date-text verdicts there #34662). The seat runs the overlap check before landing either.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.tsunder load, are the seat's to read before landing.Generated by Claude Code