@vibedeckx/linux-x64 0.3.14 → 0.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +49 -0
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -231310,10 +231310,59 @@ var AgentSessionManager = class {
|
|
|
231310
231310
|
await this.storage.agentSessions.updateStatusPreservingTimestamp(dbSession.id, "stopped");
|
|
231311
231311
|
restoredCount++;
|
|
231312
231312
|
}
|
|
231313
|
+
await this.repairOrphanedRunningRows(allSessions);
|
|
231313
231314
|
if (restoredCount > 0) {
|
|
231314
231315
|
console.log(`[AgentSession] Restored ${restoredCount} dormant session(s) from database`);
|
|
231315
231316
|
}
|
|
231316
231317
|
}
|
|
231318
|
+
/**
|
|
231319
|
+
* Reconcile rows the database still calls "running" against what this
|
|
231320
|
+
* process actually owns.
|
|
231321
|
+
*
|
|
231322
|
+
* `create` writes `status='running'` BEFORE the process is spawned, so any
|
|
231323
|
+
* path that dies between the INSERT and the first entry leaves a row
|
|
231324
|
+
* claiming to run forever. The restore loop above is supposed to be the
|
|
231325
|
+
* backstop, but it skips zero-entry rows before it resets crashed statuses
|
|
231326
|
+
* — so precisely the sessions that died earliest are the ones nothing ever
|
|
231327
|
+
* repairs. Measured on a real worker (2026-08-10): 63 such rows, the oldest
|
|
231328
|
+
* four months old, every one of them permanently exempt from session
|
|
231329
|
+
* retention (`status <> 'running'`) and inflating the project dashboard's
|
|
231330
|
+
* running count (46 reported, 1 real).
|
|
231331
|
+
*
|
|
231332
|
+
* Reconciliation rather than prevention, deliberately: a DB row and an OS
|
|
231333
|
+
* process are two resources with no atomic commit between them, so a kill
|
|
231334
|
+
* landing between the INSERT and the spawn leaves the same row no matter
|
|
231335
|
+
* how careful `create` becomes. Prevention narrows the window; only
|
|
231336
|
+
* reconciliation closes it. Same argument the retention plan's §3.1 makes
|
|
231337
|
+
* for snapshot reconciliation over delete events.
|
|
231338
|
+
*
|
|
231339
|
+
* The ownership test is "not in `this.sessions`", NOT `process === null`: a
|
|
231340
|
+
* session that is spawning or waking sits in the map with a null process,
|
|
231341
|
+
* and resetting it would be the same class of bug as the wake/retention
|
|
231342
|
+
* race in `deleteDormantSessionIfExpired`.
|
|
231343
|
+
*
|
|
231344
|
+
* STARTUP ONLY. `createNewSession` INSERTs the row before it puts the
|
|
231345
|
+
* session in the map, so a few milliseconds exist in which a perfectly
|
|
231346
|
+
* healthy session looks orphaned. That window is unreachable from here (no
|
|
231347
|
+
* requests are served yet); a periodic caller would first have to add an
|
|
231348
|
+
* age threshold.
|
|
231349
|
+
*
|
|
231350
|
+
* @param snapshot the row list read at the top of `restoreSessionsFromDb`.
|
|
231351
|
+
* Rows the loop already reset read as stale "running" here — the map check
|
|
231352
|
+
* is what excludes them, which is why it must come after the loop.
|
|
231353
|
+
*/
|
|
231354
|
+
async repairOrphanedRunningRows(snapshot) {
|
|
231355
|
+
let repaired = 0;
|
|
231356
|
+
for (const row of snapshot) {
|
|
231357
|
+
if (row.status !== "running") continue;
|
|
231358
|
+
if (this.sessions.has(row.id)) continue;
|
|
231359
|
+
await this.storage.agentSessions.updateStatusPreservingTimestamp(row.id, "stopped");
|
|
231360
|
+
repaired++;
|
|
231361
|
+
}
|
|
231362
|
+
if (repaired > 0) {
|
|
231363
|
+
console.log(`[AgentSession] Reset ${repaired} orphaned session row(s) left as "running"`);
|
|
231364
|
+
}
|
|
231365
|
+
}
|
|
231317
231366
|
/**
|
|
231318
231367
|
* Create a new dormant session that copies another session's conversation
|
|
231319
231368
|
* history ("branch"). The new session gets its own DB row, copied entry
|