#5167·gsd-core

enhancement(capability): let runtime-identity queries read overlay-installed `role: "runtime"` capabilities

Author: gremlinopsCreated Oct 1, 2026Updated Oct 1, 2026
Labelsenhancementneeds-reviewneeds-triage

Pre-submission checklist

  • I have confirmed this improves existing behavior — it does not add a new command, workflow, or concept
  • I have searched existing issues and this enhancement has not already been proposed
  • I have read CONTRIBUTING.md and understand I must wait for approved-enhancement before writing any code
  • I can clearly describe the concrete benefit — not just "it would be nicer"

What existing feature or behavior does this improve?

The ADR-1244 capability overlay (gsd-tools capability install), for third-party role: "runtime" capabilities: the runtime-identity queries in gsd-tools (dispatch-capacity, dispatch-isolation, dispatch-should-flatten, resolve-dispatch-type) and the project-instruction-file lookup in runtime-name-policy (used by project-instruction-file, generate-claude-md and generate-claude-profile)

Current behavior

The overlay accepts a third-party role: "runtime" capability, and the merged registry contains it. But the runtime-identity code paths require('./capability-registry.cjs') directly, so they read only the first-party runtimes frozen at build time. The installed runtime is ignored.

.out-of-scope/kiro-runtime-in-core.md describes this route as live ("a third-party capability, including role: "runtime", can be installed from outside gsd-core's own tree … This is a live mechanism today"). In 1.15.0 it is accepted but has no effect on runtime identity.

Reproduction (1.15.0 from npm, temp HOME):

bash
B=$(mktemp -d) && mkdir -p "$B/home" "$B/ws" "$B/src/example-host"
GSD=/path/to/node_modules/@opengsd/gsd-core   # an installed copy of 1.15.0
node -e "
const fs=require('fs');
const d=structuredClone(require('$GSD/gsd-core/bin/lib/capability-registry.cjs').capabilities.windsurf);
Object.assign(d,{id:'example-host',title:'Example host',version:'0.0.1',tier:'full'});
d.runtime.hostIntegration.dispatch.maxConcurrency=4;
fs.writeFileSync('$B/src/example-host/capability.json',JSON.stringify(d,null,2));"
cd "$B/ws"
HOME="$B/home" node "$GSD/gsd-core/bin/gsd-tools.cjs" capability install "$B/src/example-host" --global
HOME="$B/home" node -e "const L=require('$GSD/gsd-core/bin/lib/capability-loader.cjs');const r=L.loadRegistry({includeInstalled:true});console.log(Boolean(r.runtimes['example-host']))"
# -> true   (the merged registry has the runtime)
HOME="$B/home" GSD_RUNTIME=example-host node "$GSD/gsd-core/bin/gsd-tools.cjs" query dispatch-capacity --json
# -> { "runtime": "example-host", "capacity": 1, "declared": null, "source": "fallback", "reason": "unknown_runtime" }

Expected "capacity": 4, "source": "descriptor", from the installed descriptor.

Proposed behavior

When a runtime-identity lookup misses the frozen first-party map and has a project cwd, it asks the composed registry (first-party ∪ accepted overlay) for that runtime id. The overlay's existing rules apply unchanged: validation, consent for project scope, first-party wins on an id collision. With the reproduction above, dispatch-capacity returns capacity: 4, source: "descriptor"; the other three dispatch queries and the project instruction file use the installed descriptor's declared values.

First-party lookups are unchanged and do no extra I/O: the frozen map answers them before the overlay is consulted. Lookups without a cwd keep reading first-party only, which matches the existing convention in src/config-schema.cts. No caching, so a long-lived process (for example the MCP server) sees capability install / remove on its next lookup.

Reason and benefit

  • ADR-1239 points new hosts to out-of-tree host plugins, and the out-of-scope records point them to ADR-1244's third-party role: "runtime" route. Today a host plugin can install a descriptor, but GSD still reports unknown_runtime for that host. That gives fail-closed answers that the host's descriptor contradicts (for example, dispatch capacity 1 where the host runs 4 subagents in parallel), and it leaves workflows such as quick-batch and chunked planning at their slowest path.
  • It closes the gap without adding any runtime to gsd-core's own tree, which keeps the standing out-of-scope policy intact.
  • Concrete case: I am building an EoS host plugin for the Atlassian Rovo CLI. Its descriptor declares the host's verified axes (named dispatch, flat, parallel up to 4, no isolation). With this change, gsd-tools would use them instead of the fallback.

Scope of changes

Files modified:

  • src/capability-loader.cts — new exported findInstalledRuntime(id, cwd): the runtime descriptor from loadRegistry({ includeInstalled: true, cwd, gsdHome }), or undefined; never throws.
  • gsd-core/bin/gsd-tools.cjs — routeDispatchShouldFlatten, routeDispatchCapacity, resolveDispatchIsolationDecision, routeResolveDispatchType: on a first-party miss, fall back to findInstalledRuntime(runtimeId, cwd). routeProjectInstructionFile passes cwd.
  • src/runtime-name-policy.cts — getProjectInstructionFile(runtime, cwd?): optional cwd; an installed runtime is looked up by its normalized id (it has no alias entry). Docstring updated: still no I/O unless cwd is given and the runtime is not first-party. canonicalizeRuntimeName is unchanged (resolveRuntimeNameFromCandidates already passes unknown names through).
  • src/profile-output.cts — the three getProjectInstructionFile calls pass cwd.
  • tests/overlay-runtime-identity.test.cjs (new) — installs a role: "runtime" capability with the real capability install into a temp GSD_HOME and asserts each lookup above returns the declared value, with an exact first-party-fallback counter-case for each; generate-claude-md writes the declared file; plus trust rules (a project-scoped runtime counts only once installed with consent, not when placed on disk; a valid hand-placed global manifest is accepted and an invalid one ignored; a registry generator failure drops the runtime without crashing).
  • .changeset/<generated>.md — one Added fragment via npm run changeset once the PR number exists.

Not in scope (unchanged, first-party only):

  • Installer-side reads (runtime-config-adapter-registry, runtime-artifact-layout, agent-install-check, installed-surface-resolver, commands, resolveSharedHooksDirCandidates): an out-of-tree host plugin does its own install.
  • Slash-command formatting (formatGsdSlash): its ~39 production call sites have no cwd in their signature, so wiring the overlay through them is a wider change than this one. A host whose command style is the default /gsd-x is not affected; a follow-up can thread cwd through if needed.
  • getDirName and getGlobalConfigDir (runtime-homes): they locate a runtime's config home, which for an EoS host is owned by the host plugin, not by gsd-core; widening them would let an overlay redirect where gsd-core reads and writes.

No new dependencies. No new modules.

Breaking changes

None. With no role: "runtime" capability installed, every changed lookup returns exactly what it returns today. First-party runtime ids cannot be shadowed by an overlay. New cwd parameters are optional.

Alternatives considered

  • Add each new host to capabilities/ in-tree. Rejected by the standing policy (.out-of-scope/*-runtime-in-core.md).
  • Environment overrides only (GSD_DISPATCH_MAX_CONCURRENCY, GSD_RUNTIME). These cover one value each, and a host plugin often cannot set environment variables for the sessions its host starts.
  • Host plugins patching their installed copy of capability-registry.cjs. Works, but every plugin then patches generated code on every gsd-core release. The overlay already exists for this.

Area affected

Runtime integration (hooks, statusline, settings)

Additional context

  • I volunteer to implement this, with tests, once it carries approved-enhancement. I will keep to the scope above and ask for re-approval if it changes.
  • To check that the scope is right, I made a local prototype on next. It passes the new tests and the existing tests of every file it touches. I will not open a PR until this is approved, and I am happy to change the approach based on review.
  • Related: ADR-1244 (overlay), ADR-1016 (runtime descriptor), ADR-1239 (EoS), #1431, .out-of-scope/kiro-runtime-in-core.md.