Files
EJClaw/test/vitest-env.ts
Codex f944f97e54 feat: usage-alignment hold (04-08 KST daily + one-off hold until a set time)
Bring back the dawn gap that keeps Claude's 5h windows on the primer
slots (08-13, 13-18, 18-23, 23-04): it was dropped by the 2026-06-08
upstream merge (1dd948a).

- usage-alignment-hold.ts: hold during 04:00-08:00 KST, or until the ISO
  time in router_state `usage_alignment_hold_until` (ignored once past,
  so only the daily gap remains). A one-off end inside the gap runs on to
  08:00.
- Claude turns during a hold pause through the existing usage-pause path
  (messages kept, room resumed at the hold end) with an alignment notice.
  The stored pause is marked alignmentOnly so it does not act as an
  account-wide usage limit.
- Due Claude scheduled tasks stay due until the hold ends (Codex and
  GitHub CI watchers are not held).
- Urgent bypass like the old gate: a human @-mention lets that room run
  until the hold ends.
- Tests stub the wall-clock hold in test/vitest-env.ts so the suite does
  not pause when run between 04 and 08 KST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 05:54:39 +09:00

24 lines
783 B
TypeScript

import { vi } from 'vitest';
const CANONICAL_DISCORD_KEYS = new Set([
'DISCORD_OWNER_BOT_TOKEN',
'DISCORD_REVIEWER_BOT_TOKEN',
'DISCORD_ARBITER_BOT_TOKEN',
]);
for (const key of Object.keys(process.env)) {
if (key.startsWith('DISCORD_') && key.endsWith('_BOT_TOKEN')) {
if (!CANONICAL_DISCORD_KEYS.has(key)) {
delete process.env[key];
}
}
}
// The usage-alignment hold depends on the wall clock (04:00-08:00 KST) and
// would pause every Claude turn in tests run during that window. Tests that
// cover the hold set it explicitly (or use vi.importActual).
vi.mock('../src/usage-alignment-hold.js', async (importOriginal) => ({
...(await importOriginal<typeof import('../src/usage-alignment-hold.js')>()),
getUsageAlignmentHold: vi.fn(() => null),
}));