Commit 6ff29e4
committed
feat(memory): Postgres v0.8.0 multi-agent migration for zeroclaw-labs#6272 (P6b)
Mirrors the SQLite migration from P6a, but PG-flavored: idempotent
via ADD COLUMN IF NOT EXISTS / CREATE INDEX IF NOT EXISTS / ON
CONFLICT DO NOTHING, default-agent UUID generated in Rust and
bound as a parameter, backfill in the same init pass via a
parameterized UPDATE.
Schema (matches SQLite path so cross-DB code stays one shape):
- {schema}.agents: id TEXT PRIMARY KEY, alias TEXT NOT NULL UNIQUE,
created_at TIMESTAMPTZ NOT NULL.
- {qualified_table}.agent_id TEXT, indexed. Nullable at the DB
layer matching SQLite; the AgentScopedMemory<M> wrapper in P7
enforces non-null at write time.
Wired into PostgresMemory::initialize_client right after init_schema
so every fresh connection is fully migrated before
try_enable_pgvector runs (which can fail safely on pgvector
absence).
Backups: operator's responsibility for Postgres. The binary cannot
reach across the network to dump a managed cluster, so we do not
take a file-copy backup the way SQLite does. Documented.
Concurrent first-init: INSERT...ON CONFLICT (alias) DO NOTHING
plus a follow-up SELECT means concurrent initializers from
different processes converge on the same default agent UUID
(whichever insert wins is the persisted row).
Tests: skipped in this commit. Existing Postgres tests in the
crate are gated behind the memory-postgres feature and require a
running Postgres for execution; CI does not provision one.
Cross-DB parity tests for the migration land alongside any
test-container support in a follow-up. The code path is a direct
mirror of P6a's tested SQLite path so confidence is reasonable.
Lucid (the third backend) wraps SqliteMemory for its local store,
so P6a's migration runs automatically when Lucid initializes; no
separate Lucid migration code is needed for v0.8.0. The external
Lucid CLI wire format for cross-agent scoping stays deferred to
v0.8.1 per the plan.
V2->V3 migration extension: the existing
synthesize_default_agent_if_needed helper in
crates/zeroclaw-config/src/schema/v2.rs already inserts the
default agent's config-side row; the DB-side migration creates
the matching agents-table row independently. Both arrive at
"there is a default agent" without coordination; runtime resolves
the UUID by alias when AgentScopedMemory<M> is constructed in P7.
Refs zeroclaw-labs#6272.1 parent 7e19c44 commit 6ff29e4
1 file changed
Lines changed: 83 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
109 | 114 | | |
110 | 115 | | |
111 | 116 | | |
| |||
115 | 120 | | |
116 | 121 | | |
117 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
118 | 201 | | |
119 | 202 | | |
120 | 203 | | |
| |||
0 commit comments