carrick 0.3.156 → 0.3.158

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 (166) hide show
  1. package/dist/cli.d.ts +7 -0
  2. package/dist/cli.js +4 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/contract.d.ts +8 -1
  5. package/dist/contract.js.map +1 -1
  6. package/dist/engine-ask.d.ts +21 -0
  7. package/dist/engine-ask.js +50 -0
  8. package/dist/engine-ask.js.map +1 -0
  9. package/dist/facts/diff.d.ts +14 -1
  10. package/dist/facts/diff.js +21 -8
  11. package/dist/facts/diff.js.map +1 -1
  12. package/dist/facts/enabled.d.ts +6 -0
  13. package/dist/facts/enabled.js +8 -0
  14. package/dist/facts/enabled.js.map +1 -1
  15. package/dist/facts/fetch.d.ts +7 -0
  16. package/dist/facts/fetch.js +24 -2
  17. package/dist/facts/fetch.js.map +1 -1
  18. package/dist/facts/lines.d.ts +22 -4
  19. package/dist/facts/lines.js +31 -9
  20. package/dist/facts/lines.js.map +1 -1
  21. package/dist/facts/peers.d.ts +13 -4
  22. package/dist/facts/peers.js +17 -15
  23. package/dist/facts/peers.js.map +1 -1
  24. package/dist/facts/rules/packages.js +3 -1
  25. package/dist/facts/rules/packages.js.map +1 -1
  26. package/dist/facts/rules/same-name.js +1 -1
  27. package/dist/facts/rules/same-name.js.map +1 -1
  28. package/dist/facts/store.d.ts +15 -0
  29. package/dist/facts/store.js +30 -0
  30. package/dist/facts/store.js.map +1 -1
  31. package/dist/held/backoff.d.ts +8 -0
  32. package/dist/held/backoff.js +43 -0
  33. package/dist/held/backoff.js.map +1 -0
  34. package/dist/held/build.d.ts +17 -0
  35. package/dist/held/build.js +62 -0
  36. package/dist/held/build.js.map +1 -0
  37. package/dist/held/client.d.ts +43 -0
  38. package/dist/held/client.js +200 -0
  39. package/dist/held/client.js.map +1 -0
  40. package/dist/held/daemon.d.ts +151 -0
  41. package/dist/held/daemon.js +399 -0
  42. package/dist/held/daemon.js.map +1 -0
  43. package/dist/held/early.d.ts +28 -0
  44. package/dist/held/early.js +115 -0
  45. package/dist/held/early.js.map +1 -0
  46. package/dist/held/engine.d.ts +50 -0
  47. package/dist/held/engine.js +166 -0
  48. package/dist/held/engine.js.map +1 -0
  49. package/dist/held/paths.d.ts +15 -0
  50. package/dist/held/paths.js +44 -0
  51. package/dist/held/paths.js.map +1 -0
  52. package/dist/held/place.d.ts +130 -0
  53. package/dist/held/place.js +236 -0
  54. package/dist/held/place.js.map +1 -0
  55. package/dist/held/registry.d.ts +22 -0
  56. package/dist/held/registry.js +72 -0
  57. package/dist/held/registry.js.map +1 -0
  58. package/dist/held/run.d.ts +2 -0
  59. package/dist/held/run.js +78 -0
  60. package/dist/held/run.js.map +1 -0
  61. package/dist/held/runtime.d.ts +22 -0
  62. package/dist/held/runtime.js +612 -0
  63. package/dist/held/runtime.js.map +1 -0
  64. package/dist/held/shadow.d.ts +33 -0
  65. package/dist/held/shadow.js +68 -0
  66. package/dist/held/shadow.js.map +1 -0
  67. package/dist/held/steps.d.ts +11 -0
  68. package/dist/held/steps.js +29 -0
  69. package/dist/held/steps.js.map +1 -0
  70. package/dist/hook/bash-targets.d.ts +7 -2
  71. package/dist/hook/bash-targets.js +82 -27
  72. package/dist/hook/bash-targets.js.map +1 -1
  73. package/dist/hook/confirm.d.ts +79 -0
  74. package/dist/hook/confirm.js +220 -0
  75. package/dist/hook/confirm.js.map +1 -0
  76. package/dist/hook/edit-flow.d.ts +14 -3
  77. package/dist/hook/edit-flow.js +113 -33
  78. package/dist/hook/edit-flow.js.map +1 -1
  79. package/dist/hook/generation.d.ts +19 -0
  80. package/dist/hook/generation.js +75 -0
  81. package/dist/hook/generation.js.map +1 -0
  82. package/dist/hook/late.d.ts +50 -9
  83. package/dist/hook/late.js +104 -24
  84. package/dist/hook/late.js.map +1 -1
  85. package/dist/hook/lock.d.ts +26 -0
  86. package/dist/hook/lock.js +122 -0
  87. package/dist/hook/lock.js.map +1 -0
  88. package/dist/hook/post-bash.js +17 -8
  89. package/dist/hook/post-bash.js.map +1 -1
  90. package/dist/hook/post-edit.js +2 -2
  91. package/dist/hook/post-edit.js.map +1 -1
  92. package/dist/hook/post-read.js +25 -3
  93. package/dist/hook/post-read.js.map +1 -1
  94. package/dist/hook/post-search.js +1 -1
  95. package/dist/hook/post-search.js.map +1 -1
  96. package/dist/hook/probe.js +1 -0
  97. package/dist/hook/probe.js.map +1 -1
  98. package/dist/hook/read-answer.d.ts +5 -0
  99. package/dist/hook/read-answer.js +8 -4
  100. package/dist/hook/read-answer.js.map +1 -1
  101. package/dist/hook/rechecks.d.ts +59 -2
  102. package/dist/hook/rechecks.js +129 -119
  103. package/dist/hook/rechecks.js.map +1 -1
  104. package/dist/hook/session-start.d.ts +1 -1
  105. package/dist/hook/session-start.js +19 -5
  106. package/dist/hook/session-start.js.map +1 -1
  107. package/dist/hook/similar.d.ts +1 -1
  108. package/dist/hook/similar.js +21 -8
  109. package/dist/hook/similar.js.map +1 -1
  110. package/dist/hook/stop-wait.js +35 -16
  111. package/dist/hook/stop-wait.js.map +1 -1
  112. package/dist/hook/timings.d.ts +30 -2
  113. package/dist/hook/timings.js +8 -2
  114. package/dist/hook/timings.js.map +1 -1
  115. package/dist/hook/user-prompt.js +2 -2
  116. package/dist/hook/user-prompt.js.map +1 -1
  117. package/dist/hosted-snapshot.d.ts +27 -0
  118. package/dist/hosted-snapshot.js +32 -0
  119. package/dist/hosted-snapshot.js.map +1 -1
  120. package/dist/init/hosted.js +2 -9
  121. package/dist/init/hosted.js.map +1 -1
  122. package/dist/lsp-frame.d.ts +20 -0
  123. package/dist/lsp-frame.js +47 -0
  124. package/dist/lsp-frame.js.map +1 -0
  125. package/dist/render.d.ts +15 -1
  126. package/dist/render.js +50 -4
  127. package/dist/render.js.map +1 -1
  128. package/dist/server.js +5 -29
  129. package/dist/server.js.map +1 -1
  130. package/package.json +6 -6
  131. package/plugin/.claude-plugin/plugin.json +1 -1
  132. package/sidecar/dist/src/capture/anchors.d.ts +8 -0
  133. package/sidecar/dist/src/capture/anchors.js +3 -2
  134. package/sidecar/dist/src/capture/api.d.ts +98 -1
  135. package/sidecar/dist/src/capture/check-classify.d.ts +7 -0
  136. package/sidecar/dist/src/capture/check-classify.js +24 -0
  137. package/sidecar/dist/src/capture/check-probe.d.ts +86 -11
  138. package/sidecar/dist/src/capture/check-probe.js +175 -22
  139. package/sidecar/dist/src/capture/check.js +13 -1
  140. package/sidecar/dist/src/capture/graphql-leaves.d.ts +46 -0
  141. package/sidecar/dist/src/capture/graphql-leaves.js +142 -0
  142. package/sidecar/dist/src/capture/index.d.ts +12 -3
  143. package/sidecar/dist/src/capture/index.js +11 -2
  144. package/sidecar/dist/src/capture/result-label.js +3 -1
  145. package/sidecar/dist/src/capture/type-reasons.json +78 -0
  146. package/sidecar/dist/src/definition-resolver.d.ts +6 -5
  147. package/sidecar/dist/src/definition-resolver.js +20 -15
  148. package/sidecar/dist/src/engine-stamp.json +1 -0
  149. package/sidecar/dist/src/held-shadow.d.ts +70 -0
  150. package/sidecar/dist/src/held-shadow.js +222 -0
  151. package/sidecar/dist/src/index.js +65 -2
  152. package/sidecar/dist/src/library-claims.d.ts +3 -1
  153. package/sidecar/dist/src/library-claims.js +105 -6
  154. package/sidecar/dist/src/retype.d.ts +47 -0
  155. package/sidecar/dist/src/retype.js +274 -18
  156. package/sidecar/dist/src/site-find.d.ts +27 -0
  157. package/sidecar/dist/src/site-find.js +109 -0
  158. package/sidecar/dist/src/type-home.d.ts +12 -0
  159. package/sidecar/dist/src/type-home.js +41 -1
  160. package/sidecar/dist/src/type-inferrer.d.ts +13 -3
  161. package/sidecar/dist/src/type-inferrer.js +44 -22
  162. package/sidecar/dist/src/type-structural-expander.d.ts +11 -11
  163. package/sidecar/dist/src/type-structural-expander.js +73 -4
  164. package/sidecar/dist/src/types.d.ts +91 -5
  165. package/sidecar/dist/src/validators.d.ts +621 -254
  166. package/sidecar/dist/src/validators.js +37 -0
@@ -8,6 +8,7 @@
8
8
  * stdio `capture_v2` action is the only surface the Rust client sees.
9
9
  */
10
10
  import type { ResultLabel } from './result-label.js';
11
+ import type TypeReasons from './type-reasons.json';
11
12
  export type { ResultLabel };
12
13
  /**
13
14
  * How the anchor was produced upstream (design-doc amendment 2). Recorded so
@@ -273,8 +274,25 @@ export type SelfCheckOutcome = 'ok' | 'allowlisted_external' | 'decayed_internal
273
274
  * layer placed (carrick#3995). Stamped at the entry's root.
274
275
  * - `not_recorded`: the position carries a top type and this layer has no
275
276
  * cause for it.
277
+ *
278
+ * The words are the keys of `./type-reasons.json`, the one list of reasons
279
+ * (carrick#4231): each word's reader sentence and whether it means the scan
280
+ * DECIDED there is no contract (`always`, `at_call_result`, `never`). The
281
+ * engine's decided set and the Rust driver's `reason_decided` both read that
282
+ * file. A word stays in it while any stored index can still carry it.
276
283
  */
277
- export type TypeProvenanceReason = 'declared' | 'unresolved_import' | 'budget_exhausted' | 'no_payload_evidence' | 'machinery_envelope' | 'coerced_input' | 'no_success_payload' | 'no_request_body' | 'projected_value_only' | 'serialised_body_unread' | 'body_built_by_callee' | 'reshaped_by_callback' | 'result_member_missing' | 'bound_by_callers' | 'body_member_undecided' | 'not_located' | 'site_unreadable' | 'unplaced_top_type' | 'not_recorded';
284
+ export type TypeProvenanceReason = keyof typeof TypeReasons;
285
+ /**
286
+ * When a root `unknown` with this reason is a decision rather than a failed
287
+ * read: at every site, only at a consumer call's result, or never.
288
+ */
289
+ export type ReasonDecided = 'always' | 'at_call_result' | 'never';
290
+ /** One word's row in `./type-reasons.json`. */
291
+ export interface TypeReason {
292
+ /** What a reader is told the word means. */
293
+ sentence: string;
294
+ decided: ReasonDecided;
295
+ }
278
296
  /**
279
297
  * One `any`/`unknown` finding inside a captured or inferred type, with its
280
298
  * position and its cause. Sorted by `path` wherever a list is emitted, so the
@@ -506,12 +524,79 @@ export type ProbeProtocol = 'http' | 'graphql' | 'socket' | 'pubsub';
506
524
  * pairs are `both`.
507
525
  */
508
526
  export type ProbeTypeKind = 'request' | 'response' | 'both';
527
+ /**
528
+ * The representation a type is printed in.
529
+ *
530
+ * `'declared'` prints the type the source declares. `'json'` prints what a
531
+ * JSON serialiser puts on the wire for a value of that type (carrick#1163):
532
+ * `JSON.stringify` calls a value's `toJSON()` and serialises its RESULT, so a
533
+ * `Date` travels as the string its `toJSON` returns, and so does any other
534
+ * type that declares one. The mapping is read from the compiler's own
535
+ * signature, never from a list of type names. `'unknown'` is a payload whose
536
+ * form is not a known fact (an RPC procedure, carrick#4402): it prints as
537
+ * declared, and the judge abstains where the declared and JSON readings
538
+ * disagree. Which payloads travel in which form is `wireFormFor`
539
+ * (check-probe.ts), the one rule.
540
+ */
541
+ export type WireFormat = 'declared' | 'json' | 'graphql_scalars' | 'unknown';
542
+ /**
543
+ * A field's output type as the SDL declares it (carrick#4403): a built-in or
544
+ * custom scalar by name, an enum, a list or non-null wrapper around another
545
+ * leaf, or a reference to an object, interface or union type in the
546
+ * service's `GraphqlTypes` table.
547
+ */
548
+ export type GraphqlLeaf = {
549
+ scalar: string;
550
+ } | {
551
+ enum: string;
552
+ } | {
553
+ list: GraphqlLeaf;
554
+ } | {
555
+ non_null: GraphqlLeaf;
556
+ } | {
557
+ type: string;
558
+ };
559
+ /** One SDL output type: an object or interface's fields, or a union's members. */
560
+ export type GraphqlTypeDef = {
561
+ fields: {
562
+ [field: string]: GraphqlLeaf;
563
+ };
564
+ } | {
565
+ members: string[];
566
+ };
567
+ /**
568
+ * A service's SDL output types by name (carrick#4403): one table per
569
+ * service, which the engine stamps on the service record and carries here.
570
+ */
571
+ export type GraphqlTypes = {
572
+ [typeName: string]: GraphqlTypeDef;
573
+ };
574
+ /** The root field a GraphQL producer response answers (`Query.invoice`). */
575
+ export interface GraphqlRoot {
576
+ type: string;
577
+ field: string;
578
+ }
579
+ /**
580
+ * The facts besides protocol, kind and side that decide a payload's wire form
581
+ * (`wireFormFor`). An absent fact reads as unknown, never as a default.
582
+ */
583
+ export interface WireFacts {
584
+ /** The producer is an RPC router procedure (carrick#4402): its form is unknown. */
585
+ procedure?: boolean;
586
+ /** The producer service's SDL types and the root field this response answers. */
587
+ graphql?: {
588
+ types: GraphqlTypes;
589
+ root: GraphqlRoot;
590
+ };
591
+ }
509
592
  /** One capture stub package to assemble into the check workspace. */
510
593
  export interface CheckStubInput {
511
594
  /** Service name (used for scrub labels + pair endpoints). */
512
595
  service_name: string;
513
596
  /** Absolute path to the capture stub dir (package.json + types/ tree). */
514
597
  stub_dir: string;
598
+ /** The service's SDL output types (carrick#4403), when it serves a schema. */
599
+ graphql_types?: GraphqlTypes;
515
600
  }
516
601
  /** One side of a matched pair: a service + the surface alias to probe. */
517
602
  export interface CheckPairEndpoint {
@@ -537,6 +622,18 @@ export interface CheckPairSpec {
537
622
  * is the whole message from a side that is its payload.
538
623
  */
539
624
  topic?: string;
625
+ /**
626
+ * The producer is a procedure of an RPC router (tRPC and similar), and only
627
+ * then (carrick#4402). Its router's transformer, not JSON, decides the form
628
+ * the payload travels in, so the judge reads neither form alone.
629
+ */
630
+ procedure?: true;
631
+ /**
632
+ * The root field a GraphQL producer response answers (carrick#4403), and
633
+ * only of one. With the producer stub's `graphql_types`, `wireFormFor`
634
+ * compares each built-in scalar leaf in the type that scalar sends.
635
+ */
636
+ graphql_root?: GraphqlRoot;
540
637
  }
541
638
  /**
542
639
  * Classifier output: the four buckets of pinned decision 7, and one more
@@ -17,6 +17,8 @@
17
17
  * else unverifiable (no body read)
18
18
  * IsFormBody gate fired (TS2344) -> unverifiable (form-encoded body)
19
19
  * IsByteBody gate fired (TS2344) -> unverifiable (bytes, even agreeing)
20
+ * procedure wire-form gate (TS2344) -> unverifiable (declared and JSON
21
+ * readings disagree, carrick#4402)
20
22
  * raw-text read marked on a side -> unverifiable (text, even agreeing)
21
23
  * assignment error, sent union taken in part by a weak expected type
22
24
  * -> unverifiable (carrick#1995)
@@ -98,6 +100,11 @@ export interface ClassifyInput {
98
100
  }
99
101
  /** Classify one pair into exactly one bucket, honouring the precedence order. */
100
102
  export declare function classifyPair(input: ClassifyInput): CheckVerdict;
103
+ /**
104
+ * Why a procedure pair whose two wire readings disagree is not compared
105
+ * (carrick#4402). Customer-facing: it prints after "Types not verified".
106
+ */
107
+ export declare function wireFormUnknownReason(side: Side): string;
101
108
  /**
102
109
  * The note on a request the consumer's unwidened reading cleared
103
110
  * (carrick#2011).
@@ -17,6 +17,8 @@
17
17
  * else unverifiable (no body read)
18
18
  * IsFormBody gate fired (TS2344) -> unverifiable (form-encoded body)
19
19
  * IsByteBody gate fired (TS2344) -> unverifiable (bytes, even agreeing)
20
+ * procedure wire-form gate (TS2344) -> unverifiable (declared and JSON
21
+ * readings disagree, carrick#4402)
20
22
  * raw-text read marked on a side -> unverifiable (text, even agreeing)
21
23
  * assignment error, sent union taken in part by a weak expected type
22
24
  * -> unverifiable (carrick#1995)
@@ -253,6 +255,21 @@ export function classifyPair(input) {
253
255
  ...notAFact(`the ${side} body is bytes`, side),
254
256
  };
255
257
  }
258
+ // 4c'. A procedure payload whose form travels by its router's transformer
259
+ // (carrick#4402): the declared reading fails and the JSON reading
260
+ // passes, so which one travels decides the verdict, and that is not a
261
+ // known fact. Not a fact either way, and no side to retype: a retype
262
+ // would read the same two forms.
263
+ if (firedGates.has('sent:wire_form')) {
264
+ const { side } = sideForGate('sent:wire_form', plan);
265
+ return {
266
+ ...base,
267
+ bucket: 'unverifiable',
268
+ gate: `${side}:wire_form`,
269
+ diagnostic: `${wireFormUnknownReason(side)}.`,
270
+ ...notAFact(wireFormUnknownReason(side)),
271
+ };
272
+ }
256
273
  // 4d. A body read as raw text (carrick#1842): a `.text()` read, or a request
257
274
  // library's text format, takes the body unparsed, so `string` there
258
275
  // states no structural contract. Like bytes, the pair is not compared,
@@ -398,6 +415,13 @@ export function classifyPair(input) {
398
415
  // 6. No diagnostics -> compatible.
399
416
  return { ...base, bucket: 'compatible', ...factness(input) };
400
417
  }
418
+ /**
419
+ * Why a procedure pair whose two wire readings disagree is not compared
420
+ * (carrick#4402). Customer-facing: it prints after "Types not verified".
421
+ */
422
+ export function wireFormUnknownReason(side) {
423
+ return `the ${side} sends this payload through an RPC router whose transformer decides how a Date travels; the types match in one form and not the other, so Carrick cannot verify them without knowing the transformer`;
424
+ }
401
425
  /**
402
426
  * The note on a request the consumer's unwidened reading cleared
403
427
  * (carrick#2011).
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * Seam: node builtins + `typescript` + this bundle only. No imports needed here.
32
32
  */
33
- import type { CheckPairEndpoint, CheckPairSpec, ProbeProtocol, ProbeTypeKind } from './api.js';
33
+ import type { CheckPairEndpoint, CheckPairSpec, GraphqlTypes, ProbeProtocol, ProbeTypeKind, WireFacts, WireFormat } from './api.js';
34
34
  /** Which pair endpoint supplies the `sent` value / the `expected` binding. */
35
35
  export type Side = 'producer' | 'consumer';
36
36
  export interface Direction {
@@ -49,22 +49,37 @@ export interface Direction {
49
49
  */
50
50
  export declare function directionFor(protocol: ProbeProtocol, typeKind: ProbeTypeKind): Direction;
51
51
  /**
52
- * Whether a payload travels in its JSON wire form: the one rule the judge and
53
- * the stored type text both read (carrick-cloud#3503). An `http` payload is
54
- * serialised before it travels, and `JSON.stringify` writes a value's
55
- * `toJSON()` result, so the SENDING side of an `http` pair (`directionFor`'s
56
- * `sent`: the producer of a response, the consumer of a request body) is
57
- * what the other side receives in wire form. Every other protocol is compared
58
- * and stored as declared (carrick#4275 decides theirs here, once).
52
+ * The form a payload travels in: the one rule the judge and the stored type
53
+ * text both read (carrick-cloud#3503, carrick#4275). Only the SENDING side
54
+ * (`directionFor`'s `sent`) is ever transformed, because that is where
55
+ * serialisation happens:
56
+ *
57
+ * - `http`: a body is serialised with `JSON.stringify`, which writes a
58
+ * value's `toJSON()` result, so the producer of a response and the
59
+ * consumer of a request body send their JSON form;
60
+ * - `graphql` response: the server sends each leaf through its scalar's
61
+ * `serialize`, so a resolver's `Date` reaches the client as a string. With
62
+ * the producer's SDL types and the root field the response answers
63
+ * (`facts.graphql`, carrick#4403) a built-in scalar leaf is compared in the
64
+ * type its scalar sends (`'graphql_scalars'`); without them, and for a
65
+ * custom scalar or an enum, in the JSON form. The request (variables) is
66
+ * read by the server as declared;
67
+ * - socket and pub/sub payloads stay declared until the codec each library
68
+ * uses is a known fact: the codec belongs to the client, not the protocol;
69
+ * - an RPC procedure (tRPC and similar) travels in its router's
70
+ * transformer's form, either side: JSON with none, the declared `Date`
71
+ * with one that revives it (superjson). Until the transformer is a known
72
+ * fact the form is `'unknown'` (carrick#4402): the stored text prints it
73
+ * as declared, and the judge abstains where the two readings disagree.
59
74
  */
60
- export declare function sentInJsonWireForm(protocol: ProbeProtocol, typeKind: ProbeTypeKind, side: Side): boolean;
75
+ export declare function wireFormFor(protocol: ProbeProtocol, typeKind: ProbeTypeKind, side: Side, facts?: WireFacts): WireFormat;
61
76
  /** Deterministic FNV-1a (32-bit) over the pair's stable key. Never a path. */
62
77
  export declare function fnv1a(input: string): string;
63
78
  /** The pair ID is derived from the pair's semantic identity, not the workspace
64
79
  * path, so it is byte-stable across runs. */
65
80
  export declare function pairId(spec: CheckPairSpec): string;
66
81
  /** Names each gate line so a TS2344 can be attributed to a specific side+kind. */
67
- export type GateName = 'sent:any' | 'sent:unknown' | 'sent:never' | 'sent:void' | 'sent:form' | 'sent:bytes' | 'expected:any' | 'expected:unknown' | 'expected:never' | 'expected:void' | 'expected:bytes' | 'sent:envelope' | 'expected:envelope';
82
+ export type GateName = 'sent:any' | 'sent:unknown' | 'sent:never' | 'sent:void' | 'sent:form' | 'sent:bytes' | 'sent:wire_form' | 'expected:any' | 'expected:unknown' | 'expected:never' | 'expected:void' | 'expected:bytes' | 'sent:envelope' | 'expected:envelope';
68
83
  export interface ProbePlan {
69
84
  pairId: string;
70
85
  spec: CheckPairSpec;
@@ -140,6 +155,66 @@ export declare const UNWIDENED_LOCAL_NAME = "SentUnwidened";
140
155
  * (one that returns its own type), and which no depth of nesting reaches.
141
156
  */
142
157
  export declare function jsonWireDeclarations(prefix: string): string[];
158
+ /**
159
+ * The judge's decisive wire rule as a type expression: keep the declared
160
+ * `sent` type whenever it already assigns to `expected` or serialising
161
+ * changes nothing observable, else the wire form. `buildProbe` writes it at
162
+ * every wire line, and the held check appends it, so the line and the PR
163
+ * check answer "what travels" from this one text. `prefix` is the one
164
+ * `jsonWireDeclarations` was given.
165
+ */
166
+ export declare function jsonWireRule(sent: string, expected: string, prefix: string): string;
167
+ /**
168
+ * The receiver-declared-void gate's helper: `void` or `undefined` is what a
169
+ * call site that reads no body types its response as, and states no contract
170
+ * (carrick#1162). `any` is excluded first, so an `any` side keeps its own
171
+ * top-type reason. `prefix` namespaces the name, as for `jsonWireDeclarations`.
172
+ */
173
+ export declare function voidReceiverDeclaration(prefix: string): string;
174
+ /**
175
+ * The absent-body tolerance as a type expression over `sent` (carrick#2814):
176
+ * a body the sender may omit (`T | undefined`, `T | void`) is compatible with
177
+ * a receiver that requires none, which is one with no required member
178
+ * (`{} extends expected`) that either admits absence itself or whose handler
179
+ * works with nothing sent (`toleratesAbsence`, the capture record's
180
+ * `absent_body_tolerated`).
181
+ */
182
+ export declare function absentBodyRule(sent: string, expected: string, toleratesAbsence: boolean): string;
183
+ /**
184
+ * The judge's three tolerances, as the texts the probe is built from: the
185
+ * literal-widened reading (`unwidened_alias_suffix`, the export suffix a stub
186
+ * ships its unwidened response under, `unwidenedAliasOf`), and the other two
187
+ * as declarations to append beside `jsonWireDeclarations` (same `prefix`):
188
+ * `<p>IsVoid<T>` (a receiver declared void), `<p>AbsentBody<S, E>` (the absent
189
+ * body dropped when the receiver admits absence) and `<p>AbsentBodyByHandler<S,
190
+ * E>` (the same when the receiver's handler is marked to tolerate it). A
191
+ * caller that checks a value against a declared type reads them from here,
192
+ * never from a copy.
193
+ */
194
+ export interface JudgeTolerances {
195
+ unwidened_alias_suffix: string;
196
+ declarations: string[];
197
+ }
198
+ export declare function judgeTolerances(prefix: string): JudgeTolerances;
199
+ /**
200
+ * The probe's GraphQL leaf walk (carrick#4403), over the SDL types reachable
201
+ * from the root field (`graphqlReachableFields`, which reads the table only
202
+ * through `graphqlFieldLeaf`). `GqlLeafSent<C, F>` is the type the server
203
+ * sends for a value `C` declared as `F`:
204
+ *
205
+ * - `any` and `unknown` stay what they are, so a top type is never laundered
206
+ * into a scalar; non-null is read through; `null` and `undefined` stay;
207
+ * - a list maps its elements; a non-array under a list keeps the JSON form;
208
+ * - a built-in scalar is the type it sends (`GRAPHQL_SCALAR_SENT`); any
209
+ * other scalar, an enum and a field the table does not name are JSON;
210
+ * - an object type the table holds maps each field through its own leaf;
211
+ * a type reference it does not hold (an undeclared scalar) is JSON.
212
+ *
213
+ * Every test on `F` is wrapped (`[F] extends [...]`) so a missing leaf never
214
+ * distributes to `never`. Needs `JsonWire`, `GqlDepth` and the comparand's
215
+ * helpers declared before it.
216
+ */
217
+ export declare function graphqlScalarDeclarations(reachable: Record<string, Record<string, unknown>>, rootLeaf: unknown): string[];
143
218
  export declare function decisiveAssignmentLine(plan: ProbePlan): number;
144
219
  /**
145
220
  * Build one probe, recording the exact line of every gate and the assignment so
@@ -157,4 +232,4 @@ export declare function decisiveAssignmentLine(plan: ProbePlan): number;
157
232
  * capture record marks a handler that works when no body is sent
158
233
  * (carrick#2814).
159
234
  */
160
- export declare function buildProbe(spec: CheckPairSpec, packageOf: (serviceName: string) => string, unwidenedAliasFor?: (sent: CheckPairEndpoint) => string | undefined, expectedToleratesAbsence?: (expected: CheckPairEndpoint) => boolean): ProbePlan;
235
+ export declare function buildProbe(spec: CheckPairSpec, packageOf: (serviceName: string) => string, unwidenedAliasFor?: (sent: CheckPairEndpoint) => string | undefined, expectedToleratesAbsence?: (expected: CheckPairEndpoint) => boolean, graphqlTypesOf?: (serviceName: string) => GraphqlTypes | undefined): ProbePlan;
@@ -30,6 +30,7 @@
30
30
  *
31
31
  * Seam: node builtins + `typescript` + this bundle only. No imports needed here.
32
32
  */
33
+ import { GRAPHQL_SCALAR_SENT, graphqlReachableFields, graphqlRootLeaf, } from './graphql-leaves.js';
33
34
  /**
34
35
  * The direction table, keyed on (protocol, type_kind) — one place. Structurally
35
36
  * fixes the confirmed HTTP request-body inversion (data flows consumer ->
@@ -51,16 +52,43 @@ export function directionFor(protocol, typeKind) {
51
52
  return { sent: 'producer', expected: 'consumer' };
52
53
  }
53
54
  /**
54
- * Whether a payload travels in its JSON wire form: the one rule the judge and
55
- * the stored type text both read (carrick-cloud#3503). An `http` payload is
56
- * serialised before it travels, and `JSON.stringify` writes a value's
57
- * `toJSON()` result, so the SENDING side of an `http` pair (`directionFor`'s
58
- * `sent`: the producer of a response, the consumer of a request body) is
59
- * what the other side receives in wire form. Every other protocol is compared
60
- * and stored as declared (carrick#4275 decides theirs here, once).
55
+ * The form a payload travels in: the one rule the judge and the stored type
56
+ * text both read (carrick-cloud#3503, carrick#4275). Only the SENDING side
57
+ * (`directionFor`'s `sent`) is ever transformed, because that is where
58
+ * serialisation happens:
59
+ *
60
+ * - `http`: a body is serialised with `JSON.stringify`, which writes a
61
+ * value's `toJSON()` result, so the producer of a response and the
62
+ * consumer of a request body send their JSON form;
63
+ * - `graphql` response: the server sends each leaf through its scalar's
64
+ * `serialize`, so a resolver's `Date` reaches the client as a string. With
65
+ * the producer's SDL types and the root field the response answers
66
+ * (`facts.graphql`, carrick#4403) a built-in scalar leaf is compared in the
67
+ * type its scalar sends (`'graphql_scalars'`); without them, and for a
68
+ * custom scalar or an enum, in the JSON form. The request (variables) is
69
+ * read by the server as declared;
70
+ * - socket and pub/sub payloads stay declared until the codec each library
71
+ * uses is a known fact: the codec belongs to the client, not the protocol;
72
+ * - an RPC procedure (tRPC and similar) travels in its router's
73
+ * transformer's form, either side: JSON with none, the declared `Date`
74
+ * with one that revives it (superjson). Until the transformer is a known
75
+ * fact the form is `'unknown'` (carrick#4402): the stored text prints it
76
+ * as declared, and the judge abstains where the two readings disagree.
61
77
  */
62
- export function sentInJsonWireForm(protocol, typeKind, side) {
63
- return protocol === 'http' && directionFor(protocol, typeKind).sent === side;
78
+ export function wireFormFor(protocol, typeKind, side, facts = {}) {
79
+ if (directionFor(protocol, typeKind).sent !== side)
80
+ return 'declared';
81
+ if (facts.procedure)
82
+ return 'unknown';
83
+ if (protocol === 'http')
84
+ return 'json';
85
+ if (protocol === 'graphql' && typeKind === 'response') {
86
+ const graphql = facts.graphql;
87
+ return graphql !== undefined && graphqlRootLeaf(graphql.types, graphql.root) !== undefined
88
+ ? 'graphql_scalars'
89
+ : 'json';
90
+ }
91
+ return 'declared';
64
92
  }
65
93
  /** Deterministic FNV-1a (32-bit) over the pair's stable key. Never a path. */
66
94
  export function fnv1a(input) {
@@ -130,6 +158,80 @@ export function jsonWireDeclarations(prefix) {
130
158
  `type ${same}<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;`,
131
159
  ];
132
160
  }
161
+ /**
162
+ * The judge's decisive wire rule as a type expression: keep the declared
163
+ * `sent` type whenever it already assigns to `expected` or serialising
164
+ * changes nothing observable, else the wire form. `buildProbe` writes it at
165
+ * every wire line, and the held check appends it, so the line and the PR
166
+ * check answer "what travels" from this one text. `prefix` is the one
167
+ * `jsonWireDeclarations` was given.
168
+ */
169
+ export function jsonWireRule(sent, expected, prefix) {
170
+ return `[${sent}] extends [${expected}] ? ${sent} : (${prefix}JsonWireSame<${prefix}JsonWire<${sent}>, ${sent}> extends true ? ${sent} : ${prefix}JsonWire<${sent}>)`;
171
+ }
172
+ /**
173
+ * The receiver-declared-void gate's helper: `void` or `undefined` is what a
174
+ * call site that reads no body types its response as, and states no contract
175
+ * (carrick#1162). `any` is excluded first, so an `any` side keeps its own
176
+ * top-type reason. `prefix` namespaces the name, as for `jsonWireDeclarations`.
177
+ */
178
+ export function voidReceiverDeclaration(prefix) {
179
+ return `type ${prefix}IsVoid<T> = 0 extends 1 & T ? false : [T] extends [never] ? false : [T] extends [void] ? true : false;`;
180
+ }
181
+ /**
182
+ * The absent-body tolerance as a type expression over `sent` (carrick#2814):
183
+ * a body the sender may omit (`T | undefined`, `T | void`) is compatible with
184
+ * a receiver that requires none, which is one with no required member
185
+ * (`{} extends expected`) that either admits absence itself or whose handler
186
+ * works with nothing sent (`toleratesAbsence`, the capture record's
187
+ * `absent_body_tolerated`).
188
+ */
189
+ export function absentBodyRule(sent, expected, toleratesAbsence) {
190
+ const dropped = `Exclude<${sent}, undefined | void>`;
191
+ const byHandler = toleratesAbsence ? dropped : sent;
192
+ return `[Extract<${sent}, undefined | void>] extends [never] ? ${sent} : [{}] extends [${expected}] ? ([Extract<${expected}, undefined | void>] extends [never] ? ${byHandler} : ${dropped}) : ${sent}`;
193
+ }
194
+ export function judgeTolerances(prefix) {
195
+ return {
196
+ unwidened_alias_suffix: unwidenedAliasOf(''),
197
+ declarations: [
198
+ voidReceiverDeclaration(prefix),
199
+ `type ${prefix}AbsentBody<S, E> = ${absentBodyRule('S', 'E', false)};`,
200
+ `type ${prefix}AbsentBodyByHandler<S, E> = ${absentBodyRule('S', 'E', true)};`,
201
+ ],
202
+ };
203
+ }
204
+ /**
205
+ * The probe's GraphQL leaf walk (carrick#4403), over the SDL types reachable
206
+ * from the root field (`graphqlReachableFields`, which reads the table only
207
+ * through `graphqlFieldLeaf`). `GqlLeafSent<C, F>` is the type the server
208
+ * sends for a value `C` declared as `F`:
209
+ *
210
+ * - `any` and `unknown` stay what they are, so a top type is never laundered
211
+ * into a scalar; non-null is read through; `null` and `undefined` stay;
212
+ * - a list maps its elements; a non-array under a list keeps the JSON form;
213
+ * - a built-in scalar is the type it sends (`GRAPHQL_SCALAR_SENT`); any
214
+ * other scalar, an enum and a field the table does not name are JSON;
215
+ * - an object type the table holds maps each field through its own leaf;
216
+ * a type reference it does not hold (an undeclared scalar) is JSON.
217
+ *
218
+ * Every test on `F` is wrapped (`[F] extends [...]`) so a missing leaf never
219
+ * distributes to `never`. Needs `JsonWire`, `GqlDepth` and the comparand's
220
+ * helpers declared before it.
221
+ */
222
+ export function graphqlScalarDeclarations(reachable, rootLeaf) {
223
+ const sent = Object.entries(GRAPHQL_SCALAR_SENT)
224
+ .map(([name, type]) => `${name}: ${type}`)
225
+ .join('; ');
226
+ return [
227
+ `type GqlScalarSent = { ${sent} };`,
228
+ `type GqlTypes = ${JSON.stringify(reachable)};`,
229
+ `type GqlRootLeaf = ${JSON.stringify(rootLeaf)};`,
230
+ `type GqlTypeOf<F> = [F] extends [{ non_null: infer I }] ? GqlTypeOf<I> : [F] extends [{ type: infer T }] ? T : never;`,
231
+ `type GqlFieldOf<T, K> = [T] extends [never] ? unknown : [T] extends [keyof GqlTypes] ? ([K] extends [keyof GqlTypes[T]] ? GqlTypes[T][K] : unknown) : unknown;`,
232
+ `type GqlLeafSent<C, F, D extends number = 15> = [D] extends [never] ? JsonWire<C> : [unknown] extends [C] ? C : [F] extends [{ non_null: infer I }] ? GqlLeafSent<C, I, D> : C extends null | undefined ? C : [F] extends [{ list: infer I }] ? (C extends readonly unknown[] ? { [K in keyof C]: GqlLeafSent<C[K], I, GqlDepth[D]> } : JsonWire<C>) : [F] extends [{ scalar: infer N }] ? (N extends keyof GqlScalarSent ? GqlScalarSent[N] : JsonWire<C>) : [F] extends [{ type: infer T }] ? ([T] extends [keyof GqlTypes] ? (C extends readonly unknown[] ? JsonWire<C> : C extends (...args: any[]) => any ? C : C extends object ? { [K in keyof C]: GqlLeafSent<C[K], GqlFieldOf<T, K>, GqlDepth[D]> } : JsonWire<C>) : JsonWire<C>) : JsonWire<C>;`,
233
+ ];
234
+ }
133
235
  export function decisiveAssignmentLine(plan) {
134
236
  return plan.wireAssignmentLine ?? plan.assignmentLine;
135
237
  }
@@ -149,7 +251,7 @@ export function decisiveAssignmentLine(plan) {
149
251
  * capture record marks a handler that works when no body is sent
150
252
  * (carrick#2814).
151
253
  */
152
- export function buildProbe(spec, packageOf, unwidenedAliasFor, expectedToleratesAbsence) {
254
+ export function buildProbe(spec, packageOf, unwidenedAliasFor, expectedToleratesAbsence, graphqlTypesOf) {
153
255
  const id = pairId(spec);
154
256
  const direction = directionFor(spec.protocol, spec.type_kind);
155
257
  const sentEndpoint = direction.sent === 'producer' ? spec.producer : spec.consumer;
@@ -181,7 +283,7 @@ export function buildProbe(spec, packageOf, unwidenedAliasFor, expectedTolerates
181
283
  // contract, so no counterparty shape can be judged against it.
182
284
  // `any` is excluded first: `[any] extends [void]` holds, and an `any` side
183
285
  // must keep its own top-type reason, never read as "reads no body".
184
- push(`type IsVoid<T> = 0 extends 1 & T ? false : [T] extends [never] ? false : [T] extends [void] ? true : false;`);
286
+ push(voidReceiverDeclaration(''));
185
287
  gateLines.set(push(`type _G_sent_void = Assert<Not<IsVoid<Sent>>>;`), 'sent:void');
186
288
  gateLines.set(push(`type _G_expected_void = Assert<Not<IsVoid<Expected>>>;`), 'expected:void');
187
289
  // carrick#1162: a form-encoded request body (the platform `FormData` or
@@ -243,16 +345,21 @@ export function buildProbe(spec, packageOf, unwidenedAliasFor, expectedTolerates
243
345
  spec.protocol === 'socket' ||
244
346
  spec.protocol === 'pubsub';
245
347
  const toleratesAbsence = expectedToleratesAbsence?.(expectedEndpoint) === true;
246
- const sentBodyType = (sent) => {
247
- const dropped = `Exclude<${sent}, undefined | void>`;
248
- const byHandler = toleratesAbsence ? dropped : sent;
249
- return `[Extract<${sent}, undefined | void>] extends [never] ? ${sent} : [{}] extends [Expected] ? ([Extract<Expected, undefined | void>] extends [never] ? ${byHandler} : ${dropped}) : ${sent}`;
250
- };
348
+ const sentBodyType = (sent) => absentBodyRule(sent, 'Expected', toleratesAbsence);
251
349
  if (absentBodyAllowed)
252
350
  push(`type SentBody = ${sentBodyType('Sent')};`);
253
351
  const sentBody = absentBodyAllowed ? 'SentBody' : 'Sent';
254
352
  push(`declare const sent: ${sentBody};`);
353
+ const graphqlTypes = graphqlTypesOf?.(spec.producer.service_name);
354
+ const graphqlFacts = graphqlTypes !== undefined && spec.graphql_root !== undefined
355
+ ? { graphql: { types: graphqlTypes, root: spec.graphql_root } }
356
+ : {};
357
+ const wire = wireFormFor(spec.protocol, spec.type_kind, direction.sent, {
358
+ procedure: spec.procedure,
359
+ ...graphqlFacts,
360
+ });
255
361
  let assignmentLine;
362
+ let wireAssignmentLine;
256
363
  if (spec.protocol === 'graphql') {
257
364
  // GraphQL selection-set semantics (v1 `unwrapGraphqlPayload` parity): the
258
365
  // producer side (always `sent` for graphql — see the direction table) is
@@ -318,6 +425,39 @@ export function buildProbe(spec, packageOf, unwidenedAliasFor, expectedTolerates
318
425
  gateLines.set(push(`type _G_comparand_never = Assert<Not<IsNever<GqlComparand>>>;`), 'sent:never');
319
426
  push(`declare const sentComparand: GqlComparand;`);
320
427
  assignmentLine = push(`const expected: GqlExpected = sentComparand;`);
428
+ // The wire line over the comparand (carrick#4275): JSON applies after the
429
+ // envelope unwrap, so the unwrap reads the declared shape and never meets
430
+ // the transform. It mirrors `WireSent` below and keeps the comparand
431
+ // whenever that already assigns. The const is `sentWire`, the name the
432
+ // field report reads (`comparedTypes`).
433
+ if (wire === 'json') {
434
+ for (const line of jsonWireDeclarations(''))
435
+ push(line);
436
+ push(`type GqlWire = ${jsonWireRule('GqlComparand', 'GqlExpected', '')};`);
437
+ push(`declare const sentWire: GqlWire;`);
438
+ wireAssignmentLine = push(`const expectedWire: GqlExpected = sentWire;`);
439
+ }
440
+ else if (wire === 'graphql_scalars') {
441
+ // carrick#4403: each leaf in the type its scalar sends, read from the
442
+ // SDL from the root field down. The walk follows the producer's own
443
+ // type, so it ends where that type ends; the depth bound backs it up.
444
+ // A field the SDL does not name, a custom scalar and an enum keep the
445
+ // JSON form; a leaf keeps the producer's own null and undefined.
446
+ const { graphql } = graphqlFacts;
447
+ const rootLeaf = graphqlRootLeaf(graphql.types, graphql.root);
448
+ for (const line of jsonWireDeclarations(''))
449
+ push(line);
450
+ for (const line of graphqlScalarDeclarations(graphqlReachableFields(graphql.types, rootLeaf), rootLeaf)) {
451
+ push(line);
452
+ }
453
+ // After a single-payload unwrap the comparand is the payload: its leaf
454
+ // is the envelope field's, when the SDL declares the envelope. When it
455
+ // does not, the root leaf already describes the payload.
456
+ push(`type GqlComparandLeaf = [Sent] extends [GqlExpected] ? GqlRootLeaf : ([GqlPayloadOf<Sent>] extends [never] ? GqlRootLeaf : [GqlReadsOuter<Sent, Expected>] extends [true] ? GqlRootLeaf : ([unknown] extends [GqlFieldOf<GqlTypeOf<GqlRootLeaf>, GqlSingleKey<GqlPayloadKeys<Sent>>>] ? GqlRootLeaf : GqlFieldOf<GqlTypeOf<GqlRootLeaf>, GqlSingleKey<GqlPayloadKeys<Sent>>>));`);
457
+ push(`type GqlWire = [GqlComparand] extends [GqlExpected] ? GqlComparand : (JsonWireSame<GqlLeafSent<GqlComparand, GqlComparandLeaf>, GqlComparand> extends true ? GqlComparand : GqlLeafSent<GqlComparand, GqlComparandLeaf>);`);
458
+ push(`declare const sentWire: GqlWire;`);
459
+ wireAssignmentLine = push(`const expectedWire: GqlExpected = sentWire;`);
460
+ }
321
461
  }
322
462
  else {
323
463
  assignmentLine = push(`const expected: Expected = sent;`);
@@ -336,8 +476,7 @@ export function buildProbe(spec, packageOf, unwidenedAliasFor, expectedTolerates
336
476
  // so a pair that agrees as declared never instantiates the mapped type (no
337
477
  // cost, and no way for the transform to turn an agreeing pair into a
338
478
  // disagreeing one). tsc stays the judge of both forms.
339
- let wireAssignmentLine;
340
- if (sentInJsonWireForm(spec.protocol, spec.type_kind, direction.sent)) {
479
+ if (spec.protocol !== 'graphql' && wire === 'json') {
341
480
  // Keep the DECLARED type whenever serialising changes nothing observable,
342
481
  // so the compiler's headline still names the real surface alias (the probe
343
482
  // prints `Sent`, which the scrub rewrites) instead of expanding a mapped
@@ -345,10 +484,23 @@ export function buildProbe(spec, packageOf, unwidenedAliasFor, expectedTolerates
345
484
  // that name — and there the declared name no longer describes what travels.
346
485
  for (const line of jsonWireDeclarations(''))
347
486
  push(line);
348
- push(`type WireSent = [${sentBody}] extends [Expected] ? ${sentBody} : (JsonWireSame<JsonWire<${sentBody}>, ${sentBody}> extends true ? ${sentBody} : JsonWire<${sentBody}>);`);
487
+ push(`type WireSent = ${jsonWireRule(sentBody, 'Expected', '')};`);
349
488
  push(`declare const sentWire: WireSent;`);
350
489
  wireAssignmentLine = push(`const expectedWire: Expected = sentWire;`);
351
490
  }
491
+ // The wire form is unknown (carrick#4402): an RPC procedure, whose router's
492
+ // transformer decides what travels. The declared line stays decisive, and
493
+ // the gate fires where the two readings disagree: the declared form fails
494
+ // and the JSON form passes, so the verdict hangs on the transformer. Where
495
+ // both pass or both fail, the declared line decides alone. No `sentWire`
496
+ // const is declared, so the field report reads no wire form and the pair
497
+ // carries no wire note.
498
+ if (wire === 'unknown') {
499
+ for (const line of jsonWireDeclarations(''))
500
+ push(line);
501
+ push(`type WireDecides = [${sentBody}] extends [Expected] ? false : [JsonWire<${sentBody}>] extends [Expected] ? true : false;`);
502
+ gateLines.set(push(`type _G_sent_wire_form = Assert<Not<WireDecides>>;`), 'sent:wire_form');
503
+ }
352
504
  // The unwidened reading (carrick#1538). A handler that returns
353
505
  // `cond ? 'a' : 'b'` publishes `string`, because a literal widens where it
354
506
  // is inferred, and a consumer that declares `'a' | 'b'` then mismatches a
@@ -365,9 +517,10 @@ export function buildProbe(spec, packageOf, unwidenedAliasFor, expectedTolerates
365
517
  // assignment the second reading mirrors, here in the wire form. A GraphQL
366
518
  // pair compares an unwrapped comparand (above), which a plain assignment of
367
519
  // the reading would not mirror. Socket and pub/sub payloads are not read
368
- // again.
520
+ // again, and neither is a sending side whose wire form is unknown
521
+ // (carrick#4402): it is judged in JSON form, which could clear the pair.
369
522
  let unwidenedFromLine;
370
- const sentUnwidenedAlias = spec.protocol === 'http' ? unwidenedAliasFor?.(sentEndpoint) : undefined;
523
+ const sentUnwidenedAlias = spec.protocol === 'http' && wire === 'json' ? unwidenedAliasFor?.(sentEndpoint) : undefined;
371
524
  if (sentUnwidenedAlias !== undefined) {
372
525
  const local = UNWIDENED_LOCAL_NAME;
373
526
  unwidenedFromLine = push(`import type { ${sentUnwidenedAlias} as ${local} } from '${sentPkg}';`);
@@ -379,7 +532,7 @@ export function buildProbe(spec, packageOf, unwidenedAliasFor, expectedTolerates
379
532
  push(`type SentUnwidenedBody = ${sentBodyType(local)};`);
380
533
  unwidenedBody = 'SentUnwidenedBody';
381
534
  }
382
- push(`type WireSentUnwidened = [${unwidenedBody}] extends [Expected] ? ${unwidenedBody} : (JsonWireSame<JsonWire<${unwidenedBody}>, ${unwidenedBody}> extends true ? ${unwidenedBody} : JsonWire<${unwidenedBody}>);`);
535
+ push(`type WireSentUnwidened = ${jsonWireRule(unwidenedBody, 'Expected', '')};`);
383
536
  push(`declare const sentWireUnwidened: WireSentUnwidened;`);
384
537
  push(`const expectedWireUnwidened: Expected = sentWireUnwidened;`);
385
538
  }
@@ -372,7 +372,7 @@ export async function runCheck(opts, onProgress) {
372
372
  const unresolved = [];
373
373
  for (const spec of opts.pairs) {
374
374
  try {
375
- plans.push(buildProbe(spec, ws.packageOf, unwidenedAliasIn(aliasRecords), absenceToleratedIn(aliasRecords)));
375
+ plans.push(buildProbe(spec, ws.packageOf, unwidenedAliasIn(aliasRecords), absenceToleratedIn(aliasRecords), graphqlTypesIn(opts.stubs)));
376
376
  }
377
377
  catch {
378
378
  unresolved.push({
@@ -787,6 +787,18 @@ function dedupeDegraded(list) {
787
787
  seen.set(d.service_name, d);
788
788
  return [...seen.values()].sort((a, b) => a.service_name < b.service_name ? -1 : a.service_name > b.service_name ? 1 : 0);
789
789
  }
790
+ /**
791
+ * Each service's SDL output types (carrick#4403), as its stub input carries
792
+ * them. A service id named twice answers nothing: which stub the judge reads
793
+ * is not known.
794
+ */
795
+ function graphqlTypesIn(stubs) {
796
+ const byService = new Map();
797
+ for (const stub of stubs) {
798
+ byService.set(stub.service_name, byService.has(stub.service_name) ? undefined : stub.graphql_types);
799
+ }
800
+ return (serviceName) => byService.get(serviceName);
801
+ }
790
802
  /** Plan pairs without a workspace (for the isolation-unavailable early exit). */
791
803
  function planPairs(opts, packageOf) {
792
804
  const plans = [];