Commit 706eda3
committed
feat: Git-backed transaction notes and core helpers
This PR introduces a transaction core module and structured Git note support for every write operation in ChronDB, fulfilling architectural requirements for chronological traceability and external correlation/audit.
Highlights:
- Adds `chrondb.transaction.core` namespace. Provides a shared transaction context, unique `tx_id` generation, and helpers for capturing metadata (origin, user, flags) across all entrypoints (REST, SQL, Redis).
- Implements a new `chrondb.storage.git.notes` module. Every commit now stores a JSON note under the `chrondb` namespace, containing: `tx_id`, origin (protocol/source), optional `user`, semantic flags (`bulk-load`, `migration`, `rollback`, etc.), and client/request metadata (e.g. `X-Request-Id`).
- Refactors all transaction/write paths in the Git-backed storage engine to invoke these helpers. Enforces that missing notes are treated as a regression (test coverage included).
- Documents new transaction block (`with-transaction`) usage, and how to pass metadata via HTTP headers or protocol attributes to propagate context into Git notes. See `docs/api.md`, "Transaction Operations" and "Transaction Metadata and Git Notes".
- Adds and updates unit/integration tests for: correct note attachment, lookup with `git notes`, failure modes (e.g., repository contention, branch mutation), and regression coverage (notes always present after a commit).
- Updates AGENT.md: All write paths _must_ call transaction helpers to guarantee Git note context. No destructive mutations; always append-only.
- No backwards-incompatible API changes. Protocols remain consistent across REST, SQL (Postgres), and Redis wire formats.
Rationale:
ChronDB's Git-based architecture enables full auditability and time-travel. Storing rich transaction metadata as Git notes ensures every operation is contextualized—supporting debugging, lineage analysis, external audit, and advanced correlation across distributed systems. This change centralizes transaction and commit metadata handling, eliminating per-protocol ad-hoc logic and reducing the risk of silent context loss.
See also:
- `src/chrondb/storage/git/notes.clj` (implementation)
- `src/chrondb/transaction/core.clj` (transaction core logic)
- New/updated tests in `test/chrondb/storage/git/notes_test.clj`, `test/chrondb/transaction/core_test.clj`
- Expanded documentation in `docs/api.md` and process requirements in AGENT.md.
BREAKING: None, but all future write code must route through the transaction context to guarantee note coverage and protocol metadata flow.
fixed #43
fixed #44
Signed-off-by: Avelino <[email protected]>1 parent 9c46bdc commit 706eda3
File tree
19 files changed
+1136
-251
lines changed- docs
- src/chrondb
- api
- redis
- sql/execution
- v1
- cli
- storage/git
- transaction
- test/chrondb
- storage/git
- transaction
19 files changed
+1136
-251
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
180 | 202 | | |
181 | 203 | | |
182 | 204 | | |
| |||
263 | 285 | | |
264 | 286 | | |
265 | 287 | | |
| 288 | + | |
| 289 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
47 | 66 | | |
48 | 67 | | |
49 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
150 | 171 | | |
151 | 172 | | |
152 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
26 | 64 | | |
27 | 65 | | |
28 | 66 | | |
| |||
132 | 170 | | |
133 | 171 | | |
134 | 172 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
139 | 179 | | |
140 | 180 | | |
141 | 181 | | |
142 | 182 | | |
143 | | - | |
144 | | - | |
145 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
146 | 188 | | |
147 | 189 | | |
148 | 190 | | |
| |||
162 | 204 | | |
163 | 205 | | |
164 | 206 | | |
165 | | - | |
166 | | - | |
167 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
168 | 212 | | |
169 | 213 | | |
170 | 214 | | |
| |||
174 | 218 | | |
175 | 219 | | |
176 | 220 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
181 | 226 | | |
182 | 227 | | |
183 | 228 | | |
| |||
197 | 242 | | |
198 | 243 | | |
199 | 244 | | |
200 | | - | |
201 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
202 | 249 | | |
203 | 250 | | |
204 | 251 | | |
| |||
218 | 265 | | |
219 | 266 | | |
220 | 267 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
227 | 276 | | |
228 | 277 | | |
229 | 278 | | |
| |||
263 | 312 | | |
264 | 313 | | |
265 | 314 | | |
266 | | - | |
267 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
268 | 319 | | |
269 | 320 | | |
270 | 321 | | |
| |||
275 | 326 | | |
276 | 327 | | |
277 | 328 | | |
278 | | - | |
279 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
280 | 333 | | |
281 | 334 | | |
282 | 335 | | |
| |||
313 | 366 | | |
314 | 367 | | |
315 | 368 | | |
316 | | - | |
317 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
318 | 373 | | |
319 | 374 | | |
320 | 375 | | |
| |||
327 | 382 | | |
328 | 383 | | |
329 | 384 | | |
330 | | - | |
331 | | - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
332 | 389 | | |
333 | 390 | | |
334 | 391 | | |
| |||
351 | 408 | | |
352 | 409 | | |
353 | 410 | | |
354 | | - | |
355 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
356 | 415 | | |
357 | 416 | | |
358 | 417 | | |
| |||
384 | 443 | | |
385 | 444 | | |
386 | 445 | | |
387 | | - | |
388 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
389 | 451 | | |
390 | 452 | | |
391 | 453 | | |
| |||
405 | 467 | | |
406 | 468 | | |
407 | 469 | | |
408 | | - | |
409 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
410 | 474 | | |
411 | 475 | | |
412 | 476 | | |
| |||
471 | 535 | | |
472 | 536 | | |
473 | 537 | | |
474 | | - | |
475 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
476 | 543 | | |
477 | 544 | | |
478 | 545 | | |
| |||
0 commit comments