# Historical update checklist — before MVP reprioritization

These are the previous plan and reported checkmarks, preserved for reference.
They are not the current execution order or independent verification of completion.
Follow webfs-update.md for current priorities.

## Implementation milestones and acceptance checklists

Complete in order. Every checked box must link to code, a reproducible command and
saved evidence. Use fixtures without secrets. Do not mark a hardware gate passed
from a host simulation alone. No firmware flashing until M0–M3 pass.

### M0 — freeze contract and measure hardware

- [x] Record current source revision, board/flash identity, partition table and private
  USB backup; preserve the current firmware and blog for recovery.
- [x] Confirm 4 KiB erase geometry, page/write alignment and driver bounds on the actual
  chip; inspect esp-storage critical sections and cache/IRAM safety.
- [x] Implement a RAM-safe timing harness and measure erase/program/read-back stalls,
  watchdog behavior and Wi-Fi loss on reserved test space using a disposable image.
  Run after host/simulator gates; do not sacrifice the live blog for this measurement.
- [x] Freeze protocol byte layout, state transitions, journal algorithm and error codes
  in `docs/update-protocol.md`; include versioning and unsupported-version behavior.
- [x] Record public-via-Caddy availability versus temporary direct-device maintenance.
  Inventory the real Caddy config and management IP before generating deployable rules.

### M1 — deterministic host preparation

- [ ] Implement `prepare` and offline `plan`, safe tar parsing and explicit root selection.
- [ ] Test traversal, links, special files, sparse/PAX/long-name inputs, duplicate paths,
  decompression bombs, truncation and path/file/count limits; assert no escape writes.
- [ ] Repack identical files with different timestamps/order/ownership: byte-identical
  WebFS image and hashes, zero planned sector writes.
- [ ] Test one added page, global navigation change, every page changed, deleted files,
  image growth/shrink and a near-capacity image; show actual changed-sector counts.
- [ ] Build host fallback tree and manifest; validate every file against the packed image.
- [ ] Reject images beyond `0x21e000`; test final-sector padding and empty/invalid blog.

### M2 — journal and update engine in a flash simulator

- [x] Implement a host-testable engine with no socket dependencies and a flash trait
  enforcing erase-before-program, 1-to-0 writes, alignment and partition bounds.
- [x] Implement two-sector journal, checksum/digest/validity checks and rollover.
- [ ] Inject power cuts at every erase/program operation and partial-program boundary
  for BEGIN, payload writes, verification, COMMIT and rollover; include torn validity.
- [ ] After every cut, reboot simulated code: it either serves a completely validated
  committed image or offers recovery; never a mixture and never erased firmware.
- [ ] Exhaustively test monotonic record selection, duplicate commands, stale base,
  missing metadata, journal full/rollover, sequence overflow and image hash failure.
- [ ] Test recovery with partial target sectors, header written early by a malicious
  client, smaller targets and stale bytes beyond logical length.
- [ ] Prove restoring a previous release works as a new generation without old ESP data.

### M3 — protocol and host coordinator without real flash

- [ ] Implement shared framing/MAC test vectors, replay/session handling and bounded parser.
- [ ] Test wrong key/device/nonce/direction/request number, tampered opcode/length/body,
  oversized frames, fragmented TCP and slow clients; assert no unauthorized mutation.
- [ ] Implement status, begin, bounded hash scan, sector transfer, async verify/commit,
  resume and restore against the simulated device.
- [ ] Persist host intent/releases and lock per device; kill the tool before/after every
  durable write and command; restart to the correct idempotent action.
- [ ] Demonstrate interrupted full-image replacement resumes without retransmitting
  already-matching sectors, without keeping a full target image in device RAM.

### M4 — bounded firmware integration and USB migration

- [ ] Move boot networking ahead of optional volume mounting; invalid volume has a
  restricted authenticated recovery path and no public file service.
- [ ] Implement RECOVER_BEGIN for missing/corrupt journals; test recovery with both
  journal sectors erased and a garbage WebFS header. Reinstall content remotely.
- [ ] Prove boot, Wi-Fi, DHCP, authentication and update code have no content-partition
  dependency; run from cold power-on with the entire WebFS region erased.
- [ ] Enforce content-only writes at the lowest flash-writer boundary. Hash all bytes
  outside the WebFS partition before/after normal, interrupted and rejected updates
  in a controlled test that excludes unrelated platform writes. Separately trace
  every updater erase/program address; it must fall inside the authorized region.
- [ ] Reject firmware bundles, arbitrary addresses and partition changes in the
  update protocol. Confirm routine CLI commands never invoke firmware flashing or
  host OS/package/jail installation commands.
- [ ] Add flash ownership/drain barrier and restricted writer; eliminate reads during
  erase/program and stale mounted metadata after commit.
- [ ] Integrate one maintenance socket and fixed staging buffer; record static, heap,
  task and stack budget with >=20% measured headroom under combined traffic.
- [ ] Implement bounded flash progress and verification scheduling; preserve watchdog
  and Wi-Fi behavior without logging secrets or blocking on an attached console.
- [ ] Update USB provisioning to seed a valid journal and reduced image capacity;
  migrate by USB once, retaining a full private rollback backup. Never auto-detect
  and erase the last 8 KiB of an existing oversized v2 image in place.
- [ ] Native locked build/tests pass; identify ESP using esptool, flash and read-back
  verify; show normal serving plus recovery startup after an invalid image.

### M5 — Caddy orchestration and boundary

- [ ] Implement validated normal/snapshot configurations scoped to this blog, local
  admin access only, durable restart behavior and serialized config changes.
- [ ] Keep all fallback files local and complete; test GET/HEAD/404/405, MIME, gzip,
  cache handling, conditional requests and no directory listings.
- [ ] Prove snapshot selection before BEGIN and worker drain before erase; keep a
  long response open during transition and check no body is truncated.
- [ ] Test public 8081 unreachable, LAN allowlist, direct bypass attempts, forged
  forwarded headers and invalid MACs. Do not open a public upload URL.
- [ ] Configure/test Caddy upstream concurrency against the ESP per-IP limit; baseline
  four-visitor browser traffic without unexpected 503 before update qualification.
- [ ] Kill/restart coordinator and Caddy at every transition; snapshot mode survives
  unfinished updates and no unrelated site configuration is changed.

### M6 — physical failure injection and performance

- [ ] Save serial logs, transaction IDs, hashes and exact firmware revision for each run.
- [ ] Perform at least 20 physical power interruptions spanning BEGIN, sector erase,
  program, final header, verification, COMMIT and journal rollover. Software reset
  alone does not establish flash behavior during power loss; use a controlled power
  switch/fixture or explicitly record this hardware gate as awaiting that equipment.
- [ ] After each physical interruption, with no USB/serial attached, demonstrate
  DHCP reconnection and authenticated STATUS within 60 seconds on the controlled
  healthy LAN, then complete resume/restore remotely. Record any missed bound as
  a failed gate, not a successful USB-assisted recovery.
- [ ] Test erased/truncated header, torn data, one invalid journal and two invalid
  journals; every case reaches network recovery and accepts authenticated repair.
- [ ] Repeat interrupted recovery itself: cut power during RECOVER_BEGIN and its
  metadata writes, restore power and complete remote recovery again.
- [ ] Drop Wi-Fi/TCP and kill the uploader at the same phases; resume remotely without USB.
- [ ] Exercise a near-capacity worst-case all-sectors-changed image, plus no-op and tiny
  edits. Record bytes transferred, sectors erased, write/verify durations and retries.
- [ ] Continuously load the public blog through Caddy during updates: zero unexpected
  failures, exact decoded bodies and p95 page time <=120% of the measured normal
  baseline on the same host/network; report fallback and ESP phases separately.
- [ ] Run a 24-minute mixed public-traffic/update/recovery soak with at least three
  completed updates; zero unexpected resets, leaked sockets or unbounded memory growth.
- [ ] Verify restart with no serial reader; authentication failures cause zero erases;
  repeated identical package causes zero payload writes and no new transaction record.
- [ ] Measure erase counts including journal rotation, estimate wear at three updates
  per week using the identified flash's specifications, and document margin. Do not
  assume a generic ESP datasheet is the specification of the installed flash chip.

### M7 — delivery and rollback rehearsal

- [ ] Ship CLI, protocol/format specs, simulator tests, firmware integration and Caddy
  templates with a step-by-step operator README and exact rebuild/flash commands.
- [ ] Demonstrate tar.gz -> prepare -> plan -> apply -> verify -> restore using the real
  blog; compare all public files and a retained previous release byte-for-byte.
- [ ] Document secret provisioning/rotation, capacity errors, recovery mode, stale
  transactions, host backup restoration and USB rescue. Keep credentials out of Fossil.
- [ ] Record resource/performance/power-cut evidence and unresolved limitations here.
- [ ] Commit reviewed source and docs to the local Fossil repository; retain configured
  firmware privately and public test fixtures separately.

