chatroom-cli 1.144.4 → 1.145.1
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/index.js +90 -145
- package/dist/index.js.map +6 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48324,16 +48324,16 @@ var init_assigned_task = __esm(() => {
|
|
|
48324
48324
|
|
|
48325
48325
|
// src/daemon/domain/usecase/compute-backoff-delay.ts
|
|
48326
48326
|
function computeBackoffDelay(attempt, opts, random3 = Math.random) {
|
|
48327
|
-
const
|
|
48327
|
+
const raw = opts.baseMs * 2 ** (attempt - 1);
|
|
48328
|
+
const exp = Math.min(opts.maxMs, raw);
|
|
48328
48329
|
const jitterRatio = opts.jitter ?? 0;
|
|
48329
48330
|
if (jitterRatio <= 0)
|
|
48330
48331
|
return Math.max(0, Math.round(exp));
|
|
48331
|
-
const
|
|
48332
|
-
return Math.max(0, Math.round(exp +
|
|
48332
|
+
const offset = raw >= opts.maxMs ? -random3() : random3() * 2 - 1;
|
|
48333
|
+
return Math.min(opts.maxMs, Math.max(0, Math.round(exp + exp * jitterRatio * offset)));
|
|
48333
48334
|
}
|
|
48334
|
-
var REDELIVERY_BACKOFF_BASE_MS = 5000, REDELIVERY_BACKOFF_MAX_MS, REDELIVERY_BACKOFF_OPTIONS;
|
|
48335
|
+
var REDELIVERY_BACKOFF_BASE_MS = 5000, REDELIVERY_BACKOFF_MAX_MS = 60000, REDELIVERY_BACKOFF_OPTIONS;
|
|
48335
48336
|
var init_compute_backoff_delay = __esm(() => {
|
|
48336
|
-
REDELIVERY_BACKOFF_MAX_MS = 5 * 60000;
|
|
48337
48337
|
REDELIVERY_BACKOFF_OPTIONS = {
|
|
48338
48338
|
baseMs: REDELIVERY_BACKOFF_BASE_MS,
|
|
48339
48339
|
maxMs: REDELIVERY_BACKOFF_MAX_MS,
|
|
@@ -50011,7 +50011,6 @@ class AgentWorkManager {
|
|
|
50011
50011
|
recoveryGates = new Map;
|
|
50012
50012
|
respawnStartRetries = new Map;
|
|
50013
50013
|
respawnRestartSeq = 0;
|
|
50014
|
-
turnFailureAccountingFailures = new Map;
|
|
50015
50014
|
turnFailureReleaseTimers = new Map;
|
|
50016
50015
|
disposed = false;
|
|
50017
50016
|
constructor(deps) {
|
|
@@ -50045,7 +50044,6 @@ class AgentWorkManager {
|
|
|
50045
50044
|
recordDeliveryFailure: deps.taskService.recordDeliveryFailure,
|
|
50046
50045
|
clearDeliveryFailure: deps.taskService.clearDeliveryFailure,
|
|
50047
50046
|
recordTurnFailure: deps.taskService.recordTurnFailure,
|
|
50048
|
-
parkTurnFailure: deps.taskService.parkTurnFailure,
|
|
50049
50047
|
decideUncoveredTurnEnd: deps.taskService.decideUncoveredTurnEnd,
|
|
50050
50048
|
confirmNudgeSent: deps.taskService.confirmNudgeSent,
|
|
50051
50049
|
resetTurnTracking: deps.taskService.resetTurnTracking,
|
|
@@ -50214,28 +50212,22 @@ class AgentWorkManager {
|
|
|
50214
50212
|
}
|
|
50215
50213
|
async recoverTaskAfterTurnFailure(event, activeTask) {
|
|
50216
50214
|
const { chatroomId, role } = event;
|
|
50217
|
-
const { attempts,
|
|
50215
|
+
const { attempts, parked } = await this.deps.taskService.recordTurnFailure({
|
|
50218
50216
|
chatroomId,
|
|
50219
50217
|
role,
|
|
50220
50218
|
taskId: activeTask.taskId
|
|
50221
50219
|
});
|
|
50222
|
-
if (
|
|
50223
|
-
this.cancelTurnFailureRelease({
|
|
50224
|
-
|
|
50225
|
-
role,
|
|
50226
|
-
taskId: activeTask.taskId
|
|
50227
|
-
});
|
|
50228
|
-
return "exceeded";
|
|
50220
|
+
if (parked) {
|
|
50221
|
+
this.cancelTurnFailureRelease({ chatroomId, role, taskId: activeTask.taskId });
|
|
50222
|
+
return "parked";
|
|
50229
50223
|
}
|
|
50230
|
-
this.scheduleTurnFailureRelease({ chatroomId, role, taskId: activeTask.taskId }, attempts, event.completion.turnId
|
|
50224
|
+
this.scheduleTurnFailureRelease({ chatroomId, role, taskId: activeTask.taskId }, attempts, event.completion.turnId);
|
|
50231
50225
|
return "scheduled";
|
|
50232
50226
|
}
|
|
50233
|
-
scheduleTurnFailureRelease(key, attempt, turnId
|
|
50227
|
+
scheduleTurnFailureRelease(key, attempt, turnId) {
|
|
50234
50228
|
if (this.disposed)
|
|
50235
50229
|
return;
|
|
50236
50230
|
const keyStr = turnFailureReleaseKey(key);
|
|
50237
|
-
if (source === "turn-failure")
|
|
50238
|
-
this.turnFailureAccountingFailures.delete(keyStr);
|
|
50239
50231
|
this.cancelTurnFailureRelease(key);
|
|
50240
50232
|
const delay3 = computeBackoffDelay(attempt, REDELIVERY_BACKOFF_OPTIONS);
|
|
50241
50233
|
this.deps.taskService.markTurnFailureReleasePending(key);
|
|
@@ -50269,36 +50261,20 @@ class AgentWorkManager {
|
|
|
50269
50261
|
role: key.role,
|
|
50270
50262
|
taskId: key.taskId
|
|
50271
50263
|
});
|
|
50272
|
-
this.turnFailureAccountingFailures.delete(turnFailureReleaseKey(key));
|
|
50273
50264
|
} catch (error51) {
|
|
50274
50265
|
console.error(`[NativeDelivery:turn-failed-release-error] chatroom=${key.chatroomId} role=${key.role} task=${key.taskId} error=${error51 instanceof Error ? error51.stack ?? error51.message : String(error51)}`);
|
|
50275
50266
|
await this.retryReleaseAfterFailure(key, attempt);
|
|
50276
50267
|
}
|
|
50277
50268
|
}
|
|
50278
50269
|
async retryReleaseAfterFailure(key, previousAttempt) {
|
|
50279
|
-
const keyStr = turnFailureReleaseKey(key);
|
|
50280
50270
|
try {
|
|
50281
|
-
const { attempts,
|
|
50282
|
-
|
|
50283
|
-
if (exceeded)
|
|
50271
|
+
const { attempts, parked } = await this.deps.taskService.recordTurnFailure(key);
|
|
50272
|
+
if (parked)
|
|
50284
50273
|
return;
|
|
50285
|
-
this.scheduleTurnFailureRelease(key, attempts, "release-retry"
|
|
50274
|
+
this.scheduleTurnFailureRelease(key, attempts, "release-retry");
|
|
50286
50275
|
} catch (error51) {
|
|
50287
50276
|
console.error(`[NativeDelivery:turn-failed-release-retry-error] chatroom=${key.chatroomId} role=${key.role} task=${key.taskId} error=${error51 instanceof Error ? error51.stack ?? error51.message : String(error51)}`);
|
|
50288
|
-
|
|
50289
|
-
this.turnFailureAccountingFailures.set(keyStr, failures);
|
|
50290
|
-
if (failures >= MAX_TURN_FAILURE_ACCOUNTING_FAILURES) {
|
|
50291
|
-
this.turnFailureAccountingFailures.delete(keyStr);
|
|
50292
|
-
this.cancelTurnFailureRelease(key);
|
|
50293
|
-
console.error(`[NativeDelivery:turn-failure-accounting-stalled] chatroom=${key.chatroomId} role=${key.role} task=${key.taskId} failures=${failures}`);
|
|
50294
|
-
try {
|
|
50295
|
-
await this.deps.taskService.parkTurnFailure(key);
|
|
50296
|
-
} catch (parkError) {
|
|
50297
|
-
console.error(`[NativeDelivery:turn-failure-park-error] chatroom=${key.chatroomId} role=${key.role} task=${key.taskId} error=${parkError instanceof Error ? parkError.stack ?? parkError.message : String(parkError)}`);
|
|
50298
|
-
}
|
|
50299
|
-
return;
|
|
50300
|
-
}
|
|
50301
|
-
this.scheduleTurnFailureRelease(key, previousAttempt, "release-retry", "release-retry");
|
|
50277
|
+
this.scheduleTurnFailureRelease(key, previousAttempt, "release-retry");
|
|
50302
50278
|
}
|
|
50303
50279
|
}
|
|
50304
50280
|
cancelTurnFailureRelease(key) {
|
|
@@ -50308,7 +50284,6 @@ class AgentWorkManager {
|
|
|
50308
50284
|
return;
|
|
50309
50285
|
clearTimeout(entry.timer);
|
|
50310
50286
|
this.turnFailureReleaseTimers.delete(keyStr);
|
|
50311
|
-
this.turnFailureAccountingFailures.delete(keyStr);
|
|
50312
50287
|
this.deps.taskService.clearTurnFailureReleasePending(key);
|
|
50313
50288
|
}
|
|
50314
50289
|
cancelTurnFailureReleasesForRole(chatroomId, role) {
|
|
@@ -50318,7 +50293,6 @@ class AgentWorkManager {
|
|
|
50318
50293
|
continue;
|
|
50319
50294
|
clearTimeout(entry.timer);
|
|
50320
50295
|
this.turnFailureReleaseTimers.delete(keyStr);
|
|
50321
|
-
this.turnFailureAccountingFailures.delete(keyStr);
|
|
50322
50296
|
this.deps.taskService.clearTurnFailureReleasePending(entry.key);
|
|
50323
50297
|
}
|
|
50324
50298
|
}
|
|
@@ -50333,7 +50307,7 @@ class AgentWorkManager {
|
|
|
50333
50307
|
console.error(`[NativeDelivery:turn-failed] chatroom=${event.chatroomId} role=${event.role} task=${activeTask2?.taskId ?? "none"} turn=${completion.turnId} status=${completion.status} source=${completion.source} error=${errorDetail ?? "none"}`);
|
|
50334
50308
|
if (activeTask2) {
|
|
50335
50309
|
const recovery = await this.recoverTaskAfterTurnFailure(event, activeTask2);
|
|
50336
|
-
if (recovery === "
|
|
50310
|
+
if (recovery === "parked") {
|
|
50337
50311
|
this.deps.agentTaskState.clear({ chatroomId: event.chatroomId, role: event.role });
|
|
50338
50312
|
return { kind: "release-slot" };
|
|
50339
50313
|
}
|
|
@@ -50716,7 +50690,6 @@ class AgentWorkManager {
|
|
|
50716
50690
|
this.deps.taskService.clearTurnFailureReleasePending(entry.key);
|
|
50717
50691
|
}
|
|
50718
50692
|
this.turnFailureReleaseTimers.clear();
|
|
50719
|
-
this.turnFailureAccountingFailures.clear();
|
|
50720
50693
|
for (const pending of this.respawnStartRetries.values()) {
|
|
50721
50694
|
if (pending.timer)
|
|
50722
50695
|
clearTimeout(pending.timer);
|
|
@@ -50949,7 +50922,7 @@ class AgentWorkManager {
|
|
|
50949
50922
|
this.deps.agentTaskState.start(args2);
|
|
50950
50923
|
}
|
|
50951
50924
|
}
|
|
50952
|
-
var MAX_RESPAWN_START_ATTEMPTS = 3, MAX_UNCOVERED_NUDGE_SEND_ATTEMPTS = 3, UNCOVERED_NUDGE_RETRY_MS = 250,
|
|
50925
|
+
var MAX_RESPAWN_START_ATTEMPTS = 3, MAX_UNCOVERED_NUDGE_SEND_ATTEMPTS = 3, UNCOVERED_NUDGE_RETRY_MS = 250, RECOVERY_RETRY_BACKOFF, RESPAWN_RETRY_BASE_MS = 1000, recoveryKey = (chatroomId, role) => `${chatroomId}:${role.toLowerCase()}`, turnFailureReleaseKey = ({ chatroomId, role, taskId }) => `${chatroomId}:${role.toLowerCase()}:${taskId}`, sessionKeyFor = (pid, harnessSessionId) => `${pid}:${harnessSessionId ?? "none"}`;
|
|
50953
50926
|
var init_agent_work_manager = __esm(() => {
|
|
50954
50927
|
init_reliability();
|
|
50955
50928
|
init_agent();
|
|
@@ -54104,121 +54077,100 @@ function createTaskService(deps) {
|
|
|
54104
54077
|
let bootstrapRecoveryAttempts = 0;
|
|
54105
54078
|
let bootstrapRecoveryTimer;
|
|
54106
54079
|
let bootstrapRecoveryPromise;
|
|
54107
|
-
const
|
|
54080
|
+
const RETRY_WARNING_THRESHOLD = 3;
|
|
54108
54081
|
const turnFailureCounts = new Map;
|
|
54109
54082
|
const uncoveredLadder = new Map;
|
|
54110
54083
|
const redeliveryExhaustedKeys = new Set;
|
|
54111
|
-
const
|
|
54112
|
-
const
|
|
54084
|
+
const retryWarnings = new Map;
|
|
54085
|
+
const warningProbed = new Set;
|
|
54086
|
+
let retryWarningWrites = Promise.resolve();
|
|
54087
|
+
const enqueueRetryWarningWrite = (write) => {
|
|
54088
|
+
retryWarningWrites = retryWarningWrites.then(write);
|
|
54089
|
+
};
|
|
54113
54090
|
const pendingTurnFailureReleases = new Set;
|
|
54114
54091
|
const redeliveryKey = (chatroomId, role, taskId) => `${chatroomId}:${role.toLowerCase()}:${taskId}`;
|
|
54115
|
-
const
|
|
54116
|
-
const timer = rearmTimers.get(key);
|
|
54117
|
-
if (timer === undefined)
|
|
54118
|
-
return;
|
|
54119
|
-
clearTimeout(timer);
|
|
54120
|
-
rearmTimers.delete(key);
|
|
54121
|
-
};
|
|
54122
|
-
const resetRearmBudget = (key) => {
|
|
54123
|
-
clearRearmTimer(key);
|
|
54124
|
-
rearmCycleCounts.delete(key);
|
|
54125
|
-
};
|
|
54126
|
-
const scheduleRedeliveryRearm = (args2) => {
|
|
54127
|
-
if (inboxStopped)
|
|
54128
|
-
return;
|
|
54129
|
-
const { key } = args2;
|
|
54130
|
-
const cycles = rearmCycleCounts.get(key) ?? 0;
|
|
54131
|
-
if (cycles >= MAX_REARM_CYCLES) {
|
|
54132
|
-
console.log(`[NativeDelivery:redelivery-rearm-exhausted] chatroom=${args2.chatroomId} role=${args2.role} task=${args2.taskId} cycles=${MAX_REARM_CYCLES}`);
|
|
54133
|
-
return;
|
|
54134
|
-
}
|
|
54135
|
-
clearRearmTimer(key);
|
|
54136
|
-
const delay3 = REARM_DELAYS_MS[cycles];
|
|
54137
|
-
const timer = setTimeout(() => {
|
|
54138
|
-
rearmTimers.delete(key);
|
|
54139
|
-
runRedeliveryRearm({ ...args2, delay: delay3, cycle: cycles + 1 });
|
|
54140
|
-
}, delay3);
|
|
54141
|
-
rearmTimers.set(key, timer);
|
|
54142
|
-
};
|
|
54143
|
-
const runRedeliveryRearm = async (args2) => {
|
|
54144
|
-
const { chatroomId, role, taskId, key } = args2;
|
|
54145
|
-
const current = taskInboxState.getForRole(chatroomId, role, taskId);
|
|
54146
|
-
if (!current || current.status !== "in_progress" || !redeliveryExhaustedKeys.has(key)) {
|
|
54147
|
-
console.log(`[NativeDelivery:redelivery-rearm-skipped] reason=task_not_current chatroom=${chatroomId} role=${role} task=${taskId} status=${current?.status ?? "missing"}`);
|
|
54148
|
-
return;
|
|
54149
|
-
}
|
|
54150
|
-
rearmCycleCounts.set(key, args2.cycle);
|
|
54151
|
-
redeliveryExhaustedKeys.delete(key);
|
|
54152
|
-
turnFailureCounts.delete(key);
|
|
54092
|
+
const recordExhaustedOnBackend = async (args2) => {
|
|
54153
54093
|
try {
|
|
54154
|
-
await gateway.
|
|
54094
|
+
await gateway.recordDeliveryFailure({
|
|
54155
54095
|
sessionId: deps.sessionId,
|
|
54156
54096
|
machineId: deps.machineId,
|
|
54157
|
-
taskId
|
|
54097
|
+
taskId: args2.taskId,
|
|
54098
|
+
reason: "redelivery_exhausted"
|
|
54158
54099
|
});
|
|
54159
54100
|
} catch (error51) {
|
|
54160
|
-
console.warn(`[TaskService] redelivery-
|
|
54101
|
+
console.warn(`[TaskService] redelivery-exhausted failure record failed chatroom=${args2.chatroomId} role=${args2.role} task=${args2.taskId}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
54161
54102
|
}
|
|
54162
|
-
|
|
54103
|
+
};
|
|
54104
|
+
const recordRetryWarningOnBackend = async (taskId) => {
|
|
54163
54105
|
try {
|
|
54164
|
-
|
|
54165
|
-
|
|
54166
|
-
|
|
54167
|
-
|
|
54168
|
-
|
|
54106
|
+
await gateway.recordDeliveryFailure({
|
|
54107
|
+
sessionId: deps.sessionId,
|
|
54108
|
+
machineId: deps.machineId,
|
|
54109
|
+
taskId,
|
|
54110
|
+
reason: "delivery_retrying"
|
|
54111
|
+
});
|
|
54169
54112
|
} catch (error51) {
|
|
54170
|
-
console.
|
|
54113
|
+
console.warn(`[TaskService] retry-warning record failed task=${taskId}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
54171
54114
|
}
|
|
54172
|
-
if (!released) {
|
|
54173
|
-
redeliveryExhaustedKeys.add(key);
|
|
54174
|
-
await recordExhaustedOnBackend({ chatroomId, role, taskId });
|
|
54175
|
-
scheduleRedeliveryRearm(args2);
|
|
54176
|
-
return;
|
|
54177
|
-
}
|
|
54178
|
-
console.log(`[NativeDelivery:redelivery-rearm] cycle=${args2.cycle}/${MAX_REARM_CYCLES} chatroom=${chatroomId} role=${role} task=${taskId} delayMs=${args2.delay}`);
|
|
54179
54115
|
};
|
|
54180
|
-
const
|
|
54116
|
+
const clearRetryWarningOnBackend = async (taskId) => {
|
|
54181
54117
|
try {
|
|
54182
|
-
await gateway.
|
|
54118
|
+
await gateway.clearDeliveryFailure({
|
|
54183
54119
|
sessionId: deps.sessionId,
|
|
54184
54120
|
machineId: deps.machineId,
|
|
54185
|
-
taskId
|
|
54186
|
-
|
|
54121
|
+
taskId,
|
|
54122
|
+
expectedReason: "delivery_retrying"
|
|
54187
54123
|
});
|
|
54188
54124
|
} catch (error51) {
|
|
54189
|
-
console.warn(`[TaskService]
|
|
54125
|
+
console.warn(`[TaskService] retry-warning clear failed task=${taskId}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
54126
|
+
}
|
|
54127
|
+
};
|
|
54128
|
+
const clearRetryWarning = (key) => {
|
|
54129
|
+
const taskId = retryWarnings.get(key);
|
|
54130
|
+
if (taskId === undefined)
|
|
54131
|
+
return;
|
|
54132
|
+
retryWarnings.delete(key);
|
|
54133
|
+
enqueueRetryWarningWrite(() => clearRetryWarningOnBackend(taskId));
|
|
54134
|
+
};
|
|
54135
|
+
const clearRetryWarningAfterTurn = (key, taskId) => {
|
|
54136
|
+
if (retryWarnings.has(key)) {
|
|
54137
|
+
clearRetryWarning(key);
|
|
54138
|
+
warningProbed.add(key);
|
|
54139
|
+
return;
|
|
54190
54140
|
}
|
|
54141
|
+
if (warningProbed.has(key))
|
|
54142
|
+
return;
|
|
54143
|
+
warningProbed.add(key);
|
|
54144
|
+
enqueueRetryWarningWrite(() => clearRetryWarningOnBackend(taskId));
|
|
54191
54145
|
};
|
|
54192
|
-
const
|
|
54146
|
+
const parkUncoveredTurn = (args2) => {
|
|
54193
54147
|
const key = redeliveryKey(args2.chatroomId, args2.role, args2.taskId);
|
|
54194
54148
|
redeliveryExhaustedKeys.add(key);
|
|
54195
|
-
|
|
54196
|
-
|
|
54197
|
-
const rearmCycles = rearmCycleCounts.get(key) ?? 0;
|
|
54198
|
-
const rearmDelay = reason === "provider_failure" && rearmCycles < MAX_REARM_CYCLES ? REARM_DELAYS_MS[rearmCycles] : undefined;
|
|
54199
|
-
console.log(`[NativeDelivery:redelivery-exhausted] chatroom=${args2.chatroomId} role=${args2.role} task=${args2.taskId}${attemptsSuffix} reason=${reason} rearm=${rearmDelay ?? "none"} — release/redelivery stopped; user.start or explicit recovery resets`);
|
|
54200
|
-
if (reason === "provider_failure") {
|
|
54201
|
-
scheduleRedeliveryRearm({ ...args2, key });
|
|
54202
|
-
}
|
|
54149
|
+
enqueueRetryWarningWrite(() => recordExhaustedOnBackend(args2));
|
|
54150
|
+
console.log(`[NativeDelivery:redelivery-exhausted] chatroom=${args2.chatroomId} role=${args2.role} task=${args2.taskId} reason=uncovered_turn — redelivery stopped; user.start or explicit recovery resets`);
|
|
54203
54151
|
};
|
|
54204
54152
|
const recordTurnFailure = async (args2) => {
|
|
54205
54153
|
const key = redeliveryKey(args2.chatroomId, args2.role, args2.taskId);
|
|
54206
|
-
const recordedAttempts = turnFailureCounts.get(key) ?? 0;
|
|
54207
54154
|
if (redeliveryExhaustedKeys.has(key)) {
|
|
54208
|
-
return { attempts:
|
|
54155
|
+
return { attempts: turnFailureCounts.get(key) ?? 0, parked: true };
|
|
54209
54156
|
}
|
|
54210
|
-
const attempts =
|
|
54157
|
+
const attempts = (turnFailureCounts.get(key) ?? 0) + 1;
|
|
54211
54158
|
turnFailureCounts.set(key, attempts);
|
|
54212
|
-
if (attempts
|
|
54213
|
-
|
|
54214
|
-
|
|
54215
|
-
|
|
54159
|
+
if (attempts > RETRY_WARNING_THRESHOLD) {
|
|
54160
|
+
retryWarnings.set(key, args2.taskId);
|
|
54161
|
+
enqueueRetryWarningWrite(() => recordRetryWarningOnBackend(args2.taskId));
|
|
54162
|
+
if (attempts === RETRY_WARNING_THRESHOLD + 1) {
|
|
54163
|
+
console.warn(`[NativeDelivery:delivery-retrying] chatroom=${args2.chatroomId} role=${args2.role} task=${args2.taskId} attempts=${attempts} — still retrying, backoff capped at 60s`);
|
|
54164
|
+
}
|
|
54165
|
+
}
|
|
54166
|
+
return { attempts, parked: false };
|
|
54216
54167
|
};
|
|
54217
54168
|
const decideUncoveredTurnEnd2 = async (args2) => {
|
|
54218
54169
|
const key = redeliveryKey(args2.chatroomId, args2.role, args2.taskId);
|
|
54219
54170
|
if (redeliveryExhaustedKeys.has(key))
|
|
54220
54171
|
return { action: "park" };
|
|
54221
54172
|
turnFailureCounts.delete(key);
|
|
54173
|
+
clearRetryWarningAfterTurn(key, args2.taskId);
|
|
54222
54174
|
const entry = uncoveredLadder.get(key);
|
|
54223
54175
|
const decision = decideUncoveredTurnEnd(entry, args2.sessionKey, {
|
|
54224
54176
|
nudgeUnavailable: args2.nudgeUnavailable ?? false
|
|
@@ -54226,7 +54178,7 @@ function createTaskService(deps) {
|
|
|
54226
54178
|
if (decision.action === "restart-session") {
|
|
54227
54179
|
uncoveredLadder.set(key, withSessionRestart(entry));
|
|
54228
54180
|
} else if (decision.action === "park") {
|
|
54229
|
-
|
|
54181
|
+
parkUncoveredTurn(args2);
|
|
54230
54182
|
}
|
|
54231
54183
|
return decision;
|
|
54232
54184
|
};
|
|
@@ -54238,6 +54190,7 @@ function createTaskService(deps) {
|
|
|
54238
54190
|
const key = redeliveryKey(args2.chatroomId, args2.role, args2.taskId);
|
|
54239
54191
|
turnFailureCounts.delete(key);
|
|
54240
54192
|
uncoveredLadder.delete(key);
|
|
54193
|
+
clearRetryWarningAfterTurn(key, args2.taskId);
|
|
54241
54194
|
};
|
|
54242
54195
|
const isRedeliveryExhausted = (args2) => redeliveryExhaustedKeys.has(redeliveryKey(args2.chatroomId, args2.role, args2.taskId));
|
|
54243
54196
|
const clearRedeliveryTrackingForTask = (chatroomId, role, taskId) => {
|
|
@@ -54245,7 +54198,8 @@ function createTaskService(deps) {
|
|
|
54245
54198
|
turnFailureCounts.delete(key);
|
|
54246
54199
|
uncoveredLadder.delete(key);
|
|
54247
54200
|
redeliveryExhaustedKeys.delete(key);
|
|
54248
|
-
|
|
54201
|
+
warningProbed.delete(key);
|
|
54202
|
+
clearRetryWarning(key);
|
|
54249
54203
|
};
|
|
54250
54204
|
const forgetStaleTask = ({
|
|
54251
54205
|
chatroomId,
|
|
@@ -54286,13 +54240,9 @@ function createTaskService(deps) {
|
|
|
54286
54240
|
if (key.startsWith(prefix))
|
|
54287
54241
|
redeliveryExhaustedKeys.delete(key);
|
|
54288
54242
|
}
|
|
54289
|
-
for (const key of [...
|
|
54243
|
+
for (const key of [...retryWarnings.keys()]) {
|
|
54290
54244
|
if (key.startsWith(prefix))
|
|
54291
|
-
|
|
54292
|
-
}
|
|
54293
|
-
for (const key of [...rearmCycleCounts.keys()]) {
|
|
54294
|
-
if (key.startsWith(prefix))
|
|
54295
|
-
rearmCycleCounts.delete(key);
|
|
54245
|
+
clearRetryWarning(key);
|
|
54296
54246
|
}
|
|
54297
54247
|
};
|
|
54298
54248
|
const scheduleBootstrapRecovery = () => {
|
|
@@ -54388,6 +54338,7 @@ function createTaskService(deps) {
|
|
|
54388
54338
|
taskId: event.taskId,
|
|
54389
54339
|
expectedReason: "task_not_deliverable"
|
|
54390
54340
|
});
|
|
54341
|
+
enqueueRetryWarningWrite(() => clearRetryWarningOnBackend(event.taskId));
|
|
54391
54342
|
deliveredEventIds.add(event.eventId);
|
|
54392
54343
|
await acknowledgeEvent(event);
|
|
54393
54344
|
return;
|
|
@@ -54515,10 +54466,6 @@ function createTaskService(deps) {
|
|
|
54515
54466
|
},
|
|
54516
54467
|
stopTaskInbox: () => {
|
|
54517
54468
|
inboxStopped = true;
|
|
54518
|
-
for (const timer of rearmTimers.values())
|
|
54519
|
-
clearTimeout(timer);
|
|
54520
|
-
rearmTimers.clear();
|
|
54521
|
-
rearmCycleCounts.clear();
|
|
54522
54469
|
pendingTurnFailureReleases.clear();
|
|
54523
54470
|
if (bootstrapRecoveryTimer)
|
|
54524
54471
|
clearTimeout(bootstrapRecoveryTimer);
|
|
@@ -54611,7 +54558,7 @@ function createTaskService(deps) {
|
|
|
54611
54558
|
if (mode === "automatic") {
|
|
54612
54559
|
const tracking = { chatroomId: task.chatroomId, role: taskRole, taskId: task.taskId };
|
|
54613
54560
|
const key = redeliveryKey(task.chatroomId, taskRole, task.taskId);
|
|
54614
|
-
if (isRedeliveryExhausted(tracking) ||
|
|
54561
|
+
if (isRedeliveryExhausted(tracking) || pendingTurnFailureReleases.has(key)) {
|
|
54615
54562
|
skipped += 1;
|
|
54616
54563
|
continue;
|
|
54617
54564
|
}
|
|
@@ -54697,7 +54644,6 @@ function createTaskService(deps) {
|
|
|
54697
54644
|
...expectedReason ? { expectedReason } : {}
|
|
54698
54645
|
}),
|
|
54699
54646
|
recordTurnFailure,
|
|
54700
|
-
parkTurnFailure: (args2) => parkTask(args2, "provider_failure"),
|
|
54701
54647
|
decideUncoveredTurnEnd: decideUncoveredTurnEnd2,
|
|
54702
54648
|
confirmNudgeSent,
|
|
54703
54649
|
resetTurnTracking,
|
|
@@ -54715,7 +54661,7 @@ function createTaskService(deps) {
|
|
|
54715
54661
|
};
|
|
54716
54662
|
return service4;
|
|
54717
54663
|
}
|
|
54718
|
-
var BOOTSTRAP_RECOVERY_BACKOFF
|
|
54664
|
+
var BOOTSTRAP_RECOVERY_BACKOFF;
|
|
54719
54665
|
var init_task_service = __esm(() => {
|
|
54720
54666
|
init_chatroom_workspace_task_inbox();
|
|
54721
54667
|
init_pending_task_reconciliation_watcher();
|
|
@@ -54726,8 +54672,6 @@ var init_task_service = __esm(() => {
|
|
|
54726
54672
|
init_uncovered_turn_ladder();
|
|
54727
54673
|
init_convex_native_task_delivery_gateway();
|
|
54728
54674
|
BOOTSTRAP_RECOVERY_BACKOFF = { baseMs: 1000, maxMs: 30000, jitter: 0 };
|
|
54729
|
-
REARM_DELAYS_MS = [15 * 60000, 30 * 60000, 60 * 60000];
|
|
54730
|
-
MAX_REARM_CYCLES = REARM_DELAYS_MS.length;
|
|
54731
54675
|
});
|
|
54732
54676
|
|
|
54733
54677
|
// src/daemon/services/task-service/infrastructure/repository/task-handoff-repository.ts
|
|
@@ -76569,15 +76513,16 @@ ${getInterRoleHandoffRule()}
|
|
|
76569
76513
|
1. Recover the review target and focus from the injected task and the \`<handoff-templates>\` brief. If the target is not explicit, ask the {ENTRY_POINT_ROLE} through the handoff; do not guess a range.
|
|
76570
76514
|
2. Inspect the target: the diff or commits, the changed files, and the surrounding code they depend on. Read the actual files; do not review from summaries.
|
|
76571
76515
|
3. Look for correctness bugs, security issues, missing or weak tests, unclear ownership or error handling, dead code, duplication, and type drift. Stay within the stated focus when one is given.
|
|
76572
|
-
4.
|
|
76516
|
+
4. Assess readability and comment quality in every review, regardless of the stated focus. Check that names and structure are clear, that the code follows the language's idioms and the conventions of the neighbouring code, and that comments explain intent or the reason for a choice rather than restating the code or going stale. Report each readability or comment issue under the \`standards\` axis, cite the convention or neighbouring code it departs from, and give the exact rename, restructure, or rewritten comment as the suggested fix. Use \`minor\` for an issue that makes the code harder to follow or a comment that misleads the next reader, and \`nit\` for a style-only point. Append \`(judgement)\` when no documented standard or existing convention settles the call. Do not report a style the neighbouring code does not follow.
|
|
76517
|
+
5. Audit authentication and authorization for every backend endpoint in review scope. An endpoint is any exported Convex query, mutation, or action, HTTP route, or API handler that the target adds or changes, plus any such endpoint the changed code calls or exposes. For each endpoint, check:
|
|
76573
76518
|
- **Authentication:** the endpoint establishes the caller's identity before it reads or writes data, using the shared auth helper the sibling endpoints use. It does not trust a caller-supplied user id, role, or team id as proof of identity.
|
|
76574
76519
|
- **Authorization:** the endpoint checks that the authenticated caller may act on the specific resource the request names (for example chatroom membership, ownership, or role) before it returns data or changes state. A login check alone is not sufficient.
|
|
76575
76520
|
- **Coverage:** no code path returns or changes data before its check runs. An internal helper that skips checks may be called only from endpoints that already performed them.
|
|
76576
76521
|
- **Intent:** an endpoint without a check is acceptable only when the code or the spec states why it is public. Otherwise report it.
|
|
76577
76522
|
Report each missing or wrong check as a \`defect\` axis issue. Use severity \`blocker\` when the gap exposes or changes another user's data, and \`major\` otherwise. Cite the endpoint's file and line. List any endpoint in scope that you did not read under \`## Not reviewed\`.
|
|
76578
|
-
|
|
76579
|
-
|
|
76580
|
-
|
|
76523
|
+
6. Label every issue with a severity (\`blocker\`, \`major\`, \`minor\`, \`nit\`) and cite the file and line. Only report what you observed; mark anything unverified as such.
|
|
76524
|
+
7. Follow the injected \`<handoff-templates>\` review report exactly, in its order.
|
|
76525
|
+
8. Hand the report to \`{ENTRY_POINT_ROLE}\` with the normal command, then stop:
|
|
76581
76526
|
|
|
76582
76527
|
\`\`\`bash
|
|
76583
76528
|
chatroom handoff --chatroom-id="<chatroom-id>" --role="reviewer" --next-role="{ENTRY_POINT_ROLE}"
|
|
@@ -124322,4 +124267,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
124322
124267
|
});
|
|
124323
124268
|
program2.parse();
|
|
124324
124269
|
|
|
124325
|
-
//# debugId=
|
|
124270
|
+
//# debugId=0C3EBCBF90E5E90A64756E2164756E21
|