mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-05 12:16:46 +00:00
fix(cliproxy): address all review feedback (Low + informational)
- Add sync constraint comment on process.exit handler (executor) - Add TOCTOU race acceptability comment (account-safety) - Mask email in handleQuotaExhaustion reason string - Use realistic exhaustion_threshold (5) in test configs
This commit is contained in:
@@ -273,7 +273,8 @@ export function enforceProviderIsolation(provider: CLIProxyProvider): number {
|
|||||||
pauseAccount(p, accountId);
|
pauseAccount(p, accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record for crash recovery (re-read to reduce concurrent write race window)
|
// Record for crash recovery (re-read to reduce concurrent write race window).
|
||||||
|
// TOCTOU race is acceptable for a single-user CLI tool — self-heals on next launch.
|
||||||
const freshData = loadAutoPaused();
|
const freshData = loadAutoPaused();
|
||||||
freshData.sessions = freshData.sessions.filter((s) => s.initiator !== provider);
|
freshData.sessions = freshData.sessions.filter((s) => s.initiator !== provider);
|
||||||
freshData.sessions.push({
|
freshData.sessions.push({
|
||||||
@@ -457,7 +458,7 @@ export async function handleQuotaExhaustion(
|
|||||||
writeQuotaExhausted(accountId, alternative.id, cooldownMinutes);
|
writeQuotaExhausted(accountId, alternative.id, cooldownMinutes);
|
||||||
return {
|
return {
|
||||||
switchedTo: alternative.id,
|
switchedTo: alternative.id,
|
||||||
reason: `Quota exhausted, switched to ${alternative.id}`,
|
reason: `Quota exhausted, switched to ${maskEmail(alternative.id)}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -521,6 +521,7 @@ export async function execClaudeWithCLIProxy(
|
|||||||
// No enforcement — still warn about duplicates for awareness
|
// No enforcement — still warn about duplicates for awareness
|
||||||
warnCrossProviderDuplicates(provider);
|
warnCrossProviderDuplicates(provider);
|
||||||
} else {
|
} else {
|
||||||
|
// 'exit' handlers must be synchronous — restoreAutoPausedAccounts uses sync fs APIs
|
||||||
process.on('exit', () => {
|
process.on('exit', () => {
|
||||||
restoreAutoPausedAccounts(provider);
|
restoreAutoPausedAccounts(provider);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ describe('Quota Exhaustion Handlers', () => {
|
|||||||
normal_interval_seconds: 300,
|
normal_interval_seconds: 300,
|
||||||
critical_interval_seconds: 60,
|
critical_interval_seconds: 60,
|
||||||
warn_threshold: 20,
|
warn_threshold: 20,
|
||||||
exhaustion_threshold: 0,
|
exhaustion_threshold: 5,
|
||||||
cooldown_minutes: 10,
|
cooldown_minutes: 10,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -214,7 +214,7 @@ describe('Quota Exhaustion Handlers', () => {
|
|||||||
normal_interval_seconds: 300,
|
normal_interval_seconds: 300,
|
||||||
critical_interval_seconds: 60,
|
critical_interval_seconds: 60,
|
||||||
warn_threshold: 20,
|
warn_threshold: 20,
|
||||||
exhaustion_threshold: 0,
|
exhaustion_threshold: 5,
|
||||||
cooldown_minutes: 10,
|
cooldown_minutes: 10,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -252,7 +252,7 @@ describe('Quota Exhaustion Handlers', () => {
|
|||||||
normal_interval_seconds: 300,
|
normal_interval_seconds: 300,
|
||||||
critical_interval_seconds: 60,
|
critical_interval_seconds: 60,
|
||||||
warn_threshold: 20,
|
warn_threshold: 20,
|
||||||
exhaustion_threshold: 0,
|
exhaustion_threshold: 5,
|
||||||
cooldown_minutes: 10,
|
cooldown_minutes: 10,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -299,7 +299,7 @@ describe('Quota Exhaustion Handlers', () => {
|
|||||||
normal_interval_seconds: 300,
|
normal_interval_seconds: 300,
|
||||||
critical_interval_seconds: 60,
|
critical_interval_seconds: 60,
|
||||||
warn_threshold: 20,
|
warn_threshold: 20,
|
||||||
exhaustion_threshold: 0,
|
exhaustion_threshold: 5,
|
||||||
cooldown_minutes: 5,
|
cooldown_minutes: 5,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ describe('Runtime Quota Monitor', () => {
|
|||||||
normal_interval_seconds: 300,
|
normal_interval_seconds: 300,
|
||||||
critical_interval_seconds: 60,
|
critical_interval_seconds: 60,
|
||||||
warn_threshold: 20,
|
warn_threshold: 20,
|
||||||
exhaustion_threshold: 0,
|
exhaustion_threshold: 5,
|
||||||
cooldown_minutes: 5,
|
cooldown_minutes: 5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -92,7 +92,7 @@ describe('Runtime Quota Monitor', () => {
|
|||||||
normal_interval_seconds: 300,
|
normal_interval_seconds: 300,
|
||||||
critical_interval_seconds: 60,
|
critical_interval_seconds: 60,
|
||||||
warn_threshold: 20,
|
warn_threshold: 20,
|
||||||
exhaustion_threshold: 0,
|
exhaustion_threshold: 5,
|
||||||
cooldown_minutes: 5,
|
cooldown_minutes: 5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -118,7 +118,7 @@ describe('Runtime Quota Monitor', () => {
|
|||||||
normal_interval_seconds: 300,
|
normal_interval_seconds: 300,
|
||||||
critical_interval_seconds: 60,
|
critical_interval_seconds: 60,
|
||||||
warn_threshold: 20,
|
warn_threshold: 20,
|
||||||
exhaustion_threshold: 0,
|
exhaustion_threshold: 5,
|
||||||
cooldown_minutes: 5,
|
cooldown_minutes: 5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -161,7 +161,7 @@ describe('Runtime Quota Monitor', () => {
|
|||||||
normal_interval_seconds: 300,
|
normal_interval_seconds: 300,
|
||||||
critical_interval_seconds: 60,
|
critical_interval_seconds: 60,
|
||||||
warn_threshold: 20,
|
warn_threshold: 20,
|
||||||
exhaustion_threshold: 0,
|
exhaustion_threshold: 5,
|
||||||
cooldown_minutes: 5,
|
cooldown_minutes: 5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user