carrick 0.3.156 → 0.3.157

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/facts/enabled.d.ts +6 -0
  2. package/dist/facts/enabled.js +8 -0
  3. package/dist/facts/enabled.js.map +1 -1
  4. package/dist/facts/fetch.js +2 -1
  5. package/dist/facts/fetch.js.map +1 -1
  6. package/dist/held/client.d.ts +34 -0
  7. package/dist/held/client.js +85 -0
  8. package/dist/held/client.js.map +1 -0
  9. package/dist/held/daemon.d.ts +106 -0
  10. package/dist/held/daemon.js +307 -0
  11. package/dist/held/daemon.js.map +1 -0
  12. package/dist/held/engine.d.ts +50 -0
  13. package/dist/held/engine.js +166 -0
  14. package/dist/held/engine.js.map +1 -0
  15. package/dist/held/paths.d.ts +9 -0
  16. package/dist/held/paths.js +27 -0
  17. package/dist/held/paths.js.map +1 -0
  18. package/dist/held/place.d.ts +84 -0
  19. package/dist/held/place.js +198 -0
  20. package/dist/held/place.js.map +1 -0
  21. package/dist/held/registry.d.ts +22 -0
  22. package/dist/held/registry.js +72 -0
  23. package/dist/held/registry.js.map +1 -0
  24. package/dist/held/run.d.ts +2 -0
  25. package/dist/held/run.js +60 -0
  26. package/dist/held/run.js.map +1 -0
  27. package/dist/hook/bash-targets.d.ts +7 -2
  28. package/dist/hook/bash-targets.js +82 -27
  29. package/dist/hook/bash-targets.js.map +1 -1
  30. package/dist/hook/lock.d.ts +26 -0
  31. package/dist/hook/lock.js +122 -0
  32. package/dist/hook/lock.js.map +1 -0
  33. package/dist/hook/post-bash.js +14 -5
  34. package/dist/hook/post-bash.js.map +1 -1
  35. package/dist/hook/rechecks.d.ts +1 -0
  36. package/dist/hook/rechecks.js +8 -121
  37. package/dist/hook/rechecks.js.map +1 -1
  38. package/dist/hook/timings.d.ts +2 -2
  39. package/dist/hook/timings.js +1 -1
  40. package/dist/hook/timings.js.map +1 -1
  41. package/dist/lsp-frame.d.ts +20 -0
  42. package/dist/lsp-frame.js +47 -0
  43. package/dist/lsp-frame.js.map +1 -0
  44. package/dist/server.js +4 -28
  45. package/dist/server.js.map +1 -1
  46. package/package.json +6 -6
  47. package/plugin/.claude-plugin/plugin.json +1 -1
  48. package/sidecar/dist/src/capture/api.d.ts +31 -1
  49. package/sidecar/dist/src/capture/check-probe.d.ts +15 -9
  50. package/sidecar/dist/src/capture/check-probe.js +36 -11
  51. package/sidecar/dist/src/capture/index.d.ts +9 -3
  52. package/sidecar/dist/src/capture/index.js +9 -2
  53. package/sidecar/dist/src/capture/result-label.js +3 -1
  54. package/sidecar/dist/src/capture/type-reasons.json +78 -0
  55. package/sidecar/dist/src/definition-resolver.d.ts +4 -4
  56. package/sidecar/dist/src/definition-resolver.js +8 -9
  57. package/sidecar/dist/src/engine-stamp.json +1 -0
  58. package/sidecar/dist/src/held-shadow.d.ts +60 -0
  59. package/sidecar/dist/src/held-shadow.js +222 -0
  60. package/sidecar/dist/src/index.js +47 -1
  61. package/sidecar/dist/src/library-claims.d.ts +3 -1
  62. package/sidecar/dist/src/library-claims.js +79 -3
  63. package/sidecar/dist/src/type-home.d.ts +12 -0
  64. package/sidecar/dist/src/type-home.js +41 -1
  65. package/sidecar/dist/src/type-inferrer.d.ts +8 -3
  66. package/sidecar/dist/src/type-inferrer.js +36 -18
  67. package/sidecar/dist/src/type-structural-expander.d.ts +1 -11
  68. package/sidecar/dist/src/types.d.ts +43 -5
  69. package/sidecar/dist/src/validators.d.ts +293 -246
  70. package/sidecar/dist/src/validators.js +8 -0
@@ -33,7 +33,7 @@ import { callInto, calledFunction, narrowByArguments } from './argument-modes.js
33
33
  import { functionAtLine } from './function-line-index.js';
34
34
  import { attributedDeclaration, installedPackageOf } from './declaration-attribution.js';
35
35
  import { endLineOf, startLineOf } from './line-index.js';
36
- import { declaredTypeName, homeOfTypeDeclaration, isTypeSpaceDeclaration } from './type-home.js';
36
+ import { declaredTypeName, homeOfSchemaValue, homeOfTypeDeclaration, isTypeSpaceDeclaration } from './type-home.js';
37
37
  import { callsOf, descendantsOf, descendantsOnLine, descendantsOnLines, wrap, wrapCompilerNode, } from './node-index.js';
38
38
  import { elapsedMs, inferTiming, phaseClock, timedPhase } from './infer-timing.js';
39
39
  import { importedNameOf, packageNameOf } from './library-claims.js';
@@ -43,7 +43,7 @@ import { bindingToleratesAbsence, handlerToleratesAbsentBody } from './absent-bo
43
43
  import { replaceFileText } from './program-files.js';
44
44
  import { enclosingTypeParameterIn, instantiatedAtCall } from './type-parameters.js';
45
45
  import { endsWithPath, loopElementPick } from './loop-element.js';
46
- import { classifyStatusCodes, httpStatus, statesNoBody, statesNoShape, statusKeyCode, statusTableOf, successEntries, } from './capture/index.js';
46
+ import { classifyStatusCodes, httpStatus, statesNoBody, statesNoShape, statusKeyCode, statusTableOf, successEntries, TYPE_REASONS, } from './capture/index.js';
47
47
  import { addedDiagnostics, applyInsertions, fileDiagnostics, literalInsertions, mapBack, mapForward, normalise, pathOf, } from './unwidened.js';
48
48
  import { expandTypeStructural, jsonWireType, } from './type-structural-expander.js';
49
49
  /**
@@ -160,21 +160,14 @@ const STATUS_MEMBER_NAMES = ['status', 'statusCode'];
160
160
  /** An error or redirect send carries no body the route's contract describes. */
161
161
  const isDroppedResponseStatus = (status) => status === 'error' || status === 'redirect';
162
162
  /**
163
- * The reasons an `unknown` answer is a decision, not a failure to read: the
164
- * list `DECIDED_ABSTAIN_REASONS` in `src/engine/type_compat_v2.rs` holds
165
- * final. A stated reply never replaces one (carrick#2674).
163
+ * The reasons an `unknown` answer is a decision, not a failure to read, on the
164
+ * response path that reads this set: the words `capture/type-reasons.json`
165
+ * marks `always` (carrick#4231). A stated reply never replaces one
166
+ * (carrick#2674).
166
167
  */
167
- export const DECIDED_ABSTAIN_REASONS = new Set([
168
- 'no_success_payload',
169
- 'no_request_body',
170
- 'projected_value_only',
171
- 'serialised_body_unread',
172
- 'body_built_by_callee',
173
- 'result_member_missing',
174
- 'reshaped_by_callback',
175
- 'body_member_undecided',
176
- 'bound_by_callers',
177
- ]);
168
+ export const DECIDED_ABSTAIN_REASONS = new Set(Object.entries(TYPE_REASONS)
169
+ .filter(([, reason]) => reason.decided === 'always')
170
+ .map(([word]) => word));
178
171
  /** The provenance sentence for each reason a branch was not read. */
179
172
  const SERIALISED_BODY_UNREAD_DETAIL = {
180
173
  prebuilt: 'A return hands back a status and body built somewhere else, such as a variable or a field of another result, so the value in its body was not read.',
@@ -8447,7 +8440,10 @@ export class TypeInferrer {
8447
8440
  }
8448
8441
  this.log(`Route registration at ${request.file_path}:${request.line_number} declares its ` +
8449
8442
  'response schema; using the declared contract');
8450
- return this.withReads(this.createInferredType(request, declared.text, true, this.getNodeLocation(registration), undefined, undefined, undefined, undefined, undefined, undefined, declared.type), declared.reads ?? []);
8443
+ const inferred = this.createInferredType(request, declared.text, true, this.getNodeLocation(registration), undefined, undefined, undefined, undefined, undefined, undefined, declared.type);
8444
+ if (declared.home)
8445
+ inferred.type_home = declared.home;
8446
+ return this.withReads(inferred, declared.reads ?? []);
8451
8447
  }
8452
8448
  /**
8453
8449
  * The request contract of a route registration, in anchor order: the
@@ -9261,6 +9257,8 @@ export class TypeInferrer {
9261
9257
  });
9262
9258
  }
9263
9259
  const inferred = this.createInferredType(request, contract.text, true, location, undefined, undefined, undefined, undefined, undefined, undefined, contract.type);
9260
+ if (contract.home)
9261
+ inferred.type_home = contract.home;
9264
9262
  if (contract.provenance && contract.provenance.length > 0) {
9265
9263
  inferred.any_provenance = contract.provenance;
9266
9264
  }
@@ -9669,10 +9667,13 @@ export class TypeInferrer {
9669
9667
  return null;
9670
9668
  }
9671
9669
  const [first] = decided;
9670
+ // carrick#2148 H3: a home only where every deciding schema is the same one.
9671
+ const homes = new Set(decided.map(({ home }) => (home ? `${home.file_path}:${home.line}` : '')));
9672
9672
  return {
9673
9673
  text: first.text,
9674
9674
  type: first.typeNode?.getType(),
9675
9675
  provenance: first.provenance,
9676
+ ...(first.home && homes.size === 1 ? { home: first.home } : {}),
9676
9677
  at: first.at,
9677
9678
  how: first.how,
9678
9679
  typeNode: first.typeNode,
@@ -9687,7 +9688,14 @@ export class TypeInferrer {
9687
9688
  stateAtReceivingCall(call, index, reads, found, stateNode) {
9688
9689
  const contract = this.schemaHandedArgument(call, index);
9689
9690
  if (contract) {
9690
- found.push({ rank: 1, text: contract.text, provenance: contract.provenance, at: call, how: 'a schema it is handed to' });
9691
+ found.push({
9692
+ rank: 1,
9693
+ text: contract.text,
9694
+ provenance: contract.provenance,
9695
+ home: contract.home,
9696
+ at: call,
9697
+ how: 'a schema it is handed to',
9698
+ });
9691
9699
  return;
9692
9700
  }
9693
9701
  const passThrough = this.passThroughFunction(call, index);
@@ -10008,6 +10016,16 @@ export class TypeInferrer {
10008
10016
  * `unknown`.
10009
10017
  */
10010
10018
  schemaContract(value, direction) {
10019
+ const contract = this.schemaContractText(value, direction);
10020
+ if (!contract)
10021
+ return null;
10022
+ const home = homeOfSchemaValue(this.unwrapExpressionNode(value));
10023
+ return home ? { ...contract, home } : contract;
10024
+ }
10025
+ /**
10026
+ * `schemaContract`'s text and provenance, read off the schema's types.
10027
+ */
10028
+ schemaContractText(value, direction) {
10011
10029
  const node = this.unwrapExpressionNode(value);
10012
10030
  let schemaType;
10013
10031
  if (Node.isCallExpression(node)) {
@@ -30,6 +30,7 @@
30
30
  */
31
31
  import { type Node, type Type, ts } from 'ts-morph';
32
32
  import { type ExternalImports } from './origin.js';
33
+ import type { WireFormat } from './types.js';
33
34
  /**
34
35
  * Bound on the structural-expansion recursion. Deep enough for every realistic
35
36
  * request/response shape; a backstop against pathological/recursive types the
@@ -63,17 +64,6 @@ export interface MemberOverrides {
63
64
  readonly applied: Set<string>;
64
65
  readonly at: Node;
65
66
  }
66
- /**
67
- * The representation a type is printed in.
68
- *
69
- * `'declared'` prints the type the source declares. `'json'` prints what a
70
- * JSON serialiser puts on the wire for a value of that type (carrick#1163):
71
- * `JSON.stringify` calls a value's `toJSON()` and serialises its RESULT, so a
72
- * `Date` travels as the string its `toJSON` returns, and so does any other
73
- * type that declares one. The mapping is read from the compiler's own
74
- * signature, never from a list of type names.
75
- */
76
- export type WireFormat = 'declared' | 'json';
77
67
  /**
78
68
  * The program the walked type belongs to, and the service root inside it.
79
69
  *
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { ResponseModes } from './response-modes.js';
6
6
  import type { ResultLabel } from './capture/api.js';
7
+ import type { ShadowResult } from './held-shadow.js';
7
8
  /**
8
9
  * The kind of type inference to perform
9
10
  */
@@ -294,6 +295,14 @@ export interface ShutdownRequest extends BaseRequest {
294
295
  export interface ListProgramFilesRequest extends BaseRequest {
295
296
  action: 'list_program_files';
296
297
  }
298
+ /**
299
+ * Write the init'd service's program as a shadow tree a held-open TypeScript 7
300
+ * compiler reads (see held-shadow.ts). `out_dir` must lie outside the checkout.
301
+ */
302
+ export interface WriteShadowRequest extends BaseRequest {
303
+ action: 'write_shadow';
304
+ out_dir: string;
305
+ }
297
306
  /**
298
307
  * The import graph without statement texts. Every name and path is an index
299
308
  * into `strings`. Per file: its path, whether it is a script, its declared
@@ -443,8 +452,9 @@ export interface ResolveDefinitionsRequest extends BaseRequest {
443
452
  * One surface alias to resolve, and the payload it types: which protocol,
444
453
  * which kind of payload, and which side of the operation the entry is on.
445
454
  * The resolver prints the alias's structural form in JSON wire form exactly
446
- * where the judge compares that form (`sentInJsonWireForm`,
447
- * carrick-cloud#3503): the sending side of an `http` payload. A derived alias
455
+ * where the judge compares that form (`wireFormFor`, carrick-cloud#3503,
456
+ * carrick#4275): the sending side of an `http` payload and a GraphQL producer
457
+ * response. A derived alias
448
458
  * (an unwidened reading, a response-mode case) carries its base entry's facts.
449
459
  */
450
460
  export interface DefinitionAlias {
@@ -740,6 +750,14 @@ export type LibraryClaim = {
740
750
  kind: 'make';
741
751
  form: 'call' | 'new';
742
752
  member: string | null;
753
+ /**
754
+ * Amendment 12: one maker receiver id the export lists (`instance:new`).
755
+ * The member is read on that receiver's type, as an op's `of` is, and its
756
+ * declared return is the made object. Needs `form: 'call'`, a `member`
757
+ * and a `name` at an argument; `base`, `prefix`, `handler`, `runs`,
758
+ * `protocol` and `result` beside it are `claim_invalid`.
759
+ */
760
+ of?: string;
743
761
  /** An HTTP base URL, or a broker's address. */
744
762
  base?: ClaimSlot;
745
763
  /** A prefix every name the instance sends gets. */
@@ -904,6 +922,13 @@ export interface VerifyLibraryClaimsRequest extends BaseRequest {
904
922
  checks: LibraryCheck[];
905
923
  /** Checks not reached in time come back `unchecked` with reason `budget`; null or absent is the default. */
906
924
  budget_ms?: number | null;
925
+ /**
926
+ * Another service's tsconfig (absolute, or relative to the process's repo
927
+ * root): the checks are judged in a program built from its compiler options
928
+ * with only the probe file, released after the request. Absent: judged in
929
+ * this process's own program (carrick#4472).
930
+ */
931
+ tsconfig_path?: string;
907
932
  }
908
933
  /**
909
934
  * List each package's declared surface the way the verifier reads it
@@ -933,7 +958,7 @@ export interface ListLibrarySurfaceRequest extends BaseRequest {
933
958
  /**
934
959
  * Union type for all possible sidecar requests
935
960
  */
936
- export type SidecarRequest = RetypeCheckRequest | RetypePrescreenRequest | VerifyClientSemanticsRequest | VerifyLibraryClaimsRequest | ListLibrarySurfaceRequest | InitRequest | BundleRequest | CaptureV2Request | CheckV2Request | InferRequest | ResolveDefinitionsRequest | HealthRequest | ShutdownRequest | ListProgramFilesRequest | ReachGraphRequest | ReachRequest | AddProgramFilesRequest | PositionRowsRequest | ImplementationsRequest;
961
+ export type SidecarRequest = RetypeCheckRequest | RetypePrescreenRequest | VerifyClientSemanticsRequest | VerifyLibraryClaimsRequest | ListLibrarySurfaceRequest | InitRequest | BundleRequest | CaptureV2Request | CheckV2Request | InferRequest | ResolveDefinitionsRequest | HealthRequest | ShutdownRequest | ListProgramFilesRequest | WriteShadowRequest | ReachGraphRequest | ReachRequest | AddProgramFilesRequest | PositionRowsRequest | ImplementationsRequest;
937
962
  /**
938
963
  * Request for a specific symbol to be bundled
939
964
  */
@@ -1190,6 +1215,12 @@ export interface ListProgramFilesResponse extends BaseResponse {
1190
1215
  files?: string[];
1191
1216
  errors?: string[];
1192
1217
  }
1218
+ /**
1219
+ * Response for write_shadow action: the fields of `ShadowResult`.
1220
+ */
1221
+ export interface WriteShadowResponse extends BaseResponse, Partial<ShadowResult> {
1222
+ errors?: string[];
1223
+ }
1193
1224
  /**
1194
1225
  * Response for reach_graph action
1195
1226
  */
@@ -1274,7 +1305,7 @@ export interface SemanticsResult {
1274
1305
  verdict: 'verified' | 'failed' | 'unchecked';
1275
1306
  /** Absent exactly when verified. */
1276
1307
  reason?: string;
1277
- /** Verified op verdicts only: the declarations its member resolves to on the receiver. */
1308
+ /** Verified op verdicts, and a verified `of`-make's (amendment 12): the declarations its member resolves to on the receiver. */
1278
1309
  declarations?: SemanticsDeclaration[];
1279
1310
  /**
1280
1311
  * Verified receive op verdicts only: the op verified but its `request`
@@ -1546,7 +1577,7 @@ export interface ListLibrarySurfaceResponse extends BaseResponse {
1546
1577
  /**
1547
1578
  * Union type for all possible sidecar responses
1548
1579
  */
1549
- export type SidecarResponse = RetypeCheckResponse | RetypePrescreenResponse | VerifyClientSemanticsResponse | VerifyLibraryClaimsResponse | ListLibrarySurfaceResponse | InitResponse | BundleResponse | CaptureV2Response | CheckV2Response | InferResponse | ResolveDefinitionsResponse | HealthResponse | ShutdownResponse | ListProgramFilesResponse | ReachGraphResponse | ReachResponse | AddProgramFilesResponse | PositionRowsResponse | ImplementationsResponse | ErrorResponse;
1580
+ export type SidecarResponse = RetypeCheckResponse | RetypePrescreenResponse | VerifyClientSemanticsResponse | VerifyLibraryClaimsResponse | ListLibrarySurfaceResponse | InitResponse | BundleResponse | CaptureV2Response | CheckV2Response | InferResponse | ResolveDefinitionsResponse | HealthResponse | ShutdownResponse | ListProgramFilesResponse | WriteShadowResponse | ReachGraphResponse | ReachResponse | AddProgramFilesResponse | PositionRowsResponse | ImplementationsResponse | ErrorResponse;
1550
1581
  /**
1551
1582
  * An entry in the type manifest
1552
1583
  */
@@ -1558,6 +1589,11 @@ export interface TypeHome {
1558
1589
  symbol: string;
1559
1590
  file_path: string;
1560
1591
  line: number;
1592
+ /**
1593
+ * carrick#2148 H3: `schema` where the home is the `const` of a schema value
1594
+ * the contract was read off, not a type declaration. Absent for a type.
1595
+ */
1596
+ kind?: 'schema';
1561
1597
  }
1562
1598
  export interface ManifestEntry {
1563
1599
  /** The alias or original name of the type */
@@ -1805,6 +1841,8 @@ export type TypeProvenance = import('./capture/api.js').TypeProvenance;
1805
1841
  /** carrick#1836: declared in the capture bundle, which reads it on a literal anchor. */
1806
1842
  export type PrintedName = import('./capture/api.js').PrintedName;
1807
1843
  export type TypeProvenanceReason = import('./capture/api.js').TypeProvenanceReason;
1844
+ /** carrick#4275: declared in the capture bundle, where `wireFormFor` answers it. */
1845
+ export type WireFormat = import('./capture/api.js').WireFormat;
1808
1846
  /**
1809
1847
  * Source location information for a type
1810
1848
  */