test(ai-chat): cover safety-critical code paths (review follow-ups P1) #3
Closed
Ghost
wants to merge 1 commits from
test/ai-chat-safety-critical-coverage into develop
pull from: test/ai-chat-safety-critical-coverage
merge into: vvzvlad:develop
vvzvlad:main
vvzvlad:test/244-part-b
vvzvlad:fix/255-ws-redis-adapter-leak
vvzvlad:feat/251-intentional-clear
vvzvlad:fix/252-e2e-open-handles
vvzvlad:feat/184-autonomous-agent-runs
vvzvlad:feat/221-image-captions
vvzvlad:feat/git-sync
vvzvlad:refactor/193-tool-spec-registry
vvzvlad:fix/244-dataloss-bugs
vvzvlad:fix/embeddings-reindex-progress
vvzvlad:develop
vvzvlad:feature/offline-sync
vvzvlad:feat/229-catalog-yaml
vvzvlad:feat/243-blob-sandbox
vvzvlad:feat/228-inline-footnotes
vvzvlad:fix/qa-ui-bugs-216-218
vvzvlad:feature/agent-roles-catalog
vvzvlad:fix/share-alias-rename
vvzvlad:fix/ai-chat-empty-render
vvzvlad:feat/191-chat-doc-binding
vvzvlad:feat/201-temporary-notes
vvzvlad:feat/198-interrupt-agent
vvzvlad:feat/ai-chat-full-history
vvzvlad:feat/199-ai-generate-title
vvzvlad:feat/205-share-aliases
vvzvlad:batch/issues-189-187-170
vvzvlad:feat/170-mcp-test-button
vvzvlad:feat/189-context-badge
vvzvlad:feat/198-interrupt-agent-send-now
vvzvlad:fix/issues-190-159
vvzvlad:fix/ai-chat-new-chat-during-stream
vvzvlad:fix/ai-chat-stream-perf
vvzvlad:batch/issues-2026-06-25
vvzvlad:feat/ai-chat-persistent-history
vvzvlad:fix/ai-chat-copy-chat-wysiwyg
vvzvlad:fix/ai-stream-reset-resilience
vvzvlad:fix/ai-stream-undici-timeout
vvzvlad:fix/footnote-review-1227-followup
vvzvlad:fix/ai-chat-token-counter-realtime
vvzvlad:docs/manual-qa-test-plan
No Reviewers
Labels
Clear labels
bug
documentation
duplicate
enhancement
epic
feature
good first issue
help wanted
idea
invalid
needs-human
question
refactor
review/approved
review/changes-requested
review/needs
security
status/blocked
status/done
status/in-progress
status/ready
test
wontfix
Something isn't working
Improvements or additions to documentation
This issue or pull request already exists
New feature or request
Large multi-phase effort spanning many changes
New functionality request
Good for newcomers
Extra attention is needed
Idea / proposal for discussion
This doesn't seem right
эскалация: нужно решение человека
Further information is requested
Code cleanup / refactoring
в последнем ревью нет открытых blocking-находок
последнее ревью оставило открытые blocking-находки
head не ревьюился (head != reviewed_head)
Security / hardening issue
ждёт зависимость blocked_by
закрыто и проверено
в активной работе (мягкая заявка)
специфицировано, не заблокировано, ждёт исполнителя
Test coverage / test infrastructure
This will not be worked on
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vvzvlad/gitmost#3
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "test/ai-chat-safety-critical-coverage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Closes priority-1 findings of the ai-chat multi-aspect review (
docs/backlog/ai-chat-review-followups.md): five pieces of security-critical code previously had zero unit tests. A regression in any of them would fail silently — corrupted credentials, an SSRF hole, a broken chat history replay, broken OpenAI tool-calls, or a pgvector dimension crash.Changes
crypto/secret-box.spec.ts(NEW, 5 tests) — AES-256-GCM round-trip; non-determinism (two encrypts → different blobs, both decrypt); tampered authTag / ciphertext bytes throw with theAPP_SECRET may have changedmessage; wrong APP_SECRET throws the same. Guards the only at-rest protection of provider API keys.ai-chat/external-mcp/ssrf-guard.spec.ts(NEW, 20 tests) —isIpAllowedblocks every forbidden class (loopback, link-local incl. metadata169.254.169.254, private, CGNAT, ULA, unspecified, IPv4-mapped IPv6, unparseable) and allows a public IP;isUrlAllowedrejects bad scheme / invalid URL, blocks IP-literal private, and with a mockeddns.lookupblocks DNS-rebinding to a private address and an unresolvable host.ai-chat/ai-chat.service.spec.ts(extended, +5 tests) —assistantParts: paired call →output-available, unpaired call →output-error(regression guard for theMissingToolResultsErrorfixdbd83b5a/4868ca8e), broken calls skipped, step text and fallback text. Requires exportingassistantParts+StepLike— the only production change here (twoexportkeywords).ai-chat/tools/ai-chat-tools.service.spec.ts(extended, +8 tests) — JSON-string coercion inpatchNode/insertNode/updatePageJson: string parsed to object, invalid JSON throws the specific message,updatePageJsondistinguishesundefined(title-only) / object / string. Guards the OpenAI tool-call compatibility fix59b99dba.database/repos/ai-chat/page-embedding.repo.spec.ts(NEW, 1 test) —searchByEmbeddingwith emptyspaceIdsreturns[]without touching the DB (Proxy stub throws on any access). Guards the access-scoping early-return.54 new tests, all green. No functional behaviour changed.
Out of scope
Verification
pnpm --filter server test— 54 new tests pass.pnpm --filter server lint— no new errors (only the known pre-existingcommon/helpers/utils.ts:3 no-require-imports).exportkeywords inai-chat.service.ts— nothing else.Закрываю как дубликат уже влитой работы.
Все пять заявленных тестовых файлов уже есть в
develop(пришли коммитомf1980cf4, PR #11), иassistantPartsтам уже экспортирован:apps/server/src/integrations/crypto/secret-box.spec.tsapps/server/src/core/ai-chat/external-mcp/ssrf-guard.spec.tsapps/server/src/database/repos/ai-chat/page-embedding.repo.spec.tsassistantPartsиnode-arg JSON-string coercionв соответствующих спекахPR ответвлён от устаревшего
develop(merge-basec8af637), отсюда add/add и content-конфликты во всех 6 файлах (причинаmergeable:false). Единственное реально отсутствующее в develop изменение —exportуtype StepLike— на develop не используется и отдельно не нужно. Тесты сами по себе качественные, но дублируют уже имеющееся покрытие.Ghost referenced this pull request2026-06-21 16:13:37 +03:00
Ghost referenced this pull request2026-06-21 16:32:23 +03:00
Ghost referenced this pull request2026-06-24 00:10:43 +03:00
Ghost referenced this pull request2026-06-24 12:45:05 +03:00
Ghost referenced this pull request2026-06-25 12:25:48 +03:00
Ghost referenced this pull request2026-06-27 19:52:21 +03:00
Ghost referenced this pull request2026-06-28 02:46:17 +03:00
Ghost referenced this pull request2026-06-28 15:27:58 +03:00
Ghost referenced this pull request2026-06-28 21:20:45 +03:00
Ghost referenced this pull request2026-06-28 23:19:22 +03:00
Pull request closed