carlos / platform Public

edge: hold opted-in event streams while instances sleep (#432)

A browser EventSource opened with carlos_hold=1 on a hibernating
instance is held by the edge while the instance sleeps and resumed
with Last-Event-ID when something else wakes it. A held stream never
counts as activity and never wakes anything.

Activator: held legs admitted and registered under a.mu, cancelled
synchronously before every stop, swap and entry removal. Edge: marked
requests classified once after lookup, hold branch after the password
gate, one stream task per browser relaying whole SSE events through
the route's own proxy, heartbeats, wake-hook and tick reopens, caps,
no shared caching of marked requests. held_streams counters in the
box status snapshot.

Design rev 3 and plan rev 2 approved by Paul (discussion 432). Astra
per-task and whole-branch reviews; census approved. Also fixes a
pre-existing race in run_cutover_witness_test.go.

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

Prompts:

  <task-notification>
  <task-id>bnge9aug2</task-id>
  <tool-use-id>toolu_01Bqvonzn4uJMXiaoBtK1Rv4</tool-use-id>
  <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2133d32c-5178-487f-857e-d1ed11ea0d38/tasks/bnge9aug2.output</output-file>
  <status>completed</status>
  <summary>Background command "Wait for Astra round 2" completed (exit code 0)</summary>
  </task-notification>

  <cross-session-message from="uds:/run/user/1001/cc-socks/2325897.sock" from-name="platform-4e" from-mode="bypass">
  Are you driving rootfs Plan 3 Group W (worktree .claude/worktrees/rootfs-apps-3w, branch rootfs-apps-3-workers; W1a done 5b341104, W1b uncommitted, files last edited 10:19Z)? Paul asked me (platform-4e) what's left on rootfs and whether it's ready to roll to flagship. I won't touch that worktree. If it's yours, please reply: is W1b's implementer still running, what's left in W, and anything you know blocking a flagship roll of v0.29.0+.
  </cross-session-message>

  go ahead.

Squashed from edge-held-streams-432 into main.
Co-Authored-By: claude <claude~paul@keymail.dev>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 412203cbe3dbb72db6414915db98e86002d7e29e parent 20c867c
59 files changed, +9,409 −127
  • docs/superpowers/notes/census-edge-held-streams-claims.md +36 −0
  • docs/superpowers/notes/census-proposal-edge-held-streams.md +70 −0
  • docs/superpowers/notes/edge-held-streams-followups.md +10 −0
  • docs/superpowers/plans/2026-10-28-edge-held-streams.md +338 −0
  • docs/superpowers/plans/CODEX-FINDINGS-edge-held-streams-plan.md +175 −0
  • docs/superpowers/reviews/ASTRA-FINDINGS-edge-held-streams-branch-R1-fixes.md +45 −0
  • docs/superpowers/reviews/ASTRA-FINDINGS-edge-held-streams-branch-R1.md +78 −0
  • docs/superpowers/specs/2026-10-28-edge-held-streams-design.md +497 −0
  • docs/superpowers/specs/CODEX-FINDINGS-edge-held-streams-R2.md +109 −0
  • docs/superpowers/specs/CODEX-FINDINGS-edge-held-streams.md +154 −0
  • docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-streams-R2.md +101 −0
  • docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-streams.md +88 −0
  • internal/activator/activator.go +30 −69
  • internal/activator/activator_test.go +175 −0
  • internal/activator/claimproducer_test.go +2 −2
  • internal/activator/claimwake.go +24 −2
  • internal/activator/hacache.go +20 −0
  • internal/activator/haforward.go +40 −5
  • internal/activator/haforward_test.go +23 −0
  • internal/activator/heldlegs.go +311 −0
  • internal/activator/heldlegs_activity_test.go +173 −0
  • internal/activator/heldlegs_guard_test.go +1,030 −0
  • internal/activator/heldlegs_test.go +613 −0
  • internal/activator/heldstream_e2e_test.go +1,041 −0
  • internal/activator/maintenance.go +6 −2
  • internal/activator/recoveryprobe.go +11 −0
  • internal/activator/seed_exclusion.go +3 −1
  • internal/activator/swap_sim_test.go +245 −7
  • internal/activator/swaphold.go +2 −0
  • internal/domains/rootfs_apex_test.go +6 −0
  • internal/edge/alias_test.go +7 −0
  • internal/edge/assetcatch.go +16 −0
  • internal/edge/edge.go +229 −10
  • internal/edge/edge_test.go +20 −0
  • internal/edge/edgeerrors_test.go +10 −0
  • internal/edge/forwardha.go +35 −2
  • internal/edge/forwardha_test.go +10 −0
  • internal/edge/genedge_test.go +7 −0
  • internal/edge/guard_test.go +6 −0
  • internal/edge/heldleg.go +14 −0
  • internal/edge/heldstream.go +1,008 −0
  • internal/edge/heldstream_dispatch_test.go +594 −0
  • internal/edge/heldstream_sim_test.go +434 −0
  • internal/edge/heldstream_test.go +930 −0
  • internal/edge/homemap.go +21 −0
  • internal/edge/ratelimit_test.go +6 −0
  • internal/edge/reqrecords_test.go +7 −0
  • internal/edge/sse.go +134 −0
  • internal/edge/sse_test.go +68 −0
  • internal/edge/tunnel_e2e_test.go +201 −0
  • internal/edge/usagemeter.go +4 −0
  • internal/edge/usagemeter_test.go +21 −0
  • internal/host/activator_seam.go +10 −0
  • internal/host/agent.go +22 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-edge-held-streams.tsv +66 −0
  • internal/status/snapshot.go +20 −2
  • internal/status/snapshot_test.go +17 −0
  • run_cutover_witness_test.go +35 −25

CI passed — run details

landed from edge-held-streams-432

docs/superpowers/notes/census-edge-held-streams-claims.md

Loading diff…

docs/superpowers/notes/census-proposal-edge-held-streams.md

Loading diff…

docs/superpowers/notes/edge-held-streams-followups.md

Loading diff…

docs/superpowers/plans/2026-10-28-edge-held-streams.md

Loading diff…

docs/superpowers/plans/CODEX-FINDINGS-edge-held-streams-plan.md

Loading diff…

docs/superpowers/reviews/ASTRA-FINDINGS-edge-held-streams-branch-R1-fixes.md

Loading diff…

docs/superpowers/reviews/ASTRA-FINDINGS-edge-held-streams-branch-R1.md

Loading diff…

docs/superpowers/specs/2026-10-28-edge-held-streams-design.md

Loading diff…

docs/superpowers/specs/CODEX-FINDINGS-edge-held-streams-R2.md

Loading diff…

docs/superpowers/specs/CODEX-FINDINGS-edge-held-streams.md

Loading diff…

docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-streams-R2.md

Loading diff…

docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-streams.md

Loading diff…

internal/activator/activator.go

Loading diff…

internal/activator/activator_test.go

Loading diff…

internal/activator/claimproducer_test.go

Loading diff…

internal/activator/claimwake.go

Loading diff…

internal/activator/hacache.go

Loading diff…

internal/activator/haforward.go

Loading diff…

internal/activator/haforward_test.go

Loading diff…

internal/activator/heldlegs.go

Loading diff…

internal/activator/heldlegs_activity_test.go

Loading diff…

internal/activator/heldlegs_guard_test.go

Loading diff…

internal/activator/heldlegs_test.go

Loading diff…

internal/activator/heldstream_e2e_test.go

Loading diff…

internal/activator/maintenance.go

Loading diff…

internal/activator/recoveryprobe.go

Loading diff…

internal/activator/seed_exclusion.go

Loading diff…

internal/activator/swap_sim_test.go

Loading diff…

internal/activator/swaphold.go

Loading diff…

internal/domains/rootfs_apex_test.go

Loading diff…

internal/edge/alias_test.go

Loading diff…

internal/edge/assetcatch.go

Loading diff…

internal/edge/edge.go

Loading diff…

internal/edge/edge_test.go

Loading diff…

internal/edge/edgeerrors_test.go

Loading diff…

internal/edge/forwardha.go

Loading diff…

internal/edge/forwardha_test.go

Loading diff…

internal/edge/genedge_test.go

Loading diff…

internal/edge/guard_test.go

Loading diff…

internal/edge/heldleg.go

Loading diff…

internal/edge/heldstream.go

Loading diff…

internal/edge/heldstream_dispatch_test.go

Loading diff…

internal/edge/heldstream_sim_test.go

Loading diff…

internal/edge/heldstream_test.go

Loading diff…

internal/edge/homemap.go

Loading diff…

internal/edge/ratelimit_test.go

Loading diff…

internal/edge/reqrecords_test.go

Loading diff…

internal/edge/sse.go

Loading diff…

internal/edge/sse_test.go

Loading diff…

internal/edge/tunnel_e2e_test.go

Loading diff…

internal/edge/usagemeter.go

Loading diff…

internal/edge/usagemeter_test.go

Loading diff…

internal/host/activator_seam.go

Loading diff…

internal/host/agent.go

Loading diff…

internal/provision/testdata/plan14-root-reads-chain.tsv

Loading diff…

internal/provision/testdata/plan14-root-reads-edge-held-streams.tsv

Loading diff…

internal/status/snapshot.go

Loading diff…

internal/status/snapshot_test.go

Loading diff…

run_cutover_witness_test.go

Loading diff…