MCPcopy Create free account
hub / github.com/Noumena-Network/code / sameSessionId

Function sameSessionId

src/bridge/workSecret.ts:62–73  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

60 * work-received check when the ccr_v2_compat_enabled gate is on.
61 */
62export function sameSessionId(a: string, b: string): boolean {
63 if (a === b) return true
64 // The body is everything after the last underscore — this handles both
65 // `{tag}_{body}` and `{tag}_staging_{body}`.
66 const aBody = a.slice(a.lastIndexOf('_') + 1)
67 const bBody = b.slice(b.lastIndexOf('_') + 1)
68 // Guard against IDs with no underscore (bare UUIDs): lastIndexOf returns -1,
69 // slice(0) returns the whole string, and we already checked a === b above.
70 // Require a minimum length to avoid accidental matches on short suffixes
71 // (e.g. single-char tag remnants from malformed IDs).
72 return aBody.length >= 4 && aBody === bBody
73}
74
75/**
76 * Build a CCR v2 session URL from the API base URL and session ID.

Callers 3

workSecret.test.tsFile · 0.85
initBridgeCoreFunction · 0.85
runBridgeLoopFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected