Skip to content

Commit a0e211a

Browse files
committed
feat(lint): flow-region-shape-invalid — os lint refuses a flow region the engine refuses to register (#29049)
The ADR-0031 region check that os validate and os build ran through a CLI-only walk (flow-region-shape.ts) is now an authoring rule calling the spec's validateControlFlow, so all three commands judge it from the registry; the CLI walk is retired. Claude-Session: https://claude.ai/code/session_01ADHkmQjqkXDjc5jhjFfHt3 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3291213 commit a0e211a

16 files changed

Lines changed: 332 additions & 267 deletions

‎content/docs/deployment/cli.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ os compile --json # JSON output for CI pipelines
771771
→ Normalizing stack definition...
772772
→ Lowering inline handlers...
773773
→ Validating protocol compliance...
774-
→ Running author-time rules (60)...
774+
→ Running author-time rules (61)...
775775
→ Checking that every required capability has a provider installable in this edition...
776776
→ Collecting package docs (ADR-0046)... 0 collected
777777
→ Writing artifact...

‎content/docs/deployment/validating-metadata.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ A clean run walks the registry and reports timing:
760760
Config: /path/to/support-desk/objectstack.config.ts
761761
Load time: 21ms
762762
→ Validating against ObjectStack Protocol...
763-
→ Running author-time rules (60)...
763+
→ Running author-time rules (61)...
764764
→ Checking that every required capability has a provider installable in this edition...
765765
→ Checking package docs (ADR-0046)...
766766

‎content/docs/getting-started/build-with-claude-code.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ visible: 'status != "resolved"'
310310
◆ Validate
311311
────────────────────────────────────────
312312
→ Validating against ObjectStack Protocol...
313-
→ Running author-time rules (60)...
313+
→ Running author-time rules (61)...
314314
315315
✗ Author-time rules failed (1 issue)
316316
• stack · action 'resolve_ticket' visible: bare reference `status` — a

‎content/docs/ui/react-pages.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ objectstack validate
404404
────────────────────────────────────────
405405
→ Loading configuration...
406406
→ Validating against ObjectStack Protocol...
407-
→ Running author-time rules (60)...
407+
→ Running author-time rules (61)...
408408
→ Checking that every required capability has a provider installable in this edition...
409409
→ Checking package docs (ADR-0046)...
410410

‎packages/cli/src/commands/compile.ts‎

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ import { findOverrideDeclarationRefusals } from '../utils/override-declarations.
8383
// `os validate` step 3a-iv runs, over the save and install doors' own judge
8484
// (`judgeExtensionFieldSuffix`).
8585
import { findExtensionFieldSuffixRefusals } from '../utils/extension-field-suffix.js';
86-
// [#28893] The ADR-0031 region-shape check — the walk `os validate` step 3a-vi
87-
// runs, over the automation engine's own registration verdict.
88-
import { findFlowRegionRefusals } from '../utils/flow-region-shape.js';
8986

9087
export default class Compile extends Command {
9188
static override description = 'Compile ObjectStack configuration to JSON artifact';
@@ -840,28 +837,9 @@ export default class Compile extends Command {
840837
this.exit(1);
841838
}
842839

843-
// 3b-iii-ter. [#28893] Flow region shape (ADR-0031), at build time — the
844-
// SAME call `os validate` makes at its step 3a-vi: the engine's
845-
// registration verdict (`FlowSchema`, then the spec's
846-
// `validateControlFlow`). Before this the build emitted a flow the
847-
// engine then refused at boot, logging a warning and running without
848-
// it; now the door that ships refuses it and writes no artifact. Same
849-
// two faces as the gates above.
850-
const regionRefusals = findFlowRegionRefusals(result.data as Record<string, unknown>);
851-
if (regionRefusals.length > 0) {
852-
if (flags.json) {
853-
await emitJson({ success: false, errors: regionRefusals, warnings: warningsSoFar(), conversions: conversionNotices }, 0, { compact: true });
854-
this.exit(1);
855-
}
856-
const n = regionRefusals.length;
857-
console.log('');
858-
printError(`The automation engine would refuse to register ${n} flow${n > 1 ? 's' : ''} for a malformed region (ADR-0031)`);
859-
printBulletList(
860-
regionRefusals.map((r) => `${r.path} [${r.code}] ${r.message}`),
861-
{ noun: 'flow region refusal(s)', remedy: JSON_FULL_LIST_REMEDY },
862-
);
863-
this.exit(1);
864-
}
840+
// 3b-iii-ter. [#28893] Flow region shape (ADR-0031) is judged by the
841+
// rule table at step 3b since #29049 (`flow-region-shape-invalid`),
842+
// the same verdict `os validate` and `os lint` give.
865843

866844
// 3b-quater. ADR-0141 D2, author side — every `manifest.dependencies`
867845
// range of the packages one install act would deliver, judged by the

‎packages/cli/src/commands/validate.ts‎

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ import { findExtensionFieldSuffixRefusals } from '../utils/extension-field-suffi
8181
// [ADR-0146 D10, second rule] The field-patch target check's walk; the verdict
8282
// is the marketplace install door's own judge.
8383
import { findFieldPatchTargetRefusals } from '../utils/field-patch-targets.js';
84-
// [#28893] The ADR-0031 region-shape check: the automation engine's own
85-
// registration verdict (`FlowSchema` then the spec's `validateControlFlow`).
86-
import { findFlowRegionRefusals } from '../utils/flow-region-shape.js';
8784
// A field `picklist` that names no picklist the stack declares — refused, or
8885
// reported when the declaring package depends on packages outside the stack.
8986
// Walked the way the load path registers, like the refusal above.
@@ -754,35 +751,10 @@ export default class Validate extends Command {
754751
this.exit(1);
755752
}
756753

757-
// 3a-vi. [#28893] Flow region shape (ADR-0031): every `loop` body,
758-
// `parallel` branch and `try_catch` region, at every depth, must be
759-
// single-entry/single-exit and acyclic, and a `parallel` needs two
760-
// branches. The verdict is the engine's registration call
761-
// (`FlowSchema`, then the spec's `validateControlFlow`), so a flow
762-
// green here is one boot registers instead of logging
763-
// `[Automation] failed to register flow` and running without it; see
764-
// `utils/flow-region-shape.ts`.
765-
const regionRefusals = findFlowRegionRefusals(result.data as Record<string, unknown>);
766-
if (regionRefusals.length > 0) {
767-
if (flags.json) {
768-
await emitJson({
769-
valid: false,
770-
errors: regionRefusals,
771-
warnings: warningsSoFar(),
772-
conversions: conversionNotices,
773-
duration: timer.elapsed(),
774-
});
775-
this.exit(1);
776-
}
777-
const n = regionRefusals.length;
778-
console.log('');
779-
printError(`The automation engine would refuse to register ${n} flow${n > 1 ? 's' : ''} for a malformed region (ADR-0031)`);
780-
printBulletList(
781-
regionRefusals.map((r) => `${r.path} [${r.code}] ${r.message}`),
782-
{ noun: 'flow region refusal(s)', remedy: JSON_FULL_LIST_REMEDY },
783-
);
784-
this.exit(1);
785-
}
754+
// 3a-vi. [#28893] Flow region shape (ADR-0031) is judged by the rule
755+
// table above since #29049 (`flow-region-shape-invalid`,
756+
// `@objectstack/lint`'s `validate-flow-region-shape.ts`), so all
757+
// three authoring commands give the engine's registration verdict.
786758

787759
// 3b. [#3366] Installable-provider preflight — the shift-left of the
788760
// `serve`-time capability check. `os validate` previously only checked

‎packages/cli/src/utils/flow-region-shape.test.ts‎

Lines changed: 0 additions & 48 deletions
This file was deleted.

‎packages/cli/src/utils/flow-region-shape.ts‎

Lines changed: 0 additions & 95 deletions
This file was deleted.

‎packages/cli/test/authoring-rule-command-parity.test.ts‎

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { fileURLToPath } from 'node:url';
3232
import { AUTHORING_COMMANDS, runAuthoringRules, type AuthoringCommand } from '@objectstack/lint';
3333
import { childEnv } from './helpers/serve-process.js';
3434
import { defineStackSource, linkSpec } from './helpers/define-stack-fixture.js';
35-
import { findFlowRegionRefusals } from '../src/utils/flow-region-shape.js';
3635

3736
const cliBin = join(fileURLToPath(new URL('.', import.meta.url)), '..', 'bin', 'run-dev.js');
3837

@@ -141,39 +140,14 @@ const CASES: ReadonlyArray<{ rule: string; blindTo: readonly AuthoringCommand[];
141140
actions: [{ name: 'log_time', type: 'form', target: 'parity_task.default' }],
142141
}),
143142
},
144-
];
145-
146-
/**
147-
* Checks `os validate` and `os build` gate on OUTSIDE the rule table, so
148-
* `os lint`, which runs only the table, is blind to them. `blindTo` is the same
149-
* documentation as above; `gate` is the check the two doors call.
150-
*
151-
* The pin below measures two things on the SAME stack, in process: `gate`
152-
* refuses it with a row carrying `marker` (so the fixture really plants the
153-
* defect), and the rule registry, run as each `blindTo` command runs it,
154-
* reports no finding carrying `marker`. It measures the registry, not the
155-
* `os lint` command. Closing the gap (registering the check as an authoring
156-
* rule) reds the second half here and the case moves into `CASES`; a fixture
157-
* that stops planting the defect reds the first half (#29059) instead of
158-
* leaving the blindness assertion vacuously green.
159-
*
160-
* - flow region shape (#28893): a `try_catch` region that is not single-exit.
161-
* validate and build refuse it with the automation engine's own registration
162-
* verdict (`findFlowRegionRefusals`, `utils/flow-region-shape.ts`, pinned
163-
* end to end by `validate-flow-region-shape.test.ts`).
164-
*/
165-
const OUTSIDE_THE_TABLE: ReadonlyArray<{
166-
check: string;
167-
marker: string;
168-
blindTo: readonly AuthoringCommand[];
169-
gate: (stack: Record<string, unknown>) => ReadonlyArray<{ message: string }>;
170-
stack: Record<string, unknown>;
171-
}> = [
143+
// [#29049] Was the one row of an `OUTSIDE_THE_TABLE` table: `os validate`
144+
// and `os build` refused it through a CLI-only walk (#28893) and `os lint`,
145+
// which runs only this registry, passed it. The planted defect is a
146+
// `try_catch` catch region that is not single-exit, which the automation
147+
// engine refuses to register; the rule is that same call.
172148
{
173-
check: 'flow region shape (#28893)',
174-
marker: 'single-exit',
149+
rule: 'flow-region-shape-invalid',
175150
blindTo: ['lint'],
176-
gate: findFlowRegionRefusals,
177151
stack: withBaseline({
178152
objects: [{ name: 'parity_task', label: 'Task', sharingModel: 'private', fields: { name: { type: 'text', label: 'Name' } } }],
179153
flows: [{
@@ -222,20 +196,6 @@ describe('every authoring command reaches the same verdict (#4409)', () => {
222196
}
223197
});
224198

225-
it.each(OUTSIDE_THE_TABLE.map((c) => [c.check, c] as const))('%s: a known gap, os lint is still blind to it', (_check, testCase) => {
226-
// The fixture plants the defect: the doors' own gate refuses it with the
227-
// marker, or the blindness below would hold of a stack nothing refuses.
228-
const refused = testCase.gate(testCase.stack).filter((r) => r.message.includes(testCase.marker));
229-
expect(refused, JSON.stringify(testCase.gate(testCase.stack), null, 2)).not.toEqual([]);
230-
for (const command of testCase.blindTo) {
231-
const findings = runAuthoringRules(command, {
232-
normalized: testCase.stack,
233-
...(command === 'lint' ? {} : { parsed: testCase.stack }),
234-
});
235-
expect(findings.filter((f) => f.message.includes(testCase.marker))).toEqual([]);
236-
}
237-
});
238-
239199
it('the case table still covers every command as a blind spot', () => {
240200
// Guard the guard: if the table drifted to cover only one direction, the
241201
// suite above would keep passing while testing half the problem. The issue

‎packages/cli/test/validate-build-gate-parity.test.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,6 @@ const SHARED_NON_REGISTRY_GATES: readonly string[] = [
213213
// (#28727), so the row moved here — deleted there rather than reworded, for
214214
// the reason the `runPerPackageAuthoringRules` row above gives.
215215
'findExtensionFieldSuffixRefusals',
216-
// [#28893] Flow region shape (ADR-0031): every `loop` body, `parallel`
217-
// branch and `try_catch` region single-entry/single-exit and acyclic, and a
218-
// `parallel` with two branches, judged by the automation engine's own
219-
// registration call (`FlowSchema`, then the spec's `validateControlFlow`).
220-
// Wired into both commands in one card. Not a registry rule today, so
221-
// `os lint` is blind to it: the parity test pins that gap
222-
// (`authoring-rule-command-parity.test.ts`, `OUTSIDE_THE_TABLE`), and moving
223-
// it into `authoring-rules.ts` is the reported follow-up.
224-
'findFlowRegionRefusals',
225216
];
226217

227218
/**

0 commit comments

Comments
 (0)