The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
docs(core): add READMEs for cron, flows, tinyflows, and storage
Steven Enamakel1170a01009ce
diff --git a/crates/openhuman-core/src/cron/README.md b/crates/openhuman-core/src/cron/README.mdindex f017c7e814..2800ea5ac0 100644--- a/crates/openhuman-core/src/cron/README.md+++ b/crates/openhuman-core/src/cron/README.md@@ -25,8 +25,8 @@ the health subscriber, builds one `SecurityPolicy` from config, publishesinterval tick|v- tick_once ---- due_jobs(config, now) ----> tinyflows_sqlite store- | (jobs.db)+ tick_once ---- due_jobs(config, now) ----> CronDocuments (storage ports)+ | (backend, or cron/schedule.db)| error -> HealthChanged{healthy:false} (only on transition)| ok -> HealthChanged{healthy:true} (only on transition)v@@ -240,13 +240,18 @@ missing row, reschedules a drifted one, and removes the retired`memory_context_refresh` row. It runs from [`core/runtime/services.rs`](../core/runtime/services.rs) and from[`security/credentials/ops/user_scope.rs`](../security/credentials/ops/user_scope.rs).-### On a storage backend--With a storage backend configured (`OPENHUMAN_STORAGE_URL` / `[storage] url`,-see `crate::storage`), every `store` function is served by-`tinyflows_drivers::schedule::CronDocuments` instead of `cron/jobs.db`: the-same jobs and runs on the document port, in the acting agent's storage scope,-with the same history cap and due-job batch size. `reschedule_after_run`+### Storage++Every `store` function is served by `tinyflows_drivers::schedule::CronDocuments`,+jobs and runs on the document port in the acting agent's storage scope, with+the configured history cap and due-job batch size. tinyflows has no SQLite+store of its own any more, so there is one path whatever the storage URL says:+the installed backend when there is one, else a SQLite document database of the+store's own (`<workspace>/cron/schedule.db`, an embedded agent's under+`agents/<id>/cron/`). The `jobs.db` tinyflows used to write (with its policy+side table) is imported read-only once, at boot for an installed backend+(`storage::import::tinyflows`) and on first use otherwise, and is never written+again. `reschedule_after_run`advances a job only if its stored schedule still matches the job that fired,so two processes sharing one database don't double-advance it.@@ -255,7 +260,7 @@ so two processes sharing one database don't double-advance it.| Path | What it does || --- | --- || [`mod.rs`](./mod.rs) | Module wiring and re-exports. Re-exports the schedule types and pure schedule functions from `tinyflows_schedule` so `cron::CronJob`, `cron::Schedule` and friends resolve here. |-| [`store.rs`](./store.rs) | Thin wrapper over `tinyflows_sqlite::schedule`. Turns `Config` into `CronStoreOptions` (`<workspace>/cron/jobs.db`, `cron.max_run_history`, `scheduler.max_tasks`) and forwards job CRUD, due-job queries and run history. |+| [`store.rs`](./store.rs) | Thin wrapper over `tinyflows_drivers::schedule::CronDocuments`. Resolves the storage (`storage::local::open_standing`), applies `cron.max_run_history` and `scheduler.max_tasks`, and forwards job CRUD, due-job queries and run history. || `ops.rs` | Business operations: `add_once`, `add_once_at`, `parse_human_delay`, pause/resume, `update_cron_job`, the `ACTIVE_RUNS` claim set, and the async `cron_*` RPC operations. Also re-exported as `cron::rpc`. || [`schemas.rs`](./schemas.rs) | Controller schemas and handlers for the `cron` namespace. || [`scheduler.rs`](./scheduler.rs) | `run`, `tick_once`, `process_due_jobs`, `execute_and_persist_job`. |@@ -284,7 +289,7 @@ so two processes sharing one database don't double-advance it.`DeliveryStatus`, `ActiveHours`: the job and run model, defined in`tinyflows_schedule::types` and re-exported from `mod.rs`.`delivery_mode` holds the mode string constants.-- `AgentJobSpec`: the store's agent-job creation spec (from `tinyflows_sqlite`),+- `AgentJobSpec`: the store's agent-job creation spec (from `tinyflows_schedule`),used by `add_agent_job_from_spec`.- `scheduler::run(config)`: the service entry point.- `scheduler::execute_job_now` and `scheduler::deliver_job`: what Run Now uses@@ -356,9 +361,9 @@ Cron publishes, through [`core/bus.rs`](../core/bus.rs), these `DomainEvent` var## Boundaries- The schedule model, next-run computation, cadence floor and the SQLite store- (schema, CRUD, output truncation, pruning) belong to the `tinyflows`+ (job and run documents, CRUD, output truncation, pruning) belong to the `tinyflows`submodule ([`vendor/tinyflows/crates/tinyflows-schedule`](../../../../vendor/tinyflows/crates/tinyflows-schedule/) and- `tinyflows-sqlite`). Change them there, not in `store.rs`.+ `tinyflows-drivers`). Change them there, not in `store.rs`.- Shell sandboxing policy is `security::SecurityPolicy`. Cron only asks it.- Flow execution is the `flows` domain. Cron only emits `FlowScheduleTick`.- Channel construction and sending belong to `channels`. Cron reaches channels@@ -377,12 +382,14 @@ Cron publishes, through [`core/bus.rs`](../core/bus.rs), these `DomainEvent` varthe `cron_run` tool) from dispatch until its run is persisted, and the scheduler neverdispatches a claimed job. A recurring job's `next_run` is advanced at dispatch(at-most-once per slot), then recomputed from the finish time as before.-- Per-job `JobPolicy { retries, single_flight }` lives in a host-owned- `cron_job_policies` table in `jobs.db` (`policy.rs`); `CronJob` belongs to- `tinyflows-schedule`. No row is the default policy. `retries: Some(0)` means exactly one- attempt; with `single_flight` a slot that comes due mid-run is recorded as a `skipped`- run, and Run Now refuses while the job runs. The table stays in SQLite even with a- storage backend configured.+- Per-job `JobPolicy { retries, single_flight }` is a field of the job+ (`CronJob::policy`, from `tinyflows-schedule`); `policy.rs` only reads and+ writes it through the store. The default policy is stored as none.+ `retries: Some(0)` means exactly one attempt; with `single_flight` a slot that+ comes due mid-run is recorded as a `skipped` run, and Run Now refuses while the+ job runs. Policies kept apart from the job before (the `cron_job_policies`+ table, then collection) are folded into the job by the importer and by+ `CronDocuments` when it opens.- System jobs: `system_job_handlers::register(name, handler)` installs an awaited in-processhandler; the scheduler still publishes `CronSystemJobDue`, then records the handler'sresult as the run's status. With no handler, behaviour is unchanged.@@ -403,7 +410,8 @@ Tests sit beside their modules as `<module>_tests.rs` (for example[`scheduler_tests.rs`](./scheduler_tests.rs), which pulls in the `scheduler_*_tests.rs` files, plus[`store_tests.rs`](./store_tests.rs), [`ops_tests.rs`](./ops_tests.rs), [`origin_tests.rs`](./origin_tests.rs), [`job_builder_tests.rs`](./job_builder_tests.rs),[`system_jobs_tests.rs`](./system_jobs_tests.rs), `scheduler/origin_*_tests.rs` and the per-tool files in-`tools/`). The store itself is tested in `tinyflows-sqlite`.+`tools/`). The store itself is tested in `tinyflows-drivers`; the import of+`jobs.db` is covered in `storage/import/tinyflows_tests.rs` and `store_tests.rs`.```bashcargo test -p openhuman cron::diff --git a/crates/openhuman-core/src/flows/README.md b/crates/openhuman-core/src/flows/README.mdindex 8b43c155ce..6d58b91cba 100644--- a/crates/openhuman-core/src/flows/README.md+++ b/crates/openhuman-core/src/flows/README.md@@ -27,8 +27,8 @@ tools.persist | |v vstore.rs / draft_store.rs tinyflows engine (vendor/tinyflows)- (tinyflows_sqlite, under |- <workspace>/flows) | capability traits+ (FlowCatalogDocuments on the |+ storage ports) | capability traitsvtinyflows/caps (agent, llm, tools,http, code, memory, state store)@@ -233,18 +233,21 @@ so the digest subscriber, `flows_delete`, the `memory` node adapter(`tinyflows::memory_adapter::OpenHumanMemory`) and the agent tools all tag thesame way.-### On a storage backend--With a storage backend configured (`OPENHUMAN_STORAGE_URL` / `[storage] url`,-see `crate::storage`), the catalog (`store.rs`), drafts (`draft_store.rs`),-per-flow state and the run checkpointer move off `flows/flows.db`,-`flows/drafts/` and `flows/checkpoints.db` onto the document port, in the-acting agent's scope: `tinyflows_drivers::catalog::FlowCatalogDocuments`,-`FlowStateDocuments` (through `tinyflows/state.rs`'s `FlowState`, which the-engine's `StateStore` and the dedup settlement share) and-`DriverCheckpointer`. When the scope cannot be resolved (SaaS mode with no-acting agent) flow state fails every call rather than falling back to the-local file.+### Storage++The catalog (`store.rs`), drafts (`draft_store.rs`), per-flow state and the run+checkpointer are on the document port, in the acting agent's scope:+`tinyflows_drivers::catalog::FlowCatalogDocuments`, `FlowStateDocuments`+(through `tinyflows/state.rs`'s `FlowState`, which the engine's `StateStore`+and the dedup settlement share) and `DriverCheckpointer`. tinyflows has no+SQLite store of its own any more, so there is one path whatever the storage URL+says: the installed backend, else a SQLite document database of the catalog's own+(`<workspace>/flows/catalog.db`). The files tinyflows used to write+(`flows/flows.db`, `flows/drafts/`, `flows/checkpoints.db`) are imported+read-only once, at boot for an installed backend (`storage::import::tinyflows`)+and on first use otherwise, and are never written again. When the scope cannot+be resolved (SaaS mode with no acting agent) flow state fails every call rather+than falling back to a shared bucket.## Layout@@ -255,8 +258,8 @@ Top level:| `mod.rs` | Module declarations and re-exports: model types from `tinyflows_catalog`, node contracts, store helpers for the seam, flow-memory helpers. || [`ops.rs`](./ops.rs), `ops/` | Business operations returning `Outcome<T>`. See the table below. || [`schemas.rs`](./schemas.rs), `schemas/`, [`schemas_handlers.rs`](./schemas_handlers.rs) | Controller schemas (split into `builder_schemas.rs`, `definition_schemas.rs`, `draft_schemas.rs`, `run_schemas.rs`) and thin handlers that load config, read params and call `ops::flows_*`. |-| [`store.rs`](./store.rs) | Binds `tinyflows_sqlite::flows` to `<workspace_dir>/flows`. Every function only substitutes the directory; anything else in a body is host policy leaking into persistence. |-| `draft_store.rs` | Same binding for `tinyflows_sqlite::drafts`. |+| [`store.rs`](./store.rs) | Binds `FlowCatalogDocuments` to this host's storage (`scoped`, `documents`). Every function only substitutes the catalog; anything else in a body is host policy leaking into persistence. |+| `draft_store.rs` | Same binding for the catalog's drafts. || [`bus.rs`](./bus.rs), `bus/` | The three subscribers: `trigger.rs`, `run_digest.rs`, `dedup_commit.rs`. || [`tools.rs`](./tools.rs) | `ProposeWorkflowTool` (`propose_workflow`) and `RunFlowTool` (`run_flow`). || [`builder_tools.rs`](./builder_tools.rs), `builder_tools/` | The 22 `workflow_builder` tools, split by role: `draft_revise.rs`, `draft_edit.rs`, `draft_validate.rs`, `flow_reads.rs`, `run_control.rs`, `persistence.rs`, `connection_reads.rs`, `catalog_search.rs`, `tool_contract.rs`, `kind_reads.rs`, `dry_run.rs`. |@@ -324,8 +327,8 @@ Agent tools: `core`'s [`tools/ops.rs`](../tools/ops.rs) adds 27 flows tools to t- `vendor/tinyflows` (tinyflows repo) owns the workflow model, migration,validation, compilation, and the run engine with its in-crate state-graphruntime. `tinyflows-catalog` owns the saved-flow types and registries,- `tinyflows-sqlite` owns the schema and SQL for flows, drafts and checkpoints,- and `tinyflows-copilot` owns the authoring manual and pure text heuristics.+ `tinyflows-drivers` owns the document layout for flows, drafts, runs and+ checkpoints, and `tinyflows-copilot` owns the authoring manual and pure text heuristics.Fix engine and storage behavior there, not here.- `cron/` owns scheduling. This domain only arms and removes `JobType::Flow`jobs; the scheduler publishes `DomainEvent::FlowScheduleTick`.@@ -362,8 +365,9 @@ Agent tools: `core`'s [`tools/ops.rs`](../tools/ops.rs) adds 27 flows tools to tTests sit beside their modules as `*_tests.rs` files ([`ops_tests.rs`](./ops_tests.rs),[`bus_tests.rs`](./bus_tests.rs), [`schemas_tests.rs`](./schemas_tests.rs), the builder tool and agent prompt tests,-and the seam's own suite under `tinyflows/`). `store.rs` has no test-attachment; the store's behavior is covered in `tinyflows-sqlite`.+and the seam's own suite under `tinyflows/`). `store.rs`'s tests cover the+storage resolution and the import of the legacy files; the catalog's behavior is+covered in `tinyflows-drivers`.```bashcargo test -p openhuman flows::diff --git a/crates/openhuman-core/src/flows/tinyflows/README.md b/crates/openhuman-core/src/flows/tinyflows/README.mdindex 30edb1e2d0..5069ecc952 100644--- a/crates/openhuman-core/src/flows/tinyflows/README.md+++ b/crates/openhuman-core/src/flows/tinyflows/README.md@@ -15,8 +15,9 @@ security model); this README covers only the host seam.- [`mod.rs`](./mod.rs): export-focused. Re-exports `caps::build_capabilities` and`caps::open_flow_checkpointer`, the two entry points `flows::ops*.rs`- calls to drive a run; re-exports `tinyflows_sqlite::checkpoint` as- `checkpoint_sqlite` under its historical path.+ calls to drive a run. The checkpointer is `tinyflows_drivers::DriverCheckpointer`+ on the flow catalog's storage; the `checkpoints.db` tinyflows used to write is+ imported once.- `caps/`: every capability adapter except `memory`, plus construction,curation, preflight, and invocation logic. `build_capabilities` also fills`tasks` with the engine's own `TokioTaskRunner` and deliberately leaves@@ -45,8 +46,7 @@ security model); this README covers only the host seam.graph, output, or logs.- `code.rs`: `OpenHumanCode` (`CodeRunner`); runs JS/Python through`sandbox::execute_in_sandbox` under `CODE_RUN_TIMEOUT_SECS`.- - `StateStore` is `tinyflows_sqlite::flows::SqliteStateStore` (built in- `ops.rs`), namespaced per flow (`"flow:<id>"`) so saved flows never+ - `StateStore` is `FlowState` (`state.rs`, `FlowStateDocuments`), namespaced per flow (`"flow:<id>"`) so saved flows nevercollide on a state key.- `resolver.rs`: `OpenHumanWorkflowResolver` (`WorkflowResolver`);resolves a `sub_workflow` node's id to a stored workflow.diff --git a/crates/openhuman-core/src/storage/README.md b/crates/openhuman-core/src/storage/README.mdindex 45f589cd18..3ec83d9c07 100644--- a/crates/openhuman-core/src/storage/README.md+++ b/crates/openhuman-core/src/storage/README.md@@ -8,10 +8,13 @@ One URL picks it: `OPENHUMAN_STORAGE_URL`, else `[storage] url` in`config.toml` (`config::StorageConfig`), else the default,`sqlite:<workspace_dir>` (`storage::config`).-The default installs no process-wide backend. The large relational stores-(`sessions.db`, `flows.db`, `jobs.db`, `graph_checkpoints.db`) keep serving-their own SQLite files as they always have, so nothing is migrated or-duplicated. The small stores (approvals, devices, notifications, task+The default installs no process-wide backend. `sessions.db` and+`graph_checkpoints.db` keep serving their own SQLite files as they always have,+so nothing is migrated or duplicated. Cron jobs and the flow catalog are on the+ports whatever the URL says (tinyflows has no SQLite store of its own): with no+backend installed they use SQLite document databases of their own+(`cron/schedule.db`, `flows/catalog.db`), importing the old `jobs.db`,+`flows.db`, `checkpoints.db` and `drafts/` on first use. The small stores (approvals, devices, notifications, tasksources) keep their rows as document tables inside their existing `.db` file(`approval/approval.db`, `devices/devices.db`, `notifications/notifications.db`,`task_sources/sources.db`): the first call in a process opens it with the@@ -38,9 +41,12 @@ on.`import/` copies the four small stores' legacy SQLite files into an installedbackend once, read-only (see the module doc and the architecture page). Thecore calls `import::run` from `bootstrap_core_runtime` before any domain store-opens; `run_with` takes an explicit backend for tests. Sessions, cron jobs and-the flow catalog are not imported here: their formats belong to TinyAgents and-TinyFlows.+opens; `run_with` takes an explicit backend for tests. The tinyflows stores (cron+jobs with their runs and policies, the flow catalog with its drafts, and flow+checkpoints) are copied by `import::tinyflows` with `tinyflows-import`, which+keeps ids, writes only what is absent and reads copies of the files; a build+without the `flows` gate imports no cron jobs. Sessions are not imported here:+their format belongs to TinyAgents.## Entry pointsdiff --git a/crates/openhuman-core/src/storage/config.rs b/crates/openhuman-core/src/storage/config.rsindex 14690c48bf..f30d9b4c05 100644--- a/crates/openhuman-core/src/storage/config.rs+++ b/crates/openhuman-core/src/storage/config.rs@@ -13,9 +13,11 @@//! [`StorageMode::Url`].//!//! The default is [`StorageMode::Default`]: no backend is installed and-//! nothing about the large stores changes (`sessions.db`, `flows.db`,-//! `jobs.db` and `graph_checkpoints.db` are already SQLite files served as-//! they are). The small stores (approvals, devices, notifications, task+//! nothing about the large stores changes (`sessions.db` and+//! `graph_checkpoints.db` are already SQLite files served as they are). Cron+//! jobs and the flow catalog are on the ports in every mode, in SQLite document+//! databases of their own when no backend is installed+//! ([`super::local::open_standing`]). The small stores (approvals, devices, notifications, task//! sources) keep their rows as document tables inside their own `.db` files,//! `<workspace>/<domain>/<name>.db`, importing the rows of their old tables//! once ([`super::local`]). The workspace directory is therefore the default's