@tnunamak/dalan 0.8.1 → 0.8.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 +59 -2
- package/CONTRIBUTING.md +2 -0
- package/README.md +8 -12
- package/bin/dalan.mjs +25 -4
- package/bin/dot-acp-agent.mjs +572 -76
- package/bin/dot-alert.mjs +9 -3
- package/bin/dot-deadman.mjs +3 -1
- package/bin/dot-heartbeat.mjs +14 -7
- package/bin/dot-pr-reviewer.mjs +3 -31
- package/bin/dot-worker.mjs +121 -34
- package/contracts/adapter-qualification.schema.json +94 -7
- package/docs/chatgpt-worker-onboarding.md +1 -1
- package/docs/codex-to-muse.md +2 -2
- package/docs/connect-chatgpt.md +1 -1
- package/docs/connection-longevity.md +2 -2
- package/docs/dalan-upgrade.md +8 -5
- package/docs/deadman.md +4 -0
- package/docs/design/authority-matrix.md +18 -0
- package/docs/design/failure-table.md +87 -0
- package/docs/design/identities.md +22 -0
- package/docs/design/pnpm-prepared-dependencies.md +64 -0
- package/docs/design/reuse-ledger.md +75 -0
- package/docs/design/target-architecture-v2.md +434 -0
- package/docs/local-agent-mcp.md +14 -0
- package/docs/local-agent-requester.md +2 -1
- package/docs/manual-setup.md +1 -1
- package/docs/operations.md +77 -14
- package/docs/pull-workers.md +11 -1
- package/docs/service-setup.md +10 -10
- package/docs/t3-integration.md +4 -2
- package/docs/t3-reverse-control.md +5 -5
- package/docs/test-suite-isolation.md +7 -6
- package/docs/trials/chatgpt-agent.md +47 -0
- package/docs/trials/claude-code-requester.md +68 -0
- package/docs/trials/muse.md +46 -0
- package/docs/usage.md +21 -7
- package/docs/worker-clients.md +1 -1
- package/integrations/t3/acp-kit/src/errors.mjs +6 -2
- package/integrations/t3/acp-kit/src/lock.mjs +46 -17
- package/integrations/t3/acp-kit/src/session-store.mjs +15 -3
- package/integrations/t3/acp-kit/src/t3-envelope.mjs +10 -2
- package/package.json +4 -3
- package/packages/job-core/protocol/canonical.mjs +45 -7
- package/packages/job-core/transitions.mjs +4 -2
- package/scripts/upgrade-drain.mjs +96 -8
- package/scripts/worker-bridge-setup.mjs +215 -120
- package/src/ack-ledger.mjs +7 -1
- package/src/acp-bridge.mjs +256 -28
- package/src/admin-socket.mjs +32 -3
- package/src/alerts.mjs +17 -8
- package/src/answer-journal-retention.mjs +82 -0
- package/src/answer-journal.mjs +6 -4
- package/src/as-store.mjs +51 -6
- package/src/as.mjs +27 -5
- package/src/catalog-switch-inventory.mjs +70 -0
- package/src/check-response.mjs +4 -1
- package/src/cli-help.mjs +14 -3
- package/src/cli-name.mjs +13 -1
- package/src/connect-cli.mjs +159 -4
- package/src/deadman.mjs +8 -5
- package/src/delivery.mjs +2 -19
- package/src/destinations/index.mjs +75 -14
- package/src/drain-runner.mjs +5 -1
- package/src/follow-current.mjs +3 -1
- package/src/get-summary.mjs +11 -2
- package/src/git-env.mjs +1 -1
- package/src/gozar-routes.mjs +313 -94
- package/src/host-budget-storage.py +56 -6
- package/src/host-budget.mjs +98 -15
- package/src/host-execution-policy.mjs +17 -6
- package/src/legacy-names.mjs +0 -2
- package/src/lifecycle.mjs +44 -9
- package/src/loopback-probe.mjs +46 -0
- package/src/mcp-outcome.mjs +3 -1
- package/src/mcp-sse.mjs +2 -1
- package/src/mcp-stdio.mjs +192 -30
- package/src/patch-apply.mjs +212 -7
- package/src/phase-trace.mjs +73 -0
- package/src/prepared-go-modules.mjs +127 -0
- package/src/prepared-node-modules.mjs +225 -38
- package/src/prepared-pnpm.mjs +276 -0
- package/src/prepared-store-prune.mjs +52 -0
- package/src/projects.mjs +59 -7
- package/src/protocol-artifact-commands.mjs +28 -0
- package/src/protocol-finish.mjs +3 -2
- package/src/publication-authority.mjs +22 -0
- package/src/publish-plan.mjs +2 -2
- package/src/pull-queue.mjs +55 -20
- package/src/read-api.mjs +127 -0
- package/src/redaction.mjs +173 -0
- package/src/rejections.mjs +19 -3
- package/src/route-custody.mjs +90 -0
- package/src/route-publication.mjs +50 -0
- package/src/route-setup.mjs +184 -0
- package/src/schema-subset.mjs +5 -3
- package/src/server.mjs +503 -98
- package/src/service-launchd.mjs +5 -1
- package/src/service-update-lock.mjs +7 -4
- package/src/service-update-runtime.mjs +64 -19
- package/src/service-update.mjs +193 -48
- package/src/service.mjs +276 -77
- package/src/setup.mjs +48 -25
- package/src/signal.mjs +1 -1
- package/src/status-evidence.mjs +18 -5
- package/src/store.mjs +876 -120
- package/src/submission-policy.mjs +257 -56
- package/src/t3-control.mjs +1 -1
- package/src/t3.mjs +14 -8
- package/src/terminal-safe.mjs +9 -7
- package/src/tool-registry.mjs +134 -41
- package/src/try-exposure.mjs +53 -86
- package/src/try-hosted.mjs +257 -70
- package/src/try.mjs +48 -22
- package/src/work-order.mjs +11 -6
- package/src/worker-instructions.mjs +26 -4
- package/src/worker-runs.mjs +35 -0
- package/src/workers.mjs +34 -7
- package/src/workspace.mjs +354 -54
- package/systemd/dot-deadman.service +3 -1
- package/docs/dot-pr-reviewer.config.example.json +0 -9
- package/docs/pr-head-reviewer.md +0 -70
- package/src/pr-head-reviewer.mjs +0 -596
- package/systemd/dot-pr-reviewer.service +0 -11
- package/systemd/dot-pr-reviewer.timer +0 -10
|
@@ -31,7 +31,8 @@ For each job, take the brief text from my message. Do not invent it. This templa
|
|
|
31
31
|
It waits up to 300 seconds by default (--timeout N, 1 to 3600). Check its exit code:
|
|
32
32
|
- 0, finished: continue to step 4.
|
|
33
33
|
- 124, still open: run wait at most 2 more times. If it is still open after that, stop and ask me whether a worker has claimed it. Do not keep waiting on your own.
|
|
34
|
-
- 3, the worker asked a question or reported a blocker: run dalan
|
|
34
|
+
- 3, the worker asked a question or reported a blocker: run `dalan questions REQUEST_ID --json` and show me the waiting question and its question_id. For an ordinary question, ask me for the answer, then run `dalan answer REQUEST_ID QUESTION_ID 'ANSWER' --json` with my answer as one literal argument, using the same quoting rule as the brief in step 1. QUESTION_ID is the returned question_id, not a new ID; ANSWER is my reply, not text you invent. If the question is marked human-only, stop and ask me to use the required operator action instead; do not answer it with owner authority alone. If there is no identified question, run `dalan get REQUEST_ID --json`, show me the blocker and stop for its resolution. Do not run steps 4 or 5 yet. A question is not permission to change the job's scope, spend money, grant access or change where results are sent. After an answer succeeds, or I confirm the human-only action or blocker resolution, run wait again on the same REQUEST_ID; do not submit a replacement job.
|
|
35
|
+
Answers starting with a dash are refused; ask me to rephrase so the answer does not start with a dash. The answer is journaled before sending. Resending the exact same answer for the same question with the same DALAN_HOME is safe: it reuses the saved attempt, not a second answer. A lost reply may cause the same envelope to be retried; a different second answer is refused. Do not edit or remove the journal to force a change. If answering fails, show me the error and reconcile with questions/get before retrying; do not change the answer to get past it.
|
|
35
36
|
- 4, cancelled: run `dalan get REQUEST_ID --json`, show me the result and stop. Do not run decide.
|
|
36
37
|
- 5, the worker is on a usage break: tell me and stop. Do not run decide. Run wait again only when I ask.
|
|
37
38
|
- Any other non-zero exit: stop and show me the error.
|
package/docs/manual-setup.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`try` runs ordinary `dalan` commands in a private trial home. Use this page to run each piece yourself: to keep the bridge in the foreground, to choose your own worker name, or to set up a client that `try` does not cover. You need the npm package, two shells and a compatible HTTP MCP worker client with OAuth. This page explicitly installs the CLI globally before using bare `dalan` commands; `npx` alone does not put it on your persistent PATH.
|
|
6
6
|
|
|
7
|
-
For a hosted first result instead, use `dalan try --public
|
|
7
|
+
For a hosted first result instead, use `dalan try --public` (after `npm install -g @tnunamak/dalan`) ([hosted trial](../README.md#quickstart)). Dalan asks Gozar for a public HTTPS route and asks for consent before exposure; some routes are temporary and some route operators can read the connector URL and traffic. Keep private work out of the demo. A temporary demo link can change or stop without warning; the three-hour trial limit is not an availability promise. For a bridge that keeps running, use `dalan service install` ([service setup](service-setup.md)); it needs no `DALAN_HOME`. The loopback recipe below creates no public route and uses its own home, so it sets `DALAN_HOME` as an override.
|
|
8
8
|
|
|
9
9
|
<a id="owner-and-requester-setup"></a>
|
|
10
10
|
|
package/docs/operations.md
CHANGED
|
@@ -12,6 +12,53 @@ The admin socket is mode `0600`, but every process that runs as the bridge's own
|
|
|
12
12
|
|
|
13
13
|
Fresh homes use Dalan directories; existing installations retain their populated legacy roots. Use `dalan paths --json` with the service HOME and environment for the effective config, data, state and workspace roots. See [the upgrade guide](dalan-upgrade.md) for settings, catalog retention, local HTTP and explicit path migration.
|
|
14
14
|
|
|
15
|
+
## Stable read interface
|
|
16
|
+
|
|
17
|
+
Local operator tools should use `dalan jobs --json` and `dalan events --json` instead of opening `bridge.db`. The JSON documented here is a stable interface. The database, its tables, columns and schema version are private implementation details. These commands open the selected home's database read-only; they do not migrate it, create a missing store, mark results read, or change jobs. Use the CLI version installed with the service and set `DALAN_HOME` when selecting another home. This is local operator access to all jobs in that home, not a remote authorization boundary.
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
dalan jobs --json --worker assistant --status queued --limit 100
|
|
21
|
+
dalan events --json --since 24h --worker assistant --type completed
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Both responses carry `schema_version: 1`, an array (`jobs` or `events`), and `next_cursor` (an opaque string, or `null` at the end). Each call returns at most `--limit` rows: default 100, maximum 1000. Continue with `--cursor VALUE` and the same filters. Jobs sort by `(created_at, request_id)` ascending; events sort by increasing event ID. Cursors exclude the last returned row, including when jobs have identical creation times. Pages show current state, not a frozen snapshot: a job that changes filters between calls can enter or leave the result. Restart a job scan to observe updates to earlier rows. Events may expire under lifecycle retention; this is not an archival event feed.
|
|
25
|
+
|
|
26
|
+
`--since` takes an RFC3339 timestamp, a duration such as `24h` or `3d`, or `all`. The cutoff is inclusive. Omit it for all retained rows. Jobs filter **assignment creation time**; events filter event time. For report-rate or claim-age calculations, scan jobs without a cutoff and filter `finished_at` or `claimed_at` in the caller. Resolve relative cutoffs to a fixed timestamp before paginating.
|
|
27
|
+
|
|
28
|
+
Jobs support exact `--worker` (the assigned target), `--status`, `--kind` (task kind), and `--source` filters. Filters combine with AND. Status is `queued`, `claimed`, `finished`, or `cancelled`. Source is `agent`, `drainer`, `fix-loop`, or `unknown`. Kind is `build`, `review`, `fix-loop`, or a task kind already recorded in this home's store. Historical fix-loop metadata spellings are normalized as in other Dalan metadata output. Events support exact `--worker` and `--type` filters; the allowed types are listed under **Lifecycle events** below. Both commands accept any worker name (a name with no matches returns an empty page). Invalid enum filters print the allowed values, and a cursor for another schema version names both versions. Unknown options, missing values, invalid filters, times, limits or cursors fail with exit 1 and a JSON error on stderr carrying `schema_version: 1`; stdout remains empty. These verbs print JSON even without `--json`.
|
|
29
|
+
|
|
30
|
+
### Job fields
|
|
31
|
+
|
|
32
|
+
| Fields | Meaning |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `request_id`, `status`, `worker`, `priority` | Job identity, current assignment status, target worker and queue priority. |
|
|
35
|
+
| `task_kind`, `source`, `objective_key` | Assignment metadata; absent values are `null`. |
|
|
36
|
+
| `created_at`, `claimed_at`, `finished_at` | Assignment creation, current claim creation, and report creation timestamps. A missing claim or report yields `null`. |
|
|
37
|
+
| `outcome`, `summary`, `result`, `report_worker` | Report outcome, summary, full result text and reporting worker; `null` before a report exists. |
|
|
38
|
+
| `decision` | Latest owner/system decision word, with legacy acceptance/rejection fallback; `null` if undecided. |
|
|
39
|
+
| `payload` | Parsed assignment JSON, including `inputs`, for callers that route results by repository or inspect the brief. |
|
|
40
|
+
| `cancelled_at`, `valid_until`, `skipped_at` | Assignment cancellation, expiry and worker skip timestamps; `null` when absent. |
|
|
41
|
+
| `claim_worker`, `claim_state`, `abandoned_at`, `last_claim_activity_at`, `acquisition_id` | Current claim worker, active/abandoned state, abandonment and activity timestamps, and acquisition identifier; `null` without a claim. |
|
|
42
|
+
|
|
43
|
+
`worker`, `claim_worker`, and `report_worker` represent separate facts. For example, counts of queued jobs use `worker`, while counts of completed reports use `report_worker`. Presence of a report is observable through `finished_at`. No owner capability or capability hash is returned or accepted as a filter; no current migration caller needs one.
|
|
44
|
+
|
|
45
|
+
### Event fields
|
|
46
|
+
|
|
47
|
+
Each event returns `id`, `request_id`, `claim_id`, `epoch`, `type`, `at`, `actor`, `source`, `reason`, `worker`, `scope`, and `outcome`. `source` is the lifecycle provenance (`live` or `backfill`), not the job's submitter source. Optional event details are `null` when absent. Use IDs for continuation; multiple events may have the same timestamp.
|
|
48
|
+
|
|
49
|
+
Consumers must check `schema_version` and ignore added fields. Incompatible field meanings or removals require a new JSON schema version. This version is independent of the private SQLite schema number and package release number.
|
|
50
|
+
|
|
51
|
+
### Existing local-reader coverage
|
|
52
|
+
|
|
53
|
+
| Caller | Database columns read or used in predicates | Public job fields |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| `kitchen/kitchen-gen` | assignments: `request_id`, `target_worker`, `status`, `cancelled_at`, `skipped_at`; claims: `worker`, `state`, `claimed_at`, `request_id`; reports: `request_id`, `worker`, `outcome`, `created_at` | `request_id`, `worker`, `status`, `cancelled_at`, `skipped_at`, `claim_worker`, `claim_state`, `claimed_at`, `report_worker`, `outcome`, `finished_at` |
|
|
56
|
+
| `util/full-gate.py` | claims: `worker`, `claimed_at`, `last_claim_activity_at`, `acquisition_id`, `abandoned_at`, `request_id`; assignments: `request_id`, `status`, `cancelled_at`, `target_worker`, `valid_until`; reports: `request_id`, `worker`, `created_at` | `claim_worker`, `claimed_at`, `last_claim_activity_at`, `acquisition_id`, `abandoned_at`, `request_id`, `status`, `cancelled_at`, `worker`, `valid_until`, `report_worker`, `finished_at` |
|
|
57
|
+
| `util/results-router.py` | reports: `request_id`, `outcome`, `summary`, `result`; assignments: `request_id`, `task_kind`, `payload` | `request_id`, `outcome`, `summary`, `result`, `task_kind`, `payload` |
|
|
58
|
+
| `keepfull-due` | assignments: `target_worker`, `status`, `cancelled_at` | `worker`, `status`, `cancelled_at` |
|
|
59
|
+
|
|
60
|
+
No columns read by these four callers remain uncovered. Aggregation and result-ID selection remain caller-side operations over all pages. Migrating those callers is separate work; these commands do not change fleet tools.
|
|
61
|
+
|
|
15
62
|
## Versions and upgrades
|
|
16
63
|
|
|
17
64
|
**Versions (0.6.0).** Package releases and SQLite schema numbers are
|
|
@@ -129,7 +176,7 @@ See the [requester reference](usage.md) for the assignment sequence and [T3 and
|
|
|
129
176
|
|
|
130
177
|
`dalan submit` defaults to quiet `--deliver none`, retrieved through `wait` or `get`. Explicit T3 delivery verifies `t3code --json threads inspect --thread ID` and binds `runtime.environmentId`. Protected IDs in the mode 0600 `<config>/dalan/limits.json` `main_thread_ids` list require operator-authenticated `--allow-main` for submission. That flag admits a bound assignment; it does not enable notices to a protected destination. The bridge rereads protection before delivery, so adding an ID also quiets in-flight finish and blocker notices without a restart. Results and questions remain available through `wait` and `get`. Stored legacy watch and mute facts remain readable and enforced; no current command or admin route creates them. The assignment JSON cannot change after submission; a new revision or objective needs a new ID. Legacy requests have no owner capability and remain operator-read-only until explicitly adopted.
|
|
131
178
|
|
|
132
|
-
`dalan status --json` shows queue counts, pause reason, subscription state and expiry, last verification, last event 2xx, last claim, queue age and uncertain T3 deliveries. Liveness fields (additive): `claimed_outer_count` (all subjects' active claims), `max_claimed_outer_assignments` (the cap per recorded lane: subject in the legacy profile, worker in profile mode), `oldest_claim_age_ms`, `oldest_claim_progress_age_ms`, `last_worker_call_at` (the newest tool call recorded for the worker), `last_list_pending_at`, `oldest_unclaimed_event_2xx_age_ms`, `queue_classes` and `stale_claims`. Queued work is classified, never called simply "paused" or "missed": `pause_suspected` (no worker call and silence of at least 20 min), `at_capacity_healthy` (every active worker subscriber has no free capacity after counting its worker lanes and its principal's subject lanes from recorded claims, and the newest activity on at least one claim is younger than that claim's stored lease duration; the default is 60 min), `alive_not_claiming` (the default worker calls tools, slots are free, the item stays queued beyond twice the interval), `transport_failing` (no event ever got a 2xx), and `stale_claims` (claims past their persisted lease deadline, the same deadline the sweep uses, checked even with an empty queue; inspect `lease_expires_at`). The bridge's automatic claim abandonment requires lease expiry (actor `system`, reason `lease_expired`, checked by the independent maintenance timer, same path as `dalan abandon`): the item is requeued and its lane is free. A usage break does not hold the sweep and does not move `lease_expires_at`: a claim with no claimant activity for one lease period is released during a break too. After a bridge start, a claim whose last activity came before the start is not swept before the start plus that claim's own lease (`lease_ms`, one hour by default), the full lease a restart would have given it, so a deadline that ran out while the bridge was down or draining does not requeue work the worker may still be running; a claim the worker touched since the start has no grace. After that window, the first maintenance tick sweeps it. Native protocol fixed-deadline leases renew only through explicit `renew_claim`. The optional `worker_claim_lease_ms` map in `limits.json` caps durations by worker, for example `{"muse":900000}`. Keys must be valid worker names; values must be integer milliseconds from 60000 to 604800000. New claims and explicit renewals use the smaller of the requested (or default) duration and that worker cap. Other workers keep the global duration. Claim-bound activity renews ordinary leases using the smaller of their stored duration and the current worker cap. Existing deadlines stay in place until renewal or a new grant. Restart the bridge after editing this setting. The advertised tool catalog and global `lease_ms` maximum stay unchanged. Claim-bearing calls still require an unexpired grant under the applicable lease model; acquire a new epoch when permitted. Preparation expiry and default-worker-only skip expiry still run during a break and while delivery is paused (see **Preparation expiry** and **Skip expiry** under [Usage breaks and usage estimates](#usage-breaks-and-usage-estimates)).
|
|
179
|
+
`dalan status --json` shows queue counts, pause reason, subscription state and expiry, last verification, last event 2xx, last claim, queue age and uncertain T3 deliveries. Liveness fields (additive): `claimed_outer_count` (all subjects' active claims), `max_claimed_outer_assignments` (the cap per recorded lane: subject in the legacy profile, worker in profile mode), `oldest_claim_age_ms`, `oldest_claim_progress_age_ms`, `last_worker_call_at` (the newest tool call recorded for the worker), `last_list_pending_at`, `oldest_unclaimed_event_2xx_age_ms`, `queue_classes` and `stale_claims`. Queued work is classified, never called simply "paused" or "missed": `pause_suspected` (no worker call and silence of at least 20 min), `at_capacity_healthy` (every active worker subscriber has no free capacity after counting its worker lanes and its principal's subject lanes from recorded claims, and the newest activity on at least one claim is younger than that claim's stored lease duration; the default is 60 min), `alive_not_claiming` (the default worker calls tools, slots are free, the item stays queued beyond twice the interval), `transport_failing` (no event ever got a 2xx), and `stale_claims` (claims past their persisted lease deadline, the same deadline the sweep uses, checked even with an empty queue; inspect `lease_expires_at`). The bridge's automatic claim abandonment requires lease expiry (actor `system`, reason `lease_expired`, checked by the independent maintenance timer, same path as `dalan abandon`): the item is requeued and its lane is free. A usage break does not hold the sweep and does not move `lease_expires_at`: a claim with no claimant activity for one lease period is released during a break too. After a bridge start, a claim whose last activity came before the start is not swept before the start plus that claim's own lease (`lease_ms`, one hour by default), the full lease a restart would have given it, so a deadline that ran out while the bridge was down or draining does not requeue work the worker may still be running; a claim the worker touched since the start has no grace. The optional `worker_post_start_hold_ms` map in `limits.json` (worker name to integer milliseconds, 0 to 604800000; default `{}`) shortens that window for a worker. A worker whose lease is 8 minutes and that reconnects within a minute needs about two minutes (`{"muse":120000}`); without it, a restart keeps every idle claim, and so every lane, held for up to 8 minutes after the lease ran out. Restart the bridge after editing it. After that window, the first maintenance tick sweeps it. The optional `worker_claim_hint` map in `limits.json` (worker name to an integer from 1 to 10; default `{}`) changes what the bridge tells that worker, not what it allows. Its `list_pending` guidance, its `claim` guidance and its `finish` guidance say to hold at most that many claims at once and to send `progress` at least every 3 minutes, and `next_queued` and `next_action` suggest only the hint minus the claims the worker touched in the last 3 minutes. `free_lanes` and every claim check stay as they are, so a worker that claims more is still served. It exists because a worker that claims every free lane in one turn strands the claims it does not start when its run ends, and each stranded claim holds its lane for a lease. Remove the key and restart the bridge to restore the default text; restart after editing it. Native protocol fixed-deadline leases renew only through explicit `renew_claim`. The optional `worker_claim_lease_ms` map in `limits.json` caps durations by worker, for example `{"muse":900000}`. Keys must be valid worker names; values must be integer milliseconds from 60000 to 604800000. New claims and explicit renewals use the smaller of the requested (or default) duration and that worker cap. Other workers keep the global duration. Claim-bound activity renews ordinary leases using the smaller of their stored duration and the current worker cap. Existing deadlines stay in place until renewal or a new grant. Restart the bridge after editing this setting. The advertised tool catalog and global `lease_ms` maximum stay unchanged. Claim-bearing calls still require an unexpired grant under the applicable lease model; acquire a new epoch when permitted. Preparation expiry and default-worker-only skip expiry still run during a break and while delivery is paused (see **Preparation expiry** and **Skip expiry** under [Usage breaks and usage estimates](#usage-breaks-and-usage-estimates)). An expired lease also lets another claimant take the claim over; see [Claims and leases](#claims-and-leases). An event 2xx proves webhook transport only, while a claim is stronger evidence of worker wakeup. The bridge never treats worker `completed` as owner acceptance.
|
|
133
180
|
|
|
134
181
|
## Recovery and operation
|
|
135
182
|
|
|
@@ -178,6 +225,8 @@ Before first claim, an expired learned `queue_p90` deadline can be refreshed up
|
|
|
178
225
|
|
|
179
226
|
Each claim has a `claim_id` and an `epoch`. Every claim-scoped call must present the active grant for the caller's verified subject and recorded worker. In built-in mode it must also come from the live connection recorded on the grant: `renew_claim`, `progress`, `ask_question`, `consume_answer`, `finish`, `artifact_chunk` and the five workspace tools otherwise fail with `connection_not_live` and change nothing (see the [connection fence](../PROTOCOL.md#connection-fence-built-in-mode)). A live legacy `claim` retry matches worker, subject, claimant and acquisition ID, including omission matching stored NULL. Exact retries precede rotation. In built-in mode a retry must come from the live connection that holds the grant, and for a destination-approved job while the live connection set matches the approval; it does not re-run destination or repository policy and records no blocker. No idle rotation, explicit resume or re-claim after abandonment can issue a successor before the prior deadline and verified host stop. See the [protocol truth table](../PROTOCOL.md#claims-and-worker-tools) and [pull-worker continuation rules](pull-workers.md#what-one-run-does).
|
|
180
227
|
|
|
228
|
+
In profiles with the tool registry, workers can discover `ask_question` and `consume_answer` with `list_tools` and call them through `call_tool_write` using the current schema hash and an idempotency key. The same claim and connection checks apply as for native calls. Claim replies give this guidance to workers. The native `tools/list` stays the same, so workers can use the question tools without refreshing the connector.
|
|
229
|
+
|
|
181
230
|
A legacy non-protocol lease expires after its stored `lease_ms` since valid claim activity (default 60 min, bounded by `claim_lease_ms`). Native protocol grants instead expire at fixed `lease_deadline_at`; activity and repeated `claim` do not slide it, and renewal requires explicit `renew_claim` before expiry. `get` and owner notes do not extend it. An expired claim can remain recorded as active until the sweep, but mutations already fail with `lease_expired`. A known superseded grant fails with `claim_superseded`; an unknown grant fails with `invalid claim`. A takeover marks the old claim abandoned, increments the epoch and issues a new claim ID atomically. The worktree and sealed uploads move to the new claim; unsealed upload IDs stay with the old epoch, and check runs retain their original claim ID as evidence. A new finish requires a live, unexpired claim. An identical stored-report retry requires the same active claim, worker and subject, but does not require a live lease; a contradictory retry fails.
|
|
182
231
|
|
|
183
232
|
`dalan claims [--json]` lists active grants, epochs, lease deadlines and delivery gates. `dalan abandon ID [--reason TEXT] [--json]` ends an active claim and requeues the job, but does not shorten the prior deadline for regrant. Both require the operator key. Takeover and abandon are refused with `uncertain_delivery: reconcile first` while an owner delivery is `uncertain`, `sending`, `uncertain_terminal` or `waiting`, or an unresolved native question delivery holds the grant. Use operator reconciliation or matching positive acknowledgment evidence. Aging to `uncertain_terminal` after 30 minutes ends automatic retries but does not release the claim-epoch fence. Migration preserves existing claim IDs at epoch 1, but does not exempt them from lease validation.
|
|
@@ -190,7 +239,7 @@ Older rows get meta only from `dalan backfill-objectives [--dry-run] [--json]` (
|
|
|
190
239
|
|
|
191
240
|
### Lifecycle events and metrics
|
|
192
241
|
|
|
193
|
-
Every state change appends one row to `lifecycle_events` (`request_id`, `claim_id`, `epoch`, `type`, `at`, `actor`, `source`, `reason`) in the same transaction as the change. Types: `queued`, `claimed` (reason `new`, `reclaim`, `resume` or `takeover`), `working`, `waiting` (progress that leads with `QUESTION:`), `blocked` (`BLOCKED:`, `blocker:true`, or a blocked report), `completed` (the worker filed its terminal report, reason `outcome=...`; never acceptance), `consumed` (the owner first received the finished report through `wait` or `get`; `reject` also writes it with reason `rejected`), `accepted` (owner `accepted` or `applied` decisions, including the `dalan accept` alias; worker finish is not acceptance), `integrated` (the owner runs `dalan integrate ID --reason TEXT` through the operator-key route `/lifecycle`; idempotent per request), `abandoned`, `cancelled`, `delivery_sent`, `delivery_uncertain` and `reconciled` (T3, blocker and watch deliveries; webhook events write nothing),
|
|
242
|
+
Every state change appends one row to `lifecycle_events` (`request_id`, `claim_id`, `epoch`, `type`, `at`, `actor`, `source`, `reason`) in the same transaction as the change. Types: `queued`, `claimed` (reason `new`, `reclaim`, `resume` or `takeover`), `working`, `waiting` (progress that leads with `QUESTION:`), `blocked` (`BLOCKED:`, `blocker:true`, or a blocked report), `completed` (the worker filed its terminal report, reason `outcome=...`; never acceptance), `consumed` (the owner first received the finished report through `wait` or `get`; `reject` also writes it with reason `rejected`), `accepted` (owner `accepted` or `applied` decisions, including the `dalan accept` alias; worker finish is not acceptance), `integrated` (the owner runs `dalan integrate ID --reason TEXT` through the operator-key route `/lifecycle`; idempotent per request), `abandoned`, `cancelled`, `delivery_sent`, `delivery_uncertain` and `reconciled` (T3, blocker and watch deliveries; webhook events write nothing), `check_started`, `check_passed`, `check_failed`, `check_skipped`; `wake_held` (an available wake was held); and the control events `detach`, `interrupt_foreground`, `withdraw_work`, `revoke_grant`. Actors are `worker:<subject>` (older rows may carry `dot:<subject>`), `owner`, `operator`, `system` or `fix-loop`. Triggers reject UPDATE and DELETE; the only delete path is the hourly retention job, which sets a cutoff row inside its own transaction, rolls events older than 90 days into `lifecycle_daily(day, type, kind, count)` and deletes them (the trigger admits only rows older than that cutoff; it guards against accidents, not against a process that can change the schema). Migration v21 backfills history once, marked `source=backfill`, from assignments, the current claim (earlier epochs are unknown), progress, reports, cancellations, T3 delivery attempts and check jobs; it invents no `consumed`, `accepted`, `integrated`, `abandoned` or `check_skipped` history. `dalan metrics [--since RFC3339] [--json]` (no key needed, like `status`) reads the events. Definitions: *queue latency* is each `queued` event to the next `claimed`; *claim-to-first-activity* is `claimed` to the first `working`, `blocked`, `waiting` or `check_started`; a claim lasts from `claimed` to the next `claimed`, `completed`, `abandoned` or `cancelled` (or now). Inside a claim, the gap after a `blocked` or `waiting` event counts as blocked or waiting time, the gap after `check_started` counts as working (the check is running), any other gap of at most 20 minutes between consecutive claim activity events (claimed, progress, check events) counts as *working time*, and longer gaps count as idle. Utilization is working time over claimed time, and working time over (wall time × the per-subject lane cap); wall time starts at the window start or the first recorded event, whichever is later. *Kind* is the stored `task_kind` (assignment column, else the payload field) when present, else `review` (review mode) or the `execution_scope`, then `/` and the priority, for example `review/background`. *Rework* counts assignments submitted in the window whose `objective_key` was submitted earlier (at any time) with a different `revision`; *duplicates* count assignments whose `objective_key`+`revision` was submitted earlier under another `request_id`. A row cancelled because its preparation expired (`cancelled_reason` `expired`) is skipped by both: it was never worked, so its re-preparation is no duplicate. Both read the assignment columns `objective_key` and `revision` (migration v22), falling back to payload fields of the same name, and are split `by_source`. `objective_coverage` reports how many assignments in the window carry a key (`keyed`/`total`, also per source); when none does, rework and duplicates are unknown with that reason. See "Objective identity" below. Windows that reach rolled-up days report counts from the roll-ups and durations as unknown (`rolled up`).
|
|
194
243
|
|
|
195
244
|
Check metrics report separate `checks.passed`, `checks.failed` and `checks.skipped` counts. `checks.pass_rate` is passed / (passed + failed + skipped): a skipped check reduces the rate, and a window with only skipped checks reports zero. A window with no check outcomes reports an unknown pass rate. `status --explain` names all three counts.
|
|
196
245
|
|
|
@@ -339,6 +388,8 @@ systemctl --user is-active UNIT.service
|
|
|
339
388
|
journalctl --user -u UNIT.service -n 20
|
|
340
389
|
```
|
|
341
390
|
|
|
391
|
+
On Linux, when the service has a Gozar target socket (`UNIT-target.socket`), restart only `UNIT.service` and leave the `.socket` unit running. The socket stays bound, so a call that arrives while the bridge restarts waits (up to 170 seconds) instead of failing with HTTP 502: the target proxy unit follows the bridge with `PartOf=`, does not start it, and waits for the bridge port before it forwards. Do not stop `UNIT-target.socket` for a restart. A unit file written by an older release needs `dalan service install` again to get this behaviour.
|
|
392
|
+
|
|
342
393
|
macOS (launchd). `LABEL` is the label that install printed. For a service from an earlier release's setup script it is `org.dalan.dot-bridge-NAME`, or the label of the older release when it generated the service (find the file with `ls ~/Library/LaunchAgents | grep dot-bridge`):
|
|
343
394
|
|
|
344
395
|
```sh
|
|
@@ -431,9 +482,11 @@ Short downtime does not keep a built-in claim valid across migration 61. A claim
|
|
|
431
482
|
|
|
432
483
|
**Rollback limit:** 0.2.0 refuses a database newer than schema 49 (see the 0.2.0 changelog); this build refuses versions above 66 before schema bootstrap. Do not lower `user_version` or undo encryption by hand. Use compatible code, or a separately reviewed restore of the complete pre-upgrade state. Restoring that snapshot discards later work; preserve compatible newer ACK proof and account for possible duplicate notices if proof is lost.
|
|
433
484
|
|
|
434
|
-
The request log rotates before the next append after it exceeds 32 MiB, retaining four older files (`requests.jsonl.1` through `.4`, newest to oldest). Set `DALAN_LOG_MAX_BYTES` and `DALAN_LOG_KEEP` to positive integers to override these defaults. Each line stays whole, so a file can exceed the threshold by one line. Fresh logs use mode 0600, and break-usage backfills read all retained generations, oldest first; older history is discarded when retention fills.
|
|
485
|
+
The request log rotates before the next append after it exceeds 32 MiB, retaining four older files (`requests.jsonl.1` through `.4`, newest to oldest). Set `DALAN_LOG_MAX_BYTES` and `DALAN_LOG_KEEP` to positive integers to override these defaults. Each line stays whole, so a file can exceed the threshold by one line. Fresh logs use mode 0600, and break-usage backfills read all retained generations, oldest first; older history is discarded when retention fills. Every 30 s the bridge also asks its own listener a question (`GET /` on its loopback address) and measures the answer and how late its timer fired. An answer that takes 1 s or more, a timer that is 1 s late, or an error or timeout (30 s) is logged as `loopback_probe_slow` with `ms`, `lag_ms` and `status` or `error`; every tenth sample is summarized as `loopback_probe`. A bridge that stops answering writes no other line, because a request that never reaches a handler is never logged, so this line is the record of a stall. `dalan status --json` carries the same numbers as `loopback_probe` (`last`, `worst_ms`, `worst_lag_ms`, `failures` over the last 120 samples). `DALAN_LOOPBACK_PROBE_MS` sets the interval (at least 1000) and `0` turns the probe off.
|
|
435
486
|
|
|
436
|
-
|
|
487
|
+
Four line kinds split the time from submit to claim. `wake_delivery` is written for each wake webhook: `queued_to_attempt_ms`, `http_status` and `ack_ms` (how long the receiver took to answer). `claim_phase` is written for each new claim: `submit_to_wake_ms`, `wake_ack_ms`, `wake_to_listed_ms` (from the wake's acknowledgement to the worker's first sight of the row in `list_pending`; `null` when the listing came before the acknowledgement), `listed_to_claim_ms` and `submit_to_claim_ms`; `handoff` is true for a finish handoff, which has no wake or listing of its own. `claim_first_action` is written once per claim, for the holder's first call after the claim (`after_claim_ms`). `claim_dispatch` is a worker-reported estimate, written at most once per claim and best effort (a logging failure or a stop between the progress write and the log leaves no line, so report how many claims have a line next to the figures). It is written when the holder's first `progress` note starts with `dispatched_at=<UTC time, whole seconds, ending in Z>`: it carries that time, `claimed_at` and `gap_ms` (dispatch to claim, `null` when the dispatch time is later than the claim). A stamp that is not a real date is ignored. `source` is `worker_note`: the bridge does not match the stamp to a particular dispatch, so a stamp left over from an earlier dispatch of the same request (a finish handoff or a new epoch) reads as a plausible gap; treat it as unmatched unless the coordinator gives each dispatch a fresh stamp. It never copies the rest of the note. `claim_silence` measures how long a claim goes quiet: it is written for the holder's next call after at least 120 s without one (`silence_ms`, `since` is `claim` for the first call and `previous_call` after that, `calls_before`), and for the holder's `finish` whatever the gap (`final: true`, with `claim_age_ms`). It changes no lease, cancel or throttle behaviour. A claim that ends by cancel or lease expiry makes no call, so read its last silence offline from its last `mcp_outcome` line against its `claim_phase`. A step the bridge did not see is `null`. The bridge keeps the timing of the last 5000 rows in memory, so a restart makes the lines for older rows carry `null`.
|
|
488
|
+
|
|
489
|
+
MCP arrivals and response outcomes are logged without request contents or secrets. `mcp_inbound`, `mcp_outcome` and an answered `signal` line carry `worker`, the configured worker name, so a gap in one worker's calls (for example after a deploy) can be measured from the log. A failed tool call's `mcp_outcome` line also carries `tool_error_message`: the bridge's error text, redacted like alert notes and cut to 300 characters (null for a successful call).
|
|
437
490
|
|
|
438
491
|
### Usage breaks and usage estimates
|
|
439
492
|
|
|
@@ -480,7 +533,7 @@ Each permitted pair also needs a current definition in the owner-configured `che
|
|
|
480
533
|
|
|
481
534
|
For example, an owner may allow these repository/check pairs: `example-org/example-repo` with `host-disk`, `docs-consistency`, `auth-smoke`, `metrics-batch`, `storage-recovery` and `compat-v1`; and `example-org/example-tools` with `log-backup`. These entries are examples only and are not installed automatically. Removing `DALAN_HOST_CHECKS=1` or revoking the pair refuses subsequent launches; neither action cancels an already-running check. Existing cancellation still stops active checks. Linux needs bubblewrap with `--size`, `--disable-userns` and `--as-pid-1`, Python 3.12+, a running systemd user manager, unified cgroups, and working memory, swap, CPU and PID controllers. Missing controllers or failed service setup refuse execution. There is no fallback to the legacy launcher. macOS and other platforms refuse even with the setting enabled.
|
|
482
535
|
|
|
483
|
-
Every host-runnable check needs a current owner-configured definition with all six `host_budget` fields. A repository definition may tighten those limits, but cannot raise the owner limits, replace the owner command or authorize another ID. There are no per-check defaults. For example, this is one repository-entry fragment for the mode-0600 host checks file, not the complete file. Place it under the exact repository key:
|
|
536
|
+
Every host-runnable check needs a current owner-configured definition with all six `host_budget` fields. A repository definition may tighten those limits, but cannot raise the owner limits, replace the owner command or authorize another ID. There are no per-check defaults; increasing the global ceiling does not increase any existing configured allowance. For example, this is one repository-entry fragment for the mode-0600 host checks file, not the complete file. Place it under the exact repository key:
|
|
484
537
|
|
|
485
538
|
```json
|
|
486
539
|
{"checks":{"default":{"argv":["/runtime/node","--test","test/example.test.mjs"],"timeout_ms":60000,"output_bytes":65536,"host_budget":{"cpu_ms":30000,"wall_ms":60000,"memory_bytes":536870912,"processes":64,"disk_write_bytes":67108864,"output_bytes":65536}}}}
|
|
@@ -494,12 +547,12 @@ Owner-side integrator verification also requires `DALAN_HOST_CHECKS=1`. Each evi
|
|
|
494
547
|
| --- | --- | --- |
|
|
495
548
|
| `cpu_ms` | 50–120,000 ms | Whole-service `cpu.stat` usage, including short-lived children and execution preparation. Git fetching and other host work outside the service are not budgeted. An external supervisor and namespace supervisor sample every 10 ms and stop the job on exhaustion. `CPUQuota=100%` limits aggregate CPU rate. |
|
|
496
549
|
| `wall_ms` | 100–180,000 ms | systemd `RuntimeMaxSec`, independent of the bridge and check supervisor. Cleanup sends SIGKILL without a graceful execution extension. |
|
|
497
|
-
| `memory_bytes` | 128 MiB–
|
|
498
|
-
| `processes` | 16–
|
|
499
|
-
| `disk_write_bytes` | 1–
|
|
550
|
+
| `memory_bytes` | 128 MiB–4 GiB, multiples of 4096 | Kernel `MemoryMax`, including supervisor processes and tmpfs pages; `MemorySwapMax=0` and whole-group kernel OOM kills. After a kernel OOM kill, the same workload (directory, phases and budgets) on the same unit fails fast with reason `oom` for 60 s (`HOST_CHECK_OOM_RETRY_DELAY_MS` in `src/host-budget.mjs`); other workloads still start. |
|
|
551
|
+
| `processes` | 16–192 tasks | Kernel `TasksMax` / `pids.max`, including threads and trusted supervision. A failed fork increments `pids.events` and fails the check. |
|
|
552
|
+
| `disk_write_bytes` | 1–512 MiB, multiples of 4096 | One size-limited tmpfs holds the candidate copy, writable cache, HOME and temporary files. Prepared dependencies are mounted read-only and do not consume this writable-storage allowance. Root and proc are read-only; only fixed null/random devices are exposed, and shared-memory files use the bounded tmpfs. No PTY allocator is exposed. There are no writable host binds or shared writable caches. |
|
|
500
553
|
| `output_bytes` | 1 KiB–1 MiB | Combined stdout/stderr across both phases. The supervisor retains only the allowance and kills the namespace when another byte arrives. The bridge separately caps the receipt transport. |
|
|
501
554
|
|
|
502
|
-
Production uses the fixed `dot-bridge-host-check.service` unit as one active envelope per Unix user, shared by every bridge process. A second concurrent check is refused while that unit is occupied. The test runner sets `DALAN_HOST_CHECK_UNIT_SUFFIX` once per suite to select `dot-bridge-host-check-<suffix>.service`; segments share that reservation, while separate suites use different names. This variable is for test isolation and must remain unset in production. systemd applies the kernel limits and `Nice=10` before the source producer starts. The service verifies them before transferring any repository bytes. It owns the whole process tree with `KillMode=control-group`; a main-supervisor crash kills descendants. Closing the bridge control pipe stops the service, with the independent wall deadline as fallback. The exact unit is returned by the runner and recorded in the start receipt’s control-group path. To stop a stuck check manually, inspect that receipt and stop only that unit with `systemctl --user stop UNIT`; do not stop units by a shared name or wildcard. Stop re-verification also uses that recorded unit, for both the production name and suffixed test names. No application reservation files or expiry timestamps are needed. The unit is collected after cleanup. The stop receipt includes its invocation ID and checks that only the stop recorder remains in the cgroup; a missing receipt or surviving process never becomes a verified stop.
|
|
555
|
+
Production uses the fixed `dot-bridge-host-check.service` unit as one active envelope per Unix user, shared by every bridge process. A second concurrent check is refused while that unit is occupied. The test runner sets `DALAN_HOST_CHECK_UNIT_SUFFIX` once per suite to select `dot-bridge-host-check-<suffix>.service`; segments share that reservation, while separate suites use different names. This variable is for test isolation and must remain unset in production. A process that is not started with `NODE_ENV=production` and has no suffix (a bare test or script run) uses a unit of its own, `dot-bridge-host-check-proc-<pid>-<uuid>.service`, so it cannot occupy the live unit. systemd applies the kernel limits and `Nice=10` before the source producer starts. The service verifies them before transferring any repository bytes. It owns the whole process tree with `KillMode=control-group`; a main-supervisor crash kills descendants. Closing the bridge control pipe stops the service, with the independent wall deadline as fallback. The exact unit is returned by the runner and recorded in the start receipt’s control-group path. To stop a stuck check manually, inspect that receipt and stop only that unit with `systemctl --user stop UNIT`; do not stop units by a shared name or wildcard. Stop re-verification also uses that recorded unit, for both the production name and suffixed test names. No application reservation files or expiry timestamps are needed. The unit is collected after cleanup. The stop receipt includes its invocation ID and checks that only the stop recorder remains in the cgroup; a missing receipt or surviving process never becomes a verified stop.
|
|
503
556
|
|
|
504
557
|
The namespace supervisor runs as PID 1 and sets itself non-dumpable. Guest processes cannot signal namespace init to death or use `/proc/1/fd` to forge its receipt. Each command receives separate output pipes and closed inherited descriptors. The supervisor kills and reaps all phase descendants before starting the next phase. Source enters through a streamed archive with safe extraction; masked originals are omitted and approved source overlays stay read-only. A narrow `scope_paths` or any `scope_excluded` still refuses: this backend requires an owner-approved repository-wide read grant. An invalid sensitive-path policy also refuses before launch.
|
|
505
558
|
|
|
@@ -509,11 +562,19 @@ Both phases are offline. Networked package fetching is not supported by this bac
|
|
|
509
562
|
dalan prepare-deps /path/to/pinned/source --json
|
|
510
563
|
```
|
|
511
564
|
|
|
512
|
-
This local owner command runs `npm ci --ignore-scripts --no-audit --no-fund` in a fresh directory with the owner's normal network. It copies only the root manifest and lockfile, leaves the checkout unchanged, and does not copy project npm settings or credentials into the prepared tree. The private cache at `~/.dalan/prepared-node-modules` is keyed by the exact lockfile hash and Node version, ABI, platform and architecture; metadata also binds the manifest hash. Cache ancestors must be owner- or root-controlled without group or other write access.
|
|
565
|
+
This local owner command runs `npm ci --ignore-scripts --no-audit --no-fund` in a fresh directory with the owner's normal network. It copies only the root manifest and lockfile (and, for npm workspaces, each workspace's `package.json`, plus any `file:` dependency on a `.tgz` named in the lock), leaves the checkout unchanged, and does not copy project npm settings or credentials into the prepared tree. The private cache at `~/.dalan/prepared-node-modules` is keyed by the exact lockfile hash and Node version, ABI, platform and architecture; metadata also binds the manifest hash. Cache ancestors must be owner- or root-controlled without group or other write access. A root lock with npm workspaces is prepared with `npm ci` in a directory that holds the lock, the root manifest, every workspace manifest and every local tarball the lock names; the published entry holds the root `node_modules` plus each workspace's own `node_modules` (versions that conflict with the hoisted ones). The hash of every workspace manifest and local tarball joins the entry's identity, and with workspaces or tarballs the whole identity also selects the cache slot (a repository without them keeps the lock-and-runtime slot), so checkouts that share a lock but differ in a workspace manifest each keep their own entry. npm links each workspace into the root `node_modules`; a prepared tree may contain links only to workspace paths the identity names, and each workspace tree is mounted read-only beside its source (`packages/x/node_modules`). `link:` and `workspace:` dependencies, directory `file:` dependencies and workspace paths outside the checkout stay unsupported. Packages that need lifecycle scripts are unsupported by this preparation path.
|
|
566
|
+
|
|
567
|
+
Checks only look up the prepared tree; workers cannot choose what is installed. When a missing entry's workspace still carries the pinned base commit's exact `package.json`, `package-lock.json`, workspace manifests and local tarballs, `run_check` prepares it once before the check starts (the same `prepare-deps` command in a child process; concurrent checks share one run; the install does not count against the check's budget and does not block the bridge). The repository and check are already allowlisted, so this installs nothing the owner did not name. A workspace whose manifest or lockfile differs from the base is the worker's own input and is never installed: the check fails with `dependencies_unprepared` and an owner recovery command, as does an invalid entry. A failed automatic preparation fails the check with `dependencies_install_failed`. `dalan prepare-deps /path/to/pinned/source --replace-invalid` rebuilds an invalid entry and retains its old directory under `.replaced-*` in the private cache, so an existing mount is not modified. The owner can remove those retained directories after checks using the old input have ended. Preparation does not enable a check or change the repository/check allowlist.
|
|
568
|
+
|
|
569
|
+
The tree is mounted read-only at the guest's root `node_modules`. Ambient `node_modules` directories are omitted from the source archive, and the protected supervisor verifies the copied manifest, lock and workspace manifest hashes before launching either phase. A changed lock needs a matching preparation; there is no network or installed-checkout fallback. Checks without a root lock get no prepared tree. An explicit `install_argv` still runs offline within its existing envelope; it cannot replace the read-only tree. Preparation and lookup happen on the host outside that envelope. The guest retains its original CPU, wall, memory, process and output limits; read-only dependency pages remain subject to the service's memory limit.
|
|
513
570
|
|
|
514
|
-
|
|
571
|
+
A repository with a root `go.mod` gets the same treatment for Go: `dalan prepare-deps /path/to/pinned/source --go` runs `go mod download` (with `GOTOOLCHAIN=auto`, so the toolchain `go.mod` asks for is fetched too) in a fresh directory that holds only `go.mod` and `go.sum`, and publishes the module cache under `~/.dalan/prepared-go-modules`, keyed by both file hashes and the host Go version. The cache is mounted read-only as the guest's `GOMODCACHE` with `GOPROXY=off`, so a check can compile, vet and test offline. `run_check` prepares a missing entry once under the same pinned-base rule as npm (go.mod and go.sum unchanged from the base). Preparing a missing entry needs the pinned-base rule, but a check mounts any valid entry whose key matches the current `go.mod` and `go.sum` hashes (the same for npm): an entry the owner prepared earlier for those exact bytes is reused, and nothing is downloaded for the check. Preparation runs on the host before the sandbox's memory and disk budgets apply, so those budgets do not bound the download. The Go toolchain that `GOTOOLCHAIN=auto` fetches is a trusted executable that `go.sum` does not cover. A `replace` to a local path, or a `go.work` file, is unsupported and the checks of that repository are withheld like an unsupported npm lock. The Go build cache is written in the guest's tmpfs and counts against `disk_write_bytes`, so a check on a large Go tree needs a narrow target (for example `go build ./... && go vet ./...`); a cold full `go test ./...` of a mid-size module takes minutes on the one-core budget.
|
|
515
572
|
|
|
516
|
-
|
|
573
|
+
A pnpm repository (a root `pnpm-lock.yaml`, lockfile version 9, and no `package-lock.json`) gets the same treatment: `dalan prepare-deps /path/to/pinned/source --pnpm` (also chosen by itself when only `pnpm-lock.yaml` exists) runs `pnpm fetch` and then `pnpm install --offline --frozen-lockfile --ignore-scripts --ignore-pnpmfile --package-import-method=copy` in a fresh directory with a stage-private store and metadata cache, and publishes the root `node_modules` plus each importer's own `node_modules` under `~/.dalan/prepared-node-modules`. The key is the hash of `pnpm-lock.yaml`, `pnpm-workspace.yaml`, the root `package.json` and every importer's `package.json` (the importers are the keys of the lock's `importers:` block), plus Node, pnpm, platform and architecture. The `pnpm` on the host's `PATH` must report exactly the version that `packageManager` pins (pnpm switches to a pinned release it already has); otherwise the repository is unsupported. Trees are mounted read-only at `/workspace/node_modules` and `/workspace/<importer>/node_modules`; the relative links between them resolve at those mount points. `run_check` prepares a missing entry once under the same pinned-base rule (lock, workspace file and importer manifests unchanged from the base). The sandbox has no pnpm and no network, so a check runs the tools directly, for example `cd packages/x && node --import tsx ../../scripts/run-node-tests.mjs --test --test-concurrency=1 "src/**/*.test.ts"`, never `pnpm test`. Every published tree (npm and pnpm) carries empty `.cache`, `.vite`, `.vite-temp`, `.vitest` and `.vitest-cache` directories, and the sandbox mounts a 16 MiB tmpfs over each: vite bundles its config into `node_modules/.vite-temp` and aborts the run when it cannot, and vitest and other tools cache under `node_modules`. The store stays read-only and the writes vanish with the sandbox. An entry published earlier gets the directories the next time anything resolves it. Pass `--test-concurrency=1` for a sequence of packages: at the default concurrency the sequence of six pdpp packages reached the 128-process budget, while concurrency 1 peaked at about 122. Unsupported, and withheld like an unsupported npm lock: a repository `.npmrc` or `.pnpmfile.cjs`; `patchedDependencies`; any `pnpm-workspace.yaml` key outside a short allow-list (`packages`, `catalog`, `catalogs`, `overrides`, `publicHoistPattern`, `hoistPattern`, `childConcurrency`, `allowBuilds`, `onlyBuiltDependencies`, `ignoredBuiltDependencies`, `neverBuiltDependencies`, `minimumReleaseAge`, `minimumReleaseAgeExclude`), however quoted, and any YAML shape the line reader does not understand; any `package.json#pnpm` key outside `overrides`, `onlyBuiltDependencies`, `ignoredBuiltDependencies`, `neverBuiltDependencies`, `allowBuilds`, `peerDependencyRules`; a lock entry (in any layout) that names a tarball URL, a git repository, a directory or a downloaded runtime; `file:` dependencies, `link:` dependencies that are not workspace packages, importer paths with links or unusual characters, and a lock with both an npm and a pnpm lock beside it. Install scripts never run (`--ignore-scripts`), so a package that needs a native build step (for example `better-sqlite3`) is not rebuilt and a check that loads it fails; a rebuild step is a known limit.
|
|
574
|
+
|
|
575
|
+
The prepared node_modules store holds about 1 GB per distinct pnpm lock (npm entries share the same store). After each preparation `dalan prepare-deps` keeps the 4 most recently used entries (a check that resolves an entry touches its `metadata.json` at most once an hour). It never touches an entry younger than 24 hours and never deletes an entry in place: a pruned entry is renamed to `.pruned-<id>` and removed by a later pass at least an hour after, so a running check's read-only mount keeps its files. Stale `.replaced-*` and abandoned `.stage-*` directories older than a day are removed in the same pass, and an empty lock directory only after it has stayed empty for a day (a running preparation creates it first and publishes last). The version probe on the claim path waits at most 5 seconds; `dalan prepare-deps` allows two minutes, so run it once by hand when a repository pins a pnpm release the host has not downloaded yet. The owner can run it by hand: `dalan prepare-deps --prune [--keep N]` (default 4).
|
|
576
|
+
|
|
577
|
+
The prepared Go module store (about 400 MB per distinct `go.mod` and `go.sum`) follows the same rule: a preparation with `--go` keeps the 4 most recently used entries of that store, and `dalan prepare-deps --prune` prunes both stores (the Go result is under the `go` key).
|
|
517
578
|
|
|
518
579
|
Writes remain in the private execution copy and are discarded when its namespace exits. Only captured output is exported. Receipts identify `execution_storage: private_tmpfs_copy_not_exported` and the selected dependency identity; they do not claim host worktree hashes observe install or post-check mutations in that copy, or attest the entire executed source. The original candidate diff remains available for owner review.
|
|
519
580
|
|
|
@@ -648,9 +709,9 @@ Worker repository policy is not a credential boundary: the bridge host credentia
|
|
|
648
709
|
|
|
649
710
|
If repository fetch reports that `gh` is missing, check the service's `PATH`. If it reports authentication failure, run `gh auth status` with the service `HOME` and `PATH`, then complete `gh auth login` in that same environment. These diagnostics do not print credential contents.
|
|
650
711
|
|
|
651
|
-
Each implementation request names a GitHub repository as `owner/name` and a full base commit SHA. The bridge uses the host's GitHub authentication to fetch that commit into a bare-mirror cache isolated by the resolved worker and a detached per-request worktree under `<home>/.tmp/dalan/worktrees/<request_id>`. A previously validated claim-bound workspace keeps its saved legacy common directory until it finishes; cleanup does not move or purge it while active. For configured workers, only exact repositories in that worker's `repos` list are eligible. A missing policy on a fresh host denies repository work; upgraded legacy hosts use their one-time exact history seed. `dalan worker list` reports the effective policy. Policy checks precede every fresh HTTP repository claim; an exact live retry of the holding grant is not re-checked, as a live grant may still finish after revocation. Queued rows stay durable and blocked. Existing valid grants may finish under unchanged lease, check, epoch and cancellation guards. The Git askpass still uses the full host `gh`/`GH_TOKEN` credential, which is not narrowed by this policy; a fine-grained read-only PAT limited to the allowed-repository union is recommended (Contents: read; Pull requests: read only when PR inputs require it). Clone URLs with embedded credentials are rejected, and the sandbox gets no GitHub token, `.git` data, host home, credential helpers, or sockets. A new revision needs a new request ID. The owner retrieves sealed evidence with `dalan get ID --json` then `dalan artifact ARTIFACT_ID --output PATH` (a new file in an existing directory). Artifacts are kept for 14 days. A finished job's worktree is removed after 6 hours, sooner once the owner has read the result or when disk space is low. The bridge never pushes, merges, or deploys.
|
|
712
|
+
Each implementation request names a GitHub repository as `owner/name` and a full base commit SHA. The bridge uses the host's GitHub authentication to fetch that commit into a bare-mirror cache isolated by the resolved worker and a detached per-request worktree under `<home>/.tmp/dalan/worktrees/<request_id>`. A previously validated claim-bound workspace keeps its saved legacy common directory until it finishes; cleanup does not move or purge it while active. For configured workers, only exact repositories in that worker's `repos` list are eligible. A missing policy on a fresh host denies repository work; upgraded legacy hosts use their one-time exact history seed. `dalan worker list` reports the effective policy. Policy checks precede every fresh HTTP repository claim; an exact live retry of the holding grant is not re-checked, as a live grant may still finish after revocation. Queued rows stay durable and blocked. Existing valid grants may finish under unchanged lease, check, epoch and cancellation guards. The Git askpass still uses the full host `gh`/`GH_TOKEN` credential, which is not narrowed by this policy; a fine-grained read-only PAT limited to the allowed-repository union is recommended (Contents: read; Pull requests: read only when PR inputs require it). Clone URLs with embedded credentials are rejected, and the sandbox gets no GitHub token, `.git` data, host home, credential helpers, or sockets. A new revision needs a new request ID. The owner retrieves sealed evidence with `dalan get ID --json` then `dalan artifact ARTIFACT_ID --output PATH` (a new file in an existing directory). Artifacts are kept for 14 days. A finished job's worktree is removed when its finish commits; whatever that call cannot take (an active check, a failed removal) is removed by the hourly sweep, which otherwise evicts a terminal checkout after 6 hours, sooner once the owner has read the result or when disk space is low. The bridge never pushes, merges, or deploys.
|
|
652
713
|
|
|
653
|
-
Checks are detected from `package.json`, `pyproject.toml`/pytest, Cargo, Go, or a Makefile `test` target. Repository `.dalan.json` (or the legacy `.dot-bridge.json` fallback) describes checks and may tighten a budget; owner `<config>/dalan/checks.json` supplies the host command. `claim` and `get` add runnable `available_checks` only for implementation assignments when workspace tools are enabled; host jobs list only checks permitted by the owner allowlist and current owner definition. Worker and none jobs keep declared metadata for information, but do not claim that it can run on the host. Repository-backed `workspace_result` includes check discovery; without repository input it returns only `checks` and sealed `artifacts`. An eligible `run_check` with an unknown or unpermitted `check_id` returns a structured refusal without creating a check run or output artifact. With the host opt-in, exact owner allowlist pair and explicit owner budgets above, installation and checking share one offline, resource-contained execution copy, an isolated HOME and bounded output. The sandbox exposes an empty user systemd scope list; other `systemctl` operations fail without reaching the host bus. Isolated loopback works in the networkless phase. This repo's historical `default` check runs `npm run test:sandbox` but has no host budget or owner authorization. The full `npm test` suite includes `workspace-e2e.mjs`, which launches bubblewrap and cannot create a nested namespace inside the check sandbox; run it on the host. Local fake-JWKS and bubblewrap tests are in `scripts/auth-e2e.mjs` and `scripts/workspace-e2e.mjs`.
|
|
714
|
+
Checks are detected from `package.json`, `pyproject.toml`/pytest, Cargo, Go, or a Makefile `test` target. Repository `.dalan.json` (or the legacy `.dot-bridge.json` fallback) describes checks and may tighten a budget; owner `<config>/dalan/checks.json` supplies the host command. `claim` and `get` add runnable `available_checks` only for implementation assignments when workspace tools are enabled, with `available_check_details` (id to one line: the command, `&&`-joined with any install command, and its time limit) and `check_guidance` (runs in the bridge sandbox on the claim's workspace, not on the worker's machine; the argument is `check_id`); host jobs list only checks permitted by the owner allowlist and current owner definition. A host job whose root lockfile the host cannot prepare (npm workspaces, or `file:`/`link:`/`workspace:` dependencies) lists no checks and reports `host_execution_unavailable_reason` starting `dependencies_unsupported`, because every check would fail on the missing dependencies. Worker and none jobs keep declared metadata for information, but do not claim that it can run on the host. Repository-backed `workspace_result` includes check discovery; without repository input it returns only `checks` and sealed `artifacts`. An eligible `run_check` with an unknown or unpermitted `check_id` returns a structured refusal without creating a check run or output artifact. With the host opt-in, exact owner allowlist pair and explicit owner budgets above, installation and checking share one offline, resource-contained execution copy, an isolated HOME and bounded output. The sandbox exposes an empty user systemd scope list; other `systemctl` operations fail without reaching the host bus. Isolated loopback works in the networkless phase. This repo's historical `default` check runs `npm run test:sandbox` but has no host budget or owner authorization. The full `npm test` suite includes `workspace-e2e.mjs`, which launches bubblewrap and cannot create a nested namespace inside the check sandbox; run it on the host. Local fake-JWKS and bubblewrap tests are in `scripts/auth-e2e.mjs` and `scripts/workspace-e2e.mjs`.
|
|
654
715
|
|
|
655
716
|
A check spec can also carry `prerequisites`, `readiness_argv` and `test_paths`; detected checks derive the first and last where they can (npm: the `engines.node` floor, `package-lock.json` when `npm ci` is used, and the files or directories the `test` script names; pnpm/yarn/uv/cargo/go/make: that binary; pytest `testpaths`; Cargo `tests`; Go `./...`), and an override may declare them: `"prerequisites": {"binaries": ["uv"], "lockfile": "uv.lock" | true, "runtime": "node>=24"}`, `"readiness_argv": [...]`, `"test_paths": ["tests"]`. Anything not derivable or declared is `null` with a `*_reason`, never an empty list. When an implementation request uses `execution=host`, the bridge reads this metadata at the pinned `base_sha` (a `git show` into a temp directory, no worktree) and checks the `default` check: each binary must exist in the host `/usr/bin` (the check sandbox ro-binds `/usr`, so host presence is the honest signal), the lockfile must exist at `base_sha`, and a `node>=N` runtime must hold for the running bridge process. A failure of an owner-authorized default check refuses admission with `BLOCKED: check prerequisites unmet: ...` (a blocking `check_prerequisites_unmet` defer) before any row is queued, so no claim is wasted. An unallowlisted default is still inspected, but unmet prerequisites are warnings; this keeps a separately selected owner-authorized check usable without granting the default. Unmet prerequisites of other checks also come back as warnings. `readiness_argv` is recorded as skipped at admission: running a repository-declared command needs the sandboxed checkout and is unsafe on the host. The submit response adds `check_readiness: {probed, warnings, skipped}`, and the owner-side `dalan get ID --json` adds `check_metadata`; host-mode `available_checks` includes only runnable owner-authorized checks. Unreadable host check metadata is classified as `check_metadata_unreadable`. For `execution=none` or `worker`, host probes are skipped and unreadable metadata does not block admission; the regression-test scope rule still applies in every execution mode.
|
|
656
717
|
|
|
@@ -660,6 +721,8 @@ Migration from the old project policy: remove `<config>/dalan/projects.json`; re
|
|
|
660
721
|
|
|
661
722
|
`<config>/dalan/limits.json` (mode 0600) sets `max_claimed_outer_assignments`; the historical cap-1 example permits one outer claim. Capacity counts all active worker-scoped claims for that worker plus the caller's historical subject-scoped claims for the same worker. Legacy subject-scoped claims count only for their subject; worker-scoped claims share capacity across subjects. Mixed historical rows count according to their recorded `lane_scope` and `lane_key`. A fresh claim, or an expired-lease takeover, that would exceed the configured cap for those recorded lanes returns `capacity_full`; an exact live retry from the holding connection stays idempotent and is not re-judged against later destination or repository-policy changes (see [Claims and leases](#claims-and-leases)). Read the active cap from `dalan status --json`. `worker_lane_capacity` (integer 1..10, default 6) is the lane count that utilization metrics divide by; it does not limit claims (see docs/usage.md, "Lane utilization").
|
|
662
723
|
|
|
724
|
+
The optional `worker_claim_min_gap_ms` map sets a minimum gap for a worker by lower-case worker name (integer 1000 to 600000 milliseconds; defaults to `{}`, disabled). A fresh claim is refused with a retry delay while the same subject and worker has another live claim newer than that gap. Reporting that claim frees the throttle immediately; exact retries are unchanged, and the refusal never takes the queued assignment. `list_pending` still reports ordinary lane capacity. Restart the bridge after editing the config.
|
|
725
|
+
|
|
663
726
|
Fresh submissions enforce UTF-8 byte caps and explicit pinned repository scopes. The [submission policy](../PROTOCOL.md#submission-policy) defines sensitive exclusions and exact-path exceptions.
|
|
664
727
|
|
|
665
728
|
The [external dead-man monitor](deadman.md) is configured separately from the bridge service.
|
package/docs/pull-workers.md
CHANGED
|
@@ -21,6 +21,14 @@ Messages that the owner sends with `dalan tell` show up in `list_pending`; read
|
|
|
21
21
|
|
|
22
22
|
Put this loop in the worker's standing instructions, for example in its scheduled task prompt. The bridge also returns short guidance in each `get` response.
|
|
23
23
|
|
|
24
|
+
### Claim several ready assignments in one call
|
|
25
|
+
|
|
26
|
+
The opt-in `batch-claim-v1` catalog advertises `claim({ next, claimant, acquisition_id, lease_ms? })`. Set `next` to 1 through 8 instead of `request_id`. The bridge returns `{ claims, free_lanes }`; each entry is a normal claim reply with the assignment, claim ID and epoch. Treat each entry as a separate grant and start the work before moving on. Save the original acquisition ID and the returned grants across retries. Choose a new acquisition ID for a new batch.
|
|
27
|
+
|
|
28
|
+
The bridge takes ordinary, unskipped queued assignments in list order, limited by current free lanes. It stops at the first refusal and returns the admitted prefix. Cancelled, skipped, and resumable grants are not batch candidates. Native protocol jobs and policy work still use the explicit request ID or their existing acquisition path. A retry with the same batch arguments can recover the still-live grants in that batch; it never claims additional work, even if the first call was interrupted or a lane opened later. If the returned batch is partial, call `list_pending` to see what's ready and use a fresh acquisition ID for a new batch.
|
|
29
|
+
|
|
30
|
+
Older profiles and single-request calls are unchanged. Only enable the opt-in catalog after coordinating the deployment pin and refreshing the connector's tool schema. Until both advertise `next`, continue using `request_id`.
|
|
31
|
+
|
|
24
32
|
## Ways to start a run
|
|
25
33
|
|
|
26
34
|
| Pattern | How it works | Latency | Cost when idle | Use when |
|
|
@@ -70,7 +78,9 @@ A vendor run can stop in the middle of a job. Resume wake exposes an expired own
|
|
|
70
78
|
- **Record.** Lifecycle gets a `claimed` event with reason `resume` (it does not count toward claims per hour), and the progress history gets a `[bridge] run resumed: epoch N stopped after Ss ...` line.
|
|
71
79
|
- **Switch.** `DALAN_RESUME_IDLE_MS=0` turns all of it off: the signal, the `list_pending` entries and the rotation. Exact acquisition identity checks still apply: omission matches only a stored NULL, and a different live acquisition is refused. The switch never permits early regrant. Set it in the bridge service environment and restart.
|
|
72
80
|
- **Progress nudge (opt in per worker).** In `workers.json` set `"guidance": "resume"` for the worker. `claim` and `get` then add acquisition and progress guidance. The progress interval is half the idle threshold, rounded down to a multiple of 30 seconds, with a minimum of 30 seconds. Thresholds of `120000`, `240000`, and `45000` ms produce intervals of 1 minute, 2 minutes, and 30 seconds. For the default threshold the text is: "Generate one random acquisition_id per run and pass it on every claim call, including retries. Post progress at least every 1 minute with what is done and what remains, so a resumed run can continue; if your run may end, post progress first." With the switch at 0, guidance uses the default threshold. The only valid guidance value is `"resume"`.
|
|
73
|
-
- **Next job in the `finish` reply (opt in per worker).** In `workers.json` set `"finish_handoff": true` (or `{"wait_ms": 20000}`; 0 to 45000
|
|
81
|
+
- **Next job in the `finish` reply (opt in per worker).** In `workers.json` set `"finish_handoff": true` (or `{"wait_ms": 20000, "max_jobs": 6, "idle_lease_ms": 60000}`; `wait_ms` 0 to 45000, `max_jobs` 1 to 8, default 1; `idle_lease_ms` 1000 to 120000, default 120000; `only_when_empty` true hands a job only when nothing is queued at the finish, so queued work is listed for the worker to claim and a handed job is never left untouched beside it; default false) for the worker. After `finish` stores the report, the reply carries `next_job`, the normal `claim` result for the oldest queued job, claimed for this worker. With `max_jobs` above 1 the reply also carries `next_jobs`, every job handed over (`next_job` is the first): one `finish` refills every lane it frees, up to `max_jobs`, the free lanes and the queued jobs, so a worker that runs several jobs at once keeps its width instead of shrinking to one job per finish. The extra claims are keyed `handoff-<claim_id>-n<n>`, so a repeated `finish` returns the same jobs and takes no more. The claim starts on an idle lease (`idle_lease_ms`, default 2 minutes): a job that the worker never touches returns to the queue when it ends, so a session that ended after `finish` does not hold a lane. The first call on the claim (a `get` counts) moves it to the 10-minute working lease; any later tool call on the claim renews it. The bridge makes that claim with the same checks as a worker's own `claim`: repository policy, scope, pause, capacity and the live-connection fence. It keys the claim to the finished claim (`acquisition_id` `handoff-<claim_id>`), so a repeated `finish` returns the same `next_job` and two finishes never get the same job. With nothing queued, `finish` waits up to `wait_ms`, polling twice a second, and returns `queue_empty: true`; it stops at once if the bridge is paused or the client disconnects. If a claim fails, the reply keeps the old `next_queued` hint. A worker that does not opt in gets no claim and no wait. Choose `wait_ms` below the host's tool-call timeout: ChatGPT documents none, and users report about 60 seconds. The log line `finish_handoff` records `claimed`, `empty` or `none` with the wait.
|
|
82
|
+
|
|
83
|
+
**Handoffs across turns:** Choose `"finish_handoff": {"lease": "working"}` for a worker that always ends its turn after finishing and can reliably recover the returned claim on its next turn. The handed job immediately gets that worker's normal working lease (10 minutes when not configured, subject to the bridge-wide lease cap). The default `"lease": "idle"` releases untouched jobs faster and is better for same-turn workers. Do not set `idle_lease_ms` with `"lease": "working"`. A longer untouched claim holds one lane for longer when the worker does not return; choose it only for a worker that really resumes its handoffs.
|
|
74
84
|
- **Measure.** `dalan metrics --json` has `resume_wake.by_worker.<worker>`: `resumed`, `lease_expiry_retries`, and `time_to_finish_resumed` against `time_to_finish_lease_expiry` (first queued event to completed, p50/p90). `resume_wake.duplicate_epoch_claims` must be 0. The text form prints `resumed=` and `duplicate_epochs=`. Falsifier: resumed jobs do not finish sooner than lease-expiry jobs.
|
|
75
85
|
|
|
76
86
|
Maintainer check: from a source checkout installed with `npm ci`, run `node scripts/resume-wake-test.mjs`. The npm package does not include this script.
|
package/docs/service-setup.md
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
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
|
-
Before you begin, install Node.js 24 or newer
|
|
6
|
-
|
|
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.
|
|
5
|
+
Before you begin, install Node.js 24 or newer. 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.
|
|
8
6
|
|
|
9
7
|
<a id="owner-setup"></a>
|
|
10
8
|
|
|
@@ -14,11 +12,13 @@ This example names your worker `assistant`. Choose another lowercase name if you
|
|
|
14
12
|
|
|
15
13
|
```sh
|
|
16
14
|
npm install -g @tnunamak/dalan
|
|
17
|
-
dalan service install --worker assistant
|
|
15
|
+
dalan service install --worker assistant
|
|
18
16
|
dalan connect start --worker assistant
|
|
19
17
|
```
|
|
20
18
|
|
|
21
|
-
Dalan
|
|
19
|
+
Dalan chooses a free port and asks Gozar which routes meet its requirements. Review the setup steps and approve the route in the terminal. Dalan installs the background service and writes the connector URL after Gozar verifies the route.
|
|
20
|
+
|
|
21
|
+
Run `dalan setup` to save a route choice for future public runs. To resume cleanup, run `dalan setup --cancel OPERATION_ID` with the setup operation ID printed in the terminal. Review each offered action separately. Removing a resource, revoking its authorization and disconnecting a locally stored credential have separate effects.
|
|
22
22
|
|
|
23
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:
|
|
24
24
|
```sh
|
|
@@ -46,7 +46,7 @@ The authentication check tests the public route and sign-in flow, not whether an
|
|
|
46
46
|
|
|
47
47
|
### More workers and advanced setup
|
|
48
48
|
|
|
49
|
-
To configure several workers, repeat the flag in the install command, for example `dalan service install --worker assistant --worker reviewer
|
|
49
|
+
To configure several workers, repeat the flag in the install command, for example `dalan service install --worker assistant --worker reviewer`, 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.
|
|
50
50
|
|
|
51
51
|
### Pairing details
|
|
52
52
|
|
|
@@ -69,7 +69,7 @@ If you already serve a stable HTTPS address through your own reverse proxy, regi
|
|
|
69
69
|
dalan service install --worker assistant --public-url https://PUBLIC_HOST --port PORT --target TARGET_IP:TARGET_PORT
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
Run this command in a terminal and approve the matching owner-managed offer shown by Gozar. Gozar records and verifies the existing origin and listener. You retain the proxy and its configuration. 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.
|
|
73
73
|
|
|
74
74
|
The proxy must forward these routes without removing their prefixes, methods, query strings, authorization headers or cookies:
|
|
75
75
|
|
|
@@ -83,7 +83,7 @@ The proxy must forward these routes without removing their prefixes, methods, qu
|
|
|
83
83
|
| `/signal/*` | Answers wake hooks when configured. |
|
|
84
84
|
| `/.well-known/gozar/service` | Answers the Gozar check, with its query string. |
|
|
85
85
|
|
|
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.
|
|
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. Keep the target port and the Dalan listener port equal for route proof. A custom check supplied with `--verify-cmd COMMAND` cannot grant permission to publish a connector URL.
|
|
87
87
|
|
|
88
88
|
### Migrate an older bridge
|
|
89
89
|
|
|
@@ -170,7 +170,7 @@ A service installed by 0.6.0 or 0.6.1 is adopted by its first `dalan service upd
|
|
|
170
170
|
dalan service status --json
|
|
171
171
|
```
|
|
172
172
|
|
|
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.
|
|
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, `commit_uncertain` when Dalan cannot tell whether the switch committed (it keeps the candidate and recovery data and does not retry that release on its own), `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.
|
|
174
174
|
|
|
175
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.
|
|
176
176
|
|
|
@@ -189,7 +189,7 @@ The `dalan` command on your PATH runs the version the service uses. Set `DALAN_N
|
|
|
189
189
|
dalan service uninstall
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
Confirm the exact Gozar route handle when prompted. The command removes the service and its update timer or agent after Gozar confirms route cleanup. 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).
|
|
193
193
|
|
|
194
194
|
## Legacy
|
|
195
195
|
|
package/docs/t3-integration.md
CHANGED
|
@@ -46,8 +46,10 @@ To send a corrected version of earlier work, add `--revises REQUEST_ID` and a ne
|
|
|
46
46
|
|
|
47
47
|
## Builds through the T3 worker provider
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
Builds never publish a branch for you. A refusal tells you whether to commit tracked edits or, if you are authorized to publish the revision, gives the exact ref to push before delegating again. The worker cannot open a file just because the brief names a path on your computer; paste only the text you are authorized to share.
|
|
50
|
+
|
|
51
|
+
A `delegate_task` to the worker provider whose task starts with `[dot-build] <path> ...` (after an optional `[dot-decision:ID]` line; T3's role preamble is removed first) is a build. The adapter submits it with `execution_scope: "implementation"`, `scope_paths` set to the listed paths that exist at the requester's HEAD, `output_paths` set to the listed paths that do not (new files the worker creates), and meta `task_kind: "build"`, using the requester's HEAD. Set `DALAN_ACP_BUILD_EXECUTION=host` (legacy `DOT_ACP_BUILD_EXECUTION`) where the bridge runs host checks (`DALAN_HOST_CHECKS=1`): the bridge then runs the repository's named checks on the build, and runs the default check itself before finish when the worker did not. A host build's scope is the whole repository with sensitive paths excluded at submit (host checks need a repository-wide read), the same scope the fleet's own host builds use; the `[dot-build]` list still names the files the change is about. Unset, a build gets the worker profile's default execution, which may leave it unchecked. A build is refused unless `DALAN_ACP_BUILD_OWNERS` (or the legacy `DOT_ACP_BUILD_OWNERS`) is set to a comma-separated list of authorized repository owners. An empty, missing or malformed list fails closed. `DALAN_ACP_REPO_CONFIG` (or the legacy `DOT_ACP_REPO_CONFIG`) can select the local repository policy file; otherwise the adapter reads the Dalan producer configuration, with legacy path fallback. That file must provide valid `repo_selection.exclude` and `deny_path_terms` arrays; missing or malformed policy also fails closed. A brief must name no path outside its list, and at most five files may be named. Optional: `DALAN_ACP_PROSE_CHECK_OWNERS` lists the owners whose added prose is checked by an external prose linter. `DALAN_ACP_PROSE_CHECK` names its executable, which the adapter runs as `COMMAND check --stdin --kind doc --json` with the added lines on stdin; when the owner list is unset or empty, no prose check runs; an enabled check without an executable reports an error; a malformed non-empty list returns an error. The result includes the base, check results, patch preview, fetch command and verdict commands. `dalan get`, `artifact`, `accept` and `reject` work on adapter rows: with no CLI receipt, the CLI derives the owner token from `~/.config/dalan/acp-secret`.
|
|
50
52
|
|
|
51
53
|
## Consumers are assigned by code
|
|
52
54
|
|
|
53
|
-
Who a result is for comes from the code path that produced the request, never from what the submitter writes. A submit request, its `meta` or its assignment that sets `value_tier` or `tier`, or names a system consumer (`consumer` as `fix_pipeline`, `ledger` or `reserve`, or one that is not a string or `{type}`), is refused (`assignment declares tier; the bridge assigns the consumer and tier from the code path...`). A drainer manifest, or a submit whose source is `drainer` or `fix-loop`, may not declare `severity` either; an agent's `severity` hint passes, since agent work is already the first tier. Naming a requester (`consumer: {type: 'thread', id}`) is not refused, and nothing reads it yet. `--source drainer` and `--source fix-loop` must be proven by the request id of their own code (`drainerRequestId`, `fixLoopRequestId`); a forged claim is refused. Drainer work is always background priority, so no manifest can place itself ahead of agent-requested work. The consumer types are `agent` (tier 0), `fix_pipeline` (tier 1) and `reserve` (tier 5, work nobody asked for). `ledger` has no code path yet, so nothing can hold it. The rules live in `src/consumers.mjs`.
|
|
55
|
+
Who a result is for comes from the code path that produced the request, never from what the submitter writes. A submit request, its `meta` or its assignment that sets `value_tier` or `tier`, or names a system consumer (`consumer` as `fix_pipeline`, `ledger` or `reserve`, or one that is not a string or `{type}`), is refused (`assignment declares tier; the bridge assigns the consumer and tier from the code path...`). A drainer manifest, or a submit whose source is `drainer` or `fix-loop`, may not declare `severity` either; an agent's `severity` hint passes, since agent work is already the first tier. Naming a requester (`consumer: {type: 'thread', id}`) is not refused, and nothing reads it yet. `--source drainer` and `--source fix-loop` must be proven by the request id of their own code (`drainerRequestId`, `fixLoopRequestId`); a forged claim is refused. Drainer work is always background priority, so no manifest can place itself ahead of agent-requested work. The consumer types are `agent` (tier 0), `fix_pipeline` (tier 1) and `reserve` (tier 5, work nobody asked for). `ledger` has no code path yet, so nothing can hold it. The rules live in `src/consumers.mjs`. The ACP adapter sets `caller_waiting: true`; its cap counts waiting callers for the same worker and priority, and waiting normal jobs precede other normal jobs, then background (`bin/dot-acp-agent.mjs#acquire`, `src/store.mjs#submitInTransaction`, `src/store.mjs#LIST_ORDER`).
|
|
@@ -34,7 +34,7 @@ An ambiguous publish leaves a pending key that cannot be sent again automaticall
|
|
|
34
34
|
|
|
35
35
|
`t3code threads list` can return a large response when it includes every thread and all fields. The tool returns a compact result for routine reads; its name, input schema and description do not change.
|
|
36
36
|
|
|
37
|
-
- `threads`: the newest threads by `updatedAt` (descending; ties by `id`), at most 50 (`THREAD_LIST_LIMIT`) and at most 16000 bytes of serialized entries (`THREAD_LIST_BUDGET`; thread IDs can be 328 characters long).
|
|
37
|
+
- `threads`: the newest threads by `updatedAt` (descending; ties by `id`), at most 50 (`THREAD_LIST_LIMIT`) and at most 16000 bytes of serialized entries (`THREAD_LIST_BUDGET`; thread IDs can be 328 characters long). If the first entry cannot fit, the list is empty and `truncated` is true.
|
|
38
38
|
- Each entry has `id`, `title` (at most 120 characters, clipped with `…`), `projectId`, `status`, `runStatus`, `updatedAt`, `latestUserMessageAt` and `pendingRuntimeRequest` (boolean). `activityRunStatus` is present only when it is set. `branch` and `worktreePath` are present only when they are at most 80 characters.
|
|
39
39
|
- `total` (all granted threads that matched the filter), `shown`, `truncated` (`total > shown`).
|
|
40
40
|
- `projects`: `{id,title,count}` for the projects of all matched threads, most threads first, at most 20; `projects_total` is present when there are more.
|
|
@@ -61,7 +61,7 @@ Do not trigger a ChatGPT reconnect from the bridge host. The connector's current
|
|
|
61
61
|
|
|
62
62
|
## Standing instruction for worker
|
|
63
63
|
|
|
64
|
-
> You can inspect the owner's T3 threads through this connector. Use `t3_thread_list` and `t3_thread_read`. They show only threads granted by your live claimed jobs; exact IDs
|
|
64
|
+
> You can inspect the owner's T3 threads through this connector. Use `t3_thread_list` and `t3_thread_read`. They show only threads granted by your live claimed jobs; pass the exact IDs returned by `t3_thread_list`. Use `notify_owner` for a short out-of-band alert that does not start a T3 turn. Send assignment questions to the exact owner thread. Mark blockers with optional `progress.blocker:true` or start the note with `BLOCKED:` / `QUESTION:` so the bridge forwards them once if you forget. The owner can leave a lightweight message with `dalan tell`; it emits an event, but whether that starts a run depends on your client. Find it in `list_pending`, read it with `get`, and call `ack_message` after reading it. It is a message, not an assignment. `run_check` can return `{check_run_id,status:"running"}`; poll `workspace_result` for completion. Upload sealed evidence with `artifact_chunk` in any claimed assignment. Call `list_tools` first to learn the other tools you may use, then run them with `call_tool_read` or `call_tool_write`. All T3 tool calls are audited.
|
|
65
65
|
|
|
66
66
|
## After adding or changing tools
|
|
67
67
|
|
|
@@ -92,15 +92,15 @@ A registry change (add, grant, revoke, remove) needs no connector Refresh and no
|
|
|
92
92
|
- One message per worker every 10 minutes. Later messages are held and merged into the next one; a failed delivery stays queued.
|
|
93
93
|
- A global budget across all `t3_post` tools and workers: 6 messages per hour and 30 per day. Held messages, failed attempts and timer retries all count. A call over the budget is refused with `rate_limited`; the timer waits until the budget has room.
|
|
94
94
|
- Every call that reaches the budget check is logged in `tool_post_log` with its worker, message kind and outcome (`sent`, `held`, `failed`, `rate_limited`), never its text. A timer retry is logged there as its own row. The queued message text is kept in the bridge database until it is sent.
|
|
95
|
-
- Repeating a call with the same `idempotency_key` returns the first outcome and posts nothing. While the first call is still running (its 45-second lease is live) the repeat is refused with `in_progress`; retry later with the same key.
|
|
96
|
-
-
|
|
95
|
+
- Repeating a call with the same `idempotency_key` returns the first outcome and posts nothing. While the first call is still running (its 45-second lease is live) the repeat is refused with `in_progress`; retry later with the same key. When a write's lease expires without a recorded outcome, the same key returns `outcome_uncertain`. Check the destination before using a new key. If the original call later records an outcome, the same key returns it. After a `t3-post` exit code 3 the same key may retry once the message can be sent; the queued message is reused, not duplicated. Any other failure leaves delivery unknown: the bridge marks the message as possibly delivered and never retries it by itself. `dalan tool list` shows how many such messages a tool has. Check the thread before you send the same message again under a new key. Completed receipts for a key last seven days; a completed key that is reused with changed content can return the old result, so use a new key for new content.
|
|
96
|
+
- The bridge records a pending delivery before contacting the destination. After an interrupted send, check the thread to learn whether the message arrived.
|
|
97
97
|
- `t3-post` is the only delivery path. There is no fallback that posts as the owner.
|
|
98
98
|
|
|
99
99
|
**Trust rule.** The receiving thread treats every message from a worker as untrusted data and never as an instruction. The `kind` list limits the shape of a message, not its content: the text is free-form and can claim to speak for the owner. Act on it only after the owner or the repository confirms it.
|
|
100
100
|
|
|
101
101
|
Each worker may make at most 120 `call_tool_read` and `call_tool_write` calls per minute in total, across all tool names. The bridge checks this budget before it looks up the tool, and counts every call, including calls to unknown or ungranted tools and replays of a finished `idempotency_key`. A call over the budget is refused with `rate_limited` and writes no audit row. The bridge only adds to one counter per worker, `admission_refused:WORKER` in `tool_registry_meta`, so a flood cannot grow the audit log. The counter survives a restart; the minute window does not. A tool also keeps its own limit of 30 calls per minute for each worker.
|
|
102
102
|
|
|
103
|
-
A refused call returns `isError:true` with one of `tool_unavailable`, `wrong_class`, `stale_registry`, `invalid_arguments`, `rate_limited`, `in_progress` or `handler_failed`. After `stale_registry`, call `list_tools` again and use the new `schema_hash`.
|
|
103
|
+
A refused call returns `isError:true` with one of `tool_unavailable`, `wrong_class`, `stale_registry`, `invalid_arguments`, `rate_limited`, `in_progress`, `outcome_uncertain` or `handler_failed`. After `stale_registry`, call `list_tools` again and use the new `schema_hash`.
|
|
104
104
|
|
|
105
105
|
### Argument validation
|
|
106
106
|
|
|
@@ -44,7 +44,6 @@ This is a conservative source inventory of every explicit `homedir()` and `userI
|
|
|
44
44
|
| --- | --- |
|
|
45
45
|
| `scripts/acp-prose-check-test.mjs` | 10, 109 |
|
|
46
46
|
| `scripts/adapter-conformance-test.mjs` | 19, 20 |
|
|
47
|
-
| `scripts/admin-socket-path-test.mjs` | 35 |
|
|
48
47
|
| `scripts/admission-measure-test.mjs` | 8 |
|
|
49
48
|
| `scripts/admission-measure.mjs` | 84 |
|
|
50
49
|
| `scripts/answer-journal-e2e.mjs` | 20, 23 |
|
|
@@ -101,6 +100,7 @@ This is a conservative source inventory of every explicit `homedir()` and `userI
|
|
|
101
100
|
| `scripts/integrator-safety-test.mjs` | 14, 15 |
|
|
102
101
|
| `scripts/integrator-verifier-test.mjs` | 13 |
|
|
103
102
|
| `scripts/integrator-worktree-filter-context-test.mjs` | 12 |
|
|
103
|
+
| `scripts/lease-deadline-clock-origin-test.mjs` | 10 |
|
|
104
104
|
| `scripts/lease-deadline-restart-test.mjs` | 8 |
|
|
105
105
|
| `scripts/lease-migrated-null-deadline-test.mjs` | 7 |
|
|
106
106
|
| `scripts/legacy-acquisition-guidance-test.mjs` | 12 |
|
|
@@ -139,6 +139,7 @@ This is a conservative source inventory of every explicit `homedir()` and `userI
|
|
|
139
139
|
| `scripts/regrant-effects-e2e.mjs` | 12 |
|
|
140
140
|
| `scripts/regrant-waiter-fencing-test.mjs` | 32 |
|
|
141
141
|
| `scripts/remote-loopback-callback-test.mjs` | 47, 56 |
|
|
142
|
+
| `scripts/route-setup-discard-test.mjs` | 10 |
|
|
142
143
|
| `scripts/sandbox-probe-e2e.mjs` | 27 |
|
|
143
144
|
| `scripts/sandbox-source-exemption-test.mjs` | 10 |
|
|
144
145
|
| `scripts/schema-fixture-guard-test.mjs` | 10 |
|
|
@@ -171,6 +172,7 @@ This is a conservative source inventory of every explicit `homedir()` and `userI
|
|
|
171
172
|
| `scripts/work-order-test.mjs` | 6 |
|
|
172
173
|
| `scripts/worker-bridge-setup.mjs` | 89, 105, 228, 231, 758 |
|
|
173
174
|
| `scripts/worker-isolation-test.mjs` | 22 |
|
|
175
|
+
| `scripts/worker-route-reference-test.mjs` | 54 |
|
|
174
176
|
| `scripts/worker-repo-cache-test.mjs` | 7 |
|
|
175
177
|
| `scripts/worker-repo-policy-e2e.mjs` | 14 |
|
|
176
178
|
| `scripts/workspace-disk-test.mjs` | 8 |
|
|
@@ -187,19 +189,18 @@ This is a conservative source inventory of every explicit `homedir()` and `userI
|
|
|
187
189
|
| `src/integrator.mjs` | 19 |
|
|
188
190
|
| `src/limits.mjs` | 8, 16, 25 |
|
|
189
191
|
| `src/paths.mjs` | 52, 56 |
|
|
190
|
-
| `src/pr-head-reviewer.mjs` | 15 |
|
|
191
192
|
| `src/prepared-node-modules.mjs` | 10 |
|
|
192
193
|
| `src/projects.mjs` | 15, 90 |
|
|
193
194
|
| `src/route-setting.mjs` | 14 |
|
|
194
|
-
| `src/server.mjs` |
|
|
195
|
+
| `src/server.mjs` | 57 |
|
|
195
196
|
| `src/service-launchd.mjs` | 23 |
|
|
196
197
|
| `src/service-update-gate.mjs` | 9 |
|
|
197
|
-
| `src/service-update-runtime.mjs` |
|
|
198
|
+
| `src/service-update-runtime.mjs` | 250 |
|
|
198
199
|
| `src/service-update.mjs` | 118 |
|
|
199
200
|
| `src/service.mjs` | 109, 347, 403 |
|
|
200
201
|
| `src/store.mjs` | 149, 252, 253 |
|
|
201
202
|
| `src/submission-policy.mjs` | 101 |
|
|
202
203
|
| `src/t3-transport.mjs` | 30 |
|
|
203
|
-
| `src/try-hosted.mjs` |
|
|
204
|
-
| `src/try.mjs` | 55, 84,
|
|
204
|
+
| `src/try-hosted.mjs` | 109 |
|
|
205
|
+
| `src/try.mjs` | 55, 84, 271 |
|
|
205
206
|
| `src/workers.mjs` | 170, 179 |
|