You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8b550f8
Browse filesBrowse the repository at this point in the historyBrowse files
fix(formula): a flow value envelope's date-text refusal says the run fails when the value is computed (#35358)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgRuogP8Tp8XyFXLc92Bxvo6)_
repo:objectstack#5 · os-bill · session_01Utp6CZiaBg6rk7dpy1s9Me
Fixes#34660
Clause-②: no
Metadata-protocol: none
## 维护者速读
1.
流程作者在流程的赋值或记录写入步骤里把日期字段当文本计算时,校验和发布时的报错原来说“条件运行时流程会失败”,现在改为说“计算这个值时流程会在这一步停下”。
2. 这一步根本没有条件,旧说法会让作者去找一个不存在的条件,这是流程报错文案的体验问题。
3. 出错时只是这条报错的措辞或代码不对,同样的写法仍然被拒绝,流程条件处的报错不受影响,回滚即可恢复原样。
4. 无。
## What changes
- `packages/formula/src/validate.ts`: a flow value envelope
(`ExprSchemaHint.flowValueEnvelope`: an `assignment` value, a
`create_record` / `update_record` `fields.*` value) now takes its own
date-text outcome arm, `value-run-may-fail`, instead of the
flow-condition `run-may-fail` arm. Its fault clause reads: "this faults
wherever `record.borrow_date` holds that text when the value is
computed, and a flow value that cannot be computed fails the run: the
flow stops at this step and the work the flow exists to do is not done
(it does not read null)." The head (what the call or arithmetic is), the
fix hint, the grade (error) and the location are unchanged; both doors
still prefix the value-envelope sentence.
- `packages/formula/src/expression-refusal.ts`: two codes join the
closed set (params map with docblocks, `CODE_TABLE`):
`date-text-call-value-run-may-fail` and
`date-text-arithmetic-value-run-may-fail`. The names follow the ledger's
one site-qualified precedent, `type-mismatch-sweep-run-fails`: family,
then the site (`value`), then the outcome. The outcome stays
`run-may-fail`, since the envelope faults only where the field holds the
text when the value is computed. `DATE_TEXT_FAMILY_RE` already matches
both codes and is unchanged.
- Flow conditions keep `date-text-call-run-may-fail` /
`date-text-arithmetic-run-may-fail` / `-run-fails` and their sentence
byte for byte (the existing per-code message pins are untouched and
green).
- Changeset: `@objectstack/formula` patch.
## Tests
- `validate-date-text-arithmetic.test.ts`: a new top-level describe pins
the shared entry both doors call. For an `assignment`-value source and
an `update_record` `fields.*` source it checks the new code, the value
clause, no "condition" anywhere in the message, and the fix hint kept.
CONTROL: a flow condition over the same field keeps the `-run-may-fail`
code and its condition sentence. CONTROL: the accept set is unchanged
(taught shift, datetime field, no field types). The #34451 block's three
code expectations move to the new codes.
- `expression-refusal-codes.test.ts`: one exact pin (code, params, whole
message) per new code; the sweep gains a flow value-envelope schema so
its positive control reaches both new codes. The sweep budget docblock
records the re-measure (see Acceptance notes).
## Acceptance notes
- **One verdict for lint and `registerFlow`.** Both doors reach the same
call. `@objectstack/lint`'s `checkDeclaredValue` and
`@objectstack/service-automation`'s `valueEnvelopeRefusals`
(`dag-traversal.ts`) each call `validateExpression('value', envelope, {
fieldTypes, flowValueEnvelope: true })` and prefix the message. The
formula pin covers that call. The door suites live outside this claim's
file surface; they assert the fix hint and the prefix, never the code or
the condition wording, and they stay green. A one-shot measurement
through both built doors gave the same clause from each (Verification).
- **A1 holds.** No code reader outside `packages/formula` keys on the
`-run-may-fail` codes for value envelopes. `git grep` of
`date-text-call-run-may-fail` / `date-text-arithmetic-run-may-fail`
outside `packages/formula/src` finds only CHANGELOGs.
`EXPRESSION_REFUSAL_CODES` has no consumer outside the package, and no
i18n pack, docs catalogue, skill or eval names these codes.
- **A2 holds.** Clause-② stays `no`. The same sources are refused at the
same grade; only the code and the outcome sentence change, and the
accept-set CONTROL pins this. New members of the closed refusal-code set
are added under a `no` declaration, as with earlier code additions.
- **Sweep budget.** The sweep grew from 15 schemas to 16. Measured
locally (4 vCPU, file alone): 192 to 225 ms with the new schema, 186 to
267 ms for the base 15 in the same session. The 16th schema stands down
on every source but a date field's value, so the 16000 ms budget stands,
and the docblock records the reading.
- Seen, not fixed here: `registerFlow`'s multi-refusal header always
explains template braces ("Predicates … must not wrap references in
`{…}` template braces …"), whatever the listed refusal is. A date-text
verdict is listed under that header too. Reported to the seat as a
finding.
## 席位核对
- Read first: `packages/formula/src/validate.ts` (`dateArmFault`, the
`value-run-may-fail` branch; `flowValueEnvelopeDateTextIssue`), then
`packages/formula/src/expression-refusal.ts` (the two new ledger rows).
- Two-minute check: `pnpm --filter @objectstack/formula exec vitest run
src/validate-date-text-arithmetic.test.ts
src/expression-refusal-codes.test.ts`. Expect 141 tests passed,
including the `(#34660)` describe.
## Verification
<details><summary>Red leg (tests committed alone at 240b77b, source
at base)</summary>
```text
× refuses the measured expression under the value-run-may-fail arm, with the addDays shift
× refuses the bare call, a previous.FIELD read, and date-text arithmetic over record.FIELD
× an assignment value: the value arm's code and sentence, at the same grade, with the fix hint kept
× an update_record fields.* value: the value arm's code and sentence, at the same grade, with the fix hint kept
× has a pin for every code, and no pin for a code outside the set
AssertionError: expected [ 'date-text-call-run-may-fail' ] to deeply equal [ 'date-text-call-value-run-may-fail' ]
Test Files 2 failed (2) · Tests 5 failed | 134 passed (139)
os-verify-lock: VERDICT command-exit 1
```
</details>
<details><summary>Green leg and package suites (head
2cd098b)</summary>
```text
vitest run src/validate-date-text-arithmetic.test.ts src/expression-refusal-codes.test.ts
Test Files 2 passed (2) · Tests 141 passed (141) · VERDICT command-exit 0
pnpm --filter @objectstack/formula test
Test Files 68 passed (68) · Tests 1888 passed (1888) · VERDICT command-exit 0
pnpm --filter @objectstack/formula typecheck
check:test-typecheck: OK · VERDICT command-exit 0
service-automation src/builtin/assignment-value-envelope.test.ts: Tests 76 passed (76)
lint src/validate-expressions.test.ts: Tests 515 passed (515) · VERDICT command-exit 0
```
</details>
<details><summary>Both doors, measured on the built packages (one-shot,
not committed)</summary>
```text
== assignment `timestamp(record.borrow_date)`
lint: error flows[0].nodes[1].config.assignments.due
lint clause: this faults wherever `record.borrow_date` holds that text when the value is computed, and a flow value that cannot be computed fails the run: the flow stops at this step and the work the flow exists to do is not done (it does not read null).
registerFlow clause: (identical)
== update_record `record.due_date - record.borrow_date`
lint: error flows[0].nodes[1].config.fields.due_date
registerFlow clause: (identical to lint)
```
</details>
<details><summary>Derived gates (head 2cd098b)</summary>
```text
dispatch-gates --commands --repo objectstack-ai/objectstack: 65 commands derived (5 changed paths vs merge base 81c0947)
64 exit 0; 1 exit 3 PREREQUISITE NOT MET: pnpm check:dual-build-cjs-loads (workspace dist not built), NOT MEASURED locally, CI Lint & Repo Gates runs it
--ran: 65 derived famil(ies) accounted for — 64 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3), 0 UNRUN
pnpm check:nul-bytes: exit 0 (in the derived set)
overlap-check --branch=claude/issue-34660-value-envelope-refusal-wording: origin/main merges cleanly, 0 PR heads share a file, VERDICT clean exit 0
test:repo (vitest repo project): not run locally, CI Test Core runs it
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CZiaBg6rk7dpy1s9Me)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(formula): a flow value envelope's date-text refusal says the run fails when the value is computed, not when a condition runs
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
A flow value envelope (an `assignment` value, or a `create_record` / `update_record``fields.*` value) that hands a `date` field's text to a call it cannot take (`timestamp(record.borrow_date)`) or does arithmetic on it (`record.due_date - record.borrow_date`) is refused by `os validate` and by `registerFlow`. The refusal reused the flow-condition sentence: "this faults wherever `record.borrow_date` holds that text when the condition runs, and a flow condition that cannot be evaluated fails the run: the flow stops at this condition …". A value slot has no condition. It now reads "… when the value is computed, and a flow value that cannot be computed fails the run: the flow stops at this step and the work the flow exists to do is not done (it does not read null)."
11
+
12
+
-**Two codes join `ExpressionRefusalCode`** (`EXPRESSION_REFUSAL_CODES`), with the params of the code each splits from: `date-text-call-value-run-may-fail` (params of `date-text-call`) and `date-text-arithmetic-value-run-may-fail` (params of `date-text-arithmetic`). `validateExpression` serves them where `ExprSchemaHint.flowValueEnvelope` is set, in place of `date-text-call-run-may-fail` / `date-text-arithmetic-run-may-fail`. A consumer keyed to the old codes on a value envelope re-keys to the new ones.
13
+
-**Unchanged:** the same sources are refused, at the same grade (an error), at the same location, with the same leading value-envelope sentence and the same fix hint. A flow condition keeps `date-text-call-run-may-fail` / `date-text-arithmetic-run-may-fail` and `-run-fails`, byte for byte.
0 commit comments