specrails-core 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/agent-runtime/capabilities.d.ts +27 -0
  2. package/dist/agent-runtime/capabilities.js +73 -0
  3. package/dist/agent-runtime/capabilities.js.map +1 -0
  4. package/dist/agent-runtime/cli-executor.d.ts +9 -0
  5. package/dist/agent-runtime/cli-executor.js +100 -30
  6. package/dist/agent-runtime/cli-executor.js.map +1 -1
  7. package/dist/agent-runtime/cli.d.ts +1 -0
  8. package/dist/agent-runtime/cli.js +59 -11
  9. package/dist/agent-runtime/cli.js.map +1 -1
  10. package/dist/agent-runtime/codex-schema.d.ts +4 -0
  11. package/dist/agent-runtime/codex-schema.js +31 -0
  12. package/dist/agent-runtime/codex-schema.js.map +1 -0
  13. package/dist/agent-runtime/config.d.ts +4 -0
  14. package/dist/agent-runtime/config.js +110 -9
  15. package/dist/agent-runtime/config.js.map +1 -1
  16. package/dist/agent-runtime/core-host.d.ts +9 -1
  17. package/dist/agent-runtime/core-host.js +55 -20
  18. package/dist/agent-runtime/core-host.js.map +1 -1
  19. package/dist/agent-runtime/efficiency-summary.d.ts +67 -0
  20. package/dist/agent-runtime/efficiency-summary.js +52 -0
  21. package/dist/agent-runtime/efficiency-summary.js.map +1 -0
  22. package/dist/agent-runtime/efficiency-types.d.ts +60 -0
  23. package/dist/agent-runtime/efficiency-types.js +8 -0
  24. package/dist/agent-runtime/efficiency-types.js.map +1 -0
  25. package/dist/agent-runtime/efficiency.d.ts +5 -0
  26. package/dist/agent-runtime/efficiency.js +35 -0
  27. package/dist/agent-runtime/efficiency.js.map +1 -0
  28. package/dist/agent-runtime/evaluation-corpus.d.ts +13 -0
  29. package/dist/agent-runtime/evaluation-corpus.js +8 -0
  30. package/dist/agent-runtime/evaluation-corpus.js.map +1 -0
  31. package/dist/agent-runtime/evaluation.d.ts +43 -0
  32. package/dist/agent-runtime/evaluation.js +171 -0
  33. package/dist/agent-runtime/evaluation.js.map +1 -0
  34. package/dist/agent-runtime/executor-types.d.ts +35 -2
  35. package/dist/agent-runtime/executor-types.js.map +1 -1
  36. package/dist/agent-runtime/executors.d.ts +1 -0
  37. package/dist/agent-runtime/executors.js +4 -0
  38. package/dist/agent-runtime/executors.js.map +1 -1
  39. package/dist/agent-runtime/graph/artifacts.d.ts +8 -22
  40. package/dist/agent-runtime/graph/artifacts.js +99 -73
  41. package/dist/agent-runtime/graph/artifacts.js.map +1 -1
  42. package/dist/agent-runtime/graph/nodes.d.ts +3 -0
  43. package/dist/agent-runtime/graph/nodes.js +73 -26
  44. package/dist/agent-runtime/graph/nodes.js.map +1 -1
  45. package/dist/agent-runtime/graph/roles.d.ts +4 -1
  46. package/dist/agent-runtime/graph/roles.js +100 -36
  47. package/dist/agent-runtime/graph/roles.js.map +1 -1
  48. package/dist/agent-runtime/graph/state.d.ts +8 -0
  49. package/dist/agent-runtime/graph/state.js.map +1 -1
  50. package/dist/agent-runtime/index.d.ts +7 -1
  51. package/dist/agent-runtime/index.js +7 -1
  52. package/dist/agent-runtime/index.js.map +1 -1
  53. package/dist/agent-runtime/kimi-acp.d.ts +4 -0
  54. package/dist/agent-runtime/kimi-acp.js +20 -9
  55. package/dist/agent-runtime/kimi-acp.js.map +1 -1
  56. package/dist/agent-runtime/openai-executor.d.ts +8 -0
  57. package/dist/agent-runtime/openai-executor.js +28 -10
  58. package/dist/agent-runtime/openai-executor.js.map +1 -1
  59. package/dist/agent-runtime/openspec-tool-server.d.ts +1 -0
  60. package/dist/agent-runtime/openspec-tool-server.js +37 -0
  61. package/dist/agent-runtime/openspec-tool-server.js.map +1 -0
  62. package/dist/agent-runtime/openspec.d.ts +123 -0
  63. package/dist/agent-runtime/openspec.js +263 -0
  64. package/dist/agent-runtime/openspec.js.map +1 -0
  65. package/dist/agent-runtime/prompts.d.ts +5 -1
  66. package/dist/agent-runtime/prompts.js +59 -40
  67. package/dist/agent-runtime/prompts.js.map +1 -1
  68. package/dist/agent-runtime/provider-diagnostic.d.ts +2 -0
  69. package/dist/agent-runtime/provider-diagnostic.js +25 -0
  70. package/dist/agent-runtime/provider-diagnostic.js.map +1 -0
  71. package/dist/agent-runtime/repository-context.d.ts +25 -0
  72. package/dist/agent-runtime/repository-context.js +100 -0
  73. package/dist/agent-runtime/repository-context.js.map +1 -0
  74. package/dist/agent-runtime/review-context.d.ts +14 -0
  75. package/dist/agent-runtime/review-context.js +41 -0
  76. package/dist/agent-runtime/review-context.js.map +1 -0
  77. package/dist/agent-runtime/role-routing.d.ts +10 -0
  78. package/dist/agent-runtime/role-routing.js +29 -0
  79. package/dist/agent-runtime/role-routing.js.map +1 -0
  80. package/dist/agent-runtime/role-state.d.ts +19 -0
  81. package/dist/agent-runtime/role-state.js +24 -0
  82. package/dist/agent-runtime/role-state.js.map +1 -0
  83. package/dist/agent-runtime/runtime-identity.d.ts +11 -0
  84. package/dist/agent-runtime/runtime-identity.js +33 -0
  85. package/dist/agent-runtime/runtime-identity.js.map +1 -0
  86. package/dist/agent-runtime/tool-event.d.ts +3 -0
  87. package/dist/agent-runtime/tool-event.js +24 -0
  88. package/dist/agent-runtime/tool-event.js.map +1 -0
  89. package/dist/agent-runtime/verification-plan.d.ts +55 -0
  90. package/dist/agent-runtime/verification-plan.js +206 -0
  91. package/dist/agent-runtime/verification-plan.js.map +1 -0
  92. package/dist/agent-runtime/workflow-types.d.ts +17 -1
  93. package/dist/agent-runtime/workflow.js +28 -1
  94. package/dist/agent-runtime/workflow.js.map +1 -1
  95. package/dist/agent-runtime/workspace-tools.d.ts +4 -0
  96. package/dist/agent-runtime/workspace-tools.js +182 -20
  97. package/dist/agent-runtime/workspace-tools.js.map +1 -1
  98. package/dist/installer/phases/scaffold.js +39 -109
  99. package/dist/installer/phases/scaffold.js.map +1 -1
  100. package/dist/installer/runtime/pipeline-state.d.ts +142 -1
  101. package/dist/installer/runtime/pipeline-state.js +477 -28
  102. package/dist/installer/runtime/pipeline-state.js.map +1 -1
  103. package/docs/agent-runtime-efficiency.md +65 -0
  104. package/docs/agent-runtime.md +86 -15
  105. package/integration-contract.json +2 -1
  106. package/package.json +5 -2
  107. package/schemas/agent-runtime.schema.json +25 -3
  108. package/schemas/fixtures/runtime-efficiency-summary.v1.json +790 -0
  109. package/templates/codex-skills/batch-implement/SKILL.md +33 -58
  110. package/templates/codex-skills/implement/SKILL.md +21 -124
  111. package/templates/codex-skills/retry/SKILL.md +8 -34
  112. package/templates/commands/specrails/batch-implement.md +21 -16
  113. package/templates/commands/specrails/implement.md +17 -276
  114. package/templates/commands/specrails/retry.md +6 -34
  115. package/templates/gemini-commands/batch-implement.toml +34 -28
  116. package/templates/gemini-commands/implement.toml +34 -55
  117. package/templates/gemini-commands/retry.toml +10 -16
@@ -1,291 +1,32 @@
1
- # Implementation Pipeline
1
+ # Programmatic implementation
2
2
 
3
- Implement one feature or a batch as one frozen candidate: architect designs, developer implements, reviewer validates, then the coordinator authorizes archive and delivery. Reuse completed phases only when the executable journal confirms current evidence.
3
+ Implement the requested spec or batch through the installed agent runtime. The runtime owns architecture, development, verification, review and archive; do not delegate these phases yourself or launch a second coordinator.
4
4
 
5
- **Input:** $ARGUMENTS: ticket references (`#85, #71`), a feature description, area names to explore before selecting scope, `--dry-run`/`--preview`, or `--apply <change>`.
5
+ ## Freeze the requested scope
6
6
 
7
- ## Execution scope and ownership (read first)
7
+ Use the supplied absolute `SPECRAILS_EXECUTION_CONTEXT` unchanged. It defines runId, specs and acceptance criteria, artifactRoot, selected repositories and ownership. For standalone use, admit the exact requested tickets once with:
8
8
 
9
- Use the installed runtime `node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}"`, never an assumed global/downloaded substitute. `SPECRAILS_EXECUTION_CONTEXT` identifies the authoritative schemaVersion 1 context: runId, frozen specs[] with acceptance criteria, backlogRoot/backlogPath, artifactRoot/artifactRepositoryId, selected repositories[] and ownership. Do not refetch tickets to replace this scope.
10
-
11
- The working directory may be a framework workspace. Set `SPECRAILS_REPO_DIR` to artifactRoot for `${SPECRAILS_REPO_DIR:-.}/openspec/changes/<change>/`. Source edits and tests use the explicit selected repository ID/path; secondary tasks never default to the artifact root. Backlog belongs to backlogPath, independently of source roots.
12
-
13
- Inspect ownership **before any mutation**:
14
- - Host-owned worktrees: use supplied roots; no nested allocation, merge, deletion or reconstruction.
15
- - Host-owned git: no staging, commits, pushes, PRs or shipping CI; return the candidate for host delivery.
16
- - Host-owned backlog: no closing tickets/status writes; host acceptance owns completion.
17
- - Core ownership permits only operations authorized by the user/settings. Preview or false GIT_AUTO disables shipping regardless. Never change permissions or forge context to bypass ownership.
18
-
19
- Give every worker the absolute runtime/context paths, exact change, selected roots and frozen task group. Include env in each invocation; exports do not persist across tools. Workers stay foreground and must return terminal results. A background task start, summary or empty final message is not completion evidence.
20
-
21
- ### Standalone admission
22
-
23
- Without host context, choose one stable aggregate change and freeze requested tickets once:
24
-
25
- ```bash
26
- node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}" init --change <change> --tickets "85,71"
27
- ```
28
-
29
- Optional `--backlog-path <absolute-file>` selects a file under the workspace. Freeform/selected proposals use `--scope-request <absolute-file>` containing `{"specs":[{"id":"feature","title":"...","description":"...","acceptanceCriteria":["..."]}],"ownership":{"git":"host","backlog":"host","worktrees":"host"}}`. Populate real user requirements; never invent a ticket or discard scope. Complete multi-repository standalone scope uses `--context <absolute-file>`.
30
-
31
- Default fallback ownership is review-only. An explicitly authorized Core ownership request may accompany --tickets without a specs field. After init, run status and pass the returned absolute stateDir/context.json to every child/retry as SPECRAILS_EXECUTION_CONTEXT. Same-change init preserves progress and original scope; another change creates a new run. Never select the most recently modified artifact directory or use old ad-hoc state as authority.
32
-
33
- ## Phase 0: Preflight
34
-
35
- 1. Read supplied context or perform standalone admission. Resolve --apply to its existing journal; never silently initialize a missing preview.
36
- 2. Confirm Node, Git, managed runtime, official OpenSpec commands/skills and project dependencies. Missing required tooling stops with a concrete repair command. Do not emulate missing skills or silently install an unpinned global.
37
- 3. Inspect dependencies and CI commands once per selected repo; relevant package/config changes invalidate assumptions.
38
- 4. Resolve the profile below and honor host model/effort/custom roles.
39
- 5. Read `status --json`: a completed valid phase requires no new model call; blocked/failed phases are resumable and dependents remain pending.
40
-
41
- #### 5. Agent discovery
42
-
43
- `AVAILABLE_AGENTS` resolves through a single path: **a profile if one is active, otherwise the baseline trio**. There are no modes — the baseline is just the default value the resolution falls back to when no profile is present.
44
-
45
- ##### Resolve the profile path
46
-
47
- A profile is active when either condition holds (highest precedence first):
48
-
49
- 1. `SPECRAILS_PROFILE_PATH` is set AND points to a readable file. Tools like `specrails-desktop` set this to a job-scoped snapshot.
50
- 2. `.specrails/profiles/project-default.json` exists and is readable.
51
-
52
- ```bash
53
- if [[ -n "${SPECRAILS_PROFILE_PATH:-}" && -r "${SPECRAILS_PROFILE_PATH:-}" ]]; then
54
- PROFILE_PATH="$SPECRAILS_PROFILE_PATH"
55
- elif [[ -r ".specrails/profiles/project-default.json" ]]; then
56
- PROFILE_PATH=".specrails/profiles/project-default.json"
57
- else
58
- PROFILE_PATH=""
59
- fi
60
- ```
61
-
62
- ##### No profile → baseline default
63
-
64
- When `PROFILE_PATH` is empty, `AVAILABLE_AGENTS` is the baseline trio and there are no per-agent model overrides (each agent uses the `model:` in its own `.md` frontmatter). No profile file is written — the baseline is an in-memory default, honoring the reserved-paths contract (`.specrails/profiles/**` is never created by the pipeline):
65
-
66
- ```bash
67
- if [[ -z "$PROFILE_PATH" ]]; then
68
- AVAILABLE_AGENTS="$(printf '%s\n' sr-architect sr-developer sr-reviewer)"
69
- PROFILE_NAME=""
70
- fi
71
- ```
72
-
73
- ##### Profile present → load, validate, populate
74
-
75
- `jq` is required to read a profile JSON:
76
-
77
- ```bash
78
- command -v jq >/dev/null 2>&1 || { echo "[error] 'jq' is required to read a profile. Install with: brew install jq / apt install jq / https://stedolan.github.io/jq/"; exit 1; }
79
- PROFILE="$(cat "$PROFILE_PATH")"
80
- ```
81
-
82
- Validate the schema version. Only `schemaVersion: 1` is supported:
83
-
84
- ```bash
85
- SCHEMA_VERSION="$(jq -r '.schemaVersion // empty' <<<"$PROFILE")"
86
- case "$SCHEMA_VERSION" in
87
- 1) ;;
88
- "") echo "[error] profile validation failed: missing required field 'schemaVersion'"; exit 1 ;;
89
- *) echo "[error] profile validation failed: unsupported schemaVersion '$SCHEMA_VERSION'. Supported: 1"; exit 1 ;;
90
- esac
91
- ```
92
-
93
- Validate required top-level fields. Every valid v1 profile MUST contain `name`, `orchestrator.model`, `agents` (non-empty array), and `routing` (non-empty array):
94
-
95
- ```bash
96
- for field in name orchestrator agents routing; do
97
- jq -e ".$field" <<<"$PROFILE" >/dev/null 2>&1 || { echo "[error] profile validation failed: missing required field '$field'"; exit 1; }
98
- done
99
- jq -e '.orchestrator.model' <<<"$PROFILE" >/dev/null 2>&1 || { echo "[error] profile validation failed: missing required field 'orchestrator.model'"; exit 1; }
100
- jq -e '.agents | length > 0' <<<"$PROFILE" >/dev/null 2>&1 || { echo "[error] profile validation failed: 'agents' must be a non-empty array"; exit 1; }
101
- jq -e '.routing | length > 0' <<<"$PROFILE" >/dev/null 2>&1 || { echo "[error] profile validation failed: 'routing' must be a non-empty array"; exit 1; }
102
- ```
103
-
104
- Validate baseline agents — `sr-architect`, `sr-developer`, and `sr-reviewer` MUST appear in `agents[]`:
105
-
106
- ```bash
107
- for required in sr-architect sr-developer sr-reviewer; do
108
- jq -e --arg id "$required" '[.agents[].id] | index($id)' <<<"$PROFILE" >/dev/null 2>&1 \
109
- || { echo "[error] profile validation failed: required baseline agent '$required' missing from 'agents[]'"; exit 1; }
110
- done
9
+ ```sh
10
+ node .specrails/runtime/pipeline.mjs init --change <stable-change> --tickets "<requested-ids>"
111
11
  ```
112
12
 
113
- Validate routing terminal rule exactly one entry SHALL have `default: true` and it MUST be the last element:
114
-
115
- ```bash
116
- DEFAULT_COUNT="$(jq '[.routing[] | select(.default == true)] | length' <<<"$PROFILE")"
117
- if [[ "$DEFAULT_COUNT" -ne 1 ]]; then
118
- echo "[error] profile validation failed: routing must contain exactly one entry with 'default: true' (found $DEFAULT_COUNT)"; exit 1
119
- fi
120
- IS_LAST="$(jq '(.routing | last | .default) == true' <<<"$PROFILE")"
121
- if [[ "$IS_LAST" != "true" ]]; then
122
- echo "[error] profile validation failed: the 'default: true' routing rule must be the last element of 'routing'"; exit 1
123
- fi
124
- ```
13
+ For a free-form request use `--scope-request <absolute-json>` with the user's specs and criteria. Use the returned absolute context path. Never select a different run by modification time or replace scope from mutable backlog. Multiple tickets share one aggregate context and one runtime invocation.
125
14
 
126
- Populate `AVAILABLE_AGENTS` from the profile. The three baseline agents are **hard-required**: if a baseline agent's file is missing, STOP. A **non-baseline** agent whose file is missing is **warned and skipped** — this is how a pre-v5 profile that still references a removed agent (e.g. `sr-frontend-developer`) degrades gracefully:
15
+ ## Execute
127
16
 
128
- ```bash
129
- AVAILABLE_AGENTS=""
130
- for id in $(jq -r '.agents[].id' <<<"$PROFILE" | sort); do
131
- if [[ -f ".claude/agents/$id.md" ]]; then
132
- AVAILABLE_AGENTS="$AVAILABLE_AGENTS$id"$'\n'
133
- elif [[ "$id" == "sr-architect" || "$id" == "sr-developer" || "$id" == "sr-reviewer" ]]; then
134
- echo "[error] Core agent $id not found. Run npx specrails-core update to reinstall."; exit 1
135
- else
136
- echo "[warn] profile references agent '$id' but no agent file exists — skipping (removed in v5; use a custom-* agent)"
137
- fi
138
- done
139
- AVAILABLE_AGENTS="$(printf '%s' "$AVAILABLE_AGENTS" | sed '/^$/d')"
17
+ ```sh
18
+ node .specrails/runtime/agent-runtime.mjs run --context <absolute-context> --config .specrails/agent-runtime.json --change <stable-change>
140
19
  ```
141
20
 
142
- Also store per-agent model overrides and the orchestrator model for use in later phases:
21
+ Desktop launches this runtime directly and freezes its resolved global connections and project settings. Standalone installations provide a local configuration. If required runtime/configuration files are missing, repair the Core installation; do not fall back to a prompt-orchestrated implementation.
143
22
 
144
- ```bash
145
- # ORCHESTRATOR_MODEL is informational; the caller is responsible for spawning
146
- # the orchestrator with this model (e.g. specrails-desktop reads this field directly).
147
- ORCHESTRATOR_MODEL="$(jq -r '.orchestrator.model' <<<"$PROFILE")"
23
+ Wait for the foreground process. Report its structured status, acceptance and verification evidence. A process failure or pause preserves progress; it does not authorize a replacement run. Resume only the exact saved execution:
148
24
 
149
- # Per-agent model overrides keyed by agent id.
150
- # Consumed by subagent invocation sites in later phases.
151
- declare -A AGENT_MODEL
152
- while IFS=$'\t' read -r id model; do
153
- [[ -n "$model" && "$model" != "null" ]] && AGENT_MODEL[$id]="$model"
154
- done < <(jq -r '.agents[] | [.id, (.model // "null")] | @tsv' <<<"$PROFILE")
155
-
156
- # Routing rules (array), consumed by Phase 3b.
157
- ROUTING="$(jq '.routing' <<<"$PROFILE")"
158
-
159
- PROFILE_NAME="$(jq -r '.name' <<<"$PROFILE")"
25
+ ```sh
26
+ node .specrails/runtime/agent-runtime.mjs status --context <absolute-context>
27
+ node .specrails/runtime/agent-runtime.mjs resume --context <absolute-context>
160
28
  ```
161
29
 
30
+ Answers, approvals and recovery flags must correspond to the pending request and user authorization. Resume keeps the saved models, scope and configuration. Never manually rewrite phase receipts, bypass review, or treat provider prose as completion.
162
31
 
163
- ##### Invocation configuration
164
-
165
- Forward resolved models through supported per-invocation configuration; never rewrite shared agent frontmatter or profiles. If an override cannot be honored, report that limitation, not a false model claim. The caller selects the orchestrator model before launch.
166
-
167
- Route task groups by the first matching rule and final default. Missing optional targets fall through to default. Custom roles assist a canonical phase; they never bypass its acceptance gate. The baseline trio is required.
168
-
169
- ## Durable phases and verification
170
-
171
- Use `architect → developer → reviewer → archive → ship → ci`. Start a phase with running; only actual completion and its runtime gate permit done. Failed/blocked needs a concrete reason. Reopening resets dependent completion. Never skip an implementation phase because its predecessor failed.
172
-
173
- ```bash
174
- node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}" phase --phase architect --status running
175
- node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}" phase --phase architect --status done
176
- node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}" phase --phase reviewer --status blocked --reason "Unresolved acceptance condition"
177
- ```
178
-
179
- Store check requests/notes under stateDir, not as candidate files. Verification is executable argv:
180
-
181
- ```json
182
- {"kind":"full","commands":[{"repositoryId":"primary","command":"npm","args":["test"],"cwd":"/absolute/selected/repo","env":{"CI":"1"},"timeoutMs":900000}]}
183
- ```
184
-
185
- ```bash
186
- node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}" verify --request <stateDir/full-checks.json>
187
- ```
188
-
189
- Derive actual CI-equivalent checks from each selected repository's scripts/config/workflows. The example is not universal. Full requests cover every selected root and required cross-repository integration; scoped requests target repair cycles. The runtime executes commands and binds exits/output, command/argv/cwd/environment identity to frozen scope and actual candidate, including additions and deletions.
190
-
191
- Reuse a full receipt only while status.verification.valid is true **and recorded commands cover the required checks**. Baseline-only/stale evidence cannot certify changes. After candidate edits, use scoped repairs and one fresh final full pass. Command success still needs semantic acceptance review; do not replace it with another full-suite run.
192
-
193
- ## Phase 1: Architect
194
-
195
- Start architect if required by resumePhase, then invoke sr-architect once with specName and aggregate frozen scope/roots. Use the actual `Skill("opsx:ff", "<change>")` workflow (or provider-native equivalent) for `${SPECRAILS_REPO_DIR:-.}/openspec/changes/<change>/`.
196
-
197
- One design covers shared contracts, explicit repository task ownership, integration order and acceptance. Batch tickets are dependency-ordered task groups within this change, not separate full pipelines. Validate existing Modify paths and genuinely new Create paths against selected roots; do not reject a plan by a percentage-of-paths-exist heuristic.
198
-
199
- Require proposal/design/specs/tasks and medium/high design-confidence.json. Missing, malformed or low confidence blocks development with the unresolved issue. The runtime checks this before architect done. Reuse valid design after interruption; task checkbox progress does not invalidate its contract.
200
-
201
- ## Phase 2: Developer
202
-
203
- Invoke sr-developer or profile-routed roles with immutable task groups and official `Skill("opsx:apply", "<change>")`. Serialize dependent/shared-file groups in supplied candidate roots. Read-only investigations may run concurrently, but collect every result; no recursive full pipeline or colliding writers.
204
-
205
- Keep real checked task progress. Use meaningful scoped regressions during implementation and bounded repairs (at most two unsuccessful cycles per issue, then a concrete blocker). After all aggregate tasks finish, run one full CI-equivalent request. Runtime developer done requires completed tasks and current actual evidence.
206
-
207
- Supplied roots already contain the candidate: inspect additions, renames and deletions there. Do not copy changed-file lists over another checkout, patch against an assumed main branch or force-remove worktrees.
208
-
209
- ## Phase 3: Reviewer and confidence
210
-
211
- Invoke sr-reviewer once with the context, exact specName, candidate summary and receipt. Map every frozen requirement to code and behavioral evidence. Existing green tests with missing implementation mean incomplete, not PASS.
212
-
213
- Reuse unchanged full evidence; run cheap static/scoped checks as needed. Any review edit requires one fresh full request after all fixes. Security, acceptance gaps, missing required regressions, untested critical side effects or unchecked tasks block acceptance.
214
-
215
- Before archive, write `${SPECRAILS_REPO_DIR:-.}/openspec/changes/<change>/confidence-score.json` with canonical change, overall and five numeric aspects. Require overall ≥70, security ≥75, other aspects ≥60; stricter configured thresholds still apply. Missing/malformed score fails closed; a numeric average never overrules an explicit blocker.
216
-
217
- Normal reviewer returns acceptance/security verdict and confidence **without archiving**. Validate SECURITY_STATUS, task completion and acceptance, then runtime reviewer done. A human-facing PASS alone is insufficient.
218
-
219
- ## Phase 4: Archive after approval
220
-
221
- ```bash
222
- node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}" archive-check
223
- ```
224
-
225
- Approval binds candidate, requirements and exact confidence bytes. Invoke reviewer with ARCHIVE_ONLY=true and ARCHIVE_AUTHORIZED=true, or execute the equivalent official workflow in the coordinator. No rescoring/code edits after approval. Run the Skill from `${SPECRAILS_REPO_DIR:-.}`:
226
-
227
- ```
228
- Skill("opsx:archive", "<change>")
229
- ```
230
-
231
- Confirm active artifacts moved and canonical specs synced, then record archive done. Do not emulate with file moves or automatically accept incomplete-task prompts. Failure is a resumable archive blocker, not permission to redevelop or reship.
232
-
233
- ## Phase 5: Delivery and backlog
234
-
235
- Host-owned git: only ship/ci may be skipped; return ready-for-delivery evidence. Host-owned backlog stays untouched until host acceptance.
236
-
237
- For explicitly Core-owned git and GIT_AUTO=true, use the project's shipping workflow in each correct selected repo, staging only reviewed candidate changes. Preserve unrelated preexisting work. Record real commits/PRs and CI results per repository; partial delivery is not whole-batch success. CI-only retry checks existing delivery and does not ship again.
238
-
239
- Only Core-owned backlog can close after all required delivery succeeds. First compare live ticket requirements against frozen scope; changed requirements remain open with the conflict reported. Failures preserve open tickets and resumable phase details.
240
-
241
- ## Preview and apply
242
-
243
- --dry-run/--preview prepares bytes under stateDir without source edits/shipping/backlog writes. Manifest entries are `{repositoryId,path,operation:"write"|"delete",sourcePath?}`; targets are repository-relative. Record with `preview --request <stateDir/preview-request.json>`. Report **UNVERIFIED PREVIEW**; tests on untouched code describe only baseline.
244
-
245
- --apply resumes the exact journal and calls `apply-preview --request <stateDir/full-checks.json>`. Runtime rejects stale base/cache, applies exact additions/edits/deletions and executes checks on the actual candidate. Failed checks retain reviewable applied work without success evidence. Continue developer task completion, reviewer/confidence and archive gates; never skip directly to shipping.
246
-
247
- ## Completion
248
-
249
- Report run/change, frozen tickets/roots, phase statuses, actual receipt commands, acceptance, confidence, archive and per-repository delivery. Distinguish reused evidence, newly executed checks and gaps. Keep failure excerpts bounded and refer to durable receipts. Missing workers, failed gates or incomplete required repositories stay blocked/failed, never falsely complete.
250
-
251
-
252
- ### Acceptance evidence and completion
253
-
254
- After development, normal review MUST write `stateDir/acceptance.json` and run
255
- `acceptance --request <absolute-path>` before `phase --phase reviewer --status done`.
256
- The request is `{criteria: [...], checks: [...], findings: [...]}`:
257
- - Each criterion has `specId` (string), `criterionIndex` (zero-based), `requirement`
258
- (exact frozen text), `status` (`met`, `exception`, `blocked`, `pending`) and a
259
- nonempty `evidence` array of concrete code/test/capture references and observations.
260
- Cover every frozen acceptance criterion once. If a spec has no explicit criteria,
261
- use its complete frozen description (or title if empty) at index 0.
262
- - An `exception` MUST include `{reason, impact, material, acceptedBy, approvalEvidence}`.
263
- `acceptedBy` is `reviewer`, `user`, or `host`. Material scope changes require actual
264
- user/host authorization; do not invent approval or label material changes minor.
265
- Previously authorized decisions need no new confirmation. Unresolved requirements
266
- remain `blocked` or `pending`, never `met` through a rewritten interpretation.
267
- - Each check has `{name, status, required, evidence, scope, limitations}`; status is
268
- `passed`, `failed`, or `unavailable`. Include required and supplementary checks from
269
- the design. Record the original required classification; never downgrade a failed
270
- check to make the gate pass. For benchmarks state what is measured and excluded:
271
- a Node microbenchmark does not establish browser Canvas/GPU/frame performance.
272
- - `findings` lists concrete review conclusions, risks and resolutions; use an empty
273
- array only when no findings remain. Numeric confidence cannot replace this report.
274
-
275
- The runtime binds this evidence to frozen scope, source and design. Missing/stale
276
- acceptance or unresolved requirements/required checks block review and archive.
277
- Accepted exceptions and supplementary failures produce `with-exceptions` validation.
278
- Replacing the report requires review and archive authorization again; a green command
279
- receipt alone is insufficient. Evidence references and approval attribution remain
280
- reviewer assertions, not independently authenticated proof of human approval.
281
-
282
- Keep operational completion notes, check requests and reports in `stateDir` from
283
- start to finish. Run scoped checks for repairs and one final full verification after
284
- all edits. Reuse that full receipt while runtime status says it is valid and its
285
- commands cover required checks. New prose/phase handoffs alone do not warrant reruns.
286
-
287
- End with ONE concise summary from runtime `status.completion`: implementation,
288
- validation (including exceptions), archive, delivery, and evidence references.
289
- Host-owned delivery stays `pending-host`; do not call uncommitted files "landed".
290
- Report phase durations/attempts from `status.phases`; report per-phase cost only when
291
- provider telemetry attributes it, otherwise unavailable. Do not invent cost splits.
32
+ Honor the context's ownership throughout: Desktop owns worktrees, commits, PRs and backlog delivery. Runtime success prepares a reviewed candidate; host delivery remains a separate action. Preview requests must not invoke mutating execution.
@@ -1,38 +1,10 @@
1
- # Retry an Implementation Pipeline
1
+ # Resume a programmatic implementation
2
2
 
3
- **Input:** $ARGUMENTS existing change and optional --from <phase>.
3
+ Resolve the exact saved context for the requested run. Do not initialize a replacement, guess the latest change, or discard work.
4
4
 
5
- ## Resolve the exact run
6
-
7
- Use the same absolute SPECRAILS_PIPELINE_RUNTIME and SPECRAILS_EXECUTION_CONTEXT. The managed fallback is .specrails/runtime/pipeline.mjs; the standalone workspace pointer is only discovery. Do not initialize another run, choose the newest change, replace frozen tickets from mutable backlog, or trust old ad-hoc pipeline state.
8
-
9
- ```bash
10
- node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}" status --json
5
+ ```sh
6
+ node .specrails/runtime/agent-runtime.mjs status --context <absolute-context>
7
+ node .specrails/runtime/agent-runtime.mjs resume --context <absolute-context>
11
8
  ```
12
9
 
13
- Verify runId/change match. Preserve context.specs, selected roots, backlog identity and ownership. The artifact compatibility root is `${SPECRAILS_REPO_DIR:-.}`, not necessarily the framework workspace.
14
-
15
- ## Resume earliest invalid evidence
16
-
17
- Follow resumePhase and receipt reasons. Completed valid phases require no model call. Blocked/failed is resumable; never convert dependent implementation into skipped. Explicit --from can reopen an earlier phase, but runtime prerequisite checks still apply.
18
-
19
- ```bash
20
- node "${SPECRAILS_PIPELINE_RUNTIME:-.specrails/runtime/pipeline.mjs}" phase --phase <phase> --status running
21
- ```
22
-
23
- | Phase | Resume action |
24
- |-------|---------------|
25
- | architect | Repair official design artifacts/confidence; unblock development only after actual gate passes. |
26
- | developer | Continue unchecked tasks, retain completed code; scoped repairs followed by one full receipt. |
27
- | reviewer | Review acceptance/confidence; reuse current full evidence, refresh after edits. Do not redo valid architecture because review was blocked. |
28
- | archive | Fresh archive-check, then authorized official archive/sync only; preserve approved confidence bytes. |
29
- | ship | Only Core-owned and authorized; resume missing repository delivery without duplicating successful commits/PRs. |
30
- | ci | Check existing delivery; never reship merely because CI needs retry. |
31
-
32
- Only host-owned ship/ci may skip. Actual done clears old reason; failed/blocked records concrete remaining work. Reopening invalidates dependent completion.
33
-
34
- ## Evidence and report
35
-
36
- Use the implement contracts for command receipts, foreground worker completion and exact repository routing. Receipt validity plus required command coverage permits reuse; baseline-only or stale evidence does not. Preview apply must check base/cache and execute checks on actual applied source.
37
-
38
- Confidence, acceptance and archive approval precede delivery. Preserve host-owned Git/worktrees/backlog. Return current state, reused/new evidence and per-repository outcomes. If all phases remain valid, report completion without rerunning.
10
+ Use the saved scope and configuration. Pass an answer, approval or recovery flag only for the corresponding pending request with user authorization. The runtime selects the next phase and preserves valid completed work; never invoke roles directly or edit phase receipts. Preserve host ownership of Git, worktrees and backlog. Report the structured result and outstanding delivery actions.
@@ -1,31 +1,37 @@
1
- description = "Aggregate batch implementation with one durable journal and final candidate gates."
1
+ description = "Programmatic implementation with durable recovery."
2
2
 
3
3
  prompt = '''
4
- Resolve all target IDs or filters and freeze their complete descriptions,
5
- acceptance criteria and repository IDs. With a host context preserve context.specs
6
- unchanged. Resolve source/artifact/backlog roots explicitly; cwd can be external.
7
-
8
- Initialize ONE aggregate OpenSpec change and journal for this runId. Never create
9
- per-ticket child changes/journals with the same context. Read
10
- `.gemini/commands/specrails/implement.toml` and apply its capability preflight,
11
- explicit invoke_agent(agent_name,prompt) handoff, progress-bound continuation and
12
- gates to the whole batch:
13
-
14
- 1. One architect designs all tickets, groups tasks by ticket/repository and
15
- dependency order, validates OpenSpec and high/medium design confidence.
16
- 2. One developer implements groups sequentially, persisting progress in tasks.md.
17
- Use scoped checks per group and one full helper verification for the aggregate
18
- candidate before developer done. Incomplete groups remain retriable.
19
- 3. One reviewer checks every acceptance criterion and cross-ticket interaction;
20
- pass all frozen specs, changed paths and the full receipt. Ordinary review
21
- never archives. At most one exact-findings developer repair plus re-review.
22
- 4. After clean semantic reviewer done, run archive-check; only success authorizes
23
- reviewer archive-only mode. Verify the archive and record archive done. Only
24
- then close ALL Core-owned tickets, or report results to the owning host.
25
-
26
- Run these roles directly at root, no nested implement coordinator. Retry resumes
27
- this aggregate journal without repeating valid phases. A --parallel preference
28
- never overrides host ownership, unknown capacity or overlapping mutation paths;
29
- use sequential execution and report it honestly. Final output lists each ticket,
30
- aggregate verification/archive status and unresolved task groups; no partial done.
4
+ # Programmatic implementation
5
+
6
+ Implement the requested spec or batch through the installed agent runtime. The runtime owns architecture, development, verification, review and archive; do not delegate these phases yourself or launch a second coordinator.
7
+
8
+ ## Freeze the requested scope
9
+
10
+ Use the supplied absolute `SPECRAILS_EXECUTION_CONTEXT` unchanged. It defines runId, specs and acceptance criteria, artifactRoot, selected repositories and ownership. For standalone use, admit the exact requested tickets once with:
11
+
12
+ ```sh
13
+ node .specrails/runtime/pipeline.mjs init --change <stable-change> --tickets "<requested-ids>"
14
+ ```
15
+
16
+ For a free-form request use `--scope-request <absolute-json>` with the user's specs and criteria. Use the returned absolute context path. Never select a different run by modification time or replace scope from mutable backlog. Multiple tickets share one aggregate context and one runtime invocation.
17
+
18
+ ## Execute
19
+
20
+ ```sh
21
+ node .specrails/runtime/agent-runtime.mjs run --context <absolute-context> --config .specrails/agent-runtime.json --change <stable-change>
22
+ ```
23
+
24
+ Desktop launches this runtime directly and freezes its resolved global connections and project settings. Standalone installations provide a local configuration. If required runtime/configuration files are missing, repair the Core installation; do not fall back to a prompt-orchestrated implementation.
25
+
26
+ Wait for the foreground process. Report its structured status, acceptance and verification evidence. A process failure or pause preserves progress; it does not authorize a replacement run. Resume only the exact saved execution:
27
+
28
+ ```sh
29
+ node .specrails/runtime/agent-runtime.mjs status --context <absolute-context>
30
+ node .specrails/runtime/agent-runtime.mjs resume --context <absolute-context>
31
+ ```
32
+
33
+ Answers, approvals and recovery flags must correspond to the pending request and user authorization. Resume keeps the saved models, scope and configuration. Never manually rewrite phase receipts, bypass review, or treat provider prose as completion.
34
+
35
+ Honor the context's ownership throughout: Desktop owns worktrees, commits, PRs and backlog delivery. Runtime success prepares a reviewed candidate; host delivery remains a separate action. Preview requests must not invoke mutating execution.
36
+
31
37
  '''
@@ -1,58 +1,37 @@
1
- description = "Implementation with durable phase checkpoints and explicit Gemini role handoffs."
1
+ description = "Programmatic implementation with durable recovery."
2
2
 
3
3
  prompt = '''
4
- You are the implement orchestrator. Delegate role work to `invoke_agent` using
5
- only its supported fields: `agent_name` and `prompt`. Do not claim session-based
6
- resume: each invocation may start a fresh executor and conversation.
7
-
8
- For multiple ticket IDs, read `.gemini/commands/specrails/batch-implement.toml`
9
- and execute it at this root with the same context; do not ask the user to resend.
10
- For one ticket or free-form input, use the stages below.
11
-
12
- 0. Preflight: require the named sr-architect, sr-developer and sr-reviewer tools,
13
- and readable `.gemini/skills/openspec-{ff,apply,archive}-change/SKILL.md` in
14
- the execution workspace. Roles must expose `activate_skill`. If a capability
15
- is absent, record blocked with the exact missing role/skill and request Core
16
- refresh; do not silently switch to a generic agent or implement inline.
17
- Resolve `${SPECRAILS_REPO_DIR:-.}` only as a legacy fallback. The shared helper
18
- returns the actual repositories, artifactRoot and frozen ticket descriptions.
19
-
20
- 1. DESIGN: record architect running, invoke sr-architect with an explicit prompt
21
- containing runId, phase, current ticket/full frozen acceptance criteria,
22
- repository IDs and absolute roots, artifactRoot, change slug and prior artifact
23
- paths. Require validated OpenSpec proposal/design/specs/tasks and a non-low
24
- design-confidence.json. Missing confidence is blocked, never implicit success.
25
- Record architect done only after those checks.
26
-
27
- 2. APPLY: record developer running; invoke sr-developer with the SAME scope plus
28
- change slug, plan/tasks paths, unfinished tasks, prior findings and next action.
29
- Developer runs verification through the managed helper to produce a candidate-
30
- bound full receipt. Unchecked tasks or missing implementation block handoff,
31
- even when unrelated baseline tests pass. Record developer done after evidence.
32
-
33
- 3. REVIEW: invoke sr-reviewer with the complete explicit handoff, changed files,
34
- verification receipt and acceptance criteria. Ordinary review must NOT archive.
35
- Require its semantic verdict and confidence artifact; PASS alone without these
36
- artifacts is insufficient. On changes requested, give the exact findings to
37
- developer and re-review, with at most one fix round. Record reviewer done only
38
- for a clean semantic result. Preserve blockers and incomplete work for retry.
39
-
40
- 4. ARCHIVE: run `archive-check`; only success permits a new sr-reviewer invocation
41
- with ARCHIVE_ONLY=true and ARCHIVE_AUTHORIZED=true plus the same handoff. Verify
42
- that the active change is gone and its archive exists, then record archive done.
43
- If the combined gate or archive fails, leave the ticket open and record failure.
44
- Only Core-owned backlog may be updated to done; hosted runs report to Desktop.
45
-
46
- For EVERY invocation: `MAX_TURNS`, timeout, missing verdict, or early return is
47
- incomplete work. Read the on-disk checkpoint and compare task/file/evidence
48
- progress, then re-invoke the SAME role with an updated explicit prompt. At most
49
- two continuations per phase, and stop earlier when no progress was recorded.
50
- Never substitute orchestration memory for the handoff. Native turn limits are
51
- optional capabilities: use only fields accepted by the installed loader; if
52
- unknown, retain its defaults and use these bounded continuations.
53
-
54
- Record all stage outcomes with the shared helper, including blocked/failed.
55
- Retry reads that journal, not legacy .gemini/pipeline-state prose snapshots.
56
- Report actual phase outcomes and evidence; never equate tool completion with
57
- implemented behavior or close after an ambiguous review.
4
+ # Programmatic implementation
5
+
6
+ Implement the requested spec or batch through the installed agent runtime. The runtime owns architecture, development, verification, review and archive; do not delegate these phases yourself or launch a second coordinator.
7
+
8
+ ## Freeze the requested scope
9
+
10
+ Use the supplied absolute `SPECRAILS_EXECUTION_CONTEXT` unchanged. It defines runId, specs and acceptance criteria, artifactRoot, selected repositories and ownership. For standalone use, admit the exact requested tickets once with:
11
+
12
+ ```sh
13
+ node .specrails/runtime/pipeline.mjs init --change <stable-change> --tickets "<requested-ids>"
14
+ ```
15
+
16
+ For a free-form request use `--scope-request <absolute-json>` with the user's specs and criteria. Use the returned absolute context path. Never select a different run by modification time or replace scope from mutable backlog. Multiple tickets share one aggregate context and one runtime invocation.
17
+
18
+ ## Execute
19
+
20
+ ```sh
21
+ node .specrails/runtime/agent-runtime.mjs run --context <absolute-context> --config .specrails/agent-runtime.json --change <stable-change>
22
+ ```
23
+
24
+ Desktop launches this runtime directly and freezes its resolved global connections and project settings. Standalone installations provide a local configuration. If required runtime/configuration files are missing, repair the Core installation; do not fall back to a prompt-orchestrated implementation.
25
+
26
+ Wait for the foreground process. Report its structured status, acceptance and verification evidence. A process failure or pause preserves progress; it does not authorize a replacement run. Resume only the exact saved execution:
27
+
28
+ ```sh
29
+ node .specrails/runtime/agent-runtime.mjs status --context <absolute-context>
30
+ node .specrails/runtime/agent-runtime.mjs resume --context <absolute-context>
31
+ ```
32
+
33
+ Answers, approvals and recovery flags must correspond to the pending request and user authorization. Resume keeps the saved models, scope and configuration. Never manually rewrite phase receipts, bypass review, or treat provider prose as completion.
34
+
35
+ Honor the context's ownership throughout: Desktop owns worktrees, commits, PRs and backlog delivery. Runtime success prepares a reviewed candidate; host delivery remains a separate action. Preview requests must not invoke mutating execution.
36
+
58
37
  '''
@@ -1,21 +1,15 @@
1
- description = "Resume incomplete Gemini phases from the shared executable journal."
1
+ description = "Programmatic implementation with durable recovery."
2
2
 
3
3
  prompt = '''
4
- Call the installed pipeline helper `status` for the requested change and run.
5
- Use its `context`, `resumePhase`, phases and verification to select the earliest
6
- invalid phase. If legacy artifacts have no journal, initialize without deleting
7
- work and validate each claimed completed phase before recording it.
4
+ # Resume a programmatic implementation
8
5
 
9
- Read `.gemini/commands/specrails/implement.toml` and drive its remaining role
10
- stages directly through invoke_agent(agent_name, prompt). Do not spawn another
11
- implement orchestrator. Every call starts with the full bounded handoff including
12
- frozen acceptance criteria, all repository paths, artifactRoot, change/plan/tasks,
13
- last result and next action. Do not assume native session continuity or `.gemini`
14
- legacy pipeline-state files. A blocked phase is retriable, not intentionally skipped.
6
+ Resolve the exact saved context for the requested run. Do not initialize a replacement, guess the latest change, or discard work.
7
+
8
+ ```sh
9
+ node .specrails/runtime/agent-runtime.mjs status --context <absolute-context>
10
+ node .specrails/runtime/agent-runtime.mjs resume --context <absolute-context>
11
+ ```
12
+
13
+ Use the saved scope and configuration. Pass an answer, approval or recovery flag only for the corresponding pending request with user authorization. The runtime selects the next phase and preserves valid completed work; never invoke roles directly or edit phase receipts. Preserve host ownership of Git, worktrees and backlog. Report the structured result and outstanding delivery actions.
15
14
 
16
- Do not repeat completed valid design/development after a reviewer failure. If
17
- review actually requires code changes, record developer running and pass the exact
18
- findings. Follow the same progress-bound continuation and one-round repair limits.
19
- Archive-check must succeed before reviewer archive-only authorization. Preserve
20
- host ownership and report unresolved work honestly with its durable resume point.
21
15
  '''