@tnunamak/dalan 0.0.0-stage → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/CONTRIBUTING.md +26 -0
  3. package/LICENSE +204 -0
  4. package/PROTOCOL.md +351 -0
  5. package/README.md +215 -2
  6. package/SECURITY.md +30 -0
  7. package/bin/dalan.mjs +43 -0
  8. package/bin/dot-acp-agent.mjs +377 -0
  9. package/bin/dot-alert.mjs +9 -0
  10. package/bin/dot-deadman.mjs +82 -0
  11. package/bin/dot-heartbeat.mjs +29 -0
  12. package/bin/dot-pr-reviewer.mjs +32 -0
  13. package/bin/dot-worker.mjs +764 -0
  14. package/docs/chatgpt-worker-onboarding.md +112 -0
  15. package/docs/claude-worker-onboarding.md +113 -0
  16. package/docs/codex-to-muse.md +175 -0
  17. package/docs/connect-chatgpt.md +83 -0
  18. package/docs/connection-longevity.md +43 -0
  19. package/docs/dalan-upgrade.md +246 -0
  20. package/docs/deadman.md +61 -0
  21. package/docs/dot-pr-reviewer.config.example.json +9 -0
  22. package/docs/durability-audit.md +27 -0
  23. package/docs/keycloak-client-chatgpt-dot-bridge.json +59 -0
  24. package/docs/keycloak-oauth-setup.md +30 -0
  25. package/docs/local-agent-mcp.md +41 -0
  26. package/docs/manual-setup.md +135 -0
  27. package/docs/mirror-fetch.md +97 -0
  28. package/docs/operations.md +799 -0
  29. package/docs/operator-duties.md +68 -0
  30. package/docs/owner-integrator.md +27 -0
  31. package/docs/portable-auth-profile.md +107 -0
  32. package/docs/pr-head-reviewer.md +70 -0
  33. package/docs/pr-preflight.md +28 -0
  34. package/docs/pull-queue.md +131 -0
  35. package/docs/pull-workers.md +94 -0
  36. package/docs/redaction.md +27 -0
  37. package/docs/service-setup.md +219 -0
  38. package/docs/setup-reference.md +80 -0
  39. package/docs/t3-connector-icon.png +0 -0
  40. package/docs/t3-integration.md +51 -0
  41. package/docs/t3-result-retry-delivery.md +41 -0
  42. package/docs/t3-reverse-control.md +107 -0
  43. package/docs/usage.md +443 -0
  44. package/docs/worker-clients.md +290 -0
  45. package/integrations/t3/acp-kit/src/capability.mjs +25 -0
  46. package/integrations/t3/acp-kit/src/errors.mjs +13 -0
  47. package/integrations/t3/acp-kit/src/index.mjs +5 -0
  48. package/integrations/t3/acp-kit/src/lock.mjs +155 -0
  49. package/integrations/t3/acp-kit/src/session-store.mjs +36 -0
  50. package/integrations/t3/acp-kit/src/t3-envelope.mjs +62 -0
  51. package/package.json +67 -4
  52. package/packages/job-core/README.md +18 -0
  53. package/packages/job-core/index.mjs +2 -0
  54. package/packages/job-core/package.json +8 -0
  55. package/packages/job-core/protocol/canonical.mjs +11 -0
  56. package/packages/job-core/protocol/v0/command.schema.json +1154 -0
  57. package/packages/job-core/protocol/v0/event.schema.json +77 -0
  58. package/packages/job-core/protocol/v0/reply.schema.json +59 -0
  59. package/packages/job-core/transitions.mjs +25 -0
  60. package/scripts/daily-selfcheck.mjs +135 -0
  61. package/scripts/dalan-try-selfcheck.mjs +29 -0
  62. package/scripts/lib/expose-tailscale.mjs +408 -0
  63. package/scripts/live-trial/common.mjs +272 -0
  64. package/scripts/monitor-targets.mjs +44 -0
  65. package/scripts/upgrade-drain.mjs +39 -0
  66. package/scripts/worker-bridge-setup.mjs +925 -0
  67. package/src/ack-ledger.mjs +37 -0
  68. package/src/acp-bridge.mjs +418 -0
  69. package/src/acp-context.mjs +138 -0
  70. package/src/admin-socket.mjs +14 -0
  71. package/src/alerts.mjs +147 -0
  72. package/src/artifact-journal.mjs +75 -0
  73. package/src/as-files.mjs +347 -0
  74. package/src/as-store.mjs +456 -0
  75. package/src/as.mjs +538 -0
  76. package/src/auth.mjs +166 -0
  77. package/src/builtin-http.mjs +22 -0
  78. package/src/check-coverage.mjs +38 -0
  79. package/src/check-lint.mjs +88 -0
  80. package/src/check-readiness.mjs +112 -0
  81. package/src/check-response.mjs +19 -0
  82. package/src/child-exit.mjs +18 -0
  83. package/src/child-registry.mjs +94 -0
  84. package/src/claim-command-ledger.mjs +51 -0
  85. package/src/cli-help.mjs +186 -0
  86. package/src/cli-name.mjs +16 -0
  87. package/src/connect-cli.mjs +126 -0
  88. package/src/consumers.mjs +61 -0
  89. package/src/deadman.mjs +329 -0
  90. package/src/delivery.mjs +19 -0
  91. package/src/demo-worker.mjs +150 -0
  92. package/src/destinations/index.mjs +23 -0
  93. package/src/destinations/none.mjs +15 -0
  94. package/src/destinations/t3.mjs +109 -0
  95. package/src/diagnostic.mjs +78 -0
  96. package/src/docs-url.mjs +9 -0
  97. package/src/drain-runner.mjs +9 -0
  98. package/src/drained-owner.mjs +26 -0
  99. package/src/drained-slot.mjs +70 -0
  100. package/src/drained.mjs +40 -0
  101. package/src/durable-waiters.mjs +236 -0
  102. package/src/env.mjs +19 -0
  103. package/src/execution.mjs +112 -0
  104. package/src/failure-type.mjs +28 -0
  105. package/src/get-summary.mjs +32 -0
  106. package/src/git-env.mjs +15 -0
  107. package/src/host-budget-receipts.mjs +154 -0
  108. package/src/host-budget-seccomp.py +33 -0
  109. package/src/host-budget-service.mjs +54 -0
  110. package/src/host-budget-stop.mjs +26 -0
  111. package/src/host-budget-storage.py +259 -0
  112. package/src/host-budget.mjs +149 -0
  113. package/src/host-cgroup.mjs +23 -0
  114. package/src/host-check-allowlist.mjs +42 -0
  115. package/src/host-execution-policy.mjs +38 -0
  116. package/src/host-health.mjs +34 -0
  117. package/src/host-stop-reverify.mjs +44 -0
  118. package/src/inbox.mjs +55 -0
  119. package/src/integrator.mjs +322 -0
  120. package/src/job-retention.mjs +69 -0
  121. package/src/legacy-names.mjs +8 -0
  122. package/src/lifecycle.mjs +291 -0
  123. package/src/limits.mjs +31 -0
  124. package/src/loopback.mjs +9 -0
  125. package/src/mcp-outcome.mjs +79 -0
  126. package/src/mcp-sse.mjs +62 -0
  127. package/src/mcp-stdio.mjs +191 -0
  128. package/src/mirror-fetch-lock.py +164 -0
  129. package/src/mirror-fetch.mjs +174 -0
  130. package/src/notify-ledger.mjs +82 -0
  131. package/src/objectives.mjs +129 -0
  132. package/src/owner-report-artifact.mjs +66 -0
  133. package/src/patch-apply.mjs +84 -0
  134. package/src/path-syntax.mjs +16 -0
  135. package/src/paths.mjs +67 -0
  136. package/src/pr-head-reviewer.mjs +596 -0
  137. package/src/pr-preflight.mjs +51 -0
  138. package/src/prepared-node-modules.mjs +129 -0
  139. package/src/process-inspection.mjs +36 -0
  140. package/src/projects.mjs +480 -0
  141. package/src/protocol-artifact-commands.mjs +52 -0
  142. package/src/protocol-delivery-driver.mjs +167 -0
  143. package/src/protocol-finish.mjs +100 -0
  144. package/src/protocol-owner-command.mjs +35 -0
  145. package/src/protocol-owner-mutations.mjs +22 -0
  146. package/src/protocol-owner-waiters.mjs +67 -0
  147. package/src/protocol-retention.mjs +52 -0
  148. package/src/protocol-services.mjs +61 -0
  149. package/src/protocol-stop-observer.mjs +131 -0
  150. package/src/publish-plan.mjs +245 -0
  151. package/src/pull-queue.mjs +159 -0
  152. package/src/redaction.mjs +763 -0
  153. package/src/rejections.mjs +18 -0
  154. package/src/request-log.mjs +102 -0
  155. package/src/restore-check.mjs +90 -0
  156. package/src/result-binding.mjs +65 -0
  157. package/src/route-setting.mjs +24 -0
  158. package/src/runtime-check.mjs +13 -0
  159. package/src/sandbox-supervisor.mjs +105 -0
  160. package/src/schema-subset.mjs +186 -0
  161. package/src/scopes.mjs +15 -0
  162. package/src/server.mjs +1468 -0
  163. package/src/service-migrate-workers.mjs +113 -0
  164. package/src/service.mjs +388 -0
  165. package/src/setup.mjs +63 -0
  166. package/src/shutdown-signal.mjs +12 -0
  167. package/src/signal-sandbox-processes.py +56 -0
  168. package/src/signal.mjs +119 -0
  169. package/src/status-evidence.mjs +47 -0
  170. package/src/status-summary.mjs +54 -0
  171. package/src/store.mjs +3069 -0
  172. package/src/submission-policy.mjs +623 -0
  173. package/src/subscription-storage.mjs +64 -0
  174. package/src/t3-audit.mjs +120 -0
  175. package/src/t3-control.mjs +102 -0
  176. package/src/t3-transport.mjs +158 -0
  177. package/src/t3.mjs +209 -0
  178. package/src/terminal-safe.mjs +19 -0
  179. package/src/tool-registry.mjs +453 -0
  180. package/src/try-command.mjs +11 -0
  181. package/src/try-exposure.mjs +908 -0
  182. package/src/try-hosted-clients.mjs +46 -0
  183. package/src/try-hosted.mjs +444 -0
  184. package/src/try-selfcheck.mjs +168 -0
  185. package/src/try.mjs +635 -0
  186. package/src/webhooks.mjs +86 -0
  187. package/src/work-order.mjs +265 -0
  188. package/src/worker-instructions.mjs +26 -0
  189. package/src/worker-prompt.mjs +4 -0
  190. package/src/workers.mjs +632 -0
  191. package/src/workspace.mjs +1065 -0
  192. package/systemd/dot-bridge-heartbeat.service +18 -0
  193. package/systemd/dot-bridge-heartbeat.timer +10 -0
  194. package/systemd/dot-bridge-selfcheck.service +12 -0
  195. package/systemd/dot-bridge-selfcheck.timer +11 -0
  196. package/systemd/dot-bridge.service +17 -0
  197. package/systemd/dot-deadman.service +30 -0
  198. package/systemd/dot-pr-reviewer.service +11 -0
  199. package/systemd/dot-pr-reviewer.timer +10 -0
@@ -0,0 +1,135 @@
1
+ <a id="step-by-step"></a>
2
+
3
+ # Manual setup
4
+
5
+ `try` runs ordinary `dalan` commands in a private trial home. Use this page to run each piece yourself: to keep the bridge in the foreground, to choose your own worker name, or to set up a client that `try` does not cover. You need the npm package, two shells and a compatible HTTP MCP worker client with OAuth. This page explicitly installs the CLI globally before using bare `dalan` commands; `npx` alone does not put it on your persistent PATH.
6
+
7
+ For a hosted first result instead, use `npx -y @tnunamak/dalan try` ([hosted trial](../README.md#quickstart)). In `auto` mode, a saved temporary-relay choice selects bundled Gozar. Otherwise Dalan uses a usable Tailscale route, then Gozar if Tailscale is unavailable. When Gozar is selected, Dalan names tunnl.gg, links its terms and privacy notice, and asks for consent before exposure. Gozar then creates an installation-owned key for the `tunnl-gg` relay; Dalan does not pass your SSH keys. The relay terminates TLS and can see the connector URL and traffic. Keep private work out of the demo. A temporary demo link can change or stop without warning; the three-hour trial limit is not an availability promise. Use `--route tailscale` to require Tailscale without a relay fallback. The loopback recipe below creates no public route.
8
+
9
+ <a id="owner-and-requester-setup"></a>
10
+
11
+ ## Owner and requester setup
12
+
13
+ 1. Install Dalan and put `dalan` on your PATH.
14
+
15
+ ```sh
16
+ node --version
17
+ npm install -g @tnunamak/dalan
18
+ dalan --version
19
+ ```
20
+
21
+ **Check:** Node prints `v24` or higher, and npm finishes without an error. The server in step 3 starts Node with a changed `HOME`, so use a Node executable that works then; a version-manager shim can depend on your usual home directory.
22
+
23
+ 2. Choose a new, private bridge home. It must not exist yet and must not be a `try` home (`init` refuses an existing profile). Export it in every shell that you use, including the server shell; `dalan` reads it as the bridge's home. Keep paths short and free of spaces.
24
+
25
+ ```sh
26
+ export DALAN_HOME="$HOME/.local/share/dalan-manual-trial"
27
+ ```
28
+
29
+ If you forget this in a new shell, `dalan` stops with `DALAN_HOME is not set` while the default trial home exists. Without a trial home, it uses your normal home, and `dalan status --json` then shows an unexpected bridge or fails. In both cases, export the variable again.
30
+
31
+ 3. Create the worker profile and start the bridge on loopback with built-in OAuth. The listener binds only `127.0.0.1`, and every MCP call still needs an approved OAuth token.
32
+
33
+ ```sh
34
+ export DALAN_LOOPBACK=1 DALAN_AUTH_MODE=builtin DALAN_PORT=8799
35
+ dalan init --worker local --public-url http://127.0.0.1:8799
36
+ HOME="$DALAN_HOME" DALAN_LOOPBACK=1 DALAN_AUTH_MODE=builtin DALAN_PORT=8799 node "$(npm root -g)/@tnunamak/dalan/src/server.mjs"
37
+ ```
38
+
39
+ **Check:** `init` reports a new worker profile for `local`, and the server prints `MCP listening on 127.0.0.1:8799` and keeps running. Leave this terminal open: closing it stops the bridge. If you plan a repository job, add `--enable-workspace` to the `init` command before creating the home, and add `DALAN_ENABLE_WORKSPACE=1` to the server command. Both the worker grant and the host flag are required; exact repository access is granted separately. If the port is taken, choose a free port and replace `8799` in the exported `DALAN_PORT`, the init public URL, and the server command. Use that same port in the worker's MCP URL.
40
+
41
+ 4. In a second shell, export the same `DALAN_HOME`, then check the bridge.
42
+
43
+ ```sh
44
+ dalan paths --json
45
+ dalan status --json
46
+ dalan doctor --json
47
+ ```
48
+
49
+ **Check:** `config_dir` is inside your bridge home, and status returns the queue state. Doctor may say that host checks are unavailable; the first job does not need them. A socket connection error means the server is not running or this shell uses another home. (`DALAN_PORT` sets the MCP listener port, not the admin socket, which is derived from the home.)
50
+
51
+ <a id="worker-setup"></a>
52
+
53
+ ## Worker setup
54
+
55
+ 1. **Allow the client's callback and open a pairing window**, both before you add the connection in the client. Find your client's callback URI, then allow the narrowest pattern for it: its exact host and path. For example, Codex CLI uses `http://127.0.0.1/callback` and Claude Code uses `http://localhost/callback`.
56
+
57
+ ```sh
58
+ dalan connect allow-callback 'CALLBACK_PATTERN'
59
+ dalan connect start --worker local
60
+ ```
61
+
62
+ The [callback pattern rules](setup-reference.md#callback-patterns) list what a pattern may contain and what it matches.
63
+
64
+ **Check:** `dalan connect pending` shows an open window for `local`. The window stays open for 10 minutes (`--minutes N` changes it); if it reports `No pairing window is open`, run `dalan connect start --worker local` again.
65
+
66
+ 2. **Add the connection in the client**, on the same computer. The MCP URL is `http://127.0.0.1:8799/SECRET/mcp`, where `SECRET` is the `BRIDGE_PATH_SECRET` value in `$DALAN_HOME/.config/dalan/env` (on an older, unmigrated home: `$DALAN_HOME/.config/dot-bridge/env`). Keep the URL private. Choose OAuth authentication. Codex CLI starts the sign-in as soon as you add the connection; the [Codex recipe](worker-clients.md#native-cli-worker-codex-cli) shows the order.
67
+
68
+ 3. **Approve the sign-in.** Start the sign-in in the client and keep the browser page with the pairing code open. In the owner shell, inspect the pending attempt, then approve it. A client on this computer with a loopback callback is a native client; its approval needs `--confirm-redirect` with the exact redirect that `pending` shows.
69
+
70
+ ```sh
71
+ dalan connect pending
72
+ dalan connect approve CODE --worker local --confirm-redirect REDIRECT
73
+ ```
74
+
75
+ For a hosted client with an HTTPS callback, leave out `--confirm-redirect` (the command refuses it there):
76
+
77
+ ```sh
78
+ dalan connect approve CODE --worker local
79
+ ```
80
+
81
+ Before you approve, compare the code with the browser page and check the redirect. `pending` shows the MCP URL with the secret hidden as `<secret>`; check its scheme, host, port and the `/mcp` ending. Expect the scopes `dalan.read dalan.work`. The older names `dot-bridge.read dot-bridge.work` give the same access. Dalan also accepts `openid` and two optional integration scopes, `t3.read` and `t3.write`; in this version those two give no extra access, but do not approve a scope that you did not expect. The client name comes from the client and proves nothing about its identity, and `--confirm-redirect` only catches a typo.
82
+
83
+ For a native client, each attempt has its own code: approving one code approves no other. For a hosted client, only the newest attempt can be approved. When the worker is on another person's computer, they read the code from their browser page and tell you over a trusted channel.
84
+
85
+ **Check:** the browser returns to the client, which now lists Dalan's tools, including `list_pending` and `claim`.
86
+
87
+ <a id="submit-finish-and-read-the-result"></a>
88
+
89
+ ## Submit, finish and read the result
90
+
91
+ Any shell or coding agent that can run `dalan` can be the requester. Run these commands with `dalan` on your PATH and `DALAN_HOME` set to the bridge home.
92
+
93
+ 1. Make a request ID with `node -e "console.log(require('node:crypto').randomUUID())"`, then save this job as `first-job.json` with that ID. Never reuse another job's ID, and keep the file for retries.
94
+
95
+ ```json
96
+ {
97
+ "schema_version": 1,
98
+ "request_id": "req_<stable UUID>",
99
+ "brief": "Report the exact phrase: bridge first report. Do not read files, run commands or call external services.",
100
+ "inputs": [],
101
+ "expected_output": "Text report containing: bridge first report.",
102
+ "execution_scope": "read-only"
103
+ }
104
+ ```
105
+
106
+ ```sh
107
+ dalan submit --worker local --execution none --deliver none --file first-job.json --json
108
+ ```
109
+
110
+ **Check:** the response contains your `request_id`; use it as `REQUEST_ID` below. If the response is lost, submit the same file with the same options again: the bridge recognizes the same job.
111
+
112
+ 2. In the worker client, send this prompt with your request ID:
113
+
114
+ > Request REQUEST_ID is your only job: claim it with Dalan, do what its brief asks, report progress and finish it with the claim_id. Stop if it is missing or cancelled. Claim no other job.
115
+
116
+ The worker calls `list_pending`, `claim`, `progress` and `finish`.
117
+
118
+ 3. Wait for the result and read the report.
119
+
120
+ ```sh
121
+ dalan wait REQUEST_ID
122
+ dalan get REQUEST_ID
123
+ ```
124
+
125
+ **Check:** the job is finished and its report contains `bridge first report`. If nothing happens, the job is only queued: send the prompt in step 2. If `wait` times out, inspect the job with `get` and ask the worker to check Dalan again.
126
+
127
+ To find results later, for example after a restart, run `dalan inbox --all --json`. It covers the last 72 hours; add `--since` for older results. In a fresh shell with no session ID, plain `dalan inbox` lists every receipt in this bridge home. A resumed agent can have a different session label from its earlier one: use the saved label with `--producer ID`, or `--all` to list every receipt.
128
+
129
+ 4. Review the report and record your decision.
130
+
131
+ ```sh
132
+ dalan decide REQUEST_ID accepted
133
+ ```
134
+
135
+ **Check:** the response records `accepted`. Review a real report or patch before you accept or apply it. When you are done, press Ctrl-C in the server terminal. Keep the bridge home if you need its receipts or connection again.
@@ -0,0 +1,97 @@
1
+ # Mirror fetch ownership
2
+
3
+ Dalan keeps a local Git mirror, a reusable repository cache, so jobs can fetch pinned commits and create working copies without downloading every object again. Those working copies may still read objects from the mirror. Keep the mirror complete and do not prune objects while any working copy depends on them.
4
+
5
+ `prepareGithubRepo` runs fetches through `src/mirror-fetch.mjs`. The synchronous
6
+ API stays in place; a Node child supervises a detached Git process group.
7
+ Python 3.8+ must be on the bridge service PATH as `python3`; install Python 3
8
+ and update that service's PATH if the prerequisite diagnostic appears. The
9
+ supervisor checks `python3` before launching the guardian, independently of host-check execution. This prerequisite applies whenever mirror fetching runs, before creating a mutex, receipt, or disposable attempt.
10
+ No compiler is required. Both platforms use `flock` and a fetch-specific Python group anchor. Linux additionally uses `PR_SET_CHILD_SUBREAPER`; macOS uses
11
+ `kqueue NOTE_EXIT`. A normal fetch has a fixed 15-minute deadline. A corruption error permits one
12
+ `--refetch` with the same deadline (at most two network attempts). The deadline replaces the earlier 120-second normal and 300-second repair limits and needs no operator setting. It bounds an attempt; it does not promise that every repository can transfer in 15 minutes.
13
+
14
+ Each mirror has a permanent sibling `.fetch-mutex` inode. A nonblocking kernel
15
+ lock excludes concurrent fetches. The inode is never unlinked or replaced. A
16
+ versioned `.fetch-owner.json` receipt is atomically published and synced before
17
+ creating the disposable `.fetch-lock` directory and its private bare repository.
18
+ The directory's `owner.json` is diagnostic only. Existing refs and an object alternate let
19
+ the attempt negotiate incrementally against the full mirror. The remote URL is
20
+ passed only to Git, never written to config. The attempt fetches full objects.
21
+ On success, complete loose objects and finalized packs are linked into the mirror
22
+ before one compare-and-swap ref transaction publishes the fetched refs. A full-ref fetch also prunes
23
+ deleted refs; a pinned-revision fetch keeps existing refs and updates only the requested pins. Existing object files are never removed or replaced. A publication
24
+ failure can leave extra finalized objects but cannot make refs depend on the
25
+ attempt directory.
26
+
27
+ On Linux, the guardian keeps the kernel
28
+ lock while Node runs. Node and its Git commands also inherit the lock descriptor.
29
+ If Node is killed, the guardian adopts and kills orphan descendants, reaping them
30
+ before releasing ownership. A new fetch can then remove the old private attempt
31
+ under the same kernel lock and retry automatically. The guardian signals only its own unreaped children, whose PIDs
32
+ cannot be reused while it owns them. A host restart releases kernel locks; the
33
+ next fetch cleans the owned attempt without inspecting old PID or boot metadata.
34
+
35
+ On both platforms, each fetch runs in a separate group whose Python anchor stays alive
36
+ until its final group-wide SIGKILL. Only Node holds the write end of the anchor's
37
+ control pipe; Git receives `/dev/null` for stdin. Pipe EOF after Node dies, the
38
+ attempt deadline, or completion of Git makes the anchor kill its own group while
39
+ its live PID still pins the PGID. This also works when Node and the guardian die
40
+ together. The permanent sibling `.fetch-writers` lock is held by the anchor and
41
+ inherited by actual Git as stderr. Node must acquire this independent barrier
42
+ before cleanup; a new guardian checks it before removing a crashed attempt.
43
+ These locks are never unlinked. The fetch error is the bounded stderr tail.
44
+
45
+ The macOS guardian also gives Node a private session for synchronous Git commands.
46
+ It observes Node's exit with `kqueue NOTE_EXIT`, signals the group before reaping
47
+ its direct child, and waits for the fetch writer barrier. This prevents a reused
48
+ PGID from being signaled. Darwin can return EPERM for an all-zombie group; that
49
+ signal is best effort. Only the inherited kernel locks, including descriptors propagated through trusted Git, authorize cleanup; neither a process listing, a stored PID nor an age does. An escaped or unsignalable
50
+ writer can delay recovery; it cannot authorize deleting a live private attempt.
51
+
52
+ A crash before receipt publication creates no attempt, so initialization can be
53
+ repeated. Once the receipt is durable, an interrupted attempt can be removed on
54
+ the next acquisition, including crashes before refs or after refs but before
55
+ cleanup. Missing or corrupt durable receipts with an existing attempt fail safe
56
+ with a bounded diagnostic and leave that attempt untouched. Legacy lock directories
57
+ without the new ownership receipt are also left untouched. Ordinary crashes under
58
+ this protocol need no operator recovery. If a child is stuck in unkillable kernel
59
+ I/O, the guardian reports delayed settlement and holds the lock until it settles;
60
+ there is no universal hard wall-clock bound for that case.
61
+
62
+ Before each fetch, and under the same kernel lock, the attempt checks the object of
63
+ every mirror ref. A ref whose object is missing makes Git fail the fetch's
64
+ connectivity check with `bad object refs/...`, so every later fetch of that
65
+ repository fails. The repair deletes only direct refs with missing objects, with an
66
+ expected-old-value check. Symbolic refs under `refs/` are left untouched by the
67
+ repair; this does not redesign alias staging or publication. Repair stderr logs
68
+ the deleted count, at most the first 20 `mirror repair: deleted missing-object ref "REF"`
69
+ lines, and `... and N more` when names were omitted. It then fetches as usual, with the same single
70
+ `--refetch` fallback. A pin that the job needs is fetched and verified; a pin the
71
+ source cannot supply is still refused. Refs whose objects exist are not changed.
72
+
73
+ No recovery deletes preexisting mirror `tmp_pack_*` files. An unrelated fetch
74
+ writing in the mirror cannot lose its temporary packs to this cleanup. Other
75
+ bridge fetches fail immediately while the kernel lock is held. External ref
76
+ writers are protected by expected-old-value checks.
77
+
78
+ Fetch removes an existing `origin` remote from the mirror and sets `gc.auto=0`,
79
+ `maintenance.auto=false`, and `gc.autoDetach=false`. These are the only intended mirror config changes. Fetch also passes these settings explicitly, uses `--no-auto-maintenance` and leaves host and global config alone. Explicit manual GC or separately scheduled maintenance remains an owner
80
+ operation and must respect reference consumers.
81
+
82
+ `scripts/mirror-fetch-test.mjs` uses a local source and a genuine Git `index-pack` fed an incomplete real pack. A controlled Git wrapper interrupts that writer after it creates its own temporary pack, or leaves it blocked until timeout; the test never manufactures an attempt pack. Its assertions cover:
83
+
84
+ - successful, no-op and incremental fetches, finalized-pack retention, reference-consumer reads, corruption-fallback failure, process settlement, config retention and live lock refusal;
85
+ - automatic recovery when the supervisor is killed with a live `index-pack`, and continued protection of the orphan attempt when its guardian is stopped first;
86
+ - publication-boundary crashes (objects precede refs, cleanup is repeatable), receipt corruption, missing receipts, a stable lock inode and stale PID or boot metadata;
87
+ - a joint kill of guardian and Node while an actual `index-pack` lives: the test checks refusal and retained attempt data, then recovery after writer settlement. On both platforms the resumed independent anchor detects EOF and settles the group. Both death orders and near-simultaneous deaths run;
88
+ - a probe showing that actual Git alone retains both descriptors once every supervisor and wrapper is excluded as a holder;
89
+ - the missing-Python diagnostic, checked before any disposable state appears.
90
+
91
+ The fixture transport can close its own stream after a fixed delay. The test does not kill the writer, delete a lock or signal a recorded product receipt.
92
+
93
+ `scripts/mirror-dangling-refs-test.mjs` builds a mirror with dangling pin, branch and pull-request refs and a missing needed pin. It shows that an ordinary fetch fails with `bad object`, that the repair logs and deletes only the dangling refs, that the needed pin is restored and verified, and that an unfetchable pin is refused. `scripts/mirror-repair-test.mjs` tests real missing-blob repair with a live worktree.
94
+
95
+ These tests prove local object and process ownership behavior. They do not
96
+ measure transfer time for a large GitHub repository, test power loss durability,
97
+ or prove containment of a hostile executable that escapes its process group.