fix: red-team round 3 hardening across desktop, mobile, core and server

Batch of red-team r3 fixes that were in the working tree before the
2026-09-28 design overhaul, committed as one unit with their tests.

- desktop main: STT timeouts and sidecar, voice recording store, sync
  (credentials, audio, knowledge reindex, push gates), runtime
  provisioner, update policy, AltGr keybindings, voice-command policy,
  dictionary file codec/limits, meeting transcript condensing and a
  local recording ledger so interrupted-session recovery only closes
  meetings this device recorded (a phone's live meeting is left alone).
- mobile: login CSRF via implicit token callbacks rejected, account
  deletion/retention, durable queue retention, knowledge realtime
  without unfiltered DELETE, meeting re-record failure paths, cloud STT
  client, preferences store/resync.
- core: text chunking splits long unbroken transcripts to fit, template
  field policy, dictionary limits, meeting markdown inline handling.
- server: payple webhook policy and cancellation order scope, meeting
  document generation quota, team RPC null-role guard, unified LLM
  quota in-flight accounting, knowledge chunk vector index, meeting
  re-record failure paths (migrations 20260929*).
- ci: portable/runtime feed gates, update-policy schema, Forgejo file
  delete and alias planning.

Four older tests are updated to the new contracts rather than the old
behavior: token-pair auth callbacks are rejected, knowledge realtime no
longer subscribes to DELETE, long transcript lines are split, and
meeting recovery requires the local recording ledger for empty rows.
This commit is contained in:
Yun Chan 2026-09-28 20:45:52 +09:00
parent 2428ede03d
commit ba9ef9741e
161 changed files with 17056 additions and 2379 deletions

View file

@ -187,6 +187,23 @@ export const PASTE_INSERTION_THRESHOLD_CHARS = 200
* 텍스트가 되므로 키코드 재구성은 원리적으로 불가능하다. 커밋된 텍스트를 읽어
* diff 하는 방식만이 CJK 를 포함해 정확하다.
*/
/**
* 두 텍스트 사이의 편집이 문서 끝에서 일어났는가 (케어렛을 모를 때 "커서 = 문서 끝" 가정의 근거).
*
* computeTypedDelta 와 같은 공통 접두/접미 분해를 쓴다. 바뀐 구간 뒤에 남은 공통 접미가 없으면
* 끝에서 쓰거나 지운 것이다. 같으면(편집 없음) true.
*/
export function isEditAtTextEnd(prevText: string, nextText: string): boolean {
if (prevText === nextText) return true
let prefix = 0
const maxPrefix = Math.min(prevText.length, nextText.length)
while (prefix < maxPrefix && prevText[prefix] === nextText[prefix]) prefix += 1
const maxSuffix = Math.min(prevText.length - prefix, nextText.length - prefix)
// 공통 접미가 한 글자라도 남으면 편집 지점 뒤에 기존 텍스트가 있다 — 문서 중간 편집이다.
if (maxSuffix <= 0) return true
return prevText[prevText.length - 1] !== nextText[nextText.length - 1]
}
export function computeTypedDelta(
prevText: string,
nextText: string,
@ -399,6 +416,11 @@ export type SuggestionSkipReason =
| 'cooldown'
/** 포커스만 옮겨 왔을 뿐 이 필드에서 실제로 타이핑하지 않았다 (마우스 클릭 등) */
| 'not-typing'
/**
* 케어렛 위치를 알 수 없고(예: Notepad — ValuePattern 만 제공) 마지막 편집도 문서 끝이 아니었다.
* 접두가 "문서 끝" 이라 실제 커서 위치와 무관하다 — 수락하면 문서 중간에 엉뚱한 문장이 붙는다.
*/
| 'caret-unknown'
export type SuggestionDecision =
| { action: 'request'; prefix: string }
@ -423,6 +445,11 @@ export interface SuggestionPolicyInput {
typedRecently: boolean
/** 어렛 앞 스트 */
prefix: string
/**
* prefix 가 실제 커서 앞 텍스트라고 믿을 수 있는가. 케어렛 오프셋을 알면 true, 모르면
* 마지막 편집이 문서 끝에서 일어났을 때만 true. 생략하면 true(호환).
*/
caretReliable?: boolean
idleMs: number
triggerDelayMs: number
minPrefixChars: number
@ -448,6 +475,9 @@ export function decideSuggestion(input: SuggestionPolicyInput): SuggestionDecisi
if (input.appName && isAppExcluded(input.appName, input.excludedApps)) {
return { action: 'clear', reason: 'excluded-app' }
}
// 케어렛을 모르는 필드에서 문서 중간을 고쳤다 — 접두(문서 끝)가 커서 위치와 무관하다.
// 떠 있는 세션도 닫는다: 수락하면 실제 커서(문서 중간)에 문서 끝의 이어 쓰기가 붙는다.
if (input.caretReliable === false) return { action: 'clear', reason: 'caret-unknown' }
// 포커스만 옮겨 왔을 뿐(마우스 클릭 등) 이 필드에서 아무것도 치지 않았으면 제안하지 않는다.
//
// 유휴 판정이 키보드 기준이라, 필드에 이미 차 있던 텍스트로 클릭만 해도 (마지막
@ -761,7 +791,17 @@ export function shouldPersistSuggestionPrefix(input: {
appName: string | null
}): boolean {
if (!input.learnTypedText) return false
return !(input.appName && isAppExcluded(input.appName, LEARNING_EXCLUDED_APPS))
return shouldLearnFromApp(input.appName)
}
/**
* 이 앱에서 나온 텍스트를 개인 코퍼스(문구·그래프·표본)에 넣어도 되는가 — 학습 제외 앱의 정본.
*
* 출처(타이핑·받아쓰기·수락한 제안)와 무관하다: 터미널·에디터·에이전트 허브에 보낸 개발 지시는
* 어떤 경로로 들어왔든 KakaoTalk 제안으로 새면 안 된다. 앱을 모르면(null) 학습한다.
*/
export function shouldLearnFromApp(appName: string | null | undefined): boolean {
return !(appName && isAppExcluded(appName, LEARNING_EXCLUDED_APPS))
}
/** 공백을 뺀 글자 중 문자(모든 언어)가 이 비율 이상이어야 문장으로 본다. */