- Status: active
- Source of truth:
.spec2flow/runtime/model-adapter-runtime.json,docs/examples/synapse-network/model-adapter-runtime.json,packages/cli/src/adapters/adapter-runtime-resolver.ts,packages/cli/src/adapters/copilot-preflight.ts,packages/cli/src/adapters/adapter-runner.ts,schemas/model-adapter-runtime.schema.json - Verified with:
npm run build,npm run test:unit,npm run validate:docs - Last verified: 2026-03-25
Keep one stable reference for model-adapter-runtime.json so runtime wiring, provider overrides, session policy, and controller-injected environment variables do not drift across multiple docs.
- top-level
adapterRuntimefields - bundled Copilot runtime defaults
- deterministic stage delegation through
stageRuntimeRefs - environment variables used by the bundled runtimes
- which fields should usually stay unchanged
- which fields are normal override points
model-adapter-runtime.json tells Spec2Flow how to execute one claimed task through an external adapter command or a delegated deterministic runtime.
Minimal shape:
{
"adapterRuntime": {
"name": "github-copilot-cli-adapter",
"provider": "github-copilot-cli",
"command": "node",
"args": [
"docs/examples/synapse-network/example-command-adapter.mjs",
"--claim",
"${claimPath}"
],
"outputMode": "stdout"
}
}Use this as the smallest practical starting point when a repository wants one provider-backed runtime without stage-specific delegation:
{
"adapterRuntime": {
"name": "github-copilot-cli-adapter",
"provider": "github-copilot-cli",
"model": "gpt-5.4",
"command": "node",
"args": [
"docs/examples/synapse-network/example-command-adapter.mjs",
"--claim",
"${claimPath}"
],
"cwd": ".",
"env": {
"SPEC2FLOW_COPILOT_CWD": ".",
"SPEC2FLOW_COPILOT_SESSION_KEY": "${specialistSessionKey}",
"SPEC2FLOW_COPILOT_SESSION_DIR": ".spec2flow/runtime/copilot-sessions",
"SPEC2FLOW_STATE": "${statePath}",
"SPEC2FLOW_TASK_GRAPH": "${taskGraphPath}",
"SPEC2FLOW_TASK_ID": "${taskId}",
"SPEC2FLOW_RUN_ID": "${runId}"
},
"timeoutMs": 1200000,
"outputMode": "stdout"
}
}Keep this version simple first. Add stageRuntimeRefs, permission flags, or persistence overrides only when the repository actually needs them.
Human-readable runtime id used in logs, receipts, and debugging output.
Default guidance:
- keep it stable
- change it only when you are intentionally defining a different runtime identity
Declares which provider-specific policy and preflight path apply.
Common values in this repository:
github-copilot-clispec2flow-deterministic
Default guidance:
- do not change this unless the adapter command is really targeting a different provider surface
Optional model pin for provider-backed runtimes.
Default guidance:
- leave unset if provider default selection is safer for the target account
- set it only when you need a fixed model such as
gpt-5.4
Executable that Spec2Flow launches.
Bundled examples use:
node
Default guidance:
- change this only when the adapter is launched through a different executable
Arguments passed to the command.
Bundled Copilot runtime uses:
- adapter script path
--claim${claimPath}
Default guidance:
- treat this as the adapter entry contract
- change it only when the external adapter command surface changes
Working directory for the adapter process.
Default guidance:
- keep this explicit when the adapter depends on relative paths
- if omitted, ensure the adapter command is still correct from the calling directory
Template-expanded environment variables passed into the adapter process.
This is the main override surface for:
- provider behavior
- session reuse scope
- controller-to-adapter path wiring
- permission flags
Default guidance:
- do not treat all env keys as user-tunable
- some are normal override points and some are controller-owned internal wiring
Maximum execution time for one claimed task.
Default guidance:
- keep the default unless a real task class routinely exceeds it
- increase only with a concrete execution need
How the adapter returns its normalized result.
Bundled runtimes use:
stdout
Default guidance:
- leave unchanged unless the adapter contract changes
Optional per-stage runtime overrides.
This lets one top-level runtime file delegate selected stages to another runtime file.
Bundled self-dogfood runtime uses this for:
environment-preparationautomated-execution
Default guidance:
- use this only when some stages should bypass the default provider runtime
- keep one top-level runtime file as the main loop entrypoint
The repository's default self-dogfood runtime is .spec2flow/runtime/model-adapter-runtime.json.
Its operating model is:
- provider-backed by default through Copilot CLI
- deterministic override for
environment-preparation - deterministic override for
automated-execution - specialist-scoped session reuse by default
- cleanup-safe session persistence by default
- file writes and test runs allowed
- git write side effects disabled
- PR creation disabled
The example runtime at docs/examples/synapse-network/model-adapter-runtime.json is intentionally smaller. It demonstrates the external adapter contract without carrying the repository's full self-dogfood permission surface.
Use the self-dogfood runtime at .spec2flow/runtime/model-adapter-runtime.json when you want the repository's full operating model:
- deterministic delegation for
environment-preparationandautomated-execution - repository policy flags for writes, test runs, git writes, and PR creation
- the exact runtime shape used by Spec2Flow to dogfood itself
Use the example runtime at docs/examples/synapse-network/model-adapter-runtime.json when you want a smaller adoption template:
- one provider-backed runtime without the full self-dogfood policy surface
- clearer starting material for another repository to copy and simplify
- fewer repository-specific defaults to explain or remove
Environment keys fall into three categories:
- provider configuration
- session configuration
- controller-injected internal wiring
Effective model passed into the adapter.
Default guidance:
- prefer setting
adapterRuntime.model - do not usually edit this env directly in repository runtimes
Optional adapter display-name override.
Default guidance:
- leave unset unless you need to distinguish multiple similar adapter wrappers in receipts or logs
Working directory that Copilot CLI should use.
Default guidance:
- keep aligned with
adapterRuntime.cwd - override only when the adapter must run against a different repository root
Declares the session reuse scope.
Bundled default:
${specialistSessionKey}
What that means:
- one durable session per specialist agent name
requirements-agent,implementation-agent,test-design-agent,execution-agent,defect-agent, andcollaboration-agentreuse their own stable session identities
Default guidance:
- keep the bundled default unless you have a concrete isolation requirement
Override choices exposed by the adapter template context:
${specialistSessionKey}${runSessionKey}${routeSessionKey}${stageSessionKey}${executorSessionKey}${routeExecutorSessionKey}${taskSessionKey}
Use them this way:
${specialistSessionKey}: built-in default and correct for most repositories${executorSessionKey}: under the defaultautomode it is canonicalized back to the stable specialist session, so usealwaysonly when you intentionally want durable run-scoped separation${routeExecutorSessionKey}: under the defaultautomode it is canonicalized back to the stable specialist session, so usealwaysonly when you intentionally want durable route-level separation${taskSessionKey}: use only when maximum isolation is worth the extra session churn
Explicit session id override.
Default guidance:
- leave unset for normal operation
- use only when you intentionally want to attach the adapter to one already-known provider session id
Directory where durable session records are stored.
Bundled default:
.spec2flow/runtime/copilot-sessions
Default guidance:
- keep it stable so cleanup and migration tooling can find it
- change it only when you intentionally relocate the session store
Optional persistence-policy override.
Built-in default behavior:
- no explicit env is required
- stable specialist keys persist
- dynamic multi-part keys are canonicalized to the stable specialist session key instead of spawning new durable run-scoped sessions
Preflight behavior:
- successful Copilot preflight results are cached per runtime fingerprint for 15 minutes under
.spec2flow/runtime/copilot-preflight-cache - repeated workflow runs against the same runtime reuse the cached pass result and skip the extra
pwdprobe session during that cache window
Override guidance:
- do not set this for normal operation
- set
alwaysonly when you explicitly want durable dynamic keys - set
neveronly when you explicitly want all session records suppressed
These variables are controller-owned. They are not normal business-facing configuration knobs.
Path to the active execution-state.json for the claimed task.
Path to the active task-graph.json for the claimed task.
Current claimed task id.
Current workflow run id.
Default guidance for all four:
- do not hard-code them by hand in normal runtime authoring
- let Spec2Flow inject them from
${statePath},${taskGraphPath},${taskId}, and${runId}
These flags are repository-policy controls, not generic provider settings.
Whether the adapter may edit repository files.
Bundled default:
true
Use this when:
- code or test stages are expected to write files
Whether the adapter may execute repository validation commands.
Bundled default:
true
Use this when:
- the runtime is allowed to run controller-approved validation commands
Whether the adapter may perform write-side git actions.
Bundled default:
false
Default guidance:
- keep
falseunless the repository explicitly wants adapters to create commits or similar side effects
Whether the adapter may create pull requests directly.
Bundled default:
false
Default guidance:
- keep
falseunless the repository explicitly wants runtime-side PR creation
Use this rule of thumb:
- change
adapterRuntime.modelwhen you want a different model - change
SPEC2FLOW_COPILOT_SESSION_KEYonly when you want a different reuse scope - add
SPEC2FLOW_COPILOT_SESSION_PERSIST_MODEonly when you want to override the built-in cleanup-safe default - change
stageRuntimeRefswhen some stages should use a different runtime implementation - change permission flags only when the repository's automation policy changes
- leave controller-injected path variables alone