From: Jérôme Benoit Date: Mon, 18 May 2026 00:54:16 +0000 (+0200) Subject: fix(sandcastle): resolve TDZ in strategies/index.ts module init X-Git-Tag: cli@v4.8.0~29 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=829c6599237170f09d37d2124202bf1aa61d0420;p=e-mobility-charging-stations-simulator.git fix(sandcastle): resolve TDZ in strategies/index.ts module init Move the file-private validation regexes `STRATEGY_KEY_PATTERN` and `CONTROL_TAG_PATTERN` (with their JSDoc verbatim) above the eager call `STRATEGY_BY_KEY = indexByKey(STRATEGY_REGISTRY)`, so they are initialized before `indexByKey` reads them at module evaluation. --- diff --git a/.sandcastle/strategies/index.ts b/.sandcastle/strategies/index.ts index 1067f3a8..debece0e 100644 --- a/.sandcastle/strategies/index.ts +++ b/.sandcastle/strategies/index.ts @@ -30,6 +30,22 @@ export const STRATEGY_REGISTRY: readonly StrategyEntry[] = [ { controlTags: ['review'], key: 'implement', strategy: implementStrategy }, ] as const +/** + * Strict kebab-case: lowercase letters/digits, hyphen-separated, must start + * with a letter. Constrains `key` because it flows verbatim into the GitHub + * label `sandcastle-` and the git branch prefix `agent/`. + */ +const STRATEGY_KEY_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/ + +/** + * XML-name-safe subset for `controlTags`: must start with a letter, followed + * by letters, digits, `_` or `-`. Looser than {@link STRATEGY_KEY_PATTERN} + * to accept agent vocabulary such as `tool_call` while still rejecting + * empty strings and angle-bracket characters that would corrupt the + * sanitizer regex. + */ +const CONTROL_TAG_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]*$/ + /** Indexed view: strategy key → entry. Throws on duplicate keys at load time. */ export const STRATEGY_BY_KEY: ReadonlyMap = indexByKey(STRATEGY_REGISTRY) @@ -51,22 +67,6 @@ export function labelOf (key: string): string { return `sandcastle-${key}` } -/** - * Strict kebab-case: lowercase letters/digits, hyphen-separated, must start - * with a letter. Constrains `key` because it flows verbatim into the GitHub - * label `sandcastle-` and the git branch prefix `agent/`. - */ -const STRATEGY_KEY_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/ - -/** - * XML-name-safe subset for `controlTags`: must start with a letter, followed - * by letters, digits, `_` or `-`. Looser than {@link STRATEGY_KEY_PATTERN} - * to accept agent vocabulary such as `tool_call` while still rejecting - * empty strings and angle-bracket characters that would corrupt the - * sanitizer regex. - */ -const CONTROL_TAG_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]*$/ - /** * Builds the strategy-key index, validating each entry and throwing on * malformed, duplicate, or prefix-overlapping keys so registry mistakes