From 8bac2b8676913c41c3597b49c995ba3dece7c2c8 Mon Sep 17 00:00:00 2001 From: OmO Orchestrator Date: Thu, 19 Nov 2026 00:19:41 -0500 Subject: [PATCH] docs(agents): acknowledge appendEntry() as sync's own write path alongside append() --- .../task-9-backend-service-expansion.md | 46 +++++++++++++++++++ AGENTS.md | 4 +- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 .omo/evidence/backend-service-expansion/task-9-backend-service-expansion.md diff --git a/.omo/evidence/backend-service-expansion/task-9-backend-service-expansion.md b/.omo/evidence/backend-service-expansion/task-9-backend-service-expansion.md new file mode 100644 index 0000000..5afc9de --- /dev/null +++ b/.omo/evidence/backend-service-expansion/task-9-backend-service-expansion.md @@ -0,0 +1,46 @@ +# Todo 9 - Tidy AGENTS.md's stale "append() is the ONLY write path" claim + +## What changed +Two lines in `AGENTS.md` that claimed `append()` is "the ONLY write path" / +"sole event-log write path" for the signed event log were reworded to +acknowledge that `appendEntry()` (exported from `src/lib/eventlog.ts`) is +also a real, intentional second write path used by `src/lib/sync.ts` to +persist pre-verified entries pulled from the backend relay (todo 2). + +### Before/after diff +```diff +--- a/AGENTS.md ++++ b/AGENTS.md +@@ WHERE TO LOOK +-| Add/verify a signed event | `src/lib/eventlog.ts` | `append()` is the ONLY write path | ++| Add/verify a signed event | `src/lib/eventlog.ts` | `append()` is the sole LOCAL-signing write path; `appendEntry()` separately persists pre-verified foreign entries via `src/lib/sync.ts` | + +@@ CODE MAP +-| `append` | fn | `lib/eventlog.ts` | ~50 | sign + append; sole event-log write path | ++| `append` | fn | `lib/eventlog.ts` | ~50 | sign + append; sole LOCAL-signing write path (`appendEntry()` separately persists pre-verified foreign entries via `src/lib/sync.ts`) | +``` + +## Accuracy check against real code +- `src/lib/eventlog.ts`: `export async function appendEntry(entry)` verifies + the entry's signature against its own `payload`/`lamportTs`/`authorPubkey` + and persists it via `db.eventLog.add(...)`. `export function append(payload)` + is a thin serialized wrapper around `realAppend()`, which signs `payload` + locally with the local identity's private key, assigns the next Lamport + timestamp, and then calls `appendEntry(...)` itself - so `append()` is the + only path that performs LOCAL signing, while `appendEntry()` is the + lower-level persistence primitive both `append()` and outside callers use. +- `src/lib/sync.ts`: imports `appendEntry` from `./eventlog.ts` and calls it + directly (`await appendEntry(entry)`) to persist each pulled remote entry + after a dedup check - this entry was signed by the REMOTE author, never by + the local identity, so routing it through `append()` would be wrong (it + would forge local authorship over someone else's event). This is exactly + the second, intentional write path the new AGENTS.md wording describes. + +## Verification +- `npm run lint` (oxlint) in the worktree: passes with only pre-existing + warnings unrelated to this change (none in `AGENTS.md`, which oxlint does + not lint - it's a Markdown file, not JS/TS). +- No test/build impact expected; this is a pure documentation wording fix. + +## Commit +`docs(agents): acknowledge appendEntry() as sync's own write path alongside append()` diff --git a/AGENTS.md b/AGENTS.md index 2cf35e9..0658475 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,7 +26,7 @@ patriothacks/ ## WHERE TO LOOK | Task | Location | Notes | |------|----------|-------| -| Add/verify a signed event | `src/lib/eventlog.ts` | `append()` is the ONLY write path | +| Add/verify a signed event | `src/lib/eventlog.ts` | `append()` is the sole LOCAL-signing write path; `appendEntry()` separately persists pre-verified foreign entries via `src/lib/sync.ts` | | Balances / wallet math | `src/lib/ledger.ts` | pure reduction over the log; never stored | | Identity / crypto | `src/lib/identity.ts` | Ed25519 via `@noble/ed25519`, non-custodial | | DB schema / tables | `src/lib/db.ts` | Dexie, versioned `.stores()` | @@ -38,7 +38,7 @@ patriothacks/ ## CODE MAP | Symbol | Type | Location | Refs | Role | |--------|------|----------|------|------| -| `append` | fn | `lib/eventlog.ts` | ~50 | sign + append; sole event-log write path | +| `append` | fn | `lib/eventlog.ts` | ~50 | sign + append; sole LOCAL-signing write path (`appendEntry()` separately persists pre-verified foreign entries via `src/lib/sync.ts`) | | `db` | const | `lib/db.ts` | ~34 | Dexie instance (`identity`, `eventLog` tables) | | `computeBalances` / `balanceOf` | fn | `lib/ledger.ts` | ~35 | replay log -> per-account balance | | `readAll` | fn | `lib/eventlog.ts` | ~19 | ordered read for replay/live queries |