Repository navigation
Commit 0c6f679
fix(formula): a date ordered against a text field gets its own refusal code, date-text-ordering (#39148)
Part of #38959
Item 4 only, ruled option A in 7344060050. Items 1, 5 and 2 landed in
#39072, and item 3 is recorded as accepted fail-open; the seat closes
the card when this lands.
Clause-②: yes
Metadata-protocol: none
Skills-docs: none — the kind is `none` with no arm, and
`skills/objectstack-formula` names no `type-mismatch*` code for this
shape
## 维护者速读
- 用户能看到什么变化:流程条件、校验规则、公式里把日期字段和文本字段比大小时,提示语换成一条新代码
`date-text-ordering`,说的是实际发生的事——按文本逐字比较,不会运行出错;该拦截的照样拦截,级别(错误/警告)不变。
- 为什么做:流程条件发布检查那张卡的第 4 项(日期与文本比大小的提示语不实),按你选的方案 A:给这种判定一个自己的代码和真实的句子。
- 出错会怎样:最坏是某处按旧代码匹配这种写法的提示会改看到新代码,拦截与否和级别都不变;可直接撤回本 PR 恢复旧提示。
- 要你做什么:无(契约审核由席位安排)。
## Fix round (contract review 7349732810, S1 and N3), head `c18de9c61d`
- **S1.** The params and sentence of `date-text-ordering` now come from
the comparison that keeps the verdict.
- `comparesDateTextAgainstUndeclared` returns that comparison instead of
a boolean: its operator, its operand types and its counterpart.
- The counterpart is given only when it is a text field read. An index
read is named in member spelling.
- `firstTypeMismatch` passes the comparison on as `ordering`, and
`validate.ts` reads the params and sentence from it.
- `field` and `root` are untouched, so the grade cannot move.
- This supersedes the `dateTextOrdering: true` flag that the
`cel-engine.ts` bullet and the ablation lines below describe.
- **`reference` is narrower.** It now appears only for a direct
text-field read. Computed text (`upper(record.title)`,
`string(record.notes)`, a concatenation) loses it, and the sentence then
reads "a text value". An index read `record['title']` gains `reference:
record.title`. The params type is unchanged.
- **Pins.** Both of the reviewer's shapes are pinned at 7 sites, with
params asserted by equality. A base-vs-head sweep of 94,080 judgments
found 0 code or grade changes; 22,488 changed params or sentence only.
- **N3.** The lint counter comment and the `#30026` note are reworded;
prose only.
- **Review.** The delta contract review passed with `No must-fix, no
should-fix.`
## What changes
- **`@objectstack/formula`, `expression-refusal.ts`.** One new code in
the closed refusal vocabulary, `date-text-ordering`, params `operands`,
`operator`, `reference?` (the text counterpart as written, when it is a
field read). Its pin file holds three pins: a formula-field warning, a
record-triggered flow error with the reversed operand order, and a
counterpart that is no field read.
- **`validate.ts`, `typeSoundnessIssue`.** Where the type mismatch is
the kept date-against-text ordering (the #32595 verdict, unchanged), the
refusal is `date-text-ordering` with a sentence that says what the run
does: the runtime holds the date field as its text, so the comparison
evaluates as a text comparison and does not fault, answering by
spelling, not by date. It prescribes `date(TEXT)` to compare dates (null
where the text is no date) or `string(...)` on the date side to compare
text on purpose. Both prescriptions are pinned clean at every site and
evaluated.
- **Same sources, same grade.** The grade is the one the site's
`type-mismatch*` code carried: an error at a site that declares its
fault outcome (fail-closed rule, advisory rule, record-triggered flow,
sweep of the typed object, a member read under `bareNamesUnproven`), a
warning elsewhere (formula field, flow condition with no declared
outcome, unproven bare name). Review S3 on #39072 stays as ruled: the
three S3 sources keep the warning grade, now under the new code.
- **Final spelling, measured against the ledger.** The working name
`date-text-ordering-run-may-fail` was not taken. In this ledger a
`-run-fails` / `-run-may-fail` / `-fail-closed` / `-fail-open` /
`-sweep-run-fails` / `-value-run-may-fail` suffix names the fault
outcome a sentence states at one site. This verdict has no fault, so it
has no outcome to name, and its sentence is the same at every site. The
contract ("a code names ONE message template") then gives one code with
no suffix. That is the precedent of `list-equality` and
`date-duration-value`, and the shape of the `date-text-arithmetic` /
`date-text-call` family names. It does not match `DATE_TEXT_FAMILY_RE`
(`date-text-(call|arithmetic)`), so the item-1 precedence never takes it
as a date-text fault.
- **A date-text fault beside the ordering is the finding at every
grade.** The new sentence says its comparison does not fault, so where
the same source also holds a date-text fault (`record.due_date >
record.title && record.due_date - record.borrow_date > duration('1h')`),
the date-text error wins at error sites too. At warning sites it already
won (item 1). At error sites this moves the code from
`type-mismatch*-fails` to `date-text-arithmetic*`, at the same grade.
- **`cel-engine.ts`.** `firstTypeMismatch` reports which mismatch is the
kept ordering (`dateTextOrdering: true`, from the `keptOrdering` flag it
already computed). This is three code lines (one result field, two
spreads) and their doc comment beyond the claim's "comment only"
surface, declared below. The two comments that still called item 4 open
are rewritten (N8): `cel-engine.ts`, beside `offendingRecordRead(...,
!keptOrdering)`, and the S3 pin's comment in
`validate-date-text-arithmetic.test.ts`.
- **`@objectstack/lint`, `validate-expressions.ts`.** This is one
consumer branch that matched the old code on this shape. The `#30026`
note, which says why a time-relative sweep of another object only warns,
fired on `type-mismatch-run-may-fail` warnings. The ordering was served
as that code, so the note was printed for it. It now counts
`date-text-ordering` warnings at a flow condition too, so the note still
prints for the ordering, as before. Without this, the note would
silently drop for `due_date > title` on such a flow (measured on the
built lint: the warning alone, no note).
### Consumer pins of the old code on this shape
Updated, every one:
- `packages/formula/src/validate-date-text-arithmetic.test.ts`: the
#32595 rows (eight ordering rows, `type-mismatch-fail-closed` to
`date-text-ordering`; `record.title < today()` keeps
`type-mismatch-fail-closed` as the control), the flattened macro row
(`type-mismatch-run-may-fail` to `date-text-ordering`), the #38959 macro
pins (`[due_date].exists(d, d > title)` and the inner-map source,
`type-mismatch-run-fails` to `date-text-ordering`), and the S3 pin
(three sources `warning:type-mismatch-run-may-fail` to
`warning:date-text-ordering`, member control
`error:type-mismatch-run-fails` to `error:date-text-ordering`).
- `packages/formula/src/expression-refusal-codes.test.ts`: the new
code's pins, and one sweep source (`record.close_date < record.name`) so
the closed-set sweep reaches it. The sweep budget docblock's call count
(a volatile count) is replaced by its formula, per AGENTS.md.
- `packages/lint/src/validate-expressions.ts` (source, above).
Searched, with nothing pinning the old code or sentence on this shape.
Each suite below ran green against the rebuilt formula:
- flow publish and registration:
`packages/objectql/src/publish-type-mismatch-fail-closed.test.ts` (12
passed),
`packages/services/service-automation/src/flow-registration-checks.test.ts`
(35 passed);
- lint: the whole `@objectstack/lint` suite (261 files, 10,327 passed);
- MCP and validate tool:
`packages/mcp/src/mcp-validate-expression.test.ts` (80 passed);
- REST envelope: no test pins a formula refusal code. The publish door
answers `INVALID_METADATA` with the message, and the grade is unchanged,
so the status is too;
- dogfood and CLI: `git grep` of tests, `packages/qa`, `examples` and
`docs/qa` for the old sentence on a date-vs-text source and for the
operand spellings `Timestamp < string` / `string <
google.protobuf.Timestamp`: no hit outside formula.
## Tests
- New top-level describe in `validate-date-text-arithmetic.test.ts`, "a
date ordered against a text field is served under its own code, with a
true sentence (#38959 item 4)". It covers:
- `record.due_date > record.title` and its reverse, and a datetime pair,
at seven sites, each at the grade the old code carried there;
- the sentence: the first-sentence shape, the "does not fault" clause,
and no fault wording;
- the run evaluates each source;
- the text-order answer;
- both prescriptions clean at every site;
- CONTROL: a real mismatch (`record.title > 5`, `record.title <
today()`) keeps `type-mismatch*` at every site and faults;
- a date-text fault beside the ordering is the finding at every site,
and faults.
- New top-level describe in
`packages/lint/src/validate-expressions.mismatch-precedence-38959.test.ts`
(spec-valid fixtures). It covers the publish lint over:
- a record-triggered flow: error, new sentence;
- a sweep of the typed object: error;
- a sweep of another object: warning plus the note;
- CONTROL: `title > 5` keeps `type mismatch`.
- No HTTP envelope carries this code. The lint door drops formula codes
into its finding, and the publish door answers `INVALID_METADATA`, so no
`status` assertion applies. `code` is asserted at the formula layer.
<details><summary>Runs at 0fee6f4 (after merging origin/main
27ce3c0)</summary>
- `pnpm --filter @objectstack/formula build && … vitest run
--maxWorkers=2`: 72 files, 2270 passed; `@objectstack/lint` vitest: 261
files, 10327 passed (one `os-verify-lock` run, VERDICT command-exit 0).
- `pnpm --filter @objectstack/formula typecheck` and `pnpm --filter
@objectstack/lint typecheck` (both include `check:test-typecheck`): exit
0, at 037ff18 (pre-merge; the merge brought no formula or lint
change).
- mcp `mcp-validate-expression.test.ts` 80 passed; objectql
`publish-type-mismatch-fail-closed.test.ts` 12 passed;
service-automation `flow-registration-checks.test.ts` 35 passed (against
the rebuilt formula and lint).
- Sweep case wall time, `expression-refusal-codes.test.ts` alone: 461 ms
and 252 ms, against its 16 000 ms budget.
</details>
<details><summary>Ablations (scripts/ablation-replace.mjs, each restore
verified: blob equals HEAD, git diff HEAD empty)</summary>
- `if (mismatch.dateTextOrdering) {` to `if (false) {` (the new branch):
the two formula files, 34 failed.
- `}, true);` to `}, false);` (date-text precedence at every grade): 5
failed, the precedence pins at the error sites.
- `cel-engine.ts` root-pass flag to `...(false ? …)`: 14 failed.
First-pass flag to `...(false ? …)`: 18 failed.
- lint counter `(w.code === 'date-text-ordering' && scope ===
'flattened')` to `(false)`: 1 failed, the sweep-note pin.
</details>
## Acceptance notes
- **File surface.** The claim lists `cel-engine.ts` for its comment
only. The verdict's identity is known only inside `firstTypeMismatch`
(`keptOrdering`), so three code lines there carry it out. Rebuilding it
in `validate.ts` from the operand spelling would mislabel `bool +
DateText` real faults. The lint source line is the consumer branch named
above. Both are outside the stated surface and are reported to the seat.
- **A real mismatch beside the ordering is still the finding.**
Measured: `record.due_date > record.title || record.active + 1 > 2` and
`due_date > title && notes * 2 > 1` answer the `bool + int` / `string *
int` mismatch under its `type-mismatch*` code, not the ordering. The new
sentence speaks of "this comparison" only.
-
`packages/spec/src/migrations/entries/semantic/19.flow-condition-mismatch-warning-and-index-mismatch-refused.ts`
(#39072) describes the ordering as "the mismatch kept as before" and its
warning grade. Both still hold in grade, and it names no code for it. It
is untouched.
- `content/docs/releases/**` and `CHANGELOG.md` are untouched; the
changeset names the code move.
## Verification
Read first, by risk:
1. `packages/formula/src/validate.ts`: the `if
(mismatch.dateTextOrdering)` branch and `dateTextOver(…, always)`.
2. `packages/formula/src/cel-engine.ts`: the two `dateTextOrdering`
spreads.
3. `packages/lint/src/validate-expressions.ts`: the counter line.
Two-minute check: `pnpm --filter @objectstack/formula exec vitest run
--maxWorkers=2 src/validate-date-text-arithmetic.test.ts -t "item 4"`.
Expect every case green, including the seven per-site grade cases for
each pair and the two CONTROL blocks.
<details><summary>Gates: dispatch-gates --commands (71 families) and
--ran reconciliation</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at 0fee6f4: 71 families.
- 67 ran with exit 0, each exit captured before any pipe.
- `--ran` reconciliation: "71 derived famil(ies) accounted for — 67 run,
4 NOT-MEASURED".
- NOT MEASURED, left to CI:
- `check:dual-build-cjs-loads`: exit 3, needs a full build;
- `check:query-options-erasure`: exit 124 at my 200 s per-gate timeout;
- `check:slot-lookup` and `check:type-check-debt`: not started, over the
foreground cap in the earlier rounds on this card.
- `check:nul-bytes`, `check:doc-authoring`, `check:issue-citations`,
`check:adr-0087-registration --base origin/main`,
`check:empty-changeset`, `check:changeset-no-major`,
`check:closing-keyword-parity`: exit 0.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2)_
<!-- signed: repo:objectstack@os-justin · os-justin ·
session_01QSeKYnrQ7UMtHofKQVjcH2 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 355e8e3 commit 0c6f679
8 files changed
Lines changed: 456 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1022 | 1022 | | |
1023 | 1023 | | |
1024 | 1024 | | |
1025 | | - | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
1026 | 1031 | | |
1027 | 1032 | | |
1028 | 1033 | | |
1029 | 1034 | | |
1030 | | - | |
| 1035 | + | |
1031 | 1036 | | |
1032 | 1037 | | |
1033 | 1038 | | |
| |||
1095 | 1100 | | |
1096 | 1101 | | |
1097 | 1102 | | |
1098 | | - | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
1099 | 1111 | | |
1100 | | - | |
| 1112 | + | |
1101 | 1113 | | |
1102 | 1114 | | |
1103 | 1115 | | |
1104 | 1116 | | |
1105 | | - | |
| 1117 | + | |
1106 | 1118 | | |
1107 | 1119 | | |
1108 | 1120 | | |
1109 | 1121 | | |
1110 | | - | |
1111 | | - | |
1112 | | - | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
1113 | 1138 | | |
1114 | 1139 | | |
1115 | 1140 | | |
| |||
1125 | 1150 | | |
1126 | 1151 | | |
1127 | 1152 | | |
1128 | | - | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
1129 | 1168 | | |
1130 | 1169 | | |
1131 | 1170 | | |
| |||
1431 | 1470 | | |
1432 | 1471 | | |
1433 | 1472 | | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
1434 | 1492 | | |
1435 | 1493 | | |
1436 | 1494 | | |
| |||
1481 | 1539 | | |
1482 | 1540 | | |
1483 | 1541 | | |
| 1542 | + | |
1484 | 1543 | | |
1485 | 1544 | | |
1486 | 1545 | | |
1487 | 1546 | | |
1488 | 1547 | | |
1489 | 1548 | | |
| 1549 | + | |
1490 | 1550 | | |
1491 | 1551 | | |
1492 | 1552 | | |
1493 | 1553 | | |
1494 | | - | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
1495 | 1558 | | |
1496 | 1559 | | |
1497 | 1560 | | |
| |||
1515 | 1578 | | |
1516 | 1579 | | |
1517 | 1580 | | |
| 1581 | + | |
1518 | 1582 | | |
1519 | 1583 | | |
1520 | 1584 | | |
| |||
1559 | 1623 | | |
1560 | 1624 | | |
1561 | 1625 | | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
1565 | 1630 | | |
1566 | 1631 | | |
1567 | 1632 | | |
1568 | 1633 | | |
1569 | 1634 | | |
| 1635 | + | |
1570 | 1636 | | |
1571 | 1637 | | |
1572 | 1638 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
777 | 855 | | |
778 | 856 | | |
779 | 857 | | |
| |||
1012 | 1090 | | |
1013 | 1091 | | |
1014 | 1092 | | |
| 1093 | + | |
| 1094 | + | |
1015 | 1095 | | |
1016 | 1096 | | |
1017 | 1097 | | |
| |||
1153 | 1233 | | |
1154 | 1234 | | |
1155 | 1235 | | |
1156 | | - | |
1157 | | - | |
| 1236 | + | |
| 1237 | + | |
1158 | 1238 | | |
1159 | 1239 | | |
1160 | 1240 | | |
| |||
0 commit comments