feat: Tauri SQLite 事件持久化 + 讲述点追问补全(缺失检测→模板追问→沉默即数据)

This commit is contained in:
Jayway Liu
2026-10-03 12:55:00 +08:00
parent 6117ef894f
commit ba50cf3928
18 changed files with 1360 additions and 34 deletions
+8 -6
View File
@@ -1,4 +1,4 @@
import type { DimensionTag, IdentityProfile } from './types';
import type { DimensionTag, FollowUpDimension, IdentityProfile } from './types';
/**
* 选择/讲述事件存储(ADR-0004:历史不可涂改)。
@@ -17,7 +17,7 @@ export interface StoryEvent {
sessionId: string;
ts: number;
chapterId: string;
kind: 'choice' | 'narration' | 'profile';
kind: 'choice' | 'narration' | 'profile' | 'followup' | 'followup_skipped';
/** 选择点 ID,如 C1-03 */
pointId: string;
dimensions: DimensionTag[];
@@ -27,7 +27,9 @@ export interface StoryEvent {
/** narration 事件:选中的场景变体(情绪签名 → variantId) */
variantId?: string;
emotionSignature?: string;
/** 讲述转写文本(Web Speech API 只给文本,不留音频,符合 ADR-0004 即焚原则;沉默为 null) */
/** followup / followup_skipped 事件:追问针对的缺失维度 */
followUpDimension?: FollowUpDimension;
/** 讲述/追问的转写文本(Web Speech API 只给文本,不留音频,符合 ADR-0004 即焚原则;沉默为 null) */
transcript?: string | null;
/** profile 事件:用户确认后的身份登记字段(匹配硬过滤字段) */
profile?: IdentityProfile;
@@ -66,7 +68,7 @@ export class LocalStorageEventStore implements EventStore {
}
/**
* Tauri 原生端实现预留:后续用 tauri-plugin-sql(SQLite)实现同一接口,
* 表结构即 StoryEvent 一行一条,只写 INSERT/SELECT,不建 UPDATE/DELETE 路径。
* 见 README「已知缺口」。
* Tauri 原生端实现:见 ./sqliteEventStore.ts(tauri-plugin-sql + SQLite,
* 同一 EventStore 接口,SQL 层同样只写 INSERT/SELECT)。
* 运行时选择在 App.tsx:window.__TAURI__ 存在用 SqliteEventStore,否则 localStorage。
*/