Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
223 lines (205 loc) · 5.96 KB
/
Copy pathtypes.ts
File metadata and controls
223 lines (205 loc) · 5.96 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/**
* [LAYER: CORE]
* JoyRide is a bounded execution cache substrate for active task hot paths.
*/
export const JOYRIDE_CACHE_KINDS = ["hotExecution", "taskLocal", "workspaceIndex", "verification", "scratchArtifact"] as const
export type JoyRideCacheKind = (typeof JOYRIDE_CACHE_KINDS)[number]
export type JoyRideDurability = "memoryOnly" | "spillable" | "persistedDiagnostic" | "persistedReceipt"
export type JoyRideSafetyClassification = "public" | "workspace" | "taskLocal" | "sensitive" | "unsafe"
export type JoyRideInvalidationReason =
| "ttl_expired"
| "task_boundary_changed"
| "task_completed"
| "task_cancelled"
| "task_scope_changed"
| "workspace_closed"
| "workspace_drift"
| "workspace_generation_changed"
| "workspace_fingerprint_changed"
| "file_hash_changed"
| "git_head_changed"
| "dependency_fingerprint_changed"
| "lockfile_fingerprint_changed"
| "command_environment_changed"
| "approval_boundary_changed"
| "runtime_version_changed"
| "tool_version_changed"
| "config_changed"
| "security_policy_changed"
| "manual_flush"
| "manual_stale_mark"
| "validation_required"
| "validation_failed"
| "memory_pressure"
| "emergency_pressure"
| "entry_replaced"
export type JoyRideCacheScope =
| { type: "task"; id: string }
| { type: "workspace"; id: string }
| { type: "verification"; id: string }
| { type: "scratch"; id: string }
export interface JoyRideValidationFingerprint {
fingerprint?: string
workspaceFingerprint?: string
approvalBoundaryId?: string
generation?: number
dependencyFingerprint?: string
lockfileFingerprint?: string
gitHead?: string
environmentFingerprint?: string
runtimeVersion?: string
toolVersion?: string
relevantFileHashes?: Record<string, string>
}
export interface JoyRideSetMetadata extends JoyRideValidationFingerprint {
cacheKind: JoyRideCacheKind
scope: JoyRideCacheScope
ownerTaskId: string
ttlMs: number
estimatedBytes?: number
fingerprint: string
workspaceFingerprint: string
approvalBoundaryId: string
durability?: JoyRideDurability
invalidationReason: JoyRideInvalidationReason[]
cleanupHandler?: JoyRideCleanupHandler
admissionReason: string
safetyClassification: JoyRideSafetyClassification
generation: number
}
export type JoyRideCleanupHandler = (entry: JoyRideCacheEntry<unknown>) => void | Promise<void>
export interface JoyRideCacheEntry<T = unknown> {
key: string
value: T
cacheKind: JoyRideCacheKind
scope: JoyRideCacheScope
ownerTaskId: string
createdAt: number
lastAccessedAt: number
ttl: number
estimatedBytes: number
fingerprint: string
workspaceFingerprint: string
approvalBoundaryId: string
durability: JoyRideDurability
invalidationReason: JoyRideInvalidationReason[]
cleanupHandler: JoyRideCleanupHandler
admissionReason: string
staleReason?: JoyRideInvalidationReason | string
accessCount: number
generation: number
safetyClassification: JoyRideSafetyClassification
dependencyFingerprint?: string
lockfileFingerprint?: string
gitHead?: string
environmentFingerprint?: string
runtimeVersion?: string
toolVersion?: string
relevantFileHashes?: Record<string, string>
}
export interface JoyRideBudgetConfig {
maxTotalBytes: number
maxEntryBytes: number
maxPerTaskBytes: number
maxArtifactCount: number
maxArtifactBytes: number
perKindBudgetBytes: Record<JoyRideCacheKind, number>
emergencyTargetRatio: number
}
export interface JoyRideSetResult {
accepted: boolean
key: string
reason: string
entry?: JoyRideCacheEntry<unknown>
}
export interface JoyRideTrimResult {
trimmedEntries: number
freedBytes: number
reason: JoyRideInvalidationReason
}
export interface JoyRideInvalidateTarget {
scope?: JoyRideCacheScope
cacheKind?: JoyRideCacheKind
ownerTaskId?: string
workspaceFingerprint?: string
approvalBoundaryId?: string
reason?: JoyRideInvalidationReason
predicate?: (entry: JoyRideCacheEntry<unknown>) => boolean
}
export interface JoyRideEntrySummary {
key: string
cacheKind: JoyRideCacheKind
estimatedBytes: number
ownerTaskId: string
accessCount: number
ageMs: number
}
export interface JoyRideCacheStats {
hitCount: number
missCount: number
hitRate: number
missRate: number
evictionCount: number
ttlEvictionCount: number
lruEvictionCount: number
staleInvalidationCount: number
staleDiagnosticCount: number
memoryUsageEstimate: number
perCacheMemoryEstimate: Record<JoyRideCacheKind, number>
perTaskMemoryEstimate: Record<string, number>
artifactCount: number
verificationCacheReuseCount: number
pressureTrimEvents: number
emergencyTrimEvents: number
rejectedAdmissionCount: number
rejectedUnsafeEntryCount: number
rejectedOversizedEntryCount: number
lateWriteRejectionCount: number
cleanupFailureCount: number
averageEntryAgeMs: number
largestEntries: JoyRideEntrySummary[]
hottestKeys: JoyRideEntrySummary[]
staleReusePreventionCount: number
taskCleanupCount: number
scratchCleanupCount: number
spillCount: number
cacheValidationFailureCount: number
duplicateArtifactDeduplicationCount: number
entryCount: number
cacheHitAuditCount: number
lastFlushDurationMs: number
lastShutdownDurationMs: number
operationalMode: string
isHelping: boolean
}
export type JoyRideCleanupStatus = "none" | "pending" | "completed" | "failed"
export interface JoyRideExplainResult {
exists: boolean
key: string
cacheKind?: JoyRideCacheKind
ownerTaskId?: string
scope?: JoyRideCacheScope
admissionReason?: string
validity: "missing" | "valid" | "stale" | "expired"
staleReason?: JoyRideInvalidationReason | string
createdAt?: number
lastAccessedAt?: number
expiresAt?: number
ttlMs?: number
ageMs?: number
estimatedBytes?: number
canEvict?: boolean
canReuse?: boolean
reuseBlockReason?: string
diagnosticOnly?: boolean
invalidationTriggers?: JoyRideInvalidationReason[]
durability?: JoyRideDurability
safetyClassification?: JoyRideSafetyClassification
invalidationReason?: JoyRideInvalidationReason[]
workspaceFingerprint?: string
approvalBoundaryId?: string
generation?: number
fingerprint?: string
accessCount?: number
cleanupStatus?: JoyRideCleanupStatus
}