feat(#68): per-phase granularity overrides (granularities.<phaseType>) (#595)

Closes #68. Per-phase-type granularity overrides via granularities.<phaseType>, mirroring models.<phaseType>. Includes maintainer-authorized sdk-seam reference cleanup.
This commit is contained in:
Tom Boucher
2026-06-01 20:53:46 -04:00
committed by GitHub
parent 9ffe45a7c3
commit a11ba2dfcb
10 changed files with 404 additions and 8 deletions

View File

@@ -374,7 +374,7 @@ async function main() {
'from-gsd2, frontmatter, gap-analysis, generate-claude-md, generate-claude-profile, ' +
'generate-dev-preferences, generate-slug, graphify, history-digest, init, intel, ' +
'learnings, list-todos, milestone, phase, phase-plan-index, phases, profile-questionnaire, ' +
'profile-sample, progress, prompt-budget, requirements, resolve-model, roadmap, scaffold, state, ' +
'profile-sample, progress, prompt-budget, requirements, resolve-granularity, resolve-model, roadmap, scaffold, state, ' +
'task, template, validate, verify, verify-path-exists, verify-summary, workstream, worktree\n\n' +
'Global flags:\n' +
' --raw Emit raw output without post-processing\n' +
@@ -541,6 +541,11 @@ async function runCommand(command, args, cwd, raw, defaultValue, originalCommand
break;
}
case 'resolve-granularity': {
commands.cmdResolveGranularity(cwd, args[1], raw);
break;
}
case 'resolve-execution': {
// Deterministic flag parsing: consume --flag <value> pairs first,
// then the AGENT is the single remaining positional.

View File

@@ -4,11 +4,11 @@
const fs = require('fs');
const path = require('path');
const { execGit, platformWriteSync, platformReadSync, platformEnsureDir } = require('./shell-command-projection.cjs');
const { loadConfig, isGitIgnored, normalizePhaseName, comparePhaseNum, getArchivedPhaseDirs, generateSlugInternal, getMilestoneInfo, getMilestonePhaseFilter, resolveModelInternal, resolveEffortInternal, resolveFastModeInternal, resolveEffortForTier, stripShippedMilestones, extractCurrentMilestone, toPosixPath, output, error, findPhaseInternal, extractOneLinerFromBody, getRoadmapPhaseInternal, extractPhaseToken } = require('./core.cjs');
const { loadConfig, isGitIgnored, normalizePhaseName, comparePhaseNum, getArchivedPhaseDirs, generateSlugInternal, getMilestoneInfo, getMilestonePhaseFilter, resolveModelInternal, resolveEffortInternal, resolveFastModeInternal, resolveEffortForTier, stripShippedMilestones, extractCurrentMilestone, toPosixPath, output, error, findPhaseInternal, extractOneLinerFromBody, getRoadmapPhaseInternal, extractPhaseToken, resolveGranularityInternal } = require('./core.cjs');
const { renderEffortForRuntime, RUNTIMES_WITH_FAST_MODE } = require('./model-catalog.cjs');
const { planningDir, planningPaths } = require('./planning-workspace.cjs');
const { extractFrontmatter } = require('./frontmatter.cjs');
const { MODEL_PROFILES } = require('./model-profiles.cjs');
const { MODEL_PROFILES, VALID_PHASE_TYPES } = require('./model-profiles.cjs');
const { formatGsdSlash, resolveRuntime } = require('./runtime-slash.cjs');
/**
@@ -251,6 +251,17 @@ function cmdResolveModel(cwd, agentType, raw) {
output(result, raw, model);
}
function cmdResolveGranularity(cwd, phaseType, raw) {
if (!phaseType) {
error('phase-type required');
}
const granularity = resolveGranularityInternal(cwd, phaseType);
const result = VALID_PHASE_TYPES.has(phaseType)
? { granularity, phase_type: phaseType }
: { granularity, phase_type: phaseType, unknown_phase_type: true };
output(result, raw, granularity);
}
/**
* #443 — Superset execution query: model + unified effort + fast_mode.
*
@@ -1276,6 +1287,7 @@ module.exports = {
cmdVerifyPathExists,
cmdHistoryDigest,
cmdResolveModel,
cmdResolveGranularity,
cmdResolveExecution,
cmdEffortSync,
cmdCommit,

View File

@@ -3,12 +3,12 @@
/**
* Thin adapter — sources schema data from the manifest via the generated
* Configuration Module. All inline literals have been removed; the manifest
* at sdk/shared/config-schema.manifest.json is the single source of truth.
* at get-shit-done/bin/shared/config-schema.manifest.json is the single source of truth.
*
* Imported by:
* - config.cjs (isValidConfigKey validator)
* - tests/config-schema-docs-parity.test.cjs (CI drift guard)
* - tests/config-schema-sdk-parity.test.cjs (CJS↔SDK parity guard)
* - core.cjs
* - many tests (config-schema.property.test.cjs, bug-*, feat-*, etc.)
*
* See Phase 2 Cycle 5 (#3536) — schema manifest migration.
*/

View File

@@ -13,8 +13,6 @@ function loadConfigurationManifest(fileName) {
const candidates = [
// Installed runtime layout: get-shit-done/bin/shared/*.manifest.json
join(__dirname, '..', 'shared', fileName),
// Source-repo dev layout: sdk/shared/*.manifest.json
join(__dirname, '..', '..', '..', 'sdk', 'shared', fileName),
];
let lastErr = null;
for (const candidate of candidates) {

View File

@@ -497,6 +497,19 @@ function loadConfig(cwd, options = {}) {
// resolveModelInternal. Defaults to null so configs without it
// behave exactly as today.
models: parsed.models || null,
// #68 — top-level granularity (global override; written by new-project
// payloads and legacy depth→granularity migration). Pass through as-is so
// resolveGranularityInternal can honor user-set values without enum-guarding
// here (preserves Hyrum compat for the global slot).
granularity: parsed.granularity !== undefined ? parsed.granularity : null,
// #68 — per-phase-type granularity map. Six named slots mirroring `models`.
// Defaults to null so configs without it behave exactly as before.
granularities: parsed.granularities || null,
// #68 — planning sub-object (needed for planning.granularity fallback).
// Also used by other keys (planning.commit_docs etc.) via `get()` above,
// but those use the nested get() path; resolveGranularityInternal needs
// direct access to planning.granularity so we pass through the whole block.
planning: parsed.planning || null,
// #3024 — dynamic routing block. When `enabled: true`, the
// resolveModelForTier() resolver picks tier_models[default_tier]
// for the agent and escalates one tier per attempt up to
@@ -566,6 +579,9 @@ function loadConfig(cwd, options = {}) {
subagent_timeout: globalDefaults.subagent_timeout ?? defaults.subagent_timeout,
model_overrides: globalDefaults.model_overrides || null,
models: globalDefaults.models || null,
granularity: globalDefaults.granularity !== undefined ? globalDefaults.granularity : null,
granularities: globalDefaults.granularities || null,
planning: globalDefaults.planning || null,
dynamic_routing: globalDefaults.dynamic_routing || null,
effort: globalDefaults.effort || null,
fast_mode: globalDefaults.fast_mode || null,
@@ -1721,6 +1737,37 @@ function resolveModelInternal(cwd, agentType) {
return alias;
}
const VALID_GRANULARITIES = new Set(['coarse', 'standard', 'fine']);
/**
* Resolve the planning granularity for a phase type (#68).
*
* Precedence (mirrors resolveModelInternal's phase-type slot):
* 1. granularities[phaseType] — per-phase override; honored only when a
* recognized enum value (coarse|standard|fine). A typo or wrong type
* falls through so it can't silently break resolution.
* 2. top-level `granularity` — global (new-project payload / legacy depth).
* 3. planning.granularity — canonical global default (always present post-merge).
* 4. 'standard' — hard default.
*/
function resolveGranularityInternal(cwd, phaseType) {
const config = loadConfig(cwd);
const perPhase = (phaseType && config.granularities && typeof config.granularities === 'object')
? config.granularities[phaseType]
: undefined;
if (perPhase && VALID_GRANULARITIES.has(perPhase)) {
return perPhase;
}
if (config.granularity !== undefined && config.granularity !== null && config.granularity !== '') {
return config.granularity;
}
const planningGran = config.planning && config.planning.granularity;
if (planningGran !== undefined && planningGran !== null && planningGran !== '') {
return planningGran;
}
return 'standard';
}
/**
* #3024 — Resolve a model for a specific dynamic-routing attempt.
*
@@ -2462,6 +2509,8 @@ module.exports = {
getRoadmapPhaseInternal,
resolveModelInternal,
resolveModelForTier,
resolveGranularityInternal,
VALID_GRANULARITIES,
resolveEffortInternal,
resolveFastModeInternal,
resolveEffortForTier,

View File

@@ -142,6 +142,11 @@
"source": "^models\\.(planning|discuss|research|execution|verification|completion)$",
"description": "models.<planning|discuss|research|execution|verification|completion>"
},
{
"topLevel": "granularities",
"source": "^granularities\\.(planning|discuss|research|execution|verification|completion)$",
"description": "granularities.<planning|discuss|research|execution|verification|completion>"
},
{
"topLevel": "dynamic_routing",
"source": "^dynamic_routing\\.(enabled|escalate_on_failure|max_escalations|tier_models\\.(light|standard|heavy))$",