docs(agents): acknowledge appendEntry() as sync's own write path alongside append()
This commit is contained in:
1 parent
ca26ae1c64
commit
8bac2b8676
2 files changed
+48
-2
No files matched your search
@@ -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()`
|
||||||
@@ -26,7 +26,7 @@ patriothacks/
|
|||||||
## WHERE TO LOOK
|
## WHERE TO LOOK
|
||||||
| Task | Location | Notes |
|
| 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 |
|
| 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 |
|
| Identity / crypto | `src/lib/identity.ts` | Ed25519 via `@noble/ed25519`, non-custodial |
|
||||||
| DB schema / tables | `src/lib/db.ts` | Dexie, versioned `.stores()` |
|
| DB schema / tables | `src/lib/db.ts` | Dexie, versioned `.stores()` |
|
||||||
@@ -38,7 +38,7 @@ patriothacks/
|
|||||||
## CODE MAP
|
## CODE MAP
|
||||||
| Symbol | Type | Location | Refs | Role |
|
| 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) |
|
| `db` | const | `lib/db.ts` | ~34 | Dexie instance (`identity`, `eventLog` tables) |
|
||||||
| `computeBalances` / `balanceOf` | fn | `lib/ledger.ts` | ~35 | replay log -> per-account balance |
|
| `computeBalances` / `balanceOf` | fn | `lib/ledger.ts` | ~35 | replay log -> per-account balance |
|
||||||
| `readAll` | fn | `lib/eventlog.ts` | ~19 | ordered read for replay/live queries |
|
| `readAll` | fn | `lib/eventlog.ts` | ~19 | ordered read for replay/live queries |
|
||||||
|
|||||||
Reference in new issue
Block a user