Skip to content

test(session): cover file and MongoDB driver contracts - #494

Merged
senamakel merged 18 commits into
tinyhumansai:mainfrom
senamakel:epic-8089-71-sessions
Oct 18, 2026
Merged

senamakel merged 18 commits into
tinyhumansai:mainfrom
senamakel:epic-8089-71-sessions

Conversation

@senamakel

@senamakel senamakel commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Adds conformance coverage for the file and MongoDB storage drivers used by tinyagents-session.

  • File-backed session stores run the shared round-trip, list/delete, and agent-isolation contracts. File-backed run ledgers cover workflow CRUD/scope semantics, competing lease claims, renewal, and revision fencing. Unsupported validated-batch operations are checked for unchanged full collections, including event heads and outbox records.
  • MongoDB session-store and run-ledger conformance use the same shared contract suites in an excluded proof workspace. Tests require explicit TSD_MONGO_URL, reject non-loopback hosts, and use unique databases. Keeping MongoDB/BSON outside the normal workspace prevents its serde_json/preserve_order feature from changing the workspace dependency graph. A dedicated workflow starts a TSD-style local replica set and runs both tests for PRs and nightly.

Validation:

  • cargo fmt --all -- --check; Mongo proof manifest formatting and actionlint passed.
  • cargo check -p tinyagents-session --all-features; cargo test -p tinyagents-session --all-features (597 passed; 2 doctests passed).
  • Strict Clippy passed for tinyagents-session (--all-targets --all-features) and the full workspace (--workspace --all-targets). The exact same commands passed on isolated base 43861dbf2f89c72f493a57eb7dce474369267800. The initial Clippy failure was dependency feature unification from the MongoDB dev-dependency; MongoDB now lives in its excluded proof manifest, and the normal feature graph no longer enables BSON's serde_json/preserve_order.
  • Mongo proof check, test, target-specific strict Clippy, and format checks passed. With no URL, both Mongo tests are visibly ignored; with TSD_MONGO_URL=mongodb://localhost:27317/tsd_test?directConnection=true, both passed against a local replica set. Forcing --ignored without the URL fails loudly as intended.
  • File conformance filter passed (11 tests), including full-record no-partial-write snapshots and a synchronized three-way lease race.

Refs senamakel#71
Part of tinyhumansai/openhuman#8089

Summary by CodeRabbit

  • Tests
    • Expanded storage-driver conformance coverage for file-backed and MongoDB stores, including session persistence, workflow records, leases, and tenant isolation.
    • Added checks for concurrent lease handling and for unsupported batch operations leaving records unchanged.
    • Added an opt-in MongoDB test workflow that runs against a local replica set.

Extend the session store conformance suite to cover the file and MongoDB
storage drivers alongside the existing memory and SQLite backends. The
MongoDB test is ignored by default and requires a local replica set via
TSD_MONGO_URL, with a helper that validates the target is loopback and
generates a unique database name per run.

Auto-committed-on: dragonfly
Adds a shared conformance check that runs the run ledger contract against a scoped backend and verifies that a separate scope cannot list another scope's runs. The check runs against file storage by default and against MongoDB behind an ignored test that requires a local replica set.

Auto-committed-on: dragonfly
Reordered the driver imports so the core crate precedes the file crate, and
reformatted the MongoDB-backed conformance test's store construction to fit
within the line width. No behaviour changed.

Auto-committed-on: dragonfly
Auto-committed-on: dragonfly
The file storage driver no longer needs its own conformance test since the shared helper already covers ledger conformance and scope isolation for all backends.

Auto-committed-on: dragonfly
@tinysweeper

tinysweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

Tiny Sweeper reviewed this change across 5 lane(s) and found 0 active actionable finding(s). Detailed lane evidence and any incomplete work are listed below.

State: Incomplete
Priority: none
Reviewed head: 4988f64bb693
Updated: 2026-10-18T19:48:43Z

Review snapshot

Change surface Files Review signal Count
Production 0 Active findings 0
Tests 4 Noted findings 0
Documentation 0 Resolved findings 0
Configuration 4 Pending checks/questions 16

Completeness: Incomplete
Test assessment: No supported feature-to-test mapping was available; this does not mean tests are absent or passed.

Features

None identified with supported citations.

Tests

No supported feature-to-test mapping was produced. Test execution is not inferred.

  • Unreviewed: tinysweeper/tests

Findings

No active actionable findings.

Could not review: .github/workflows/session-mongodb.yml, Cargo.toml, crates/tinyagents-session/Cargo.toml, crates/tinyagents-session/src/port/drivers/mod_tests.rs, crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs, crates/tinyagents-session/src/testkit/conformance.rs, integration-proofs/run-ledger-mongodb/tests/session_driver_conformance.rs, tinysweeper/description, tinysweeper/tests

Before merge

  • Complete the critique review for .github/workflows/session-mongodb.yml, Cargo.toml, crates/tinyagents-session/Cargo.toml, crates/tinyagents-session/src/port/drivers/mod_tests.rs, crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs, crates/tinyagents-session/src/testkit/conformance.rs, integration-proofs/run-ledger-mongodb/tests/session_driver_conformance.rs.
  • Complete the security review for .github/workflows/session-mongodb.yml, crates/tinyagents-session/Cargo.toml, crates/tinyagents-session/src/port/drivers/mod_tests.rs, crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs, Cargo.toml, integration-proofs/run-ledger-mongodb/tests/session_driver_conformance.rs, crates/tinyagents-session/src/testkit/conformance.rs.
  • Complete the tests review for tinysweeper/tests.
  • Complete the description review for tinysweeper/description.

How this fits together

flowchart LR
  n0["sqlite_backed_stores_keep_agents_apart<br/>changed"]:::changed
  n1["unwrap"]:::impacted
  n2["ledgers"]:::impacted
  n3["upsert_workflow_run"]:::impacted
  n4["workflow"]:::impacted
  n5["...ence_stale_owners_and_lifecycle_revisions"]:::impacted
  n6["...low_concurrent_native_claim_has_one_owner"]:::impacted
  n0 -->|calls| n1
  n0 -->|tests| n1
  n2 -->|calls| n1
  n5 -->|calls| n1
  n5 -->|tests| n1
  n5 -->|calls| n2
  n5 -->|tests| n2
  n5 -->|calls| n3
  n5 -->|tests| n3
  n5 -->|calls| n4
  n5 -->|tests| n4
  n6 -->|calls| n1
  n6 -->|tests| n1
  n6 -->|calls| n2
  n6 -->|tests| n2
  n6 -->|calls| n3
  n6 -->|tests| n3
  n6 -->|calls| n4
  n6 -->|tests| n4
  classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
  classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
  classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
  classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Loading
Agent review details

critique

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered: .github/workflows/session-mongodb.yml, Cargo.toml, crates/tinyagents-session/Cargo.toml, crates/tinyagents-session/src/port/drivers/mod_tests.rs, crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs, crates/tinyagents-session/src/testkit/conformance.rs, integration-proofs/run-ledger-mongodb/tests/session_driver_conformance.rs
  • Lane summary: Reviewed 0 files; 0 findings. 7 files could not be reviewed: .github/workflows/session-mongodb.yml, Cargo.toml, crates/tinyagents-session/Cargo.toml, crates/tinyagents-session/src/port/drivers/mod_tests.rs, crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs, crates/tinyagents-session/src/testkit/conformance.rs, integration-proofs/run-ledger-mongodb/tests/session_driver_conformance.rs.

security

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered: .github/workflows/session-mongodb.yml, crates/tinyagents-session/Cargo.toml, crates/tinyagents-session/src/port/drivers/mod_tests.rs, crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs, Cargo.toml, integration-proofs/run-ledger-mongodb/tests/session_driver_conformance.rs, crates/tinyagents-session/src/testkit/conformance.rs
  • Lane summary: Reviewed 0 files; 0 findings. 7 files could not be reviewed: .github/workflows/session-mongodb.yml, crates/tinyagents-session/Cargo.toml, crates/tinyagents-session/src/port/drivers/mod_tests.rs, crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs, Cargo.toml, integration-proofs/run-ledger-mongodb/tests/session_driver_conformance.rs, crates/tinyagents-session/src/testkit/conformance.rs.

tests

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered: tinysweeper/tests
  • Lane summary: No reviewer produced a usable response.

commits

  • Conclusion: Neutral
  • Scope reviewed: all assigned evidence
  • Lane summary: Nothing sensitive found in what this pull request commits.

description

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered: tinysweeper/description
  • Lane summary: No reviewer produced a usable response.
Evidence and run details
  • Models: ladder/vectors-oai3
  • Spend: $0.000097
  • Tokens: 0 input · 0 output · 0 cached · 746 embedding
Head State Pass summary
15d047d755b7 incomplete 0 active finding(s), 0 resolved finding(s) (at 2026-10-18T19:10:06Z)
4988f64bb693 incomplete 0 active finding(s), 0 resolved finding(s) (at 2026-10-18T19:48:43Z)

tinysweeper 0.1.2

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T19:53:09.650969Z 4988f64 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1ef4ea5f-19e6-4fd8-bace-b956f9917b6d
📥 Commits

Reviewing files that changed from the base of the PR and between 15d047d and 4988f64.

⛔ Files ignored due to path filters: 2
  • Cargo.lock is excluded by !**/*.lock
  • integration-proofs/run-ledger-mongodb/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing: 7
  • .github/workflows/session-mongodb.yml
  • Cargo.toml
  • crates/tinyagents-session/Cargo.toml
  • crates/tinyagents-session/src/port/drivers/mod_tests.rs
  • crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs
  • crates/tinyagents-session/src/testkit/conformance.rs
  • integration-proofs/run-ledger-mongodb/tests/session_driver_conformance.rs
💤 Files with no reviewable changes: 3
  • Cargo.toml
  • crates/tinyagents-session/Cargo.toml
  • crates/tinyagents-session/src/port/drivers/mod_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

📝 Walkthrough

Adds FileStorage and MongoDB conformance tests for session stores and run ledgers. Adds a local MongoDB replica-set launcher and a GitHub Actions workflow to run the MongoDB tests.

Changes: Session storage conformance

Layer / File(s) Summary
FileStorage conformance tests
Cargo.toml, crates/tinyagents-session/Cargo.toml, crates/tinyagents-session/src/port/drivers/mod_tests.rs, crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs, crates/tinyagents-session/src/testkit/conformance.rs
Adds FileStorage session-store and run-ledger checks. These cover scoped workflow persistence, lease claims and updates, unsupported validated-batch operations, and single-record telemetry upserts.
MongoDB conformance tests
integration-proofs/run-ledger-mongodb/tests/session_driver_conformance.rs
Adds ignored MongoDB tests for session-store and run-ledger conformance. The tests validate loopback URLs, use uniquely named databases, and check tenant isolation.
MongoDB replica-set CI execution
.github/scripts/start-session-mongo-replset.sh, .github/workflows/session-mongodb.yml
Adds a script that starts MongoDB and waits for a writable primary. Adds a workflow that runs the ignored MongoDB conformance tests.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 4988f

The new conformance tests are included in the dedicated CI workflow, and no actionable merge-blocking issue remains.

Security architecture risk: 🔵 Low · up to 4988f

Exposure is limited to an opt-in local test database and a read-only CI job, rather than production services. No introduced security vulnerability was established. Database cleanup outside disposable CI and some external-driver connection semantics remain unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The supported automated path exposes synthetic test state and the CI runner, not a production tenant or deployment credential. PR-controlled code executes with the job's declared read-only repository permission, while the database endpoint is fixed in workflow configuration.

Trust Boundaries and Controls

  • observed — The URL guard requires mongodb, an explicit port, an allowlisted loopback host spelling, and no username or password. Compared with the existing native proof, the new helper additionally accepts localhost rather than requiring a literal loopback address. CI fixes that URL, enables direct connection, and disables persisted checkout credentials; arbitrary operator-supplied URI options are not independently validated here.

Hardening Proposals

  • proposed — For reuse outside disposable CI, wrap fixture startup and testing in owner-scoped teardown that removes only the container created by that invocation, including after failure or interruption. The existing native-proof procedure provides a container-ID-based ownership pattern.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding contract coverage for file and MongoDB session drivers.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the store with care,
Then tests each lease and scoped-run pair.
Mongo starts; the primary gleams,
While CI checks the storage streams.
The ledger keeps its boundaries clear.

Comment @coderabbitai help to get the list of available commands.

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tinysweeper found nothing blocking, but could not review everything, so this is not an approval: .github/scripts/start-session-mongo-replset.sh, .github/workflows/session-mongodb.yml, Cargo.toml, crates/tinyagents-session/Cargo.toml, crates/tinyagents-session/src/port/drivers/mod_tests.rs, crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs, crates/tinyagents-session/src/testkit/mod.rs, tinysweeper/description and 1 more.

$0.0001 · 0 in / 0 out · 628 embedded · ladder/vectors-oai3

@tinysweeper tinysweeper Bot added the priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect. label Oct 18, 2026
@senamakel
senamakel marked this pull request as draft October 18, 2026 19:12
…c ops

Adds tests exercising the FileStorage workflow lease path, including
concurrent claimers, renewal by a non-owner, and revision-fenced
compare-and-swap. Also verifies that unsupported validated-batch agent
operations fail without leaving partial writes in agent or event rows.

Auto-committed-on: dragonfly
Extend the file ledger test to verify that a claim on an agent team task fails with an unsupported validated batch error when the driver cannot perform atomic writes. The task is asserted to remain in the todo state and unclaimed after the failed operation.

Auto-committed-on: dragonfly
Explain that FileStorage is tested against the operations its capability set supports, namely workflow CRUD and leases, and that atomic agent, event, and task operations are verified to return Unsupported(ValidatedBatch) without partial writes because its document driver lacks the required multi-document transaction boundary.

Auto-committed-on: dragonfly

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15d047d755

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/tinyagents-session/Cargo.toml Outdated
The driver tests now compare full collection snapshots before and after
failed atomic operations instead of checking only the public list views,
so partial writes to any record are caught. The lease race test also
synchronises claimants on a barrier and asserts that losing live
claimants report Busy with the winning owner.

Auto-committed-on: dragonfly
The file ledger test now snapshots the tasks and members collections after the
seed upserts instead of before them, so the comparison reflects only the
partial-write behaviour under test. The unused request imports were dropped.

Auto-committed-on: dragonfly
Auto-committed-on: dragonfly
The MongoDB driver conformance tests were removed from the
tinyagents-session crate and relocated to the integration-proofs
workspace, so the crate no longer depends on tinystoragedrivers-mongodb.
The CI workflow now runs the conformance suite from its new location and
watches the integration-proofs path for changes.

Auto-committed-on: dragonfly
…/conformance.rs,integration-pro

Auto-committed-on: dragonfly
Adjust line wrapping and assertion formatting in the MongoDB session
driver conformance test to satisfy rustfmt. No behaviour changes.

Auto-committed-on: dragonfly
Drops the unused conformance and scope isolation helper along with its
now-unneeded RunLedgerStore import from the driver tests. The helper was
no longer referenced, so removing it keeps the test module free of dead
code.

Auto-committed-on: dragonfly
Updates the Cargo.lock for the MongoDB run-ledger integration proof to
pick up tinyagents 2.2.0 and the tinystoragedrivers v1.0.0 tag, along
with the cap-std and rustix dependencies those crates now require.

Auto-committed-on: dragonfly
…names

The test now builds database names from a shorter prefix and a compact
UUID representation, keeping identifiers within MongoDB's length limit
while still guaranteeing uniqueness per run.

Auto-committed-on: dragonfly
@senamakel
senamakel marked this pull request as ready for review October 18, 2026 19:47

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tinysweeper found nothing blocking, but could not review everything, so this is not an approval: .github/workflows/session-mongodb.yml, Cargo.toml, crates/tinyagents-session/Cargo.toml, crates/tinyagents-session/src/port/drivers/mod_tests.rs, crates/tinyagents-session/src/run_ledger/drivers/mod_tests.rs, crates/tinyagents-session/src/testkit/conformance.rs, integration-proofs/run-ledger-mongodb/tests/session_driver_conformance.rs, tinysweeper/description and 1 more.

$0.0001 · 0 in / 0 out · 746 embedded · ladder/vectors-oai3

@senamakel
senamakel merged commit fb31e6f into tinyhumansai:main Oct 18, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant