Skip to content

Commit 9c02bb5

Browse files
committed
fix(scenarios): keep the reach codes' load-time catalogue parse
The ErrorCode type admits any string, so a typed literal alone would not catch a code the catalogue drops. The literals stay (the error-vocabulary gate reads them) and are parsed once at load, as before. Claude-Session: https://claude.ai/code/session_016WV4cyjYBCnWT8iGQXxoeH Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0f08411 commit 9c02bb5

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

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

Lines changed: 8 additions & 6 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 type { ErrorCode } from '@objectstack/spec/api';
23+
import { ErrorCode } from '@objectstack/spec/api';
2424

2525
import {
2626
GUARDRAIL_CHECKS,
@@ -146,11 +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. 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.
149+
* cannot reach with. Spelled as literals, because `check:dispatcher-error-vocabulary`
150+
* judges the `code` these feed into `want` below and reads a constant only when
151+
* it resolves to a literal; parsed through the spec's catalogue (`ErrorCode`,
152+
* ADR-0112) once at load, so a code the platform stops answering refuses here
153+
* instead of drifting (the `ErrorCode` type alone admits any string).
154154
*
155155
* NOT_REACHABLE_ROW_CODE a by-id write on a row the caller cannot READ is
156156
* answered not-found, indistinguishable from a
@@ -161,6 +161,8 @@ type Persona = ScenarioCard['run']['personas'][number];
161161
*/
162162
const NOT_REACHABLE_ROW_CODE: ErrorCode = 'RECORD_NOT_FOUND';
163163
const HIDDEN_WRITE_CODE: ErrorCode = 'PERMISSION_DENIED';
164+
ErrorCode.parse(NOT_REACHABLE_ROW_CODE);
165+
ErrorCode.parse(HIDDEN_WRITE_CODE);
164166

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

0 commit comments

Comments
 (0)