* feat(#22): add plan_review.source_grounding + _authority config keys Two additive opt-out keys for the drift guard: source_grounding (bool, default true) gates the source-grounded reviewer pass; _authority (enum grep|intel|treesitter|lsp|scip, default grep) selects the resolver rung. No existing default changed. Refs #22 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(#22): add intel api-surface renderer + CLI subcommand Renders .planning/intel/api-map.json into a human-readable API-SURFACE.md for planner injection. Empty/missing map still writes a surface that announces itself incomplete (absence = unknown, not 'does not exist'). Gated on intel.enabled like all intel functions. Refs #22 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(#22): add source-grounding pass to plan-review-convergence Default-on reviewer pass (plan_review.source_grounding) that enumerates every symbol a plan cites, excludes declared new artifacts, resolves each against source via the configured authority adapter, and records three-valued verdicts. rung-0/1 MISSING is needs-acknowledgement, not a hard block; UNCHECKABLE is logged in a REVIEWS.md coverage section. Refs #22 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(#22): inject API-SURFACE.md into planner + require Artifacts section When intel.enabled, plan-phase regenerates API-SURFACE.md and injects it as a HINT (prefer, may be incomplete, absence = unknown), never a hard rule. Every plan must now emit an 'Artifacts this phase produces' section so the source-grounding reviewer can separate new symbols from references to existing code. Refs #22 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(#22): surface drift-guard in setup + settings, add docs /gsd:new-project asks to enable plan_review.source_grounding (default Y); /gsd:settings exposes the toggle and authority knob. Documents both config keys in CONFIGURATION.md, the intel api-surface command in COMMANDS.md, the drift guard in USER-GUIDE.md, and links ADR 22 from ARCHITECTURE.md. Refs #22 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(#22): respect AskUserQuestion 4-option cap and plan-phase XL line budget settings drift-guard toggle moved to its own 2-option question; #22 plan-phase additions condensed to bring the file back under the 1810-line XL budget without dropping the intel gate, the incomplete-surface hint, or the Artifacts-section requirement. Refs #22 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(#22): use live slash-command forms in drift-guard docs Doc-parity gate requires every slash-command token in docs/*.md to resolve to a registered command. Corrected the command form(s) referenced in the #22 drift-guard / api-surface documentation. The unresolved token was /gsd-core, matched from the GitHub repo reference "open-gsd/gsd-core#22" in docs/adr/22-plan-drift-guard.md. This is the same pattern as the existing 'test-runner' exemption (open-gsd/gsd-test-runner). Added 'core' to INTERNAL_COMPONENT_SLUGS with a matching explanatory comment. Refs #22 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(#22): add changeset fragment for drift guard (PR #487) Refs #22 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: CI Rebase Check <ci@gsd-redux> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -83,6 +83,7 @@
|
||||
* intel patch-meta <file> Update _meta.updated_at in an intel file
|
||||
* intel validate Validate intel file structure
|
||||
* intel extract-exports <file> Extract exported symbols from a source file
|
||||
* intel api-surface Render api-map.json into API-SURFACE.md
|
||||
*
|
||||
* Scaffolding:
|
||||
* scaffold context --phase <N> Create CONTEXT.md template
|
||||
@@ -1266,8 +1267,11 @@ async function runCommand(command, args, cwd, raw, defaultValue, originalCommand
|
||||
} else if (subcommand === 'update') {
|
||||
const planningDir = path.join(cwd, '.planning');
|
||||
core.output(intel.intelUpdate(planningDir), raw);
|
||||
} else if (subcommand === 'api-surface') {
|
||||
const planningDir = path.join(cwd, '.planning');
|
||||
core.output(intel.intelApiSurface(planningDir), raw);
|
||||
} else {
|
||||
error('Unknown intel subcommand. Available: query, status, update, diff, snapshot, patch-meta, validate, extract-exports', ERROR_REASON.SDK_UNKNOWN_COMMAND);
|
||||
error('Unknown intel subcommand. Available: query, status, update, diff, snapshot, patch-meta, validate, extract-exports, api-surface', ERROR_REASON.SDK_UNKNOWN_COMMAND);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -208,6 +208,10 @@ function buildNewProjectConfig(userChoices) {
|
||||
phase_naming: 'sequential',
|
||||
agent_skills: {},
|
||||
claude_md_path: './CLAUDE.md',
|
||||
plan_review: {
|
||||
source_grounding: true,
|
||||
source_grounding_authority: 'grep',
|
||||
},
|
||||
};
|
||||
|
||||
// Three-level deep merge: hardcoded <- userDefaults <- choices
|
||||
@@ -240,6 +244,11 @@ function buildNewProjectConfig(userChoices) {
|
||||
...(userDefaults.agent_skills || {}),
|
||||
...(choices.agent_skills || {}),
|
||||
},
|
||||
plan_review: {
|
||||
...hardcoded.plan_review,
|
||||
...(userDefaults.plan_review || {}),
|
||||
...(choices.plan_review || {}),
|
||||
},
|
||||
};
|
||||
|
||||
validateShipPrBodySections(config.ship.pr_body_sections);
|
||||
@@ -476,6 +485,19 @@ function cmdConfigSet(cwd, keyPath, value, raw) {
|
||||
error(`Invalid code_quality.fallow.profile '${value}'. Valid values: ${VALID_FALLOW_PROFILES.join(', ')}`);
|
||||
}
|
||||
|
||||
// plan_review.source_grounding (#22) — boolean only
|
||||
if (keyPath === 'plan_review.source_grounding') {
|
||||
if (typeof parsedValue !== 'boolean') {
|
||||
error(`Invalid plan_review.source_grounding '${value}'. Must be a boolean (true or false).`);
|
||||
}
|
||||
}
|
||||
|
||||
// plan_review.source_grounding_authority (#22) — enum
|
||||
const VALID_SOURCE_GROUNDING_AUTHORITIES = ['grep', 'intel', 'treesitter', 'lsp', 'scip'];
|
||||
if (keyPath === 'plan_review.source_grounding_authority' && !VALID_SOURCE_GROUNDING_AUTHORITIES.includes(String(parsedValue))) {
|
||||
error(`Invalid plan_review.source_grounding_authority '${value}'. Valid values: ${VALID_SOURCE_GROUNDING_AUTHORITIES.join(', ')}`);
|
||||
}
|
||||
|
||||
if (keyPath === 'review.default_reviewers') {
|
||||
const normalized = normalizeConfiguredDefaultReviewers(parsedValue);
|
||||
if (normalized.errors.length > 0) {
|
||||
|
||||
@@ -456,6 +456,70 @@ function intelValidate(planningDir) {
|
||||
return { valid: errors.length === 0, errors, warnings };
|
||||
}
|
||||
|
||||
/**
|
||||
* Render .planning/intel/api-map.json into a human-readable API-SURFACE.md.
|
||||
* Always writes the file — even when api-map.json is absent or empty, the
|
||||
* surface will contain an explicit "incomplete" banner so consumers never
|
||||
* mistake silence for "nothing exists".
|
||||
*
|
||||
* @param {string} planningDir - Path to .planning directory
|
||||
* @returns {{ written: string, symbolCount: number, stale: boolean } | { disabled: true, message: string }}
|
||||
*/
|
||||
function intelApiSurface(planningDir) {
|
||||
if (!isIntelEnabled(planningDir)) return disabledResponse();
|
||||
|
||||
const intelPath = ensureIntelDir(planningDir);
|
||||
const apiMapPath = path.join(intelPath, INTEL_FILES.apis);
|
||||
const outputPath = path.join(intelPath, 'API-SURFACE.md');
|
||||
|
||||
const data = safeReadJson(apiMapPath);
|
||||
const entries = (data && data.entries && typeof data.entries === 'object')
|
||||
? Object.entries(data.entries)
|
||||
: [];
|
||||
const symbolCount = entries.length;
|
||||
|
||||
// Staleness: reuse the _meta.updated_at field if present
|
||||
const STALE_MS = 24 * 60 * 60 * 1000;
|
||||
let stale = true;
|
||||
if (data && data._meta && data._meta.updated_at) {
|
||||
const age = Date.now() - new Date(data._meta.updated_at).getTime();
|
||||
stale = age > STALE_MS;
|
||||
}
|
||||
|
||||
const lines = [];
|
||||
lines.push('# API Surface');
|
||||
lines.push('');
|
||||
lines.push('> Generated from `.planning/intel/api-map.json`. Do not edit by hand.');
|
||||
lines.push('');
|
||||
|
||||
if (symbolCount === 0) {
|
||||
lines.push('> **Incomplete:** api-map.json has no entries (intel extraction is regex/JS-only or not yet populated).');
|
||||
lines.push('> Treat absence here as "unknown", not "does not exist".');
|
||||
lines.push('');
|
||||
} else {
|
||||
if (stale) {
|
||||
lines.push('> **Warning:** api-map.json is stale (>24 hours old). Data below may be out of date.');
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
for (const [symbol, info] of entries) {
|
||||
lines.push(`## \`${symbol}\``);
|
||||
lines.push('');
|
||||
if (info && typeof info === 'object') {
|
||||
for (const [field, val] of Object.entries(info)) {
|
||||
const display = Array.isArray(val) ? val.join(', ') : String(val);
|
||||
lines.push(`- **${field}:** ${display}`);
|
||||
}
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
}
|
||||
|
||||
platformWriteSync(outputPath, lines.join('\n'));
|
||||
|
||||
return { written: outputPath, symbolCount, stale };
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch _meta.updated_at in a JSON intel file to the current timestamp.
|
||||
* Reads the file, updates _meta.updated_at, increments version, writes back.
|
||||
@@ -632,6 +696,7 @@ module.exports = {
|
||||
intelValidate,
|
||||
intelExtractExports,
|
||||
intelPatchMeta,
|
||||
intelApiSurface,
|
||||
|
||||
// Utilities
|
||||
ensureIntelDir,
|
||||
|
||||
@@ -89,5 +89,9 @@
|
||||
"heavy": false
|
||||
},
|
||||
"agent_overrides": {}
|
||||
},
|
||||
"plan_review": {
|
||||
"source_grounding": true,
|
||||
"source_grounding_authority": "grep"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,9 @@
|
||||
"runtime",
|
||||
"resolve_model_ids",
|
||||
"effort.default",
|
||||
"fast_mode.enabled"
|
||||
"fast_mode.enabled",
|
||||
"plan_review.source_grounding",
|
||||
"plan_review.source_grounding_authority"
|
||||
],
|
||||
"runtimeStateKeys": [
|
||||
"workflow._auto_chain_active"
|
||||
|
||||
Reference in New Issue
Block a user