carrick 0.3.136 → 0.3.138

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.
@@ -470,11 +470,17 @@ export declare class TypeInferrer {
470
470
  * success body.
471
471
  */
472
472
  private statementEndsFunctionPath;
473
+ /**
474
+ * The handler returns a send the service's labels name (carrick#3053): a
475
+ * `new` construction or a static call whose declaration a verified label
476
+ * keys. Its result is transport whatever its type looks like, so the body
477
+ * is read from the send's argument.
478
+ */
479
+ private returnsLabelledSend;
473
480
  /**
474
481
  * True when `candidate` is a response send: a call or `new` whose result is
475
482
  * transport machinery (by the extraction config's verified rule or the
476
- * structural check), or whose callee this handler's own returns prove is a
477
- * serialiser (`calleesProvenSerialiser`, which holds on a bare checkout).
483
+ * structural check).
478
484
  */
479
485
  private isResponseSend;
480
486
  /**
@@ -1472,36 +1478,6 @@ export declare class TypeInferrer {
1472
1478
  * bare object literal does.
1473
1479
  */
1474
1480
  private responseReturnedExpressions;
1475
- /**
1476
- * The callees these returned expressions PROVE are response serialisers.
1477
- *
1478
- * A return type of `any` says the callee could not be resolved, not that it
1479
- * was a serialiser — the reason the unresolvable-callee case is otherwise
1480
- * restricted to arguments the source annotates. But a handler that writes
1481
- *
1482
- * return f(problem, { status: 401 });
1483
- * return f(payload);
1484
- *
1485
- * has stated what `f` is in its own source: a call that takes a body and,
1486
- * beside it, an HTTP status is a response serialiser, and nothing else is
1487
- * written that way. That is evidence the compiler does not need to resolve
1488
- * anything to see, so it survives the bare checkout CI scans, and it makes
1489
- * the second call's unannotated argument a payload rather than a guess.
1490
- *
1491
- * Three deliberate limits, each a negative test:
1492
- * - only RETURNED expressions count. A handler may well call a logger with
1493
- * `{ status: 500 }`; what it returns is what it serialises.
1494
- * - the status-stating argument must sit at index >= 1. A status in FIRST
1495
- * position is a field of the body (`{ status: 503, note }`), and reading
1496
- * it as evidence would promote every callee that takes a status field.
1497
- * - the evidence is per HANDLER, never cached across files. It says what
1498
- * this handler does, and that is all it is used for.
1499
- *
1500
- * Callees are keyed by resolved symbol where one exists — an import alias
1501
- * resolves locally even when its module does not — and by callee text
1502
- * otherwise.
1503
- */
1504
- private calleesProvenSerialiser;
1505
1481
  /**
1506
1482
  * Stable identity for a call's callee within one file: its resolved symbol
1507
1483
  * when the compiler has one, else the callee's source text.
@@ -1521,9 +1497,7 @@ export declare class TypeInferrer {
1521
1497
  *
1522
1498
  * `statedOnly` narrows what counts as a payload to an argument the source
1523
1499
  * annotates; see `recoverPayloadFromReturnStatements`. It is lifted for a
1524
- * callee the handler's own returned calls PROVE is a serialiser
1525
- * (`calleesProvenSerialiser`): there the source has stated what the callee
1526
- * is, so its argument is the payload even unannotated.
1500
+ * callee a caller has its own evidence for (`serialisers`).
1527
1501
  */
1528
1502
  private responseHelperPayloadNode;
1529
1503
  /**
@@ -2298,8 +2272,16 @@ export declare class TypeInferrer {
2298
2272
  * (nothing, `void`, or an `unknown` the inferrer did not decide), the reply
2299
2273
  * its handler's parameter states, cut to its success variants. A typed
2300
2274
  * reading, or a decided abstain, stands as it is.
2275
+ *
2276
+ * carrick#3054: a route whose receive op carries a `returns` label replies
2277
+ * with what its handler returns. A labelled send the handler's parameters
2278
+ * state wins over the return. The returned reply replaces a typed reading
2279
+ * only where it prints differently (the label names a part of the return,
2280
+ * or a nothing part is dropped); where it prints the same, today's reading
2281
+ * stands with everything it carries.
2301
2282
  */
2302
2283
  private withStatedReply;
2284
+ private publishStatedReply;
2303
2285
  /** Nothing read: `void`, or an `unknown` with no decided reason at its root. */
2304
2286
  private isEmptyResponseReading;
2305
2287
  /**
@@ -474,7 +474,7 @@ export class TypeInferrer {
474
474
  */
475
475
  infer(requests, extractionConfig, onRequestDone, modelSymbols, labels, onUnwidenedStep) {
476
476
  this.modelSymbols = new Map((modelSymbols ?? []).map((symbol) => [symbol.alias, symbol]));
477
- this.statedParams = this.statedParamsFor(labels ?? { sends: new Map(), bodies: new Set() });
477
+ this.statedParams = this.statedParamsFor(labels ?? { sends: new Map(), sets: new Map(), returns: new Map(), bodies: new Set() });
478
478
  const inferredTypes = [];
479
479
  const errors = [];
480
480
  /** Response inferences the unwidened reading re-reads (carrick#1516). */
@@ -614,7 +614,7 @@ export class TypeInferrer {
614
614
  * members the batch's verified server-framework labels name. Empty when
615
615
  * the batch carries no labels, and then it reads nothing.
616
616
  */
617
- statedParams = this.statedParamsFor({ sends: new Map(), bodies: new Set() });
617
+ statedParams = this.statedParamsFor({ sends: new Map(), sets: new Map(), returns: new Map(), bodies: new Set() });
618
618
  /**
619
619
  * carrick#2111: where the model named a type for the response this request
620
620
  * reads, record on `inferred` how that type relates to the compiler's type
@@ -1151,7 +1151,8 @@ export class TypeInferrer {
1151
1151
  // annotates (`satisfies` / `as` / `<T>`): the developer stated the
1152
1152
  // contract, so it is a claim rather than a guess.
1153
1153
  const machinery = unwrapResult.verifiedMachinery === true ||
1154
- this.typeIsOrContainsResponseMachinery(awaitedType);
1154
+ this.typeIsOrContainsResponseMachinery(awaitedType) ||
1155
+ this.returnsLabelledSend(func);
1155
1156
  const unresolvable = awaitedType.isAny() || awaitedType.isUnknown();
1156
1157
  if (machinery || unresolvable) {
1157
1158
  const recovered = this.recoverPayloadFromReturnStatements(func, !machinery, this.wireFormatFor(request));
@@ -1898,8 +1899,20 @@ export class TypeInferrer {
1898
1899
  (func.getStartLineNumber() <= request.line_number &&
1899
1900
  request.line_number <= func.getEndLineNumber());
1900
1901
  const returnedBranches = this.responseReturnedExpressions(func).flatMap((expression) => this.expandResponseBranches(expression, 0));
1901
- const serialisers = this.calleesProvenSerialiser(returnedBranches);
1902
- const isSend = (candidate) => this.isResponseSend(candidate, extractionConfig, serialisers);
1902
+ // carrick#2472 C2: the service's labels answer first. A labelled send is
1903
+ // a send, an unlabelled member of a labelled reply object is a setter;
1904
+ // where no label speaks, the structural reading decides.
1905
+ const labelledSend = (candidate) => this.statedParams.sendAt(this.peelTransparentExpression(candidate));
1906
+ const isLabelledSend = (candidate) => {
1907
+ const labelled = labelledSend(candidate);
1908
+ return labelled !== undefined && labelled !== 'setter';
1909
+ };
1910
+ const isSend = (candidate) => {
1911
+ const labelled = labelledSend(candidate);
1912
+ if (labelled !== undefined)
1913
+ return labelled !== 'setter';
1914
+ return this.isResponseSend(candidate, extractionConfig);
1915
+ };
1903
1916
  // carrick#2427: a handler that sends through a parameter returns nothing,
1904
1917
  // its sends are statements, and the located one can be an error send.
1905
1918
  // Statement sends find and drop that branch. A call whose result is
@@ -1929,9 +1942,12 @@ export class TypeInferrer {
1929
1942
  branches = [
1930
1943
  ...returnedBranches,
1931
1944
  ...statementSends
1945
+ // A labelled send is a body wherever it sits (carrick#2472 C2).
1932
1946
  // FROZEN (old path, 2026-10-21): the `statementEndsFunctionPath` test
1933
1947
  // here; see that method.
1934
- .filter((s) => s.send === locatedBranch || this.statementEndsFunctionPath(s.statement, func))
1948
+ .filter((s) => s.send === locatedBranch ||
1949
+ isLabelledSend(s.send) ||
1950
+ this.statementEndsFunctionPath(s.statement, func))
1935
1951
  .map((s) => s.send),
1936
1952
  ];
1937
1953
  }
@@ -2060,19 +2076,31 @@ export class TypeInferrer {
2060
2076
  // wrong or missing types go in labelled sends (carrick#2472 C4). Delete when
2061
2077
  // a delete-and-replay on the four repos moves no row wrongly, after
2062
2078
  // carrick-cloud#2379 and carrick#2445 (carrick#2472, C6).
2079
+ /**
2080
+ * The handler returns a send the service's labels name (carrick#3053): a
2081
+ * `new` construction or a static call whose declaration a verified label
2082
+ * keys. Its result is transport whatever its type looks like, so the body
2083
+ * is read from the send's argument.
2084
+ */
2085
+ returnsLabelledSend(func) {
2086
+ if (!this.statedParams.readsReplies)
2087
+ return false;
2088
+ return this.responseReturnedExpressions(func)
2089
+ .flatMap((expression) => this.expandResponseBranches(expression, 0))
2090
+ .some((branch) => {
2091
+ const labelled = this.statedParams.sendAt(this.peelTransparentExpression(branch));
2092
+ return labelled !== undefined && labelled !== 'setter';
2093
+ });
2094
+ }
2063
2095
  /**
2064
2096
  * True when `candidate` is a response send: a call or `new` whose result is
2065
2097
  * transport machinery (by the extraction config's verified rule or the
2066
- * structural check), or whose callee this handler's own returns prove is a
2067
- * serialiser (`calleesProvenSerialiser`, which holds on a bare checkout).
2098
+ * structural check).
2068
2099
  */
2069
- isResponseSend(candidate, extractionConfig, serialisers) {
2100
+ isResponseSend(candidate, extractionConfig) {
2070
2101
  const call = this.peelTransparentExpression(candidate);
2071
2102
  if (!Node.isCallExpression(call) && !Node.isNewExpression(call))
2072
2103
  return false;
2073
- const identity = this.calleeIdentity(call);
2074
- if (identity !== undefined && serialisers.has(identity))
2075
- return true;
2076
2104
  const result = this.unwrapPromiseType(call.getType());
2077
2105
  if (result.isAny() || result.isUnknown())
2078
2106
  return false;
@@ -5455,11 +5483,8 @@ export class TypeInferrer {
5455
5483
  const candidates = [];
5456
5484
  const returned = expressions.flatMap((expression) => this.expandResponseBranches(expression, 0));
5457
5485
  // `alsoSerialisers` are callees a caller has its own evidence for
5458
- // (`calleeIdentity` keys), beside the ones these expressions prove.
5459
- const serialisers = this.calleesProvenSerialiser(returned);
5460
- for (const identity of alsoSerialisers ?? []) {
5461
- serialisers.add(identity);
5462
- }
5486
+ // (`calleeIdentity` keys).
5487
+ const serialisers = new Set(alsoSerialisers ?? []);
5463
5488
  for (const expression of returned) {
5464
5489
  const payloadNode = this.responseHelperPayloadNode(expression, 0, statedOnly, serialisers);
5465
5490
  if (!payloadNode)
@@ -6168,59 +6193,6 @@ export class TypeInferrer {
6168
6193
  }
6169
6194
  return flattened;
6170
6195
  }
6171
- // FROZEN (old path, 2026-10-21): this method only. Deletions and safety fixes
6172
- // only. Fixes for wrong or missing types go in labelled sends (carrick#2472
6173
- // C4). Delete when a delete-and-replay on the four repos moves no row
6174
- // wrongly, after carrick-cloud#2379 and carrick#2445 (carrick#2472, C6).
6175
- /**
6176
- * The callees these returned expressions PROVE are response serialisers.
6177
- *
6178
- * A return type of `any` says the callee could not be resolved, not that it
6179
- * was a serialiser — the reason the unresolvable-callee case is otherwise
6180
- * restricted to arguments the source annotates. But a handler that writes
6181
- *
6182
- * return f(problem, { status: 401 });
6183
- * return f(payload);
6184
- *
6185
- * has stated what `f` is in its own source: a call that takes a body and,
6186
- * beside it, an HTTP status is a response serialiser, and nothing else is
6187
- * written that way. That is evidence the compiler does not need to resolve
6188
- * anything to see, so it survives the bare checkout CI scans, and it makes
6189
- * the second call's unannotated argument a payload rather than a guess.
6190
- *
6191
- * Three deliberate limits, each a negative test:
6192
- * - only RETURNED expressions count. A handler may well call a logger with
6193
- * `{ status: 500 }`; what it returns is what it serialises.
6194
- * - the status-stating argument must sit at index >= 1. A status in FIRST
6195
- * position is a field of the body (`{ status: 503, note }`), and reading
6196
- * it as evidence would promote every callee that takes a status field.
6197
- * - the evidence is per HANDLER, never cached across files. It says what
6198
- * this handler does, and that is all it is used for.
6199
- *
6200
- * Callees are keyed by resolved symbol where one exists — an import alias
6201
- * resolves locally even when its module does not — and by callee text
6202
- * otherwise.
6203
- */
6204
- calleesProvenSerialiser(returned) {
6205
- const proven = new Set();
6206
- for (const expression of returned) {
6207
- const call = this.peelTransparentExpression(expression);
6208
- if (!Node.isCallExpression(call))
6209
- continue;
6210
- const args = call.getArguments().map((a) => this.peelTransparentExpression(a));
6211
- if (args.length < 2)
6212
- continue;
6213
- const statesStatus = args
6214
- .slice(1)
6215
- .some((arg) => Array.isArray(this.statedStatusCodes(arg)));
6216
- if (!statesStatus)
6217
- continue;
6218
- const key = this.calleeIdentity(call);
6219
- if (key)
6220
- proven.add(key);
6221
- }
6222
- return proven;
6223
- }
6224
6196
  /**
6225
6197
  * Stable identity for a call's callee within one file: its resolved symbol
6226
6198
  * when the compiler has one, else the callee's source text.
@@ -6250,9 +6222,7 @@ export class TypeInferrer {
6250
6222
  *
6251
6223
  * `statedOnly` narrows what counts as a payload to an argument the source
6252
6224
  * annotates; see `recoverPayloadFromReturnStatements`. It is lifted for a
6253
- * callee the handler's own returned calls PROVE is a serialiser
6254
- * (`calleesProvenSerialiser`): there the source has stated what the callee
6255
- * is, so its argument is the payload even unannotated.
6225
+ * callee a caller has its own evidence for (`serialisers`).
6256
6226
  */
6257
6227
  responseHelperPayloadNode(expression, depth, statedOnly, serialisers) {
6258
6228
  if (depth > RESPONSE_HELPER_MAX_DEPTH)
@@ -6272,6 +6242,16 @@ export class TypeInferrer {
6272
6242
  const status = this.responseSiteStatus(call);
6273
6243
  if (status === 'error' || status === 'redirect')
6274
6244
  return undefined;
6245
+ // carrick#3053: a send the service's labels name carries its body in the
6246
+ // slot the label states, read as a labelled call send reads it.
6247
+ const labelled = this.statedParams.sendAt(call);
6248
+ if (labelled !== undefined && labelled !== 'setter') {
6249
+ const body = args[labelled.arg];
6250
+ if (!body || Node.isSpreadElement(body))
6251
+ return undefined;
6252
+ const slotted = this.unwrapJsonStringifyArg(body);
6253
+ return this.nodeCarriesPayloadContract(slotted, false) ? slotted : undefined;
6254
+ }
6275
6255
  const identity = this.calleeIdentity(call);
6276
6256
  const proven = identity !== undefined && serialisers.has(identity);
6277
6257
  const effectiveStatedOnly = statedOnly && !proven;
@@ -8498,26 +8478,42 @@ export class TypeInferrer {
8498
8478
  if (sourceFile.isDeclarationFile())
8499
8479
  return false;
8500
8480
  return !isExternalOrigin(this.project.getProgram().compilerObject, sourceFile.compilerNode, this.repoRoot, externalImportsOf(this.project));
8501
- }, (call) => this.chainStatus(call));
8481
+ }, (call) => this.chainStatus(call), (value) => this.statusOfValue(value), (value) => this.unwrapJsonStringifyArg(this.unwrapExpressionNode(value)));
8502
8482
  }
8503
8483
  /**
8504
8484
  * carrick#2674: where today's reading of a route's response is empty
8505
8485
  * (nothing, `void`, or an `unknown` the inferrer did not decide), the reply
8506
8486
  * its handler's parameter states, cut to its success variants. A typed
8507
8487
  * reading, or a decided abstain, stands as it is.
8488
+ *
8489
+ * carrick#3054: a route whose receive op carries a `returns` label replies
8490
+ * with what its handler returns. A labelled send the handler's parameters
8491
+ * state wins over the return. The returned reply replaces a typed reading
8492
+ * only where it prints differently (the label names a part of the return,
8493
+ * or a nothing part is dropped); where it prints the same, today's reading
8494
+ * stands with everything it carries.
8508
8495
  */
8509
8496
  withStatedReply(sourceFile, request, today) {
8510
- if (!this.statedParams.readsReplies)
8497
+ const reads = this.statedParams.readsReplies;
8498
+ if (!reads && !this.statedParams.readsReturns)
8511
8499
  return today;
8512
- if (today && !this.isEmptyResponseReading(today))
8500
+ const empty = !today || this.isEmptyResponseReading(today);
8501
+ if (reads && !empty && !this.statedParams.readsReturns)
8513
8502
  return today;
8514
- const handler = this.registrationAtLine(sourceFile, request.line_number)?.handler ??
8515
- this.exportedFunctionOpeningOn(sourceFile, request.line_number);
8503
+ const at = this.registrationAtLine(sourceFile, request.line_number);
8504
+ const handler = at?.handler ?? this.exportedFunctionOpeningOn(sourceFile, request.line_number);
8516
8505
  if (!handler)
8517
8506
  return today;
8518
- const stated = this.statedParams.reply(handler);
8519
- if (!stated)
8507
+ const sent = reads ? this.statedParams.reply(handler) : undefined;
8508
+ if (sent) {
8509
+ return empty ? this.publishStatedReply(request, handler, sent, today, "its handler's reply parameter states the body") : today;
8510
+ }
8511
+ const returned = at ? this.statedParams.returned(at.registration, handler) : undefined;
8512
+ if (!returned)
8520
8513
  return today;
8514
+ return this.publishStatedReply(request, handler, returned, today, 'its handler returns the reply');
8515
+ }
8516
+ publishStatedReply(request, handler, stated, today, why) {
8521
8517
  const texts = [];
8522
8518
  for (const variant of stated.variants) {
8523
8519
  const text = this.structuralTextFromType(variant, stated.at);
@@ -8528,8 +8524,11 @@ export class TypeInferrer {
8528
8524
  return today;
8529
8525
  texts.push(text);
8530
8526
  }
8531
- this.log(`Route at ${request.file_path}:${request.line_number}: its handler's reply parameter states the body`);
8532
- return this.createInferredType(request, texts.length === 1 ? texts[0] : texts.map((text) => `(${text})`).join(' | '), true, this.getNodeLocation(handler));
8527
+ const printed = texts.length === 1 ? texts[0] : texts.map((text) => `(${text})`).join(' | ');
8528
+ if (today && today.type_string === printed)
8529
+ return today;
8530
+ this.log(`Route at ${request.file_path}:${request.line_number}: ${why}`);
8531
+ return this.createInferredType(request, printed, true, this.getNodeLocation(handler));
8533
8532
  }
8534
8533
  /** Nothing read: `void`, or an `unknown` with no decided reason at its root. */
8535
8534
  isEmptyResponseReading(inferred) {
@@ -443,10 +443,37 @@ export interface VerifyClientSemanticsRequest extends BaseRequest {
443
443
  * Where one part of a library call sits: argument `arg` (0-based), or, with
444
444
  * `key`, the property `key` of the object passed there (carrick#1616).
445
445
  */
446
- export interface ClaimSlot {
446
+ export interface SlotPosition {
447
447
  arg: number;
448
448
  key?: string;
449
449
  }
450
+ /** A slot of a call (carrick#1616), with the reads amendment 7 adds. */
451
+ export interface ClaimSlot extends SlotPosition {
452
+ /** A member path walked from the value there; `[]` steps into an array element (amendment 7 of carrick#2434). */
453
+ at?: string[];
454
+ /** A rest slot: every element is read (amendment 7). */
455
+ each?: boolean;
456
+ }
457
+ /** A slot that holds a name: also read as a GraphQL document, or as the name of a function or class (amendment 7). */
458
+ export interface NameSlot extends ClaimSlot {
459
+ document?: 'graphql';
460
+ ref?: 'function' | 'class';
461
+ }
462
+ /** How a service writes an op (amendment 7); absent is `call`. */
463
+ export type ClaimForm = 'call' | 'new' | 'set' | 'override' | 'decorate';
464
+ /** The protocol an op speaks (amendment 7); absent is the role's own. */
465
+ export type ClaimProtocol = 'http' | 'graphql' | 'rpc' | 'socket' | 'message';
466
+ /** Two or three slots joined into one name (amendment 7). */
467
+ export interface NameParts {
468
+ parts: ClaimSlot[];
469
+ join?: string;
470
+ }
471
+ /** A name the library fixes (amendment 7). */
472
+ export interface NameLiteral {
473
+ literal: string;
474
+ }
475
+ /** Where an op's name comes from. */
476
+ export type OpNameSource = BoundName | NameParts | NameLiteral | NameSlot;
450
477
  /**
451
478
  * A name the call does not carry: the one the maker's `name` slot bound to
452
479
  * the instance (`maker`), the one the scope member bound (`scope`), or the
@@ -454,7 +481,13 @@ export interface ClaimSlot {
454
481
  * R6a).
455
482
  */
456
483
  export interface BoundName {
457
- bound: 'maker' | 'scope' | 'key';
484
+ bound: 'maker' | 'scope' | 'key' | 'path' | 'export' | 'subscribed';
485
+ /** `path`: the property names walked on the receiver are joined by this (amendment 7). */
486
+ join?: string;
487
+ /** `subscribed`: the handler parameter that is handed the name. */
488
+ param?: number;
489
+ /** `subscribed`: the member path to the name inside that parameter. */
490
+ at?: string[];
458
491
  }
459
492
  /**
460
493
  * Where a router member takes its procedures (#2474 R6a, contract amendment
@@ -462,7 +495,7 @@ export interface BoundName {
462
495
  * whose property values are procedures or nested collections, each named by
463
496
  * its key; nested keys join with `join`.
464
497
  */
465
- export interface Collects extends ClaimSlot {
498
+ export interface Collects extends SlotPosition {
466
499
  join: string;
467
500
  }
468
501
  /**
@@ -471,7 +504,7 @@ export interface Collects extends ClaimSlot {
471
504
  * made the receiver (a mutation object whose `mutate` runs the function its
472
505
  * maker was given).
473
506
  */
474
- export interface RunsSlot extends ClaimSlot {
507
+ export interface RunsSlot extends SlotPosition {
475
508
  bound?: 'maker';
476
509
  }
477
510
  /**
@@ -484,6 +517,8 @@ export interface Yields {
484
517
  param: number;
485
518
  export: string;
486
519
  side: string;
520
+ /** The package that declares `export`, when it is not the claim's own (amendment 7). */
521
+ package?: string;
487
522
  }
488
523
  /**
489
524
  * Where a route handler's request holds its path and method (#2474 R0): the
@@ -537,7 +572,7 @@ export type LibraryClaim = {
537
572
  /** A prefix every name the instance sends gets. */
538
573
  prefix?: ClaimSlot;
539
574
  /** A definition's id or a queue's name: bound to every op that names `{ bound: 'maker' }`. */
540
- name?: ClaimSlot;
575
+ name?: NameSlot;
541
576
  handler?: ClaimSlot;
542
577
  /** The function or client the maker runs (label v2). */
543
578
  runs?: ClaimSlot;
@@ -550,8 +585,10 @@ export type LibraryClaim = {
550
585
  /** A member that returns a receiver bound to a name (a channel, room or queue). */
551
586
  kind: 'scope';
552
587
  member: string;
588
+ /** Amendment 7: absent is `call`; `decorate` is a class decorator whose name prefixes its methods' ops. */
589
+ form?: 'call' | 'decorate';
553
590
  /** Exactly one of `name` and `collects` (#2474 R6a). */
554
- name?: ClaimSlot;
591
+ name?: NameSlot;
555
592
  path?: string[];
556
593
  on?: ClaimOn;
557
594
  of?: string;
@@ -579,7 +616,19 @@ export type LibraryClaim = {
579
616
  on?: ClaimOn;
580
617
  /** The one receiver the op acts on, by its receiver id. */
581
618
  of?: string;
582
- name?: ClaimSlot | BoundName;
619
+ name?: OpNameSource;
620
+ /** Amendment 7: how the service writes the op; absent is `call`. */
621
+ form?: ClaimForm;
622
+ /** Amendment 7: the protocol the op speaks; absent is the role's own. */
623
+ protocol?: ClaimProtocol;
624
+ /** Amendment 7: the op applies only where this slot holds this literal. */
625
+ when?: SlotPosition & {
626
+ literal: string;
627
+ };
628
+ /** Amendment 7: the response a route's receive op sends; `{}` is a response of no stated shape. */
629
+ returns?: {
630
+ result?: ResultShape;
631
+ };
583
632
  payload?: ClaimSlot;
584
633
  handler?: ClaimSlot;
585
634
  ack?: ClaimSlot;
@@ -681,6 +730,8 @@ export interface ListLibrarySurfaceRequest extends BaseRequest {
681
730
  exports?: Record<string, string[]>;
682
731
  /** List each member's handler-parameter members (`handlers`, carrick#2674 S3); default false (carrick#2966). */
683
732
  handlers?: boolean;
733
+ /** List `types[]` widened, with `settable` (carrick#3050); default false. */
734
+ types?: boolean;
684
735
  /** The most handler-parameter members the whole listing lists; default 500000 (carrick#3016). */
685
736
  max_handler_members?: number;
686
737
  /** List each signature's `result_candidates` (carrick#2817); default false (carrick#2966). */
@@ -1089,6 +1140,13 @@ export interface SurfaceMember {
1089
1140
  * of the hash.
1090
1141
  */
1091
1142
  scope_receiver?: SurfaceReceiver;
1143
+ /**
1144
+ * The event names Node's runtime gives every emitter (`error`,
1145
+ * `newListener`, `removeListener`) that no signature of this member spells,
1146
+ * on a member of the runtime's own `EventEmitter` that takes an event name
1147
+ * (carrick#3032). Runtime-module surfaces only, and left out of the hash.
1148
+ */
1149
+ runtime_events?: string[];
1092
1150
  signatures: SurfaceSignature[];
1093
1151
  }
1094
1152
  /**
@@ -1101,13 +1159,39 @@ export interface SurfaceHandler {
1101
1159
  key?: string;
1102
1160
  params: SurfaceHandlerParam[];
1103
1161
  }
1104
- /** One parameter of a handler, with the members its type declares (none: not listed). */
1162
+ /**
1163
+ * One parameter of a handler whose type declares members (none: not
1164
+ * listed), by the id of its entry in the surface's `handler_types`
1165
+ * (carrick#2977).
1166
+ */
1105
1167
  export interface SurfaceHandlerParam {
1106
1168
  param: number;
1107
1169
  name: string;
1170
+ type_id: number;
1171
+ }
1172
+ /**
1173
+ * One handler-parameter type of a surface (carrick#2977): every parameter
1174
+ * whose printed type, members and export name are equal refers to one entry.
1175
+ */
1176
+ export interface SurfaceHandlerType {
1177
+ /** From 1, in first-reference order within the surface. */
1178
+ id: number;
1108
1179
  /** The parameter's type as the declarations print it, truncated. */
1109
1180
  type: string;
1110
1181
  members: SurfaceHandlerMember[];
1182
+ /** Members the cap of 500 per type dropped (carrick#2966). */
1183
+ dropped: number;
1184
+ /**
1185
+ * The specifier's type-only export that is this type (the same symbol),
1186
+ * declared in the home of the receiver that hands it, every type
1187
+ * parameter defaulted: what a `yields` names, and what `types` lists.
1188
+ */
1189
+ export?: string;
1190
+ }
1191
+ /** A type export some `handler_types` entry names, listed as the one receiver `type` (carrick#2977). */
1192
+ export interface SurfaceTypeExport {
1193
+ export: string;
1194
+ receivers: SurfaceReceiver[];
1111
1195
  }
1112
1196
  /** A member of a handler's parameter, by path from the parameter, to two levels. */
1113
1197
  export interface SurfaceHandlerMember {
@@ -1123,6 +1207,19 @@ export interface SurfaceReceiver {
1123
1207
  call?: SurfaceSignature[];
1124
1208
  construct?: SurfaceSignature[];
1125
1209
  members: SurfaceMember[];
1210
+ /**
1211
+ * With `types: true`, on a `types[]` receiver only: the properties a
1212
+ * service may assign (not a method, not readonly, an open declared type),
1213
+ * depth 1, sorted by name (carrick#3050). Absent when none.
1214
+ */
1215
+ settable?: SurfaceSettable[];
1216
+ }
1217
+ /** A property of a type receiver that `settable` answers `ok` for. */
1218
+ export interface SurfaceSettable {
1219
+ name: string;
1220
+ type: string;
1221
+ /** As a member's `own`: the receiver's home declares it. */
1222
+ own: boolean;
1126
1223
  }
1127
1224
  export interface SurfaceExport {
1128
1225
  export: string;
@@ -1137,13 +1234,28 @@ export interface LibrarySurface {
1137
1234
  reason?: string;
1138
1235
  /** Entries dropped by `max_entries`. */
1139
1236
  truncated: number;
1237
+ exports: SurfaceExport[];
1238
+ /** With `handlers: true`: the handler-parameter types its handlers' parameters refer to (carrick#2977). */
1239
+ handler_types?: SurfaceHandlerType[];
1240
+ /** With `handlers: true`: each type export a `handler_types` entry names, as receiver `type` (carrick#2977). */
1241
+ types?: SurfaceTypeExport[];
1140
1242
  /**
1141
- * With `handlers: true`, the handler-parameter members dropped by the cap of
1142
- * 500 per parameter (carrick#2966) and the parameters the listing's budget
1143
- * left out (`max_handler_members`, carrick#3016), summed over every parameter.
1243
+ * With `handlers: true`: the handler parameters the listing's budget of
1244
+ * handler members (`max_handler_members`, carrick#3016) left out, because
1245
+ * their type's new entry would pass it.
1144
1246
  */
1145
- handlers_truncated?: number;
1146
- exports: SurfaceExport[];
1247
+ handler_params_left_out?: number;
1248
+ /**
1249
+ * With `types: true`: entries of `types` the listing's budget left out
1250
+ * (carrick#3050). `truncated` does not count them.
1251
+ */
1252
+ types_left_out?: number;
1253
+ /**
1254
+ * With `types: true`: per export, per receiver the surface lists, the
1255
+ * `types` receiver ids its built type and base types are declared by
1256
+ * (carrick#3051). Outside `surface_sha256`.
1257
+ */
1258
+ receiver_types?: Record<string, Record<string, string[]>>;
1147
1259
  }
1148
1260
  export interface ListLibrarySurfaceResponse extends BaseResponse {
1149
1261
  /** One per requested specifier, in request order. */