From 829c6599237170f09d37d2124202bf1aa61d0420 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 18 May 2026 02:54:16 +0200 Subject: [PATCH] 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. --- .sandcastle/strategies/index.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 -- 2.43.0