@intentius/chant 0.124.95 → 0.124.96

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.
@@ -21,6 +21,15 @@
21
21
  * falls back to another stack's export or the checked-in file. Any other kind
22
22
  * answers `read-unsupported`.
23
23
  *
24
+ * A member of a package's kind whose kinds file names a drift reader
25
+ * (`drift.reader`, #5068) is read by that module instead (`./drift-reader.ts`):
26
+ * chant imports it in this process, with this process's environment, calls
27
+ * it with the member's directory, the kind's config (placeholders
28
+ * substituted), `--read`, `--resource` and `--stack`, and checks each line
29
+ * it returns with the drift codec. The reader answers for itself, refusals
30
+ * included; chant makes no forge call for it. A declared drift reader comes
31
+ * before the table above.
32
+ *
24
33
  * Any other kind has no drift read and answers `no-drift-read`. A member of
25
34
  * a package's kind runs in the reader project `workspace graph` writes for it
26
35
  * (`./kind-readers.ts`), under the member's own toolchain, so chant core
@@ -1 +1 @@
1
- {"version":3,"file":"drift-cli.d.ts","sourceRoot":"","sources":["../../src/workspace/drift-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAeL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EAGf,MAAM,iBAAiB,CAAC;AASzB,sEAAsE;AACtE,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,yUAcY,CAAC;AAC3C,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,oGAAoG;AACpG,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAKpE,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAA4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E,SAAS,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAuH5G;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CA+FpF;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,sBAAsB,CAQjG;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAuC5E"}
@@ -21,6 +21,15 @@
21
21
  * falls back to another stack's export or the checked-in file. Any other kind
22
22
  * answers `read-unsupported`.
23
23
  *
24
+ * A member of a package's kind whose kinds file names a drift reader
25
+ * (`drift.reader`, #5068) is read by that module instead (`./drift-reader.ts`):
26
+ * chant imports it in this process, with this process's environment, calls
27
+ * it with the member's directory, the kind's config (placeholders
28
+ * substituted), `--read`, `--resource` and `--stack`, and checks each line
29
+ * it returns with the drift codec. The reader answers for itself, refusals
30
+ * included; chant makes no forge call for it. A declared drift reader comes
31
+ * before the table above.
32
+ *
24
33
  * Any other kind has no drift read and answers `no-drift-read`. A member of
25
34
  * a package's kind runs in the reader project `workspace graph` writes for it
26
35
  * (`./kind-readers.ts`), under the member's own toolchain, so chant core
@@ -41,13 +50,15 @@
41
50
  * prints nothing on stdout in stream mode and says why on stderr.
42
51
  */
43
52
  import { existsSync } from "node:fs";
44
- import { resolve } from "node:path";
53
+ import { join, resolve } from "node:path";
45
54
  import { formatError } from "../cli/format.js";
46
55
  import { graphNodeFor } from "../change-set-graph.js";
47
56
  import { componentStatusDriftRecords, countDriftStatuses, decodeDriftLines, DRIFT_READS, DRIFT_SCHEMA_ID, DRIFT_VERSION, driftExpected, driftPlanner, driftRecordLine, driftSettle, driftStart, encodeDriftLines, foldDriftLines, lexiconDriftRecords, } from "../drift-record.js";
48
57
  import { readDeclaration, readerVersion, WORKSPACE_ERROR_CODES, WorkspaceReadError } from "./declaration.js";
58
+ import { readDriftWithModule } from "./drift-reader.js";
49
59
  import { prepareKindReaders } from "./kind-readers.js";
50
- import { loadKindRegistry } from "./kinds.js";
60
+ import { loadKindRegistry, substituteGraphConfig } from "./kinds.js";
61
+ import { memberReason } from "./ls.js";
51
62
  import { emitDocument, executePlan, planMembers } from "./member-commands.js";
52
63
  import { handToRootChant, locateWorkspace } from "./which-chant.js";
53
64
  /** The version of the read contract the document is written under. */
@@ -96,6 +107,33 @@ class DriftReadFailure extends Error {
96
107
  function tail(text) {
97
108
  return text.trim().split("\n").slice(-5).join("\n");
98
109
  }
110
+ /** Read a member through its kind's drift reader module (#5068): the lines it returns, checked, or a failure. */
111
+ async function kindReaderLines(query, entry, drift, root) {
112
+ if (query.read !== undefined && !DRIFT_READS.includes(query.read)) {
113
+ throw new DriftReadFailure("read-unsupported", `--read ${query.read} is not a drift read; the reads are ${DRIFT_READS.join(", ")}`);
114
+ }
115
+ const abs = entry.dir === "." ? root : join(root, entry.dir);
116
+ const config = substituteGraphConfig(drift.config, { member: entry.name, dir: abs, workspace: root });
117
+ const answer = await readDriftWithModule(drift.readerFile, {
118
+ dir: typeof config.dir === "string" ? config.dir : abs,
119
+ config,
120
+ member: entry.name,
121
+ observedAt: new Date().toISOString(),
122
+ ...(query.read !== undefined ? { read: query.read } : {}),
123
+ ...(query.resource !== undefined ? { resource: query.resource } : {}),
124
+ ...(query.stack !== undefined ? { stack: query.stack } : {}),
125
+ });
126
+ if ("error" in answer)
127
+ throw new DriftReadFailure("command-failed", `${query.member}: ${answer.error}`);
128
+ if ("refused" in answer)
129
+ throw new DriftReadFailure(answer.refused.code, `${query.member}: ${answer.refused.message}`);
130
+ return answer.lines;
131
+ }
132
+ /** The kinds `workspace drift` reads, for the no-drift-read message: the table's, and each loaded kind with a drift reader. */
133
+ function driftKinds(kinds) {
134
+ const readers = kinds.names().filter((k) => kinds.get(k)?.drift?.readerFile && !DRIFT_READS_BY_KIND[k]);
135
+ return [...Object.keys(DRIFT_READS_BY_KIND), ...readers].join(", ");
136
+ }
99
137
  /** The member's node ids, without the member in front, from its source graph; null when it can't be read. */
100
138
  async function memberGraph(cwd, member) {
101
139
  try {
@@ -189,9 +227,21 @@ export async function readWorkspaceDrift(query) {
189
227
  if (!entry) {
190
228
  throw new DriftReadFailure("member-required", `--member ${query.member} is not a member of ${declaration.name}; it declares ${declaration.members.map((m) => m.name).join(", ")}`);
191
229
  }
230
+ const { registry: kinds, problems } = loadKindRegistry(declaration.pins, located.rootOnDisk);
231
+ const drift = kinds.get(entry.kind)?.drift;
232
+ if (drift?.readerFile) {
233
+ // A kind's own drift reader (#5068), imported here: no reader project, and the member's graph places its records as for any member.
234
+ const reason = memberReason(entry, located.tree, kinds);
235
+ if (reason)
236
+ throw new DriftReadFailure("command-failed", `${query.member}: ${reason.code}: ${reason.message}`);
237
+ const [graph, lines] = await Promise.all([memberGraph(query.cwd, query.member), kindReaderLines(query, entry, drift, located.rootOnDisk)]);
238
+ return { lines: placeLines(lines, query.member, graph) };
239
+ }
192
240
  const reads = DRIFT_READS_BY_KIND[entry.kind];
193
- if (!reads)
194
- throw new DriftReadFailure("no-drift-read", `${query.member} is kind ${entry.kind}, and chant workspace drift reads members of kind ${Object.keys(DRIFT_READS_BY_KIND).join(", ")}`);
241
+ if (!reads) {
242
+ const problem = problems.find((p) => p.message.includes(`kind ${entry.kind} names drift reader`));
243
+ throw new DriftReadFailure("no-drift-read", `${query.member} is kind ${entry.kind}, and chant workspace drift reads members of kind ${driftKinds(kinds)}${problem ? `; ${problem.message}` : ""}`);
244
+ }
195
245
  if (query.read !== undefined && !DRIFT_READS.includes(query.read)) {
196
246
  throw new DriftReadFailure("read-unsupported", `--read ${query.read} is not a drift read; the reads are ${DRIFT_READS.join(", ")}`);
197
247
  }
@@ -208,7 +258,6 @@ export async function readWorkspaceDrift(query) {
208
258
  throw new DriftReadFailure("read-unsupported", "--stack needs a stack name");
209
259
  if (entry.kind === "chant" && !query.env)
210
260
  throw new DriftReadFailure("env-required", `${query.member} is a chant member, read live through chant lifecycle diff <env> --live: add --env <env>`);
211
- const { registry: kinds, problems } = loadKindRegistry(declaration.pins, located.rootOnDisk);
212
261
  const plan = planMembers("graph", located.rootOnDisk, { only: [query.member], tree: located.tree, kinds, kindProblems: problems.map((p) => p.message) });
213
262
  const notRun = [...plan.unreadable, ...plan.skipped].find((s) => s.name === query.member);
214
263
  if (notRun)
@@ -0,0 +1,60 @@
1
+ /**
2
+ * A kind's drift reader (#5068).
3
+ *
4
+ * A kinds file can name a drift reader module beside its graph reader:
5
+ *
6
+ * ```json
7
+ * "drift": { "reader": "dist/drift-reader.mjs", "config": { "dir": "{dir}", "file": "governance.yml" } }
8
+ * ```
9
+ *
10
+ * `chant workspace drift --member <name>` imports the module for a member of
11
+ * that kind and calls its default export with {@link DriftReaderInput}. It
12
+ * answers as a lexicon's `readDrift` answers `chant lifecycle drift`
13
+ * ({@link DriftReaderOutput}, `ReadDriftResult` in `../drift-record.ts`):
14
+ * the drift stream lines of each read it ran, or a refusal. Its schema is
15
+ * `./drift-reader.schema.json`, `$id` {@link DRIFT_READER_SCHEMA_ID}.
16
+ *
17
+ * The module runs in the process of the chant that reads the workspace, with
18
+ * that process's environment, so a reader that asks a forge brings its own
19
+ * credentials from there. chant makes no call to the forge for it. Each line
20
+ * the module returns is checked with the drift record's codec
21
+ * (`decodeDriftLine`), so a state read that says in-sync, or a not-observed
22
+ * record with no reason, fails the read rather than reaching a renderer.
23
+ */
24
+ import { type DriftRead, type ReadDriftResult } from "../drift-record.js";
25
+ /** The schema a drift reader's output holds to. */
26
+ export declare const DRIFT_READER_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/drift-reader/v1/drift-reader.schema.json";
27
+ /** What a drift reader module's default export is called with. */
28
+ export interface DriftReaderInput {
29
+ /** The member's directory, absolute: the kind config's `dir` when it sets one as a string, else the member's own directory. */
30
+ dir: string;
31
+ /** The kind's `drift.config`, with `{member}`, `{dir}` and `{workspace}` substituted. */
32
+ config: Record<string, unknown>;
33
+ /** The workspace member the records are for. chant puts this name on every line whatever the reader writes. */
34
+ member: string;
35
+ /** RFC 3339, the `observedAt` to give every record the reader builds. */
36
+ observedAt: string;
37
+ /** `--read`, when given. Unset, the reader's default read. */
38
+ read?: DriftRead;
39
+ /** `--resource`, when given: one address to read. */
40
+ resource?: string;
41
+ /** `--stack`, when given. */
42
+ stack?: string;
43
+ }
44
+ /** What a drift reader module returns: the same answer as a lexicon's `readDrift`. */
45
+ export type DriftReaderOutput = ReadDriftResult;
46
+ /** A drift reader module's default export. */
47
+ export type DriftReader = (input: DriftReaderInput) => DriftReaderOutput | Promise<DriftReaderOutput>;
48
+ /**
49
+ * Check what a reader returned: each line through the drift codec, a
50
+ * refusal's code against the closed list. `error` says why it is not an
51
+ * answer.
52
+ */
53
+ export declare function checkDriftReaderOutput(out: unknown): DriftReaderOutput | {
54
+ error: string;
55
+ };
56
+ /** Import the module and call it, or say why not. Never throws. */
57
+ export declare function readDriftWithModule(module: string, input: DriftReaderInput): Promise<DriftReaderOutput | {
58
+ error: string;
59
+ }>;
60
+ //# sourceMappingURL=drift-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drift-reader.d.ts","sourceRoot":"","sources":["../../src/workspace/drift-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EAAmC,KAAK,SAAS,EAA6B,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEnI,mDAAmD;AACnD,eAAO,MAAM,sBAAsB,0FAA0F,CAAC;AAE9H,kEAAkE;AAClE,MAAM,WAAW,gBAAgB;IAC/B,+HAA+H;IAC/H,GAAG,EAAE,MAAM,CAAC;IACZ,yFAAyF;IACzF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,+GAA+G;IAC/G,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,sFAAsF;AACtF,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEhD,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAMtG;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAmB1F;AAED,mEAAmE;AACnE,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAiBjI"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * A kind's drift reader (#5068).
3
+ *
4
+ * A kinds file can name a drift reader module beside its graph reader:
5
+ *
6
+ * ```json
7
+ * "drift": { "reader": "dist/drift-reader.mjs", "config": { "dir": "{dir}", "file": "governance.yml" } }
8
+ * ```
9
+ *
10
+ * `chant workspace drift --member <name>` imports the module for a member of
11
+ * that kind and calls its default export with {@link DriftReaderInput}. It
12
+ * answers as a lexicon's `readDrift` answers `chant lifecycle drift`
13
+ * ({@link DriftReaderOutput}, `ReadDriftResult` in `../drift-record.ts`):
14
+ * the drift stream lines of each read it ran, or a refusal. Its schema is
15
+ * `./drift-reader.schema.json`, `$id` {@link DRIFT_READER_SCHEMA_ID}.
16
+ *
17
+ * The module runs in the process of the chant that reads the workspace, with
18
+ * that process's environment, so a reader that asks a forge brings its own
19
+ * credentials from there. chant makes no call to the forge for it. Each line
20
+ * the module returns is checked with the drift record's codec
21
+ * (`decodeDriftLine`), so a state read that says in-sync, or a not-observed
22
+ * record with no reason, fails the read rather than reaching a renderer.
23
+ */
24
+ import { isAbsolute } from "node:path";
25
+ import { pathToFileURL } from "node:url";
26
+ import { decodeDriftLine } from "../drift-record.js";
27
+ /** The schema a drift reader's output holds to. */
28
+ export const DRIFT_READER_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/drift-reader/v1/drift-reader.schema.json";
29
+ const REFUSAL_CODES = ["read-unsupported", "resource-unsupported", "no-drift-read"];
30
+ const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
31
+ /**
32
+ * Check what a reader returned: each line through the drift codec, a
33
+ * refusal's code against the closed list. `error` says why it is not an
34
+ * answer.
35
+ */
36
+ export function checkDriftReaderOutput(out) {
37
+ if (!isObject(out))
38
+ return { error: "returned something that is not an object with lines or refused" };
39
+ if ("refused" in out) {
40
+ const refused = out.refused;
41
+ if (!isObject(refused) || !REFUSAL_CODES.includes(refused.code) || typeof refused.message !== "string" || refused.message === "") {
42
+ return { error: `returned a refusal that is not { code: ${REFUSAL_CODES.join(" | ")}, message }` };
43
+ }
44
+ return { refused: { code: refused.code, message: refused.message } };
45
+ }
46
+ if (!Array.isArray(out.lines))
47
+ return { error: "returned something with no lines array and no refusal" };
48
+ const lines = [];
49
+ for (const [i, line] of out.lines.entries()) {
50
+ try {
51
+ lines.push(decodeDriftLine(JSON.stringify(line)));
52
+ }
53
+ catch (err) {
54
+ return { error: `returned a line ${i} that is not drift: ${err instanceof Error ? err.message : String(err)}` };
55
+ }
56
+ }
57
+ return { lines };
58
+ }
59
+ /** Import the module and call it, or say why not. Never throws. */
60
+ export async function readDriftWithModule(module, input) {
61
+ if (!isAbsolute(module))
62
+ return { error: `drift reader ${module} must be an absolute path` };
63
+ let read;
64
+ try {
65
+ read = (await import(pathToFileURL(module).href)).default;
66
+ }
67
+ catch (err) {
68
+ return { error: `drift reader ${module} could not be loaded: ${err instanceof Error ? err.message : String(err)}` };
69
+ }
70
+ if (typeof read !== "function")
71
+ return { error: `drift reader ${module} has no default export function` };
72
+ let out;
73
+ try {
74
+ out = await read(input);
75
+ }
76
+ catch (err) {
77
+ return { error: `drift reader ${module} failed: ${err instanceof Error ? err.message : String(err)}` };
78
+ }
79
+ const checked = checkDriftReaderOutput(out);
80
+ return "error" in checked ? { error: `drift reader ${module} ${checked.error}` } : checked;
81
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://intentius.io/chant/schemas/workspace/drift-reader/v1/drift-reader.schema.json",
4
+ "title": "drift reader output",
5
+ "description": "What a kind's drift reader module returns (#5068), the same answer a lexicon's readDrift gives chant lifecycle drift (ReadDriftResult in @intentius/chant/drift-record, DriftReaderOutput in @intentius/chant/workspace/drift-reader). Either the lines of each read the reader ran, in order, as the drift record's NDJSON stream has them (a drift-start, its drift-record lines and a drift-settle per read, each line one of drift.schema.json's $defs/line), or a refusal with a code chant workspace drift prints. A read that ran and failed is not a refusal: its addresses are records with status not-observed. chant workspace drift renames every line's member to the workspace member and places each record on the member's graph. First read by chant 0.124.96.",
6
+ "oneOf": [
7
+ {
8
+ "type": "object",
9
+ "required": ["lines"],
10
+ "properties": {
11
+ "lines": {
12
+ "type": "array",
13
+ "items": {
14
+ "$ref": "https://intentius.io/chant/schemas/workspace/drift/v1/drift.schema.json#/$defs/line"
15
+ },
16
+ "description": "The stream lines, in order. An empty list is a read that found nothing to report."
17
+ }
18
+ },
19
+ "additionalProperties": false
20
+ },
21
+ {
22
+ "type": "object",
23
+ "required": ["refused"],
24
+ "properties": {
25
+ "refused": {
26
+ "type": "object",
27
+ "required": ["code", "message"],
28
+ "properties": {
29
+ "code": {
30
+ "enum": ["read-unsupported", "resource-unsupported", "no-drift-read"],
31
+ "description": "read-unsupported for a --read or --stack the reader has not got, resource-unsupported for --resource on a reader that cannot read one resource on its own, no-drift-read when there is nothing to read (ReadDriftRefusalCode)."
32
+ },
33
+ "message": {
34
+ "type": "string",
35
+ "minLength": 1
36
+ }
37
+ },
38
+ "additionalProperties": false
39
+ }
40
+ },
41
+ "additionalProperties": false
42
+ }
43
+ ]
44
+ }
@@ -144,6 +144,19 @@ export interface KindGraph {
144
144
  readerFile?: string;
145
145
  config: Record<string, unknown>;
146
146
  }
147
+ /**
148
+ * How `chant workspace drift --member` reads a member of a package's kind
149
+ * (#5068): a drift reader module the package ships, and the config it is
150
+ * called with. See `./drift-reader.ts` for the contract and
151
+ * {@link substituteGraphConfig} for the placeholders.
152
+ */
153
+ export interface KindDrift {
154
+ /** The drift reader module, as the kinds file names it: a path inside the supplying package. */
155
+ reader: string;
156
+ /** The reader module, absolute; set once the package directory is known. */
157
+ readerFile?: string;
158
+ config: Record<string, unknown>;
159
+ }
147
160
  export interface MemberKind {
148
161
  name: string;
149
162
  /** One line for listings and error messages. */
@@ -165,6 +178,8 @@ export interface MemberKind {
165
178
  packageDir?: string;
166
179
  /** How `workspace graph` reads a member of this kind (#2874); unset, the member is `kind-not-run`. */
167
180
  graph?: KindGraph;
181
+ /** How `workspace drift` reads a member of this kind (#5068); unset, the member answers `no-drift-read` unless chant reads its kind itself. */
182
+ drift?: KindDrift;
168
183
  /** The fields a member entry of this kind may set, with their defaults (#3151); unset, the kind declares none. */
169
184
  fields?: Record<string, KindField>;
170
185
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../../src/workspace/kinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG5C,OAAO,EAAmC,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAIrF,eAAO,MAAM,eAAe,QAAa,CAAC;AAE1C,oDAAoD;AACpD,eAAO,MAAM,aAAa,sBAAsB,CAAC;AAEjD;;;;;;GAMG;AACH,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AyCnD,sGAAsG;AACtG,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,uIAAuI;IACvI,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IACrF,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,YAAY,CAsCrH"}
@@ -351,6 +351,7 @@ export function parseKindData(text, source) {
351
351
  ...(k.graph
352
352
  ? { graph: { ...(k.graph.lexicon ? { lexicon: k.graph.lexicon } : {}), ...(k.graph.reader ? { reader: k.graph.reader } : {}), config: structuredClone(k.graph.config ?? {}) } }
353
353
  : {}),
354
+ ...(k.drift ? { drift: { reader: k.drift.reader, config: structuredClone(k.drift.config ?? {}) } } : {}),
354
355
  ...(k.fields ? { fields: structuredClone(k.fields) } : {}),
355
356
  ...(k.reader && KIND_LINK_READERS.includes(k.reader) ? { reader: k.reader } : {}),
356
357
  ...(k.memberFile ? { memberFile: { path: k.memberFile.path, schema: k.memberFile.schema } } : {}),
@@ -430,6 +431,22 @@ export function readPackageKinds(packageDir, source) {
430
431
  `and this package is ${packageName ?? "unnamed"}; the kind is kept, and workspace graph lists its members with kind-not-run`);
431
432
  delete k.graph;
432
433
  }
434
+ if (k.drift) {
435
+ // A drift reader module (#5068) is the package's own file, like a graph reader: inside the package and present. Nothing is imported here.
436
+ const file = resolve(packageDir, ...k.drift.reader.split("/"));
437
+ const inside = relative(packageDir, file);
438
+ if (inside.startsWith("..") || isAbsolute(inside)) {
439
+ data.problems.push(`${name}: kind ${k.name} names drift reader ${k.drift.reader}, which is outside the package; the kind is kept, and workspace drift answers no-drift-read for its members`);
440
+ delete k.drift;
441
+ }
442
+ else if (!existsSync(file)) {
443
+ data.problems.push(`${name}: kind ${k.name} names drift reader ${k.drift.reader}, which does not exist in the package; the kind is kept, and workspace drift answers no-drift-read for its members`);
444
+ delete k.drift;
445
+ }
446
+ else {
447
+ k.drift.readerFile = file;
448
+ }
449
+ }
433
450
  }
434
451
  return { ...data, file };
435
452
  }
@@ -76,6 +76,9 @@
76
76
  "graph": {
77
77
  "$ref": "#/$defs/graph"
78
78
  },
79
+ "drift": {
80
+ "$ref": "#/$defs/drift"
81
+ },
79
82
  "fields": {
80
83
  "$ref": "#/$defs/fields"
81
84
  },
@@ -265,6 +268,26 @@
265
268
  },
266
269
  "additionalProperties": false
267
270
  },
271
+ "drift": {
272
+ "type": "object",
273
+ "description": "How chant workspace drift --member reads a member of this kind (#5068): a drift reader module the supplying package ships, called with the member's directory and config. In every string key and value of config, {member} becomes the member's name, {dir} its absolute directory and {workspace} the absolute workspace root, as in graph. Without this field a member of the kind answers no-drift-read. A chant older than this field can't read a kinds file that uses it.",
274
+ "required": ["reader"],
275
+ "properties": {
276
+ "reader": {
277
+ "type": "string",
278
+ "pattern": "^(?!/)(?!.*\\.\\.)(?!.*\\\\)[^\\u0000-\\u001f]+$",
279
+ "description": "A drift reader module, as a path inside the supplying package: an ES module whose default export is (input: { dir, config, member, observedAt, read?, resource?, stack? }) => DriftReaderOutput, sync or async, the lines of each read it ran or a refusal (drift-reader.schema.json). chant workspace drift imports it in its own process, with the process's environment, so the reader brings its own credentials; chant makes no call of its own for it."
280
+ },
281
+ "config": {
282
+ "type": "object",
283
+ "description": "The config object the module is called with (optional). Placeholders are substituted; nothing else is interpreted."
284
+ }
285
+ },
286
+ "patternProperties": {
287
+ "^x-": true
288
+ },
289
+ "additionalProperties": false
290
+ },
268
291
  "fields": {
269
292
  "type": "object",
270
293
  "description": "The fields a member entry of this kind may set under its own fields block, each with a type and, optionally, a default (#3151). chant workspace check fails a member whose fields name one the kind doesn't declare or give a value of the wrong type (WSP005), and chant workspace status --json prints every declared field with the defaults filled in. Added by chant 0.103.0; an older chant can't read a kinds file that uses it.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant",
3
- "version": "0.124.95",
3
+ "version": "0.124.96",
4
4
  "description": "Declarative infrastructure-as-code toolkit — TypeScript on Node.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -241,8 +241,9 @@ export const FLOOR_ROWS: readonly FloorRow[] = [
241
241
  { name: "OP_WAVES_REMAINDER_FLOOR", version: "0.124.94", gates: "The first chant whose Op waves keep the record of an apply under an approval themselves (#5047): with `approvals.spend`, `approvals.remainder` writes each change the approved plans make, the commit and the run on the applied line (a split wave's gate job writes it), the job that applies the whole wave or the record job writes how the apply ended, and a wave run again at that commit applies the rest under the same approval when its plans make only changes the stopped apply did not finish; a wave that plans no change closes a stopped apply, and `approvals.spendStanding` spends an approval of the digest a wave its gate let through applies.", issue: "#5047", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/op","@intentius/chant/op/index","@intentius/chant/op/op-waves-remainder","@intentius/chant/release-floors"] },
242
242
  { name: "OP_WAVES_SPLIT_RESUME_FLOOR", version: "0.124.94", gates: "The first chant whose `chant run resume` starts a killed split apply again on GitLab and Forgejo (#5052): under `approvals.remainder` the gate job's applied line names its run there too, GitLab's with the wave's applying and record jobs by name (`retry`), which the resume retries, and Forgejo's with the run's dispatch inputs (`inputs`), which the resume dispatches with, so the new run applies the rest at the same decided head or commit.", issue: "#5052", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/op/op-waves-split-resume","@intentius/chant/release-floors"] },
243
243
  { name: "OP_WAVES_REMAINDER_PARITY_FLOOR", version: "0.124.94", gates: "The first chant whose `approvals.remainder` resumes the waves terragucci's own records resume (#5056): the terraform step gives a live choudoufu root's plan (`live-plan-set`) its `resourceDigests`, so its applied line names the changes, and the cover leaves out the cost member `(monthly cost)`, whose digest follows from the plans, on both sides.", issue: "#5056", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/op/op-waves-remainder","@intentius/chant/release-floors"] },
244
- { name: "OP_WAVES_CONTROL_BEFORE_MERGE_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose Op waves generators, in a product's workflow (`runIf`) with `beforeMerge` and a spec `control`, run the control job on the default branch's push, outside the product's `runIf` and after its `firstWaveNeeds` jobs, and tell the control repo the waves applied at the pushed commit without adding up outcomes, on GitHub, Forgejo and GitLab (#5060).", issue: "#5060", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
245
- { name: "WAVES_BEFORE_MERGE_LOCKS_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose waves before merge lock and unlock on a comment by the product plan's reach line (#5061): with `wavesBeforeMerge` and `productPlan.reach`, and no `locks: \"plan\"`, the comment job (GitHub, Forgejo) and the note poll (GitLab, `chantNoteRuns`) answer `/<product> lock` on an open pull request by taking the locks of what the reach line prints at stage `apply` in `_locks/<reach.gate>.json` without applying (`decideLocksBeforeMerge`), refused with the holder named, and `/<product> unlock` by releasing the pull request's locks; and the product plan takes `reach` without `locks: \"plan\"` under `wavesBeforeMerge`, writing no reach lock job.", issue: "#5061", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/release-floors"] },
244
+ { name: "OP_WAVES_CONTROL_BEFORE_MERGE_FLOOR", version: "0.124.95", gates: "The first chant whose Op waves generators, in a product's workflow (`runIf`) with `beforeMerge` and a spec `control`, run the control job on the default branch's push, outside the product's `runIf` and after its `firstWaveNeeds` jobs, and tell the control repo the waves applied at the pushed commit without adding up outcomes, on GitHub, Forgejo and GitLab (#5060).", issue: "#5060", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
245
+ { name: "WAVES_BEFORE_MERGE_LOCKS_FLOOR", version: "0.124.95", gates: "The first chant whose waves before merge lock and unlock on a comment by the product plan's reach line (#5061): with `wavesBeforeMerge` and `productPlan.reach`, and no `locks: \"plan\"`, the comment job (GitHub, Forgejo) and the note poll (GitLab, `chantNoteRuns`) answer `/<product> lock` on an open pull request by taking the locks of what the reach line prints at stage `apply` in `_locks/<reach.gate>.json` without applying (`decideLocksBeforeMerge`), refused with the holder named, and `/<product> unlock` by releasing the pull request's locks; and the product plan takes `reach` without `locks: \"plan\"` under `wavesBeforeMerge`, writing no reach lock job.", issue: "#5061", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/release-floors"] },
246
+ { name: "KIND_DRIFT_READER_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose kinds file takes `drift: { reader, config }` beside `graph` and whose `chant workspace drift --member` reads a member of such a kind with that module, `(input: { dir, config, member, observedAt, read?, resource?, stack? }) => DriftReaderOutput` from `@intentius/chant/workspace/drift-reader`, checked against `drift-reader.schema.json` (#5068).", issue: "#5068", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
246
247
  { name: "GITLAB_WAVE_EVIDENCE_RETRY_FLOOR", version: "0.124.89", gates: "The first chant whose `chant run resume` (`resumeGateRun`) on GitLab retries a wave job's `<wave job>-evidence` with the wave job when the evidence job already ran, and whose `ci evidence sign --from-job` waits for a job it reads to finish, so a resumed wave's evidence job signs from the new try (#4978).", issue: "#4978", file: "release-floors.ts", modules: ["@intentius/chant/ci-evidence-jobs","@intentius/chant/release-floors"] },
247
248
  { name: "TERRAFORM_COMMAND_TRACE_FLOOR", version: "0.124.91", gates: "The first chant whose terraform lexicon's engine runs carry what a product's own command tracing read: `runBinary` and the engine runner's `exec` and `execSync` answer stderr apart (`Ran.stderr`) and a spawn failure's message (`Ran.error`), a hook's `after` gets a binary that could not be started as a null code with `error`, `commandTrace` ends that span with the message, and `composeCommandHooks` runs a product's own hook and `commandTrace` as one `onCommand` (#5007).", issue: "#5007", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
248
249
  { name: "RUN_EVENT_FLOOR", version: "0.124.28", gates: "The first chant that writes contract version 1 of the run-event stream.", file: "run-event.ts", modules: ["@intentius/chant","@intentius/chant/index","@intentius/chant/run-event"] },
@@ -19,7 +19,7 @@
19
19
  * this constant to the next patch (#4501). The check fails while a floor
20
20
  * still names this constant after its version shipped.
21
21
  */
22
- export const NEXT_RELEASE = "0.124.95";
22
+ export const NEXT_RELEASE = "0.124.96";
23
23
 
24
24
  /** The first chant with `chant dev local` and `chant dev bundle-check`, `@intentius/chant/local-chant` and `@intentius/chant/bundle-check` (`chantRuntimeTarget`, `chantExternalPlugin`, `checkBundle`): a product built against a chant checkout, and its bundle checked, without its own scripts (#4787). */
25
25
  export const LOCAL_CHANT_FLOOR = "0.124.86";
@@ -247,10 +247,13 @@ export const OP_WAVES_SPLIT_RESUME_FLOOR = "0.124.94";
247
247
  export const OP_WAVES_REMAINDER_PARITY_FLOOR = "0.124.94";
248
248
 
249
249
  /** The first chant whose Op waves generators, in a product's workflow (`runIf`) with `beforeMerge` and a spec `control`, run the control job on the default branch's push, outside the product's `runIf` and after its `firstWaveNeeds` jobs, and tell the control repo the waves applied at the pushed commit without adding up outcomes, on GitHub, Forgejo and GitLab (#5060). */
250
- export const OP_WAVES_CONTROL_BEFORE_MERGE_FLOOR = NEXT_RELEASE;
250
+ export const OP_WAVES_CONTROL_BEFORE_MERGE_FLOOR = "0.124.95";
251
251
 
252
252
  /** The first chant whose waves before merge lock and unlock on a comment by the product plan's reach line (#5061): with `wavesBeforeMerge` and `productPlan.reach`, and no `locks: "plan"`, the comment job (GitHub, Forgejo) and the note poll (GitLab, `chantNoteRuns`) answer `/<product> lock` on an open pull request by taking the locks of what the reach line prints at stage `apply` in `_locks/<reach.gate>.json` without applying (`decideLocksBeforeMerge`), refused with the holder named, and `/<product> unlock` by releasing the pull request's locks; and the product plan takes `reach` without `locks: "plan"` under `wavesBeforeMerge`, writing no reach lock job. */
253
- export const WAVES_BEFORE_MERGE_LOCKS_FLOOR = NEXT_RELEASE;
253
+ export const WAVES_BEFORE_MERGE_LOCKS_FLOOR = "0.124.95";
254
+
255
+ /** The first chant whose kinds file takes `drift: { reader, config }` beside `graph` and whose `chant workspace drift --member` reads a member of such a kind with that module, `(input: { dir, config, member, observedAt, read?, resource?, stack? }) => DriftReaderOutput` from `@intentius/chant/workspace/drift-reader`, checked against `drift-reader.schema.json` (#5068). */
256
+ export const KIND_DRIFT_READER_FLOOR = NEXT_RELEASE;
254
257
 
255
258
  /** The first chant whose `chant run resume` (`resumeGateRun`) on GitLab retries a wave job's `<wave job>-evidence` with the wave job when the evidence job already ran, and whose `ci evidence sign --from-job` waits for a job it reads to finish, so a resumed wave's evidence job signs from the new try (#4978). */
256
259
  export const GITLAB_WAVE_EVIDENCE_RETRY_FLOOR = "0.124.89";
@@ -21,6 +21,15 @@
21
21
  * falls back to another stack's export or the checked-in file. Any other kind
22
22
  * answers `read-unsupported`.
23
23
  *
24
+ * A member of a package's kind whose kinds file names a drift reader
25
+ * (`drift.reader`, #5068) is read by that module instead (`./drift-reader.ts`):
26
+ * chant imports it in this process, with this process's environment, calls
27
+ * it with the member's directory, the kind's config (placeholders
28
+ * substituted), `--read`, `--resource` and `--stack`, and checks each line
29
+ * it returns with the drift codec. The reader answers for itself, refusals
30
+ * included; chant makes no forge call for it. A declared drift reader comes
31
+ * before the table above.
32
+ *
24
33
  * Any other kind has no drift read and answers `no-drift-read`. A member of
25
34
  * a package's kind runs in the reader project `workspace graph` writes for it
26
35
  * (`./kind-readers.ts`), under the member's own toolchain, so chant core
@@ -42,7 +51,7 @@
42
51
  */
43
52
 
44
53
  import { existsSync } from "node:fs";
45
- import { resolve } from "node:path";
54
+ import { join, resolve } from "node:path";
46
55
  import { formatError } from "../cli/format";
47
56
  import type { CommandContext, ParsedArgs } from "../cli/registry";
48
57
  import { graphNodeFor, type ChangeSetGraphNodes } from "../change-set-graph";
@@ -69,8 +78,10 @@ import {
69
78
  } from "../drift-record";
70
79
  import type { ComponentStatusRow } from "../lifecycle/status";
71
80
  import { readDeclaration, readerVersion, WORKSPACE_ERROR_CODES, WorkspaceReadError } from "./declaration";
81
+ import { readDriftWithModule } from "./drift-reader";
72
82
  import { prepareKindReaders } from "./kind-readers";
73
- import { loadKindRegistry } from "./kinds";
83
+ import { loadKindRegistry, substituteGraphConfig, type KindDrift, type KindRegistry } from "./kinds";
84
+ import { memberReason } from "./ls";
74
85
  import { emitDocument, executePlan, planMembers, type UnitResult } from "./member-commands";
75
86
  import type { ReasonCode } from "./reason-codes";
76
87
  import { handToRootChant, locateWorkspace } from "./which-chant";
@@ -156,6 +167,33 @@ function tail(text: string): string {
156
167
  return text.trim().split("\n").slice(-5).join("\n");
157
168
  }
158
169
 
170
+ /** Read a member through its kind's drift reader module (#5068): the lines it returns, checked, or a failure. */
171
+ async function kindReaderLines(query: DriftQuery, entry: { name: string; dir: string; kind: string }, drift: KindDrift, root: string): Promise<DriftLine[]> {
172
+ if (query.read !== undefined && !(DRIFT_READS as readonly string[]).includes(query.read)) {
173
+ throw new DriftReadFailure("read-unsupported", `--read ${query.read} is not a drift read; the reads are ${DRIFT_READS.join(", ")}`);
174
+ }
175
+ const abs = entry.dir === "." ? root : join(root, entry.dir);
176
+ const config = substituteGraphConfig(drift.config, { member: entry.name, dir: abs, workspace: root });
177
+ const answer = await readDriftWithModule(drift.readerFile!, {
178
+ dir: typeof config.dir === "string" ? config.dir : abs,
179
+ config,
180
+ member: entry.name,
181
+ observedAt: new Date().toISOString(),
182
+ ...(query.read !== undefined ? { read: query.read as DriftRead } : {}),
183
+ ...(query.resource !== undefined ? { resource: query.resource } : {}),
184
+ ...(query.stack !== undefined ? { stack: query.stack } : {}),
185
+ });
186
+ if ("error" in answer) throw new DriftReadFailure("command-failed", `${query.member}: ${answer.error}`);
187
+ if ("refused" in answer) throw new DriftReadFailure(answer.refused.code, `${query.member}: ${answer.refused.message}`);
188
+ return answer.lines;
189
+ }
190
+
191
+ /** The kinds `workspace drift` reads, for the no-drift-read message: the table's, and each loaded kind with a drift reader. */
192
+ function driftKinds(kinds: KindRegistry): string {
193
+ const readers = kinds.names().filter((k) => kinds.get(k)?.drift?.readerFile && !DRIFT_READS_BY_KIND[k]);
194
+ return [...Object.keys(DRIFT_READS_BY_KIND), ...readers].join(", ");
195
+ }
196
+
159
197
  /** The member's node ids, without the member in front, from its source graph; null when it can't be read. */
160
198
  async function memberGraph(cwd: string, member: string): Promise<ChangeSetGraphNodes | null> {
161
199
  try {
@@ -246,8 +284,20 @@ export async function readWorkspaceDrift(query: DriftQuery): Promise<DriftReadRe
246
284
  if (!entry) {
247
285
  throw new DriftReadFailure("member-required", `--member ${query.member} is not a member of ${declaration.name}; it declares ${declaration.members.map((m) => m.name).join(", ")}`);
248
286
  }
287
+ const { registry: kinds, problems } = loadKindRegistry(declaration.pins, located.rootOnDisk);
288
+ const drift = kinds.get(entry.kind)?.drift;
289
+ if (drift?.readerFile) {
290
+ // A kind's own drift reader (#5068), imported here: no reader project, and the member's graph places its records as for any member.
291
+ const reason = memberReason(entry, located.tree, kinds);
292
+ if (reason) throw new DriftReadFailure("command-failed", `${query.member}: ${reason.code}: ${reason.message}`);
293
+ const [graph, lines] = await Promise.all([memberGraph(query.cwd, query.member), kindReaderLines(query, entry, drift, located.rootOnDisk)]);
294
+ return { lines: placeLines(lines, query.member, graph) };
295
+ }
249
296
  const reads = DRIFT_READS_BY_KIND[entry.kind];
250
- if (!reads) throw new DriftReadFailure("no-drift-read", `${query.member} is kind ${entry.kind}, and chant workspace drift reads members of kind ${Object.keys(DRIFT_READS_BY_KIND).join(", ")}`);
297
+ if (!reads) {
298
+ const problem = problems.find((p) => p.message.includes(`kind ${entry.kind} names drift reader`));
299
+ throw new DriftReadFailure("no-drift-read", `${query.member} is kind ${entry.kind}, and chant workspace drift reads members of kind ${driftKinds(kinds)}${problem ? `; ${problem.message}` : ""}`);
300
+ }
251
301
  if (query.read !== undefined && !(DRIFT_READS as readonly string[]).includes(query.read)) {
252
302
  throw new DriftReadFailure("read-unsupported", `--read ${query.read} is not a drift read; the reads are ${DRIFT_READS.join(", ")}`);
253
303
  }
@@ -262,7 +312,6 @@ export async function readWorkspaceDrift(query: DriftQuery): Promise<DriftReadRe
262
312
  if (query.stack !== undefined && query.stack.trim() === "") throw new DriftReadFailure("read-unsupported", "--stack needs a stack name");
263
313
  if (entry.kind === "chant" && !query.env) throw new DriftReadFailure("env-required", `${query.member} is a chant member, read live through chant lifecycle diff <env> --live: add --env <env>`);
264
314
 
265
- const { registry: kinds, problems } = loadKindRegistry(declaration.pins, located.rootOnDisk);
266
315
  const plan = planMembers("graph", located.rootOnDisk, { only: [query.member], tree: located.tree, kinds, kindProblems: problems.map((p) => p.message) });
267
316
  const notRun = [...plan.unreadable, ...plan.skipped].find((s) => s.name === query.member);
268
317
  if (notRun) throw new DriftReadFailure(plan.unreadable.includes(notRun) ? "command-failed" : "no-drift-read", `${query.member}: ${notRun.reason.code}: ${notRun.reason.message}`);