@tnunamak/dalan 0.0.0-stage → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +172 -0
- package/CONTRIBUTING.md +26 -0
- package/LICENSE +204 -0
- package/PROTOCOL.md +339 -0
- package/README.md +348 -2
- package/SECURITY.md +30 -0
- package/bin/dalan.mjs +38 -0
- package/bin/dot-acp-agent.mjs +377 -0
- package/bin/dot-alert.mjs +9 -0
- package/bin/dot-deadman.mjs +82 -0
- package/bin/dot-heartbeat.mjs +29 -0
- package/bin/dot-pr-reviewer.mjs +32 -0
- package/bin/dot-worker.mjs +755 -0
- package/docs/chatgpt-worker-onboarding.md +112 -0
- package/docs/claude-worker-onboarding.md +113 -0
- package/docs/connect-chatgpt.md +78 -0
- package/docs/connection-longevity.md +37 -0
- package/docs/dalan-upgrade.md +242 -0
- package/docs/deadman.md +59 -0
- package/docs/dot-pr-reviewer.config.example.json +9 -0
- package/docs/durability-audit.md +27 -0
- package/docs/keycloak-client-chatgpt-dot-bridge.json +59 -0
- package/docs/keycloak-oauth-setup.md +30 -0
- package/docs/local-agent-mcp.md +39 -0
- package/docs/manual-setup.md +135 -0
- package/docs/mirror-fetch.md +98 -0
- package/docs/operations.md +751 -0
- package/docs/operator-duties.md +68 -0
- package/docs/owner-integrator.md +27 -0
- package/docs/portable-auth-profile.md +109 -0
- package/docs/pr-head-reviewer.md +54 -0
- package/docs/pr-preflight.md +26 -0
- package/docs/pull-workers.md +97 -0
- package/docs/redaction.md +27 -0
- package/docs/service-setup.md +166 -0
- package/docs/setup-reference.md +80 -0
- package/docs/t3-connector-icon.png +0 -0
- package/docs/t3-integration.md +49 -0
- package/docs/t3-result-retry-delivery.md +41 -0
- package/docs/t3-reverse-control.md +107 -0
- package/docs/usage.md +439 -0
- package/docs/worker-clients.md +285 -0
- package/integrations/t3/acp-kit/src/capability.mjs +25 -0
- package/integrations/t3/acp-kit/src/errors.mjs +13 -0
- package/integrations/t3/acp-kit/src/index.mjs +5 -0
- package/integrations/t3/acp-kit/src/lock.mjs +155 -0
- package/integrations/t3/acp-kit/src/session-store.mjs +36 -0
- package/integrations/t3/acp-kit/src/t3-envelope.mjs +62 -0
- package/package.json +65 -4
- package/packages/job-core/README.md +18 -0
- package/packages/job-core/index.mjs +2 -0
- package/packages/job-core/package.json +8 -0
- package/packages/job-core/protocol/canonical.mjs +11 -0
- package/packages/job-core/protocol/v0/command.schema.json +1154 -0
- package/packages/job-core/protocol/v0/event.schema.json +77 -0
- package/packages/job-core/protocol/v0/reply.schema.json +59 -0
- package/packages/job-core/transitions.mjs +25 -0
- package/scripts/daily-selfcheck.mjs +135 -0
- package/scripts/lib/expose-tailscale.mjs +408 -0
- package/scripts/live-trial/common.mjs +272 -0
- package/scripts/monitor-targets.mjs +44 -0
- package/scripts/upgrade-drain.mjs +39 -0
- package/scripts/worker-bridge-setup.mjs +925 -0
- package/src/ack-ledger.mjs +37 -0
- package/src/acp-bridge.mjs +412 -0
- package/src/acp-context.mjs +138 -0
- package/src/admin-socket.mjs +14 -0
- package/src/alerts.mjs +147 -0
- package/src/artifact-journal.mjs +75 -0
- package/src/as-files.mjs +347 -0
- package/src/as-store.mjs +456 -0
- package/src/as.mjs +497 -0
- package/src/auth.mjs +166 -0
- package/src/builtin-http.mjs +22 -0
- package/src/check-coverage.mjs +38 -0
- package/src/check-lint.mjs +88 -0
- package/src/check-readiness.mjs +112 -0
- package/src/check-response.mjs +19 -0
- package/src/claim-command-ledger.mjs +51 -0
- package/src/cli-help.mjs +172 -0
- package/src/cli-name.mjs +16 -0
- package/src/connect-cli.mjs +126 -0
- package/src/consumers.mjs +61 -0
- package/src/deadman.mjs +329 -0
- package/src/delivery.mjs +19 -0
- package/src/demo-worker.mjs +150 -0
- package/src/destinations/index.mjs +23 -0
- package/src/destinations/none.mjs +15 -0
- package/src/destinations/t3.mjs +109 -0
- package/src/diagnostic.mjs +78 -0
- package/src/docs-url.mjs +9 -0
- package/src/drain-runner.mjs +9 -0
- package/src/drained-slot.mjs +53 -0
- package/src/drained.mjs +40 -0
- package/src/durable-waiters.mjs +236 -0
- package/src/env.mjs +19 -0
- package/src/execution.mjs +112 -0
- package/src/failure-type.mjs +28 -0
- package/src/get-summary.mjs +32 -0
- package/src/git-env.mjs +15 -0
- package/src/host-budget-receipts.mjs +154 -0
- package/src/host-budget-seccomp.py +33 -0
- package/src/host-budget-service.mjs +54 -0
- package/src/host-budget-stop.mjs +26 -0
- package/src/host-budget-storage.py +259 -0
- package/src/host-budget.mjs +149 -0
- package/src/host-cgroup.mjs +23 -0
- package/src/host-check-allowlist.mjs +42 -0
- package/src/host-execution-policy.mjs +38 -0
- package/src/host-health.mjs +34 -0
- package/src/host-stop-reverify.mjs +44 -0
- package/src/inbox.mjs +55 -0
- package/src/integrator.mjs +322 -0
- package/src/job-retention.mjs +69 -0
- package/src/legacy-names.mjs +8 -0
- package/src/lifecycle.mjs +291 -0
- package/src/limits.mjs +31 -0
- package/src/loopback.mjs +9 -0
- package/src/mcp-outcome.mjs +70 -0
- package/src/mcp-stdio.mjs +191 -0
- package/src/mirror-fetch-lock.py +164 -0
- package/src/mirror-fetch.mjs +174 -0
- package/src/notify-ledger.mjs +82 -0
- package/src/objectives.mjs +129 -0
- package/src/owner-report-artifact.mjs +66 -0
- package/src/patch-apply.mjs +84 -0
- package/src/path-syntax.mjs +16 -0
- package/src/paths.mjs +67 -0
- package/src/pr-head-reviewer.mjs +596 -0
- package/src/pr-preflight.mjs +51 -0
- package/src/prepared-node-modules.mjs +129 -0
- package/src/projects.mjs +480 -0
- package/src/protocol-artifact-commands.mjs +52 -0
- package/src/protocol-delivery-driver.mjs +167 -0
- package/src/protocol-finish.mjs +100 -0
- package/src/protocol-owner-command.mjs +35 -0
- package/src/protocol-owner-mutations.mjs +22 -0
- package/src/protocol-owner-waiters.mjs +67 -0
- package/src/protocol-retention.mjs +52 -0
- package/src/protocol-services.mjs +61 -0
- package/src/protocol-stop-observer.mjs +131 -0
- package/src/publish-plan.mjs +245 -0
- package/src/redaction.mjs +763 -0
- package/src/rejections.mjs +18 -0
- package/src/request-log.mjs +102 -0
- package/src/restore-check.mjs +90 -0
- package/src/result-binding.mjs +65 -0
- package/src/runtime-check.mjs +13 -0
- package/src/sandbox-supervisor.mjs +105 -0
- package/src/schema-subset.mjs +186 -0
- package/src/scopes.mjs +15 -0
- package/src/server.mjs +1340 -0
- package/src/shutdown-signal.mjs +12 -0
- package/src/signal-sandbox-processes.py +56 -0
- package/src/signal.mjs +119 -0
- package/src/status-evidence.mjs +47 -0
- package/src/status-summary.mjs +54 -0
- package/src/store.mjs +3057 -0
- package/src/submission-policy.mjs +623 -0
- package/src/subscription-storage.mjs +64 -0
- package/src/t3-audit.mjs +120 -0
- package/src/t3-control.mjs +102 -0
- package/src/t3-transport.mjs +158 -0
- package/src/t3.mjs +209 -0
- package/src/terminal-safe.mjs +19 -0
- package/src/tool-registry.mjs +451 -0
- package/src/try-command.mjs +11 -0
- package/src/try.mjs +589 -0
- package/src/webhooks.mjs +86 -0
- package/src/work-order.mjs +265 -0
- package/src/worker-instructions.mjs +26 -0
- package/src/worker-prompt.mjs +4 -0
- package/src/workers.mjs +622 -0
- package/src/workspace.mjs +1058 -0
- package/systemd/dot-bridge-heartbeat.service +18 -0
- package/systemd/dot-bridge-heartbeat.timer +10 -0
- package/systemd/dot-bridge-selfcheck.service +12 -0
- package/systemd/dot-bridge-selfcheck.timer +11 -0
- package/systemd/dot-bridge.service +17 -0
- package/systemd/dot-deadman.service +30 -0
- package/systemd/dot-pr-reviewer.service +11 -0
- package/systemd/dot-pr-reviewer.timer +10 -0
|
@@ -0,0 +1,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 a [checkout](../README.md#from-source), two shells and a worker client with OAuth.
|
|
6
|
+
|
|
7
|
+
<a id="owner-and-requester-setup"></a>
|
|
8
|
+
|
|
9
|
+
## Owner and requester setup
|
|
10
|
+
|
|
11
|
+
1. Clone and install Dalan, and put `dalan` on your PATH.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
git clone https://github.com/tnunamak/dalan.git
|
|
15
|
+
cd dalan
|
|
16
|
+
node --version
|
|
17
|
+
npm ci
|
|
18
|
+
npm link
|
|
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 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 `DALAN_ENABLE_WORKSPACE=1` to the server command now to save a restart. If the port is taken, choose another free port in both commands.
|
|
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,98 @@
|
|
|
1
|
+
# Mirror fetch ownership
|
|
2
|
+
|
|
3
|
+
Mirrors hold full Git objects for live worktrees and reference clones. They must
|
|
4
|
+
not use partial clones or prune objects that consumers still need.
|
|
5
|
+
|
|
6
|
+
`prepareGithubRepo` runs fetches through `src/mirror-fetch.mjs`. The synchronous
|
|
7
|
+
API stays in place; a Node child supervises a detached Git process group.
|
|
8
|
+
Python 3.8+ must be on the bridge service PATH as `python3`; install Python 3
|
|
9
|
+
and update that service's PATH if the prerequisite diagnostic appears. The
|
|
10
|
+
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.
|
|
11
|
+
No compiler is required. Both platforms use `flock` and a fetch-specific Python group anchor. Linux additionally uses `PR_SET_CHILD_SUBREAPER`; macOS uses
|
|
12
|
+
`kqueue NOTE_EXIT`. A normal fetch has a fixed 15-minute deadline. A corruption error permits one
|
|
13
|
+
`--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.
|
|
14
|
+
|
|
15
|
+
Each mirror has a permanent sibling `.fetch-mutex` inode. A nonblocking kernel
|
|
16
|
+
lock excludes concurrent fetches. The inode is never unlinked or replaced. A
|
|
17
|
+
versioned `.fetch-owner.json` receipt is atomically published and synced before
|
|
18
|
+
creating the disposable `.fetch-lock` directory and its private bare repository.
|
|
19
|
+
The directory's `owner.json` is diagnostic only. Existing refs and an object alternate let
|
|
20
|
+
the attempt negotiate incrementally against the full mirror. The remote URL is
|
|
21
|
+
passed only to Git, never written to config. The attempt fetches full objects.
|
|
22
|
+
On success, complete loose objects and finalized packs are linked into the mirror
|
|
23
|
+
before one compare-and-swap ref transaction publishes the fetched refs. A full-ref fetch also prunes
|
|
24
|
+
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
|
|
25
|
+
failure can leave extra finalized objects but cannot make refs depend on the
|
|
26
|
+
attempt directory.
|
|
27
|
+
|
|
28
|
+
On Linux, the guardian keeps the kernel
|
|
29
|
+
lock while Node runs. Node and its Git commands also inherit the lock descriptor.
|
|
30
|
+
If Node is killed, the guardian adopts and kills orphan descendants, reaping them
|
|
31
|
+
before releasing ownership. A new fetch can then remove the old private attempt
|
|
32
|
+
under the same kernel lock and retry automatically. The guardian signals only its own unreaped children, whose PIDs
|
|
33
|
+
cannot be reused while it owns them. A host restart releases kernel locks; the
|
|
34
|
+
next fetch cleans the owned attempt without inspecting old PID or boot metadata.
|
|
35
|
+
|
|
36
|
+
On both platforms, each fetch runs in a separate group whose Python anchor stays alive
|
|
37
|
+
until its final group-wide SIGKILL. Only Node holds the write end of the anchor's
|
|
38
|
+
control pipe; Git receives `/dev/null` for stdin. Pipe EOF after Node dies, the
|
|
39
|
+
attempt deadline, or completion of Git makes the anchor kill its own group while
|
|
40
|
+
its live PID still pins the PGID. This also works when Node and the guardian die
|
|
41
|
+
together. The permanent sibling `.fetch-writers` lock is held by the anchor and
|
|
42
|
+
inherited by actual Git as stderr. Node must acquire this independent barrier
|
|
43
|
+
before cleanup; a new guardian checks it before removing a crashed attempt.
|
|
44
|
+
These locks are never unlinked. The fetch error is the bounded stderr tail.
|
|
45
|
+
|
|
46
|
+
The macOS guardian also gives Node a private session for synchronous Git commands.
|
|
47
|
+
It observes Node's exit with `kqueue NOTE_EXIT`, signals the group before reaping
|
|
48
|
+
its direct child, and waits for the fetch writer barrier. This prevents a reused
|
|
49
|
+
PGID from being signaled. Darwin can return EPERM for an all-zombie group; that
|
|
50
|
+
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
|
|
51
|
+
writer can delay recovery; it cannot authorize deleting a live private attempt.
|
|
52
|
+
|
|
53
|
+
A crash before receipt publication creates no attempt, so initialization can be
|
|
54
|
+
repeated. Once the receipt is durable, an interrupted attempt can be removed on
|
|
55
|
+
the next acquisition, including crashes before refs or after refs but before
|
|
56
|
+
cleanup. Missing or corrupt durable receipts with an existing attempt fail safe
|
|
57
|
+
with a bounded diagnostic and leave that attempt untouched. Legacy lock directories
|
|
58
|
+
without the new ownership receipt are also left untouched. Ordinary crashes under
|
|
59
|
+
this protocol need no operator recovery. If a child is stuck in unkillable kernel
|
|
60
|
+
I/O, the guardian reports delayed settlement and holds the lock until it settles;
|
|
61
|
+
there is no universal hard wall-clock bound for that case.
|
|
62
|
+
|
|
63
|
+
Before each fetch, and under the same kernel lock, the attempt checks the object of
|
|
64
|
+
every mirror ref. A ref whose object is missing makes Git fail the fetch's
|
|
65
|
+
connectivity check with `bad object refs/...`, so every later fetch of that
|
|
66
|
+
repository fails. The repair deletes only direct refs with missing objects, with an
|
|
67
|
+
expected-old-value check. Symbolic refs under `refs/` are left untouched by the
|
|
68
|
+
repair; this does not redesign alias staging or publication. Repair stderr logs
|
|
69
|
+
the deleted count, at most the first 20 `mirror repair: deleted missing-object ref "REF"`
|
|
70
|
+
lines, and `... and N more` when names were omitted. It then fetches as usual, with the same single
|
|
71
|
+
`--refetch` fallback. A pin that the job needs is fetched and verified; a pin the
|
|
72
|
+
source cannot supply is still refused. Refs whose objects exist are not changed.
|
|
73
|
+
|
|
74
|
+
No recovery deletes preexisting mirror `tmp_pack_*` files. An unrelated fetch
|
|
75
|
+
writing in the mirror cannot lose its temporary packs to this cleanup. Other
|
|
76
|
+
bridge fetches fail immediately while the kernel lock is held. External ref
|
|
77
|
+
writers are protected by expected-old-value checks.
|
|
78
|
+
|
|
79
|
+
Fetch removes an existing `origin` remote from the mirror and sets `gc.auto=0`,
|
|
80
|
+
`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
|
|
81
|
+
operation and must respect reference consumers.
|
|
82
|
+
|
|
83
|
+
`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:
|
|
84
|
+
|
|
85
|
+
- successful, no-op and incremental fetches, finalized-pack retention, reference-consumer reads, corruption-fallback failure, process settlement, config retention and live lock refusal;
|
|
86
|
+
- 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;
|
|
87
|
+
- publication-boundary crashes (objects precede refs, cleanup is repeatable), receipt corruption, missing receipts, a stable lock inode and stale PID or boot metadata;
|
|
88
|
+
- 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;
|
|
89
|
+
- a probe showing that actual Git alone retains both descriptors once every supervisor and wrapper is excluded as a holder;
|
|
90
|
+
- the missing-Python diagnostic, checked before any disposable state appears.
|
|
91
|
+
|
|
92
|
+
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.
|
|
93
|
+
|
|
94
|
+
`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.
|
|
95
|
+
|
|
96
|
+
These tests prove local object and process ownership behavior. They do not
|
|
97
|
+
measure transfer time for a large GitHub repository, test power loss durability,
|
|
98
|
+
or prove containment of a hostile executable that escapes its process group.
|