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

@ -26,12 +26,12 @@ import {
calculateFrictionInsight,
classifyKeyStroke,
computeTypedDelta,
isEditAtTextEnd,
shouldLearnFromApp,
countWords,
emptyActivityBucket,
extractPhrases,
isAppExcluded,
isLearnablePhrase,
LEARNING_EXCLUDED_APPS,
manhattanDistance,
mergeActivityBucket,
rankFlowWindows,
@ -99,6 +99,11 @@ export interface TypingContext {
editedSinceFocus: boolean
/** 최근에 실제로 타이핑했는가 (recentTypingWindowMs 이내) */
typedRecently: boolean
/**
* prefix 가 실제 커서 앞 텍스트라고 믿을 수 있는가 — 케어렛 오프셋을 알면 true, 모르면
* 마지막 편집이 문서 끝에서 일어났을 때만 true. 생략하면 true 로 본다(호환).
*/
caretReliable?: boolean
}
interface InputTelemetryEvents {
@ -181,6 +186,10 @@ class InputTelemetryService extends EventEmitter {
private _lastFocusKey = ''
/** 현재 포커스에 들어왔을 때의 텍스트 (비밀번호는 저장하지 않는다) — 편집 여부 판정 기준선. */
private _textAtFocus = ''
/** 직전 스냅샷의 (포커스 키, 텍스트) — 케어렛을 모를 때 편집 위치 판정에 쓴다 */
private _editProbe: { key: string; text: string } | null = null
/** 마지막 편집이 문서 끝에서 일어났는가 (케어렛을 모를 때만 의미가 있다) */
private _lastEditAtEnd = true
/** 클릭 뒤 첫 스냅샷에서 기준선을 다시 잡는다 */
private _rebaseFocusText = false
private _lastActiveTickAt = 0
@ -644,6 +653,16 @@ class InputTelemetryService extends EventEmitter {
}
context.editedSinceFocus = textForFocus !== this._textAtFocus
// 케어렛을 모르면 "문서 끝 = 커서" 가정이 맞는지 마지막 편집 위치로 확인한다.
// 문서 중간을 고쳤다면 접두(문서 끝)는 커서와 무관하다 — 제안·수락을 막는다.
if (this._editProbe === null || this._editProbe.key !== focusKey) {
this._lastEditAtEnd = true
} else if (this._editProbe.text !== textForFocus) {
this._lastEditAtEnd = isEditAtTextEnd(this._editProbe.text, textForFocus)
}
this._editProbe = { key: focusKey, text: textForFocus }
context.caretReliable = caretKnown || this._lastEditAtEnd
if (snapshot.isEditable && !snapshot.isPassword && !snapshot.isComposing) {
this._applyTypedDelta(snapshot)
}
@ -817,9 +836,8 @@ class InputTelemetryService extends EventEmitter {
raw: string,
meta: { appName: string | null; windowTitle: string | null; source: PhraseSource }
): void {
if (meta.source === 'typed' && meta.appName && isAppExcluded(meta.appName, LEARNING_EXCLUDED_APPS)) {
return
}
// 학습 제외 앱은 출처와 무관하다 — 터미널에서 수락한 제안(개발 지시)도 코퍼스에 넣지 않는다.
if (!shouldLearnFromApp(meta.appName)) return
const text = sanitizeSample(
raw
.split(/\r?\n/u)
@ -1374,8 +1392,8 @@ class InputTelemetryService extends EventEmitter {
* 있었다 — 규칙을 과거 데이터에도 똑같이 적용해 그래프를 되돌린다.
*/
private _pruneUnlearnableCorpus(): void {
const excluded = (source: string, appName: string | null): boolean =>
source === 'typed' && appName !== null && isAppExcluded(appName, LEARNING_EXCLUDED_APPS)
// 학습과 같은 규칙(출처 무관) — 규칙 이전에 쌓인 제외 앱의 수락 제안도 걷어낸다.
const excluded = (_source: string, appName: string | null): boolean => !shouldLearnFromApp(appName)
try {
const db = getDatabase()