Repository navigation
Commit d33183a
fix(lint)!: the publish gate refuses a subflow or map step that calls a flow the deployment does not hold (#38594)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Jianguo** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbJg9RAhiuDxvothojbXXC9Z)_
Fixes #35143
Supersedes #38241 (closed, 7256687325)
Clause-②: yes (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #38259 — skills/objectstack-automation/SKILL.md
(the `subflow` row says `os validate` warns `flow-subflow-unknown`; it
does not say the publish refuses a call to a flow nothing in the
deployment holds),
skills/objectstack-automation/evals/flows-triggers-approvals.json (the
eval that names `flow-subflow-unknown`)
## 维护者速读
- 用户能看到什么变化:搭建者(包括
AI)发布一个流程时,如果其中“调用子流程”或“逐项调用流程”的步骤写了一个整个环境里都不存在的流程名,发布现在会直接被拒并说明原因;以前能发布成功,但每次运行到这一步都会失败。命令行校验仍然只给警告。
- 为什么做:属于“开源框架先拦住云端构建检查才拦得住的问题”这一族收尾(流程族最后两条),替写流程的搭建者挡住“发布成功、运行必失败”。
-
出错会怎样:这是一次收紧——以前能发布的这类流程下次发布会被拒;被调用的流程只要以草稿形式存在、或在同一批次发布、或在同一个软件包安装里(顺序不限)、或由已安装的软件包提供,都不会被拒;用另一个命名空间安装的软件包副本若有流程调用同包流程,安装会被整体拒绝并回滚(改名没有改到调用处,以前装得上但这一步必失败);撤回本改动即恢复原样。
- 要你做什么:无
## What changes
The card's last two open lines, re-verified on `main` (1208460) first.
**F1, option label in decision-node and edge conditions: already covered
on `main`, no change here.** `flow-condition-option-label` reads every
edge condition and every `decision` node's `conditions[].expression`
(and query filter operands) since #37491 (`optionLabelsBeyondStart` in
`validate-flow-trigger-readiness.ts`, at `error`, same id, runtime gate
and CLI). Its positive and negative pins are in
`flow-publish-checks-second-batch.test.ts`, describe "past the start
condition". The card gets a line saying so.
**F6, a `subflow` / `map` step calling a flow that does not exist: now
refused at the publish gate.** It was a CLI-only warning because the
gate's per-write snapshot holds just the written flow. The gate now
judges the call against the names of every flow the deployment holds,
which the host states on a flow publish:
- every installed package's flows (the registry, read with
`includeDisabledPackages`, so a disabled package's are included);
- the stored flow rows of **every state**, drafts included, so two new
flows that call each other can still be published one at a time;
- the flows the same publish batch carries (`pending.flows`), so a
package that ships a flow with its caller publishes;
- the flows the same unmanaged package install writes
(`copyPlanFlowNames`, new in this head), so a package whose flow calls a
sibling it declares later installs;
- every flow the automation engine holds (`listFlows`), so a flow
registered straight into the engine with no metadata row resolves.
A call that names none of them, and is not the written flow itself, is
an `error` (`flow-subflow-unknown`): `execute` answers `Flow 'X' not
found` on every run.
Severity per door:
- **CLI** (`os validate` / `lint` / `compile` / `build`): `warning`,
unchanged. The stack is one app, and another installed package may ship
the called flow.
- **Runtime publish gate, names stated and non-empty**: `error`. The set
is the whole deployment, so "held nowhere" is decided, the #24668
reading of a whole collection.
- **Runtime publish gate, no names or an empty set**: no verdict. That
covers no automation service, a failed store read or a failed
`listFlows` (each logged once at `warn`) and an empty set. A missing
`sys_metadata` table is no stored flow: the other sources still decide.
An empty set with no closure is no universe (#24668).
- **Package closure**: the set is never narrowed to the written
package's closure. So a call the engine's package-scoped resolution
would refuse (ADR-0150 D3, `outside-closure`) is not judged here. This
rule never refuses a call the engine would accept.
Wiring:
- `@objectstack/lint`: `validateFlowSubflowTargets(stack, {
deploymentFlowNames })`, the `AuthoringRuleContext.deploymentFlowNames`
input, and `runRuntimeAuthoringRules({ deploymentFlowNames })`. The
rule's registry entry moves to `tier: 'gating'`, `surfaces:
CLI_AND_RUNTIME`, `runtimeTypes: ['flow']`. Its runtime pass judges
nothing without stated names. The rule's explanation text is updated.
- `@objectstack/metadata-protocol`: `evaluateRuntimeAuthoringGate({
deploymentFlowNames })` adds the batch's flow drafts.
`judgeRuntimeAuthoringRules` reads the names only on a flow write whose
body calls another flow (`flowCallsAnotherFlow` in
`runtime-authoring-gate.ts`; `deploymentFlowNamesOf`,
`automationFlowNames`, `registeredFlowsWithDisabled` in
`protocol-authoring-gate.ts`), through the host's existing
`servicesRegistry`; the registry is listed with its disabled packages,
since the served listing drops their items. The stored names are one
`sys_metadata` read, `type` `$in` both spellings, projected to `fields:
['name']`. `saveMetaItem` takes a server-only `copyPlanFlowNames`
(`protocol-door-requests.ts`), which `importUnmanagedPackage` states on
each flow write and the save door hands the gate as `pending.flows`.
`protocol.ts` moves no line: one docblock (the `pending` field) is
reworded in place.
- `@objectstack/spec`: the ADR-0087 entry
`publish-refuses-flows-that-save-and-do-not-run` now counts eight errors
at the publish gate, seven of them also on the CLI: its `surface` names
the `subflow` / `map` refusal, the warnings sentence says which door
each warning is silent at, the acceptance line is no longer seven, and
the reason says what holds for a package install.
No rule is added, so no "author-time rules (N)" count moves.
## Rework on contract review 7238045522 (FAIL at `bc21970eab`)
This PR continues #38241 (seat 6's branch
`claude/issue-35143-flows-leftovers`, whose dev ran out of budget). It
starts at that head, merges `main`, and closes every open item of the
review:
- **M1** (an unmanaged install refused a package whose flow calls a
sibling declared after it): `importUnmanagedPackage` states its plan's
flow names on each flow write (`copyPlanFlowNames`), which reach the
gate as `pending.flows`, the batch's channel. Pinned in
`package-unmanaged-install.test.ts`, describe "a flow calling a sibling
flow of the same package": a package declaring `crm_parent` (calls
`crm_child`) before `crm_child`, on a protocol whose automation service
holds another flow, installs both; the control (a call to a flow nothing
holds) is still refused 422 and leaves no row and no base.
`duplicatePackage` is unchanged: it copies stored rows, which the gate's
stored read already holds (the review's own reading).
- **S1** (every flow body read for names, on every flow publish): one
read, both type spellings, `fields: ['name']`; none at all for a flow
that calls no other flow, or only itself. Pinned on the shared harness.
- **S2** (the entry still counted seven): `surface`, `reason` and
`acceptanceCriteria` rewritten as above.
- **S3** (three no-verdict exits unpinned): one pin each through
`saveMetaItem` on the shared harness: a store read that throws
(accepted, one `warn`), a `listFlows` that throws (accepted, one
`warn`), and a missing `sys_metadata` table (no `warn`; a call to an
engine or registry flow is accepted and a call to nothing is still
refused).
- **N1**: the `sealedFlowNodeTypeVocabulary` docblock is back above its
function. N2–N5 are left as the review graded them (no effect on
correctness); see the acceptance notes.
## Patch round on contract review 7257069704 (PASS, S4 open at
`a7c00fdd85`)
- **S4** (the texts said a disabled package's flows count; the gate read
the served registry listing, which drops them): the first closing
condition. The names read lists the registry with
`includeDisabledPackages: true` (`registeredFlowsWithDisabled`), so a
call to a disabled package's flow is let through, as a draft is: the
flow is held, and runs once its package is enabled. The docblock, the
changeset and this body now say what the code does. Pinned through
`saveMetaItem`; removing the option fails the pin.
- **N6, N7, N8** in the same commit: the entry's `reason` gives the
right cause (the install states its flow names) and says the rename
covers prefixed names only; the `pending` docblocks, the lint docblocks
and the `os explain` text name a package install's flows and a disabled
package's; the changeset's Exports bullet names `saveMetaItem`'s
`copyPlanFlowNames` and no longer names `evaluateRuntimeAuthoringGate`.
N9 and N10 stand as accepted.
## Why
#35143 "Done when": each line is a rule with its pins, or a line on the
card saying which rule covers it. F1 is the second case and F6 is now
the first. The hosted copy of the subflow check can be deleted.
## Tests
<details><summary>Lint: new pins in
flow-publish-checks-second-batch.test.ts (describe
flow-subflow-unknown)</summary>
- CLI: still exactly one `warning`.
- Runtime gate refuses a call to a name the stated set lacks: `error`,
path `flows[0].nodes[1].config.flowName`, message opening, `rulesRun`
names the rule.
- A `map` call inside a loop body: `error` at
`flows[0].nodes[1].config.body.nodes[0].config.flowName`.
- Silent: a name the stated set holds, the written flow calling itself.
- No verdict: no stated names, an empty set.
</details>
<details><summary>Metadata-protocol: the describe in
protocol.runtime-authoring-gate.test.ts (the shared harness), end to end
through saveMetaItem</summary>
- 422 `INVALID_METADATA`, issue `flow-subflow-unknown` at the path,
nothing stored.
- Accepted: a flow only the automation engine holds, an installed
package's flow (registry), a stored draft, a stored active flow.
- No automation service: accepted (no verdict).
- New (S4): a flow only a DISABLED package ships (listed by the registry
only with `includeDisabledPackages`) resolves; a call to nothing in the
same case is still a 422.
- New (S1): the stored names are read once, `{ where: { type: { $in:
['flow', 'flows'] } }, fields: ['name'] }`; a flow calling only itself,
and a flow with no call, read nothing.
- New (S3): a store read that throws, accepted with one `warn` naming
the cause; a `listFlows` that throws, the same; a missing `sys_metadata`
table, no `warn`, engine and registry flows still resolve and a call to
nothing is still a 422.
- `evaluateRuntimeAuthoringGate`: a flow in `pending.flows` resolves;
without it the call is refused.
</details>
<details><summary>Metadata-protocol: new describe in
package-unmanaged-install.test.ts (M1)</summary>
- A package declaring `crm_parent` (a `subflow` step calling
`crm_child`) before `crm_child`, with an automation service holding
`other_flow`: installs, both flows stored active.
- Control: `crm_parent` calling `crm_nowhere`: refused 422 with
`flow-subflow-unknown`, no active row left, the base
`com.example.crm-copy` removed.
- Reading, not pinned: the same package installed with `targetNamespace:
'crm2'` is refused 422 (`flow 'crm2_parent' could not be written …
flows[0].nodes[1].config.flowName [flow-subflow-unknown]`) and rolled
back, because the rename does not rewrite `config.flowName`; see the
acceptance notes.
</details>
<details><summary>Ablations (each fix removed on disk from the committed
head, then restored with git checkout HEAD)</summary>
- `importUnmanagedPackage` states no `copyPlanFlowNames`: "installs a
package that declares the calling flow before the flow it calls" fails
(1 failed / 1 passed).
- The names read for every flow write (the `flowCallsAnotherFlow` guard
dropped): "reads the stored names once …" fails (1 failed / 7 passed).
- At 93f3643, the registry read without `includeDisabledPackages`:
"lets a call through to a disabled package's flow …" fails (1 failed).
</details>
<details><summary>Suites (head 93f3643, main merged at 3014176;
under os-verify-lock)</summary>
- `@objectstack/lint` test: 246 files / 9962 tests passed. typecheck
exit 0.
- `@objectstack/metadata-protocol` test: 372 passed / 9 skipped files,
23660 passed / 45 skipped tests. typecheck exit 0.
`protocol.runtime-authoring-gate.test.ts` +
`package-unmanaged-install.test.ts`: 383/383.
- `@objectstack/spec` `src/migrations`: 5 files / 209 tests.
- Dogfood battery: head 93f3643, `pnpm --filter @objectstack/dogfood
test` under the lock after a clean closure build (exit 0): VERDICT
command-exit 0, Test Files 495 passed / 3 skipped (498), Tests 4187
passed / 68 skipped (4255), no failure.
</details>
## Acceptance notes
- Not judged: whether the engine's package-scoped name resolution lets
the calling flow reach the called one (ADR-0150 D3). The set is the
whole deployment, so an `outside-closure` call still fails at run time.
Judging that would need the resolver's verdict at the door.
- A call to a stored draft, or an archived or deprecated row, is let
through. The step fails until that flow is active. This keeps two new
flows that call each other publishable one at a time.
- The stored read for names is not filtered for legacy organization
rows. An extra name can only let a call through.
- A package install under another namespace (`targetNamespace`) renames
its flows but not the `config.flowName` that calls them, so a package
whose flow calls a sibling is now refused and rolled back unless the
deployment holds the old name. On `main` it installed with a step that
fails on every run. Making the rename follow flow names is outside this
card; reported to the seat as a finding.
- A plan flow name counts even if that flow's own write then fails: the
install then rolls back whole, so no caller is left pointing at it.
- Not addressed, as graded (nits): N2 `listFlows` is read with no seal;
N3 the empty-set exit depends on the door; N4 the "did you mean"
suggestion draws on the unfiltered stored read; N5 `rulesRun` names the
rule on a write where it judged nothing.
## Verification
- Read first:
`packages/metadata-protocol/src/protocol-package-commits.ts`
`importUnmanagedPackage` (`copyPlanFlowNames`) with `protocol-save.ts`
(where it becomes `pending.flows`);
`packages/metadata-protocol/src/protocol-authoring-gate.ts`
`deploymentFlowNamesOf` (the union, the projected read, the no-verdict
exits), `packages/lint/src/authoring-rules.ts` the
`validateFlowSubflowTargets` entry (runtime pass with no names =
nothing), `packages/lint/src/validate-flow-trigger-readiness.ts`
`validateFlowSubflowTargets`.
- Two minutes: `pnpm --filter @objectstack/metadata-protocol exec vitest
run src/protocol.runtime-authoring-gate.test.ts
src/package-unmanaged-install.test.ts -t '35143|sibling flow'`. Expect
11 passed, among them a 422 naming `flow-subflow-unknown` and a package
install of a caller before its callee.
<details><summary>Gates (head 93f3643)</summary>
- `dispatch-gates --ran` at 93f3643, run after the closure build: 103
derived, 102 run (all exit 0), 1 NOT MEASURED, 0 unrun (`✓
dispatch-gates --ran: 103 derived famil(ies) accounted for`).
- `check:dual-build-cjs-loads` exit 3: needs a full workspace build.
Left to CI.
- `overlap-check` (`--exclude-pr=38241`) at a7c00fd: clean against
origin/main 3014176 and the two open PRs sharing a file (#38550,
#38497). The 93f3643 commit touches only files of this PR.
- `protocol.ts` moves no line, so `check:facade-delegation-only`'s
ceiling is untouched (exit 0 in the sweep).
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes (CI-owned run).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: only a migration entry's text, no
generated artifact moves.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QsR2jSjBfkaFUVwRa3pdUK
<!-- signed: repo:objectstack#1 · zhuangjianguo ·
session_01QsR2jSjBfkaFUVwRa3pdUK -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c1fb1fe commit d33183a
16 files changed
Lines changed: 644 additions & 43 deletions
File tree
- .changeset
- packages
- lint/src
- metadata-protocol/src
- spec/src/migrations/entries/semantic
| 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 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
525 | 538 | | |
526 | 539 | | |
527 | 540 | | |
| |||
1739 | 1752 | | |
1740 | 1753 | | |
1741 | 1754 | | |
1742 | | - | |
1743 | | - | |
1744 | | - | |
1745 | | - | |
1746 | | - | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
1747 | 1763 | | |
1748 | 1764 | | |
1749 | | - | |
| 1765 | + | |
1750 | 1766 | | |
1751 | 1767 | | |
1752 | 1768 | | |
1753 | | - | |
1754 | | - | |
1755 | | - | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
1756 | 1776 | | |
1757 | 1777 | | |
1758 | 1778 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
615 | 615 | | |
616 | 616 | | |
617 | 617 | | |
618 | | - | |
| 618 | + | |
619 | 619 | | |
620 | | - | |
621 | | - | |
622 | | - | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
623 | 671 | | |
624 | 672 | | |
625 | 673 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7185 | 7185 | | |
7186 | 7186 | | |
7187 | 7187 | | |
7188 | | - | |
7189 | | - | |
7190 | | - | |
| 7188 | + | |
| 7189 | + | |
| 7190 | + | |
| 7191 | + | |
| 7192 | + | |
7191 | 7193 | | |
7192 | 7194 | | |
7193 | 7195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1479 | 1479 | | |
1480 | 1480 | | |
1481 | 1481 | | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
1482 | 1492 | | |
1483 | 1493 | | |
1484 | 1494 | | |
| |||
1551 | 1561 | | |
1552 | 1562 | | |
1553 | 1563 | | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
1554 | 1569 | | |
1555 | 1570 | | |
1556 | 1571 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1920 | 1920 | | |
1921 | 1921 | | |
1922 | 1922 | | |
1923 | | - | |
1924 | | - | |
1925 | | - | |
1926 | | - | |
1927 | | - | |
1928 | | - | |
1929 | | - | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
1930 | 1946 | | |
1931 | 1947 | | |
1932 | 1948 | | |
1933 | | - | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
1934 | 1963 | | |
1935 | 1964 | | |
1936 | 1965 | | |
1937 | | - | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
1938 | 1970 | | |
1939 | 1971 | | |
1940 | 1972 | | |
| |||
1954 | 1986 | | |
1955 | 1987 | | |
1956 | 1988 | | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
1957 | 2006 | | |
1958 | 2007 | | |
1959 | 2008 | | |
| |||
0 commit comments