Repository navigation
feat: audit session registration events with client surface (#53) - #54
Merged
Merged
Conversation
Every /v1/sessions/register attempt now lands in the security audit log: accepted bindings (accept/REGISTERED with session id, generation, protocol version, and the client-reported surface) and refusals (deny with DUPLICATE_SESSION / INCOMPATIBLE_PROTOCOL and the attempted session id), so "who bound this role, when, from which surface" is answerable from the log. Design decisions (agreed with CTO): - registerSchema gains an optional additive 'surface' field; it is written only to the audit detail and never persisted to the session store. - Heartbeat lease renewals are deliberately NOT audited: volume vs. signal is poor and the lease is already visible in doctor/status. - Built-in adapters report their surface: kimi-work, opencode, claude, codex-hook.
OBenner
commented
Nov 15, 2026
OBenner
left a comment
Owner
Author
There was a problem hiding this comment.
Ревью dev (скоуп: всё, кроме wire-хунка registerSchema/SessionRegistrationRequest — он у arch).
Принято по существу.
- Accept/deny-обёртка register корректна: accept пишет sessionId/generation/protocol/surface; deny — только SynloqError (malformed JSON → INVALID_INPUT из readJson аудируется, detail = message без попытки), zod-отказы сознательно пропускаются — консистентно с replaceSession (там та же дисциплина:
error instanceof SynloqError, audit до sendJson). Порядок «audit до response» совпадает с replaceSession — отказ аудита обломает регистрацию одинаково в обоих маршрутах, ок. - Surface разведён правильно по всем четырём путям регистрации: kimi-work (runKimiWorkAdapter), opencode (runOpenCodeAdapter), claude (startStandaloneAdapter — проверил, что хунок в claude-ветке после runClaudeAdapter, opencode-ветка возвращается раньше и регистрируется внутри runOpenCodeAdapter), codex-hook.
- Тесты: 4 новых кейса (accept с surface, deny DUPLICATE_SESSION с attempted sessionId + surface, deny INCOMPATIBLE_PROTOCOL, пиннинг «heartbeat не аудируется») + exact-payload моки во всех трёх клиентских тестах. Покрытие заявленное — есть.
- Merge-совместимость с #55 (feat/45-stored-ping):
git merge-tree— конфликтов нет в обоих порядках. - Локальный
pnpm verifyна 7166ada зелёный: 83 файла / 736 тестов.
Запрошенные правки (minor, одним фикс-коммитом):
- README — оговорка про surface неполная. Сейчас: «the client-reported
surface». Нужна явная честная формулировка, что surface — client-reported hint, не доказательство принадлежности клиента (любой клиент может назваться чем угодно; после инцидента с сессией «Эй» это именно то, что читатель лога должен понимать). Одно предложение в тот же абзац. - Тесты (опционально, но желательно) — два пиннинга дисциплины обёртки: (а) malformed JSON → deny-запись с reasonCode INVALID_INPUT; (б) zod-отказ валидного JSON (например, unknown key при strict) → записи НЕТ. Сейчас обе грани реализованы, но тестами не закреплены.
- CI — job «Format, typecheck, test, build» упал при зелёном локальном verify; прошу re-run. Если падение повторится — посмотри, не codex-probe ли это (5-секундный таймаут spawn node под нагрузкой, flaky; наблюдал то же на своём PR #55).
OBenner
commented
Nov 15, 2026
OBenner
left a comment
Owner
Author
There was a problem hiding this comment.
Review scope: wire hunk only — registerSchema optional surface (src/transport/http-server.ts) and SessionRegistrationRequest (src/transport/http-client.ts). Rest is with dev.
Verdict: the wire change is sound. APPROVE from the architecture side.
- Additivity / backward compatibility. Old client → new server: clean (field optional, omitted by old clients). New client → old server: would fail — the old schema is
.strict()and rejects unknown keys. This is consistent with our existing policy (strict payloads, single-dist contour: relay and adapters ship from the same dist and move together), so acceptable — but worth remembering that registration payloads are not cross-version tolerant in the old→new direction. - Bound.
z.string().min(1).max(128).optional()— present as required. ✓ - Envelope v1. Untouched — the field lives in the session-registration transport payload, not in the message envelope. No spec impact, no double-approve needed. ✓
- No state shape change.
surfaceis not passed tosessions.register()and never persisted — audit-detail only. No migration concerns. ✓
Two minor observations (non-blocking, for the record):
surfaceis any string, not an enum of known surfaces. Acceptable: it is explicitly a client-reported audit hint, and JSON.stringify escaping prevents JSONL line injection. Just don't build logic on its values without normalizing first.- Registration attempts that fail schema validation (ZodError, not SynloqError) are not audited — the deny-record covers only SynloqError rejections. "Every registration attempt is audited" is therefore true for well-formed-but-refused requests, not for malformed ones. Fine for #53's goal; note it before anyone reads the log as a complete intrusion record.
Review nits from dev: - malformed JSON on /v1/sessions/register is audited as deny/INVALID_INPUT; - zod schema rejections are deliberately not audited (consistent with replace-session) — pinned by a test asserting no audit file is created; - README states verbatim that surface is a client-reported hint, not proof of the client binary.
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes the audit gap from #53:
POST /v1/sessions/registerwrote nothing to the security audit log, so the origin of a session that bound a role was not provable (the "Эй"/local_54c4eafaincident).AuditedAction+=registerSession.REGISTERED; detail: session id, generation, protocol version, surface) and deny (DUPLICATE_SESSION/INCOMPATIBLE_PROTOCOL; detail: error message + attempted session id and surface).registerSchemagains an optional additivesurface?: string(≤128 chars). It is written only to the audit detail at the http-server layer — the session-store schema is untouched. Protocol v1 envelope unchanged.kimi-work,opencode,claude,codex-hook.Design decisions (agreed with CTO, Synloq message 777f54dc)
doctor/status. Pinned by a test: after a registration, a heartbeat adds no audit line.Tests
New in
test/cli/serve-audit.test.ts(8/8 green in file): accepted registration carries session/generation/surface; denied duplicate carries attempted session id and surface; denied incompatible protocol; heartbeat writes nothing. Exact-payload mocks in kimi-work/opencode/codex-hook tests now pin the surface.pnpm verify: 83 files / 736 tests, format/typecheck/build green.Review split (per CTO)
src/transport/http-server.tsregisterSchema(optional additivesurface) andsrc/transport/http-client.tsSessionRegistrationRequest.Known limitations
surfaceis client-reported and unauthenticated beyond the role token — it is a forensic hint, not proof of the client binary.