@tnunamak/dalan 0.0.0-stage → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +172 -0
- package/CONTRIBUTING.md +26 -0
- package/LICENSE +204 -0
- package/PROTOCOL.md +339 -0
- package/README.md +348 -2
- package/SECURITY.md +30 -0
- package/bin/dalan.mjs +38 -0
- package/bin/dot-acp-agent.mjs +377 -0
- package/bin/dot-alert.mjs +9 -0
- package/bin/dot-deadman.mjs +82 -0
- package/bin/dot-heartbeat.mjs +29 -0
- package/bin/dot-pr-reviewer.mjs +32 -0
- package/bin/dot-worker.mjs +755 -0
- package/docs/chatgpt-worker-onboarding.md +112 -0
- package/docs/claude-worker-onboarding.md +113 -0
- package/docs/connect-chatgpt.md +78 -0
- package/docs/connection-longevity.md +37 -0
- package/docs/dalan-upgrade.md +242 -0
- package/docs/deadman.md +59 -0
- package/docs/dot-pr-reviewer.config.example.json +9 -0
- package/docs/durability-audit.md +27 -0
- package/docs/keycloak-client-chatgpt-dot-bridge.json +59 -0
- package/docs/keycloak-oauth-setup.md +30 -0
- package/docs/local-agent-mcp.md +39 -0
- package/docs/manual-setup.md +135 -0
- package/docs/mirror-fetch.md +98 -0
- package/docs/operations.md +751 -0
- package/docs/operator-duties.md +68 -0
- package/docs/owner-integrator.md +27 -0
- package/docs/portable-auth-profile.md +109 -0
- package/docs/pr-head-reviewer.md +54 -0
- package/docs/pr-preflight.md +26 -0
- package/docs/pull-workers.md +97 -0
- package/docs/redaction.md +27 -0
- package/docs/service-setup.md +166 -0
- package/docs/setup-reference.md +80 -0
- package/docs/t3-connector-icon.png +0 -0
- package/docs/t3-integration.md +49 -0
- package/docs/t3-result-retry-delivery.md +41 -0
- package/docs/t3-reverse-control.md +107 -0
- package/docs/usage.md +439 -0
- package/docs/worker-clients.md +285 -0
- package/integrations/t3/acp-kit/src/capability.mjs +25 -0
- package/integrations/t3/acp-kit/src/errors.mjs +13 -0
- package/integrations/t3/acp-kit/src/index.mjs +5 -0
- package/integrations/t3/acp-kit/src/lock.mjs +155 -0
- package/integrations/t3/acp-kit/src/session-store.mjs +36 -0
- package/integrations/t3/acp-kit/src/t3-envelope.mjs +62 -0
- package/package.json +65 -4
- package/packages/job-core/README.md +18 -0
- package/packages/job-core/index.mjs +2 -0
- package/packages/job-core/package.json +8 -0
- package/packages/job-core/protocol/canonical.mjs +11 -0
- package/packages/job-core/protocol/v0/command.schema.json +1154 -0
- package/packages/job-core/protocol/v0/event.schema.json +77 -0
- package/packages/job-core/protocol/v0/reply.schema.json +59 -0
- package/packages/job-core/transitions.mjs +25 -0
- package/scripts/daily-selfcheck.mjs +135 -0
- package/scripts/lib/expose-tailscale.mjs +408 -0
- package/scripts/live-trial/common.mjs +272 -0
- package/scripts/monitor-targets.mjs +44 -0
- package/scripts/upgrade-drain.mjs +39 -0
- package/scripts/worker-bridge-setup.mjs +925 -0
- package/src/ack-ledger.mjs +37 -0
- package/src/acp-bridge.mjs +412 -0
- package/src/acp-context.mjs +138 -0
- package/src/admin-socket.mjs +14 -0
- package/src/alerts.mjs +147 -0
- package/src/artifact-journal.mjs +75 -0
- package/src/as-files.mjs +347 -0
- package/src/as-store.mjs +456 -0
- package/src/as.mjs +497 -0
- package/src/auth.mjs +166 -0
- package/src/builtin-http.mjs +22 -0
- package/src/check-coverage.mjs +38 -0
- package/src/check-lint.mjs +88 -0
- package/src/check-readiness.mjs +112 -0
- package/src/check-response.mjs +19 -0
- package/src/claim-command-ledger.mjs +51 -0
- package/src/cli-help.mjs +172 -0
- package/src/cli-name.mjs +16 -0
- package/src/connect-cli.mjs +126 -0
- package/src/consumers.mjs +61 -0
- package/src/deadman.mjs +329 -0
- package/src/delivery.mjs +19 -0
- package/src/demo-worker.mjs +150 -0
- package/src/destinations/index.mjs +23 -0
- package/src/destinations/none.mjs +15 -0
- package/src/destinations/t3.mjs +109 -0
- package/src/diagnostic.mjs +78 -0
- package/src/docs-url.mjs +9 -0
- package/src/drain-runner.mjs +9 -0
- package/src/drained-slot.mjs +53 -0
- package/src/drained.mjs +40 -0
- package/src/durable-waiters.mjs +236 -0
- package/src/env.mjs +19 -0
- package/src/execution.mjs +112 -0
- package/src/failure-type.mjs +28 -0
- package/src/get-summary.mjs +32 -0
- package/src/git-env.mjs +15 -0
- package/src/host-budget-receipts.mjs +154 -0
- package/src/host-budget-seccomp.py +33 -0
- package/src/host-budget-service.mjs +54 -0
- package/src/host-budget-stop.mjs +26 -0
- package/src/host-budget-storage.py +259 -0
- package/src/host-budget.mjs +149 -0
- package/src/host-cgroup.mjs +23 -0
- package/src/host-check-allowlist.mjs +42 -0
- package/src/host-execution-policy.mjs +38 -0
- package/src/host-health.mjs +34 -0
- package/src/host-stop-reverify.mjs +44 -0
- package/src/inbox.mjs +55 -0
- package/src/integrator.mjs +322 -0
- package/src/job-retention.mjs +69 -0
- package/src/legacy-names.mjs +8 -0
- package/src/lifecycle.mjs +291 -0
- package/src/limits.mjs +31 -0
- package/src/loopback.mjs +9 -0
- package/src/mcp-outcome.mjs +70 -0
- package/src/mcp-stdio.mjs +191 -0
- package/src/mirror-fetch-lock.py +164 -0
- package/src/mirror-fetch.mjs +174 -0
- package/src/notify-ledger.mjs +82 -0
- package/src/objectives.mjs +129 -0
- package/src/owner-report-artifact.mjs +66 -0
- package/src/patch-apply.mjs +84 -0
- package/src/path-syntax.mjs +16 -0
- package/src/paths.mjs +67 -0
- package/src/pr-head-reviewer.mjs +596 -0
- package/src/pr-preflight.mjs +51 -0
- package/src/prepared-node-modules.mjs +129 -0
- package/src/projects.mjs +480 -0
- package/src/protocol-artifact-commands.mjs +52 -0
- package/src/protocol-delivery-driver.mjs +167 -0
- package/src/protocol-finish.mjs +100 -0
- package/src/protocol-owner-command.mjs +35 -0
- package/src/protocol-owner-mutations.mjs +22 -0
- package/src/protocol-owner-waiters.mjs +67 -0
- package/src/protocol-retention.mjs +52 -0
- package/src/protocol-services.mjs +61 -0
- package/src/protocol-stop-observer.mjs +131 -0
- package/src/publish-plan.mjs +245 -0
- package/src/redaction.mjs +763 -0
- package/src/rejections.mjs +18 -0
- package/src/request-log.mjs +102 -0
- package/src/restore-check.mjs +90 -0
- package/src/result-binding.mjs +65 -0
- package/src/runtime-check.mjs +13 -0
- package/src/sandbox-supervisor.mjs +105 -0
- package/src/schema-subset.mjs +186 -0
- package/src/scopes.mjs +15 -0
- package/src/server.mjs +1340 -0
- package/src/shutdown-signal.mjs +12 -0
- package/src/signal-sandbox-processes.py +56 -0
- package/src/signal.mjs +119 -0
- package/src/status-evidence.mjs +47 -0
- package/src/status-summary.mjs +54 -0
- package/src/store.mjs +3057 -0
- package/src/submission-policy.mjs +623 -0
- package/src/subscription-storage.mjs +64 -0
- package/src/t3-audit.mjs +120 -0
- package/src/t3-control.mjs +102 -0
- package/src/t3-transport.mjs +158 -0
- package/src/t3.mjs +209 -0
- package/src/terminal-safe.mjs +19 -0
- package/src/tool-registry.mjs +451 -0
- package/src/try-command.mjs +11 -0
- package/src/try.mjs +589 -0
- package/src/webhooks.mjs +86 -0
- package/src/work-order.mjs +265 -0
- package/src/worker-instructions.mjs +26 -0
- package/src/worker-prompt.mjs +4 -0
- package/src/workers.mjs +622 -0
- package/src/workspace.mjs +1058 -0
- package/systemd/dot-bridge-heartbeat.service +18 -0
- package/systemd/dot-bridge-heartbeat.timer +10 -0
- package/systemd/dot-bridge-selfcheck.service +12 -0
- package/systemd/dot-bridge-selfcheck.timer +11 -0
- package/systemd/dot-bridge.service +17 -0
- package/systemd/dot-deadman.service +30 -0
- package/systemd/dot-pr-reviewer.service +11 -0
- package/systemd/dot-pr-reviewer.timer +10 -0
package/PROTOCOL.md
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Dalan protocol
|
|
2
|
+
|
|
3
|
+
The product is Dalan, and the OAuth scopes are `dalan.read` and `dalan.work`. The older `dot-bridge.read` and `dot-bridge.work` names remain accepted aliases with exactly the same permissions, so existing tokens, connections and clients keep working. Existing metadata namespaces and persisted protocol identifiers keep their values. T3 reverse-control tools require `DALAN_ENABLE_T3_TOOLS=1` as well as the worker capability; `notify_owner` is the notification tool. See [upgrade settings and connector refresh](docs/dalan-upgrade.md).
|
|
4
|
+
|
|
5
|
+
## Worker identity and client independence
|
|
6
|
+
|
|
7
|
+
A worker is a configured identity, not a particular model or vendor. Named profiles bind approved connections to a worker and isolate its jobs and repository grants. Use `dalan init --worker NAME` for a fresh profile, then follow [client registration](docs/worker-clients.md). The same claim and finish contract applies to every client. Catalog profiles below select protocol behavior, not client vendors.
|
|
8
|
+
|
|
9
|
+
### Connection fence (built-in mode)
|
|
10
|
+
|
|
11
|
+
A worker call that acts on a claim must come from the connection recorded on that claim, and that connection must be live. The check runs in the transaction that writes the effect. Workspace tools check synchronously, right before the tool body and after their last `await`; `finish` checks again after its `makeRoom` await, and captures its patch artifact inside the finish transaction, after the check. A call that fails it refuses with `connection_not_live`. It changes no claim-scoped state: no claim, workspace, report, notification or artifact row, no file of that job, and no claim activity counter. It does not re-run destination policy, and the refusal text is fixed and carries no receipt, result, answer or holder identity.
|
|
12
|
+
|
|
13
|
+
The refusal does not cover system effects that run before the check. The server counts every authenticated call per worker (`worker_calls`, `worker_activity`, and for the default worker the end of an active usage break), runs `sweepExpired` (it cancels or requeues expired queued assignments), and runs `makeRoom` before a workspace tool or `finish` (it can delete other jobs' expired artifacts and workspaces under disk pressure). A claim takeover also reconciles host stops of the expired claim. A refused call can still cause these. A legacy call that loses its connection after its first check keeps the activity time that the implicit touch recorded while the connection was live. Native calls have no such touch.
|
|
14
|
+
|
|
15
|
+
Refused for any caller but the live holding connection:
|
|
16
|
+
|
|
17
|
+
- `claim` retry; `renew_claim`; `progress`; `ask_question`; `consume_answer`.
|
|
18
|
+
- `finish`, legacy and native: a fresh finish, a stored-report or stored-receipt replay, and the late-evidence write after a cancel.
|
|
19
|
+
- `artifact_chunk`: native upload and seal (the native command choke point, `protocolMutationInTransaction`) and legacy upload (the claim activity touch).
|
|
20
|
+
- Every workspace tool, on native and legacy jobs: `list_files`, `read_file`, `apply_patch`, `run_check`, `workspace_result`. The read tools are fenced too, because they create the worktree and its workspace row on first use.
|
|
21
|
+
- The implicit claim activity touch and the per-tool activity counters.
|
|
22
|
+
|
|
23
|
+
Still allowed to any authenticated worker connection: `get`, `list_pending`, `ack_message`, and `claim` of other work. `get` returns the assignment as before, but it moves the claim's note-seen cursor (`last_seen_note_seq`) only for the live holding connection, in one transaction. A `get` from a revoked, replaced or other connection reads and changes nothing.
|
|
24
|
+
|
|
25
|
+
Limits, stated exactly:
|
|
26
|
+
|
|
27
|
+
- The auth store and the bridge database are separate databases and cannot commit together. The linearization point is the liveness read inside the writing transaction: a revocation committed before that read refuses the call, and one committed after it does not.
|
|
28
|
+
- `run_check` is fenced when it starts. The bridge records the result of a check that has already started under the claim epoch, not under the connection.
|
|
29
|
+
- Owner and system actions (cancel, abandon, lease sweeps, owner notes and answers) are not worker-connection scoped.
|
|
30
|
+
- Pre-schema-61 claims with a NULL connection ID cannot satisfy the fence and must wait for lease expiry. External OAuth presents no connection and is unchanged.
|
|
31
|
+
|
|
32
|
+
`.dot-bridge.json`, stored format labels and event markers remain literal compatibility identifiers. Do not substitute new strings in a token, manifest or stored report. T3 tools belong to an optional integration and grant authority outside the ordinary job lifecycle.
|
|
33
|
+
|
|
34
|
+
## Native contract v6: optional destination revision admission
|
|
35
|
+
|
|
36
|
+
Schema 60 adds immutable per-job destination approval, durable refusal evidence and the destination revision recorded by a claim. Existing worker catalogs and undeclared-worker legacy authority/lease behavior are unchanged. Unbound jobs require approval when the current worker declares a destination: a fresh epoch is durably refused with `destination_approval_required`, and unreadable current configuration cannot admit a new submission. The v5 native surfaces below remain the underlying protocol; this adds no shared Fixture Profile conformance claim.
|
|
37
|
+
|
|
38
|
+
A worker's optional declaration produces a canonical disclosure in private owner submit-preview. New submissions explicitly supply its exact `destination_revision`, binding snapshot, request ID, owner-capability identity, worker, execution and approval time. Retry revision intent must match, and no notice, transport acknowledgment or worker argument authorizes approval. Repository policy is a separate current restriction. The identity also binds a stable digest of sorted connection identities (issuer, subject, client_id, and connection_id when configured) and, in built-in auth mode, the worker's live approved connection IDs; reordering connections is immaterial.
|
|
39
|
+
|
|
40
|
+
Every fresh epoch (claim, takeover, reclaim, resume after expiry) checks current declaration after awaited work. In built-in mode, a fresh epoch additionally requires the claimant's own connection to be live at claim time (`connection_not_live` otherwise), and an approval is never recorded while the worker's live connection set is empty (`destination_connection_required`). Exact authorized live duplicates retain their existing grant without a new epoch or approval. In built-in mode each grant records the connection it was given to (`claims.connection_id`, schema 61); a duplicate or native receipt replay is accepted only from that connection, whether or not the worker declares a destination, and, when the owner approved a destination, only while the live connection set still matches the approved digest. A retry does not re-run destination or repository policy, so an owner edit between a lost reply and its retry does not strand the holder, and a retry writes no refusal record. A grant made before schema 61 has no recorded connection and is not recovered by a duplicate; the holder claims again after its lease ends. External OAuth records no connection and is unchanged. Drift commits durable `destination_changed` evidence before throwing an error: approved/current revisions and snapshots plus readable differences. A generation/protocol-revision guard prevents stale refusal state overwriting a successor. Refusal creates no successful claim-command receipt or native claimed event. Owner get and existing `/wait` expose it; delivery acknowledgment does not approve a revision.
|
|
41
|
+
|
|
42
|
+
The synchronous authoritative configuration read inside the SQLite admission transaction is the snapshot linearization point, not a filesystem publication lock. A configured resolver must be synchronous and load valid configuration; failure refuses admission even for an unbound job. An unbound job is admitted without approval only while its current worker declares no destination. Enabling a declaration requires approval for a fresh epoch; it does not grandfather old jobs. Recovery is owner cancel and resubmit with a new request ID, not mutable reapproval. Restoring the already approved destination, while current repository policy allows the job, removes the historical destination block from listing and next-job selection without a claim by ID; normal visibility, liveness, ordering and list limits still apply, and a fresh claim is still admitted or refused on its own. Listing retains refusal evidence and never changes approval.
|
|
43
|
+
|
|
44
|
+
An unreadable or invalid current worker configuration refuses new submissions and fresh claim epochs with `destination_configuration_invalid` until it is fixed. An exact authorized retry of a committed submission replays its original receipt without reading the current configuration. Adding a destination to a worker causes its unbound queued jobs and subsequent fresh claim epochs to require approval. The admission check uses a synchronous snapshot; a later configuration change applies to subsequent admissions.
|
|
45
|
+
|
|
46
|
+
In built-in mode a grant records the connection it was given to (`claims.connection_id`, schema 61). A duplicate `claim` or native receipt replay is accepted only from that connection while it is live and, when the owner approved a destination, only while the live connection set matches the approved digest. The same connection check also gates every later call that acts on the grant: `renew_claim`, `progress`, `ask_question`, `consume_answer`, `finish` (fresh, replay and late evidence after cancel), `artifact_chunk`, and the workspace tools `list_files`, `read_file`, `apply_patch`, `run_check` and `workspace_result`. The Store runs it in the transaction that writes the effect, after the claim check and before any state change, and a call from a revoked, replaced or other connection fails with `connection_not_live` and changes nothing. Checks on the claim come first, so a wrong subject or worker, a superseded claim or an expired lease keeps its own error. `get`, `list_pending` and `ack_message` stay open to any authenticated worker connection; `get` moves the note-seen cursor only for the live holder. Under external OAuth (no connection id and no liveness check) the check does not run for a claim that stored no connection. A claim that stored a `connection_id` (for example, a database that moved from built-in to external OAuth) is refused with `connection_not_live` until its lease expires, because external OAuth presents no connection. In built-in mode a grant made before schema 61 records no connection, fails the check, and waits for its lease to expire. See [Connection fence](#connection-fence-built-in-mode).
|
|
47
|
+
|
|
48
|
+
This is **destination disclosure and claim admission, not egress protection**. Pre-claim list/get/wake disclosure remains possible; declarations may be inaccurate; active remote work is not stopped. See [usage](docs/usage.md#destination-disclosure-and-claim-admission) for configuration, private HTTP approval and limitations.
|
|
49
|
+
|
|
50
|
+
## Native contract v5: protocol-v0 jobs
|
|
51
|
+
|
|
52
|
+
Set `DALAN_CATALOG_PROFILE=protocol-v0` to advertise the opt-in native job tools. The default catalog remains the stable profile: 20 named tools with `DALAN_ENABLE_T3_TOOLS=1` and 14 without T3; `tools/list` further hides T3 and notification tools from workers without the `t3` capability. `questions-v1` remains available with its existing identified-question behavior. Release 0.5.0 changes the advertised tool list once ([Catalog v2](#catalog-v2)): after you upgrade, refresh the connector or reconnect each worker client one time. Changing `DALAN_CATALOG_PROFILE` also changes the tool list and needs the same refresh. `legacy-v46` is unchanged. This section describes the native bridge contract; it does not claim full Job Protocol Fixture Profile conformance.
|
|
53
|
+
|
|
54
|
+
A protocol job has an immutable `protocol` object with exactly `profile: 'job-v0'`, `source`, `scope`, `policy`, `destination`, and `retain_until_ms`. The retention deadline is an absolute safe integer in milliseconds. Owner labels in these fields describe intent and routing; they do not grant execution authority. Existing owner capability checks, worker identity, claim and epoch checks still control actions. Protocol jobs use schema 60 native revisioned events and command receipts. Worker mutations provide `command_key` and `expected_revision`, with an optional `epoch` checked against the current grant. Private owner mutations use the same key and revision fields. Authorization, current grant and lease checks precede replay; an exact retry then returns its original receipt before revision comparison. Changed intent conflicts, while a committed finish receipt can be retrieved after lease expiry by its original authenticated holder, without restoring authority. Cancelled jobs may retain bounded late output as audit evidence while the original lease remains valid; they accept no result or new worker authority.
|
|
55
|
+
|
|
56
|
+
Protocol claims have a fixed lease deadline. Repeating `claim` does not slide it. `renew_claim` is explicit, requires the current grant, revision and command key, and returns the original deadline for an exact retry; expired grants cannot renew. The legacy non-protocol claim behavior is unchanged.
|
|
57
|
+
|
|
58
|
+
Uploads are recorded in a native artifact journal. Each upload/seal mutation binds the command receipt to verified bytes, including offset, size and digest; the result selects byte-verified artifact bindings. A worker report receipt remains distinct from owner acceptance. The owner API supports durable wait registration and delivery through `/protocol/{wait,inbox,ack}`. Protocol jobs reject the legacy conditional `/cancel-if-queued` route; use keyed `/cancel` with its expected revision so terminal waiters receive the committed cancellation fact. Registration and delivery are persisted; acknowledgments identify a delivery. Logical retention expiry creates a tombstone and fences protocol reads and writes. It does not promise secure erasure of files or guarantee that physical cleanup has stopped.
|
|
59
|
+
|
|
60
|
+
This contract is limited to the native surfaces and evidence described here. It is not a full conformance claim for the shared fixture profile or an assertion that remote compute is physically stopped.
|
|
61
|
+
|
|
62
|
+
### Private native service operations
|
|
63
|
+
|
|
64
|
+
Version 5 extends native v4 without changing the shared Fixture Profile v0 or advertised worker catalogs. Protocol finishes now require references sealed by their current claim and epoch. A successor can explicitly upload and seal the same verified bytes under a new reference; it cannot cite its predecessor's seal. The old artifact's origin and bytes remain retained. Non-protocol jobs retain their existing sealed-inheritance behavior.
|
|
65
|
+
|
|
66
|
+
Protocol event insertion and waiter delivery materialization share the same SQLite transaction. Private dispatch, result and reconciliation operate on the same durable delivery that owner inbox and acknowledgement use. Dispatch commits `sending` before invoking a transport. Restart changes unresolved sends to `unknown`; it never infers that nothing was sent. A trusted transport must bind evidence to job, delivery, immutable destination, body digest and attempt. A definite non-send or authoritative absence must also establish that the original attempt cannot arrive later. Incomplete searches remain unknown, and an owner's persisted acknowledgement wins a delayed callback. Question delivery checks its live epoch before dispatch; unresolved question sends block regrant, and old-epoch questions cannot be dispatched after it. Owner audit facts are retained.
|
|
67
|
+
|
|
68
|
+
The following POST routes exist only on the private admin Unix socket in `protocol-v0` mode. Their JSON objects are closed and every body includes `id`; the table lists the remaining fields. Worker OAuth and the public HTTP listener grant no access. `X-Protocol-Service-Capability` carries a separate dispatcher or observer capability derived from the owner's operator key with a role-specific HMAC domain. Service identity comes from that authenticated capability, never a body field.
|
|
69
|
+
|
|
70
|
+
| Route under `/protocol/service/` | Role | Remaining body fields |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| `dispatch` | dispatcher | `key`, `delivery` |
|
|
73
|
+
| `delivery-result` | dispatcher | `key`, `delivery`, `outcome`, `receipt` |
|
|
74
|
+
| `reconcile` | dispatcher | `key`, `delivery`, `outcome`, `receipt` |
|
|
75
|
+
| `enroll` | observer | `execution` containing `claim`, `epoch`, `invocation`, `scope` |
|
|
76
|
+
| `observe-stop` | observer | `key`, `revision`, `stop`, `evidence` |
|
|
77
|
+
|
|
78
|
+
Service receipts bind authenticated role, operation, job and key. Exact replay returns the original receipt without another send or observation event. Retention and role checks still apply; receipt labels are lookup keys for trusted dependencies, not evidence supplied by a worker. The default local owner-inbox transport trusts its actual persisted owner acknowledgement. Other transports require an explicitly constructed trusted adapter.
|
|
79
|
+
|
|
80
|
+
Stop observation requires prior enrollment of the current claim, epoch, invocation and execution scope. The normal resolver accepts only matching trusted host-check receipts. A successful observation atomically stores scoped evidence, advances revision and journals `stop_observed`; it never changes the terminal outcome, restores authority or publishes a result. Opted-in owner get exposes `protocol_stop` with its scope and assurance. It does not turn `compute_stopped` into a claim about remote provider computation. Trusted inert executor/receiver dependencies are injected only by the isolated conformance bootstrap; ordinary service startup cannot validate their evidence.
|
|
81
|
+
|
|
82
|
+
## Historical native contract v3: questions-v1 profile
|
|
83
|
+
|
|
84
|
+
This section records the historical questions-v1 contract. The conformance adapter enables `protocol-v0` in isolated servers; the unchanged `questions-v1` profile remains available. The default `stable` catalog preserves the approved stable catalog. To advertise and accept `ask_question` and `consume_answer` under this historical questions profile, explicitly set `DALAN_CATALOG_PROFILE=questions-v1`. Existing progress notes, owner notes and their schemas keep their previous behavior; a `QUESTION:` progress note does not create an identified question, and an ordinary owner note does not answer one. Changing the profile changes the complete advertised catalog: compare it with the approved profile before a coordinated connector refresh and worker restart. Deploying schema 55 with the default profile requires no catalog refresh.
|
|
85
|
+
|
|
86
|
+
`ask_question {request_id,claim_id,question_id,text}` creates a durable question under the current worker, subject, claim and epoch. IDs contain 1–128 ASCII letters, digits, `_`, `:`, `.` or `-`; text is 1–4096 UTF-8 bytes. An exact retry returns the original question without another event or notification. Reusing an ID with different text returns `KEY_CONFLICT`; an ID from another grant returns `STALE_EPOCH`. Questions do not pause the lease or permit early regrant.
|
|
87
|
+
|
|
88
|
+
The owner lists questions with `dalan questions REQUEST_ID --json` and answers one with `dalan answer REQUEST_ID QUESTION_ID "answer text" --json`. These commands use the saved per-request owner capability. The corresponding Unix-socket routes are `GET /questions?id=REQUEST_ID` and `POST /answer {id,question_id,text}`. An answer requires an existing question from the current live grant. Missing, terminal, stale and already answered questions are refused; a second answer cannot replace the first. An answer remains awaiting consumption across restart. It queues an ordinary `assignment.available` event with the existing request/title payload; private notification metadata binds the wake to the question and epoch.
|
|
89
|
+
|
|
90
|
+
`consume_answer {request_id,claim_id,question_id}` returns the saved answer and records its first consumption atomically. It requires the original current grant and refuses an unanswered question. An exact repeat under a live nonterminal job returns the same answer with `duplicate:true`. Cancelled and finished jobs refuse consumption, including a duplicate read; this does not change committed finish-receipt retries. Worker `get` includes question records without claim credentials or OAuth subject. A `completed` finish refuses `QUESTION_OPEN` while that grant has any unconsumed question, including an answered question. A `blocked` or `failed` finish may terminate without an answer; unanswered questions remain visible through owner `questions` as open audit facts, with no fabricated consumption or further authority. Questions from a prior epoch cannot block the new grant, and the new grant cannot answer or consume them. It must ask a fresh question and receive its own answer. Cancellation still permits audit-only late evidence under the existing rules.
|
|
91
|
+
|
|
92
|
+
Schema 55 stores questions and their answer-wake associations. Ask, answer and first consumption append native lifecycle events with explicit `question:ask:ID`, `question:answer:ID` and `question:consume:ID` reasons. State and events commit together, and the conformance adapter projects these native facts; it does not infer answers from timestamps or keep a separate answer store. This revision adds no general command keys, revision compare-and-swap, or full profile-conformance claim. The historical v1 section below describes its pinned older source; v2 remains the authority and lease contract.
|
|
93
|
+
|
|
94
|
+
## Native contract v2: expiry-only authority and host effects
|
|
95
|
+
|
|
96
|
+
This revision changes regrant semantics from the historical v1 mapping below. A new epoch is allowed only after the previous lease deadline, including explicit resume and reclaim after abandonment. Abandonment can revoke a grant immediately, but does not shorten that deadline. For legacy non-protocol jobs, an admitted exact live retry retains its grant and refreshes activity. Native v5 protocol jobs instead use the fixed deadline and explicit renewal described above.
|
|
97
|
+
|
|
98
|
+
For legacy non-protocol jobs, a worker may request `claim.lease_ms` from 1 ms up to the owner-configured `claim_lease_ms` maximum. Omission uses that maximum; migration 53 persists the duration on each grant; existing grants inherit the configured duration during upgrade. Later configuration edits do not change a stored grant. An admitted exact live retry keeps the stored duration and refreshes activity using it; a competing request cannot shorten the old grant. Expiry checks use the stored activity plus duration, including after restart. This v2 activity-lease behavior is not the native v5 fixed-deadline renewal contract.
|
|
99
|
+
|
|
100
|
+
The local owner API accepts an optional `command_key` on `POST /submit` (1–128 characters). Schema 54 atomically stores its digest, immutable submission intent and original submit decision beside the assignment. The key is scoped to the request ID and owner capability. A matching retry returns the original submit status with `duplicate: true`, even if the job has since finished; use `get` for current status. Changed intent under the same key returns `KEY_CONFLICT`; a different or omitted key on that keyed job returns `EXISTS`. An existing unkeyed job keeps its legacy retry behavior and cannot silently acquire a key. Preview, refused and deferred submissions create no binding. This adds no general revision counter, compare-and-swap or keys for worker commands.
|
|
101
|
+
|
|
102
|
+
The local owner API also accepts `supersedes: {target_id, target_token}` on `POST /submit`. This narrow submit-time operation replaces one queued legacy assignment using its owner capability; `owner_token` establishes or authenticates the new request. Both capabilities are checked on every replacement retry. The target must never have been claimed: requeued/abandoned work is refused because queued status does not prove remote compute stopped. Native protocol sources or targets are unsupported. The target capability is not scoped to a worker, as with `/cancel`: the replacement may go to a different worker than the target. An eligible target is excluded only from the queue and background-capacity counts it otherwise belongs to, so a replacement that leaves those counts unchanged can be admitted at the cap. Missing targets return `supersede_target_not_found`, ineligible targets `supersede_target_not_queued`, native jobs `supersede_native_unsupported`, and self-reference `supersede_cycle`; owner-capability and immutable-request/key conflicts retain their existing errors.
|
|
103
|
+
|
|
104
|
+
Schema 58 commits the source, one immutable reference, cancellation through the existing cancellation core, notification/watch suppression, and any submit-command receipt in one transaction. `get` exposes `supersedes` on the source and `superseded_by` on the target as `{request_id, created_at}` (otherwise `null`), never capabilities. Exact retries preserve the reference, cancellation timestamp and receipt without cancelling twice; changing or omitting replacement intent conflicts. Only a first committed replacement wakes the target's attached owner waiter. Cancellation revokes bridge authority, not proof of physical compute stop. This adds no general lineage endpoint or post-submit relation mutation; `Store.submit` keeps `commandKey` as argument 16 and adds the narrow option after it.
|
|
105
|
+
|
|
106
|
+
Before regrant, host check work must finish stopping with a verified process-group stop receipt. The HTTP claim handler waits outside the database transaction; the Store rechecks expiry, stop evidence and current authority in its transaction. Missing or unverified stop evidence refuses regrant, including interrupted checks after restart; automatic recovery of an unverified stop is not established here. A check whose authority expires is cancelled, and its output is discarded rather than published as a check result or artifact. Assignment-bound tools continue to require the active grant, so an old holder cannot mutate the new epoch's workspace.
|
|
107
|
+
|
|
108
|
+
Owner-granted `t3` reverse-control tools and `notify_owner` have job-independent authority, no assignment epoch and no job-claim requirement. They are outside this contract's job-effect fencing. Worker profiles opt in with the `t3` capability; the legacy single-worker profile retains its existing grant. Their capability, scope and audit checks remain in force.
|
|
109
|
+
|
|
110
|
+
This does not stop a provider's computation. It closes the old grant's bridge-owned effect channels. Actual T3 receiver deduplication is a separate acceptance requirement and is not proven by the local check stop. Historical fixture failures and unvalidated renewal prototypes do not establish current conformance.
|
|
111
|
+
|
|
112
|
+
Regression commands: `node scripts/regrant-effects-e2e.mjs --store-only` checks the expiry boundaries without an executor. On a Linux host with a working confined backend, `DALAN_HOST_CHECKS=1 node scripts/regrant-effects-e2e.mjs` uses real HTTP calls, a live host check and a current-epoch positive control. The host journey reports a skip when its backend is unavailable, not a pass for containment.
|
|
113
|
+
|
|
114
|
+
## Shared Job Protocol contract (historical native contract v1)
|
|
115
|
+
|
|
116
|
+
This section preserves the historical native contract v1 mapping to the **Job Protocol Fixture Profile v0**. The profile document hash (`docSha256=e912cd9caea2283c98900b2577e3bbf3bb547ab760cd2af90ade45cfd165c3d0`) and generated trace count are recorded by `scripts/conformance/fixtures/MANIFEST.json`. The fixture inputs comprise three schemas and 42 trace files. This is a versioned native contract, not a claim of full profile conformance. The profile version, native contract version and wire/schema versions are separate version spaces. The profile distinguishes job intent, attempts, claims, result proposals, receipts and owner acceptance. The mapping below records the historical v1 concepts and limitations.
|
|
117
|
+
|
|
118
|
+
### Active version checks
|
|
119
|
+
|
|
120
|
+
The native contract version is 6, the shared fixture profile version is 0, and command/event schema version `v` is 0. These are separate version spaces, and the conformance runner accepts only the pinned profile version, source identity and digest, schema digests, and ordered trace IDs recorded by its manifest. It validates every fixture command, expected reply and event against the pinned schemas before running the corpus. A profile or wire version other than 0 is refused at the adapter boundary with the profile error `INVALID`, before a native operation or state change. A change to any pinned source, schema or trace requires a new profile/adapter contract version and matching fixtures; changing the manifest alone does not update the implementation's pins.
|
|
121
|
+
|
|
122
|
+
### Ownership and version policy
|
|
123
|
+
|
|
124
|
+
Dalan maintainers own this native mapping and its compatibility policy. Native contract v1 describes the native objects, verbs and behavior in the historical v1 baseline described above. The fixture profile owns the shared vocabulary and schemas; it grants no execution authority. A change to a native name, required field, state meaning, authority check, ordering, retry rule or error mapping requires a new adapter contract version plus migration and conformance evidence. An additive response field may stay in v1 only if it preserves existing authorization and meaning. The manifest hash pins the profile text; do not regenerate fixtures or relabel unsupported operations to make a trace pass. Other implementations can add adapters to the shared profile. This document makes no claim about any external implementation.
|
|
125
|
+
|
|
126
|
+
### Object and verb mapping
|
|
127
|
+
|
|
128
|
+
| Shared profile concept | Native Dalan object / verb | Actual mapping and limit |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| Job | Immutable assignment, addressed by `request_id`; owner `submit`, worker `list_pending` and `get` | A submitted assignment is immutable; changed work needs a new request ID. Opaque read-only inputs are supported. See **Submission policy** and `Store.submit` / `Store.checkRetry` in `src/store.mjs`. |
|
|
131
|
+
| Attempt | No separate durable attempt object | A claim takeover increments `epoch` and replaces `claim_id`; this is a claim generation, not a profile attempt with its own lifecycle record. The bridge does not represent every profile attempt transition. |
|
|
132
|
+
| Claim / lease | Claim row; worker `claim`, repeated `claim`, lease expiry and takeover | In the historical v1 baseline, exact live retries are matched before idle rotation when worker, subject, claimant and acquisition ID match. Omitted acquisition ID matches stored NULL; explicit JSON null is rejected. A keyed mismatch with idle rotation disabled returns `already claimed by another claimant`; a nonidle mismatch returns `claim_busy`. The default idle rotation remains enabled at 120 seconds and may rotate an idle claim. No worker self-stop or receiver deduplication is established. Lease expiry permits takeover; it does not prove old remote compute stopped. |
|
|
133
|
+
| Progress | Progress notes; worker `progress` | Durable notes are ordered by storage; blocker/question notes can notify the owner. They are not the profile's revisioned event journal. |
|
|
134
|
+
| Result proposal | Finished assignment; worker `finish` with `completed`, `blocked`, or `failed`, summary/result and optional sealed artifact IDs | Finish is claim-bound and terminal. This is a worker report, not owner acceptance, correctness, or integration. Conflicting result fields fail under the retry comparison below. |
|
|
135
|
+
| Receipt | `receipt_id` returned by `finish`; stored report row | The receipt identifies the committed worker report. A retry with the same outcome, summary and result under the same active claim returns the same receipt; changing those fields fails. Selected artifact IDs are not part of that retry equality or a persisted receipt reference list. The receipt does not mean the owner accepted or applied the result. |
|
|
136
|
+
| Artifact | Sealed upload; worker `artifact_chunk`, owner `artifact` | Chunks are bounded and sealed with digest/length metadata before they can be referenced by finish. This is not the profile's full staged-metadata transaction model. |
|
|
137
|
+
| Owner acceptance | Owner `decide`, `apply` | Disposition is separate from worker finish. `apply` verifies the patch/base and records application; it is not automatic merge or deployment. |
|
|
138
|
+
| Cancellation | Owner `cancel` over the private admin socket | Returns `cancellation_requested:true`, `authority_revoked:true`, `compute_stopped:false`. A later finish from a valid live claim may be retained as bounded audit evidence, but it is not a result or successful receipt and does not wake T3. Cancellation revokes bridge authority; physical worker stop is not established. |
|
|
139
|
+
| Delivery | Signed `assignment.available` event; optional T3 result/watch delivery | Event retries and T3 reconciliation are native delivery mechanisms. A delivered event is a wake-up, not a claim or accepted result. Uncertain T3 delivery is held for reconciliation rather than automatically retried. |
|
|
140
|
+
|
|
141
|
+
Native object and verb details are evidenced in this file's **Claims and worker tools**, **Owner operations and delivery recovery**, and **Implementation evidence and OAuth** sections; corresponding implementation lives in `src/server.mjs`, `src/store.mjs`, `src/webhooks.mjs`, and `bin/dot-worker.mjs`. Fixture projection rules and exact unsupported profile verbs are documented in `scripts/conformance/README.md` and `scripts/conformance/adapter-dot-bridge.mjs`.
|
|
142
|
+
|
|
143
|
+
### Profile verb and native name map
|
|
144
|
+
|
|
145
|
+
This table maps profile v0 operation names to the closest operation in the historical native v1 baseline. “Closest” does not mean semantically equivalent. Names from the historical standalone renewal prototype are marked in the last column.
|
|
146
|
+
|
|
147
|
+
| Profile verb | Native name in historical v1 | Mapping limit | Prototype name |
|
|
148
|
+
|---|---|---|---|
|
|
149
|
+
| `submit` | Owner `submit` / `Store.submit` | Same request ID plus matching immutable input returns the existing assignment; profile caller-keyed response caching is absent. | — |
|
|
150
|
+
| `claim` | Worker `claim` | Produces `claim_id` and `epoch`; exact live retries match before idle rotation, including omission-to-NULL acquisition identity. This is not profile revision or attempt state. | — |
|
|
151
|
+
| `renew` | Repeated worker `claim` | The historical v1 baseline had no dedicated renewal call or caller-keyed renewal receipt. | `renew_claim` in the historical standalone renewal prototype. |
|
|
152
|
+
| `progress` | Worker `progress` | Appends a note; it does not increment profile revision or journal a profile event. | — |
|
|
153
|
+
| `ask` | No equivalent; `progress` with `QUESTION:` may notify the owner | No durable profile question object, attempt binding or consumption predicate. | — |
|
|
154
|
+
| `answer` | Owner `note` / `dalan note` | An owner note is durable, but is not a one-answer record for a profile question. | — |
|
|
155
|
+
| `consume` | No profile-equivalent operation | Worker `get` marks owner notes seen; owner `get` and inbox operations record owner reads. Neither consumes a profile answer. | — |
|
|
156
|
+
| `upload` | Worker `artifact_chunk` | Chunked upload is supported; profile per-command idempotency keys are not. | — |
|
|
157
|
+
| `seal` | Final `artifact_chunk` with `final:true` and `sha256` | Seal is part of the chunk call, not a separate profile-style operation or revision. | — |
|
|
158
|
+
| `finish` | Worker `finish` | Stores a terminal worker report and receipt; owner acceptance and application are separate. | — |
|
|
159
|
+
| `cancel` | Owner `cancel` | Revokes bridge authority; physical stop remains a separate fact. | — |
|
|
160
|
+
| `expire` | Internal expiry/lease sweeps | Lease expiry abandons a claim and requeues its assignment. Queued input expiry cancels it, except an eligible learned deadline may be requeued up to twice with a fresh deadline capped at 12 hours from creation. There is no caller `expire` command, profile revision or profile expiry receipt. | — |
|
|
161
|
+
| `get` | Worker/owner `get` | Returns current native facts, not a caller-keyed historical snapshot. | — |
|
|
162
|
+
| `wait` | Owner `dalan wait` / admin `/wait` | Native waiter is process-local and is not a durable profile predicate registration. | — |
|
|
163
|
+
| `inbox` | Owner `dalan inbox` | Lists native unread/read state; it is not the profile's per-waiter delivery inbox. | — |
|
|
164
|
+
| `ack` | Owner `dalan inbox --mark-read` | Records a native owner read, not acknowledgment of a profile delivery ID. | — |
|
|
165
|
+
| `dispatch` | Subscription event-delivery scheduler | Sends `assignment.available` wakes; there is no profile dispatch command or returned dispatch receipt. | — |
|
|
166
|
+
| `delivery_result` | Native notification state and callback outcome | No profile operation records acknowledged / not-sent / unknown for a caller key. | — |
|
|
167
|
+
| `reconcile` | Operator `dalan reconcile` for uncertain T3 delivery | Reconciles the native T3 transport marker; it is not the profile's generic destination reconciliation verb. | — |
|
|
168
|
+
| `observe_stop` | No worker-facing verb; admin state reports sandbox stop evidence | Physical stop is only reported when supported by host evidence; no profile receipt is accepted. | — |
|
|
169
|
+
|
|
170
|
+
### Historical v0 compatibility notes
|
|
171
|
+
|
|
172
|
+
This section preserves v0 compatibility context and identifies separate historical prototype work. Exact-identity retry ordering was included in the historical native v1 baseline; the separate standalone renewal prototype was not.
|
|
173
|
+
|
|
174
|
+
| Historical change | Historical behavior | Relationship to native v1 |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| Historical exact-identity retry fix | Before idle rotation, recognize a live retry only when worker, OAuth subject, claimant and stored acquisition ID all match, including when the claim is idle. Omission matches only when the stored acquisition ID is `NULL`. For a nonidle keyed claim, omission or mismatch remains refused. If a mismatched request reaches an idle claim, the existing idle takeover rule creates a new epoch. | The historical native v1 baseline checked an exact live retry before idle rotation. A mismatch on an idle claim followed idle takeover. Default idle rotation was 120 seconds, which did not satisfy the revised stop requirement; the baseline provided no worker self-stop or receiver deduplication. |
|
|
177
|
+
| Historical standalone renewal prototype | `claim.lease_ms` is optional, must be at least 1 ms and cannot exceed the owner-configured maximum. The selected duration is stored on each grant. Omitting it on a duplicate retry retains the stored duration; an explicit different duration is rejected. `renew_claim` names the request and current claim, binds to its worker and subject, refuses expired, stale or foreign grants, and refreshes the same epoch. | The historical v1 baseline lacked `lease_ms` and `renew_claim`; its bridge-wide lease configuration led the fixture adapter to map profile `renew` to repeated `claim`. This standalone prototype is historical context, not the current native renewal contract or conformance evidence. |
|
|
178
|
+
|
|
179
|
+
The exact-identity retry fix and the standalone renewal prototype were separate historical changes, not a cumulative implementation. The renewal prototype rotated idle claims before its duplicate-duration check, so retaining a stored duration applied only when that branch was reached. Earlier behavior differed between enabled and disabled idle rotation; native contract v1 documented the exact-identity retry rule in both configurations. Clients must retain their original acquisition ID or handle refusal. These historical notes add no wire protocol or database migration and establish no current conformance result. Use the current native contract sections for implemented renewal and regrant rules.
|
|
180
|
+
|
|
181
|
+
### Durable states, authority and ordering
|
|
182
|
+
|
|
183
|
+
The native assignment status is `queued`, `claimed`, then `finished` or `cancelled`. A finished report separately has `outcome:completed|blocked|failed`; these outcomes are not assignment statuses. Lifecycle event names are another vocabulary, projected separately by the adapter; the store also retains delivery/check/artifact facts outside that compact state. Profile states such as `waiting`, `expired`, `cancelled+revoked`, and revisioned transition events must not be claimed as native state unless represented by native durable facts. The fixture adapter derives some profile state from bridge facts and projects the native lifecycle journal; this projection is diagnostic, not a native profile journal.
|
|
184
|
+
|
|
185
|
+
Only an admitted worker principal can list its eligible work. `claim` establishes the current claim ID and epoch; claim-bound worker mutations must present that ID, and takeover fences the old grant. Terminal state prevents new authoritative results, but a stored-report retry may return its receipt without a live lease, and cancellation may retain audit-only late evidence from a valid live grant. The `claimant` field is self-declared under the authenticated worker path, so it is collision control, not authenticated human/model identity. OAuth subject and scope authorize the tool call; neither a job ID nor a T3 thread ID is a claim credential. Owner operations use per-request capabilities, with separate operator authority for privileged controls. See **Implementation evidence and OAuth** for scope and principal binding.
|
|
186
|
+
|
|
187
|
+
Store transactions decide competing lifecycle mutations: a successful finish/cancel is terminal; whichever accepted transition commits first governs, and retries cannot replace a contradictory terminal result. Native receipts and event IDs support idempotent delivery/reconciliation in their stated boundaries, but do not establish exactly-once execution of arbitrary remote side effects. Ordering is native durable-operation order; the bridge does not expose the profile's general `revision`/`seq` contract. See `scripts/conformance/runner.mjs` for profile ordering checks and `scripts/conformance/variants.mjs` for fault/race coverage and its limits.
|
|
188
|
+
|
|
189
|
+
### Errors, idempotency and compatibility limits
|
|
190
|
+
|
|
191
|
+
Native errors remain native API/CLI errors, and the conformance adapter maps known native error text to profile codes; unmapped text stays `NATIVE:<text>`. That mapping is test instrumentation, not a public guarantee that every profile error code is implemented. Submission retries with the same request ID and identical immutable payload resolve to the existing job; conflicting payloads fail. Repeated claims and finishes have their documented native idempotency behavior, not a blanket guarantee for every verb or external effect. Event delivery retries preserve event identity; T3 delivery can be uncertain and requires reconciliation.
|
|
192
|
+
|
|
193
|
+
At native contract v1, these profile semantics are **unsupported or materially different**: a separate attempt record and full attempt state machine; caller-keyed revisioned commands and general revision numbers; profile lease duration/deadline semantics; profile `dispatch`, `delivery_result`, `reconcile` and `observe_stop` verbs; durable waiter predicates and profile inbox acknowledgements; the complete artifact staging/retention contract; and observed physical executor stop. The base adapter attempts profile `renew` through repeated native `claim`. Its unkeyed claims now have matching unkeyed retries, but that operation cannot request the profile lease duration or return a profile renewal receipt. Native claim-bound calls refresh live activity before dispatch, and progress also refreshes it; worker `get` does not renew. The historical v1 baseline had no dedicated renewal verb. A separate standalone prototype added `renew_claim` and per-grant duration without the other missing semantics. The historical v1 baseline included unkeyed exact retries. Early idle rotation and the absence of worker self-stop and receiver epoch deduplication remain gaps in the historical baseline. These gaps are not normalized into conformance.
|
|
194
|
+
|
|
195
|
+
### Conformance status and evidence
|
|
196
|
+
|
|
197
|
+
Conformance results describe only the exact source revision and configuration used for a run. Use the conformance harness and its pinned inputs before making a conformance claim. The harness and its gate run as part of `npm test` (`node scripts/conformance/runner-full-test.mjs`); a failing trace or required fault variant turns the suite red.
|
|
198
|
+
|
|
199
|
+
A queued assignment with an expired learned (`queue_p90`) deadline can be requeued up to twice if a fresh deadline can be computed and at least 15 minutes remain before 12 hours after creation. The fresh deadline is capped at that 12-hour boundary; the sweep increments `expiry_requeues` and records a `queued` lifecycle event with reason `expired_requeued`. Requester deadlines, exhausted requeue budgets, insufficient history and less than 15 minutes remaining cause cancellation. Claimed rows and rows without a deadline are untouched, and a paused bridge does not sweep. `get` exposes `valid_until_source` and `expiry_requeues`.
|
|
200
|
+
|
|
201
|
+
The public path `/<secret>/mcp` accepts JSON-RPC POST. It supports `server/discover` for MCP Events, classic `initialize`, `ping`, `tools/list`, `tools/call`, `events/list`, `events/subscribe`, and `events/unsubscribe`. JSON-RPC notifications return HTTP 202; GET returns 405. In production, OAuth verifies the authenticated worker subject and scopes; the path secret remains part of the endpoint URL.
|
|
202
|
+
|
|
203
|
+
`server/discover` advertises MCP Events version `2026-07-28`. This is separate from `initialize`, which accepts `2025-11-25`, `2025-06-18`, `2025-03-26` and `2024-11-05`; any other value, including `2026-07-28`, defaults to `2025-11-25`. Successful JSON-RPC results carry `resultType: 'complete'`; `server/discover` and `tools/list` also carry `ttlMs: 0` and `cacheScope: 'private'`.
|
|
204
|
+
|
|
205
|
+
`assignment.available` is the only work event. Assignment payloads have `request_id` and a title of at most 160 characters; owner-note payloads use the same `request_id` payload with the note id inside the title (the event schema is frozen, so there is no `note_id` field); lightweight message payloads have `message_id` and `title`. Event bodies include a stable `eventId`, timestamp and null cursor. Signed webhook headers are `webhook-id`, `webhook-timestamp`, `webhook-signature` and `X-MCP-Subscription-Id`; signature is `v1,` plus base64 HMAC-SHA256 of `id.timestamp.rawBody` with the decoded `whsec_` key. A transport retry keeps the same event ID.
|
|
206
|
+
|
|
207
|
+
While assignments stay queued, a subscription with a free lane can receive one re-wake event per tick (a new event ID, same payload schema). The usual minimum interval after its last sent assignment or owner-note event is `queue_rewake_ms` (default 90 s); a freed lane waives that interval once. A pending, sending or failed assignment wake holds back another re-wake for that subscription. Items younger than `queue_rewake_window_ms` (default 2 h) are eligible at the usual cadence. Older items remain eligible after `queue_rewake_stale_ms` (default 20 min) since their last sent assignment wake; recorded usage breaks do not count toward queued age. The event names the first eligible item in `list_pending` order and can include the queue count and free lanes in its title. Pause, no active subscription, an uncertain or sending owner delivery for the item, a reported claim denial, and a terminal HTTP 410/413 callback rejection suppress it. Capacity holds and owner-confirmed breaks add further pacing. Eligibility and free lanes are checked again before sending. These limits are configurable in `~/.config/dalan/limits.json`; see [operations](docs/operations.md) for the full rule. The bridge verifies callbacks with a challenge, checks DNS addresses and pins the checked address. Private webhook URLs are rejected outside the test flag.
|
|
208
|
+
|
|
209
|
+
`events/subscribe` accepts `name`, empty `arguments`, `delivery:{mode:"webhook",url,secret:"whsec_<base64>"}`, optional cursor and `ttlMs`. It returns deterministic `id`, `refreshBefore`, null cursor and `truncated`. The default TTL is **7 days**, capped at **7 days**; an explicit value below 60 seconds is raised to 60 seconds. A verified refresh updates the subscription; on a lapsed resubscribe, still-queued requests get a fresh availability event; at most one active availability notification per request and subscription is queued. Key rotation blocks while old-key events remain outstanding. `events/unsubscribe` revokes that callback and suppresses pending retries. An event 2xx does not imply a worker claim.
|
|
210
|
+
|
|
211
|
+
## Claims and worker tools
|
|
212
|
+
|
|
213
|
+
Worker tool inputs are JSON objects with `additionalProperties:false`; dispatch rejects unknown fields. `list_pending {}` returns up to 50 idle own claims, pending lightweight messages and queued assignments in `assignments`, plus `attention:[{request_id,note_count}]` for claimed assignments with unread owner notes. Destination-blocked jobs remain visible with `blocked:true` after unblocked items, but are excluded from `next_queued` recommendations and the queued count used with free lanes. `get {request_id}` reports assignment facts, progress, owner notes, check status, sealed uploads, or a lightweight message. `get` marks owner notes seen, in built-in mode only for the live holding connection, but does not renew the lease. `ack_message {message_id}` acknowledges a message without claim or finish.
|
|
214
|
+
|
|
215
|
+
For legacy non-protocol jobs in this revision, `claim {request_id,claimant,acquisition_id?}` atomically acquires work and returns the immutable assignment, `claim_id`, `epoch` and `guidance` (guidance also appears on `get`). The wire schema requires only `request_id` and `claimant`. If supplied, `acquisition_id` must contain 1–128 ASCII letters, digits, underscores or hyphens. Generate a random nonempty ID for each independent run and keep it stable for retries. The default resume-idle threshold is 2 minutes, but resume also requires lease expiry; a running check prevents resume.
|
|
216
|
+
|
|
217
|
+
| Legacy non-protocol situation in this revision | Result with resume wake enabled (default) |
|
|
218
|
+
|---|---|
|
|
219
|
+
| Fresh eligible job, acquisition supplied or omitted | New claim and epoch 1; omission stores a null acquisition, even for a newly created claim |
|
|
220
|
+
| Live claim, same worker, subject, claimant and acquisition identity, including omission matching stored NULL | Same claim ID and epoch, `duplicate:true`; refreshes legacy activity once the connection checks below pass |
|
|
221
|
+
| Unexpired live claim, same worker and subject, different claimant or acquisition identity, even when idle | `claim_busy` (`already claimed by another claimant` when `DALAN_RESUME_IDLE_MS=0`); omission differs from a stored nonempty acquisition ID |
|
|
222
|
+
| Expired idle claim, same worker and subject | New claim ID and epoch, `resumed:true`, `previous_epoch`, only after verified host stop and delivery gates |
|
|
223
|
+
| Live claim held by another subject | `already claimed by another claimant` until lease expiry |
|
|
224
|
+
| Expired claim, including a previously abandoned claim | New claim ID and next epoch only after the prior deadline, verified host stop, delivery and capacity gates |
|
|
225
|
+
|
|
226
|
+
Exact live retries compare worker, subject, claimant and acquisition identity. Omission matches a stored NULL acquisition ID; explicit JSON null is rejected. In built-in mode a retry must come from the live connection that holds the grant and, when the owner approved a destination, while the live connection set matches the approved digest. A retry does not re-run destination or repository policy and writes no refusal record. A different acquisition cannot take over before expiry, even when idle. Explicit resume and re-claim after abandonment also wait for the prior lease deadline and verified host-check cessation. Abandonment does not shorten that deadline, and unknown or sending owner deliveries remain a fence until reconciled. After regrant, a known old grant fails with `claim_superseded`; an unknown grant fails with `invalid claim`. Legacy leases expire after the stored duration since valid claim activity; native protocol leases instead use a fixed deadline and explicit `renew_claim`. Neither idle settings nor sweep grace extend authority. `DALAN_RESUME_IDLE_MS=0` disables resume wake/idle rotation, not acquisition identity checks or expiry-only regrant. See [pull workers](docs/pull-workers.md#resume-wake-idle-own-claims).
|
|
227
|
+
|
|
228
|
+
### Worker-get capability redaction and the compatible-immediate acquisition rule
|
|
229
|
+
|
|
230
|
+
Worker `get` never exposes claim capability values. The worker claim projection
|
|
231
|
+
omits `claim_id` from its field allowlist, and every other generated worker-get
|
|
232
|
+
field (claim activity, sealed-upload metadata, check and report evidence,
|
|
233
|
+
delivery arguments, nested objects and arrays) is recursively stripped of the
|
|
234
|
+
keys `claim_id`, `origin_claim_id` and `acquisition_id`. The submitted
|
|
235
|
+
assignment is split out before projection and restored unchanged, so
|
|
236
|
+
same-named keys inside assignment inputs or prose are not rewritten. Key-based
|
|
237
|
+
redaction does not remove capability values embedded in arbitrary strings or
|
|
238
|
+
assignment prose. Owner reads use a separate path and retain the full
|
|
239
|
+
evidence, as do stored reports, artifact provenance and database rows.
|
|
240
|
+
Successful `claim` responses still return the newly acquired grant and list
|
|
241
|
+
sealed uploads without `origin_claim_id`; that delivery is not a worker `get`.
|
|
242
|
+
|
|
243
|
+
For a live (unexpired) active grant, continuation requires exact acquisition
|
|
244
|
+
identity: the same worker, subject, claimant and acquisition ID, with omission
|
|
245
|
+
matching only a stored NULL. An omitted or different acquisition against a
|
|
246
|
+
stored nonempty acquisition, and a newly supplied acquisition against a stored
|
|
247
|
+
unkeyed grant, are refused (`claim_busy` for the same subject while idle
|
|
248
|
+
rotation is enabled, otherwise `already claimed by another claimant`).
|
|
249
|
+
|
|
250
|
+
Residual gaps, deliberately preserved for compatibility: unkeyed-to-unkeyed
|
|
251
|
+
retries still return the existing grant, because existing inputs cannot
|
|
252
|
+
distinguish an unkeyed continuation from a separate unkeyed wake with
|
|
253
|
+
identical worker, subject and claimant; that ambiguity is not closed by this
|
|
254
|
+
change. A post-expiry new epoch is a new admission, not a retry: once the
|
|
255
|
+
lease has expired (and delivery and capacity gates pass), a new epoch under
|
|
256
|
+
the caller's acquisition rebinds the worktree and sealed uploads, and lease
|
|
257
|
+
expiry alone does not prove the old host's compute stopped. Full closure
|
|
258
|
+
requires an owner-selected strict legacy policy (nonempty acquisition
|
|
259
|
+
identity on new claims and retries, with an explicit transition for
|
|
260
|
+
historical grants, preserving known-grant progress, upload and finish while
|
|
261
|
+
valid and without fabricating historical acquisitions); under strict refusal
|
|
262
|
+
an unkeyed client that loses its initial claim response cannot recover the
|
|
263
|
+
grant without a new authenticated retry identity. A blanket
|
|
264
|
+
`acquisitionId !== null` predicate is not backward-compatible: it would break
|
|
265
|
+
the verified unkeyed retries (claim-epoch pre-migration and null retries,
|
|
266
|
+
worker-isolation unkeyed claim and boundary retries, migrated unkeyed grant
|
|
267
|
+
retries, and the malformed-metadata non-host claim/retry path).
|
|
268
|
+
|
|
269
|
+
`progress {request_id,claim_id,note,blocker?}` appends progress history. An empty note is refused. A note over 4096 bytes is cut to 4096 bytes. `blocker:true` or a line leading with `BLOCKED:` / `QUESTION:` queues a notice, deduplicated by identical note body. A QUESTION records waiting history; it does not pause the lease or stop compute. Across an answer pause or reconnect, retain the acquisition ID, claimant and claim ID. Continue with the saved grant while it remains valid; an independent later run must acquire under its own ID when permitted. Never copy authority from `get`. An owner note alone does not renew or rotate a claim.
|
|
270
|
+
|
|
271
|
+
When T3 delivery is enabled and unprotected, notices go to the bound owner thread with a stable `[dot-bridge event <id>]` marker. CLI-delivered notices use `--if-busy steer`; job results sent through the result transport instead use orchestration `message.dispatch`, selecting `steer_active` for the latest active run, `queue_after_active` when no active run exists but a queue does, and `start_immediately` otherwise. Lifecycle checks prevent waking settled or archived threads. `finish {request_id,claim_id,outcome,summary,result,artifact_ids?}` accepts `completed|blocked|failed` and a `result` of 1 to 262144 bytes. `summary` is optional: a missing, empty or blank summary is taken from the first non-empty line of `result`, and a summary over 4096 bytes is cut to 4096 bytes. A call with no summary and no non-empty line in `result` is refused. Nonempty `artifact_ids` must name sealed uploads bound to the claim. A new report requires a live, unexpired claim and validates supplied sealed artifact references. A stored-report retry requires the same active claim, worker and subject plus equal outcome, summary and result, but not a live lease. It skips artifact validation; changed or nonexistent artifact IDs do not make that stored-report replay contradictory. Changing the compared result fields fails. A cancelled assignment accepts no result: a live claim's finish is retained as bounded audit evidence and returns terminal `assignment_cancelled`; an invalid or expired grant is refused before that evidence write. A successful finish suppresses legacy watch state and sends one result notice; an identical retry returns the stored receipt without writing another report.
|
|
272
|
+
|
|
273
|
+
The six workspace and artifact tools and their input fields are:
|
|
274
|
+
|
|
275
|
+
| Tool | Required | Optional |
|
|
276
|
+
|---|---|---|
|
|
277
|
+
| `list_files` | `request_id`, `claim_id` | `path`, `limit` (1–200) |
|
|
278
|
+
| `read_file` | `request_id`, `claim_id`, `path` | `start_line` (≥1), `max_lines` (1–200) |
|
|
279
|
+
| `apply_patch` | `request_id`, `claim_id`, `patch` | none |
|
|
280
|
+
| `run_check` | `request_id`, `claim_id`, `check_id` | none |
|
|
281
|
+
| `workspace_result` | `request_id`, `claim_id` | none |
|
|
282
|
+
| `artifact_chunk` | `request_id`, `claim_id`, `artifact_id`, `offset`, `data_base64` | `final`, `sha256` |
|
|
283
|
+
|
|
284
|
+
All six require built-in or external OAuth mode and `DALAN_ENABLE_WORKSPACE=1`; otherwise they return `capability_not_enabled`. There is no general shell or arbitrary command tool. Their published names and required input fields stay unchanged. `artifact_chunk` works for any claimed assignment, including read-only assignments without a GitHub workspace.
|
|
285
|
+
|
|
286
|
+
For `artifact_chunk`, `artifact_id` must match `art_[A-Za-z0-9_-]{8,128}`. `data_base64` must be standard padded base64 without whitespace; an empty string is allowed. Start at offset 0, then append at the stored byte count. An identical retry of bytes already stored is accepted; conflicting bytes or an offset beyond the stored count fail. `sha256` is optional on nonfinal chunks but required when `final:true`: supply the 64 hexadecimal digits of the whole file's SHA-256. Sealing verifies that digest, and a sealed final-chunk retry succeeds only with the same ending offset, bytes and digest. Uploads remain bound to their request and claim.
|
|
287
|
+
|
|
288
|
+
## Catalog v2
|
|
289
|
+
|
|
290
|
+
Catalog v2 is the last advertised catalog change. ChatGPT caches tool names, descriptions and schemas, so every change needs an owner Refresh. v2 is the last advertised change: add abilities by registering tools, which never changes the tool list. Do not change a tool name, description or schema. `scripts/catalog-golden-test.mjs` enforces the freeze.
|
|
291
|
+
|
|
292
|
+
- Every tool carries MCP `annotations`. Read-only tools (`list_pending`, `get`, `list_files`, `read_file`, `workspace_result`, `t3_thread_list`, `t3_thread_read`, `t3_thread_wait`, `list_tools`, `call_tool_read`) set `readOnlyHint:true`. All other tools, including `call_tool_write`, set `readOnlyHint:false` and `destructiveHint:false`; `notify_owner` also sets `openWorldHint:true` because it reaches an outside service.
|
|
293
|
+
- Three fixed tools front a server-side tool registry. `list_tools` takes no arguments and returns `{registry_version, tools}`. `registry_version` is a monotonic integer that moves on every register, remove, grant, revoke, enable and disable. Each tool has `name`, `description`, `input_schema`, `class` (`read` or `write`) and `schema_hash`. `call_tool_read` and `call_tool_write` take `{tool, arguments, schema_hash, idempotency_key}` and no other field. `arguments` is an open object that the registry validates against the registered tool's own schema. `schema_hash` and `idempotency_key` (at most 128 characters) are required for `call_tool_write` and optional for `call_tool_read`. `call_tool_read` runs only `read` tools and `call_tool_write` only `write` tools. Their names, descriptions and schemas are fixed and name no individual registered tool, so registering, changing or removing a tool never changes `tools/list`.
|
|
294
|
+
- The advertised `tools/list` is fixed per catalog profile and worker capability (for example profile `stable` and a worker without `t3`). Registry changes never alter it, and the tools a worker can actually use vary per worker and are read through `list_tools`.
|
|
295
|
+
- `schema_hash` pins what the model saw. It covers the tool name, description, input schema, class, handler kind and handler config (target thread, command template) and the calling worker's grants. A call whose hash differs from the current one is refused with `stale_registry` and the text `call list_tools again`. A changed target or a new grant therefore cannot ride on an older view or an older approval. The ChatGPT approval of `call_tool_write` is a user-interface convenience, not the control. The control is the owner-managed grant plus this pin.
|
|
296
|
+
- Every call passes one enforcement function, in this order: authenticate, resolve the worker, a per-worker admission budget (it also counts unknown and ungranted tools), exact-match registry lookup (no case or whitespace normalisation), grant, class, schema hash, idempotency, argument validation, rate limit, handler. Handlers take their target and config only from the registry row, never from arguments.
|
|
297
|
+
- `idempotency_key` is stored per (worker, tool, key) in SQLite before the handler runs. The reservation holds a lease of the handler timeout plus 30 seconds (45 s for `t3_post`); a finished outcome is kept for 7 days. A repeat returns the stored outcome without running the handler again. A repeat while the lease is live is refused with `in_progress` (retryable, with the seconds left); after a crash, a repeat once the lease has expired takes the reservation over and runs the handler again. A failed handler may run again under the same key only when it proved it delivered nothing (`t3-post` exit code 3).
|
|
298
|
+
- A refused call is an MCP result with `isError:true` whose text starts with one machine-readable code: `tool_unavailable` (unknown, ungranted and disabled tools look the same, so a worker cannot list tools it cannot use), `wrong_class`, `stale_registry`, `invalid_arguments`, `rate_limited`, `in_progress` or `handler_failed`. It is never a transport error, and the text never holds registry contents. Results are redacted and capped at 32 KiB; a longer result becomes `{truncated:true, preview}`. The owner manages the registry with `dalan tool` ([operator-registered tools](docs/t3-reverse-control.md#adding-abilities-without-a-refresh)). A worker sees and may call only the tools granted to its resolved worker name; with no grants `list_tools` returns an empty `tools` array.
|
|
299
|
+
- The worker tools `t3_thread_create`, `t3_thread_send`, `t3_thread_wait` and `t3_thread_set` are top-level tools again, advertised only with `DALAN_ENABLE_T3_TOOLS=1` and a worker that holds the `t3` capability; `t3_thread_wait` is read-only. With the setting on, `tools/list` therefore has these four extra entries (`scripts/fixtures/catalog.t3-on.tools.golden.json` freezes it). `legacy-v46` keeps its frozen twelve-tool catalog byte for byte, without annotations or the registry tools.
|
|
300
|
+
|
|
301
|
+
## Owner operations and delivery recovery
|
|
302
|
+
|
|
303
|
+
Local admin operations use the private Unix socket. Use `dalan note REQUEST_ID "text"` for ordinary messages about a specific assignment; use `dalan answer` for an identified question as described in native contract v3 above. It requires the owner receipt, rejects flags except `--json`, and appends a note of at most 4096 UTF-8 bytes (aggregate 16 KiB per assignment). `get` and both fresh and repeated `claim` results include `owner_notes:[{id,at,text}]`, oldest first. Each note emits `assignment.available` with `{request_id,title}` through the existing event delivery path, where `title` begins `Owner note NOTE_ID: ` (the event schema is frozen, so there is no `note_id` field); no worker tool or required input changes. `dalan tell "text"` queues a durable message and emits `assignment.available` through the existing signed webhook and retry path. `tell` rejects option-like text beginning with `-` except `--json`. `dalan untell MESSAGE_ID` withdraws a pending message and hides it from `list_pending`; `dalan audit [--since RFC3339]` reads append-only T3 audit records with the operator key. `get` and `cancel` require a per-request owner capability; operator `pause`, `resume`, `reconcile` and explicit legacy adoption require a separate key. `watch`, `unwatch` and `mute` were retired: neither CLI commands nor admin mutation routes are available. Retained legacy watch and mute facts remain readable and can still appear in delivery checks; legacy watch state still changes when finish, cancel or expiry suppresses it.
|
|
304
|
+
|
|
305
|
+
`cancel` returns `cancellation_requested:true`, `authority_revoked:true` and `compute_stopped:false`. A new finish after cancellation still requires a valid, unexpired claim. It retains bounded audit-only `late_evidence` (one row per claim, up to 4 KiB summary and 64 KiB result, with the full-output hash), then returns the terminal error `assignment_cancelled`. An expired or otherwise invalid claim is refused before this evidence write. It creates no report or successful late receipt, sends no owner wake or T3 notice and frees no lane. Existing legacy `late:true` reports remain readable; they are not the new cancelled-finish path. The `late:true` success path applies only to matching retries of an already-stored legacy report.
|
|
306
|
+
|
|
307
|
+
Accepted T3 sends and webhook 2xx responses are recorded in a separate mode-0600 `delivery-acks.db`, with SQLite `synchronous=FULL`. Each acceptance is keyed by event ID, body hash and destination-binding hash. Preserve this ledger as well as `bridge.db` during backup and recovery: restoring only the main database can leave delivery state behind an acceptance. A positive ledger match suppresses a resend; it proves transport acceptance, not owner consumption. Automatic reconciliation reads only this local positive evidence. Explicit operator reconciliation can also look for the transcript marker. Unproved `uncertain` deliveries are held without automatic resend; after 30 minutes from the attempt, reconciliation moves them to `uncertain_terminal` without releasing the claim-epoch hold. Positive acknowledgment or transcript reconciliation remains available for this state. This state means delivery is unknown, not proven undelivered; a late accepted message remains possible.
|
|
308
|
+
|
|
309
|
+
Local CLI submit defaults to `delivery:"none"`; explicit T3 delivery stays supported. A protected `main_thread_ids` destination requires both `allow_main:true` and a valid `x-operator-key` to admit submission. This admission does not bypass delivery protection. The current protection list and stored legacy per-assignment mute facts are checked before every T3 notice send, including retries and assignments already in flight. Quiet results and questions stay in the durable wait queue; legacy quiet watches remain visible in `get`. Removing protection does not replay notices already retained quietly.
|
|
310
|
+
|
|
311
|
+
Reference: [OpenAI MCP Events](https://developers.openai.com/plugins/build/mcp-events) and [MCP Events design sketch](https://github.com/modelcontextprotocol/experimental-ext-triggers-events/blob/main/docs/design-sketch-proposal.md). Before you rely on unattended webhook delivery, check subscription refresh and signing-key rotation with the worker client you use.
|
|
312
|
+
|
|
313
|
+
## Implementation evidence and OAuth
|
|
314
|
+
|
|
315
|
+
When OAuth mode and the explicit workspace flag are both active, `list_files`, `read_file`, `apply_patch` and `run_check` use a claim-bound worktree fetched from the assignment's `github_repo` (`owner/name`) at its full `base_sha`. An optional `head_sha` checks out that revision and shows its diff from `base_sha` for review. The host uses its GitHub authentication to update a bare-mirror cache. Clone URLs with embedded credentials are rejected, and the sandbox sees no GitHub token, `.git` data, host home, credential helpers, or sockets. Paths are relative and cannot traverse `.git` or symlinks. Patches are at most 256 KiB; sealed uploads are at most 8 MiB in 64 KiB chunks with SHA-256. `claim` and `get` add `available_checks` only when workspace tools are enabled and the assignment is implementation work. Check metadata can instead report `available_checks_error`, including repository-policy denial. A repository-backed `workspace_result` includes check discovery; a result without repository input returns only `checks` and sealed `artifacts`. For an eligible check execution, an unknown `run_check` ID returns a structured skip and the available list. The `default` check is auto-detected from standard repository files, or overridden by `.dot-bridge.json` / a mode-0600 host file. Host execution is disabled unless the operator sets `DALAN_HOST_CHECKS=1`. Each check must declare six `host_budget` fields: `cpu_ms`, `wall_ms`, `memory_bytes`, `processes`, `disk_write_bytes` and `output_bytes`. Admission reserves one systemd user-service slot and applies kernel limits before source transfer. Installation and checking share one offline tmpfs copy and cumulative allowances, an isolated HOME with an empty `.tmp` directory, and no inherited credentials. Guest writes are not exported to the host worktree. Resource failures return `budget exceeded: <which>` and store failed checks; supervisor interruption is separate. See [operations](docs/operations.md#execution-capability-and-check-evidence) for enforcement, ranges and limitations. The sandbox reports an empty user systemd scope list and rejects other `systemctl` operations. `run_check` returns a completed receipt for fast checks or `{check_run_id,status:"running"}` after about 20 seconds. A same-diff, same-`check_id` retry while running returns the same ID. Poll `workspace_result` or `get` for the final state; a restart marks an unfinished check `interrupted`. `artifact_chunk` needs only a claimed assignment, enforces the same 64 KiB chunk and 8 MiB total limits, and never creates a worktree. Sealed uploads appear in `workspace_result` and `get` even for non-workspace assignments. A finish records a diff snapshot, check receipts and artifact hashes when a workspace exists; the local owner fetches bytes through the admin socket. The bridge never pushes.
|
|
316
|
+
|
|
317
|
+
OAuth mode exposes `/.well-known/oauth-protected-resource`, requires a Bearer access token on MCP requests (an opaque token from the built-in server, or an RS256 JWT from an external issuer), and publishes per-tool `securitySchemes`. Assignment read tools require `dalan.read`; claim, progress, finish, message acknowledgment and workspace mutation tools require `dalan.work`. The legacy names `dot-bridge.read` and `dot-bridge.work` are accepted aliases for these two scopes: a token or grant that carries a legacy name gets exactly the permission of its neutral name, no more. A new grant is issued the scope names the client requested; the built-in server advertises only the neutral names (`scopes_supported`, challenge `scope`). With an external issuer the server keeps advertising and challenging with the legacy `dot-bridge.read` and `dot-bridge.work` names unless the operator sets `OAUTH_SCOPE_NAMES=neutral` in `oauth.env`; under the frozen `legacy-v46` catalog profile the challenge and metadata use the legacy names, matching `securitySchemes`. An unknown scope is never granted, and T3 tools share the same two scopes (`scopeFor` in `src/server.mjs`): `t3_thread_list`, `t3_thread_read`, `list_tools` and `call_tool_read` require `dalan.read`; `call_tool_write` and `notify_owner` require `dalan.work`. There are no separate `t3.read` or `t3.write` scopes; a token that carries them is still accepted by the token check but they grant nothing. The service verifies issuer, audience, expiry, RSA signature, approved subject and scope per request. Claims and subscriptions bind to that subject. Unauthenticated requests receive HTTP 401 and `WWW-Authenticate`; insufficient tool scope also returns `mcp/www_authenticate` metadata. The [reverse-control runbook](docs/t3-reverse-control.md) records the T3 tools, audit and reconnect steps.
|
|
318
|
+
|
|
319
|
+
After an advertised catalog change, refresh or reconnect the worker client so it receives the new tool snapshot. For ChatGPT, refresh the connector and restart the worker conversation; other clients have their own refresh procedure.
|
|
320
|
+
|
|
321
|
+
## Submission policy
|
|
322
|
+
|
|
323
|
+
Fresh admin submissions enforce a 16 KiB UTF-8 brief and 24 KiB total instruction cap. Owner note limits are enforced atomically with insertion. Existing immutable assignments remain readable and retryable at their original sizes; retries still verify payload, destination, owner and review identity.
|
|
324
|
+
|
|
325
|
+
Opaque read-only inputs remain supported. New pinned repository submissions require a nonempty `scope_paths` array; omitting it or supplying an empty array is refused with `missing_scope`. The workspace tools enforce the readable set at runtime: `scope_paths` plus separately authorized, explicit new-file `output_paths`, minus `scope_excluded` paths. Admission verifies that outputs are absent at the pinned revision and pass path and sensitive-content policy. `list_files` shows only that set, and `read_file` refuses paths outside it. Implementation `apply_patch` may change files named by `scope_paths` and `output_paths`, never the immutable declarations themselves, and rejects a patch touching a file outside both (`path outside scope_paths: <path>`); read-only work may create or edit only its declared outputs, never arbitrary files or existing scoped inputs. Created outputs are readable in the same assignment. Review submissions still disallow patches and outputs. An explicit `.` grants repository-wide scope subject to sensitivity, symlink and exclusion policy; it does not permit read-only work to change existing inputs. `run_check` refuses narrow read grants or exclusions because the executor requires repository-wide read permission. With that permission, it runs against a private execution copy with sensitive paths masked. Guest writes are discarded rather than exported to the host worktree; the original candidate diff remains subject to the writable-scope result guards (see [usage](docs/usage.md)). A background worker scans the pinned Git tree, full base/head diff and parsed input patch before admission, rejecting symlink scopes, undeclared paths, inconsistent read lists and live-slot authority claims. A recognized bare filename with no repository match, or multiple matches with none already in scope, refuses submission with `unknown_path` or `ambiguous_path` and a full-path fix. A matching in-scope file satisfies the mention. A unique outside-scope file, including an explicit repository path, may expand an eligible free-form read-only or review job with a warning; implementation work, structured briefs and explicit read lists keep their declared scope and refuse undeclared files. A bare word with no `/` and no extension (`web`, `tests`) is prose. Outside-scope directories and valid relative slash paths absent from the tree warn instead; host paths, traversal and sensitive names remain subject to refusal. For a new root file, mention `./name` and declare the canonical `name` in `output_paths`. Path characters are `[A-Za-z0-9_.@-]` plus whole router segments in a path with a `/`: `[id]`, `[...slug]`, `[[...slug]]`, `(group)`, `(.)x`, `(..)x`, `@slot`, and a leading `+` after a slash (`src/routes/+page.svelte`); `app/(group)/[id]/page.tsx` is one path, while prose brackets (`(see a.ts)`, `[1]`) split as before, and `scope_paths` accept brackets and parentheses only in that form. Spaces, `$`, backticks, quotes, `;|&<>` and `..` segments end a path token. A JSX/HTML tag name right after `<` or `</` (`</Button>`, `<Card.Header>`, `<Icon />`) is markup, not a path, unless it is a hard sensitive name; explicit paths inside an embedded excerpt (`../lib/util.ts`, `href="web/index.html"`) are checked like any other. The soft sensitive rule matches credential meaning: `auth`, `secret` and `credential` names, signing paths, and token files qualified as credentials (`auth-token.json`, `access_token`, `gh-tokens.txt`, a bare `token` file). Design-token files such as `tokens.css`, `tokens.json` and `design-tokens.json` pass. Managed assignments may provide `objective` and `stop_rule` instead of `brief`; code renders the brief with exact revisions and the read allow-list.
|
|
326
|
+
|
|
327
|
+
Implementation submissions with `execution:"host"` also pass a host check-readiness gate after the pinned commit is fetched. The bridge reads check metadata at `base_sha` as `availableChecksFor` does and rejects with `BLOCKED: check prerequisites unmet: <check>: <what>` when the currently owner-authorized `default` check declares a binary missing from the host `/usr/bin` (the sandbox ro-binds `/usr`), a lockfile absent at `base_sha`, or a `node>=N` runtime newer than the running process; unreadable metadata rejects with `BLOCKED: check metadata unreadable`; unmet prerequisites of an unauthorized default or nondefault checks are warnings. Current default authorization requires an exact repository/check allowlist entry, an owner-configured definition and a valid owner budget. No assignment row is created on rejection, and a retry of an already-stored request skips the gate. `readiness_argv` is recorded as skipped (never run on the host). For `execution=none` or `worker`, host prerequisite probes are skipped and unreadable check metadata does not block admission.
|
|
328
|
+
|
|
329
|
+
The regression-test scope rule still applies to implementation assignments, including non-host execution. An implementation assignment whose `expected_output` asks for a regression test (and does not negate it) is rejected with `regression_test_scope` unless some `scope_paths` entry is a test path: a path the check links through `test_paths`, or one matching `test/`, `tests/`, `__tests__/`, `spec/`, `*.test.*`, `*.spec.*`, `*_test.*`, `test_*.py`, `scripts/*-test.mjs` or `scripts/*-e2e.mjs` anywhere in the path, or a directory whose tree at `base_sha` already holds such a test file (colocated tests such as `internal/foo/bar_test.go` or `src/a.test.ts` admit `internal/foo` or `src`).
|
|
330
|
+
|
|
331
|
+
Armor detection is case-insensitive and accepts runs of one or more dashes, optional whitespace and either an empty label or a label containing `KEY` or `PRIVATE`. Whitespace may fold a marker across lines. Reads, output and admission use the same grammar; admission scans actual instruction strings before JSON encoding. A block ends only at an END with the same label (ignoring case and repeated whitespace) and dash counts; otherwise its BEGIN masks through EOF, even mid-line. A stray END masks its marker lines. Complete blocks preserve surrounding text and all masking preserves line counts.
|
|
332
|
+
|
|
333
|
+
Mode-0600 `~/.config/dalan/submission-policy.json` holds `version:1`, `sensitive_paths` and `exceptions:[{id,github_repo,path,reason}]`. `--sensitive-scope-override ID` applies only to that configured repository and exact soft-sensitive path. Credential/private-key/signing exclusions and detected secret content cannot be overridden. Prose lint is heuristic and cannot certify arbitrary content as secret-free.
|
|
334
|
+
|
|
335
|
+
## Owner report archive
|
|
336
|
+
|
|
337
|
+
Every newly committed `completed` read-only finish creates one bridge-owned `owner-report` artifact in the same finish transaction. Its UTF-8 JSON document has `format: "dalan-owner-report"`, `version: 1`, the final `summary` and `result`, and `progress`, an array of all progress notes in storage order. Each note records its sequence, timestamp and text. Existing operational-secret redaction is applied to each text field before encoding. The encoded document is limited to 8 MiB; a larger document refuses finish atomically and is never truncated.
|
|
338
|
+
|
|
339
|
+
The archive is immutable, retained through the artifact store, and listed to the owner with its ID, kind, size and digest. The owner download route still checks the request owner capability. It is not a worker upload, cannot be selected in `artifact_ids`, and does not alter result binding or acceptance. `workspace_evidence.owner_report_artifact` is a supplementary stable reference. This is an archival copy of worker statements; it does not establish that the report satisfies the assignment. Blocked, failed, cancelled, stale and unresolved-question outcomes do not receive a success archive. Low-level direct `Store.finish` calls without a trusted capture callback remain storage-only; the public bridge finish path supplies the callback. A process crash after file publication but before SQLite commit can leave an unreferenced sealed file; no separate recovery journal is introduced, and normal transaction failures remove the file.
|