~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/stream

jetstream v2 in zig · mirror of https://tangled.org/zat.dev/stream

0
0
maintenance/2026-11
1015 lines · 49.4 KB Raw History
# Full-network experiment — July 2026

This is the durable field log for the first public whole-network bootstrap
experiment. It records commissioning failures as well as the clean measurement
baseline so a future operator does not have to reconstruct them from chat or
pod logs.

## Experiment envelope

- Started: 14 July 2026
- Decision deadline: 15 July 2026 at 05:47:25 UTC
- Public page: <http://stream-full-135-181-196-59.sslip.io/>
- Hetzner HEL1 CPX62: 16 shared x86 vCPUs, 32 GiB RAM, 640 GB local disk
- Data volume: 4 TB, XFS, mounted at /data
- Kubernetes: single-node k3s, one Stream replica, Recreate rollout strategy
- Container limit: 16 CPUs / 24 GiB; request: 8 CPUs / 12 GiB
- Approximate experiment cost: USD 18 for the authorized 24-hour window

The existing Indigo node and stream.waow.tech canary were not repurposed.

## Commissioning findings

### Worker memory was bounded but undersized

Build 94e50a0 requested sixteen workers under an 8 GiB aggregate allocation
budget. Its 1.25 GiB per-worker ceiling was too small for a real sub-512 MiB CAR
while the response body, CID index, MST conversion arena, and arena growth
coexisted. The bounded allocator returned OutOfMemory at about 1.8 GiB aggregate
use and the process treated that as lifecycle-fatal.

Build ed91c32 raised the conversion envelope to 2 GiB, yielding four effective
workers under the same 8 GiB aggregate budget. Exhausting one bounded worker is
now a failed-repository transition for durable retry; archive append failures
remain lifecycle-fatal.

### Pooled redirected connections produced false failures

getRepo requests go through the relay and redirect to independently operated
PDSes. The original long-lived clients emitted dozens of
HttpConnectionClosing failures per minute. Direct curl probes for the same DIDs
returned HTTP 200 and complete CAR bodies.

Build ade3d5d disables keep-alive for bootstrap downloads. In its first
three-minute public run it produced zero connection-closing errors, compared
with dozens in the same interval before the change. This trades connection
setup work for correctness and should be revisited if the Zig HTTP pool learns
to discard these closing redirected sockets reliably.

### Restart recovery worked

Both spontaneous and intentional restarts:

- sealed the interrupted archive segment;
- reopened the same RocksDB metadata store;
- recovered the live-capture segment;
- resumed the firehose from the persisted upstream cursor; and
- returned the health and public pages while subscription serving remained
  gated.

An interrupted 1,000-repository durability page is intentionally converted from
not_started to pending on reopen. That is correct service recovery, but repeated
commissioning rollouts would make a historical throughput measurement
unrepresentative by deferring those repositories to current-state resync.

## Scheduler evidence from Hubble

Hubble's sync library independently confirms two constraints to carry into the
next experiment's coordinator design:

- `getRepo` must still be requested through the upstream relay and redirects
  followed manually, with a concurrency/rate permit held for every redirect
  hop and the final PDS permit retained for the response stream. Scheduling by
  identity-resolved PDS is necessarily predictive because the relay chooses the
  actual destination.
- high small-repo concurrency and low large-repo concurrency should be separate
  resources. Hubble starts unknown repos optimistically, changes class after a
  byte threshold, and remembers confirmed-large repositories so retries acquire
  a scarce large-repo permit before opening another expensive CAR export.

This is scheduling evidence, not a substitute semantic oracle: Jetstream V2
remains the reference for Stream's rows, durability, retries, and public API.
The reviewed Hubble source was commit `74ed75d377c5b6b6d33d15b9068f379ecb74a704`
(`hubble-sync/src/resync_scheduler.rs`, `host/client.rs`, and
`resync/big_repo_permits.rs`).

## Clean baseline

Commissioning produced 7.4 GB of disposable data across several intentional
rollouts. After preserving the findings above, the volume was cleared once and
build 0bfeafb started from a fresh archive at approximately 06:24:39 UTC on
14 July 2026. The billing/decision deadline was not extended.

At 41 seconds:

- archive next sequence started at 1; durable cursor reached 2,846,721;
- upstream sequence was 853,375,749;
- 1,728 live events and 1,753 frames were received;
- verification reported 1,724 valid and zero invalid;
- four backfill workers were active with eight queued;
- bounded transient allocation was 21.3 MB, 614.2 MB peak;
- pod RSS was 407 MiB, with zero restarts;
- /data contained 212.9 MB; and
- all drop counters were zero.

The 24-hour monitor should measure from this clean baseline while retaining the
original cost deadline. Any later rollout must be called out because it changes
the interpretation of repository completion and throughput.

## Termination and disposition

The experiment was terminated early on 14 July 2026 after the live crawl found
repositories larger than Stream's hard-coded 512 MiB `getRepo` CAR limit. That
limit has no equivalent in upstream Jetstream V2: upstream streams the HTTP
response into its CAR reader, retains decoded blocks in an in-memory block
store, checks that the full MST is complete, and imposes a download deadline
rather than a repository-size exclusion.

Consequently this run did not demonstrate full-network backfill. The rejected
repositories made the partial archive semantically invalid for that claim, so
the archive was not retained. The following experiment-only Hetzner resources
were deleted and provider inventory was checked afterward:

- server `stream-experiment` (`150777708`);
- volume `stream-experiment-data` (`106359203`, 4 TB); and
- firewall `stream-experiment-fw` (`11304930`).

The final public snapshot before deletion showed upstream sequence 853,602,603,
four active backfill workers, eight queued jobs, 751,123,595 bytes of transient
in-flight allocation, zero completed durability pages, and zero failed
durability pages. The zero failure count did not contradict the observed
oversized-repository errors: results for the first 1,000-repository page had not
yet crossed the page durability boundary.

No replacement historical-bootstrap deployment is permitted until Stream has
semantic equivalents for the upstream backfill path. At minimum, that means no
arbitrary repository-size exclusion; incremental CAR consumption; complete-MST
verification before completion; durable per-repository failure and retry state;
and restart-safe progress whose completion semantics match upstream. Passing
shape-compatible endpoint tests alone is not sufficient evidence.

The live implementation gate is maintained in
[`bootstrap-semantic-parity.md`](bootstrap-semantic-parity.md). It records both
the size-limit removal work and the remaining deployment blockers; none of the
preserved experiment measurements waive that gate.

## 2026-07-21 live resync capacity receipt

The immutable `76f7eb0` live-only candidate was briefly placed on the
colocated canary with a 4 GiB container limit after its repair wire-encoding
ownership fix passed offline. It was rejected and rolled back, not promoted.
At 112 seconds the process reported 4,203,716,608 bytes RSS, all 32 upstream-
equivalent resync workers active, the exact 64-job queue full, 112 completed
repairs, two failed fetches, and eight pending same-DID events. Pipeline tickets
were 783 submitted, 783 claimed, and 393 emitted; public live conformance had no
matching events during its two eight-second observation windows. The prior
public build recovered immediately after rollback.

The corresponding offline receipt uses the pinned simulator, 96 signed repos,
real chain breaks, real HTTP getRepo CARs, real MST validation, RocksDB, and JSS.
It reproduces exactly 32 active plus 64 queued repairs, then releases and
completes all 96 with zero failures and exact simulator-ground-truth convergence.
With uniformly small 128-record repos it measured 54,886,400 bytes RSS at
saturation and a 72,695,808-byte peak. This distinguishes a scheduler leak from
the intended concurrency multiplier: retained bytes scale with the sizes of up
to 32 simultaneous complete repositories. A parity-default candidate therefore
requires the upstream-sized 32 GiB memory class Jim reported; the 4 GiB
colocated canary is not an admissible host for that build.

## 2026-07-22 isolated full-network experiment

The second experiment used an isolated CCX43 workload, an independent
watchdog, an off-host four-mode public consumer, and a 2.5 TB XFS Cloud Volume.
It was intentionally destroyed early, and the Hetzner project was verified
empty afterward. The live-price cost ceiling at teardown was approximately
$2.53.

Before teardown, 26,099 repositories had crossed the durable completion
boundary. The workload used approximately 73.9 GB of disk and 12.3 GB RSS,
while block writes were approximately 36.9 MB/s. Those are partial-run sizing
receipts, not a full-network completion estimate.

The experiment exposed a correctness failure more important than throughput:
the live scheduler stopped at 399,362 archived events while its WebSocket
reader continued and advanced its reconnect cursor 459,475 upstream sequences
beyond the last accepted frame. The process stayed alive and bootstrap kept
crawling, so ordinary health and backfill counters concealed the dead live
path. The exact original persistence error was not retained because the build
had neither a terminal pipeline metric nor fail-loud capture supervision.

Commit `b7cd5f0` closes the demonstrated loss mechanism. Zat acknowledges a raw
frame only after Stream accepts it; Stream propagates a closed pipeline's
original cause; bootstrap races live capture against the repository crawl; and
a failure between frames can no longer degrade into `LiveCaptureEnded`.
Real RocksDB fault injection, same-disk restart, the complete nine-crashpoint
oracle, and the pinned upstream differential oracle all pass. The next
experiment additionally requires pipeline tickets, stage gaps, and terminal
failure signals to remain scrapeable throughout bootstrap, not only after
steady-state construction.

## 2026-07-23/24 isolated experiment — image `e1926f3`

This run's record previously existed only in a temporary session handoff and
was nearly lost. Reconstructed from the retained harness receipts under
`relay/stream/experiment/receipts/`, whose final capture
(`20260724T045946Z`) is the most useful artifact of the three experiments:

```
jetstream_backfill_discovered_total   100000
jetstream_backfill_completed_total         0
jetstream_backfill_progress_completed      0
process_resident_memory_bytes     24,263,409,664
stream_events_total                   618,558
/data/stream                             26 GB
```

One hundred thousand repositories discovered and **zero durably complete**.
Completion was counted at the reusable 100,000-entry dispatch boundary, so each
of the four process starts visible in the log replayed nearly the whole batch,
while the dashboard's "durably committed" series — reading a process-local
counter — climbed anyway. The archive was therefore not what the page claimed
it was.

Three distinct crashes were also observed: borrowed CAR/MST data reaching
`segment_writer.appendPrepared` after its lifetime ended; an `UnsupportedFloat`
row escaping as a process-fatal live error; and a shutdown exceeding 45 seconds
and being killed. Two further restarts followed ordinary
`firehose connection closed` disconnects — exit code 1, not OOM. Scaling from
100 workers/8 GiB to 200/16 GiB made throughput *worse*, roughly 11 to 9
repositories per second, with the in-flight limit saturated.

The most important finding is procedural rather than technical: `e1926f3` was
never an admitted artifact. It included source and dependency changes made
after the receipt that supposedly covered it, and nothing in the pipeline
objected. `scripts/admit` exists because of this run, and `deploy.sh` now
refuses `sha256:adc276257fd8bc0cd8c0c94341afe220b50690cbef79539fe1ce3f7e6bcbd9fe`.

The operational plan derived from all three experiments is
[`deployment-runbook.md`](deployment-runbook.md).

## 4 — 27 July 2026, image `eb95c14`, stopped at ~55 minutes

CCX43 + 2.5 TB volume, CPX12 watchdog, CPX12 observer, HEL1. Stopped
deliberately under the runbook's first stop rule. Cost was roughly one hour of
the envelope.

The first properly admitted artifact:
`sha256:4300104135c6fd35bd13a264b744c5f842c41ee9a51e0cf1c57c9a59640551a2`,
`receipts/eb95c14.json`, 20/20 suites, built natively on linux/amd64.
`deploy.sh` refused the previous run's `e1926f3` on the first attempt, which is
the guard working exactly as intended.

Final capture, `receipts/live-20260727T1830Z/` (534 series):

```
jetstream_backfill_handle_repo_duration_seconds_count   12,686
jetstream_backfill_completion_queued_total                   0
jetstream_backfill_completion_queue_wait_seconds_count       0
stream_backfill_repos_total{result="complete"}               0
stream_backfill_repos_total{result="failed"}                 0
stream_backfill_repos_durable{status="not_started"}    100,000
stream_backfill_inflight_bytes                  17,169,399,984
process_resident_memory_bytes                   14,718,148,608
stream_events_total                                  1,219,982
/data/stream/segments                       23 GB, 88 segments
```

**The completion path never ran.** The archive was healthy throughout —
88 segments, rotating every few seconds, 1.22M events durable — and 12,686
repositories were fetched and emitted successfully. Yet not one reached the
completion queue: `completion_queued_total` is zero, every latency bucket in
`completion_queue_wait_seconds` is zero, and every repository row in RocksDB is
still `not_started`. The repositories were held in memory instead, which is
where the 17.2 GB of in-flight bytes and 14.7 GB RSS went.

This corrects the read of experiment 3. That run's per-repository completion
was treated as a *metric* defect — a dashboard reading a process-local counter
— and the restart-stable gauge shipped in this artifact fixed the reporting.
The gauge worked: it reported zero, truthfully, for 55 minutes. The commit it
reports on does not fire. `CompletionBatcher.stageDurable` and the
`onArchiveDurable` hook are correct as written; nothing reaches them.

This is the property the differential oracle is documented as unable to confirm
end to end, because a 100-repo simulator flushes its whole corpus at once and
cannot produce a crash with some repositories durable and others not. That row
was marked partial and described as an evidence limit rather than a known
defect. It was a real defect, and only a real run at scale surfaced it. An
evidence limit on a durability property is not a lesser kind of gap.

Two operator errors, both mine:

- The compose file still carried experiment 3's tuning — `--backfill-workers=200`
  and `--backfill-max-inflight-bytes=17179869184` — the settings whose scale-up
  made that run *slower*. The artifact was admitted at defaults and deployed at
  values never re-validated. The image digest was checked carefully; the
  arguments beside it were not. Admission covers the artifact, not its
  invocation, and nothing yet checks the second.
- The runbook's stop rule is 15 minutes of active crawling with zero durable
  completions. It was called at roughly 55.

Also stale and now fixed: image identity was hardcoded in `stage_bundle.py` and
`compose.yaml` (both naming `e1926f3` — the mechanism by which it shipped
unadmitted), and the public progress dashboard still integrated
`jetstream_backfill_completed_total` gated on experiment 3's start epoch. It
now reads `stream_backfill_repos_durable{status="complete"}` directly.

### Root cause and fix, same day

A three-way circular wait in `finishWorkBatch`:

- the **main fiber** blocked in `submit()`, because it submitted the whole
  100,000-job batch before consuming any result and the queue holds
  `worker_count * 2` (400);
- the **workers** blocked in `Budget.acquire`, which *waits* when the budget is
  exhausted rather than failing;
- the **budget** released only when the main fiber consumes results.

Consuming while submitting breaks the cycle: results reach the completion
batcher, the archive's durability boundary frees their memory, and workers keep
draining the queue. Fixed in `fcc63f8`.

Four attempts to reproduce it offline failed, and the reason matters more than
the attempts: the pinned simulator's repositories are ~4 KiB, so a 3,000-repo
run peaks near 50 KiB in flight and no budget a single repository fits in can be
exhausted. The failure is structurally unreachable in the fixture.

It reproduced against the real network in 90 seconds on a ccx23 costing about
€0.03/hour — 50 workers, a 256 MiB in-flight budget:

| t | `eb95c14` handled / durable | `fcc63f8` handled / durable |
|---|---|---|
| +90s | 66 / **0** | 4 / 0 |
| +180s | 416 / **0** | 323 / **322** |
| +360s | 842 / **0** | 953 / **953** |
| +540s | 1,403 / **0** | 1,662 / **1,660** |

Same flags, same box, same network. Before, nothing was ever queued for
completion; after, `queued == handled` at every sample and durable completions
track one behind, which is the repository still awaiting its durability
boundary.

The general lesson is about the gate, not the bug. Whole-network bootstrap was
marked **verified** on suites that could not reach this, and the
differential-oracle row had already recorded that the fixture was too small —
described as an evidence limit rather than a known defect. It has now produced
two. A cheap real-network repro is the tool that was missing; it costs pennies
and should be reached for whenever a hypothesis involves memory pressure or
worker contention.

## 5 — 27 July 2026, image `96de421`, stopped deliberately

The first run where bootstrap durably committed at scale: **14,434 repositories
complete**, `handled == queued == 14,433`, 127 failed, RSS stable at 9.05 GB.
The batch-deadlock fix held exactly as the ccx23 repro predicted.

Stopped on purpose, not on a defect. Throughput measured ~4.2 repos/s, which
projected to weeks against a 24-hour envelope — a projection that turned out to
be wrong for an interesting reason (below), but the decision to stop and
measure rather than run blind was right.

Also fixed here: the deployed image was carrying experiment 3's tuning
(`--backfill-workers=200`, 16 GiB in-flight) because nothing validated
deploy-time arguments against the admitted artifact. `assert_deploy_args.py`
now refuses that.

## The feasibility investigation, 27–28 July

Between experiments 5 and 6, the whole premise got re-derived from measurement.
Every number in the first pass was wrong, and the corrections matter more than
the conclusions:

| Claimed | Actual | Why the first number was wrong |
|---|---|---|
| 183–216 TB | **~8.7 TB** | mean repo size taken from 7 clusters of 40 *consecutive* `listRepos` entries, drawn from the head of the list |
| 9.45 MB mean repo | **0.45 MB** mean, **0.01 MB** median | 400 independent uniformly-random cursors instead |
| 22.7M repos | **~19.4M** | the `listRepos` cursor is not an offset; density falls from 0.92 to 0.67 across the space |
| 37–41 days | **~19–42 h** | follows from the corrected volume |
| "170x slower than upstream" | not a code gap at all | our client already beats plain parallel curl at every concurrency tested |
| "5.7 Gbps available, using 8%" | meaningless | that was an in-datacenter Hetzner mirror, not real `getRepo` traffic |

Upstream documents ~16 hours for a full backfill, which needs only ~1.2 Gbps —
consistent with their stated profile of "a single server" with "a few TB" of
disk. **There is no infrastructure gap. We were already on their hardware.**

Two Stream-only mechanisms were removed in this window, neither of which
upstream has and neither of which was ever decided:

- the **global parse mutex** (`prepare_mu`), which serialized all 100 workers'
  CAR parsing behind one core; and
- the **in-flight byte budget**, whose blocking `acquire` was half of the
  experiment-4 deadlock.

Measured honestly, removing them changed throughput by **nothing**
(6.30 → 5.02 → 5.61 repos/s, all within spread). They were removed because they
were unjustified divergences, not because they were slow. Removing the budget
does leave worker count as the only bound on concurrent CAR ownership: 100
workers sits near 6 GB, while 200 and 400 OOM-killed a 15 GB box.

## 6 — 28 July 2026, image `29705cb`, running

CCX43, 2.5 TB, 48-hour envelope, upstream defaults (100 workers), admitted
`sha256:0f45468c…` with 20/20 suites and a self-consistent receipt.

First run where the live path has been completely boring, which is the point:

```
jetstream_livestream_sequence_gaps_total                 0
jetstream_livestream_reconnects_total                    0
jetstream_livestream_stream_error_frames_total{*}        0
jetstream_livestream_decode_errors_total                 0
replay/verify drop families (4)                          0
jetstream_verifier_failures_total{invalid|unverified}  28 | 147  (of 268,958)
```

Zero sequence gaps is the experiment-2 killer, absent. Zero reconnects over the
first hours is the experiment-3/5 killer, absent — the `setsockopt` fix in zat
v0.3.18 holding under real load. `subscribers = 0` is correct: serving is
gated with 503 until steady state, as upstream does.

A deliberate restart in hour one confirmed durability end to end:

```
BEFORE  durable = 7,971   handled = 7,971
        docker compose restart stream
AFTER   durable = 8,065   handled = 0
recovery: resumed active segment seg_000000001k.jss at 191,648,876 valid bytes
live capture reconnect: cursor=32233814109
```

`durable` continued; `handled` reset because it is process-local. Both the
archive tail and the firehose cursor resumed in place. **The work is saved and
restartable** — a pause costs only the risk that the live cursor falls outside
the relay's retention window, which is what makes long pauses unwise rather
than impossible.

Throughput behaves exactly as the corrected size distribution predicts, and
this is the number to watch in future runs:

| elapsed | repos/s | bytes/repo | projection |
|---|---|---|---|
| 0.5 h | 3.43 | 11.09 MB | 63.5 h |
| 1.4 h | 6.71 | 6.11 MB | 58.9 h |

Repos/s doubles while bytes/repo halves, because the crawl is working down the
size distribution from the heaviest accounts. **Early throughput always
understates the run.** Judge health by sustained bandwidth, not repos/s, until
the crawl is past the head.

### …and past the head, that advice inverts

Extending the same table to hour 55 shows why the bandwidth rule has a shelf
life:

| elapsed | repos/s | note |
|---|---|---|
| 0.5 h | 3.43 | 11.09 MB/repo |
| 1.4 h | 6.71 | 6.11 MB/repo |
| 30 h | 8.1 | still in the head |
| 45 h | 23.6 | |
| 52 h | 31.9 | |
| 55 h | **45.0** | ~1.1 MB/repo |

Once the crawl is past the heavy accounts it becomes **request-bound, not
bytes-bound**: repos/s keeps climbing while bytes/s *falls*, because each
request now returns a small repository. A bandwidth-based projection therefore
reads **backwards** in this regime — it shows the run slowing down while it is
in fact 13x faster than at hour 1. Judge by `complete` against a known
denominator instead.

### The denominator is not the metric sum

`sum(stream_backfill_repos_durable)` is **enumeration progress, not the network
size.** It grows in exact +100,000 steps, one per batch, and went 132,000 →
3,200,002 over the run without ever settling. Dividing `complete` by it produced
a confident, meaningless "92.7% done" at a point that was really under half.

The independent number, from the indigo relay's own database
(`account_repo`, across 2,530 hosts): **~5,716,765 repos**, with 5,778,477
active accounts. Use that as the denominator. At hour 55, `complete` was
3,035,833 — **53.1%**.

Also: the `pending` bucket froze at exactly **103,077** and never moved again.
It is inert, not in-flight, so adding it to "remaining" overstates the work.
`complete` is the only monotonic bucket.

### The envelope moved twice, in place

48 h as provisioned → 72 h → **120 h** (`expires_at_unix = 1785646907`,
Sun 2026-08-02 05:01 UTC), because the crawl needed roughly 24 h more when only
20 h remained. Done by writing `/etc/stream-watchdog/deadline` on the running
watchdog, which `stream-experiment-expire` re-reads every timer tick — **no
Terraform, so no watchdog replace.** Changing `expires_at_unix` alters
cloud-init and *replaces* the enforcer; a previous attempt was killed mid-replace
by a command timeout and destroyed the watchdog outright. Terraform state still
holds the old value; anything that replaces the watchdog restores the stale
baked-in deadline. `arm_watchdog.sh` only *verifies* a deadline, it does not set
one.

### The process restarts every ~45 minutes, by design-accident

`RestartCount` reached 32 by hour 55. The cause is neither the firehose nor OOM:
it is the **batch boundary**. With `--backfill-batch-size=100000`, the process
drains its batch, dies fetching the next `listRepos` page with
`HttpConnectionClosing` escaping to `main`, and Docker restarts it — whereupon
discovery admits the next 100,000. **The restart is load-bearing by accident:
the run advances because it keeps crashing.**

The interval is therefore `batch size ÷ crawl rate`, which is why the originally
documented "every 3.5 h" became ~45 min: the crawl got faster, not worse.

| crawl rate | interval |
|---|---|
| ~8 repos/s (early) | 3.5 h |
| ~45 repos/s (hour 55) | ~45 min |

Exactly **one** real oom-kill occurred in the whole run (2026-07-29 06:06,
62.9 GB anon-rss). Every other restart has the boundary signature. Grep `dmesg`
for a literal `Out of memory: Killed process` before ever calling it OOM.
Recovery is clean every time — the active segment resumes at its last valid byte
and `complete` never regresses.

### Resident blooms are the memory ceiling, and a recurring startup tax

Measured at hour 55 from the sealed segment headers:

| | |
|---|---|
| sealed segments | 4,767 |
| total blocks | 5,041,001 |
| archived events | **16,728,092,842** |
| per-block bloom at capacity 4096 | 8,409 bytes each |
| resident bloom bytes | **39.5 GiB** |
| process RSS | 44.3 GB (41.3 GiB) → **~96% is blooms** |

`segment_writer.zig` passes `max_events_per_block` (4096) as the footer
`bloom_capacity`, so every per-block bloom marshals to 8,409 bytes however few
DIDs it holds. Upstream `f02919c` (2026-07-10) right-sizes these and reports the
same symptom — *">90% of server heap (44.3 GiB full-network)"* — with a median
per-block unique-DID count of **1–3**, making the sizing ~1000x too large.
Upstream states the fix is **not a format change**. Stream has not adopted it;
see `jss-seal-spec.md`.

It is paid twice, because `manifest.zig` keeps that metadata resident and must
load it before crawling resumes:

| startup latency (process start → backfill begins) | |
|---|---|
| early in the run | 2.0 min median |
| by hour 55 | **4.5 min** median |

With a restart every ~45 min, that is **~10% of wall-clock time in startup**,
growing with the archive. It also revises the restart bug's cost upward: not
"~60 s of crawl per occurrence" but ~4.5 min. The two defects compound, and
either fix recovers most of it.

### "Never crash on bad upstream data" holds at network scale

`invariants.md` requires that invalid *upstream* data is dropped, counted with a
labelled metric, and never crashes or stops the server — while invalid
*internal* state is fatal. Fifty-seven hours against the real network is the
first proper test of that boundary, and it holds:

| reason | drops in 57 h | |
|---|---|---|
| `invalid_collection` | 14,030 | 98.4% |
| `invalid_rev` | 112 | 0.8% |
| `field_too_long` | 89 | 0.6% |
| `missing_block` | 21 | 0.1% |
| **total** | **14,252** | **0.000085% of ~16.7 B archived events** |

Every drop is attributable to a named reason, and the counters that would
indicate the *other* side of the boundary are clean over the same window:
`jetstream_ingest_append_errors_total` is 0, `stream_pipeline_failures_total` is
0, and `stream_pipeline_fatal` is 0. So the process saw fourteen thousand pieces
of malformed network data, discarded each with a reason, and never once treated
one as its own corruption.

The dominance of `invalid_collection` is the expected shape: NSIDs are the part
of a record most exposed to arbitrary client input, and the network contains
plenty that do not parse.

Worth noting while reading alert state here:
`stream_pipeline_stage_gap{boundary="submitted_to_emitted"}` sits at **41**,
which is nonzero, and `StreamPipelineStalled` is nonetheless correctly inactive —
its rule requires a gap *and* tickets failing to advance, and tickets are
advancing (2,104,138). The conjunction is doing real work rather than decorating
the rule.

### The archive decodes, and the block index proves continuity at file level

Integrity counters say no events were dropped. That is a claim about the
*ingest* path. `stream inspect-segment --blocks=table` checks the other end —
whether what landed on disk can actually be read back — and it can:

```
blocks (858 total):
  idx       offset  comp_size  uncomp_size  events     min_seq     max_seq  cols
    0  0x0000000100       8142        29352      80           1          80     4
    1  0x00000020d6     246953      1226370    4096          81        4176    11
  ... (854 rows omitted) ...
  856  0x0010135d78     284623      1331596    4096     3502161     3506256     2
  857  0x001017b54f      39892       168884     490     3506257     3506746     1
```

Every block decompressed, and the seq ranges are **exactly contiguous** across
all 858 blocks — 1–80, 81–4176, … 3,502,161–3,506,256, 3,506,257–3,506,746, with
no gap at any boundary. That is independent, file-level corroboration of
`sequence_gaps_total = 0`: the counter says the consumer never observed a gap,
the block index says none exists in the bytes. Two different failure modes would
have to coincide silently for both to be wrong.

Compression is running about 5:1 (247 KB compressed from 1.23 MB) on live-shaped
blocks.

**The collection table is the evidence that this is a network archive, not a
Bluesky archive.** Alongside `app.bsky.*` the same segment carries
`social.moat.event`, `blue.flashes.actor.profile`, `uk.skyblur.post`,
`tech.tokimeki.poll.vote`, `events.smokesignal.lfg`, `place.stream.chat.profile`,
`net.anisota.harvest.minigame` and more — the long tail of independent atproto
lexicons, captured without being enumerated in advance.

Checked on one sealed segment, not all 4,818.

### CORRECTION: the denominator below is wrong — it is a different relay's database

Everything in the next section, and every percentage reported during 2026-07-30,
used **5,716,765** from the indigo relay at `relay.waow.tech`. **Stream does not
crawl that relay.** The deployed command line is
`--relay-url=https://bsky.network`, and bsky.network's own
`com.atproto.sync.listHosts` — which returns `accountCount` per host — gives:

| | hosts | accounts |
|---|---|---|
| **bsky.network** (what Stream crawls) | **5,742** | **22,845,221** (22,658,063 on active hosts) |
| indigo `relay.waow.tech` (what was used) | 2,551 | 5,716,765 |

indigo tracks **44% of the hosts**. Using its count as "the network" understated
the target by roughly 4x.

This also means the feasibility investigation was right and was overridden. It
estimated **~19.4M**, correcting a raw **22.7M** for accounts without crawlable
repos — and the raw sum measured directly today is 22.85M, matching. The number
that was days old and derived from the correct relay was discarded in favour of
one pulled from the wrong relay and never reconciled.

**Corrected position at hour 59.5:** 3,675,382 complete is **16–19%**, not the
63.6% reported all day. Remaining is 15.7–19.2M repos, which at the observed
48 repos/s is **91–111 hours more** — against a 120-hour envelope with 60 hours
left. Bootstrap does not finish in this envelope.

**The rate has plateaued — do not assume it keeps climbing.** It rose 6.6 → 47
repos/s over the first two days as the crawl left the large-repository head, and
then stopped. Measured from batch intervals (each batch is exactly 100,000
repos, so the interval is a clean rate measurement):

```
12:26->13:11  45 min = 41/s     15:16->15:56  40 min = 47/s
13:11->13:54  43 min = 44/s     15:56->16:43  47 min = 40/s
13:54->14:35  42 min = 45/s     16:43->17:22  39 min = 48/s
14:35->15:16  41 min = 46/s
```

Five hours, median 47/s, no trend. An earlier version of this section offered
"103–113 h if the rate doubles to 100/s" as an optimistic case; that case is
**not supported by the data** and was speculation. At the measured rate the
finish is **152–173 h elapsed**, overrunning the 120-hour envelope by 32–53
hours, before merge and cutover.

**Independently confirmed against a PDS's own API.** `accountCount` from
`listHosts` could in principle overcount — accounts without crawlable repos —
which is the correction the feasibility work applied to reach 19.4M. Checked
directly:

| | |
|---|---|
| `enoki.us-east.host.bsky.network` `accountCount` | 214,128 |
| that PDS's own `listRepos` | **≥201,000** (capped at 200 pages) |
| Stream's `/status?tab=hosts` for the same host | **94,044** |

So `accountCount` ≈ real repos (ratio near 1.0), and **Stream's per-host counts
are partial** — what the *global* `listRepos` walk has reached, not the host's
total. Stream has enumerated 44% of that single host.

**That trap nearly reversed a correct finding.** Summing Stream's hosts tab
gives 3.80M repos across hosts whose `accountCount` totals 17.3M — a ratio of
0.220, which if taken at face value implies a ~5.0M crawlable network and would
have "vindicated" the wrong indigo denominator. It is an artifact of partial
enumeration. Any per-host progress figure from `/status` must be read as
walk-progress, never as host totals.

**The method failure worth keeping:** the right denominator was one command away
(`docker inspect` the running container for `--relay-url`) for the entire run.
The wrong one was never checked against the project's own prior work, which
disagreed by 3.4x and was sitting in this same file.

### What the 5,716,765 denominator does and does not mean

Progress is quoted against ~5,716,765 repositories, taken from the indigo
relay's `account_repo` table. That is the best independent number available, but
it is an **upper bound on the crawlable set, not a measurement of it**, and the
percentage should be read accordingly.

`unavailable` sat at **17** for the whole run, which looks impossibly low for a
real network — `RepoDeactivated`, `RepoSuspended` and `RepoTakendown` all land
in that bucket, and a network of millions has far more than seventeen such
accounts. The explanation is not misclassification:
`jetstream_backfill_active_flips_total` reads **0 over 57 h**, meaning
`listRepos` has never once returned a repository whose `active` flag differed
from the stored value. Inactive accounts are largely not in the enumeration at
all, so they are never attempted, never fail, and never become `unavailable`.
The 17 are the handful that changed state between being listed and being
fetched.

Two consequences:

- **Coverage of the crawlable set is higher than the headline percentage**, since
  the denominator counts accounts `listRepos` may never offer.
- **Bootstrap may finish earlier than a projection against 5.72 M suggests.**
  Enumeration had reached 3.4 M and was still advancing 100,000 per batch with no
  sign of a ceiling, so the true total is somewhere above that and at most
  ~5.72 M. Where it lands is not knowable until `listRepos` is exhausted.

Quote the percentage with the denominator named, not as a bare figure.

### Measured: more workers will not fix the throughput

The obvious rescue for a run that cannot finish in its envelope is more
concurrency — workers sit at 100/100 with a permanently full queue while CPU
idles at ~20%, and the bloom oversizing above is what caps worker count. That
argument is wrong, and it was worth EUR 0.02 to find out before spending a
rebuild on it.

Measured 2026-07-30 on a throwaway cx43 (8 cores, nbg1), fetching `getRepo`
concurrently from a 54,000-DID sample across 9 real PDSes, 60 s per level:

| concurrency | repos/s | bandwidth |
|---|---|---|
| 100 | 68.1 | 86.3 MB/s |
| 400 | 83.8 | 101.9 MB/s |

**4x concurrency bought 1.23x throughput**, and even that is suspect: 101.9 MB/s
is 815 Mbps, pressed against a 1 Gbps NIC, so the ceiling measured may be the
test box's network rather than the PDSes.

The comparison that matters is against production:

| | repos/s | bandwidth |
|---|---|---|
| plain fetcher, 100 concurrent, 8 cores | 68 | 86 MB/s |
| **production, 100 workers, 16 cores** | **47** | **41 MB/s (332 Mbps)** |

Production moves **less than half the bytes** a dumb fetcher pulled from the same
PDSes on half the cores. So it is not network-bound, not CPU-bound (80% idle),
and not PDS-rate-limited — yet its workers are all blocked.

That points at serialization in the post-fetch path — CAR parse, MST walk,
verification, archive append, RocksDB commit — with the single archive writer the
obvious suspect. **More workers cannot relieve a serialized writer.** Finding the
real constraint is a profiling job on the write path, not a configuration change.

The bloom fix remains worth doing for memory and the 4.5-minute startup tax, but
it should not be sold as a throughput fix. It is not one.

**Method note:** the first attempt at this sampled only 3,600 DIDs and both runs
drained the queue, reporting identical `fetched` counts. That measures time to
exhaust a list, not steady-state throughput. Any concurrency test needs a work
queue large enough that the highest concurrency level never runs dry.

### The tell that bootstrap is about to finish

Projecting the end from crawl rate requires knowing the denominator, which is
not knowable (see above). There is a directly observable signal instead:
**enumeration advances in increments of exactly 100,000**, one per batch, and
the final batch cannot — `listRepos` will run out partway through it. So the
first genuinely short increment means bootstrap is on its last batch.

**Guard against sampling straddle before believing a short increment.** Over 36
increments in one window, 31 read as exactly +100,000 and four were fragments:

```
+39,000 then +61,000     = 100,000   (one batch, split across two samples)
 +4,000 then +96,000     = 100,000   (same)
```

A batch admitted across a sampling boundary looks exactly like a partial batch.
Sum consecutive increments before concluding anything: real exhaustion is a run
that sums to **less** than 100,000 and is followed by no further growth. A
watcher that alerts on any increment ≠ 100,000 will cry wolf roughly one time in
nine at a 600 s step.

(The remaining `+2` is the persistent `…002` tail carried in every enumeration
total.)

### Coverage: 99.9%, and the failure rate is falling

`failed` reached 3,409 by hour 56, which is easy to report without examining.
As a share of what was actually attempted it is **0.105%** — and it has been
*improving* for two days:

| | complete | failed | failure rate |
|---|---|---|---|
| 07-28 08:53 | 84,534 | 152 | 0.179% |
| 07-28 14:53 | 252,449 | 1,048 | **0.413%** (peak) |
| 07-29 02:53 | 596,830 | 2,256 | 0.377% |
| 07-29 14:53 | 1,046,486 | 2,315 | 0.221% |
| 07-30 02:53 | 2,089,660 | 2,463 | 0.118% |
| 07-30 08:53 | 2,687,437 | 3,358 | 0.125% |

The marginal rate is lower still: between 07-29 20:53 and 07-30 08:53, 986 new
failures against 1,205,745 new completions — **0.082%**.

The early peak is consistent with the size distribution. `listRepos` runs
oldest and largest first, and that head holds disproportionately many
deactivated, suspended, taken-down and outright broken repositories, as well as
the ones large enough to hit a fetch deadline. Once past it the crawl meets
ordinary small repositories and the rate drops.

**None of these 3,409 have been retried yet, and that is correct.** Every
`failed_repo_retry_*` counter reads 0 over the whole run: the retry loop is a
*steady-state* mechanism (4 h interval, 16 workers, 4 per host) that only runs
after cutover, and merge additionally performs a pending-repo retry pass before
it. So this figure is the coverage floor before either recovery mechanism has
had a turn, not the final number.

The counters above were read in hour one. Re-read at hour 56, after 34 restarts:

```
jetstream_livestream_sequence_gaps_total                 0
jetstream_livestream_reconnects_total                    0
jetstream_livestream_decode_errors_total                 0
jetstream_livestream_stream_error_frames_total           0
jetstream_livestream_verify_queue_dropped_events_total   0
```

**Read these with `increase()`, not as raw values.** They are per-process
counters and reset at every batch-boundary restart, so the current value only
describes the *current* process — at the time of this reading, 18 minutes of a
56-hour run. The query that actually covers the run accounts for resets:

```
increase(jetstream_livestream_sequence_gaps_total[57h])   0
max_over_time(jetstream_livestream_sequence_gaps_total[57h])   0
```

Both zero, so the counter never incremented in *any* of the 34 process
instances. That is the meaningful statement: **no sequence gap has occurred at
any point in the run.**

This matters more than the other integrity numbers because a gap is the one
defect merge cannot repair. Merge reconciles captured live segments against
backfilled repository heads; it does not refetch events the consumer never
received. A clean cursor for the whole capture window means merge's input is
intact, and the restart tolerance claimed after the hour-one deliberate restart
now has 34 unplanned confirmations rather than one arranged.

### Merge crash-safety was verified against HEAD; confirmed it holds for `29705cb`

Merge durability was checked by reading `merge.zig`, `repo_store.zig`,
`lifecycle.zig` and `meta_store.zig` — **at local HEAD**, while the run is on
`29705cb`. That is exactly the mistake this file warns about elsewhere, so it
was worth closing rather than assuming.

The four files all differ between the two commits, which looks alarming until
the diff is read: `93a0f33` regrouped `src/internal/`, so every changed line is
an `@import` path rewrite.

```
merge.zig        non-import changed lines: 0
repo_store.zig   non-import changed lines: 0
lifecycle.zig    non-import changed lines: 0
meta_store.zig   non-import changed lines: 0
```

Note the file *paths* also moved — at `29705cb` these are
`src/internal/bootstrap/*.zig` and `src/internal/meta_store.zig`. Comparing by
path reports "did not exist"; the comparison has to be by content across the
rename.

Every durability construct is present in the deployed tree: the
`durability ordering` comment, `flushBlockTraced` before the cursor advances,
the `after_merge_dst_flush_before_source_commit` crashpoint, `commitMergeSource`
and its `commitDurable` batch. `tests/powerloss_oracle.py` is byte-identical
between the two commits, so the oracle that kills the process at that crashpoint
is the same one that passed for this artifact.

**So the crash-safety verification transfers.** Worth stating explicitly,
because "I checked the code" means nothing when the checked code is not the
running code.

### Steady state costs ~48x less disk than bootstrap

Disk burn during bootstrap is ~12 GB/h, which is what fills a 2.5 TB volume in
about 108 hours. That rate is an artifact of the crawl, not of running the
service, and it stops at cutover.

The steady-state rate is already measurable, because the live capture has been
writing the firehose alongside the crawl for the whole run:

| | |
|---|---|
| live capture | 14.7 GB over 59 h |
| **steady-state write rate** | **0.248 GB/h** |
| bootstrap burn | 12 GB/h — **~48x higher** |
| archive now | 1.37 TB |
| free | 1.28 TB |
| **runway after cutover** | **~215 days (7.2 months)** |

So the volume is sized by the *backfill*, and once the archive is built the same
disk carries the live stream for roughly seven months. That is the number that
matters for running this indefinitely: the expensive phase is the one-time one.

Excludes compaction, which rewrites rather than grows, and the one-off ~18 GB
merge write. Both are small against 1.28 TB.

### Deadline extended a second time: 180h -> 228h (2026-08-03)

`expires_at 1785862907` -> `1786035707` (Thu 2026-08-06 17:01:47 UTC), written in
place on the watchdog host and verified through the same read path the expiry
script uses. Backup at `/etc/stream-watchdog/deadline.bak-20260803T145236Z`.
`armed` intact, `stream-experiment-expire.timer` still active.

**Why:** bootstrap was cut over to merge on 2026-08-03 07:04:58Z with
`--backfill-max-repos=1` after the crawl fell to ~7.5 repos/s against an
unfetchable tail (see the brid.gy finding in
`~/tangled.org/zzstoatzz.io/notes/protocols/atproto/network-backfill.md`). Merge
drained cleanly — `255,799,323 kept, 126,488,978 dropped across 137 sources` —
but the pending-repo pass and an unmeasured compaction over a 1.6 TB archive did
not fit inside the remaining 26h. The watchdog deletes **the volume**, not just
the servers, so the deadline was the difference between having an archive and
having nothing.

**Scope of the extension:** run until serving is proven or disproven. The open
question is whether `steady_state` commits and `listSegments` returns 200 over a
16.2M-repo archive; that has never been exercised at this scale.

**Cost:** verified against Hetzner's pricing API rather than recalled — ccx43
€0.528/h, 2x cpx12 €0.0288/h, volume €0.0767/GB-month. Running rate **€0.90/h**
(~€21.60/day); ~€135 spent at 153.7h. The €1.01/h figure used earlier in this
document is stale.

### What to watch once merge starts

`EVENTS.log` fires at the two *transitions* (leaving bootstrap, reaching steady
state) and says nothing in between. Merge itself has no coverage, so if it runs
long or stalls there is no signal. These counters are the visibility, and all six
are present in the deployed `29705cb`:

| counter | what it tells you |
|---|---|
| `jetstream_orchestrator_merge_segments_consumed_total` | **the progress bar** — against the live-segment count (54 at hour 59) |
| `jetstream_orchestrator_merge_events_kept_total` | rows that survived the filter and were written |
| `jetstream_orchestrator_merge_events_dropped_total` | rows dropped as already covered by a backfilled head |
| `jetstream_orchestrator_merge_repo_revs_updated_total` | per-source commits landing |
| `jetstream_orchestrator_merge_did_lookups_total` | the per-DID `Backfill.Rev` cache working |
| `jetstream_orchestrator_merge_dids_discovered_post_bootstrap_total` | unknown DIDs found in post-bootstrap discovery |

**Expect `dropped` to dominate `kept` by a wide margin.** Merge discards every
row already covered by a completed repository's backfilled head, and bootstrap
completed ~3.6 M repositories before merge began, so most of the captured live
window is redundant. `kept` greatly exceeding `dropped` would mean the filter is
not matching — the `Backfill.Rev` comparison failing — and is the thing to
escalate on, not a slow segment count.

Also watch `merge/next_source_idx` advancing via `segments_consumed_total`: it is
the per-source cursor, so a stuck count with a live process means a single source
is not completing rather than merge being slow overall.

**All six export at 0 before merge runs** — confirmed at hour 59 with the
process 6 minutes past startup and `jetstream_orchestrator_phase` returning `1`
as a control. That matters for reading them: they are live series, so a `NONE`
result means the scrape target is down (almost always a batch-boundary restart),
**not** that merge has not started.

Always read a control metric alongside them. An earlier attempt at this returned
`NONE` for all six and looked like a finding; the control metrics were also
`NONE`, because the query landed mid-restart. Without the control it would have
been written up as "the merge counters do not exist until merge runs", which is
the opposite of the truth.

### Merge sizing, measured before it runs

Merge is the untested path at full-network scale, so it is worth knowing how big
the job actually is. Measured at hour 56:

| | |
|---|---|
| live capture (merge's input) | **13.9 GB across 51 segments** |
| growth rate | 0.25 GB/h over 56 h |
| projected at bootstrap completion | **~18 GB** |
| permanent archive (merge's destination) | 1,300 GB across 4,818 segments |
| free space | 1,305 GB |

**Merge reads ~18 GB, not 1.3 TB — about 1.6% of the archive.** It drains the
captured live segments into the permanent archive, dropping every row already
covered by a completed repository's backfilled head, so most of that input is
discarded rather than written. Then `backfill/` is removed, returning the space.

So neither disk nor duration should be the risk at cutover: there is 1,305 GB
free against a peak need of tens of gigabytes, and the input is small enough that
the drain plus the merge-tail compaction pass is not a multi-hour job at these
sizes. **The risk in merge is correctness, not capacity** — it is the phase whose
full-network behaviour has never executed, and the reason to capture a receipt
before it starts.

Note the live capture lives at `backfill/live/segments/`, not `backfill/live/`.
The logs print the *container's* view, `/data/backfill/live`, while the host path
is `/data/stream/backfill/live` — checking the wrong one of those three reports
an empty capture.

### State at hour 55

`phase=1` still — bootstrap has never completed, so merge and cutover remain
unexercised at full-network scale, and `jetstream_orchestrator_phase_transitions_total`
does not yet exist as a series. 3,035,833 of ~5.72 M complete, 1.2 TB written of
2.5 TB, disk filling at 12 GB/h (108 h to full, not a constraint), spend ~€55 at
€1.01/h.