Skip to content

Commit 0f08411

Browse files
committed
fix(scenarios): spell the reach rule's two codes as catalogue-typed literals
check:dispatcher-error-vocabulary reads the code an object literal stamps only when its constant resolves to a literal, and ErrorCode.parse(...) does not. The two constants are now literals typed ErrorCode, so a code the catalogue drops fails the package's typecheck instead of drifting. Claude-Session: https://claude.ai/code/session_016WV4cyjYBCnWT8iGQXxoeH Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4ff318e commit 0f08411

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎packages/qa/scenarios/src/loader.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import { readdirSync, readFileSync } from 'node:fs';
2121
import { basename, join } from 'node:path';
2222

23-
import { ErrorCode } from '@objectstack/spec/api';
23+
import type { ErrorCode } from '@objectstack/spec/api';
2424

2525
import {
2626
GUARDRAIL_CHECKS,
@@ -146,8 +146,11 @@ type Persona = ScenarioCard['run']['personas'][number];
146146

147147
/**
148148
* The two codes a faithful build answers an operation its acting persona
149-
* cannot reach with. Parsed through the spec's catalogue (ADR-0112), so a code
150-
* the platform stops answering refuses here at load instead of drifting.
149+
* cannot reach with. Typed against the spec's catalogue (`ErrorCode`, ADR-0112),
150+
* so a code the platform stops answering fails this package's typecheck instead
151+
* of drifting. Spelled as literals because `check:dispatcher-error-vocabulary`
152+
* judges the `code` these feed into `want` below, and it reads a constant only
153+
* when the constant resolves to a literal.
151154
*
152155
* NOT_REACHABLE_ROW_CODE a by-id write on a row the caller cannot READ is
153156
* answered not-found, indistinguishable from a
@@ -156,8 +159,8 @@ type Persona = ScenarioCard['run']['personas'][number];
156159
* to a field it must not read, is refused by the
157160
* security gate before the object's validation runs.
158161
*/
159-
const NOT_REACHABLE_ROW_CODE: ErrorCode = ErrorCode.parse('RECORD_NOT_FOUND');
160-
const HIDDEN_WRITE_CODE: ErrorCode = ErrorCode.parse('PERMISSION_DENIED');
162+
const NOT_REACHABLE_ROW_CODE: ErrorCode = 'RECORD_NOT_FOUND';
163+
const HIDDEN_WRITE_CODE: ErrorCode = 'PERMISSION_DENIED';
161164

162165
function duplicates<T>(items: readonly T[], keyOf: (t: T) => string, at: IssuePath, what: string, refuse: Refuse) {
163166
const seen = new Set<string>();

0 commit comments

Comments
 (0)