@procedures/dag 0.3.0 → 0.4.0

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.
package/dist/index.d.ts CHANGED
@@ -39,4 +39,7 @@
39
39
  */
40
40
  export type { DAGNode, DependencyDAG, DAGExecutionOptions, NodeResult, DAGResult, NodeProcessor, } from "./types.js";
41
41
  export { buildLeveledDAG, getTopologicalOrder, visualizeDAG, executeDAG, executeDAGSequential, createProcessor, filterDAGFromRoot, getAncestors, getDescendants, createNode, buildNodeMap, } from "./dag/index.js";
42
+ export * from "./module.js";
43
+ export { DagTraverseInputSchema, DagTraverseOutputSchema, type DagTraverseInput, type DagTraverseOutput, type TraverseNodeResult, type ScannedPackage, type ScanOutput, type PackageNode, } from "./procedures/types.js";
44
+ export { dagTraverse, packageNodes, callsGit, keyedLock, repositoryRoot } from "./procedures/traverse.js";
42
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAGH,YAAY,EACV,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,UAAU,EACV,YAAY,GACb,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAGH,YAAY,EACV,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,UAAU,EACV,YAAY,GACb,MAAM,gBAAgB,CAAC;AAIxB,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -39,4 +39,9 @@
39
39
  */
40
40
  // DAG utilities
41
41
  export { buildLeveledDAG, getTopologicalOrder, visualizeDAG, executeDAG, executeDAGSequential, createProcessor, filterDAGFromRoot, getAncestors, getDescendants, createNode, buildNodeMap, } from "./dag/index.js";
42
+ // The procedure dag.traverse. The root registers nothing: import "@procedures/dag/register", or
43
+ // give the module to createRegistry() with the module of @procedures/lib.
44
+ export * from "./module.js";
45
+ export { DagTraverseInputSchema, DagTraverseOutputSchema, } from "./procedures/types.js";
46
+ export { dagTraverse, packageNodes, callsGit, keyedLock, repositoryRoot } from "./procedures/traverse.js";
42
47
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAYH,gBAAgB;AAChB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,UAAU,EACV,YAAY,GACb,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAYH,gBAAgB;AAChB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,UAAU,EACV,YAAY,GACb,MAAM,gBAAgB,CAAC;AAExB,gGAAgG;AAChG,0EAA0E;AAC1E,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GAOxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Module (no side effects): the procedures of this package as data, for `createRegistry()`.
3
+ *
4
+ * The package has one procedure, `dag.traverse`. It came from `@procedures/lib`, and its name
5
+ * stays the same. The graph algorithms of the package root do not need this module.
6
+ */
7
+ import { type ProcedureModule, type ProcedureRegistry } from "@procedures/client";
8
+ /**
9
+ * The module of this package, for `createRegistry()`: its procedures as data. Importing this
10
+ * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
11
+ *
12
+ * `dag.traverse` uses `lib.scan`. This module cannot list the module of `@procedures/lib` as a
13
+ * dependency, because that package depends on this one. A host registers both modules
14
+ * (`bundle-dev`, `bundle-mcp` and `mark` do).
15
+ */
16
+ export declare const dagModule: ProcedureModule;
17
+ export default dagModule;
18
+ /**
19
+ * This function registers the procedures of @procedures/dag in a registry. The default is the
20
+ * global registry. Importing this file registers nothing: the `./register` entry starts this
21
+ * function (ARCHITECTURE-PROPOSALS-2026-10, P9).
22
+ */
23
+ export declare function registerDagProcedures(registry?: ProcedureRegistry): void;
24
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAQL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAuC5B;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,EAAE,eAAyE,CAAC;eAEnF,SAAS;AAExB;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,GAAE,iBAAsC,GAAG,IAAI,CAE5F"}
package/dist/module.js ADDED
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Module (no side effects): the procedures of this package as data, for `createRegistry()`.
3
+ *
4
+ * The package has one procedure, `dag.traverse`. It came from `@procedures/lib`, and its name
5
+ * stays the same. The graph algorithms of the package root do not need this module.
6
+ */
7
+ import { createProcedure, zodAdapter, RUNS_REFS_TAG, defineModule, PROCEDURE_REGISTRY, registerModules, } from "@procedures/client";
8
+ import { dagTraverse } from "./procedures/traverse.js";
9
+ import { DagTraverseInputSchema, DagTraverseOutputSchema, } from "./procedures/types.js";
10
+ // =============================================================================
11
+ // dag.* Procedures
12
+ // =============================================================================
13
+ const dagTraverseProcedure = createProcedure()
14
+ .path(["dag", "traverse"])
15
+ .input(zodAdapter(DagTraverseInputSchema))
16
+ .output(zodAdapter(DagTraverseOutputSchema))
17
+ .meta({
18
+ description: "Traverse ecosystem packages in dependency order, executing visit procedure for each",
19
+ // It runs the procedure refs of its input: a server with an expose rule limits what they call
20
+ tags: [RUNS_REFS_TAG],
21
+ // It gets the packages from lib.scan (@procedures/lib). This package cannot import that one,
22
+ // because @procedures/lib depends on this package.
23
+ calls: ["lib.scan"],
24
+ // Its own effect is the scan of the workspace. The admission examines each visit call.
25
+ effects: { reads: ["fs"], writes: [] },
26
+ args: [],
27
+ shorts: { root: "r", concurrency: "j", continueOnError: "c", dryRun: "d" },
28
+ output: "streaming",
29
+ })
30
+ .handler(async (input, ctx) => {
31
+ return dagTraverse(input, ctx);
32
+ })
33
+ .build();
34
+ // =============================================================================
35
+ // Registration
36
+ // =============================================================================
37
+ /**
38
+ * The module of this package, for `createRegistry()`: its procedures as data. Importing this
39
+ * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
40
+ *
41
+ * `dag.traverse` uses `lib.scan`. This module cannot list the module of `@procedures/lib` as a
42
+ * dependency, because that package depends on this one. A host registers both modules
43
+ * (`bundle-dev`, `bundle-mcp` and `mark` do).
44
+ */
45
+ export const dagModule = defineModule("@procedures/dag", [dagTraverseProcedure]);
46
+ export default dagModule;
47
+ /**
48
+ * This function registers the procedures of @procedures/dag in a registry. The default is the
49
+ * global registry. Importing this file registers nothing: the `./register` entry starts this
50
+ * function (ARCHITECTURE-PROPOSALS-2026-10, P9).
51
+ */
52
+ export function registerDagProcedures(registry = PROCEDURE_REGISTRY) {
53
+ registerModules(registry, [dagModule]);
54
+ }
55
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,eAAe,EACf,UAAU,EACV,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,eAAe,GAIhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GAGxB,MAAM,uBAAuB,CAAC;AAE/B,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF,MAAM,oBAAoB,GAAG,eAAe,EAAE;KAC3C,IAAI,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;KACzB,KAAK,CAAC,UAAU,CAAmB,sBAAsB,CAAC,CAAC;KAC3D,MAAM,CAAC,UAAU,CAAoB,uBAAuB,CAAC,CAAC;KAC9D,IAAI,CAAC;IACJ,WAAW,EAAE,qFAAqF;IAClG,8FAA8F;IAC9F,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,6FAA6F;IAC7F,mDAAmD;IACnD,KAAK,EAAE,CAAC,UAAU,CAAC;IACnB,uFAAuF;IACvF,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;IACtC,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAC1E,MAAM,EAAE,WAAW;CACpB,CAAC;KACD,OAAO,CAAC,KAAK,EAAE,KAAuB,EAAE,GAAqB,EAA8B,EAAE;IAC5F,OAAO,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC,CAAC;KACD,KAAK,EAAE,CAAC;AAEX,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAoB,YAAY,CAAC,iBAAiB,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAElG,eAAe,SAAS,CAAC;AAEzB;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAQ,GAAsB,kBAAkB;IACpF,eAAe,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * dag.traverse procedure
3
+ *
4
+ * General-purpose DAG traversal that executes a visit procedure
5
+ * for each node in dependency order.
6
+ *
7
+ * This enables declarative composition of traversals:
8
+ * ```typescript
9
+ * // Execute git add on all packages (using $when: "$parent")
10
+ * await client.exec({
11
+ * $proc: ["dag", "traverse"],
12
+ * input: {
13
+ * visit: {
14
+ * $proc: ["git", "add"],
15
+ * input: { all: true },
16
+ * $when: "$parent" // Defer to dag.traverse
17
+ * }
18
+ * }
19
+ * });
20
+ *
21
+ * // Simple form with just procedure path
22
+ * await client.exec({
23
+ * $proc: ["dag", "traverse"],
24
+ * input: {
25
+ * visit: ["git", "add"]
26
+ * }
27
+ * });
28
+ * ```
29
+ *
30
+ * The `$when` field controls when nested $proc refs are executed:
31
+ * - "$immediate" (default): Execute during hydration
32
+ * - "$parent": Defer to parent procedure (dag.traverse executes per-node)
33
+ * - "$never": Never auto-execute, pass as pure data
34
+ *
35
+ * The procedure gets the packages of the workspace from `lib.scan` of `@procedures/lib`, through
36
+ * `ctx.client`. It does not import that package, because `@procedures/lib` depends on this one.
37
+ * Thus a registry with `dag.traverse` also needs the module of `@procedures/lib`.
38
+ */
39
+ import type { ProcedureContext } from "@procedures/client";
40
+ import type { DagTraverseInput, DagTraverseOutput, PackageNode, ScanOutput } from "./types.js";
41
+ /**
42
+ * This function gives the nodes of the packages of a `lib.scan` output. A dependency on a
43
+ * package that the scan did not find is not an edge.
44
+ */
45
+ export declare function packageNodes(packages: ScanOutput["packages"]): Map<string, PackageNode>;
46
+ /** The folder of the git repository that holds `path` (it has `.git`), or `path` itself. */
47
+ export declare function repositoryRoot(path: string): string;
48
+ /** True when the value names a `git` procedure: a path, or a `$proc` ref at any depth. */
49
+ export declare function callsGit(value: unknown): boolean;
50
+ /**
51
+ * Run the tasks of one key one at a time, in the order of the calls. Tasks of other keys run
52
+ * in parallel.
53
+ */
54
+ export declare function keyedLock(): <T>(key: string, task: () => Promise<T>) => Promise<T>;
55
+ /**
56
+ * Execute a DAG traversal with a custom visit procedure
57
+ *
58
+ * The visits of nodes in one git repository run one at a time when the visit calls git (or
59
+ * with `serialize: "repository"`). All the packages of a workspace share one repository, and
60
+ * concurrent `git add` calls failed on `index.lock` (deep dive DATA-17).
61
+ */
62
+ export declare function dagTraverse(input: DagTraverseInput, ctx: ProcedureContext): Promise<DagTraverseOutput>;
63
+ //# sourceMappingURL=traverse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traverse.d.ts","sourceRoot":"","sources":["../../src/procedures/traverse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,oBAAoB,CAAC;AAE1E,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,UAAU,EAEX,MAAM,YAAY,CAAC;AAQpB;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAWvF;AAED,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED,0FAA0F;AAC1F,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAShD;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAkBlF;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAgL5B"}
@@ -0,0 +1,275 @@
1
+ /**
2
+ * dag.traverse procedure
3
+ *
4
+ * General-purpose DAG traversal that executes a visit procedure
5
+ * for each node in dependency order.
6
+ *
7
+ * This enables declarative composition of traversals:
8
+ * ```typescript
9
+ * // Execute git add on all packages (using $when: "$parent")
10
+ * await client.exec({
11
+ * $proc: ["dag", "traverse"],
12
+ * input: {
13
+ * visit: {
14
+ * $proc: ["git", "add"],
15
+ * input: { all: true },
16
+ * $when: "$parent" // Defer to dag.traverse
17
+ * }
18
+ * }
19
+ * });
20
+ *
21
+ * // Simple form with just procedure path
22
+ * await client.exec({
23
+ * $proc: ["dag", "traverse"],
24
+ * input: {
25
+ * visit: ["git", "add"]
26
+ * }
27
+ * });
28
+ * ```
29
+ *
30
+ * The `$when` field controls when nested $proc refs are executed:
31
+ * - "$immediate" (default): Execute during hydration
32
+ * - "$parent": Defer to parent procedure (dag.traverse executes per-node)
33
+ * - "$never": Never auto-execute, pass as pure data
34
+ *
35
+ * The procedure gets the packages of the workspace from `lib.scan` of `@procedures/lib`, through
36
+ * `ctx.client`. It does not import that package, because `@procedures/lib` depends on this one.
37
+ * Thus a registry with `dag.traverse` also needs the module of `@procedures/lib`.
38
+ */
39
+ import { existsSync } from "node:fs";
40
+ import { dirname, join, resolve } from "node:path";
41
+ import { isAnyProcedureRef, hydrateInput, scopeOf } from "@procedures/client";
42
+ import { buildLeveledDAG, executeDAG, createProcessor, filterDAGFromRoot, } from "../dag/index.js";
43
+ /**
44
+ * This function gives the nodes of the packages of a `lib.scan` output. A dependency on a
45
+ * package that the scan did not find is not an edge.
46
+ */
47
+ export function packageNodes(packages) {
48
+ const nodes = new Map();
49
+ for (const [name, info] of Object.entries(packages)) {
50
+ nodes.set(name, {
51
+ id: name,
52
+ name,
53
+ repoPath: info.repoPath,
54
+ dependencies: info.mark1russell7Deps.filter((dep) => packages[dep] !== undefined),
55
+ });
56
+ }
57
+ return nodes;
58
+ }
59
+ /** The folder of the git repository that holds `path` (it has `.git`), or `path` itself. */
60
+ export function repositoryRoot(path) {
61
+ let current = resolve(path);
62
+ for (;;) {
63
+ if (existsSync(join(current, ".git")))
64
+ return current;
65
+ const parent = dirname(current);
66
+ if (parent === current)
67
+ return resolve(path);
68
+ current = parent;
69
+ }
70
+ }
71
+ /** True when the value names a `git` procedure: a path, or a `$proc` ref at any depth. */
72
+ export function callsGit(value) {
73
+ if (Array.isArray(value)) {
74
+ if (value[0] === "git" && value.every((part) => typeof part === "string"))
75
+ return true;
76
+ return value.some(callsGit);
77
+ }
78
+ if (typeof value === "object" && value !== null) {
79
+ return Object.values(value).some(callsGit);
80
+ }
81
+ return false;
82
+ }
83
+ /**
84
+ * Run the tasks of one key one at a time, in the order of the calls. Tasks of other keys run
85
+ * in parallel.
86
+ */
87
+ export function keyedLock() {
88
+ const tails = new Map();
89
+ return async (key, task) => {
90
+ const previous = tails.get(key) ?? Promise.resolve();
91
+ let release;
92
+ const done = new Promise((resolveDone) => {
93
+ release = resolveDone;
94
+ });
95
+ const tail = previous.then(() => done);
96
+ tails.set(key, tail);
97
+ await previous;
98
+ try {
99
+ return await task();
100
+ }
101
+ finally {
102
+ release();
103
+ if (tails.get(key) === tail)
104
+ tails.delete(key);
105
+ }
106
+ };
107
+ }
108
+ /**
109
+ * Execute a DAG traversal with a custom visit procedure
110
+ *
111
+ * The visits of nodes in one git repository run one at a time when the visit calls git (or
112
+ * with `serialize: "repository"`). All the packages of a workspace share one repository, and
113
+ * concurrent `git add` calls failed on `index.lock` (deep dive DATA-17).
114
+ */
115
+ export async function dagTraverse(input, ctx) {
116
+ const startTime = Date.now();
117
+ const results = [];
118
+ // Scan for all packages (lib.scan of @procedures/lib)
119
+ const scanResult = await ctx.client.call(["lib", "scan"], input.rootPath !== undefined ? { rootPath: input.rootPath } : {});
120
+ let allNodes = packageNodes(scanResult.packages);
121
+ // Filter to specific packages if requested
122
+ if (input.filter && input.filter.length > 0) {
123
+ const filtered = new Map();
124
+ for (const name of input.filter) {
125
+ const node = allNodes.get(name);
126
+ if (node) {
127
+ filtered.set(name, node);
128
+ }
129
+ }
130
+ allNodes = filtered;
131
+ }
132
+ // Filter to root and its dependencies if requested
133
+ if (input.root) {
134
+ const rootNode = allNodes.get(input.root);
135
+ if (!rootNode) {
136
+ return {
137
+ success: false,
138
+ results: [],
139
+ totalDuration: Date.now() - startTime,
140
+ visited: 0,
141
+ failed: 0,
142
+ };
143
+ }
144
+ allNodes = filterDAGFromRoot(allNodes, input.root);
145
+ }
146
+ // Build DAG for dependency-ordered execution
147
+ const dag = buildLeveledDAG(allNodes);
148
+ // Determine how to execute the visit procedure
149
+ // visit can be:
150
+ // - Array: procedure path like ["git", "add"]
151
+ // - $proc ref: { $proc: [...], input: {...}, $when: "$parent" }
152
+ const visitIsRef = isAnyProcedureRef(input.visit);
153
+ let visitPath;
154
+ let baseInput = {};
155
+ if (Array.isArray(input.visit)) {
156
+ visitPath = input.visit;
157
+ }
158
+ else if (visitIsRef && typeof input.visit === "object" && "$proc" in input.visit) {
159
+ visitPath = input.visit.$proc;
160
+ baseInput = input.visit.input ?? {};
161
+ }
162
+ else {
163
+ throw new Error("visit must be a procedure path or $proc reference with $when");
164
+ }
165
+ const serialize = input.serialize ?? "auto";
166
+ const oneAtATime = serialize === "repository" || (serialize === "auto" && callsGit(input.visit));
167
+ const lock = keyedLock();
168
+ // Create processor that executes visit procedure per node
169
+ const processor = createProcessor(async (node) => {
170
+ if (oneAtATime) {
171
+ await lock(repositoryRoot(node.repoPath), () => visit(node));
172
+ }
173
+ else {
174
+ await visit(node);
175
+ }
176
+ });
177
+ async function visit(node) {
178
+ if (input.dryRun) {
179
+ results.push({
180
+ name: node.name,
181
+ path: node.repoPath,
182
+ success: true,
183
+ duration: 0,
184
+ output: { dryRun: true, wouldExecute: visitPath },
185
+ });
186
+ return;
187
+ }
188
+ const nodeStartTime = Date.now();
189
+ try {
190
+ // Merge base input with node context
191
+ const visitInput = {
192
+ ...(typeof baseInput === "object" ? baseInput : {}),
193
+ cwd: node.repoPath,
194
+ node: {
195
+ name: node.name,
196
+ path: node.repoPath,
197
+ dependencies: node.dependencies,
198
+ },
199
+ };
200
+ // Create executor for hydration that injects cwd into every call
201
+ const executor = async (path, inp) => {
202
+ // Inject cwd into the input so nested procedures run in correct directory
203
+ const inputWithCwd = typeof inp === "object" && inp !== null
204
+ ? { ...inp, cwd: node.repoPath }
205
+ : inp;
206
+ return ctx.client.call(path, inputWithCwd);
207
+ };
208
+ // Hydrate the input (execute any nested procedure refs like chain steps)
209
+ // Push "dag.traverse" onto context stack so refs with $when: "dag.traverse" execute
210
+ const hydratedInput = await hydrateInput(visitInput, executor, {
211
+ contextStack: ["dag.traverse"],
212
+ onRef: ctx.onRef,
213
+ // The names of the chain around this procedure: a `$ref` in the visit can read them
214
+ scope: scopeOf(input),
215
+ });
216
+ // Execute visit procedure with hydrated input
217
+ const output = await ctx.client.call(visitPath, hydratedInput);
218
+ results.push({
219
+ name: node.name,
220
+ path: node.repoPath,
221
+ success: true,
222
+ duration: Date.now() - nodeStartTime,
223
+ output,
224
+ });
225
+ }
226
+ catch (error) {
227
+ const result = {
228
+ name: node.name,
229
+ path: node.repoPath,
230
+ success: false,
231
+ duration: Date.now() - nodeStartTime,
232
+ error: error instanceof Error ? error.message : String(error),
233
+ };
234
+ results.push(result);
235
+ throw error; // Re-throw for DAG executor to handle
236
+ }
237
+ }
238
+ // Execute DAG traversal
239
+ const dagResult = await executeDAG(dag, processor, {
240
+ concurrency: input.concurrency ?? 4,
241
+ failFast: !input.continueOnError,
242
+ });
243
+ // If dry run, we already populated results in the processor
244
+ if (!input.dryRun) {
245
+ // Ensure all nodes have results (some may have been skipped due to errors)
246
+ for (const [name, nodeResult] of dagResult.results) {
247
+ const existing = results.find((r) => r.name === name);
248
+ // No test reaches this branch: each visit adds its result before it ends or throws, and
249
+ // executeDAG gives no result for a node of a level that it skipped. The branch came with
250
+ // the procedure from client-lib (2026-10). It stays until a decision about it.
251
+ /* v8 ignore if -- @preserve */
252
+ if (!existing) {
253
+ const node = allNodes.get(name);
254
+ const result = {
255
+ name,
256
+ path: node?.repoPath ?? "unknown",
257
+ success: nodeResult.success,
258
+ duration: nodeResult.duration,
259
+ };
260
+ if (nodeResult.error?.message) {
261
+ result.error = nodeResult.error.message;
262
+ }
263
+ results.push(result);
264
+ }
265
+ }
266
+ }
267
+ return {
268
+ success: dagResult.success,
269
+ results,
270
+ totalDuration: Date.now() - startTime,
271
+ visited: results.filter((r) => r.success).length,
272
+ failed: results.filter((r) => !r.success).length,
273
+ };
274
+ }
275
+ //# sourceMappingURL=traverse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traverse.js","sourceRoot":"","sources":["../../src/procedures/traverse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;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AAO,CAAC,CAAC,MAAM;QAChD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM;KACjD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * The types and schemas of the `dag.traverse` procedure.
3
+ *
4
+ * The procedure came from `@procedures/lib` (roadmap, items for a decision). Its name stays
5
+ * `dag.traverse`.
6
+ */
7
+ import { z } from "zod";
8
+ import type { DAGNode } from "../types.js";
9
+ /**
10
+ * Schema for $proc references with $when control.
11
+ */
12
+ declare const ProcRefSchema: z.ZodObject<{
13
+ $proc: z.ZodArray<z.ZodString>;
14
+ input: z.ZodOptional<z.ZodUnknown>;
15
+ $when: z.ZodOptional<z.ZodString>;
16
+ $name: z.ZodOptional<z.ZodString>;
17
+ }>;
18
+ export declare const DagTraverseInputSchema: z.ZodObject<{
19
+ visit: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, typeof ProcRefSchema]>;
20
+ filter: z.ZodOptional<z.ZodArray<z.ZodString>>;
21
+ root: z.ZodOptional<z.ZodString>;
22
+ rootPath: z.ZodOptional<z.ZodString>;
23
+ concurrency: z.ZodDefault<z.ZodNumber>;
24
+ serialize: z.ZodDefault<z.ZodEnum<{
25
+ auto: "auto";
26
+ repository: "repository";
27
+ none: "none";
28
+ }>>;
29
+ continueOnError: z.ZodDefault<z.ZodBoolean>;
30
+ dryRun: z.ZodDefault<z.ZodBoolean>;
31
+ }>;
32
+ export type DagTraverseInput = z.infer<typeof DagTraverseInputSchema>;
33
+ export interface TraverseNodeResult {
34
+ name: string;
35
+ path: string;
36
+ success: boolean;
37
+ duration: number;
38
+ error?: string | undefined;
39
+ output?: unknown | undefined;
40
+ }
41
+ export interface DagTraverseOutput {
42
+ success: boolean;
43
+ results: TraverseNodeResult[];
44
+ totalDuration: number;
45
+ visited: number;
46
+ failed: number;
47
+ }
48
+ export declare const DagTraverseOutputSchema: z.ZodType<DagTraverseOutput>;
49
+ /**
50
+ * A package of the output of `lib.scan`: the fields that `dag.traverse` reads. The type is local,
51
+ * because `@procedures/lib` depends on this package, and this package must not depend on it.
52
+ */
53
+ export interface ScannedPackage {
54
+ /** The package name */
55
+ name: string;
56
+ /** The folder of the package */
57
+ repoPath: string;
58
+ /** The ecosystem packages that the package depends on */
59
+ mark1russell7Deps: string[];
60
+ }
61
+ /** The output of `lib.scan`: the fields that `dag.traverse` reads. */
62
+ export interface ScanOutput {
63
+ packages: Record<string, ScannedPackage>;
64
+ }
65
+ /** A node of the traversal: a workspace package. `id` is the package name. */
66
+ export interface PackageNode extends DAGNode {
67
+ /** The package name. It is the same as `id`. */
68
+ name: string;
69
+ /** The folder of the package */
70
+ repoPath: string;
71
+ }
72
+ export {};
73
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/procedures/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;GAEG;AACH,QAAA,MAAM,aAAa,EAAE,CAAC,CAAC,SAAS,CAAC;IAC/B,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC/B,KAAK,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACnC,KAAK,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAClC,KAAK,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;CACnC,CAKC,CAAC;AAEH,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,SAAS,CAAC;IAC/C,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC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C;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAiB/D,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,sEAAsE;AACtE,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC1C;AAED,8EAA8E;AAC9E,MAAM,WAAW,WAAY,SAAQ,OAAO;IAC1C,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The types and schemas of the `dag.traverse` procedure.
3
+ *
4
+ * The procedure came from `@procedures/lib` (roadmap, items for a decision). Its name stays
5
+ * `dag.traverse`.
6
+ */
7
+ import { z } from "zod";
8
+ /**
9
+ * Schema for $proc references with $when control.
10
+ */
11
+ const ProcRefSchema = z.object({
12
+ $proc: z.array(z.string()),
13
+ input: z.unknown().optional(),
14
+ $when: z.string().optional(),
15
+ $name: z.string().optional(),
16
+ });
17
+ export const DagTraverseInputSchema = z.object({
18
+ /**
19
+ * The procedure to start for each node.
20
+ * - A list: a procedure path, for example ["git", "add"]
21
+ * - A `$proc` ref with `$when: "$never"` or `"$parent"`: deferred. The traversal starts it for each node.
22
+ *
23
+ * Example:
24
+ * ```json
25
+ * { "$proc": ["git", "add"], "input": { "all": true }, "$when": "$parent" }
26
+ * ```
27
+ */
28
+ visit: z.union([
29
+ z.array(z.string()),
30
+ ProcRefSchema,
31
+ ]).describe("Procedure to execute for each node. - Array: procedure path, e.g., [\"git\", \"add\"] - $proc with $when: \"$never\" or \"$parent\": deferred, executed per-node Example: ```json { \"$proc\": [\"git\", \"add\"], \"input\": { \"all\": true }, \"$when\": \"$parent\" } ```"),
32
+ /** Filter to specific package names */
33
+ filter: z.array(z.string()).optional().describe("Filter to specific package names"),
34
+ /** Start from specific root package */
35
+ root: z.string().optional().describe("Start from specific root package"),
36
+ /** The workspace root that `lib.scan` reads (default: the pnpm workspace that contains client-lib) */
37
+ rootPath: z.string().optional().describe("Workspace root (defaults to the pnpm workspace that contains client-lib)"),
38
+ /** Max parallel operations (default: 4) */
39
+ concurrency: z.number().default(4).describe("Max parallel operations (default: 4)"),
40
+ /**
41
+ * When the visits of nodes in one git repository start one at a time (default: "auto").
42
+ * - "auto": when the visit uses a `git` procedure (git locks the index of the repository)
43
+ * - "repository": always
44
+ * - "none": not at any time
45
+ */
46
+ serialize: z.enum(["auto", "repository", "none"]).default("auto").describe("When the visits of nodes in one git repository run one at a time (default: \"auto\"). - \"auto\": when the visit calls a `git` procedure (git locks the index of the repository) - \"repository\": always - \"none\": never"),
47
+ /** Continue on error (default: false) */
48
+ continueOnError: z.boolean().default(false).describe("Continue on error (default: false)"),
49
+ /** Give the plan only, and start no visit (default: false) */
50
+ dryRun: z.boolean().default(false).describe("Preview without executing (default: false)"),
51
+ });
52
+ export const DagTraverseOutputSchema = z.looseObject({
53
+ success: z.boolean().describe("True when every visit succeeded"),
54
+ results: z
55
+ .array(z.looseObject({
56
+ name: z.string().describe("The package name of the node"),
57
+ path: z.string().describe("The folder of the node"),
58
+ success: z.boolean().describe("True when the visit succeeded"),
59
+ duration: z.number().describe("The time of the visit, in milliseconds"),
60
+ error: z.string().optional().describe("The error of a failed visit"),
61
+ output: z.unknown().optional().describe("The result of the visit"),
62
+ }))
63
+ .describe("The result of each visited node"),
64
+ totalDuration: z.number().describe("The time of the traversal, in milliseconds"),
65
+ visited: z.number().describe("The number of visited nodes"),
66
+ failed: z.number().describe("The number of failed visits"),
67
+ });
68
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
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AAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IAC3D,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;CAC3D,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Importing this file registers the procedures of @procedures/dag in the global registry:
3
+ * `import "@procedures/dag/register"`. The package root and the `./module` entry register nothing
4
+ * (ARCHITECTURE-PROPOSALS-2026-10, P9). `dag.traverse` calls `lib.scan`: also import
5
+ * `@procedures/lib/register`.
6
+ */
7
+ export * from "./module.js";
8
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,cAAc,aAAa,CAAC"}