@intentius/chant 0.124.45 → 0.124.46

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 (190) hide show
  1. package/dist/capabilities/aws.paths +148 -0
  2. package/dist/capabilities/base-mappings.json +122 -0
  3. package/dist/capabilities/catalog.d.ts +89 -0
  4. package/dist/capabilities/catalog.d.ts.map +1 -0
  5. package/dist/capabilities/catalog.js +204 -0
  6. package/dist/capabilities/language.d.ts +103 -0
  7. package/dist/capabilities/language.d.ts.map +1 -0
  8. package/dist/capabilities/language.js +335 -0
  9. package/dist/capabilities/matcher.d.ts +65 -0
  10. package/dist/capabilities/matcher.d.ts.map +1 -0
  11. package/dist/capabilities/matcher.js +299 -0
  12. package/dist/capabilities/view.d.ts +207 -0
  13. package/dist/capabilities/view.d.ts.map +1 -0
  14. package/dist/capabilities/view.js +484 -0
  15. package/dist/cli/commands/lint.d.ts.map +1 -1
  16. package/dist/cli/commands/lint.js +1 -0
  17. package/dist/cli/handlers/declared-graph.d.ts +44 -0
  18. package/dist/cli/handlers/declared-graph.d.ts.map +1 -0
  19. package/dist/cli/handlers/declared-graph.js +87 -0
  20. package/dist/cli/handlers/graph.d.ts +25 -0
  21. package/dist/cli/handlers/graph.d.ts.map +1 -1
  22. package/dist/cli/handlers/graph.js +93 -87
  23. package/dist/cli/handlers/pr-env.d.ts.map +1 -1
  24. package/dist/cli/handlers/pr-env.js +2 -1
  25. package/dist/cli/handlers/search-count.d.ts +89 -0
  26. package/dist/cli/handlers/search-count.d.ts.map +1 -0
  27. package/dist/cli/handlers/search-count.js +132 -0
  28. package/dist/cli/handlers/search.d.ts +358 -6
  29. package/dist/cli/handlers/search.d.ts.map +1 -1
  30. package/dist/cli/handlers/search.js +1065 -155
  31. package/dist/cli/main.d.ts.map +1 -1
  32. package/dist/cli/main.js +23 -3
  33. package/dist/cli/mcp/server.d.ts.map +1 -1
  34. package/dist/cli/mcp/server.js +3 -0
  35. package/dist/cli/mcp/tools/capabilities.d.ts +7 -0
  36. package/dist/cli/mcp/tools/capabilities.d.ts.map +1 -0
  37. package/dist/cli/mcp/tools/capabilities.js +27 -0
  38. package/dist/cli/mcp/workspace-tools.d.ts +3 -1
  39. package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
  40. package/dist/cli/mcp/workspace-tools.js +47 -2
  41. package/dist/cli/parse-args.d.ts.map +1 -1
  42. package/dist/cli/parse-args.js +64 -17
  43. package/dist/cli/registry.d.ts +22 -0
  44. package/dist/cli/registry.d.ts.map +1 -1
  45. package/dist/components/pr-env-ports.d.ts +29 -0
  46. package/dist/components/pr-env-ports.d.ts.map +1 -0
  47. package/dist/components/pr-env-ports.js +77 -0
  48. package/dist/components/pr-env-run.d.ts +5 -21
  49. package/dist/components/pr-env-run.d.ts.map +1 -1
  50. package/dist/components/pr-env-run.js +6 -70
  51. package/dist/components/pr-environment.d.ts +2 -1
  52. package/dist/components/pr-environment.d.ts.map +1 -1
  53. package/dist/components/pr-environment.js +1 -1
  54. package/dist/config-environments.d.ts +92 -0
  55. package/dist/config-environments.d.ts.map +1 -0
  56. package/dist/config-environments.js +102 -0
  57. package/dist/config.d.ts +24 -84
  58. package/dist/config.d.ts.map +1 -1
  59. package/dist/config.js +9 -96
  60. package/dist/graph-detail.d.ts.map +1 -1
  61. package/dist/graph-detail.js +15 -3
  62. package/dist/graph-effective.d.ts +33 -2
  63. package/dist/graph-effective.d.ts.map +1 -1
  64. package/dist/graph-effective.js +215 -68
  65. package/dist/graph-ir.d.ts +23 -0
  66. package/dist/graph-ir.d.ts.map +1 -1
  67. package/dist/graph-ir.js +130 -0
  68. package/dist/graph-sub-template.d.ts +11 -0
  69. package/dist/graph-sub-template.d.ts.map +1 -0
  70. package/dist/graph-sub-template.js +19 -0
  71. package/dist/lexicon.d.ts +9 -0
  72. package/dist/lexicon.d.ts.map +1 -1
  73. package/dist/lifecycle/observe.d.ts +28 -0
  74. package/dist/lifecycle/observe.d.ts.map +1 -1
  75. package/dist/lifecycle/observe.js +23 -1
  76. package/dist/lint/rule.d.ts +6 -0
  77. package/dist/lint/rule.d.ts.map +1 -1
  78. package/dist/live-endpoint.d.ts +1 -1
  79. package/dist/live-endpoint.d.ts.map +1 -1
  80. package/dist/live-endpoint.js +1 -1
  81. package/dist/observation.d.ts +48 -1
  82. package/dist/observation.d.ts.map +1 -1
  83. package/dist/observation.js +21 -5
  84. package/dist/op/activities/activity-contracts.d.ts +4 -4
  85. package/dist/wave-runtime.mjs +250 -249
  86. package/dist/workspace/capabilities-contract.d.ts +66 -0
  87. package/dist/workspace/capabilities-contract.d.ts.map +1 -0
  88. package/dist/workspace/capabilities-contract.js +107 -0
  89. package/dist/workspace/capabilities.schema.json +229 -0
  90. package/dist/workspace/compose-graph.d.ts +9 -0
  91. package/dist/workspace/compose-graph.d.ts.map +1 -1
  92. package/dist/workspace/compose-graph.js +3 -1
  93. package/dist/workspace/conformance/index.d.ts +1 -1
  94. package/dist/workspace/conformance/index.d.ts.map +1 -1
  95. package/dist/workspace/conformance/index.js +39 -2
  96. package/dist/workspace/graph-cache.d.ts +8 -0
  97. package/dist/workspace/graph-cache.d.ts.map +1 -1
  98. package/dist/workspace/graph-cache.js +27 -3
  99. package/dist/workspace/graph-cli.d.ts +39 -2
  100. package/dist/workspace/graph-cli.d.ts.map +1 -1
  101. package/dist/workspace/graph-cli.js +66 -24
  102. package/dist/workspace/graph.schema.json +148 -0
  103. package/dist/workspace/kind-readers.d.ts +3 -0
  104. package/dist/workspace/kind-readers.d.ts.map +1 -1
  105. package/dist/workspace/kind-readers.js +7 -1
  106. package/dist/workspace/member-commands.d.ts +10 -1
  107. package/dist/workspace/member-commands.d.ts.map +1 -1
  108. package/dist/workspace/member-commands.js +17 -1
  109. package/dist/workspace/nested-graph.d.ts +2 -0
  110. package/dist/workspace/nested-graph.d.ts.map +1 -1
  111. package/dist/workspace/nested-graph.js +32 -1
  112. package/dist/workspace/reason-codes.d.ts +10 -0
  113. package/dist/workspace/reason-codes.d.ts.map +1 -1
  114. package/dist/workspace/reason-codes.js +12 -0
  115. package/dist/workspace/search-cli.d.ts +204 -0
  116. package/dist/workspace/search-cli.d.ts.map +1 -0
  117. package/dist/workspace/search-cli.js +466 -0
  118. package/dist/workspace/search-contract.d.ts +56 -0
  119. package/dist/workspace/search-contract.d.ts.map +1 -0
  120. package/dist/workspace/search-contract.js +70 -0
  121. package/dist/workspace/search.schema.json +822 -0
  122. package/package.json +1 -1
  123. package/src/__snapshots__/okf.test.ts.snap +10 -0
  124. package/src/capabilities/aws.paths +148 -0
  125. package/src/capabilities/base-mappings.json +122 -0
  126. package/src/capabilities/catalog.ts +230 -0
  127. package/src/capabilities/language.test.ts +191 -0
  128. package/src/capabilities/language.ts +373 -0
  129. package/src/capabilities/matcher.ts +315 -0
  130. package/src/capabilities/view-compose.test.ts +76 -0
  131. package/src/capabilities/view.ts +631 -0
  132. package/src/cli/commands/lint.ts +1 -0
  133. package/src/cli/handlers/declared-graph.ts +99 -0
  134. package/src/cli/handlers/graph.test.ts +94 -3
  135. package/src/cli/handlers/graph.ts +123 -96
  136. package/src/cli/handlers/pr-env.ts +1 -2
  137. package/src/cli/handlers/search-build-roots.test.ts +144 -0
  138. package/src/cli/handlers/search-count.test.ts +191 -0
  139. package/src/cli/handlers/search-count.ts +165 -0
  140. package/src/cli/handlers/search-json.test.ts +333 -0
  141. package/src/cli/handlers/search-live.test.ts +387 -0
  142. package/src/cli/handlers/search-paths.test.ts +235 -0
  143. package/src/cli/handlers/search.ts +1312 -166
  144. package/src/cli/main.test.ts +28 -3
  145. package/src/cli/main.ts +23 -3
  146. package/src/cli/mcp/server.test.ts +3 -3
  147. package/src/cli/mcp/server.ts +3 -0
  148. package/src/cli/mcp/tools/capabilities.ts +32 -0
  149. package/src/cli/mcp/workspace-tools.e2e.test.ts +21 -1
  150. package/src/cli/mcp/workspace-tools.ts +47 -2
  151. package/src/cli/parse-args.ts +52 -13
  152. package/src/cli/registry.ts +22 -0
  153. package/src/components/pr-env-ports.ts +89 -0
  154. package/src/components/pr-env-run-bundle.test.ts +54 -0
  155. package/src/components/pr-env-run.ts +5 -76
  156. package/src/components/pr-environment.ts +2 -1
  157. package/src/config-environments.ts +133 -0
  158. package/src/config.ts +37 -124
  159. package/src/graph-detail.ts +15 -3
  160. package/src/graph-effective.ts +226 -75
  161. package/src/graph-ir.test.ts +163 -0
  162. package/src/graph-ir.ts +147 -0
  163. package/src/graph-sub-template.ts +22 -0
  164. package/src/lexicon.ts +10 -0
  165. package/src/lifecycle/observe.test.ts +27 -1
  166. package/src/lifecycle/observe.ts +43 -1
  167. package/src/lint/rule.ts +6 -0
  168. package/src/live-endpoint.ts +1 -1
  169. package/src/observation.test.ts +25 -0
  170. package/src/observation.ts +69 -5
  171. package/src/workspace/capabilities-contract.test.ts +88 -0
  172. package/src/workspace/capabilities-contract.ts +132 -0
  173. package/src/workspace/capabilities.schema.json +229 -0
  174. package/src/workspace/compose-graph.ts +10 -1
  175. package/src/workspace/conformance/conformance.e2e.test.ts +14 -1
  176. package/src/workspace/conformance/index.ts +31 -2
  177. package/src/workspace/graph-cache.ts +27 -3
  178. package/src/workspace/graph-cli.ts +96 -24
  179. package/src/workspace/graph.schema.json +148 -0
  180. package/src/workspace/kind-readers.e2e.test.ts +28 -0
  181. package/src/workspace/kind-readers.test.ts +1 -1
  182. package/src/workspace/kind-readers.ts +7 -1
  183. package/src/workspace/member-commands.ts +22 -1
  184. package/src/workspace/nested-graph.ts +32 -1
  185. package/src/workspace/reason-codes.test.ts +7 -0
  186. package/src/workspace/reason-codes.ts +12 -0
  187. package/src/workspace/search-cli.e2e.test.ts +305 -0
  188. package/src/workspace/search-cli.ts +591 -0
  189. package/src/workspace/search-contract.ts +95 -0
  190. package/src/workspace/search.schema.json +822 -0
@@ -307,9 +307,7 @@ export function splitCached(plan, args, cache, at, argvFor = (u) => memberArgv("
307
307
  // A member read through a generated reader project (#2874) is also keyed on
308
308
  // the kind's graph block and the version of the package that reads it.
309
309
  const reader = unit.reader ? readerStamp(unit.reader) : "";
310
- const abs = unit.dir === "." ? plan.workspace.root : join(plan.workspace.root, ...unit.dir.split("/"));
311
- const revision = at ? { commit: at, dir: unit.dir } : undefined;
312
- const stamp = memberStamp(abs, unit.exclude, revision);
310
+ const { abs, revision, stamp } = unitStamp(plan, unit, at);
313
311
  if (!stamp)
314
312
  continue;
315
313
  stamps.set(unit.id, stamp.value);
@@ -325,6 +323,32 @@ export function splitCached(plan, args, cache, at, argvFor = (u) => memberArgv("
325
323
  }
326
324
  return { hits, stamps, pending, started };
327
325
  }
326
+ /** One unit's stamp, and what it was taken over: the member's directory on disk, and the commit for `--at`. */
327
+ function unitStamp(plan, unit, at) {
328
+ const abs = unit.dir === "." ? plan.workspace.root : join(plan.workspace.root, ...unit.dir.split("/"));
329
+ const revision = at ? { commit: at, dir: unit.dir } : undefined;
330
+ return { abs, ...(revision ? { revision } : {}), stamp: memberStamp(abs, unit.exclude, revision) };
331
+ }
332
+ /**
333
+ * Every member unit's stamp, by unit id, by the rule {@link splitCached} keys
334
+ * the cache on (ws-059), with no cache read. A read that is never cached, such
335
+ * as `chant workspace search` (#4374), still stamps its members this way, so a
336
+ * reader compares stamps across documents with one meaning. A unit whose stamp
337
+ * can't be taken is left out.
338
+ */
339
+ export function planStamps(plan, at) {
340
+ const stamps = new Map();
341
+ for (const group of plan.groups) {
342
+ for (const unit of group.units) {
343
+ if (unit.group)
344
+ continue;
345
+ const { stamp } = unitStamp(plan, unit, at);
346
+ if (stamp)
347
+ stamps.set(unit.id, stamp.value);
348
+ }
349
+ }
350
+ return stamps;
351
+ }
328
352
  /** The plan without the units in `ids`; a toolchain left with no units is dropped. */
329
353
  export function withoutUnits(plan, ids) {
330
354
  if (ids.size === 0)
@@ -26,8 +26,9 @@
26
26
  import type { CommandContext, ParsedArgs } from "../cli/registry.js";
27
27
  import { type Plantable } from "./box-factory.js";
28
28
  import { type WorkspaceGraph } from "./compose-graph.js";
29
- import { type ErrorLocation } from "./declaration.js";
30
- import { type MemberPlan, type Toolchain, type UnitResult } from "./member-commands.js";
29
+ import { type Declaration, type ErrorLocation } from "./declaration.js";
30
+ import { type MemberArgv, type MemberPlan, type Toolchain, type UnitResult } from "./member-commands.js";
31
+ import { type KindRegistry } from "./kinds.js";
31
32
  import { type LocatedWorkspace } from "./which-chant.js";
32
33
  /** The version of the `graph` document this chant writes. */
33
34
  export declare const GRAPH_CONTRACT_VERSION = 1;
@@ -109,6 +110,42 @@ export declare function componentGraphArgv(args: Partial<ParsedArgs>): string[];
109
110
  export declare function exportRevision(located: LocatedWorkspace, memberDirs: string[]): string;
110
111
  /** Plan a graph read without running anything, for `--dry-run`. Throws a {@link WorkspaceReadError}. */
111
112
  export declare function planGraph(query: GraphQuery): MemberPlan;
113
+ /** The members of a workspace read, each read under its own toolchain: what graph and search compose (#4374). */
114
+ export interface MemberReads {
115
+ located: LocatedWorkspace;
116
+ declaration: Declaration;
117
+ kinds: KindRegistry;
118
+ /** The plan the members ran from. */
119
+ plan: MemberPlan;
120
+ /** Each member's answer, the cache's included, in no particular order. */
121
+ results: UnitResult[];
122
+ /** The members the cache answered. */
123
+ served: ReadonlySet<string>;
124
+ /** Each member's stamp, by unit id (ws-059). */
125
+ stamps: ReadonlyMap<string, string>;
126
+ /** With {@link GraphQuery.components}: each member's component graph run. */
127
+ components?: UnitResult[];
128
+ }
129
+ export interface MemberReadOptions {
130
+ /** The command line each member runs; `chant graph --format ir` and the verb's flags by default. */
131
+ argvFor?: MemberArgv;
132
+ /**
133
+ * Answer members from the per-member cache and store what they print
134
+ * (ws-059). Only a read whose output is a graph IR may be cached. When
135
+ * off, every member is still stamped by the same rule.
136
+ */
137
+ cache: boolean;
138
+ }
139
+ /**
140
+ * Plan the members a workspace read covers, run each under its own toolchain
141
+ * (ws-021) at the revision asked for, and return what they printed. One
142
+ * fan-out, shared by `chant workspace graph` and `chant workspace search`
143
+ * (#4374): `--at` exports the tree once, a member of a package's kind runs in
144
+ * its reader project, and every member is stamped by the rule of ws-059. The
145
+ * exported tree and the reader projects are removed before this returns.
146
+ * Throws a {@link WorkspaceReadError} when the declaration can't be read.
147
+ */
148
+ export declare function readMembers(query: GraphQuery, options: MemberReadOptions): Promise<MemberReads>;
112
149
  /** Read and compose the graph, and build the document. Never throws a {@link WorkspaceReadError}. */
113
150
  export declare function workspaceGraph(query: GraphQuery): Promise<GraphResult>;
114
151
  export declare function runWorkspaceGraph(ctx: CommandContext): Promise<number>;
@@ -1 +1 @@
1
- {"version":3,"file":"graph-cli.d.ts","sourceRoot":"","sources":["../../src/workspace/graph-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAA+E,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEnI,OAAO,EAA6E,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9H,OAAO,EAAgF,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAOnK,OAAO,EAAoC,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAExF,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,2EAA2E;AAC3E,eAAO,MAAM,sBAAsB,4EAA4E,CAAC;AAEhH;;;GAGG;AACH,eAAO,MAAM,iBAAiB,2OAA0D,CAAC;AACzF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAQhE,UAAU,IAAI;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,aAAa,GACrB,CAAC,IAAI,GAAG;IAAE,EAAE,EAAE,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D,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsE5E"}
@@ -29,8 +29,10 @@ import { tmpdir } from "node:os";
29
29
  import { dirname, join, resolve } from "node:path";
30
30
  import { formatError } from "../cli/format.js";
31
31
  import { graphBox, plantability } from "./box-factory.js";
32
- import { composeWorkspaceGraph, readMemberIr } from "./compose-graph.js";
33
- import { openGraphCache, splitCached, storeReads, withoutUnits } from "./graph-cache.js";
32
+ import { composedId, composeWorkspaceGraph, readMemberIr } from "./compose-graph.js";
33
+ import { isViewDocument, prefixView } from "../capabilities/view.js";
34
+ import { refusedCapabilityView } from "./nested-graph.js";
35
+ import { openGraphCache, planStamps, splitCached, storeReads, withoutUnits } from "./graph-cache.js";
34
36
  import { readDeclaration, readerVersion, WORKSPACE_ERROR_CODES, WorkspaceReadError } from "./declaration.js";
35
37
  import { describePlan, emitDocument, executePlan, memberStatus, planJson, planMembers } from "./member-commands.js";
36
38
  import { loadKindRegistry } from "./kinds.js";
@@ -101,7 +103,7 @@ export function exportRevision(located, memberDirs) {
101
103
  }
102
104
  return out;
103
105
  }
104
- function compose(plan, results, only, declarationMembers, live = false) {
106
+ function compose(plan, results, only, declarationMembers, live = false, capabilityView = false) {
105
107
  // A member that ran was read live when --live was given, and says when (#2875).
106
108
  const read = (member, r) => {
107
109
  if (live) {
@@ -138,6 +140,12 @@ function compose(plan, results, only, declarationMembers, live = false) {
138
140
  }
139
141
  const member = read(memberStatus(m.name, m.dir, m.kind, "composed", null, r.chant), r);
140
142
  member.irVersion = ir.irVersion;
143
+ // The member's own capability view (#4378), with composed ids; null when its chant printed none.
144
+ if (capabilityView) {
145
+ const view = ir.ir.capabilityView;
146
+ member.capabilityView = isViewDocument(view) ? prefixView(view, composedId(m.name, "")) : null;
147
+ }
148
+ delete ir.ir.capabilityView;
141
149
  inputs.push({ member, ir: ir.ir });
142
150
  }
143
151
  return { inputs, failed };
@@ -146,40 +154,47 @@ function compose(plan, results, only, declarationMembers, live = false) {
146
154
  export function planGraph(query) {
147
155
  const located = locateWorkspace(query.cwd, query.at);
148
156
  const declaration = readDeclaration(located.tree, "", { rootChant: true });
149
- const kinds = loadKindRegistry(declaration.pins, located.rootOnDisk).registry;
150
- return planMembers("graph", located.rootOnDisk, { only: query.members, reader: query.reader, tree: located.tree, kinds });
157
+ const { registry: kinds, problems } = loadKindRegistry(declaration.pins, located.rootOnDisk);
158
+ return planMembers("graph", located.rootOnDisk, { only: query.members, reader: query.reader, tree: located.tree, kinds, kindProblems: problems.map((p) => p.message) });
151
159
  }
152
- /** Read and compose the graph, and build the document. Never throws a {@link WorkspaceReadError}. */
153
- export async function workspaceGraph(query) {
154
- const head = { $schema: GRAPH_OUTPUT_SCHEMA_ID, contract: GRAPH_CONTRACT_VERSION, chant: readerVersion() };
160
+ /**
161
+ * Plan the members a workspace read covers, run each under its own toolchain
162
+ * (ws-021) at the revision asked for, and return what they printed. One
163
+ * fan-out, shared by `chant workspace graph` and `chant workspace search`
164
+ * (#4374): `--at` exports the tree once, a member of a package's kind runs in
165
+ * its reader project, and every member is stamped by the rule of ws-059. The
166
+ * exported tree and the reader projects are removed before this returns.
167
+ * Throws a {@link WorkspaceReadError} when the declaration can't be read.
168
+ */
169
+ export async function readMembers(query, options) {
155
170
  let exported;
156
171
  let readers;
157
- if (query.args?.live && query.at !== undefined) {
158
- return { doc: { ...head, error: { code: "live-at-revision", message: LIVE_AT_REVISION, location: null } }, failed: true };
159
- }
160
172
  try {
161
173
  const located = locateWorkspace(query.cwd, query.at);
162
174
  const declaration = readDeclaration(located.tree, "", { rootChant: true });
163
175
  // Kinds are read before planning: a package kind with a graph block runs (#2874).
164
- const kinds = loadKindRegistry(declaration.pins, located.rootOnDisk).registry;
165
- let plan = planMembers("graph", located.rootOnDisk, { only: query.members, reader: query.reader, tree: located.tree, kinds });
176
+ const { registry: kinds, problems } = loadKindRegistry(declaration.pins, located.rootOnDisk);
177
+ const kindProblems = problems.map((p) => p.message);
178
+ let plan = planMembers("graph", located.rootOnDisk, { only: query.members, reader: query.reader, tree: located.tree, kinds, kindProblems });
166
179
  const args = (query.args ?? {});
167
180
  // Members whose last source read still stands are answered from the cache (#2876).
168
181
  // A composites read runs every member's component graph as well, so it reads everything.
169
- const cache = query.noCache || query.components ? undefined : openGraphCache(located.rootOnDisk);
182
+ const cache = !options.cache || query.noCache || query.components ? undefined : openGraphCache(located.rootOnDisk);
170
183
  const split = cache ? splitCached(plan, args, cache, located.at) : undefined;
184
+ const stamps = split?.stamps ?? (options.cache ? new Map() : planStamps(plan, located.at));
171
185
  const served = new Set(split?.hits.map((h) => h.id));
172
186
  if (located.at !== null && withoutUnits(plan, served).groups.length > 0) {
173
187
  exported = exportRevision(located, withoutUnits(plan, served).groups.flatMap((g) => g.units.map((u) => u.dir)));
174
- plan = planMembers("graph", exported, { only: query.members, reader: query.reader, tree: workingTree(exported), kinds });
188
+ plan = planMembers("graph", exported, { only: query.members, reader: query.reader, tree: workingTree(exported), kinds, kindProblems });
175
189
  }
176
190
  // Only the members that run get a reader project; a served member needs none.
177
191
  const toRun = withoutUnits(plan, served);
178
192
  readers = prepareKindReaders(toRun, exported ?? located.rootOnDisk);
179
- const [ran, components] = await Promise.all([
180
- executePlan(toRun, args),
193
+ const [first, components] = await Promise.all([
194
+ executePlan(toRun, args, options.argvFor),
181
195
  query.components ? executePlan(plan, args, () => componentGraphArgv(args)) : Promise.resolve(undefined),
182
196
  ]);
197
+ const ran = args.capabilityView && !options.argvFor ? await withoutViewWhereRefused(toRun, args, first) : first;
183
198
  if (cache && split)
184
199
  storeReads(split, ran, cache);
185
200
  const results = [...(split?.hits ?? []), ...ran];
@@ -191,12 +206,44 @@ export async function workspaceGraph(query) {
191
206
  for (const r of results)
192
207
  if (r.stderr.trim() && query.onStderr)
193
208
  query.onStderr(r.stderr.endsWith("\n") ? r.stderr : `${r.stderr}\n`);
194
- const { inputs, failed } = compose(plan, results, query.members, declaration.members, !!args.live);
209
+ return { located, declaration, kinds, plan, results, served, stamps, ...(components ? { components } : {}) };
210
+ }
211
+ finally {
212
+ readers?.cleanup();
213
+ if (exported)
214
+ rmSync(dirname(exported), { recursive: true, force: true });
215
+ }
216
+ }
217
+ /**
218
+ * A member's chant from before #4378 refuses `--capability-view` as a flag
219
+ * it doesn't know. Read those members again without it, so the graph still
220
+ * composes them; they carry `capabilityView: null`, which a capability search
221
+ * reports as `member-chant-too-old`.
222
+ */
223
+ async function withoutViewWhereRefused(plan, args, results) {
224
+ const refused = new Set(results.filter((r) => r.exitCode !== 0 && refusedCapabilityView(r.stderr)).map((r) => r.id));
225
+ if (refused.size === 0)
226
+ return results;
227
+ const others = new Set(results.filter((r) => !refused.has(r.id)).map((r) => r.id));
228
+ const again = await executePlan(withoutUnits(plan, others), { ...args, capabilityView: false });
229
+ const byId = new Map(again.map((r) => [r.id, r]));
230
+ return results.map((r) => byId.get(r.id) ?? r);
231
+ }
232
+ /** Read and compose the graph, and build the document. Never throws a {@link WorkspaceReadError}. */
233
+ export async function workspaceGraph(query) {
234
+ const head = { $schema: GRAPH_OUTPUT_SCHEMA_ID, contract: GRAPH_CONTRACT_VERSION, chant: readerVersion() };
235
+ if (query.args?.live && query.at !== undefined) {
236
+ return { doc: { ...head, error: { code: "live-at-revision", message: LIVE_AT_REVISION, location: null } }, failed: true };
237
+ }
238
+ try {
239
+ const { located, declaration, kinds, plan, results, served, stamps, components } = await readMembers(query, { cache: true });
240
+ const args = (query.args ?? {});
241
+ const { inputs, failed } = compose(plan, results, query.members, declaration.members, !!args.live, !!args.capabilityView);
195
242
  for (const { member } of inputs) {
196
243
  if (member.status !== "composed")
197
244
  continue;
198
245
  member.cached = served.has(member.name);
199
- member.stamp = split?.stamps.get(member.name) ?? null;
246
+ member.stamp = stamps.get(member.name) ?? null;
200
247
  }
201
248
  // Links (#2539) resolve against the declaration that was read, the revision's for --at, and the kinds installed now.
202
249
  // A kind's link reader (#3932) reads the member's files in the tree read, as check does.
@@ -231,11 +278,6 @@ export async function workspaceGraph(query) {
231
278
  throw err;
232
279
  return { doc: { ...head, error: { code: err.code, message: err.message, location: err.location ?? null } }, failed: true };
233
280
  }
234
- finally {
235
- readers?.cleanup();
236
- if (exported)
237
- rmSync(dirname(exported), { recursive: true, force: true });
238
- }
239
281
  }
240
282
  /**
241
283
  * Expand every member of kind `workspace` the query covers, read-only (#2551,
@@ -437,6 +437,17 @@
437
437
  }
438
438
  }
439
439
  ]
440
+ },
441
+ "capabilityView": {
442
+ "description": "Added in contract 1 by #4378. Only with `--capability-view`, which `chant workspace search` asks for when a query has a capability term. The lexicon-neutral view capability rules read, built by the member's own chant through the mappings and adapters of the lexicons the member loads (its `chant graph --format ir --capability-view`), with `<member>/<id>` ids. null on a composed member whose chant printed no view (one from before #4378); a capability search reports that member as `member-chant-too-old`. Absent without the flag, and on a member that was not composed.",
443
+ "oneOf": [
444
+ {
445
+ "type": "null"
446
+ },
447
+ {
448
+ "$ref": "#/$defs/capabilityView"
449
+ }
450
+ ]
440
451
  }
441
452
  },
442
453
  "if": {
@@ -1438,6 +1449,143 @@
1438
1449
  ]
1439
1450
  }
1440
1451
  }
1452
+ },
1453
+ "capabilityView": {
1454
+ "type": "object",
1455
+ "description": "One member's capability view (#4378), as `capabilities/view.ts` serializes it. Rules read labels, attributes and edges; a node's attributes are the neutral ones its lexicon's mapping names.",
1456
+ "required": [
1457
+ "version",
1458
+ "lexicons",
1459
+ "nodes",
1460
+ "edges",
1461
+ "unresolved"
1462
+ ],
1463
+ "properties": {
1464
+ "version": {
1465
+ "const": 1,
1466
+ "description": "The view's own format version. A reader treats a view of a version it doesn't know as no view."
1467
+ },
1468
+ "lexicons": {
1469
+ "type": "array",
1470
+ "items": {
1471
+ "type": "string"
1472
+ },
1473
+ "description": "The lexicons whose nodes a mapping labelled."
1474
+ },
1475
+ "nodes": {
1476
+ "type": "array",
1477
+ "items": {
1478
+ "type": "object",
1479
+ "required": [
1480
+ "id",
1481
+ "label",
1482
+ "irId",
1483
+ "lexicon",
1484
+ "attrs"
1485
+ ],
1486
+ "properties": {
1487
+ "id": {
1488
+ "type": "string",
1489
+ "description": "A node id of the composed graph, or, for a policy statement or an inline block, that id with `#<attribute path>`."
1490
+ },
1491
+ "label": {
1492
+ "type": "string",
1493
+ "description": "The neutral label (`Role`, `Bucket`, `Statement`, `IngressRule`)."
1494
+ },
1495
+ "irId": {
1496
+ "type": "string",
1497
+ "description": "The composed graph node this view node is, or sits inside."
1498
+ },
1499
+ "lexicon": {
1500
+ "type": "string"
1501
+ },
1502
+ "attrs": {
1503
+ "type": "object"
1504
+ }
1505
+ }
1506
+ }
1507
+ },
1508
+ "edges": {
1509
+ "type": "array",
1510
+ "items": {
1511
+ "type": "object",
1512
+ "required": [
1513
+ "from",
1514
+ "to",
1515
+ "name",
1516
+ "hops"
1517
+ ],
1518
+ "properties": {
1519
+ "from": {
1520
+ "type": "string"
1521
+ },
1522
+ "to": {
1523
+ "type": "string"
1524
+ },
1525
+ "name": {
1526
+ "type": "string",
1527
+ "description": "The view edge's name (`subnet`, `statement`, `resource`, `attachedTo`)."
1528
+ },
1529
+ "hops": {
1530
+ "type": "array",
1531
+ "description": "The graph references the edge stands for, in walk order from `from`, each in the reference's own direction.",
1532
+ "items": {
1533
+ "type": "object",
1534
+ "required": [
1535
+ "from",
1536
+ "to",
1537
+ "edge"
1538
+ ],
1539
+ "properties": {
1540
+ "from": {
1541
+ "type": "string"
1542
+ },
1543
+ "fromAttr": {
1544
+ "type": "string"
1545
+ },
1546
+ "to": {
1547
+ "type": "string"
1548
+ },
1549
+ "toAttr": {
1550
+ "type": "string"
1551
+ },
1552
+ "edge": {
1553
+ "type": "string"
1554
+ }
1555
+ }
1556
+ }
1557
+ }
1558
+ }
1559
+ }
1560
+ },
1561
+ "unresolved": {
1562
+ "type": "array",
1563
+ "description": "ARN strings naming a role, bucket or table that the member declares nothing of. `chant workspace search` resolves them by name over every member's view, so a policy in one member reaches a bucket in another.",
1564
+ "items": {
1565
+ "type": "object",
1566
+ "required": [
1567
+ "from",
1568
+ "fromAttr",
1569
+ "edge",
1570
+ "value"
1571
+ ],
1572
+ "properties": {
1573
+ "from": {
1574
+ "type": "string"
1575
+ },
1576
+ "fromAttr": {
1577
+ "type": "string"
1578
+ },
1579
+ "edge": {
1580
+ "type": "string"
1581
+ },
1582
+ "value": {
1583
+ "type": "string"
1584
+ }
1585
+ }
1586
+ }
1587
+ }
1588
+ }
1441
1589
  }
1442
1590
  }
1443
1591
  }
@@ -13,6 +13,9 @@
13
13
  * (`substituteGraphConfig`). The terraform lexicon's config names one root
14
14
  * after the member, at the member's directory, with `moduleRoot` at the
15
15
  * workspace root, so a member that calls `../modules/x` keeps its modules.
16
+ * - It also sets `graph.lint: "report"` (behold#919), so a member whose
17
+ * source fails the lexicon's lint is still composed, with the findings on
18
+ * its `meta.lint`, instead of failing with `command-failed`.
16
19
  * - `node_modules` links to the `node_modules` directory holding the lexicon
17
20
  * package, found from the workspace root as the kind's pin was. The lexicon
18
21
  * chant loads is then the one the declaration pins.
@@ -1 +1 @@
1
- {"version":3,"file":"kind-readers.d.ts","sourceRoot":"","sources":["../../src/workspace/kind-readers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAW,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,gEAAgE;IAChE,OAAO,IAAI,IAAI,CAAC;CACjB;AAmCD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAiClF"}
1
+ {"version":3,"file":"kind-readers.d.ts","sourceRoot":"","sources":["../../src/workspace/kind-readers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAW,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,gEAAgE;IAChE,OAAO,IAAI,IAAI,CAAC;CACjB;AAmCD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAoClF"}
@@ -13,6 +13,9 @@
13
13
  * (`substituteGraphConfig`). The terraform lexicon's config names one root
14
14
  * after the member, at the member's directory, with `moduleRoot` at the
15
15
  * workspace root, so a member that calls `../modules/x` keeps its modules.
16
+ * - It also sets `graph.lint: "report"` (behold#919), so a member whose
17
+ * source fails the lexicon's lint is still composed, with the findings on
18
+ * its `meta.lint`, instead of failing with `command-failed`.
16
19
  * - `node_modules` links to the `node_modules` directory holding the lexicon
17
20
  * package, found from the workspace root as the kind's pin was. The lexicon
18
21
  * chant loads is then the one the declaration pins.
@@ -86,7 +89,10 @@ export function prepareKindReaders(plan, root) {
86
89
  const project = join(scratch, unit.id);
87
90
  mkdirSync(project, { recursive: true });
88
91
  const config = substituteGraphConfig(unit.reader.config, { member: unit.member, dir: unit.abs, workspace: root });
89
- writeFileSync(join(project, "chant.config.json"), `${JSON.stringify({ lexicons: [unit.reader.lexicon], [unit.reader.lexicon]: config }, null, 2)}\n`);
92
+ // `graph.lint: "report"` (behold#919): chant did not author a reader
93
+ // member's source, so a lint error there is a finding about it, carried
94
+ // on the member's `meta.lint`, not a reason to leave it out of the graph.
95
+ writeFileSync(join(project, "chant.config.json"), `${JSON.stringify({ lexicons: [unit.reader.lexicon], [unit.reader.lexicon]: config, graph: { lint: "report" } }, null, 2)}\n`);
90
96
  symlinkSync(found.modules, join(project, "node_modules"), "dir");
91
97
  unit.abs = project;
92
98
  return true;
@@ -12,7 +12,10 @@
12
12
  * - For `graph` only, members of a pinned package's kind whose kinds file
13
13
  * says how to read them (#2874, a `graph` block): each runs `chant graph`
14
14
  * in a reader project chant writes for it (`kind-readers.ts`). Other
15
- * package kinds are `kind-not-run`, as before.
15
+ * package kinds are `kind-not-run`, as before. A kind no built-in or
16
+ * pinned package supplies, such as `terraform` when the pinned lexicon is
17
+ * missing or at another version, is `unknown-kind` and fails the read,
18
+ * with the pin's problem in the message (#4380).
16
19
  * - For `build` and `lint` only, every project an example group matches
17
20
  * (ws-051): groups are built and linted, and have no ledger, audit or place
18
21
  * in the graph. On a large repository this is most of the run, so
@@ -116,6 +119,12 @@ export interface PlanOptions {
116
119
  reader?: Toolchain;
117
120
  /** The files to plan from, such as a revision's (`--at`); the working tree under `root` by default. */
118
121
  tree?: WorkspaceTree;
122
+ /**
123
+ * Why a pinned package's kinds couldn't be loaded (`loadKindRegistry`'s
124
+ * problems), such as a pin at one version with another installed. A graph
125
+ * read names them on a member whose kind is unknown (#4380).
126
+ */
127
+ kindProblems?: readonly string[];
119
128
  }
120
129
  /** Work out which projects run and under which chant. Throws a {@link WorkspaceReadError} for an unreadable declaration or an unknown `--member` name. */
121
130
  export declare function planMembers(verb: WorkspaceVerb, root: string, options?: PlanOptions): MemberPlan;
@@ -1 +1 @@
1
- {"version":3,"file":"member-commands.d.ts","sourceRoot":"","sources":["../../src/workspace/member-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAA0B,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAuB,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAwC,KAAK,aAAa,EAAyB,MAAM,cAAc,CAAC;AAC/G,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEzD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AAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAQlD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAQ3E;AAwCD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,cAAc,CAEzK;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA+EnG"}
@@ -12,7 +12,10 @@
12
12
  * - For `graph` only, members of a pinned package's kind whose kinds file
13
13
  * says how to read them (#2874, a `graph` block): each runs `chant graph`
14
14
  * in a reader project chant writes for it (`kind-readers.ts`). Other
15
- * package kinds are `kind-not-run`, as before.
15
+ * package kinds are `kind-not-run`, as before. A kind no built-in or
16
+ * pinned package supplies, such as `terraform` when the pinned lexicon is
17
+ * missing or at another version, is `unknown-kind` and fails the read,
18
+ * with the pin's problem in the message (#4380).
16
19
  * - For `build` and `lint` only, every project an example group matches
17
20
  * (ws-051): groups are built and linted, and have no ledger, audit or place
18
21
  * in the graph. On a large repository this is most of the run, so
@@ -141,6 +144,16 @@ export function planMembers(verb, root, options = {}) {
141
144
  });
142
145
  continue;
143
146
  }
147
+ // A kind no built-in or pinned package supplies is unknown, not a kind
148
+ // the read leaves out (#4380): a terraform member whose pinned lexicon is
149
+ // missing or at another version said kind-not-run before, as if the graph
150
+ // never read its kind. Say why, the pin's problem included.
151
+ if (verb === "graph" && !kinds.get(entry.kind)) {
152
+ const reason = memberReason(entry, tree, kinds) ?? { code: "unknown-kind", message: `no built-in kind or pinned package supplies kind ${entry.kind}` };
153
+ const problems = reason.code === "unknown-kind" ? (options.kindProblems ?? []) : [];
154
+ unreadable.push({ name: entry.name, dir: entry.dir, kind: entry.kind, reason: problems.length ? { ...reason, message: `${reason.message}; ${problems.join("; ")}` } : reason });
155
+ continue;
156
+ }
144
157
  if (entry.kind !== "chant") {
145
158
  const why = entry.kind === "workspace"
146
159
  ? "a nested workspace runs its own chant workspace commands"
@@ -245,6 +258,9 @@ export function memberArgv(verb, unit, args) {
245
258
  // composites with their rolled-up status (#4228).
246
259
  if (args.detail !== undefined)
247
260
  argv.push("--detail", String(args.detail));
261
+ // Each member's chant maps its own capability view (#4378).
262
+ if (args.capabilityView)
263
+ argv.push("--capability-view");
248
264
  }
249
265
  return argv;
250
266
  }
@@ -45,6 +45,8 @@ export declare function readNestedDocument(stdout: string, exitCode: number, std
45
45
  export declare function readNested(abs: string, args: Partial<ParsedArgs>, at: string | null | undefined, schemaId: string, contract: number, toolchain?: Toolchain | undefined): Promise<NestedRead & {
46
46
  stderr: string;
47
47
  }>;
48
+ /** Whether a chant refused `--capability-view` as a flag it doesn't know (#4378): one from before it. */
49
+ export declare function refusedCapabilityView(stderr: string): boolean;
48
50
  /**
49
51
  * Fold a nested workspace's graph into the outer one, under the outer member
50
52
  * `outer`, and fill that member's entry. The outer graph's other sections are
@@ -1 +1 @@
1
- {"version":3,"file":"nested-graph.d.ts","sourceRoot":"","sources":["../../src/workspace/nested-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAA8B,KAAK,cAAc,EAAqB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE1H,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpE,8CAA8C;AAC9C,MAAM,MAAM,UAAU,GAClB;IAAE,EAAE,EAAE,IAAI,CAAC;IAA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SAAS,EAC7B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,SAAS,GAAG,SAAqB,GAC3C,OAAO,CAAC,UAAU,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAS1C;AAED,yGAAyG;AACzG,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7D;AAYD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA0E5H"}
@@ -20,6 +20,7 @@
20
20
  * in the user's cache directory, ws-059), and the outer side keeps nothing.
21
21
  */
22
22
  import { spawn } from "node:child_process";
23
+ import { isViewDocument, prefixView, VIEW_DOCUMENT_VERSION } from "../capabilities/view.js";
23
24
  import { danglingKey, SCOPED_GROUPS } from "./compose-graph.js";
24
25
  import { readerToolchain } from "./member-commands.js";
25
26
  /** The command line of the nested read: the outer command's own read flags, passed on. */
@@ -35,6 +36,7 @@ export function nestedArgv(dir, args, at) {
35
36
  ...(args.traffic !== undefined ? ["--traffic", String(args.traffic)] : []),
36
37
  ...(args.detail !== undefined ? ["--detail", String(args.detail)] : []),
37
38
  ...(args.noCache ? ["--no-cache"] : []),
39
+ ...(args.capabilityView ? ["--capability-view"] : []),
38
40
  ];
39
41
  }
40
42
  function spawnRead(command, argv, cwd) {
@@ -78,9 +80,19 @@ export function readNestedDocument(stdout, exitCode, stderr, schemaId, contract)
78
80
  }
79
81
  /** Run the nested workspace's own `chant workspace graph` in `abs`. */
80
82
  export async function readNested(abs, args, at, schemaId, contract, toolchain = undefined) {
81
- const r = await spawnRead((toolchain ?? readerToolchain()).command, nestedArgv(abs, args, at), abs);
83
+ const command = (toolchain ?? readerToolchain()).command;
84
+ let r = await spawnRead(command, nestedArgv(abs, args, at), abs);
85
+ // A nested chant from before #4378 has no --capability-view: read it
86
+ // without, and its members carry no view.
87
+ if (args.capabilityView && r.exitCode !== 0 && refusedCapabilityView(r.stderr)) {
88
+ r = await spawnRead(command, nestedArgv(abs, { ...args, capabilityView: false }, at), abs);
89
+ }
82
90
  return { ...readNestedDocument(r.stdout, r.exitCode, r.stderr, schemaId, contract), stderr: r.stderr };
83
91
  }
92
+ /** Whether a chant refused `--capability-view` as a flag it doesn't know (#4378): one from before it. */
93
+ export function refusedCapabilityView(stderr) {
94
+ return /Unknown flag:?\s*--capability-view/i.test(stderr);
95
+ }
84
96
  const prefixed = (outer, id) => `${outer}/${id}`;
85
97
  function prefixRefs(value, outer) {
86
98
  if (Array.isArray(value))
@@ -129,6 +141,25 @@ export function foldNested(graph, member, inner) {
129
141
  for (const i of inner.imports ?? [])
130
142
  graph.imports.push({ ...i, node: prefixed(outer, i.node), member: outer });
131
143
  graph.groups.byMember[outer] = ids.sort();
144
+ // The capability view (#4378): each nested member's, under the outer id. A
145
+ // nested member that read without one leaves the outer member without one.
146
+ const composedInner = inner.members.filter((m) => m.status === "composed");
147
+ if (composedInner.some((m) => m.capabilityView !== undefined)) {
148
+ const views = composedInner.map((m) => m.capabilityView);
149
+ if (views.every(isViewDocument)) {
150
+ const ps = views.map((v) => prefixView(v, `${outer}/`));
151
+ member.capabilityView = {
152
+ version: VIEW_DOCUMENT_VERSION,
153
+ lexicons: [...new Set(ps.flatMap((v) => v.lexicons))].sort(),
154
+ nodes: ps.flatMap((v) => v.nodes),
155
+ edges: ps.flatMap((v) => v.edges),
156
+ unresolved: ps.flatMap((v) => v.unresolved),
157
+ };
158
+ }
159
+ else {
160
+ member.capabilityView = null;
161
+ }
162
+ }
132
163
  const groups = graph.groups;
133
164
  const innerGroups = inner.groups;
134
165
  for (const key of ["byLexicon", "byComposite"]) {