c8ctl-plugin-nano 1.19.0 → 1.21.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.
Files changed (3) hide show
  1. package/README.md +72 -0
  2. package/c8ctl-plugin.js +1328 -30
  3. package/package.json +8 -8
package/README.md CHANGED
@@ -207,6 +207,29 @@ c8ctl nano work reviewer # poll for work until Ctrl-C
207
207
  c8ctl nano work reviewer --max-parallel 2 --job-timeout 600000
208
208
  ```
209
209
 
210
+ ### Live profile reload (no restart on `assign`)
211
+
212
+ A running `c8ctl nano work <name>` **watches** the profile it is servicing. When
213
+ you extend or reduce that profile's capabilities in another terminal —
214
+
215
+ ```bash
216
+ c8ctl nano assign reviewer fix-ci # add a capability to the live profile
217
+ ```
218
+
219
+ — the supervisor reconciles its pollers in place: it **starts** pollers for the
220
+ newly added rank×capability job types and **gracefully drains** the pollers for
221
+ removed types — best-effort: each draining poller is given a bounded grace
222
+ window (`STOP_GRACE_MS`) for its in-flight jobs to finish before
223
+ it is stopped, so long-running work exceeding that window may still be
224
+ interrupted. Unchanged job types keep running undisturbed, so there is no need
225
+ to stop and restart the worker.
226
+
227
+ Only **job types** (rank + capabilities, plus any `--job-type` extras) reconcile
228
+ live. Changes to the profile's `command`, `model`, `sandbox`/`image`, or `env`
229
+ still require a restart to take effect. If the profile is deleted or the config
230
+ file is mid-write when the reload fires, the running workers are **kept** (never
231
+ torn down) and a warning is logged.
232
+
210
233
  Each activated job runs the profile's command **once** (one-shot): the job is
211
234
  serialized to JSON and piped to the CLI's **stdin** —
212
235
 
@@ -413,6 +436,55 @@ than `--min-free-mb` MB free (default `1024`).
413
436
  > are frozen so the [nano-ide element-template pack](https://github.com/jwulf/nano-ide/issues/37)
414
437
  > can be built against this contract.
415
438
 
439
+ ## Supervising a fleet of workers: `supervisor`
440
+
441
+ Running several workers means several `nano work` foreground processes — one
442
+ terminal each, none of them restarted if they crash. The **`supervisor`** runs
443
+ and manages a whole fleet from a **single terminal**: a detached daemon spawns
444
+ one `nano work <profile>` child per worker, restarts a crashed child with capped
445
+ backoff, and is driven either interactively (a console you can **detach from**,
446
+ leaving it running) or non-interactively with plain subcommands.
447
+
448
+ ```bash
449
+ # Start a detached supervisor managing several workers at once
450
+ c8ctl nano supervisor start --worker reviewer --worker coder --worker decider
451
+
452
+ # Attach an interactive console (starts the daemon if needed).
453
+ # Detach with `detach` or Ctrl-D — the daemon KEEPS RUNNING. `stop` tears it down.
454
+ c8ctl nano supervisor
455
+
456
+ # Manage the fleet without the console (any terminal, any time):
457
+ c8ctl nano supervisor status # id, state, pid, restarts, uptime
458
+ c8ctl nano supervisor add reviewer --max-parallel 2 # add + spawn a worker (forwards work flags)
459
+ c8ctl nano supervisor restart reviewer # by worker id or profile name
460
+ c8ctl nano supervisor remove coder # stop + drop a worker (also: `all`)
461
+ c8ctl nano supervisor logs reviewer --follow # tail a worker's log (or the daemon's)
462
+ c8ctl nano supervisor stop # stop the daemon and every worker
463
+ ```
464
+
465
+ Each worker takes the **same flags as `nano work`** (`--max-parallel`,
466
+ `--job-timeout`, `--lock-grace`, `--poll-timeout`, `--sandbox`/`--image`,
467
+ `--job-type`, `--env`, `--arg`, …); they are forwarded verbatim to the spawned
468
+ child, so a supervised worker is byte-identical to a hand-run `nano work`. In the
469
+ interactive console, type the flags after the profile: `add reviewer --max-parallel 2`.
470
+
471
+ How it works and where things live:
472
+
473
+ - The daemon runs **detached + `unref`'d** (like `nano start` nodes), so it
474
+ outlives the CLI invocation that launched it — that is what "detach" means.
475
+ - A JSON state file `supervisor.json` records `{ pid, socket, workers:[…] }`;
476
+ management commands talk to the daemon over a **control socket** (a Unix domain
477
+ socket, or a named pipe on Windows) and fall back to the state file when the
478
+ socket is unreachable (to report a stale/dead daemon).
479
+ - Per-worker and daemon logs live under `logs/supervisor/` in the state home
480
+ (`worker-<id>.log`, `daemon.log`).
481
+ - **Restart policy:** a crashed child is restarted with exponential backoff
482
+ (1s → 30s cap); a child that stayed up ≥60s resets its backoff. `remove`/`stop`
483
+ cancel any pending restart, and a `restart` cleanly swaps the child (a late
484
+ exit from the old process is never mis-counted against the new one).
485
+ - Stopping is SIGTERM → grace → SIGKILL, per worker and for the daemon; `stop`
486
+ always clears `supervisor.json` so a stale marker never wedges a future start.
487
+
416
488
  ## Cleaning up disk
417
489
 
418
490
  ```bash