Author SHA1 Message Date
serversdown ab3bab764a Merge pull request 'Release v0.36.0 — Micromate events from the file alone, and three loose ends tied' (#61) from dev into main
Reviewed-on: #61
2026-12-03 16:07:22 -05:00
serversdown eec88a62b8 Merge pull request 'Release v0.35.0 — 80 of 88 report fields from the file, and monitor logs (.MLG)' (#60) from dev into main
Reviewed-on: #60
2026-11-16 15:49:03 -05:00
serversdown 30bfdd6eff Merge pull request 'Release v0.34.0 — Series-4 parity, and most of Blastware's report from the event file alone' (#59) from dev into main
Reviewed-on: #59
2026-11-04 18:19:22 -05:00
serversdown fb14a8f7bb Merge pull request 'Release v0.33.0 — SFM reads Series-3 events from the file alone' (#56) from dev into main
Reviewed-on: #56
2026-11-01 14:33:00 -05:00
serversdown e9c01ce8d4 Merge pull request 'Release v0.32.0 — event times you can trust, and Series 4 mapped' (#54) from dev into main
Reviewed-on: #54
2026-10-27 11:00:59 -04:00
serversdown d2258dad4e Merge pull request 'Release v0.31.0 — report parity + the inverted rescue (0.29.0 → 0.31.0)' (#40) from dev into main
Reviewed-on: #40
2026-09-18 16:46:41 -04:00
serversdown e050e602c2 Merge pull request 'Release v0.29.0 — offset detector + false_trigger_reason + BlastMate serials (0.27.0→0.29.0)' (#36) from dev into main
Reviewed-on: #36
2026-09-07 15:57:37 -04:00
serversdown fc1c7c7936 Merge pull request 'Docs/claude.md corrections' (#35) from dev into main
Reviewed-on: #35
2026-08-29 15:48:33 -04:00
serversdown 7d0d12079b Merge pull request 'v0.27.0 Decoder fixes, offset exploration and testing.' (#34) from dev into main
Reviewed-on: #34
2026-08-28 22:40:34 -04:00
serversdown 5203aab849 Merge pull request 'update to 0.26.0. Big chonking update including 0.23, 0.24, and 0.25 as well.' (#33) from dev into main
Reviewed-on: #33
2026-08-27 13:43:00 -04:00
serversdown 5b65718b72 Merge pull request 'v0.23.0 - ZC freq in events store' (#31) from dev into main
Reviewed-on: #31
2026-08-06 12:12:19 -04:00
serversdown 483762607e Merge pull request 'Update to v0.22.0' (#30) from dev into main
Reviewed-on: #30
2026-07-03 15:35:20 -04:00
serversdown d0b66368d5 Merge pull request 'update to v0.21.1, thor data import successful' (#29) from dev into main
Reviewed-on: #29
2026-06-01 16:54:23 -04:00
serversdown 2eb1d25028 Merge pull request 'v0.20.0 -- Full s3 event parse and PDF creation.' (#28) from dev into main
Reviewed-on: #28
2026-05-28 17:54:31 -04:00
claude cc821f9ee3 hotfix: fix dockerfile on main to fix import bug on prod 2026-05-21 20:42:15 +00:00
3 changed files with 2520 additions and 2876 deletions

No files matched your search

+2424 -214
View File
File diff suppressed because it is too large. Load diff
+96 -127
View File
@@ -1,28 +1,30 @@
# SFM — where it actually stands as a tool
**Status as of 2026-12-04 (v0.36.0).** This is the honest assessment, not the
**Status as of 2026-09-20 (v0.31.0).** This is the honest assessment, not the
roadmap — `README.md § Roadmap` covers where it is *going*. Expect this file to
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`.
go stale; re-date it when you revise it.
---
## The framing
SFM is one module (Terra-View's ADR 0003 retired the old SFM / SDM split), but its
parts sit at very different levels of maturity:
SFM is **three different things wearing one name**, at three very different
levels of maturity:
| part | what it is | maturity |
| | what it is | maturity |
|---|---|---|
| **Decoding** | `minimateplus/`, `micromate/`: bytes in, events out | **Production, measured.** Checked field by field against Blastware and Thor at archive scale. |
| **The store and ingest** | the DB, the waveform store, `/db/*`, `/db/import/*` | **Production.** Terra-View depends on it daily. |
| **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** | `bridges/`, `scratch/`, `seismo_lab.py` | **Research tools.** Kept out of the production image since v0.36.0. |
| **The codec library** | `minimateplus/`, `micromate/` — bytes in, `Event` out | **Production.** Verified per-sample at scale. |
| **SDM — the data side** | the DB, waveform store, `/db/*`, ingest | **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 lab** | `seismo_lab.py`, `scratch/`, the Inspector | **Research artifacts.** Useful, not products. |
In September the device side was "an emergency tool and a research project"
(Brian). That has changed more than anything else here: it now speaks both
series by serial, with dry runs, an audit table and read-backs. What it lacks is
not protocol work but **a login, long-running jobs, and field use**.
Brian's own description — *"right now it's an emergency tool and a research
project"* — is accurate, and it applies specifically to the **device side**.
The data side is not an emergency tool; it has been carrying production for
months.
Most confusion about "is SFM reliable?" comes from answering for the wrong
tier.
---
@@ -30,69 +32,42 @@ not protocol work but **a login, long-running jobs, and field use**.
### Production-grade — trust it
- **Series-3 decode.** The checker (`scratch/check_s3_decode.py`) decodes all
70,042 DL2 events (2016–2026) from their bytes alone and compares every field,
sample and interval with Blastware's own `_XML.XML` report.
- **80 of 88 fields match on every event**; every other field matches or is
accepted under a carve-out with its evidence.
- **Geophone samples** are exact on 6,524 / 6,524 waveforms; **histogram**
interval peaks have 0 mismatches on every file.
- Left, by Brian's decision (2026-11-11): the vector sum's last digit on 4
waveform/histogram twins, and 4 accelerations.
- **Series-4 (Thor) decode.** 3,807,158 / 3,807,165 samples exact across 459
files and three corpora of Thor's own CSV exports (the 7 others are Thor's own
rounding); production IDFW 575 / 575 with zero truncations. Since v0.36.0 a
Thor file's settings, notes and event time come from the file itself (2,027 /
2,027 against Thor's reports).
- **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.
- **Series-3 decode.** 14,338 / 14,338 files decode per-sample exact against
preserved Blastware ASCII exports, 45 units, files back to 2018.
- **Series-4 (Thor) decode.** 1,057,536 / 1,057,536 geo samples exact against
Thor's own CSV exports; production IDFW 575/575 with zero truncations.
- **Histogram decode.** 1,211 / 1,211 production histograms exact, including
842,442 per-interval frequency comparisons with zero mismatches.
- **The ingest path.** `/db/import/blastware_file` and `/db/import/idf_file`
fed by the watchers — this is how prod actually gets its data, and it has
been running unattended for months.
- **`/db/*` read API.** Always-on, consumed by Terra-View for every fleet
listing, event detail and report.
- **The waveform store** — `.h5` + `.sfm.json` sidecars + retained raw
binaries, with operator review state preserved across regeneration.
- **`bridges/ach_server.py`** — speaks the full BW protocol to calling units.
Proven in the field, including as a rescue tool (see the runbook).
### Bench-proven — works, not yet trusted in the field
### Emergency-grade — works, but you are the error handling
- **Live device control by serial, both series** (`sfm/device_access/`, merged
2026-11-04): identify, status, settings read and change, event list and
download, start/stop monitoring, call-home on/off.
- Every write goes through one safety core: a fresh identity read, the run
state, a dry run showing the exact frames, a row in the `device_commands`
audit table, one send never retried, and a read-back.
- Verified on one bench unit per series (UM20147, BE9441); settings and
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.
- **`/device/*` live endpoints.** They do what they say. But they are
synchronous, unauthenticated, and a single cellular download can exceed the
60 s timeouts that sit in front of them.
- **The rescue ladder** (`rescue`, `stop_monitoring_*`, `events/erase`).
Each has worked in a real incident — but each has been used a handful of
times, by one person, with the runbook open.
- **The standalone webapp.** Perfectly usable, and as of v0.31.0 the cheap
probes and rescue actions are reachable without curl. No auth of any kind.
### Emergency-grade — you are the error handling
### Research artifacts — useful, not products
- **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 /
- **`seismo_lab.py`** — 2,789 lines of Tkinter (Bridge / Analyzer / Query DB /
Inspector). Desktop-only, single-user, no tests.
- **`scratch/`**: the checker and the verification harnesses
(`verify_thor_against_csv.py`, `verify_against_ascii.py`) and the offset
detector (`offset_scan3.py`). The production numbers above rest on them, so
they matter, but they are analysis scripts.
- **`bridges/`**: probes, relays and recording bridges for the bench.
- **`docs/offset_investigation.md`**: an open investigation, not a feature.
- **`scratch/`** — the verification harnesses (`verify_against_ascii.py`,
`verify_thor_against_csv.py`) and the offset detector (`offset_scan3.py`).
These produced the numbers the production claims rest on, so they matter —
but they are analysis scripts, not maintained code.
- **`docs/offset_investigation.md`** — an open investigation, not a feature.
---
@@ -100,19 +75,17 @@ not protocol work but **a login, long-running jobs, and field use**.
| you want to… | use | notes |
|---|---|---|
| Know if a unit is monitoring, its battery, its memory | SFM page → Serial → Status, or `GET /device/monitor/status?serial=…` | both series |
| Know whether call-home is on | `GET /device/call_home/state?serial=…` | both series |
| See how full a MiniMate's buffer is | `GET /device/events/storage_range` | MiniMate only; no event walk |
| List a unit's stored events | Events tab with a Serial, or `GET /device/events?serial=…` | a MiniMate's list reads headers only |
| 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 |
| 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 |
| 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 |
| Know if a unit is monitoring / its battery / memory | `GET /device/monitor/status?force=true` | ~2 s |
| Know whether ACH is on | `GET /device/call_home` | ~2 s. **Not** `/device/events`. |
| See how full a unit's buffer is | `GET /device/events/storage_range` | ~2 s, no chain walk |
| Stop a runaway unit | Diagnostics tab → Stop Monitoring | see the runbook first |
| 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 |
| List a unit's stored events | Events tab → Load events | **slow**, and broken past 64 KB (below) |
| Get event data into the DB | the watcher → `/db/import/*` path | not the live walk |
The single most useful habit still holds: **the cheap probes are cheap and the
event walk is not.** Do not list events to answer a yes/no question about a unit.
The single most useful habit: **the cheap probes are cheap and the event walk
is not.** Reaching for `/device/events` to answer a yes/no question about a
unit is the mistake that motivated the v0.31.0 webapp changes.
---
@@ -120,62 +93,58 @@ event walk is not.** Do not list events to answer a yes/no question about a uni
| issue | impact | status |
|---|---|---|
| **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`. |
| **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. |
| **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. |
| **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. |
| **#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. |
| **#32: some events decode to ramps or garbage** | corrupts shape-based false-trigger detection | Open, needs more information. |
| **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. |
| **`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).
| **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 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. |
| **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. |
| **`SUB 0x08` lifetime counter reads 0** | `/device/events/index` returns a meaningless number | Suspected field-offset bug. Surfaced in the UI as "unreliable". |
| **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. |
| **`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. |
| **14 sensitive-range files show an exact 8× discrepancy** | 10.0 / 1.25 — a units problem, not a decode problem | Open, not blocking. |
| **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. |
---
## 4. What stands between this and a real tool
Roughly in dependency order.
Roughly in dependency order — each unblocks the ones below it.
**1. A login.** Everything remote is gated on this. SFM has none, and the
modem IP whitelist gives no protection because SFM *is* the whitelisted origin.
The agreed design delegates rather than builds: Terra-View becomes the
authenticated jump host (`/api/sfm/*` already sits behind its operator login and
passes any path through), and the `8200:8200` publish is dropped so Terra-View is
the only door.
**1. Authentication.** Everything else is gated on this. SFM has none, and
the modem IP whitelist gives zero protection because SFM *is* the whitelisted
origin. The agreed design delegates rather than builds: Terra-View becomes the
authenticated jump host (`/api/sfm/*` already inherits deny-by-default operator
auth), and the `8200:8200` publish is dropped so Terra-View is the only door.
**2. Long operations as jobs.** POST starts a job, GET polls. Retrofitting
this after Terra-View drives units through synchronous calls would be far worse
than designing for it first.
**2. Async long operations.** POST starts a job, GET polls. Retrofitting this
after building a remote lab on top of synchronous endpoints would be far worse
than designing for it now.
**3. Field use of the device side.** It has been proven on one bench unit per
series. Using it on deployed units, a little at a time, is what turns "works"
into "trusted".
**3. Confirm-guards on the remaining destructive endpoints.** Auth answers
*who*, not *did you mean it*. The webapp's erase is guarded; the other seven
destructive POSTs and `/docs` are not.
**4. SFM answering call-ins itself** (ADR 0003's call-in server, after its staged
proof). It replaces Blastware's ACH and THOR as the receivers and ends the
modem contention.
**4. The 5A page-boundary fix.** Until this lands, live event download is
unreliable on exactly the units most likely to need attention — the ones that
have been recording heavily. Wants a Blastware capture of an event spanning a
page boundary before the chunk-addressing half is trustworthy.
**5. Retiring the Blastware report overlay.** The decoder is ready; the
remaining work is storing the decoded fields listed above and letting SFM's own
report read them.
**5. A live Thor / Micromate client.** The device side is MiniMate-only.
Series-4 units can only be read from forwarded files, so half the fleet has no
live path at all.
**Done since September:** the 64 KB fix; a live Series-4 client and both series
by serial; confirmation on every serial-named write (dry run, preview, audit,
read-back); a suite that goes green on a fresh checkout. The planned "SDM
rename" is dropped: the repo becomes `sfm` instead (ADR 0003).
**6. Test coverage that runs from a clean checkout.** 15 of 16 current
failures are missing fixture bundles. A test suite that cannot go green on a
fresh clone cannot gate anything.
**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 **data side is a real tool** and has been for months; the decoder now
matches Blastware field by field across ten years of files. The **device side
has grown from sharp instruments into a bench-proven tool for both series**,
with the safety core a real tool needs. The gap to using it on the fleet from
Terra-View is **a login, jobs instead of long calls, and field time** — not
protocol work.
The **data side is a real tool already**. The **device side is a set of sharp
instruments** that work in the hands of the person who wrote them, with the
runbook open. The gap between those two states is mostly **auth, async, and
guardrails** — not protocol work. The protocol is the part that is actually
finished.
File diff suppressed because it is too large. Load diff