# Wire-format coverage

| Component | Supported behavior and boundaries |
| --- | --- |
| Steim-1 (10) | Four signed 8-bit, two signed 16-bit or one signed 32-bit difference per data word. Integration uses the full signed 32-bit sample domain. The first frame contains the forward and reverse integration constants. The declared sample count delimits trailing padding. |
| Steim-2 (11) | All seven layouts, from seven signed 4-bit differences up to one signed 30-bit difference. Encoding ends a record before a difference outside −536,870,912 through 536,870,911. The next record starts at the new absolute amplitude. |
| Frame packing | The encoder chooses the longest prefix that fits the frame budget and writes only the required frames. Each record starts with an independent first difference. A decoder ignores that first inter-record difference and checks the final sample against Xn. Reserved selectors in consumed words and impossible sample counts are errors. |
| miniSEED 2.4 | Reads data records with quality D, R, Q or M and blockette 1000. Header and sample word order may differ. Blockette 100 supplies an actual sample rate. Blockette 1001 supplies timing quality, signed microseconds and a frame count. Timing corrections are applied once. The reader translates the network, station, location and channel fields to a source ID. |
| miniSEED 3 | Checks length, calendar fields, UTF-8 JSON extra headers, source ID and CRC-32C. Reads and writes raw payloads through the record API. Header-only records have zero samples, rate, encoding and payload length. Raw access preserves records whose payload format is outside the waveform decoder. |
| Samples | The waveform API reads signed PCM (1, 3), IEEE binary32 and binary64 (4, 5), and Steim (10, 11). `samples` reads integers. `samples_f64` and `samples_f64_range` accept all six encodings. Unfiltered decoding follows input order. An exact source ID extracts one channel from a mixed archive. |
| Encoding-preserving conversion | `repack --encoding preserve` and `@wave.migrate_record` write one v3 record per numeric or header-only input, retaining encoding, sample bits, times and mapped extras. Fixed-width output uses little-endian sample lanes, including original IEEE NaN payloads and signed zero. Compressed output uses big-endian Steim words with the original differences and packing. Valid supported v3 records round-trip byte for byte. An unknown sample count, unsupported encoding, unmapped legacy blockette or v3 size overflow stops migration. |
| Integer recompression | `repack --encoding steim1` or `steim2` recompresses each source record independently. One output record preserves its extra-header text. If the frame budget or a large jump requires a split, FDSN.Sequence stays on the first fragment. DataQuality and Time.Quality follow each fragment. Extra fields of unknown scope and duplicate JSON keys cause an error when a split is required. `--frames` applies only to Steim encoding and recompression. |
| Timing | Positive rates express samples per second. Negative on-wire rates express seconds per sample. Splits use the original start and cumulative sample index. Fractional rates are evaluated from their binary64 representation and rounded once to the nearest nanosecond (ties upward). Civil-time arithmetic covers years 0001 through 9999. A supplied second 60 survives subsecond arithmetic. Add elapsed time across an unmarked civil date on an ordinary 86,400-second day. |
| Limits | The reader accepts miniSEED 2 record lengths from 128 bytes to 16 MiB, including different lengths within one stream. Individual v3 records are limited to 16 MiB. A raw codec decode accepts up to 16,777,216 samples per call, subject to frame capacity. The CLI frame budget is 1 through 65,536. Unsupported legacy blockette IDs remain available through Record.unmapped_blockettes. |

The header reader validates record structure and version 3 checksums. Waveform decoding additionally validates compressed data and the reverse integration constant. Unknown or compressed payloads whose sample count is unspecified are available through the record API for inspection.

Legacy blockettes 200 and 201 map to the ordered `FDSN.Event.Detection` array. The mapping retains onset time, detector, amplitude, period, background estimate and the detector-specific parameters. A generic detection with flag bit 2 set has undetermined polarity. Blockette 500 maps to `FDSN.Time.Exception`, including signed microsecond offsets, unsigned exception counts and clock status. A common model maps to `FDSN.Clock.Model`. Unrepresentable fields or conflicting clock models leave the blockette ID in `unmapped_blockettes` and prevent lossy conversion. `select` can copy the original record intact. [FDSN mapping reference](https://docs.fdsn.org/projects/miniseed3/en/latest/appendix.html)

Blockettes 300, 310, 320 and 390 add step, sine, pseudo-random and generic entries to `FDSN.Calibration.Sequence` in input order. Entries retain the recorded start, duration, amplitude, trigger and type-specific fields. Blockette 395 adds an entry containing only `EndTime`. The start of an aborted calibration may be in another record. Ambiguous amplitude flags, reserved values or fields that cannot be represented leave the original blockette ID in `unmapped_blockettes`. A structurally truncated blockette is a read error. [FDSN calibration mapping](https://docs.fdsn.org/projects/miniseed3/en/latest/appendix.html#blockette-300-step-calibration) · [FDSN extra-header schema](https://docs.fdsn.org/projects/miniseed3/en/latest/fdsn-reserved.html)

## Source selection and time coverage

`inspect`, `decode`, `select`, `repack`, `timeline` and `availability` accept a repeatable `--sid`. Selection uses the complete, case-sensitive source identifier. All input records pass structural checks and applicable CRCs before selection. A well-formed unrelated payload may use another encoding. An unmatched selector gives empty output or a zero-record summary.

`decode` and `select` accept `--from` (inclusive) and `--until` (exclusive), independently or together. They use UTC timestamps ending in Z with up to nine fractional digits. Equal bounds select nothing. A data record matches if the window contains a sample instant, rounded to the nearest nanosecond as in `@wave.time_at`. A window between two samples can therefore match no record. A header-only record is a point at its header start for raw selection. Timed selection reports an error with the file offset when the timing of a potentially relevant record cannot be determined. A single sample can be located at a known start even when its rate is unknown.

`select` writes whole matching records in input order, including their original padding and extra headers. It supports floating-point and opaque records. A record with a known positive sample count and a start inside the window can be selected even if its rate is missing. `decode` requires enough timing information to locate the cut. For a selected Steim record it integrates the entire record through Xn while retaining only the requested samples. Library users can call `@wave.TimeWindow::new`, `window.indices(record)` and either `@wave.samples_range` or `@wave.samples_f64_range` for the same cut, or `window.contains_record(record)` before copying its original bytes.

The default decode format, `i32le`, writes signed 32-bit integers and rejects floating-point records. `f64le` writes little-endian binary64, widening binary32 and integers, and copies original binary64 bits, including NaN payloads. CSV emits the header `source_id,time_utc,value` even for an empty selection. Each row includes the quoted source ID when needed, the UTC timestamp calculated from the original sample index with nine fractional digits, and the sample value. Non-finite values appear as `NaN`, `Infinity` and `-Infinity`. Negative zero appears as `-0`. A single sample at index zero needs only the start time. Later sample timestamps require a known rate. CSV exports recorded amplitudes without applying instrument-response calibration.

`@timeline.Tracker` compares the next start for each source with the furthest exclusive end previously covered. For example, a 20 Hz record with 400 samples covers 20 seconds, so the next record can start exactly 20 seconds later. A contained duplicate produces an overlap while preserving that end. When record starts and ends advance together, the tracker keeps one endpoint per source. Overlapping records with different starting minutes can leave several possible endpoints when a subsequent record may reveal a leap second. The tracker retains those endpoints and updates coverage when it sees the label.

The tracker evaluates records in arrival order. A gap it reports before a late backfill remains an arrival event. For a final archive inventory, use `availability` on records in any order. At end of input it emits the union for each source as half-open UTC spans in sorted order. Gaps between consecutive spans of the same source identify missing coverage. A tolerance joins gaps up to and including its value. `coveredNs` counts distinct covered nanoseconds and `bridgedNs` counts the joined gaps. Both are decimal strings. Records with indeterminate coverage emit `unassessed` with the original offset. Header-only records add no duration.

In MoonBit, create an inventory with `let inventory = @timeline.Availability::new()`, then call `inventory.step(record)` for each parsed record. It returns a reason when a record is immediately unassessable. `inventory.finish()` returns a snapshot of the spans. `inventory.finish_report()` also identifies records whose endpoints still exceed the supported calendar after all same-source leap labels arrive. Passing `offset` to `step` preserves the original byte offset in those diagnostics. The inventory stores interval endpoints and distinct explicit leap-minute labels per source. It uses O(R) storage for R records and O(R log R) time including sorting. The online tracker is available for applications that need immediate arrival alerts.

The CLI reports the arriving record's UTC start and byte offset. A gap or overlap also carries the signed difference in nanoseconds as a decimal string. A rate change compares consecutive known rates for that source, including equivalent positive hertz and negative period representations. An unknown sample count or rate, or an end outside the supported calendar, produces `unassessed` and clears that source's cursor. A header-only record leaves coverage untouched. The tracker remembers each explicitly labelled leap minute once per source, including when records arrive out of order. For intervals without such labels, civil days have 86,400 seconds.

## Native archive checks

`steimcheck` reads one record at a time from a file, redirected stdin or a pipe. Default mode checks the byte extent of integer and IEEE samples and integrates Steim differences through Xn without storing a decoded array. All IEEE bit patterns are valid waveform values. `--headers-only` accepts other waveform encodings, checks miniSEED 3 CRCs and reports the sum of the header sample counts. miniSEED 2 does not carry a record CRC. On success both modes write one JSON summary. A failure writes a diagnostic with the record offset to stderr and exits nonzero.

The Steim word layouts are defined in Appendix B of the SEED 2.4 manual. FDSN defines the miniSEED 3 fixed header and the byte order of each payload encoding. [SEED reference manual](https://www.fdsn.org/pdf/SEEDManual_V2.4.pdf) · [miniSEED 3 record definition](https://docs.fdsn.org/projects/miniseed3/en/latest/definition.html) · [FDSN data encodings](https://docs.fdsn.org/projects/miniseed3/en/latest/data-encodings.html)
