1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! Session ID tag translation helpers for the CCR v2 compat layer.
//!
//! Lives in its own file (rather than workSecret.rs) so that sessionHandle and
//! replBridgeTransport can import from workSecret without pulling in these retag functions.
//!
//! The isCseShimEnabled gate is injected via set_cse_shim_gate() to avoid
//! a static import of bridgeEnabled -> growthbook -> config. Callers that
//! already import bridgeEnabled register the gate.
use OnceLock;
// =============================================================================
// CSE SHIM GATE
// =============================================================================
static CSE_SHIM_GATE: = new;
/// Register the GrowthBook gate for the cse_ shim. Called from bridge
/// init code that already imports bridgeEnabled.
// =============================================================================
// SESSION ID TRANSLATION
// =============================================================================
/// Re-tag a `cse_*` session ID to `session_*` for use with the v1 compat API.
///
/// Worker endpoints (/v1/code/sessions/{id}/worker/*) want `cse_*`; that's
/// what the work poll delivers. Client-facing compat endpoints
/// (/v1/sessions/{id}, /v1/sessions/{id}/archive, /v1/sessions/{id}/events)
/// want `session_*`. Same UUID, different costume. No-op for IDs that aren't `cse_*`.
///
/// bridgeMain holds one sessionId variable for both worker registration and
/// session-management calls. It arrives as `cse_*` from the work poll under
/// the compat gate, so archiveSession/fetchSessionTitle need this re-tag.
/// Re-tag a `session_*` session ID to `cse_*` for infrastructure-layer calls.
///
/// Inverse of to_compat_session_id. POST /v1/environments/{id}/bridge/reconnect
/// lives below the compat layer: once ccr_v2_compat_enabled is on server-side,
/// it looks sessions up by their infra tag (`cse_*`). createBridgeSession still
/// returns `session_*` and that's what bridge-pointer stores — so perpetual
/// reconnect passes the wrong costume and gets "Session not found" back.
/// Same UUID, wrong tag. No-op for IDs that aren't `session_*`.