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:
parent
2428ede03d
commit
ba9ef9741e
161 changed files with 17056 additions and 2379 deletions
|
|
@ -34,6 +34,14 @@ import { getMainWindow } from '../windows/WindowManager'
|
|||
|
||||
const logger = getLogger('CaptionService')
|
||||
|
||||
/** 로딩을 기다리던 start() 가 stop()·새 start 로 무효화됐다 (내부 신호) */
|
||||
class CaptionStartCancelledError extends Error {
|
||||
constructor() {
|
||||
super('caption start cancelled')
|
||||
this.name = 'CaptionStartCancelledError'
|
||||
}
|
||||
}
|
||||
|
||||
/** 트랙 판단 주기 (ms) — 인식 주기는 트랙이 정한다(중간 결과 1초) */
|
||||
const TICK_INTERVAL_MS = 250
|
||||
|
||||
|
|
@ -123,6 +131,11 @@ class CaptionService extends EventEmitter {
|
|||
private _audio: CaptionAudioSources = this._createAudioSources()
|
||||
/** 현재 세션 옵션(소유자·오버레이·히스토리 저장) — 세션이 없으면 기본값 */
|
||||
private _session: ResolvedStartOptions = { ...DEFAULT_START_OPTIONS }
|
||||
/**
|
||||
* 시작 세대. start() 마다 올리고, 'starting' 중 stop() 도 올린다 — 모델 로딩을 기다리던 start 가
|
||||
* 깨어났을 때 세대가 바뀌었으면 마이크를 열지 않고 물러난다(취소한 자막이 오버레이 없이 켜지던 문제).
|
||||
*/
|
||||
private _startEpoch = 0
|
||||
|
||||
// ── 공개 접근자 ──
|
||||
|
||||
|
|
@ -169,6 +182,11 @@ class CaptionService extends EventEmitter {
|
|||
showOverlay: options.showOverlay ?? DEFAULT_START_OPTIONS.showOverlay,
|
||||
persistHistory: options.persistHistory ?? DEFAULT_START_OPTIONS.persistHistory,
|
||||
}
|
||||
const epoch = ++this._startEpoch
|
||||
const assertCurrent = (): void => {
|
||||
if (epoch !== this._startEpoch || this._disposed) throw new CaptionStartCancelledError()
|
||||
}
|
||||
let ownAudio: CaptionAudioSources | null = null
|
||||
this._setState('starting')
|
||||
|
||||
// 오버레이를 즉시 표시 (로딩 상태) — 회의 모드처럼 자체 UI 가 있으면 띄우지 않는다
|
||||
|
|
@ -182,9 +200,11 @@ class CaptionService extends EventEmitter {
|
|||
// STT 초기화 (모델 로딩 — 시간 소요)
|
||||
const sttService = getLocalSTTService()
|
||||
await sttService.initialize()
|
||||
assertCurrent()
|
||||
// 자막 전용 모델을 골랐으면 받아쓰기 모델과 별도로 올려 둔다(보조 자리).
|
||||
this._captionModelId = configGet('captionSttModelId') ?? null
|
||||
if (this._captionModelId) await sttService.ensureAuxModel(this._captionModelId)
|
||||
assertCurrent()
|
||||
|
||||
// 세션 초기화
|
||||
this._sessionId = crypto.randomUUID()
|
||||
|
|
@ -218,8 +238,10 @@ class CaptionService extends EventEmitter {
|
|||
this._systemTrack = this._createTrack('system', initialContext)
|
||||
}
|
||||
// 마이크 캡처(mic/both) + 시스템 오디오 캡처 요청(system/both — 렌더러에 시작 요청)
|
||||
this._audio = this._createAudioSources()
|
||||
await this._audio.acquire(audioSource, { onMicChunk: (buffer) => this._onAudioData(buffer) })
|
||||
ownAudio = this._createAudioSources()
|
||||
this._audio = ownAudio
|
||||
await ownAudio.acquire(audioSource, { onMicChunk: (buffer) => this._onAudioData(buffer) })
|
||||
assertCurrent()
|
||||
|
||||
// 트랙 판단 타이머 — 각 트랙은 한 번에 인식 한 건만 돌린다
|
||||
this._tickTimer = setInterval(() => {
|
||||
|
|
@ -231,6 +253,13 @@ class CaptionService extends EventEmitter {
|
|||
getSoundEffectService().play('recording-start')
|
||||
logger.info(`Live Caption 시작: sessionId=${this._sessionId}`)
|
||||
} catch (err) {
|
||||
if (err instanceof CaptionStartCancelledError) {
|
||||
// 기다리는 사이 stop()(또는 새 start)이 세션을 가져갔다 — 공유 상태는 건드리지 않고
|
||||
// 이 시도가 연 자원만 돌려준다(release 는 멱등).
|
||||
await ownAudio?.release()
|
||||
logger.info('캡션 시작 취소: 로딩 중 정지됨')
|
||||
throw new D3ROError(ErrorCode.CaptionStartFailed, '캡션 시작이 취소되었습니다')
|
||||
}
|
||||
if (this._tickTimer) {
|
||||
clearInterval(this._tickTimer)
|
||||
this._tickTimer = null
|
||||
|
|
@ -272,6 +301,8 @@ class CaptionService extends EventEmitter {
|
|||
return false
|
||||
}
|
||||
|
||||
// 로딩 중(start 가 모델을 기다리는 중)이면 그 start 를 무효화한다 — 깨어나도 마이크를 열지 않는다.
|
||||
if (this._state === 'starting') this._startEpoch += 1
|
||||
this._setState('stopping')
|
||||
|
||||
// 타이머 정리
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue