@tnunamak/dalan 0.6.2 → 0.8.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 (74) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/CONTRIBUTING.md +4 -0
  3. package/PROTOCOL.md +2 -0
  4. package/README.md +81 -84
  5. package/bin/dalan.mjs +9 -0
  6. package/bin/dot-worker.mjs +29 -4
  7. package/contracts/adapter-qualification.schema.json +170 -0
  8. package/docs/chatgpt-worker-onboarding.md +10 -14
  9. package/docs/claude-worker-onboarding.md +9 -8
  10. package/docs/codex-to-muse.md +21 -35
  11. package/docs/connect-chatgpt.md +10 -16
  12. package/docs/dalan-upgrade.md +4 -2
  13. package/docs/local-agent-mcp.md +24 -4
  14. package/docs/local-agent-requester.md +46 -0
  15. package/docs/manual-setup.md +2 -2
  16. package/docs/operations.md +12 -13
  17. package/docs/pull-workers.md +1 -2
  18. package/docs/service-setup.md +110 -163
  19. package/docs/setup-reference.md +6 -6
  20. package/docs/t3-question-relationship.md +43 -0
  21. package/docs/t3-reverse-control.md +12 -8
  22. package/docs/t3-wake-fence-r4.md +42 -0
  23. package/docs/test-suite-isolation.md +204 -0
  24. package/docs/worker-clients.md +6 -4
  25. package/package.json +5 -3
  26. package/qualification/README.md +13 -0
  27. package/qualification/mcp.json +121 -0
  28. package/qualification/protocol-v0.json +127 -0
  29. package/scripts/dalan-try-selfcheck.mjs +8 -7
  30. package/scripts/worker-bridge-setup.mjs +91 -81
  31. package/src/admin-socket.mjs +2 -1
  32. package/src/answer-journal.mjs +200 -0
  33. package/src/as-store.mjs +5 -3
  34. package/src/as.mjs +35 -26
  35. package/src/auth-check.mjs +59 -0
  36. package/src/cli-help.mjs +16 -16
  37. package/src/client-approval.mjs +57 -0
  38. package/src/client-convenience.mjs +166 -0
  39. package/src/client-conveniences.json +106 -0
  40. package/src/client-conveniences.schema.json +97 -0
  41. package/src/connect-cli.mjs +5 -5
  42. package/src/default-home.mjs +36 -0
  43. package/src/destinations/index.mjs +6 -0
  44. package/src/destinations/none.mjs +3 -0
  45. package/src/destinations/t3.mjs +63 -6
  46. package/src/execution.mjs +20 -2
  47. package/src/follow-current.mjs +27 -0
  48. package/src/gozar-routes.mjs +315 -0
  49. package/src/host-budget.mjs +17 -11
  50. package/src/host-execution-policy.mjs +2 -2
  51. package/src/host-stop-reverify.mjs +6 -4
  52. package/src/integrator.mjs +3 -1
  53. package/src/redirect-policy.mjs +61 -0
  54. package/src/route-setting.mjs +71 -12
  55. package/src/server.mjs +64 -12
  56. package/src/service-auto-update.mjs +8 -1
  57. package/src/service-launchd.mjs +186 -0
  58. package/src/service-migrate-workers.mjs +12 -2
  59. package/src/service-update-runtime.mjs +40 -6
  60. package/src/service-update.mjs +20 -14
  61. package/src/service.mjs +211 -63
  62. package/src/setup.mjs +55 -44
  63. package/src/store.mjs +77 -14
  64. package/src/submission-policy.mjs +8 -4
  65. package/src/t3.mjs +21 -2
  66. package/src/tool-registry.mjs +54 -8
  67. package/src/try-exposure.mjs +7 -657
  68. package/src/try-hosted.mjs +71 -101
  69. package/src/try-selfcheck.mjs +15 -8
  70. package/src/try.mjs +9 -13
  71. package/src/workers.mjs +4 -3
  72. package/src/workspace.mjs +94 -15
  73. package/scripts/lib/expose-tailscale.mjs +0 -408
  74. package/src/try-hosted-clients.mjs +0 -46
@@ -1,249 +1,196 @@
1
1
  # Run Dalan as a service
2
2
 
3
- Use this guide after a first job works with `dalan try`, when you want a bridge that keeps running or a worker on another computer. Built-in OAuth binds the bridge to `127.0.0.1`; a tunnel or HTTPS reverse proxy forwards worker traffic to that listener. The owner CLI uses a private Unix socket, which must never be exposed through the proxy.
3
+ Install Dalan once to keep your MCP agent connected to your Mac or Linux computer. You do not need to run the trial first.
4
4
 
5
- ## Install one bridge for several workers
5
+ Before you begin, install Node.js 24 or newer and Tailscale with Funnel enabled. Your agent's account must allow custom MCP connectors. The basic install commands below are the same on macOS and Linux; forwarding to a non-loopback target is Linux-only.
6
6
 
7
- The Linux-only `dalan service install` creates a systemd user service and registers its HTTPS origin as a Gozar service route. Gozar records and verifies an origin-to-target route that your reverse proxy already serves; it does not edit the proxy. The bridge uses built-in OAuth. Moving a connector to the new URL requires reauthorization and a catalog refresh. All workers use the same stable catalog. The process-wide `legacy-v46` setting remains available for other installations. Its auth keys, worker allowlists and job queue stay in one private home.
7
+ **Tailscale prerequisite.** `--route tailscale` publishes through Tailscale Funnel, which your tailnet administrator must allow (a `funnel` entry in the tailnet access controls; HTTPS and MagicDNS must be on too). If Funnel is not allowed, Dalan stops before it publishes anything and tells you which setup step is missing, or prints Tailscale's own refusal. Enable Funnel once at <https://tailscale.com/kb/1223/funnel>, then run the command again. Other routes need no Tailscale setting; `dalan setup` lists them.
8
8
 
9
- First prepare the public origin so it forwards to the address in `--target`. Preserve the public `Host` header. The bridge rejects requests with another Host, including requests that try to replace it with `X-Forwarded-Host`. The proxy must pass the secret MCP path, the OAuth discovery and authorization paths, `/signal/*` when used, and `/.well-known/gozar/service` with its query string. TLS terminates at the proxy. Keep the secret path out of proxy logs.
9
+ <a id="owner-setup"></a>
10
10
 
11
- For existing installations, create the new home and copy each worker's repository allowlist. Replace the example paths with the old bridge homes on this computer:
11
+ ## Install and connect your agent
12
+
13
+ This example names your worker `assistant`. Choose another lowercase name if you prefer, and use it in every command.
12
14
 
13
15
  ```sh
14
- dalan service migrate-workers \
15
- --home "$HOME/.local/share/dalan-service" \
16
- --source "$HOME/.config/dot-bridge/workers.json" \
17
- --source "$HOME/OLD_BRIDGE_TWO/.config/dot-bridge/workers.json" \
18
- --source "$HOME/OLD_BRIDGE_THREE/.config/dot-bridge/workers.json"
16
+ npm install -g @tnunamak/dalan
17
+ dalan service install --worker assistant --route tailscale
18
+ dalan connect start --worker assistant
19
19
  ```
20
20
 
21
- The helper reads the source files without changing them. If an older home has no `workers.json`, it can read the adjacent `workers-repos.json` migration journal. It preserves worker names and repository allowlists, and copies supported worker capabilities and guidance. It does not copy OAuth registrations, tokens, jobs or results. The new bridge starts with `default_execution: none`. Workspace access defaults to denied; add `--workspace-worker NAME` for each worker that needs an explicit workspace grant. This option records the owner's grant; it does not require an earlier audit record. Existing explicit `workspaceAllowed` and T3 capability settings are retained. Destination declarations are copied, but old destination approvals bind old jobs and connections, so each new job requires a fresh approval.
22
-
23
- Optionally pass `--source-db PATH` for each old job database. The helper opens it read-only and writes a private `service-migration.json` checklist containing active subscription counts, callback origins and destination approval counts. It omits callback paths, query strings, signing secrets and encrypted records. This checklist grants no authority. Re-enrol every connector, call `events/subscribe` with a fresh signing key, and approve each new destination revision. Without `--source-db`, the checklist still records those required steps but has no old subscription inventory. For a brand-new bridge, skip migration and pass `--worker NAME` once for each worker instead; those initial workers have empty repository allowlists, no capabilities, and no host execution.
24
-
25
- Replace `192.0.2.10` below with the address configured on this computer, then run the install after the proxy route reaches the target:
21
+ Dalan installs a background service, chooses a free port and remembers its settings. No environment variables or manual server process are needed.
26
22
 
23
+ Add the private connector URL shown by Dalan to the agent's MCP settings. Start sign-in in that client, then check the pending request:
27
24
  ```sh
28
- dalan service install \
29
- --home "$HOME/.local/share/dalan-service" \
30
- --public-url https://bridge.example.com \
31
- --port 8787 \
32
- --target 192.0.2.10:8787 \
33
- --lan-port 8787
25
+ dalan connect pending
34
26
  ```
35
27
 
36
- The Dalan process listens on `127.0.0.1:8787`. With `--lan-port`, systemd opens the address and matching port in `--target` and forwards it to that loopback listener. A separate target requires this explicit option, even when its numeric port equals the bridge port. Use a distinct non-wildcard address configured on this computer: the example binds 192.0.2.10:8787 separately from 127.0.0.1:8787. Do not use 0.0.0.0 for a same-port forwarder because it collides with loopback. Challenge verification binds the actual receiving socket port to the declared target port; its challenge path has no port override. Translating to a different numeric port is allowed only with an explicit nonempty trusted `--verify-cmd COMMAND`, not challenge verification. Add `--enable-workspace` or `--enable-t3` to enable those host capabilities; each worker must also have its own workspace or T3 grant. Without these options both host capabilities are disabled. If Gozar runs on the same computer and can reach loopback directly, set `--target 127.0.0.1:8787`. `gozar service add` runs after systemd starts the bridge; install succeeds only when Gozar returns a verified route. If the origin filters the Gozar verifier by source IP, pass the trusted host check with `--verify-cmd COMMAND`.
37
-
38
- Set `DALAN_HOME` to the selected home. The private MCP URL is stored in `$DALAN_HOME/resource-url` with mode 0600. Point the client's connector at that URL and sign in separately for each worker. Repository jobs remain blocked until their allowlists are present. `dalan service install` creates a unit named `dalan-<10 hex>.service`; use the exact unit name printed by install with `systemctl --user status UNIT`, then confirm the public origin returns 404 for `/admin` and accepts the secret MCP path with its original Host header.
39
-
40
- The service starts when the systemd user manager starts. `dalan service install` does not check or warn whether user lingering is enabled. Without lingering, the user manager may start only after the user logs in after a reboot. If the bridge must start before login, ask an administrator to run `loginctl enable-linger USER` for the account that owns the bridge.
41
-
42
- `--write-units-only` writes the systemd unit files without initializing the bridge home, starting systemd or calling Gozar. It is for offline inspection; run the normal install to finish setup.
43
-
44
- ### Restarting and backing up built-in sign-ins
45
-
46
- With compatible code, a restart using the same private home and issuer preserves an unexpired built-in OAuth access token while its grant and connection remain live. The issuer includes the public origin and secret path. Access tokens last up to one hour.
47
-
48
- Before an upgrade or restore, stop the bridge and every other writer and make a consistent SQLite backup. Preserve the complete active private config directory, including `as.json`, `as-jwks.json`, `as-cookie-keys.json`, `as.sqlite` and its sibling `as-storage.key`; the keys alone cannot restore sign-ins. Follow the [backup and rollback steps](operations.md#upgrade-and-rollback).
49
-
50
- For the built-in public-client flow, a client that loses a refresh response can recover it only by retrying the identical request within five seconds, while the successor token and connection remain live. A retry after that window can fail and require the client to pair again. This is not a promise of recovery after a longer outage or across incompatible code or storage changes.
28
+ Compare the pending code with the code in your client. If they match, replace `CODE` with that code:
29
+ ```sh
30
+ dalan connect approve CODE --worker assistant
31
+ ```
51
32
 
52
- ## Legacy setup with `scripts/worker-bridge-setup.mjs`
33
+ Do not approve a code you did not request, and do not share the connector URL or codes.
53
34
 
54
- The sections below document the separate legacy setup script, not `dalan service install`. The script supports the Linux and macOS setup options shown below. In particular, its `dot-bridge-NAME.service` unit name and lingering warning do not apply to `dalan service install`.
35
+ Next, [send your first job](../README.md#give-your-connected-agent-a-job), using `assistant` as the worker name. Dalan queues jobs; you must ask your agent to claim them. A new installation has no repository grants or permission to run host checks.
55
36
 
56
- ## Keep a local trial working
37
+ ### Optional checks
57
38
 
58
- Setup has no local-only service mode, and it needs either `--public-url https://HOST` or `--expose tailscale` (or `--expose ngrok`, for the [ngrok](https://ngrok.com/) tunnel service), so a service always has an HTTPS origin. Dalan does not supply a launchd or systemd recipe for a bridge that serves only `127.0.0.1`, and it cannot convert the paired trial home into a service. Do not point setup at the trial home: it needs a fresh home.
39
+ After pairing, use these if you need to diagnose the service:
40
+ ```sh
41
+ dalan status
42
+ dalan doctor --auth
43
+ ```
59
44
 
60
- To go from a trial to a service:
45
+ The authentication check tests the public route and sign-in flow, not whether an agent can complete a job.
61
46
 
62
- 1. Keep the trial home if you want its results. Save them first, while `dalan try` still runs: with `DALAN_HOME` set to the trial home, run `dalan inbox --all --json` to list the request IDs, then `dalan get REQUEST_ID --json > result-REQUEST_ID.json` for each result you want. Then stop `dalan try` with Ctrl-C.
63
- 2. Run setup below with a new home. It makes a new bridge, with its own keys and port.
64
- 3. Pair the worker again, as the setup steps below describe. Re-running `try` or pairing replaces the worker client's old connection. Remove the old entry first with `codex mcp remove NAME` or `claude mcp remove --scope user NAME`.
65
- 4. Run the first job again on the new bridge. Read old results from the files you saved in step 1. To read a result you did not save, the trial bridge must run again: `dalan get` asks the running bridge through the admin socket in `DALAN_HOME`, so with the trial stopped it fails with `connect ECONNREFUSED`, and setting `DALAN_HOME` does not start it. Start the retained trial bridge by hand, from the Dalan checkout or package directory, on the port that its `as.json` names (the trial home is tied to that port), then read the result from a second shell:
47
+ ### More workers and advanced setup
66
48
 
67
- ```sh
68
- export DALAN_HOME=TRIAL_HOME
69
- port="$(sed -n 's#.*"public_url": *"http://127.0.0.1:\([0-9][0-9]*\)".*#\1#p' "$(dalan paths --config-root)/as.json")"
70
- HOME="$DALAN_HOME" DALAN_LOOPBACK=1 DALAN_AUTH_MODE=builtin DALAN_PORT="$port" node src/server.mjs
71
- # second shell, with DALAN_HOME set to TRIAL_HOME again:
72
- dalan get REQUEST_ID --json
73
- ```
49
+ To configure several workers, repeat the flag in the install command, for example `dalan service install --worker assistant --worker reviewer --route tailscale`, and pair each separately. A worker name starts with a lowercase letter, uses lowercase letters, digits, hyphens or underscores, and is at most 32 characters; `pool` and `unknown` are reserved.
74
50
 
75
- Stop it with Ctrl-C when you have read the results. Do not run `dalan try` for this, because it pairs the worker again and replaces the worker client's connection to the new bridge. If the new service already listens on the trial's port, read the old results before you start the service.
51
+ ### Pairing details
76
52
 
77
- If you want only a bridge on this computer that stays up, run the server in a terminal as the [manual setup](manual-setup.md#owner-and-requester-setup) describes, which is the supported local path.
53
+ A client on this computer with a loopback callback needs `--confirm-redirect` with the exact redirect that `pending` shows; see [worker pairing](manual-setup.md#worker-setup). A worker on another computer follows [Native client on a remote HTTPS bridge](worker-clients.md#native-client-on-a-remote-https-bridge). Then run [submit, finish and read the result](manual-setup.md#submit-finish-and-read-the-result) with `--worker` set to your worker's name.
78
54
 
79
- ## Owner setup
55
+ Where the README and manual setup use the trial worker `local`, use your service's worker name as `NAME`:
80
56
 
81
- You need the installed package (from `npm install -g @tnunamak/dalan`) or a checkout, a stable Node.js 24 LTS or newer executable, a fresh private bridge home, and a free port from 1024 through 65535. Use short, space-free paths without symlinks; on Linux, starting the service needs a running systemd user manager; on macOS, it needs the user's launchd domain (`user/UID`), which exists while that user has a login session. `worker-bridge-setup.mjs` does not check the Node.js version.
57
+ - Submission: pass `--worker NAME` to `dalan submit` for the first job and for every repository job.
58
+ - Repository grants: `dalan worker allow NAME OWNER/REPO` and `dalan worker list NAME --json`.
82
59
 
83
- On macOS the service is a LaunchAgent. A LaunchAgent starts when you log in to the Mac and stops when you log out, so it does not run after a reboot until someone logs in and you cannot rely on it for unattended availability.
60
+ `wait`, `get` and `decide` select the job by request ID and take no worker flag.
84
61
 
85
- **After a reboot on macOS:**
62
+ The rest of this guide covers advanced routes, migration, updates and removal. None is required for the first connection.
86
63
 
87
- - **Check:** log in, then run `dalan status --json` (with `DALAN_HOME` set to the service home) and send one first job to prove the worker path still works.
88
- - **Check the agent itself:** run `launchctl print user/$(id -u)/org.dalan.dot-bridge-NAME | grep -E 'state|pid|runs'`. Setup loads the agent into the `user/UID` domain, and `state = running` with a `pid` means the bridge is up.
64
+ ### An existing reverse proxy
89
65
 
90
- **Symptom: `launchctl print` prints `Could not find service`.**
66
+ If you already serve a stable HTTPS address through your own reverse proxy, register that address with Gozar, the tool Dalan uses to publish its public route, instead of asking Gozar for a new route. This command is a template. Replace `PUBLIC_HOST` with your proxy's public hostname, `PORT` with a free local port number for Dalan to listen on, and `TARGET_IP:TARGET_PORT` with the IPv4 address and port your proxy forwards to, such as `127.0.0.1:8787` (a hostname is refused):
91
67
 
92
- - That print only says that the agent is not in the `user/UID` domain; it does not say the service failed.
93
- - **Check:** run `dalan status --json`, and run the same `launchctl print` with `gui/$(id -u)` in place of `user/$(id -u)`. An agent that an older release loaded lives in `gui/UID`.
94
- - **Action:** if neither shows `state = running` and `dalan status --json` fails, load the agent with the `bootstrap` and `kickstart` lines in [Restart a service and check its state](operations.md#restart-a-service-and-check-its-state).
68
+ ```sh
69
+ dalan service install --worker assistant --public-url https://PUBLIC_HOST --port PORT --target TARGET_IP:TARGET_PORT
70
+ ```
95
71
 
96
- The domain and label are the ones that `worker-bridge-setup.mjs` writes.
72
+ Gozar records and verifies an origin-to-target route that your reverse proxy already serves; it does not edit the proxy. Prepare the proxy first so the public origin forwards to the address in `--target`, an IPv4 address and port such as `192.168.1.20:8792`. Preserve the public `Host` header. The bridge rejects requests with another Host, including requests that try to replace it with `X-Forwarded-Host`. TLS ends at the proxy. Keep the secret path out of proxy logs.
97
73
 
98
- ### After a reboot
74
+ The proxy must forward these routes without removing their prefixes, methods, query strings, authorization headers or cookies:
99
75
 
100
- The bridge and the worker come back by separate rules:
76
+ | Route | Purpose |
77
+ |---|---|
78
+ | `/<secret>/mcp` | Carries worker MCP requests. |
79
+ | `/.well-known/oauth-protected-resource/<secret>/mcp` | Identifies the protected resource and authorization server. |
80
+ | `/.well-known/oauth-authorization-server/<secret>/oauth` | Publishes OAuth endpoints. |
81
+ | `/.well-known/openid-configuration/<secret>/oauth` | Provides the discovery alias. |
82
+ | `/<secret>/oauth` and `/<secret>/oauth/*` | Handle OAuth and browser pairing. |
83
+ | `/signal/*` | Answers wake hooks when configured. |
84
+ | `/.well-known/gozar/service` | Answers the Gozar check, with its query string. |
101
85
 
102
- - **Bridge, Linux.** The generated unit is wanted by `default.target`, so it starts when your systemd user manager starts. Without lingering, that is your first login after the reboot; with lingering (an administrator runs `loginctl enable-linger USER`; the legacy setup script warns when it is off), it is the boot. Check with `systemctl --user is-active dot-bridge-NAME.service`, which must print `active`.
103
- - **Bridge, macOS.** It starts at your login, as described above.
104
- - **Worker, both systems.** Dalan has no worker scheduler, and nothing wakes the worker when the bridge returns. Jobs wait in the queue until a worker run claims them. The supported way is manual, and it takes three steps. First wait until `dalan status --json` answers, with `DALAN_HOME` set to the service home. Then prompt the worker in its own client, for example: "Use Dalan to list pending work. Claim the oldest job you may claim, read it, report progress and finish it exactly as instructed. Stop when nothing is pending." In Codex, `codex exec "PROMPT" < /dev/null` runs that without a screen (see [worker clients](worker-clients.md)). Last, check that the job moved: `dalan wait REQUEST_ID` returns `finished`, or `dalan get REQUEST_ID --json` shows the report.
86
+ An unauthenticated request to `/admin` on the public origin must return 404. The Dalan process listens on `127.0.0.1:PORT`. On Linux, when the target is another address on this computer, pass `--lan-port N`; the service then opens the target address and forwards it to the loopback listener. Use a distinct non-wildcard address, not 0.0.0.0, which collides with loopback. macOS refuses other targets: use `--target 127.0.0.1:PORT` with the same port as `--port`. If Gozar runs on this computer and reaches loopback directly, use `--target 127.0.0.1:PORT`. Challenge verification binds the receiving socket port to the declared target port. Translating to a different numeric port needs an explicit, trusted `--verify-cmd COMMAND`. If the origin filters the Gozar verifier by source IP, pass the same option. Install succeeds only when Gozar returns a verified route.
105
87
 
106
- A schedule or hook in the worker's vendor tool is outside Dalan's supported path; [pull workers](pull-workers.md#ways-to-start-a-run) lists the patterns and what they cost. A queued job still expires under the [preparation-expiry rule](pull-workers.md#jobs-the-worker-never-takes) if no worker claims it in time.
88
+ ### Migrate an older bridge
107
89
 
108
- Setup writes the service definition under the `HOME` (macOS: `$HOME/Library/LaunchAgents`) or `XDG_CONFIG_HOME` (Linux: `$XDG_CONFIG_HOME/systemd/user`) of the shell that runs it. The service manager reads only the real user locations, so run setup with your normal `HOME` and `XDG_CONFIG_HOME`; a different value writes a definition the manager does not see. Concurrent setup runs for one user serialize on a lock file in `/tmp/dot-bridge-setup-locks-UID`. A test run that must not wait on that lock can set `DALAN_SETUP_LOCK_DIR` to its own absolute directory.
90
+ For existing installations, create the new home and copy each worker's repository allowlist. Change the `--source` path if your old bridge keeps `workers.json` elsewhere:
109
91
 
110
- Choose a worker name of up to 32 characters, starting with a lowercase letter and continuing with lowercase letters, digits, `-` or `_`. `pool` and `unknown` are reserved, and you replace `NAME`, `PORT`, `HOME_PATH` and the example hostname in the commands below.
92
+ ```sh
93
+ dalan service migrate-workers \
94
+ --home "$HOME/.local/share/dalan-service" \
95
+ --source "$HOME/.config/dot-bridge/workers.json"
96
+ ```
111
97
 
112
- ### With an existing HTTPS reverse proxy
98
+ Add one `--source PATH` per further old bridge home, replacing `PATH` with that home's `workers.json`.
113
99
 
114
- 1. Configure a stable HTTPS origin that forwards to the bridge computer at `127.0.0.1:PORT`. Preserve the public `Host` header, including a non-default port. Rewriting Host to localhost returns HTTP 421; `X-Forwarded-Host` does not override this check.
100
+ The helper reads the source files without changing them. If an older home has no `workers.json`, it can read the adjacent `workers-repos.json` migration journal. It preserves worker names and repository allowlists, and copies supported worker capabilities and guidance. It does not copy OAuth registrations, tokens, jobs or results. The new bridge starts with `default_execution: none`. Workspace access defaults to denied; add `--workspace-worker NAME` for each worker that needs an explicit workspace grant. This option records the owner's grant; it does not require an earlier audit record. Existing explicit `workspaceAllowed` and T3 capability settings are retained. Destination declarations are copied, but old destination approvals bind old jobs and connections, so each new job requires a fresh approval.
115
101
 
116
- Forward the following routes without removing their prefixes, methods, query strings, authorization headers or cookies.
102
+ Optionally pass `--source-db PATH` for each old job database. The helper opens it read-only and writes a private `service-migration.json` checklist containing active subscription counts, callback origins and destination approval counts. It omits callback paths, query strings, signing secrets and encrypted records. This checklist grants no authority. Re-enrol every connector, call `events/subscribe` with a fresh signing key, and approve each new destination revision. Without `--source-db`, the checklist still records those required steps but has no old subscription inventory. For a brand-new bridge, skip migration and pass `--worker NAME` once for each worker instead; those initial workers have empty repository allowlists, no capabilities, and no host execution.
117
103
 
118
- | Route | Purpose |
119
- |---|---|
120
- | `/<secret>/mcp` | Carries worker MCP requests. |
121
- | `/.well-known/oauth-protected-resource/<secret>/mcp` | Identifies the protected resource and authorization server. |
122
- | `/.well-known/oauth-authorization-server/<secret>/oauth` | Publishes OAuth endpoints. |
123
- | `/.well-known/openid-configuration/<secret>/oauth` | Provides the discovery alias. |
124
- | `/<secret>/oauth` and `/<secret>/oauth/*` | Handle OAuth and browser pairing. |
125
- | `/signal/*` | Answers wake hooks when configured. |
104
+ ### Move from a trial to a service
126
105
 
127
- The proxy should terminate TLS and keep secret-bearing paths out of access logs. An unauthenticated request to `/admin` should return 404.
106
+ A service needs a fresh home; do not point it at a trial home. To keep trial results, save them first while `dalan try` still runs: with `DALAN_HOME` set to the trial home that `try` printed, run `dalan inbox --all --json` to list request IDs, then `dalan get REQUEST_ID --json > result-REQUEST_ID.json` for each result you want, replacing `REQUEST_ID` with each ID. Then stop the trial with Ctrl-C, install the service, and pair the worker again. Pairing replaces the worker client's old connection; remove the old entry first with `codex mcp remove NAME` or `claude mcp remove --scope user NAME`, where `NAME` is the connector name you gave the client.
128
107
 
129
- 2. Generate and start the bridge from a checkout:
108
+ ### Keep the service running
130
109
 
131
- ```sh
132
- node scripts/worker-bridge-setup.mjs --worker NAME --public-url https://bridge.example.com --port PORT --home HOME_PATH --start
133
- ```
110
+ On Linux the service starts when the systemd user manager starts. Without lingering, that may be your first login after a reboot. If the bridge must start before login, ask an administrator to run `loginctl enable-linger USER`, replacing `USER` with the account that owns the bridge; install does not check or warn about it. On macOS the LaunchAgent starts when you log in and stops when you log out, so it does not run unattended after a reboot until someone logs in.
134
111
 
135
- From an npm install (`scripts/worker-bridge-setup.mjs` ships in the package), use the installed copy with the same options:
112
+ `--write-units-only` writes the service files without initializing the bridge home, starting the service or calling Gozar. It is for offline inspection; run the normal install to finish setup.
136
113
 
137
- ```sh
138
- node "$(npm root -g)/@tnunamak/dalan/scripts/worker-bridge-setup.mjs" --worker NAME --public-url https://bridge.example.com --port PORT --home HOME_PATH --start
139
- ```
114
+ ### Restarting and backing up built-in sign-ins
140
115
 
141
- Setup reports the private home and service definition. With an explicit `--public-url` it does not verify public DNS or HTTPS: before pairing, check that an unauthenticated request to `/admin` on the public origin returns 404. It enables repository tools unless you pass `--no-repo-tools`; it does not enable host checks or grant repositories. A reverse proxy on another Linux LAN computer can reach a generated forwarder by adding `--lan-forward ADDR:PORT`. Anything on that network can reach this forwarder, so retain HTTPS and OAuth at the public origin.
116
+ With compatible code, a restart using the same private home and issuer preserves an unexpired built-in OAuth access token while its grant and connection remain live. The issuer includes the public origin and secret path. Access tokens last up to one hour.
142
117
 
143
- 3. Set `DALAN_HOME` to the exact generated home and make `dalan` available on your PATH with the [manual setup](manual-setup.md#owner-and-requester-setup) steps (no shell helper is needed). The complete MCP URL is in the mode-0600 file `$DALAN_HOME/resource-url`. Use it only in the intended worker's connector settings.
118
+ Before an upgrade or restore, stop the bridge and every other writer and make a consistent SQLite backup. Preserve the complete active private config directory, including `as.json`, `as-jwks.json`, `as-cookie-keys.json`, `as.sqlite` and its sibling `as-storage.key`; the keys alone cannot restore sign-ins. Follow the [backup and rollback steps](operations.md#upgrade-and-rollback).
144
119
 
145
- ```sh
146
- dalan status --json
147
- ```
120
+ For the built-in public-client flow, a client that loses a refresh response can recover it only by retrying the identical request within five seconds, while the successor token and connection remain live. A retry after that window can fail and require the client to pair again. This is not a promise of recovery after a longer outage or across incompatible code or storage changes.
148
121
 
149
- Status returns the running bridge's state. Continue with [worker pairing](manual-setup.md#worker-setup), using this HTTPS endpoint instead of the local loopback URL. Skip the manual setup's `dalan init` and foreground `node src/server.mjs` steps: the setup script already created the profile and started the service. The `<secret>` in each route above is the `BRIDGE_PATH_SECRET` from the manual [worker setup](manual-setup.md#worker-setup).
122
+ <a id="after-a-reboot"></a>
150
123
 
151
- The README and manual setup examples use the trial worker `local`. In every command that names a worker, replace `local` with your service's `NAME`:
124
+ ## After a reboot
152
125
 
153
- - Pairing: `dalan connect start --worker NAME` and `dalan connect approve CODE --worker NAME`.
154
- - Submission: `dalan submit --worker NAME ...` for the first job and for every repository job.
155
- - Repository grants: `dalan worker allow NAME OWNER/REPO` and `dalan worker list NAME --json`.
126
+ The bridge and the worker come back by separate rules:
156
127
 
157
- `wait`, `get` and `decide` select the job by request ID and take no worker flag. Run them with `DALAN_HOME` set to this service's home; with the trial home they will not find the job.
128
+ - **Bridge.** Linux starts it with the systemd user manager (see lingering above). macOS starts it at your login. Check with `dalan service status` and `dalan status`.
129
+ - **Your agent.** Dalan does not start or schedule the agent. Once `dalan status` answers, open the client where you connected the agent and ask it: “Use Dalan to list pending jobs, claim the oldest job within your permissions, follow its brief, report progress and finish it. Stop when no jobs remain.” Check the result with `dalan wait REQUEST_ID` or `dalan get REQUEST_ID --json`, replacing `REQUEST_ID` with your job's ID.
158
130
 
159
- ### With Tailscale Funnel
131
+ A schedule or hook in the worker's vendor tool is outside Dalan's supported path; [pull workers](pull-workers.md#ways-to-start-a-run) lists the patterns and what they cost. A queued job still expires under the [preparation-expiry rule](pull-workers.md#jobs-the-worker-never-takes) if no worker claims it in time.
160
132
 
161
- A tailnet is your Tailscale private network. Check each item below before you run setup. Setup checks them too and stops with the exact next step when one is missing.
133
+ ## Service updates
162
134
 
163
- 1. **Tailscale daemon.** On macOS, Funnel needs the open-source `tailscaled`. The App Store app and the Standalone app do not supply it, and they conflict with it. If one of them is installed, quit it and move it to the Trash. Then install the daemon with [Homebrew](https://brew.sh/) and sign in:
135
+ New installs enable a daily update check: a systemd user timer on Linux (daily, up to one hour of random delay) and a launchd agent on macOS (every day at a fixed minute between 03:00 and 03:59 that depends on the home). On Linux, a missed run can run when the user manager next starts. On macOS, a check missed while the Mac is shut down or you are logged out is not caught up at the next login; run `dalan service update --check` yourself or wait for the next scheduled check. Installation with `--no-auto-update` disables the timer; `--auto-update` explicitly enables it. Reinstalling preserves the saved choice unless you pass one of those flags. On Linux, the timer needs your systemd user manager to run; it does not configure login lingering.
164
136
 
165
- ```sh
166
- brew install tailscale && sudo brew services start tailscale && sudo tailscale up
167
- ```
137
+ ```sh
138
+ dalan service update --check
139
+ dalan service update
140
+ dalan service status --json
141
+ dalan service auto-update off
142
+ dalan service auto-update on
143
+ ```
168
144
 
169
- See [macOS variants](https://tailscale.com/docs/concepts/macos-variants); on Linux, use the [installation guide](https://tailscale.com/download).
170
- 2. **Signed in.** Run `tailscale version` and `tailscale status`. The host must show as signed in.
171
- 3. **MagicDNS** (Tailscale's automatic DNS names for your devices). Turn it on at the [DNS page](https://console.tailscale.com/admin/dns).
172
- 4. **HTTPS Certificates.** On the same page, choose Enable HTTPS. Your machine's name then appears in public certificate transparency logs.
173
- 5. **Funnel policy.** In [Access controls](https://console.tailscale.com/admin/acls), add Funnel to the policy (the "Add Funnel to policy" button).
174
- 6. **Your shell user.** The user who runs setup must be allowed to manage Tailscale without `sudo`. If `tailscale funnel status` asks for `sudo`, run `sudo tailscale set --operator="$USER"` once.
145
+ The home defaults to `~/.local/share/dalan-service` and Dalan remembers it; pass `--home DIR` only to select a different one. `service status` shows the selected version, saved automatic-update preference and last update result. On Linux, use `systemctl --user list-timers` to inspect the actual timer schedule. Turning updates off prevents future starts; it does not cancel an update already running. Preference changes refuse while an update holds the home lock. A release that was rolled back is recorded and skipped on later runs, including the timer; `dalan service update --retry` tries it again, and a newer or republished release is attempted normally. `service status` shows it as `failed_release`.
175
146
 
176
- Run setup with Funnel instead of an explicit public URL. From a checkout:
147
+ `--check` queries the public npm registry for the latest stable `@tnunamak/dalan` version and reports availability without installation or restart. A normal update installs the exact release under `HOME/versions/<version>`, with npm integrity checks and install scripts disabled. The registry's integrity value binds the downloaded bytes to its metadata; it is not an independent publisher signature. The original package must remain available until the first successful update. Later starts use the selected package through `HOME/current`.
177
148
 
178
- ```sh
179
- node scripts/worker-bridge-setup.mjs --worker NAME --port PORT --home HOME_PATH --expose tailscale --start
180
- ```
149
+ Before switching, Dalan starts the candidate on a scratch loopback port against a private copy of the worker configuration, fresh mutable state, and synthetic keys made for that check. It never receives the service's signing, cookie, storage or operator keys. It checks initialization, ping and complete tool descriptors for every configured worker, then compares them with the running bridge. An unreachable worker, failed check or incomplete catalog stops the update. This local check does not test the public HTTPS route or hosted-client OAuth sign-in.
181
150
 
182
- From an npm install:
151
+ If a descriptor changes, the candidate stays staged and the last result is `connector_refresh_required`. To authorize switching to that release, run:
183
152
 
184
153
  ```sh
185
- node "$(npm root -g)/@tnunamak/dalan/scripts/worker-bridge-setup.mjs" --worker NAME --port PORT --home HOME_PATH --expose tailscale --start
154
+ dalan service update --yes
186
155
  ```
187
156
 
188
- Setup should report the derived HTTPS origin, generated service and exposure verification. It chooses the first free Funnel port from 443, 8443 and 10000, and the origin it prints includes that port when it is not 443. Pass `--funnel-port N` only to choose one; setup refuses a port that another Funnel or Serve rule already uses and never replaces that rule. Verify the selected port with the target client.
157
+ Refresh the Dalan connector in each hosted client after that switch. `--yes` allows the catalog change; it does not skip integrity, scratch checks or post-restart health checks. The timer never supplies it. Equal catalogs permit an automatic switch, but they cannot prove equal tool behavior or authorization semantics. Restarting interrupts connections and can interrupt in-progress requests.
189
158
 
190
- Setup prints a `dalan()` shell function for the owner commands; you can use it or set `DALAN_HOME` as step 1 says. Continue as follows, and skip `dalan init` and the foreground `node src/server.mjs` step, because setup already created and started this service.
159
+ While a switch is in progress, the restarted candidate refuses every worker call, OAuth request and owner command with a retryable 503 (`service_updating`, with `Retry-After`) and starts no background writer, until the update commits or rolls back. A rollback restores the saved state, so no change that Dalan acknowledged can be lost. Hosted clients retry after the window. For a switch, Dalan stops the bridge, saves its persistent configuration and data, selects the candidate, restarts the unit and checks local health and catalogs. On failure it attempts to stop the candidate, restore the previous selection and saved state, then restart and check the old version. A failed rollback is reported separately. An interrupted switch leaves a transaction record for recovery. Recovery runs when the service starts (an `ExecStartPre` step, `dalan service recover`) and again on the next update attempt; it does nothing while another update is running. Retention keeps three staged versions, including the active and previous versions. This is update recovery, not a replacement for your own backups.
191
160
 
192
- 1. Export `DALAN_HOME="HOME_PATH"` with the exact home you passed above, and run `dalan status --json`. Make `dalan` available on your PATH with the [manual setup](manual-setup.md#owner-and-requester-setup) steps. The private MCP URL is in `$DALAN_HOME/resource-url`, as in step 3 of the reverse-proxy route.
193
- 2. A worker on this computer follows [worker pairing](manual-setup.md#worker-setup). A worker on another computer follows [Native client on a remote HTTPS bridge](worker-clients.md#native-client-on-a-remote-https-bridge). Then run [submit, finish and read the result](manual-setup.md#submit-finish-and-read-the-result), replacing `local` with `NAME` in every command.
161
+ A service installed by 0.6.0 or 0.6.1 is adopted by its first `dalan service update` with no other step: Dalan reads the package path and node binary from the service unit, keeps that node binary, and leaves the original package in place until a later update succeeds. To turn on the daily timer for such a service, run `dalan service auto-update on`, or enroll it the long way: install the current Dalan package, then repeat its original `dalan service install` command with the same home, origin, port and target. Enrollment preserves keys and worker grants, changes the unit's package path and restarts it. Its timer stays off unless you pass `--auto-update` or run `service auto-update on`. A modified unit is refused for inspection. These update commands cover the service made by `dalan service install`; services from the older setup script are not enrolled automatically.
194
162
 
195
- ### When setup stops before verification
163
+ ### Living with updates
196
164
 
197
- Setup with `--expose tailscale` or `--expose ngrok` can leave the home, service and keys in place if public DNS or HTTPS is not ready. Run the exact `--retry-public-check` command it prints after fixing the public route. That checks the existing installation without replacing its keys; do not rerun a fresh install over it. DNS checks can take up to ten minutes, followed by up to two minutes for HTTPS plus request overhead.
165
+ **What a daily run does.** It looks up the latest stable release. With none newer, it changes nothing. With a newer one whose tool list matches, it installs, checks and switches by itself, and restarts the service. With a changed tool list, it stages the release and stops: the running version keeps serving jobs, and nothing switches until you run `dalan service update --yes`. Each later daily run repeats the check and leaves it staged, until you approve or a newer release replaces it.
198
166
 
199
- The retry has the form below. It needs the exposure record that those two modes save, so it does not work for an install made with an explicit `--public-url`.
167
+ **Find out that an update waits.** Dalan sends no notice. Run:
200
168
 
201
169
  ```sh
202
- node "$(npm root -g)/@tnunamak/dalan/scripts/worker-bridge-setup.mjs" --retry-public-check --worker NAME --public-url EXPOSURE_URL --port PORT --home HOME_PATH
170
+ dalan service status --json
203
171
  ```
204
172
 
205
- From a source checkout, use `node scripts/worker-bridge-setup.mjs` with the same options.
173
+ In `last_result`, `outcome` is `connector_refresh_required` for a staged release (`candidate_version` names it), `rolled_back` or `rollback_failed` after a failed switch, `failed` when an update stops before or during the switch, `update_available` after a check finds a newer release, `skipped_failed_release` when the timer passes over a rolled-back release, and `up_to_date` when none is waiting. A top-level `failed_release` names a release that Dalan will not retry on its own.
206
174
 
207
- It should mark the existing exposure verified. A 404 from unauthenticated `/admin` proves the expected public route answers, not that OAuth pairing or a worker job works, so complete both separately.
175
+ **Approve and refresh.** Run `dalan service update --yes`, then refresh the connector in each hosted client before you send new jobs. Until you do, the client may still offer the old tool list.
208
176
 
209
- ## Service updates
210
-
211
- For the Linux service made by `dalan service install`, new installs enable a systemd user timer that runs once daily with up to one hour of random delay. A missed run can run after the user manager next starts. Installation with `--no-auto-update` disables the timer; `--auto-update` explicitly enables it. Reinstalling preserves the saved choice unless you pass one of those flags. The timer needs your systemd user manager to run; it does not configure login lingering.
212
-
213
- ```sh
214
- dalan service update --check --home HOME_PATH
215
- dalan service update --home HOME_PATH
216
- dalan service status --home HOME_PATH --json
217
- dalan service auto-update off --home HOME_PATH
218
- dalan service auto-update on --home HOME_PATH
219
- ```
177
+ - ChatGPT: open the Dalan connector and select **Refresh**, then test in a new conversation.
178
+ - Claude Code, Codex CLI and other clients: restart the client session so that it lists the tools again. If the new tools still do not appear, remove and re-add the connector as in [worker clients](worker-clients.md).
220
179
 
221
- The home defaults to `~/.local/share/dalan-service`; pass the home used for installation if it differs. `service status` shows the selected version, saved automatic-update preference and last update result. Use `systemctl --user list-timers` to inspect the actual timer schedule. Turning updates off prevents future starts; it does not cancel an update already running. Preference changes refuse while an update holds the home lock. A release that was rolled back is recorded and skipped on later runs, including the timer; `dalan service update --retry` tries it again, and a newer or republished release is attempted normally. `service status` shows it as `failed_release`.
180
+ **Pause or check.** `dalan service auto-update off` stops the daily run; `dalan service auto-update on` restores it. `dalan service update --check` reports whether a newer release exists and records the answer in `last_result`; it installs nothing. Inspect the schedule with `systemctl --user list-timers` on Linux, or `launchctl list | grep -- -update` on macOS (the label is `org.dalan.<service>-update`).
222
181
 
223
- `--check` queries the public npm registry for the latest stable `@tnunamak/dalan` version and reports availability without installation or restart. A normal update installs the exact release under `HOME_PATH/versions/<version>`, with npm integrity checks and install scripts disabled. The registry's integrity value binds the downloaded bytes to its metadata; it is not an independent publisher signature. The original package must remain available until the first successful update. Later starts use the selected package through `HOME_PATH/current`.
182
+ **Roll back by hand.** Dalan has no command that returns to an earlier version after a successful update. Only a failed switch rolls back, and it does so by itself. `dalan service update --retry` retries a release that was rolled back; it does not restore an older one. To go back after a bad update, run `dalan service auto-update off` so the timer does not switch again, then follow [upgrade and rollback](operations.md#upgrade-and-rollback): stop the service, restore compatible state, and run the older code. Do not edit `HOME/current` by hand.
224
183
 
225
- Before switching, Dalan starts the candidate on a scratch loopback port against a private copy of the worker configuration, fresh mutable state, and synthetic keys made for that check. It never receives the service's signing, cookie, storage or operator keys. It checks initialization, ping and complete tool descriptors for every configured worker, then compares them with the running bridge. An unreachable worker, failed check or incomplete catalog stops the update. This local check does not test the public HTTPS route or hosted-client OAuth sign-in.
184
+ The `dalan` command on your PATH runs the version the service uses. Set `DALAN_NO_FOLLOW=1` to use the installed copy instead.
226
185
 
227
- If a descriptor changes, the candidate stays staged and the last result is `connector_refresh_required`. To authorize switching to that release, run:
186
+ ## Remove the service
228
187
 
229
188
  ```sh
230
- dalan service update --yes --home HOME_PATH
189
+ dalan service uninstall
231
190
  ```
232
191
 
233
- Refresh the Dalan connector in each hosted client after that switch. `--yes` allows the catalog change; it does not skip integrity, scratch checks or post-restart health checks. The timer never supplies it. Equal catalogs permit an automatic switch, but they cannot prove equal tool behavior or authorization semantics. Restarting interrupts connections and can interrupt in-progress requests.
234
-
235
- While a switch is in progress, the restarted candidate refuses every worker call, OAuth request and owner command with a retryable 503 (`service_updating`, with `Retry-After`) and starts no background writer, until the update commits or rolls back. A rollback restores the saved state, so no change that Dalan acknowledged can be lost. Hosted clients retry after the window. For a switch, Dalan stops the bridge, saves its persistent configuration and data, selects the candidate, restarts the unit and checks local health and catalogs. On failure it attempts to stop the candidate, restore the previous selection and saved state, then restart and check the old version. A failed rollback is reported separately. An interrupted switch leaves a transaction record for recovery. Recovery runs when the service starts (an `ExecStartPre` step, `dalan service recover`) and again on the next update attempt; it does nothing while another update is running. Retention keeps three staged versions, including the active and previous versions. This is update recovery, not a replacement for your own backups.
236
-
237
- A service installed by 0.6.0 or 0.6.1 is adopted by its first `dalan service update` with no other step: Dalan reads the package path and node binary from the service unit, keeps that node binary, and leaves the original package in place until a later update succeeds. To turn on the daily timer for such a service, run `dalan service auto-update on`, or enroll it the long way: install the current Dalan package, then repeat its original `dalan service install` command with the same home, origin, port and target. Enrollment preserves keys and worker grants, changes the unit's package path and restarts it. Its timer stays off unless you pass `--auto-update` or run `service auto-update on`. A modified unit is refused for inspection. These update commands cover the service made by `dalan service install`; the older `worker-bridge-setup.mjs` Linux/macOS units are not enrolled automatically. `service install` has no launchd support.
238
-
239
- ## Remove a generated service
240
-
241
- Use the same worker and home that created it. The full list of things an uninstall must remove (service, homes, trial home, client entries, lock file) is in [operations](operations.md#remove-an-installation).
242
-
243
- ```sh
244
- node scripts/worker-bridge-setup.mjs --remove --worker NAME --home HOME_PATH
245
- ```
192
+ This stops and removes the service, its update timer or agent and its public route. It never deletes data: the private home, keys and state move to `<home>.removed-<date>`, and the command prints that path. Delete that directory yourself when you want the data gone. A modified service definition may need inspection instead of automatic removal. The full list of things an uninstall must remove (homes, trial home, client entries) is in [operations](operations.md#remove-an-installation).
246
193
 
247
- From an npm install, run `node "$(npm root -g)/@tnunamak/dalan/scripts/worker-bridge-setup.mjs"` with the same options.
194
+ ## Legacy
248
195
 
249
- The script stops and removes its generated service and any unchanged recorded Funnel rule. It checks generated markers before removal and refuses to disable a Funnel rule that has changed. It retains the private home, keys and state. Add `--purge-home` only when you intend to delete those too. An interrupted copy or a modified service may require inspection instead of automatic removal.
196
+ Installations made by `scripts/worker-bridge-setup.mjs` in earlier releases keep working; that script is kept for compatibility only. See [operations](operations.md#restart-a-service-and-check-its-state) and the [upgrade guide](dalan-upgrade.md) to manage or replace one.
@@ -4,12 +4,12 @@ Use this page after the [README](../README.md) first-job path works. It lists se
4
4
 
5
5
  ## Environment and storage
6
6
 
7
- Set server variables in the process or service environment, then restart the bridge. Only the `dalan` command reads `DALAN_HOME`; it does not replace the server's `HOME`.
7
+ Set server variables in the process or service environment, then restart the bridge. Only the `dalan` command reads `DALAN_HOME`; it does not replace the server's `HOME`. A service made by `dalan service install` needs none: `dalan` remembers its home.
8
8
 
9
9
  | Setting | Effect |
10
10
  |---|---|
11
11
  | `HOME` | Selects the bridge's private configuration, state and requester receipts. The server and requester must use the same home. |
12
- | `DALAN_HOME` | The `dalan` command uses this directory as its `HOME`, so it reads the home of a server started with that `HOME`. `dalan try` uses it as the default trial home. |
12
+ | `DALAN_HOME` | The `dalan` command uses this directory as its `HOME`, so it reads the home of a server started with that `HOME`. It overrides the remembered service home. `dalan try` uses it as the default trial home. |
13
13
  | `DALAN_AUTH_MODE=builtin` | Uses the built-in OAuth authorization server. `oauth` selects an external issuer instead. |
14
14
  | `DALAN_LOOPBACK=1` | Runs authenticated HTTP on loopback only. Requires `DALAN_AUTH_MODE=builtin` and a fixed `DALAN_PORT`; the public URL must be `http://127.0.0.1:<port>`. |
15
15
  | `DALAN_PORT` | Sets the HTTP listener port; the server default is 8787. |
@@ -23,7 +23,7 @@ The corresponding old `DOT_BRIDGE_*` environment names remain readable for compa
23
23
 
24
24
  ## Requester commands
25
25
 
26
- The table lists the common commands. Run `dalan help --all` to see every command. Export `DALAN_HOME` in each shell, so that every command reads the same home and private receipts.
26
+ The table lists the common commands. Run `dalan help --all` to see every command. Every command must read the same home and private receipts: a service home is remembered; for a trial or a bridge you started by hand, export `DALAN_HOME` in each shell.
27
27
 
28
28
  | Command | Result |
29
29
  |---|---|
@@ -35,7 +35,7 @@ The table lists the common commands. Run `dalan help --all` to see every command
35
35
  | `dalan inbox --all --json` | Finds receipts across requester sessions without marking results read. Covers the last 72 hours unless you pass `--since`. |
36
36
  | `dalan note REQUEST_ID "text"` | Appends a job-specific message. |
37
37
  | `dalan questions REQUEST_ID --json` | Lists identified questions when the selected catalog supports them. |
38
- | `dalan answer REQUEST_ID QUESTION_ID "text"` | Answers an identified question; an ordinary note does not answer it. |
38
+ | `dalan answer REQUEST_ID QUESTION_ID "text"` | Answers an identified question; an ordinary note does not answer it. The attempt is saved under `receipts/` first, so after a crash or a lost reply, run the same command again: the answer reaches the worker once. A different text for the same question is refused. |
39
39
  | `dalan artifact ARTIFACT_ID --output PATH` | Downloads a sealed artifact after get or wait records its owning request. PATH must not exist; its directory must. |
40
40
  | `dalan decide REQUEST_ID accepted` | Records a review decision. Other choices are `applied`, `useful_no_change`, `useful_negative` and `not_useful`. |
41
41
  | `dalan apply REQUEST_ID --dir CHECKOUT` | Verifies and applies a returned patch, then records `applied`. |
@@ -66,7 +66,7 @@ For upgrades, use the [changelog](../CHANGELOG.md) and [operations procedure](op
66
66
 
67
67
  ## Legacy service examples
68
68
 
69
- The `dot-bridge.service`, `dot-bridge-selfcheck.service` and `dot-bridge-selfcheck.timer` examples are in `systemd/`. Keep these filenames when installing them for an existing deployment so service dependencies and timer targets still resolve. The legacy templates retain their original checkout default for compatibility. Set each example's `WorkingDirectory` to the deployed checkout and set `PATH` to a Node.js 24 installation before installing it. Units installed as copies, and drop-ins, do not need to change. A unit installed as a symbolic link to `dot-bridge.service`, `dot-bridge-selfcheck.service` or `dot-bridge-selfcheck.timer` in the repository root breaks when you update the checkout, because 0.5.0 removes those root links: before you update, point each such link at the same file in `systemd/`, then run `systemctl --user daemon-reload`. For a new installation, prefer the generator in the [service guide](service-setup.md): `node scripts/worker-bridge-setup.mjs --worker NAME --public-url https://bridge.example.com --port PORT --home HOME_PATH --start`. The external self-check is deployment-specific; configure it before enabling its timer.
69
+ The `dot-bridge.service`, `dot-bridge-selfcheck.service` and `dot-bridge-selfcheck.timer` examples are in `systemd/`. Keep these filenames when installing them for an existing deployment so service dependencies and timer targets still resolve. The legacy templates retain their original checkout default for compatibility. Set each example's `WorkingDirectory` to the deployed checkout and set `PATH` to a Node.js 24 installation before installing it. Units installed as copies, and drop-ins, do not need to change. A unit installed as a symbolic link to `dot-bridge.service`, `dot-bridge-selfcheck.service` or `dot-bridge-selfcheck.timer` in the repository root breaks when you update the checkout, because 0.5.0 removes those root links: before you update, point each such link at the same file in `systemd/`, then run `systemctl --user daemon-reload`. For a new installation, use `dalan service install` ([service guide](service-setup.md)). The external self-check is deployment-specific; configure it before enabling its timer.
70
70
 
71
71
  <a id="names-you-may-see"></a>
72
72
 
@@ -74,7 +74,7 @@ The `dot-bridge.service`, `dot-bridge-selfcheck.service` and `dot-bridge-selfche
74
74
 
75
75
  Earlier versions of Dalan used other names. Some remain so that existing installations keep working; use `dalan` and `DALAN_*` names for anything new.
76
76
 
77
- - **`dot-bridge.service`, `dot-bridge-selfcheck.service` and `dot-bridge-selfcheck.timer`** are legacy systemd templates in `systemd/`. Do not use them for a new install; use `scripts/worker-bridge-setup.mjs`.
77
+ - **`dot-bridge.service`, `dot-bridge-selfcheck.service` and `dot-bridge-selfcheck.timer`** are legacy systemd templates in `systemd/`. Do not use them for a new install; use `dalan service install`.
78
78
  - **`.dot-bridge.json`** is the older name of a repository's check file, `.dalan.json`. Dalan still reads it when `.dalan.json` is absent.
79
79
  - **`dot-bridge.*` OAuth scopes and `DOT_BRIDGE_*` settings** are older names that still work; the `dot-worker` command is replaced by `dalan`. They do not limit which client can be a worker.
80
80
  - **T3 Code** is a separate desktop app for running coding agents. Dalan has an optional integration with it (the `t3.*` scopes, [T3 tools](t3-reverse-control.md) and [operator-registered tools](worker-clients.md#operator-registered-tools)). Ordinary jobs do not need it.
@@ -0,0 +1,43 @@
1
+ # A question can outlive its parent's run
2
+
3
+ Run `node scripts/question-relationship-e2e.mjs` from the repository root. This standalone acceptance test runs the same worker conversation twice: an owner using the CLI with `--deliver none` and `dalan wait`, and an owner using a T3 destination. It uses an isolated HOME, a real server process, real SQLite transactions and authenticated MCP worker calls. The deterministic demo worker is the script's `worker` function; it calls the real claim, question, renewal, consumption and finish handlers. No model or live T3 service runs.
4
+
5
+ The parent finishes its run before the worker asks whether to return JSON or plain text. The question remains identified as `Q` on the job. The CLI owner discovers it through `dalan wait` (exit 3), then lists it through `dalan questions`. The T3 owner receives one question notification on its bound thread. Two scheduler passes must not produce a duplicate.
6
+
7
+ The owner selects JSON. The test prepares the answer through R5's `prepare(job, questionId, text)` journal interface, sends it through `send(prepared)` to the real admin handler, and deliberately loses the committed reply. The saved attempt remains prepared. The worker renews its claim, advancing the job's revision past the answer. The test kills the server with SIGKILL and starts another process against the same database. `dalan answer` must resend the original key, revision and text, return the original receipt, and leave the revision unchanged. `reconcile(job, questionId)` confirms the journal's committed state. There must still be one answer receipt and one answered event.
8
+
9
+ The worker explicitly consumes the answer before it finishes. The CLI owner receives the finished state through `dalan wait`; it produces no T3 message. The T3 destination delivers one result notice to the bound parent thread. The report itself remains in Dalan for the owner to fetch.
10
+
11
+ A second job exercises interruption. While the parent's latest run is `interrupted`, the worker asks a question. Dalan must hold its wake. Starting a new parent run releases exactly one question notice. After the answer is consumed, the parent is interrupted again before the worker finishes. The report must remain stored, with no result notice sent during interruption. A new parent run releases exactly one result notice. The test counts messages added after each resume, so an early, incorrect send cannot satisfy the resume assertion. With no destination, leaving the result unread preserves it until a later `dalan wait`.
12
+
13
+ A follow-up is submitted with a fresh job ID and claim. It starts with no questions and does not change the earlier report. Continuing the relationship does not reopen terminal work.
14
+
15
+ ## Responsibility boundary
16
+
17
+ T3 owns the parent thread, runs, lifecycle projection, admission of a new continuation, and stable acceptance of a message dispatch. Its destination adapter supplies an opaque generation and continuation-admission decision through `readGeneration` and `canAdmitContinuation`. Dalan stores that generation without interpreting the host's schema. T3 decides when a person has resumed the parent. Dalan does not choose the answer or start a reasoning model.
18
+
19
+ Dalan owns job and question identity, owner capabilities, claims, revisions, answer receipts, answer consumption, reports and durable notification state. The requester-side answer journal preserves the exact attempted command in `receipts/<job>.answers/<qid>.json`. Dalan's T3 adapter reads the host lifecycle before delivery, holds ineligible wakes, and releases them when the parent becomes eligible. The same core question and result flow works with the CLI and no destination.
20
+
21
+ The T3 side of this test uses the existing `t3code` stub pattern and `startT3ResultFixture` receiver. It proves Dalan's behavior against the supplied host metadata and dispatch receipts. It does not prove a live T3 stop/resume journey, hosted-worker activation, or an exact stop-versus-interrupt distinction. In the R6 contract, `interrupted` is held conservatively.
22
+
23
+ ## Dependencies and baseline
24
+
25
+ Assertions inside `cut()` record a failure and allow later cuts to continue. An assertion or operation that fails outside `cut()` aborts the remaining cuts for that requester mode and is recorded as a `trace infrastructure` failure. The script still attempts the next requester mode, and either kind of failure produces a nonzero exit. R5 and R6 are now merged, so the journal is required and the trace runs in the default suite. The table records the original main baseline at `4d2abf19`, before those dependencies merged.
26
+
27
+ | Cut | Main baseline |
28
+ | --- | --- |
29
+ | Question after parent run ended | Pass, both requesters |
30
+ | One question wake with repeated scheduler passes | Pass, both requesters |
31
+ | Journal and CLI replay after SIGKILL and revision advance | Waits on R5, both requesters |
32
+ | One answer receipt and answered event | Pass, both requesters |
33
+ | `consume_answer` | Pass, both requesters |
34
+ | Finish and result only to eligible parent | Pass, both requesters |
35
+ | Interrupted parent holds question wake | CLI passes; T3 waits on R6 |
36
+ | Held question delivered once after resume | CLI passes; T3 waits on R6 |
37
+ | Result retained while parent stopped | Pass, both requesters |
38
+ | Interrupted parent holds result wake | CLI passes; T3 waits on R6 |
39
+ | Held result delivered once after resume | CLI passes; T3 waits on R6 |
40
+ | Follow-up is a new job | Pass, both requesters |
41
+ | Destination generation/admission interface | T3 waits on R6 |
42
+
43
+ The test is registered in `scripts/test-segments.json`; its temporary test-listing exemption has been removed. Promotion to conformance traces T43+ comes afterward.