feat(#1452): add workflow.context_guard_mode to guard execute-phase against context exhaustion

Proactive checkpoint guard fires at each wave boundary before spawning agents.
Self-assesses context pressure against context-budget.md degradation tiers and
warns (warn, default) or auto-invokes /gsd:pause-work (auto) when POOR tier
(70%+) is detected. Config key validated; defaults to \"warn\".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-06-20 18:10:49 -04:00
parent 9d057882e9
commit 4eca5ac96c
9 changed files with 247 additions and 9 deletions

View File

@@ -239,6 +239,7 @@ function buildNewProjectConfig(userChoices: Record<string, unknown>): Record<str
ui_safety_gate: true,
ai_integration_phase: true,
human_verify_mode: 'end-of-phase',
context_guard_mode: 'warn',
text_mode: false,
research_before_questions: false,
discuss_mode: 'discuss',
@@ -613,6 +614,12 @@ function cmdConfigSet(cwd: string, keyPath: string | undefined, value: string |
error(`Invalid workflow.human_verify_mode '${val}'. Valid values: ${VALID_HUMAN_VERIFY_MODES.join(', ')}`);
}
// Context exhaustion guard mode (#1452)
const VALID_CONTEXT_GUARD_MODES = ['auto', 'warn', 'off'];
if (kp === 'workflow.context_guard_mode' && !VALID_CONTEXT_GUARD_MODES.includes(String(parsedValue))) {
error(`Invalid workflow.context_guard_mode '${val}'. Valid values: ${VALID_CONTEXT_GUARD_MODES.join(', ')}`);
}
// Context position enum validation (#2937)
const VALID_CONTEXT_POSITIONS = ['front', 'end'];
if (kp === 'statusline.context_position' && !VALID_CONTEXT_POSITIONS.includes(String(parsedValue))) {