Author SHA1 Message Date
serversdownandClaude Opus 5.5 e2a0f8d58f docs: re-assess SFM as a tool (2026-12-04, v0.36.0)
The 2026-09-20 assessment had gone stale: the 64 KB download bug, "no
live Series-4 path", the failing suite and the 8x Sensitive reading are
all fixed, and the SFM / SDM split it was framed on is retired.

Rewritten on the same plan, each claim re-checked against today's code:
decoding and the store are production; the device side, both series by
serial, is bench-proven behind the safety core but has no login, runs
synchronously behind Terra-View's 60 s proxy, and is not used in the field
yet; the lab tools left the image.  Known issues now list the open Gitea
issues (#6 first) and the overlay.  The old text is
`git show v0.36.0:docs/sfm_tool_status.md`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R9LdWawLzUxwewZGA1
2026-12-04 17:46:08 -05:00
serversdownandClaude Opus 5.5 4c934a2665 docs: trim CLAUDE.md to its rules and a short status (147 KB -> 21 KB)
Every session loaded the whole file at start-up, ~150 KB of it protocol
history.  CLAUDE.md now keeps:

- a short "Where things stand" (goal, checker, Thor, .MLG, device control,
  what is next)
- "Rules that bite": device safety, Series-III framing, constants not to
  "fix", the store, tests and fixtures
- where protocol knowledge lives, the changelog & release convention
  (verbatim), where code goes (ADR 0003), an updated layout, the API

The rest -- the status log, the waveform codec, the protocol gotchas,
field locations, write / monitor / erase / monitor-log / call-home
sections, capture tables, the superseded tier model and the old layout --
moved verbatim to docs/working_notes.md.  A script checked every non-blank
line of the old file: each is in one of the two files except four,
changed on purpose (the intro, and the changelog example's "~2 h" backfill,
now ~8 h as v0.34.0 and v0.35.0 measured).

The last full copy is `git show v0.36.0:CLAUDE.md`.  Code comments that
cite "CLAUDE.md" for a protocol fact now mean docs/working_notes.md, as
both files say.  Suite: 1,806 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R9LdWawLzUxwewZGA1
2026-12-04 17:31:20 -05:00
3 changed files with 2876 additions and 2520 deletions

No files matched your search

+214 -2424
View File
File diff suppressed because it is too large. Load diff
+127 -96
View File
@@ -1,30 +1,28 @@
# SFM — where it actually stands as a tool # SFM — where it actually stands as a tool
**Status as of 2026-09-20 (v0.31.0).** This is the honest assessment, not the **Status as of 2026-12-04 (v0.36.0).** This is the honest assessment, not the
roadmap — `README.md § Roadmap` covers where it is *going*. Expect this file to roadmap — `README.md § Roadmap` covers where it is *going*. Expect this file to
go stale; re-date it when you revise it. go stale; re-date it when you revise it. The previous assessment (2026-09-20,
v0.31.0) is `git show v0.36.0:docs/sfm_tool_status.md`.
--- ---
## The framing ## The framing
SFM is **three different things wearing one name**, at three very different SFM is one module (Terra-View's ADR 0003 retired the old SFM / SDM split), but its
levels of maturity: parts sit at very different levels of maturity:
| | what it is | maturity | | part | what it is | maturity |
|---|---|---| |---|---|---|
| **The codec library** | `minimateplus/`, `micromate/` — bytes in, `Event` out | **Production.** Verified per-sample at scale. | | **Decoding** | `minimateplus/`, `micromate/`: bytes in, events out | **Production, measured.** Checked field by field against Blastware and Thor at archive scale. |
| **SDM — the data side** | the DB, waveform store, `/db/*`, ingest | **Production.** Terra-View depends on it daily. | | **The store and ingest** | the DB, the waveform store, `/db/*`, `/db/import/*` | **Production.** Terra-View depends on it daily. |
| **SFM — the device side** | `/device/*`, live connections to units | **Emergency-grade.** Works, but manual, unauthenticated, and thinly tested. | | **The device side** | `/device/*`, live connections to units, both series | **Bench-proven, not field-proven.** Every feature works on a bench unit of each series, behind an audited safety core. No login, and nothing in production uses it yet. |
| **The lab** | `seismo_lab.py`, `scratch/`, the Inspector | **Research artifacts.** Useful, not products. | | **The lab** | `bridges/`, `scratch/`, `seismo_lab.py` | **Research tools.** Kept out of the production image since v0.36.0. |
Brian's own description — *"right now it's an emergency tool and a research In September the device side was "an emergency tool and a research project"
project"* — is accurate, and it applies specifically to the **device side**. (Brian). That has changed more than anything else here: it now speaks both
The data side is not an emergency tool; it has been carrying production for series by serial, with dry runs, an audit table and read-backs. What it lacks is
months. not protocol work but **a login, long-running jobs, and field use**.
Most confusion about "is SFM reliable?" comes from answering for the wrong
tier.
--- ---
@@ -32,42 +30,69 @@ tier.
### Production-grade — trust it ### Production-grade — trust it
- **Series-3 decode.** 14,338 / 14,338 files decode per-sample exact against - **Series-3 decode.** The checker (`scratch/check_s3_decode.py`) decodes all
preserved Blastware ASCII exports, 45 units, files back to 2018. 70,042 DL2 events (2016–2026) from their bytes alone and compares every field,
- **Series-4 (Thor) decode.** 1,057,536 / 1,057,536 geo samples exact against sample and interval with Blastware's own `_XML.XML` report.
Thor's own CSV exports; production IDFW 575/575 with zero truncations. - **80 of 88 fields match on every event**; every other field matches or is
- **Histogram decode.** 1,211 / 1,211 production histograms exact, including accepted under a carve-out with its evidence.
842,442 per-interval frequency comparisons with zero mismatches. - **Geophone samples** are exact on 6,524 / 6,524 waveforms; **histogram**
- **The ingest path.** `/db/import/blastware_file` and `/db/import/idf_file` interval peaks have 0 mismatches on every file.
fed by the watchers — this is how prod actually gets its data, and it has - Left, by Brian's decision (2026-11-11): the vector sum's last digit on 4
been running unattended for months. waveform/histogram twins, and 4 accelerations.
- **`/db/*` read API.** Always-on, consumed by Terra-View for every fleet - **Series-4 (Thor) decode.** 3,807,158 / 3,807,165 samples exact across 459
listing, event detail and report. files and three corpora of Thor's own CSV exports (the 7 others are Thor's own
- **The waveform store** — `.h5` + `.sfm.json` sidecars + retained raw rounding); production IDFW 575 / 575 with zero truncations. Since v0.36.0 a
binaries, with operator review state preserved across regeneration. Thor file's settings, notes and event time come from the file itself (2,027 /
- **`bridges/ach_server.py`** — speaks the full BW protocol to calling units. 2,027 against Thor's reports).
Proven in the field, including as a rescue tool (see the runbook). - **The ingest path.** The watchers forward each unit's files to
`/db/import/blastware_file` and `/db/import/idf_file`. This is how prod gets
its data, and it has run unattended for months.
- **`/db/*` read API.** Always on; Terra-View reads every fleet listing, event
detail and report from it.
- **The waveform store**: `.h5` + `.sfm.json` sidecars + the retained original
files, with operator review state preserved across regeneration. Events are
keyed unit + time + type.
### Emergency-grade — works, but you are the error handling ### Bench-proven — works, not yet trusted in the field
- **`/device/*` live endpoints.** They do what they say. But they are - **Live device control by serial, both series** (`sfm/device_access/`, merged
synchronous, unauthenticated, and a single cellular download can exceed the 2026-11-04): identify, status, settings read and change, event list and
60 s timeouts that sit in front of them. download, start/stop monitoring, call-home on/off.
- **The rescue ladder** (`rescue`, `stop_monitoring_*`, `events/erase`). - Every write goes through one safety core: a fresh identity read, the run
Each has worked in a real incident — but each has been used a handful of state, a dry run showing the exact frames, a row in the `device_commands`
times, by one person, with the runbook open. audit table, one send never retried, and a read-back.
- **The standalone webapp.** Perfectly usable, and as of v0.31.0 the cheap - Verified on one bench unit per series (UM20147, BE9441); settings and
probes and rescue actions are reachable without curl. No auth of any kind. call-home changes were confirmed on the unit's own screen. MiniMate downloads
match Blastware's files byte for byte, including the 64 KB page crossings
that broke in September.
- Used from SFM's own page (`sfm/sfm_webapp.html`, Serial field). No Terra-View
page uses `/device/*` yet.
- **The `.MLG` monitor log and each unit's timeline** (v0.35.0). Every record's
checksum held on the files examined (3,329 / 3,329), and it builds sessions,
gaps and call-ins. The DL2 archive is not imported yet.
In prod, but its tables are **empty** until the watcher forwards `.MLG`s.
### Research artifacts — useful, not products ### Emergency-grade — you are the error handling
- **`seismo_lab.py`** — 2,789 lines of Tkinter (Bridge / Analyzer / Query DB / - **The rescue ladder.** Runbook Method A (`docs/runbooks/wedged_unit_recovery.md`:
point a wedged unit's modem at `bridges/ach_server.py` and answer its call)
and the blind stop tools (`/device/stop_monitoring_*`; `scripts/blind_stop.sh`,
`slow_drip.sh`, `spam_stop.sh`).
Each has worked in a real incident, used a handful of times by one person with
the runbook open. Method A runs from a checkout on the dev box, not the image.
- **The legacy, serial-less `/device/*` routes** (MiniMate only). Kept for the
rescue tools; the serial-named routes replace them for everything else.
### Research tools — useful, not products
- **`seismo_lab.py`**: 2,882 lines of Tkinter (Bridge / Analyzer / Query DB /
Inspector). Desktop-only, single-user, no tests. Inspector). Desktop-only, single-user, no tests.
- **`scratch/`** — the verification harnesses (`verify_against_ascii.py`, - **`scratch/`**: the checker and the verification harnesses
`verify_thor_against_csv.py`) and the offset detector (`offset_scan3.py`). (`verify_thor_against_csv.py`, `verify_against_ascii.py`) and the offset
These produced the numbers the production claims rest on, so they matter — detector (`offset_scan3.py`). The production numbers above rest on them, so
but they are analysis scripts, not maintained code. they matter, but they are analysis scripts.
- **`docs/offset_investigation.md`** — an open investigation, not a feature. - **`bridges/`**: probes, relays and recording bridges for the bench.
- **`docs/offset_investigation.md`**: an open investigation, not a feature.
--- ---
@@ -75,17 +100,19 @@ tier.
| you want to… | use | notes | | you want to… | use | notes |
|---|---|---| |---|---|---|
| Know if a unit is monitoring / its battery / memory | `GET /device/monitor/status?force=true` | ~2 s | | Know if a unit is monitoring, its battery, its memory | SFM page → Serial → Status, or `GET /device/monitor/status?serial=…` | both series |
| Know whether ACH is on | `GET /device/call_home` | ~2 s. **Not** `/device/events`. | | Know whether call-home is on | `GET /device/call_home/state?serial=…` | both series |
| See how full a unit's buffer is | `GET /device/events/storage_range` | ~2 s, no chain walk | | See how full a MiniMate's buffer is | `GET /device/events/storage_range` | MiniMate only; no event walk |
| Stop a runaway unit | Diagnostics tab → Stop Monitoring | see the runbook first | | List a unit's stored events | Events tab with a Serial, or `GET /device/events?serial=…` | a MiniMate's list reads headers only |
| Reach a unit that will not answer | **point its modem at an `ach_server` and answer its call** | runbook Method A — do not race it | | Pull one event into the store | the Download button per event, or `POST /device/events/download?serial=…&event_id=…` | checked against the unit's own peaks before it is stored |
| List a unit's stored events | Events tab → Load events | **slow**, and broken past 64 KB (below) | | Start or stop monitoring | the Live tab with a Serial, or `POST /device/monitor/start\|stop?serial=…` | try `dry_run=true` first; audited, read back |
| Get event data into the DB | the watcher → `/db/import/*` path | not the live walk | | Change a unit's settings | Config tab: Preview, then Send (`POST /device/settings/change`) | refused while monitoring; nobody in the unit's menus while it sends |
| Reach a unit that will not answer | runbook Method A: **answer its call** | do not race its call-home |
| Get event data into the DB | the watchers → `/db/import/*` | not the live walk |
| Know whether a unit was monitoring at a time | `GET /db/units/{serial}/monitoring_at?at=…` | answers "unknown" until `.MLG`s are forwarded |
The single most useful habit: **the cheap probes are cheap and the event walk The single most useful habit still holds: **the cheap probes are cheap and the
is not.** Reaching for `/device/events` to answer a yes/no question about a event walk is not.** Do not list events to answer a yes/no question about a unit.
unit is the mistake that motivated the v0.31.0 webapp changes.
--- ---
@@ -93,58 +120,62 @@ unit is the mistake that motivated the v0.31.0 webapp changes.
| issue | impact | status | | issue | impact | status |
|---|---|---| |---|---|---|
| **5A walk dies once a unit's buffer crosses 64 KB** | `/device/events` 500s; event body never downloads | Known, documented in `CLAUDE.md`. Needs a BW capture of a spanning event to fix properly. | | **No login on SFM at all** | 27 `/device/*` routes (16 of them POSTs) plus `/db/restore` and `/db/events/delete_bulk`, open to anything that reaches port 8200 | Design agreed (Terra-View as the authenticated jump host); not built. Terra-View's `docker-compose.yml` still publishes `8200:8200`. |
| **No auth on SFM at all** | 21 `/device/*` endpoints, including destructive ones, open to anything that reaches the port | Design agreed (Terra-View as authenticated jump host); not built. | | **The API's try-it-out page is live** | `:8200/docs` can send any of the above, erase included | Unguarded. The SFM page's erase asks you to type the serial; `/docs` does not. |
| **Swagger try-it-out is live on destructive endpoints** | `POST /device/events/erase` is one click away at `:8200/docs` | Partially mitigated: the webapp's erase now requires typing the serial. `/docs` itself is unguarded. | | **Long device operations are synchronous** | Terra-View's `/api/sfm/*` proxy times out at 60 s; a long download over cellular can exceed it | Known design constraint. Must become start-a-job / poll before Terra-View drives units remotely. |
| **`SUB 0x08` lifetime counter reads 0** | `/device/events/index` returns a meaningless number | Suspected field-offset bug. Surfaced in the UI as "unreliable". | | **THOR and SFM contend for a Micromate's modem** | a call-home is lost while SFM holds the line | Brian (2026-10-29): keep the hold as is; the long-term fix is SFM answering call-ins itself. |
| **Long device operations are synchronous** | 60 s timeouts in `routers/sfm.py` and the reverse proxy; a full download exceeds both | Known design constraint. Must be POST-starts-job / GET-polls before any remote lab. | | **#6: a MiniMate stays connected after a call-in unless its events are deleted** | it does not resume monitoring | Open, Priority/High, from April. May be stale; triage first. |
| **`backfill_sidecars.py --force` silently inserts DB rows** | store files with no DB row get one; the dry-run does not report the count | Known. Avoid `--force` — `TOOL_VERSION` gates regeneration anyway. | | **#32: some events decode to ramps or garbage** | corrupts shape-based false-trigger detection | Open, needs more information. |
| **14 sensitive-range files show an exact 8× discrepancy** | 10.0 / 1.25 — a units problem, not a decode problem | Open, not blocking. | | **Prod still overlays Blastware's ASCII report** | where a report arrives, its peaks, notes, sample rate and record time replace SFM's decode | By design until the overlay is retired. Some decoded fields (displacement, time of peak, acceleration, sensor checks, the Monitor Log line, over-range flags) are not stored yet. |
| **16 failing tests on `dev`** | 15 need gitignored fixture bundles; 1 is real (`sc["peak_values"]["transverse"]` returns `None` where `0.0` is expected) | The real one shipped in v0.31.0. | | **`SUB 0x08` lifetime counter reads a meaningless number** | `/device/events/index` | Labelled "unreliable" on the SFM page. |
| **`backfill_sidecars.py --force` silently inserts DB rows** | store files with no DB row get one; the dry run does not count them | Known. Avoid `--force`; `TOOL_VERSION` gates regeneration anyway. |
| **Smaller open issues** | #52 (restamp follow-ups), #53 (unknown regions of Series-3 files), #55 (PDF footer), #57 (detect a unit's series from its reply) | Open, low to medium. |
**Fixed since September:** the 64 KB download bug (2026-10-26); the 8× reading on
Sensitive-range events (v0.34.0); the test suite now passes on a fresh checkout
(1,806 passed, 0 skipped).
--- ---
## 4. What stands between this and a real tool ## 4. What stands between this and a real tool
Roughly in dependency order — each unblocks the ones below it. Roughly in dependency order.
**1. Authentication.** Everything else is gated on this. SFM has none, and **1. A login.** Everything remote is gated on this. SFM has none, and the
the modem IP whitelist gives zero protection because SFM *is* the whitelisted modem IP whitelist gives no protection because SFM *is* the whitelisted origin.
origin. The agreed design delegates rather than builds: Terra-View becomes the The agreed design delegates rather than builds: Terra-View becomes the
authenticated jump host (`/api/sfm/*` already inherits deny-by-default operator authenticated jump host (`/api/sfm/*` already sits behind its operator login and
auth), and the `8200:8200` publish is dropped so Terra-View is the only door. passes any path through), and the `8200:8200` publish is dropped so Terra-View is
the only door.
**2. Async long operations.** POST starts a job, GET polls. Retrofitting this **2. Long operations as jobs.** POST starts a job, GET polls. Retrofitting
after building a remote lab on top of synchronous endpoints would be far worse this after Terra-View drives units through synchronous calls would be far worse
than designing for it now. than designing for it first.
**3. Confirm-guards on the remaining destructive endpoints.** Auth answers **3. Field use of the device side.** It has been proven on one bench unit per
*who*, not *did you mean it*. The webapp's erase is guarded; the other seven series. Using it on deployed units, a little at a time, is what turns "works"
destructive POSTs and `/docs` are not. into "trusted".
**4. The 5A page-boundary fix.** Until this lands, live event download is **4. SFM answering call-ins itself** (ADR 0003's call-in server, after its staged
unreliable on exactly the units most likely to need attention — the ones that proof). It replaces Blastware's ACH and THOR as the receivers and ends the
have been recording heavily. Wants a Blastware capture of an event spanning a modem contention.
page boundary before the chunk-addressing half is trustworthy.
**5. A live Thor / Micromate client.** The device side is MiniMate-only. **5. Retiring the Blastware report overlay.** The decoder is ready; the
Series-4 units can only be read from forwarded files, so half the fleet has no remaining work is storing the decoded fields listed above and letting SFM's own
live path at all. report read them.
**6. Test coverage that runs from a clean checkout.** 15 of 16 current **Done since September:** the 64 KB fix; a live Series-4 client and both series
failures are missing fixture bundles. A test suite that cannot go green on a by serial; confirmation on every serial-named write (dry run, preview, audit,
fresh clone cannot gate anything. read-back); a suite that goes green on a fresh checkout. The planned "SDM
rename" is dropped: the repo becomes `sfm` instead (ADR 0003).
**7. The SDM rename.** Cosmetic relative to the above, but the longer `sfm/`
holds the data-side code the more the tiers blur. ~30–50 files here, ~10–15 in
Terra-View, plus a Docker volume migration. Do it when the codebase is quiet.
--- ---
## The short version ## The short version
The **data side is a real tool already**. The **device side is a set of sharp The **data side is a real tool** and has been for months; the decoder now
instruments** that work in the hands of the person who wrote them, with the matches Blastware field by field across ten years of files. The **device side
runbook open. The gap between those two states is mostly **auth, async, and has grown from sharp instruments into a bench-proven tool for both series**,
guardrails** — not protocol work. The protocol is the part that is actually with the safety core a real tool needs. The gap to using it on the fleet from
finished. Terra-View is **a login, jobs instead of long calls, and field time** — not
protocol work.
File diff suppressed because it is too large. Load diff