mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-18 22:24:17 +01:00
Unattended /autoplan on Claude Code says its phase guard is on, and a report hidden in reasoning gets a clear fix (GST-3062) (#4481)
An unattended /autoplan run on Claude Code now says its phase guard is on, instead of saying it is off while the guard blocks it. A phase report written only in reasoning now gets a denial that says so and names the exact command to send. Why: in the day-one eval, two runs were blocked by a guard their own record called off, and one run ended blocked after four publish attempts whose report was invisible. Nothing to do. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
f87d4325a3
commit
44170d6791
19 files changed
+244
-34
No files matched your search
@@ -3,7 +3,7 @@
|
||||
* B2): `plan.md` (the `## URGENT, outside this plan` block above the
|
||||
* `## Implementation plan` section; warns above 30 KB), `review-record.md`
|
||||
* (the `## Review record` section plus the run log: phases, voices, consensus
|
||||
* tables, the gate and the GUARD_NOT_INSTALLED line the validator requires),
|
||||
* tables, the gate and the guard line the validator requires),
|
||||
* `findings.jsonl`, `tasks.jsonl`, `decisions.jsonl` (already written by the
|
||||
* gate), `timing.json`, and `run.json` with every artifact's path and hash
|
||||
* and the counts `gstack-artifact validate` checks against the files, plus
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* What gstack-skill-start and the gstack-autoplan run record say about the
|
||||
* /autoplan publication guard. The guard is the PreToolUse hook that the
|
||||
* Claude render of autoplan/SKILL.md declares in its frontmatter
|
||||
* (scripts/resolvers/composition.ts). Claude Code runs it whenever /autoplan
|
||||
* was started as a skill, whatever GSTACK_SESSION_KIND says, so the line
|
||||
* follows the host and the installed skill, never the session kind (GST-3062).
|
||||
* bin/gstack-skill-start carries the same rule in bash; test/autoplan-guard-status.test.ts holds them equal.
|
||||
*/
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
|
||||
export const GUARD_NOT_INSTALLED_LINE = 'autoplan guard: not enforced by this host; publication order is unverified (GUARD_NOT_INSTALLED)';
|
||||
export const GUARD_ENFORCED_LINE = "autoplan guard: enforced by Claude Code's /autoplan hook at phase Reads and reviewer dispatch; " +
|
||||
'publish each phase report as visible message text, not reasoning, before the next phase (GUARD_ENFORCED)';
|
||||
|
||||
/** True when the installed autoplan/SKILL.md declares the publication hook in its frontmatter. */
|
||||
export function publicationHookDeclared(root: string): boolean {
|
||||
let text: string;
|
||||
try { text = fs.readFileSync(path.join(root, 'autoplan', 'SKILL.md'), 'utf8'); } catch { return false; }
|
||||
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text)?.[1] ?? '';
|
||||
return frontmatter.includes('autoplan/bin/phase-publication-hook');
|
||||
}
|
||||
|
||||
/** The one guard line for this process: enforced only on Claude Code with the hook declared. */
|
||||
export function autoplanGuardLine(env: Record<string, string | undefined>, root: string): string {
|
||||
const claude = !!env.CLAUDECODE && (!env.GSTACK_ACTIVE_HOST || env.GSTACK_ACTIVE_HOST === 'claude');
|
||||
return claude && publicationHookDeclared(root) ? GUARD_ENFORCED_LINE : GUARD_NOT_INSTALLED_LINE;
|
||||
}
|
||||
+2
-1
@@ -26,6 +26,7 @@ import { GSTACK_VERSION } from './autoplan-migrate';
|
||||
import { driftLine, normalizeFindingFile, reviewHash, scaffold } from './autoplan-plan-text';
|
||||
import { PHASES, SNAPSHOT_TOOL, attemptFile, bindPromptResult, detectScope, driverFile, extractHeading, phaseOrder, reviewSkillFile, scopeLines, scopeSourceLabel, sectionLoadFor, snapshotTool, writePrompts, type Phase, type Scope, type ScopeFlags } from './autoplan-prompts';
|
||||
import { recoverRevise } from './autoplan-revise';
|
||||
import { autoplanGuardLine } from './autoplan-guard-status';
|
||||
import { FILES, RunError, journal, now, pendingAmendments, readDecisions, readJournal, readState, voiceTerminal, writeState, type AttemptState, type PhaseState, type RunState, type Voice, type VoiceState } from './autoplan-state';
|
||||
import { checkPlanReality, checkRealityRows, PLAN_REALITY_CHECKER } from './plan-reality';
|
||||
import type { RunStatus } from './headless-artifacts';
|
||||
@@ -129,7 +130,7 @@ export function initRun(o: InitOptions, lines: string[] = []): RunState {
|
||||
outside_enabled: (o.outsideEnabled ?? true) && !consentMissing && !lean, attempt_counter: 0, spend_cap_usd: o.spendCap ?? null,
|
||||
...(consentMissing ? { outside_not_run: { reason: 'consent_missing', detail: consentMissing } } : {}),
|
||||
session_kind: sessionKind, host: 'gstack-autoplan', max_rounds: o.maxRounds ?? (lean ? 1 : sessionKind === 'unattended' ? DEFAULT_MAX_ROUNDS : null), history: [], created_at: now(), updated_at: now(),
|
||||
deviations: ['autoplan guard: not enforced by this host; publication order is unverified (GUARD_NOT_INSTALLED)'],
|
||||
deviations: [autoplanGuardLine(process.env, path.resolve(import.meta.dir, '..'))],
|
||||
...(o.deadlineMin ? { deadline_at: new Date(Date.now() + o.deadlineMin * 60_000).toISOString() } : {}),
|
||||
...(o.light ? { light: true } : {}),
|
||||
...(o.ceoOnly ? { ceo_only: true } : {}), ...(o.shadow ? { shadow: o.shadow } : {}), gstack_version: GSTACK_VERSION, plan_input: input, scope_flags: { ...(o.scope ?? {}) },
|
||||
|
||||
@@ -502,7 +502,7 @@ export interface ValidationResult { valid: boolean; errors: ValidationError[]; m
|
||||
* that is missing, stale (hash) or escapes the run directory, malformed JSONL,
|
||||
* schema violations, duplicate or unbound ids, dangling references, task
|
||||
* dependency cycles, count mismatches, and an unattended run whose
|
||||
* review-record.md lacks the GUARD_NOT_INSTALLED line.
|
||||
* review-record.md lacks its GUARD_ENFORCED or GUARD_NOT_INSTALLED line.
|
||||
*/
|
||||
export function validateRun(runJson: string): ValidationResult {
|
||||
const runDir = path.dirname(path.resolve(runJson));
|
||||
@@ -549,7 +549,7 @@ export function validateRun(runJson: string): ValidationResult {
|
||||
const record = manifest.artifacts['review-record.md'];
|
||||
const abs = record ? resolveInside(runDir, record.path).abs : '';
|
||||
const text = abs && fs.existsSync(abs) ? fs.readFileSync(abs, 'utf8') : '';
|
||||
if (!text.includes('GUARD_NOT_INSTALLED')) errors.push({ code: 'ARTIFACT_GUARD_LINE_MISSING', path: 'review-record.md', message: 'unattended run without the guard line' });
|
||||
if (!/\((?:GUARD_ENFORCED|GUARD_NOT_INSTALLED)\)/.test(text)) errors.push({ code: 'ARTIFACT_GUARD_LINE_MISSING', path: 'review-record.md', message: 'unattended run without the guard line' });
|
||||
}
|
||||
return { valid: errors.length === 0, errors, manifest, runDir, attested: countAttested(manifest) };
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* Result codes for the CEO-only driver run (`gstack-autoplan next --ceo-only`,
|
||||
* Result codes for the /autoplan publication guard line (GUARD_ENFORCED, printed by
|
||||
* gstack-skill-start; lib/autoplan-guard-status.ts), the CEO-only driver run (`gstack-autoplan next --ceo-only`,
|
||||
* lib/autoplan-ceo-only.ts) and its shadow-mode reader (`gstack-autoplan shadow`,
|
||||
* lib/autoplan-shadow-reader.ts). Kept beside lib/result-codes.ts, which spreads
|
||||
* this table into RESULT_CODES; the same rules apply: one stable
|
||||
@@ -9,6 +10,11 @@
|
||||
import type { ResultCode } from './result-codes';
|
||||
|
||||
export const AUTOPLAN_RESULT_CODES = {
|
||||
GUARD_ENFORCED: {
|
||||
anchor: 'guard-enforced',
|
||||
summary: 'Claude Code runs the autoplan publication hook, so a phase Read or reviewer dispatch is denied until the previous phase report is published',
|
||||
fix: 'publish each phase report as visible message text, not reasoning, in a message whose only tool call is `true autoplan-published <phase>`',
|
||||
},
|
||||
CEO_ONLY_CONFLICT: {
|
||||
anchor: 'ceo-only-conflict',
|
||||
summary: '--ceo-only was combined with a flag that adds a phase (--ui, --developer-tool, --agent-primary), or a plan\'s scope marker names it',
|
||||
|
||||
+2
-2
@@ -101,8 +101,8 @@ export const RESULT_CODES = {
|
||||
},
|
||||
ARTIFACT_GUARD_LINE_MISSING: {
|
||||
anchor: 'artifact-guard-line-missing',
|
||||
summary: 'an unattended run’s review-record.md does not state that the publication guard was not enforced',
|
||||
fix: 'start the run through gstack-skill-start so the GUARD_NOT_INSTALLED line is recorded',
|
||||
summary: 'an unattended run’s review-record.md does not state whether the publication guard was enforced',
|
||||
fix: 'start the run through gstack-skill-start so its GUARD_ENFORCED or GUARD_NOT_INSTALLED line is recorded',
|
||||
},
|
||||
GUARD_NOT_INSTALLED: {
|
||||
anchor: 'guard-not-installed',
|
||||
|
||||
Reference in new issue
Block a user