carlos / platform Public

Rootfs processes get HOME=/tmp when nothing sets one

Rootfs Plan 6's dev checklist (Task 15 Step 3) found that carlos console
on the Rails sample exits 1 at start. Nothing gave a rootfs process a
HOME, which Docker and the OCI runtimes always do. Ruby's Dir.home then
fell back to getlogin_r, which answers ENODEV on a session's terminal
because every instance template hides /dev/pts. Every Rails boot also
logged "`/` is not writable. Bundler will use /tmp...".

The trampoline's rootfs launch now passes the merged environment
through withDefaultHome. It appends HOME=/tmp (DefaultRootfsHome, a
private writable tmpfs in every rootfs template) only when no entry
names HOME. A HOME the image's config, the processes file or the
instance sets, even an empty one, is kept. It is box-side, so releases
already shipped get it without a reship. Every rootfs role reaches it:
web generations, workers, cmd (release and carlos run) and tty.
Binary instances are unchanged.

Docs: rootfs.md "What every process gets" adds "HOME is /tmp unless the
image or the app sets it." (RFS-4-C147, approved by Paul unchanged).

Test: TestRootfsLaunchGivesAProcessAHome covers no HOME, the manifest's,
the instance's and an empty one. Census rootfs-default-home approved
by Astra on #280 (execRootfsLaunch body, the instanceexec envelope, the
record-write re-digest); Astra correctness READY.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from rootfs-default-home into main.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 5887f944056101f2ffeb353fd2622d39721d844a parent 581e648
9 files changed, +98 −4
  • approved_rootfs_copy_test.go +4 −2
  • docs/site/rootfs.md +2 −0
  • docs/superpowers/notes/census-proposal-rootfs-default-home.md +19 −0
  • docs/superpowers/plans/2026-10-24-rootfs-apps-copy.md +1 −0
  • internal/instanceexec/exec_rootfs.go +21 −1
  • internal/instanceexec/exec_rootfs_test.go +43 −0
  • internal/provision/rootfs_apps_2_census_test.go +2 −1
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-rootfs-default-home.tsv +5 −0

CI passed — run details

diff --git a/approved_rootfs_copy_test.go b/approved_rootfs_copy_test.go
index aff1cf469..4ccc24f14 100644
--- a/approved_rootfs_copy_test.go
+++ b/approved_rootfs_copy_test.go
@@ -21,7 +21,7 @@ import (
const rootfsCopyRecordPath = "docs/superpowers/plans/2026-10-24-rootfs-apps-copy.md"
// Canonical ids only: two digits from C01 to C99, three digits from C100
-// (Plan 4 runs to RFS-4-C146). No leading zero on a three-digit id, no C00.
+// (Plan 4 runs to RFS-4-C146; RFS-4-C147 is the rootfs-default-home follow-up). No leading zero on a three-digit id, no C00.
var rootfsCopyIDPattern = regexp.MustCompile(`^RFS-[1-6]-C(0[1-9]|[1-9][0-9]{1,2})$`)
// rootfsCopyIDs is the deck's inventory, pinned as a literal list in the
@@ -82,7 +82,7 @@ var rootfsCopyIDs = []string{
"RFS-4-C33", "RFS-4-C34", "RFS-4-C35", "RFS-4-C36",
"RFS-4-C37", "RFS-4-C38", "RFS-4-C39", "RFS-4-C40",
"RFS-4-C41", "RFS-4-C42", "RFS-4-C43", "RFS-4-C44",
- "RFS-4-C45", "RFS-4-C46", "RFS-4-C47", "RFS-4-C48",
+ "RFS-4-C45", "RFS-4-C46", "RFS-4-C47", "RFS-4-C147", "RFS-4-C48",
"RFS-4-C49", "RFS-4-C50", "RFS-4-C51", "RFS-4-C52",
"RFS-4-C53", "RFS-4-C54", "RFS-4-C55", "RFS-4-C56",
"RFS-4-C57", "RFS-4-C58", "RFS-4-C59", "RFS-4-C60",
@@ -248,6 +248,8 @@ var rootfsCopyBuilt = []string{
// Task 8b: carlos ship --check --env (ship_rootfs.go, docs/site/cli.md);
// C145 is Task 9's, in rails.md
"RFS-4-C141", "RFS-4-C142", "RFS-4-C143", "RFS-4-C144", "RFS-4-C146",
+ // rootfs-default-home (2026-11-01): HOME is /tmp unless set (docs/site/rootfs.md)
+ "RFS-4-C147",
// Plan 4 Task 9: the Rails guide, the Laravel and Django notes, and the Guides nav (docs/site/rails.md, laravel-and-django.md, nav.json)
"RFS-4-C63", "RFS-4-C64", "RFS-4-C65", "RFS-4-C66", "RFS-4-C67", "RFS-4-C68", "RFS-4-C69", "RFS-4-C70",
"RFS-4-C71", "RFS-4-C72", "RFS-4-C73", "RFS-4-C74", "RFS-4-C75", "RFS-4-C76", "RFS-4-C77", "RFS-4-C78",
diff --git a/docs/site/rootfs.md b/docs/site/rootfs.md
index abc521ba4..68f93e32e 100644
--- a/docs/site/rootfs.md
+++ b/docs/site/rootfs.md
@@ -45,6 +45,8 @@ Every process of the instance gets the same environment: web, the workers and re
- CARLOS_HOST, CARLOS_REGION, CARLOS_CONTROL_SOCKET and CARLOS_PURGE mean what they mean for a binary instance, as [What an instance is started with](/docs/cli#what-an-instance-is-started-with) says.
+- HOME is /tmp unless the image or the app sets it.
+
## Health
web must answer GET / on CARLOS_SOCKET with a status below 500 within 120 seconds of starting. Until it does, the instance does not serve and its workers do not start.
diff --git a/docs/superpowers/notes/census-proposal-rootfs-default-home.md b/docs/superpowers/notes/census-proposal-rootfs-default-home.md
new file mode 100644
index 000000000..52cba6137
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-rootfs-default-home.md
@@ -0,0 +1,19 @@
+# Census approval: rootfs-default-home
+
+Ruling `census-ruling-rootfs-default-home`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/instanceexec/exec_rootfs.go` `execRootfsLaunch` | body | unchanged (2) | rootfs HOME default: the merged environment passes through withDefaultHome, which appends HOME=/tmp (DefaultRootfsHome) only when no entry names HOME; a HOME the manifest or the tenant launch sets, even empty, is kept. Environment only: argv, argv0 resolution (still the manifest PATH, never the tenant PATH), working dir, both launch-file checks and every refusal are unchanged; reads nothing new, the same two sites |
+
+Envelopes re-pinned: `internal/instanceexec`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/instanceexec/exec_rootfs.go` `execRootfsLaunch`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-2;identity=the trampoline (/opt/carlos/carlos instance-exec --rootfs <role> <iid>, the ExecStart= of a rootfs unit, run by PID 1 as user carlos inside the unit's namespace, whose root is the instance's own image mounted read-only, nosuid, nodev; no root process runs it);basis=root-input (J4, as execLaunch): new (rootfs Plan 2 Task 6): reads the tenant half (launch.<role>.json in the instance's own directory, instancefs.ReadBeneath, refusing a symlink or an escape) for the environment only, refusing a file that names a command, another host or a bad env entry; then root's half at /opt/carlos/launch.json, a read-only bind of root's file, after realRootLaunchOwned; the argv, working dir and PATH are root's alone; the Stat is ResolveRootfsCommand's os.Stat of a candidate inside the image; it execs as carlos and decides nothing for root
+
+Seal: `03a92257beb9b8aac421559e247d191bd69f28a0b26243397a1344a90d59fc2a` → `7a0a3da3d6fe7e3c77abb22676db000af2a276c3d13ccae0f038190f51287ed5`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-rootfs-default-home.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/plans/2026-10-24-rootfs-apps-copy.md b/docs/superpowers/plans/2026-10-24-rootfs-apps-copy.md
index 46a212ec0..d4472e98d 100644
--- a/docs/superpowers/plans/2026-10-24-rootfs-apps-copy.md
+++ b/docs/superpowers/plans/2026-10-24-rootfs-apps-copy.md
@@ -287,6 +287,7 @@ From the plan: Placeholders: `<app>` an app; `<fleet>` a fleet name; `<region>`
| RFS-4-C45 | docs/site/rootfs.md | CARLOS_SOCKET is the unix socket web serves HTTP on. | approved |
| RFS-4-C46 | docs/site/rootfs.md | CARLOS_DB is the instance's SQLite database, the one file the platform replicates. An app that keeps its data somewhere else can ignore it. | approved |
| RFS-4-C47 | docs/site/rootfs.md (fact) | CARLOS_HOST, CARLOS_REGION, CARLOS_CONTROL_SOCKET and CARLOS_PURGE mean what they mean for a binary instance, as [What an instance is started with](/docs/cli#what-an-instance-is-started-with) says. | approved |
+| RFS-4-C147 | docs/site/rootfs.md (fact, rootfs-default-home) | HOME is /tmp unless the image or the app sets it. | approved |
| RFS-4-C48 | docs/site/rootfs.md | Health | approved |
| RFS-4-C49 | docs/site/rootfs.md | web must answer GET / on CARLOS_SOCKET with a status below 500 within 120 seconds of starting. Until it does, the instance does not serve and its workers do not start. | approved |
| RFS-4-C50 | docs/site/rootfs.md | What it can write | approved |
diff --git a/internal/instanceexec/exec_rootfs.go b/internal/instanceexec/exec_rootfs.go
index f998be63d..97c4aec5a 100644
--- a/internal/instanceexec/exec_rootfs.go
+++ b/internal/instanceexec/exec_rootfs.go
@@ -123,7 +123,27 @@ func execRootfsLaunch(dataDir, rootLaunch string, role instancectl.Role, inst st
if err != nil {
return refused("%v", err)
}
- return execFn(argv0, root.Argv, MergeRootfsEnv(root.Env, tenant.Env))
+ return execFn(argv0, root.Argv, withDefaultHome(MergeRootfsEnv(root.Env, tenant.Env)))
+}
+
+// DefaultRootfsHome is the HOME a rootfs process gets when neither the
+// image's config, the app nor the instance sets one. Docker and the OCI
+// runtimes always give a process a HOME. Without one, Ruby's Dir.home asks
+// getlogin_r, which answers ENODEV on a session's terminal because every
+// instance template hides /dev/pts, so `carlos console` on a Rails app
+// stopped at start (rootfs Plan 6 Task 15, dev). /tmp is writable by every
+// process of the instance; the image itself is read-only.
+const DefaultRootfsHome = "/tmp"
+
+// withDefaultHome is env with HOME=DefaultRootfsHome appended when no
+// entry names HOME. A HOME that is set, even to "", is kept.
+func withDefaultHome(env []string) []string {
+ for _, kv := range env {
+ if strings.HasPrefix(kv, "HOME=") {
+ return env
+ }
+ }
+ return append(env, "HOME="+DefaultRootfsHome)
}
// ResolveRootfsCommand resolves argv0 inside the image by Plan 1's rule
diff --git a/internal/instanceexec/exec_rootfs_test.go b/internal/instanceexec/exec_rootfs_test.go
index d2680f08e..0fc5a3dc5 100644
--- a/internal/instanceexec/exec_rootfs_test.go
+++ b/internal/instanceexec/exec_rootfs_test.go
@@ -627,3 +627,46 @@ func TestBinaryTrampolineRefusesARootfsLaunchFileAndTheReverse(t *testing.T) {
t.Fatalf("the rootfs shape ran a schema-1 launch file: %v", err)
}
}
+
+// A rootfs process always has a HOME, as under Docker and the OCI
+// runtimes. Without one Ruby's Dir.home asks getlogin_r, which answers
+// ENODEV on a session's terminal because /dev/pts is hidden, and
+// `carlos console` on a Rails app stopped at start (Plan 6 Task 15, dev).
+// A HOME the image's config, the app or the instance sets is kept.
+func TestRootfsLaunchGivesAProcessAHome(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ manifest map[string]string
+ tenantHome string
+ want string
+ }{
+ {"none set", nil, "", DefaultRootfsHome},
+ {"the manifest's", map[string]string{"HOME": "/rails"}, "", "/rails"},
+ {"the instance's", nil, "/srv/home", "/srv/home"},
+ {"set empty", map[string]string{"HOME": ""}, "", ""},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ f := newRootfsExecFixture(t)
+ if tc.tenantHome != "" {
+ f.tenant.Env = append(f.tenant.Env, "HOME="+tc.tenantHome)
+ f.writeTenant(t)
+ }
+ env := map[string]string{"PATH": f.imagePath("app") + ":" + f.imagePath("usr/bin")}
+ for k, v := range tc.manifest {
+ env[k] = v
+ }
+ f.writeRoot(t, instancectl.RootfsLaunch{Schema: 1, Host: f.host, Process: "web", Argv: []string{"serve"}, Env: env, Version: "v1", Digest: f.digest})
+ var c captured
+ if err := execRootfsLaunch(f.dataDir, f.rootLaunch, instancectl.RoleRun, f.iid, c.exec); err != nil {
+ t.Fatal(err)
+ }
+ got, ok := envMap(c.env)["HOME"]
+ if !ok || got != tc.want {
+ t.Errorf("HOME = %q (set %v), want %q", got, ok, tc.want)
+ }
+ if dups := duplicateKeys(c.env); len(dups) > 0 {
+ t.Errorf("duplicate env keys %v", dups)
+ }
+ })
+ }
+}
diff --git a/internal/provision/rootfs_apps_2_census_test.go b/internal/provision/rootfs_apps_2_census_test.go
index 988bd0365..8c41ec25d 100644
--- a/internal/provision/rootfs_apps_2_census_test.go
+++ b/internal/provision/rootfs_apps_2_census_test.go
@@ -53,7 +53,8 @@ func rootfsApps2WriteCensusInventory() []censusEntry {
censusEntry{"internal/instanceexec/exit.go", "parseExitArgs", "key-site", "lit:instances", "fa4b37d7203a51f29f7783aa741cfee2210c42a32c2a664b1bb8a23afeda958e"},
censusEntry{"internal/instanceexec/probe.go", "ownTreesCheck", "key-site", "lit:instances", "b185ad889c0b7661b1dac7c85c7d5ff7fb5bd2596c4a44d67867c9aa64ea8b8a"},
censusEntry{"internal/instanceexec/probe.go", "symlinkChecks", "key-site", "lit:instances", "ae6456ea50d360fc3c6967d8e9b7bcb0523e93365674e3c4c292ff2698110ced"},
- censusEntry{"internal/instanceexec/exec_rootfs.go", "execRootfsLaunch", "key-site", "lit:instances", "047b129f61f6e9ebd737754ace0d0d58873c66845473af13402afbd725cfb630"},
+ // Re-digested for rootfs-default-home (census-ruling-rootfs-default-home, 2026-11-01): the merged env passes through withDefaultHome (HOME=/tmp when no entry names HOME). Same single ReadBeneath of the tenant launch file under instances/<iid>; no write.
+ censusEntry{"internal/instanceexec/exec_rootfs.go", "execRootfsLaunch", "key-site", "lit:instances", "6c16958b78174f2c5f58a6ce7b3d8edbe77df4d2cdef0f7505a66546d2f414b9"},
censusEntry{"internal/instanceexec/probe_rootfs.go", "foreignInstance", "key-site", "lit:instances", "c4d5b15bdef79937583a9b149d8dc971af6be15b8b161c5083719c9ce6825568"},
)
}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 017438a68..46cc5e1f8 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -54,3 +54,4 @@ plan14-root-reads-rootfs-apps-6.tsv c86929d08b9b2038fa103d1c7311ab2958e7100e92dc
plan14-root-reads-devbox-macos.tsv 67b54b219f990c3dcfe32c6ffb11a80a4ca3898aec060fe9f4450e21098af714
plan14-root-reads-fix-set-aside-exdev.tsv f9d3016cc6803338f9db19311f3f598e20c37c8a19e111a3dabf4741dabe1b19
plan14-root-reads-durability-3a-escrow.tsv 03a92257beb9b8aac421559e247d191bd69f28a0b26243397a1344a90d59fc2a
+plan14-root-reads-rootfs-default-home.tsv 7a0a3da3d6fe7e3c77abb22676db000af2a276c3d13ccae0f038190f51287ed5
diff --git a/internal/provision/testdata/plan14-root-reads-rootfs-default-home.tsv b/internal/provision/testdata/plan14-root-reads-rootfs-default-home.tsv
new file mode 100644
index 000000000..3d1cd95b3
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-rootfs-default-home.tsv
@@ -0,0 +1,5 @@
+# Census overlay rootfs-default-home, written by census-propose (#369). census-ruling-rootfs-default-home, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-rootfs-default-home.md.
+# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy 8536f278ff7ce94db58628970287992caf5a500edd37e25dc432b8146f2c0132 internal/instanceexec/exec_rootfs.go execRootfsLaunch legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-2;identity=the trampoline (/opt/carlos/carlos instance-exec --rootfs <role> <iid>, the ExecStart= of a rootfs unit, run by PID 1 as user carlos inside the unit's namespace, whose root is the instance's own image mounted read-only, nosuid, nodev; no root process runs it);basis=root-input (J4, as execLaunch): new (rootfs Plan 2 Task 6): reads the tenant half (launch.<role>.json in the instance's own directory, instancefs.ReadBeneath, refusing a symlink or an escape) for the environment only, refusing a file that names a command, another host or a bad env entry; then root's half at /opt/carlos/launch.json, a read-only bind of root's file, after realRootLaunchOwned; the argv, working dir and PATH are root's alone; the Stat is ResolveRootfsCommand's os.Stat of a candidate inside the image; it execs as carlos and decides nothing for root;rev3=census-ruling-rootfs-default-home;basis=rootfs HOME default: the merged environment passes through withDefaultHome, which appends HOME=/tmp (DefaultRootfsHome) only when no entry names HOME; a HOME the manifest or the tenant launch sets, even empty, is kept. Environment only: argv, argv0 resolution (still the manifest PATH, never the tenant PATH), working dir, both launch-file checks and every refusal are unchanged; reads nothing new, the same two sites file:ReadFile@1654,file:Stat@3002 6c16958b78174f2c5f58a6ce7b3d8edbe77df4d2cdef0f7505a66546d2f414b9
+internal/instanceexec/exec_rootfs.go execRootfsLaunch legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-2;identity=the trampoline (/opt/carlos/carlos instance-exec --rootfs <role> <iid>, the ExecStart= of a rootfs unit, run by PID 1 as user carlos inside the unit's namespace, whose root is the instance's own image mounted read-only, nosuid, nodev; no root process runs it);basis=root-input (J4, as execLaunch): new (rootfs Plan 2 Task 6): reads the tenant half (launch.<role>.json in the instance's own directory, instancefs.ReadBeneath, refusing a symlink or an escape) for the environment only, refusing a file that names a command, another host or a bad env entry; then root's half at /opt/carlos/launch.json, a read-only bind of root's file, after realRootLaunchOwned; the argv, working dir and PATH are root's alone; the Stat is ResolveRootfsCommand's os.Stat of a candidate inside the image; it execs as carlos and decides nothing for root;rev3=census-ruling-rootfs-default-home;basis=rootfs HOME default: the merged environment passes through withDefaultHome, which appends HOME=/tmp (DefaultRootfsHome) only when no entry names HOME; a HOME the manifest or the tenant launch sets, even empty, is kept. Environment only: argv, argv0 resolution (still the manifest PATH, never the tenant PATH), working dir, both launch-file checks and every refusal are unchanged; reads nothing new, the same two sites file:ReadFile@1654,file:Stat@3002 6c16958b78174f2c5f58a6ce7b3d8edbe77df4d2cdef0f7505a66546d2f414b9
+@coverage internal/instanceexec 5d763fa91affc67202892a101b99cf6e9e0f8f7b8129cffffa83cfe73f3ccf41