synapse-db 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connectome.d.ts +11 -2
- package/dist/engine.d.ts +22 -3
- package/dist/index.d.ts +27 -0
- package/dist/index.js +1068 -100
- package/dist/serializer.d.ts +5 -0
- package/dist/types.d.ts +2 -0
- package/dist/wal/arena.d.ts +70 -0
- package/dist/wal/config.d.ts +52 -0
- package/dist/wal/index.d.ts +81 -0
- package/dist/wal/ringBuffer.d.ts +94 -0
- package/dist/wal/sqliteWalStore.d.ts +38 -0
- package/dist/wal/timeTravel.d.ts +34 -0
- package/package.json +2 -2
package/dist/serializer.d.ts
CHANGED
|
@@ -7,8 +7,13 @@ export interface RawParsedMarkdown<T = Record<string, any>> {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* 텍스트에서 옵시디언 위키링크([[target|alias]] 또는 [[target]]) 자동 추출
|
|
10
|
+
* 초고속 Zero-Regex 인덱스 스캐너: 정규식 엔진 생성/컴파일/exec 배열 할당 없이 indexOf 슬라이싱으로 추출
|
|
10
11
|
*/
|
|
11
12
|
export declare function extractWikilinks(text: string, defaultCollection?: string): SynapseWikilink[];
|
|
13
|
+
/**
|
|
14
|
+
* 직렬화/파싱 왕복 없이 메모리 객체(data)와 본문(body)에서 직접 위키링크를 초고속 추출
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractWikilinksFromDataAndBody(data: Record<string, any> | undefined | null, body: string, defaultCollection?: string): SynapseWikilink[];
|
|
12
17
|
/**
|
|
13
18
|
* YAML Frontmatter 안전 파서 (순수 TypeScript 무손실 복원)
|
|
14
19
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* 범용 마크다운 시냅스 데이터베이스 타입 규격 (Synapse-DB Type Specifications)
|
|
3
3
|
* SOLID 원칙 준수: 단일 책임 원칙(SRP)에 따른 타입 정의 분리
|
|
4
4
|
*/
|
|
5
|
+
import type { CausalWalConfig } from "./wal/config";
|
|
5
6
|
/** 시냅스 위키링크 규격 ([[collection/id|alias]]) */
|
|
6
7
|
export interface SynapseWikilink {
|
|
7
8
|
readonly raw: string;
|
|
@@ -52,6 +53,7 @@ export interface SynapseDBConfig {
|
|
|
52
53
|
readonly vaultDir: string;
|
|
53
54
|
readonly autoWatch?: boolean;
|
|
54
55
|
readonly persistDebounceMs?: number;
|
|
56
|
+
readonly wal?: CausalWalConfig;
|
|
55
57
|
}
|
|
56
58
|
/** 시냅스 데이터베이스 전체 통계 요약 */
|
|
57
59
|
export interface SynapseDBStats {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 러스트 Bumpalo 스타일 지역 아레나 할당기 및 트랜잭션 스코프 (Arena Transaction Lifecycle)
|
|
3
|
+
* - 트랜잭션 중 발생하는 모든 변경 슬롯을 사전 할당된 연속 풀(Pool)에서 포인터 전진(cursor++)만으로 O(1) 할당
|
|
4
|
+
* - 커밋(Commit) 또는 롤백(Rollback) 즉시 포인터를 0으로 리셋하여 0ns 일괄 해제 (Zero-GC)
|
|
5
|
+
*/
|
|
6
|
+
import type { SynapseDocument } from "../types";
|
|
7
|
+
import { CausalWalEventType, type CompilerTemporalMetric } from "./config";
|
|
8
|
+
/** 아레나 내부에서 재사용되는 가변 슬롯 구조체 */
|
|
9
|
+
export interface ArenaMutationSlot {
|
|
10
|
+
eventType: CausalWalEventType;
|
|
11
|
+
collection: string;
|
|
12
|
+
docId: string;
|
|
13
|
+
prevDoc: SynapseDocument | null;
|
|
14
|
+
nextDoc: SynapseDocument | null;
|
|
15
|
+
edgesAdded: string[];
|
|
16
|
+
edgesRemoved: string[];
|
|
17
|
+
rawMarkdown: string | null;
|
|
18
|
+
targetDiskPath: string | null;
|
|
19
|
+
compilerMetric?: CompilerTemporalMetric;
|
|
20
|
+
}
|
|
21
|
+
/** 아레나 메모리 통계 */
|
|
22
|
+
export interface ArenaStats {
|
|
23
|
+
readonly poolCapacity: number;
|
|
24
|
+
readonly activeCursor: number;
|
|
25
|
+
readonly totalTransactionsCommitted: number;
|
|
26
|
+
readonly totalTransactionsRolledBack: number;
|
|
27
|
+
readonly totalSlotReuses: number;
|
|
28
|
+
}
|
|
29
|
+
export declare class CausalArenaAllocator {
|
|
30
|
+
private readonly pool;
|
|
31
|
+
private cursor;
|
|
32
|
+
private inTransaction;
|
|
33
|
+
private totalCommitted;
|
|
34
|
+
private totalRolledBack;
|
|
35
|
+
private totalSlotReuses;
|
|
36
|
+
constructor(initialCapacity?: number);
|
|
37
|
+
private createEmptySlot;
|
|
38
|
+
/**
|
|
39
|
+
* 트랜잭션 아레나 스코프 시작
|
|
40
|
+
*/
|
|
41
|
+
beginScope(): void;
|
|
42
|
+
/**
|
|
43
|
+
* 현재 트랜잭션 스코프 활성화 여부
|
|
44
|
+
*/
|
|
45
|
+
isScopeActive(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* 포인터 전진(Bump Allocation)을 통해 힙 할당 없이 슬롯 획득
|
|
48
|
+
*/
|
|
49
|
+
allocSlot(eventType: CausalWalEventType, collection: string, docId: string, prevDoc: SynapseDocument | null, nextDoc: SynapseDocument | null, edgesAdded: string[], edgesRemoved: string[], rawMarkdown?: string | null, targetDiskPath?: string | null, compilerMetric?: CompilerTemporalMetric): ArenaMutationSlot;
|
|
50
|
+
/**
|
|
51
|
+
* 현재 스코프에 적재된 유효 슬롯 뷰 반환
|
|
52
|
+
*/
|
|
53
|
+
getActiveSlots(): readonly ArenaMutationSlot[];
|
|
54
|
+
/**
|
|
55
|
+
* 커밋 완료 후 O(1) 포인터 리셋 (0ns Instant Deallocation)
|
|
56
|
+
*/
|
|
57
|
+
commitAndReset(): void;
|
|
58
|
+
/**
|
|
59
|
+
* 예외 발생 시 롤백 및 O(1) 포인터 리셋 (커넥톰 및 WAL 오염 0%)
|
|
60
|
+
*/
|
|
61
|
+
rollbackAndReset(): void;
|
|
62
|
+
/**
|
|
63
|
+
* 사용된 슬롯의 내부 참조만 즉시 비워 메모리 누수 차단 (슬롯 객체 자체는 풀에 보존)
|
|
64
|
+
*/
|
|
65
|
+
private clearReferencesUpToCursor;
|
|
66
|
+
/**
|
|
67
|
+
* 아레나 할당기 통계 조회
|
|
68
|
+
*/
|
|
69
|
+
getStats(): ArenaStats;
|
|
70
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 시냅스 Causal-WAL 엔진 환경 설정 및 상수 모듈 (WAL Configuration & Constants)
|
|
3
|
+
* 하드코딩 배제 원칙 준수: 모든 기본 용량, 타임아웃, PRAGMA 상수를 중앙 집중 관리
|
|
4
|
+
*/
|
|
5
|
+
export declare const WAL_CONFIG_DEFAULTS: {
|
|
6
|
+
/** 순환 링 버퍼 기본 슬롯 용량 (2의 거듭제곱 권장) */
|
|
7
|
+
readonly RING_BUFFER_CAPACITY: number;
|
|
8
|
+
/** 트랜잭션 아레나 초기 사전 할당 슬롯 수 */
|
|
9
|
+
readonly ARENA_INITIAL_CAPACITY: number;
|
|
10
|
+
/** 아레나 최대 확장 상한선 */
|
|
11
|
+
readonly ARENA_MAX_CAPACITY: number;
|
|
12
|
+
/** SQLite WAL 기본 파일명 */
|
|
13
|
+
readonly SQLITE_WAL_FILENAME: string;
|
|
14
|
+
/** SQLite mmap 가상 메모리 매핑 크기 (256MB - OS 페이지 캐시 제로-카피 위임) */
|
|
15
|
+
readonly SQLITE_MMAP_SIZE_BYTES: number;
|
|
16
|
+
/** SQLite Busy Timeout (밀리초) */
|
|
17
|
+
readonly SQLITE_BUSY_TIMEOUT_MS: number;
|
|
18
|
+
/** SQLite WAL 동기화 모드 */
|
|
19
|
+
readonly SQLITE_SYNC_MODE: "NORMAL" | "FULL" | "OFF";
|
|
20
|
+
};
|
|
21
|
+
/** 인과율 WAL 이벤트 유형 */
|
|
22
|
+
export declare enum CausalWalEventType {
|
|
23
|
+
DOC_UPSERT = "DOC_UPSERT",
|
|
24
|
+
DOC_DELETE = "DOC_DELETE",
|
|
25
|
+
EDGE_LINK = "EDGE_LINK",
|
|
26
|
+
EDGE_UNLINK = "EDGE_UNLINK",
|
|
27
|
+
COMPILER_METRIC = "COMPILER_METRIC",
|
|
28
|
+
CHECKPOINT_MARK = "CHECKPOINT_MARK"
|
|
29
|
+
}
|
|
30
|
+
/** 컴파일러 시계열 메트릭 페이로드 규격 */
|
|
31
|
+
export interface CompilerTemporalMetric {
|
|
32
|
+
readonly targetFile: string;
|
|
33
|
+
readonly language: string;
|
|
34
|
+
readonly durationMs: number;
|
|
35
|
+
readonly binarySizeBytes?: number;
|
|
36
|
+
readonly symbolCount?: number;
|
|
37
|
+
readonly success: boolean;
|
|
38
|
+
readonly errorMessage?: string;
|
|
39
|
+
}
|
|
40
|
+
/** WAL 설정 옵션 인터페이스 */
|
|
41
|
+
export interface CausalWalConfig {
|
|
42
|
+
/** 인메모리 링 버퍼 최대 슬롯 수 (기본: 4096) */
|
|
43
|
+
readonly ringCapacity?: number;
|
|
44
|
+
/** 아레나 사전 할당 슬롯 수 (기본: 256) */
|
|
45
|
+
readonly arenaCapacity?: number;
|
|
46
|
+
/** SQLite WAL 디스크 영속화 활성화 여부 (기본: false - 순수 인메모리 링 버퍼) */
|
|
47
|
+
readonly persistSqlite?: boolean;
|
|
48
|
+
/** SQLite WAL 파일 커스텀 경로 (미지정 시 vaultDir 내부에 생성) */
|
|
49
|
+
readonly sqlitePath?: string;
|
|
50
|
+
/** SQLite 동기화 수준 */
|
|
51
|
+
readonly syncMode?: "NORMAL" | "FULL" | "OFF";
|
|
52
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { SynapseConnectome } from "../connectome";
|
|
2
|
+
import type { SynapseDocument } from "../types";
|
|
3
|
+
import { type CausalWalConfig, type CompilerTemporalMetric } from "./config";
|
|
4
|
+
import { TemporalRingBuffer, type CausalWalEntry, type RingBufferStats } from "./ringBuffer";
|
|
5
|
+
import { CausalArenaAllocator, type ArenaMutationSlot, type ArenaStats } from "./arena";
|
|
6
|
+
import { SqliteCausalWalStore } from "./sqliteWalStore";
|
|
7
|
+
import { type CausalTimelineDiff } from "./timeTravel";
|
|
8
|
+
export interface CausalWalUnifiedStats {
|
|
9
|
+
readonly ringBuffer: RingBufferStats;
|
|
10
|
+
readonly arena: ArenaStats;
|
|
11
|
+
readonly sqlite: {
|
|
12
|
+
readonly enabled: boolean;
|
|
13
|
+
readonly dbPath: string | null;
|
|
14
|
+
readonly journalMode: string;
|
|
15
|
+
readonly lastFlushedLsn: number;
|
|
16
|
+
readonly persistedCount: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare class CausalWalEngine {
|
|
20
|
+
readonly ringBuffer: TemporalRingBuffer;
|
|
21
|
+
readonly arena: CausalArenaAllocator;
|
|
22
|
+
readonly sqliteStore: SqliteCausalWalStore | null;
|
|
23
|
+
constructor(vaultDir: string, config?: CausalWalConfig);
|
|
24
|
+
/**
|
|
25
|
+
* SQLite WAL 스토어 초기화 및 기존 WAL 로그로부터 크래시 복구 수행
|
|
26
|
+
*/
|
|
27
|
+
initAndRecover(connectome: SynapseConnectome): number;
|
|
28
|
+
/**
|
|
29
|
+
* 이전 문서와 신규 문서 간의 위키링크 시냅스 간선 차분(Added / Removed) 계산
|
|
30
|
+
* Zero-Allocation Fast-Path: 위키링크가 없거나 단일 링크가 동일한 경우 Set/배열 할당 완전 생략
|
|
31
|
+
*/
|
|
32
|
+
static computeEdgeDiff(prevDoc: SynapseDocument | null, nextDoc: SynapseDocument | null): {
|
|
33
|
+
edgesAdded: string[];
|
|
34
|
+
edgesRemoved: string[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 문서 생성/수정 이벤트를 WAL에 기록 (트랜잭션 중이면 아레나에 스테이징, 아니면 즉시 커밋)
|
|
38
|
+
*/
|
|
39
|
+
recordDocumentUpsert(prevDoc: SynapseDocument | null, nextDoc: SynapseDocument, rawMarkdown?: string | null, targetDiskPath?: string | null, timestampMs?: number): CausalWalEntry | null;
|
|
40
|
+
/**
|
|
41
|
+
* 문서 삭제 이벤트를 WAL에 기록
|
|
42
|
+
*/
|
|
43
|
+
recordDocumentDelete(prevDoc: SynapseDocument, targetDiskPath?: string | null, timestampMs?: number): CausalWalEntry | null;
|
|
44
|
+
/**
|
|
45
|
+
* 컴파일러 빌드 지연시간 및 바이너리 크기 시계열 메트릭을 WAL에 기록
|
|
46
|
+
*/
|
|
47
|
+
recordCompilerMetric(metric: CompilerTemporalMetric, timestampMs?: number): CausalWalEntry;
|
|
48
|
+
/**
|
|
49
|
+
* 아레나 기반 원자적 트랜잭션 실행 (예외 발생 시 0ns 롤백, 성공 시 일괄 커밋)
|
|
50
|
+
*/
|
|
51
|
+
executeArenaTransaction<TResult>(fn: () => TResult, onCommitSlot: (slot: ArenaMutationSlot) => void): TResult;
|
|
52
|
+
/**
|
|
53
|
+
* 아레나 기반 비동기 원자적 트랜잭션 실행 (async 콜백 내 save/delete 완벽 지원)
|
|
54
|
+
*/
|
|
55
|
+
executeArenaTransactionAsync<TResult>(fn: () => Promise<TResult> | TResult, onCommitSlot: (slot: ArenaMutationSlot) => void): Promise<TResult>;
|
|
56
|
+
/**
|
|
57
|
+
* 특정 LSN 시점의 시냅스 커넥톰 즉시 복원 (Time-Travel)
|
|
58
|
+
*/
|
|
59
|
+
asOfLsn(connectome: SynapseConnectome, targetLsn: number): SynapseConnectome;
|
|
60
|
+
/**
|
|
61
|
+
* 특정 타임스탬프 시점의 시냅스 커넥톰 즉시 복원 (Time-Travel)
|
|
62
|
+
*/
|
|
63
|
+
asOf(connectome: SynapseConnectome, timestampMsOrIso: number | string): SynapseConnectome;
|
|
64
|
+
/**
|
|
65
|
+
* 두 LSN 시점 간의 인과율 차분(Diff) 조회
|
|
66
|
+
*/
|
|
67
|
+
diffBetweenLsn(fromLsn: number, toLsn: number): CausalTimelineDiff;
|
|
68
|
+
/**
|
|
69
|
+
* 통합 WAL 통계 조회
|
|
70
|
+
*/
|
|
71
|
+
getStats(): CausalWalUnifiedStats;
|
|
72
|
+
/**
|
|
73
|
+
* SQLite WAL 스토어 안전 종료
|
|
74
|
+
*/
|
|
75
|
+
close(): void;
|
|
76
|
+
}
|
|
77
|
+
export * from "./config";
|
|
78
|
+
export * from "./ringBuffer";
|
|
79
|
+
export * from "./arena";
|
|
80
|
+
export * from "./sqliteWalStore";
|
|
81
|
+
export * from "./timeTravel";
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 러스트 메모리 철학 기반 순환 링 버퍼 WAL (Zero-GC Temporal Ring Buffer)
|
|
3
|
+
* - 고정 용량 슬롯 배열 및 TypedArray(Float64Array) 인덱스 사전 할당
|
|
4
|
+
* - 용량 초과 시 가비지 컬렉터(GC) 개입 없이 가장 오래된 슬롯을 O(1)로 덮어쓰기(FIFO Drop)
|
|
5
|
+
* - LSN(Log Sequence Number) 및 타임스탬프 기반 초고속 시계열 탐색 지원
|
|
6
|
+
*/
|
|
7
|
+
import type { SynapseDocument } from "../types";
|
|
8
|
+
import { CausalWalEventType, type CompilerTemporalMetric } from "./config";
|
|
9
|
+
/** 단일 인과율 WAL 로그 엔트리 (구조적 공유를 위한 불변 참조 유지) */
|
|
10
|
+
export interface CausalWalEntry<TData = any> {
|
|
11
|
+
readonly lsn: number;
|
|
12
|
+
readonly timestampMs: number;
|
|
13
|
+
readonly eventType: CausalWalEventType;
|
|
14
|
+
readonly collection: string;
|
|
15
|
+
readonly docId: string;
|
|
16
|
+
/** 변경 전 문서 상태 참조 (Time-Travel 역방향 복원용, 신규 생성 시 null) */
|
|
17
|
+
readonly prevDoc: SynapseDocument<TData> | null;
|
|
18
|
+
/** 변경 후 문서 상태 참조 (삭제 시 null) */
|
|
19
|
+
readonly nextDoc: SynapseDocument<TData> | null;
|
|
20
|
+
/** 이번 이벤트로 새로 연결된 위키링크 시냅스 타겟 노드 목록 */
|
|
21
|
+
readonly edgesAdded: readonly string[];
|
|
22
|
+
/** 이번 이벤트로 단절된 위키링크 시냅스 타겟 노드 목록 */
|
|
23
|
+
readonly edgesRemoved: readonly string[];
|
|
24
|
+
/** 컴파일러 시계열 메트릭 (COMPILER_METRIC 이벤트 전용) */
|
|
25
|
+
readonly compilerMetric?: CompilerTemporalMetric;
|
|
26
|
+
}
|
|
27
|
+
/** 링 버퍼 상태 통계 */
|
|
28
|
+
export interface RingBufferStats {
|
|
29
|
+
readonly capacity: number;
|
|
30
|
+
readonly size: number;
|
|
31
|
+
readonly currentLsn: number;
|
|
32
|
+
readonly oldestLsn: number;
|
|
33
|
+
readonly overwrittenCount: number;
|
|
34
|
+
readonly utilizationRatio: number;
|
|
35
|
+
}
|
|
36
|
+
export declare class TemporalRingBuffer {
|
|
37
|
+
readonly capacity: number;
|
|
38
|
+
private readonly isPowerOfTwo;
|
|
39
|
+
private readonly bitMask;
|
|
40
|
+
private readonly slots;
|
|
41
|
+
private readonly lsnBuffer;
|
|
42
|
+
private readonly tsBuffer;
|
|
43
|
+
private head;
|
|
44
|
+
private tail;
|
|
45
|
+
private count;
|
|
46
|
+
private nextLsn;
|
|
47
|
+
private overwrittenCount;
|
|
48
|
+
constructor(capacity?: number);
|
|
49
|
+
private wrapIndex;
|
|
50
|
+
/**
|
|
51
|
+
* 새로운 WAL 이벤트를 링 버퍼에 O(1)로 기록 (용량 초과 시 자동 FIFO 덮어쓰기)
|
|
52
|
+
*/
|
|
53
|
+
append(entryInput: Omit<CausalWalEntry, "lsn" | "timestampMs"> & {
|
|
54
|
+
timestampMs?: number;
|
|
55
|
+
}): CausalWalEntry;
|
|
56
|
+
/**
|
|
57
|
+
* 외부(SQLite WAL 복구 등)에서 이미 LSN이 부여된 엔트리를 링 버퍼에 적재
|
|
58
|
+
*/
|
|
59
|
+
appendRecovered(entry: CausalWalEntry): void;
|
|
60
|
+
private writeRawEntry;
|
|
61
|
+
/**
|
|
62
|
+
* LSN 번호로 O(1) 직접 슬롯 계산 조회
|
|
63
|
+
*/
|
|
64
|
+
getByLsn(targetLsn: number): CausalWalEntry | null;
|
|
65
|
+
/**
|
|
66
|
+
* 최신 엔트리부터 역순(최신 ➔ 과거)으로 순회하며 콜백 실행 (Time-Travel 역방향 리플레이 전용)
|
|
67
|
+
* 콜백이 false를 반환하면 즉시 순회 중단
|
|
68
|
+
*/
|
|
69
|
+
forEachReverse(visitor: (entry: CausalWalEntry) => boolean | void): void;
|
|
70
|
+
/**
|
|
71
|
+
* 오래된 엔트리부터 시간순(과거 ➔ 최신)으로 전체 엔트리 배열 반환
|
|
72
|
+
*/
|
|
73
|
+
toArray(): CausalWalEntry[];
|
|
74
|
+
/**
|
|
75
|
+
* 특정 LSN 이후의 엔트리들만 시간순 반환 (증분 SQLite 플러시 및 Diff 계산용)
|
|
76
|
+
*/
|
|
77
|
+
getEntriesSinceLsn(afterLsn: number): CausalWalEntry[];
|
|
78
|
+
/**
|
|
79
|
+
* 현재 최신 LSN 번호 반환 (기록된 엔트리가 없으면 0)
|
|
80
|
+
*/
|
|
81
|
+
getCurrentLsn(): number;
|
|
82
|
+
/**
|
|
83
|
+
* 링 버퍼에 남아 있는 가장 오래된 LSN 번호 반환
|
|
84
|
+
*/
|
|
85
|
+
getOldestLsn(): number;
|
|
86
|
+
/**
|
|
87
|
+
* 링 버퍼 실시간 통계 반환
|
|
88
|
+
*/
|
|
89
|
+
getStats(): RingBufferStats;
|
|
90
|
+
/**
|
|
91
|
+
* 링 버퍼 전체 슬롯 O(1) 리셋
|
|
92
|
+
*/
|
|
93
|
+
clear(): void;
|
|
94
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CausalWalEntry } from "./ringBuffer";
|
|
2
|
+
export declare class SqliteCausalWalStore {
|
|
3
|
+
private readonly syncMode;
|
|
4
|
+
readonly dbPath: string;
|
|
5
|
+
private sqlite;
|
|
6
|
+
private insertStmt;
|
|
7
|
+
private batchTx;
|
|
8
|
+
private lastFlushedLsn;
|
|
9
|
+
constructor(dbPath: string, syncMode?: "NORMAL" | "FULL" | "OFF");
|
|
10
|
+
/**
|
|
11
|
+
* SQLite 데이터베이스 초기화 및 WAL / mmap PRAGMA 활성화
|
|
12
|
+
*/
|
|
13
|
+
init(): void;
|
|
14
|
+
/**
|
|
15
|
+
* WAL 엔트리 배치를 사전 컴파일된 단일 원자적 트랜잭션으로 SQLite WAL에 영속화
|
|
16
|
+
*/
|
|
17
|
+
flushEntries(entries: readonly CausalWalEntry[]): number;
|
|
18
|
+
/**
|
|
19
|
+
* 디스크에 영속화된 전체 WAL 엔트리 로드 (크래시 복구 및 링 버퍼 재구성용)
|
|
20
|
+
*/
|
|
21
|
+
loadAllEntries(): CausalWalEntry[];
|
|
22
|
+
/**
|
|
23
|
+
* 현재 활성화된 journal_mode 조회 (WAL 검증용)
|
|
24
|
+
*/
|
|
25
|
+
getJournalMode(): string;
|
|
26
|
+
/**
|
|
27
|
+
* 마지막으로 디스크에 플러시된 LSN 번호
|
|
28
|
+
*/
|
|
29
|
+
getLastFlushedLsn(): number;
|
|
30
|
+
/**
|
|
31
|
+
* 저장된 총 WAL 레코드 수
|
|
32
|
+
*/
|
|
33
|
+
getPersistedCount(): number;
|
|
34
|
+
/**
|
|
35
|
+
* WAL 체크포인트 강제 실행 및 파일 핸들 안전 해제 (Windows EBUSY 잠금 방지)
|
|
36
|
+
*/
|
|
37
|
+
close(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 무손실 시계열 시간 여행 및 역방향 델타 리플레이 엔진 (Causal Time-Travel Engine)
|
|
3
|
+
* - 구조적 공유(Structural Sharing): 변경되지 않은 문서 객체는 복제 없이 불변 참조 공유
|
|
4
|
+
* - 역방향 델타 리플레이(Reverse Delta Replay): 최신 상태에서 목표 시점(LSN/Timestamp)까지 역순 복원
|
|
5
|
+
* - 복원된 시점의 위키링크 커넥톰 그래프 및 BM25 전문 검색 색인을 완벽 재구성
|
|
6
|
+
*/
|
|
7
|
+
import { SynapseConnectome } from "../connectome";
|
|
8
|
+
import { type CompilerTemporalMetric } from "./config";
|
|
9
|
+
import type { TemporalRingBuffer } from "./ringBuffer";
|
|
10
|
+
/** 두 시점(LSN) 간의 인과율 변경 차분 요약 */
|
|
11
|
+
export interface CausalTimelineDiff {
|
|
12
|
+
readonly fromLsn: number;
|
|
13
|
+
readonly toLsn: number;
|
|
14
|
+
readonly addedDocuments: readonly string[];
|
|
15
|
+
readonly modifiedDocuments: readonly string[];
|
|
16
|
+
readonly deletedDocuments: readonly string[];
|
|
17
|
+
readonly edgesLinked: readonly string[];
|
|
18
|
+
readonly edgesUnlinked: readonly string[];
|
|
19
|
+
readonly compilerMetrics: readonly CompilerTemporalMetric[];
|
|
20
|
+
}
|
|
21
|
+
export declare class CausalTimeTravelEngine {
|
|
22
|
+
/**
|
|
23
|
+
* 특정 LSN(Log Sequence Number) 시점의 전체 시냅스 커넥톰을 즉시 복원
|
|
24
|
+
*/
|
|
25
|
+
static asOfLsn(currentConnectome: SynapseConnectome, ringBuffer: TemporalRingBuffer, targetLsn: number): SynapseConnectome;
|
|
26
|
+
/**
|
|
27
|
+
* 특정 타임스탬프(밀리초 숫자 또는 ISO 문자열) 시점의 시냅스 커넥톰 복원
|
|
28
|
+
*/
|
|
29
|
+
static asOf(currentConnectome: SynapseConnectome, ringBuffer: TemporalRingBuffer, timestampMsOrIso: number | string): SynapseConnectome;
|
|
30
|
+
/**
|
|
31
|
+
* 두 LSN 시점 사이의 문서 생성·수정·삭제 및 위키링크 시냅스 변화량 정밀 비교
|
|
32
|
+
*/
|
|
33
|
+
static diffBetweenLsn(ringBuffer: TemporalRingBuffer, fromLsn: number, toLsn: number): CausalTimelineDiff;
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "synapse-db",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Universal Markdown-First & In-Memory Connectome Database with
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Universal Markdown-First & In-Memory Connectome Database with Causal-WAL Time-Travel, Zero-GC Ring Buffer, Bump Arena & Obsidian Canvas Exporter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|