Commit c162362
committed
compartment-trigger: make silent-skip diagnostics best-effort
The previous diagnostic instrumentation called getRawSessionMessageCount
and getProtectedTailStartOrdinal in the !hasNewRawHistory skip path.
Those helpers open OpenCode's session DB in read-only mode, which throws
in environments where the OpenCode DB is unavailable (unit tests, fresh
Pi sessions before RawMessageProvider registration, etc).
The throw propagated up through checkCompartmentTrigger to the
event-handler.ts message.updated try/catch wrapper, which caught it
and SKIPPED the subsequent updateSessionMeta call. Net effect:
session_meta writes for lastResponseTime, cacheTtl,
lastContextPercentage, observedSafeInputTokens, and cacheAlertSent
silently failed whenever the diagnostic helpers couldn't reach the
OpenCode DB.
Wrap the diagnostic data collection in its own try/catch. If the DB
helpers throw, log without the diagnostic fields and continue. Skip
behavior is unchanged.
Fixes 4 event-handler.test.ts failures introduced in 5b44bd7.1 parent 357830d commit c162362
1 file changed
Lines changed: 21 additions & 7 deletions
Lines changed: 21 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
215 | 229 | | |
216 | 230 | | |
217 | 231 | | |
| |||
0 commit comments