Repository navigation
feat(drivers): tinyflows-drivers — StateStore and Checkpointer over tinystoragedrivers ports #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fc3a68c
chore(checkpoint): add drivers module
senamakel 7a0fba4
chore(checkpoint): add drivers module
senamakel bf81680
feat(caps): add capability drivers for checkpointing
senamakel a217c43
fix(tinyflows): map storage errors to capability errors
senamakel 4b369d5
test(checkpoint): cover driver checkpoint round-trips
senamakel e939d65
refactor(checkpoint): tidy imports and test helpers
senamakel 313a9d0
test(checkpoint): use crate-relative path for resume index
senamakel 3f3e341
docs: document storage-driver backends feature
senamakel d479906
feat(drivers): add checkpoint and state store driver capabilities
senamakel 5fe9db4
refactor(caps): remove storage-drivers feature and driver state store
senamakel 90dd5b1
feat(checkpoint): add checkpoint and state store drivers
senamakel e349461
feat(checkpoint): add indexed state history lookup
senamakel 4ac94a4
refactor(checkpoint): import merge_writes directly
senamakel 4a81db5
test(drivers): cover thread deletion, checkpoint pruning and state hi…
senamakel b4c89eb
test(checkpoint): use from_ref for single-element write slice
senamakel ac54524
feat(checkpoint): add checkpoint history and key listing
senamakel bf5d844
feat(state_store): add checkpoint persistence tests
senamakel 04fa4a9
test(checkpoint): cover documents missing a value field
senamakel 7ce8740
test(checkpoint): import StorageError in checkpoint tests
senamakel 9fd522e
Merge origin/main into storage-drivers
senamakel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # `tinyflows` capabilities and checkpoints on `tinystoragedrivers` ports. | ||
| # | ||
| # A crate of its own rather than a feature of the engine: the storage crates | ||
| # are git dependencies (OpenHuman vendors them once and `[patch]`es the URL), | ||
| # and the published `tinyflows` package cannot carry a git dependency, even an | ||
| # optional one. It also keeps the engine's MSRV where it is; this crate needs | ||
| # the storage crates' 1.88. | ||
| [package] | ||
| name = "tinyflows-drivers" | ||
| version = "0.1.0" | ||
| description = "tinyflows StateStore and graph Checkpointer over tinystoragedrivers document ports" | ||
| edition.workspace = true | ||
| rust-version = "1.88" | ||
|
senamakel marked this conversation as resolved.
|
||
| license.workspace = true | ||
| repository.workspace = true | ||
| homepage.workspace = true | ||
| readme = "README.md" | ||
| publish = false | ||
|
|
||
| [dependencies] | ||
| tinyflows = { workspace = true } | ||
| tinystoragedrivers-core = { git = "https://github.com/tinyhumansai/tinystoragedrivers", tag = "v0.4.0" } | ||
| async-trait = { workspace = true } | ||
| serde = { workspace = true } | ||
| serde_json = { workspace = true } | ||
| sha2 = { workspace = true } | ||
| tokio = { workspace = true } | ||
| tracing = { workspace = true } | ||
|
|
||
| [dev-dependencies] | ||
| tokio = { workspace = true } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # tinyflows-drivers | ||
|
|
||
| `tinyflows` run state and graph checkpoints on | ||
| [tinystoragedrivers](https://github.com/tinyhumansai/tinystoragedrivers) | ||
| document ports. A host that has opened a storage backend (SQLite on a desktop, | ||
| MongoDB in the cloud, memory in tests) gets the engine's durable pieces on it, | ||
| scoped per tenant by the document handle it passes in. | ||
|
|
||
| | Type | Implements | Layout | | ||
| | --- | --- | --- | | ||
| | `DriverStateStore` | `tinyflows::caps::StateStore` | one document per key in `flows_state` | | ||
| | `DriverCheckpointer<State>` | `tinyflows::graph::Checkpointer<State>` | `flows_graph_checkpoints`, `_threads`, `_writes` | | ||
|
|
||
| ```rust | ||
| use std::sync::Arc; | ||
| use tinyflows_drivers::{DriverCheckpointer, DriverStateStore}; | ||
|
|
||
| let docs = Arc::clone(scoped_storage.documents()); | ||
| let state = Arc::new(DriverStateStore::new(Arc::clone(&docs))); | ||
| let checkpointer = DriverCheckpointer::<serde_json::Value>::new(docs); | ||
| ``` | ||
|
|
||
| ## Checkpointer guarantees | ||
|
|
||
| - One document per checkpoint with a per-thread `seq` advanced by | ||
| compare-and-swap, so listing is insertion order and a re-used checkpoint id | ||
| resolves to its latest write, as in the SQLite and file backends. | ||
| - `get_scoped` is one indexed `(thread, namespace, seq)` query, so a parent | ||
| run and its subgraphs never load each other's checkpoints, even when ids | ||
| repeat. | ||
| - `state_history` reads the namespace's checkpoints and pending writes in two | ||
| queries and walks the lineage in memory, rather than two round trips per | ||
| ancestor. | ||
| - Pending writes merge with `merge_writes` under compare-and-swap. | ||
| - Key components are length-prefixed and namespaces encoded injectively; ids | ||
| over 400 bytes become their SHA-256. | ||
|
|
||
| ## Why a separate crate | ||
|
|
||
| `tinystoragedrivers` is a git dependency: OpenHuman vendors it once (through | ||
| TinyAgents) and points the URL at that copy with | ||
| `[patch."https://github.com/tinyhumansai/tinystoragedrivers"]`, so there is | ||
| exactly one `DocumentStore` trait in its graph. The published `tinyflows` | ||
| package cannot carry a git dependency, so these adapters live here | ||
| (`publish = false`). The engine stays dependency-free and keeps its MSRV; this | ||
| crate needs Rust 1.88, the storage crates' MSRV. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the new crate compatible with the repository MSRV
The repository rules require Rust 1.85, but this entry explicitly introduces a workspace crate requiring Rust 1.88. That makes the new crate incompatible with the declared MSRV for users and CI environments pinned to 1.85. Either lower the crate's requirement to Rust 1.85 or update the repository's MSRV policy and all affected compatibility guarantees together.
[RULE] msrv-compatibility ·