Skip to content

feat(storage): journal sealing and storage maintenance sweep - #123

Merged
senamakel merged 7 commits into
epic/7973-storage-schema-v2from
epic-7973-7995-journal-seal
Oct 17, 2026
Merged

senamakel merged 7 commits into
epic/7973-storage-schema-v2from
epic-7973-7995-journal-seal

Conversation

@senamakel

Copy link
Copy Markdown
Owner

Refs tinyhumansai#7995

What changed

  • agent/tinyagents/journal.rs: finish_completed/finish_failed flush the append worker, then seal_run the run's harness.journal/<run_id> stream (non-fatal, logged).
  • storage/journal_maintenance.rs (new): periodic sweep = Registry::maintain_all then backend.maintain; retention applied by composing the owner schemas with the journal retain_ms taken from config. Spawned with the other periodic services (ServiceSet.cron switch, beside blob_sweep) in core/runtime/services.rs.
  • One-shot backfill per scope, recorded in tsd.migrations (harness / journal_seal_backfill_v1): seals every unsealed journal whose run is not active. Sealing is idempotent, so a crash re-runs it.
  • Config: [storage] journal_retention_days (default 30, 0 keeps forever) in config/schema/storage.rs.
  • No tinyagents change was needed; storage/boot.rs, storage/schema.rs and host stores untouched.

v1 to v2 mapping

No record shapes change; no new migration Step. The only new storage record is the tsd.migrations importer marker.

Tests (isolated HOME, memory backend fixtures)

sealed vs unsealed pages identical; backfill seals finished not active runs and records itself; retention honours config (1 day vs 30 default); 0 keeps forever; config default/TOML.

Gates

cargo check (root all-targets, app), clippy (4 crates, -D warnings), focused lib tests, check-storage-owner, check-storage-schema, check-feature-forwarding, rust:layout: all pass. Did not run the storage_*_e2e targets or full lib suite.

TurnJournal now retains the underlying journal and, on both terminal paths, flushes the append worker before sealing the run's stream so nothing is appended to a finished run and reads stay stable while retention runs. Sealing failures are logged and ignored, keeping the terminal writes best-effort.

Auto-committed-on: dragonfly
Add a journal_retention_days setting to StorageConfig that controls how
long a finished run's sealed event journal is kept before the storage
maintenance sweep deletes it, defaulting to 30 days with 0 meaning
forever. The manual Default impl replaces the derived one so the new
field gets its non-zero default.

Auto-committed-on: dragonfly
Expose the new journal_maintenance module from the storage module so its
maintenance routines can be used elsewhere in the crate.

Auto-committed-on: dragonfly
The runtime now starts the journal maintenance task alongside the other
background sweeps so sealing and retention run on a schedule. Retention
falls back to the storage config default instead of a standalone constant,
and tests cover the default and TOML override.

Auto-committed-on: dragonfly
Auto-committed-on: dragonfly
Reformat long method chains and the tracing macro call in the journal
maintenance module to satisfy rustfmt. No behaviour changes.

Auto-committed-on: dragonfly
Point the journal maintenance code and its tests at the relocated
HarnessStatusStore, StorageConfig, and read_run_events_page paths so the
module compiles against the reorganized harness crate.

Auto-committed-on: dragonfly
@senamakel
senamakel merged commit d336675 into epic/7973-storage-schema-v2 Oct 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant