@procedures/dag 0.2.3 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @procedures/dag
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2fd2398: `dag.traverse` moved from `@procedures/lib` to `@procedures/dag`. Its name, input, output and effects stay the same. In this version, `@procedures/dag` has a `./module` entry, a `./register` entry and the `client.procedures` field, and it depends on `@procedures/client` and `zod`. The graph algorithms of its root do not change.
8
+
9
+ `dag.traverse` gets the packages from `lib.scan` through `ctx.client` (`calls: ["lib.scan"]`). `@procedures/lib` depends on `@procedures/dag`, so the module of `@procedures/dag` does not list the module of `@procedures/lib` as a dependency: a host registers the two modules. `bundle-dev`, `bundle-mcp` and `mark` do. The module of `@procedures/lib` does not register `dag.traverse` any more.
10
+
11
+ `DagTraverseInputSchema`, `DagTraverseInput`, `DagTraverseOutput` and `TraverseNodeResult` are exports of `@procedures/dag`, not of `@procedures/lib`.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [d919678]
16
+ - Updated dependencies [057d69a]
17
+ - Updated dependencies [b2a1a1e]
18
+ - Updated dependencies [057d69a]
19
+ - Updated dependencies [057d69a]
20
+ - Updated dependencies [057d69a]
21
+ - Updated dependencies [057d69a]
22
+ - Updated dependencies [057d69a]
23
+ - Updated dependencies [afd6a19]
24
+ - Updated dependencies [057d69a]
25
+ - Updated dependencies [4e751da]
26
+ - @procedures/client@0.4.0
27
+
28
+ ## 0.3.0
29
+
30
+ No changes in this release.
31
+
3
32
  ## 0.2.3
4
33
 
5
34
  No changes in this release.
package/README.md CHANGED
@@ -382,7 +382,7 @@ graph LR
382
382
 
383
383
  ### Package Build Order
384
384
 
385
- Build packages in dependency order (`dag.traverse` of `client-lib` does this):
385
+ Build packages in dependency order (the procedure `dag.traverse` of this package does this):
386
386
 
387
387
  ```typescript
388
388
  const packages = [
@@ -439,20 +439,54 @@ await executeDAG(dag, async (mod) => {
439
439
 
440
440
  ## Integration
441
441
 
442
- ### With client-lib
442
+ ### The procedure `dag.traverse`
443
+
444
+ The package has one procedure, `dag.traverse`. It came from `client-lib` in version 0.4.0, and its name stays the same. The graph algorithms of the package root do not need it.
445
+
446
+ `dag.traverse` starts the `visit` procedure once for each package, with `cwd` set to the folder of the package. A package starts after the packages that it depends on.
447
+
448
+ | Field | Default | Function |
449
+ |---|---|---|
450
+ | `visit` | | A procedure path, or a call with `$when: "$parent"` (or `$never`) |
451
+ | `filter` | | Only these package names |
452
+ | `root` | | Only this package and the packages that it depends on |
453
+ | `rootPath` | the workspace | The workspace root |
454
+ | `concurrency` | 4 | The number of visits at the same time |
455
+ | `serialize` | `auto` | When the visits in one git repository start one at a time: `auto` (when the visit uses a `git` procedure), `repository` (always) or `none` |
456
+ | `continueOnError` | false | Continue after a failed visit |
457
+ | `dryRun` | false | Give the plan only |
458
+
459
+ All packages of the monorepo are in one git repository. Concurrent `git add` commands fail on `index.lock`, so `auto` starts git visits one at a time (deep dive DATA-17).
460
+
461
+ ```typescript
462
+ import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
463
+ import "@procedures/lib/register"; // lib.scan, and the fs and git procedures that it uses
464
+ import "@procedures/dag/register"; // dag.traverse
443
465
 
444
- `client-lib` uses `client-dag` for ecosystem package management:
466
+ const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
467
+
468
+ await client.exec(["dag", "traverse"], {
469
+ visit: { $proc: ["pnpm", "run"], input: { script: "build" }, $when: "$parent" },
470
+ root: "@procedures/fs",
471
+ });
472
+ ```
473
+
474
+ - `dag.traverse` gets the packages from `lib.scan` of `@procedures/lib`, through `ctx.client`. Its metadata declares the call (`calls: ["lib.scan"]`).
475
+ - `@procedures/lib` depends on this package. Thus this package does not import `@procedures/lib`, and the module of this package does not list the module of `@procedures/lib` as a dependency. A host registers the two modules. `bundle-dev`, `bundle-mcp` and `mark` do.
476
+ - `dag.traverse` has the tag `runs-refs`: it starts the refs of its input. Thus a server with an `expose` rule lets it use only exposed procedures, `lib.scan` too.
477
+ - A call in `visit` with `$when: "dag.traverse"` waits for this runner ([PROGRAM-FORMAT.md](../documentation/PROGRAM-FORMAT.md), section 5).
478
+ - `bundle-mcp` registers the procedure, but `dag` is not a tool namespace of the MCP server.
445
479
 
446
480
  ```mermaid
447
481
  graph TB
448
- subgraph "client-lib"
449
- Scan[lib.scan<br/>Discover packages]
482
+ subgraph "client-dag"
450
483
  Traverse[dag.traverse<br/>Visit in dependency order]
484
+ Build[buildLeveledDAG]
485
+ Execute[executeDAG]
451
486
  end
452
487
 
453
- subgraph "client-dag"
454
- Build[buildDAG]
455
- Execute[executeDAG]
488
+ subgraph "client-lib"
489
+ Scan[lib.scan<br/>Find the packages]
456
490
  end
457
491
 
458
492
  subgraph "Packages"
@@ -461,36 +495,24 @@ graph TB
461
495
  P3[Package C]
462
496
  end
463
497
 
464
- Scan --> Build
498
+ Traverse -->|ctx.client| Scan
499
+ Traverse --> Build
465
500
  Build --> Execute
466
- Traverse --> Execute
467
501
  Execute --> P1
468
502
  Execute --> P2
469
503
  Execute --> P3
470
504
  ```
471
505
 
472
- ### dag.traverse Procedure
473
-
474
- The `dag.traverse` procedure in `client-lib` wraps this functionality:
475
-
476
- ```typescript
477
- // Via procedure
478
- await client.exec(["dag", "traverse"], {
479
- visit: ["pnpm", "install"],
480
- concurrency: 4,
481
- });
506
+ ### With client-lib
482
507
 
483
- // Internally uses
484
- const dag = buildDAG(packages);
485
- await executeDAG(dag, processor);
486
- ```
508
+ `client-lib` uses the algorithms of this package for `lib.graph`.
487
509
 
488
510
  ---
489
511
 
490
512
  ## Requirements
491
513
 
492
514
  - **Node.js** >= 22
493
- - **Dependencies:** none
515
+ - **Dependencies:** `@procedures/client` and `zod`, for the procedure. The graph algorithms use neither.
494
516
 
495
517
  ---
496
518