carlos / platform Public

Rootfs fleet follow-ups from Task 11 (#366). carlos logs names the process: rootfs app lines carry the field process=web, release or the worker's declared name (applog.Sink.AppProcess through an optional processSink; the platform's value wins over the app's own JSON key; the stream stays app; binary instances unchanged), so carlos logs --field process=web filters them (row RFS-4-C99). carlos instances list HEALTH for a fleet-placed instance comes from its fleet box's rollout view under the existing tenant join: Running, Asleep or Failed, and unknown when the view is unavailable, transient, or was generated before the record was created. The console's Running tab is unchanged, because fleet reports are an uncached per-request read. No new copy. Reviews: Astra R1 READY AFTER FIXES (P2: health from a report older than the record, fixed); census rootfs-fleet-followups approved by Astra on #280, re-sealed unchanged on main 43c8677a. Not released.

Squashed from rootfs-fleet-followups into main.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 11c6f199fb5e12ff093415e17c211b09e3d3e0f7 parent 43c8677
17 files changed, +633 −76
  • docs/superpowers/notes/census-proposal-rootfs-fleet-followups.md +29 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-rootfs-fleet-followups-R1.md +30 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-rootfs-fleet-followups.md +29 −0
  • internal/activator/logsink.go +26 −0
  • internal/activator/prepare.go +12 −7
  • internal/activator/rootfs_process_logs_test.go +112 −0
  • internal/activator/rootfsrelease.go +3 −7
  • internal/applog/record.go +5 −0
  • internal/applog/sink.go +15 −0
  • internal/applog/sink_test.go +26 −0
  • internal/console/apiinstances.go +47 −2
  • internal/console/fleethealth_test.go +124 −0
  • internal/provision/plan9_b8_census_test.go +1 −1
  • internal/provision/rootfs_fleet_followups_census_test.go +38 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-rootfs-fleet-followups.tsv +15 −0
  • logs_e2e_test.go +120 −59

CI passed — run details

diff --git a/docs/superpowers/notes/census-proposal-rootfs-fleet-followups.md b/docs/superpowers/notes/census-proposal-rootfs-fleet-followups.md
new file mode 100644
index 000000000..ec62a9318
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-rootfs-fleet-followups.md
@@ -0,0 +1,29 @@
+# Census approval: rootfs-fleet-followups
+
+Ruling `census-ruling-rootfs-fleet-followups`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/activator/prepare.go` `ExecBackend.prepareKeyedAt` | body | unchanged (13) | names the process for the role log listener: release.ProcessWeb when rt.Rootfs() and the role is run, else none, passed to logEmitter; reads rt.Runtime through Rootfs(); no file, path or env read added or moved |
+| `internal/activator/prepare.go` `ExecBackend.prepareWorker` | body | unchanged (6) | passes the worker name (already checked by release.ValidWorkerName at the top) to logEmitter as the process; no read added or moved |
+| `internal/activator/prepare.go` `ExecBackend.logEmitter` | sites | -registry:App, -registry:Host | takes a process name and returns appLineEmitter(b.Logs, rt, process); the route account, app and host reads moved into appLineEmitter; no file read |
+| `internal/activator/rootfsrelease.go` `Service.releaseAppLog` | sites | -registry:App, -registry:Host | returns lineEmitter(appLineEmitter(a.Logs, rt, release.ProcessRelease)); the route reads moved into appLineEmitter; no file read |
+
+Envelopes re-pinned: `internal/activator`, `internal/applog`.
+
+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/activator/prepare.go` `ExecBackend.prepareKeyedAt`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling zddr4, with no further change from this branch beyond carrying main's new early return into the six-value signature. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): body of the frozen prepareAt, which is now its wrapper; it also returns the instance key's layer and reads no env for the cmd role; same reads, same nested launch paths;rev3=census-ruling-wake-latency-2;basis=takes an optional timer and marks its steps with time.Now() (dirs, admin token, instance key, env, control socket, key gate, logs); no read added or moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, run and seed roles only, under a 30 s context (haSecretsBudget): the token producer is ensureAdminTokenFor(hctx, rt, p) (on this nested path the same beneath producer, EnsureAdminTokenBeneath's, plus the HA mint decision inside it); ensureInstanceKeyFor now gets hctx instead of context.Background(), so the key's bucket read is bounded by 30 s as well as configReadTimeout; the env is launchEnvLayer(hctx, rt) (instanceEnvLayer for a non-HA host; for an HA host one capture, published and acknowledged); a test seam (haLaunchHooks.afterGate, nil in production) is called before the producers. The separate haMintGate and haSecretsReady calls are gone (final fix F2). Sites against main: -registry:Host (the rt.Host+".env" argument EnsureAdminTokenBeneath took) and +whole:Route (rt to launchEnvLayer); the cmd role and a non-HA host are unchanged
+- `internal/activator/prepare.go` `ExecBackend.prepareWorker`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1: prepare for a worker: the instance's two directories and the worker log socket's, the worker's stale exit records cleared by its name prefix (another worker's and every generation's kept), its log listener bound where root's worker drop-in points StandardOutput=; reads no environment file; binds no control listener; asks no replica gate
+- `internal/activator/prepare.go` `ExecBackend.logEmitter`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route
+- `internal/activator/rootfsrelease.go` `Service.releaseAppLog`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1 [pf R1.5]: new; the writer a release's output goes through: each line to the instance's own app log (a.Logs.App(account, app, host, line)); reads the route's account, app and host for the log's key; no file read
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- new `internal/activator/logsink.go:appLineEmitter`: reads +registry:App, +registry:Host, +whole:Route; written legacy, accepted-legacy, frozen
+
+Seal: `042684bf5af6f61ce8b87f10b68a42b08d131ba4cb5bcab16320c7b032a724e6` → `78b7e7e30ad3ada44388a4ee16f3950ef888ae03e552477dcbfbb07c51ffb83e`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-rootfs-fleet-followups.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-rootfs-fleet-followups-R1.md b/docs/superpowers/reviews/CODEX-FINDINGS-rootfs-fleet-followups-R1.md
new file mode 100644
index 000000000..f6b0b2039
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-rootfs-fleet-followups-R1.md
@@ -0,0 +1,30 @@
+No P1 findings.
+
+**P2 — Fleet HEALTH can describe an earlier instance lifetime.** At [apiinstances.go:498](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-fleet-followups/internal/console/apiinstances.go:498), `fleetHealth` accepts the rollout view without checking when its box report was generated. The platform-remote path explicitly rejects reports generated before `rec.CreatedAt` at [remoteinstances.go:344](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-fleet-followups/internal/console/remoteinstances.go:344).
+
+If an instance is deleted and recreated with the same host, account and app while its previous snapshot remains fresh, the new row inherits the old instance’s `Running`, `Asleep` or `Failed` word. It should remain unknown until a report covers the new record.
+
+**Fix:** retain the snapshot’s `GeneratedAt` in the rollout join and require it to be after `rec.CreatedAt` before deriving fleet health. Add an API witness with a report predating the record and a newer-report control.
+
+**Invariant / fault family:** health observations must belong to the current instance lifetime.
+
+No P3 findings.
+
+Census verdicts for `ff0605208c91c02b86beae5fdb12136e0d10ca88`:
+
+| Unit or envelope | Verdict and evidence |
+|---|---|
+| `ExecBackend.prepareKeyedAt` | **APPROVE**, existing legacy disposition. [prepare.go:179](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-fleet-followups/internal/activator/prepare.go:179): adds process selection; launch gates and filesystem operations remain intact. |
+| `ExecBackend.prepareWorker` | **APPROVE**, existing legacy disposition. [prepare.go:209](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-fleet-followups/internal/activator/prepare.go:209): validated worker name reaches the existing listener; no additional reads. |
+| `ExecBackend.logEmitter` | **APPROVE**, existing legacy disposition. [prepare.go:325](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-fleet-followups/internal/activator/prepare.go:325): delegates route attribution to `appLineEmitter`. |
+| `Service.releaseAppLog` | **APPROVE**, existing legacy disposition. [rootfsrelease.go:353](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-fleet-followups/internal/activator/rootfsrelease.go:353): same output destination, with the release process name. |
+| `appLineEmitter` | **APPROVE**, new `legacy / accepted-legacy` disposition. [logsink.go:47](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-fleet-followups/internal/activator/logsink.go:47): reads route identity and invokes an in-memory sink; grants no filesystem or execution authority. |
+| `internal/activator` envelope | **APPROVE**. Changed functions preserve existing capture destinations, validation and launch boundaries. |
+| `internal/applog` envelope | **APPROVE**. [sink.go:131](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-fleet-followups/internal/applog/sink.go:131): process attribution overrides parsed JSON; stream and binary-instance behavior remain intact. |
+| Record-write re-pin: `Server.handleAPIInstanceList` | **APPROVE**, unchanged `key-site / lit:instances` classification. [apiinstances.go:1230](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-fleet-followups/internal/console/apiinstances.go:1230): annotates health without changing record writes. |
+
+The five unit digests, legacy fingerprints, both envelope hashes and record-write re-pin match the source. Tenant checks remain enforced; neither change adds S3 calls per list or pass. Web generations, worker restarts and release retries reach the updated capture paths.
+
+Targeted tests and census tests could not start because the read-only sandbox prevented Go from creating its work directory. `GOCACHE` was unset. `git diff --check` passed; runtime and mutation results remain unverified.
+
+READY AFTER FIXES
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-rootfs-fleet-followups.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-rootfs-fleet-followups.md
new file mode 100644
index 000000000..5d54cb7ae
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-rootfs-fleet-followups.md
@@ -0,0 +1,29 @@
+# Review brief: rootfs-fleet-followups (process names in carlos logs, fleet HEALTH), round 1 of 3
+
+Repo carlos/platform, branch `rootfs-fleet-followups`, review the diff `1fa2a99b..<this brief's parent>`.
+Authorities on main: docs/superpowers/specs/2026-10-24-rootfs-apps-design.md, docs/superpowers/plans/2026-10-24-rootfs-apps-4-console-and-docs.md (row RFS-4-C99: "carlos logs shows all three processes"), AGENTS.md (census, request budget, tenant isolation, production-wired witnesses, stopping rules).
+
+You are an independent reviewer. Read the diff, then the code it names, and check every claim against that code.
+
+## The changes
+1. a19a0c42: rootfs app log lines carry Fields["process"] = web | release | <worker name> (applog.Sink.AppProcess via an optional processSink interface; the platform's value wins over the app's JSON key; stream stays `app`; binary instances unchanged).
+2. 7545ef9a: `carlos instances list` HEALTH for fleet-placed records comes from the fleet box's rollout view via join.rollout(host, acct, app) (fleetHealth after instanceHealth in handleAPIInstanceList); Unavailable/Transient views stay unknown; "failed" on AttemptDown. The console's Running tab is deliberately NOT changed (its remote facts come only from cached platform box reports; fleet reports are an uncached per-request read).
+3. b0d928c0: census proposal (card docs/superpowers/notes/census-proposal-rootfs-fleet-followups.md; record-write re-pin internal/provision/rootfs_fleet_followups_census_test.go).
+
+## What to check
+1. Tenant isolation for item 2: can a caller see HEALTH derived from another account's or app's fleet report, or from a box of a fleet its account does not own? (Task 9 / #155 tenant join rules; TestInstanceListWorkersStayInTheirTenant.)
+2. Item 2's health words: do they mirror the platform-remote branch exactly (always-on vs hibernating, crashed web, held build still serving)? Any row that now shows a misleading word?
+3. Item 1: can an app spoof another process's name, or inject a field that changes how the console or CLI filters or renders? Is every rootfs capture site covered (web generations including overlap swaps, workers including restarts, release including retries), and nothing else changed for binary instances?
+4. Request budget: do either change add S3 requests per list or per pass?
+5. Census: a verdict for every unit and envelope on the card and the re-pin, per AGENTS.md "Getting a change approved".
+6. Tests: production-wired, and do the stated mutations pin the behaviour?
+
+## Severity
+- **P1**: unsafe, would not compile, a test fails, or it would not work. Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review.
+- **P3**: clarity or polish. Follow-up list only.
+
+## Output
+Findings ranked P1, P2, P3 with evidence (file:line), failure scenario, fix, invariant. Census verdicts. End with exactly one verdict: READY, READY AFTER FIXES, or NOT READY.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of your own. Do not run the full test suites.
diff --git a/internal/activator/logsink.go b/internal/activator/logsink.go
index 431364dca..75944a932 100644
--- a/internal/activator/logsink.go
+++ b/internal/activator/logsink.go
@@ -12,6 +12,7 @@ import (
"regexp"
"strings"
+ "github.com/carlosframework/platform/internal/applog"
"github.com/carlosframework/platform/internal/cgroup"
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
@@ -29,6 +30,31 @@ type EventSink interface {
Event(acct, app, host, level, msg string)
}
+// processSink is an EventSink that can name the process an app line came
+// from (applog.Sink.AppProcess). It is asked for by assertion, not added to
+// EventSink, so the package's EventSink fakes stay as they are; the
+// assertion below keeps the real sink holding it.
+type processSink interface {
+ AppProcess(acct, app, host, process, line string)
+}
+
+var _ processSink = (*applog.Sink)(nil)
+
+// appLineEmitter is the emit function for rt's app output, or nil when
+// sink is nil. A non-empty process (a rootfs instance's web, release or
+// worker name) is passed to a sink that can name it; otherwise the line
+// goes through App as before.
+func appLineEmitter(sink EventSink, rt registry.Route, process string) func(string) {
+ if sink == nil {
+ return nil
+ }
+ acct, app, host := release.RouteAccount(rt), rt.App, rt.Host
+ if ps, ok := sink.(processSink); ok && process != "" {
+ return func(line string) { ps.AppProcess(acct, app, host, process, line) }
+ }
+ return func(line string) { sink.App(acct, app, host, line) }
+}
+
// emitEvent publishes one platform event for rt's app, tolerating a nil
// sink. level is an applog.Level* value ("info"/"warn"/"error" — string
// here to keep the dependency one-way).
diff --git a/internal/activator/prepare.go b/internal/activator/prepare.go
index e921303f8..47c54aef9 100644
--- a/internal/activator/prepare.go
+++ b/internal/activator/prepare.go
@@ -179,7 +179,13 @@ func (b *ExecBackend) prepareKeyedAt(rt registry.Route, role instancectl.Role, s
var logs *logListener
if role != instancectl.RoleCmd {
var err error
- logs, err = listenLogs(b.logSocketFor(rt.Host, role, gen), b.logEmitter(rt))
+ // A rootfs row's run role is its web process; a binary row's
+ // lines name no process.
+ process := ""
+ if rt.Rootfs() && role == instancectl.RoleRun {
+ process = release.ProcessWeb
+ }
+ logs, err = listenLogs(b.logSocketFor(rt.Host, role, gen), b.logEmitter(rt, process))
if err != nil {
if ctl != nil {
ctl.Close()
@@ -222,7 +228,7 @@ func (b *ExecBackend) prepareWorker(rt registry.Route, name string) (instancePat
}
}
}
- logs, err := listenLogs(sock, b.logEmitter(rt))
+ logs, err := listenLogs(sock, b.logEmitter(rt, name))
if err != nil {
return p, nil, fmt.Errorf("log listener for %s worker %s: %w", rt.Host, name, err)
}
@@ -314,11 +320,10 @@ func (b *ExecBackend) logSocketNamed(host, name string) string {
}
// logEmitter is the same sink teeStd feeds, or nil when Logs is unset.
-func (b *ExecBackend) logEmitter(rt registry.Route) func(string) {
- if b.Logs == nil {
- return nil
- }
- return func(line string) { b.Logs.App(release.RouteAccount(rt), rt.App, rt.Host, line) }
+// process names the process the lines come from ("" for none):
+// appLineEmitter.
+func (b *ExecBackend) logEmitter(rt registry.Route, process string) func(string) {
+ return appLineEmitter(b.Logs, rt, process)
}
// writeLaunch is writeLaunchFor for the original templates.
diff --git a/internal/activator/rootfs_process_logs_test.go b/internal/activator/rootfs_process_logs_test.go
new file mode 100644
index 000000000..46695953a
--- /dev/null
+++ b/internal/activator/rootfs_process_logs_test.go
@@ -0,0 +1,112 @@
+package activator
+
+import (
+ "context"
+ "net"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/applog"
+ "github.com/carlosframework/platform/internal/instancectl"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// A rootfs instance's output reaches `carlos logs` naming the process that
+// wrote it (#366 Task 11 follow-up): web through the generation's log
+// listener, a worker through its own, the release through releaseAppLog.
+// Each line goes in at the socket or writer production hands the unit, and
+// comes out of a real applog.Sink, so the wiring at each capture site is
+// what is checked. A process key in the app's own JSON loses to the
+// platform's.
+func TestRootfsAppLinesNameTheirProcess(t *testing.T) {
+ t.Parallel()
+ b, ctl, rt, units := newWorkerBackend(t)
+ sink := applog.NewSink("box1", time.Now)
+ b.Logs = sink
+ web, g := startWorkerWeb(t, b, ctl, rt, units, "")
+ units.set(instancectl.WorkerUnitName(rt.Host, "jobs"), "active", "inv1", true)
+ wp, err := b.LaunchRootfsWorker(context.Background(), rt, "jobs", g, web)
+ if err != nil {
+ t.Fatalf("LaunchRootfsWorker: %v", err)
+ }
+ t.Cleanup(func() { stopWorker(t, wp) })
+
+ writeUnitLine(t, b.logSocketFor(rt.Host, instancectl.RoleRun, g.N), `{"msg":"web line","process":"spoof"}`)
+ writeUnitLine(t, b.workerLogSocket(rt.Host, "jobs"), "worker line")
+ a := &Service{Logs: sink}
+ if _, err := a.releaseAppLog(rt).Write([]byte("release line")); err != nil {
+ t.Fatal(err)
+ }
+
+ got := map[string]string{}
+ for _, r := range drainAppLines(t, sink, 3) {
+ got[r.Msg] = r.Fields["process"]
+ if r.Stream != applog.StreamApp {
+ t.Errorf("%q is on stream %q, want app", r.Msg, r.Stream)
+ }
+ }
+ want := map[string]string{"web line": release.ProcessWeb, "worker line": "jobs", "release line": release.ProcessRelease}
+ for msg, p := range want {
+ if got[msg] != p {
+ t.Errorf("%q has process %q, want %q (all: %v)", msg, got[msg], p, got)
+ }
+ }
+}
+
+// A binary instance's nested run role is unchanged: its lines carry no
+// process field.
+func TestBinaryAppLinesNameNoProcess(t *testing.T) {
+ t.Parallel()
+ b, _ := newRootfsBackend(t)
+ rt := rootfsRoute(b)
+ rt.Runtime = ""
+ sink := applog.NewSink("box1", time.Now)
+ b.Logs = sink
+ _, ctl, logs, _, _, err := b.prepareKeyedAt(rt, instancectl.RoleRun, rt.Socket, 0, nil)
+ if err != nil {
+ t.Fatalf("prepareKeyedAt: %v", err)
+ }
+ if ctl != nil {
+ t.Cleanup(func() { ctl.Close() })
+ }
+ t.Cleanup(func() { logs.Close() })
+ writeUnitLine(t, b.logSocketFor(rt.Host, instancectl.RoleRun, 0), "binary line")
+ for _, r := range drainAppLines(t, sink, 1) {
+ if p, ok := r.Fields["process"]; ok {
+ t.Errorf("%q carries process %q, want none", r.Msg, p)
+ }
+ }
+}
+
+// writeUnitLine is a unit's stdout: one connection to its log socket, one
+// line, closed.
+func writeUnitLine(t *testing.T, sock, line string) {
+ t.Helper()
+ c, err := net.Dial("unix", sock)
+ if err != nil {
+ t.Fatalf("dial %s: %v", sock, err)
+ }
+ defer c.Close()
+ if _, err := c.Write([]byte(line + "\n")); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// drainAppLines drains sink until n app-stream records have arrived.
+func drainAppLines(t *testing.T, sink *applog.Sink, n int) []applog.Record {
+ t.Helper()
+ var out []applog.Record
+ for deadline := time.Now().Add(5 * time.Second); len(out) < n && time.Now().Before(deadline); time.Sleep(10 * time.Millisecond) {
+ for _, recs := range sink.Drain() {
+ for _, r := range recs {
+ if r.Stream == applog.StreamApp {
+ out = append(out, r)
+ }
+ }
+ }
+ }
+ if len(out) != n {
+ t.Fatalf("%d app lines arrived, want %d: %+v", len(out), n, out)
+ }
+ return out
+}
diff --git a/internal/activator/rootfsrelease.go b/internal/activator/rootfsrelease.go
index ee6376dbe..6244ca4d5 100644
--- a/internal/activator/rootfsrelease.go
+++ b/internal/activator/rootfsrelease.go
@@ -348,14 +348,10 @@ func releaseLeaseGone(held leaseWatch) bool {
}
// releaseAppLog is the writer a release's output goes through to the app
-// log, a line a Write (StartRelease's line writer feeds it whole lines);
-// nil Logs discards.
+// log, a line a Write (StartRelease's line writer feeds it whole lines),
+// each naming the release process; nil Logs discards.
func (a *Service) releaseAppLog(rt registry.Route) io.Writer {
- if a.Logs == nil {
- return lineEmitter(nil)
- }
- sink := a.Logs
- return lineEmitter(func(line string) { sink.App(release.RouteAccount(rt), rt.App, rt.Host, line) })
+ return lineEmitter(appLineEmitter(a.Logs, rt, release.ProcessRelease))
}
// runRelease runs id's release process for rt, if one is due, under held
diff --git a/internal/applog/record.go b/internal/applog/record.go
index 92ae49d69..ea153fdd6 100644
--- a/internal/applog/record.go
+++ b/internal/applog/record.go
@@ -23,6 +23,11 @@ const (
StreamRelease = "release" // ship/promote history join (stage 3)
)
+// FieldProcess is the field an app line carries naming the process that
+// wrote it, when the platform knows (Sink.AppProcess): a rootfs instance's
+// web, release or worker. `carlos logs --field process=web` filters on it.
+const FieldProcess = "process"
+
// ValidStream reports whether s names a known stream — the CLI/API's
// vocabulary check, kept here so there is exactly one list.
func ValidStream(s string) bool {
diff --git a/internal/applog/sink.go b/internal/applog/sink.go
index 19a3db172..e40b8eed7 100644
--- a/internal/applog/sink.go
+++ b/internal/applog/sink.go
@@ -129,7 +129,22 @@ func (s *Sink) Known() []AppKey {
// JSON lines at the door (ParseAppLine) so the bucket holds fields and
// honored levels rather than opaque text. Subject to both budgets.
func (s *Sink) App(acct, app, host, line string) {
+ s.AppProcess(acct, app, host, "", line)
+}
+
+// AppProcess is App for a line the platform knows the process of (a rootfs
+// instance's web, release or a named worker): a non-empty process is set
+// as Fields["process"] after parsing, over any "process" key in the app's
+// own JSON, so the name a member filters on is always the platform's. The
+// stream stays StreamApp; StreamRelease is the ship/promote history.
+func (s *Sink) AppProcess(acct, app, host, process, line string) {
msg, level, fields := ParseAppLine(line)
+ if process != "" {
+ if fields == nil {
+ fields = make(map[string]string, 1)
+ }
+ fields[FieldProcess] = process
+ }
s.mu.Lock()
defer s.mu.Unlock()
b := s.buf(AppKey{acct, app})
diff --git a/internal/applog/sink_test.go b/internal/applog/sink_test.go
index fcdaa2ac0..17068a9fd 100644
--- a/internal/applog/sink_test.go
+++ b/internal/applog/sink_test.go
@@ -162,3 +162,29 @@ func TestIsDropNotice(t *testing.T) {
}
}
}
+
+// AppProcess is App with the platform naming the process that wrote the
+// line (a rootfs instance's web, release or a worker): the name rides in
+// Fields["process"], on a plain line and on a structured one alike, and
+// the platform's value wins over a "process" key in the app's own JSON.
+// The stream stays app: "release" is the ship/promote history's stream.
+func TestSinkAppProcessNamesTheProcess(t *testing.T) {
+ now, _ := testClock(time.Date(2026, 10, 30, 12, 0, 0, 0, time.UTC))
+ sk := NewSink("box1", now)
+ sk.AppProcess("bab", "shop", "shop.bab.oncarlos.com", "web", "listening")
+ sk.AppProcess("bab", "shop", "shop.bab.oncarlos.com", "jobs", `{"msg":"tick","process":"web","n":3}`)
+ sk.AppProcess("bab", "shop", "shop.bab.oncarlos.com", "release", "migrated")
+ sk.App("bab", "shop", "shop.bab.oncarlos.com", `{"msg":"own","process":"mine"}`)
+ recs := sk.Drain()[AppKey{"bab", "shop"}]
+ if len(recs) != 4 {
+ t.Fatalf("records: %d, want 4", len(recs))
+ }
+ for i, want := range []struct{ msg, process, n string }{
+ {"listening", "web", ""}, {"tick", "jobs", "3"}, {"migrated", "release", ""}, {"own", "mine", ""},
+ } {
+ r := recs[i]
+ if r.Stream != StreamApp || r.Msg != want.msg || r.Fields["process"] != want.process || r.Fields["n"] != want.n {
+ t.Errorf("record %d = %+v, want app stream, msg %q, process %q, n %q", i, r, want.msg, want.process, want.n)
+ }
+ }
+}
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go
index e4f71c70e..4a46e84de 100644
--- a/internal/console/apiinstances.go
+++ b/internal/console/apiinstances.go
@@ -476,6 +476,44 @@ func (s *Server) instanceHealth(ctx context.Context, recs []provision.Record) ma
return out
}
+// fleetHealth fills in, from join, the health of each record placed on a
+// customer fleet that instanceHealth left unknown: the platform's boxes do
+// not report fleet-placed hosts, but the fleet's own boxes' rollout reports
+// do, and join (loadRolloutJoin) reads them for the caller's own fleets
+// only. join.rollout keeps its tenant rule: a report is used only when it
+// names this account and app. A view whose box could not arm its scheduler
+// (Unavailable, which also covers a refused view with no tenant to check)
+// or whose host is starting or stopping (Transient) says nothing about the
+// host's state, and the word stays unknown, as it does for a view whose
+// box generated its snapshot no later than the record was created: that
+// report may be about an earlier lifetime of the same host, account and
+// app (appFacts.host's rule for a platform-remote record). Otherwise the
+// word is the platform-remote one (instanceHealth): awake is Running, a
+// host held down after a failed hold-mode build is Failed.
+func fleetHealth(health map[string]string, recs []provision.Record, join boxJoin, acct, app string) {
+ for _, rec := range recs {
+ if health[rec.Host] != healthUnknown {
+ continue
+ }
+ if _, fleetPlaced := registry.FleetPlacement(rec.Region); !fleetPlaced {
+ continue
+ }
+ v := join.rollout(rec.Host, acct, app)
+ if v == nil || v.Unavailable != "" || v.Transient || !v.at.After(rec.CreatedAt) {
+ continue
+ }
+ kind := rec.Kind
+ if kind == "" {
+ kind = "instance"
+ }
+ st := "ready"
+ if v.Attempt == status.AttemptDown {
+ st = "failed"
+ }
+ health[rec.Host] = healthWord(kind, st, rec.HibernateOrDefault(), v.Awake, true)
+ }
+}
+
// healthByHost is the metrics half of a health answer, shared by
// instanceHealth (records joined to routes) and handleAPIRoutes (routes
// directly, issue #64) so the two — and the Running tab, which uses the
@@ -716,6 +754,11 @@ type rolloutView struct {
// refused marks a view built from an Unavailable box, which has no
// account or app to check (hosts are unique; the caller filtered by app).
refused bool
+ // at is when the reporting box generated its snapshot (status.Box's
+ // GeneratedAt). Not shown: fleetHealth uses a view only when it is
+ // later than the record's creation, so a report about an earlier
+ // lifetime of the same host never describes this one.
+ at time.Time
}
// workerView is one worker of a rootfs instance as a member sees it
@@ -1044,12 +1087,12 @@ func (j *boxJoin) foldRollout(b status.Box, override bool) {
if _, held := ro.Hosts[host]; held {
continue
}
- put(host, rolloutView{Box: b.Label, Installed: v, Unavailable: ro.Unavailable, refused: true})
+ put(host, rolloutView{Box: b.Label, Installed: v, Unavailable: ro.Unavailable, refused: true, at: b.GeneratedAt})
}
for host, hr := range ro.Hosts {
put(host, rolloutView{Box: b.Label, Installed: hr.Installed, Good: hr.Good, Attempt: hr.Attempt, AttemptBuild: hr.AttemptBuild,
HeldBy: hr.HeldBy, Reason: hr.Reason, Unavailable: ro.Unavailable, Workers: workerViews(hr.Workers),
- account: hr.Account, app: hr.App, heldEpoch: hr.HeldEpoch, heldBook: hr.HeldBook, retryV: hr.RetryV})
+ account: hr.Account, app: hr.App, heldEpoch: hr.HeldEpoch, heldBook: hr.HeldBook, retryV: hr.RetryV, at: b.GeneratedAt})
}
return
}
@@ -1072,6 +1115,7 @@ func (j *boxJoin) foldRollout(b status.Box, override bool) {
ConfigPending: hr.ConfigPending, Transient: hr.Transient, SchedulerIdle: a.Queued == 0 && a.Running == 0 && a.Settling == 0,
Workers: workerViews(hr.Workers),
account: hr.Account, app: hr.App, heldEpoch: hr.HeldEpoch, heldBook: hr.HeldBook, retryV: hr.RetryV,
+ at: b.GeneratedAt,
})
}
}
@@ -1193,6 +1237,7 @@ func (s *Server) handleAPIInstanceList(w http.ResponseWriter, r *http.Request) {
}
}
health := s.instanceHealth(ctx, recs)
+ fleetHealth(health, recs, join, acct.Sqid, app)
counts := map[string]int{}
matched := make([]instanceListRecord, 0, len(recs))
home, names := s.regionHome(), s.regionNames()
diff --git a/internal/console/fleethealth_test.go b/internal/console/fleethealth_test.go
new file mode 100644
index 000000000..83c9a5405
--- /dev/null
+++ b/internal/console/fleethealth_test.go
@@ -0,0 +1,124 @@
+package console
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// writeFleetRolloutBox registers fleet to owner and writes, under the
+// fleet's own prefix, a box named machine reporting ro (and versions as its
+// route versions, which an Unavailable report's hosts come from), generated
+// at at.
+func writeFleetRolloutBox(t *testing.T, fx *consoleFixture, fleet, owner, machine string, at time.Time, ro *status.RolloutReport, versions map[string]string) {
+ t.Helper()
+ reg, err := registry.Open(fx.regPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer reg.Close()
+ if err := reg.UpsertFleet(registry.Fleet{Name: fleet, Account: owner, Bucket: fleet + "-bucket"}); err != nil {
+ t.Fatal(err)
+ }
+ box := status.CollectBox(nil, status.Probes{MachineID: machine}, at)
+ box.Metrics = &status.BoxMetrics{Rollout: ro, RouteVersions: versions}
+ if err := status.WriteBox(context.Background(), release.NewPrefixStore(fx.rel, "fleets/"+fleet+"/"), box); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// listHealth is the instance list's health word per host.
+func listHealth(t *testing.T, fx *consoleFixture, token, app string) map[string]string {
+ t.Helper()
+ code, _, out := rawReq(t, http.MethodGet, fx.ts.URL+"/api/cli/apps/"+fx.sqid+"/"+app+"/instances", token, "")
+ if code != http.StatusOK {
+ t.Fatalf("list = %d %s", code, out)
+ }
+ var list struct {
+ Instances []struct {
+ Host string `json:"host"`
+ Health string `json:"health"`
+ } `json:"instances"`
+ }
+ if err := json.Unmarshal([]byte(out), &list); err != nil {
+ t.Fatal(err)
+ }
+ got := map[string]string{}
+ for _, r := range list.Instances {
+ got[r.Host] = r.Health
+ }
+ return got
+}
+
+// #366 Task 11 follow-up: a record placed on the caller's own fleet takes
+// its health word from that fleet box's rollout report (the join the
+// list's rollout column reads), as a platform-remote record takes its word
+// from its box: awake is Running, a hibernating instance not awake is
+// Asleep, a host held down is Failed. Everything the join cannot vouch for
+// stays "Can't tell right now": a host starting or stopping, a report
+// naming another app, a box that could not arm its scheduler, a host no
+// box reports, another account's fleet box naming this app's host, and a
+// report generated before the record was created (an earlier lifetime of
+// the same host, account and app; the platform-remote rule, appFacts.host).
+// Every other report here is generated after the records, the control.
+func TestFleetPlacedHealthComesFromItsFleetBox(t *testing.T) {
+ fx := newConsoleFixture(t)
+ const app = "kass"
+ host := func(slug string) string { return slug + ".kass.carlosapp.dev" }
+ asleep := true
+ now := time.Now().UTC()
+ created := now.Add(-10 * time.Second)
+ for _, slug := range []string{"run", "nap", "down", "busy", "other", "gone", "stranger", "unavail", "reborn"} {
+ place := registry.PlacementTarget("pi")
+ if slug == "stranger" {
+ place = registry.PlacementTarget("stranger")
+ }
+ if err := provision.CreateRecord(context.Background(), fx.rel, provision.Record{
+ Schema: 1, Host: host(slug), Slug: slug, App: app, Account: fx.sqid, Region: place,
+ Channel: "stable", Hibernate: &asleep, CreatedAt: created, CreatedBy: "paul@keymail.dev",
+ }); err != nil {
+ t.Fatal(err)
+ }
+ }
+ mine := func(hr status.HostRollout) status.HostRollout {
+ hr.Account, hr.App, hr.Installed = fx.sqid, app, "v1"
+ return hr
+ }
+ writeFleetRolloutBox(t, fx, "pi", fx.sqid, "pi-box", now, &status.RolloutReport{Hosts: map[string]status.HostRollout{
+ host("run"): mine(status.HostRollout{Awake: true}),
+ host("nap"): mine(status.HostRollout{}),
+ host("down"): mine(status.HostRollout{Attempt: status.AttemptDown, AttemptBuild: "v1"}),
+ host("busy"): mine(status.HostRollout{Transient: true}),
+ host("other"): {Account: fx.sqid, App: "other", Installed: "v1", Awake: true},
+ }}, nil)
+ writeFleetRolloutBox(t, fx, "pi", fx.sqid, "pi-box-2", now, &status.RolloutReport{Unavailable: "flag-off"},
+ map[string]string{host("unavail"): "v1"})
+ writeFleetRolloutBox(t, fx, "stranger", "zzz", "stranger-box", now, &status.RolloutReport{Hosts: map[string]status.HostRollout{
+ host("stranger"): mine(status.HostRollout{Awake: true}),
+ }}, nil)
+ // Fresh (well inside the staleness window) but from before the record.
+ writeFleetRolloutBox(t, fx, "pi", fx.sqid, "pi-box-old", created.Add(-10*time.Second), &status.RolloutReport{Hosts: map[string]status.HostRollout{
+ host("reborn"): mine(status.HostRollout{Awake: true}),
+ }}, nil)
+ token := cliToken(t, fx, "paul@keymail.dev", "code-fleet-health")
+
+ got := listHealth(t, fx, token, app)
+ want := map[string]string{
+ host("run"): "Running", host("nap"): "Asleep", host("down"): "Failed",
+ host("busy"): healthUnknown, host("other"): healthUnknown, host("gone"): healthUnknown,
+ host("stranger"): healthUnknown, host("unavail"): healthUnknown, host("reborn"): healthUnknown,
+ }
+ for h, w := range want {
+ if got[h] != w {
+ t.Errorf("%s health = %q, want %q", strings.SplitN(h, ".", 2)[0], got[h], w)
+ }
+ }
+}
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index 3ac707aa4..0098f6133 100644
--- a/internal/provision/plan9_b8_census_test.go
+++ b/internal/provision/plan9_b8_census_test.go
@@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) {
if len(got) < 100 {
t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root)
}
- inventory := rootfsCheckVolumesWriteCensusInventory()
+ inventory := rootfsFleetFollowupsWriteCensusInventory()
problems := append(censusDiff(inventory, got), censusPolicy(inventory)...)
if len(problems) > 0 {
t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n "))
diff --git a/internal/provision/rootfs_fleet_followups_census_test.go b/internal/provision/rootfs_fleet_followups_census_test.go
new file mode 100644
index 000000000..b8c263799
--- /dev/null
+++ b/internal/provision/rootfs_fleet_followups_census_test.go
@@ -0,0 +1,38 @@
+package provision
+
+// Record-write census entries for the rootfs fleet follow-ups (#366,
+// branch rootfs-fleet-followups), layered on
+// rootfsCheckVolumesWriteCensusInventory (main's newest at 43c8677a, merged
+// into the branch; it layers on fleetSecretsKeyWriteCensusInventory, the
+// newest at the branch's base 1fa2a99b). Reviewed by the branch author against the source; the census
+// approval is recorded on #280 with the root-read card
+// (docs/superpowers/notes/census-proposal-rootfs-fleet-followups.md).
+//
+// One re-pin, no new unit:
+// - internal/console/apiinstances.go Server.handleAPIInstanceList
+// (key-site): after instanceHealth, fleetHealth fills the health word of
+// a fleet-placed record still unknown from the rollout join the handler
+// already loads (join.rollout, its tenant rule kept). The record listing
+// and its literal are unchanged; it writes no record.
+func rootfsFleetFollowupsWriteCensusInventory() []censusEntry {
+ entries := append([]censusEntry(nil), rootfsCheckVolumesWriteCensusInventory()...)
+ repins := []censusEntry{
+ // rootfs-fleet-followups: fleetHealth after instanceHealth; the same listing and literal.
+ {"internal/console/apiinstances.go", "Server.handleAPIInstanceList", "key-site", "lit:instances", "fc3da89d5a32eeed50e4a5c4811d2f90e0a2bce9a49bd2d71694844d5b1009d3"},
+ }
+ for _, r := range repins {
+ found := false
+ for i, e := range entries {
+ if e.File == r.File && e.Unit == r.Unit {
+ if e.Class != r.Class || e.Kinds != r.Kinds {
+ panic("rootfs-fleet-followups re-pin changes the class or kinds of " + r.File + ":" + r.Unit)
+ }
+ entries[i], found = r, true
+ }
+ }
+ if !found {
+ panic("rootfs-fleet-followups re-pin of an unlisted unit " + r.File + ":" + r.Unit)
+ }
+ }
+ return entries
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 33b508de6..172d774b2 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -35,3 +35,4 @@ plan14-root-reads-named-unit-delivery-114.tsv d92c9d40eb2a9e66c859e2fe6df3af10a1
plan14-root-reads-fleet-secrets-key.tsv 9df7f5aca9a502966c9643b7062829c1c25bfbd86fa20e92d764d66f676d2cd6
plan14-root-reads-static-headers.tsv 94b8ccf921f64be24a4773f72d55a8e24ceba3acfb40eefe3b56af6f5b008138
plan14-root-reads-rootfs-check-volumes.tsv 042684bf5af6f61ce8b87f10b68a42b08d131ba4cb5bcab16320c7b032a724e6
+plan14-root-reads-rootfs-fleet-followups.tsv 78b7e7e30ad3ada44388a4ee16f3950ef888ae03e552477dcbfbb07c51ffb83e
diff --git a/internal/provision/testdata/plan14-root-reads-rootfs-fleet-followups.tsv b/internal/provision/testdata/plan14-root-reads-rootfs-fleet-followups.tsv
new file mode 100644
index 000000000..7fbb80339
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-rootfs-fleet-followups.tsv
@@ -0,0 +1,15 @@
+# Census overlay rootfs-fleet-followups, written by census-propose (#369). census-ruling-rootfs-fleet-followups, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-rootfs-fleet-followups.md.
+# 2 body, 2 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy d82ca4f88546b2b29b8e9619c60118f3b3f1c492c071d39f7ae63f334d9ed6cb internal/activator/prepare.go ExecBackend.prepareKeyedAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling zddr4, with no further change from this branch beyond carrying main's new early return into the six-value signature. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): body of the frozen prepareAt, which is now its wrapper; it also returns the instance key's layer and reads no env for the cmd role; same reads, same nested launch paths;rev3=census-ruling-wake-latency-2;basis=takes an optional timer and marks its steps with time.Now() (dirs, admin token, instance key, env, control socket, key gate, logs); no read added or moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, run and seed roles only, under a 30 s context (haSecretsBudget): the token producer is ensureAdminTokenFor(hctx, rt, p) (on this nested path the same beneath producer, EnsureAdminTokenBeneath's, plus the HA mint decision inside it); ensureInstanceKeyFor now gets hctx instead of context.Background(), so the key's bucket read is bounded by 30 s as well as configReadTimeout; the env is launchEnvLayer(hctx, rt) (instanceEnvLayer for a non-HA host; for an HA host one capture, published and acknowledged); a test seam (haLaunchHooks.afterGate, nil in production) is called before the producers. The separate haMintGate and haSecretsReady calls are gone (final fix F2). Sites against main: -registry:Host (the rt.Host+".env" argument EnsureAdminTokenBeneath took) and +whole:Route (rt to launchEnvLayer); the cmd role and a non-HA host are unchanged;rev3=census-ruling-rootfs-fleet-followups;basis=names the process for the role log listener: release.ProcessWeb when rt.Rootfs() and the role is run, else none, passed to logEmitter; reads rt.Runtime through Rootfs(); no file, path or env read added or moved file:ReadDir@2929,registry:Host@1770,registry:Host@1982,registry:Host@5787,registry:Host@5985,registry:Host@612,whole:Route@1661,whole:Route@1872,whole:Route@2103,whole:Route@320,whole:Route@4642,whole:Route@5170,whole:Route@5821 0c049e8ff1256f466b0f6e770d65c9e0ba6943f03c377924481e0210c723da30
+@legacy 2467c84503328707bba08f52e54cc3498f611783447a44511b49a4df0b1ea58d internal/activator/prepare.go ExecBackend.prepareWorker legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1: prepare for a worker: the instance's two directories and the worker log socket's, the worker's stale exit records cleared by its name prefix (another worker's and every generation's kept), its log listener bound where root's worker drop-in points StandardOutput=; reads no environment file; binds no control listener; asks no replica gate;rev3=census-ruling-rootfs-fleet-followups;basis=passes the worker name (already checked by release.ValidWorkerName at the top) to logEmitter as the process; no read added or moved file:ReadDir@563,registry:Host@224,registry:Host@440,registry:Host@902,whole:Route@124,whole:Route@809 a22180a3d5c23b92e9c227a45e90e482fc5789baec5345f1151e37773b5941f8
+@legacy 5e26653fcccbee1e5f20286530b4789cd53e32d7984fabcbff14824667457077 internal/activator/logsink.go appLineEmitter legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-fleet-followups;basis=new: the app-line emit function for rt: nil for a nil sink; reads the route account (release.RouteAccount), app and host; a sink holding AppProcess (applog.Sink) gets the process name, otherwise App as before; in-memory log sink only, no file, path or env read registry:App@166,registry:Host@174,whole:Route@161 d3af8b263f021bcba5926116366bf4a4e853a21ef7c14bcaced53dbd75247324
+@legacy d765f7a7dd9ac5f10ac545c84454e8ae9046dc36142c9a3b88e6634613b5fa6b internal/activator/prepare.go ExecBackend.logEmitter legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-fleet-followups;basis=takes a process name and returns appLineEmitter(b.Logs, rt, process); the route account, app and host reads moved into appLineEmitter; no file read whole:Route@114 171f5bc4eca79f08dc335fccac8cd11385b72ce27bded922a71e639b8a8a6ce0
+@legacy 4ed1b4930a5a677b33ea8194fba90f4b9e9c56702129a055be0fb584e008e16d internal/activator/rootfsrelease.go Service.releaseAppLog legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1 [pf R1.5]: new; the writer a release's output goes through: each line to the instance's own app log (a.Logs.App(account, app, host, line)); reads the route's account, app and host for the log's key; no file read;rev3=census-ruling-rootfs-fleet-followups;basis=returns lineEmitter(appLineEmitter(a.Logs, rt, release.ProcessRelease)); the route reads moved into appLineEmitter; no file read whole:Route@106 20871e7bd6d22cf8a1bf733fe8b8f34e9702b2b2f6d661d1ef8140963518ed70
+internal/activator/prepare.go ExecBackend.prepareKeyedAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling zddr4, with no further change from this branch beyond carrying main's new early return into the six-value signature. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): body of the frozen prepareAt, which is now its wrapper; it also returns the instance key's layer and reads no env for the cmd role; same reads, same nested launch paths;rev3=census-ruling-wake-latency-2;basis=takes an optional timer and marks its steps with time.Now() (dirs, admin token, instance key, env, control socket, key gate, logs); no read added or moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, run and seed roles only, under a 30 s context (haSecretsBudget): the token producer is ensureAdminTokenFor(hctx, rt, p) (on this nested path the same beneath producer, EnsureAdminTokenBeneath's, plus the HA mint decision inside it); ensureInstanceKeyFor now gets hctx instead of context.Background(), so the key's bucket read is bounded by 30 s as well as configReadTimeout; the env is launchEnvLayer(hctx, rt) (instanceEnvLayer for a non-HA host; for an HA host one capture, published and acknowledged); a test seam (haLaunchHooks.afterGate, nil in production) is called before the producers. The separate haMintGate and haSecretsReady calls are gone (final fix F2). Sites against main: -registry:Host (the rt.Host+".env" argument EnsureAdminTokenBeneath took) and +whole:Route (rt to launchEnvLayer); the cmd role and a non-HA host are unchanged;rev3=census-ruling-rootfs-fleet-followups;basis=names the process for the role log listener: release.ProcessWeb when rt.Rootfs() and the role is run, else none, passed to logEmitter; reads rt.Runtime through Rootfs(); no file, path or env read added or moved file:ReadDir@2929,registry:Host@1770,registry:Host@1982,registry:Host@5787,registry:Host@5985,registry:Host@612,whole:Route@1661,whole:Route@1872,whole:Route@2103,whole:Route@320,whole:Route@4642,whole:Route@5170,whole:Route@5821 0c049e8ff1256f466b0f6e770d65c9e0ba6943f03c377924481e0210c723da30
+internal/activator/prepare.go ExecBackend.prepareWorker legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1: prepare for a worker: the instance's two directories and the worker log socket's, the worker's stale exit records cleared by its name prefix (another worker's and every generation's kept), its log listener bound where root's worker drop-in points StandardOutput=; reads no environment file; binds no control listener; asks no replica gate;rev3=census-ruling-rootfs-fleet-followups;basis=passes the worker name (already checked by release.ValidWorkerName at the top) to logEmitter as the process; no read added or moved file:ReadDir@563,registry:Host@224,registry:Host@440,registry:Host@902,whole:Route@124,whole:Route@809 a22180a3d5c23b92e9c227a45e90e482fc5789baec5345f1151e37773b5941f8
+internal/activator/logsink.go appLineEmitter legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-fleet-followups;basis=new: the app-line emit function for rt: nil for a nil sink; reads the route account (release.RouteAccount), app and host; a sink holding AppProcess (applog.Sink) gets the process name, otherwise App as before; in-memory log sink only, no file, path or env read registry:App@166,registry:Host@174,whole:Route@161 d3af8b263f021bcba5926116366bf4a4e853a21ef7c14bcaced53dbd75247324
+internal/activator/prepare.go ExecBackend.logEmitter legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-fleet-followups;basis=takes a process name and returns appLineEmitter(b.Logs, rt, process); the route account, app and host reads moved into appLineEmitter; no file read whole:Route@114 171f5bc4eca79f08dc335fccac8cd11385b72ce27bded922a71e639b8a8a6ce0
+internal/activator/rootfsrelease.go Service.releaseAppLog legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1 [pf R1.5]: new; the writer a release's output goes through: each line to the instance's own app log (a.Logs.App(account, app, host, line)); reads the route's account, app and host for the log's key; no file read;rev3=census-ruling-rootfs-fleet-followups;basis=returns lineEmitter(appLineEmitter(a.Logs, rt, release.ProcessRelease)); the route reads moved into appLineEmitter; no file read whole:Route@106 20871e7bd6d22cf8a1bf733fe8b8f34e9702b2b2f6d661d1ef8140963518ed70
+@coverage internal/activator 0debca01a10c2e37b744daed7b60c23788e9dca7d50086cb33eb0bf25e57ad75
+@coverage internal/applog 0f5d06983a3e8b949179ce74443aba0747cdc0a3d730e6189c9cfee4c808f59b
diff --git a/logs_e2e_test.go b/logs_e2e_test.go
index d0939784f..13d0b8352 100644
--- a/logs_e2e_test.go
+++ b/logs_e2e_test.go
@@ -20,65 +20,7 @@ import (
)
func TestE2ELogsThroughConsole(t *testing.T) {
- useTempCredentials(t)
- clearDeploymentEnv(t)
- checkNoRegistry := requireNoRegistryTouch(t)
-
- tmp := t.TempDir()
- relStore := release.NewDirStore(filepath.Join(tmp, "store"))
- seed, pubB64, err := release.GenerateKey()
- if err != nil {
- t.Fatal(err)
- }
- priv, err := release.ParseSigningKey(seed, "e2e")
- if err != nil {
- t.Fatal(err)
- }
- pub, err := release.ParsePublicKey(pubB64, "e2e")
- if err != nil {
- t.Fatal(err)
- }
- cst, err := console.Open(filepath.Join(tmp, "console.db"))
- if err != nil {
- t.Fatal(err)
- }
- t.Cleanup(func() { cst.Close() })
-
- var srv *console.Server
- ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- srv.ServeHTTP(w, r)
- }))
- t.Cleanup(ts.Close)
- srv, err = console.NewServer(console.Config{
- Origin: ts.URL,
- Keymail: "http://keymail.invalid", // never dialled — see e2eDeviceLogin
- Registry: filepath.Join(tmp, "registry.db"),
- Releases: relStore,
- ReleasePub: pub,
- Key: priv,
- AppScheme: "http",
- AppsDomain: "oncarlos.test",
- }, cst)
- if err != nil {
- t.Fatal(err)
- }
-
- const addr = "paul@keymail.dev"
- if err := cst.AddMember(console.OpsAccountID, addr, console.RoleOwner, time.Now()); err != nil {
- t.Fatal(err)
- }
- if _, err := cst.CreateAppIn(console.OpsAccountID, "titogo", addr, time.Now()); err != nil {
- t.Fatal(err)
- }
- token, expiresAt := e2eDeviceLogin(t, ts.URL, cst, addr, "e2e@laptop")
- credFile, err := loadCredentials()
- if err != nil {
- t.Fatal(err)
- }
- credFile.put(credential{Console: ts.URL, Address: addr, Token: token, ExpiresAt: expiresAt})
- if err := credFile.save(); err != nil {
- t.Fatal(err)
- }
+ checkNoRegistry, relStore := startLogsE2E(t)
// A box shipped two chunks: routine output, then a wake failure — the
// #131 case, as the shipping loop would have written it.
@@ -160,3 +102,122 @@ func TestE2ELogsThroughConsole(t *testing.T) {
// a local registry.
checkNoRegistry()
}
+
+// startLogsE2E is a real console.Server over a DirStore, an ops app
+// titogo and a device-flow login for its owner. It returns the
+// no-registry check and the store boxes ship chunks into.
+func startLogsE2E(t *testing.T) (checkNoRegistry func(), relStore *release.DirStore) {
+ t.Helper()
+ useTempCredentials(t)
+ clearDeploymentEnv(t)
+ checkNoRegistry = requireNoRegistryTouch(t)
+
+ tmp := t.TempDir()
+ relStore = release.NewDirStore(filepath.Join(tmp, "store"))
+ seed, pubB64, err := release.GenerateKey()
+ if err != nil {
+ t.Fatal(err)
+ }
+ priv, err := release.ParseSigningKey(seed, "e2e")
+ if err != nil {
+ t.Fatal(err)
+ }
+ pub, err := release.ParsePublicKey(pubB64, "e2e")
+ if err != nil {
+ t.Fatal(err)
+ }
+ cst, err := console.Open(filepath.Join(tmp, "console.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { cst.Close() })
+
+ var srv *console.Server
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ srv.ServeHTTP(w, r)
+ }))
+ t.Cleanup(ts.Close)
+ srv, err = console.NewServer(console.Config{
+ Origin: ts.URL,
+ Keymail: "http://keymail.invalid", // never dialled — see e2eDeviceLogin
+ Registry: filepath.Join(tmp, "registry.db"),
+ Releases: relStore,
+ ReleasePub: pub,
+ Key: priv,
+ AppScheme: "http",
+ AppsDomain: "oncarlos.test",
+ }, cst)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ const addr = "paul@keymail.dev"
+ if err := cst.AddMember(console.OpsAccountID, addr, console.RoleOwner, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := cst.CreateAppIn(console.OpsAccountID, "titogo", addr, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ token, expiresAt := e2eDeviceLogin(t, ts.URL, cst, addr, "e2e@laptop")
+ credFile, err := loadCredentials()
+ if err != nil {
+ t.Fatal(err)
+ }
+ credFile.put(credential{Console: ts.URL, Address: addr, Token: token, ExpiresAt: expiresAt})
+ if err := credFile.save(); err != nil {
+ t.Fatal(err)
+ }
+
+ return checkNoRegistry, relStore
+}
+
+// A rootfs instance's lines name their process end to end (#366 Task 11
+// follow-up): a real applog.Sink tags them as the activator's capture
+// sites do, the drain is shipped as the agent's logshipFlush writes a
+// chunk, and the member reads them through the console with the real
+// runLogs. --field process=<name> narrows to one process; every line stays
+// on the app stream, never "release" (the ship/promote history's).
+func TestE2ELogsNameTheProcess(t *testing.T) {
+ checkNoRegistry, relStore := startLogsE2E(t)
+
+ const host = "titogo.bab.oncarlos.test"
+ sink := applog.NewSink("box1", time.Now)
+ sink.AppProcess(release.OpsAccount, "titogo", host, release.ProcessWeb, `{"msg":"web says hi","process":"spoof"}`)
+ sink.AppProcess(release.OpsAccount, "titogo", host, "jobs", "worker tick")
+ sink.AppProcess(release.OpsAccount, "titogo", host, release.ProcessRelease, "migrations ran")
+ for k, recs := range sink.Drain() {
+ body, err := applog.EncodeChunk(recs)
+ if err != nil {
+ t.Fatal(err)
+ }
+ key, err := applog.ChunkKey(k.Acct, k.App, recs[0].Box, applog.HourOf(recs[0].TS), recs[0].Seq, len(body))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := relStore.Put(context.Background(), key, body, ""); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ buf := captureStdout(t)
+ runLogs([]string{"-app", "titogo", "-account", "ops"})
+ out := buf.String()
+ for _, want := range []string{"web says hi process=web", "worker tick process=jobs", "migrations ran process=release"} {
+ if !strings.Contains(out, want) {
+ t.Errorf("logs stdout missing %q:\n%s", want, out)
+ }
+ }
+ if strings.Contains(out, "spoof") || strings.Contains(out, "[release]") || strings.Count(out, "[app]") != 3 {
+ t.Errorf("want three [app] lines and the platform's process names only:\n%s", out)
+ }
+
+ for _, c := range []struct{ process, want string }{{"web", "web says hi"}, {"jobs", "worker tick"}, {"release", "migrations ran"}} {
+ buf.Reset()
+ runLogs([]string{"-app", "titogo", "-account", "ops", "-field", "process=" + c.process})
+ out := buf.String()
+ if !strings.Contains(out, c.want) || strings.Count(out, "[app]") != 1 {
+ t.Errorf("--field process=%s: want %q alone:\n%s", c.process, c.want, out)
+ }
+ }
+ checkNoRegistry()
+}