Liking cljdoc? Tell your friends :D

us.whitford.fulcro.rad.database-adapters.git.statechart-store

Git-backed statechart WorkingMemoryStore with Fulcro state atom as hot path.

Implements sp/WorkingMemoryStore using a two-layer strategy:

  • Hot path: Fulcro state atom (synchronous, always succeeds)
  • Cold path: Async git persistence (selective, sanitized, config-change-only)

WM lives at [::sc/session-id session-id] in the Fulcro state atom — exactly where Tony's FulcroWorkingMemoryStore keeps it. This store is a drop-in replacement: same address space, adds git durability on top.

On restart: seed-from-git! reads EDN from worktrees and hydrates the atom before the event loop starts, recovering all durable sessions.

Constructor: new-fulcro-git-wm-store — config map, all keys optional except :fulcro-app.

Repo structure (bare repo, one worktree per durable session): statecharts.git/ worktrees/ lucrum/ ← committed on each ::sc/configuration change state.edn paper-trading/ state.edn agent-xyz/ ← ephemeral agents, if persist? selects them state.edn

Git-backed statechart WorkingMemoryStore with Fulcro state atom as hot path.

Implements `sp/WorkingMemoryStore` using a two-layer strategy:
- Hot path:  Fulcro state atom (synchronous, always succeeds)
- Cold path: Async git persistence (selective, sanitized, config-change-only)

WM lives at [::sc/session-id session-id] in the Fulcro state atom — exactly
where Tony's FulcroWorkingMemoryStore keeps it. This store is a drop-in
replacement: same address space, adds git durability on top.

On restart: `seed-from-git!` reads EDN from worktrees and hydrates the atom
before the event loop starts, recovering all durable sessions.

Constructor: `new-fulcro-git-wm-store` — config map, all keys optional except
:fulcro-app.

Repo structure (bare repo, one worktree per durable session):
  statecharts.git/
    worktrees/
      lucrum/           ← committed on each ::sc/configuration change
        state.edn
      paper-trading/
        state.edn
      agent-xyz/        ← ephemeral agents, if persist? selects them
        state.edn
raw docstring

default-strip-runtimeclj

(default-strip-runtime wm)
(default-strip-runtime wm runtime-keys)

Remove runtime-only keys from working memory, then walk remaining values to strip any leaked unserialisable objects (closures, atoms, connections). Safe to call on any WM map. Exported so callers can compose with it.

Remove runtime-only keys from working memory, then walk remaining values
to strip any leaked unserialisable objects (closures, atoms, connections).
Safe to call on any WM map. Exported so callers can compose with it.
sourceraw docstring

make-persist-predicateclj

(make-persist-predicate {:keys [persist-sessions persist-charts]
                         :or {persist-sessions #{} persist-charts #{}}})

Build a persist? predicate from session and/or chart keyword sets.

  • :persist-sessions #{:lucrum :paper-trading} — explicit session ids
  • :persist-charts #{:agent} — match ::sc/statechart-src

Returns (fn [session-id wmem]) → boolean.

Build a persist? predicate from session and/or chart keyword sets.

- :persist-sessions #{:lucrum :paper-trading} — explicit session ids
- :persist-charts   #{:agent}                 — match ::sc/statechart-src

Returns (fn [session-id wmem]) → boolean.
sourceraw docstring

new-fulcro-git-wm-storeclj

(new-fulcro-git-wm-store {:keys [fulcro-app repo-dir worktree-dir persist?
                                 sanitize-fn on-save on-delete]
                          :or {persist? (constantly false)
                               sanitize-fn default-strip-runtime}})

Create a FulcroGitWorkingMemoryStore.

Required:

  • :fulcro-app — headless Fulcro app (state atom is the hot path)

Optional:

  • :repo-dir — bare git repo path; nil disables git (default nil)
  • :worktree-dir — base path for per-session worktrees
  • :persist? — (fn [session-id wmem]) → bool (default: persist nothing)
  • :sanitize-fn — (fn [wmem]) → wmem before git write (default: default-strip-runtime)
  • :on-save — (fn [session-id wmem]) called after successful git commit
  • :on-delete — (fn [session-id]) called after session removal

With no :repo-dir the store behaves identically to Tony's FulcroWorkingMemoryStore.

Create a FulcroGitWorkingMemoryStore.

Required:
- :fulcro-app    — headless Fulcro app (state atom is the hot path)

Optional:
- :repo-dir      — bare git repo path; nil disables git (default nil)
- :worktree-dir  — base path for per-session worktrees
- :persist?      — (fn [session-id wmem]) → bool (default: persist nothing)
- :sanitize-fn   — (fn [wmem]) → wmem before git write (default: default-strip-runtime)
- :on-save       — (fn [session-id wmem]) called after successful git commit
- :on-delete     — (fn [session-id]) called after session removal

With no :repo-dir the store behaves identically to Tony's FulcroWorkingMemoryStore.
sourceraw docstring

seed-from-git!clj

(seed-from-git! {:keys [fulcro-app repo-dir worktree-dir] :as _store})

Hydrate the Fulcro state atom from persisted git worktrees on restart. Reads state.edn from each non-bare worktree and loads it into [::sc/session-id session-id] in the Fulcro state atom.

Call before the event loop starts (before coordinator chart is started).

Returns the set of session-ids that were successfully restored.

Hydrate the Fulcro state atom from persisted git worktrees on restart.
Reads state.edn from each non-bare worktree and loads it into
[::sc/session-id session-id] in the Fulcro state atom.

Call before the event loop starts (before coordinator chart is started).

Returns the set of session-ids that were successfully restored.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close