Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

feat: make model profiles runtime-aware for Codex/non-Claude runtimes (closes #2517) - #2609

Merged
trek-e merged 2 commits into
gsd-build:mainfrom
trek-e:feat/2517-runtime-aware-model-profiles
Apr 23, 2026
Merged

trek-e merged 2 commits into
gsd-build:mainfrom
trek-e:feat/2517-runtime-aware-model-profiles

Conversation

@trek-e

@trek-e trek-e commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2517

Summary

Makes GSD's model_profile system runtime-aware. A new optional runtime config key, combined with an optional model_profile_overrides[runtime][tier] map, lets profile tiers (opus/sonnet/haiku) resolve to runtime-native model IDs and (where supported) reasoning_effort settings. On Codex this means quality / balanced / budget / adaptive produce real Codex-native model selections instead of empty strings, eliminating the need for large per-agent model_overrides blocks documented in #2256 / #2511.

GSD ships built-in defaults that users can override per-runtime, per-tier (no provider-specific IDs are emitted for runtimes the resolver does not know about; those fall back to the safe Claude alias). Built-in tier maps (from #2517 spec):

Runtime opus sonnet haiku reasoning_effort
claude claude-opus-4-6 claude-sonnet-4-6 claude-haiku-4-5 (not used)
codex gpt-5.4 gpt-5.3-codex gpt-5.4-mini xhigh / medium / medium

Other runtimes (opencode, gemini, qwen, copilot, …) consume the resolver at spawn time today; install-path emission for them is tracked in #2612.

Resolution chain

Pre-#2609 resolveModelInternal (get-shit-done/bin/lib/core.cjs):

  1. model_overrides[agent] returns first.
  2. resolve_model_ids === "omit" → "".
  3. model_profile tier lookup → alias (opus etc) or full ID if resolve_model_ids: true.

New chain:

  1. model_overrides[agent] (unchanged — most specific knob).
  2. runtime is set to a non-Claude value AND tier resolves under model_profile_overrides[runtime][tier] → RUNTIME_PROFILE_MAP[runtime][tier].
  3. resolve_model_ids === "omit" (preserved fallback so existing Codex installs keep working when the user has not opted in).
  4. Claude-native default (alias or full ID).
  5. inherit literal passthrough.

runtime: "claude" is the implicit default and behaves as a no-op for resolution — it does not override resolve_model_ids: "omit" or any other Claude-native semantics. Step 2 is gated on config.runtime != null && config.runtime !== "claude". With runtime unset every config behaves byte-identically to today.

Changes

  • get-shit-done/bin/lib/core.cjs: loadConfig reads runtime + model_profile_overrides (default null) and warns at read time on unknown runtime values or unknown tier keys (no rejection — preserves back-compat for runtimes added later). Adds RUNTIME_PROFILE_MAP, resolveTierEntry (single shared resolver consumed by both core and install), and resolveReasoningEffortInternal gated strictly on RUNTIMES_WITH_REASONING_EFFORT. resolveModelInternal adds the runtime-aware branch only when config.runtime is set to a non-Claude value, preserves all prior fallbacks, and never returns reasoning_effort (keeps the string contract intact).
  • get-shit-done/bin/lib/config-schema.cjs: adds runtime to VALID_CONFIG_KEYS and a dynamic pattern model_profile_overrides.<runtime>.<opus|sonnet|haiku> (tier enum-restricted, runtime free-string).
  • bin/install.js: readGsdRuntimeProfileResolver(targetDir) probes <targetDir>/.planning/config.json AND ~/.gsd/defaults.json (per-project wins) and returns a resolver that delegates to the shared resolveTierEntry. Failed JSON parses warn to stderr instead of swallowing. generateCodexAgentToml accepts the resolver and emits model = "..." plus model_reasoning_effort = "..." when runtime: "codex" is configured. Per-agent model_overrides keeps highest precedence.

Documentation

Tests

tests/issue-2517-runtime-aware-profiles.test.cjs — 52 tests covering:

  • Backwards compat (no runtime set): balanced, inherit, resolve_model_ids: true, resolve_model_ids: "omit", adaptive all unchanged; reasoning_effort returns null.
  • runtime: "claude" is a no-op: balanced returns the alias; runtime:"claude" + resolve_model_ids:"omit" returns ""; runtime:"claude" + resolve_model_ids:true maps the alias to the full Claude ID; reasoning_effort never leaks.
  • runtime: "codex": opus → gpt-5.4 xhigh, sonnet → gpt-5.3-codex medium, haiku → gpt-5.4-mini medium; adaptive still works (no Add adaptive model profile preset and per-agent model overrides #1713 / feat(model-profiles): add adaptive preset with role-based model assignment #1806 regression); inherit profile passes through unchanged; runtime opt-in beats resolve_model_ids: "omit".
  • Precedence: per-agent model_overrides beats profile override beats default.
  • Field-merge of overrides with built-in defaults: string-shorthand { opus: "gpt-5-pro" } keeps reasoning_effort from the built-in entry; partial-object { opus: { reasoning_effort: "low" } } keeps the built-in model.
  • reasoning_effort allowlist gates regardless of overrides — typo runtime: "codx" plus an override does not leak xhigh.
  • Unknown runtime: falls back to Claude alias safe default rather than emit Codex IDs; user-supplied overrides for unknown runtime still resolve a model (no effort).
  • loadConfig warning paths for unknown runtime values and unknown tier keys.
  • End-to-end install path: per-project .planning/config.json reaches the Codex TOML emit (model = ..., model_reasoning_effort = ...); per-project wins over ~/.gsd/defaults.json; install.js library require paths exist relative to __dirname.
  • Schema: runtime is valid; tier enum is enforced (opus/sonnet/haiku accepted, banana rejected); runtime is free-string; bare model_profile_overrides rejected.

Tests isolate HOME and GSD_HOME to a per-test tmpdir so the developer's real ~/.gsd/defaults.json cannot bleed into assertions.

Full suite: 5244 / 5244 passing (npm test).

Design decisions

  • runtime: "codex" overrides resolve_model_ids: "omit". Explicit non-Claude opt-in beats safety-valve; otherwise the new feature would be dead-on-arrival for the Codex installs that auto-set omit. Existing users keep their behavior because they have not set runtime.
  • runtime: "claude" is a no-op for resolution. It is the implicit default; treating it as anything else would silently flip resolve_model_ids semantics on for everyone setting runtime: "claude" to "be explicit."
  • Built-in tier maps are the source of truth. model_profile_overrides field-merges per (runtime, tier) so users can override just the model and keep the built-in reasoning_effort, or vice versa.
  • reasoning_effort only flows through Codex install paths. resolveModelInternal keeps its string-return contract; a parallel resolveReasoningEffortInternal exposes effort, gated on a strict allowlist (currently: codex). The Codex TOML generator is the only emitter today.
  • Unknown runtime → Claude-alias safe fallback. Per the spec, do not emit provider-specific IDs the runtime cannot accept. Users who want a new runtime can supply model_profile_overrides[<runtime>] to populate it; install-path emission for additional runtimes is tracked in feat: extend runtime-aware profiles to all supported runtimes + interactive override UI #2612.

Adversarial review fixes

The review of the original commit surfaced 16 findings (2 critical, 8 major, 5 minor, 1 nit). All were addressed in the follow-on commit on this branch — see the commit message for the per-finding mapping.

Summary by CodeRabbit

  • New Features

    • Added runtime-aware model profile resolution supporting multiple AI runtimes
    • Introduced runtime configuration option to specify runtime (Claude, Codex)
    • Added model_profile_overrides configuration for custom tier-to-model mappings
  • Documentation

    • Updated configuration guide with runtime tier resolution behavior
    • Added user guide section on switching runtime selection
    • Updated workflow settings guidance for runtime-specific profiles
  • Tests

    • Added comprehensive test suite for runtime-aware profile functionality

…closes #2517)

Adds an optional top-level `runtime` config key plus a
`model_profile_overrides[runtime][tier]` map. When `runtime` is set,
profile tiers (opus/sonnet/haiku) resolve to runtime-native model IDs
(and reasoning_effort where supported) instead of bare Claude aliases.

Codex defaults from the spec:
  opus   -> gpt-5.4        reasoning_effort: xhigh
  sonnet -> gpt-5.3-codex  reasoning_effort: medium
  haiku  -> gpt-5.4-mini   reasoning_effort: medium

Claude defaults mirror MODEL_ALIAS_MAP. Unknown runtimes fall back to
the Claude-alias safe default rather than emit IDs the runtime cannot
accept. reasoning_effort is only emitted into Codex install paths;
never returned from resolveModelInternal and never written to Claude
agent frontmatter.

Backwards compatible: any user without `runtime` set sees identical
behavior — the new branch is gated on `config.runtime != null`.

Precedence (highest to lowest):
  1. per-agent model_overrides
  2. runtime-aware tier resolution (when `runtime` is set)
  3. resolve_model_ids: "omit"
  4. Claude-native default
  5. inherit (literal passthrough)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@trek-e
trek-e requested a review from glittercowboy as a code owner April 23, 2026 02:12
@coderabbitai

coderabbitai Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Implements runtime-aware model-profile resolution enabling automatic mapping of profile tiers (opus/sonnet/haiku) to runtime-native model IDs and reasoning-effort values. Adds configuration support for runtime selection, per-runtime tier overrides, schema validation, Codex installer integration, and comprehensive documentation.

Changes

Cohort / File(s) Summary
Core Runtime Resolution
get-shit-done/bin/lib/core.cjs, get-shit-done/bin/lib/config-schema.cjs
Introduces resolveReasoningEffortInternal, RUNTIME_PROFILE_MAP, and related exports to resolve profile tiers to runtime-specific models. Adds config schema support for runtime key and model_profile_overrides.<runtime>.<tier> patterns with validation for unknown runtimes/tiers.
Installation Integration
bin/install.js
Exports readGsdRuntimeProfileResolver, adds runtimeResolver parameter to generateCodexAgentToml, and embeds Codex-native model and model_reasoning_effort derived from runtime-aware tier resolution when per-agent model overrides are absent.
Configuration & Workflow Documentation
docs/CONFIGURATION.md, docs/USER-GUIDE.md, get-shit-done/workflows/settings.md
Documents new runtime and model_profile_overrides configuration keys, runtime-aware tier mapping behavior, field-merge semantics, precedence rules, and user guidance for switching runtimes via minimal config changes.
Test Suite
tests/core.test.cjs, tests/issue-2517-runtime-aware-profiles.test.cjs
Updates existing test to handle value validation for known keys; adds comprehensive new suite covering runtime absence/presence, Claude and Codex tier mapping, precedence rules, field merging, reasoning-effort allowlisting, config validation, and end-to-end Codex TOML generation.

Sequence Diagram

sequenceDiagram
    participant User
    participant ConfigLoader as Config Loader
    participant TierResolver as Tier Resolver
    participant ProfileMap as Runtime Profile Map
    participant CodexInstaller as Codex Installer
    
    User->>ConfigLoader: Load .planning/config.json + ~/.gsd/defaults.json
    ConfigLoader->>ConfigLoader: Merge configs (project precedence)
    ConfigLoader->>ConfigLoader: Validate runtime & model_profile_overrides
    ConfigLoader->>TierResolver: Get resolved model for agent tier
    
    alt runtime = "codex"
        TierResolver->>ProfileMap: Look up tier → Codex model mapping
        ProfileMap-->>TierResolver: Return Codex model ID
        TierResolver->>TierResolver: Apply model_profile_overrides[codex][tier]
        TierResolver-->>CodexInstaller: model ID + reasoning_effort
    else runtime = "claude" or absent
        TierResolver->>ProfileMap: Use Claude alias (existing behavior)
        ProfileMap-->>TierResolver: Claude model alias
        TierResolver-->>CodexInstaller: null reasoning_effort
    end
    
    CodexInstaller->>CodexInstaller: Generate agent TOML with model & reasoning_effort
    CodexInstaller-->>User: Codex config embedded with resolved runtime models
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Suggested labels

size/L

Suggested reviewers

  • glittercowboy

Poem

🐰 A runtime resolver hops into view,
Mapping tiers to models, shiny and new!
Codex and Claude now play side-by-side,
With reasoning effort as nature's guide.
Profile-aware magic—hop, skip, compile! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is comprehensive and well-structured, covering summary, resolution chain, changes, documentation, tests, and design decisions; however, it does not match the required typed PR template structure for Feature PRs. Use the Feature template (?template=PULL_REQUEST_TEMPLATE/feature.md) with required sections: Overview, Motivation, Solution, Testing, and Checklist. The current freeform description should be adapted to fit that structure.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: making model profiles runtime-aware for Codex and non-Claude runtimes, with an issue reference.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Addresses all 16 findings from the adversarial review of PR #2609.
Each finding is enumerated below with its resolution.

CRITICAL
- F1: readGsdRuntimeProfileResolver(targetDir) now probes per-project
  .planning/config.json AND ~/.gsd/defaults.json with per-project winning,
  so the PR's headline claim ("set runtime in project config and Codex
  TOML emit picks it up") actually holds end-to-end.
- F2: resolveTierEntry field-merges user overrides with built-in defaults.
  The CONFIGURATION.md string-shorthand example
    `{ codex: { opus: "gpt-5-pro" } }`
  now keeps reasoning_effort from the built-in entry. Partial-object
  overrides like `{ opus: { reasoning_effort: 'low' } }` keep the
  built-in model. Both paths regression-tested.

MAJOR
- F3: resolveReasoningEffortInternal gates strictly on the
  RUNTIMES_WITH_REASONING_EFFORT allowlist regardless of override
  presence. Override + unknown-runtime no longer leaks reasoning_effort.
- F4: runtime:"claude" is now a no-op for resolution (it is the implicit
  default). It no longer hijacks resolve_model_ids:"omit". Existing
  tests for `runtime:"claude"` returning Claude IDs were rewritten to
  reflect the no-op semantics; new test asserts the omit case returns "".
- F5: _readGsdConfigFile in install.js writes a stderr warning on JSON
  parse failure instead of silently returning null. Read failure and
  parse failure are warned separately. Library require is hoisted to top
  of install.js so it is not co-mingled with config-read failure modes.
- F6: install.js requires for core.cjs / model-profiles.cjs are hoisted
  to the top of the file with __dirname-based absolute paths so global
  npm install works regardless of cwd. Test asserts both lib paths exist
  relative to install.js __dirname.
- F7: docs/CONFIGURATION.md `runtime` row no longer lists `opencode` as
  a valid runtime — install-path emission for non-Codex runtimes is
  explicitly out of scope per #2517 / #2612, and the doc now points at
  #2612 for the follow-on work. resolveModelInternal still accepts any
  runtime string (back-compat) and falls back safely for unknown values.
- F8: Tests now isolate HOME (and GSD_HOME) to a per-test tmpdir so the
  developer's real ~/.gsd/defaults.json cannot bleed into assertions.
  Same pattern CodeRabbit caught on PRs #2603 / #2604.
- F9: `runtime` and `model_profile_overrides` documented as flat-only
  in core.cjs comments — not routed through `get()` because they are
  top-level keys per docs/CONFIGURATION.md and introducing nested
  resolution for two new keys was not worth the edge-case surface.
- F10/F13: loadConfig now invokes _warnUnknownProfileOverrides on the
  raw parsed config so direct .planning/config.json edits surface
  unknown runtime values (e.g. typo `runtime: "codx"`) and unknown
  tier values (e.g. `model_profile_overrides.codex.banana`) at read
  time. Warnings only — preserves back-compat for runtimes added
  later. Per-process warning cache prevents log spam across repeated
  loadConfig calls.

MINOR / NIT
- F11: Removed dead `tier || 'sonnet'` defensive shortcut. The local
  is now `const alias = tier;` with a comment explaining why `tier`
  is guaranteed truthy at that point (every MODEL_PROFILES entry
  defines `balanced`, the fallback profile).
- F12: Extracted resolveTierEntry() in core.cjs as the single source
  of truth for runtime-aware tier resolution. core.cjs and bin/install.js
  both consume it — no duplicated lookup logic between the two files.
- F14: Added regression tests for findings #1, #2, #3, #4, #6, #10, #13
  in tests/issue-2517-runtime-aware-profiles.test.cjs. Each must-fix
  path has a corresponding test that fails against the pre-fix code
  and passes against the post-fix code.
- F15: docs/CONFIGURATION.md `model_profile` row cross-references
  #1713 / #1806 next to the `adaptive` enum value.
- F16: RUNTIME_PROFILE_MAP remains in core.cjs as the single source of
  truth; install.js imports it through the exported resolveTierEntry
  helper rather than carrying its own copy. Doc files (CONFIGURATION.md,
  USER-GUIDE.md, settings.md) intentionally still embed the IDs as text
  — code comment in core.cjs flags that those doc files must be updated
  whenever the constant changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@trek-e

trek-e commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

Adversarial review — resolution summary

All 16 findings addressed in 408bfc8. Full suite 5244/5244 passing; PR mergeable.

# Severity Finding Commit Status
1 Critical readGsdRuntimeProfileResolver never read per-project .planning/config.json — PR's headline claim broken 408bfc8 Fixed: resolver now takes targetDir, walks up to find .planning/config.json, merges with ~/.gsd/defaults.json (per-project wins). End-to-end install→TOML test added.
2 Critical _resolveRuntimeTier returned user override verbatim — string shorthand dropped reasoning_effort, partial object dropped model 408bfc8 Fixed: extracted resolveTierEntry helper that field-merges built-in with user override. Tests cover shorthand-keeps-effort and partial-object-keeps-model.
3 Major resolveReasoningEffortInternal leaked effort to unknown runtimes when overrides supplied it 408bfc8 Fixed: gates strictly on RUNTIMES_WITH_REASONING_EFFORT regardless of override presence. Test asserts unknown-runtime override yields null effort.
4 Major runtime: "claude" silently overrode resolve_model_ids: "omit" 408bfc8 Fixed: runtime: "claude" is now a no-op for resolution. Test asserts runtime:"claude" + resolve_model_ids:"omit" returns "".
5 Major Bare try/catch { return null } swallowed JSON parse + require failures 408bfc8 Fixed: _readGsdConfigFile writes a stderr warning on read failure and parse failure separately. Library requires separated from config-read failure modes.
6 Major Relative require('../get-shit-done/...') may fail outside repo 408bfc8 Fixed: requires hoisted to top of bin/install.js with __dirname-based absolute paths. Test asserts both lib paths exist relative to install.js __dirname.
7 Major OpenCode/Kilo install path was not extended despite docs listing opencode as a runtime 408bfc8 Fixed by docs route: opencode removed from the docs valid-runtime row; doc now points at #2612 for install-path emission. (Per #2612: not adding install-path emission for non-Codex runtimes is explicitly out of scope for #2517.)
8 Major Tests had no HOME=tmpdir isolation 408bfc8 Fixed: every test in tests/issue-2517-runtime-aware-profiles.test.cjs sets HOME and GSD_HOME to a per-test tmpdir; restored on teardown. Same pattern CodeRabbit caught on PRs #2603 / #2604.
9 Major runtime and model_profile_overrides read flat-only — inconsistent with sibling keys that support workflow.X nesting 408bfc8 Documented decision: kept flat-only (lighter touch — these are top-level keys per docs). Comment in loadConfig explains the reasoning.
10 Major loadConfig had zero validation of runtime / model_profile_overrides values 408bfc8 Fixed: _warnUnknownProfileOverrides runs against raw parsed config and warns on unknown runtime values and unknown tier keys (no rejection — preserves back-compat). Tests cover both warning paths.
11 Minor Dead tier || 'sonnet' shortcut 408bfc8 Removed. Replaced with const alias = tier; and a comment explaining why tier is guaranteed truthy at that point.
12 Minor Parallel tier-resolution logic in install.js and core.cjs 408bfc8 Fixed: resolveTierEntry extracted in core.cjs and consumed by both files. install.js no longer carries duplicate lookup logic.
13 Minor Typo runtime: "codx" silently accepted 408bfc8 Fixed by #10's warning path. Test asserts codx triggers the unknown-runtime warning.
14 Minor Test coverage gaps for #1, #2, #4, #13 408bfc8 Fixed: 27 new tests added in tests/issue-2517-runtime-aware-profiles.test.cjs (52 total). Each must-fix path has a corresponding regression test.
15 Minor adaptive doc addition without changelog cross-ref 408bfc8 Added cross-ref to #1713 / #1806 next to the adaptive enum value in docs/CONFIGURATION.md.
16 Nit Provider-specific IDs in 4 places 408bfc8 RUNTIME_PROFILE_MAP remains the single source of truth in core.cjs; install.js consumes it via resolveTierEntry. Code comment in core.cjs flags that doc files (CONFIGURATION.md, USER-GUIDE.md, settings.md) must be updated whenever the constant changes (docs-from-source generation deliberately out of scope).

Notable behavior changes from the review

  • runtime: "claude" is no longer a path that resolves to full Claude IDs — it is the implicit default and behaves exactly like having runtime unset. Tests for that case were rewritten to reflect the no-op semantics. Users who want claude-opus-4-6 instead of opus should set resolve_model_ids: true (the existing knob), not runtime: "claude".
  • opencode no longer appears in the docs runtime enum row — install-path emission for non-Codex runtimes lives in feat: extend runtime-aware profiles to all supported runtimes + interactive override UI #2612. The resolver itself still accepts any runtime string (back-compat), so users on a runtime not in the doc list keep their existing fallback behavior.

PR body update

The PR body's "GSD ships zero provider-specific IDs" framing was inaccurate — softened to "GSD ships built-in defaults that users can override per-runtime, per-tier" with a note that unknown-runtime fallback is the safe Claude alias. Adversarial-review fixes section appended.

@trek-e
trek-e merged commit cc17886 into gsd-build:main Apr 23, 2026
11 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
get-shit-done/bin/lib/core.cjs (1)

324-347: ⚠️ Potential issue | 🟠 Major

Whitelist model_profile_overrides in the top-level key check.

loadConfig() now reads parsed.model_profile_overrides on Line 411, but KNOWN_TOP_LEVEL never includes the model_profile_overrides container. That means a valid config like { "model_profile_overrides": { "codex": { "opus": "gpt-5-pro" }}} still emits the generic “unknown config key(s) … ignored” warning here, which is misleading for the new feature.

Suggested fix
     const KNOWN_TOP_LEVEL = new Set([
       // Extract top-level key names from dot-notation paths (e.g., 'workflow.research' → 'workflow')
       ...[...VALID_CONFIG_KEYS].map(k => k.split('.')[0]),
       // Section containers that hold nested sub-keys
       'git', 'workflow', 'planning', 'hooks', 'features',
       // Internal keys loadConfig reads but config-set doesn't expose
-      'model_overrides', 'agent_skills', 'context_window', 'resolve_model_ids', 'claude_md_path',
+      'model_overrides', 'model_profile_overrides', 'agent_skills', 'context_window', 'resolve_model_ids', 'claude_md_path',
       // Deprecated keys (still accepted for migration, not in config-set)
       'depth', 'multiRepo',
     ]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@get-shit-done/bin/lib/core.cjs` around lines 324 - 347, KNOWN_TOP_LEVEL
currently omits the new top-level container model_profile_overrides, causing
valid configs to be flagged as unknown; update the KNOWN_TOP_LEVEL set (the Set
created where VALID_CONFIG_KEYS is mapped and the additional container names are
listed) to include the string 'model_profile_overrides' so that the unknownKeys
filter no longer treats that container as unexpected, and keep the existing call
to _warnUnknownProfileOverrides(parsed, '.planning/config.json') for finer
validation.
🧹 Nitpick comments (2)
tests/core.test.cjs (1)

165-183: Add a regression for model_profile_overrides specifically.

This loop only exercises exact keys from VALID_CONFIG_KEYS, so it still won't catch a false “unknown config key(s)” warning on the top-level model_profile_overrides object. A focused case with a valid payload under model_profile_overrides.codex.opus would keep the new warning path covered.

Suggested test shape
+  test('does not warn for valid model_profile_overrides container', (t) => {
+    writeConfig({
+      model_profile_overrides: {
+        codex: { opus: 'gpt-5-pro' },
+      },
+    });
+    const origWrite = process.stderr.write;
+    let stderrOutput = '';
+    process.stderr.write = (chunk) => { stderrOutput += chunk; };
+    t.after(() => { process.stderr.write = origWrite; });
+
+    loadConfig(tmpDir);
+
+    assert.ok(
+      !stderrOutput.includes('unknown config key(s)'),
+      'valid model_profile_overrides should not trigger unknown-key warning'
+    );
+  });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/core.test.cjs` around lines 165 - 183, Add a focused regression that
writes a config containing a valid model_profile_overrides payload (e.g., {
model_profile_overrides: { codex: { opus: { /* valid entries */ } } } }), then
call loadConfig(tmpDir) and assert that stderr does not include the "unknown
config key(s)" warning for model_profile_overrides; reuse the same stderr
capture pattern (overriding process.stderr.write) and the helper writeConfig
used in the existing loop to ensure the specific top-level key
model_profile_overrides is exercised and doesn't spuriously trigger the
unknown-key warning.
tests/issue-2517-runtime-aware-profiles.test.cjs (1)

507-562: Add a project-level model_overrides installer case.

The integration block proves that project runtime / model_profile reach Codex TOML generation, but it never exercises project model_overrides. That leaves the current precedence regression in installCodexConfig() green. A case that pins gsd-planner in .planning/config.json and asserts the TOML uses that model would close the gap.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/issue-2517-runtime-aware-profiles.test.cjs` around lines 507 - 562, Add
a new test in tests/issue-2517-runtime-aware-profiles.test.cjs that exercises
project-level model overrides: call writeConfig(tmpDir, { runtime: 'codex',
model_profile: 'quality', model_profile_overrides: { codex: { opus: {
'gsd-planner': { model: 'pinned-model' } } } } }); then obtain the resolver via
readGsdRuntimeProfileResolver(tmpDir), generate the TOML with
generateCodexAgentToml('gsd-planner', '---\nname: gsd-planner\n---\nBody.\n',
null, resolver) and assert the generated TOML includes model = "pinned-model"
(and optionally that no other precedence sources override it). This verifies
installCodexConfig()/generateCodexAgentToml honor per-project model overrides
for gsd-planner.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bin/install.js`:
- Around line 3190-3196: The current code only uses
readGsdGlobalModelOverrides() for modelOverrides, so project-scoped
model_overrides (e.g. model_overrides.gsd-planner) are ignored; update the flow
to first load project-level overrides for the given targetDir (e.g. via a
readGsdProjectModelOverrides(targetDir) or similar helper), merge them with the
global overrides so project values take precedence, and then pass the merged
modelOverrides into generateCodexAgentToml(name, content, modelOverrides,
runtimeResolver); ensure you reference the existing symbols
readGsdGlobalModelOverrides, readGsdRuntimeProfileResolver,
generateCodexAgentToml, modelOverrides and targetDir when locating where to add
the project override read-and-merge logic.
- Around line 1938-1947: The branch in generateCodexAgentToml using
runtimeResolver.resolve(resolvedName) / resolve(agentName) must be gated to only
accept mappings intended for Codex: after retrieving entry (from
runtimeResolver), verify it is a Codex mapping before writing entry.model (e.g.,
check a runtime/type flag on entry such as entry.runtime === 'codex' or validate
entry.model against the known Codex model IDs via a helper like isCodexModelId),
and skip adding model/model_reasoning_effort when the predicate fails; update
generateCodexAgentToml and add a small helper (isCodexModelId or isCodexRuntime)
and reference runtimeResolver, resolvedName, agentName, and entry.model when
implementing the guard.

In `@docs/CONFIGURATION.md`:
- Around line 615-623: The docs example is incorrect: resolveModelInternal()
intentionally skips the runtime-aware branch when runtime === "claude" and will
still return aliases unless resolve_model_ids is enabled; update the
documentation example to either set resolve_model_ids: true or show alias
results (e.g., "opus"/"sonnet"/"haiku") instead of implying full IDs like
"claude-opus-4-6". Locate the example around the Claude section and change the
JSON to include "resolve_model_ids": true if you want full Claude IDs, or adjust
the explanatory text to state that runtime: "claude" alone yields aliases per
resolveModelInternal().

In `@get-shit-done/workflows/settings.md`:
- Around line 66-76: Update the option copy for the model-profile choices
(Quality, Balanced, Budget, Adaptive, Inherit) so it matches the new note:
remove any "Claude only" language and state that tiered profiles map to
runtime-native model IDs when `runtime` is set (e.g., Codex -> gpt-5.4 /
gpt-5.3-codex / gpt-5.4-mini), otherwise profiles do not change the runtime's
default model and users should choose "Inherit" or use `model_overrides` in
.planning/config.json; ensure the model-profile descriptions reference `runtime`
and `model_overrides` consistently with the new "Runtime-Aware Profiles" note.

---

Outside diff comments:
In `@get-shit-done/bin/lib/core.cjs`:
- Around line 324-347: KNOWN_TOP_LEVEL currently omits the new top-level
container model_profile_overrides, causing valid configs to be flagged as
unknown; update the KNOWN_TOP_LEVEL set (the Set created where VALID_CONFIG_KEYS
is mapped and the additional container names are listed) to include the string
'model_profile_overrides' so that the unknownKeys filter no longer treats that
container as unexpected, and keep the existing call to
_warnUnknownProfileOverrides(parsed, '.planning/config.json') for finer
validation.

---

Nitpick comments:
In `@tests/core.test.cjs`:
- Around line 165-183: Add a focused regression that writes a config containing
a valid model_profile_overrides payload (e.g., { model_profile_overrides: {
codex: { opus: { /* valid entries */ } } } }), then call loadConfig(tmpDir) and
assert that stderr does not include the "unknown config key(s)" warning for
model_profile_overrides; reuse the same stderr capture pattern (overriding
process.stderr.write) and the helper writeConfig used in the existing loop to
ensure the specific top-level key model_profile_overrides is exercised and
doesn't spuriously trigger the unknown-key warning.

In `@tests/issue-2517-runtime-aware-profiles.test.cjs`:
- Around line 507-562: Add a new test in
tests/issue-2517-runtime-aware-profiles.test.cjs that exercises project-level
model overrides: call writeConfig(tmpDir, { runtime: 'codex', model_profile:
'quality', model_profile_overrides: { codex: { opus: { 'gsd-planner': { model:
'pinned-model' } } } } }); then obtain the resolver via
readGsdRuntimeProfileResolver(tmpDir), generate the TOML with
generateCodexAgentToml('gsd-planner', '---\nname: gsd-planner\n---\nBody.\n',
null, resolver) and assert the generated TOML includes model = "pinned-model"
(and optionally that no other precedence sources override it). This verifies
installCodexConfig()/generateCodexAgentToml honor per-project model overrides
for gsd-planner.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 948a6d48-9050-4300-850d-7089e9d7f111

📥 Commits

Reviewing files that changed from the base of the PR and between 41dc475 and 408bfc8.

📒 Files selected for processing (8)
  • bin/install.js
  • docs/CONFIGURATION.md
  • docs/USER-GUIDE.md
  • get-shit-done/bin/lib/config-schema.cjs
  • get-shit-done/bin/lib/core.cjs
  • get-shit-done/workflows/settings.md
  • tests/core.test.cjs
  • tests/issue-2517-runtime-aware-profiles.test.cjs

Comment thread bin/install.js
Comment on lines +1938 to +1947
} else if (runtimeResolver) {
// #2517 — runtime-aware tier resolution. Embeds Codex-native model + reasoning_effort
// from RUNTIME_PROFILE_MAP / model_profile_overrides for the configured tier.
const entry = runtimeResolver.resolve(resolvedName) || runtimeResolver.resolve(agentName);
if (entry?.model) {
lines.push(`model = ${JSON.stringify(entry.model)}`);
if (entry.reasoning_effort) {
lines.push(`model_reasoning_effort = ${JSON.stringify(entry.reasoning_effort)}`);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Gate this branch to Codex-only runtime mappings.

generateCodexAgentToml() will currently emit whatever runtimeResolver returns. If a user has runtime: "claude" configured and runs gsd install codex, this writes Claude IDs like claude-opus-4-6 into Codex TOML, which Codex cannot use.

Suggested guard
-  } else if (runtimeResolver) {
+  } else if (runtimeResolver?.runtime === 'codex') {
     // `#2517` — runtime-aware tier resolution. Embeds Codex-native model + reasoning_effort
     // from RUNTIME_PROFILE_MAP / model_profile_overrides for the configured tier.
     const entry = runtimeResolver.resolve(resolvedName) || runtimeResolver.resolve(agentName);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/install.js` around lines 1938 - 1947, The branch in
generateCodexAgentToml using runtimeResolver.resolve(resolvedName) /
resolve(agentName) must be gated to only accept mappings intended for Codex:
after retrieving entry (from runtimeResolver), verify it is a Codex mapping
before writing entry.model (e.g., check a runtime/type flag on entry such as
entry.runtime === 'codex' or validate entry.model against the known Codex model
IDs via a helper like isCodexModelId), and skip adding
model/model_reasoning_effort when the predicate fails; update
generateCodexAgentToml and add a small helper (isCodexModelId or isCodexRuntime)
and reference runtimeResolver, resolvedName, agentName, and entry.model when
implementing the guard.

Comment thread bin/install.js
Comment on lines 3190 to +3196
const modelOverrides = readGsdGlobalModelOverrides();
const tomlContent = generateCodexAgentToml(name, content, modelOverrides);
// Pass `targetDir` so per-project .planning/config.json wins over global
// ~/.gsd/defaults.json — without this, the PR's headline claim that
// setting runtime in the project config reaches the Codex emit path is
// false (review finding #1).
const runtimeResolver = readGsdRuntimeProfileResolver(targetDir);
const tomlContent = generateCodexAgentToml(name, content, modelOverrides, runtimeResolver);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Project-scoped model_overrides are still skipped here.

This path now honors .planning/config.json for runtime / model_profile, but modelOverrides still comes only from ~/.gsd/defaults.json. A project-level model_overrides.gsd-planner will be ignored, and the tier-resolved fallback gets embedded instead, which breaks the documented precedence chain.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/install.js` around lines 3190 - 3196, The current code only uses
readGsdGlobalModelOverrides() for modelOverrides, so project-scoped
model_overrides (e.g. model_overrides.gsd-planner) are ignored; update the flow
to first load project-level overrides for the given targetDir (e.g. via a
readGsdProjectModelOverrides(targetDir) or similar helper), merge them with the
global overrides so project values take precedence, and then pass the merged
modelOverrides into generateCodexAgentToml(name, content, modelOverrides,
runtimeResolver); ensure you reference the existing symbols
readGsdGlobalModelOverrides, readGsdRuntimeProfileResolver,
generateCodexAgentToml, modelOverrides and targetDir when locating where to add
the project override read-and-merge logic.

Comment thread docs/CONFIGURATION.md
Comment on lines +615 to +623
**Claude example** — explicit opt-in resolves to full Claude IDs (no `resolve_model_ids: true` needed):

```json
{
"runtime": "claude",
"model_profile": "quality"
}
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

The runtime: "claude" example doesn't match the current resolver.

resolveModelInternal() intentionally skips the runtime-aware branch when runtime === "claude" and still returns aliases unless resolve_model_ids is enabled. As written, this example implies runtime: "claude" alone yields full IDs like claude-opus-4-6, but the current code path still returns opus/sonnet/haiku.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/CONFIGURATION.md` around lines 615 - 623, The docs example is incorrect:
resolveModelInternal() intentionally skips the runtime-aware branch when runtime
=== "claude" and will still return aliases unless resolve_model_ids is enabled;
update the documentation example to either set resolve_model_ids: true or show
alias results (e.g., "opus"/"sonnet"/"haiku") instead of implying full IDs like
"claude-opus-4-6". Locate the example around the Claude section and change the
JSON to include "resolve_model_ids": true if you want full Claude IDs, or adjust
the explanatory text to state that runtime: "claude" alone yields aliases per
resolveModelInternal().

Comment on lines +66 to +76
Note: Quality, Balanced, Budget, and Adaptive profiles assign semantic tiers
(Opus/Sonnet/Haiku) to each agent. When `runtime` is set in .planning/config.json,
tiers resolve to runtime-native model IDs — on Codex that's gpt-5.4 / gpt-5.3-codex /
gpt-5.4-mini with appropriate reasoning effort. See "Runtime-Aware Profiles" in
docs/CONFIGURATION.md.

If `runtime` is unset on a non-Claude runtime, the profile tiers have no effect on
actual model selection — agents use the runtime's default model. Choose "Inherit" to
force session-model behavior, set `runtime` + a profile to get tiered models, or
configure `model_overrides` manually in .planning/config.json to target specific
models per agent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Update the option copy to match this new note.

The note now says tiered profiles work on Codex when runtime is set, but the model-profile choices on Lines 110-113 still describe Quality/Balanced/Budget as “Claude only” and Inherit as required for non-Claude runtimes. Text-mode users will get contradictory guidance in the same prompt.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@get-shit-done/workflows/settings.md` around lines 66 - 76, Update the option
copy for the model-profile choices (Quality, Balanced, Budget, Adaptive,
Inherit) so it matches the new note: remove any "Claude only" language and state
that tiered profiles map to runtime-native model IDs when `runtime` is set
(e.g., Codex -> gpt-5.4 / gpt-5.3-codex / gpt-5.4-mini), otherwise profiles do
not change the runtime's default model and users should choose "Inherit" or use
`model_overrides` in .planning/config.json; ensure the model-profile
descriptions reference `runtime` and `model_overrides` consistently with the new
"Runtime-Aware Profiles" note.

trek-e added a commit that referenced this pull request Apr 23, 2026
…ans and verified (closes #2492) (#2611)

* feat(#2492): add gates ensuring discuss-phase decisions are translated and verified

Two gates close the loop between CONTEXT.md `<decisions>` and downstream
work, fixing #2492:

- Plan-phase **translation gate** (BLOCKING). After requirements
  coverage, refuses to mark a phase planned when a trackable decision
  is not cited (by id `D-NN` or by 6+-word phrase) in any plan's
  `must_haves`, `truths`, or body. Failure message names each missed
  decision with id, category, text, and remediation paths.

- Verify-phase **validation gate** (NON-BLOCKING). Searches plans,
  SUMMARY.md, files modified, and recent commit subjects for each
  trackable decision. Misses are written to VERIFICATION.md as a
  warning section but do not change verification status. Asymmetry is
  deliberate — fuzzy-match miss should not fail an otherwise green
  phase.

Shared helper `parseDecisions()` lives in `sdk/src/query/decisions.ts`
so #2493 can consume the same parser.

Decisions opt out of both gates via `### Claude's Discretion` heading
or `[informational]` / `[folded]` / `[deferred]` tags.

Both gates skip silently when `workflow.context_coverage_gate=false`
(default `true`).

Closes #2492

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(#2492): make plan-phase decision gate actually block (review F1, F8, F9, F10, F15)

- F1: replace `${context_path}` with `${CONTEXT_PATH}` in the plan-phase
  gate snippet so the BLOCKING gate receives a non-empty path. The
  variable was defined in Step 4 (`CONTEXT_PATH=$(_gsd_field "$INIT" ...)`)
  and the gate snippet referenced the lowercase form, leaving the gate to
  run with an empty path argument and silently skip.
- F15: wrap the SDK call with `jq -e '.data.passed == true' || exit 1` so
  failure halts the workflow instead of being printed and ignored. The
  verify-phase counterpart deliberately keeps no exit-1 (non-blocking by
  design) and now carries an inline note documenting the asymmetry.
- F10: tag the JSON example fence as `json` and the options-list fence as
  `text` (MD040).
- F8/F9: anchor the heading-presence test regexes to `^## 13[a-z]?\\.` so
  prose substrings like "Requirements Coverage Gate" mentioned in body
  text cannot satisfy the assertion. Added two new regression tests
  (variable-name match, exit-1 guard) so a future revert is caught.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(#2492): tighten decision-coverage gates against false positives and config drift (review F3,F4,F5,F6,F7,F16,F18,F19)

- F3: forward `workstream` arg through both gate handlers so workstream-scoped
  `workflow.context_coverage_gate=false` actually skips. Added negative test
  that creates a workstream config disabling the gate while the root config
  has it enabled and asserts the workstream call is skipped.
- F4: restrict the plan-phase haystack to designated sections — front-matter
  `must_haves` / `truths` / `objective` plus body sections under headings
  matching `must_haves|truths|tasks|objective`. HTML comments and fenced
  code blocks are stripped before extraction so a commented-out citation or
  a literal example never counts as coverage. Verify-phase keeps the broader
  artifact-wide haystack by design (non-blocking).
- F5: reject decisions with fewer than 6 normalized words from soft-matching
  (previously only rejected when the resulting phrase was under 12 chars
  AFTER slicing — too lenient). Short decisions now require an explicit
  `D-NN` citation, with regression tests for the boundary.
- F6: walk every `*-SUMMARY.md` independently and use `matchAll` with the
  `/g` flag so multiple `files_modified:` blocks across multiple summaries
  are all aggregated. Previously only the first block in the concatenated
  string was parsed, silently dropping later plans' files.
- F7: validate every `files_modified` path stays inside `projectDir` after
  resolution (rejects absolute paths, `../` traversal). Cap each file read
  at 256 KB. Skipped paths emit a stderr warning naming the entry.
- F16: validate `workflow.context_coverage_gate` is boolean in
  `loadGateConfig`; warn loudly on numeric or other-shaped values and
  default to ON. Mirrors the schema-vs-loadConfig validation gap from
  #2609.
- F18: bump verify-phase `git log -n` cap from 50 to 200 so longer-running
  phases are not undercounted. Documented as a precision-vs-recall tradeoff
  appropriate for a non-blocking gate.
- F19: tighten `QueryResult` / `QueryHandler` to be parameterized
  (`<T = unknown>`). Drops the `as unknown as Record<string, unknown>`
  casts in the gate handlers and surfaces shape mismatches at compile time
  for callers that pass a typed `data` value.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(#2492): harden decisions parser and verify-phase glob (review F11,F12,F13,F14,F17,F20)

- F11: strip fenced code blocks from CONTEXT.md before searching for
  `<decisions>` so an example block inside ``` ``` is not mis-parsed.
- F12: accept tab-indented continuation lines (previously required a leading
  space) so decisions split with `\t` continue cleanly.
- F13: parse EVERY `<decisions>` block in the file via `matchAll`, not just
  the first. CONTEXT.md may legitimately carry more than one block.
- F14: `decisions.parse` handler now resolves a relative path against
  `projectDir` — symmetric with the gate handlers — and still accepts
  absolute paths.
- F17: replace `ls "${PHASE_DIR}"/*-CONTEXT.md | head -1` in verify-phase.md
  with a glob loop (ShellCheck SC2012 fix). Also avoids spawning an extra
  subprocess and survives filenames with whitespace.
- F20: extend the unicode quote-stripping in the discretion-heading match
  to cover U+2018/2019/201A/201B and the U+201C-F double-quote variants
  plus backtick, so any rendering of "Claude's Discretion" collapses to
  the same key.

Each fix has a regression test in `decisions.test.ts`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make model profiles runtime-aware for Codex/non-Claude runtimes

1 participant