fix(provenance): address #143 re-review — shared resolver + decoupled badge
Architecture & design: - Arch A: introduce resolveProvenance() as the single source of truth for deriving a write's actor/aiChatId from the SIGNED identity, and wire it into BOTH transport seams — the REST jwt.strategy and the collab authentication.extension. Previously the collab seam derived actor from the token claim alone and ignored user.isAgent, so a flagged service account's page-content edits over the websocket persisted as lastUpdatedSource='user', drifting from REST. The seams now share one resolver and can't diverge. - Arch B: drop AiAgentBadge's page-history coupling. The generic ui/ badge no longer imports historyAtoms; it exposes an onActivate callback fired after the deep-link, and the history row passes onActivate to close its own modal. Suggestions/warnings: - S1: soften the jwt.strategy provenance comment (applies to every REST write). - S2/suggestion-3: drop the redundant comment-list-item null-aiChatId test (covered by ai-agent-badge.test.tsx). - S3: de-duplicate jwt.strategy.spec test #3 (the no-claim→'user' half duplicated test #2); keep only the signed actor='agent' claim assertion. - W2: add keyboard-activation tests for the badge (Enter/Space, unrelated key). - W3: flip the design doc status to "реализовано (#143)". Tests: - new auth-provenance.decorator.spec.ts unit-tests resolveProvenance + agentSourceFields. - new collab-seam test: is_agent user with no claim → actor='agent' (Arch A regression guard). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
# Атрибуция комментариев (и записей) от MCP как «AI», а не как пользователь
|
||||
|
||||
Статус: **открыто (дизайн).** Сейчас комментарии, созданные через MCP-инструмент,
|
||||
показываются как комментарии обычного пользователя (сервис-аккаунта, под которым
|
||||
залогинен MCP). Нужно, чтобы они показывались как комментарии от AI. Инфраструктура
|
||||
agent-провенанса (`§15 C3`) в проекте уже наполовину построена — задача переиспользует
|
||||
её, а не строит заново.
|
||||
Статус: **реализовано (#143).** Комментарии и записи страниц, созданные через MCP
|
||||
(или любым `is_agent`-аккаунтом), помечаются неподделываемым AI-бейджем. Провенанс
|
||||
выводится из подписанной идентичности на ОБОИХ транспортных швах — REST
|
||||
(`jwt.strategy`) и collab-websocket (`authentication.extension`) — через общий
|
||||
`resolveProvenance` (см. `auth-provenance.decorator.ts`), поэтому швы не расходятся.
|
||||
Документ оставлен как запись дизайна/обоснования; дальнейшая работа по нему не нужна.
|
||||
|
||||
## Цель
|
||||
|
||||
|
||||
Reference in New Issue
Block a user