@tnunamak/dalan 0.5.2 → 0.6.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 (62) hide show
  1. package/CHANGELOG.md +29 -25
  2. package/PROTOCOL.md +16 -4
  3. package/README.md +127 -260
  4. package/SECURITY.md +1 -1
  5. package/bin/dalan.mjs +5 -0
  6. package/bin/dot-worker.mjs +35 -26
  7. package/docs/chatgpt-worker-onboarding.md +5 -5
  8. package/docs/claude-worker-onboarding.md +5 -5
  9. package/docs/codex-to-muse.md +175 -0
  10. package/docs/connect-chatgpt.md +9 -4
  11. package/docs/connection-longevity.md +7 -1
  12. package/docs/dalan-upgrade.md +17 -13
  13. package/docs/deadman.md +5 -3
  14. package/docs/local-agent-mcp.md +8 -6
  15. package/docs/manual-setup.md +8 -8
  16. package/docs/mirror-fetch.md +1 -2
  17. package/docs/operations.md +90 -42
  18. package/docs/operator-duties.md +1 -1
  19. package/docs/owner-integrator.md +2 -2
  20. package/docs/portable-auth-profile.md +12 -14
  21. package/docs/pr-head-reviewer.md +21 -5
  22. package/docs/pr-preflight.md +2 -0
  23. package/docs/pull-queue.md +131 -0
  24. package/docs/pull-workers.md +7 -10
  25. package/docs/redaction.md +1 -1
  26. package/docs/service-setup.md +56 -3
  27. package/docs/setup-reference.md +1 -1
  28. package/docs/t3-integration.md +2 -0
  29. package/docs/t3-result-retry-delivery.md +2 -2
  30. package/docs/t3-reverse-control.md +7 -7
  31. package/docs/usage.md +19 -15
  32. package/docs/worker-clients.md +18 -13
  33. package/package.json +3 -1
  34. package/scripts/dalan-try-selfcheck.mjs +29 -0
  35. package/scripts/worker-bridge-setup.mjs +1 -1
  36. package/src/acp-bridge.mjs +18 -12
  37. package/src/as.mjs +41 -0
  38. package/src/child-exit.mjs +18 -0
  39. package/src/child-registry.mjs +94 -0
  40. package/src/cli-help.mjs +25 -11
  41. package/src/demo-worker.mjs +2 -2
  42. package/src/drained-owner.mjs +26 -0
  43. package/src/drained-slot.mjs +20 -3
  44. package/src/mcp-outcome.mjs +10 -1
  45. package/src/mcp-sse.mjs +62 -0
  46. package/src/pr-head-reviewer.mjs +3 -3
  47. package/src/process-inspection.mjs +36 -0
  48. package/src/pull-queue.mjs +159 -0
  49. package/src/route-setting.mjs +24 -0
  50. package/src/server.mjs +157 -29
  51. package/src/service-migrate-workers.mjs +113 -0
  52. package/src/service.mjs +388 -0
  53. package/src/setup.mjs +63 -0
  54. package/src/store.mjs +21 -9
  55. package/src/tool-registry.mjs +3 -1
  56. package/src/try-exposure.mjs +908 -0
  57. package/src/try-hosted-clients.mjs +46 -0
  58. package/src/try-hosted.mjs +444 -0
  59. package/src/try-selfcheck.mjs +168 -0
  60. package/src/try.mjs +63 -17
  61. package/src/workers.mjs +33 -23
  62. package/src/workspace.mjs +10 -3
@@ -6,7 +6,7 @@
6
6
 
7
7
  Run these checks under each service's HOME and environment, using the new build. The operator remains responsible for service, proxy and connector changes.
8
8
 
9
- Order of an upgrade: (1) drain claims while the old service still runs (built-in auth; see the [drain paragraph](#preserve-historical-repositories-on-upgrade)); (2) stop the service; (3) take the backup; (4) replace the code; (5) run checklist items 1 to 8; (6) start the service; (7) run `dalan resume` if you drained; (8) finish checklist item 9. [Upgrade an npm install](#upgrade-an-npm-install) and [Upgrade a source install](#upgrade-a-source-install) follow this order.
9
+ Upgrade in this order: drain built-in-auth claims while the old service runs; stop every writer; take and verify the complete backup; replace the code; complete the stopped-service repository migration and any configuration or path changes; start the service; run `dalan resume` if you drained; then refresh connectors and finish the schema, status and authenticated smoke checks. Keep the backup until the post-start checks pass. The checklist below identifies requirements, not a separate sequence to run before startup. [Upgrade an npm install](#upgrade-an-npm-install) and [Upgrade a source install](#upgrade-a-source-install) provide the ordered steps.
10
10
 
11
11
  **Run a command in the service's environment.** A generated service sets only `HOME` (the bridge home), `NODE_ENV=production`, `DALAN_AUTH_MODE=builtin`, `DALAN_PORT`, `PATH`, and `DALAN_ENABLE_WORKSPACE=1` when repository tools are on. Read them, then run each command with those values in front of that one command. Do not `export` them or change `HOME` in your shell: `launchctl` and `systemctl --user` need your own `HOME`.
12
12
 
@@ -27,15 +27,15 @@ env -u DALAN_HOME -u DALAN_LOOPBACK HOME=BRIDGE_HOME NODE_ENV=production DALAN_A
27
27
 
28
28
  Before the first command that writes (`worker migrate-repos`, the drain, `resume`), check where the command resolves: `env -u DALAN_HOME -u DALAN_LOOPBACK HOME=BRIDGE_HOME dalan paths --json` must print `config_dir`, `data_dir` and `state_dir` under `BRIDGE_HOME`. If they are under another home, a variable is still set.
29
29
 
30
- Before checklist item 2 or the first start of the new version, stop every writer and take a consistent backup of each existing installation, even when paths and schema do not change. Include the config, data and state roots, but not the ownership-lock files described below. Take each SQLite database with `.backup`, as described in [operations](operations.md#upgrade-and-rollback). If `DALAN_WORKERS_FILE` points outside the config root, also include that workers file, its sibling `<name>-repos.json` journal and `workers-audit.jsonl`. `dalan paths` does not list overridden files. Step 2 reads the database without changing it, but it writes a one-time journal and can update the workers file.
30
+ Before checklist item 2 or the first start of the new version, stop every writer and take a consistent backup of each existing installation, even when paths and schema do not change. Include the config, data and state roots, but not the ownership-lock files described below. Take each SQLite database with `.backup`, as described in [operations](operations.md#upgrade-and-rollback). If `DALAN_WORKERS_FILE` points outside the config root, also include that workers file, its sibling `<name>-repos.json` journal, and its matching repository-policy audit log and checkpoint. Preserve the audit log and checkpoint as a pair, taking the checkpoint database with SQLite `.backup`. Resolve their actual configured locations before backing up; `dalan paths` does not list overridden files. Step 2 reads the database without changing it, but it writes a one-time journal and can update the workers file.
31
31
 
32
32
  1. If a requester uses T3 reverse control, set `DALAN_ENABLE_T3_TOOLS=1` before restart, retain its `t3` worker capability and inspect doctor. The legacy spelling is `DOT_BRIDGE_ENABLE_T3_TOOLS=1` when the new name is unset.
33
33
  2. With the old service stopped, run `dalan worker migrate-repos --json` under that service's own HOME and environment file. Check that its `database` and `workers_file` belong to the same bridge; a mismatch seeds one bridge's job history into another bridge's lists, and the seed is not repeated. Then run `dalan doctor --json` and `dalan worker list --json`. Inspect each worker's migration-seeded exact list and add any further owner-approved repository with `dalan worker allow NAME OWNER/REPO`. The allow and deny commands refuse a workers file that is a symlink; edit the real file in that case. Fresh and explicit empty lists still deny repository work.
34
- 3. After upgrading, refresh non-legacy connectors and restart worker conversations to load the Dalan identity and, for a `t3`-capable worker, `notify_owner`.
34
+ 3. After upgrading, refresh non-legacy connectors and restart worker conversations to load the Dalan identity and current process-wide catalog.
35
35
  4. For non-loopback external-OAuth HTTP, configure an HTTPS reverse proxy and set `DALAN_TRUST_PROXY=1`; same-machine workers can instead use the authenticated loopback profile below.
36
36
  5. If migrating paths, stop every component and take the consistent backup of the SQLite databases (see [operations](operations.md#upgrade-and-rollback)) and encryption keys. Use the explicit procedure below for all roots, then verify `dalan paths`, `status`, `doctor` and an authenticated smoke job before removing the backup. A partial new root can remain inactive while the legacy root serves data.
37
37
  6. After an explicit migration, update hardcoded socket, adapter, monitor and script paths and verify their operation. Valid mixed config/data roots are supported without file merging; the resolved roots are authoritative.
38
- 7. If any bridge is still on 0.2.0, take the schema-49 backup described in [operations](operations.md#from-020) before upgrading to schema 65. Drain built-in-mode claims before upgrading: older claims have no recorded connection and cannot act after migration; they must expire before a new grant can be acquired. See the [connection fence](portable-auth-profile.md#connect-a-worker).
38
+ 7. If any bridge is still on 0.2.0, take the schema-49 backup described in [operations](operations.md#from-020) before upgrading to schema 66. Drain built-in-mode claims before upgrading: older claims have no recorded connection and cannot act after migration; they must expire before a new grant can be acquired. See the [connection fence](portable-auth-profile.md#connect-a-worker).
39
39
  8. Keep every existing catalog pin, including `legacy-v46`. Do not send `lease_ms` to a legacy-v46 bridge; its captured schema does not accept that field.
40
40
  9. After every upgrade, whether or not paths changed: confirm the service is running and read its startup warnings; confirm the schema (below); run `dalan paths`, `status` and `doctor` under its environment; check authenticated connector discovery; and finish one repository-free worker job. If the worker does repository work, also finish one job on an allowed repository. `doctor` is local only and does not prove the service accepts work. Upgrade one bridge and pass this step before starting the next.
41
41
 
@@ -45,13 +45,13 @@ Before checklist item 2 or the first start of the new version, stop every writer
45
45
  sqlite3 -readonly "$(env -u DALAN_HOME -u DALAN_LOOPBACK HOME=BRIDGE_HOME dalan paths --data-root)/bridge.db" 'PRAGMA user_version;'
46
46
  ```
47
47
 
48
- For this release it must print `65`. A smaller number means the new version has not started on this database yet (the service is still the old code, or it stopped at start; read its log). A larger number is a database from a newer release: the service refuses to start on it, and you must not lower the number by hand (see [operations](operations.md#upgrade-and-rollback)).
48
+ For this release it must print `66`. A smaller number means the new version has not started on this database yet (the service is still the old code, or it stopped at start; read its log). A larger number is a database from a newer release: the service refuses to start on it, and you must not lower the number by hand (see [operations](operations.md#upgrade-and-rollback)).
49
49
 
50
50
  An empty new `AUTH_MODE` is treated as unset so a templated variable cannot mask `DOT_BRIDGE_AUTH_MODE=builtin`. Without either auth mode, startup still fails closed. Other empty new names keep precedence: an empty bind is refused in builtin/loopback modes, an empty catalog selects `stable`, and an empty workers-file setting selects the effective default profile path rather than a legacy override. Check templated units for these cases.
51
51
 
52
52
  ## Upgrade an npm install
53
53
 
54
- Releases before 0.4.0 were published as `dot-bridge`. The old package installs the commands `dot-worker`, `dot-deadman` and `dot-heartbeat`; Dalan installs `dalan` and `dalan-*` only. Remove the old package first so those old commands leave `PATH`; this removes only the code and leaves every bridge home, database and key alone, so a service that still names that code must be pointed at the new copy before it starts. Do all steps with the service stopped and after the [backup](operations.md#upgrade-and-rollback). Replace `NAME` with the worker name.
54
+ Releases before 0.4.0 were published as `dot-bridge`. The old package installs the commands `dot-worker`, `dot-deadman` and `dot-heartbeat`; Dalan installs `dalan` and `dalan-*` only. Remove the old package first so those old commands leave `PATH`; this removes only the code and leaves every bridge home, database and key alone, so a service that still names that code must be pointed at the new copy before it starts. Run step 1 while the old service is running. Then stop the service in step 2 and take the [backup](operations.md#upgrade-and-rollback) in step 3 before replacing code. Replace `NAME` with the worker name.
55
55
 
56
56
  1. Drain, while the old service still runs. Put the new release in a scratch directory, so the old install stays in place, and run the drain from there with the service's own HOME and environment (see the drain paragraph in the [checklist](#pre-upgrade-checklist)):
57
57
 
@@ -62,6 +62,8 @@ Releases before 0.4.0 were published as `dot-bridge`. The old package installs t
62
62
 
63
63
  Replace `VERSION` with the release you want (`npm view @tnunamak/dalan versions` lists them). The command is `@tnunamak/dalan@VERSION` here and in step 3, so both steps use the same release. The script is in the package; an installed `dalan` of a release that ships `scripts/upgrade-drain.mjs` can run it from `"$(npm root -g)/@tnunamak/dalan"` the same way. `BRIDGE_HOME` and `PORT` come from [Run a command in the service's environment](#pre-upgrade-checklist).
64
64
 
65
+ The old package may not provide `dalan`. Until step 3 installs the new command, run new-release CLI commands as `node "$HOME/dalan-new/node_modules/@tnunamak/dalan/bin/dalan.mjs"` instead of `dalan`, with the same service-environment prefix. Use that staged CLI for every `dalan paths` call in the backup recipe; do not replace the serving package merely to obtain the backup command.
66
+
65
67
  2. Stop the service. Linux: `systemctl --user stop dot-bridge-NAME.service`. macOS: `launchctl bootout user/$(id -u) ~/Library/LaunchAgents/LABEL.plist`; for an agent that an earlier release loaded, use `gui/$(id -u)` instead of `user/$(id -u)`. `LABEL` is `org.dalan.dot-bridge-NAME`. An install made by a release before 0.4.0 has a different label; find its file with `ls ~/Library/LaunchAgents | grep dot-bridge`.
66
68
  3. Take the [backup](operations.md#upgrade-and-rollback), then replace the package and check which build the shell now runs:
67
69
 
@@ -92,13 +94,15 @@ Releases before 0.4.0 were published as `dot-bridge`. The old package installs t
92
94
  ```
93
95
 
94
96
  The last command must show `state = running`. `kickstart` on an agent that `bootout` unloaded fails with exit 113 (`Could not find service`).
95
- 6. Run `dalan resume` if you used the drain, run the schema check from [Confirm the schema](#pre-upgrade-checklist) (it must print `65`), then follow step 5 of [Upgrade a source install](#upgrade-a-source-install): check the log shows `MCP listening` and finish a [first-job smoke check](operations.md#smoke-check-an-installed-service). When the smoke check passes, remove the staging install from step 1: check that the unit directory for your system has no unit that names it (Linux: `grep -Rl dalan-new ~/.config/systemd/user`; macOS: `grep -RSl dalan-new ~/Library/LaunchAgents`). `grep` exits 1 and prints nothing when it finds none; any other exit status, or any error message, means the check failed, so do not delete anything until you fix it. Then delete `$HOME/dalan-new` (it holds no bridge home). It is also in the [uninstall list](operations.md#remove-an-installation).
97
+ 6. Run `dalan resume` if you used the drain, run the schema check from [Confirm the schema](#pre-upgrade-checklist) (it must print `66`), then follow step 5 of [Upgrade a source install](#upgrade-a-source-install): check the log shows `MCP listening` and finish a [first-job smoke check](operations.md#smoke-check-an-installed-service). When the smoke check passes, remove the staging install from step 1: check that the unit directory for your system has no unit that names it (Linux: `grep -Rl dalan-new ~/.config/systemd/user`; macOS: `grep -RSl dalan-new ~/Library/LaunchAgents`). `grep` exits 1 and prints nothing when it finds none; any other exit status, or any error message, means the check failed, so do not delete anything until you fix it. Then delete `$HOME/dalan-new` (it holds no bridge home). It is also in the [uninstall list](operations.md#remove-an-installation).
96
98
 
97
99
  ## Upgrade a source install
98
100
 
99
- A source install is a Git checkout that `npm link` put on your PATH. Steps 1 to 4 need the service stopped and the [backup](operations.md#upgrade-and-rollback) taken first. Replace `CHECKOUT` with the absolute path of your checkout and `TAG` with the release you want.
101
+ A source install is a Git checkout that `npm link` put on your PATH. Drain while the old service is running in step 1, then stop it and take the [backup](operations.md#upgrade-and-rollback) before step 2. Keep it stopped through step 3; step 4 starts it again. Replace `CHECKOUT` with the absolute path of your checkout and `TAG` with the release you want.
100
102
 
101
103
  1. Drain, then stop the service. With built-in auth, drain first while the old service still runs: `git -C CHECKOUT worktree add "$HOME/dalan-drain" TAG`, then `cd "$HOME/dalan-drain" && npm ci && env -u DALAN_HOME -u DALAN_LOOPBACK HOME=BRIDGE_HOME NODE_ENV=production DALAN_AUTH_MODE=builtin DALAN_PORT=PORT node scripts/upgrade-drain.mjs` (values from [Run a command in the service's environment](#pre-upgrade-checklist)). Then stop the service. Linux: `systemctl --user stop dot-bridge-NAME.service`. macOS: `launchctl bootout user/$(id -u) ~/Library/LaunchAgents/LABEL.plist`; for an agent that an earlier release loaded, use `gui/$(id -u)` instead of `user/$(id -u)`. `LABEL` is `org.dalan.dot-bridge-NAME` for a new install. An install made by a release before 0.4.0 has a different label; find its file with `ls ~/Library/LaunchAgents | grep dot-bridge`. The path is under the `HOME` that setup ran with, which is the directory that holds your `Library` folder.
104
+
105
+ Before replacing or relinking the old checkout, use `node "$HOME/dalan-drain/bin/dalan.mjs"` instead of `dalan` for the backup recipe's CLI calls, with the same service environment. This uses the new tag staged above while leaving the serving checkout unchanged.
102
106
  2. Replace the code, then link it again so the commands in this document exist:
103
107
 
104
108
  ```sh
@@ -114,9 +118,9 @@ A source install is a Git checkout that `npm link` put on your PATH. Steps 1 to
114
118
  A checkout of a release before 0.4.0 is linked under the old package name `dot-bridge`. `npm unlink -g dot-bridge` removes the old link and its commands only; it prints nothing to remove if you never linked the old code. A release before 0.4.0 installs `dot-worker`, not `dalan`; `dalan` exists after the `npm link` above. Then run `node scripts/worker-bridge-setup.mjs --repoint --worker NAME` from this checkout, whether or not it moved. It points the unit at this checkout when the path changed, and on macOS it adds the `Background` and `Aqua` session types that the `user/UID` domain needs to a plist that lacks them (it prints `already points at` when there is nothing to change). It changes nothing else in the unit. It finds only the label `org.dalan.dot-bridge-NAME`: for a macOS agent made by a release before 0.4.0, delete the old plist by hand (step 1) and write a new unit with the `--write-units-only` command in step 4 of [Upgrade an npm install](#upgrade-an-npm-install) before you start the service.
115
119
  3. Run the commands in the checklist above (`dalan worker migrate-repos --json`, `dalan doctor --json`, `dalan worker list --json`) under the service's own HOME and environment, as in [Run a command in the service's environment](#pre-upgrade-checklist).
116
120
  4. Start the service again, then run `dalan resume` (with the same `env` prefix) if you drained.
117
- - Linux: `systemctl --user start dot-bridge-NAME.service`, then `systemctl --user is-active dot-bridge-NAME.service` must print `active`.
121
+ - Linux: `systemctl --user daemon-reload && systemctl --user start dot-bridge-NAME.service`, then `systemctl --user is-active dot-bridge-NAME.service` must print `active`.
118
122
  - macOS: step 1 unloaded the agent, so load it first: `launchctl bootstrap user/$(id -u) ~/Library/LaunchAgents/LABEL.plist`, then `launchctl kickstart -k user/$(id -u)/LABEL`, then `launchctl print user/$(id -u)/LABEL | grep -E 'state|runs'` must show `state = running`. `kickstart` alone fails with exit 113 after `bootout`, because the service is no longer loaded. Keep the `kickstart` after the `bootstrap`: a plist generated by an older release can load with `state = not running` and never start until it is kicked.
119
- 5. Check the log shows `MCP listening`, run the schema check from [Confirm the schema](#pre-upgrade-checklist) (it must print `65`), then finish a [first-job smoke check](operations.md#smoke-check-an-installed-service).
123
+ 5. Check the log shows `MCP listening`, run the schema check from [Confirm the schema](#pre-upgrade-checklist) (it must print `66`), then finish a [first-job smoke check](operations.md#smoke-check-an-installed-service).
120
124
 
121
125
  The upgrade does not rewrite the service that an older release generated. That service keeps its unit or plist name (on macOS, the launchd label that release created), its `DOT_BRIDGE_*` environment names and its `~/.config/dot-bridge`, `~/.local/share/dot-bridge` and `~/.local/state/dot-bridge` directories. It works as it did, and each start logs one deprecation line for the old environment names. `worker-bridge-setup.mjs --remove` finds only the current label. Stop an agent of a release before 0.4.0 and delete its plist by hand before you remove the install; `--purge-home` refuses while another unit file in the user's unit directory names the home or a process holds its `bridge.db` open, and it names what it found. Do not run `worker-bridge-setup.mjs` again for the same worker to "refresh" it: it refuses to overwrite an existing unit.
122
126
 
@@ -124,7 +128,7 @@ The upgrade does not rewrite the service that an older release generated. That s
124
128
 
125
129
  Fresh homes use `~/.config/dalan`, `~/.local/share/dalan`, `~/.local/state/dalan`, `~/.tmp/dalan`, and `~/.dalan/prepared-node-modules`. An existing legacy root remains in use when the corresponding new root is absent. Existing legacy installations also keep their not-yet-created state roots under the old name. An empty new root, empty directory scaffolding or zero-byte placeholders never hide a populated legacy root. Partial bootstrap roots also remain inactive until they contain the listed durable components present in the legacy root: authorization keys, database ledgers, worker profiles and their audit, thread limits, alert files and the ACP secret. Signal tokens count as one group: if the legacy root holds any `signal-token` or `signal-token.NAME` file, the new root must hold at least one, because rotation can replace one form with the other. The check uses this fixed list. It is not a full comparison, so a copy that lacks a custom file can still win; move whole roots, as below, and verify `dalan paths` afterwards. A listed file you removed on purpose from the new root keeps the legacy root in use; remove it from the legacy root too, or remove the legacy root after the explicit migration. When both corresponding roots are initialized, the new root wins. Companion roots that do not exist yet follow the existing installation; after a complete config, data or state area is explicitly migrated, absent companions use the new spelling. Complete config-only or data-only migrations can therefore start with the other area still under its legacy name. A missing workers profile recorded as previously present still requires explicit recovery, regardless of the directory spelling. Files from two roots are never merged. Repository checks prefer `.dalan.json` and accept `.dot-bridge.json` when the new file is absent.
126
130
 
127
- No startup command moves data. Existing OAuth issuers (an external issuer keeps being asked for the `dot-bridge.read` and `dot-bridge.work` scopes unless you set `OAUTH_SCOPE_NAMES=neutral` in `oauth.env`), resource URLs, scopes, client IDs, signing keys, storage keys, database records and path secrets retain their values. Existing unit filenames and adapter command filenames remain valid.
131
+ No startup command moves data. Existing OAuth issuers (an external issuer keeps being asked for the `dot-bridge.read` and `dot-bridge.work` scopes unless you set `OAUTH_SCOPE_NAMES=neutral` in `oauth.env`), resource URLs, scopes, client IDs, signing keys, storage keys, database records and path secrets retain their values. Existing service-unit filenames and internal adapter script filenames remain compatibility names. The globally installed executable names change to `dalan` and `dalan-*` as listed at the start of this guide; update scripts and timers that invoke the old package commands.
128
132
 
129
133
  When a populated new config, data or state root is passed over, `dalan paths` warns on stderr (`--json` includes a `warnings` array) and startup logs a `root_passed_over` event naming the area, chosen legacy root, passed-over new root and missing legacy file names, never their contents; complete or empty new roots do not warn.
130
134
 
@@ -161,7 +165,7 @@ The six `t3_thread_*` tools are off by default. Two read threads (`t3_thread_lis
161
165
 
162
166
  `notify_owner` is the notification tool. Its earlier alias was removed; a call to the old name now fails with `unknown tool`, so change any caller and refresh the connector. `notify_owner` keeps its `{text}` schema, work scope, capability check, audit admission and persistent deduplication ledger. It does not depend on the reverse-control switch. Notification retries keep using the `dot-bridge/idempotencyKey` metadata namespace.
163
167
 
164
- Refresh a non-legacy connector for a worker with the `t3` capability to discover `notify_owner`. A worker without that capability cannot discover or call either notification alias. With the reverse-control switch enabled, all previously advertised tool names and input schemas remain. The explicit `legacy-v46` compatibility profile retains its exact twelve-tool catalog; it gains neither notification alias. No OAuth scope rename or new authorization grant is needed for existing tools. See [T3 reverse control](t3-reverse-control.md).
168
+ Refresh non-legacy connectors after changing the catalog profile or global T3 setting. Modern `tools/list` is process-wide: workers see the same advertised schemas, and a name does not grant call authority. `notify_owner` remains advertised, while its call requires the worker's `t3` capability; the six `t3_thread_*` names depend on the global reverse-control switch and their calls also require that capability. The removed notification alias is the exception described above: callers must use `notify_owner`. The explicit `legacy-v46` compatibility profile retains its pinned catalog behavior and gains no notification tool. No OAuth scope rename or new authorization grant is needed for existing tools. See [T3 reverse control](t3-reverse-control.md).
165
169
 
166
170
  ## Repository policy requires an explicit list
167
171
 
@@ -207,7 +211,7 @@ For an existing identity profile, startup fills only omitted lists and leaves ex
207
211
 
208
212
  The private journal commits each seed and one audit event together, with `before: legacy-any` and `after: exact`. Interrupted profile publication reuses that committed seed. Doctor and `worker list --json` show the resulting lists and audit events. Back up `workers-repos.json` with the rest of the private configuration. Preserve `bridge.db.secrets/storage.key` with the encrypted database too; a new data sibling missing that key cannot replace the legacy root, even when all its other data files exist.
209
213
 
210
- Before upgrading a built-in-auth installation, run `node scripts/upgrade-drain.mjs` from the new release while the old service is still running, with the old HOME and environment. From a checkout, run it in a checkout of the new tag (`git worktree add`). For an npm install, run it from a scratch copy of the new package (`npm install --prefix "$HOME/dalan-new" @tnunamak/dalan`, then `cd "$HOME/dalan-new/node_modules/@tnunamak/dalan"`): it uses the `bin/dot-worker.mjs` in the current directory. It pauses new claims but does not pause submissions, so jobs can still be queued while it waits. It prints each active job ID and lease expiry. The default timeout is five minutes; set `DALAN_UPGRADE_DRAIN_TIMEOUT_MS` for another bounded wait. If a command times out, returns an HTTP error, or prints invalid JSON, the drain prints the same recovery step: keep the old service running, let workers finish or wait for leases to expire, run `dalan resume` under the old HOME, then retry the drain. After a successful drain, stop the old service, replace only the code, start the new service with the same HOME and configuration, then run `dalan resume` to release the persisted pause. An expired lease revokes the old claim ID but does not prove its process stopped; the new service sweeps the row back to the queue, where the claimant can resume the work only with a fresh claim epoch after stopping the old run. Pre-upgrade claims have no authenticated connection binding and cannot be safely assigned one during migration.
214
+ Before upgrading a built-in-auth installation, run `node scripts/upgrade-drain.mjs` from the new release while the old service is still running, with the old HOME and environment. From a checkout, run it in a checkout of the new tag (`git worktree add`). For an npm install, run it from a scratch copy of the new package (`npm install --prefix "$HOME/dalan-new" @tnunamak/dalan@VERSION`, then `cd "$HOME/dalan-new/node_modules/@tnunamak/dalan"`): it uses the `bin/dot-worker.mjs` in the current directory. Use the same `VERSION` that you will install in the upgrade; do not substitute the latest release for the planned one. It pauses new claims but does not pause submissions, so jobs can still be queued while it waits. It prints each active job ID and lease expiry. The default timeout is five minutes; set `DALAN_UPGRADE_DRAIN_TIMEOUT_MS` for another bounded wait. If a command times out, returns an HTTP error, or prints invalid JSON, the drain prints the same recovery step: keep the old service running, let workers finish or wait for leases to expire, run `dalan resume` under the old HOME, then retry the drain. After a successful drain, stop the old service, replace only the code, start the new service with the same HOME and configuration, then run `dalan resume` to release the persisted pause. An expired lease revokes the old claim ID but does not prove its process stopped; the new service sweeps the row back to the queue, where the claimant can resume the work only with a fresh claim epoch after stopping the old run. Pre-upgrade claims have no authenticated connection binding and cannot be safely assigned one during migration.
211
215
 
212
216
  To inspect and finish the migration before restarting the service, stop the service and run the new build with its HOME, PATH and environment:
213
217
 
package/docs/deadman.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # External heartbeat dead-man
2
2
 
3
- `dalan-deadman` is a small receiver for health-gated pings from the bridge host. Run it on an independently powered and networked host of your choice. It stores heartbeat and episode state in SQLite on that host. The bridge host sends `POST /heartbeat` with `Authorization: Bearer <token>` and `{"healthy":true}`. The body is limited to 1 KiB. The receiver accepts only `{"healthy":true}`; any other field, including a sender timestamp, gets HTTP 400. It records its own receive time.
3
+ `dalan-deadman` is a small receiver for health-gated pings from the bridge host. Run it on an independently powered and networked host. The setup below requires Linux with systemd on both the receiver and bridge hosts; other service managers need their own installation steps. It stores heartbeat and episode state in SQLite on that host. The bridge host sends `POST /heartbeat` with `Authorization: Bearer <token>` and `{"healthy":true}`. The body is limited to 1 KiB. The receiver accepts only `{"healthy":true}`; any other field, including a sender timestamp, gets HTTP 400. It records its own receive time.
4
4
 
5
5
  The receiver opens an episode after five minutes without a heartbeat. A new process waits through a five-minute startup grace period for a ping before opening a new episode; an episode already open before restart keeps its alert and reminder state. It sends one initial notification, then one reminder two hours after a confirmed initial notification if the episode remains open. It clears an episode only after timely pings continue for 15 minutes. A tick that observes a late or missing heartbeat resets the recovery clock. Deadline arithmetic uses a monotonic logical clock while the process runs, so wall-clock steps do not freeze recovery. The receiver anchors that clock across restarts using persisted state and nonnegative wall-clock downtime. A new episode is created for a later outage.
6
6
 
7
7
  Notification publication is optional: set `DOT_DEADMAN_NTFY_URL` to an HTTPS ntfy topic URL and, if required, set `DOT_DEADMAN_NTFY_TOKEN`. Missing publisher configuration leaves delivery pending and makes no off-host delivery claim. Confirmed 4xx rejections and failures observed before transport is ready are retried after one minute. Publication uses a total five-second deadline: a timeout before TCP connection (or TLS handshake) completes is safe to retry. A timeout after transport is ready, a 5xx response, or a process crash during publication is marked uncertain and is not resent automatically, because the provider may have accepted the notification. The database retains that evidence. The publisher never follows redirects; redirects and TLS certificate/protocol failures before a completed handshake are recorded as publisher configuration errors and retried only after service restart, once the endpoint is corrected. Publisher tokens with control characters or invalid header values, and URLs containing user credentials, are rejected before the monitor starts. Configuration errors contain no token or URL credentials. Messages contain no heartbeat payload, token, or bridge assignment text.
8
8
 
9
- One auditable state machine holds all of this policy, which is easier to test than a notification provider's vendor-specific repeat, reminder and hysteresis settings. The provider only transports notifications; it does not decide when an episode starts or clears.
9
+ If publication becomes `uncertain`, check the receiver for the alert's stable delivery reference before retrying. Follow [Interrupted dead-man alerts](durability-audit.md#interrupted-dead-man-alerts) to reconcile the result. Do not record `unsent` while delivery is still ambiguous: that decision permits another send.
10
+
11
+ Dalan decides when an episode starts, when to send a reminder and when to clear it. The notification provider only transports those messages.
10
12
 
11
13
  ## Operator setup
12
14
 
@@ -47,7 +49,7 @@ The timer is one minute; the five-minute receiver deadline tolerates a few misse
47
49
 
48
50
  ## Local check
49
51
 
50
- Run the deterministic state and HTTP boundary checks with:
52
+ From a source checkout installed with `npm ci`, run the deterministic state and HTTP boundary checks below. These test scripts are not included in the npm package:
51
53
 
52
54
  ```sh
53
55
  node scripts/deadman-test.mjs
@@ -7,7 +7,7 @@
7
7
  | Tool | Does | Read-only |
8
8
  | --- | --- | --- |
9
9
  | `dalan_submit` | Queues an assignment, like `dalan submit`. Returns the `request_id` and the bridge verdict. A `clarify` or `reject` verdict comes back as an error result with its reasons. Optional: `worker`, `execution`, `dry_run`, `queue_anyway`, `refuse_defer`. | no |
10
- | `dalan_wait` | Waits for a stop. `timeout_seconds` defaults to 120 and is capped at 300. On timeout it returns the current state (`"status": "timeout"`); call it again. | yes |
10
+ | `dalan_wait` | Waits for a finished report, question, blocker, cancellation, worker break or timeout. `timeout_seconds` defaults to 120 and is capped at 300. A timeout returns `status: timeout`; call again to keep waiting. | yes |
11
11
  | `dalan_result` | Returns the job state and, once finished, the report. Secrets are redacted. Output over 32 KiB is cut at 32 KiB and ends with a note on how to read the rest. | yes |
12
12
  | `dalan_status` | Returns `dalan status --json`. | yes |
13
13
 
@@ -15,14 +15,14 @@ Each tool runs the matching `dalan` command with `--json`, so receipts, assignme
15
15
 
16
16
  ## Access
17
17
 
18
- The server has the access of the user who starts it: it reaches the bridge through the local admin socket, as the CLI does. It opens no network port and has no separate credential. Do not run it for someone you would not give `dalan` to. Set `DALAN_HOME` in the server environment if your bridge home is not the default.
18
+ The server has the access of the user who starts it: it reaches the bridge through the local admin socket, as the CLI does. It opens no network port and has no separate credential. Do not run it for someone you would not give `dalan` to. Set `DALAN_HOME` explicitly in this MCP server's environment to the exact home of the running bridge. For a normal `dalan try`, that is `$HOME/.local/share/dalan-trial`; if the trial printed another home, use that instead. The trial home is not the CLI's normal default, and `dalan mcp` does not stop to ask which home you meant.
19
19
 
20
20
  ## Claude Code
21
21
 
22
+ This example uses the usual trial home. Replace it with the home printed by your running bridge, and replace `/path/to/dalan` as described below.
23
+
22
24
  ```sh
23
- claude mcp add dalan -- /path/to/dalan mcp
24
- # with a custom bridge home:
25
- claude mcp add dalan --env DALAN_HOME=/path/to/bridge-home -- /path/to/dalan mcp
25
+ claude mcp add dalan --env DALAN_HOME="$HOME/.local/share/dalan-trial" -- /path/to/dalan mcp
26
26
  ```
27
27
 
28
28
  ## Codex
@@ -33,7 +33,9 @@ Add this to `~/.codex/config.toml`:
33
33
  [mcp_servers.dalan]
34
34
  command = "/path/to/dalan"
35
35
  args = ["mcp"]
36
- # env = { DALAN_HOME = "/path/to/bridge-home" }
36
+ env = { DALAN_HOME = "/absolute/path/to/the-running-bridge-home" }
37
37
  ```
38
38
 
39
39
  Replace `/path/to/dalan` with the output of `command -v dalan`, or with `node /path/to/dalan/bin/dalan.mjs` split into `command = "node"` and `args = ["/path/to/dalan/bin/dalan.mjs", "mcp"]`.
40
+
41
+ Use an absolute home path in the TOML; do not leave `$HOME` or `~` in it. Start a new client session and ask it to call `dalan_status`. Check that the returned status belongs to your running bridge before submitting a job. If the call cannot connect, verify the configured home and run `dalan status --json` in a shell using that same `DALAN_HOME`. For a complete submit-and-result example, follow [Send one small job and read the result](codex-to-muse.md#4-send-one-small-job-and-read-the-result), using your connected worker's name.
@@ -2,20 +2,20 @@
2
2
 
3
3
  # Manual setup
4
4
 
5
- `try` runs ordinary `dalan` commands in a private trial home. Use this page to run each piece yourself: to keep the bridge in the foreground, to choose your own worker name, or to set up a client that `try` does not cover. You need a [checkout](../README.md#from-source), two shells and a worker client with OAuth.
5
+ `try` runs ordinary `dalan` commands in a private trial home. Use this page to run each piece yourself: to keep the bridge in the foreground, to choose your own worker name, or to set up a client that `try` does not cover. You need the npm package, two shells and a compatible HTTP MCP worker client with OAuth. This page explicitly installs the CLI globally before using bare `dalan` commands; `npx` alone does not put it on your persistent PATH.
6
+
7
+ For a hosted first result instead, use `npx -y @tnunamak/dalan try` ([hosted trial](../README.md#quickstart)). In `auto` mode, a saved temporary-relay choice selects bundled Gozar. Otherwise Dalan uses a usable Tailscale route, then Gozar if Tailscale is unavailable. When Gozar is selected, Dalan names tunnl.gg, links its terms and privacy notice, and asks for consent before exposure. Gozar then creates an installation-owned key for the `tunnl-gg` relay; Dalan does not pass your SSH keys. The relay terminates TLS and can see the connector URL and traffic. Keep private work out of the demo. A temporary demo link can change or stop without warning; the three-hour trial limit is not an availability promise. Use `--route tailscale` to require Tailscale without a relay fallback. The loopback recipe below creates no public route.
6
8
 
7
9
  <a id="owner-and-requester-setup"></a>
8
10
 
9
11
  ## Owner and requester setup
10
12
 
11
- 1. Clone and install Dalan, and put `dalan` on your PATH.
13
+ 1. Install Dalan and put `dalan` on your PATH.
12
14
 
13
15
  ```sh
14
- git clone https://github.com/tnunamak/dalan.git
15
- cd dalan
16
16
  node --version
17
- npm ci
18
- npm link
17
+ npm install -g @tnunamak/dalan
18
+ dalan --version
19
19
  ```
20
20
 
21
21
  **Check:** Node prints `v24` or higher, and npm finishes without an error. The server in step 3 starts Node with a changed `HOME`, so use a Node executable that works then; a version-manager shim can depend on your usual home directory.
@@ -33,10 +33,10 @@
33
33
  ```sh
34
34
  export DALAN_LOOPBACK=1 DALAN_AUTH_MODE=builtin DALAN_PORT=8799
35
35
  dalan init --worker local --public-url http://127.0.0.1:8799
36
- HOME="$DALAN_HOME" DALAN_LOOPBACK=1 DALAN_AUTH_MODE=builtin DALAN_PORT=8799 node src/server.mjs
36
+ HOME="$DALAN_HOME" DALAN_LOOPBACK=1 DALAN_AUTH_MODE=builtin DALAN_PORT=8799 node "$(npm root -g)/@tnunamak/dalan/src/server.mjs"
37
37
  ```
38
38
 
39
- **Check:** `init` reports a new worker profile for `local`, and the server prints `MCP listening on 127.0.0.1:8799` and keeps running. Leave this terminal open: closing it stops the bridge. If you plan a repository job, add `DALAN_ENABLE_WORKSPACE=1` to the server command now to save a restart. If the port is taken, choose another free port in both commands.
39
+ **Check:** `init` reports a new worker profile for `local`, and the server prints `MCP listening on 127.0.0.1:8799` and keeps running. Leave this terminal open: closing it stops the bridge. If you plan a repository job, add `--enable-workspace` to the `init` command before creating the home, and add `DALAN_ENABLE_WORKSPACE=1` to the server command. Both the worker grant and the host flag are required; exact repository access is granted separately. If the port is taken, choose a free port and replace `8799` in the exported `DALAN_PORT`, the init public URL, and the server command. Use that same port in the worker's MCP URL.
40
40
 
41
41
  4. In a second shell, export the same `DALAN_HOME`, then check the bridge.
42
42
 
@@ -1,7 +1,6 @@
1
1
  # Mirror fetch ownership
2
2
 
3
- Mirrors hold full Git objects for live worktrees and reference clones. They must
4
- not use partial clones or prune objects that consumers still need.
3
+ Dalan keeps a local Git mirror, a reusable repository cache, so jobs can fetch pinned commits and create working copies without downloading every object again. Those working copies may still read objects from the mirror. Keep the mirror complete and do not prune objects while any working copy depends on them.
5
4
 
6
5
  `prepareGithubRepo` runs fetches through `src/mirror-fetch.mjs`. The synchronous
7
6
  API stays in place; a Node child supervises a detached Git process group.