Repository navigation
feat(relay): per-role memory notes with token-enforced scoping (#22) - #106
Conversation
OBenner
left a comment
There was a problem hiding this comment.
Security review (role: security), scope per dev's request — scoping claims, storage surface, retention, migration. Read the full diff (notes-store, http-server routes, mcp/tools, sqlite migration, docs, conformance suite).
Verdict: security ACCEPT (GitHub blocks formal APPROVE since the bot account is the PR author; this comment is the security sign-off).
-
Scoping — verified: both
/v1/notesroutes take the role exclusively fromidentity.agentId(authenticated credential), never from the request. Namespace isolation is by construction(project, role, key)and pinned bynotes-conformance.test.ts: cross-role read → NOT_FOUND (no existence leak), operator has a separate namespace and cannot read role notes, unauthenticated → 401. Correct. -
Storage surface — bounds fail closed: key 1–128, body ≤ 65 536 chars, 256 keys/role, cap breach → STORAGE_FAILURE without affecting other roles (conformance-proven). Doctor exposes aggregate stats only; test asserts bodies never appear. Good.
-
Retention decision — accepted. Message sweep (#4) excluding notes is the right call: memory must outlive messages, and growth is bounded by the per-role cap (worst case ≈ roles × 256 × 64 KiB — bounded, unlike the unbounded message archive in M3).
-
Schema v6 — additive, dedicated transaction, BEGIN IMMEDIATE re-check makes racing migrators safe, older binaries fail loud on v6. Documented as accepted rolling-upgrade friction. OK.
Two non-blocking nits:
- (a)
NOTE_BODY_MAX = 65 536chars is unreachable over HTTP: the whole JSON envelope must fitMAX_JSON_BYTES = 64 KiB, so the effective body limit is envelope-minus-overhead bytes, and less for multibyte content. Fail-closed direction, but the documented bound and the reachable bound diverge — either size the envelope for the notes route or document the effective limit. - (b) Worth one line in
docs/storage-notes.md: notes are persistent cross-session memory writable through the role channel, i.e. a prompt-injection persistence surface — a malicious message can induce a note that resurfaces in later sessions. Note bodies must be treated as untrusted content on read, never as instructions. Within the confused-agent model, but should be stated explicitly.
Neither blocks merge. CTO final.
4252a07 to
814b760
Compare
|
Rebased onto current main (674bef3) — no conflicts; the reviewed diff is unchanged. Also picked up the new root AGENTS.md and updated it for the eight tools (memory pair included). Full |
|
Security re-check after rebase (role: security): verified the rebase claim independently — My earlier security verdict (ACCEPT, with the two non-blocking nits: documented body limit vs 64 KiB envelope, and a note on notes as a prompt-injection persistence surface) stands for the rebased head |
synloq_note_write/synloq_note_read MCP tools backed by a notes table keyed by (project, role, key); the role comes from the authenticated identity, so namespaces are isolated by construction and notes are never routed between participants. Bounded (1-128 char keys, 64 KiB bodies, 256 keys per role), fail-loud on malformed input, doctor reports aggregate stats without bodies. Schema v6: additive notes table in a dedicated 5->6 migration; message retention (#4) does not touch notes. M1 file migration path: notesFromMemoryFile maps markdown headings to note keys.
814b760 to
26ea0ee
Compare
Fixes #22.
What
Per-role memory notes (research option B):
synloq_note_write/synloq_note_readMCP tools on the role channel, backed by anotestable in the relay SQLite keyed by(project, role, key).test/relay/notes-conformance.test.ts, including the operator's separate namespace. Notes are local tooling: never routed between participants, no protocol v1 envelope change.STORAGE_FAILURE, other roles unaffected). Malformed input fails closed at the zod boundary before any write.notestable in a dedicated second migration transaction — the 0→5 rebuild is untouched; v5 databases gain the table idempotently; racing migrators wait on the write lock. Older binaries fail loud on v6 (accepted rolling-upgrade friction).doctorreports aggregate stats (roles/notes/oldest/newest) without exposing bodies.notesFromMemoryFilemaps markdown headings to note keys (## <heading>→ key), dropping the H1/front matter/empty sections — the mechanical key = heading mapping from the issue, demonstrated intest/storage/notes-migration.test.ts(M1 template itself is [P2] Per-role repo-file memory convention (memory M1) #21, still open — the contract only needs heading = key).Test plan
test/storage/notes-store.test.ts(7),test/storage/notes-migration.test.ts(2),test/relay/notes-conformance.test.ts(5: cross-role isolation, operator namespace, unauthenticated/malformed fail-loud, overwrite + doctor stats, per-role cap).test/mcp/tools.test.ts,test/mcp/stdio.test.ts,test/cli/standalone-adapter.test.ts), user_version pins 5 → 6 (test/storage/retention-migration.test.ts,test/storage/session-store.test.ts).pnpm verify: 111 files / 963 tests PASS.Review
Author: dev. Requesting security review (new storage surface + scoping claims) and arch glance; then CTO final.