Skip to content

fix(facade): MongoDB streams can seal, so hosts' journal maintenance runs - #102

Merged
M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/facade-mongo-stream-seal
Nov 11, 2026
Merged

M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/facade-mongo-stream-seal

Conversation

@M3gA-Mind

Copy link
Copy Markdown
Collaborator

Part of #49. Not breaking.

Summary

The facade built MongoStreams with no blob store (config/mod.rs, plain and conditioned MongoDB engines), so seal() returned Unsupported(StreamSeal) for every facade user on MongoDB. Nothing outside this repo attaches a blob store itself or checks StreamSeal first, so every caller failed:

  • OpenHuman journal maintenance (storage/journal_maintenance.rs, every 6 h): its one-time backfill seals inactive journals with seal(..).await?. The Unsupported error ended the scope's pass, so the backfill marker was never written, the same "journal maintenance failed; retrying" warning repeated every sweep, and retention (delete_sealed_stream) never ran. Run journals accumulated on MongoDB.
  • OpenHuman scope move (storage/scope_move.rs) refused to move a sealed legacy stream onto MongoDB ("target cannot preserve sealed state").
  • tinyagents: the harness Store::seal, the storage-kit seal policy and stream migration failed the same way.

Fix

  • Plain MongoDB engine: builds the scope's MongoBlobStore first and gives it to MongoStreams (with_blob_store). Streams then advertise StreamSeal.
  • Conditioned MongoDB engine:
    • The bundle still exposes no blob port, because GridFS writes can't join the condition's transaction.
    • Its streams get their own unconditioned MongoBlobStore for the sealed log only. That's safe because the seal writes the log before the guarded marker transaction and deletes it if that transaction fails (MongoStreams::conditioned's documented contract).

Validation

On a Linux build host, merged onto main 6372924:

  • cargo test --locked -p tinystoragedrivers --features mongodb mongo_seal against a live replica set: 2 passed. Against a standalone mongod: the plain test passes; the conditioned test reports its expected skip (no transactions, so no conditioned bundle).
  • Revert check: with the previous config/mod.rs, both tests fail. The streams don't advertise StreamSeal, and the conditioned seal returns Unsupported(StreamSeal).
  • cargo test --workspace --all-features --locked: 857 passed, 0 failed, 1 ignored.
  • clippy -D warnings (0 items), cargo fmt --check, rustdoc -D warnings, cargo check -p tinystoragedrivers --no-default-features and with --features mongodb.

Tests (config/mod_mongo_seal_tests.rs, live MongoDB)

  • facade_mongo_streams_seal_read_and_delete_a_sealed_stream: the journal-maintenance lifecycle through tinystoragedrivers::open. It appends, seals, reads the sealed log, checks appends are refused, then deletes the sealed stream by info().sealed_ms.
  • facade_mongo_conditioned_streams_seal_while_blobs_stay_unsupported: a conditioned bundle seals while its blob port stays unsupported.

Reaching OpenHuman

OpenHuman pins tinystoragedrivers 5e8c8378. The fix applies after a release that includes it and an OpenHuman pin bump.

Manual check on a MongoDB-backed OpenHuman: finish an agent run, wait for the first maintenance sweep (10 min). The log shows no "journal maintenance failed" warning, and the run's journal stream is sealed.

…runs

The facade built MongoStreams with no blob store, so seal() returned
Unsupported(StreamSeal) for every facade user on MongoDB. OpenHuman's
journal maintenance stops a scope's pass on that error: its one-time
backfill never completed and retention never deleted sealed journals,
so run journals accumulated on MongoDB. Its scope move refused sealed
legacy streams, and tinyagents' and the storage kit's seal paths failed
the same way.

The plain MongoDB engine now builds the scope's MongoBlobStore first and
gives it to the streams. The conditioned engine exposes no blob port
(GridFS writes cannot join the condition's transaction), so its streams
get their own MongoBlobStore for the sealed log only: it is written
before the guarded marker transaction and deleted if that fails.

Part of tinyhumansai#49
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0abd6898-c320-4012-9ca9-4ff9e74a7272
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@M3gA-Mind
M3gA-Mind merged commit 6355ea2 into tinyhumansai:main Nov 11, 2026
14 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