Implementation:1ay1 Agentty Persistence As Effects
| Knowledge Sources | |
|---|---|
| Domains | Persistence, Effects |
| Last Updated | 2026-10-28 12:00 GMT |
Overview
Persistence operations as effect values the reducer returns (not calls through a seam), keeping the reducer pure and testable without a fake store.
Description
The agentty::store_fx module expresses persistence as effects, not as calls through a `Deps` seam. A reducer used to reach the disk through `deps().save_thread(...)`, making it impure — testing a save required a fake store. As effects, the same thing is a VALUE the reducer returns: `return save_thread_fx(m.d.current)` describes a save. The host carries it out; a test asserts on the returned Cmd with no store at all.
Covers: SaveThread (incremental delta), DeleteThread, RenameThread, WriteFile (diff-review accept), SaveSettings (write-behind), PublishSubagent, PublishSelection, PublishWebSearchPolicy, PublishPasteConfig, PublishToolLoading, InstallAuth, SaveCredentials, SaveCodexCredentials, LoadAuthView, and AccountOp (activate/remove/register/add-key/sign-out/clear-active).
Usage
Import this when you need to: return a persistence effect from a reducer, publish Model state to process-global copies, or perform account operations as effects.
Code Reference
Source Location
- Repository: 1ay1_Agentty
- File: include/agentty/runtime/store_fx.hpp
- Lines: 1-187
Signature
namespace agentty {
using save_thread = maya::pure_fx<SaveThread, "save_thread">;
using delete_thread = maya::pure_fx<DeleteThread, "delete_thread">;
using rename_thread = maya::pure_fx<RenameThread, "rename_thread">;
using write_file = maya::pure_fx<WriteFile, "write_file">;
using save_settings = maya::pure_fx<SaveSettings, "save_settings">;
using publish_subagent = maya::pure_fx<PublishSubagent, "publish_subagent">;
using publish_selection = maya::pure_fx<PublishSelection, "publish_selection">;
using publish_web_search = maya::pure_fx<PublishWebSearchPolicy, "publish_web_search_policy">;
using publish_paste = maya::pure_fx<PublishPasteConfig, "publish_paste_config">;
using publish_tool_loading = maya::pure_fx<PublishToolLoading, "publish_tool_loading">;
using install_auth = maya::pure_fx<InstallAuth, "install_auth">;
using save_credentials = maya::pure_fx<SaveCredentials, "save_credentials">;
using save_codex = maya::pure_fx<SaveCodexCredentials, "save_codex_credentials">;
using load_auth_view = maya::pure_fx<LoadAuthView, "load_auth_view">;
using account_op = maya::pure_fx<AccountOp, "account_op">;
// Example structs:
struct SaveThread { ThreadDelta delta; };
struct SaveSettings { store::Settings settings; };
struct InstallAuth { std::string provider; bool clear = false; };
struct AccountOp { Kind kind; std::string provider, label, key; };
}
Import
#include "agentty/runtime/store_fx.hpp"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| SaveThread.delta | ThreadDelta | Yes | The part that may have changed since last save |
| SaveSettings.settings | store::Settings | Yes | Full settings record |
| InstallAuth.provider | std::string | Yes | Which provider's auth to install/clear |
Outputs
| Name | Type | Description |
|---|---|---|
| pure_fx | effect value | Described effect — host carries it out after the reducer returns |
Usage Examples
Return a Save Effect
#include "agentty/runtime/store_fx.hpp"
// Reducer returns an effect, not a call:
Cmd update(Model m, SomeMsg msg) {
// ... modify m.d.current ...
return save_thread{ThreadDelta{ /* changed parts */ }};
}
// Test: expect_effect<save_thread>(1) — no fake store needed
Account Operations
// Switch account:
return account_op{AccountOp::Kind::Activate, "anthropic", "work", ""};
// Sign out:
return account_op{AccountOp::Kind::SignOut, "openai", "", ""};
// Add a pasted key:
return account_op{AccountOp::Kind::AddKey, "groq", "", "gsk_..."};