@tnunamak/dalan 0.0.0-stage → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +172 -0
- package/CONTRIBUTING.md +26 -0
- package/LICENSE +204 -0
- package/PROTOCOL.md +339 -0
- package/README.md +348 -2
- package/SECURITY.md +30 -0
- package/bin/dalan.mjs +38 -0
- package/bin/dot-acp-agent.mjs +377 -0
- package/bin/dot-alert.mjs +9 -0
- package/bin/dot-deadman.mjs +82 -0
- package/bin/dot-heartbeat.mjs +29 -0
- package/bin/dot-pr-reviewer.mjs +32 -0
- package/bin/dot-worker.mjs +755 -0
- package/docs/chatgpt-worker-onboarding.md +112 -0
- package/docs/claude-worker-onboarding.md +113 -0
- package/docs/connect-chatgpt.md +78 -0
- package/docs/connection-longevity.md +37 -0
- package/docs/dalan-upgrade.md +242 -0
- package/docs/deadman.md +59 -0
- package/docs/dot-pr-reviewer.config.example.json +9 -0
- package/docs/durability-audit.md +27 -0
- package/docs/keycloak-client-chatgpt-dot-bridge.json +59 -0
- package/docs/keycloak-oauth-setup.md +30 -0
- package/docs/local-agent-mcp.md +39 -0
- package/docs/manual-setup.md +135 -0
- package/docs/mirror-fetch.md +98 -0
- package/docs/operations.md +751 -0
- package/docs/operator-duties.md +68 -0
- package/docs/owner-integrator.md +27 -0
- package/docs/portable-auth-profile.md +109 -0
- package/docs/pr-head-reviewer.md +54 -0
- package/docs/pr-preflight.md +26 -0
- package/docs/pull-workers.md +97 -0
- package/docs/redaction.md +27 -0
- package/docs/service-setup.md +166 -0
- package/docs/setup-reference.md +80 -0
- package/docs/t3-connector-icon.png +0 -0
- package/docs/t3-integration.md +49 -0
- package/docs/t3-result-retry-delivery.md +41 -0
- package/docs/t3-reverse-control.md +107 -0
- package/docs/usage.md +439 -0
- package/docs/worker-clients.md +285 -0
- package/integrations/t3/acp-kit/src/capability.mjs +25 -0
- package/integrations/t3/acp-kit/src/errors.mjs +13 -0
- package/integrations/t3/acp-kit/src/index.mjs +5 -0
- package/integrations/t3/acp-kit/src/lock.mjs +155 -0
- package/integrations/t3/acp-kit/src/session-store.mjs +36 -0
- package/integrations/t3/acp-kit/src/t3-envelope.mjs +62 -0
- package/package.json +65 -4
- package/packages/job-core/README.md +18 -0
- package/packages/job-core/index.mjs +2 -0
- package/packages/job-core/package.json +8 -0
- package/packages/job-core/protocol/canonical.mjs +11 -0
- package/packages/job-core/protocol/v0/command.schema.json +1154 -0
- package/packages/job-core/protocol/v0/event.schema.json +77 -0
- package/packages/job-core/protocol/v0/reply.schema.json +59 -0
- package/packages/job-core/transitions.mjs +25 -0
- package/scripts/daily-selfcheck.mjs +135 -0
- package/scripts/lib/expose-tailscale.mjs +408 -0
- package/scripts/live-trial/common.mjs +272 -0
- package/scripts/monitor-targets.mjs +44 -0
- package/scripts/upgrade-drain.mjs +39 -0
- package/scripts/worker-bridge-setup.mjs +925 -0
- package/src/ack-ledger.mjs +37 -0
- package/src/acp-bridge.mjs +412 -0
- package/src/acp-context.mjs +138 -0
- package/src/admin-socket.mjs +14 -0
- package/src/alerts.mjs +147 -0
- package/src/artifact-journal.mjs +75 -0
- package/src/as-files.mjs +347 -0
- package/src/as-store.mjs +456 -0
- package/src/as.mjs +497 -0
- package/src/auth.mjs +166 -0
- package/src/builtin-http.mjs +22 -0
- package/src/check-coverage.mjs +38 -0
- package/src/check-lint.mjs +88 -0
- package/src/check-readiness.mjs +112 -0
- package/src/check-response.mjs +19 -0
- package/src/claim-command-ledger.mjs +51 -0
- package/src/cli-help.mjs +172 -0
- package/src/cli-name.mjs +16 -0
- package/src/connect-cli.mjs +126 -0
- package/src/consumers.mjs +61 -0
- package/src/deadman.mjs +329 -0
- package/src/delivery.mjs +19 -0
- package/src/demo-worker.mjs +150 -0
- package/src/destinations/index.mjs +23 -0
- package/src/destinations/none.mjs +15 -0
- package/src/destinations/t3.mjs +109 -0
- package/src/diagnostic.mjs +78 -0
- package/src/docs-url.mjs +9 -0
- package/src/drain-runner.mjs +9 -0
- package/src/drained-slot.mjs +53 -0
- package/src/drained.mjs +40 -0
- package/src/durable-waiters.mjs +236 -0
- package/src/env.mjs +19 -0
- package/src/execution.mjs +112 -0
- package/src/failure-type.mjs +28 -0
- package/src/get-summary.mjs +32 -0
- package/src/git-env.mjs +15 -0
- package/src/host-budget-receipts.mjs +154 -0
- package/src/host-budget-seccomp.py +33 -0
- package/src/host-budget-service.mjs +54 -0
- package/src/host-budget-stop.mjs +26 -0
- package/src/host-budget-storage.py +259 -0
- package/src/host-budget.mjs +149 -0
- package/src/host-cgroup.mjs +23 -0
- package/src/host-check-allowlist.mjs +42 -0
- package/src/host-execution-policy.mjs +38 -0
- package/src/host-health.mjs +34 -0
- package/src/host-stop-reverify.mjs +44 -0
- package/src/inbox.mjs +55 -0
- package/src/integrator.mjs +322 -0
- package/src/job-retention.mjs +69 -0
- package/src/legacy-names.mjs +8 -0
- package/src/lifecycle.mjs +291 -0
- package/src/limits.mjs +31 -0
- package/src/loopback.mjs +9 -0
- package/src/mcp-outcome.mjs +70 -0
- package/src/mcp-stdio.mjs +191 -0
- package/src/mirror-fetch-lock.py +164 -0
- package/src/mirror-fetch.mjs +174 -0
- package/src/notify-ledger.mjs +82 -0
- package/src/objectives.mjs +129 -0
- package/src/owner-report-artifact.mjs +66 -0
- package/src/patch-apply.mjs +84 -0
- package/src/path-syntax.mjs +16 -0
- package/src/paths.mjs +67 -0
- package/src/pr-head-reviewer.mjs +596 -0
- package/src/pr-preflight.mjs +51 -0
- package/src/prepared-node-modules.mjs +129 -0
- package/src/projects.mjs +480 -0
- package/src/protocol-artifact-commands.mjs +52 -0
- package/src/protocol-delivery-driver.mjs +167 -0
- package/src/protocol-finish.mjs +100 -0
- package/src/protocol-owner-command.mjs +35 -0
- package/src/protocol-owner-mutations.mjs +22 -0
- package/src/protocol-owner-waiters.mjs +67 -0
- package/src/protocol-retention.mjs +52 -0
- package/src/protocol-services.mjs +61 -0
- package/src/protocol-stop-observer.mjs +131 -0
- package/src/publish-plan.mjs +245 -0
- package/src/redaction.mjs +763 -0
- package/src/rejections.mjs +18 -0
- package/src/request-log.mjs +102 -0
- package/src/restore-check.mjs +90 -0
- package/src/result-binding.mjs +65 -0
- package/src/runtime-check.mjs +13 -0
- package/src/sandbox-supervisor.mjs +105 -0
- package/src/schema-subset.mjs +186 -0
- package/src/scopes.mjs +15 -0
- package/src/server.mjs +1340 -0
- package/src/shutdown-signal.mjs +12 -0
- package/src/signal-sandbox-processes.py +56 -0
- package/src/signal.mjs +119 -0
- package/src/status-evidence.mjs +47 -0
- package/src/status-summary.mjs +54 -0
- package/src/store.mjs +3057 -0
- package/src/submission-policy.mjs +623 -0
- package/src/subscription-storage.mjs +64 -0
- package/src/t3-audit.mjs +120 -0
- package/src/t3-control.mjs +102 -0
- package/src/t3-transport.mjs +158 -0
- package/src/t3.mjs +209 -0
- package/src/terminal-safe.mjs +19 -0
- package/src/tool-registry.mjs +451 -0
- package/src/try-command.mjs +11 -0
- package/src/try.mjs +589 -0
- package/src/webhooks.mjs +86 -0
- package/src/work-order.mjs +265 -0
- package/src/worker-instructions.mjs +26 -0
- package/src/worker-prompt.mjs +4 -0
- package/src/workers.mjs +622 -0
- package/src/workspace.mjs +1058 -0
- package/systemd/dot-bridge-heartbeat.service +18 -0
- package/systemd/dot-bridge-heartbeat.timer +10 -0
- package/systemd/dot-bridge-selfcheck.service +12 -0
- package/systemd/dot-bridge-selfcheck.timer +11 -0
- package/systemd/dot-bridge.service +17 -0
- package/systemd/dot-deadman.service +30 -0
- package/systemd/dot-pr-reviewer.service +11 -0
- package/systemd/dot-pr-reviewer.timer +10 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# Upgrade to Dalan
|
|
2
|
+
|
|
3
|
+
`dalan` is the main command. The package also installs `dalan-worker`, `dalan-acp-agent`, `dalan-alert`, `dalan-deadman`, `dalan-heartbeat` and `dalan-pr-reviewer`. It does not install the commands of the `dot-bridge` package; change scripts, units and timers that run `dot-worker`, `dot-deadman`, `dot-heartbeat`, `dot-alert`, `dot-acp-agent` or `dot-pr-reviewer` to the `dalan` or `dalan-*` command. `DALAN_X` takes precedence over `DOT_BRIDGE_X`, including an explicitly empty value except `AUTH_MODE`; an empty `DALAN_AUTH_MODE` falls back to a non-empty legacy auth mode, or stays unset if neither supplies one; an actual legacy fallback emits at most one warning from the main thread in each process. The `DOT_ACP_*` and `DOT_DRAINED_*` adapter settings keep their existing names.
|
|
4
|
+
|
|
5
|
+
## Pre-upgrade checklist
|
|
6
|
+
|
|
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
|
+
|
|
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.
|
|
10
|
+
|
|
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
|
+
|
|
13
|
+
Your shell can carry more than the service has. The README tells you to `export DALAN_HOME=...` and `DALAN_LOOPBACK=1` for a trial, and `dalan` makes `DALAN_HOME` win over the `HOME` you pass, so an inherited `DALAN_HOME` points every command at the trial, not at the service. `env -u NAME` removes a variable from one command. List the `DALAN_` and `DOT_BRIDGE_` names your shell exports, and remove each one that the service does not set:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
env | grep -E '^(DALAN|DOT_BRIDGE)_' | cut -d= -f1
|
|
17
|
+
# Linux: read the values
|
|
18
|
+
systemctl --user show dot-bridge-NAME.service -p Environment --value
|
|
19
|
+
# macOS: read the values
|
|
20
|
+
plutil -p ~/Library/LaunchAgents/LABEL.plist | grep -A12 EnvironmentVariables
|
|
21
|
+
# then, for every dalan or node command in this guide (BRIDGE_HOME and PORT from the output above;
|
|
22
|
+
# add one -u for each other name the first command listed). Exception: do not put HOME=BRIDGE_HOME on the
|
|
23
|
+
# service-file commands `worker-bridge-setup.mjs --repoint`, `--remove` and `--write-units-only`. They find the unit
|
|
24
|
+
# files (macOS plists, Linux units) under your own HOME, so run them with your normal HOME:
|
|
25
|
+
env -u DALAN_HOME -u DALAN_LOOPBACK HOME=BRIDGE_HOME NODE_ENV=production DALAN_AUTH_MODE=builtin DALAN_PORT=PORT dalan doctor --json
|
|
26
|
+
```
|
|
27
|
+
|
|
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
|
+
|
|
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.
|
|
31
|
+
|
|
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
|
+
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`.
|
|
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
|
+
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
|
+
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).
|
|
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
|
+
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
|
+
|
|
42
|
+
**Confirm the schema.** `dalan --version` is the package version, not the database schema. The service migrates `bridge.db` when it starts, so run this after the first start of the new version (checklist item 6 of the order above), under the service's environment, whether or not the service is running. It reads the database and changes nothing:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
sqlite3 -readonly "$(env -u DALAN_HOME -u DALAN_LOOPBACK HOME=BRIDGE_HOME dalan paths --data-root)/bridge.db" 'PRAGMA user_version;'
|
|
46
|
+
```
|
|
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)).
|
|
49
|
+
|
|
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
|
+
|
|
52
|
+
## Upgrade an npm install
|
|
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.
|
|
55
|
+
|
|
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
|
+
|
|
58
|
+
```sh
|
|
59
|
+
npm install --prefix "$HOME/dalan-new" @tnunamak/dalan@VERSION
|
|
60
|
+
cd "$HOME/dalan-new/node_modules/@tnunamak/dalan" && 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
|
|
61
|
+
```
|
|
62
|
+
|
|
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
|
+
|
|
65
|
+
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
|
+
3. Take the [backup](operations.md#upgrade-and-rollback), then replace the package and check which build the shell now runs:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
npm uninstall -g dot-bridge
|
|
70
|
+
npm install -g @tnunamak/dalan@VERSION
|
|
71
|
+
command -v dalan
|
|
72
|
+
dalan --version
|
|
73
|
+
ls "$(npm root -g)/@tnunamak/dalan/src/server.mjs"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`dalan --version` must print `VERSION`, and the last command must find the file: that path is what step 4 writes into the service. If you installed with `--prefix DIR`, add the same `--prefix DIR` to the npm commands and run `DIR/bin/dalan`.
|
|
77
|
+
4. Point the service at the new code. The command changes only the code directory in the unit or plist; the port, bridge home and environment stay as they are:
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
node "$(npm root -g)/@tnunamak/dalan/scripts/worker-bridge-setup.mjs" --repoint --worker NAME
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`--repoint` finds only the label `org.dalan.dot-bridge-NAME`. For a macOS service made by a release before 0.4.0, delete the old plist by hand after step 2, then write a new one for the same home and start it as in step 5: `node "$(npm root -g)/@tnunamak/dalan/scripts/worker-bridge-setup.mjs" --worker NAME --public-url URL --port PORT --home HOME_PATH --write-units-only` (use the URL, port and home of the old service).
|
|
84
|
+
|
|
85
|
+
Before you start the service, run the review from [checklist](#pre-upgrade-checklist) item 2 with the new build, under the service's own HOME and environment, as in [Run a command in the service's environment](#pre-upgrade-checklist): `dalan worker migrate-repos --json` (it converts an old repository policy and needs the service stopped; check that its `database` and `workers_file` belong to this bridge), then `dalan doctor --json` and `dalan worker list --json` (each worker's repository access).
|
|
86
|
+
5. Start the service. Linux: `systemctl --user daemon-reload && systemctl --user start dot-bridge-NAME.service`, then `systemctl --user is-active dot-bridge-NAME.service` must print `active`. macOS: the agent is unloaded, so load it before you start it:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
launchctl bootstrap user/$(id -u) ~/Library/LaunchAgents/LABEL.plist
|
|
90
|
+
launchctl kickstart -k user/$(id -u)/LABEL
|
|
91
|
+
launchctl print user/$(id -u)/LABEL | grep -E 'state|runs'
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
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).
|
|
96
|
+
|
|
97
|
+
## Upgrade a source install
|
|
98
|
+
|
|
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.
|
|
100
|
+
|
|
101
|
+
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.
|
|
102
|
+
2. Replace the code, then link it again so the commands in this document exist:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
cd CHECKOUT
|
|
106
|
+
git fetch origin --tags
|
|
107
|
+
git checkout TAG
|
|
108
|
+
npm ci
|
|
109
|
+
npm unlink -g dot-bridge
|
|
110
|
+
npm link
|
|
111
|
+
dalan paths --json
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
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
|
+
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
|
+
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`.
|
|
118
|
+
- 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).
|
|
120
|
+
|
|
121
|
+
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
|
+
|
|
123
|
+
## Existing homes and explicit path migration
|
|
124
|
+
|
|
125
|
+
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
|
+
|
|
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.
|
|
128
|
+
|
|
129
|
+
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
|
+
|
|
131
|
+
Ownership-lock files are not application data: exclude `as-owner.sqlite` and `bridge.db.secrets/owner.sqlite` from every backup, copy, sync and restore. Never read, unlink, rename or replace them while an owner may hold them; contenders must use the same inode. With every component stopped, let the software recreate missing locks locally after restore. Preserve the application databases and encryption keys, including `bridge.db.secrets/storage.key`. See [ownership and backup rules](operations.md#built-in-authorization-server-ownership).
|
|
132
|
+
|
|
133
|
+
To migrate paths explicitly:
|
|
134
|
+
|
|
135
|
+
1. Stop the service and every CLI, heartbeat, monitor and adapter using this HOME. Make a consistent backup of the config, data and state roots, excluding ownership-lock files and taking each SQLite database with `.backup`; use the backup and rollback procedure in [operations](operations.md#upgrade-and-rollback).
|
|
136
|
+
2. Inspect both names under each parent below. If both exist, resolve the conflict manually before proceeding. Do not overwrite or merge databases or authorization-server keys.
|
|
137
|
+
3. With the processes stopped, run this in the service HOME's shell. It refuses an existing destination and preserves permissions through a directory rename.
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
for parent in .config .local/share .local/state .tmp; do
|
|
141
|
+
old="$HOME/$parent/dot-bridge"
|
|
142
|
+
new="$HOME/$parent/dalan"
|
|
143
|
+
if [ -e "$old" ]; then
|
|
144
|
+
[ ! -e "$new" ] || { echo "Refusing existing destination: $new" >&2; exit 1; }
|
|
145
|
+
mv "$old" "$new" || exit 1
|
|
146
|
+
fi
|
|
147
|
+
done
|
|
148
|
+
if [ -e "$HOME/.dot-bridge" ]; then
|
|
149
|
+
[ ! -e "$HOME/.dalan" ] || { echo 'Refusing existing .dalan cache' >&2; exit 1; }
|
|
150
|
+
mv "$HOME/.dot-bridge" "$HOME/.dalan"
|
|
151
|
+
fi
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
4. Update any explicit paths in service environment, adapters and external scripts. Start the service, then use `dalan status --json`, `dalan doctor --json` and an authenticated worker smoke job. Verify the same jobs, connections and artifacts before removing the backup. To roll back path selection, stop all components and rename the directories back before starting the old build.
|
|
155
|
+
|
|
156
|
+
Migrating paths does not rename the repository, DNS names, OAuth scope strings, Git refs, report-format identifiers or service unit filenames.
|
|
157
|
+
|
|
158
|
+
## T3 control and notification aliases
|
|
159
|
+
|
|
160
|
+
The six `t3_thread_*` tools are off by default. Two read threads (`t3_thread_list`, `t3_thread_read`); the others wait on, create, send to and reconfigure threads. An existing installation that uses them must set `DALAN_ENABLE_T3_TOOLS=1` before upgrading and retain each worker's existing `capabilities: ["t3"]` grant. The exact legacy spelling `DOT_BRIDGE_ENABLE_T3_TOOLS=1` is also accepted when `DALAN_ENABLE_T3_TOOLS` is unset. The switch turns on all six, so a worker with the grant gets write and control access to T3 threads, not only read access. Keep the current catalog profile pin; this switch does not change its job protocol or tool schemas.
|
|
161
|
+
|
|
162
|
+
`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
|
+
|
|
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).
|
|
165
|
+
|
|
166
|
+
## Repository policy requires an explicit list
|
|
167
|
+
|
|
168
|
+
Fresh installations deny repository inputs unless explicitly allowed. On an existing installation, the first upgrade seeds omitted policies from that worker's retained claims and jobs that are still queued and live under the service's expiry rules, as described below. The legacy profile retains its identity and can use that persisted exact list. `DALAN_LEGACY_PROFILE=1` can permit the existing profile-recovery path, but never grants repository access.
|
|
169
|
+
|
|
170
|
+
Before upgrading a worker that relied on implicit access, inspect the seeded list with the migration and doctor commands below; add any additional owner-approved repository with `dalan worker allow NAME OWNER/REPO`. Existing exact lists keep their meaning, and denied queued jobs remain queued; an already-valid grant can finish under its existing lease and epoch. See [legacy repository-policy migration](operations.md#legacy-repository-policy-migration).
|
|
171
|
+
|
|
172
|
+
## Same-machine workers over HTTP
|
|
173
|
+
|
|
174
|
+
This is a recipe for a new, separate local installation, not a conversion of an existing bridge. For an in-place upgrade, keep the existing HOME, worker profile, auth mode and public URL: do not rerun `init --worker` against an existing profile, and do not delete authorization files to make it succeed. Changing an existing public URL changes the issuer and ends every connection.
|
|
175
|
+
|
|
176
|
+
From the installed checkout, use the built-in authorization server for authenticated local clients. Choose a fixed free port and initialize a new, empty HOME with the same settings used at startup:
|
|
177
|
+
|
|
178
|
+
```sh
|
|
179
|
+
export DALAN_HOME="$HOME/dalan-local" # a path that does not exist yet; not your service home or a trial home
|
|
180
|
+
export DALAN_LOOPBACK=1 DALAN_AUTH_MODE=builtin DALAN_PORT=8787
|
|
181
|
+
dalan init --worker local --public-url http://127.0.0.1:8787
|
|
182
|
+
HOME="$DALAN_HOME" node src/server.mjs
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The listener binds only `127.0.0.1`, and `DALAN_BIND_HOST`, if set, must be exactly `127.0.0.1`. No test OAuth switch is needed, including with `NODE_ENV=production`. The secret MCP path alone grants no access: every MCP call requires a valid, approved bearer token, and revocation is checked on each call. Authentication-off settings cannot bypass this requirement in loopback mode.
|
|
186
|
+
|
|
187
|
+
In a second shell with the same `DALAN_HOME`, port and auth settings, allow the client's exact callback path and open a pairing window:
|
|
188
|
+
|
|
189
|
+
```sh
|
|
190
|
+
dalan connect allow-callback http://127.0.0.1/callback
|
|
191
|
+
dalan connect start --worker local
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Use the client's actual callback path. HTTP callbacks may use `127.0.0.1`, `localhost` or `[::1]`, with any port, as described in [RFC 8252 section 7.3](https://www.rfc-editor.org/rfc/rfc8252.html#section-7.3). Omit the port in an owner allow-list pattern; an explicit port is refused because native client ports vary. Each hostname and path needs its own owner allow-list entry; paths cannot contain wildcards, queries or fragments. For a native callback, the teammate reads the code from the browser page on their own machine and shares it with the owner over a trusted channel. The owner compares that code and the full redirect, then passes the redirect to `dalan connect approve CODE --worker local --confirm-redirect URI`; this flag checks for a typo only, not identity. When several pairings are pending, approval selects the unique entry matching the code. If the code matches no unique entry, run `dalan connect pending` and compare codes. The registered callback port may differ from the port used for the authorization flow. Non-loopback HTTP callback URIs remain refused; remote bridges accept only explicitly allowlisted canonical native loopback URIs. The listener itself remains IPv4 loopback only.
|
|
195
|
+
|
|
196
|
+
Every HTTP route checks the exact `Host: 127.0.0.1:PORT` authority. A present Origin must be exactly `http://127.0.0.1:PORT`; absent Origin still requires MCP authentication. Null, foreign, duplicate and malformed origins, alternate hosts and forwarded authority headers are refused before routing. Browser clients hosted at another origin cannot use this mode. This is a local HTTP interoperability profile, not a general replacement for OAuth's HTTPS deployment rules. The checks cover host and origin validation and authentication against DNS rebinding.
|
|
197
|
+
|
|
198
|
+
For a non-loopback HTTP listener behind a TLS reverse proxy, explicitly set `DALAN_TRUST_PROXY=1` and configure the proxy to terminate HTTPS. The flag acknowledges that deployment requirement; it does not enable TLS or make forwarded headers trusted in loopback mode. The existing built-in HTTPS public-URL mode continues to bind loopback behind its tunnel.
|
|
199
|
+
|
|
200
|
+
Outside the local production profile, authentication-off fixtures must explicitly set `DALAN_DEV_ALLOW_UNAUTHENTICATED=1` and cannot use `NODE_ENV=production`. The historical `DALAN_ALLOW_INSECURE_PUBLIC=1` alias remains restricted to non-production fixtures, and neither flag permits authentication-off loopback mode.
|
|
201
|
+
|
|
202
|
+
## Preserve historical repositories on upgrade
|
|
203
|
+
|
|
204
|
+
On the first start against an existing database, a worker with no explicit `repos` list receives an exact list from that installation's retained jobs: the distinct well-formed `inputs[0].github_repo` values of jobs that worker claimed, plus jobs still queued and live under the service's expiry rules. Queued jobs already expired under those rules do not count, even when the service was stopped before its expiry sweep. A queued job with a blocked destination still seeds its repository because the owner submitted that work under the old policy; the destination block still prevents the job from being claimed until resolved. The migration output lists each seeded repository and the queued job IDs that caused it. A still-queued job for an unlisted repository stays queued until `dalan worker allow` adds it. Other workers' jobs cannot add repositories. The migration does not fetch repositories or infer issuer, subject or client bindings.
|
|
205
|
+
|
|
206
|
+
For an existing identity profile, startup fills only omitted lists and leaves explicit lists, including `[]`, unchanged. For the legacy worker without `workers.json`, the repos-only `workers-repos.json` journal keeps the exact list without creating an identity profile. Fresh installations remain deny-by-default. A later worker, later job or restart cannot expand the seed; removing an already-published list does not trigger another history scan.
|
|
207
|
+
|
|
208
|
+
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
|
+
|
|
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.
|
|
211
|
+
|
|
212
|
+
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
|
+
|
|
214
|
+
```sh
|
|
215
|
+
dalan worker migrate-repos --json
|
|
216
|
+
dalan doctor --json
|
|
217
|
+
dalan worker list --json
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
This command reads the existing database without migrating its schema. It performs the same one-time migration as startup and requires no identity profile for worker. Afterwards, `dalan worker allow worker OWNER/REPO` and `dalan worker deny worker OWNER/REPO` can edit the profile-less worker's exact list; those owner edits are audited. Configured workers use the same commands with their own names. Seeded repositories remain subject to authentication, worker visibility and all execution policy.
|
|
221
|
+
|
|
222
|
+
Doctor also warns when a worker retains the `t3` capability while reverse-control tools are off. Set `DALAN_ENABLE_T3_TOOLS=1` (or, only when the new name is unset, `DOT_BRIDGE_ENABLE_T3_TOOLS=1`) to retain those tools. The opt-in catalog comparison is deliberate: it proves an explicitly configured upgrade preserves every parent tool field and adds `notify_owner`; it does not claim a no-edit upgrade keeps T3 enabled. Existing durable T3 notices retain their old command spelling because rendered notice bytes are part of delivery-ACK identity; those commands remain working aliases.
|
|
223
|
+
|
|
224
|
+
Older builds do not enforce the profile-less repos-only policy. Reverting only the executable restores their historical repository authority; rollback must account for that difference as well as restoring consistent private state.
|
|
225
|
+
|
|
226
|
+
Restoring the backed-up private state also restores the built-in OAuth server's database. A connector that refreshed its token after the backup gets `invalid_grant` and must sign in again. Copy the current state aside before you restore it, so the restore itself can be undone. A code-only rollback keeps every sign-in, except that a connection approved with the neutral `dalan.read` and `dalan.work` scopes after the upgrade must reconnect, because an older build only knows the `dot-bridge.*` names.
|
|
227
|
+
|
|
228
|
+
## Breaking security changes in 0.4.0
|
|
229
|
+
|
|
230
|
+
External-OAuth installations binding `0.0.0.0` (or another non-loopback address) now require an HTTPS reverse proxy and `DALAN_TRUST_PROXY=1`. `DALAN_ALLOW_INSECURE_PUBLIC=1` cannot waive this acknowledgment. Authentication-off `DALAN_ALLOW_INSECURE_PUBLIC` and `DALAN_DEV_ALLOW_UNAUTHENTICATED` settings are refused with `NODE_ENV=production`; use built-in or external OAuth instead.
|
|
231
|
+
|
|
232
|
+
Startup reports one `repository_policy_empty` event per worker with an empty exact list, including `queued_repo_jobs_blocked`. Review that count and the migration audit before resuming repository work. Loopback Host/Origin refusals record `mcp_inbound` with status `403` and route `loopback`, without headers, credentials or request bodies.
|
|
233
|
+
|
|
234
|
+
## Fix-loop source name
|
|
235
|
+
|
|
236
|
+
The producer source for the fix loop is now `fix-loop`. The name used before this release (formerly `dot-fix`) is still accepted by `dalan submit --source`, in `/submit` metadata, in objective keys and task kinds, and in old receipts. Stored rows keep the old value in the `assignments.source` column, so no schema migration runs and a rollback needs no data change; the bridge reads it back as `fix-loop`. New lifecycle `integrated` events use the actor `fix-loop`; earlier events keep the old actor. Stored objective keys and task kinds keep their old spelling too (`dot-fix:...`, `dot-fix`). Retries, `backfill-objectives`, rework and duplicate counts, and the per-kind queue, throughput and rejection reports read both spellings as one (`fix-loop`). Rows that earlier releases rolled into the daily throughput table are read back under `fix-loop` as well.
|
|
237
|
+
|
|
238
|
+
Deploy the CLI and the server together. A request that the new CLI sends or stores with `fix-loop` as its source, objective key or task kind is rejected by a server that has been rolled back to an earlier release, so a rollback of the server needs a rollback of the CLI, and the reverse. The database itself needs no change in either direction.
|
|
239
|
+
|
|
240
|
+
## PR-head reviewer report thread key
|
|
241
|
+
|
|
242
|
+
The `report_thread_id` key of the PR-head reviewer config was named `lead_thread_id` before this release. The old key is still read; when both are set, `report_thread_id` wins. The `delivery_via` value in the reviewer log for this fallback is now `report-thread` (it was `lead`).
|
package/docs/deadman.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# External heartbeat dead-man
|
|
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.
|
|
4
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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.
|
|
10
|
+
|
|
11
|
+
## Operator setup
|
|
12
|
+
|
|
13
|
+
Path examples use fresh-home defaults. For an existing installation, use the roots from `dalan paths --json`; populated legacy roots remain active. See [the upgrade guide](dalan-upgrade.md).
|
|
14
|
+
|
|
15
|
+
**Upgrading an install that relied on the drainer gate: set `DALAN_DRAINER_HEALTH_FILE` to its drainer evidence file before restarting the heartbeat, or the heartbeat will ping on bridge health alone. The value must be an absolute path; a relative path resolves against the service `WorkingDirectory`.**
|
|
16
|
+
|
|
17
|
+
Install the repository on the independent host at `/opt/dot-bridge` or edit the service's paths. Create the `dot-deadman` account, install Node 24+, and create `/etc/dot-deadman.env` with mode 0600:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
DOT_DEADMAN_TOKEN=<random bearer-safe value of at least 32 characters>
|
|
21
|
+
DOT_DEADMAN_NTFY_URL=https://ntfy.example.net/dot-deadman
|
|
22
|
+
DOT_DEADMAN_NTFY_TOKEN=<optional provider token>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The service listens on `127.0.0.1:8788`; put an HTTPS reverse proxy in front of it for the bridge host, or use a private authenticated transport. Keep the bearer token only on the bridge host and the receiver host. The configured notification URL must be canonical and must not redirect. The receiver rejects a remote plain-HTTP publisher URL at startup. The unit resolves Node through `/usr/local/bin:/usr/bin:/bin` and the CLI requires Node 24+. Install Node there or set `ExecStart` to its installed absolute path. Then enable `systemd/dot-deadman.service` on the independent host.
|
|
26
|
+
|
|
27
|
+
On the bridge host, create `~/.config/dalan/deadman.env` with mode 0600:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
DOT_DEADMAN_URL=https://dot-deadman.example.net/dot-deadman
|
|
31
|
+
DOT_DEADMAN_TOKEN=<same bearer token>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The pinger appends `/heartbeat` to the configured base path, so the example sends to `/dot-deadman/heartbeat`. Configure the reverse proxy to strip `/dot-deadman` before forwarding, because the receiver serves exactly `/heartbeat`. Its environment parser accepts matching single or double quotes around values and LF or CRLF line endings. Tokens use bearer characters (letters, digits, `-._~+/` and optional trailing `=`); URL credentials and other schemes are rejected before sending. Remote endpoints require HTTPS; plain HTTP is allowed only on loopback for tests.
|
|
35
|
+
|
|
36
|
+
The user heartbeat timer runs `bin/dot-heartbeat.mjs`, which requires a successful `/status` check on the bridge's admin socket. Empty supply, ordinary policy refusals and intentional operator pause count as healthy. A missing socket or invalid status prevents the external ping. Fresh installs do not need a drainer: when `DALAN_DRAINER_HEALTH_FILE` is unset or empty, drainer files are ignored, including stale files left on disk.
|
|
37
|
+
|
|
38
|
+
For installs that run a drainer, explicitly opt in by adding `Environment=DALAN_DRAINER_HEALTH_FILE=%h/.local/share/dalan/drainer-health.json` to the heartbeat service's `[Service]` section (a commented example is included). Use the actual data root from `dalan paths --json`; existing installs using legacy roots should point this setting to their existing drainer-health file. With the setting enabled, missing, malformed, unhealthy, more than 150 seconds old, or more than 30 seconds future-dated evidence prevents the ping. The checker atomically writes `~/.local/share/dalan/health.json` only after those checks pass:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{"healthy":true,"observed_at":"2000-01-01T00:00:00.000Z"}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The pinger independently requires a timestamp no more than 90 seconds old and no more than 30 seconds in the future. A failed local check removes stale positive evidence. Install `systemd/dot-bridge-heartbeat.service` and its timer in `~/.config/systemd/user/`; set the unit PATH (replace `/ABSOLUTE/PATH/TO/NODE/BIN` with your Node binary directory) so it resolves Node 24+. For user units to run when logged out, enable lingering with `loginctl enable-linger <user>`. Adjust `WorkingDirectory` and `ExecStart` to the checkout, and set `Environment=DOT_DEADMAN_ENV=%h/.config/dalan/deadman.env` to the private file above (use the actual config root for existing installations). Run `systemctl --user daemon-reload`, then `systemctl --user enable --now dot-bridge-heartbeat.timer` after the bridge and independent receiver are configured. If opting in to drainer evidence, configure and enable its writer/timer first. These files do not install or restart the live bridge.
|
|
45
|
+
|
|
46
|
+
The timer is one minute; the five-minute receiver deadline tolerates a few missed runs. A successful HTTP response proves only that the remote receiver accepted a heartbeat. It does not prove the external provider delivered an alert or that a person saw it. Test provider delivery and host/network-loss notification separately before claiming the dead-man path is operational.
|
|
47
|
+
|
|
48
|
+
## Local check
|
|
49
|
+
|
|
50
|
+
Run the deterministic state and HTTP boundary checks with:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
node scripts/deadman-test.mjs
|
|
54
|
+
node scripts/deadman-transport-test.mjs
|
|
55
|
+
node scripts/host-health-test.mjs
|
|
56
|
+
node scripts/heartbeat-e2e.mjs
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The tests use fake time, temporary SQLite databases, and loopback listeners, including a stopped listener with a full accept queue to prove safe retry before connection. They do not contact an external host or notification provider.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"report_thread_id": "mcp:00000000-0000-0000-0000-000000000000",
|
|
3
|
+
"owners": ["example-org"],
|
|
4
|
+
"repos": ["example-org/example-repo", "example-org/example-docs"],
|
|
5
|
+
"exclude_owners": ["example-user", "example-bot"],
|
|
6
|
+
"exclude_repos": [],
|
|
7
|
+
"headroom": 6,
|
|
8
|
+
"max_submits_per_run": 10
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Durability review notes
|
|
2
|
+
|
|
3
|
+
This page lists what Dalan guarantees across a crash or restart, and what an operator must settle by hand: notification delivery, claim leases, dead-man alerts, fenced waiters and protocol retention.
|
|
4
|
+
|
|
5
|
+
The notification ledger commits a pending reservation before publishing. A process that restarts with a pending reservation treats the notification as uncertain and does not publish it again without reconciliation. An operator can inspect pending hashes through `GET /notify-pending` and settle one through `POST /notify-reconcile` after checking the receiver. Definite rejections become retryable without manual intervention. Delivered keys are retained, so a wall-clock jump cannot prune them and permit a duplicate send.
|
|
6
|
+
|
|
7
|
+
Owner cancellation waits when a result notification is sending or uncertain. The owner can reconcile the delivery before deciding whether to cancel.
|
|
8
|
+
|
|
9
|
+
## Claim leases
|
|
10
|
+
|
|
11
|
+
Every new claim stores an absolute lease deadline. Ordinary activity moves that deadline; protocol claims keep their fixed deadline. The authoritative lease rule, including usage breaks, is in [connection longevity](connection-longevity.md). Preparation deadlines (the time a job may wait in the queue) are a different rule and are covered in [pull workers](pull-workers.md). The service anchors its runtime clock to a monotonic source so wall-clock adjustments do not change lease authority while it runs. Claims created before the deadline column use their last recorded activity plus the stored lease duration as a fallback.
|
|
12
|
+
|
|
13
|
+
The acknowledgment ledger records a receiver response before the main database marks delivery. If the service stops between those local writes, recovery uses the stored acknowledgment without sending again. A stop after receiver acceptance but before the acknowledgment write remains a remote-delivery window. Each webhook sends its stable event ID as Idempotency-Key; receivers must deduplicate that key to prevent a repeated effect, and the header cannot force them to do so.
|
|
14
|
+
|
|
15
|
+
An expired durable waiter can still expose already materialized deliveries through its inbox and accept their acknowledgments.
|
|
16
|
+
|
|
17
|
+
## Interrupted dead-man alerts
|
|
18
|
+
|
|
19
|
+
An alert that was accepted just before the dead-man process stopped may remain `uncertain`. The alert includes a stable delivery reference. Check the receiver for that reference, then run `dalan-deadman reconcile EPISODE initial|reminder sent|unsent --evidence RECEIPT` with evidence that identifies the receiver's result. Reconciliation is sent to the running dead-man service, which refuses while a publish is still `sending`; restart the service after a crash so it can mark that send uncertain before reconciliation. `sent` records confirmed delivery; `unsent` allows a new attempt with the same delivery reference. Do not reconcile an ambiguous result as `unsent` without checking the receiver. The `status` command opens the database read-only and cannot change a live send.
|
|
20
|
+
|
|
21
|
+
A waiter reserved by a process in a different PID namespace can also remain waiting after a container replacement. The bridge cannot safely infer that the old process exited from a namespace mismatch. Keep the reservation fenced until an operator or supervisor can provide reliable process-incarnation evidence; a timeout alone must not release it.
|
|
22
|
+
|
|
23
|
+
Regrant also remains blocked when any historical host check lacks a verified stop receipt. Elapsed time or a finished check does not prove that the old process stopped. Resolve the block only with trusted stop evidence.
|
|
24
|
+
|
|
25
|
+
## Protocol retention
|
|
26
|
+
|
|
27
|
+
Assignments whose protocol retention has expired no longer count as queued, appear in the worker queue, or set the queue wake bit. Logical expiry writes a tombstone that fences later reads and claims. Physical purge is not implemented: the tombstone remains pending, and late stop observations are rejected after that fence. Retention expiry therefore does not mean that stored bytes were erased.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"client": {
|
|
3
|
+
"attributes": {
|
|
4
|
+
"access.token.lifespan": "300",
|
|
5
|
+
"backchannel.logout.revoke.offline.tokens": "false",
|
|
6
|
+
"backchannel.logout.session.required": "true",
|
|
7
|
+
"pkce.code.challenge.method": "S256",
|
|
8
|
+
"realm_client": "false"
|
|
9
|
+
},
|
|
10
|
+
"clientId": "chatgpt-dot-bridge",
|
|
11
|
+
"description": "Example public OAuth client for Dalan",
|
|
12
|
+
"directAccessGrantsEnabled": false,
|
|
13
|
+
"enabled": true,
|
|
14
|
+
"fullScopeAllowed": false,
|
|
15
|
+
"implicitFlowEnabled": false,
|
|
16
|
+
"name": "Dalan worker",
|
|
17
|
+
"protocol": "openid-connect",
|
|
18
|
+
"publicClient": true,
|
|
19
|
+
"redirectUris": [
|
|
20
|
+
"https://chatgpt.com/connector_platform_oauth_redirect"
|
|
21
|
+
],
|
|
22
|
+
"serviceAccountsEnabled": false,
|
|
23
|
+
"standardFlowEnabled": true,
|
|
24
|
+
"webOrigins": []
|
|
25
|
+
},
|
|
26
|
+
"defaultClientScopes": [],
|
|
27
|
+
"optionalClientScopes": [
|
|
28
|
+
{
|
|
29
|
+
"attributes": {
|
|
30
|
+
"display.on.consent.screen": "true",
|
|
31
|
+
"include.in.token.scope": "true"
|
|
32
|
+
},
|
|
33
|
+
"name": "dot-bridge.read"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"attributes": {
|
|
37
|
+
"display.on.consent.screen": "true",
|
|
38
|
+
"include.in.token.scope": "true"
|
|
39
|
+
},
|
|
40
|
+
"name": "dot-bridge.work"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"protocolMappers": [
|
|
44
|
+
{
|
|
45
|
+
"config": {
|
|
46
|
+
"access.token.claim": "true",
|
|
47
|
+
"id.token.claim": "false",
|
|
48
|
+
"included.custom.audience": "https://dalan.example.com/<bridge-path-secret>/mcp",
|
|
49
|
+
"introspection.token.claim": "true",
|
|
50
|
+
"userinfo.token.claim": "false"
|
|
51
|
+
},
|
|
52
|
+
"consentRequired": false,
|
|
53
|
+
"name": "dot-bridge audience",
|
|
54
|
+
"protocol": "openid-connect",
|
|
55
|
+
"protocolMapper": "oidc-audience-mapper"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"realm": "agents"
|
|
59
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# External OAuth issuer setup
|
|
2
|
+
|
|
3
|
+
For new installations, use the built-in OAuth flow in the [README](../README.md). Use this guide when you already operate an external issuer such as Keycloak. Configure it for your worker client; no particular account, domain or identity provider deployment is required.
|
|
4
|
+
|
|
5
|
+
## Configure the issuer
|
|
6
|
+
|
|
7
|
+
Create a public OpenID Connect client with the authorization-code flow, PKCE S256, and the worker client’s exact redirect URI. Disable implicit and service-account grants. Configure an audience mapper so access tokens contain the bridge’s exact resource URI, the full public MCP URL used as `OAUTH_AUDIENCE` below. Access tokens must be JWTs signed with RS256 whose header has a string `kid` matching an RSA key in the JWKS; opaque tokens and other algorithms are rejected. `OAUTH_ISSUER` and `OAUTH_JWKS_URI` must be HTTPS URLs on the same origin. Allow the `dot-bridge.read` and `dot-bridge.work` scopes. By default the bridge advertises and challenges with these names, so an existing issuer needs no change. To use the neutral names instead, define `dalan.read` and `dalan.work` in the issuer and add `OAUTH_SCOPE_NAMES=neutral` to `oauth.env`; the bridge accepts both spellings either way. These are identifiers for Dalan’s read and work permissions, not restrictions to a particular worker.
|
|
8
|
+
|
|
9
|
+
Store the issuer settings in the bridge home’s `~/.config/dalan/oauth.env`, mode 0600. For an existing installation use `dalan paths --json` to find the active configuration root; legacy roots remain supported. Replace all example values with your own deployment settings:
|
|
10
|
+
|
|
11
|
+
```env
|
|
12
|
+
OAUTH_ISSUER=https://identity.example.com/realms/agents
|
|
13
|
+
OAUTH_AUDIENCE=https://dalan.example.com/<bridge-path-secret>/mcp
|
|
14
|
+
OAUTH_JWKS_URI=https://identity.example.com/realms/agents/protocol/openid-connect/certs
|
|
15
|
+
OAUTH_ALLOWED_SUBJECTS=<approved-subject-id>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`<bridge-path-secret>` is the bridge's `BRIDGE_PATH_SECRET`. The audience contains it, so it also appears in the identity provider's mapper settings and in every token's `aud` claim. Treat the Keycloak client configuration as secret for the same reason.
|
|
19
|
+
|
|
20
|
+
The bridge validates issuer, audience, expiry, signature, approved subject and scopes. Keep tokens and identity subject values out of repository files and logs. In external-issuer mode, configure worker connection identities in the local worker profile as described in [the authentication profile](portable-auth-profile.md).
|
|
21
|
+
|
|
22
|
+
## Configure and verify the bridge
|
|
23
|
+
|
|
24
|
+
Set `DALAN_AUTH_MODE=oauth` in the service environment. For a non-loopback listener, configure an HTTPS reverse proxy and `DALAN_TRUST_PROXY=1`; preserve the public Host header. The bridge serves protected-resource metadata at `/.well-known/oauth-protected-resource` and at `/.well-known/oauth-protected-resource/<bridge-path-secret>/mcp`; forward both on the same public origin as the MCP endpoint. Discovery must identify the same issuer and resource used in token validation.
|
|
25
|
+
|
|
26
|
+
Back up private configuration and state before restarting an existing bridge. Verify the issuer discovery document and JWKS, complete the worker client’s authorization flow, and submit a repository-free text job through claim and finish. Verify refresh behavior with that client before relying on unattended work.
|
|
27
|
+
|
|
28
|
+
Keep workspace tools and host checks disabled until the basic worker journey succeeds. See [operations](operations.md) for repository grants, execution authority, backups and rollback. T3 access is a separate opt-in; the worker does not need it for ordinary jobs.
|
|
29
|
+
|
|
30
|
+
The [example Keycloak client export](keycloak-client-chatgpt-dot-bridge.json) retains its legacy filename. Review its redirect URIs, client ID, audience and scopes before importing it; it is not a deployable configuration for your host.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Use Dalan from a local agent (`dalan mcp`)
|
|
2
|
+
|
|
3
|
+
`dalan mcp` is a local MCP server on standard input and output. It lets an agent on the bridge computer (Claude Code, Codex) hand off a job and read the result as tool calls, without shell commands. It is not the worker endpoint: workers and ChatGPT connect to the bridge over HTTP as described in [connect any worker](worker-clients.md).
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
| Tool | Does | Read-only |
|
|
8
|
+
| --- | --- | --- |
|
|
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 |
|
|
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
|
+
| `dalan_status` | Returns `dalan status --json`. | yes |
|
|
13
|
+
|
|
14
|
+
Each tool runs the matching `dalan` command with `--json`, so receipts, assignment checks and verdicts are the same as on the command line. Failures are tool results with `isError: true` and a message; they never end the server. Only protocol messages go to standard output; logs go to standard error.
|
|
15
|
+
|
|
16
|
+
## Access
|
|
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.
|
|
19
|
+
|
|
20
|
+
## Claude Code
|
|
21
|
+
|
|
22
|
+
```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
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Codex
|
|
29
|
+
|
|
30
|
+
Add this to `~/.codex/config.toml`:
|
|
31
|
+
|
|
32
|
+
```toml
|
|
33
|
+
[mcp_servers.dalan]
|
|
34
|
+
command = "/path/to/dalan"
|
|
35
|
+
args = ["mcp"]
|
|
36
|
+
# env = { DALAN_HOME = "/path/to/bridge-home" }
|
|
37
|
+
```
|
|
38
|
+
|
|
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"]`.
|