Skip to content

Commit 300aafa

Browse files
committed
test(cli): os build --json reports the region refusal under issues; changeset; correct the two pending region changesets
Claude-Session: https://claude.ai/code/session_01ADHkmQjqkXDjc5jhjFfHt3 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 96f4483 commit 300aafa

4 files changed

Lines changed: 26 additions & 5 deletions

File tree

‎.changeset/28893-flow-region-shape-at-validate-build.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ Metadata-protocol: none
99

1010
**BREAKING** accept-set narrowing at `os validate` and `os build` (`@objectstack/cli`): a stack carrying a flow whose `loop` body, `parallel` branches or `try_catch` region is not single-entry/single-exit or is cyclic, at any depth, or whose `parallel` has fewer than two branches, now fails validation and the build instead of passing and emitting an artifact.
1111

12-
Both commands now call `findFlowRegionRefusals`, which hands each flow (each `packages[]` entry's flows, or the stack's own) to the automation engine's own registration verdict: `FlowSchema`, then the spec's `validateControlFlow`. A refused flow prints `Flow '<name>' would be refused at registration: <where>: <the engine's message>` (`VALIDATION_ERROR`, exit 1), and the build writes nothing to `dist/`. Before, both passed it, and the engine refused it at boot with an `[Automation] failed to register flow` warning while the server ran without the flow. What the engine registers is unchanged. The fix is the engine's own sentence, e.g. add one node every exit of the region leads to.
12+
Both commands now hand each flow to the automation engine's own registration verdict: `FlowSchema`, then the spec's `validateControlFlow`. A refused flow is reported by the author-time rule `flow-region-shape-invalid` as `Flow '<name>' would be refused at registration: <where>: <the engine's message>` (exit 1), and the build writes nothing to `dist/`; `os lint` reports it too. Before, both passed it, and the engine refused it at boot with an `[Automation] failed to register flow` warning while the server ran without the flow. What the engine registers is unchanged. The fix is the engine's own sentence, e.g. add one node every exit of the region leads to.
1313

1414
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export or type changes: `os validate` and `os build` now run the check `registerFlow` already runs, with the same function (`validateControlFlow` from `@objectstack/spec/automation`) and its message. Every flow they now refuse was already refused at registration and never ran, so there is nothing for `objectstack migrate meta` to rewrite and no tombstone; the remedy is the engine's own sentence (close the region with one exit node, or give the parallel a second branch). -->
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/lint': patch
3+
'@objectstack/cli': patch
4+
---
5+
6+
feat(lint): `os lint` refuses a flow whose structured region the automation engine refuses to register (`flow-region-shape-invalid`, ADR-0031)
7+
8+
Clause-②: no (narrowing)
9+
Metadata-protocol: none
10+
11+
**BREAKING** accept-set narrowing at `os lint` (`@objectstack/cli`, through the `@objectstack/lint` rule table): a stack carrying a flow whose `loop` body, `parallel` branches or `try_catch` region is not single-entry/single-exit or is cyclic, at any depth, or whose `parallel` has fewer than two branches, now fails `os lint` (exit 1) instead of passing. `os validate` and `os build` already refused it; their verdicts are unchanged.
12+
13+
- **One rule for all three commands.** The check is now the author-time rule `flow-region-shape-invalid` (`validateFlowRegionShape` and `FLOW_REGION_SHAPE_INVALID`, exported from `@objectstack/lint`). It calls the automation engine's own registration verdict, `FlowSchema` then the spec's `validateControlFlow`, and its message is the engine's refusal behind the flow's name. `os explain flow-region-shape-invalid` prints the full reasoning.
14+
- **What changes at `os validate` and `os build`.** They refuse the same flows as before, now from the rule table, so the refusal prints under `Author-time rules failed` and appears once. Under `--json` it is a rule finding (`rule`, `where`, `path`, `message`, `hint`), in `errors` for `os validate` and in `issues` for `os build`. A flow in a multi-package artifact is located at its place in the artifact's flows (`flows[N]`), with the flow's name in `where`.
15+
- **A flow the flow schema refuses** is reported by the same rule as one that could not be judged, with the schema's issues, never passed. `os validate` and `os build` refuse such a flow at the schema step already; `os lint`, which does not parse, now reports it here.
16+
- **Not judged:** a cycle in a flow's top-level graph, outside any region.
17+
18+
**The remedy.** Fix the flow the way the engine's sentence says: add one node every exit of the region leads to, remove the edge that loops back inside the region, or give the `parallel` a second branch.
19+
20+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped: `os lint` now runs the check `registerFlow`, `os validate` and `os build` already run, with the same function (`validateControlFlow` from `@objectstack/spec/automation`) and its message. Every flow it now refuses was already refused by `os validate`, `os build` and at registration, and never ran, so there is nothing for `objectstack migrate meta` to rewrite and no tombstone. -->

‎.changeset/29059-flow-region-gate-hardening.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ fix(cli): the os validate / os build flow-region check never passes a flow it co
77
Clause-②: no
88
Metadata-protocol: none
99

10-
- **No silent pass.** The flow-region check `os validate` and `os build` run (the automation engine's registration verdict, ADR-0031) parses each flow with `FlowSchema` before it judges the regions. When that parse failed it used to skip the flow with no row, so the flow passed unjudged. It now refuses it with a `VALIDATION_ERROR` row at the flow's `path`, naming the flow and the schema's issues. No authored stack reaches this branch today: the stack schema has already parsed every flow the check reads, and `FlowSchema` accepts its own output. Nothing refused or accepted today changes.
10+
- **No silent pass.** The flow-region check `os validate` and `os build` run (the automation engine's registration verdict, ADR-0031) parses each flow with `FlowSchema` before it judges the regions. When that parse failed it used to skip the flow with no row, so the flow passed unjudged. It now refuses it with a `flow-region-shape-invalid` finding at the flow's `path`, naming the flow and the schema's issues. No authored stack reaches this branch today: the stack schema has already parsed every flow the check reads, and `FlowSchema` accepts its own output. Nothing refused or accepted today changes.
1111
- **Refused flows in the boot banner.** When the automation engine refuses a declared flow at registration, boot still continues and the per-flow reason is still under Boot diagnostics. The `os serve` / `os dev` banner now also prints one line beside the declared count, for example `⚠ Flows: 2 flow(s) declared, 1 refused at registration`, read from the engine's own record (`getFlowRegistration`). It prints even when every declared flow was refused and nothing registered. A boot with nothing refused prints no such line.

‎packages/cli/test/validate-flow-region-shape.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
* (`flow-region-shape-invalid`, `@objectstack/lint`), so `os lint` gives it
2020
* too: each fixture below is run through all three commands. A refusal is now
2121
* a rule finding (`rule`, `where`, `path`, `message`, `hint`) in the rule
22-
* table's `errors`, not a separate gate's `VALIDATION_ERROR` row.
22+
* table's failure envelope (`errors` under `os validate --json`, `issues` under
23+
* `os build --json`), not a separate gate's `VALIDATION_ERROR` row.
2324
*/
2425

2526
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
@@ -196,7 +197,7 @@ describe('[#28893] validate, build and lint refuse a flow region the engine refu
196197
expect(built.code).toBe(1);
197198
const payload = json(built, `build ${label}`);
198199
expect(payload.success).toBe(false);
199-
const builtRows = (payload.errors as Array<Record<string, unknown>>).filter((r) => String(r.message).includes(refusal!));
200+
const builtRows = (payload.issues as Array<Record<string, unknown>>).filter((r) => String(r.message).includes(refusal!));
200201
expect(builtRows.map((r) => r.rule)).toEqual([RULE]);
201202
expect(existsSync(fixtures[label].dist)).toBe(false);
202203

@@ -229,7 +230,7 @@ describe('[#28893] validate, build and lint refuse a flow region the engine refu
229230
expect(built.code, built.stdout).toBe(1);
230231
const payload = json(built, 'build assembled');
231232
expect(payload.success).toBe(false);
232-
const builtRows = (payload.errors as Array<Record<string, unknown>>).filter((r) => String(r.message).includes(refusal!));
233+
const builtRows = (payload.issues as Array<Record<string, unknown>>).filter((r) => String(r.message).includes(refusal!));
233234
expect(builtRows.map(({ rule, where, path }) => ({ rule, where, path }))).toEqual([expected]);
234235
expect(existsSync(fixtures.assembled.dist)).toBe(false);
235236

0 commit comments

Comments
 (0)