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 54b491a
Browse filesBrowse the repository at this point in the historyBrowse files
fix(lint)!: refuse a time-relative start whose objectName is not the object it sweeps (#30393)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgQkhZiM9XtP8WTGmWoj9hrq)_
domain:server#2 · os-bill · session_01Utp6CXGZhZVasbhiGEdpZk
Fixes#30283
Clause-②: yes (narrowing) — a new published readiness rule id,
`flow-time-relative-object-mismatch`, graded `error`: the author-time
gate (`os build`, `os validate`, the package publish and the flow
publish door) refuses a time-relative start whose `config.objectName` is
set and is not `config.timeRelative.object`, which it passed with no
readiness verdict before.
Metadata-protocol: narrowed
Skills-docs: none — `skills/**` and `content/docs/**` teach the
time-relative sweep with `timeRelative.object` alone and no `objectName`
on its start node, which this rule accepts; the MCP skill text keeps its
`sweepObject` advice for `validate_expression`, whose expression verdict
this change does not move.
## 维护者速读
- 改了什么:时间相对(定时扫描)流程的开始节点如果 `objectName` 写的对象和
`timeRelative.object`(真正被扫描的对象)不一样,发布和 `os validate` 现在直接拦下(新规则
`flow-time-relative-object-mismatch`,error),提示里写明两个对象和改法:删掉 `objectName`
或改成被扫描对象。
- 为什么改:运行时每次拿到的 `record` 只是被扫描对象的一行,`objectName` 从不被读,但条件检查却按
`objectName` 的字段来做。实测两个方向都错:只有 `objectName` 对象才有的字段写进条件,所有检查全过、每次运行都报
`No such key` 失败;反过来正确读被扫描对象的字段,却被当成未知字段拒掉。
- 风险与回滚:只收窄这一种自相矛盾的写法(BREAKING 与作者该怎么改已写进 changeset);删掉 `objectName`
不改变任何运行行为;仓里的示例、文档、技能都没有这种写法;已存的此类流程照常运行,只是下次发布会被拦;回滚即撤 PR。
- 先看:`packages/lint/src/validate-flow-trigger-readiness.ts` 的 1b-iii
判决块(只判引擎真正绑到时间相对触发器的流程);同文件 `FLOW_TIME_RELATIVE_OBJECT_MISMATCH`
的说明与严重度段;`packages/lint/src/rule-explanations.ts` 新条目。
- 两分钟验证:`pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2
src/validate-flow-trigger-readiness.test.ts -t "30283"`,预期 7 个用例通过,其中
"closes the measured hole" 在三个命令下都只报这一条 error。
- 需要你做的:无,席位落地(收窄面由席位安排 CONTRACT_REVIEW_TIER 复审)。
## What changes
- **Lint — new readiness rule `flow-time-relative-object-mismatch`**
(`validateFlowTriggerReadiness`, block 1b-iii). On a time-relative start
whose `config.objectName` is a string and is not
`config.timeRelative.object` (a string), one `error` at
`flows[i].nodes[j].config.objectName`: the verdict names both objects
("each run's record is a 'B' row, and 'A' is never bound"), the `fix:`
line says remove `objectName` or set it to the swept object. Judged only
where the engine binds the time-relative trigger:
`resolveFlowTriggerKind(flow) === 'time_relative'` and no array-form
record token (the engine's `deriveTriggerBinding` pre-check routes that
shape to the record-change trigger, which does bind `objectName`). A
`record-*` token outranks the descriptor in the resolver, so that flow
is not judged either. A descriptor whose `object` is not a string is
left to `flow-time-relative-descriptor-invalid`; a bad window beside a
string object reports both, at two keys.
- **Severity: `error`**, on the file's own criterion (is this stack
enough to know?). Both names sit on the one start node, and which one
the run binds is a hardcoded read in the engine's binding resolver
(`timeRelative.object` first), so nothing installed changes the answer.
The file header, the severity section and the `authoring-rules.ts` entry
comment say so. Not a never-fire verdict: the sweep binds and runs; the
rule is not added to the never-fire id list.
- **`os explain flow-time-relative-object-mismatch`**
(`rule-explanations.ts`): what the run binds, what the checks type
against, the measured outcome both ways, the fix, what is not reported,
and the gate reach (the runtime publish gate judges only the written
flow, so a stored flow keeps being served and its own next publish is
refused).
- **Barrel:** `FLOW_TIME_RELATIVE_OBJECT_MISMATCH` is exported from
`@objectstack/lint` (`rule-id-barrel-exports.test.ts` holds it).
- **`validate-expressions.ts` — the `config.objectName` warning** on a
sweep of another object (from #30026) keeps its explanation and now
names the readiness rule as the verdict asking for the same fix ("as
flow-time-relative-object-mismatch asks of this start"); it does not
repeat the verdict.
- **Tests** (`validate-flow-trigger-readiness.test.ts`): a
severity-table row; a `[#30283]` block with seven cases: the refusal
(rule, severity, where, path, both names, one-line message and fix of at
most 200 characters); silence on the swept object and on no
`objectName`; silence where the engine binds another trigger
(`record-after-update`, array form), paired with the shape that fires;
the descriptor-rule split and co-firing; the measured hole through every
authoring command (`validate`, `build`, `lint` answer exactly this one
error); the runtime publish gate refusing the write on the flow alone;
the `os explain` facts. `validate-expressions.test.ts`: the note names
the rule.
- **Changeset** `.changeset/30283-time-relative-object-mismatch.md`,
`minor` on `@objectstack/lint`, BREAKING with what an author does,
ADR-0087 `not-required (no-migration-prescription)`: no rewrite keeps
intent, because whether the author meant the swept object or the named
one is a judgement.
## Acceptance notes
- **Measurement that decided `error` (on `9afcd6a6`).** Objects
`crm_opportunity { amount }` and `crm_task { priority, close_date }`, a
start with `objectName: 'crm_opportunity'` sweeping `crm_task`. Author
time (lint `validateStackExpressions` + readiness): `record.amount > 10`
and `amount > 10` → no finding at all; `record.priority > 1` → `unknown
field priority on crm_opportunity` (error); the same two conditions with
no `objectName` → `unknown field amount on crm_task` and clean,
respectively. Run time (`AutomationEngine.execute` with the context
`time-relative-trigger.ts` builds: a `crm_task` row as `record`,
`object: 'crm_task'`): `record.amount > 10` → run fails `No such key:
amount`; `amount > 10` → `Unknown variable: amount`; `record.priority >
1` → run succeeds, while the engine's registration pass logs `unknown
field priority on crm_opportunity`. So the contradiction hides a
run-failing condition from every gate and refuses a correct one. The
binding itself was read from source, not run: `deriveTriggerBinding`
(`plugin-extension-api.ts`) takes `timeRelative.object` before
`objectName`, and `expandDeclaredLookups` reads the run's `object`.
- **Corpus.** `git grep` over `examples/`, `skills/`, `content/docs/`
(outside the generated references) and the MCP skill text: no
time-relative start carries an `objectName` (the showcase
`showcase_task_due_reminder` sweep names none). The dogfood battery
below is the executed check.
- **MCP `validate_expression`'s `sweepObject` advice**
(`packages/mcp/src/skill-md.ts`, `mcp-http-tools.ts`) still says a
mismatch of `sweepObject` and `objectName` makes the expression verdict
a warning. That stays true of the expression verdict; the publish gate
now also refuses the start. Outside this card's surface; noted, not
changed.
- **The engine's registration advisory pass**
(`flow-registration-checks.ts`) still types a time-relative flow's
conditions against `objectName`, logging the misleading `unknown field`
warn measured above. After this rule such a flow cannot be published, so
the warn is reachable only for a flow stored before; noted, not touched.
## Verification
All readings on head ``d3580892` (`fb38ffb0` the change, `b4c229b6`
merged with `main` at `8589756a`, `d3580892` the changeset's author
paragraph)` (this branch merged with `main` at `8589756a`) unless named.
<details><summary>Build, typecheck, tests</summary>
- Build: `pnpm --filter '@objectstack/dogfood^...' build` (lint
included), VERDICT command-exit 0; the seven packages
`check:dual-build-cjs-loads` reads that lie outside that closure,
VERDICT command-exit 0.
- `@objectstack/lint` on `d3580892`: `pnpm test` 8014/8014 (193 files);
`pnpm typecheck` 0 (with `check:test-typecheck`).
- `pnpm lint` (`eslint . --no-inline-config`) on `d3580892`: exit 0.
</details>
<details><summary>Ablations (each through scripts/ablation-replace.mjs;
restored blob == HEAD, `git diff HEAD` empty)</summary>
- A1, the verdict (lint suite imports `src`): the mismatch condition
gated off (`'ABLATE-30283' === 'on' &&`). 6 red, among them `closes the
measured hole …: validate: expected [] to deeply equal [ [
'flow-time-relative-object-mismatch',
'flows[0].nodes[0].config.objectName' ] ]` (the pre-fix answer: no error
from any rule) and the severity row `flow-time-relative-object-mismatch
is error`.
- A2, the routing guard: `resolveFlowTriggerKind(flow) ===
'time_relative' && !isArrayRecordTriggered` replaced by a constant true.
1 red: `is silent where the engine binds another trigger, which reads
objectName and never sweeps`.
</details>
<details><summary>Derived gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on `d3580892`: 57 families (the same list as
on `b4c229b6`), all 57 exit 0 (exit code captured per line before any
pipe).
- Three were red on the first pass and are recorded at their re-run:
`check-adr-0087-registration` (the changeset carried a FROM/TO rewrite
beside `no-migration-prescription`; fixed in `d3580892`, the author
paragraph is now prose), `check-plugin-teardown-shape --self-test` (its
pinned fixture commit was outside this shallow clone; that commit
fetched, 48 cases pass), `check:dual-build-cjs-loads` (PREREQUISITE NOT
MET: seven unrelated packages had no `dist/`; built, then exit 0).
- `--ran` reconciliation: "57 derived famil(ies) accounted for — 57 run,
0 NOT-MEASURED".
</details>
<details><summary>Dogfood (the narrowing arm's battery, on the final
head)</summary>
- `pnpm --filter @objectstack/dogfood test` under the lock on `b4c229b6`
(no shard, no path; `d3580892` changes only the changeset text): Test
Files 419 passed, 3 skipped (422); Tests 3492 passed, 36 skipped (3528);
VERDICT command-exit 0. No fixture or example flow carries the refused
shape.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Utp6CXGZhZVasbhiGEdpZk
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CXGZhZVasbhiGEdpZk)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(lint)!: a time-relative flow whose start node names, in `config.objectName`, another object than the one it sweeps (`config.timeRelative.object`) is refused with `flow-time-relative-object-mismatch`: each run binds a row of the swept object, while the start's `objectName` is what its conditions are checked against (#30283)
6
+
7
+
Clause-②: yes (narrowing) — a new published readiness rule id, `flow-time-relative-object-mismatch`, graded `error`: the author-time gate (`os build`, `os validate`, the package publish and the flow publish door) refuses a time-relative start whose `config.objectName` is set and is not `config.timeRelative.object`, which it passed with no readiness verdict before.
8
+
Metadata-protocol: narrowed
9
+
Skills-docs: none — `skills/**` and `content/docs/**` teach the time-relative sweep with `timeRelative.object` alone and no `objectName` on its start node, which this rule accepts; the MCP skill text keeps its `sweepObject` advice for `validate_expression`, whose expression verdict this change does not move.
10
+
11
+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped: the flow schema still admits objectName beside a timeRelative descriptor, and what narrows is the publish door's accept set for one combination of two existing keys. No rewrite keeps what the author meant: the start names two objects, and whether the author meant to sweep the swept object (drop objectName) or the named one (change timeRelative.object) is a judgement no ledger entry can derive. The other categories are closed on facts: the bumped package publishes (not unpublished); no ADR-0087 id covers this combination (flow-record-read-and-decision-type-mismatch-refused prescribes a rewrite of a condition, not of the start node) and this diff adds none (not registered, not already-registered); no published export is removed or retyped (not runtime-export-retired, runtime-interface-only or type-surface-only). -->
12
+
13
+
**BREAKING** accept-set narrowing at the author-time flow readiness gate, served by `os build`, `os validate`, `POST /api/v1/packages/:id/publish-drafts` and the flow publish door.
14
+
15
+
-**Before.** A time-relative start could name `config.objectName: 'A'` and sweep `config.timeRelative.object: 'B'`. The run binds only `B`: the engine's binding resolver reads `timeRelative.object` first, and the trigger launches each run with a `B` row as `record` and `B` as the run's object. The expression checks typed the flow's conditions against `A` all the same. Measured both ways: `record.amount > 10`, where only `A` declares `amount`, passed every check and failed every run (`No such key: amount`); `record.priority > 1`, a correct read of a `B` field, was refused as `unknown field priority on A`.
16
+
-**Now.** That start is refused at `config.objectName`, naming both objects and the fix. A start whose `objectName` equals `timeRelative.object`, or that names none, is not reported; neither is a start whose `triggerType` routes the flow to the record-change trigger (a `record-` token, or an array holding one), which binds `objectName` and never sweeps. The runtime publish gate judges only the flow being written, so a stored flow that names two objects keeps being served; its own next publish is refused.
17
+
-**The `config.objectName` warning on a sweep of another object** (served where a condition's type verdict was softened to a warning) now names `flow-time-relative-object-mismatch` as the verdict that asks for the same fix.
18
+
19
+
**What an author does.** Nothing for a time-relative start that names no `objectName`, or names the object it sweeps. A start that names two objects says which one the author meant, and nothing mechanical can: for the swept one, remove `config.objectName` (the sweep never reads it, so the run is unchanged) or set it to the value of `config.timeRelative.object`, then correct any condition the expression checks now refuse against that object; for the named one, point `config.timeRelative.object` (and its `dateField`) at it instead. The refusal names both objects.
for(constfactof['No part of the run reads','No such key','refused as an unknown field','nothing the run does changes','that trigger binds `objectName`','what is refused is its own publish']){
1915
+
expect(text,fact).toContain(fact);
1916
+
}
1917
+
});
1918
+
});
1919
+
1788
1920
describe('[#30009] api trigger readiness reads the hook\'s one verifier (config.signature)',()=>{
0 commit comments