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:
Tam Nhu Tran
2026-02-12 00:42:54 +07:00
parent a7495cdd4f
commit 7d049d8f1e
4 changed files with 12 additions and 10 deletions
+3 -2
View File
@@ -273,7 +273,8 @@ export function enforceProviderIsolation(provider: CLIProxyProvider): number {
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();
freshData.sessions = freshData.sessions.filter((s) => s.initiator !== provider);
freshData.sessions.push({
@@ -457,7 +458,7 @@ export async function handleQuotaExhaustion(
writeQuotaExhausted(accountId, alternative.id, cooldownMinutes);
return {
switchedTo: alternative.id,
reason: `Quota exhausted, switched to ${alternative.id}`,
reason: `Quota exhausted, switched to ${maskEmail(alternative.id)}`,
};
}
+1
View File
@@ -521,6 +521,7 @@ export async function execClaudeWithCLIProxy(
// No enforcement — still warn about duplicates for awareness
warnCrossProviderDuplicates(provider);
} else {
// 'exit' handlers must be synchronous — restoreAutoPausedAccounts uses sync fs APIs
process.on('exit', () => {
restoreAutoPausedAccounts(provider);
});
@@ -173,7 +173,7 @@ describe('Quota Exhaustion Handlers', () => {
normal_interval_seconds: 300,
critical_interval_seconds: 60,
warn_threshold: 20,
exhaustion_threshold: 0,
exhaustion_threshold: 5,
cooldown_minutes: 10,
},
});
@@ -214,7 +214,7 @@ describe('Quota Exhaustion Handlers', () => {
normal_interval_seconds: 300,
critical_interval_seconds: 60,
warn_threshold: 20,
exhaustion_threshold: 0,
exhaustion_threshold: 5,
cooldown_minutes: 10,
},
});
@@ -252,7 +252,7 @@ describe('Quota Exhaustion Handlers', () => {
normal_interval_seconds: 300,
critical_interval_seconds: 60,
warn_threshold: 20,
exhaustion_threshold: 0,
exhaustion_threshold: 5,
cooldown_minutes: 10,
},
});
@@ -299,7 +299,7 @@ describe('Quota Exhaustion Handlers', () => {
normal_interval_seconds: 300,
critical_interval_seconds: 60,
warn_threshold: 20,
exhaustion_threshold: 0,
exhaustion_threshold: 5,
cooldown_minutes: 5,
},
});
@@ -59,7 +59,7 @@ describe('Runtime Quota Monitor', () => {
normal_interval_seconds: 300,
critical_interval_seconds: 60,
warn_threshold: 20,
exhaustion_threshold: 0,
exhaustion_threshold: 5,
cooldown_minutes: 5,
},
},
@@ -92,7 +92,7 @@ describe('Runtime Quota Monitor', () => {
normal_interval_seconds: 300,
critical_interval_seconds: 60,
warn_threshold: 20,
exhaustion_threshold: 0,
exhaustion_threshold: 5,
cooldown_minutes: 5,
},
},
@@ -118,7 +118,7 @@ describe('Runtime Quota Monitor', () => {
normal_interval_seconds: 300,
critical_interval_seconds: 60,
warn_threshold: 20,
exhaustion_threshold: 0,
exhaustion_threshold: 5,
cooldown_minutes: 5,
},
},
@@ -161,7 +161,7 @@ describe('Runtime Quota Monitor', () => {
normal_interval_seconds: 300,
critical_interval_seconds: 60,
warn_threshold: 20,
exhaustion_threshold: 0,
exhaustion_threshold: 5,
cooldown_minutes: 5,
},
},