Skip to content

feat(sandbox): Go sandbox daemon, dormant behind SANDBOX_DAEMON_IMPL - #5484

Merged
pedrofrxncx merged 17 commits into
mainfrom
wt/daemon-go
Jul 31, 2026
Merged

pedrofrxncx merged 17 commits into
mainfrom
wt/daemon-go

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 31, 2026 •

Copy link
Copy Markdown
Collaborator

Ports the sandbox daemon to Go. Both daemons ship in the sandbox image;
SANDBOX_DAEMON_IMPL (default ts) picks one at container start, so this is
deployed nowhere and enabled nowhere
— the switch is env, not the image CMD,
because a CMD change is a rebuild and a rebuild is not a rollback.

Why

The bug class that pages us is a blocked single-threaded event loop starving the
daemon's HTTP health probe, which Studio reads as dead and tears the sandbox
down — discarding every uncommitted change (CONTRIBUTING.md rule #1). Measured
under a git status loop over 4000 dirty files, against Studio's 500ms probe
budget:

p50 p95 worst
Go 0ms 0ms 1ms
TS 22ms 60ms 186ms

What's proven

  • Conformance suite passes on both implementations. daemon.*e2e*.test.ts is
    black-box HTTP/SSE — it imports no daemon source, so DAEMON_E2E_CMD points it
    at either binary and nothing else changes. CI enforces both (daemon-e2e,
    daemon-e2e-go incl. go vet + go test -race), plus docker-smoke, which
    builds the image and smokes it twice: variable unset (must land on TS) and
    SANDBOX_DAEMON_IMPL=go.
  • Dependency telemetry is byte-identical to the TS daemon (log lines, not OTLP —
    a sandbox pod's egress is locked to 53/443).
  • Golden node_modules cache L1 (reflink), org-fs links, the file watcher, the
    tools-catalog coalescer, the harness-runner bridge, protected-branch guard,
    SSRF allowlist, decofile validation — each covered by the suite.

TS daemon bugs fixed here too

Writing tests against the TS baseline first surfaced three real bugs in the TS
daemon; the suite has to pass on the daemon actually in production, so they're
fixed here:

  1. The decofile last-resort net never fired for a new block — git status --porcelain collapses an untracked dir into one ?? .deco/ entry, so an
    invalid block written by bash reached the user's branch and broke the site
    render.
  2. /write_from_url and /upload_to_url had no URL validation at all — TS
    daemon, Go daemon, and the apps/native Rust local-api. Both daemons now
    enforce the boot-env allowlist and re-check every redirect hop.
    apps/native's Rust implementation is still unguarded.
  3. A zero-dependency install emitted a stderr error instead of its telemetry, so
    the countable zero-dep line the denominator needs was never emitted.

Not in scope

Deleting packages/sandbox/daemon — post-soak, and the desktop path still needs
the TS bundle. Golden cache L2 (blocked on infrastructure) and org-fs mounting
(desktop-only) are deliberate won't-ports. /dispatch is dead code on a cluster
sandbox, so a cluster canary needs neither it nor the harness bridge. Rollout
(targeting, canary phases, alerts) ships in follow-up PRs.

Testing

bun run --cwd=packages/sandbox build:daemon
cd packages/sandbox/daemon-go && go build -o bin/daemon . && go test -race ./...
cd .. && DAEMON_E2E_CMD="$PWD/daemon-go/bin/daemon" bun test daemon/daemon.*e2e*.test.ts
bun test daemon/daemon.*e2e*.test.ts   # TS baseline

pedrofrxncx and others added 17 commits July 31, 2026 12:36
…e suites

Single Go module implementing the sandbox daemon wire contract behind
DAEMON_E2E_CMD: startup contract, bearer auth + CORS + dual prefix,
config store (classify/merge/validate), fs routes with safePath clamp,
bash pipe-mode with process groups, task manager (TTL reaper, log tees,
SSE streams), events broadcaster with replay + handshake order, setup
orchestrator (FIFO rank subsumption, clone triage, install), git routes
(status/diff/publish/discard/rebase), reverse proxy + WS splice, probe
debounce, dispatch transport with HARNESS_RUNNER_CMD seam. Golden cache
and org-fs mounting stubbed (deferred).
Table-driven classify precedence tests, deepMerge env null-deletes,
safePath clamp table + fuzz target, lifecycle phase exhaustiveness,
dispatch write-after-close guard (closed-controller storm invariant),
offload allowlist fail-closed, ring buffer tail, port-sniffer lock-in.
…ndent

resolveDaemonCmd defaulted `raw` to process.env.DAEMON_E2E_CMD, but a JS
default parameter also fires on an explicit `undefined` — so the test asserting
the no-override case could never express it, and the conformance suite failed on
its own harness self-check under ANY DAEMON_E2E_CMD run.

`raw` is now required; the env read moved to the single call site.
…153)

Catches the Go daemon up to main and closes the remaining conformance gaps, so
`DAEMON_E2E_CMD=<go binary> bun test daemon/daemon.*e2e*.test.ts` matches the TS
baseline exactly.

- POST /_sandbox/tools/sync + internal/toolscatalog: writes the endpoint file
  (dotfile, 0600) and one JSON Schema per tool under <repo>/.deco/tools/, prunes
  stale entries, git-excludes the dir. Carries a minimal MCP streamable-HTTP
  client (initialize -> notifications/initialized -> paged tools/list) rather
  than an MCP SDK — the daemon never calls tools itself, the in-workspace
  typegen CLI does, reading .endpoint.json.
- ws proxy: report an unreachable dev server as a WebSocket close (complete the
  101, then close 1011) instead of a 502 on the upgrade, which the client
  surfaces as a protocol error.
- publish: push --no-verify, so a repo's own pre-push hook can't fail or hang the
  shutdown sync out of its grace period.
- Because --no-verify skips the pre-push hook entirely, port the in-code
  protected-branch guard too: {main, master, origin's actual default}, refused
  before the commit so no stray commit lands either, mapped to 409. The hook's
  branch list is a data file, so an unusual ref name can't inject shell syntax.

README.md documents the DAEMON_E2E_CMD contract, the package<->TS map, the
invariants that must be carried, and — deliberately — the gap ledger plus what
the suite does NOT prove (harness dispatch is gate-only; org-fs mounting, golden
cache, decofile validation and six more behaviors are unported and untested).
It replaces the docs-design RFCs, which were never committed and are lost.
Gates G0-G6 with exit criteria rather than a task list, ordered so the
every-sandbox path (observability -> correctness -> boot cost -> real pod) lands
before dispatch, which is one route on the daemon and gates only its own
traffic.

Calls out the things the conformance suite structurally cannot catch: the
uid/gid drop Bun has silently ignored for years and Go will actually honor, the
single-missed-probe teardown, SIGTERM-publish inside the real grace period, and
the harness bridge (its e2e is gate-only).
… and dep telemetry

Conformance suite now 176/176 on both daemons. Three TS-daemon bugs found and
fixed along the way: the decofile net never fired for a new block, the URL
offload routes had no SSRF validation at all, and a zero-dep install logged an
error instead of its telemetry line.
…pl switch

Closes the remaining code-side gates from PRODUCTION-READINESS.md. The
conformance suite is 184/184 on both daemons, and CI now runs it against both
instead of the docs claiming it.

- G3 (L1): reflink golden node_modules cache — restore/publish keyed by
  (repo, pm, lockfile), publish held until the probe reports the dev server
  healthy, TTL + per-repo cap GC, dormant behind GOLDEN_CACHE_ENABLED. The e2e
  asserts the publish is never even ATTEMPTED on an unhealthy boot; asserting an
  empty store would pass on a non-CoW filesystem while the gate was broken.
- G4/G1: org-fs links for the cluster path — sidecar status gate, one-shot
  first-mount grace, repo/org link (git-excluded), per-run output/upload thread
  links. Mounting stays unported on purpose: a pod cannot mount (the sidecar
  does), and daemon-side mounting is the desktop path, which runs the TS bundle.
- G1: catalog re-sync on dispatch (coalesced per endpoint, 60s floor) and
  fsnotify-based change detection, so a file written through bash — i.e. by every
  CLI harness — surfaces as file-changed instead of waiting on the 3s poll. The
  e2e for it is control-tested: it fails with the watcher disabled.
- G4: probe-under-load e2e against Studio's real 500ms budget. Measured here,
  Go worst 1ms vs TS worst 186ms while git status runs over 4000 dirty files.
- G6: both daemons ship in the image; SANDBOX_DAEMON_IMPL (default ts) selects
  one at container start via an exec'd entrypoint, exposed as the chart's
  daemonImpl. Env, not CMD — a rebuild is not a rollback. CI smokes both.

Still needs a human: the harness-runner transport pick (the reading now argues
for the extraction branch's loopback HTTP — no HARNESS_RUNNER_CMD runner exists
in this repo at all), the real-pod session, and the canary + rollback drill.
…nner

Settles G5's transport (owner decision): the Go daemon now speaks the protocol
`wt/harness-runner-extraction` defines — spawn with HARNESS_RUNNER_MODE=1 and a
per-spawn token, parse HARNESS_RUNNER_READY, POST /run with that bearer, stream
NDJSON, cancel by aborting the request. The stdio spawner is deleted rather than
kept alongside it. That branch already ships the runner, its e2e, and a
protocol.ts whose docblock says it is the piece a non-TS daemon reimplements;
stdio had no runner in the repo at all, so picking it meant writing an untested
one and discarding tested code.

One shared runner, spawned on demand, never auto-respawned: a crash costs each
in-flight run one harness_crashed and the next dispatch spawns fresh, where a
respawn loop would turn one bad run into a storm. The daemon holds the runner's
stdin open and never writes to it, so the pipe closing is what tells the runner
this daemon died — including under SIGKILL. The HTTP client has no overall
timeout (a run streams for minutes); only the response headers are deadlined.

runner_test.go drives the bridge with the test binary re-executed as a fake
runner: frame integrity, reuse across runs, respawn after a mid-stream death,
cancelling one run without killing the runner, a runner that never reports ready,
and a missing binary. Suite still 184/184 on both daemons.

Still needed for a real run: merge wt/harness-runner-extraction so
HARNESS_RUNNER_CMD has something to point at.
Two findings drive the shape of it.

Harness dispatch is not used by cluster sandboxes: localDispatch is documented
as the only dispatch path for hosted harnesses, the cluster runs the harness in
the API process with no HTTP, and the only callers of the daemon's /dispatch are
the desktop link path and apps/native's e2e. So G5 does not gate this rollout —
it gates cloud-CLI, whenever that lands.

The per-sandbox opt-in cannot be a per-claim env var. SANDBOX_DAEMON_IMPL is read
at container start, and in warm-pool mode the operator rejects claim.spec.env
outright — so an env-based choice would force warmpool:"none" and a cold pod per
Go sandbox, confounding the boot comparison the canary exists to make. What is
per-claim is sandboxTemplateRef, so selection is by template: a second
SandboxTemplate + small warm pool in the SAME helm release (a second release
would mint a second sentinel Secret that Studio cannot authenticate against).

Control is three independent layers — a global env kill switch, a per-org flag
for who gets Go by default, and the SANDBOX_START prop for targeting one sandbox
— resolved prop → flag → ts, with the choice persisted per sandbox so pod
recovery cannot silently change implementation mid-life.
SPEC.md is now the single authoritative document — startup and wire contracts,
carried invariants, what is proven and by which test, what is deliberately not
ported and under what precondition, the targeted prod rollout, risks, and the
open actions that need a human. PRODUCTION-READINESS.md is deleted rather than
left beside it: two overlapping docs is how the last one ended up claiming
176/176 while the suite was at 184, and how the gap ledger kept listing work that
had already landed.

The gate names (G0-G6) are retired. A closed gate is just a row in the evidence
table; the ones still open are phases in the rollout section, where they are
actionable. README.md keeps only package orientation and points at the spec.
Two daemons ship in the same image behind SANDBOX_DAEMON_IMPL, so a pod's
log has to say which binary ran — without it the Go canary's panels are a
guess. Both daemons now emit an unconditional `impl=` boot line
(`impl=go` / `impl=ts`), greppable with one pattern.
…fers

CI, running on this branch for the first time, hung the SSRF test for 5s
instead of failing it. Two real bugs behind that:

1. write_from_url validated only the caller's URL and then used a plain
   fetch, whose default redirect:"follow" chases a 302 anywhere — so an
   allowed origin answering `302 -> https://169.254.169.254/...` walked the
   daemon into the cloud metadata endpoint. The Go daemon already did this
   correctly via urlallow.Client's CheckRedirect; the TS daemon, the one
   actually in production, did not. Both transfer routes now go through
   fetchAllowedUrl, which re-asserts the allowlist on every hop.
   upload_to_url uses maxRedirects: 0 — its body is a one-shot stream that
   could not be replayed to a second URL even if that URL were allowed.

2. The test asserted only "not 200", which a laptop satisfies by failing to
   connect to that address. It now asserts the rejection *reason*, so a
   daemon that follows the redirect cannot pass by hitting a closed port.

Also fixes the golden-cache clone probe, which cloned an empty directory:
copying no data blocks succeeds under `cp --reflink=always` even on ext4, so
CI picked the reflink cloner and then failed on the first real tree. The
probe writes a file, and the macOS clonefile arm is GOOS-gated rather than
probed (GNU cp also accepts -c, which would have made a plain copy report
itself as copy-on-write).

Verified: 184/184 on both daemons locally, go test -race clean.
…viors

The parity oracle asserts an EXACT failing-test set against local-api, so
every test this branch added for a behavior the Rust crate does not have
reads as a regression. 18 new, 1 vanished (the swappable-spawn-target
self-check now passes).

Derived from the run's own junit with the gate's own extractor rather than
transcribed, so the strings cannot drift.

The header comment now says what each pinned name IS, and separates the two
deliberate divergences (auth/CORS tightening, no-publish-on-close) from the
19 that are simply unported. Naming that split matters most for the 11
url-transfer SSRF entries: local-api's write_from_url / upload_to_url have
no allowlist and follow redirects, which is a real hole in the desktop app,
pinned only to keep this a set match — not sanctioned.
…ng tree

Two changes to the Go daemon, no change to its wire contract.

Leaner routing. A 130-line if/switch ladder, three regexes, a prefix matcher
and a stringly-typed `map[string]http.HandlerFunc` are replaced by declarative
`http.ServeMux` registration (Go 1.22 method+wildcard patterns).
`taskIdFrom` and exec's `strings.Index` arithmetic become `r.PathValue`. The
routing table is now the single place that knows which routes are
authenticated, which get org-fs links, and which mutate the tree.

The mux deliberately covers only `/_sandbox` and `/_decopilot_vm`: ServeMux
cleans and 301-redirects paths, which is right for our own API and wrong for
whatever the tenant's dev server serves, so the proxy stays off it. The
unauthenticated catch-all keeps returning 401 rather than 404 so routes cannot
be enumerated without a token.

Also dropped: a dead `ChunkBroadcaster` interface, a dead `_ = truncated`, an
anonymous `interface{ Read(...) }` that was `io.Reader`, hand-rolled image
magic-byte sniffing (`http.DetectContentType`), and a provably-empty loop in
`orchestrator.enqueue` — the early return above it guaranteed `kept` was always
empty, so the queue only ever holds one step.

Serialize the working tree. The daemon had no serialization at all, and `/edit`
is read-modify-write: concurrent edits to one path lose updates. The daemon is
the only component that sees every writer of a tree, so the lock belongs here.
`internal/worktree` holds one mutex taken by the mutating fs routes, by
publish/discard/rebase, and by the shutdown sync. Reads and the frequently
polled git status/diff stay unguarded; `bash`/`exec` cannot be held (they are
long-running and would stall every other writer), so a bash write can still
interleave with a publish — noted at the registration site.

The regression test appends through the guarded handler from 50 goroutines.
Without the lock 45 of 50 writes are lost.

The TS daemon has the same race and no equivalent fix; it is the one in
production.
The daemon implementation becomes the image: `studio-sandbox` runs the TS
daemon, `studio-sandbox-go` the Go one. A SandboxTemplate picks a daemon by
picking an image, and a claim picks the template — so a pod cannot disagree
with the template that created it, and which daemon ran is provable by
inspecting the image rather than by reading an env var out of a pod spec.

This replaces `SANDBOX_DAEMON_IMPL` and `start-daemon.sh`, both deleted. The
original argument for an env switch was that "a CMD change is a rebuild and a
rebuild is not a rollback" — that no longer applies: with one template per
image, rollback is a per-claim template swap, which is faster and finer-grained
than the env switch ever was.

One Dockerfile, one shared `runtime-base` carrying everything expensive
(LibreOffice, Python, Node, Deno, corepack, node-pty), then two leaf stages
that differ only in the daemon they copy and their CMD. The two images are
therefore byte-identical below their daemon layer and the second build costs
the Go compile plus one thin layer. `ts` is the LAST stage on purpose, so a
bare `docker build` still produces the TS image and no existing build command
changes meaning.

Chart: `daemonImpl` selects image.repository vs image.goRepository instead of
injecting env. One tag drives both images — they are released together from the
same source revision and must never skew. `sandbox-env.validateDaemonImpl`
fails at template time on an unrecognised impl or a missing goRepository: the
failure mode it prevents is a typo falling through to the TS repository, which
would give a canary that reads "Go is fine" while never having run Go. The
default render is unchanged.

CI smokes both images and asserts each logs the `impl=` it claims, so an image
that shipped the wrong daemon fails there instead of in a canary panel. The
release workflow builds, signs and attests both.

Versions bumped because the release workflow skips a build when the tag already
exists: without it studio-sandbox-go:1.28.4 would never be published while the
chart already referenced it.

Follow-ups, outside this commit:
- deco-apps-cd's bump-image receiver matches a `repository:` line; the new
  `goRepository:` value is a superstring of the match target, so verify it
  matches on the exact value before this ships.
- #5485 (second SandboxTemplate) already ranges over `$t.impl`; it needs the
  env block dropped, its image line selecting on impl, and its chart bump moved
  to 0.9.53.
…tempt

Shared agent sandboxes (#5112, #5116, #5132) shipped and were fully reverted by
#5240, with migration 147 dropping the tables. The 16-hole audit of that attempt
concluded "fix forward, do not revert" — that decision was overtaken, so the
audit is a post-mortem, not an incident list, and its holes are restated here as
twelve requirements a rebuild has to answer before code.

Records the two judgement calls worth arguing with:

Sharing must be explicit, never derived. The first attempt's root cause was not
a missing lock — `(org, virtualMcp, branch)` plus a `staging` default silently
collapsed every chat in an org onto one pod with nobody opting in. A session gets
its own id, owner and participant list; per-user stays the default; a default-off
org flag exists from the first commit.

No CRDT. "Realtime editing" splits into a shared workspace (buildable now) and
character-level co-editing (a document server, not a sandbox). File-level soft
ownership, revisited only if per-file data shows real collisions.

Also states the properties that are accepted rather than fixed: a shared sandbox
is an org-wide read surface, the dev server is singular, and bash/exec cannot be
serialized.

Phase 1 is actor identity, which is additive and testable on today's per-user
sandbox with no flag and no sharing model. Phase 0 (the daemon worktree lock)
already landed. The branch model — hole 13, never decided — has to be resolved
before Phase 2.
@pedrofrxncx
pedrofrxncx merged commit b174df9 into main Jul 31, 2026
29 checks passed
@pedrofrxncx
pedrofrxncx deleted the wt/daemon-go branch July 31, 2026 15:52
decocms Bot pushed a commit that referenced this pull request Jul 31, 2026
PR: #5484 feat(sandbox): Go sandbox daemon, dormant behind SANDBOX_DAEMON_IMPL
Bump type: minor

- decocms (apps/api/package.json): 4.153.0 -> 4.154.0
- @decocms/native (apps/native/package.json): 4.153.0 -> 4.154.0
- @decocms/sandbox (packages/sandbox/package.json): 1.29.0 -> 1.30.0
- deploy/helm/sandbox-env (chart 0.9.56) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.30.0

Deploy-Scope: both
pedrofrxncx added a commit that referenced this pull request Aug 3, 2026
The Go daemon has been the implementation every sandbox claims since #5484/
#5569; the TS daemon was still building, still shipping in a second image and
still claiming half the docs. Delete it (~24k lines) and keep only what is not
the daemon:

- `daemon-e2e/` — the black-box HTTP/SSE conformance suite, moved out of the
  implementation it used to live inside. Its default target is now
  `daemon-go/bin/daemon` instead of the TS bundle; `DAEMON_E2E_CMD` still
  swaps in any other binary.
- `orgfs/` — the org-fs client/WebDAV plus the privileged mounter sidecar,
  which is its own image and stays TypeScript. Dead `detachMount` (the sync
  twin, only reachable from the deleted daemon's exit hook) removed with it.
- `daemon-protocol.ts` — the config + SSE wire types Studio's daemon client and
  web UI consume, previously reached into the daemon source.

One image, one daemon: the Dockerfile's `ts`/`go` targets collapse into a
single stage and `studio-sandbox-go` is the only image published — the
`studio-sandbox` name is frozen at 1.35.3 (its last TS tag) and stays pullable
for rollback. The image also drops the node-pty install that existed only
because the TS bundle marked it external.

CI: the two daemon-e2e jobs become one (Go, keeping the `daemon-e2e` job name),
docker-smoke builds and boots one image, and daemon-e2e-windows.yml — a gate on
a subtree that no longer exists — is deleted.

Docs say Go: sandbox README rewritten (it still described the Bun daemon and
the removed desktop link), a README for daemon-go, CONTRIBUTING rule #4 and
AGENTS gotcha #8 rewritten, and every `packages/sandbox/daemon/...` pointer in
the Rust local-api parity comments repointed at its Go or daemon-e2e successor.

Co-authored-by: Pedro França <[email protected]>
aka-sacci-ccr added a commit that referenced this pull request Aug 11, 2026
* fix(sandbox): port submodule credentials to the Go daemon

#4885 shipped per-host submodule PATs, with the daemon half in
`packages/sandbox/daemon/setup/clone.ts`. The Go port (#5484) omitted that
half, and #5575 deleted the TypeScript daemon — so since then the Studio
side has resolved the secret, redacted it, and shipped it in the config
payload, while the daemon dropped it on unmarshal and never ran
`git submodule update`. A repo with private submodules clones with empty
submodule directories and the dev server dies on unresolved imports.

Ports the deleted implementation:

- `git.repository.submoduleCredentials` on the Go config, carried through
  `mergeRepository` (absent keeps current, so a clone-URL-only credential
  refresh doesn't drop the PATs).
- Host validation (mirrors `SUBMODULE_HOST_RE`), dedupe by host,
  percent-encoded credentials-file lines, per-host SSH→HTTPS `insteadOf`
  rewrites, and `submodule update --init --recursive --depth 1` — funnelled
  through `finalize` so both acquisition paths and both branch cases get it.
- Opt-in and best-effort throughout: no-op without credentials or a
  `.gitmodules`; a fetch failure warns and leaves the checkout intact.
- The token stays on the git-only channel: a 0600 temp file outside the repo,
  deleted after the fetch, never in argv, env, or the repo's `.git/config`,
  and redacted from both `/_sandbox/config` responses (the copy is what the
  browser sees; the live store keeps the token for the clone step).

Tests: Go unit tests for the pure argv/credentials-line functions and the
best-effort paths, config merge + classify, and route redaction; a
`daemon.submodules.e2e.test.ts` black-box suite asserting the fetch is
attempted with the rewrite applied, the clone survives an unreachable
submodule, an invalid host is skipped, and no response echoes the token.
Verified the e2e fails against the pre-fix wiring.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(sandbox): persist no-op config patches, and let a deleted credential revoke

Review of the submodule-credentials port surfaced two defects on the config
plane, both of which made the feature partially unusable, plus three smaller
ones. Each had a test pinning the broken behavior as correct; those are
inverted here.

- `Store.apply` returned on a `KindNoOp` transition WITHOUT writing the merged
  config. "No-op" classifies the side effect (no re-clone, no restart), not the
  write — so a patch carrying a field `Classify` has no arm for, which is
  exactly submodule credentials, was answered 200 with a receipt echoing the
  new value while the store kept the old one. Guarded on non-nil so an inert
  patch still can't claim an unclaimed daemon.

- `submoduleCredentials` is now always sent, empty array included. The daemon
  reads an absent field as "keep current", and both `buildConfigPayload` and
  `readValidatedSubmoduleCredentials` collapsed "the user deleted their last
  row" into "never configured" — so a revoked PAT stayed live in the pod for
  its lifetime, and a re-bootstrapped pod kept the previous config's tokens.
  The `[]`-clears path the merge documents was unreachable from its only
  producer.

- The credentials file moves from a random `os.CreateTemp` name in the shared
  /tmp to a deterministic path in the daemon's own tmp dir, swept at boot. A
  SIGKILL between the write and the `defer os.Remove` strands a live PAT on
  disk, and only a name the next boot can predict is sweepable.

- The submodule fetch runs through `runStep`, not `runNetworkStep`. `--recursive`
  emits aggregate output, so one dead submodule host matches the transient-error
  list and bought 4 full recursive passes plus 9s of sleeps ahead of install and
  the dev server, for a step whose failure is already tolerated.

- Two comments claimed protection the runtime doesn't provide: 0600 does not
  hide the file from tenant code (every process in the pod shares one uid — the
  control is lifetime), and `/config` redaction is defense in depth against a
  remote reader, not a boundary against in-pod code.

Tests: the two that pinned the bugs are inverted; the redaction tests now
assert 200 + a cloneUrl round-trip so they can't pass on an empty response;
`cloneLog` throws instead of returning "" so the e2e's absence assertions
can't pass vacuously; the e2e proves the SSH→HTTPS rewrite positively (the
URL git actually dialed) rather than by the absence of an ssh error. New:
credentials-file write failure, deletion after a failed fetch, per-host token
pairing, the boot sweep, and an e2e for revocation.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: decobot <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant