Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .bestpractices.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"version_unique_status": "Met",
"version_unique_justification": "Each source revision has a unique Git commit ID. Release policy requires unique, immutable SemVer tags; the -dev label alone is not used as a release identifier. https://github.com/lennrt/tempestkeep/blob/main/RELEASING.md",
"version_semver_status": "Met",
"version_semver_justification": "Version metadata uses 0.2.0 and the release process requires vMAJOR.MINOR.PATCH tags and SemVer artifact versions. https://github.com/lennrt/tempestkeep/blob/main/internal/version/VERSION https://github.com/lennrt/tempestkeep/blob/main/RELEASING.md",
"version_semver_justification": "Version metadata uses 0.4.0 and the release process requires vMAJOR.MINOR.PATCH tags and SemVer artifact versions. https://github.com/lennrt/tempestkeep/blob/main/internal/version/VERSION https://github.com/lennrt/tempestkeep/blob/main/RELEASING.md",
"version_tags_status": "Unmet",
"version_tags_justification": "There are no published stable releases or release tags yet. Future approved releases require immutable signed SemVer tags. https://github.com/lennrt/tempestkeep/tags https://github.com/lennrt/tempestkeep/blob/main/RELEASING.md",
"release_notes_status": "Met",
Expand Down
6 changes: 4 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ TEMPEST_TOKEN=
# Keep the active archive on a local filesystem, outside cloud-sync folders.
# TEMPEST_DB=/absolute/path/to/weather/tempest.sqlite

# Optional: device for CLI collection. A positive integer selects the device.
# Optional: device for CLI collection and the MCP server's default station.
# A positive integer selects an accessible Tempest (ST) device.
# Unset or 0 discovers the first Tempest device available to the token.
# MCP and live CLI views discover their device and do not use this variable.
# MCP --device-id overrides this value; its explicit value must be positive.
# Live CLI views (now and explore) do not use this variable.
# TEMPEST_DEVICE_ID=

# Optional: earliest date for CLI backfill on a new archive, YYYY-MM-DD.
Expand Down
74 changes: 74 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,79 @@
# Changelog

## 0.4.0 (proposed, unreleased)

### Added

- Explicit CLI archive repair with paired inclusive `collect --start` and
`--end` dates, bounded to 366 calendar days and safe to replay.
- Exact `before_epoch` continuation for MCP backfill, including batches that
stop inside a daylight-saving transition day.
- `rain_readings` and `lightning_readings` counts in observation-series buckets,
with missing-value displays and incomplete-coverage notices in MCP Apps.
- Pointer, touch, and keyboard inspection for every returned chart point,
including dense series above 60 readings.
- Optional `export --metadata` fields for device ID, report interval, wind
interval, precipitation type, and source. Defaults remain unchanged.
- Read-only streaming access to stored observation metadata through
`store.ArchiveObs` and `Store.EachArchiveObs`.
- MCP `--device-id` and `TEMPEST_DEVICE_ID` selection for collection and the
default live station, with lazy resolution and explicit station overrides.
- A searchable Devices table in the `list_stations` app, with parent stations,
exact identifiers, bounded traversal, and compatible refresh state.
- Observation and rain-reading counts in rain summaries, with missing/partial
coverage guidance in CLI reports, MCP results, and the rainfall app view.

### Changed

- Preserve table search, sorting, dataset selection, and valid page position
across compatible refreshes. New requests and changed table structures reset
controls. Focused search text and selection survive a pending refresh.
- Center both time and temperature by calendar month in the trend fit, so
uneven seasonal coverage does not dilute the within-month slope.
- Report zero slope for repeated constant monthly temperatures and omit the
undefined R². See [ADR 0009](docs/adr/0009-seasonal-trend-estimation.md).
- Bump active development, plugin, and embedded app metadata to 0.4.0.
- Choose the nearest eligible pressure sample on either side of the requested
window start. Sparse history can now use a pair spanning at least half the
window, and an older sample can no longer mask a closer reading after it.
- Reject unsupported CLI report and export dates before configuration or archive
access, with usage status 2 and unchanged local calendar boundaries.
- Return a null rain summary total when no rain readings exist. Preserve measured
zero and sum only reported values in partially observed ranges.
- Lead the docs overview with multi-station workflows and guides to interactive
charts, table refresh, archive repair, metadata exports, and offline analysis.

### Compatibility

Archive recovery adds a `before_epoch` input to `backfill_archive` and two
reading-count fields to `get_observations` points. Existing numeric totals
keep their types; a zero count means its total is unknown, and a count below
`obs` means partial coverage. Exported `SeriesPoint` gains the corresponding
fields. See [ADR 0008](docs/adr/0008-archive-recovery-and-coverage.md).

Default CSV columns and JSON Lines fields remain unchanged. `--metadata` appends
five CSV columns and optional JSON fields. Metadata retains its stored units in
SI and US exports. Older schemas expose unavailable metadata as missing. The
store API additions do not change `model.Obs`. See
[ADR 0010](docs/adr/0010-export-metadata-and-development-version.md).

MCP now honors `TEMPEST_DEVICE_ID`; empty or zero keeps automatic selection.
An invalid or inaccessible selection does not fall back to another live device.
Sparse pressure results can change because comparison samples now match the
documented nearest-reading rule. See
[ADR 0011](docs/adr/0011-mcp-device-selection-and-pressure-samples.md).

`RainStats.TotalIn` changes from `float64` to `*float64`; Go callers must check
for nil. CLI rain JSON and MCP `rain_stats` now always encode `total_in` as a
number or `null`, with `observations` and `rain_readings` counts. Consumers must
accept null and the additional fields. Day counts, thresholds, spell rules,
and other rain aggregate types retain their contracts. Counts describe samples,
not continuous coverage. See [ADR 0012](docs/adr/0012-rain-summary-coverage.md).

Existing archives need no migration. Version 0.4.0 remains a development target;
no tag, release, plugin publication, or merge is part of this change.
Qualification still follows [RELEASING.md](RELEASING.md).

## 0.3.0 (proposed, unreleased)

### Added
Expand Down
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ credentials described below.

| Explore | In the app |
|---|---|
| Weather over time | Switch chart metrics, explore the wind rose, and inspect exact readings in the table. |
| Weather over time | Switch metrics, inspect chart points with pointer, touch, or keyboard, and explore the wind rose. |
| Archive and SQL results | Search rows, sort columns, and move between table pages. |
| Updated results | Refresh the same read-only tool with its original arguments. |
| Your working environment | Use responsive views that follow the host's light or dark theme. |
Expand All @@ -49,6 +49,8 @@ Search and pagination cover the returned rows. Views display up to 2,000 rows
and 64 columns, with a notice when a limit applies. If a server limit truncates
the result, narrow the tool request before drawing conclusions about the archive.
Missing readings remain distinct from zero. The app does not run archive writes.
Observation-series views show when rain or lightning readings are missing or
partial. Available totals do not imply complete sensor coverage.

MCP Apps support depends on the host and its version. Clients without the
extension retain the existing text and structured tool results. See the
Expand Down Expand Up @@ -147,7 +149,9 @@ For an existing archive without live access, omit `TEMPEST_TOKEN` and add
environment or loaded from `.env`. The server reads `.env` from its working
directory, which can differ from your terminal's directory.

If the token can access several devices, read the
If the token can access several devices, use `list_stations` or
`tempestkeep list-devices` to find the intended device. Set `TEMPEST_DEVICE_ID`
or add `--device-id` with that ID to the MCP arguments. See the
[device selection rules](docs/mcp.md#capabilities) before collecting.

The host launches `tempestkeep mcp` and exchanges JSON-RPC over stdin/stdout.
Expand Down Expand Up @@ -203,6 +207,17 @@ the interactive setup wizard, then collect history and open the dashboard:
./bin/tempestkeep explore
```

To fill a gap in an existing archive, collect an explicit range:

```sh
./bin/tempestkeep collect --start 2025-06-01 --end 2025-06-03
```

Both local dates are included. A range can cover at most 366 calendar days.
Repeating it is safe and leaves ordinary collection progress unchanged.
MCP clients can use `backfill_archive` and pass its exact `next_before` value
as `before_epoch` to continue a bounded request; repeat `start` and `max_days`.

For manual setup on Unix-like systems, copy `.env.example` to `.env` and run
`chmod 600 .env` before entering the token. Commands read that file from their
current working directory. Use the [CLI guide](cmd/tempestkeep/README.md) for
Expand Down Expand Up @@ -239,9 +254,9 @@ cycles the month/year metric. The `g` or Home key returns to the latest period.
The `q`, Esc, and Ctrl+C keys exit either dashboard.

`tempestkeep version` reports the build's injected version, then Go's module
version when available. If neither exists, it falls back to `v0.3.0-dev`.
version when available. If neither exists, it falls back to `v0.4.0-dev`.
`make build` injects a version from Git tags or that development fallback.
Version 0.3.0 is the proposed next minor release. See [CHANGELOG.md](CHANGELOG.md)
Version 0.4.0 is the proposed next minor release. See [CHANGELOG.md](CHANGELOG.md)
for its scope. This change does not publish a release.

## Archive behavior
Expand Down Expand Up @@ -382,7 +397,7 @@ Tempest names and marks belong to their respective owners. See [NOTICE.md](NOTIC

TempestKeep uses the MIT License. See [LICENSE](LICENSE).

[version-badge]: https://img.shields.io/badge/development-v0.3.0--dev-blue
[version-badge]: https://img.shields.io/badge/development-v0.4.0--dev-blue
[ci-b]: https://img.shields.io/github/actions/workflow/status/lennrt/tempestkeep/ci.yml?branch=main
[ci]: https://github.com/lennrt/tempestkeep/actions/workflows/ci.yml
[license-badge]: https://img.shields.io/github/license/lennrt/tempestkeep
Expand Down
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Choose a semantic version. Do not reuse or move a published tag.

Use `vMAJOR.MINOR.PATCH` for release tags and the corresponding SemVer version
for artifacts. Development snapshots retain the exact source commit as their
unique identifier; `v0.3.0-dev` alone does not identify a source revision.
unique identifier; `v0.4.0-dev` alone does not identify a source revision.

Update [CHANGELOG.md](CHANGELOG.md) with a human-readable account of changes,
compatibility effects, and upgrade instructions. Include every publicly known
Expand Down
75 changes: 71 additions & 4 deletions cmd/tempestkeep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ bin/tempestkeep list-devices

This output includes station and device identifiers. Keep it private. If your
token can access several devices, select the intended Tempest device for
collection with `--device-id` or `TEMPEST_DEVICE_ID`.
CLI collection or MCP with `--device-id` or `TEMPEST_DEVICE_ID`. For MCP, this
also sets the default live station; explicit tool station arguments can override
individual reads. See the [MCP selection rules](../../docs/mcp.md#capabilities).

## Collection

Expand All @@ -92,8 +94,28 @@ bin/tempestkeep collect --backfill-start 2025-01-01
```

The date starts at midnight in the process timezone. The flag does not request
an older gap repair on an archive that already has a watermark. For that case,
use an explicit `backfill_archive` window through [MCP](../../docs/mcp.md#build-an-archive).
an older gap repair on an archive that already has a watermark.

To repair a gap or collect a selected historical period, provide both dates:

```sh
bin/tempestkeep collect --start 2025-06-01 --end 2025-06-30
```

This mode requests only the selected local calendar days, including the entire
end date. If the end date is today, it requests observations only through the
current time. Both flags are required. A range may contain at most 366 calendar
days, including 23-hour or 25-hour days across daylight-saving changes. Dates
before the Unix epoch, future end dates, and reversed ranges are rejected
before API requests or archive creation.

An explicit range can populate a new archive or revisit rows older than the
current watermark. Existing observations are preserved, and repeated runs do
not add duplicates. It leaves saved seed and MCP sync progress unchanged.
It ignores `TEMPEST_BACKFILL_START`; combining the range flags with an explicit
`--backfill-start` flag is an error. Missing upstream observations remain missing.
The [MCP backfill tool](../../docs/mcp.md#build-an-archive) also supports selected
historical windows, with an exclusive end date instead.

Each API request covers at most five days. Each successful chunk commits before
the next request. The `(device_id, epoch)` key prevents duplicate rows when a
Expand All @@ -107,7 +129,9 @@ bin/tempestkeep collect --quiet

SIGINT and SIGTERM cancel collection. An interrupted run exits with a failure
status and preserves committed rows and resume metadata. Rerun the same command
to continue.
to continue. For an explicit range, repeat the same `--start` and `--end`
arguments. Earlier committed chunks are replayed safely before collection
reaches the unfinished part; this mode does not save a separate range cursor.

After successful collection, the command checkpoints SQLite's write-ahead log
(WAL), which holds recent database changes. It then closes the writer and makes
Expand Down Expand Up @@ -167,10 +191,23 @@ Both dates are local calendar dates. The end date includes the entire day.
Without a start date, the range starts at the beginning of the archive.
Without an end date, the range ends at the current time.

Both `stats` and `export` reject unsupported dates before loading configuration
or opening an archive. Resolved UTC timestamps must fall between 1970-01-01
00:00:00 and 9999-12-31 23:59:59. The inclusive bounds can differ by at most
36,600 days. Invalid ranges return usage status 2. Valid dates still use local
calendar boundaries, including 23-hour and 25-hour daylight-saving days.

The range applies to rain, wind, lightning, solar, pressure, comfort, and
weather-spell sections. Coverage, records, and temperature trend always
summarize the whole archive. This remains true in JSON output.

The rain section shows unavailable rainfall when no rain readings exist. A
measured zero remains `0.00 in`. Sample counts show how many stored observations
reported rain, and a partial-coverage warning identifies totals based on only
some readings. These counts do not prove continuous weather coverage.
In JSON, `rain.total_in` is a number or explicit `null`; `rain.observations` and
`rain.rain_readings` are always present. Missing rain does not hide other sections.

Reports use US display units for temperature, wind, pressure, and rain.
The command reads the archive without contacting WeatherFlow. See the
[query guide](../../docs/querying.md) before interpreting gaps or trends.
Expand Down Expand Up @@ -208,6 +245,36 @@ corresponding key. A missing temperature is not 0°C. See the
[query guide](../../docs/querying.md#units-and-aggregation) for interval totals
and aggregation rules.

Add `--metadata` to include stored observation context:

```sh
bin/tempestkeep export --format jsonl --metadata
```

The flag appends these CSV columns after the existing sensor columns. JSON Lines
adds the corresponding keys when their stored values are present:

| Field | Meaning |
|---|---|
| `device_id` | Device identifier stored with the observation. |
| `report_interval_min` | Report interval in minutes. |
| `wind_interval_s` | Wind sampling interval in seconds. |
| `precip_type` | Stored precipitation code: 0 none, 1 rain, 2 hail, 3 rain and hail. |
| `source` | Stored observation source, such as `rest`. |

These fields retain their stored values and units under `--units us`. Missing
values stay empty in CSV or absent in JSON; a known zero stays zero. If an older
archive lacks a metadata column, its values are missing. Source text is limited
to 1,024 UTF-8 bytes per row. Longer or invalid UTF-8 source values fail the
export rather than being silently changed. Omitting `--metadata` preserves the existing output.

Use `solar_wm2 * report_interval_min * 60 / 1000000` for each row's solar-energy
estimate in MJ/m². Match the archive report by including only present solar
readings with report intervals greater than zero and no more than 1,440 minutes.
For example, 100 W/m² over one minute gives 0.006 MJ/m². Missing intervals cannot
be reconstructed from an assumed sampling rate. This estimate does not establish
continuous sensor coverage or replace a restorable archive backup.

Exports contain private weather observations. For a saved export on Unix-like
systems, use a protected destination and an owner-only creation mask:

Expand Down
Loading
Loading