Skip to content

feat(spec): a formula field can return percent - #35565

Merged
objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/issue-35047-formula-percent-return
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/issue-35047-formula-percent-return

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread

Fixes #35047

Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up #35607 — skills/objectstack-data/rules/field-types.md (line 130) lists formula return types without percent; skills prose is outside this card's fence

维护者速读

  1. 用户能看到什么变化:比率类公式字段(如预算使用率、毛利率)可以声明为百分比,记录页和列表里显示为带百分号的数值,与存储的百分比字段一致,而不再是一串裸小数。
  2. 为什么做:客户关系应用里的预算使用率、毛利率等比率公式此前只能显示为裸数字,与旁边存储的百分比字段格式不一致,平台没有其他办法补上。
  3. 出错会怎样:没有声明百分比的公式不受影响;若显示有误,最坏是某个比率按百分比格式显示错位,回滚本次改动即可恢复。
  4. 要你做什么:无。

What changes

  • @objectstack/spec: formula returnType admits percent, mirroring currency (spec: a formula field cannot declare a currency result — returnType is number | text | boolean | date, so a formula over money renders as a bare number #22727). The value is read as a percent field reads its stored value: a fraction (0.25 shows 25%) unless the formula declares max above 1, then percentage points (percentScaleOf). scale counts the decimal places of the displayed percentage (absent: 0). percentDisplay applies to a percent formula too. Declared, never inferred. Readers that switch on returnType (display-name eligibility per ADR-0079, filter operator and comparand typing, stack.zod.ts, component.zod.ts) class percent with number. The field and object forms offer Percent, and the field form's percentDisplay row opens for a percent formula.
  • @objectstack/objectql: formulaRoundingScale rounds a percent formula's fraction result to scale + 2 places and a whole percentage to scale.
  • The same rounding step also serves an existing stored percent field computed from its expression. Before, its computed fraction was rounded to scale itself (0.417 at scale: 1 was stored 0.4, reading 40.0%); it now keeps scale + 2 places (0.417, 41.7%). This applies from the next computed write; rows written earlier are not rewritten. The changeset says so too.
  • @object-ui/fields: FormulaField renders a percent result with the percent formatter. The field and object forms offer percent as a return type. @object-ui/app-shell: editing the expression in the field inspector keeps a declared percent or currency unless the new expression proves text, a boolean or a date (an unproven field-over-field quotient no longer clears it).
  • Docs: content/docs/data-modeling/formulas.mdx and field-types.mdx list percent with its convention; the reference pages and the en metadata-forms bundle are regenerated.

Tests

  • New: spec formula-percent-result.test.ts; objectql engine-formula-scale.test.ts (percent arm); ui formulaFaces.returnType-11748.test.tsx and the inspector pins (a number verdict, and a field-over-field quotient that proves no type, for percent and currency; the new arm fails 3 of 11 with the fix taken out).
  • Moved with the enum: the filter operator / comparand declared-type tests, formula-currency-result.test.ts, service-analytics formula-return-type-measure.test.ts, and the lint shipped-predicate census (63 → 65, the percent formula's percentDisplay gate holds two literal comparisons).

席位核对

  • Head bc810f4ad9: the S1 fix round from the contract review (7017037505), fe974fb467 (inspector keeps a declared percent / currency under a number or unproven verdict, jsdoc and describe, changeset wording) and bc810f4ad9 (reference docs regenerated), over 03a17ea72f, which follows a base-only merge of main via os-regen-merge.sh at 986de618a. K = 13. +437/−56 over 28 files, not governed.
  • os-dev-report 7016442707: spec 857 files / 27395 tests, objectql 616 / 13911, touched ui tests green, six typechecks exit 0; dispatch-gates 128 derived, 128 run, 0 NOT-MEASURED. overlap-check clean against origin/main and PRs feat(spec): the Studio hook form offers texts, and HookContext declares ctx.text #35510, fix(audit): a search the server widens never names a column the caller may not query #34817.
  • S1 round, run locally: the inspector pin file 11 passed; with the fix taken out, the 3 new percent / currency arms fail. check:generated --fix regenerated the reference docs; check-i18n-bundles in sync after the build closure.
  • CI on bc810f4ad9: 61 success, 9 skipped, 0 failed.
  • Two-minute check: pnpm --filter @objectstack/spec exec vitest run src/data/formula-percent-result.test.ts.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Utp6CajiB6BSQKWowy6YLB

Round-1 work saved before its commit was refused, committed on the
maintainer's word; the changeset, regenerated artifacts and gates
follow in the next commit.

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

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/objectql, @objectstack/platform-objects, @objectstack/spec, touching 8 documentable anchor(s).

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

  • content/docs/concepts/metadata-driven.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/data-modeling/currency.mdx (via returnType (literal, a string literal in sections))
  • content/docs/data-modeling/external-datasources.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/data-modeling/field-types.mdx (via FieldSchema (symbol, a top-level const), percentDisplay (literal, a string literal in sections), returnType (literal, a string literal in sections))
  • content/docs/data-modeling/formulas.mdx (via percentDisplay (literal, a string literal in sections), returnType (literal, a string literal in sections))
  • content/docs/data-modeling/validation-rules.mdx (via FieldSchema (symbol, a top-level const), returnType (literal, a string literal in sections))
  • content/docs/data-modeling/virtual-objects.mdx (via returnType (literal, a string literal in sections))
  • content/docs/deployment/troubleshooting.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/deployment/validating-metadata.mdx (via FieldSchema (symbol, a top-level const), returnType (literal, a string literal in sections))
  • content/docs/getting-started/common-patterns.mdx (via returnType (literal, a string literal in sections))
  • content/docs/getting-started/quick-reference.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/kernel/contracts/data-engine.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/protocol/backward-compatibility.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/protocol/objectql/types.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/protocol/objectui/concept.mdx (via FieldSchema (symbol, a top-level const))

⛔ 5 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/releases/v17/17-1.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/releases/v17/17-6.mdx (via returnType (literal, a string literal in sections))
  • content/docs/releases/v18/18-3.mdx (via FieldSchema (symbol, a top-level const), percentDisplay (literal, a string literal in sections))
  • content/docs/releases/v18/18-4.mdx (via FieldSchema (symbol, a top-level const))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 2 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 — 176 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 08d920a16e977a1c0842f511ef40158ee3bc7c61 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 08d920a16e977a1c0842f511ef40158ee3bc7c61

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

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 08d920a16e977a1c0842f511ef40158ee3bc7c61 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 19, 2026
…returnType inspector pin

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CajiB6BSQKWowy6YLB

CI on 1503829de · 2026-11-19T15:53Z: the one red gate is Check generated reference docs are in sync with the spec (Type Check · source gates). This PR's own change makes it red: the reference pages are not yet regenerated for the new returnType member. That is owed together with the main merge, as the body's "Draft status" says, so it lands in the next round and not in a commit of its own. The test-source alias gate this PR also turned red is fixed in 1503829de. The earlier reds on b53d3a37 / bcc99c9d were runs cancelled by the next push.


Generated by Claude Code

… percentDisplay gate

Claude-Session: https://claude.ai/code/session_01Utp6CajiB6BSQKWowy6YLB
Co-authored-by: Claude <noreply@anthropic.com>
…r the percent formula return type

Claude-Session: https://claude.ai/code/session_01Utp6CajiB6BSQKWowy6YLB
Co-authored-by: Claude <noreply@anthropic.com>
The formulas and field-types pages enumerate a formula's returnType; both
now name percent and state its fraction convention, its scale and its
percentDisplay face, as the field schema's describe does.

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CajiB6BSQKWowy6YLB

Final head for review · area data-2 · 2026-11-19T17:19Z
Head: 2cafa561fd1a6174c206167ae7dab3ea63880147. Round 1 is the dev's feature commit b53d3a37. The PM's commits follow it: the changeset; two CI fixes (the test-source alias imports, and the lint shipped-predicate census 63 → 65); a base-only merge of main via os-regen-merge.sh (986de618a); and the regenerated reference pages plus the en metadata-forms bundle. The dev's round 2 adds the hand-written docs (formulas.mdx, field-types.mdx). K = 7. CI on the head: 61 success, 9 skipped, 0 failed.
Fixes #35047 · Clause-②: yes (widening) · Metadata-protocol: added · Skills-docs: follow-up #35607 (p3, pm:blocked on this card, nested under it, unclaimed) · +383/−54 over 28 files · NOT governed.
Gates: os-dev-report 7016442707 — dispatch-gates 128 derived, 128 run, 0 NOT-MEASURED; spec 857 files / 27395 tests, objectql 616 / 13911, six typechecks exit 0; overlap-check clean against origin/main and PRs #35510, #34817. No narrowing arm, so no dogfood battery.
PM body edit: brought to this head; attribution header, four-line 维护者速读, English 席位核对, signed trailer.
Review route: L1-a, then seat 5's contract review (Metadata-protocol added); the area lands.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 用户能看到什么变化:公式字段可以声明返回"百分比",像百分比字段一样显示(0.25 显示为 25%,可选进度条或纯文字);预算使用率、毛利率这类比率公式不再显示成一个光秃秃的小数。
  • 为什么做:以前公式只能返回数字,比率公式显示成 0.25,和旁边的百分比字段对不上。
  • 出错会怎样:只影响声明了百分比的公式和"由表达式计算的百分比字段"的小数位;已有公式不受影响。后者的保存精度会比以前多两位,这点需要在发布说明里写明。
  • 要你做什么:无。区域补两处说明后,席位做合同复审,再由区域落地。
  • 席位意见:实现正确、各处读取口径一致,可以进入合同复审;落地前须在发布说明里补上已有百分比字段精度变化这一条。

席位核对

L1-a: ACCEPT, with two required items before queueing · head 2cafa561fd1a6174c206167ae7dab3ea63880147 · Fixes #35047 · 2026-11-19T17:20Z · reviewed to pm-dispatch text at origin/main fca72dfa32

Readings, my own.

Code.

  • The spec enum. FieldSchema.returnType gains percent, and its describe states the reading: fraction unless max > 1 (percentScaleOf), scale = displayed places, declared and never inferred. percentDisplay's describe and its form gate (data.type == 'formula' && data.returnType == 'percent') open for it.
  • Readers that switch on returnType. Each gains the member as a number-like:
    • display-name eligibility;
    • filter operator typing (['percent','percent']);
    • comparand typing;
    • the stack and component describes.
  • The renderers. Both reuse the percent field's own faces: the cell via PercentCellRenderer with type: 'percent', so resolveFieldScale sees the percent default; the form via PercentField read-only. There is no second formatter. Whitespace stays empty.
  • The engine (formulaRoundingScale). A percentage rounds at scale + 2 when stored as a fraction, and at scale when stored as whole points, matching the write seam's max_scale allowance.

R1 (required before queueing): name the stored-percent change in the changeset and the PR body. formulaRoundingScale also changes for a stored percent field computed from its expression (def?.type === 'percent'). That is an existing, published shape.

  • Before: its computed fraction was rounded to scale, so 0.417 at scale: 1 was stored 0.4 (40.0%).
  • Now: it keeps scale + 2 places (41.7%).

That is a correct fix, and it is pinned ("a stored percent field computed from its expression is rounded the same way"). But it changes what an existing field's next computed write stores, and the changeset only speaks of percent formulas ("A percent formula result…", "the engine rounds a fraction result"). "Nothing stored needs migrating" stays true, since rows written before keep their value. Add one bullet saying:

  • the same rounding now applies to an existing percent field that computes from an expression;
  • what it stored before;
  • rows written earlier are not rewritten.

Mirror it in the PR body. This is a changeset and body edit. I re-read only the changeset on the new head, so no full fresh L1 is needed. The arm stays yes (widening): no input is refused, and an answer gains precision.

R2 (required before queueing): amend the claim for packages/lint. packages/lint/src/validate-predicate-path-refs.test.ts (census 63 → 65) is outside the claim's surface. The PR body names it with the reason, at line 27: the percentDisplay gate's two new literal comparisons. Post a claim amendment on #35047 naming it. Text only.

Pins (names grepped).

  • formula-percent-result.test.ts (spec).
  • engine-formula-scale.test.ts:
    • a percent formula keeps scale + 2 (5/12 at scale: 1 = 0.417);
    • max > 1 rounds to scale;
    • a stored percent field is rounded the same way;
    • CONTROL: a number formula still rounds to scale.
  • formulaFaces.returnType-11748, per locale:
    • a fraction reads 25%;
    • scale counts the displayed places;
    • max > 1 reads points;
    • both faces equal the percent field's own faces;
    • CONTROL: returnType: number reads 0.25;
    • the bar unless percentDisplay: plain;
    • whitespace empty, not 0%.
  • The inspector pin offers percent.

Declaration: agreed, apart from R1.

  • Clause-②: yes (widening) / Metadata-protocol: added: the enum gains a member, and every formula that parsed still parses.
  • Skills-docs: follow-up #35607, written as #N. It is a p3 card blocked on this one: skills/objectstack-data/rules/field-types.md:130 lists return types without percent.

Changeset sentences checked against the diff:

  • the value reading;
  • its places;
  • its face (percentDisplay, the renderer, the inspector);
  • declared, never inferred;
  • readers treat percent as a number;
  • "the enum only gains a member".

Routing. L2 is owed at CONTRACT_REVIEW_TIER (published packages/spec/src/**) by seat 5 on the head after R1. It is not governed, so data-2 lands it after the L2.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 用户能看到什么变化:与上一版相同;发布说明补写了已有"由表达式计算的百分比字段"保存精度提高(0.4 变为 0.417)这一条。
  • 为什么做:上一轮审核要求把这项对已有字段的变化写进发布说明。
  • 出错会怎样:本轮只改说明文字,不改代码。
  • 要你做什么:无。席位做合同复审后由区域落地。
  • 席位意见:两项要求都已补齐,CI 全绿后可进入合同复审。

席位核对

L1-a delta: ACCEPT, R1 and R2 closed · head 03a17ea72f45c96fb8ec0546a55fff23e9ca1756 (delta over 2cafa561fd, my record 7016603071) · 2026-11-19T17:23Z

Delta. One commit, one file: .changeset/35047-formula-percent-return.md, +1 line. No source or test changed, so the rest of 7016603071 stands as read.

R1: closed. The new bullet names "an existing percent field computed from its expression". It gives:

  • the before and after (0.417 at scale: 1 stored 0.4 / 40.0%, now 0.417 / 41.7%);
  • the whole-percentage case (scale);
  • "applies to the next computed write; rows written earlier are not rewritten".

That matches formulaRoundingScale's def?.type === 'percent' branch and its pin. The PR body mirrors it (line 21).

R2: closed. Claim amendment 7016639769 on #35047 names packages/lint/src/validate-predicate-path-refs.test.ts with the reason, the gate's two literal comparisons, and CI evidence (Test Core 5/10 red on 1503829de). It also lists the inspector pin's import fix and the service-analytics test that moves with the enum.

Still owed before queueing: CI green on this head, which was running at this reading.

Routing. L2 is owed at CONTRACT_REVIEW_TIER by seat 5 on this head once it is green. It is not governed, so data-2 lands it after the L2.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 03a17ea72f45c96fb8ec0546a55fff23e9ca1756
Local-runs: none
Scope: packages/spec/src/data/display-name.ts, packages/spec/src/data/field.form.ts, packages/spec/src/data/field.zod.ts, packages/spec/src/data/filter-text-operator-declared-type.ts, packages/spec/src/data/object.form.ts, packages/spec/src/stack.zod.ts, packages/spec/src/ui/component.zod.ts + packages/objectql/src/engine-top-level.ts, ui/packages/fields/src/index.tsx, ui/packages/fields/src/widgets/FormulaField.tsx, ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx

PR #35565 for card #35047, schema face. Read: the card body and its six comments (no ruling and no earlier record among them), the PR body, the 28-file list, and the net diff against main (merge base 97f342037d). Tests, generated reference pages, the generated en forms bundle, the docs pages and the changeset body are outside ④.

Check-runs on this head when this record was written: 71 runs: 33 success, 11 skipped, 1 cancelled, 26 in progress, none red. The cancelled run is PR-body guards (claim · duplicate · Part-of · single-writer path); a second run of that name concluded success. Concluded success among the gates this review leans on: Check Changeset (both runs), Spec property liveness, Governed Surface Queue Guard, Lint & Repo Gates and the seven Lint · runs, Build Core, Build Docs, Build & E2E UI, Live E2E UI, Dogfood Regression Gate, Type Check · source gates, Type Check · consumer gates, Type Check · debt ledger, and Test Core shards 6, 7 and 8 of 10. Still in progress: Test Core shards 1, 2, 3, 4, 5, 9 and 10 of 10, all sixteen Test UI shards, Type Check UI, Type Check · workspace and Lint UI. Those families have not answered on this head, and this record does not speak for them. The PR body's count of 61 success and 9 skipped is not what the head shows now.

① Derived judgments

Accept-set and public-surface changes the diff implies:

  1. FieldSchema.returnType gains the member percent. Right. A pure widening: every formula that parsed before parses the same, and a value outside the six is still refused.
  2. FieldSchema.percentDisplay now describes a formula returning percent as well. Right. The key never carried a parse-time type restriction, so no accept set moves; the describe now matches what the percent cell does with the field it is handed.
  3. FieldSchema.scale describe: on a percent formula the engine rounds a fraction to scale + 2 places. Right, and it is what formulaRoundingScale does.
  4. FORMULA_RETURN_TYPE_AS_FIELD_TYPE (exported) gains percent to percent. Right. percent is in the numeric class, so the text-operator door refuses a text operator over a percent formula and the number door judges its comparands as it does for a percent field. Nothing that parsed before is newly refused, because the return type did not parse before.
  5. LOOKUP_AUTOFILL_FORMULA_VALUE_TYPE in stack.zod.ts gains percent. Right. A lookupAutofill pair whose source is a percent formula is now judged as a percent source: it fills a percent target and is refused into any other, exactly as a stored percent source is.
  6. The object-form runtime field's returnType in component.zod.ts widens by reference to the field schema; only its describe is edited. Right.
  7. display-name.ts moves a jsdoc list only. Right. Title eligibility still requires text.
  8. The field form and the object form offer Percent, and the field form's percentDisplay row opens for a percent formula. Right. The predicate has the shape of the currencyConfig row beside it, and the lint census moves from 63 to 65 for the two added literal comparisons.
  9. Engine behaviour: a percent formula is rounded at the percent storage (scale + 2 for a fraction, scale for a whole percentage). Right.
  10. Engine behaviour on EXISTING metadata: a stored percent field computed from its expression is rounded the same way, where it was rounded to scale itself. Right. The scale describe on main already states that a fraction-stored percent keeps scale + 2 stored places, and the record validator allows exactly that; the computed path was the one reader that cut the value shorter. The changeset and the PR body both say so.
  11. The formula cell and the formula form face draw a percent result through the percent field's own faces. Right.
  12. The Studio inspector's stamp keeps a declared percent when the engine's verdict is number. Right as far as it goes, and wrong for an unproven verdict: see S1.

② Semver level

  • The changeset grades @objectstack/spec minor and @objectstack/objectql, @object-ui/fields and @object-ui/app-shell patch. Right. The protocol package the diff widens is graded minor, which is what an added kind requires of at least one moved package. The other three move behaviour and no protocol.
  • @objectstack/platform-objects (the regenerated en forms bundle) carries no entry of its own and is in the fixed group with @objectstack/spec, so it releases with it.
  • The PR body and the changeset both carry Clause-②: yes (widening) and Metadata-protocol: added at the start of a line. Both are right: an accepted value is added and nothing is refused or tightened. Item 10 above is not a semantic kind: it brings the computed value to the precision the scale describe already declared, and changes no meaning an author wrote against.
  • N1 (nit) — the changeset says "the Studio field inspector offers percent as a return type", and the PR body says the same. The tree does not: ObjectFieldInspector.tsx has no return-type control, and its four added lines only keep a declared percent through a number verdict. The offer is in the field and object forms. A prose face, so the wording can be corrected on the head that closes S1.

③ Boundary flags

  • open_questions in the os-dev-report (comment 7016442707): an empty list. Nothing to answer.
  • Dev flag: skills/objectstack-data/rules/field-types.md lists the formula return types without percent. Answered: it is carried by docs(skills): name the percent formula return type in the data field-types rules #35607, which is open, and the skills surface is outside this card's fence. The follow-up stands.
  • Dev flag: the "In the Console" paragraph of field-types.mdx does not say how a currency formula is drawn. Answered: older than this card and prose outside ④; it needs no carrier from this PR.
  • Claim amendment (comment 7016639769): the lint census moves 63 to 65. Answered: right, counted in ① item 8.
  • The stored-percent rounding change (PR body and changeset). Answered: accepted, ① item 10. It applies from the next computed write and earlier rows are not rewritten, so one column can hold both precisions until its rows are written again; the changeset says so, and no migration is owed because no metadata is refused or re-read.
  • The release and its withdrawal (comments 7013556381 and 7013617911) are process notes and raise no contract question.
  • SQL push-down: no query path is touched. The rounding is a per-value step on the existing formula plan; the diff adds no id materialisation and no in-app join.
  • Outside the diff, read and not reviewed, for the seat to route:
    • packages/lint/src/rule-explanations.ts line 2694 lists the formula return types as five, without percent. Same class as docs(skills): name the percent formula return type in the data field-types rules #35607.
    • Faces that branch on the field's own type do not read a percent formula as a percentage: the record header chip in ui/packages/plugin-detail/src/DetailView.tsx and the grid footer in ui/packages/plugin-grid/src/useColumnSummary.ts. A currency formula has the same gap at the header chip.
    • In ObjectFieldInspector.tsx the same stamp appears to write a number verdict over a declared currency, since the inspector's verdict vocabulary has no currency. Read only, on lines this diff does not touch.

④ Design judgment

Hits files:

  • packages/spec/src/data/field.zod.ts — the enum member and the three describes hold against their first consumers. The engine rounds a fraction at scale + 2 and a whole percentage at scale (engine-top-level.ts lines 1427 to 1445), reading the same max above 1 statement the record validator reads. The cell and the form face resolve an absent scale to 0 and the storage from max, through resolveFieldScale and percentScaleOf. One sentence does not hold against the scenario it is accepted for: S1. Two nits, N2 and N3.
  • packages/spec/src/data/field.form.ts — holds. The sixth option and the percentDisplay gate agree with the schema. One nit, N4.
  • packages/spec/src/data/object.form.ts — holds. The sixth option agrees with the enum, and datetime stays refused as the comment says.
  • packages/spec/src/data/filter-text-operator-declared-type.ts — holds. The map stays the identity over the enum, which its own jsdoc requires.
  • packages/spec/src/stack.zod.ts — holds, ① item 5.
  • packages/spec/src/ui/component.zod.ts — holds; describe only.
  • packages/spec/src/data/display-name.ts — holds; jsdoc only.

Implementing files:

  • packages/objectql/src/engine-top-level.ts — agrees with the contract sentence by sentence. A scale of 99 or 100 on a fraction asks for more than 100 places and is left unrounded, which is the existing bound's own answer. An absent scale rounds nothing and the faces resolve the width, as for a percent field that declares none.
  • ui/packages/fields/src/index.tsx — agrees. The formula cell hands the percent cell the formula's own scale, max and percentDisplay under the type percent, and the grid column builder already relays all four keys whatever the field's type.
  • ui/packages/fields/src/widgets/FormulaField.tsx — agrees. PercentField asks both resolvers about percent whatever type the bag carries, so the form face and the cell read one rule.
  • ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx — S1.

Findings:

S1 (should-fix) — ObjectFieldInspector.tsx, settleFormulaType (lines 1103 to 1108), keeps a declared percent only when the engine's verdict is number. Under an unproven verdict (unknown, or no verdict) next is undefined, the new guard does not apply, and line 1108 patches returnType: undefined over the declared percent. By the tree's own account that is the verdict of the ratio shape this card is accepted against: an operator over two field reads types dyn (packages/formula/src/formula-return.ts line 129), inferExpressionType('amount + rate') is pinned unknown (validate.test.ts line 1275), and inferFormulaReturn('record.budget - record.spent') is pinned to stamp nothing (formula-return.test.ts line 152). The spec's own fixture for this feature is record.spent / record.budget (formula-percent-result.test.ts line 27). So the first edit of such an expression in the Studio inspector silently turns a percent formula back into an undeclared one, and the inspector has no return-type control to put it back. The new pin edits to record.est_hours / 40, a constant divisor the engine does prove number, so it does not exercise this arm. The contract is silent on the same case: the returnType jsdoc in field.zod.ts says the stamp is "absent when the type can't be proven" and, further down, that percent is "DECLARED, never inferred", kept "where it would stamp number". Asked: say in that jsdoc what a declared percent does under an unproven verdict, make the stamp follow it (a declared percent survives every verdict that does not prove another type), and pin it on a field-over-field quotient. Caveat: the quotient's own inferred type is pinned nowhere in the tree and nothing was run for this record; if the new pin shows record.a / record.b proves number, S1 narrows to the no-verdict arm and the jsdoc sentence.

N2 (nit) — the returnType describe opens "Inferred value type of a formula field (number/text/boolean/date/currency/percent)" and closes "Declared by the author, never inferred". The first words no longer cover the sixth member.

N3 (nit) — percentScaleOf and resolveFieldScale answer undefined for a percent formula handed over as declared (type: 'formula'), while the scale describe names resolveFieldScale as the single source for an absent scale and the returnType describe promises "absent: 0". The three consumers in this diff ask about percent instead, which is the existing practice of PercentField and percentCellScale; the rule itself is written only in a test comment. A follow-up card, or one sentence in the describe.

N4 (nit) — the forms open percentDisplay for a percent formula, and not scale or max, the two other keys the describe says the formula carries (field.form.ts gates scale to number and max to number and currency; object.form.ts gates both without formula). A form author cannot state the decimal places or whole-percent storage, and the card's own symptom (100.0) is a formula in percentage points. The gating is older than this diff. A follow-up card.

No must-fix. S1 is open on this head and earns a delta review of its fix; the four nits do not.

Implemented-by: claude/issue-35047-formula-percent-return
Reviewed-by: isolated-l2-35565

VERDICT: PASS

…rmula verdict

The field inspector cleared a declared `percent` return type when the edited
expression proved no type, which is the verdict of a field-over-field quotient
such as `record.spent / record.budget`. A declared `percent` or `currency` now
survives every verdict that proves no other type (`number`, or none); a verdict
that proves text, a boolean or a date still stamps. The returnType jsdoc and
describe say so, and the changeset names the forms, not the inspector, as the
place that offers `percent`.

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CajiB6BSQKWowy6YLB

Final head for review (S1 round) · area data-2 · 2026-11-19T18:36Z
Head: bc810f4ad9458176645f43b29574130fc6d03f44, over 03a17ea72f (the head contract review 7017037505 judged, PASS with S1 should-fix open). Two commits, both the PM's:

  • fe974fb467 S1: ObjectFieldInspector.settleFormulaType returns early when the declared returnType is percent or currency and the verdict is number or unproven, so a field-over-field quotient (dyn) no longer clears it; a verdict proving text, boolean or date still stamps. The returnType jsdoc says so and names record.spent / record.budget; the describe no longer opens "Inferred" and closes "never inferred" (N2); the changeset says the field and object forms offer percent, and what the inspector keeps (N1). New pins in ObjectFieldInspector.returnTypeHeld-27485.test.tsx: field-over-field keeps percent, keeps currency; a number verdict keeps currency; a boolean verdict stamps over currency; CONTROL: the quotient still clears a declared number. 11 passed; with the fix taken out, the three keep arms fail (3 of 11).
  • bc810f4ad9: reference docs regenerated by check:generated --fix (field.mdx, object.mdx, migration.mdx). check-i18n-bundles: in sync, no bundle change.
    CI on the head: 61 success, 9 skipped, 0 failed. K = 13 (< 15, no main merge). +437/−56 over 28 files · NOT governed.
    Left as ruled: N3, N4 (no change). Out of the diff, routed by the seat to seat 7: rule-explanations.ts five-type list, header chip and grid footer.
    Review route: L1-a delta, then seat 5's narrow S1 delta; the area lands.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 用户能看到什么变化:在 Studio 里改一个"百分比"或"金额"公式的表达式时,不再悄悄把它的类型丢掉;只有表达式明确算出文字、是否或日期时才会改类型。
  • 为什么做:合同复审指出,像"已花费 ÷ 预算"这种两个字段相除的写法,改一次表达式就会把百分比类型清空,而界面上没有地方能改回来。
  • 出错会怎样:作者得手动去配置文件里补回类型;最坏是百分比公式显示成普通数字。
  • 要你做什么:无。席位做窄范围复审后由区域落地。
  • 席位意见:修复正确、有对照测试;有一句对外说明把"金额"类型写成只能手工声明,与系统会自动识别金额的事实不符,建议顺手改一句,不挡合并。

席位核对

L1-a delta: ACCEPT, no required item · head bc810f4ad9458176645f43b29574130fc6d03f44 (delta over 03a17ea72f, my records 7016603071 / 7016662780; seat 5 L2 7017037505 S1, N1, N2) · K=13 · merge-tree clean · not governed (0 of 28 paths) · 2026-11-19T18:38Z

Delta. Two commits, 7 files, +65 / −14: fe974fb467 (inspector, its pin, field.zod.ts jsdoc and describe, changeset) and bc810f4ad9 (three regenerated reference pages, the describe text only).

S1: closed. settleFormulaType now returns early when the declared type is percent or currency and the verdict is number or unproven (next === undefined). A text, boolean or date verdict still patches. The five new pins cover:

  • percent on the field-over-field quotient record.est_hours / record.budget (the stub answers unknown, mirroring formula-return.ts's dyn);
  • currency on the same quotient;
  • currency on a proven number verdict;
  • a boolean verdict still stamping over currency;
  • CONTROL: a declared number is still cleared by the quotient.
    Read against the pre-fix guard (percent && next === 'number' only), the first three fail without the fix and the last two pass both ways, as the relay says. Not re-run locally (no install in this container); CI ran the file green.

N1: closed. The changeset now says the field and object forms offer percent, and the inspector only keeps a declared percent or currency.

N2: closed, with one new inaccuracy. The describe no longer opens "Inferred". But its new sentence says "currency and percent are declared by the author". For currency that is half the story: the jsdoc 20 lines above, in the same file, says inferFormulaReturn (packages/formula/src/formula-return.ts line 290) proves the result is money at authoring and stamps currency with its currencyConfig. A reader of the generated reference page now gets the wrong account of how a currency formula gets its type.

  • Suggested wording: "currency is stamped when authoring proves the result is money, or declared by the author; percent is only declared."
  • I grade it a nit and hand it to seat 5's S1 delta to decide: it is a published describe, a prose face only, fixable with the describe plus a docs regeneration.

Scope note for seat 5. The currency arm goes beyond S1, which asked only for percent. On main, editing a currency formula's expression in the inspector stamps number over it, or clears it on an unproven verdict. With this head it keeps currency. That is a Studio behaviour change to an existing shape. The changeset discloses it ("keeps a declared percent (or currency)"), the claim's surface covers the inspector, and the jsdoc states it. I read it as in scope.

CI. 62 success, 11 skipped, 0 failed. One Check Changeset re-run was still in progress at this reading; the earlier run of the same check completed success at 17:59:42Z.

Routing. Seat 5 runs the narrow S1 delta at CONTRACT_REVIEW_TIER on this head. Not governed, so data-2 lands it after that.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: bc810f4ad9458176645f43b29574130fc6d03f44
Local-runs: none
Scope: packages/spec/src/data/display-name.ts, packages/spec/src/data/field.form.ts, packages/spec/src/data/field.zod.ts, packages/spec/src/data/filter-text-operator-declared-type.ts, packages/spec/src/data/object.form.ts, packages/spec/src/stack.zod.ts, packages/spec/src/ui/component.zod.ts + packages/objectql/src/engine-top-level.ts, ui/packages/fields/src/index.tsx, ui/packages/fields/src/widgets/FormulaField.tsx, ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx

DELTA review d1 from 03a17ea72f45c96fb8ec0546a55fff23e9ca1756 (record 7017037505: PASS, should-fix S1, nits N1 to N4) to this head, PR #35565 for card #35047.

The delta is two commits in a line, fe974fb467 and bc810f4ad9, with no merge of main: the merge base is still 97f342037d and the old head is an ancestor of the new one. Seven files move, 65 lines added and 14 removed. Of the scoped files only two are touched: field.zod.ts (the returnType jsdoc and describe) and ObjectFieldInspector.tsx (the stamp guard). The other nine scoped files are byte-identical to the head the first record judged, so its judgments on them stand. Also read for this round: the dev's head note 7018413333 and the L1-a delta 7018455890 on the PR.

Check-runs on this head when this record was written: 74 runs, 63 success, 11 skipped, none in progress, none red. Every Test Core shard, every Test UI shard, Type Check UI, Type Check · workspace and Lint UI concluded success; those are the families the first record could not speak for.

S1: closed.

settleFormulaType (ObjectFieldInspector.tsx lines 1101 to 1110) now returns before the patch when the declared returnType is percent or currency and the verdict is number or unproven. Unproven is next === undefined, which covers both an unknown verdict and no verdict at all, so the three cases asked for (number, unproven, absent) are one arm. Any other proven type (text, boolean, date) still reaches the patch on line 1110. The fix no longer depends on which verdict a field-over-field quotient gets, so the caveat the first record left on S1 is moot.

The returnType jsdoc in field.zod.ts now decides the case it was silent on: the stamp is "absent when the type can't be proven ... except that a declared percent or currency stays", and the percent paragraph says it is kept "under every verdict that proves no other type". The code agrees with both sentences.

① Derived judgments

  1. Studio authoring: a declared percent survives an unproven verdict as well as a number one. Right; it is what S1 asked for.
  2. Studio authoring: a declared currency survives a number or unproven verdict. Right. On main the same stamp wrote number over every declared currency on the first expression edit, or cleared it, because the inspector's verdict vocabulary has no currency; the first record noted that outside the diff. It is the same defect with the same cause, closed by the same guard, and the jsdoc, the describe and the changeset all state it.
  3. The returnType describe is reworded. Right. No accept set moves: the enum is the six members of the earlier head.
  4. No other accept-set or public-surface change. The changeset's package levels and both declaration lines are unchanged.

② Semver level

Unchanged and still right: @objectstack/spec minor, @objectstack/objectql, @object-ui/fields and @object-ui/app-shell patch. The currency arm is a Studio behaviour change in @object-ui/app-shell, which the patch entry covers; it adds nothing to the protocol, so Metadata-protocol: added and Clause-②: yes (widening) in the PR body and the changeset stay right.

N1: closed. The changeset now says the field and object forms offer percent as a return type, and that editing the expression in the Studio field inspector keeps a declared percent (or currency) unless the new expression proves text, a boolean or a date. The PR body says the same. Both match the tree.

③ Boundary flags

  • The pins discriminate. Five new cases in ObjectFieldInspector.returnTypeHeld-27485.test.tsx, over a stubbed engine that answers unknown for a field-over-field quotient: the quotient keeps percent; the quotient keeps currency; a number verdict keeps currency; a boolean verdict stamps over currency; and a control, the quotient still clears a declared number. Read against the earlier guard (percent with a number verdict only), the first three do not hold without the fix and the last two hold either way, so the first three carry the fix and the last two bound it. Together with the two earlier percent pins, each kept arm (percent and currency, under number and under unproven) has a case. A date verdict and an absent verdict have no case of their own; both run through arms that do. Test Core and Test UI concluded success on this head.
  • The stub's statement that a field-over-field quotient types dyn is the stub's, taken from formula-return.ts; no pin measures it against the real engine. Since the guard treats number and unproven alike, nothing in this delta rests on it.
  • Scope of the currency arm: beyond the letter of S1, inside the claim's surface (the inspector), and disclosed in the changeset and the PR body. Accepted, ① item 2.
  • N3 and N4 are left as ruled, with no change in this delta. The three out-of-diff observations of the first record are reported by the dev's note as routed to another seat; nothing in this delta touches them.
  • Docs regeneration is consistent. bc810f4ad9 moves three reference pages only, and the new describe appears five times across them (field.mdx once, object.mdx twice, migration.mdx twice); the earlier describe text appears nowhere in the tree. component.mdx carries the runtime field's own describe and is rightly untouched.
  • SQL push-down: no query path is touched.

④ Design judgment

  • packages/spec/src/data/field.zod.ts — holds. The jsdoc and the describe now say the same thing as the stamp, sentence by sentence. N2: closed; the describe no longer opens "Inferred" and no longer closes "never inferred". Two nits, N5 and N6.
  • ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx — agrees with the contract. Tried against it: a percent or currency formula edited into text, a boolean or a date is restamped; an emptied expression still clears the type on the edit itself; a broken source still leaves the stored type; a declared number is still cleared by an unproven verdict.

N5 (nit) — the L1-a delta's point that the describe's "currency and percent are declared by the author" contradicts the jsdoc's account of inferFormulaReturn. In the tree the describe is the true one. inferFormulaReturn is exported from @objectstack/formula and pinned by its own tests and one example-app test, and no authoring door calls it: the Studio stamp reads inferExpressionType, whose answers are number, text, boolean, date and unknown, and neither the CLI nor the MCP tools call it. formulas.mdx says the same: "You declare it yourself — nothing back-fills it", with inferFormulaReturn as the function that answers what to declare. So a currency return type reaches a formula only by an author writing it, and the rewording L1-a suggests ("stamped when authoring proves the result is money") would be less true than what stands. What is left is that the describe does not name the function, and that the older jsdoc sentence "for the stamp to copy", which this diff does not touch, reads ahead of the tree. An accepted deviation; it can ride on N6's follow-up.

N6 (nit) — a kept currency can go stale where a kept percent cannot be judged at all. When an edit turns a money formula into a count, the engine proves number, and this head keeps currency and its currencyConfig; formula-return.ts says of the stamp it was written for that a formula edited from money to a count must lose them. On main every edit lost the declaration, right or wrong, so this head is the better of the two on the common path, and the author can still change the type in the field form. A follow-up card: have the inspector's stamp ask inferFormulaReturn, which can both prove a currency and withdraw one.

No must-fix, no should-fix.

Implemented-by: claude/issue-35047-formula-percent-return
Reviewed-by: isolated-l2-35565

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CajiB6BSQKWowy6YLB

Landing · area data-2 · 2026-11-19T18:46Z

reading value
L1-a ACCEPT 7016662780 at 03a17ea72f; delta 7018455890 ACCEPT at bc810f4ad9 (= current head)
Contract review (CONTRACT_REVIEW_TIER) 7017037505 PASS with S1 at 03a17ea72f; delta d1 7018560972 PASS at bc810f4ad9458176645f43b29574130fc6d03f44 (= current head), S1 / N1 / N2 closed; L1-a's describe nit recorded as accepted deviation N5 (wording left as is); N3 / N4 accepted; N6 filed as #35631 under #35047
Battery os-dev-report 7016442707 (spec 857 files / 27395 tests, objectql 616 / 13911, six typechecks exit 0); S1 round: inspector pin file 11 passed, the three new keep arms fail with the fix taken out
CI on head 61 success, 9 skipped, 0 failed; mergeable clean
check-governed-merges --pr 35565 NOT governed; +437/−56 ≤ 3000; K = 14 (< 15)

State: draft → ready + auto-merge (merge queue). #35047 closes on merge via Fixes. Skills follow-up #35607 unblocks on merge.

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 protocol:data protocol:ui 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.

spec: a formula has no percent return type, so a ratio formula (budget used, gross margin) reads as a bare number

2 participants