]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(sandcastle): resolve TDZ in strategies/index.ts module init
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 18 May 2026 00:54:16 +0000 (02:54 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 18 May 2026 00:54:16 +0000 (02:54 +0200)
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

index 1067f3a82ea1ddb5b28e402577bf86761925df9c..debece0e4361b1a04ec5de9d9cbe2239ad01ab68 100644 (file)
@@ -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-<key>` and the git branch prefix `agent/<key>`.
+ */
+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<string, StrategyEntry> = 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-<key>` and the git branch prefix `agent/<key>`.
- */
-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