Repository navigation
feat(types)!: WriteOp::PutWith carries a put's WriteOptions into an atomic batch - #100
Conversation
…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
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Tiny Sweeper reviewVerdict: Incomplete · Priority: none Diagnostics and supporting detailsFull summaryPull 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
Partial review reasons
Review snapshot
Completeness: Incomplete 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
TestsNo supported feature-to-test mapping was produced. Test execution is not inferred. FindingsNo active actionable findings. Before merge
Agent review detailscritique
security
tests
commits
description
Evidence and run details
|
Breaking: for tinystoragedrivers v3.0.0 (after v2.1.3). Part of #49, item (g).
Summary
A batched
WriteOp::Putcarried no options, so every engine wrote it withWriteOptions::default(): schema 0 and no expiry, even where a singleput_withwould have recorded both. Three batch writes in consumers silently lose their declared schema today:registry/store/index.rs:404-405);tinyflows-drivers/src/store/proposals.rs:83-89);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 asput_withdoes, and a plainPutstill writes the defaults. A new variant, rather than a new field onPut, keeps every existingWriteOp::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 withInvalidInput, as they already do forPut, so a module still can't choose a record's creation time.API or behavior changes (breaking)
WriteOpgains a variant. Code that matchesWriteOpexhaustively must handlePutWith. Known non-test exhaustive matches outside this repo:crates/openhuman-core/src/cron/documents_port.rs:289-294(Put { .. } | Delete { .. }, no wildcard);src/schedule_documents.rs:197-201.cron/documents_port.rs:341is test-only.put_withis new. A host built before this fails to decode a batch carrying one; batches without it decode as before.tinystoragedrivers_bus::CONTRACT_VERSION7 → 8 andtinystoragedrivers_api::CONTRACT_VERSION5 → 6.is_compatible, and module admission doesn't check them, so the bumps are documentation.docs/specs/primitives-v2.mdsays 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)
write_chunk: batch withPutWith { options: write_options() }.save_proposal_if_fingerprint: batch withPutWithandSCHEMA_VERSION, and handlePutWithinschedule_documents.rs.PutWithwith its schema.cron/documents_port.rs: add thePutWitharm.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 mongodbagainst a live replica set: 91 passed, 0 skipped. That includes the conformancebatched_optionscase on MongoDB, SQLite and memory.-D warnings(0 items),cargo fmt --check, rustdoc-D warnings,cargo check -p tinystoragedrivers --no-default-features.Tests
batched_options(testkit, every engine withRecordMetadata): a batchedPutWithrecords its schema and expiry, and a later batched plainPutwrites the defaults over them.PutWithcarries its options across the wire;created_msis refused before sending (client);batch_opsrefuses it too (server).put_withserde round-trip, and its options default when omitted.