@procedures/mark 0.23.0 → 0.24.1

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,76 @@
1
1
  # @procedures/mark
2
2
 
3
+ ## 0.24.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [2735505]
8
+ - @procedures/client@0.24.1
9
+ - @procedures/cli-run@0.24.1
10
+ - @procedures/lib@0.24.1
11
+ - @procedures/pnpm@0.24.1
12
+ - @procedures/procedure@0.24.1
13
+ - @procedures/peer@0.24.1
14
+ - @procedures/shell@0.24.1
15
+ - @procedures/vitest@0.24.1
16
+ - @procedures/mcp-dev-tools@0.24.1
17
+ - @procedures/server@0.24.1
18
+
19
+ ## 0.24.0
20
+
21
+ ### Minor Changes
22
+
23
+ - 4261f65: Breaking: each `mark` command starts under `run()` of `@mark1russell7/service` (CLI-26, decision D17). The cold mode runs the procedures host of the CLI server in its own process. The runner owns the signals, the stop in stages and the exit. Thus the exit codes of a signal change. The release before this one marked the old behaviors as deprecated.
24
+
25
+ The new behavior:
26
+
27
+ - Each `mark` command that runs a procedure is a service of one request, with the profile `ephemeral`. `mark` has no signal handler and no `process.exit` of its own in this path. `interruptSignal()` is gone.
28
+ - The cold mode (no CLI server in this folder, or `--local`): the host has the same registry and policy as `mark --server` (`markHostOptions()`), and no listener, port, token or lockfile. The client sends each call through the local face of the host.
29
+ - `localFace()` of `@procedures/peer` is new. It gives a face factory and a transport of `@procedures/client`. A `Client` on the transport sends its calls to the host of the same process, through the request tracking of the service, with `LOCAL_CREDENTIALS`.
30
+ - A first Ctrl-C starts the stop, and the drain aborts the call at once.
31
+ - The warm mode: the call to the CLI server gets the abort signal. A Ctrl-C aborts the call on the server too. Before, the signal ended `mark`, and the server continued the call.
32
+ - After the command, the runner ends the process with the exit code of the command. A timer or a socket that a procedure left open does not keep the process alive.
33
+ - `run()` and `main()` of `@procedures/mark` get the optional options `run` (the options of `run()`: the process port and the clock) and `ownsProcess`. The bin gives `ownsProcess: true`. Without it, a program keeps its process: no signal handler, and the exit code goes to `process.exitCode`.
34
+ - `CliContext` gets the optional field `registry`. `executeArgs()` does not use `ctx.client` for a command any more.
35
+ - A program that calls `run()` or `executeArgs()` without a port, and the REPL (`mark -i`), get no signal handler for a command.
36
+
37
+ The exit codes, in the cold mode and in the warm mode:
38
+
39
+ | Event | Before | From this release |
40
+ |---|---|---|
41
+ | The command ends without a failure | 0 | 0 |
42
+ | The command fails | 1 | 1 |
43
+ | The first Ctrl-C, cold mode | 1 | 130 |
44
+ | The first Ctrl-C, warm mode | the signal ended the process (the shell showed 130) | 130 |
45
+ | `SIGTERM` | the signal ended the process (the shell showed 143) | 143 |
46
+ | A second signal during the stop, cold mode | 130 | 1 |
47
+
48
+ A cold `mark server create` keeps its peer only until the end of the command. Before, the peer kept the process alive after the command.
49
+
50
+ Migration:
51
+
52
+ - A script that reads the exit code of an interrupted `mark` command: read 130 for a Ctrl-C, also in the cold mode. Read 1 for a second signal.
53
+ - A script that starts `mark server create` as a server in the foreground: start `mark --server` or `procedure-server` in its place.
54
+ - A program that calls `run()`, `main()` or `executeArgs()` of `@procedures/mark`: no change. It keeps its process. Give `ownsProcess: true` to give the process to the runner, as the bin does.
55
+ - The site: no change. It does not start `mark`.
56
+ - MiniMongo: no change. Its dev host starts through `runProcedureHost()`, not through `mark`.
57
+ - Graph: no change. It does not start `mark`.
58
+ - jarvis: no change, unless a script of jarvis reads the exit code of an interrupted `mark` command. Then apply the first step.
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [4261f65]
63
+ - @procedures/peer@0.24.0
64
+ - @procedures/server@0.24.0
65
+ - @procedures/client@0.24.0
66
+ - @procedures/cli-run@0.24.0
67
+ - @procedures/lib@0.24.0
68
+ - @procedures/pnpm@0.24.0
69
+ - @procedures/procedure@0.24.0
70
+ - @procedures/shell@0.24.0
71
+ - @procedures/vitest@0.24.0
72
+ - @procedures/mcp-dev-tools@0.24.0
73
+
3
74
  ## 0.23.0
4
75
 
5
76
  ### Patch Changes
package/README.md CHANGED
@@ -45,7 +45,7 @@ graph TB
45
45
 
46
46
  subgraph "Execution Layer"
47
47
  REGISTRY[Procedure Registry]
48
- TRANSPORT[Local Transport]
48
+ TRANSPORT["Local face of the host"]
49
49
  CLIENT[Client]
50
50
  end
51
51
 
@@ -145,13 +145,32 @@ The bin is `dist/bin.js`. `node dist/cli.js` also runs the CLI. Importing `@proc
145
145
 
146
146
  | Command | Host | Notes |
147
147
  |---|---|---|
148
- | `mark <command>` | This process | The registry has the module of each workspace package with `client.procedures`. |
148
+ | `mark <command>` | This process (the cold mode), or the CLI server (the warm mode) | The registry has the module of each workspace package with `client.procedures`. In the two modes, the command starts under `run()` of `@mark1russell7/service`. |
149
149
  | `mark --server` | The CLI server | The same registry, on `127.0.0.1`, with a token in the lockfile. A later `mark` command in the same folder uses it. |
150
150
  | `mark serve` | The procedure server | The options of the `procedure-server` command. A package of `--procedures` resolves from the current folder, then from the folder of `mark`. A token is necessary by default. |
151
151
  | `mark mcp` | The dev-tools MCP server, over stdio | The server of Claude Code's MCP configuration. stdout holds only protocol lines, and `mark mcp --help` writes to stderr. |
152
152
 
153
153
  `mark mcp <procedure>` runs an `mcp.*` procedure (for example `mark mcp listTools`), not the server. Each host gets its policy from `hostPolicy()` of `@procedures/client`.
154
154
 
155
+ #### The cold mode and the warm mode
156
+
157
+ Each command that runs a procedure is a service of one request (CLI-26, decision D17). The runner of `@mark1russell7/service` owns the signals, the stop in stages and the exit. `mark` installs no signal handler of its own.
158
+
159
+ - **The warm mode.** A CLI server (`mark --server`) of this build operates in this folder, with the same `--fs-root`. The command goes to the server over HTTP.
160
+ - **The cold mode.** No such server operates, or the command has `--local`. The procedures host of the CLI server then operates in this process, with the same registry and policy. It has no port, no token and no lockfile.
161
+ - **The profile.** The service has the profile `ephemeral`: no checks, no probes, and a flush of the output before the exit.
162
+ - **Ctrl-C.** A first Ctrl-C starts the stop. The drain aborts the call at once: a shell command stops its process tree, and a stream ends. In the warm mode, the server aborts the call too. Before, the server continued it.
163
+ - **A second Ctrl-C.** A second signal during the stop ends the process at once, with the exit code 1.
164
+ - **The exit.** After the command, the runner ends the process with the exit code of the command. A timer or a socket that a procedure left open does not keep the process alive.
165
+ - **The REPL.** `mark -i` starts each line in the cold mode, without the signals: the REPL keeps its process.
166
+
167
+ ```mermaid
168
+ graph LR
169
+ CMD[mark command] --> SVC["service of the command<br/>run(), profile ephemeral"]
170
+ SVC -->|warm| HTTP[HttpTransport + signal] --> SERVER["CLI server<br/>runProcedureHost, daemon"]
171
+ SVC -->|cold| FACE["localFace()"] --> HOST["the same host<br/>in this process"]
172
+ ```
173
+
155
174
  #### Remote events of the hosts
156
175
 
157
176
  `mark --server` and `mark serve` always serve the procedure `events.subscribe` ([EVENTS.md](../documentation/EVENTS.md)):
@@ -234,15 +253,24 @@ A procedure reports a failure in one of three ways:
234
253
 
235
254
  For a streaming procedure, `mark` examines each item. One failed item makes the command fail.
236
255
 
237
- #### Deprecated: a signal during a command
256
+ The exit codes of a command, since the MINOR of CLI-26. A signal stops a command through the runner:
257
+
258
+ | Event | Cold mode | Warm mode |
259
+ |---|---|---|
260
+ | The command ends without a failure | 0 | 0 |
261
+ | The command fails | 1 | 1 |
262
+ | The first `SIGINT` (Ctrl-C) | 130 | 130 |
263
+ | `SIGTERM` | 143 | 143 |
264
+ | `SIGQUIT` | 131 | 131 |
265
+ | A second signal during the stop | 1 | 1 |
238
266
 
239
- The MINOR of CLI-26 starts each command under `run()` of `@mark1russell7/service` (decision D17). The runner then owns the signals and the exit. These behaviors are deprecated, and that MINOR changes them:
267
+ The cold mode is a command in this process: no CLI server operates in this folder, or the command has `--local`. The MINOR of CLI-26 changed three behaviors. The release before it marked them as deprecated:
240
268
 
241
- - **The first Ctrl-C in the cold mode.** A command in this process gives the exit code 1. After the change, it gives 130.
242
- - **A second signal.** A second Ctrl-C in the cold mode ends the process at once with the exit code 130. After the change, the exit code is 1.
243
- - **`mark server create` in the cold mode.** The peer of the command keeps the process alive after the command. After the change, the peer stops at the end of the command. For a server in the foreground, use `mark --server` or `procedure-server`.
269
+ - **The first Ctrl-C in the cold mode.** Before, the aborted command gave the exit code 1. The runner gives 130.
270
+ - **A second signal.** Before, a second Ctrl-C in the cold mode gave the exit code 130. The runner gives 1.
271
+ - **`mark server create` in the cold mode.** Before, the peer of the command kept the process alive after the command. The peer stops at the end of the command. For a server in the foreground, use `mark --server` or `procedure-server`.
244
272
 
245
- The cold mode is a command in this process: no CLI server operates in this folder, or the command has `--local`. A command on the CLI server (the warm mode) keeps the exit codes 0 and 1.
273
+ Before CLI-26, a signal in the warm mode ended the process, and the server continued the call. The shell showed 130 or 143. The runner gives the same codes, after the server aborts the call.
246
274
 
247
275
  #### Examples
248
276
 
@@ -271,7 +299,7 @@ mark --verbose lib new my-pkg
271
299
 
272
300
  ### Programmatic API
273
301
 
274
- #### `run(argv: string[]): Promise<void>`
302
+ #### `run(argv: string[], options?): Promise<void>`
275
303
 
276
304
  Main CLI entry point.
277
305
 
@@ -282,6 +310,10 @@ import { run } from "@procedures/mark";
282
310
  await run(["lib", "new", "my-package"]);
283
311
  ```
284
312
 
313
+ - By default, the program keeps its process. A command installs no signal handler, does not end the process, and sets `process.exitCode`.
314
+ - `ownsProcess: true` gives the process to the runner of each command, as the bin does. The runner then owns the signals, and it ends the process with the exit code of the command.
315
+ - `run` gives the options of `run()` of `@mark1russell7/service`: the process port and the clock. A test gives `fakeProcess()` of `@mark1russell7/service/testing`.
316
+
285
317
  #### `parseFromSchema(params, meta, schema?): Record<string, unknown>`
286
318
 
287
319
  Parse CLI arguments based on procedure metadata. With the schema, each value is converted by the type of its field. `parseCommandLine(argv, procedures)` splits a whole command line: the global flags, the path and the input.
@@ -641,19 +673,24 @@ packages/client-lib/
641
673
 
642
674
  ### Transport Layer
643
675
 
676
+ In the cold mode, the client sends each call to the procedures host of this process through `localFace()` of `@procedures/peer` (CLI-26). In the warm mode, the client sends each call to the CLI server through `HttpTransport`.
677
+
644
678
  ```mermaid
645
679
  graph LR
646
680
  CLI[CLI]
647
681
  CLIENT[Client]
648
- TRANSPORT[LocalTransport]
682
+ TRANSPORT["localFace() transport"]
683
+ HOST["ProcedureServer of the host<br/>(request tracking of the service)"]
649
684
  REGISTRY[ProcedureRegistry]
650
685
  HANDLER[Procedure Handler]
651
686
 
652
687
  CLI --> CLIENT
653
688
  CLIENT --> TRANSPORT
654
- TRANSPORT --> REGISTRY
689
+ TRANSPORT --> HOST
690
+ HOST --> REGISTRY
655
691
  REGISTRY --> HANDLER
656
- HANDLER --> TRANSPORT
692
+ HANDLER --> HOST
693
+ HOST --> TRANSPORT
657
694
  TRANSPORT --> CLIENT
658
695
  CLIENT --> CLI
659
696