carrick 0.3.142 → 0.3.144

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 (109) hide show
  1. package/README.md +1 -1
  2. package/bin/carrick.mjs +7 -7
  3. package/dist/auth/read.d.ts +0 -10
  4. package/dist/auth/read.js +3 -11
  5. package/dist/auth/read.js.map +1 -1
  6. package/dist/cli.d.ts +23 -20
  7. package/dist/cli.js +17 -32
  8. package/dist/cli.js.map +1 -1
  9. package/dist/contract.d.ts +72 -0
  10. package/dist/contract.js +14 -0
  11. package/dist/contract.js.map +1 -1
  12. package/dist/hook/checked.d.ts +11 -0
  13. package/dist/hook/checked.js +44 -0
  14. package/dist/hook/checked.js.map +1 -0
  15. package/dist/hook/edited.d.ts +22 -0
  16. package/dist/hook/edited.js +84 -0
  17. package/dist/hook/edited.js.map +1 -0
  18. package/dist/hook/invoker.d.ts +7 -0
  19. package/dist/hook/invoker.js +18 -0
  20. package/dist/hook/invoker.js.map +1 -0
  21. package/dist/hook/late.d.ts +8 -0
  22. package/dist/hook/late.js +60 -0
  23. package/dist/hook/late.js.map +1 -0
  24. package/dist/hook/post-edit.d.ts +0 -22
  25. package/dist/hook/post-edit.js +78 -126
  26. package/dist/hook/post-edit.js.map +1 -1
  27. package/dist/hook/post-read.js +19 -9
  28. package/dist/hook/post-read.js.map +1 -1
  29. package/dist/hook/probe.d.ts +15 -0
  30. package/dist/hook/probe.js +41 -0
  31. package/dist/hook/probe.js.map +1 -0
  32. package/dist/hook/recheck-run.d.ts +2 -0
  33. package/dist/hook/recheck-run.js +28 -0
  34. package/dist/hook/recheck-run.js.map +1 -0
  35. package/dist/hook/rechecks.d.ts +108 -0
  36. package/dist/hook/rechecks.js +537 -0
  37. package/dist/hook/rechecks.js.map +1 -0
  38. package/dist/hook/refresh.d.ts +1 -0
  39. package/dist/hook/refresh.js +1 -1
  40. package/dist/hook/refresh.js.map +1 -1
  41. package/dist/hook/reuse.d.ts +15 -3
  42. package/dist/hook/reuse.js +31 -11
  43. package/dist/hook/reuse.js.map +1 -1
  44. package/dist/hook/session-start.js +14 -0
  45. package/dist/hook/session-start.js.map +1 -1
  46. package/dist/hook/stop-wait.d.ts +17 -0
  47. package/dist/hook/stop-wait.js +120 -0
  48. package/dist/hook/stop-wait.js.map +1 -0
  49. package/dist/hook/stop.js +12 -1
  50. package/dist/hook/stop.js.map +1 -1
  51. package/dist/hook/user-prompt.js +4 -1
  52. package/dist/hook/user-prompt.js.map +1 -1
  53. package/dist/init/agents-section.js +1 -3
  54. package/dist/init/agents-section.js.map +1 -1
  55. package/dist/init/connect.d.ts +6 -107
  56. package/dist/init/connect.js +7 -318
  57. package/dist/init/connect.js.map +1 -1
  58. package/dist/init/doctor.d.ts +8 -71
  59. package/dist/init/doctor.js +37 -223
  60. package/dist/init/doctor.js.map +1 -1
  61. package/dist/init/hosted.d.ts +7 -7
  62. package/dist/init/hosted.js +8 -10
  63. package/dist/init/hosted.js.map +1 -1
  64. package/dist/init/outdated.d.ts +11 -0
  65. package/dist/init/outdated.js +1 -1
  66. package/dist/init/outdated.js.map +1 -1
  67. package/dist/init/output.d.ts +0 -55
  68. package/dist/init/output.js +0 -142
  69. package/dist/init/output.js.map +1 -1
  70. package/dist/init/projects.d.ts +3 -200
  71. package/dist/init/projects.js +22 -352
  72. package/dist/init/projects.js.map +1 -1
  73. package/dist/init/remove.js +4 -5
  74. package/dist/init/remove.js.map +1 -1
  75. package/dist/init/repos.d.ts +25 -53
  76. package/dist/init/repos.js +28 -65
  77. package/dist/init/repos.js.map +1 -1
  78. package/dist/init/run.d.ts +52 -212
  79. package/dist/init/run.js +247 -987
  80. package/dist/init/run.js.map +1 -1
  81. package/dist/init/self-update.d.ts +18 -0
  82. package/dist/init/self-update.js +147 -0
  83. package/dist/init/self-update.js.map +1 -0
  84. package/dist/init/settings.d.ts +2 -0
  85. package/dist/init/settings.js +13 -2
  86. package/dist/init/settings.js.map +1 -1
  87. package/dist/render.d.ts +24 -6
  88. package/dist/render.js +135 -28
  89. package/dist/render.js.map +1 -1
  90. package/dist/templates.d.ts +1 -6
  91. package/dist/templates.js +4 -14
  92. package/dist/templates.js.map +1 -1
  93. package/package.json +6 -6
  94. package/plugin/.claude-plugin/plugin.json +1 -1
  95. package/plugin/hooks/hooks.json +3 -2
  96. package/sidecar/dist/src/capture/api.d.ts +2 -2
  97. package/sidecar/dist/src/capture/deno-project.js +5 -1
  98. package/sidecar/dist/src/capture/index.d.ts +18 -0
  99. package/sidecar/dist/src/capture/index.js +73 -0
  100. package/sidecar/dist/src/index.js +1 -1
  101. package/sidecar/dist/src/library-claims.d.ts +4 -0
  102. package/sidecar/dist/src/library-claims.js +2 -2
  103. package/sidecar/dist/src/project-loader.js +9 -2
  104. package/sidecar/dist/src/type-inferrer.d.ts +17 -2
  105. package/sidecar/dist/src/type-inferrer.js +59 -16
  106. package/sidecar/dist/src/types.d.ts +26 -0
  107. package/sidecar/dist/src/validators.d.ts +6 -0
  108. package/sidecar/dist/src/validators.js +2 -0
  109. package/templates/carrick.json +0 -7
@@ -5541,7 +5541,7 @@ function isNamedPackage(specifier, packageName) {
5541
5541
  return packageName === named || packageName === typesPackageOf(named);
5542
5542
  }
5543
5543
  /** The name a service imports a package by: `@types/scope__name` is `@scope/name`, `@types/name` is `name`. */
5544
- function importedNameOf(installed) {
5544
+ export function importedNameOf(installed) {
5545
5545
  if (!installed.startsWith('@types/'))
5546
5546
  return installed;
5547
5547
  const bare = installed.slice('@types/'.length);
@@ -5553,7 +5553,7 @@ function typesPackageOf(named) {
5553
5553
  return `@types/${named.startsWith('@') ? named.slice(1).replace('/', '__') : named}`;
5554
5554
  }
5555
5555
  /** The package a specifier names: `@scope/name` or `name`, without a subpath. */
5556
- function packageNameOf(specifier) {
5556
+ export function packageNameOf(specifier) {
5557
5557
  const segments = specifier.split('/');
5558
5558
  return specifier.startsWith('@') ? segments.slice(0, 2).join('/') : segments[0];
5559
5559
  }
@@ -31,12 +31,19 @@ const DEFAULT_SOURCE_PATTERNS = [
31
31
  '*.ts',
32
32
  ];
33
33
  /**
34
- * Default compiler options used when no tsconfig.json is found
34
+ * Default compiler options used when no tsconfig.json is found.
35
+ *
36
+ * Resolution is `Bundler` (carrick#3313), as capture's synthesized defaults
37
+ * are: a relative import without an extension (`./config`) or naming a
38
+ * directory (`./lib`) resolves, `exports` maps are honoured, and `.js`
39
+ * specifiers still reach their `.ts` source. `NodeNext` read every `import`
40
+ * as ESM and resolved none of the first two (and TypeScript 6 rejects it
41
+ * beside `module: ESNext`, TS5110).
35
42
  */
36
43
  const DEFAULT_COMPILER_OPTIONS = {
37
44
  target: 99, // ESNext
38
45
  module: 99, // ESNext
39
- moduleResolution: 99, // NodeNext
46
+ moduleResolution: 100, // Bundler
40
47
  strict: true,
41
48
  esModuleInterop: true,
42
49
  skipLibCheck: true,
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { Project, SourceFile, type CallExpression } from 'ts-morph';
21
21
  import type { InferRequestItem, InferResult, ModelSymbol, ExtractionConfig } from './types.js';
22
- import type { LabelledMembers } from './library-claims.js';
22
+ import { type LabelledMembers } from './library-claims.js';
23
23
  /**
24
24
  * Strongly-discriminating member names of HTTP transport machinery — the
25
25
  * fetch/DOM `Response` & `Request`, a Node `http.ServerResponse`, a framework
@@ -143,7 +143,7 @@ export declare class TypeInferrer {
143
143
  * @param onUnwidenedStep - Called once per unit of the unwidened reading's work
144
144
  * @returns InferResult with inferred types or errors
145
145
  */
146
- infer(requests: InferRequestItem[], extractionConfig?: ExtractionConfig, onRequestDone?: InferRequestDone, modelSymbols?: ModelSymbol[], labels?: LabelledMembers, onUnwidenedStep?: UnwidenedStepDone): InferResult;
146
+ infer(requests: InferRequestItem[], extractionConfig?: ExtractionConfig, onRequestDone?: InferRequestDone, modelSymbols?: ModelSymbol[], labels?: LabelledMembers, onUnwidenedStep?: UnwidenedStepDone, frameworkPackages?: readonly string[]): InferResult;
147
147
  /** The types the model named, by the alias of the row each is for (carrick#2111). */
148
148
  private modelSymbols;
149
149
  /**
@@ -151,6 +151,11 @@ export declare class TypeInferrer {
151
151
  * members the batch's verified server-framework labels name. Empty when
152
152
  * the batch carries no labels, and then it reads nothing.
153
153
  */
154
+ /**
155
+ * The packages the store labels a server framework for this batch (N8),
156
+ * by the name a service imports them as.
157
+ */
158
+ private frameworkPackages;
154
159
  private statedParams;
155
160
  /**
156
161
  * carrick#2111: where the model named a type for the response this request
@@ -1143,6 +1148,16 @@ export declare class TypeInferrer {
1143
1148
  * the origin gate makes certain a user's own local type sharing those member
1144
1149
  * names is never mistaken for framework machinery (the advisor's guard).
1145
1150
  */
1151
+ /**
1152
+ * Blueprint row N8: true when `type` is framework machinery by where it is
1153
+ * declared, never by its name. Either it passes the structural test
1154
+ * (`typeIsFrameworkMachinery`: the transport's members, declared by a
1155
+ * library or an installed package), or an installed package the store
1156
+ * labels a server framework declares it (`frameworkPackages`), which also
1157
+ * covers app and router instances that carry no reply members. A
1158
+ * service's own `Context` or `Router` is neither.
1159
+ */
1160
+ private isFrameworkMachinery;
1146
1161
  private typeIsFrameworkMachinery;
1147
1162
  /**
1148
1163
  * True once the type carries at least `MACHINERY_INDICATOR_THRESHOLD` DISTINCT
@@ -33,6 +33,7 @@ import { attributedDeclaration, installedPackageOf } from './declaration-attribu
33
33
  import { endLineOf, startLineOf } from './line-index.js';
34
34
  import { callsOf, descendantsOf, descendantsOnLine, descendantsOnLines, wrap, } from './node-index.js';
35
35
  import { elapsedMs, inferTiming, phaseClock, timedPhase } from './infer-timing.js';
36
+ import { importedNameOf, packageNameOf } from './library-claims.js';
36
37
  import { StatedParams } from './stated-params.js';
37
38
  import { bindingToleratesAbsence, handlerToleratesAbsentBody } from './absent-body.js';
38
39
  import { replaceFileText } from './program-files.js';
@@ -481,7 +482,8 @@ export class TypeInferrer {
481
482
  * @param onUnwidenedStep - Called once per unit of the unwidened reading's work
482
483
  * @returns InferResult with inferred types or errors
483
484
  */
484
- infer(requests, extractionConfig, onRequestDone, modelSymbols, labels, onUnwidenedStep) {
485
+ infer(requests, extractionConfig, onRequestDone, modelSymbols, labels, onUnwidenedStep, frameworkPackages) {
486
+ this.frameworkPackages = new Set((frameworkPackages ?? []).map((specifier) => importedNameOf(packageNameOf(specifier))));
485
487
  this.modelSymbols = new Map((modelSymbols ?? []).map((symbol) => [symbol.alias, symbol]));
486
488
  this.statedParams = this.statedParamsFor(labels ?? { sends: new Map(), sets: new Map(), returns: new Map(), bodies: new Set() });
487
489
  const inferredTypes = [];
@@ -660,6 +662,11 @@ export class TypeInferrer {
660
662
  * members the batch's verified server-framework labels name. Empty when
661
663
  * the batch carries no labels, and then it reads nothing.
662
664
  */
665
+ /**
666
+ * The packages the store labels a server framework for this batch (N8),
667
+ * by the name a service imports them as.
668
+ */
669
+ frameworkPackages = new Set();
663
670
  statedParams = this.statedParamsFor({ sends: new Map(), sets: new Map(), returns: new Map(), bodies: new Set() });
664
671
  /**
665
672
  * carrick#2111: where the model named a type for the response this request
@@ -1298,7 +1305,7 @@ export class TypeInferrer {
1298
1305
  path: '',
1299
1306
  kind: awaitedType.isAny() ? 'any' : 'unknown',
1300
1307
  reason: 'no_payload_evidence',
1301
- detail: "the handler returns a call whose callee has no resolvable declaration, and nothing states what it is: no returned sibling call hands it a body plus a status, and no returned argument carries a 'satisfies'/'as' annotation",
1308
+ detail: "the handler returns a call whose callee has no resolvable declaration, and nothing states what it is: the compiler cannot resolve the callee, no labelled response send names the payload, and no returned argument carries a 'satisfies'/'as' annotation",
1302
1309
  },
1303
1310
  ];
1304
1311
  }
@@ -1324,7 +1331,7 @@ export class TypeInferrer {
1324
1331
  return null;
1325
1332
  }
1326
1333
  const anchor = this.unwrapArrayLevels(awaitedType);
1327
- const inferred = this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(func), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined, this.primaryTypeSymbol(anchor.element), anchor.depth, this.primaryTypeSymbolSource(anchor.element));
1334
+ const inferred = this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(func), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined, this.primaryTypeSymbol(anchor.element), anchor.depth, this.primaryTypeSymbolSource(anchor.element), unwrapResult.wasUnwrapped ? unwrapResult.payloadType : awaitedType, anchor.element);
1328
1335
  if (provenance && provenance.length > 0) {
1329
1336
  inferred.any_provenance = provenance;
1330
1337
  }
@@ -1360,7 +1367,7 @@ export class TypeInferrer {
1360
1367
  // (carrick#1985).
1361
1368
  const returnType = timedPhase('type', () => func.getReturnType());
1362
1369
  const typeString = typeText(returnType, func);
1363
- return this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(func));
1370
+ return this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(func), undefined, undefined, undefined, undefined, returnType);
1364
1371
  }
1365
1372
  /**
1366
1373
  * Infer the type of a single named parameter. `is_explicit` reflects whether
@@ -1395,7 +1402,7 @@ export class TypeInferrer {
1395
1402
  // scanner re-aims the explicit bundle at the root symbol instead of
1396
1403
  // pasting this string, so the alias's definition stays self-contained.
1397
1404
  const anchor = this.unwrapArrayLevels(this.unwrapPromiseType(paramType));
1398
- const inferred = this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(target.node), undefined, this.primaryTypeSymbol(anchor.element), anchor.depth, this.primaryTypeSymbolSource(anchor.element));
1405
+ const inferred = this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(target.node), undefined, this.primaryTypeSymbol(anchor.element), anchor.depth, this.primaryTypeSymbolSource(anchor.element), paramType, anchor.element);
1399
1406
  // carrick#2814: a subscriber that defaults its payload, or reads it only
1400
1407
  // in ways `undefined` survives, still works when none is sent.
1401
1408
  const binding = Node.isBindingElement(target.node) ? target.node : target.param;
@@ -1687,7 +1694,7 @@ export class TypeInferrer {
1687
1694
  typeString = this.expandResolvedTypeStructural(resolved, typeText(resolved, payloadNode), this.wireFormatFor(request));
1688
1695
  }
1689
1696
  const anchor = this.unwrapArrayLevels(this.unwrapPromiseType(payloadType));
1690
- const inferred = this.createInferredType(request, typeString, false, this.getNodeLocation(payloadNode), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined, this.primaryTypeSymbol(anchor.element), anchor.depth, this.primaryTypeSymbolSource(anchor.element));
1697
+ const inferred = this.createInferredType(request, typeString, false, this.getNodeLocation(payloadNode), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined, this.primaryTypeSymbol(anchor.element), anchor.depth, this.primaryTypeSymbolSource(anchor.element), unwrapResult.wasUnwrapped ? unwrapResult.payloadType : this.unwrapPromiseType(payloadType), anchor.element);
1691
1698
  this.relateModelSymbol(request, inferred, [
1692
1699
  unwrapResult.wasUnwrapped ? unwrapResult.payloadType : this.unwrapPromiseType(payloadType),
1693
1700
  ]);
@@ -1970,7 +1977,7 @@ export class TypeInferrer {
1970
1977
  const resolvedSource = resolvedSymbol !== undefined && recoveredAnchor
1971
1978
  ? this.primaryTypeSymbolSource(recoveredAnchor.element)
1972
1979
  : undefined;
1973
- const inferred = this.createInferredType(request, recovered.typeString, recovered.isExplicit, this.getNodeLocation(recovered.node), undefined, resolvedSymbol ?? writtenAnchor?.symbol, writtenAnchor ? writtenAnchor.depth : recoveredAnchor?.depth, writtenAnchor ? writtenAnchor.source : resolvedSource);
1980
+ const inferred = this.createInferredType(request, recovered.typeString, recovered.isExplicit, this.getNodeLocation(recovered.node), undefined, resolvedSymbol ?? writtenAnchor?.symbol, writtenAnchor ? writtenAnchor.depth : recoveredAnchor?.depth, writtenAnchor ? writtenAnchor.source : resolvedSource, recovered.anchorType, resolvedSymbol !== undefined ? recoveredAnchor?.element : undefined);
1974
1981
  if (recovered.responseModes)
1975
1982
  inferred.response_modes = recovered.responseModes;
1976
1983
  this.relateModelSymbol(request, inferred, recovered.readTypes);
@@ -2428,7 +2435,7 @@ export class TypeInferrer {
2428
2435
  texts.push(text);
2429
2436
  }
2430
2437
  const anchor = read.length === 1 ? this.unwrapArrayLevels(this.unwrapPromiseType(read[0])) : undefined;
2431
- return this.createInferredType(request, texts.join(' | '), false, location, undefined, anchor ? this.primaryTypeSymbol(anchor.element) : undefined, anchor?.depth, anchor ? this.primaryTypeSymbolSource(anchor.element) : undefined);
2438
+ return this.createInferredType(request, texts.join(' | '), false, location, undefined, anchor ? this.primaryTypeSymbol(anchor.element) : undefined, anchor?.depth, anchor ? this.primaryTypeSymbolSource(anchor.element) : undefined, read.length === 1 ? this.unwrapPromiseType(read[0]) : undefined, anchor?.element);
2432
2439
  }
2433
2440
  inferCallResult(sourceFile, request, extractionConfig) {
2434
2441
  const callExpr = this.resolveTargetCallExpression(sourceFile, request);
@@ -2451,11 +2458,14 @@ export class TypeInferrer {
2451
2458
  const terminalNode = use.terminal;
2452
2459
  const returnType = terminalNode.getType();
2453
2460
  let typeString = typeText(returnType, terminalNode);
2461
+ // Blueprint row N8: the type `typeString` prints, while it prints one.
2462
+ let printedType = this.unwrapPromiseType(returnType);
2454
2463
  let isExplicit = false;
2455
2464
  const unwrapResult = this.unwrapTypeWithConfig(returnType, terminalNode, extractionConfig);
2456
2465
  if (unwrapResult.wasUnwrapped) {
2457
2466
  typeString = unwrapResult.typeString;
2458
2467
  isExplicit = unwrapResult.isExplicit;
2468
+ printedType = unwrapResult.payloadType;
2459
2469
  }
2460
2470
  // carrick#3004: around a call whose body a chain callback reshapes, an
2461
2471
  // annotation or a cast further out states the reshaped value.
@@ -2465,6 +2475,7 @@ export class TypeInferrer {
2465
2475
  if (explicitType) {
2466
2476
  typeString = explicitType;
2467
2477
  isExplicit = true;
2478
+ printedType = undefined;
2468
2479
  }
2469
2480
  // carrick#2714: the body read is cast to a placeholder
2470
2481
  // (`(await res.json()) as { data: Item[] } | { error: unknown }`) and the
@@ -2475,6 +2486,7 @@ export class TypeInferrer {
2475
2486
  if (narrowed) {
2476
2487
  typeString = narrowed.text;
2477
2488
  isExplicit = true;
2489
+ printedType = narrowed.typeNode ? this.unwrapPromiseType(narrowed.typeNode.getType()) : undefined;
2478
2490
  }
2479
2491
  // carrick#1843: a rule can now match a thenable or a carrier by its alias,
2480
2492
  // so on a result that is a carrier (`Task<Outcome<Reply<T>, E>>`) the
@@ -2509,6 +2521,7 @@ export class TypeInferrer {
2509
2521
  const yielded = this.awaitedBeyondPromise(returnType);
2510
2522
  if (yielded) {
2511
2523
  typeString = typeText(yielded, terminalNode);
2524
+ printedType = yielded;
2512
2525
  }
2513
2526
  }
2514
2527
  // The rules verified what the carrier holds as transport and read no
@@ -2601,6 +2614,7 @@ export class TypeInferrer {
2601
2614
  const carrierPayload = carrierText ? carried : undefined;
2602
2615
  if (carrierPayload && carrierText) {
2603
2616
  typeString = carrierText;
2617
+ printedType = carrierPayload;
2604
2618
  }
2605
2619
  else if (carrierCandidate) {
2606
2620
  this.log(`Call result at ${request.file_path}:${request.line_number} carries a payload with no ` +
@@ -2684,6 +2698,7 @@ export class TypeInferrer {
2684
2698
  `(${stated.how}); publishing that type`);
2685
2699
  typeString = stated.text;
2686
2700
  isExplicit = true;
2701
+ printedType = undefined;
2687
2702
  }
2688
2703
  }
2689
2704
  // #336: consumer analogue of the #306 producer anchor. Anchor on the
@@ -2780,7 +2795,7 @@ export class TypeInferrer {
2780
2795
  }
2781
2796
  }
2782
2797
  }
2783
- const inferred = this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(terminalNode), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined, anchor ? this.primaryTypeSymbol(anchor.element) : undefined, anchor?.depth, anchor ? this.primaryTypeSymbolSource(anchor.element) : undefined);
2798
+ const inferred = this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(terminalNode), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined, anchor ? this.primaryTypeSymbol(anchor.element) : undefined, anchor?.depth, anchor ? this.primaryTypeSymbolSource(anchor.element) : undefined, printedType, anchor?.element);
2784
2799
  // carrick#1749: say when the text is the source's own statement of the
2785
2800
  // body, and what that statement is rooted at, so the scanner can tell a
2786
2801
  // model symbol that names the body from one that names a part of it.
@@ -3022,6 +3037,7 @@ export class TypeInferrer {
3022
3037
  ...(source ? { root_source: source } : {}),
3023
3038
  ...depthField,
3024
3039
  ...(typeArguments > 0 ? { root_type_arguments: typeArguments } : {}),
3040
+ ...(this.isFrameworkMachinery(node.getType()) ? { machinery: true } : {}),
3025
3041
  };
3026
3042
  }
3027
3043
  inferVariable(sourceFile, request, extractionConfig) {
@@ -3045,7 +3061,7 @@ export class TypeInferrer {
3045
3061
  typeString = unwrapResult.typeString;
3046
3062
  }
3047
3063
  typeString = this.unwrapPromise(typeString, varType);
3048
- return this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(varDecl), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined);
3064
+ return this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(varDecl), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined, undefined, undefined, undefined, unwrapResult.wasUnwrapped ? unwrapResult.payloadType : this.unwrapPromiseType(varType));
3049
3065
  }
3050
3066
  inferExpression(sourceFile, request, extractionConfig) {
3051
3067
  const node = this.resolveTargetNode(sourceFile, request);
@@ -3069,7 +3085,7 @@ export class TypeInferrer {
3069
3085
  ? unwrapResult.payloadType
3070
3086
  : type;
3071
3087
  const anchor = this.unwrapArrayLevels(this.unwrapPromiseType(anchorSource));
3072
- return this.createInferredType(request, typeString, false, this.getNodeLocation(node), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined, this.primaryTypeSymbol(anchor.element), anchor.depth, this.primaryTypeSymbolSource(anchor.element));
3088
+ return this.createInferredType(request, typeString, false, this.getNodeLocation(node), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined, this.primaryTypeSymbol(anchor.element), anchor.depth, this.primaryTypeSymbolSource(anchor.element), this.unwrapPromiseType(anchorSource), anchor.element);
3073
3089
  }
3074
3090
  inferRequestBody(sourceFile, request, extractionConfig) {
3075
3091
  let located = this.resolveTargetNode(sourceFile, request);
@@ -3254,7 +3270,7 @@ export class TypeInferrer {
3254
3270
  else if (inCall.kind === 'body_type') {
3255
3271
  this.log(`Request locator at ${request.file_path}:${request.line_number} names ${inCall.from}; ` +
3256
3272
  "reading the body off the config variable's type");
3257
- return this.createInferredType(request, this.expandResolvedTypeStructural(inCall.type, typeText(inCall.type, inCall.at)), false, this.getNodeLocation(inCall.at));
3273
+ return this.createInferredType(request, this.expandResolvedTypeStructural(inCall.type, typeText(inCall.type, inCall.at)), false, this.getNodeLocation(inCall.at), undefined, undefined, undefined, undefined, inCall.type);
3258
3274
  }
3259
3275
  else if (inCall.kind === 'abstain') {
3260
3276
  this.log(`Request locator at ${request.file_path}:${request.line_number}: ${inCall.why}; leaving unresolved`);
@@ -3405,7 +3421,11 @@ export class TypeInferrer {
3405
3421
  return null;
3406
3422
  }
3407
3423
  typeString = this.unwrapPromise(typeString, payloadType);
3408
- return this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(node), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined);
3424
+ return this.createInferredType(request, typeString, isExplicit, this.getNodeLocation(node), unwrapResult.wasUnwrapped ? unwrapResult.typeString : undefined, undefined, undefined, undefined, explicitType
3425
+ ? undefined
3426
+ : unwrapResult.wasUnwrapped
3427
+ ? unwrapResult.payloadType
3428
+ : this.unwrapPromiseType(payloadType));
3409
3429
  }
3410
3430
  // ===========================================================================
3411
3431
  // Call Result Resolution
@@ -4257,7 +4277,7 @@ export class TypeInferrer {
4257
4277
  const anchor = stated.typeNode
4258
4278
  ? this.unwrapArrayLevels(this.unwrapPromiseType(stated.typeNode.getType()))
4259
4279
  : undefined;
4260
- const inferred = this.createInferredType(request, stated.text, true, this.getNodeLocation(stated.at), undefined, anchor ? this.primaryTypeSymbol(anchor.element) : undefined, anchor?.depth, anchor ? this.primaryTypeSymbolSource(anchor.element) : undefined);
4280
+ const inferred = this.createInferredType(request, stated.text, true, this.getNodeLocation(stated.at), undefined, anchor ? this.primaryTypeSymbol(anchor.element) : undefined, anchor?.depth, anchor ? this.primaryTypeSymbolSource(anchor.element) : undefined, stated.typeNode ? this.unwrapPromiseType(stated.typeNode.getType()) : undefined, anchor?.element);
4261
4281
  if (stated.typeNode) {
4262
4282
  inferred.stated_body = this.statedRoot(stated.typeNode);
4263
4283
  }
@@ -5306,6 +5326,25 @@ export class TypeInferrer {
5306
5326
  * the origin gate makes certain a user's own local type sharing those member
5307
5327
  * names is never mistaken for framework machinery (the advisor's guard).
5308
5328
  */
5329
+ /**
5330
+ * Blueprint row N8: true when `type` is framework machinery by where it is
5331
+ * declared, never by its name. Either it passes the structural test
5332
+ * (`typeIsFrameworkMachinery`: the transport's members, declared by a
5333
+ * library or an installed package), or an installed package the store
5334
+ * labels a server framework declares it (`frameworkPackages`), which also
5335
+ * covers app and router instances that carry no reply members. A
5336
+ * service's own `Context` or `Router` is neither.
5337
+ */
5338
+ isFrameworkMachinery(type) {
5339
+ if (this.typeIsFrameworkMachinery(type)) {
5340
+ return true;
5341
+ }
5342
+ if (this.frameworkPackages.size === 0) {
5343
+ return false;
5344
+ }
5345
+ const declaring = this.declaringPackageOf(type);
5346
+ return declaring !== undefined && this.frameworkPackages.has(importedNameOf(declaring));
5347
+ }
5309
5348
  typeIsFrameworkMachinery(type) {
5310
5349
  if (!this.hasMachineryIndicatorThreshold(type)) {
5311
5350
  return false;
@@ -7027,7 +7066,7 @@ export class TypeInferrer {
7027
7066
  const receiverType = receiver.getType();
7028
7067
  const typeString = this.namedTypeLabel(receiverType, receiver);
7029
7068
  return {
7030
- ...this.createInferredType(request, typeString, false, this.getNodeLocation(receiver)),
7069
+ ...this.createInferredType(request, typeString, false, this.getNodeLocation(receiver), undefined, undefined, undefined, undefined, receiverType),
7031
7070
  declaring_package: this.declaringPackageOf(receiverType),
7032
7071
  member_return_type: this.memberReturnTypeOf(call, receiver),
7033
7072
  };
@@ -10237,7 +10276,7 @@ export class TypeInferrer {
10237
10276
  this.readNodes.set(location, node);
10238
10277
  return location;
10239
10278
  }
10240
- createInferredType(request, typeString, isExplicit, sourceLocation, payloadTypeString, primaryTypeSymbol, arrayDepth, primaryTypeSymbolSource) {
10279
+ createInferredType(request, typeString, isExplicit, sourceLocation, payloadTypeString, primaryTypeSymbol, arrayDepth, primaryTypeSymbolSource, printedType, anchorType) {
10241
10280
  const alias = request.alias ||
10242
10281
  this.generateAlias(request.file_path, request.line_number, request.infer_kind);
10243
10282
  return {
@@ -10255,6 +10294,10 @@ export class TypeInferrer {
10255
10294
  array_depth: arrayDepth !== undefined && arrayDepth > 0 ? arrayDepth : undefined,
10256
10295
  // Same gate: a declaration source without an anchor symbol is useless.
10257
10296
  primary_type_symbol_source: primaryTypeSymbol !== undefined ? primaryTypeSymbolSource : undefined,
10297
+ ...(printedType && this.isFrameworkMachinery(printedType) ? { machinery: true } : {}),
10298
+ ...(primaryTypeSymbol !== undefined && anchorType && this.isFrameworkMachinery(anchorType)
10299
+ ? { anchor_machinery: true }
10300
+ : {}),
10258
10301
  };
10259
10302
  }
10260
10303
  generateAlias(filePath, lineNumber, inferKind) {
@@ -217,6 +217,13 @@ export interface InferRequest extends BaseRequest {
217
217
  * receive op's `request.body` path names. Absent or empty, nothing is read.
218
218
  */
219
219
  server_claims?: ServerClaims;
220
+ /**
221
+ * Blueprint row N8: the packages the store labels `server_framework` for
222
+ * this service, as the service imports them. A type one of them declares is
223
+ * framework machinery (`InferredType.machinery`). Absent or empty, only the
224
+ * structural test decides.
225
+ */
226
+ framework_packages?: string[];
220
227
  }
221
228
  /** The server-framework claims an `infer` request reads handler parameters through (carrick#2674). */
222
229
  export interface ServerClaims {
@@ -1473,6 +1480,20 @@ export interface InferredType {
1473
1480
  * is.
1474
1481
  */
1475
1482
  primary_type_symbol_source?: string;
1483
+ /**
1484
+ * Blueprint row N8: the type `type_string` prints is framework machinery,
1485
+ * decided by where it is declared (a library or installed package with the
1486
+ * transport's members, or a package the store labels a server framework),
1487
+ * never by its name. The scanner reads such a text as `unknown`. Absent
1488
+ * otherwise.
1489
+ */
1490
+ machinery?: true;
1491
+ /**
1492
+ * Blueprint row N8: the type `primary_type_symbol` names is framework
1493
+ * machinery, by the same test. Machinery never anchors a row. Absent
1494
+ * otherwise.
1495
+ */
1496
+ anchor_machinery?: true;
1476
1497
  /**
1477
1498
  * Why this inference carries `any`/`unknown` (carrick#376), recorded at the
1478
1499
  * decision point that produced it rather than reconstructed downstream.
@@ -1579,6 +1600,11 @@ export interface StatedBody {
1579
1600
  * `root` alone does not name the body such a statement states.
1580
1601
  */
1581
1602
  root_type_arguments?: number;
1603
+ /**
1604
+ * Blueprint row N8: `root` is framework machinery, decided by where it is
1605
+ * declared, as `InferredType.machinery`. Absent otherwise.
1606
+ */
1607
+ machinery?: true;
1582
1608
  }
1583
1609
  /**
1584
1610
  * Why a type carries `any`/`unknown` at a position, and where.
@@ -897,6 +897,7 @@ export declare const InferRequestSchema: z.ZodObject<{
897
897
  scan_root?: string | undefined;
898
898
  type_packages?: Record<string, string[]> | undefined;
899
899
  }>>>;
900
+ framework_packages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
900
901
  }, "strip", z.ZodTypeAny, {
901
902
  request_id: string;
902
903
  action: "infer";
@@ -942,6 +943,7 @@ export declare const InferRequestSchema: z.ZodObject<{
942
943
  scan_root?: string | undefined;
943
944
  type_packages?: Record<string, string[]> | undefined;
944
945
  } | undefined;
946
+ framework_packages?: string[] | undefined;
945
947
  }, {
946
948
  request_id: string;
947
949
  action: "infer";
@@ -987,6 +989,7 @@ export declare const InferRequestSchema: z.ZodObject<{
987
989
  scan_root?: string | undefined;
988
990
  type_packages?: Record<string, string[]> | undefined;
989
991
  } | undefined;
992
+ framework_packages?: string[] | undefined;
990
993
  }>;
991
994
  export declare const HealthRequestSchema: z.ZodObject<{
992
995
  request_id: z.ZodString;
@@ -4446,6 +4449,7 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
4446
4449
  scan_root?: string | undefined;
4447
4450
  type_packages?: Record<string, string[]> | undefined;
4448
4451
  }>>>;
4452
+ framework_packages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
4449
4453
  }, "strip", z.ZodTypeAny, {
4450
4454
  request_id: string;
4451
4455
  action: "infer";
@@ -4491,6 +4495,7 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
4491
4495
  scan_root?: string | undefined;
4492
4496
  type_packages?: Record<string, string[]> | undefined;
4493
4497
  } | undefined;
4498
+ framework_packages?: string[] | undefined;
4494
4499
  }, {
4495
4500
  request_id: string;
4496
4501
  action: "infer";
@@ -4536,6 +4541,7 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
4536
4541
  scan_root?: string | undefined;
4537
4542
  type_packages?: Record<string, string[]> | undefined;
4538
4543
  } | undefined;
4544
+ framework_packages?: string[] | undefined;
4539
4545
  }>, z.ZodObject<{
4540
4546
  request_id: z.ZodString;
4541
4547
  } & {
@@ -279,6 +279,8 @@ export const InferRequestSchema = BaseRequestSchema.extend({
279
279
  .optional(),
280
280
  // Declared below with the library claims; read lazily (carrick#2674).
281
281
  server_claims: z.lazy(() => ServerClaimsSchema).optional(),
282
+ // Blueprint row N8: the packages the store labels a server framework.
283
+ framework_packages: z.array(z.string().min(1)).optional(),
282
284
  });
283
285
  export const HealthRequestSchema = BaseRequestSchema.extend({
284
286
  action: z.literal('health'),
@@ -1,7 +0,0 @@
1
- {
2
- "serviceName": "",
3
- "internalEnvVars": [],
4
- "externalEnvVars": [],
5
- "internalDomains": [],
6
- "externalDomains": []
7
- }