edge: hold up to 1,000 live streams per host; size the box cap
A live page with more than 64 viewers on one app left the rest on a page that never updated: the edge held at most 64 streams per host (carlos_hold=1) and answered the 65th with retry: 30000. PerHost is now 1,000, what Rastrillo's live hub serves per process. PerBox, fixed at 4,096 before, now comes from the box: an eighth of its memory at 256 KiB a stream (measured 232 KiB over TLS and HTTP/2 with the leg open, 95 KiB asleep), never under PerHost, within the open-file limit. A new PerChannel cap of 64 keeps held streams from filling a fleet or link channel's 250 HTTP/2 streams. Proxying past the cap was weighed and not taken (spec §3.6 rev 4). Witness: TestHeldE2EManyStreamsOneHost, 200 streams on one host. Astra R1 READY AFTER FIXES, no P1; census approved on #280. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from edge-held-cap into main.
14 files changed,
+566
−14
docs/superpowers/notes/census-proposal-edge-held-cap.md+19 −0docs/superpowers/notes/edge-held-streams-followups.md+6 −0docs/superpowers/specs/2026-10-28-edge-held-streams-design.md+48 −2docs/superpowers/specs/CODEX-FINDINGS-edge-held-cap.md+39 −0docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-cap.md+95 −0internal/activator/heldstream_e2e_test.go+66 −0internal/edge/heldbudget.go+65 −0internal/edge/heldbudget_linux.go+19 −0internal/edge/heldbudget_other.go+7 −0internal/edge/heldstream.go+29 −9internal/edge/heldstream_test.go+86 −3internal/edge/tunnel_e2e_test.go+81 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-edge-held-cap.tsv+5 −0
CI passed — run details
diff --git a/docs/superpowers/notes/census-proposal-edge-held-cap.md b/docs/superpowers/notes/census-proposal-edge-held-cap.md| new file mode 100644 |
| index 000000000..a5b8aacf5 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-edge-held-cap.md |
| @@ -0,0 +1,19 @@ |
| +# Census approval: edge-held-cap |
| + |
| +Ruling `census-ruling-edge-held-cap`. 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/edge/heldstream.go` `Edge.serveHeld` | body | unchanged (5) | register now takes whether a tunnel or link channel delivered the request (fromTunnel or linkedRequest on the request context, both set only by this process), so channel-delivered streams count against the new PerChannel cap. No read added; the caps themselves come from in-memory config (heldbudget.go reads Sysinfo and RLIMIT_NOFILE of its own process once at package start). | |
| + |
| +Envelopes re-pinned: `internal/edge`. |
| + |
| +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/edge/heldstream.go` `Edge.serveHeld`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): new; runs one held stream. Registers it in the in-memory held set, checks holdsHost against the published map, and runs the heldTask, which opens legs through the activator's AdmitHeldLeg and the route's own proxy. Reads only the request and in-memory state; no bucket, registry or file read of tenant-writable input. Whole-branch fix: calls a nil-in-production test seam (afterMapCheck) after the map check; a reload closing a stream with no response yet now writes the empty event stream; each leg request carries its own in-memory outcome. No read added. |
| + |
| +Seal: `89f2b0e097f2de04bcef403f0b4aaa7a56a17dc7d0000a87993f033e268fc2fa` → `f06c832e5595b5a0c256639131d094a94da4505d0e64586813c357cb7eea8f33`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-edge-held-cap.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/notes/edge-held-streams-followups.md b/docs/superpowers/notes/edge-held-streams-followups.md| index 7302127f0..8832901b9 100644 |
| --- a/docs/superpowers/notes/edge-held-streams-followups.md |
| +++ b/docs/superpowers/notes/edge-held-streams-followups.md |
| @@ -8,3 +8,9 @@ P3s and parked items from the build's reviews (stopping rule 1: none starts a ro |
| - A multi-chunk, slow terminal-body witness for first-leg pass-through (401/5xx); no total-body cap is required by the spec. |
| - A stream closed right after it registers can race its first leg admission (the task ends and cancels the leg; no activity effect). |
| - swapsim mutant M5 panics (close of closed channel) on main as well; pre-existing. |
| + |
| +From `edge-held-cap` (rev 4 caps, 2026-11-20): |
| + |
| +- Hops cap held streams at 64 per destination box (Astra R1 P2-1). A held stream that reaches its holder through another box's edge rides the hop for its life and takes one of `backhaulMaxInflight`'s 64 slots toward that box, counted on the sending edge and shared by every app on the destination. That covers the in-region HA forward as well as the cross-region backhaul: `forwardHAFollow` calls `hopTo` (`forwardha.go`), which takes the slot in `backhaulAdmit` and keeps it for the response's life (`edge.go` `hopTo`), and the busy-client share (`backhaulClientShare`, once the box is half full) applies too. Past it the hop answers 503, which a native `EventSource` treats as fatal, and ordinary hopped requests to that box get 503 as well. So in a region HA pool, viewers whose connection lands on a box that is not the holder are limited to 64 per sending box across all apps, well under the holder's 1,000. Held streams on a hop want their own share of the slots, and the over-cap retry answer rather than a 503; that touches the egress containment ruling (2026-08-24), so it is Paul's call. Unchanged by rev 4, which raises only what the holding edge accepts. |
| +- The unlanded docs page `docs/site/live-streams.md` (plan Task 9, copy approved 2026-11-02, never merged) says "Each instance can have 64 held streams open at once." It needs the rev 4 numbers, and a fresh copy review of that line, before it lands. |
| +- The fleet tunnel's 250 streams per channel are shared by held streams, other long responses and plain requests. Rev 4 caps held streams per channel at 64; ordinary long responses (an unmarked event stream, a slow download) still have no channel-level cap, and a plain request finding the channel full waits. |
diff --git a/docs/superpowers/specs/2026-10-28-edge-held-streams-design.md b/docs/superpowers/specs/2026-10-28-edge-held-streams-design.md| index f6efd7e7c..f6df8208e 100644 |
| --- a/docs/superpowers/specs/2026-10-28-edge-held-streams-design.md |
| +++ b/docs/superpowers/specs/2026-10-28-edge-held-streams-design.md |
| @@ -1,7 +1,8 @@ |
| # Edge-held event streams — design |
| Discussion: carlos/platform #432 (feature request from Rastrillo, with the |
| -amendment in post 835). Status: draft, rev 3, 2026-10-28. |
| +amendment in post 835). Status: rev 4, 2026-11-20 (rev 3, 2026-10-28, shipped |
| +as #432; rev 4 raises the caps in §3.6, branch `edge-held-cap`). |
| Review history: round 1 (Astra, `CODEX-FINDINGS-edge-held-streams.md`): |
| NOT READY, 4 P1 and 6 P2. All ten are accepted in rev 2 and marked |
| @@ -311,7 +312,52 @@ waits through it. |
| ### 3.6 Bounds |
| -- **Per host:** 64 held streams. **Per box:** 4,096. |
| +- **Per host:** 1,000 held streams (rev 4; 64 before). A live event with |
| + more than 64 viewers on one app left the rest on a page that never |
| + updated. 1,000 is what Rastrillo's live hub serves per process |
| + (`live.Config.MaxStreams`), and an app left at systemd's default soft |
| + limit of 1,024 open files cannot take many more, so holding more would |
| + only queue legs the app refuses. |
| +- **Per box:** sized from the box when the edge starts (rev 4; 4,096 |
| + before, fixed). Measured 2026-11-20 over TLS and HTTP/2, one connection |
| + per browser, a held stream costs the edge about 95 KiB and one open file |
| + while its host sleeps, and 232 KiB and two open files (the leg's |
| + socket) with its leg open: three goroutines asleep, seven awake. The |
| + cap is as many streams as fit in an eighth of the box's memory at |
| + 256 KiB each, never fewer than the per-host cap (so every box can hold |
| + one full host), and never more than the open-file limit allows at two |
| + each after a reserve of 8,192 for everything else the edge does. By the |
| + memory the kernel reports (a little under the instance size) that is |
| + 1,000 on a 1 or 2 GiB box, about 2,000 at 4 GiB and about 8,000 at |
| + 16 GiB. The edge's unit sets no `LimitNOFILE`, so it runs near systemd's |
| + hard limit (524,288 on current boxes; Go raises the soft limit to just |
| + under it), |
| + and memory is the bound that matters. The old fixed 4,096 could take |
| + 930 MiB with every leg open, nearly half a 2 GiB box. |
| +- **Per channel:** 64 held streams, all hosts together, for requests a |
| + tunnel or link channel delivered (fleet boxes, linked deployments; |
| + rev 4). Each keeps one HTTP/2 stream of its channel open for its life, |
| + and a channel serves 250 streams at once for every request the hub |
| + sends (`tunnelclient.DefaultLimits`). With the hub's 128 upgrades |
| + (`tunnelUpgradeCap`) that leaves 58 for plain requests; a plain request |
| + that finds none waits for one, so without this cap one busy page could |
| + stall every app on the box. Past it, the same retry answer as any cap. |
| +- **Not proxied past a cap (rev 4, weighed and kept).** Proxying a stream |
| + as an ordinary request when the host is awake and the cap is full was |
| + considered for busy events. It is not done: a proxied stream is |
| + activity, so after the event every tab left open past the cap keeps the |
| + instance awake until the plan's awake ceiling, which is the bill this |
| + design exists to stop; it costs the edge the same memory and files as a |
| + held stream while counting against no cap, so the box bound would no |
| + longer bound anything; and it holds up a stop (G5). The anti-goal stands. |
| + Raising the caps to what the box can afford gives the same viewers the |
| + same stream without any of that. |
| +- **Hops are not raised (rev 4).** A held stream that reaches its holder |
| + through another box's edge (in-region HA forward, cross-region |
| + backhaul) still takes one of the hop's 64 slots toward that box for its |
| + life (`backhaulMaxInflight`), shared by every app there, and past it gets |
| + a 503. In a region HA pool that is the binding limit for viewers who |
| + land on a box other than the holder. See the follow-ups note. |
| - **Maximum hold:** 1 hour per browser connection, then the edge closes it |
| (at an event boundary). The browser reconnects and is held again; the |
| bound is a recycle, not a cut-off, and it limits how stale a held |
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-edge-held-cap.md b/docs/superpowers/specs/CODEX-FINDINGS-edge-held-cap.md| new file mode 100644 |
| index 000000000..a0cce3bcc |
| --- /dev/null |
| +++ b/docs/superpowers/specs/CODEX-FINDINGS-edge-held-cap.md |
| @@ -0,0 +1,39 @@ |
| +Reviewed `cdf98181..53c039755834feaf21bbd4934ec1f37e9555b17c`, round 1. No P1 found. Two P2 findings: |
| + |
| +1. **P2 — Brief §4: the forwarding limitation also affects same-region HA.** |
| + The [follow-up note, line 14](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-cap/docs/superpowers/notes/edge-held-streams-followups.md:14) describes the 64-slot restriction as cross-region only. However, HA forwarding calls `hopTo` at [forwardha.go:485](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-cap/internal/edge/forwardha.go:485), which acquires the same backhaul slot and retains it for the response’s lifetime at [edge.go:4847](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-cap/internal/edge/edge.go:4847). |
| + |
| + **Failure scenario:** 64 held streams forwarded to a same-region holder exhaust the sending edge’s allowance toward that box. Subsequent streams and ordinary requests receive 503 despite capacity remaining under the holder’s new caps. This is pre-existing behavior, not a new merge blocker. |
| + |
| + **Fix:** extend the follow-up to cover same-region HA forwarding; remove the implication that this matters only after cross-region latency routing. Include the shared path’s busy-client restriction at `edge.go:4717–4729`. |
| + |
| + **Fault family:** end-to-end capacity claims must account for intermediate admission limits. |
| + |
| +2. **P2 — Brief §5: idle expiry races the 200-stream witness.** |
| + The test sets a three-second idle period at [heldstream_e2e_test.go:603](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-cap/internal/activator/heldstream_e2e_test.go:603), then wakes once and allows thirty seconds for event delivery at [line 627](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-cap/internal/activator/heldstream_e2e_test.go:627). Meanwhile, its harness sweeps every 50 ms, and idle expiry stops the instance at `activator.go:6069–6083`. |
| + |
| + **Failure scenario:** on a loaded shard, some admissions or child handlers take longer than three seconds. The instance correctly sleeps before those browsers receive the event. Held streams cannot wake it, so the thirty-second wait cannot recover. This is a source-established flake risk; I could not execute the test here. |
| + |
| + **Fix:** control idle expiry in the witness. First observe all 200 events, then trigger expiry through a test-controlled sweep or clock and verify that sleep preserves every stream. |
| + |
| + **Fault family:** test success must depend on observed lifecycle transitions rather than scheduler speed. |
| + |
| +**P3 — Brief §§1/3: minor sizing inaccuracies.** |
| +[heldbudget.go:49](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-cap/internal/edge/heldbudget.go:49) says 2 GiB gives the 1,000 floor; an exact 2 GiB input gives 1,024, as the new test correctly expects. Also, [heldbudget_linux.go:6](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-cap/internal/edge/heldbudget_linux.go:6) says Go raises the soft limit to the hard limit; this toolchain normally raises it to `Max−1` ([syscall/rlimit.go:30](/home/paulca/.local/go-dist/src/syscall/rlimit.go:30)). Readers predicting exact values get different results. Clarify nominal box RAM versus reported RAM and say “near the hard limit.” **Fault family:** sizing descriptions match the implementation. Follow-up only. |
| + |
| +The remaining checks found no additional blocker: |
| + |
| +- Budget division, guarded subtraction and integer clamp are sound. Linux initialization follows `syscall` initialization; the non-Linux implementation avoids Linux-only symbols. |
| +- Channel registration and release balance, including the unmanaged return. Tunnel, fleet, replica and link delivery retain the tunnel mark; direct requests do not acquire it. The implemented cap conservatively aggregates all channel-delivered streams on one edge. |
| +- The 250-stream limit, 128-upgrade cap and full-channel waiting behavior match the code. Memory measurements were not independently reproduced. |
| +- Wake, close and leg cancellation scan streams during lifecycle transitions. Event delivery has no shared-set scan; idle checks are constant-time per stream. Rate slots return at response headers. |
| +- The tunnel witness exercises actual delivery and retry refusal. The unit witnesses cover arithmetic, host/box boundaries and channel-slot reuse. |
| + |
| +Targeted tests could not start because the read-only sandbox denied Go’s work-directory creation. `GOCACHE` was unset. No full suites, cross-builds or census tests ran. `git diff --check` passed; no files changed. |
| + |
| +**Census verdicts** |
| + |
| +- **APPROVE — `Edge.serveHeld`.** Reviewed [heldstream.go:334](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-held-cap/internal/edge/heldstream.go:334) through line 370 and the context-marker producers. The change adds in-memory accounting; route ownership checks, activator admission and proxy selection remain intact. No new tenant-controlled root input is followed. |
| +- **APPROVE — `internal/edge` envelope.** Reviewed the changed configuration, registration, release and budget functions, including `heldbudget_linux.go:9–18` and `heldbudget_other.go:1–7`. New reads obtain kernel memory information and this process’s resource limit. No new file, executable or tenant-selected input is opened, and no authority check is weakened. |
| + |
| +**READY AFTER FIXES** |
| \ No newline at end of file |
diff --git a/docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-cap.md b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-cap.md| new file mode 100644 |
| index 000000000..0c33872e7 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/CODEX-REVIEW-BRIEF-edge-held-cap.md |
| @@ -0,0 +1,95 @@ |
| +# Review brief: branch edge-held-cap (held-stream caps, spec rev 4), round 1 of 3 |
| + |
| +Repo carlos/platform, branch `edge-held-cap`, commit cc07354138e1d1b84bf8e45088a10888c6242f32. |
| +Under review: the diff `cdf98181c40def06a8ebc780c2c58a04e42e0c59..cc07354138e1d1b84bf8e45088a10888c6242f32` |
| +(`git diff cdf98181..HEAD`), and the census card |
| +`docs/superpowers/notes/census-proposal-edge-held-cap.md`. |
| +Authorities: `docs/superpowers/specs/2026-10-28-edge-held-streams-design.md` |
| +(rev 3 merged on main as #432; this branch's §3.6 is the rev 4 text under |
| +review), `AGENTS.md` (census section). |
| + |
| +You are an independent reviewer. Read the diff, then the code it names, |
| +and check every claim against that code. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul approved raising the held-stream cap on the platform (2026-11-20). |
| +- Post 835's anti-goal (no proxied fallback past a cap) is kept; the |
| + branch records the alternative as weighed in §3.6. Do not propose the |
| + fallback. |
| +- No release or roll is part of this branch. |
| + |
| +## What to check |
| + |
| +1. **The caps.** `internal/edge/heldbudget.go`: `heldPerBox(mem, nofile)` |
| + and its constants. Is the arithmetic right (overflow, unsigned |
| + underflow, clamp), and do the stated numbers in §3.6 and the comments |
| + follow from it? Is reading `syscall.Sysinfo` and `RLIMIT_NOFILE` at |
| + package init correct on Linux amd64/arm64 (Go has already raised the |
| + soft limit by then?), and does `heldbudget_other.go` keep darwin and |
| + windows building? |
| +2. **The per-channel cap.** `heldSet.register(host, channel)` and |
| + `finish` in `internal/edge/heldstream.go`: is `channel` counted and |
| + released exactly once on every path a stream ends (including the |
| + unmanaged early return in `serveHeld`)? Is |
| + `fromTunnel(ctx) || linkedRequest(ctx)` the right test for "this |
| + request holds one of a channel's HTTP/2 streams"? Are there paths where |
| + a held stream rides a channel and is not counted (replica arm, link |
| + arm, fleet forward), or where a direct request is wrongly counted? |
| +3. **The sizing claims.** Spec §3.6 rev 4 says a held stream costs about |
| + 95 KiB / 1 fd asleep and 232 KiB / 2 fds awake (measured), the edge |
| + unit has no LimitNOFILE, a channel serves 250 streams with 128 kept for |
| + upgrades, and a plain request waits when the channel is full (x/net |
| + v0.62.0 `awaitOpenSlotForStreamLocked`). Check what you can against |
| + the code: `internal/host/units/carlos-edge.service`, |
| + `internal/tunnelclient/upgrade.go`, `internal/edge/upgrades.go`, |
| + `internal/edge/tunnel.go` transportFor. |
| +4. **What a 1,000-stream host does elsewhere.** Anything in the edge or |
| + activator that is O(streams) per event or per tick under `heldSet.mu` |
| + or `a.mu`, or bounded somewhere else at 64 (backhaul, HA forward, |
| + rate limit, plan throttle), that makes 1,000 per host unsafe or |
| + untrue. The follow-ups note already lists the cross-region backhaul |
| + slot cap; say whether anything else belongs there or blocks. |
| +5. **The witnesses.** `TestHeldE2EManyStreamsOneHost` |
| + (`internal/activator/heldstream_e2e_test.go`), |
| + `TestTunnelHeldStreamsCappedPerChannel` |
| + (`internal/edge/tunnel_e2e_test.go`), `TestHeldPerBox`, |
| + `TestHeldSetDefaultCaps`, `TestHeldSetPerChannel` |
| + (`internal/edge/heldstream_test.go`). Do they prove what they claim, |
| + and are they likely to flake on a loaded CI shard (timings, 200 |
| + connections)? |
| +6. **Census.** Give a verdict (approve or reject, citing the lines you |
| + read) for the unit `internal/edge/heldstream.go` `Edge.serveHeld` and |
| + for the re-pinned envelope `internal/edge`, by the rule in the card: |
| + 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, or weakens a check root relies on. |
| + |
| +## 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. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). Then the census verdicts. End with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +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/heldstream_e2e_test.go b/internal/activator/heldstream_e2e_test.go| index 23d5e5506..53596c8fe 100644 |
| --- a/internal/activator/heldstream_e2e_test.go |
| +++ b/internal/activator/heldstream_e2e_test.go |
| @@ -589,6 +589,72 @@ func TestHeldE2ESleepFastDrain(t *testing.T) { |
| } |
| } |
| +// heldLoadStreams is the load witness's browsers on one host: well past the |
| +// old per-host cap of 64. |
| +const heldLoadStreams = 200 |
| + |
| +// The cap (§3.6, rev 4): one host holds far more than 64 streams on the |
| +// production caps. heldLoadStreams browsers connect to one asleep host; every |
| +// one is held by the edge, none is refused, and nothing wakes. A plain |
| +// request wakes the host: every stream opens its leg on the one child and |
| +// every browser gets the next event. The streams are still not activity: |
| +// the instance sleeps again under all of them, and they stay open. |
| +// |
| +// The idle window is long enough that the host cannot sleep while a loaded |
| +// machine is still opening legs; once every browser has its event, the |
| +// plans idle hook (SetIdleFor, which can only shorten it) lets the next |
| +// sweep put it to sleep. |
| +func TestHeldE2EManyStreamsOneHost(t *testing.T) { |
| + h := newHeldE2E(t, heldE2EOpts{idle: 5 * time.Minute}) |
| + if h.cfg.PerHost != edge.DefaultHeldConfig.PerHost || h.cfg.PerHost < heldLoadStreams { |
| + t.Fatalf("PerHost %d: the witness runs the production cap, at least %d", h.cfg.PerHost, heldLoadStreams) |
| + } |
| + if h.cfg.PerBox < heldLoadStreams { |
| + t.Fatalf("PerBox %d on this machine (its memory or open-file limit), want at least %d", h.cfg.PerBox, heldLoadStreams) |
| + } |
| + bs := make([]*sseBrowser, heldLoadStreams) |
| + cs := make([]*sseConn, heldLoadStreams) |
| + for i := range bs { |
| + bs[i] = newBrowser(t, h.front.URL, heldPath) |
| + cs[i] = bs[i].connect() |
| + if cs[i].resp.StatusCode != http.StatusOK || cs[i].ended() { |
| + t.Fatalf("browser %d: status %d, ended %v body %q, want a held stream", i+1, cs[i].resp.StatusCode, cs[i].ended(), cs[i].body) |
| + } |
| + } |
| + if st := h.e.HeldStreamStats(); st.Held != heldLoadStreams || st.Hosts[e2eHost] != heldLoadStreams || st.OverCap != 0 { |
| + t.Fatalf("held-stream stats %+v, want all %d held for %s and none over a cap", st, heldLoadStreams, e2eHost) |
| + } |
| + if n := len(h.starts()); n != 0 || !h.asleep() { |
| + t.Fatalf("%d child starts with only held streams open, want none", n) |
| + } |
| + |
| + pid := h.wake() |
| + h.appendEvent("e1") |
| + for i, b := range bs { |
| + waitE2E(t, 30*time.Second, fmt.Sprintf("browser %d's event", i+1), func() bool { return b.eventCount() >= 1 }) |
| + ev, _, _ := b.snapshot() |
| + wantEvents(t, ev, 1) |
| + } |
| + if legs := h.liveReqs(pid); len(legs) != heldLoadStreams { |
| + t.Fatalf("%d legs on the woken child, want one per stream, %d", len(legs), heldLoadStreams) |
| + } |
| + |
| + h.a.SetIdleFor(func(registry.Route) time.Duration { return time.Millisecond }) |
| + waitE2E(t, 30*time.Second, "the instance to sleep under the open streams", h.asleep) |
| + h.shutdownOf(pid, 10*time.Second) |
| + for i, c := range cs { |
| + if c.ended() { |
| + t.Fatalf("browser %d's stream ended with the instance's sleep", i+1) |
| + } |
| + } |
| + if st := h.e.HeldStreamStats(); st.Held != heldLoadStreams || st.OverCap != 0 { |
| + t.Fatalf("held-stream stats after the sleep %+v, want all %d still held", st, heldLoadStreams) |
| + } |
| + if n := len(h.starts()); n != 1 { |
| + t.Fatalf("%d child starts, want 1 (the plain wake)", n) |
| + } |
| +} |
| + |
| // Case 4: events 1-2 relayed; the instance sleeps; a plain request wakes it |
| // and the test appends event 3. The stream resumes on the new process with |
| // Last-Event-ID 2, and the browser receives event 3 next, with no duplicate. |
diff --git a/internal/edge/heldbudget.go b/internal/edge/heldbudget.go| new file mode 100644 |
| index 000000000..7361e457b |
| --- /dev/null |
| +++ b/internal/edge/heldbudget.go |
| @@ -0,0 +1,65 @@ |
| +package edge |
| + |
| +// The held-stream caps (spec 2026-10-28-edge-held-streams-design.md §3.6, |
| +// rev 4) and the box budget PerBox comes from. |
| + |
| +const ( |
| + // heldPerHost is the most streams one host holds on one edge. Rastrillo's |
| + // live hub serves at most 1,000 streams per process (live.Config |
| + // MaxStreams), and an app left at systemd's default soft limit of 1,024 |
| + // open files cannot take many more, so holding more would only queue |
| + // legs the app refuses. |
| + heldPerHost = 1000 |
| + |
| + // heldStreamCost is the most one held stream is taken to cost the edge in |
| + // memory. Measured 2026-11-20 over TLS and HTTP/2, one connection per |
| + // browser: about 95 KiB while the host sleeps and 232 KiB with its leg |
| + // open (seven goroutines and their buffers); rounded up. |
| + heldStreamCost = 256 << 10 |
| + |
| + // heldMemoryShare: held streams, every one with its leg open, may take |
| + // 1/heldMemoryShare of the box's memory. |
| + heldMemoryShare = 8 |
| + |
| + // heldStreamFiles is the open files one held stream takes: the browser's |
| + // connection, and the leg's while the host is awake. |
| + heldStreamFiles = 2 |
| + |
| + // heldFileReserve is the open files left for everything else the edge |
| + // does before held streams may take any. |
| + heldFileReserve = 8192 |
| + |
| + // heldPerChannel caps the streams held for requests a tunnel or link |
| + // channel delivered (fleet boxes, linked deployments), all channels |
| + // together. Each keeps one HTTP/2 stream of its channel open for its life, |
| + // and a channel serves 250 at once (tunnelclient.DefaultLimits) for every |
| + // request the hub sends: with the hub's 128 upgrades (tunnelUpgradeCap) |
| + // this leaves 58 for plain requests. A plain request finding none waits |
| + // for one, so without this cap one busy page could stall every app on |
| + // the box. |
| + heldPerChannel = 64 |
| +) |
| + |
| +// heldPerBox is the box's cap on held streams: as many as fit in |
| +// 1/heldMemoryShare of memBytes at heldStreamCost each, never fewer than |
| +// heldPerHost so that every box can hold one full host, and never more than |
| +// the open-file limit nofile leaves room for after heldFileReserve. A zero |
| +// memBytes or nofile means unknown, and that bound is left out. |
| +// |
| +// For scale, by the memory the kernel reports (a little under the instance |
| +// size): a 1 or 2 GiB box gets 1,000 (the floor), 4 GiB about 2,000, 8 GiB |
| +// about 4,000 and 16 GiB about 8,000. |
| +func heldPerBox(memBytes, nofile uint64) int { |
| + n := uint64(heldPerHost) |
| + if m := memBytes / heldMemoryShare / heldStreamCost; m > n { |
| + n = m |
| + } |
| + if nofile > 0 { |
| + f := uint64(0) |
| + if nofile > heldFileReserve { |
| + f = (nofile - heldFileReserve) / heldStreamFiles |
| + } |
| + n = min(n, f) |
| + } |
| + return int(min(n, 1<<30)) |
| +} |
diff --git a/internal/edge/heldbudget_linux.go b/internal/edge/heldbudget_linux.go| new file mode 100644 |
| index 000000000..89b0f0e77 |
| --- /dev/null |
| +++ b/internal/edge/heldbudget_linux.go |
| @@ -0,0 +1,19 @@ |
| +package edge |
| + |
| +import "syscall" |
| + |
| +// heldBoxLimits reads the box's memory and this process's open-file limit |
| +// for heldPerBox, once, when the package starts. By then the syscall package |
| +// has raised the soft limit to just under the hard one. Either is 0 when it |
| +// cannot be read. |
| +func heldBoxLimits() (memBytes, nofile uint64) { |
| + var si syscall.Sysinfo_t |
| + if syscall.Sysinfo(&si) == nil { |
| + memBytes = uint64(si.Totalram) * uint64(si.Unit) |
| + } |
| + var rl syscall.Rlimit |
| + if syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rl) == nil { |
| + nofile = rl.Cur |
| + } |
| + return memBytes, nofile |
| +} |
diff --git a/internal/edge/heldbudget_other.go b/internal/edge/heldbudget_other.go| new file mode 100644 |
| index 000000000..012d7d34e |
| --- /dev/null |
| +++ b/internal/edge/heldbudget_other.go |
| @@ -0,0 +1,7 @@ |
| +//go:build !linux |
| + |
| +package edge |
| + |
| +// heldBoxLimits is unknown off Linux, where no box runs: heldPerBox then |
| +// gives heldPerHost. |
| +func heldBoxLimits() (memBytes, nofile uint64) { return 0, 0 } |
diff --git a/internal/edge/heldstream.go b/internal/edge/heldstream.go| index 213c229dc..28092def2 100644 |
| --- a/internal/edge/heldstream.go |
| +++ b/internal/edge/heldstream.go |
| @@ -28,8 +28,10 @@ import ( |
| // HeldConfig holds the held-stream bounds and timings. It is exported so |
| // tests in other packages can shorten it (SetHeldConfig). |
| type HeldConfig struct { |
| - // PerHost and PerBox cap the streams held at once (§3.6). |
| - PerHost, PerBox int |
| + // PerHost and PerBox cap the streams held at once (§3.6). PerChannel |
| + // caps, within PerBox, the streams held for requests a tunnel or link |
| + // channel delivered, all channels together. |
| + PerHost, PerBox, PerChannel int |
| // MaxHold recycles a browser connection; Commit is how long the browser |
| // may wait for a first response; LegHeader bounds a leg's response |
| // headers; WriteDeadline bounds one downstream write; Tick is the |
| @@ -43,8 +45,14 @@ type HeldConfig struct { |
| ShortLegsToClose int |
| } |
| -// DefaultHeldConfig is the spec's values. |
| -var DefaultHeldConfig = HeldConfig{64, 4096, time.Hour, 2 * time.Second, 10 * time.Second, 10 * time.Second, 25 * time.Second, time.Second, 30 * time.Second, 30 * time.Second, 5} |
| +// DefaultHeldConfig is the spec's values. PerBox is this box's own, from its |
| +// memory and open-file limit (heldbudget.go). |
| +var DefaultHeldConfig = HeldConfig{ |
| + PerHost: heldPerHost, PerBox: heldPerBox(heldBoxLimits()), PerChannel: heldPerChannel, |
| + MaxHold: time.Hour, Commit: 2 * time.Second, LegHeader: 10 * time.Second, WriteDeadline: 10 * time.Second, Tick: 25 * time.Second, |
| + ReopenSpacing: time.Second, ShortLeg: 30 * time.Second, BackoffCap: 30 * time.Second, |
| + ShortLegsToClose: 5, |
| +} |
| // SetHeldConfig replaces the held set with an empty one using c. Call it |
| // before serving: streams held by the old set are not moved. |
| @@ -82,6 +90,8 @@ type heldSet struct { |
| mu sync.Mutex |
| byHost map[string]map[*heldStream]struct{} |
| total int |
| + // channel is how many of total a tunnel or link channel delivered. |
| + channel int |
| // Counters (spec §3.9), under mu. |
| everHeld bool |
| resumes int64 |
| @@ -103,6 +113,7 @@ type heldSet struct { |
| // goroutines send its task. |
| type heldStream struct { |
| host string |
| + channel bool // a tunnel or link channel delivered it (PerChannel) |
| wakeC chan struct{} // buffered 1; a full buffer drops the signal |
| closeC chan struct{} // closed once by closeHost |
| closeOnce sync.Once |
| @@ -112,16 +123,19 @@ func newHeldSet(cfg HeldConfig) *heldSet { |
| return &heldSet{cfg: cfg, byHost: make(map[string]map[*heldStream]struct{})} |
| } |
| -// register adds a stream for host, or returns nil over a cap. |
| -func (s *heldSet) register(host string) *heldStream { |
| +// register adds a stream for host, or returns nil over a cap. channel says |
| +// a tunnel or link channel delivered the request: such a stream keeps one of |
| +// its channel's HTTP/2 streams open for its life, so they have their own cap |
| +// (§3.6). |
| +func (s *heldSet) register(host string, channel bool) *heldStream { |
| s.mu.Lock() |
| defer s.mu.Unlock() |
| s.everHeld = true |
| - if s.total >= s.cfg.PerBox || len(s.byHost[host]) >= s.cfg.PerHost { |
| + if s.total >= s.cfg.PerBox || len(s.byHost[host]) >= s.cfg.PerHost || channel && s.channel >= s.cfg.PerChannel { |
| s.overCap++ |
| return nil |
| } |
| - st := &heldStream{host: host, wakeC: make(chan struct{}, 1), closeC: make(chan struct{})} |
| + st := &heldStream{host: host, channel: channel, wakeC: make(chan struct{}, 1), closeC: make(chan struct{})} |
| m := s.byHost[host] |
| if m == nil { |
| m = make(map[*heldStream]struct{}) |
| @@ -129,6 +143,9 @@ func (s *heldSet) register(host string) *heldStream { |
| } |
| m[st] = struct{}{} |
| s.total++ |
| + if channel { |
| + s.channel++ |
| + } |
| return st |
| } |
| @@ -213,6 +230,9 @@ func (s *heldSet) finish(st *heldStream, r heldCloseReason) { |
| if _, ok := m[st]; ok { |
| delete(m, st) |
| s.total-- |
| + if st.channel { |
| + s.channel-- |
| + } |
| } |
| if len(m) == 0 { |
| delete(s.byHost, st.host) |
| @@ -318,7 +338,7 @@ func (e *Edge) serveHeld(w http.ResponseWriter, r *http.Request, rt registry.Rou |
| if s.beforeRegister != nil { |
| s.beforeRegister() |
| } |
| - st = s.register(rt.Host) |
| + st = s.register(rt.Host, fromTunnel(r.Context()) || linkedRequest(r.Context())) |
| } |
| if st == nil { |
| d := DefaultHeldConfig.WriteDeadline |
diff --git a/internal/edge/heldstream_test.go b/internal/edge/heldstream_test.go| index 9b575509d..f59c159bd 100644 |
| --- a/internal/edge/heldstream_test.go |
| +++ b/internal/edge/heldstream_test.go |
| @@ -28,7 +28,7 @@ const heldTestHost = "shop.example.com" |
| // their own. |
| func heldTestConfig() HeldConfig { |
| return HeldConfig{ |
| - PerHost: 64, PerBox: 4096, |
| + PerHost: 64, PerBox: 4096, PerChannel: 64, |
| MaxHold: 2 * time.Second, Commit: time.Minute, LegHeader: time.Second, |
| // The brief's 30 ms write deadline is set only by the tests about |
| // deadlines; elsewhere a starved test process must not turn a slow |
| @@ -684,12 +684,95 @@ func TestHeldConfigOnNew(t *testing.T) { |
| if e.held == nil || e.held.cfg != heldTestConfig() { |
| t.Fatal("SetHeldConfig did not replace the held set") |
| } |
| - if DefaultHeldConfig.MaxHold != time.Hour || DefaultHeldConfig.Tick != 25*time.Second || DefaultHeldConfig.PerHost != 64 || |
| - DefaultHeldConfig.PerBox != 4096 || DefaultHeldConfig.ShortLegsToClose != 5 { |
| + if DefaultHeldConfig.MaxHold != time.Hour || DefaultHeldConfig.Tick != 25*time.Second || DefaultHeldConfig.PerHost != 1000 || |
| + DefaultHeldConfig.PerBox != heldPerBox(heldBoxLimits()) || DefaultHeldConfig.PerChannel != 64 || DefaultHeldConfig.ShortLegsToClose != 5 { |
| t.Fatalf("DefaultHeldConfig %+v", DefaultHeldConfig) |
| } |
| } |
| +// PerBox is sized from the box (§3.6): an eighth of its memory at 256 KiB a |
| +// stream, never under PerHost, and never more than its open files allow |
| +// after the reserve, two a stream. Zero means unknown. |
| +func TestHeldPerBox(t *testing.T) { |
| + const gib = 1 << 30 |
| + for _, c := range []struct { |
| + mem, nofile uint64 |
| + want int |
| + }{ |
| + {0, 0, 1000}, // nothing known: one full host |
| + {1 * gib, 524288, 1000}, // the floor |
| + {1900 << 20, 524288, 1000}, // a 2 GiB box's MemTotal: the floor |
| + {2 * gib, 524288, 1024}, // memory decides |
| + {3 * gib, 524288, 1536}, // memory decides |
| + {16 * gib, 524288, 8192}, // memory decides |
| + {64 * gib, 0, 32768}, // no file limit known |
| + {16 * gib, 10192, 1000}, // files decide: (10192-8192)/2 |
| + {16 * gib, 9192, 500}, // files decide, below the floor |
| + {16 * gib, 8192, 0}, // nothing past the reserve |
| + {0, 1024, 0}, // nothing past the reserve |
| + {1 << 62, 1 << 62, 1 << 30}, // clamped to an int on every platform |
| + } { |
| + if got := heldPerBox(c.mem, c.nofile); got != c.want { |
| + t.Errorf("heldPerBox(%d, %d) = %d, want %d", c.mem, c.nofile, got, c.want) |
| + } |
| + } |
| +} |
| + |
| +// The production per-host cap (§3.6): heldPerHost streams for one host, then |
| +// the over-cap answer; another host still has room until PerBox. |
| +func TestHeldSetDefaultCaps(t *testing.T) { |
| + cfg := DefaultHeldConfig |
| + cfg.PerBox = heldPerHost + 1 // this machine's PerBox is not the subject |
| + s := newHeldSet(cfg) |
| + for i := range heldPerHost { |
| + if s.register("a.example.com", false) == nil { |
| + t.Fatalf("stream %d refused under the per-host cap", i+1) |
| + } |
| + } |
| + if s.register("a.example.com", false) != nil { |
| + t.Fatalf("stream %d admitted over the per-host cap", heldPerHost+1) |
| + } |
| + if s.register("b.example.com", false) == nil { |
| + t.Fatal("another host refused under the box cap") |
| + } |
| + if s.register("c.example.com", false) != nil { |
| + t.Fatal("admitted over the box cap") |
| + } |
| + if st, _ := s.stats(); st.Held != heldPerHost+1 || st.Hosts["a.example.com"] != heldPerHost || st.OverCap != 2 { |
| + t.Fatalf("stats %+v", st) |
| + } |
| +} |
| + |
| +// Streams a tunnel or link channel delivered stop at PerChannel, all hosts |
| +// together, whatever room PerHost and PerBox leave; streams the box's own |
| +// listener took are not counted against it; a finished channel stream gives |
| +// its place back. |
| +func TestHeldSetPerChannel(t *testing.T) { |
| + cfg := heldTestConfig() |
| + cfg.PerChannel = 2 |
| + s := newHeldSet(cfg) |
| + first := s.register("a.example.com", true) |
| + if first == nil || s.register("b.example.com", true) == nil { |
| + t.Fatal("channel stream refused under PerChannel") |
| + } |
| + if s.register("c.example.com", true) != nil { |
| + t.Fatal("channel stream admitted over PerChannel") |
| + } |
| + if s.register("c.example.com", false) == nil { |
| + t.Fatal("a direct stream was refused by the channel cap") |
| + } |
| + s.finish(first, heldCloseClientGone) |
| + if s.register("c.example.com", true) == nil { |
| + t.Fatal("a finished channel stream did not give its place back") |
| + } |
| + if s.register("d.example.com", true) != nil { |
| + t.Fatal("channel stream admitted over PerChannel after the swap") |
| + } |
| + if st, _ := s.stats(); st.Held != 3 || st.OverCap != 2 { |
| + t.Fatalf("stats %+v, want 3 held and 2 over a cap", st) |
| + } |
| +} |
| + |
| func TestStripHoldMarker(t *testing.T) { |
| for _, c := range []struct { |
| in, out string |
diff --git a/internal/edge/tunnel_e2e_test.go b/internal/edge/tunnel_e2e_test.go| index f6fe04f16..496763c9e 100644 |
| --- a/internal/edge/tunnel_e2e_test.go |
| +++ b/internal/edge/tunnel_e2e_test.go |
| @@ -322,6 +322,87 @@ func TestTunnelForwardsHoldMarkerAndSkipsCache(t *testing.T) { |
| } |
| } |
| +// TestTunnelHeldStreamsCappedPerChannel: a held stream the tunnel delivered |
| +// keeps one of the channel's HTTP/2 streams for its life, so the box holds |
| +// at most PerChannel of them (edge-held streams spec §3.6) and answers the |
| +// next with the over-cap retry, through the real hub and tunnel client loop. |
| +func TestTunnelHeldStreamsCappedPerChannel(t *testing.T) { |
| + const host = "shop.example.com" |
| + reg := tunnelRoute(t, registry.Route{ |
| + Host: host, Kind: "instance", Status: "ready", Tunnel: "pi-box", Hibernate: true, |
| + }) |
| + hubEdge, err := New(reg, nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + srv := httptest.NewServer(hubEdge) |
| + defer srv.Close() |
| + u, err := url.Parse(srv.URL) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + hub := NewTunnelHub(u.Hostname(), map[string]string{"pi-box": "sekrit"}) |
| + hubEdge.EnableTunnels(hub) |
| + if err := hubEdge.Reload(); err != nil { |
| + t.Fatal(err) |
| + } |
| + |
| + boxReg := openReg(t) |
| + if err := boxReg.Upsert(registry.Route{Host: host, Kind: "instance", Addr: "127.0.0.1:1", Status: "ready", App: "web", Hibernate: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + act := &scriptActivator{} |
| + act.asleep.Store(true) |
| + boxEdge, err := New(boxReg, act) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(boxEdge.probers.Stop) |
| + cfg := heldTestConfig() |
| + cfg.MaxHold = 30 * time.Second |
| + cfg.PerChannel = 1 |
| + boxEdge.SetHeldConfig(cfg) |
| + stop := startFakeRemoteHost(t, srv.URL, "pi-box", "sekrit", boxEdge) |
| + defer stop() |
| + waitForTunnelState(t, hub, "pi-box", "connected", e2eReconnectBound) |
| + |
| + ctx, cancel := context.WithCancel(context.Background()) |
| + defer cancel() |
| + open := func() *http.Response { |
| + t.Helper() |
| + req, err := http.NewRequestWithContext(ctx, http.MethodGet, srv.URL+"/live?carlos_hold=1", nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + req.Host = host |
| + req.Header.Set("Accept", "text/event-stream") |
| + req.Header.Set("Accept-Encoding", "identity") |
| + resp, err := http.DefaultClient.Do(req) |
| + if err != nil { |
| + t.Fatalf("held request through tunnel: %v", err) |
| + } |
| + t.Cleanup(func() { resp.Body.Close() }) |
| + return resp |
| + } |
| + first := open() |
| + if got, _ := readFor(first.Body, 300*time.Millisecond); first.StatusCode != http.StatusOK || !strings.Contains(got, ": ping\n") { |
| + t.Fatalf("first: status %d body %q, want the box's held stream", first.StatusCode, got) |
| + } |
| + // The retry answer ends its response, so the read ends with io.EOF; a |
| + // held stream would still be open when the bound passes. |
| + second := open() |
| + body, err := readFor(second.Body, 5*time.Second) |
| + if err != io.EOF || second.StatusCode != http.StatusOK || body != "retry: 30000\n\n" { |
| + t.Fatalf("second: status %d body %q err %v, want the over-cap retry, then the end", second.StatusCode, body, err) |
| + } |
| + if st := boxEdge.HeldStreamStats(); st.Held != 1 || st.OverCap != 1 { |
| + t.Fatalf("box held-stream stats %+v, want 1 held and 1 over a cap", st) |
| + } |
| + if n := act.admits.Load(); n != 0 { |
| + t.Fatalf("box activator admitted %d legs for an asleep host", n) |
| + } |
| +} |
| + |
| // TestTunnelMarkedResponseNeverStored: the storage half of §7's hub cache |
| // bypass (whole-branch fix P2-4). The box answers a marked request with a |
| // finite, explicitly cacheable response, which the hub would store for an |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index ca75f7070..f9e34d8b4 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -264,3 +264,4 @@ plan14-root-reads-replica-wake-gap.tsv 837b586c0aa17936bc64201245a86c3fd66c58e7f |
| plan14-root-reads-replica-wake-gap-r3.tsv 460c6557a81afc8e5a73db79b8673a7495f84c67a0457e69a0e8443f17a265e7 |
| plan14-root-reads-replica-wake-gap-ch.tsv 6c3e03c493dbca78fc128355f071caa2b2d5f22674b98994cd85a0cf63d40ca8 |
| plan14-root-reads-plan-domains-2a.tsv 89f2b0e097f2de04bcef403f0b4aaa7a56a17dc7d0000a87993f033e268fc2fa |
| +plan14-root-reads-edge-held-cap.tsv f06c832e5595b5a0c256639131d094a94da4505d0e64586813c357cb7eea8f33 |
diff --git a/internal/provision/testdata/plan14-root-reads-edge-held-cap.tsv b/internal/provision/testdata/plan14-root-reads-edge-held-cap.tsv| new file mode 100644 |
| index 000000000..f249c16dd |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-edge-held-cap.tsv |
| @@ -0,0 +1,5 @@ |
| +# Census overlay edge-held-cap, written by census-propose (#369). census-ruling-edge-held-cap, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-edge-held-cap.md. |
| +# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy 1688e98a17fa7ec7c0f1617d35f0ab89d400f19349ec0ff5388fc2d926da8a4d internal/edge/heldstream.go Edge.serveHeld legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): new; runs one held stream. Registers it in the in-memory held set, checks holdsHost against the published map, and runs the heldTask, which opens legs through the activator's AdmitHeldLeg and the route's own proxy. Reads only the request and in-memory state; no bucket, registry or file read of tenant-writable input. Whole-branch fix: calls a nil-in-production test seam (afterMapCheck) after the map check; a reload closing a stream with no response yet now writes the empty event stream; each leg request carries its own in-memory outcome. No read added.;rev3=census-ruling-edge-held-cap;basis=register now takes whether a tunnel or link channel delivered the request (fromTunnel or linkedRequest on the request context, both set only by this process), so channel-delivered streams count against the new PerChannel cap. No read added; the caps themselves come from in-memory config (heldbudget.go reads Sysinfo and RLIMIT_NOFILE of its own process once at package start). registry:Host@245,registry:Host@793,registry:Host@996,whole:Route@1005,whole:Route@1009 59917cca66ea136fae16b1d04550937ec3ff26a2ea29f175aa90267c2684bf80 |
| +internal/edge/heldstream.go Edge.serveHeld legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): new; runs one held stream. Registers it in the in-memory held set, checks holdsHost against the published map, and runs the heldTask, which opens legs through the activator's AdmitHeldLeg and the route's own proxy. Reads only the request and in-memory state; no bucket, registry or file read of tenant-writable input. Whole-branch fix: calls a nil-in-production test seam (afterMapCheck) after the map check; a reload closing a stream with no response yet now writes the empty event stream; each leg request carries its own in-memory outcome. No read added.;rev3=census-ruling-edge-held-cap;basis=register now takes whether a tunnel or link channel delivered the request (fromTunnel or linkedRequest on the request context, both set only by this process), so channel-delivered streams count against the new PerChannel cap. No read added; the caps themselves come from in-memory config (heldbudget.go reads Sysinfo and RLIMIT_NOFILE of its own process once at package start). registry:Host@245,registry:Host@793,registry:Host@996,whole:Route@1005,whole:Route@1009 59917cca66ea136fae16b1d04550937ec3ff26a2ea29f175aa90267c2684bf80 |
| +@coverage internal/edge 70d6216036dea9403349b631794f447bd3a914640495513d5514689230b81af9 |