wrxn-reversa 1.11.0 → 1.12.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 (70) hide show
  1. package/agents/reversa/references/coordination.md +289 -0
  2. package/agents/reversa/references/modo-de-execucao.md +10 -0
  3. package/agents/reversa/references/owner-decisions.md +5 -0
  4. package/agents/reversa/references/stack-record.md +1 -0
  5. package/agents/reversa/references/state-schema.md +66 -0
  6. package/agents/reversa/scripts/lib/delegation.mjs +250 -0
  7. package/agents/reversa/scripts/lib/git-read.mjs +97 -0
  8. package/agents/reversa/scripts/lib/messages.mjs +48 -0
  9. package/agents/reversa/scripts/lib/repositories.mjs +72 -0
  10. package/agents/reversa/scripts/lib/safe-fs.mjs +115 -0
  11. package/agents/reversa/scripts/lib/scope.mjs +61 -0
  12. package/agents/reversa/scripts/session-state.mjs +64 -112
  13. package/agents/reversa-add/SKILL.md +1 -0
  14. package/agents/reversa-audit/SKILL.md +1 -0
  15. package/agents/reversa-code-express/SKILL.md +1 -0
  16. package/agents/reversa-coding/SKILL.md +1 -0
  17. package/agents/reversa-debugger/SKILL.md +2 -2
  18. package/agents/reversa-debugger-fix/SKILL.md +3 -3
  19. package/agents/reversa-forward/SKILL.md +3 -2
  20. package/agents/reversa-forward-autonomous/SKILL.md +1 -0
  21. package/agents/reversa-new/SKILL.md +1 -0
  22. package/agents/reversa-plan/SKILL.md +1 -0
  23. package/agents/reversa-refactor/SKILL.md +3 -3
  24. package/agents/reversa-requirements/SKILL.md +5 -4
  25. package/agents/reversa-resume/SKILL.md +1 -0
  26. package/agents/reversa-router/SKILL.md +1 -0
  27. package/agents/reversa-sync/SKILL.md +1 -0
  28. package/agents/reversa-to-do/SKILL.md +1 -0
  29. package/agents/reversa-worker/SKILL.md +101 -0
  30. package/agents/reversa-worker/agents/openai.yaml +5 -0
  31. package/bin/reversa.js +8 -0
  32. package/lib/commands/add-engine.js +4 -0
  33. package/lib/commands/install.js +12 -2
  34. package/lib/commands/repo.js +40 -0
  35. package/lib/commands/role.js +117 -0
  36. package/lib/commands/status.js +9 -0
  37. package/lib/commands/uninstall.js +5 -0
  38. package/lib/commands/update.js +7 -2
  39. package/lib/installer/entry-block.js +11 -4
  40. package/lib/installer/policy.js +10 -2
  41. package/lib/installer/prompts.js +31 -5
  42. package/lib/installer/registry.js +171 -0
  43. package/lib/installer/role.js +61 -0
  44. package/lib/installer/writer.js +24 -11
  45. package/locales/README.md +11 -1
  46. package/locales/en/agents/reversa/references/state-schema.md +66 -0
  47. package/locales/en/agents/reversa-add/SKILL.md +1 -0
  48. package/locales/en/agents/reversa-audit/SKILL.md +1 -0
  49. package/locales/en/agents/reversa-code-express/SKILL.md +1 -0
  50. package/locales/en/agents/reversa-coding/SKILL.md +1 -0
  51. package/locales/en/agents/reversa-debugger/SKILL.md +2 -2
  52. package/locales/en/agents/reversa-debugger-fix/SKILL.md +3 -3
  53. package/locales/en/agents/reversa-forward/SKILL.md +3 -2
  54. package/locales/en/agents/reversa-forward-autonomous/SKILL.md +1 -0
  55. package/locales/en/agents/reversa-new/SKILL.md +1 -0
  56. package/locales/en/agents/reversa-plan/SKILL.md +1 -0
  57. package/locales/en/agents/reversa-refactor/SKILL.md +3 -3
  58. package/locales/en/agents/reversa-requirements/SKILL.md +5 -4
  59. package/locales/en/agents/reversa-resume/SKILL.md +1 -0
  60. package/locales/en/agents/reversa-router/SKILL.md +1 -0
  61. package/locales/en/agents/reversa-sync/SKILL.md +1 -0
  62. package/locales/en/agents/reversa-to-do/SKILL.md +1 -0
  63. package/locales/en/agents/reversa-worker/SKILL.md +101 -0
  64. package/locales/en/agents/reversa-worker/agents/openai.yaml +5 -0
  65. package/locales/en/templates/engines/worker-card.md +30 -0
  66. package/locales/en/templates/hooks/README.md +3 -0
  67. package/package.json +2 -2
  68. package/templates/engines/worker-card.md +30 -0
  69. package/templates/hooks/README.md +3 -0
  70. package/templates/hooks/check-legacy-policy.mjs +41 -10
@@ -0,0 +1,289 @@
1
+ # Coordination across repositories and workers
2
+
3
+ This reference applies when the project has `.reversa/repositories.json`, or when the owner asks for parallel workers.
4
+ Without either, ignore it: the flow runs inline in one repository, as always.
5
+ It extends the execution contract in [`modo-de-execucao.md`](modo-de-execucao.md), which still applies in full.
6
+ A worker follows the `reversa-worker` skill of its own installation, not this file.
7
+
8
+ ## Terms
9
+
10
+ | Term | Meaning |
11
+ |---|---|
12
+ | Hub | This repository: it holds the specs, the plans, and the flow state |
13
+ | Satellite | A code repository with a satellite installation, registered in the hub |
14
+ | Repository ID | The short name of a registered repository, for example `web`; `hub` is the hub itself |
15
+ | Checkout | One working copy of a repository on disk |
16
+ | Parallel checkout | An extra checkout (Git worktree or clone) of a registered repository, made for one delegation |
17
+ | Coordinator | You: the session that owns the active flow in the hub |
18
+ | Worker | An agent session that executes one delegation in one checkout |
19
+ | Scope | The globs, relative to the checkout root, where one delegation may write |
20
+
21
+ ## Rules that never change
22
+
23
+ - Only the coordinator writes flow state: `state.json`, `actions.md`, `progress.jsonl`, the roadmap, and every spec.
24
+ - A worker writes only inside its scope and never decides a gate.
25
+ - The legacy edit policy that applies to a file is the one of the repository where the file lives.
26
+ Never edit a satellite's `.reversa/reversa-config.json`.
27
+ - Never edit `.reversa/repositories.json`.
28
+ When a repository is missing, moved, or on another version, give the owner the exact command to run in the hub (`repo add <id> <path>`, `repo remove <id>`, `repo list`) or in the satellite (`update`).
29
+ - Delegation needs the owner's explicit yes.
30
+ A blank reply and autonomous mode are not that yes.
31
+ - Delegation is never required.
32
+ A second agent is reachable when the harness can start one, when a multi-agent manager is present, or when the owner agrees to open a session by hand and paste the brief.
33
+ When none of these holds, execute inline.
34
+ - At most one delegation per checkout, and at most eight in flight.
35
+ - Never push, in any repository.
36
+
37
+ ## What each phase does
38
+
39
+ Read the registry with `repo list` output or by reading `.reversa/repositories.json`.
40
+ When it lists no repository, skip this section.
41
+
42
+ | Phase | What to add |
43
+ |---|---|
44
+ | `reversa-requirements` | Name the repositories that the feature touches, by ID. An unknown repository is an open question for the owner |
45
+ | `reversa-plan` | Name the repository of each decision that touches code. Use a repository ID in the scope column of the stack record and of an engineering exception when it applies to one repository |
46
+ | `reversa-to-do` | Add the `Repositório` column (`Repository` in an English installation) before the target file column, and fill it for every action. This adds one column to the list in the phase skill and in the template. See "The actions table" |
47
+ | `reversa-audit` | In the parallel check, two parallel actions conflict when they share a repository and no parallel checkout is planned, not only when they share a file |
48
+ | `reversa-coding` | Before the execution loop, follow "Before the execution loop". For every action in a satellite that you execute yourself, follow "Execute a satellite action inline" |
49
+ | `reversa-code-express`, `reversa-add`, `reversa-new` | Execute inline. When the actions table has an action outside the hub, add the repository column to it. For an action in a satellite, follow "Execute a satellite action inline" |
50
+ | `reversa-forward`, `reversa-router`, and `reversa-resume` when it resumes a feature | Show the registered repositories and the delegations in flight (from `inspect`). On resume, follow "Recovery" |
51
+ | `reversa-forward-autonomous` | Delegate only when the owner said yes in the opening interview or recorded `OD-10` as approved for the plan. Otherwise execute inline |
52
+ | `reversa-sync` | In the addendum, cite the repository and the commit of each action, from `progress.jsonl` |
53
+ | Bug, refactor, and reconstruction flows | Execute inline. For a change in a satellite, follow "Execute a satellite action inline" |
54
+
55
+ The coding gate still needs the anchor in the hub's spec folder.
56
+ When the hub has no spec for the code of a satellite, say so and stop at the gate, as the phase skill says.
57
+
58
+ ## The actions table
59
+
60
+ - The column holds a repository ID.
61
+ An empty cell, or a table without the column, means `hub`.
62
+ - The target file column keeps a plain path, relative to the root of the repository of that row.
63
+ - The status column stays last.
64
+ - Two actions marked parallel never share a file.
65
+ They also never share a repository, unless the plan gives a parallel checkout to every group but one; one group may use the main checkout.
66
+ - A file that two parallel actions both need goes into a later, sequential action.
67
+
68
+ ## Before the execution loop
69
+
70
+ 1. Group the open actions of the coding stage, across every phase of `actions.md`, by repository, then by the parallel mark.
71
+ Keep a test action and the action that makes its test pass in the same group.
72
+ One group is one candidate delegation: one checkout, one scope, a list of action IDs.
73
+ 2. Keep with you every action that is a gate, that needs a decision not yet taken, that touches the hub, or that depends on an action of another group.
74
+ 3. Write the scope of each group as one to twenty globs that cover its target files and their tests, and nothing wider than needed.
75
+ A scope always includes the test path of its actions.
76
+ Scopes of delegations in one repository must not overlap, in any checkout.
77
+ `*` matches inside one path segment and `**` matches any number of segments.
78
+ No absolute path, no `..`.
79
+ 4. For each group that changes or deletes a pre-existing file, read that repository's `.reversa/reversa-config.json`.
80
+ When the policy blocks a path, show the owner the snippet to edit in that repository, and keep those actions out of the delegation until the owner opens the path.
81
+ 5. Ask the authorization question below.
82
+ With a recorded `OD-10` that approves the plan's delegations, show the list and proceed.
83
+
84
+ ### The authorization question
85
+
86
+ Ask once per phase, in one message:
87
+
88
+ - one line per proposed delegation: repository ID, checkout, scope, action IDs, and whether it needs a new parallel checkout;
89
+ - the isolation that applies to each worker (read-only mode, sandbox, separate checkout, or none);
90
+ - the options: execute everything inline; delegate the listed groups; delegate some of them.
91
+
92
+ Recommend the delegation when the harness or a multi-agent manager can start the worker, and "execute everything inline" otherwise, with the reason in one line.
93
+ When the only way is a session that the owner opens by hand, say so in the option.
94
+ Start a delegation only after an explicit yes.
95
+ A deletion of a pre-existing file needs its own explicit yes, and only then goes into `deletions`.
96
+
97
+ ## Dispatch one delegation
98
+
99
+ 1. The position must not be at a user gate: `checkpoint` it with status `working` first.
100
+ 2. Call the helper:
101
+
102
+ ```json
103
+ { "op": "delegate-start", "identity": {}, "generation": "<generation>",
104
+ "repository": "web", "checkout": "/abs/checkout", "scope": ["src/cart/**", "test/cart/**"],
105
+ "inputs": [ { "path": "_reversa_forward/004-cart/actions.md", "required": true } ],
106
+ "actions": ["T004", "T005"], "deletions": [] }
107
+ ```
108
+
109
+ - `inputs` are hub files, with paths relative to the hub root.
110
+ - `deletions` lists tracked files inside the scope that the owner approved for deletion.
111
+
112
+ 3. Read the result: `delegation.id`, `delegation.base` (the base commit), `delegation.inputs` (absolute paths and hashes), and `delegation.wholeRepository`.
113
+ When `wholeRepository` is true, tell the owner that the scope covers the whole repository before you dispatch.
114
+ 4. On a refusal, act by its code:
115
+
116
+ | Code | What to do |
117
+ |---|---|
118
+ | `unregistered_repository`, `repository_unavailable`, `foreign_checkout` | Give the owner the `repo add` command, or fix the checkout path. For a parallel checkout, create it first |
119
+ | `hub_checkout` | The hub's main checkout is yours: execute inline, or use a parallel checkout of the hub |
120
+ | `not_git_repository` | Scoped delegation needs Git: execute inline |
121
+ | `dirty_scope` | The scope has uncommitted changes: ask the owner to commit or stash them; never do it alone |
122
+ | `version_mismatch` | Ask the owner to run `update` in the satellite |
123
+ | `checkout_busy` | Wait for that checkout's delegation, or use a parallel checkout |
124
+ | `scope_overlap` | Narrow one of the scopes, or run the two groups in sequence |
125
+ | `scope_too_large` | Narrow the scope |
126
+ | `delegation_limit` | Wait for a delegation to finish |
127
+ | `user_gate` | Step 1 was skipped |
128
+ | `missing_input` | Fix the input path |
129
+
130
+ 5. Build the brief: the header `REVERSA-DELEGAÇÃO v2`, then one JSON object.
131
+
132
+ ```json
133
+ { "id": "<delegation.id>", "flow": "forward", "agent": "reversa-coding", "repository": "web", "checkout": "/abs/checkout",
134
+ "scope": ["src/cart/**", "test/cart/**"],
135
+ "actions": [ { "id": "T004", "description": "...", "file": "src/cart/total.js", "acceptance": "..." } ],
136
+ "inputs": [ { "path": "/abs/hub/_reversa_forward/004-cart/roadmap.md", "sha256": "<hash>", "content": null } ],
137
+ "decisions": [ "OD-1: test first", "D-03: ..." ],
138
+ "baseline": { "commit": "<commit>", "created": [] },
139
+ "deletions": [] }
140
+ ```
141
+
142
+ - The brief must be complete without the conversation.
143
+ - `inputs` in the brief uses the absolute paths and hashes of `delegation.inputs`, not the hub-relative paths of the request.
144
+ - `actions` carries the description and the acceptance criteria of each action, copied from `actions.md` and the requirements.
145
+ - `decisions` carries every owner decision, stack row, and plan decision that the actions depend on.
146
+ - Write the descriptions in the language of the hub; the worker answers in the language of the brief.
147
+ - `baseline.commit` is the base commit of the first delegation of this feature into that repository.
148
+ Take it from the first line of this feature's `progress.jsonl` that has that `repository`; for the first delegation, use `delegation.base`.
149
+ `baseline.created` may stay empty: the worker checks the commit.
150
+ - When the worker cannot read the hub's files, embed each input under 20,000 bytes in `content`, with its hash.
151
+ A larger input that the worker cannot read blocks the delegation: execute inline.
152
+
153
+ 6. Send the brief once, by the first capability that applies:
154
+
155
+ - the harness can start another agent in a given folder: start it in the checkout, and give it the full brief even if it inherits context;
156
+ - a multi-agent manager is present: follow its own dispatch guide and send the same brief;
157
+ - neither: print the brief, ask the owner to paste it into a session opened in the checkout, and to paste the return back.
158
+
159
+ Tell the worker to read the `reversa-worker` skill of its installation.
160
+ Never send the generation to a worker.
161
+
162
+ 7. While delegations are in flight, keep working on your own actions.
163
+ `checkpoint` and `write` stay available while the phase agent is the same; a checkpoint that changes the agent, and `release`, are refused until every delegation is finished or cancelled.
164
+ The position header gains ` · delegations <n> → <repository IDs>` (` · delegações <n> → <IDs>` in a Portuguese installation).
165
+
166
+ ## Finish one delegation
167
+
168
+ Delegations finish in any order.
169
+
170
+ 1. When the worker returns, call the helper with the return exactly as received:
171
+
172
+ ```json
173
+ { "op": "delegate-finish", "identity": {}, "generation": "<generation>", "id": "<delegation.id>", "stopped": true,
174
+ "result": "REVERSA-RETORNO v2\n{ ... }" }
175
+ ```
176
+
177
+ 2. The helper compares the checkout with the base commit through Git.
178
+ Trust its lists, not the worker's.
179
+ Read `delegation.status`, `head`, `changed`, `deleted`, `violations`, `accepted`, `installer`, `warnings`, `actions`, and `questions`.
180
+
181
+ | Status | What to do |
182
+ |---|---|
183
+ | `completed` | Mark each action done in `actions.md` and record it |
184
+ | `partial` | Mark each action by the status the worker gave it. `done` is finished, and so is `red` for an action that only writes the failing test. Every other action goes back to your list |
185
+ | `blocked` | Dispatch again or execute inline, after the questions are answered |
186
+ | `violation` | Nothing is accepted yet: show the list and the menu below |
187
+ | `cancelled` | Reopen its actions |
188
+
189
+ 3. With any status, ask the owner each entry of `questions`, with the worker's recommended option.
190
+ 4. On `commit_mismatch`, the return names a commit that is not the head of the checkout (on a second finish: not in the history of the head): ask the worker again, or cancel.
191
+ On `invalid_request`, the return is malformed or the delegation is already finished: check `inspect` before you ask the worker again.
192
+ 5. A `warnings` entry `input_changed` on a hub file that you edited yourself during the flight is expected; on any other file, tell the owner that the worker may have used a stale input.
193
+ 6. A `warnings` entry `file_list_mismatch` only says that the worker's own list differs from what Git shows: Git decides.
194
+
195
+ ### The violation menu
196
+
197
+ A delegation with the status `violation` stays open: its checkout takes no new delegation and `release` is refused with `pending_delegation` until you resolve it.
198
+ Show every path in `violations` with its reason, then:
199
+
200
+ 1. Discard those changes (recommended): after an explicit yes, add a commit in that checkout that restores those paths to the base commit.
201
+ When a path already equals the base commit at the head, add no commit.
202
+ Then call `delegate-finish` again with the same `id`, the same return, and `"accepted": ["<path>", ...]` for the restored paths: the commits of the worker still touch them, so the helper needs the owner's decision on record.
203
+ The helper verifies again and gives the final status.
204
+ 2. Keep them: check the legacy edit policy of that repository for each path and record the wider scope as a decision in the roadmap.
205
+ The helper does not check the policy: when it does not cover a kept path, show the owner the snippet to edit in that repository and wait.
206
+ Do not offer this option for `installer_changed` on a skill file that the worker edited: the installation would differ from its bundle.
207
+ Then call `delegate-finish` again with the same `id`, the same return, and `"accepted": ["<path>", ...]` for the paths that the owner keeps.
208
+ 3. Discard the whole delegation: after an explicit yes, add a commit in that checkout that restores every changed path to the base commit, call `delegate-finish` with `"result": null`, and reopen the actions.
209
+
210
+ | Reason | Meaning |
211
+ |---|---|
212
+ | `outside_scope` | A path outside the scope changed, in the final state or in any commit since the base |
213
+ | `unapproved_deletion` | A pre-existing file was deleted without being in `deletions` |
214
+ | `not_a_file` | A link or another non-file appeared inside the scope |
215
+ | `installer_changed` | A file that the installer owns changed: someone ran the installer, or the worker edited a skill |
216
+ | `policy_file` | The repository's legacy edit policy file changed: only the owner may keep this |
217
+ | `reverted_outside_scope` | Uncommitted work that existed outside the scope before dispatch was undone |
218
+ | `history_rewritten` | The head no longer descends from the base commit: only option 3 applies |
219
+ | `hidden_from_git` | A file was marked so that Git ignores its changes |
220
+ | `too_many_changes` | The change set is over the size limits: only option 3 applies |
221
+
222
+ A warning `unmatched_acceptance` names an accepted path that matched no violation: check the path.
223
+
224
+ A restore to the base commit returns a file to its state before the flow, so the legacy edit policy does not block it; it still needs the owner's explicit yes.
225
+ Never rewrite history to undo a worker's commit.
226
+ Record the head after the last verification as the `commit` of the actions.
227
+
228
+ ### Cancel
229
+
230
+ When a worker will not return, and the owner confirms that it no longer runs, call `delegate-finish` with `"result": null`.
231
+ The actions reopen.
232
+ The checkout keeps the worker's partial commits: tell the owner where they are.
233
+
234
+ ## Record the result
235
+
236
+ - Write one `progress.jsonl` line per action, with the status the worker reported, unchanged: `done`, `red`, `unexpected-green`, `blocked-policy`, `failed`.
237
+ - Add to that line `repository`, `delegation` (the ID), `commit` (the verified head), and `base` (the base commit).
238
+ - In `legacy-impact.md` and `regression-watch.md`, name the repository of each file.
239
+ - Apply nothing from an unverified return.
240
+
241
+ ## Execute a satellite action inline
242
+
243
+ When you execute an action whose repository is a satellite yourself:
244
+
245
+ 1. Read that repository's instruction file and `.reversa/reversa-config.json`, and apply its policy to every pre-existing file.
246
+ 2. Write only the files of the action.
247
+ Run the planned test of the action first; write no test file that the plan does not list.
248
+ 3. Commit in that repository and record `repository`, `commit`, and `base` (the head of that repository before your commit) in the `progress.jsonl` line.
249
+ One commit may serve a test action and the action that makes its test pass.
250
+ 4. When the harness cannot write in that repository, mark the action blocked and report it.
251
+
252
+ ## Parallel work inside one repository
253
+
254
+ - A parallel checkout is a Git worktree or a clone of a registered repository.
255
+ Create it only after the owner's explicit yes, in a folder next to the repository root, not inside it.
256
+ Say which kind you created and where.
257
+ - It starts from a commit.
258
+ Uncommitted changes of the main checkout are not in it: say so before dispatch.
259
+ - Pass its root as `checkout`, with the repository's ID.
260
+ The hub can have parallel checkouts too, with the ID `hub`; the hub's main checkout stays yours.
261
+ - Use a new branch for a worktree, named after the feature and the action IDs of the group, and tell the owner its name.
262
+ Commits made in the main checkout after the parallel checkout was created are not in it.
263
+ A parallel checkout serves the delegations of one group until integration.
264
+ - After a verified finish, integrate the worker's commits into the repository's main checkout by applying them in order.
265
+ When an apply conflicts, stop and report the conflicting paths; never resolve a conflict alone.
266
+ When the delegation had a discarded violation, do not apply its commits as they are: apply the net change of its scope paths as one commit, and say so.
267
+ Mark an action of a parallel checkout done only after its commits apply to the main checkout, and add `integrated` (the head of the main checkout after the last applied commit) to its `progress.jsonl` line.
268
+ When the owner discards a conflicting commit, skip it, keep its action open, and append a corrected `progress.jsonl` line.
269
+ In a satellite, integration is a change to that repository and follows its policy.
270
+ - Remove a parallel checkout that you created, after its delegation is accepted or discarded, and after you show the owner what will be removed.
271
+ Keep its branch until the owner confirms that it can go.
272
+
273
+ ## Recovery
274
+
275
+ | Situation | What to do |
276
+ |---|---|
277
+ | You resume and `inspect` lists delegations in flight | After the confirmed transfer, ask for each one: wait (recommended), finish with a pasted return, or cancel |
278
+ | You resume and a finished delegation has no line in `progress.jsonl` | Read its verified result in `.reversa/context/delegations/<id>.json` and record it, as in "Record the result" |
279
+ | A worker never returns | Cancel, after the owner confirms that it no longer runs |
280
+ | `missing_record` at finish | The dispatch record is gone: the delegation can only be cancelled |
281
+ | A satellite was moved or removed | Give the owner the `repo add` or `repo remove` command |
282
+ | A conflict when integrating a parallel checkout | Stop and report; the owner resolves or discards |
283
+ | The return is not valid (`invalid_request`) | Ask the worker for the return again, in the exact format |
284
+
285
+ A delegation is in flight while its `status` is `dispatched`; `inspect` also lists the finished ones.
286
+ A `transfer` moves every scoped delegation in flight to the new owner.
287
+ Record the owner's yes to a delegation in the roadmap's decisions, with the delegation ID.
288
+ When the roadmap is an input of a delegation in flight, that edit gives an expected `input_changed` warning at finish.
289
+ Do not retry an uncertain dispatch before you reconcile it.
@@ -73,6 +73,16 @@ For a foreign owner, display its identity, current step, and last heartbeat. Tre
73
73
 
74
74
  An in-flight delegate blocks release and transfer. If dispatch ended without a valid return, verify cancellation or termination. The current owner can use `delegate-finish` with `stopped:true,result:null`. For an authorized transfer after confirmed termination, include `stoppedDelegationId` for the exact in-flight attempt. Do not retry an uncertain dispatch before reconciling it.
75
75
 
76
+ ## Coordinate other repositories and parallel workers
77
+
78
+ The section below delegates one phase to one checkout of the same project, with an exact file list.
79
+ To delegate actions to a registered repository or to a parallel checkout, with a write scope that the helper verifies through Git, follow [`coordination.md`](coordination.md).
80
+ That form uses the `REVERSA-DELEGAÇÃO v2` and `REVERSA-RETORNO v2` messages and allows several delegations in flight.
81
+ It leaves the position status as you set it; `inspect` shows `waiting_delegate` only when you are `ready` and delegations are in flight.
82
+ A recorded `OD-10` that approves the plan's delegations counts as the explicit authorization for them.
83
+ The two forms are never in flight together.
84
+ A session in a satellite checkout never claims a flow: the helper refuses with `satellite_checkout`.
85
+
76
86
  ## Delegate a phase only on request
77
87
 
78
88
  1. Confirm the exact target, requested capability, phase, authorized inputs, and write scope. Do not dispatch to a different harness by default. Use the strongest isolation the harness offers (read-only mode, sandbox, or separate checkout) and tell the user which one applies. When none exists, delegation is still allowed: the brief limits the write scope, and `delegate-finish` verifies it afterward. Never delegate a destructive action or a change to a pre-existing file without the owner's approval.
@@ -90,6 +90,7 @@ It records each answer only where it may write.
90
90
  | OD-7 | Style of new code | New code copies the style of the nearest existing code. With no code, it follows the common conventions of the approved stack. | A style guide, code checker, or commit message format that you name. | Principle |
91
91
  | OD-8 | Language of names, comments, and commit messages | The language that the existing code uses, or English when there is no code. | A language that you name. | Principle |
92
92
  | OD-9 | Optional stops | The agent stops at every human checkpoint of the flow. | Fewer optional stops, named one by one. | Principle |
93
+ | OD-10 | Delegation to workers (only with `.reversa/repositories.json` or a request for parallel workers) | The agent asks you at each phase before it hands actions to a worker in another repository or in a parallel checkout. | The agent delegates, for the registered repositories, every delegation that the plan lists, without asking again. | Principle |
93
94
 
94
95
  Ask `OD-2` only when `OD-1` keeps automated tests, the project has no test and no test configuration (check the manifests and the test folders), and no record answers it.
95
96
  When tests existed before this flow started, use the existing tool; the record owner writes the `Testing` row as `detected` (a skill that cannot write `stack.md` leaves it to the next `reversa-plan`).
@@ -102,3 +103,7 @@ Ask `OD-5` when the planned work reads configuration or credentials.
102
103
  A defaulted `OD-5` answer never writes the stack row: it stays in `.reversa/owner-decisions.md` and the record of the flow. Only a named answer writes the `Configuration/secrets` row.
103
104
  `OD-9` covers optional stops only.
104
105
  It never waives the legacy edit policy, the approval of a deletion, a dependency, or a technology choice, a `[DÚVIDA]`, or a migration gate.
106
+ Ask `OD-10` only when `.reversa/repositories.json` lists a repository or the owner asks for parallel workers.
107
+ Check that file with a plain file read: the session helper does not manage it.
108
+ A `default (not confirmed)` answer of `OD-10` never authorizes a delegation: an unattended run executes inline.
109
+ `OD-10` never waives the approval of a deletion, the legacy edit policy of a repository, or the creation of a parallel checkout.
@@ -19,6 +19,7 @@ Do not fill missing decisions from the other target or infer permission from a p
19
19
  Copy the record template below when a flow first writes the record.
20
20
  Key each row by its layer and scope within the selected section.
21
21
  Use separate scopes for components or modules that do not share a single implementation.
22
+ When a decision applies to one registered repository, start its scope with the repository ID.
22
23
  Leave unaffected rows and existing approvals intact.
23
24
  If evidence conflicts with the applicable row, mark `[DÚVIDA]` and stop the dependent action instead of changing the row silently.
24
25
  A missing record is not a reason to repeat discovery; first consult configured `dependencies.md`, manifests, and the nearest relevant code.
@@ -75,6 +75,72 @@ Este arquivo persiste o estado completo da análise entre sessões. O Reversa l
75
75
  | `created_files` | string[] | Todos os arquivos criados pelo Reversa (para uninstall seguro) |
76
76
  | `entry_blocks` | object | Arquivo → `{ mode: created \| merged \| skipped, sha256 }`: blocos do Reversa em arquivos compartilhados (`AGENTS.md`, `GEMINI.md`…) |
77
77
 
78
+ ## Delegations in `active.delegations`
79
+
80
+ The session helper writes this list; agents never edit it.
81
+ A file-list delegation keeps the 1.11 shape: `target`, `step`, `inputs`, and `outputs`.
82
+ A scoped delegation has `form: "scope"` and these fields:
83
+
84
+ | Field | Type | Description |
85
+ |-------|------|-----------|
86
+ | `id` | string | `D-<uuid>`; also the name of the dispatch record |
87
+ | `form` | string | `scope` |
88
+ | `generation` | string | Owner generation; a confirmed `transfer` moves it to the new owner |
89
+ | `agent` | string | Phase agent that started it; a `checkpoint` to another agent is refused while it is in flight |
90
+ | `repository` | string | Registered repository ID, or `hub` for a parallel checkout of the hub |
91
+ | `checkout` | string | Physical absolute root of the checkout |
92
+ | `scope` | string[] | One to twenty globs relative to the checkout root |
93
+ | `actions` | string[] | Action IDs that the delegation covers |
94
+ | `deletions` | string[] | Pre-existing files that the owner approved for deletion |
95
+ | `base` | string | Commit of the checkout at dispatch |
96
+ | `record_sha256` | string | SHA-256 of the dispatch record without its `result`; a finish refuses `missing_record` when the record differs |
97
+ | `started_at`, `returned_at` | string, string \| null | Dispatch and finish times |
98
+ | `status` | string | `dispatched`, `completed`, `partial`, `blocked`, `violation`, or `cancelled` |
99
+
100
+ At most one file-list delegation is in flight.
101
+ Up to eight scoped delegations can be in flight at once, one per checkout.
102
+ A scoped delegation in `violation` still holds its checkout and counts toward that limit until the owner resolves it.
103
+ A file-list delegation and a scoped delegation are never in flight together.
104
+ While a scoped delegation is in flight or in `violation`, the state has `"delegation-format": 2` at the top level.
105
+ The helper removes that key when none is left, and refuses it in a `write` of `state.json`.
106
+ `release` is refused while one is left, and a confirmed `transfer` moves each one to the new generation.
107
+ The 1.11 helper refuses a state that lists a scoped delegation, so use an older package only after `release`.
108
+ The stored position status never becomes `waiting_delegate` for a scoped delegation.
109
+ `inspect` shows `waiting_delegate` when the stored status is `ready` and a scoped delegation is in flight.
110
+
111
+ Each scoped delegation has a dispatch record in `.reversa/context/delegations/<id>.json`.
112
+ The helper writes it before `state.json` changes.
113
+ It holds the base commit, the scope files and the inputs with their SHA-256, and the paths outside the scope that already differed from the base at dispatch.
114
+ It also holds `installer_files`, the keys of the checkout's installer manifest read at dispatch.
115
+ `delegate-finish` writes the verified `result` to the same record, and each later finish replaces it.
116
+
117
+ ### Finish and violations
118
+
119
+ `delegate-finish` compares the checkout with the base commit: the final tree, every commit of `base..head`, and the index entries hidden by skip-worktree or assume-unchanged.
120
+ A path that some commit changed counts, even when a later commit restored it.
121
+ The result has `status`, `head`, `changed`, `deleted`, `violations`, `accepted`, `installer`, `warnings`, `actions`, and `questions`.
122
+ Each violation is `{ path, reason }`, and `path` is `.` for a reason about the whole checkout.
123
+
124
+ | Reason | Meaning |
125
+ |-------|-----------|
126
+ | `outside_scope` | A change outside the scope, including Git control files and a change that a later commit restored |
127
+ | `unapproved_deletion` | A deletion inside the scope that `deletions` does not list |
128
+ | `not_a_file` | A path inside the scope that is a link, a folder, or a submodule |
129
+ | `installer_changed` | A path that an installer run writes: `.reversa/`, a top-level `.<name>/skills/reversa*/` folder, or a manifest key; it is also listed in `installer` |
130
+ | `policy_file` | A change to `.reversa/reversa-config.json` |
131
+ | `reverted_outside_scope` | A path that differed from the base at dispatch and now equals it again |
132
+ | `hidden_from_git` | An index entry flagged skip-worktree or assume-unchanged |
133
+ | `history_rewritten` | Path `.`: the head does not descend from the base |
134
+ | `too_many_changes` | Path `.`: the change set is over 5,000 files or 200 MB, so the helper hashed nothing |
135
+
136
+ The warning codes are `file_list_mismatch`, `input_changed`, and `unmatched_acceptance`.
137
+ A delegation in `violation` stays open: `delegate-finish` with the same `id` verifies it again from the base commit.
138
+ On that later finish the return's `commit` may be an ancestor of the head, because the coordinator may have added restore commits.
139
+ Its optional `accepted` lists up to 200 paths that the owner accepted; each matching violation moves to `accepted` as `{ path, sha256, reason }`.
140
+ `sha256` is null for a deletion, and an `accepted` field on a delegation that is not in `violation` is refused.
141
+ A path `.` cannot be accepted, so the coordinator fixes the checkout or cancels.
142
+ `"result": null` cancels a delegation in `violation`.
143
+
78
144
  ## Fases válidas
79
145
 
80
146
  `reconhecimento` → `escavacao` → `interpretacao` → `geracao` → `revisao`