Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions docs/C13-READINESS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# C13 campaign and 80% band checks

C13 measures usable charge from stock Full to a software reserve on the
internal meter. The natural 80% band and the guard crash inside that band each
need their own observations under the production guard. Schedule them outside
the calibration attempts.

1. **Build on the host.** Run `python3 -B scripts/i14-calibration-launch.py
--build NEW_DIRECTORY`, then `--verify NEW_DIRECTORY` with the same script
and `sh -n NEW_DIRECTORY/wrapper.sh`. Independently review the exact package
and measurement hashes, runtime pins, retention budgets and launch gate.
Changed bytes need a fresh review and a grant bound to the new manifest.
2. **Reserve one operator and prove supervision.** The coordinator grants an
exclusive window up to 72 hours including restoration. Verify export and a
real unattended continuation through the deadline. The probe must be at
most 15 minutes old, the next checkpoint within one hour, with a boundary
check within five minutes. Retain the actual receipts behind the gate hashes.
3. **Preflight immediately before each launch.** Require fresh K1–K7, pinned
board, normal stock 3.18.19 boot ID, verified recovery routes, workload,
software/configuration and services. Require two valid same-boot guard
readings at least ten minutes apart, the latest and K at most 150 s old.
USB/AC must be online, voltage ≥3700 mV, stock capacity ≥10%, temperature
0–40 °C, and the production guard valid with no drain or competing writer.
Read charging state from the approved cached getters and BCCT readback.
Reading `current_cmd` disables charging.
4. **Budget both cycles and all writers.** Verify actual userdata backing
and available bytes after any image staging. The start gate requires the
larger of 2 GiB and **3040 MiB + fixed observer bytes + background growth
bytes**. Fixed observer overhead includes at least 1 MiB. Background
growth includes at least 3,934,208 bytes for both guard logs plus the
reviewed ceilings of other writers. Verify quota and retention on each
backing filesystem through closure. Rows are capped at 128 KiB and each
sample trace at 480 MiB. Stop at ≤512 MiB free or on an unreadable budget.
5. **Attempt 1.** Place the reviewed bundle and newly bound gate in the
launcher's fixed code directory. From that directory the approved entry
point is `sh ./wrapper.sh gate-1.json`. Each attempt consumes a slot
before the child starts. Allow at most eight hours to reach the 300 s
stock Full anchor and 32 hours for the whole measurement. Keep the cable
attached. Stop discharge at 3550 mV or stock capacity 6%, whichever is
reached first. Use `python3 -B launcher.py --checkpoint` to inspect and
`--ack-checkpoint ACK_FILE` for a fresh matching scheduler receipt.
A missed checkpoint beyond its five-minute grace stops the attempt.
`--stop` targets the identified measurement process. Let the owning
supervisor finish teardown and restart production.
6. **Restore and review before attempt 2.** Export raw samples, state,
results or failure, wrapper receipts and hashes. Verify child and wrapper
exit, actual BCCT release, fresh production guard, services, unchanged
settings/hashes and full K1–K7. Recover to ≥3700 mV and ≥10% within four
hours. Incomplete teardown retains ownership. A safety abort ends the
campaign. For a complete accepted cycle, replay the trace and freeze the
cycle-1-only fit and input hashes in the independent review. With the
same boot, package and runtime, a fresh matching gate and at least
32 h + 4 h + 30 s remaining, launch `sh ./wrapper.sh gate-2.json`
within the four-hour restoration/start window. Repeat restoration.
7. **Score the holdout offline.** The reviewer checks complete traces,
coverage, comparable workload, reset segments and the same reserve type.
Require reserve voltages within 50 mV, discharge median temperatures
within 3 °C, and usable-charge difference ≤5% of the pair's mean.
Unknown-interval charge must be ≤1% of usable charge per cycle. Evaluate
the frozen fit against cycle 2's own CAR reference at all common 10–90%
landmarks without extrapolation or refitting. Require mean absolute error
≤5 percentage points and maximum ≤10. A result file or launcher success
only releases the data for review. A failed gate ends the campaign without
a profile or a third attempt.
8. **Production band and crash-in-band.** With a separate grant, normal
production ownership and unchanged 80% settings, capture the natural ZCV
rise to ≥4109 mV and verified BCCT pause, descent through the band,
release at ≤4003 mV and continued charging back inside the band. For the
crash check, first establish a fresh same-boot hardware pause strictly
inside 4003–4109 mV. Under the reviewed guard-crash procedure capture
the old and respawned guard PIDs, same-boot ZCV/status and matching BCCT
readbacks across the crash while still inside the band. Verify the pause
survives and the natural lower crossing releases it. Finish with full
restoration. A threshold crossing during the crash leaves hysteresis
unproven. Keep raw observations for both checks.
8 changes: 4 additions & 4 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ Use an existing project virtual environment if one is configured. Some older
experimental tests and C host tests under `tests/` depend on local firmware,
captures, or optional C/host tooling and are not part of the default CI matrix.

The host-only M0 recovery-timing analyzer
(`scripts/i14-k70-recovery-timing.py`) reads normalized synthetic traces and
proves crash-to-return timing only, not device acceptance; see
[K70 recovery timing](K70-RECOVERY-TIMING.md) for usage and the trace schema.
The M0 analyzer reads normalized JSONL traces. The passive host capture writer
and analyzer are tested together using synthetic observations. Capture hooks,
the trace schema and the hardware gates are documented in
[K70 recovery timing](K70-RECOVERY-TIMING.md).
See [ROADMAP.md](ROADMAP.md) for remaining device acceptance gates.

## Current route: Alpine with the stock kernel
Expand Down
66 changes: 54 additions & 12 deletions docs/K70-RECOVERY-TIMING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
interval for the Linux 7 recovery gate (M0) in
[the roadmap](ROADMAP.md#3-linux-7-mainline-recovery-m0), section 3.
The historical crash test returned in 70.6 s against the unchanged 40 s limit.
This tool is host-only: it reads a normalized saved JSON Lines trace and never
touches the phone, firmware or live evidence. Until a reviewed capture exists,
traces are generated only by the synthetic fixtures in
`tests/test_i14_k70_recovery_timing.py`.
The analyzer reads a saved JSON Lines trace. A passive writer,
`scripts/i14_k70_capture.py`, can record either terminal trigger inside a
host observer. Both paths have been exercised with synthetic observations.

A within-limit result proves **timing only**. It does not establish M0
acceptance, pstore correspondence, restoration K, or a cause; those remain
Expand All @@ -29,8 +28,8 @@ object; stderr stays empty and malformed input never produces a traceback.
| 2 | `INCOMPLETE` | A required anchor is absent (contract, crash trigger, or confirmed return). Nothing is inferred. |
| 2 | `INCONSISTENT` | Malformed, ambiguous or conflicting evidence, including bad usage or an unreadable trace. |

Durations are computed in one clock domain and reported at microsecond
resolution (`round(x, 6)`); the limit comparison uses that reported value.
The limit applies to the unrounded host interval (`duration_unrounded_s`).
`duration_s` is its display value rounded to six decimal places.

## Trace schema `i14-k70-recovery-trace/1`

Expand All @@ -48,6 +47,11 @@ bounded by 2^53). File order is irrelevant; records are identified by `type`.
| `production_return` | `clock: "host_monotonic"`, `session`, `boot_id`, `kernel`, `image`, `t_s`, `confirmed: true` | Exactly one confirmed record: the first confirmed production return. Unconfirmed records (`confirmed` absent or `false`) are counted as diagnostics, never anchors; several confirmed returns are ambiguous. |
| `stage` | `stage`, `phase` (`start`/`end`), `clock: "boot_uptime"`, `boot_id`, `t_s` | Optional, paired. Timed on the returned production boot's uptime clock only. |

New captures also include `previous_production_boot_id` in the contract and
`method` (`sysrq-crash` or `keeper-stop`) in the trigger. Both methods use
the historical wire name `crash_trigger`. A confirmed return carrying the
pre-trial production boot ID invalidates the trace. Older traces remain readable.

### Transition and identity rules

The measurement requires a valid transition: the crash trigger sits on the
Expand Down Expand Up @@ -80,7 +84,7 @@ Problematic stage records are called out separately in `stage_issues`
(`{line, stage, reason}`) and are excluded from `stages`, so they cannot become
measurement evidence: `malformed_stage`, `unknown_stage`, `stage_wrong_clock`,
`stage_mixed_boot` (not the returned boot), `duplicate_stage_start`,
`duplicate_stage_end` (first occurrence kept), `unpaired_stage`,
`duplicate_stage_end` (the entire ambiguous pair is excluded), `unpaired_stage`,
`reversed_stage`. Stage issues do not alter the timing verdict;
`stage_evidence` reports `absent`, `valid`, `issues`, or `unevaluated` (when the
core evidence is invalid).
Expand All @@ -94,8 +98,46 @@ the core evidence is fully valid), `stages`, `stage_issues`, `stage_evidence`,
(record counts, unconfirmed returns) and `scope_note` stating the timing-only
scope.

## Limitations

Synthetic fixtures only; no capture pipeline or device evidence exists yet.
The analyzer cannot verify pstore, restoration K, power state or the cause of
the slow return, and a within-limit fixture run is not a recovery acceptance.
## Capture and trial order

1. **Commission the observer offline.** The live trip runner and returned-boot
stage producers are outside this checkout. Bind the writer to the reviewed
runner's dispatch and first identity-probe completion in one host process.
For each trial, open a new private JSONL file in exclusive creation mode.
Construct `RecoveryCapture(stream, previous_boot=..., experimental_boot=...,
kernel=..., image=...)` using the observed pre-trial and RAM-boot IDs and
the reviewed production pins. Wrap just the terminal dispatch in
`with capture.trigger(method):`. Raise if dispatch is refused or uncertain.
Call `observe_return(boot_id=..., kernel=..., image=...)` at probe completion
with observed identities. Preserve raw probe successes and failures. Reading
a saved log later cannot recreate either host timestamp.
2. Bind both edges of `early_init`, `sysinit_services` and `mdev_coldplug` to
the corresponding operations in the pinned production startup. Export each
observed edge with its original production boot ID and uptime through
`capture.stage(name, phase, boot_id, uptime_s)`. Exercise the entire path
with fixtures and review the exact runner, marker sources and artifact pins.
The writer performs no boot instrumentation. Missing edges leave that
interval unknown. Keep raw evidence, capture errors and restoration handling
independent so a logging failure cannot skip recovery.
3. **Fresh M0 grant and preflight.** Reserve one actor and a window clear of
calibration or soak. Verify the board, normal 3.18.19 boot ID, production
boot/rootfs and rollback hashes, serial recovery, healthy services and
fresh same-boot guard matching BCCT. Require USB power, 3800–4100 mV,
10–40 °C, no drain or experiment, and the reviewed RAM image and keeper hashes.
4. **Crash trial first.** RAM-boot once. Confirm the 7.0 board/kernel and
experimental boot ID, no-touch settings, read-only eMMC, armed watchdog and
keeper, and its battery margin. Dispatch the reviewed `sysrq-crash` check.
Observe the first confirmed new production return. Run
`python3 scripts/i14-k70-recovery-timing.py TRACE.jsonl` on the host. Save
raw trace, exit code, last_kmsg/pstore evidence of the same trial and full
production restoration K1–K7, including guard/service continuity.
5. **Keeper-stop is conditional.** On missing evidence, a late return, a
pstore mismatch or failed restoration, stop and retain the failure. An
unconfirmed return goes to the authorized recovery procedure. Only after
independent crash acceptance and renewed preflight under a covering grant
run a separate RAM-only `keeper-stop` trial in a new directory. Apply the
same 40 s bound and full restoration checks. Require evidence of the keeper
stopping its feeds and the watchdog reset; a fallback reboot fails that check.

Historical status remains 70.6 s for the crash trial, with no accepted
keeper-stop trial. The source of the delay remains unknown.
4 changes: 4 additions & 0 deletions docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ firmware dumps, images, credentials and raw captures outside Git.

### Unattended collector & 48-hour Soak C (H2/H3)

The [H1, Soak C and H3 execution sequence](verification/H1-SOAK-C.md) lists
the commissioning steps, commands and evidence required for these gates.

- Commission a phone-local collector and export path with bounded retention and
clean process teardown before starting a 48-hour acceptance window.
- Freeze exact boot/rootfs identity, runtime hashes, sampler and probe settings,
Expand Down Expand Up @@ -59,6 +62,7 @@ firmware dumps, images, credentials and raw captures outside Git.
- Verify userdata free space, log retention budget and unattended supervision
(`scripts/i14-calibration-launch.py`) before running a bounded two-cycle
calibration campaign (fit on cycle 1, independent holdout on cycle 2).
See the [C13 and production charge-band sequence](C13-READINESS.md).

### Nearly-empty recovery (D)

Expand Down
18 changes: 18 additions & 0 deletions docs/ROOTFS-SWAP-ROLLBACK.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ must have a matching `rootfs-trial.img` link, a previous image at
`rootfs-prev.img`, and a 512-byte `rootfs-trial` record. Without the record,
the normal boot follows the usual image checks.

Before releasing a staged trial for boot, check that `rootfs.img` and
`rootfs-trial.img` are regular files with the same device and inode, and that
`rootfs-prev.img` has the independently verified previous image on a different
inode. Reconcile old markers and receipts first. If the trial link is missing
or points elsewhere, rollback can replace the candidate's last name. Verify
the restored image independently of the `rollback` record.

The initramfs records each candidate boot before checking or mounting the
image. It falls back after at most two starts, or immediately if the candidate
fails the filesystem, mount or init check. If an image cannot be unmounted, the
Expand All @@ -19,6 +26,17 @@ host's check. Confirmation also requires the configured services, SSH on port
without confirmation is restarted by the watcher so the initramfs can roll
back. Recovery login and power-off charging follow the existing boot paths.

The base rootfs builder seeds the packaged DNS trust anchor. Trial preparation
must carry the agreed baseline bytes, write their SHA-256 to
`/etc/i14-rootfs-root-key.sha256`, and write a fresh candidate stamp to
`/etc/i14-rootfs-id`. Verify the staged image after these writes. Before
acknowledging a trial, compare the retained `rootfs-trial-root-key.<boot-id>`
bytes and the receipt's boot ID, stamp and digest with the independent host
evidence. During the automatic rollback rehearsal, withhold the acknowledgement
on both starts and verify the subsequent boot against the restoration baseline.
`scripts/i14-r2-handoff-preflight.py` and `scripts/i14-r2-host-handoff.py`
manage a historical host supervisor.

Host tests exercise the decision and watcher logic with disposable files and
fake system actions. Device acceptance follows the [R section of the
roadmap](ROADMAP.md#restore-integrity-and-accept-the-new-rootfs-r).
Loading