@@ -31,10 +31,11 @@ export function idempotencyKey(environmentId: string, key: string): string {
3131 return `wp:idem:{${ environmentId } }:${ key } ` ;
3232}
3333
34- // "#" separates the id from the index. A waitpoint id and a run id never contain "#", so
35- // the split is unambiguous. An absent index collapses onto the empty suffix, which is how
36- // the partial unique index on a null batchIndex behaves; index 0 keeps its own field,
37- // because "0" and "" are different strings.
34+ // "#" separates the id from the index. An absent index collapses onto the empty suffix,
35+ // which is how the partial unique index on a null batchIndex behaves; index 0 keeps its
36+ // own field, because "0" and "" are different strings. The split back to an id below is
37+ // taken from the LAST "#", not the first, so this stays unambiguous even if a waitpoint id
38+ // or a run id ever contains "#" itself.
3839const SEPARATOR = "#" ;
3940
4041export function edgeField ( waitpointId : string , batchIndex ?: number | null ) : string {
@@ -45,6 +46,9 @@ export function watcherField(runId: string, batchIndex?: number | null): string
4546 return `${ runId } ${ SEPARATOR } ${ batchIndex ?? "" } ` ;
4647}
4748
49+ // The last-"#" rule here is re-implemented as a Lua pattern in runClear (scripts.ts). This
50+ // function has no caller besides its own test, so that test is what pins the rule as a
51+ // specification the Lua mirrors, not just documentation of this helper.
4852export function waitpointIdFromEdgeField ( field : string ) : string | undefined {
4953 const separator = field . lastIndexOf ( SEPARATOR ) ;
5054 return separator === - 1 ? undefined : field . slice ( 0 , separator ) ;
0 commit comments