carrick 0.3.183 → 0.3.185

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 (85) hide show
  1. package/dist/contract.d.ts +0 -4
  2. package/dist/contract.js.map +1 -1
  3. package/dist/facts/fetch.d.ts +1 -1
  4. package/dist/facts/fetch.js +1 -1
  5. package/dist/facts/fetch.js.map +1 -1
  6. package/dist/held/client.d.ts +1 -1
  7. package/dist/held/client.js +27 -19
  8. package/dist/held/client.js.map +1 -1
  9. package/dist/held/clone-worker.d.ts +1 -0
  10. package/dist/held/clone-worker.js +7 -0
  11. package/dist/held/clone-worker.js.map +1 -0
  12. package/dist/held/daemon.d.ts +92 -4
  13. package/dist/held/daemon.js +418 -74
  14. package/dist/held/daemon.js.map +1 -1
  15. package/dist/held/paths.d.ts +9 -0
  16. package/dist/held/paths.js +9 -0
  17. package/dist/held/paths.js.map +1 -1
  18. package/dist/held/registry.d.ts +8 -0
  19. package/dist/held/registry.js +28 -0
  20. package/dist/held/registry.js.map +1 -1
  21. package/dist/held/run.js +8 -0
  22. package/dist/held/run.js.map +1 -1
  23. package/dist/held/runtime.js +88 -17
  24. package/dist/held/runtime.js.map +1 -1
  25. package/dist/held/shadow.d.ts +62 -0
  26. package/dist/held/shadow.js +359 -1
  27. package/dist/held/shadow.js.map +1 -1
  28. package/dist/held/state.d.ts +2 -1
  29. package/dist/held/state.js.map +1 -1
  30. package/dist/hook/added.d.ts +51 -0
  31. package/dist/hook/added.js +96 -0
  32. package/dist/hook/added.js.map +1 -0
  33. package/dist/hook/confirm.d.ts +15 -0
  34. package/dist/hook/confirm.js +28 -3
  35. package/dist/hook/confirm.js.map +1 -1
  36. package/dist/hook/edit-flow.d.ts +7 -0
  37. package/dist/hook/edit-flow.js +29 -8
  38. package/dist/hook/edit-flow.js.map +1 -1
  39. package/dist/hook/late.d.ts +24 -7
  40. package/dist/hook/late.js +100 -33
  41. package/dist/hook/late.js.map +1 -1
  42. package/dist/hook/not-checked.d.ts +13 -0
  43. package/dist/hook/not-checked.js +50 -1
  44. package/dist/hook/not-checked.js.map +1 -1
  45. package/dist/hook/post-edit.d.ts +2 -0
  46. package/dist/hook/post-edit.js +3 -1
  47. package/dist/hook/post-edit.js.map +1 -1
  48. package/dist/hook/post-read.js +8 -1
  49. package/dist/hook/post-read.js.map +1 -1
  50. package/dist/hook/rechecks.d.ts +23 -5
  51. package/dist/hook/rechecks.js +31 -6
  52. package/dist/hook/rechecks.js.map +1 -1
  53. package/dist/hook/refresh.d.ts +7 -2
  54. package/dist/hook/refresh.js +7 -2
  55. package/dist/hook/refresh.js.map +1 -1
  56. package/dist/hook/session-start.js +17 -1
  57. package/dist/hook/session-start.js.map +1 -1
  58. package/dist/hook/similar.d.ts +6 -3
  59. package/dist/hook/similar.js +10 -3
  60. package/dist/hook/similar.js.map +1 -1
  61. package/dist/hook/stop-wait.js +24 -9
  62. package/dist/hook/stop-wait.js.map +1 -1
  63. package/dist/hook/upgrade.d.ts +1 -1
  64. package/dist/hook/upgrade.js +4 -1
  65. package/dist/hook/upgrade.js.map +1 -1
  66. package/dist/hook/usage.d.ts +1 -1
  67. package/dist/hook/usage.js +1 -1
  68. package/dist/hook/usage.js.map +1 -1
  69. package/dist/hook/worktree-rules.d.ts +5 -0
  70. package/dist/hook/worktree-rules.js +30 -0
  71. package/dist/hook/worktree-rules.js.map +1 -0
  72. package/dist/hook/worktree.d.ts +5 -0
  73. package/dist/hook/worktree.js +7 -0
  74. package/dist/hook/worktree.js.map +1 -1
  75. package/dist/render.d.ts +3 -1
  76. package/dist/render.js +8 -9
  77. package/dist/render.js.map +1 -1
  78. package/dist/update.js +2 -1
  79. package/dist/update.js.map +1 -1
  80. package/package.json +6 -6
  81. package/plugin/.claude-plugin/plugin.json +1 -1
  82. package/templates/skills/carrick-audit.md +325 -95
  83. package/templates/skills/carrick-census.md +11 -2
  84. package/templates/skills/carrick-drift.md +56 -13
  85. package/templates/skills/carrick-reuse.md +13 -28
@@ -1,66 +1,214 @@
1
1
  ---
2
2
  name: carrick-audit
3
- description: Use when the ask is what is wrong in this codebase, what to clean up, or a health check of the project. Reads what the Carrick index already flags on main (calls that reach no route, type mismatches between endpoints and their callers, functions written twice), proves each item in source, and returns a fix list. It reads a lot of source, so it uses many tokens; narrow it to one service where you can.
3
+ description: Use when the ask is what is wrong in this codebase, what to clean up, a health check of the project, or where the whole project has built the same thing twice. A full audit from the Carrick index on main (calls that reach no route, type mismatches between endpoints and their callers, functions written twice, routes written twice, one job done several ways), with each item proven in source and a fix list at the end. It states its estimated tokens and minutes before it reads any source; narrow it to one service to spend less.
4
4
  ---
5
5
 
6
- # What the index flags on main, proven in source
6
+ # A full audit from the index, proven in source
7
7
 
8
8
  {{SCOPE_NOTE}}
9
9
 
10
- Cost: this skill opens source for every item it reads. On a monorepo of six
11
- services and about 1,600 TypeScript files, ten type mismatches and ten groups of
12
- similar functions took one headless Sonnet run 2 to 3 minutes and 72 to 81
13
- turns: about 130,000 new input tokens, 1.7 to 2.6 million cached input tokens
14
- and 16,000 to 19,000 output tokens (3 runs, 19 Nov 2026).
10
+ Three rules hold from the first call to the last.
15
11
 
16
- The index states the leads. Your work is to prove or drop each one in source.
17
- Class nothing from the index's own words alone.
12
+ - **Leads come from the index.** Every item starts as a row a Carrick call
13
+ returned. Do not read through the code looking for problems. Open source only
14
+ to prove or drop a row: the lines the row names, and a grep for a path or a
15
+ name the row names.
16
+ - **Nothing is classed from the index's words alone.** Every item you call real
17
+ quotes the source line that makes it real. Say what code does only where you
18
+ can quote the line that does it; a comment or a log line is not behaviour.
19
+ Name a caller, a count or what a file mounts only from a row or a line you
20
+ hold; where you hold none, leave the statement out.
21
+ - **Nothing is skipped or cut short.** Every section runs. Each list is paged to
22
+ its end. Each section ends with a count line: rows the index returned against
23
+ rows you classed. The two numbers are equal, or the line says which call was
24
+ refused.
18
25
 
19
- ## 1. The counts
26
+ Run one command per shell call, with no `;`, `&&`, `|` or `$(...)`: a
27
+ non-interactive run refuses compound commands.
28
+
29
+ ## 1. Count, estimate, ask
30
+
31
+ Four calls. Open no source yet.
20
32
 
21
33
  ```
22
34
  get_project_map({{SCOPE}})
35
+ get_service_graph({{SCOPE}}, limit: 1)
36
+ find_similar({{SCOPE}}, audit: true, limit: 1)
37
+ get_findings({{SCOPE}}, limit: 1)
38
+ ```
39
+
40
+ Read these counts out of the answers:
41
+
42
+ - **Calls that reach no route**: in the graph's `unmatched_by_reason`, the sum
43
+ of `no_matching_producer`, `no_case_answers` and `procedure_unserved`. Keep
44
+ `unmatched_by_service` too: section A reads those services.
45
+ - **Pairs**: each consumer and producer pair under the map's CONSUMERS. Where
46
+ the map cuts the list short, call it again with `detail: true`.
47
+ - **Groups of similar functions**: `total_clusters` from `find_similar`.
48
+ - **Operations served**: the endpoint count per service in the map's SERVICES.
49
+ - The first line of the `get_findings` answer (`FINDINGS · project <slug> ·
50
+ index at <commits> · built <day>`): copy it to the top of the report, word
51
+ for word. Where the answer says no findings list has been built yet, say so
52
+ in the report and carry on: the sections below ask the index directly.
53
+
54
+ Where the ask is only where the project has built the same thing twice, or
55
+ which duplicates are worth fixing, the audit is sections C, D and E: count and
56
+ estimate those three, and say in the report that A and B were not asked for.
57
+ It is still the whole of C, D and E. Every unit of the three runs, in
58
+ sub-agents where you can start them, and the answer waits for every count
59
+ line: the duplicates most worth fixing sit low on the list, so its first page
60
+ does not answer the question. Any other ask runs all five.
61
+
62
+ Work out the estimate from the counts. New tokens are input read for the first
63
+ time plus output:
64
+
65
+ | Section | Per item | New tokens |
66
+ |---|---|---|
67
+ | Counting and the report | once | 80,000 |
68
+ | A. Calls that reach no route | each service with unmatched calls | 20,000 |
69
+ | | each call that reaches no route | 6,000 |
70
+ | B. Type verdicts | each pair | 16,000 |
71
+ | C. Functions written twice | each group | 3,500 |
72
+ | D. Routes written twice | each 100 operations served | 90,000 |
73
+ | E. One job, several answers | once | 110,000 |
74
+
75
+ Each turn also re-reads what the run already holds from the cache: about six
76
+ times the new tokens again, at a tenth of the price. Time is about 13 minutes
77
+ for each million new tokens when the sections run one after another, and about
78
+ half of that with sub-agents. These figures were measured with Claude Sonnet
79
+ on a monorepo of 17 packages, 208 operations and 4,500 functions (24 Nov 2026):
80
+ about 1 million new tokens and 5 minutes a run with sub-agents.
81
+
82
+ The first thing the user reads from you is this block, filled in. Write it as
83
+ text in your reply, not only in your reasoning, before any source is opened:
84
+ ahead of the first call of section 2, and at the latest as your first words
85
+ once the first units have started and before any has returned.
86
+
87
+ ```
88
+ Carrick audit: estimate, before any source is read
89
+ - Calls that reach no route: <n>, in <n> services with unmatched calls
90
+ - Consumer and producer pairs: <n>
91
+ - Groups of similar functions: <n>
92
+ - Operations served: <n>
93
+ Estimate: about <total> new tokens (A <n>, B <n>, C <n>, D <n>, E <n>, counting and report <n>)
94
+ Time: about <n> minutes with sub-agents, about <n> one section after another
23
95
  ```
24
96
 
25
- Note the counts under FOUND ON MAIN: type mismatches and similar functions.
26
- Note also how many unmatched calls it says match no route.
97
+ After the block, one of two things:
98
+
99
+ - You have a tool for putting a question to the user (such as
100
+ `AskUserQuestion`): use it to ask whether to go ahead or to narrow the audit
101
+ to one service or to some sections, and wait for the answer.
102
+ - You have no such tool: nobody can answer, so do not end your turn on a
103
+ question. Carry on with every section in the same turn.
104
+
105
+ There is no cap in either case.
106
+
107
+ ## 2. Run every section
108
+
109
+ Sections A to E do not depend on each other. Split them into units:
110
+
111
+ - **A**: one unit for each service in `unmatched_by_service` with more than 30
112
+ unmatched calls, and one unit for all the other services in it together.
113
+ - **B**: one unit for every 10 pairs.
114
+ - **C**: one unit for every 20 groups: offsets 0 to 19, 20 to 39, and so on to
115
+ `total_clusters`.
116
+ - **D**: one unit.
117
+ - **E**: one unit.
27
118
 
28
- Your first words to the user are the three counts and the cap you will use,
29
- written before you open any source. Where
30
- you can ask, offer to narrow to one service or cap the count. Where you cannot
31
- wait for a reply, such as a non-interactive run, the run caps each section at
32
- 10, says so, and carries on.
119
+ Where you can start sub-agents, give each unit to its own sub-agent and start
120
+ them together, six at a time at most. The reply that starts them opens with
121
+ the estimate block from step 1 as text, where the user has not been shown it
122
+ yet. The brief for each is these words with the unit filled in, and nothing
123
+ else:
33
124
 
34
- ## 2. Type mismatches
125
+ > Load the carrick-audit skill. Run only section <letter> of it, for <the
126
+ > unit: its services or pairs, each named as the index spells it, or its
127
+ > offsets>. Work to the end of the unit
128
+ > and return its table, its count line and any refused calls. Run no other
129
+ > section. Do not estimate, do not ask the user anything and do not start
130
+ > sub-agents.
131
+
132
+ Where you cannot start sub-agents, run the units yourself in the order above,
133
+ and write each unit's table and count line to the user before you start the
134
+ next unit.
135
+
136
+ A unit is done when it has returned its count line and the two numbers in it
137
+ are equal. Run again any unit that came back without one.
138
+
139
+ ## A. Calls that reach no route
140
+
141
+ For each service in the unit:
35
142
 
36
143
  ```
37
- get_findings({{SCOPE}}, kind: "type_mismatch")
144
+ get_service_graph({{SCOPE}}, service: "<service>", limit: 200)
38
145
  ```
39
146
 
40
- Copy the first line of the answer (`FINDINGS · project <slug> · index at
41
- <commits> · built <day>`) to the top of the report, word for word. The report's
42
- first line names the index commit and the day the list was built.
147
+ Read `unmatched_calls` and nothing else: the other arrays are for other
148
+ questions, so never page for them. Page with `offset` until you have seen as
149
+ many unmatched rows as `unmatched_count`. Take only the rows whose `reason` is
150
+ `no_matching_producer`, `no_case_answers` or `procedure_unserved`: each names
151
+ an operation no indexed service serves. The other reasons go to third parties
152
+ or to a base Carrick has not placed, and are not evidence of a broken call.
43
153
 
44
- When the answer is `No findings list has been built for this project yet.`,
45
- stop the audit: the similar-functions list in step 3 comes from the same list.
46
- Tell the user in one sentence that the index has not built
47
- its findings list yet and that the list is built after a scan of main. Do not
48
- look for issues by hand and present them as the audit.
154
+ For each row you took, open the call site at its file and line. Then ask the
155
+ index for the nearest thing that does exist, once for each service that serves
156
+ operations, until one answers:
49
157
 
50
- Page until the last page. For each finding, read the producer's handler, the
51
- consumer's call site and the code that uses its result. Run one command per shell
52
- call, with no `;`, `&&`, `|` or `$(...)`: a non-interactive run refuses compound
53
- commands. Where the finding does not show both types, narrow the pair:
158
+ ```
159
+ get_api_endpoints({{SCOPE}}, service: "<producer>", path_contains: "<last segment of the path, or the operation, event or topic name>")
160
+ ```
161
+
162
+ Then grep the workspace for the last two segments of the path, or for the
163
+ name, to see whether a route, a proxy rule or a rewrite serves it somewhere the
164
+ index did not read.
165
+
166
+ Class each row:
167
+
168
+ - **REAL**: the line makes this call and nothing in the workspace serves it.
169
+ Say what stops working for the user, and name the nearest route the index
170
+ holds, such as the same handler under another prefix. A relative path a
171
+ browser sends to its own origin is REAL when no route, proxy rule or rewrite
172
+ in the workspace answers it.
173
+ - **FALSE**: the line does not make this call (a `candidate: model` row whose
174
+ path is not in the source), or a route does serve it. Name the route's file
175
+ and line.
176
+ - **OUTSIDE**: the call is meant for something this project does not hold, such
177
+ as a third party or a service that is not indexed. Say which.
178
+ - **CAN'T TELL**: you cannot settle it. Say what you looked for.
179
+
180
+ Count line: `A <services>: <rows taken> no-route rows, <rows classed> classed,
181
+ <unmatched rows seen> of <unmatched_count> unmatched rows read`.
182
+
183
+ ## B. Type verdicts, pair by pair
184
+
185
+ The findings list can hold no type mismatch while a pair still holds a stored
186
+ verdict, so read the verdicts from each pair:
187
+
188
+ ```
189
+ check_compatibility({{SCOPE}}, consumer_service: "<consumer>", producer_service: "<producer>", limit: 50)
190
+ ```
191
+
192
+ Note `status`, `pairs_compared` and `pairs_uncompared`. Errors come first in
193
+ `issues`: take every row whose severity is `error`, and page with `offset`
194
+ while the last row of a page is still an error. Where `candidate_findings` is
195
+ above 0, page on and take those warning rows too. Leave the other warnings and
196
+ the unused endpoints.
197
+
198
+ An error row that says a call matches no operation is classed as in section A.
199
+ For an error row that says two types disagree, read the producer's handler, the
200
+ consumer's call site and the code that uses its result. Where the row does not
201
+ show both types, narrow the pair:
54
202
 
55
203
  ```
56
204
  get_contract_pair({{SCOPE}}, consumer_service: "<consumer>", producer_service: "<producer>", method: "<METHOD>", path: "<path>")
57
205
  ```
58
206
 
59
- Before you class a finding REAL, grep for a second producer of the same path in
60
- another router or under another prefix. Where one exists, read which one the
61
- consumer calls.
207
+ Before you class a row REAL, check for a second producer of the same path with
208
+ `get_operation({{SCOPE}}, method: "<METHOD>", path: "<path>")`. Where one
209
+ exists, read which one the consumer calls.
62
210
 
63
- Class each finding:
211
+ Class each type row:
64
212
 
65
213
  - **REAL**: the consumer reads a field the producer does not send, or a value
66
214
  the producer can send breaks the consumer, such as a null passed to code that
@@ -74,91 +222,173 @@ Class each finding:
74
222
  - **CAN'T TELL**: the value comes from somewhere you cannot read, such as a JSON
75
223
  column or an outside service. Say where.
76
224
 
77
- The fields a finding names are leads. The field that breaks may be another
78
- one; name the one that does. Where it is not one the finding names, class the
79
- finding by the field that breaks and list the named fields beside it as
80
- TYPE-ONLY.
225
+ The fields a row names are leads. The field that breaks may be another one;
226
+ name the one that does, and list the named fields beside it as TYPE-ONLY.
227
+
228
+ Count line: `B: <pairs read> of <pairs> pairs, <error rows> error rows,
229
+ <rows classed> classed, <sum of pairs_compared> calls compared, <sum of
230
+ pairs_uncompared> not compared`. A call that was not compared has no verdict,
231
+ which is not agreement.
81
232
 
82
- ## 3. Functions written twice
233
+ ## C. Functions written twice
83
234
 
84
235
  ```
85
- get_findings({{SCOPE}}, kind: "similar_functions")
236
+ find_similar({{SCOPE}}, audit: true, offset: <first offset of the unit>, limit: 20)
86
237
  ```
87
238
 
88
- Page until the last page, or to the cap the user agreed, and state the cap.
89
- Read every member of each group at its file and line, and diff the bodies.
90
- Class each member against the first:
91
-
92
- - **DUPLICATE**: same contract, nothing to name apart.
93
- - **VARIANT**: same contract, and a difference you can name in a clause.
94
- - **FALSE POSITIVE**: different contracts.
239
+ A page can come back shorter than its limit. Follow `next_offset` until you
240
+ hold every group of the unit. Where an answer carries `window`, the project is
241
+ larger than one pass: run the units for that window, then call again with
242
+ `scan_from: <next_scan_from>` and run them for the next, until an answer
243
+ carries no `next_scan_from`. Read every member of every group at its file and
244
+ line, also in a group that lists its members as locators only, and diff the
245
+ bodies. Class each group:
246
+
247
+ - **DUPLICATE**: the same job and the same result. Nothing to name apart.
248
+ - **DIVERGED**: the same job, the same kind of input and the same kind of
249
+ result, and for one input the members give different results that a user or
250
+ another system can see. Quote the line that differs in each member, and write
251
+ one input with each result beside it ("1234.5 comes out as `1,234.50` here
252
+ and `1234,5` there"). Work each result through the code line by line; where
253
+ you cannot, describe the difference in words and write no example. Every
254
+ member must be in use: say where each result is shown, from the callers the
255
+ index names, or, for a function local to one file, from that file:
256
+
257
+ ```
258
+ get_callers({{SCOPE}}, function_name: "<name>", file: "<file>")
259
+ ```
260
+
261
+ A member with no recorded caller and no other use of its name in the
262
+ workspace (grep it) is unused code, which nobody sees a result from: the
263
+ group is then VARIANT, and the row says which member is unused.
264
+ - **VARIANT**: the same job with a difference that is there on purpose or that
265
+ changes no result: an extra parameter, another unit, a format an outside
266
+ service asks for, names that state the difference (`fetchJson` beside
267
+ `fetchJsonWithAuth`). Quote the line that differs. If you cannot quote one,
268
+ the class is DUPLICATE.
269
+ - **FALSE POSITIVE**: different jobs, a different call signature (the
270
+ parameters a caller passes), a different kind of result, or handlers that
271
+ read their own component's state or props and so cannot be shared.
272
+ - **CAN'T TELL**: you could not read a body or a helper it depends on. Say
273
+ which. A group you have not proven to the end is never DIVERGED.
95
274
 
96
275
  Class what the function does: its body and the constants and helpers it reads.
97
276
  Other code in the same file that it does not read does not count.
98
277
 
99
- A different call signature (parameters a caller passes) is a different
100
- contract: FALSE POSITIVE.
278
+ For a DUPLICATE or DIVERGED group whose members sit in separate apps, check
279
+ their package.json files for a package they already share. Where one exists,
280
+ the fix is to move the function there and import it; where none does, say so:
281
+ the fix is a new shared package.
101
282
 
102
- A VARIANT quotes the line that differs. If you cannot quote one, the class is
103
- DUPLICATE.
283
+ Count line: `C <first offset>-<last offset>: <groups returned> groups,
284
+ <groups classed> classed`.
104
285
 
105
- Where the members sit in separate apps, check their package.json files for a
106
- package they already share. Where one exists, the fix is to move the function
107
- there and import it; where none does, say so: the fix is a new shared package.
286
+ ## D. Routes written twice
108
287
 
109
- ## 4. Calls that reach no route
288
+ Route handlers are left out of section C's list. Ask for them, once for each
289
+ service that serves operations:
110
290
 
111
291
  ```
112
- get_service_graph({{SCOPE}}, limit: 200)
292
+ find_similar({{SCOPE}}, audit: true, include_callbacks: true, service: "<producer>", limit: 20)
113
293
  ```
114
294
 
115
- Read `unmatched_by_reason`. Take only the rows of `unmatched_calls` whose
116
- `reason` is `no_matching_producer`, `no_case_answers` or `procedure_unserved`:
117
- each names an operation no indexed service serves. Page with `offset` until
118
- you hold as many as `unmatched_by_reason` counts for those reasons. This
119
- section has no cap: read every one. Leave the other reasons and the whole
120
- `model_calls_unplaced` list alone: they go to third parties or to a base
121
- Carrick has not placed, and are not evidence of a broken call.
122
-
123
- For each row, open the call site at its file and line. Then grep the whole
124
- workspace for the last two segments of the path, or for the operation, event or
125
- topic name, to find a route or handler that serves it under another prefix or
126
- in another router.
295
+ Page with `next_offset` to the end. Take only the groups where two or more
296
+ members are route handlers in different files: a route handler's name starts
297
+ with its method or operation kind and ends in `_handler`, such as
298
+ `post_orders_handler`. Leave every other group: section C covers the named
299
+ functions, and callbacks inside one function are not routes.
127
300
 
128
- Class each row:
301
+ For each group you took, find the full path of each handler and who calls it:
129
302
 
130
- - **REAL**: the line makes this call, and nothing in the workspace serves it.
131
- Say what the user sees when it fails, and name the nearest route that does
132
- exist, such as the same handler mounted under another prefix.
133
- - **FALSE**: the line does not make this call (a `candidate: model` row whose
134
- path is not in the source), or a route does serve it. Name the route's
135
- file and line.
136
- - **OUTSIDE**: the call is meant for something this project does not hold, such
137
- as a third party or a service that is not indexed. Say which.
138
- - **CAN'T TELL**: you cannot find what should serve it. Say what you looked for.
303
+ ```
304
+ get_api_endpoints({{SCOPE}}, service: "<producer>", path_contains: "<a word of the route's path>")
305
+ get_operation({{SCOPE}}, method: "<METHOD>", path: "<full path>")
306
+ ```
139
307
 
140
- ## 5. Report
308
+ One file and line listed under two prefixes is one router mounted twice, which
309
+ is not a copy. `consumer_count` on each operation says which copy the apps
310
+ call. Then read both handlers to their last line and diff them line by line.
311
+ Name a difference only where you quote the line from each copy; a line that is
312
+ only a comment or a log in one copy is not a difference in what the route
313
+ does. Class each group:
141
314
 
142
- One table per section, with the class column never empty, and the counts read
143
- against the counts from step 1 and any cap.
315
+ - **WRITTEN TWICE, DIFFERS**: two handlers serve the same thing and the bodies
316
+ differ in what they do. Quote a line that differs, and say which copy the
317
+ apps call and which has no recorded caller.
318
+ - **WRITTEN TWICE, SAME**: the same logic in two files.
319
+ - **NOT A COPY**: the handlers serve different things.
144
320
 
145
- Then a fix list: every REAL and DUPLICATE, most harmful first (a REAL call
146
- that reaches no route goes before a duplicate), each with
147
- file:line and the change in one line ("send createdAt from
148
- formatTaskResponse"; "move validateName into a shared package and delete the
149
- two copies"). TYPE-ONLY items go in a short list after it, as optional tidying.
321
+ Count line: `D: <groups returned> groups read, <handler groups> with route
322
+ handlers in two files, <groups classed> classed`.
150
323
 
151
- When a command or tool call you need is refused or fails, class any finding you
152
- cannot settle without it CAN'T TELL with the reason `refused: <the command>`.
153
- List every refused call under the tables, including any you then worked around.
324
+ ## E. One job, several answers
154
325
 
155
- Name the protocols the findings came from (HTTP, GraphQL, sockets, pub/sub,
156
- queues, RPC routers) and the ones that held none.
326
+ Functions that do one job and give different results are the ones a user
327
+ sees, and they rank low on a list of look-alikes. Ask the function index for
328
+ each of these jobs, one call each:
157
329
 
158
- Not covered yet: endpoints nobody calls, and routes that change data without
159
- an auth check. Say so in the report.
330
+ ```
331
+ search_by_intent({{SCOPE}}, query: "<job>", also_phrased_as: ["<the same job in other words>"], top_k: 30, compact: true)
332
+ ```
160
333
 
161
- ## 6. Act
334
+ | Job | In other words |
335
+ |---|---|
336
+ | format an amount of money as a currency string for display | turn a number of cents into a price string with a currency symbol |
337
+ | format a date or a time for display | turn a timestamp into a readable date string |
338
+ | validate or normalise a phone number | mask or format a phone number for display |
339
+ | validate an email address | check that a string is a well-formed email |
340
+ | check whether the current user may do something | check a role or a permission before an action |
341
+ | build the page or cursor arguments for a list request | encode or decode a pagination cursor |
342
+ | report an error to a tracking service | send a client error to the server |
343
+ | build the headers or base address for a call to this project's own API | wrap fetch with authentication and error handling |
344
+
345
+ In each answer, flag a set of rows when one name appears in two or more files,
346
+ or when three or more rows in one service do the job asked for. Rows that only
347
+ share a word with the query are not flagged. Read every flagged function at its
348
+ file and lines. Class each set with section C's classes: DIVERGED, DUPLICATE,
349
+ VARIANT or FALSE POSITIVE. A DIVERGED set needs the same proof: the lines that
350
+ differ, and one input with each result beside it.
351
+
352
+ Count line: `E: 8 jobs searched, <sets flagged> sets flagged, <sets classed>
353
+ classed`.
354
+
355
+ ## 3. Report
356
+
357
+ Before you write, check that you hold a count line for every unit of every
358
+ section and that its numbers are equal. Run now any unit that is missing.
359
+
360
+ The report, in this order:
361
+
362
+ 1. The `get_findings` first line. Then the estimate block you gave at the
363
+ start, again. Then one line per section: rows the index returned, rows classed,
364
+ and how many are in the fix list.
365
+ 2. **The fix list.** Every REAL, DIVERGED, WRITTEN TWICE and DUPLICATE item,
366
+ most harmful first: what a user can hit comes first (a REAL call that reaches
367
+ no route, a REAL type break), then DIVERGED, then WRITTEN TWICE, DIFFERS,
368
+ then WRITTEN TWICE, SAME, then the copies, largest group first. Each item
369
+ has its class, every file and line, what the user sees or what it costs, and
370
+ the change in one line ("send createdAt from formatTaskResponse"; "move
371
+ validateName into a shared package and delete the two copies"). An item two
372
+ sections found is one item. An item a unit could not prove to the end is not
373
+ in the fix list: it is CAN'T TELL.
374
+ 3. TYPE-ONLY and VARIANT items in a short list, as optional tidying.
375
+ 4. **Everything else the index returned**, section by section, so every row is
376
+ accounted for: each FALSE, FALSE POSITIVE, OUTSIDE, NOT A COPY and CAN'T
377
+ TELL row by name, with its class and the reason in a few words.
378
+ 5. **What the index could not tell you**: calls compared against calls not
379
+ compared, from section B; the call sites Carrick could not resolve, with the
380
+ three largest reasons from `unread_sites_by_reason`; and the rows only a
381
+ model states, from the map.
382
+ 6. Every refused or failed call, including any you then worked around. An item
383
+ you could not settle without it is CAN'T TELL with the reason `refused: <the
384
+ command>`.
385
+ 7. The protocols the items came from (HTTP, GraphQL, sockets, pub/sub, queues,
386
+ RPC routers) and the ones that held none.
387
+
388
+ Not covered yet: routes nobody calls that have no second copy, and routes that
389
+ change data without an auth check. Say so in the report.
390
+
391
+ ## 4. Act
162
392
 
163
393
  Change nothing yet. Ask the user which items on the fix list to apply, and apply
164
394
  only those.
@@ -80,8 +80,17 @@ get_operation({{SCOPE}}, method: "<METHOD>", path: "<path>")
80
80
  ```
81
81
 
82
82
  Read `consumers` only: service and `call_file_location`. Skip `unread_sites`.
83
- Where more than 10 endpoints were reached, do this for the 10 the question
84
- cares about most and say how many were not looked up.
83
+ Do this for every endpoint step 2 reached; there is no cap. Where there are
84
+ more than 15, say the number first (each lookup is one call of about 6,000
85
+ tokens) and split them into lots of 15. Where you can start sub-agents, give
86
+ each lot to its own sub-agent with this brief and nothing else:
87
+
88
+ > Call get_operation({{SCOPE}}, method, path) for each of these endpoints and
89
+ > return, for each, every consumer's service and call_file_location, or "no
90
+ > recorded caller": <the lot's methods and paths>
91
+
92
+ Where you cannot, do the lots yourself one after another. The report states
93
+ endpoints reached against endpoints looked up, and the two are equal.
85
94
 
86
95
  ## 4. Report
87
96
 
@@ -8,18 +8,34 @@ description: Use when the ask is whether a consumer and a producer still agree o
8
8
  {{SCOPE_NOTE}}
9
9
 
10
10
  `get_contract_pair` holds both sides and the verdict. It reports what the scan
11
- stored and computes no verdict of its own, and neither do you.
11
+ stored and computes no verdict of its own, and neither do you. Whether a
12
+ difference can break anything is a second question, answered in source in step
13
+ 4 and reported in its own column.
12
14
 
13
15
  ## 1. The pairs
14
16
 
15
17
  ```
16
- get_service_graph({{SCOPE}})
18
+ get_project_map({{SCOPE}})
17
19
  ```
18
20
 
19
- Each edge is a consumer and a producer. An edge carrying `via_sdk` reaches its
20
- producer through a published package and has no call site of its own. Page with
21
- `offset: <next_offset>` while the rows keep coming. To start from one service,
22
- pass `service: "<name>"`.
21
+ Each line under CONSUMERS is a producer and the services that call it: one pair
22
+ per consumer. Where the map cuts the list short, call it again with `detail:
23
+ true`. A consumer that reaches its producer through a published package has no
24
+ call site of its own.
25
+
26
+ Where the ask names one pair or one operation, do steps 2 to 4 for that. Where
27
+ it is about the whole project, every pair is read: say how many pairs there
28
+ are before you start, and do steps 2 to 4 for each. Where you can start
29
+ sub-agents, give each pair to its own sub-agent, six at a time at most, with
30
+ this brief and nothing else:
31
+
32
+ > Load the carrick-drift skill. Do its steps 2 to 4 for the one pair <consumer>
33
+ > to <producer>, every page, and return the rows, the count of operations
34
+ > returned against operations classed, and any refused calls. Do no other pair
35
+ > and start no sub-agents.
36
+
37
+ Where you cannot, do the pairs yourself one after another, and write each
38
+ pair's rows to the user before you start the next.
23
39
 
24
40
  ## 2. Each pair, operation by operation
25
41
 
@@ -74,12 +90,34 @@ A GET declares no request type by design, and `untyped_sides` already counts it
74
90
  that way. The wire note covers both readings above, so a `Date` on one side
75
91
  against a `string` on the other is not a difference.
76
92
 
77
- ## 4. Report
93
+ ## 4. Can it break: prove it in source
94
+
95
+ The classes above say what the index holds. For every DRIFT row, and every
96
+ row whose type texts differ, open source before you say it can break: the
97
+ producer's handler (how it reads the request, what it sends), the consumer's
98
+ call site, and the code that uses the response. A body the two sides describe
99
+ differently can still be read correctly, so look at how the producer parses it
100
+ (a validator, a form or multipart parser) before you call it a mismatch. Then
101
+ give the row one of these:
78
102
 
79
- | operation | class | producer type | consumer type | call site | verdict |
80
- |---|---|---|---|---|---|
81
- | GET /api/orders/:id | DRIFT | Order | OrderSummary | web/src/orders.ts:31 | incompatible |
82
- | POST /api/orders | UNRESOLVED | NewOrder | OrderDraft | web/src/orders.ts:52 | unresolved; type texts differ on `note` |
103
+ - **REAL**: the consumer reads a field the producer does not send, or one side
104
+ can send a value that breaks the other, such as a null passed to code that
105
+ needs a string. Quote the line that breaks.
106
+ - **TYPE-ONLY**: the types disagree and no value that is sent can break
107
+ anything: a null that is dropped or guarded before use, a string holding a
108
+ fixed set of values against a union of them. Quote the guard.
109
+ - **FALSE**: the index is wrong about one side: the field is sent, the body is
110
+ parsed the way the consumer sends it, or the type is misread. Quote the line.
111
+ - **CAN'T TELL**: the value comes from somewhere you cannot read. Say where.
112
+
113
+ Never write that a row can break, or is likely to, from the type texts alone.
114
+
115
+ ## 5. Report
116
+
117
+ | operation | class | producer type | consumer type | call site | verdict | can it break |
118
+ |---|---|---|---|---|---|---|
119
+ | GET /api/orders/:id | DRIFT | Order | OrderSummary | web/src/orders.ts:31 | incompatible | REAL: the page reads `total`, which the handler no longer sends (api/orders.ts:88) |
120
+ | POST /api/orders | UNRESOLVED | NewOrder | OrderDraft | web/src/orders.ts:52 | unresolved; type texts differ on `note` | TYPE-ONLY: the handler drops a null `note` (api/orders.ts:40) |
83
121
 
84
122
  Class words, and only these: MATCH, DRIFT, UNRESOLVED, NOT JUDGED, CONSUMER
85
123
  UNTYPED, PRODUCER UNTYPED. Every operation the answer returned carries one of
@@ -90,14 +128,19 @@ UNRESOLVED, NOT JUDGED, MATCH, because a stored incompatible verdict is the
90
128
  finding and a side carrying no type is why nothing past it could be judged.
91
129
  A reading of the two type texts goes in the verdict
92
130
  column beside the stored state, in the words "type texts differ", so nothing in
93
- the table reads as a verdict the index did not give you.
131
+ the table reads as a verdict the index did not give you. The last column
132
+ holds step 4's word and its quoted line for every DRIFT row and every row whose
133
+ type texts differ, and is empty for the rest.
134
+
135
+ For a whole-project ask, state pairs read against pairs the map lists, and put
136
+ the REAL rows first.
94
137
 
95
138
  State alongside it: `operations_total` against `operations_shown`,
96
139
  `matched_calls` and `unmatched_calls`, `dropped_rows`, and the `non_http_note`
97
140
  where the pair also carries GraphQL, socket or pub/sub operations, whose type
98
141
  text this surface does not hold.
99
142
 
100
- ## 5. Act
143
+ ## 6. Act
101
144
 
102
145
  Change no type unless you were asked to. Offer one issue per DRIFT, and one per
103
146
  UNRESOLVED or NOT JUDGED row whose type texts differ. File the ones accepted: