Skip to content

Commit a443c23

Browse files
fix: evict token cache in budgetPause, rebuild, and crash paths
Addresses review feedback: evictCreatureTokenCache was only called in stop() but not in budgetPause, rebuild, or failure paths where the creature exits. This ensures the token cache is cleaned up on all exit paths.
1 parent da945ba commit a443c23

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/host/supervisor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export class CreatureSupervisor {
9898
this.status = 'sleeping';
9999
this.sleepReason = 'budget';
100100
this.creature = null;
101+
evictCreatureTokenCache(this.name);
101102
}
102103

103104
async restart(): Promise<void> {
@@ -153,6 +154,7 @@ export class CreatureSupervisor {
153154
this.healthyAt = null;
154155
this.destroyContainer();
155156
this.creature = null;
157+
evictCreatureTokenCache(this.name);
156158
this.currentSHA = getCurrentSHA(this.dir);
157159
this.status = 'starting';
158160
await this.spawnCreature();
@@ -448,6 +450,7 @@ export class CreatureSupervisor {
448450
if (!this.isDockerAvailable()) {
449451
console.log(`[${this.name}] Docker unavailable, stopping (not rolling back)`);
450452
this.status = 'stopped';
453+
evictCreatureTokenCache(this.name);
451454
this.creature = null;
452455
await this.emit({ t: new Date().toISOString(), type: 'host.infra_failure', reason: 'Docker unavailable' });
453456
return;
@@ -493,6 +496,7 @@ export class CreatureSupervisor {
493496
if (this.consecutiveFailures > MAX_CONSECUTIVE_FAILURES) {
494497
console.log(`[${this.name}] ${this.consecutiveFailures} consecutive failures, giving up`);
495498
this.status = 'stopped';
499+
evictCreatureTokenCache(this.name);
496500
this.creature = null;
497501
return;
498502
}

0 commit comments

Comments
 (0)