Skip to content

feat(types)!: WriteOp::PutWith carries a put's WriteOptions into an atomic batch - #100

Merged
M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:feat/write-op-put-with
Nov 11, 2026
Merged

M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:feat/write-op-put-with

Conversation

@M3gA-Mind

Copy link
Copy Markdown
Collaborator

Breaking: for tinystoragedrivers v3.0.0 (after v2.1.3). Part of #49, item (g).

Summary

A batched WriteOp::Put carried no options, so every engine wrote it with WriteOptions::default(): schema 0 and no expiry, even where a single put_with would have recorded both. Three batch writes in consumers silently lose their declared schema today:

  • tinymcp registry index pages (registry/store/index.rs:404-405);
  • tinyflows saved proposals (tinyflows-drivers/src/store/proposals.rs:83-89);
  • tinyagents thread metadata (tinyagents-session/src/threads/driver/append.rs:258-263).

This adds WriteOp::PutWith { collection, id, doc, precondition, options }. The memory, SQLite and MongoDB batches apply its options exactly as put_with does, and a plain Put still writes the defaults. A new variant, rather than a new field on Put, keeps every existing WriteOp::Put { … } literal compiling; about 30 such literals exist across openhuman, tinyflows, tinyagents and tinymcp.

Over the bus, a module's batch may declare schema and expiry but never created_ms. Both the client and the host refuse it with InvalidInput, as they already do for Put, so a module still can't choose a record's creation time.

API or behavior changes (breaking)

  • WriteOp gains a variant. Code that matches WriteOp exhaustively must handle PutWith. Known non-test exhaustive matches outside this repo:
    • openhuman crates/openhuman-core/src/cron/documents_port.rs:289-294 (Put { .. } | Delete { .. }, no wildcard);
    • tinyflows-module src/schedule_documents.rs:197-201.
    • openhuman cron/documents_port.rs:341 is test-only.
  • On the wire, a batch op tagged put_with is new. A host built before this fails to decode a batch carrying one; batches without it decode as before.
  • tinystoragedrivers_bus::CONTRACT_VERSION 7 → 8 and tinystoragedrivers_api::CONTRACT_VERSION 5 → 6.
    • Nothing outside this repo reads either constant or calls is_compatible, and module admission doesn't check them, so the bumps are documentation.
    • Note: docs/specs/primitives-v2.md says every bus request carries the version and is rejected on a mismatch, but no busproxy code does that today.

Follow-ups for the consumers (after the release)

  • tinymcp write_chunk: batch with PutWith { options: write_options() }.
  • tinyflows save_proposal_if_fingerprint: batch with PutWith and SCHEMA_VERSION, and handle PutWith in schedule_documents.rs.
  • tinyagents thread append: PutWith with its schema.
  • openhuman cron/documents_port.rs: add the PutWith arm.

Validation

On a Linux build host, merged onto main f5a3302 (merges cleanly onto 6372924):

  • cargo test --workspace --all-features --locked: 858 passed, 0 failed, 1 ignored (855 + 3 new).
  • cargo test --locked -p tinystoragedrivers-document --features mongodb against a live replica set: 91 passed, 0 skipped. That includes the conformance batched_options case on MongoDB, SQLite and memory.
  • clippy -D warnings (0 items), cargo fmt --check, rustdoc -D warnings, cargo check -p tinystoragedrivers --no-default-features.

Tests

  • Conformance batched_options (testkit, every engine with RecordMetadata): a batched PutWith records its schema and expiry, and a later batched plain Put writes the defaults over them.
  • busproxy:
    • a batched PutWith carries its options across the wire;
    • a batched created_ms is refused before sending (client);
    • the host's batch_ops refuses it too (server).
  • types: put_with serde round-trip, and its options default when omitted.

…tomic batch

A batched WriteOp::Put had no options, so every engine wrote it with
WriteOptions::default(): schema 0 and no expiry, even where a single
put_with would have recorded both. tinymcp's registry index pages,
tinyflows' saved proposals and tinyagents' thread metadata are batch
writes that silently lose their declared schema this way.

WriteOp::PutWith { collection, id, doc, precondition, options } applies
its options exactly as put_with does in the memory, SQLite and MongoDB
batches; a plain Put still writes the defaults. Over the bus, a
module's batch may set schema and expiry but never created_ms, which
both the client and the host refuse, as on Put.

BREAKING CHANGE: WriteOp gains a variant. Code that matches WriteOp
exhaustively must handle PutWith. The bus contract moves to 8 and the
API contract to 6.

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: 5e425677-6a14-461a-bf03-53b82e6d8b11
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@tinysweeper

tinysweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

Verdict: Incomplete · Priority: none
Coverage: Reviewed 6 of 16 files; not reviewed (large PR): crates/tinystora…, crates/tinystora…, and 8 additional unreviewed files.
Pull request purpose (title): feat(types)!: WriteO…

Diagnostics and supporting details

Full summary

Pull request purpose (title): feat(types)!: WriteOp::PutWith carries a put's WriteOptions into an atomic batch. This pull request adds `WriteOp::PutWith` so an atomic batch can carry a put's `WriteOptions` (schema version and expiry) instead of always writing the defaults, and wires it through the memory, SQLite and MongoDB engines, the busproxy client/server, the conformance suite and the specs, with contract-version bumps on the types/bus and API contracts. The latest-push delta is unavailable (no trusted base-to-head comparison), so nothing here is a push-delta assessment. No findings were reported by any lane, so there is nothing to soften, remove or reprioritize.

Unreviewed paths

  • crates/tinystoragedrivers-api/src/lib_tests.rs
  • crates/tinystoragedrivers-bus/src/limits_tests.rs
  • crates/tinystoragedrivers-busproxy/src/client/documents.rs
  • crates/tinystoragedrivers-busproxy/src/server/documents.rs
  • crates/tinystoragedrivers-busproxy/src/server/documents_tests.rs
  • crates/tinystoragedrivers-document/src/sqlite/documents/mod.rs
  • crates/tinystoragedrivers-types/src/document/types.rs
  • crates/tinystoragedrivers-types/src/document/types_tests.rs
  • docs/specs/primitives-v2.md
  • docs/specs/storage-bus.md

Partial review reasons

  • critique: crates/tinystoragedrivers-api/src/lib_tests.rs — not selected by the large-review budget
  • security: crates/tinystoragedrivers-api/src/lib_tests.rs — not selected by the large-review budget
  • critique: crates/tinystoragedrivers-bus/src/limits_tests.rs — not selected by the large-review budget
  • security: crates/tinystoragedrivers-bus/src/limits_tests.rs — not selected by the large-review budget
  • critique: crates/tinystoragedrivers-busproxy/src/client/documents.rs — not selected by the large-review budget
  • security: crates/tinystoragedrivers-busproxy/src/client/documents.rs — not selected by the large-review budget
  • critique: crates/tinystoragedrivers-busproxy/src/server/documents.rs — not selected by the large-review budget
  • security: crates/tinystoragedrivers-busproxy/src/server/documents.rs — not selected by the large-review budget
  • critique: crates/tinystoragedrivers-busproxy/src/server/documents_tests.rs — not selected by the large-review budget
  • security: crates/tinystoragedrivers-busproxy/src/server/documents_tests.rs — not selected by the large-review budget
  • critique: crates/tinystoragedrivers-document/src/sqlite/documents/mod.rs — not selected by the large-review budget
  • security: crates/tinystoragedrivers-document/src/sqlite/documents/mod.rs — not selected by the large-review budget
  • critique: crates/tinystoragedrivers-types/src/document/types.rs — not selected by the large-review budget
  • security: crates/tinystoragedrivers-types/src/document/types.rs — not selected by the large-review budget
  • critique: crates/tinystoragedrivers-types/src/document/types_tests.rs — not selected by the large-review budget
  • security: crates/tinystoragedrivers-types/src/document/types_tests.rs — not selected by the large-review budget
  • critique: docs/specs/primitives-v2.md — not selected by the large-review budget
  • critique: docs/specs/storage-bus.md — not selected by the large-review budget

Review snapshot

Change surface Files Review signal Count
Production 8 Active findings 0
Tests 6 Noted findings 0
Documentation 2 Resolved findings 0
Configuration 0 Pending checks/questions 28

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

What changed

`WriteOp` gains a `PutWith` variant carrying a document plus `WriteOptions`, while a plain `Put` continues to write `WriteOptions::default`. The memory engine, the SQLite engine and the MongoDB engine apply a batched `PutWith` exactly as a single `put_with`; MongoDB additionally factors its per-op batch logic into a shared `batch_op` helper used inside the transaction. Over the wire, the busproxy client refuses a batched `created_ms` before sending, and the host's `batch_ops` refuses it on decode, so a module still cannot choose a record's creation time. `tinystoragedrivers_bus::CONTRACT_VERSION` moves 7 → 8 and `tinystoragedrivers_api::CONTRACT_VERSION` moves 5 → 6, with the pinned version tests updated; `docs/specs/primitives-v2.md` and `docs/specs/storage-bus.md` document the new batch semantics. The change is breaking: exhaustive matches on `WriteOp` must handle the new variant, and a host built before this cannot decode a batch op tagged `put_with`.

Features

  • Added — `WriteOp::PutWith` variant: Lets one operation in an atomic batch declare a schema version and expiry, closing the gap where batched puts silently dropped both. Existing `WriteOp::Put { .. }` literals keep compiling because no field was added to `Put`. (crates/tinystoragedrivers-types/src/document/types.rs pub enum WriteOp {)
  • Modified — Memory engine batch handling of `PutWith`: A batched `PutWith` applies its own options through the same guarded write path the single `put_with` uses, including the schema check over batch collections. (crates/tinystoragedrivers-document/src/memory/documents.rs impl DocumentStore for MemoryDocuments {)
  • Modified — SQLite engine batch handling of `PutWith`: A batched `PutWith` is routed to the SQLite `put_with` write path with its options, so schema and expiry are recorded transactionally with the rest of the batch. (crates/tinystoragedrivers-document/src/sqlite/documents/mod.rs impl DocumentStore for SqliteDocuments {)
  • Internal refactor — MongoDB per-op batch helper: The inline per-op match inside the batch transaction is extracted into a `batch_op` helper that distinguishes plain `Put` (default options) from `PutWith` (its own options), keeping the multi-document transaction behavior unchanged for existing ops. (crates/tinystoragedrivers-document/src/mongodb/documents.rs impl MongoDocuments {)
  • Added — Client-side refusal of a batched `created_ms`: A module that includes `created_ms` in a batched `PutWith` gets `InvalidInput` before anything is sent, matching the existing single-`put_with` refusal. (crates/tinystoragedrivers-busproxy/src/client/documents.rs fn batch(checks: &[ReadCheck], ops: Vec<WriteOp>) -> Result<wire::BatchRequest>)
  • Added — Host-side refusal of a batched `created_ms`: The host independently rejects a decoded batch op that sets `created_ms`, so a hand-crafted or older client request cannot choose a record's creation time; schema and expiry remain permitted. (crates/tinystoragedrivers-busproxy/src/server/documents.rs fn batch_ops(ops: Vec<wire::WriteOp>) -> Result<Vec<WriteOp>, wire::StorageFailu)
  • Modified — Contract version bumps and pinned tests: The bus wire contract moves to 8 and the API contract to 6, with the pinned assertions updated; the description states nothing outside this repo reads these constants or checks them at module admission, so the bumps are documentation of the wire addition. (crates/tinystoragedrivers-bus/src/limits.rs, crates/tinystoragedrivers-api/src/lib.rs)
  • Added — Spec documentation of batched write options: The primitive and bus specs now state that a batch applies `Put` with defaults and `PutWith` with its own options, and that a batched `created_ms` is refused by both client and host. (docs/specs/primitives-v2.md, docs/specs/storage-bus.md)

Tests

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

Findings

No active actionable findings.

Before merge

  • Complete the critique review for crates/tinystoragedrivers-document/src/sqlite/documents/mod.rs, crates/tinystoragedrivers-types/src/document/types_tests.rs, crates/tinystoragedrivers-types/src/document/types.rs, crates/tinystoragedrivers-busproxy/src/server/documents_tests.rs, crates/tinystoragedrivers-busproxy/src/server/documents.rs, docs/specs/storage-bus.md, crates/tinystoragedrivers-busproxy/src/client/documents.rs, crates/tinystoragedrivers-api/src/lib_tests.rs, docs/specs/primitives-v2.md, crates/tinystoragedrivers-bus/src/limits_tests.rs.
  • Complete the security review for crates/tinystoragedrivers-document/src/sqlite/documents/mod.rs, crates/tinystoragedrivers-types/src/document/types_tests.rs, crates/tinystoragedrivers-types/src/document/types.rs, crates/tinystoragedrivers-busproxy/src/server/documents_tests.rs, crates/tinystoragedrivers-busproxy/src/server/documents.rs, crates/tinystoragedrivers-busproxy/src/client/documents.rs, crates/tinystoragedrivers-api/src/lib_tests.rs, crates/tinystoragedrivers-bus/src/limits_tests.rs.
  • Review uncovered paths: crates/tinystoragedrivers-api/src/lib_tests.rs, crates/tinystoragedrivers-bus/src/limits_tests.rs, crates/tinystoragedrivers-busproxy/src/client/documents.rs, crates/tinystoragedrivers-busproxy/src/server/documents.rs, crates/tinystoragedrivers-busproxy/src/server/documents_tests.rs, crates/tinystoragedrivers-document/src/sqlite/documents/mod.rs, crates/tinystoragedrivers-types/src/document/types.rs, crates/tinystoragedrivers-types/src/document/types_tests.rs, docs/specs/primitives-v2.md, docs/specs/storage-bus.md.
Agent review details

critique

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered files: crates/tinystoragedrivers-document/src/sqlite/documents/mod.rs, crates/tinystoragedrivers-types/src/document/types_tests.rs, crates/tinystoragedrivers-types/src/document/types.rs, crates/tinystoragedrivers-busproxy/src/server/documents_tests.rs, crates/tinystoragedrivers-busproxy/src/server/documents.rs, docs/specs/storage-bus.md, crates/tinystoragedrivers-busproxy/src/client/documents.rs, crates/tinystoragedrivers-api/src/lib_tests.rs, docs/specs/primitives-v2.md, crates/tinystoragedrivers-bus/src/limits_tests.rs
  • Lane summary: Reviewed 6 of 16 files — 10 not reviewed. Reviewed 6 files; 0 findings. 10 files were omitted: not selected by the large-review budget.

security

  • Conclusion: Neutral
  • Scope reviewed: incomplete; unanswered files: crates/tinystoragedrivers-document/src/sqlite/documents/mod.rs, crates/tinystoragedrivers-types/src/document/types_tests.rs, crates/tinystoragedrivers-types/src/document/types.rs, crates/tinystoragedrivers-busproxy/src/server/documents_tests.rs, crates/tinystoragedrivers-busproxy/src/server/documents.rs, crates/tinystoragedrivers-busproxy/src/client/documents.rs, crates/tinystoragedrivers-api/src/lib_tests.rs, crates/tinystoragedrivers-bus/src/limits_tests.rs
  • Lane summary: Reviewed 6 of 14 files — 8 not reviewed. Reviewed 6 files; 0 findings. 8 files were omitted: not selected by the large-review budget. 2 files were not security-reviewed: docs/specs/primitives-v2.md (prose or tabular data), docs/specs/storage-bus.md (prose or tabular data).

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: This change introduces `WriteOp::PutWith` to carry schema/expiry options inside atomic batches, wires it through all three document engines, enforces the host-only `created_ms` rejection at both busproxy client and server, and bumps contract versions. The diff looks sound and is well covered by new integration and unit tests, including the conformance suite that exercises all three backends. No reportable defects were found. _The code index is behind this pull request (indexed at `4e26639426e0`), so retrieved context may be out of date._

commits

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The commits lane answered and found no sensitive content in the committed files.
  • Lane summary: No sensitive content in committed files. _The code index is behind this pull request (indexed at `4e26639426e0`), so retrieved context may be out of date._

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The description matches the diff: it announces the new `WriteOp::PutWith` variant, the memory/SQLite/MongoDB batch handling, the client and host refusals of a batched `created_ms`, the two `CONTRACT_VERSION` bumps with their pinned-test updates, the spec edits, and the new conformance and busproxy tests — all of which are present, and the stated test tally lines up with the three new test functions. Nothing significant in the change is left unmentioned, so it is safe to merge as described. _The code index is behind this pull request (indexed at `4e26639426e0`), so retrieved context may be out of date._
Evidence and run details
  • Models: ladder/vectors-oai3, deepseek-v4.1-flash, deepseek-v4-flash
  • Spend: $0.024271
  • Completion usage: incomplete; some provider completion costs are unavailable.
  • Tokens: 771590 input · 81148 output · 323456 cached · 681 embedding
  • Updated: 2026-11-11T12:24:14Z
Head State Pass summary
f732fb62ccda incomplete 0 active finding(s), 0 resolved finding(s) (at 2026-11-11T12:24:14Z)

tinysweeper 0.1.2

@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 could not complete coverage (10 unanswered item(s)), so this is not an approval.

Diagnostics

Total spend: $0.0243

@M3gA-Mind
M3gA-Mind merged commit 9cae2ad into tinyhumansai:main Nov 11, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant