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>
This commit is contained in:
@@ -41,7 +41,16 @@ import {
|
||||
stopRoomWorkIfRequested,
|
||||
type RoomStopResult,
|
||||
} from './room-stop.js';
|
||||
import { isRoomPausedForClaudeUsage } from './claude-usage-pause.js';
|
||||
import {
|
||||
isRoomPausedForClaudeUsage,
|
||||
isRoomPausedOnlyForAlignment,
|
||||
releaseRoomFromClaudeUsagePause,
|
||||
} from './claude-usage-pause.js';
|
||||
import {
|
||||
getUsageAlignmentHold,
|
||||
grantUsageAlignmentBypass,
|
||||
hasUrgentMention,
|
||||
} from './usage-alignment-hold.js';
|
||||
import { reopenReviewSkippedTaskForReview } from './review-request-gate.js';
|
||||
import { createScopedLogger, logger } from './logger.js';
|
||||
import type { GroupQueue, GroupRunContext } from './group-queue.js';
|
||||
@@ -274,6 +283,20 @@ async function processMissedMessages(
|
||||
args.failureFinalText,
|
||||
);
|
||||
|
||||
// Urgent bypass of the usage-alignment hold: an @-mention lets this room
|
||||
// run until the hold ends.
|
||||
const alignmentHold = getUsageAlignmentHold();
|
||||
if (alignmentHold && hasUrgentMention(missedMessages)) {
|
||||
grantUsageAlignmentBypass(runtime.chatJid, alignmentHold.until);
|
||||
if (isRoomPausedOnlyForAlignment(runtime.chatJid)) {
|
||||
releaseRoomFromClaudeUsagePause(runtime.chatJid);
|
||||
}
|
||||
runtime.log.info(
|
||||
{ until: alignmentHold.until.toISOString() },
|
||||
'Urgent mention; room bypasses the usage alignment hold',
|
||||
);
|
||||
}
|
||||
|
||||
// A stop request still goes through, so the user can drop paused work.
|
||||
if (
|
||||
isRoomPausedForClaudeUsage(runtime.chatJid) &&
|
||||
|
||||
Reference in New Issue
Block a user