carrick 0.3.184 → 0.3.186
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.
- package/dist/facts/fetch.d.ts +1 -1
- package/dist/facts/fetch.js +1 -1
- package/dist/facts/fetch.js.map +1 -1
- package/dist/held/client.d.ts +1 -1
- package/dist/held/client.js +27 -19
- package/dist/held/client.js.map +1 -1
- package/dist/held/clone-worker.d.ts +1 -0
- package/dist/held/clone-worker.js +7 -0
- package/dist/held/clone-worker.js.map +1 -0
- package/dist/held/coverage.d.ts +3 -1
- package/dist/held/coverage.js +40 -7
- package/dist/held/coverage.js.map +1 -1
- package/dist/held/daemon.d.ts +92 -4
- package/dist/held/daemon.js +418 -74
- package/dist/held/daemon.js.map +1 -1
- package/dist/held/paths.d.ts +9 -0
- package/dist/held/paths.js +9 -0
- package/dist/held/paths.js.map +1 -1
- package/dist/held/registry.d.ts +8 -0
- package/dist/held/registry.js +28 -0
- package/dist/held/registry.js.map +1 -1
- package/dist/held/run.js +8 -0
- package/dist/held/run.js.map +1 -1
- package/dist/held/runtime.d.ts +5 -0
- package/dist/held/runtime.js +104 -19
- package/dist/held/runtime.js.map +1 -1
- package/dist/held/shadow.d.ts +62 -0
- package/dist/held/shadow.js +359 -1
- package/dist/held/shadow.js.map +1 -1
- package/dist/held/state.d.ts +2 -1
- package/dist/held/state.js.map +1 -1
- package/dist/hook/added.d.ts +51 -0
- package/dist/hook/added.js +96 -0
- package/dist/hook/added.js.map +1 -0
- package/dist/hook/edit-flow.d.ts +7 -0
- package/dist/hook/edit-flow.js +25 -8
- package/dist/hook/edit-flow.js.map +1 -1
- package/dist/hook/late.d.ts +5 -2
- package/dist/hook/late.js +35 -11
- package/dist/hook/late.js.map +1 -1
- package/dist/hook/not-checked.d.ts +13 -0
- package/dist/hook/not-checked.js +50 -1
- package/dist/hook/not-checked.js.map +1 -1
- package/dist/hook/post-edit.d.ts +2 -0
- package/dist/hook/post-edit.js +3 -1
- package/dist/hook/post-edit.js.map +1 -1
- package/dist/hook/post-read.js +8 -1
- package/dist/hook/post-read.js.map +1 -1
- package/dist/hook/rechecks.d.ts +23 -5
- package/dist/hook/rechecks.js +31 -6
- package/dist/hook/rechecks.js.map +1 -1
- package/dist/hook/refresh.d.ts +7 -2
- package/dist/hook/refresh.js +7 -2
- package/dist/hook/refresh.js.map +1 -1
- package/dist/hook/session-start.js +17 -1
- package/dist/hook/session-start.js.map +1 -1
- package/dist/hook/similar.d.ts +6 -3
- package/dist/hook/similar.js +10 -3
- package/dist/hook/similar.js.map +1 -1
- package/dist/hook/stop-wait.js +13 -4
- package/dist/hook/stop-wait.js.map +1 -1
- package/dist/hook/upgrade.d.ts +1 -1
- package/dist/hook/upgrade.js +4 -1
- package/dist/hook/upgrade.js.map +1 -1
- package/dist/hook/usage.d.ts +1 -1
- package/dist/hook/usage.js +1 -1
- package/dist/hook/usage.js.map +1 -1
- package/dist/hook/worktree-rules.d.ts +5 -0
- package/dist/hook/worktree-rules.js +30 -0
- package/dist/hook/worktree-rules.js.map +1 -0
- package/dist/hook/worktree.d.ts +5 -0
- package/dist/hook/worktree.js +7 -0
- package/dist/hook/worktree.js.map +1 -1
- package/dist/init/doctor.d.ts +1 -1
- package/dist/init/doctor.js +13 -3
- package/dist/init/doctor.js.map +1 -1
- package/dist/update.js +2 -1
- package/dist/update.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/engine-stamp.json +1 -1
- package/sidecar/dist/src/type-inferrer.d.ts +14 -2
- package/sidecar/dist/src/type-inferrer.js +32 -7
- package/sidecar/dist/src/types.d.ts +4 -2
- package/templates/skills/carrick-audit.md +325 -95
- package/templates/skills/carrick-census.md +11 -2
- package/templates/skills/carrick-drift.md +56 -13
- package/templates/skills/carrick-reuse.md +13 -28
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carrick",
|
|
3
3
|
"description": "Claude Code plugin for Carrick, which indexes TypeScript codebases across service and repository boundaries. After each edit it adds the file's routes, calls, and cross-service type mismatches to the session, and it registers Carrick's language server. It pairs with the Carrick MCP server, which lets agents search functions by intent rather than name.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.186",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Carrick",
|
|
7
7
|
"email": "hello@carrick.tools"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs_sha256":"
|
|
1
|
+
{"inputs_sha256":"fc5550e393efbcbb9f64a68343eaa33d3b15f8797cddc678bfa14bb2c30a2446"}
|
|
@@ -1623,6 +1623,13 @@ export declare class TypeInferrer {
|
|
|
1623
1623
|
* the answer is `unknown` with the decided reason `serialised_body_unread`
|
|
1624
1624
|
* and one sentence per cause: the branches that did read are part of the
|
|
1625
1625
|
* contract, and neither the envelope nor its `string` body is any of it.
|
|
1626
|
+
*
|
|
1627
|
+
* carrick#5133: that abstain still names where the handler sends the values
|
|
1628
|
+
* it found (`read_spans`): each read branch's payload, and each payload whose
|
|
1629
|
+
* type holds `any` or `unknown`, joined as a typed answer joins them. A
|
|
1630
|
+
* branch with no value found (a prebuilt envelope, a helper not followed, a
|
|
1631
|
+
* body not made by `JSON.stringify`) names nothing, and the stated type
|
|
1632
|
+
* stays `unknown`.
|
|
1626
1633
|
*/
|
|
1627
1634
|
private inferSerialisedBodyEnvelope;
|
|
1628
1635
|
/**
|
|
@@ -2913,10 +2920,15 @@ export declare class TypeInferrer {
|
|
|
2913
2920
|
* them. An answer whose text is bare `any`/`unknown`, a no-value type
|
|
2914
2921
|
* (`void`, `undefined`, `never`) or empty has no value to place and gets
|
|
2915
2922
|
* none, annotated or not; a decided abstain is built by
|
|
2916
|
-
* `decidedAbstain` and never passes through here
|
|
2917
|
-
*
|
|
2923
|
+
* `decidedAbstain` and never passes through here (the one abstain that
|
|
2924
|
+
* names its sends calls `stampReads` itself, carrick#5133).
|
|
2918
2925
|
*/
|
|
2919
2926
|
private withReads;
|
|
2927
|
+
/**
|
|
2928
|
+
* Stamp `nodes` on `inferred` as `read_spans`, deduped, whatever its text.
|
|
2929
|
+
* Outer parentheses are peeled: `({ ... })` is the literal.
|
|
2930
|
+
*/
|
|
2931
|
+
private stampReads;
|
|
2920
2932
|
private getNodeLocation;
|
|
2921
2933
|
private createInferredType;
|
|
2922
2934
|
/**
|
|
@@ -168,6 +168,8 @@ const SERIALISED_BODY_UNREAD_DETAIL = {
|
|
|
168
168
|
builder: 'A return calls a response helper that could not be followed to the one value it serialises, so what it sends was not read.',
|
|
169
169
|
top_type: 'A return serialises a value typed any or unknown, so the shape of its body is not known.',
|
|
170
170
|
};
|
|
171
|
+
/** Type text with no value to place: bare `any`/`unknown`, a no-value type, or empty. */
|
|
172
|
+
const NO_VALUE_TEXT = /^\s*(any|unknown|void|undefined|never)?\s*$/;
|
|
171
173
|
/** `any` or `unknown` as a type in printed type text, not as a member name or a string. */
|
|
172
174
|
const TOP_TYPE_TOKEN = /(?<![\w$'"`])(?:any|unknown)(?![\w$'"`?:])/;
|
|
173
175
|
/**
|
|
@@ -6678,31 +6680,45 @@ export class TypeInferrer {
|
|
|
6678
6680
|
* the answer is `unknown` with the decided reason `serialised_body_unread`
|
|
6679
6681
|
* and one sentence per cause: the branches that did read are part of the
|
|
6680
6682
|
* contract, and neither the envelope nor its `string` body is any of it.
|
|
6683
|
+
*
|
|
6684
|
+
* carrick#5133: that abstain still names where the handler sends the values
|
|
6685
|
+
* it found (`read_spans`): each read branch's payload, and each payload whose
|
|
6686
|
+
* type holds `any` or `unknown`, joined as a typed answer joins them. A
|
|
6687
|
+
* branch with no value found (a prebuilt envelope, a helper not followed, a
|
|
6688
|
+
* body not made by `JSON.stringify`) names nothing, and the stated type
|
|
6689
|
+
* stays `unknown`.
|
|
6681
6690
|
*/
|
|
6682
6691
|
inferSerialisedBodyEnvelope(request, func) {
|
|
6683
6692
|
const wire = this.wireFormatFor(request);
|
|
6684
6693
|
const branches = this.envelopeBranches(func);
|
|
6685
6694
|
const candidates = [];
|
|
6695
|
+
const located = [];
|
|
6686
6696
|
const causes = new Set();
|
|
6687
6697
|
for (const branch of branches) {
|
|
6688
6698
|
const read = this.readEnvelopeBranch(branch, func, wire, 0);
|
|
6689
6699
|
if (read === 'dropped')
|
|
6690
6700
|
continue;
|
|
6691
|
-
if ('unread' in read)
|
|
6701
|
+
if ('unread' in read) {
|
|
6692
6702
|
causes.add(read.unread);
|
|
6693
|
-
|
|
6703
|
+
if (read.located)
|
|
6704
|
+
located.push(read.located);
|
|
6705
|
+
}
|
|
6706
|
+
else {
|
|
6694
6707
|
candidates.push(read);
|
|
6708
|
+
}
|
|
6695
6709
|
}
|
|
6696
6710
|
const location = this.getNodeLocation(func);
|
|
6697
6711
|
if (causes.size > 0) {
|
|
6698
6712
|
this.log(`Return at ${request.file_path}:${request.line_number} is a serialised-body ` +
|
|
6699
6713
|
`envelope and a returned branch was not read (${[...causes].join(', ')}); abstaining`);
|
|
6700
|
-
|
|
6714
|
+
const abstain = this.decidedAbstain(request, location, {
|
|
6701
6715
|
path: '',
|
|
6702
6716
|
kind: 'unknown',
|
|
6703
6717
|
reason: 'serialised_body_unread',
|
|
6704
6718
|
detail: [...causes].map((cause) => SERIALISED_BODY_UNREAD_DETAIL[cause]).join(' '),
|
|
6705
6719
|
});
|
|
6720
|
+
const placed = [...candidates, ...located].filter((candidate) => !NO_VALUE_TEXT.test(candidate.typeString));
|
|
6721
|
+
return this.stampReads(abstain, this.joinPayloadCandidates(placed)?.nodes ?? []);
|
|
6706
6722
|
}
|
|
6707
6723
|
const recovered = this.joinPayloadCandidates(candidates);
|
|
6708
6724
|
if (!recovered) {
|
|
@@ -7085,7 +7101,9 @@ export class TypeInferrer {
|
|
|
7085
7101
|
* envelope.
|
|
7086
7102
|
*/
|
|
7087
7103
|
checkedEnvelopeCandidate(candidate) {
|
|
7088
|
-
return TOP_TYPE_TOKEN.test(candidate.typeString)
|
|
7104
|
+
return TOP_TYPE_TOKEN.test(candidate.typeString)
|
|
7105
|
+
? { unread: 'top_type', located: candidate }
|
|
7106
|
+
: candidate;
|
|
7089
7107
|
}
|
|
7090
7108
|
/**
|
|
7091
7109
|
* The request field each member of a joined union answers
|
|
@@ -10776,12 +10794,19 @@ export class TypeInferrer {
|
|
|
10776
10794
|
* them. An answer whose text is bare `any`/`unknown`, a no-value type
|
|
10777
10795
|
* (`void`, `undefined`, `never`) or empty has no value to place and gets
|
|
10778
10796
|
* none, annotated or not; a decided abstain is built by
|
|
10779
|
-
* `decidedAbstain` and never passes through here
|
|
10780
|
-
*
|
|
10797
|
+
* `decidedAbstain` and never passes through here (the one abstain that
|
|
10798
|
+
* names its sends calls `stampReads` itself, carrick#5133).
|
|
10781
10799
|
*/
|
|
10782
10800
|
withReads(inferred, nodes) {
|
|
10783
|
-
if (
|
|
10801
|
+
if (NO_VALUE_TEXT.test(inferred.type_string))
|
|
10784
10802
|
return inferred;
|
|
10803
|
+
return this.stampReads(inferred, nodes);
|
|
10804
|
+
}
|
|
10805
|
+
/**
|
|
10806
|
+
* Stamp `nodes` on `inferred` as `read_spans`, deduped, whatever its text.
|
|
10807
|
+
* Outer parentheses are peeled: `({ ... })` is the literal.
|
|
10808
|
+
*/
|
|
10809
|
+
stampReads(inferred, nodes) {
|
|
10785
10810
|
const seen = new Set();
|
|
10786
10811
|
const spans = [];
|
|
10787
10812
|
for (const read of nodes) {
|
|
@@ -1694,8 +1694,10 @@ export interface InferredType {
|
|
|
1694
1694
|
* expression a response joined, the annotation or schema a declared
|
|
1695
1695
|
* contract came from, or the one body read a request was taken from.
|
|
1696
1696
|
* `source_location` still names the one node the answer is located at (on
|
|
1697
|
-
* a producer, usually the handler). Absent on
|
|
1698
|
-
*
|
|
1697
|
+
* a producer, usually the handler). Absent on an answer whose text is bare
|
|
1698
|
+
* `any` or `unknown` and on a decided abstain: there is no value to place.
|
|
1699
|
+
* One abstain is the exception (carrick#5133): `serialised_body_unread`
|
|
1700
|
+
* names the sends it found, while its text stays `unknown`.
|
|
1699
1701
|
*/
|
|
1700
1702
|
read_spans?: ReadSpan[];
|
|
1701
1703
|
/** The kind of inference that was performed */
|
|
@@ -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,
|
|
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
|
-
#
|
|
6
|
+
# A full audit from the index, proven in source
|
|
7
7
|
|
|
8
8
|
{{SCOPE_NOTE}}
|
|
9
9
|
|
|
10
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
144
|
+
get_service_graph({{SCOPE}}, service: "<service>", limit: 200)
|
|
38
145
|
```
|
|
39
146
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
60
|
-
|
|
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
|
|
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
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
##
|
|
233
|
+
## C. Functions written twice
|
|
83
234
|
|
|
84
235
|
```
|
|
85
|
-
|
|
236
|
+
find_similar({{SCOPE}}, audit: true, offset: <first offset of the unit>, limit: 20)
|
|
86
237
|
```
|
|
87
238
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
100
|
-
|
|
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
|
-
|
|
103
|
-
|
|
283
|
+
Count line: `C <first offset>-<last offset>: <groups returned> groups,
|
|
284
|
+
<groups classed> classed`.
|
|
104
285
|
|
|
105
|
-
|
|
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
|
-
|
|
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
|
-
|
|
292
|
+
find_similar({{SCOPE}}, audit: true, include_callbacks: true, service: "<producer>", limit: 20)
|
|
113
293
|
```
|
|
114
294
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
301
|
+
For each group you took, find the full path of each handler and who calls it:
|
|
129
302
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
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
|
-
|
|
143
|
-
|
|
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
|
-
|
|
146
|
-
|
|
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
|
-
|
|
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
|
-
|
|
156
|
-
|
|
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
|
-
|
|
159
|
-
|
|
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
|
-
|
|
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.
|