greprag 5.74.9 → 5.74.11

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.
@@ -1,95 +1,102 @@
1
1
  # Codex Chip Spawn Method
2
2
 
3
- Use this for Codex visible child tasks. Claude-side `spawn_task` rules do not
4
- apply to Codex: Codex creates the task, selects its workspace, and provides the
5
- native parent-child reply channel.
6
-
7
- ## Roles and models
8
-
9
- The exact first-line title selects the governance and model slot:
10
-
11
- | Title | Purpose | Model slot |
12
- | --- | --- | --- |
13
- | `Chip A/B/C: <Specific Purview>` | Independent implementation worker | `chip.worker` |
14
- | `LEAD: <Mission>` | Own and integrate a multi-chip mission | `chip.leader` |
15
- | `PLANNER: <Mission>` | Create and brief a separate LEAD | `chip.planner` |
16
- | `ADVISOR: <Purview>` | Read-only consultation to the LEAD | `chip.advisor` |
17
- | `FIX: [harness\|doctrine\|injection\|env\|code] <one friction unit>` | Root-cause repair | `chip.fix` |
18
-
19
- Check active slots with `greprag codex models show`. Pass the selected slot as
20
- top-level `model` and `thinking` in `codex_app__create_thread`; do not rely on
21
- Codex Desktop defaults for a visible chip.
22
-
23
- ## Mode selection
24
-
25
- - 1-2 visible tasks: rename the current task `LEAD: <Mission>` and
26
- spawn `Chip A` / `Chip B` directly.
27
- - More chips or shared seams: rename the current task `PLANNER: <Mission>`,
28
- create a separate `LEAD: <Mission>` first, then that LEAD spawns children.
29
- - Bounded same-session work: use `greprag load codex-subagent-spawn` instead.
30
-
31
- A dedicated `LEAD: <Mission>` creates a native top-level goal with
32
- `create_goal`, verifies it with `get_goal`, then fans out children. PLANNER is
33
- a handoff role: after briefing the LEAD it goes quiet until completion,
34
- blocker, explicit decision request, or operator intervention.
35
-
36
- ## Workspace selection and project preflight
37
-
38
- Standard writable chips use the current project with
39
- `environment: { "type": "worktree" }`. For a FIX chip, run
40
- `greprag fix spawn` in the source project and honor its top-level
41
- `workspaceMode` without a fail-then-fallback attempt:
42
-
43
- - `workspaceMode=worktree`: use the project worktree target. Before the call,
44
- check the saved project/main repo for `.codex/environments/environment.toml`.
45
- If missing, stop and set up the repo first with the `codex-environments`
46
- skill.
47
- - `workspaceMode=local`: use the project local target. The source has no usable
48
- Git HEAD, so do not initialize Git, invoke `codex-environments`, or request a
49
- worktree. This is the project-local task path with serialized writes: the
50
- caller yields file writes until the FIX chip reports back.
51
- - Non-FIX writable chips remain worktree-only.
52
- - Missing for `PLANNER` or `ADVISOR` consultation: local/projectless fallback
53
- is allowed only when the prompt explicitly forbids writes and no child
54
- worktree dispatch happens until the repo environment exists.
55
-
56
- ## Dispatch
57
-
58
- Call `codex_app__create_thread` once as a standalone tool call:
3
+ Codex has no Claude Code `pre-spawn-check` validator over `spawn_task`. The
4
+ agent writes the exact first-line title + Block 1 + task body + Block 2 into
5
+ the prompt itself, then dispatches exactly once with
6
+ `codex_app__create_thread`. Codex task creation proves dispatch only; the
7
+ child's native `IN-FLIGHT` reply proves launch/setup.
8
+
9
+ > **Part of a multi-chip mission?** If this chip is one of ≥2 aimed at a
10
+ > single objective, you should already be inside a chip-leader plan — your
11
+ > **base branch** and **merge target** (the integration branch, *never* master)
12
+ > come from it. If you're not, stop and run `greprag load chip-leader` first.
13
+ > A lone chip targeting its own objective proceeds here directly.
14
+
15
+ ## What the agent provides
16
+
17
+ - `title: "Chip A: <verb-phrase>"` — exact first prompt line. Use the
18
+ leader-assigned label (`A`/`B`/`C`...) per workstream, for example
19
+ `"Chip B: Build freshness engine"`. The label is the shared handle the
20
+ leader and chip both use end-to-end (title -> report-back self-ID -> merge
21
+ references). Dedicated orchestration titles are exact too: `PLANNER:
22
+ <Mission>`, `LEAD: <Mission>`, `ADVISOR: <Purview>`, and `FIX:
23
+ [type] <one friction unit>`.
24
+ - `prompt:` — exact title line + Block 1 + task body + Block 2 (templates
25
+ below).
26
+ - The first-line title also selects the model slot:
27
+ `Chip A/B/C` -> `chip.worker`, `LEAD` -> `chip.leader`, `PLANNER` ->
28
+ `chip.planner`, `ADVISOR` -> `chip.advisor`, `FIX` -> `chip.fix`.
29
+ - `target:` — Codex project target. Writable worktree chips must include the
30
+ prepared branch as `startingState`; this is the required Codex parameter
31
+ Claude does not have:
59
32
 
60
33
  ```json
61
34
  {
62
35
  "target": {
63
36
  "type": "project",
64
37
  "projectId": "<current-project-id>",
65
- "environment": { "type": "<worktree|local>" }
38
+ "environment": {
39
+ "type": "worktree",
40
+ "startingState": { "type": "branch", "branchName": "<prepared chip branch>" }
41
+ }
66
42
  },
67
- "prompt": "<Block 1 + Task + Block 2>",
43
+ "prompt": "<exact title + Block 1 + Task + Block 2>",
68
44
  "model": "<selected role model>",
69
45
  "thinking": "<selected role effort>"
70
46
  }
71
47
  ```
72
48
 
73
- Creation success proves dispatch, not successful startup. If the result is
74
- ambiguous, do not retry blindly: use `list_threads` for the expected title,
75
- inspect candidates with `read_thread`, and retry only after proving no matching
76
- task exists.
49
+ - `model:` / `thinking:` — select with `greprag codex models show`; pass them
50
+ top-level in `codex_app__create_thread`, not by relying on Desktop defaults.
77
51
 
78
- ## Block 1 - Setup and startup acknowledgement
52
+ `workspaceMode=local` FIX tasks keep the same required Codex shape but use the
53
+ project-local environment and omit `startingState`:
79
54
 
80
- Paste this at the top of the child prompt after the title.
55
+ ```json
56
+ {
57
+ "target": {
58
+ "type": "project",
59
+ "projectId": "<current-project-id>",
60
+ "environment": { "type": "local" }
61
+ },
62
+ "prompt": "<exact title + Block 1 + Task + Block 2>",
63
+ "model": "<selected role model>",
64
+ "thinking": "<selected role effort>"
65
+ }
66
+ ```
67
+
68
+ Codex has no `mode: interactive` create-thread field. If the chip must pause
69
+ for human input, put that requirement in the task body and make the child
70
+ report `BLOCKED` with the decision needed.
71
+
72
+ ## Block 1 — Setup (verbatim, substitute `<exact-title>`, `<branch>` + mode)
73
+
74
+ `<exact-title>` = the first prompt line. `<branch>` = the prepared chip branch
75
+ used in `startingState.branchName`. `workspaceMode` comes from the dispatch
76
+ path; standard chips and `workspaceMode=worktree` FIX chips are already in a
77
+ Codex worktree environment.
78
+
79
+ ````
80
+ **Setup — do this FIRST:**
81
81
 
82
82
  ```text
83
83
  ## Setup - do this FIRST
84
- Stay in the selected workspace and inspect the current repository state.
84
+ Stay in the Codex-provided selected workspace and inspect the current
85
+ repository state.
85
86
  Applicable AGENTS.md instructions and the session-start recap are already in
86
- context. Do not create another worktree; a `workspaceMode=local` FIX stays in
87
- the project directory and never initializes Git.
88
- Bootstrap this checkout before build/test: if `scripts/ensure-npm-deps.cjs`
89
- exists, run `node scripts/ensure-npm-deps.cjs`; if
90
- `scripts/worktree-bootstrap.cjs` exists, run
91
- `node scripts/worktree-bootstrap.cjs`. Never link or junction `node_modules` to
92
- another checkout.
87
+ context.
88
+ Do not create another worktree. Standard chips and `workspaceMode=worktree`
89
+ FIX chips are already in the Codex worktree environment created from
90
+ `startingState.branchName`. A `workspaceMode=local` FIX stays in the project
91
+ directory, never initializes Git, never requests a worktree, and requires the
92
+ caller to yield file writes until the FIX chip reports back.
93
+ Bootstrap this checkout before build/test: if `scripts/worktree-bootstrap.cjs`
94
+ exists, run `node scripts/worktree-bootstrap.cjs`; if only
95
+ `scripts/ensure-npm-deps.cjs` exists, run `node scripts/ensure-npm-deps.cjs`.
96
+ Never link or junction `node_modules` to another checkout.
97
+ When running build/test or other env-driven commands, use
98
+ `node scripts/codex-run.cjs -- <command ...>` if that wrapper exists. It loads
99
+ ignored env files from the main checkout; never copy or print secrets.
93
100
  After setup and bootstrap succeed, reply to the LEAD in the native Codex task
94
101
  thread:
95
102
  `IN-FLIGHT: <exact title> — setup complete; work started`
@@ -111,25 +118,36 @@ the LEAD only: findings, questions, tradeoffs, and recommendations. Do not
111
118
  write operator-facing completion language or decide/spawn worker chips.
112
119
  ```
113
120
 
114
- ## Task body
121
+ The `IN-FLIGHT` reply is non-negotiable — without it the parent assumes the
122
+ Codex task exists but was not successfully launched.
115
123
 
116
- Keep the actual work dominant:
124
+ ---
125
+ ````
126
+
127
+ **Multi-chip mission (`greprag load chip-leader`)?** The first-line title alone
128
+ is not enough because Codex can auto-title before the child is renamed. The
129
+ parent or LEAD must set the exact registry/task title immediately after the
130
+ task appears, then read it back twice before treating the title as durable:
117
131
 
118
132
  ```text
119
- ## Task
120
- Outcome: <observable result>
121
- Problem and evidence: <failure, request, or proof motivating the work>
122
- Relevant files/contracts: <starting points; child still owns discovery>
123
- Constraints and prior decisions: <invariants that must survive>
124
- Seams and integration order: <shared contracts/order, or none>
125
- Acceptance: <checks/evidence that mean done>
126
- Own repository discovery, design, implementation, tests, and commit; do not
127
- wait for a parent-authored implementation plan.
133
+ set_thread_title "<exact-title>"
134
+ read_thread -> exact title
135
+ read_thread -> exact title again after the retry delay
128
136
  ```
129
137
 
130
- ## Block 2 - Report back
138
+ The leader dictates the exact string (for example `Chip A: Converter format
139
+ coverage`). Single chips still use the exact title, but skip leader-assigned
140
+ registry retitle planning.
141
+
142
+ ## Block 2 — Report back (verbatim, substitute `<branch>` + LEAD task)
131
143
 
132
- Paste this at the end of the child prompt.
144
+ Use the native Codex parent-child task-message channel for Codex-to-Codex
145
+ completion. Do not substitute `greprag send` for normal Codex child reports.
146
+
147
+ ````
148
+ ---
149
+
150
+ **Block 2 — Report back via native Codex task reply:**
133
151
 
134
152
  ```text
135
153
  ## Report when done
@@ -161,45 +179,72 @@ worktree pruning. If review is needed, the parent creates a fresh review
161
179
  chip/session.
162
180
  ```
163
181
 
164
- ## FIX contract
165
-
166
- For `FIX:` tasks, the mission printed by `greprag fix spawn` is the source of
167
- truth. The FIX chip keeps the existing route and carries its type in the title,
168
- for example `FIX: [doctrine] stale skill text sent Codex to Claude rules`.
169
- Type means durable repair surface: `harness` hooks/watchers/task dispatch,
170
- `doctrine` load entries/skills/rendered instructions, `injection`
171
- recap/Capture/doc-pointer/stateful injection, `env` bootstrap/deps/scripts, and
172
- `code` product/source behavior. It identifies the exact friction, makes the
173
- smallest durable root-cause fix, explains why it works, verifies and commits
174
- it, then hands it to the parent delivery owner.
175
-
176
- Removal comes first: remove offending doctrine, gates, controls, duplication,
177
- or wrong boundaries before adding guidance. Add prose or controls only when
178
- removal cannot solve the friction. Data-only repair rows and diagnosis do not
179
- require a writable task.
180
-
181
- ## After spawning
182
-
183
- - Wait for the child-confirmed native `IN-FLIGHT` reply; task creation alone
184
- does not prove setup/bootstrap succeeded.
185
- - In `workspaceMode=local`, yield parent file writes until the FIX chip reports
186
- back; both tasks share the same project directory.
187
- - Use native Codex parent-child task replies for Codex-to-Codex reporting.
188
- - Use `greprag send` only for explicit cross-harness or fallback coordination.
189
- - Contact same-project Codex peers through `codex_app.list_threads` scoped by
190
- `cwd`, then `codex_app.send_message_to_thread`. Coordination asks only about
191
- blockers, owned dirt, or sequencing constraints; peer review is a separate
192
- child task.
193
-
194
- ## Parent cleanup
195
-
196
- After integration, the parent may clear remaining GrepRAG manifest/branch
197
- bookkeeping with:
182
+ **Cleanup discipline (HARD RULE):** chip prompts forbid `git clean`,
183
+ `git reset --hard`, `git checkout <other>`, raw recursive delete outside the
184
+ selected workspace, manual worktree deletion, or manual Codex managed-checkout
185
+ pruning.
186
+ ````
187
+
188
+ ## After spawning — wait for native IN-FLIGHT (HARD RULE)
189
+
190
+ The chip reports back to the LEAD through native Codex task replies. Nothing
191
+ else proves it launched correctly: `create_thread` success proves only that
192
+ Codex accepted the dispatch. So immediately after `codex_app__create_thread`
193
+ returns, resolve the visible task, set the exact title, read it back twice, and
194
+ wait for:
195
+
196
+ ```text
197
+ IN-FLIGHT: <exact-title> — setup complete; work started
198
+ ```
199
+
200
+ If `create_thread` returns a generic/transport failure, treat it as ambiguous
201
+ success. Do not call `create_thread` again until recovery checks prove no
202
+ existing task exists: use `list_threads` for the expected title or manifest id,
203
+ inspect candidates with `read_thread`, and recover a matching visible task
204
+ before retrying.
205
+
206
+ Use native Codex task replies for Codex-to-Codex reporting. Use `greprag send`
207
+ only for explicit cross-harness or fallback coordination; a stored GrepRAG row
208
+ is not proof that an idle Codex task woke or acted.
209
+
210
+ **Launch state:** the Block 1 `IN-FLIGHT` reply is your only signal the child
211
+ actually entered its selected workspace and completed setup. No `IN-FLIGHT` =
212
+ assume the task is not launched, blocked, or not yet set up — don't wait on
213
+ results from a chip that never started.
214
+
215
+ ## Before composing
216
+
217
+ `greprag fix list --repaired --scope chip-startup --limit 20 --project <chip-project> --format markdown` — already scoped, no slicing. If non-empty, paste at top of body as `**Project Fixes (do not re-discover):**`. Do not use `fix search` for this pull.
218
+
219
+ ## Merge before testing globally (HARD RULE)
220
+
221
+ Chips never `npm link` from the worktree — dangling symlinks silently break the
222
+ CLI everywhere. To test a built CLI globally: merge through the repo delivery
223
+ path first, then install from the main checkout.
224
+
225
+ ## Parent merge discipline — cleanup after integration (HARD RULE)
226
+
227
+ When you (the parent) integrate a Codex chip branch — through the canonical
228
+ commit path or a profile-declared merge — clear the Codex chip bookkeeping in
229
+ the same breath after the child's `Archive: yes` report and merge:
198
230
 
199
231
  ```bash
200
232
  greprag codex chip cleanup <id> --native-archived
201
233
  ```
202
234
 
203
235
  The child archives its own task after sending `Archive: yes`; the parent does
204
- not perform routine child-task archival. Codex owns managed-worktree pruning.
205
- Local-mode FIX tasks have no worktree or branch to prune.
236
+ not perform routine child-task archival. The parent may delete the branch after
237
+ merge. Codex owns managed-worktree pruning, and the cleanup command records the
238
+ archive-safe attestation before removing managed checkout state. Local-mode FIX
239
+ tasks have no worktree or branch to prune.
240
+
241
+ **FIX chips use the same delivery owner.** A `greprag fix spawn` mission is the
242
+ source of truth for FIX behavior. `fix spawn` detects usable Git history and
243
+ emits `workspaceMode`: Git uses an isolated worktree; non-Git, unavailable
244
+ Git, or no commit uses the project-local task with serialized writes. Dispatch
245
+ honors that mode without trying a worktree first. The FIX chip identifies the
246
+ exact friction, makes the smallest durable root-cause fix, verifies and
247
+ checkpoints it, then reports the commit/result and cleanup parameters to the
248
+ parent delivery owner. It creates no human landing gate. If no live parent
249
+ exists and the chip carries the full-goal mission, it becomes delivery owner
250
+ and follows the repo profile.
@@ -52,11 +52,14 @@ project, repo, customer, handle, or unexplained proper noun, search memory for
52
52
  that entity before responding when prior context could affect the answer. Do
53
53
  not do this for generic nouns or for entities fully defined in the current turn.
54
54
 
55
- ## Law 4 — Friction ⇒ fix spawn, at the moment
55
+ For any env, toolchain, worktree, secret, tool, hook, command, correction, or
56
+ repetition friction, search Memory for the exact error/friction plus repo/tool.
57
+ If Memory has a clear overcome, apply it and continue.
56
58
 
57
- Friction — you repeated yourself, fought a tool, got corrected twice on the
58
- same thing, rediscovered something already known, hit a setup failure that
59
- wasn't your edit — is fixed at the MOMENT it happens:
59
+ ## Law 4 — Unresolved friction ⇒ fix spawn
60
+
61
+ Escalate only when Memory has no answer, the remembered overcome fails, or the
62
+ same friction repeats:
60
63
 
61
64
  greprag fix spawn --type <harness|doctrine|injection|env|code> "<one unit>"
62
65
 
@@ -66,9 +69,9 @@ wasn't your edit — is fixed at the MOMENT it happens:
66
69
  (Claude Code `spawn_task`, Codex `codex_app__create_thread`, opencode
67
70
  bootloader) and send the mission as its first message. Method:
68
71
  `greprag load chip-spawn`.
69
- - **One unit = one chip.** A fix chip exists for exactly one unit of
70
- friction. Adjacent friction gets its own spawn — a chip that absorbs new
71
- friction loses the context each unit needs.
72
+ - **One unresolved unit = one chip.** A fix chip exists for exactly one unit of
73
+ unresolved friction. Adjacent friction gets its own spawn — a chip that
74
+ absorbs new friction loses the context each unit needs.
72
75
  - **Type = durable repair surface.** `harness` fixes hooks/watchers/task
73
76
  dispatch/harness behavior; `doctrine` fixes `greprag load`, bundled skills,
74
77
  and rendered AGENTS/CLAUDE instructions; `injection` fixes recap, Capture,
@@ -86,10 +89,10 @@ wasn't your edit — is fixed at the MOMENT it happens:
86
89
  the operator before touching code. Rarely can a chip design the durable
87
90
  repair alone; the gate is what keeps repairs durable instead of
88
91
  workarounds.
89
- - **Never queue friction for later.** The queue-first reflex (`fix log` →
90
- periodic digestion) is retired; the moment that produced the friction
91
- holds the context the fix needs. `greprag fix log` survives only for
92
- audit trails and design-input notes that are deliberately not chips.
92
+ - **Never queue unresolved friction for later.** The queue-first reflex
93
+ (`fix log` → periodic digestion) is retired; the live context belongs with
94
+ the fix chip. `greprag fix log` survives only for audit trails and
95
+ design-input notes that are deliberately not chips.
93
96
  - Every repair is ROOT-CAUSE: fix the pattern that makes the friction class
94
97
  possible, never a guard on today's trigger.
95
98
 
@@ -98,4 +101,4 @@ wasn't your edit — is fixed at the MOMENT it happens:
98
101
  If the operator explains the same thing twice, the explanation belongs in a
99
102
  durable surface — a skill, a load entry, a STATE block, an ADR — not in the
100
103
  conversation. Hand-taught doctrine that stays in chat dies with the session;
101
- that is itself friction (Law 4 applies).
104
+ that is itself unresolved friction (Law 4 applies).
@@ -1,34 +0,0 @@
1
- # Codex Internal Subagent
2
-
3
- Use an internal subagent for ephemeral, same-session work: a bounded research
4
- pass, comparison, review, edit, or test whose result can return directly to the
5
- current task.
6
-
7
- ## Contract
8
-
9
- - Load this method with `greprag load codex-subagent-spawn` when the shape is
10
- not already in context.
11
- - The subagent is ephemeral and same-session. It has no visible worktree task,
12
- durable manifest, inbox identity, or goal.
13
- - Keep concurrency at `max_threads=6` and recursion at `max_depth=1`.
14
- - Give it one specific question or purview and ask for a compact result with
15
- evidence. `fast_scan` is read-only; `routine_worker` and `deep_worker` may
16
- perform bounded edits/tests in the parent workspace.
17
- - Use the configured model slots: `subagent.fast_scan`, `subagent.routine_worker`,
18
- and `subagent.deep_worker`. Inspect them with `greprag codex models show`.
19
- - The parent prevents overlapping concurrent edits and owns the final judgment,
20
- integration, and any commit that should outlive the session.
21
- - Do not use it for independent worktree isolation, parent-visible lifecycle
22
- reporting, or work that must outlive the session; choose a quick chip instead.
23
-
24
- ## Compact brief
25
-
26
- ```text
27
- Subagent purview: <one bounded question>
28
- Context: <the files or facts it may inspect>
29
- Return: <decision / findings / recommended next step>
30
- ```
31
-
32
- Internal subagents do not need `greprag send`; their result is returned to the
33
- initiating task. If you need a visible child identity, report, or cleanup
34
- boundary, stop using this primitive and load `codex-chip-spawn`.