fix(runtime): separate liveness health from deep life audit
This commit is contained in:
parent
22d0f3e25e
commit
306b2b1a01
7 changed files with 327 additions and 2 deletions
|
|
@ -157,7 +157,9 @@ export class PersonaSelfLoop {
|
|||
}
|
||||
|
||||
async drain() {
|
||||
if (this.draining) return {status: 'BUSY'}; const lifeLine = this.lifeLineStatus(); if (this.requireLifeLine && lifeLine.wake_allowed !== true) { this.lastDrain = {status: 'LIFE_LINE_BLOCKED', at: this.now().toISOString(), life_line_state: lifeLine.state}; return this.lastDrain; }
|
||||
if (this.draining) return {status: 'BUSY'};
|
||||
if (this.pendingJobs.size === 0) return this.lastDrain = {status:'DRAINED',at:this.now().toISOString(),processed:0,duration_ms:0};
|
||||
const lifeLine = this.lifeLineStatus(); if (this.requireLifeLine && lifeLine.wake_allowed !== true) { this.lastDrain = {status: 'LIFE_LINE_BLOCKED', at: this.now().toISOString(), life_line_state: lifeLine.state}; return this.lastDrain; }
|
||||
this.draining = true; const started = Date.now(); let processed = 0;
|
||||
try { while (processed < this.queueBatchSize && Date.now() - started < this.drainBudgetMs) { const entry = this.nextPending(); if (!entry) break; await this.process(entry.id); processed += 1; } this.lastDrain = {status: 'DRAINED', at: this.now().toISOString(), processed, duration_ms: Date.now() - started}; return this.lastDrain; }
|
||||
finally { this.draining = false; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue