MCPcopy Create free account
hub / github.com/Facets-cloud/flow / fakeSessionID

Function fakeSessionID

internal/app/testhelpers_test.go:59–83  ·  view source on GitHub ↗

fakeSessionID makes a deterministic v4-shaped UUID derived from slug. Used by insertTask to satisfy the session-id invariant on non-backlog rows without entangling tests with real Claude session lifecycles. The format passes sessionUUIDRe so tests that pin --session-id-style behavior keep working.

(slug string)

Source from the content-addressed store, hash-verified

57// session lifecycles. The format passes sessionUUIDRe so tests that
58// pin --session-id-style behavior keep working.
59func fakeSessionID(slug string) string {
60 // FNV-64 hash → 16 hex chars, padded to 32 for v4 layout.
61 const fnvOff = 0xcbf29ce484222325
62 const fnvPri = 0x100000001b3
63 h := uint64(fnvOff)
64 for _, b := range []byte(slug) {
65 h ^= uint64(b)
66 h *= fnvPri
67 }
68 // Build "xxxxxxxx-xxxx-4xxx-8xxx-xxxxxxxxxxxx" from one hash + slug filler.
69 first := fmt.Sprintf("%016x", h)
70 // Use the slug bytes (zero-padded) as additional entropy for the
71 // last 12 chars so distinct slugs that hash-collide still differ.
72 pad := slug
73 for len(pad) < 12 {
74 pad += "0"
75 }
76 tailRaw := []byte(pad)[:12]
77 for i, b := range tailRaw {
78 // Force into hex range.
79 tailRaw[i] = "0123456789abcdef"[uint(b)%16]
80 }
81 tail := string(tailRaw)
82 return fmt.Sprintf("%s-%s-4%s-8%s-%s", first[:8], first[8:12], first[12:15], first[15:16]+first[0:2], tail)
83}

Callers 12

TestCmdDoneHappyPathFunction · 0.85
TestCmdDoneIdempotentFunction · 0.85
TestCmdDoDoneTaskRefusedFunction · 0.85
TestListTasksKindAllFunction · 0.85
TestCmdListRunsFunction · 0.85
TestCmdListRunsByStatusFunction · 0.85
seedRunningAutoFunction · 0.85
insertTaskFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected