carrick 0.3.162 → 0.3.164
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/held/early.js +62 -3
- package/dist/held/early.js.map +1 -1
- package/dist/held/runtime.js +29 -1
- package/dist/held/runtime.js.map +1 -1
- package/dist/init/task-skills.d.ts +1 -1
- package/dist/init/task-skills.js +1 -0
- package/dist/init/task-skills.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/capture/check-probe.d.ts +9 -4
- package/sidecar/dist/src/capture/check-probe.js +11 -5
- package/sidecar/dist/src/capture/index.js +12 -15
- package/sidecar/dist/src/capture/installed-root.d.ts +17 -0
- package/sidecar/dist/src/capture/installed-root.js +39 -0
- package/sidecar/dist/src/capture/lockfile.d.ts +1 -1
- package/sidecar/dist/src/capture/lockfile.js +9 -3
- package/sidecar/dist/src/capture/self-check.d.ts +2 -2
- package/sidecar/dist/src/capture/stub-resolution.d.ts +3 -3
- package/sidecar/dist/src/capture/stub-resolution.js +3 -3
- package/sidecar/dist/src/engine-stamp.json +1 -1
- package/sidecar/dist/src/type-inferrer.d.ts +76 -0
- package/sidecar/dist/src/type-inferrer.js +267 -5
- package/sidecar/dist/src/validators.d.ts +16 -16
- package/templates/skills/carrick-audit.md +97 -0
- package/templates/skills/carrick-census.md +73 -87
|
@@ -302,6 +302,12 @@ export class TypeInferrer {
|
|
|
302
302
|
* named one. The open-parameter check (carrick#4201) reads it.
|
|
303
303
|
*/
|
|
304
304
|
printedTypes = new WeakMap();
|
|
305
|
+
/**
|
|
306
|
+
* The type the source states for a call result whose text is that
|
|
307
|
+
* statement (a cast, an annotation, a narrowing). The consumer floor
|
|
308
|
+
* (carrick#4513 P1) reads it beside the printed type.
|
|
309
|
+
*/
|
|
310
|
+
statedTypes = new WeakMap();
|
|
305
311
|
unwidenedLimits;
|
|
306
312
|
now;
|
|
307
313
|
/**
|
|
@@ -1058,11 +1064,82 @@ export class TypeInferrer {
|
|
|
1058
1064
|
return inferred;
|
|
1059
1065
|
const printed = this.printedTypes.get(inferred);
|
|
1060
1066
|
const node = this.readNodes.get(inferred.source_location);
|
|
1067
|
+
const stated = this.statedTypes.get(inferred);
|
|
1068
|
+
if (request.infer_kind === 'call_result') {
|
|
1069
|
+
// carrick#4513 P1: a consumer's call result, printed or stated by the
|
|
1070
|
+
// source, states no type when the type is a bare type parameter
|
|
1071
|
+
// (whoever declares it) or a generic class an installed package
|
|
1072
|
+
// declares. A parameter nested inside a body shape is not floored
|
|
1073
|
+
// here: the shape is the caller's, and the capture prints that one
|
|
1074
|
+
// position as unknown.
|
|
1075
|
+
for (const type of [printed, stated]) {
|
|
1076
|
+
const floor = type ? this.consumerFloorOf(type) : undefined;
|
|
1077
|
+
if (floor?.kind === 'parameter')
|
|
1078
|
+
return this.boundByCallers(request, inferred.source_location, floor.name);
|
|
1079
|
+
if (floor?.kind === 'library_class')
|
|
1080
|
+
return this.libraryClassAbstain(request, inferred.source_location, floor.name);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1061
1083
|
if (!printed || !node)
|
|
1062
1084
|
return inferred;
|
|
1063
1085
|
const open = this.openTypeParameterAt(printed, node);
|
|
1064
1086
|
return open === undefined ? inferred : this.boundByCallers(request, inferred.source_location, open);
|
|
1065
1087
|
}
|
|
1088
|
+
/**
|
|
1089
|
+
* What a consumer's call result is when it is no body (carrick#4513 P1),
|
|
1090
|
+
* read after `await` (`Promise` and other thenables peeled):
|
|
1091
|
+
* - a bare type parameter, other than a polymorphic `this`: only the
|
|
1092
|
+
* callers of whatever declares it set it, a library class's own `T`
|
|
1093
|
+
* included;
|
|
1094
|
+
* - a union member, nullish ones aside, that is an instance of a generic
|
|
1095
|
+
* class an installed package declares (a result, future or page class
|
|
1096
|
+
* around the body). JSON never builds a class instance, so the class is
|
|
1097
|
+
* the library's carrier of the body, and its declaration prints its own
|
|
1098
|
+
* parameters open. A class without type parameters (an SDK's data
|
|
1099
|
+
* class) and a TypeScript lib type (`ArrayBuffer`, `Date`) are kept.
|
|
1100
|
+
*/
|
|
1101
|
+
consumerFloorOf(type) {
|
|
1102
|
+
const awaited = this.awaitedBeyondPromise(this.unwrapPromiseType(type)) ?? this.unwrapPromiseType(type);
|
|
1103
|
+
const members = awaited.isUnion() ? awaited.getUnionTypes() : [awaited];
|
|
1104
|
+
for (const member of members) {
|
|
1105
|
+
if (isNullishType(member))
|
|
1106
|
+
continue;
|
|
1107
|
+
if (member.isTypeParameter()) {
|
|
1108
|
+
if (member.compilerType.isThisType)
|
|
1109
|
+
continue;
|
|
1110
|
+
return { kind: 'parameter', name: member.getText() };
|
|
1111
|
+
}
|
|
1112
|
+
const library = this.genericLibraryClassOf(member);
|
|
1113
|
+
if (library !== undefined)
|
|
1114
|
+
return { kind: 'library_class', name: library };
|
|
1115
|
+
}
|
|
1116
|
+
return undefined;
|
|
1117
|
+
}
|
|
1118
|
+
/** The name of the generic class an installed package declares that `type` is an instance of. */
|
|
1119
|
+
genericLibraryClassOf(type) {
|
|
1120
|
+
const symbol = type.getSymbol();
|
|
1121
|
+
if (!symbol || !(symbol.getFlags() & ts.SymbolFlags.Class))
|
|
1122
|
+
return undefined;
|
|
1123
|
+
const compiler = type.compilerType;
|
|
1124
|
+
const declared = (compiler.target ?? compiler);
|
|
1125
|
+
if (!declared.typeParameters?.length)
|
|
1126
|
+
return undefined;
|
|
1127
|
+
// TypeScript's lib files declare no classes (`ArrayBuffer`, `Date` are
|
|
1128
|
+
// an interface beside a value), so the class flag already leaves them.
|
|
1129
|
+
return this.declaringPackageOf(type) === undefined ? undefined : symbol.getName();
|
|
1130
|
+
}
|
|
1131
|
+
/** The decided answer for a call result that is a generic library class instance (carrick#4513 P1). */
|
|
1132
|
+
libraryClassAbstain(request, location, name) {
|
|
1133
|
+
this.log(`Read at ${request.file_path}:${request.line_number} is an instance of the library class '${name}', ` +
|
|
1134
|
+
'which carries the body rather than being it; leaving it unknown');
|
|
1135
|
+
return this.decidedAbstain(request, location, {
|
|
1136
|
+
path: '',
|
|
1137
|
+
kind: 'unknown',
|
|
1138
|
+
reason: 'machinery_envelope',
|
|
1139
|
+
detail: `the type read here is an instance of the generic class '${name}' an installed package ` +
|
|
1140
|
+
'declares, which carries the body rather than being it, so this site states no type',
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1066
1143
|
/**
|
|
1067
1144
|
* The name of a type parameter `type` holds that a declaration around
|
|
1068
1145
|
* `node`, or `node` itself, declares. A function or class read at itself is
|
|
@@ -1844,10 +1921,11 @@ export class TypeInferrer {
|
|
|
1844
1921
|
if (walked === null) {
|
|
1845
1922
|
// The walk read everything the handler returns and published nothing.
|
|
1846
1923
|
// A located expression inside one of those returns was part of that.
|
|
1847
|
-
|
|
1924
|
+
const holding = this.returnedSendHolding(returned, located);
|
|
1925
|
+
if (holding) {
|
|
1848
1926
|
this.log(`Response locator at ${request.file_path}:${request.line_number} names a send ` +
|
|
1849
1927
|
'its handler returns, which carries no body a contract can describe; abstaining');
|
|
1850
|
-
return null;
|
|
1928
|
+
return this.noSuccessPayloadOf(request, handler, returned, holding) ?? null;
|
|
1851
1929
|
}
|
|
1852
1930
|
// Outside the return, it is either a send itself or what one was handed.
|
|
1853
1931
|
const sends = [
|
|
@@ -1876,9 +1954,14 @@ export class TypeInferrer {
|
|
|
1876
1954
|
// Blueprint row N34: the callee resolves to nothing, so only the model's
|
|
1877
1955
|
// locator says the returned call is a response sender. That is a lead,
|
|
1878
1956
|
// never a type the check enforces: the row keeps its honest `any`, and the
|
|
1879
|
-
// located argument's reading rides in the provenance for a reader.
|
|
1957
|
+
// located argument's reading rides in the provenance for a reader. Where
|
|
1958
|
+
// every reply the handler returns states an error or redirect status or
|
|
1959
|
+
// carries no body, the lead says there is no success body: decided.
|
|
1880
1960
|
const sender = this.returnedSendHolding(returned, located);
|
|
1881
1961
|
if (sender) {
|
|
1962
|
+
const noSuccess = this.noSuccessPayloadOf(request, handler, returned, sender);
|
|
1963
|
+
if (noSuccess)
|
|
1964
|
+
return noSuccess;
|
|
1882
1965
|
// The printed type names a module the use site does not import by its
|
|
1883
1966
|
// declaring file, `import("/abs/path").Name`, and this text reaches a
|
|
1884
1967
|
// reader: keep the bare name, before truncation can split the path.
|
|
@@ -1894,6 +1977,86 @@ export class TypeInferrer {
|
|
|
1894
1977
|
}
|
|
1895
1978
|
return walked;
|
|
1896
1979
|
}
|
|
1980
|
+
/**
|
|
1981
|
+
* The decided answer of a declared handler none of whose replies carries a
|
|
1982
|
+
* success body, or `undefined` when one might (reply-status T2a).
|
|
1983
|
+
*
|
|
1984
|
+
* Every branch of what the handler returns (`responseReturnedExpressions`,
|
|
1985
|
+
* conditionals split; a returned call whose callbacks' returns are already
|
|
1986
|
+
* listed, such as `.match(ok, err)`, is a container and not judged itself)
|
|
1987
|
+
* must be a reply that states an error or redirect status
|
|
1988
|
+
* (`replyStatus`, chain read), or a reply stating a success status that
|
|
1989
|
+
* carries no body: no first argument, `null`, `undefined`, or an init
|
|
1990
|
+
* object (`statesResponseInit`). A branch counts as a reply only when it
|
|
1991
|
+
* is the located send, makes the same call as the located send (callee
|
|
1992
|
+
* root and member, so `reply.status(400).send(x)` matches
|
|
1993
|
+
* `reply.status(410).send(y)`), or types as framework machinery: a status
|
|
1994
|
+
* read off an argument of any other call (`clip(rows, 404)`) is no reply's
|
|
1995
|
+
* status. A status no source states (`new Response(null)`, `next()`) or a
|
|
1996
|
+
* computed one keeps the row undecided.
|
|
1997
|
+
*/
|
|
1998
|
+
noSuccessPayloadOf(request, handler, returned, locatedSend) {
|
|
1999
|
+
const branches = returned.flatMap((expression) => this.expandResponseBranches(expression, 0));
|
|
2000
|
+
const judged = branches.filter((branch) => !branches.some((inner) => inner !== branch &&
|
|
2001
|
+
branch.getStart() <= inner.getStart() &&
|
|
2002
|
+
inner.getEnd() <= branch.getEnd()));
|
|
2003
|
+
const sentWith = locatedSend ? this.sendCalleeKey(locatedSend) : undefined;
|
|
2004
|
+
const isReply = (branch) => branch === locatedSend ||
|
|
2005
|
+
(sentWith !== undefined && this.sendCalleeKey(branch) === sentWith) ||
|
|
2006
|
+
this.typeIsOrContainsResponseMachinery(this.unwrapPromiseType(branch.getType()));
|
|
2007
|
+
const carriesNoSuccessBody = (branch) => {
|
|
2008
|
+
if (!isReply(branch))
|
|
2009
|
+
return false;
|
|
2010
|
+
const status = replyStatus(this.replyChecker(), branch.compilerNode, { readChain: true });
|
|
2011
|
+
if (isDroppedReplyStatus(status))
|
|
2012
|
+
return true;
|
|
2013
|
+
if (status !== 'success')
|
|
2014
|
+
return false;
|
|
2015
|
+
if (!Node.isCallExpression(branch) && !Node.isNewExpression(branch))
|
|
2016
|
+
return false;
|
|
2017
|
+
const body = branch.getArguments()[0];
|
|
2018
|
+
if (body === undefined)
|
|
2019
|
+
return true;
|
|
2020
|
+
const peeled = this.peelTransparentExpression(body);
|
|
2021
|
+
return (Node.isNullLiteral(peeled) ||
|
|
2022
|
+
(Node.isIdentifier(peeled) && peeled.getText() === 'undefined') ||
|
|
2023
|
+
this.statesResponseInit(peeled));
|
|
2024
|
+
};
|
|
2025
|
+
if (judged.length === 0 || !judged.every(carriesNoSuccessBody)) {
|
|
2026
|
+
return undefined;
|
|
2027
|
+
}
|
|
2028
|
+
this.log(`Response locator at ${request.file_path}:${request.line_number} names a send of a ` +
|
|
2029
|
+
'handler whose every reply states an error or redirect status or carries no body; ' +
|
|
2030
|
+
'no success payload');
|
|
2031
|
+
return this.decidedAbstain(request, this.getNodeLocation(handler), {
|
|
2032
|
+
path: '',
|
|
2033
|
+
kind: 'unknown',
|
|
2034
|
+
reason: 'no_success_payload',
|
|
2035
|
+
detail: "every response this route's handler sends states an error or redirect status, " +
|
|
2036
|
+
'or carries no body a JSON contract can describe, so it publishes no success body',
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* What a send calls, as two sends of one reply API share it: `new` and the
|
|
2041
|
+
* constructor's text, or the root of the callee chain and the member
|
|
2042
|
+
* called (`reply.status(400).send` -> `reply…send`), or the callee's text.
|
|
2043
|
+
*/
|
|
2044
|
+
sendCalleeKey(node) {
|
|
2045
|
+
const send = this.peelTransparentExpression(node);
|
|
2046
|
+
if (Node.isNewExpression(send)) {
|
|
2047
|
+
return `new ${send.getExpression().getText()}`;
|
|
2048
|
+
}
|
|
2049
|
+
if (!Node.isCallExpression(send))
|
|
2050
|
+
return undefined;
|
|
2051
|
+
const callee = send.getExpression();
|
|
2052
|
+
if (!Node.isPropertyAccessExpression(callee))
|
|
2053
|
+
return callee.getText();
|
|
2054
|
+
let root = callee.getExpression();
|
|
2055
|
+
while (Node.isPropertyAccessExpression(root) || Node.isCallExpression(root)) {
|
|
2056
|
+
root = root.getExpression();
|
|
2057
|
+
}
|
|
2058
|
+
return `${root.getText()}…${callee.getName()}`;
|
|
2059
|
+
}
|
|
1897
2060
|
/**
|
|
1898
2061
|
* The call inside one of `returned` that the located expression is, or is
|
|
1899
2062
|
* an argument of: the send a located payload was handed to. `undefined`
|
|
@@ -2700,7 +2863,90 @@ export class TypeInferrer {
|
|
|
2700
2863
|
this.readNodes.delete(this.getNodeLocation(node));
|
|
2701
2864
|
return { type: atCaller.type };
|
|
2702
2865
|
}
|
|
2866
|
+
/**
|
|
2867
|
+
* The type of `call` as the call `through_call` names instantiates the
|
|
2868
|
+
* wrapper it is made in (carrick#4375): `typeAtThroughCall`, with no
|
|
2869
|
+
* answer recorded. A request that names no call, or a call that binds
|
|
2870
|
+
* nothing the type holds, reads the call's own type.
|
|
2871
|
+
*/
|
|
2872
|
+
callTypeAsCallerBinds(call, request) {
|
|
2873
|
+
if (!request.through_call)
|
|
2874
|
+
return call.getType();
|
|
2875
|
+
const atCaller = this.typeAtThroughCall(call, request);
|
|
2876
|
+
return atCaller.kind === 'instantiated' ? atCaller.type : call.getType();
|
|
2877
|
+
}
|
|
2878
|
+
/**
|
|
2879
|
+
* A call's result as the caller reads it. A request made below a wrapper
|
|
2880
|
+
* (`through_call` names the call that reaches the wrapper) is read at the
|
|
2881
|
+
* call it names, where the caller states what it reads, in two cases:
|
|
2882
|
+
*
|
|
2883
|
+
* - the read below finds only transport (a decided `machinery_envelope`,
|
|
2884
|
+
* or the response object itself, stated by nothing): the wrapper hands
|
|
2885
|
+
* the transport on, and the body is read off it by its caller;
|
|
2886
|
+
* - the caller chooses a raw text body: a text read of the value, or a
|
|
2887
|
+
* text format passed at the call (carrick#4513). A raw text body has no
|
|
2888
|
+
* JSON shape, so the mark is read at the deciding call whichever call
|
|
2889
|
+
* the type came from.
|
|
2890
|
+
*
|
|
2891
|
+
* A read below the wrapper that finds a body keeps it.
|
|
2892
|
+
*/
|
|
2703
2893
|
inferCallResult(sourceFile, request, extractionConfig) {
|
|
2894
|
+
const read = this.inferCallResultBelowWrapper(sourceFile, request, extractionConfig);
|
|
2895
|
+
const through = request.through_call;
|
|
2896
|
+
if (!through)
|
|
2897
|
+
return read;
|
|
2898
|
+
const callerFile = this.getSourceFile(through.file_path);
|
|
2899
|
+
const deciding = callerFile
|
|
2900
|
+
? this.findCallExpressionAtSpan(callerFile, through.span_start, through.span_end)
|
|
2901
|
+
: undefined;
|
|
2902
|
+
if (!callerFile || !deciding || !callNamedBy(deciding.compilerNode))
|
|
2903
|
+
return read;
|
|
2904
|
+
if (read && !this.readIsOnlyTransport(sourceFile, request, read)) {
|
|
2905
|
+
return this.markedAtDecidingCall(read, deciding);
|
|
2906
|
+
}
|
|
2907
|
+
const decidingRequest = {
|
|
2908
|
+
...request,
|
|
2909
|
+
file_path: through.file_path,
|
|
2910
|
+
line_number: deciding.getStartLineNumber(),
|
|
2911
|
+
span_start: through.span_start,
|
|
2912
|
+
span_end: through.span_end,
|
|
2913
|
+
expression_text: undefined,
|
|
2914
|
+
expression_line: undefined,
|
|
2915
|
+
through_call: undefined,
|
|
2916
|
+
result: undefined,
|
|
2917
|
+
};
|
|
2918
|
+
const atDeciding = this.inferCallResultBelowWrapper(callerFile, decidingRequest, extractionConfig);
|
|
2919
|
+
if (!atDeciding || this.readIsOnlyTransport(callerFile, decidingRequest, atDeciding)) {
|
|
2920
|
+
return read ?? atDeciding;
|
|
2921
|
+
}
|
|
2922
|
+
this.log(`Call result at ${request.file_path}:${request.line_number} is only transport; ` +
|
|
2923
|
+
`reading it at the call that reaches the wrapper, ${through.file_path}:${decidingRequest.line_number}`);
|
|
2924
|
+
return atDeciding;
|
|
2925
|
+
}
|
|
2926
|
+
/** The read states nothing but transport: a decided envelope, or the response object unstated. */
|
|
2927
|
+
readIsOnlyTransport(sourceFile, request, read) {
|
|
2928
|
+
if ((read.any_provenance ?? []).some((p) => p.path === '' && p.reason === 'machinery_envelope')) {
|
|
2929
|
+
return true;
|
|
2930
|
+
}
|
|
2931
|
+
if (read.is_explicit || (read.any_provenance ?? []).length > 0 || request.result)
|
|
2932
|
+
return false;
|
|
2933
|
+
const call = this.resolveTargetCallExpression(sourceFile, request);
|
|
2934
|
+
if (!call)
|
|
2935
|
+
return false;
|
|
2936
|
+
const value = this.unwrapPromiseType(call.getType());
|
|
2937
|
+
return (this.typeIsOrContainsResponseMachinery(value) &&
|
|
2938
|
+
read.type_string.replace(/\s+/g, ' ').trim() === typeText(value, call).replace(/\s+/g, ' ').trim());
|
|
2939
|
+
}
|
|
2940
|
+
/** The raw-text mark the deciding call states, added to a read that did not carry it. */
|
|
2941
|
+
markedAtDecidingCall(read, deciding) {
|
|
2942
|
+
if (read.raw_text_read || !isBareStringText(read.type_string))
|
|
2943
|
+
return read;
|
|
2944
|
+
const func = this.findContainingFunctionForNode(deciding);
|
|
2945
|
+
const terminal = this.resolveCallResultTerminalNode(deciding, func).terminal;
|
|
2946
|
+
markRawTextRead(read, this.textReadAtTerminal(deciding, terminal) || this.callChoosesTextBody(deciding));
|
|
2947
|
+
return read;
|
|
2948
|
+
}
|
|
2949
|
+
inferCallResultBelowWrapper(sourceFile, request, extractionConfig) {
|
|
2704
2950
|
const callExpr = this.resolveTargetCallExpression(sourceFile, request);
|
|
2705
2951
|
// A call's result is read off the call. A locator that finds no call names
|
|
2706
2952
|
// nothing this can read, and whatever other node its text overlaps is not
|
|
@@ -3039,7 +3285,12 @@ export class TypeInferrer {
|
|
|
3039
3285
|
// type. Where no rule matched that type as the names peel it, the same
|
|
3040
3286
|
// protocol reading the text takes is read here, so a subclass of
|
|
3041
3287
|
// `Promise` anchors the row on what it resolves to and never on itself.
|
|
3042
|
-
|
|
3288
|
+
//
|
|
3289
|
+
// carrick#4513: a call read below a wrapper is anchored on its payload as
|
|
3290
|
+
// the call `through_call` names instantiates it, as its text is
|
|
3291
|
+
// (`callResultAtThroughCall`): read inside a generic wrapper, the call's
|
|
3292
|
+
// own type holds the wrapper's type parameter, which is never an anchor.
|
|
3293
|
+
let callPayloadType = this.unwrapPromiseType(this.callTypeAsCallerBinds(callExpr, request));
|
|
3043
3294
|
let callUnwrap = this.unwrapTypeWithConfig(callPayloadType, callExpr, extractionConfig);
|
|
3044
3295
|
let readByProtocol = false;
|
|
3045
3296
|
if (!callUnwrap.wasUnwrapped) {
|
|
@@ -3100,7 +3351,11 @@ export class TypeInferrer {
|
|
|
3100
3351
|
// call is what judges such a call today.
|
|
3101
3352
|
if (!anchor || !this.primaryTypeSymbol(anchor.element)) {
|
|
3102
3353
|
const typeArgs = callExpr.getTypeArguments();
|
|
3103
|
-
|
|
3354
|
+
// carrick#4513: a type argument that is the enclosing function's own
|
|
3355
|
+
// type parameter (`http.get<T>(…)` inside `callApi<T>`) names no type
|
|
3356
|
+
// of this site's: only that function's callers set it (the
|
|
3357
|
+
// carrick#4201 rule).
|
|
3358
|
+
if (typeArgs.length === 1 && this.openTypeParameterAt(typeArgs[0].getType(), callExpr) === undefined) {
|
|
3104
3359
|
const argType = this.unwrapPromiseType(typeArgs[0].getType());
|
|
3105
3360
|
const argUnwrap = this.unwrapTypeWithConfig(argType, typeArgs[0], extractionConfig);
|
|
3106
3361
|
const argSource = argUnwrap.wasUnwrapped
|
|
@@ -3118,6 +3373,13 @@ export class TypeInferrer {
|
|
|
3118
3373
|
// carrick#2148: a carrier the call's reading left (carrick#1376) is the
|
|
3119
3374
|
// transport's bookkeeping, not the body, so it has no home either.
|
|
3120
3375
|
leftCarrier && !anchor ? null : undefined);
|
|
3376
|
+
const statedNode = narrowed
|
|
3377
|
+
? narrowed.typeNode
|
|
3378
|
+
: explicitType
|
|
3379
|
+
? this.explicitTypeNodeFromAncestor(terminalNode)
|
|
3380
|
+
: undefined;
|
|
3381
|
+
if (statedNode)
|
|
3382
|
+
this.statedTypes.set(inferred, statedNode.getType());
|
|
3121
3383
|
// carrick#1749: say when the text is the source's own statement of the
|
|
3122
3384
|
// body, and what that statement is rooted at, so the scanner can tell a
|
|
3123
3385
|
// model symbol that names the body from one that names a part of it.
|
|
@@ -226,12 +226,12 @@ export declare const InitRequestSchema: z.ZodObject<{
|
|
|
226
226
|
}, "strip", z.ZodTypeAny, {
|
|
227
227
|
compilerOptions: {
|
|
228
228
|
types?: string[] | undefined;
|
|
229
|
+
declaration?: boolean | undefined;
|
|
230
|
+
declarationMap?: boolean | undefined;
|
|
229
231
|
module?: string | undefined;
|
|
230
232
|
moduleResolution?: string | undefined;
|
|
231
233
|
target?: string | undefined;
|
|
232
234
|
skipLibCheck?: boolean | undefined;
|
|
233
|
-
declaration?: boolean | undefined;
|
|
234
|
-
declarationMap?: boolean | undefined;
|
|
235
235
|
paths?: Record<string, string[]> | undefined;
|
|
236
236
|
baseUrl?: string | undefined;
|
|
237
237
|
jsx?: string | undefined;
|
|
@@ -245,12 +245,12 @@ export declare const InitRequestSchema: z.ZodObject<{
|
|
|
245
245
|
}, {
|
|
246
246
|
compilerOptions: {
|
|
247
247
|
types?: string[] | undefined;
|
|
248
|
+
declaration?: boolean | undefined;
|
|
249
|
+
declarationMap?: boolean | undefined;
|
|
248
250
|
module?: string | undefined;
|
|
249
251
|
moduleResolution?: string | undefined;
|
|
250
252
|
target?: string | undefined;
|
|
251
253
|
skipLibCheck?: boolean | undefined;
|
|
252
|
-
declaration?: boolean | undefined;
|
|
253
|
-
declarationMap?: boolean | undefined;
|
|
254
254
|
paths?: Record<string, string[]> | undefined;
|
|
255
255
|
baseUrl?: string | undefined;
|
|
256
256
|
jsx?: string | undefined;
|
|
@@ -273,12 +273,12 @@ export declare const InitRequestSchema: z.ZodObject<{
|
|
|
273
273
|
tsconfig_snapshot?: {
|
|
274
274
|
compilerOptions: {
|
|
275
275
|
types?: string[] | undefined;
|
|
276
|
+
declaration?: boolean | undefined;
|
|
277
|
+
declarationMap?: boolean | undefined;
|
|
276
278
|
module?: string | undefined;
|
|
277
279
|
moduleResolution?: string | undefined;
|
|
278
280
|
target?: string | undefined;
|
|
279
281
|
skipLibCheck?: boolean | undefined;
|
|
280
|
-
declaration?: boolean | undefined;
|
|
281
|
-
declarationMap?: boolean | undefined;
|
|
282
282
|
paths?: Record<string, string[]> | undefined;
|
|
283
283
|
baseUrl?: string | undefined;
|
|
284
284
|
jsx?: string | undefined;
|
|
@@ -301,12 +301,12 @@ export declare const InitRequestSchema: z.ZodObject<{
|
|
|
301
301
|
tsconfig_snapshot?: {
|
|
302
302
|
compilerOptions: {
|
|
303
303
|
types?: string[] | undefined;
|
|
304
|
+
declaration?: boolean | undefined;
|
|
305
|
+
declarationMap?: boolean | undefined;
|
|
304
306
|
module?: string | undefined;
|
|
305
307
|
moduleResolution?: string | undefined;
|
|
306
308
|
target?: string | undefined;
|
|
307
309
|
skipLibCheck?: boolean | undefined;
|
|
308
|
-
declaration?: boolean | undefined;
|
|
309
|
-
declarationMap?: boolean | undefined;
|
|
310
310
|
paths?: Record<string, string[]> | undefined;
|
|
311
311
|
baseUrl?: string | undefined;
|
|
312
312
|
jsx?: string | undefined;
|
|
@@ -4619,12 +4619,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
4619
4619
|
}, "strip", z.ZodTypeAny, {
|
|
4620
4620
|
compilerOptions: {
|
|
4621
4621
|
types?: string[] | undefined;
|
|
4622
|
+
declaration?: boolean | undefined;
|
|
4623
|
+
declarationMap?: boolean | undefined;
|
|
4622
4624
|
module?: string | undefined;
|
|
4623
4625
|
moduleResolution?: string | undefined;
|
|
4624
4626
|
target?: string | undefined;
|
|
4625
4627
|
skipLibCheck?: boolean | undefined;
|
|
4626
|
-
declaration?: boolean | undefined;
|
|
4627
|
-
declarationMap?: boolean | undefined;
|
|
4628
4628
|
paths?: Record<string, string[]> | undefined;
|
|
4629
4629
|
baseUrl?: string | undefined;
|
|
4630
4630
|
jsx?: string | undefined;
|
|
@@ -4638,12 +4638,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
4638
4638
|
}, {
|
|
4639
4639
|
compilerOptions: {
|
|
4640
4640
|
types?: string[] | undefined;
|
|
4641
|
+
declaration?: boolean | undefined;
|
|
4642
|
+
declarationMap?: boolean | undefined;
|
|
4641
4643
|
module?: string | undefined;
|
|
4642
4644
|
moduleResolution?: string | undefined;
|
|
4643
4645
|
target?: string | undefined;
|
|
4644
4646
|
skipLibCheck?: boolean | undefined;
|
|
4645
|
-
declaration?: boolean | undefined;
|
|
4646
|
-
declarationMap?: boolean | undefined;
|
|
4647
4647
|
paths?: Record<string, string[]> | undefined;
|
|
4648
4648
|
baseUrl?: string | undefined;
|
|
4649
4649
|
jsx?: string | undefined;
|
|
@@ -4666,12 +4666,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
4666
4666
|
tsconfig_snapshot?: {
|
|
4667
4667
|
compilerOptions: {
|
|
4668
4668
|
types?: string[] | undefined;
|
|
4669
|
+
declaration?: boolean | undefined;
|
|
4670
|
+
declarationMap?: boolean | undefined;
|
|
4669
4671
|
module?: string | undefined;
|
|
4670
4672
|
moduleResolution?: string | undefined;
|
|
4671
4673
|
target?: string | undefined;
|
|
4672
4674
|
skipLibCheck?: boolean | undefined;
|
|
4673
|
-
declaration?: boolean | undefined;
|
|
4674
|
-
declarationMap?: boolean | undefined;
|
|
4675
4675
|
paths?: Record<string, string[]> | undefined;
|
|
4676
4676
|
baseUrl?: string | undefined;
|
|
4677
4677
|
jsx?: string | undefined;
|
|
@@ -4694,12 +4694,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
4694
4694
|
tsconfig_snapshot?: {
|
|
4695
4695
|
compilerOptions: {
|
|
4696
4696
|
types?: string[] | undefined;
|
|
4697
|
+
declaration?: boolean | undefined;
|
|
4698
|
+
declarationMap?: boolean | undefined;
|
|
4697
4699
|
module?: string | undefined;
|
|
4698
4700
|
moduleResolution?: string | undefined;
|
|
4699
4701
|
target?: string | undefined;
|
|
4700
4702
|
skipLibCheck?: boolean | undefined;
|
|
4701
|
-
declaration?: boolean | undefined;
|
|
4702
|
-
declarationMap?: boolean | undefined;
|
|
4703
4703
|
paths?: Record<string, string[]> | undefined;
|
|
4704
4704
|
baseUrl?: string | undefined;
|
|
4705
4705
|
jsx?: string | undefined;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
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 (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.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# What the index flags on main, proven in source
|
|
7
|
+
|
|
8
|
+
{{SCOPE_NOTE}}
|
|
9
|
+
|
|
10
|
+
Cost: this skill opens source for every item it reads. Ten type mismatches and
|
|
11
|
+
ten groups of similar functions took between 130,000 and 230,000 tokens on a
|
|
12
|
+
project of six services and 2,200 files. Before reading, tell the user how many items each
|
|
13
|
+
section holds and offer to narrow to one service or cap the count.
|
|
14
|
+
|
|
15
|
+
The index states the leads. Your work is to prove or drop each one in source.
|
|
16
|
+
Class nothing from the index's own words alone.
|
|
17
|
+
|
|
18
|
+
## 1. The counts
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
get_project_map({{SCOPE}})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Note the counts under FOUND ON MAIN: type mismatches and similar functions.
|
|
25
|
+
|
|
26
|
+
## 2. Type mismatches
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
get_findings({{SCOPE}}, kind: "type_mismatch")
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Page until the last page. For each finding, read the producer's handler, the
|
|
33
|
+
consumer's call site and the code that uses its result. Where the finding does
|
|
34
|
+
not show both types, narrow the pair:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
get_contract_pair({{SCOPE}}, consumer_service: "<consumer>", producer_service: "<producer>", method: "<METHOD>", path: "<path>")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Before you class a finding REAL, grep for a second producer of the same path in
|
|
41
|
+
another router or under another prefix. Where one exists, read which one the
|
|
42
|
+
consumer calls.
|
|
43
|
+
|
|
44
|
+
Class each finding:
|
|
45
|
+
|
|
46
|
+
- **REAL**: the consumer reads a field the producer does not send, or a value
|
|
47
|
+
the producer can send breaks the consumer, such as a null passed to code that
|
|
48
|
+
needs a string. Name the field and the line that breaks.
|
|
49
|
+
- **TYPE-ONLY**: the two types disagree, but no value the producer sends can
|
|
50
|
+
break the consumer: a string column holding a fixed set of values against a
|
|
51
|
+
union of those values, a null the database never writes (a default, a check
|
|
52
|
+
that blocks it), a null where every read is guarded. Say which.
|
|
53
|
+
- **FALSE**: the index is wrong about one side: the field is sent, or the type is
|
|
54
|
+
misread.
|
|
55
|
+
- **CAN'T TELL**: the value comes from somewhere you cannot read, such as a JSON
|
|
56
|
+
column or an outside service. Say where.
|
|
57
|
+
|
|
58
|
+
The fields a finding names are leads. The field that breaks may be another
|
|
59
|
+
one; name the one that does. Where it is not one the finding names, class the
|
|
60
|
+
finding by the field that breaks and list the named fields beside it as
|
|
61
|
+
TYPE-ONLY.
|
|
62
|
+
|
|
63
|
+
## 3. Functions written twice
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
get_findings({{SCOPE}}, kind: "similar_functions")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Page until the last page, or to the cap the user agreed, and state the cap.
|
|
70
|
+
Read every member of each group at its file and line, and diff the bodies.
|
|
71
|
+
Class each member against the first:
|
|
72
|
+
|
|
73
|
+
- **DUPLICATE**: same contract, nothing to name apart.
|
|
74
|
+
- **VARIANT**: same contract, and a difference you can name in a clause.
|
|
75
|
+
- **FALSE POSITIVE**: different contracts.
|
|
76
|
+
|
|
77
|
+
Where the members sit in separate apps, check their package.json files for a
|
|
78
|
+
package they already share. Where one exists, the fix is to move the function
|
|
79
|
+
there and import it; where none does, say so: the fix is a new shared package.
|
|
80
|
+
|
|
81
|
+
## 4. Report
|
|
82
|
+
|
|
83
|
+
One table per section, with the class column never empty, and the counts read
|
|
84
|
+
against the counts from step 1 and any cap.
|
|
85
|
+
|
|
86
|
+
Then a fix list: every REAL and DUPLICATE, most harmful first, each with
|
|
87
|
+
file:line and the change in one line ("send createdAt from
|
|
88
|
+
formatTaskResponse"; "move validateName into a shared package and delete the
|
|
89
|
+
two copies"). TYPE-ONLY items go in a short list after it, as optional tidying.
|
|
90
|
+
|
|
91
|
+
Not covered yet: calls that reach no route and endpoints nobody calls. Say so in
|
|
92
|
+
the report.
|
|
93
|
+
|
|
94
|
+
## 5. Act
|
|
95
|
+
|
|
96
|
+
Change nothing yet. Ask the user which items on the fix list to apply, and apply
|
|
97
|
+
only those.
|