@morlay/session-rdb 0.0.15 → 0.0.16-alpha.0
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/README.md +11 -13
- package/dist/artifact.d.mts +6 -16
- package/dist/artifact.mjs +3 -3
- package/dist/{import-DFed8DBt.mjs → import-CKrzjXVB.mjs} +73 -83
- package/dist/import.d.mts +2 -3
- package/dist/import.mjs +2 -2
- package/dist/index-CgGDHQSK.d.mts +225 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +694 -169
- package/dist/log-DTJsxMud.mjs +314 -0
- package/dist/{schema-CFXZURX7.d.mts → schema-COK7-wRV.d.mts} +3 -15
- package/dist/sqlite-DCy4VTD8.mjs +698 -0
- package/dist/storage.d.mts +2 -7
- package/dist/storage.mjs +2 -3
- package/dist/testing.d.mts +30 -1
- package/dist/testing.mjs +676 -1991
- package/drizzle/postgres/20260908072805_v2_initial/migration.sql +58 -0
- package/drizzle/postgres/20260908072805_v2_initial/snapshot.json +686 -0
- package/drizzle/postgres/20260908072806_v3_drop_original_seq/migration.sql +1 -0
- package/drizzle/postgres/20260908072806_v3_drop_original_seq/snapshot.json +673 -0
- package/drizzle/sqlite/20260908072751_v2_initial/migration.sql +53 -0
- package/drizzle/sqlite/20260908072751_v2_initial/snapshot.json +492 -0
- package/drizzle/sqlite/20260908072752_v3_drop_original_seq/migration.sql +6 -0
- package/drizzle/sqlite/20260908072752_v3_drop_original_seq/snapshot.json +513 -0
- package/package.json +17 -12
- package/src/adapters/index.ts +10 -2
- package/src/adapters/to-postgres.ts +19 -15
- package/src/adapters/to-sqlite.ts +20 -14
- package/src/{entities → adapters}/types.ts +7 -8
- package/src/backend.ts +0 -7
- package/src/branch.ts +29 -110
- package/src/drizzle/postgres-v2.ts +11 -0
- package/src/drizzle/postgres-v3.ts +11 -0
- package/src/drizzle/sqlite-v2.ts +10 -0
- package/src/drizzle/sqlite-v3.ts +11 -0
- package/src/entities/index.ts +2 -30
- package/src/entities/v2/index.ts +20 -0
- package/src/entities/v2/session-events.ts +11 -0
- package/src/entities/v3/events.ts +27 -0
- package/src/entities/v3/index.ts +27 -0
- package/src/entities/v3/persistence-state.ts +10 -0
- package/src/entities/v3/schema-meta.ts +9 -0
- package/src/entities/v3/session-events.ts +26 -0
- package/src/entities/v3/sessions.ts +20 -0
- package/src/import.ts +65 -57
- package/src/index.ts +868 -223
- package/src/invariant.ts +0 -2
- package/src/legacy.ts +67 -0
- package/src/log.ts +41 -87
- package/src/postgres.ts +75 -93
- package/src/schema.ts +3 -14
- package/src/sqlite.ts +59 -46
- package/src/testing/contract.ts +460 -375
- package/src/testing/coordinator-contract.ts +108 -1374
- package/src/testing.ts +1 -6
- package/dist/index-uUvn6gYp.d.mts +0 -111
- package/dist/schema-vwzwEXNE.mjs +0 -878
- package/dist/sqlite-CG_Qcx5C.mjs +0 -356
- package/src/adapters/ddl.ts +0 -77
- package/src/entities/events.ts +0 -27
- package/src/entities/persistence-state.ts +0 -10
- package/src/entities/schema-meta.ts +0 -9
- package/src/entities/session-events.ts +0 -29
- package/src/entities/sessions.ts +0 -20
- package/src/migrate.ts +0 -137
package/dist/storage.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as BackendTx, a as JournalMode, c as eventDimensions, d as tPersistenceState, f as tSchemaMeta, g as Backend, h as WriteGuard, i as EventRole, l as eventKind, m as tSessions, n as EVENT_ENCODING, o as SCHEMA_VERSION, p as tSessionEvents, r as EventKind, s as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, t as DEFAULT_BUSY_TIMEOUT_MS, u as tEvents, v as EventRow, y as SessionRow } from "./schema-COK7-wRV.mjs";
|
|
2
2
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
3
3
|
import { DatabaseSync } from "node:sqlite";
|
|
4
4
|
//#region src/sqlite.d.ts
|
|
@@ -18,10 +18,6 @@ declare class SqliteBackend implements Backend {
|
|
|
18
18
|
open(): Promise<void>;
|
|
19
19
|
close(): Promise<void>;
|
|
20
20
|
getSession(id: SessionId): Promise<SessionRow | undefined>;
|
|
21
|
-
getSeqMapRows(id: SessionId): Promise<Array<{
|
|
22
|
-
fSequence: number;
|
|
23
|
-
fOriginalSeq: number;
|
|
24
|
-
}>>;
|
|
25
21
|
getEventRows(id: SessionId, fromSequence?: number): Promise<EventRow[]>;
|
|
26
22
|
listSessions(): Promise<SessionRow[]>;
|
|
27
23
|
transaction<T>(fn: (tx: BackendTx) => Promise<T>): Promise<T>;
|
|
@@ -37,8 +33,7 @@ declare class SqliteBackend implements Backend {
|
|
|
37
33
|
private bumpRevision;
|
|
38
34
|
private deleteBridgeTail;
|
|
39
35
|
private getPrevBridge;
|
|
40
|
-
private getLastBridge;
|
|
41
36
|
private eventRows;
|
|
42
37
|
}
|
|
43
38
|
//#endregion
|
|
44
|
-
export { DEFAULT_BUSY_TIMEOUT_MS,
|
|
39
|
+
export { DEFAULT_BUSY_TIMEOUT_MS, EVENT_ENCODING, EventKind, EventRole, type EventRow, JournalMode, SCHEMA_VERSION, SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, type SessionRow, SqliteBackend, SqliteBackendOptions, WriteGuard, eventDimensions, eventKind, openDatabase, tEvents, tPersistenceState, tSchemaMeta, tSessionEvents, tSessions };
|
package/dist/storage.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { DEFAULT_BUSY_TIMEOUT_MS, EPHEMERAL_EVENT_TYPES, EVENT_ENCODING, SCHEMA_VERSION, SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, SqliteBackend, WriteGuard, eventDimensions, eventKind, isEphemeralType, isPersistedEvent, openDatabase, tEvents, tPersistenceState, tSessionEvents, tSessions };
|
|
1
|
+
import { a as SCHEMA_VERSION, c as eventKind, d as tSchemaMeta, f as tSessionEvents, g as WriteGuard, i as EVENT_ENCODING, l as tEvents, n as openDatabase, o as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, p as tSessions, r as DEFAULT_BUSY_TIMEOUT_MS, s as eventDimensions, t as SqliteBackend, u as tPersistenceState } from "./sqlite-DCy4VTD8.mjs";
|
|
2
|
+
export { DEFAULT_BUSY_TIMEOUT_MS, EVENT_ENCODING, SCHEMA_VERSION, SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, SqliteBackend, WriteGuard, eventDimensions, eventKind, openDatabase, tEvents, tPersistenceState, tSchemaMeta, tSessionEvents, tSessions };
|
package/dist/testing.d.mts
CHANGED
|
@@ -11,13 +11,37 @@ declare class EmptySettings extends SettingsProvider {
|
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/testing/contract.d.ts
|
|
14
|
-
|
|
14
|
+
/** One backend service instance under test plus its teardown. */
|
|
15
|
+
interface ContractBackendInstance {
|
|
15
16
|
persistence: SessionPersistence;
|
|
16
17
|
dispose: () => Promise<void>;
|
|
17
18
|
}
|
|
19
|
+
/** A backend under test: the primary instance plus optional storage-level capabilities. */
|
|
20
|
+
interface ContractBackend extends ContractBackendInstance {
|
|
21
|
+
/**
|
|
22
|
+
* Open a FRESH backend instance over the SAME storage, as another process
|
|
23
|
+
* would after this one exits. Enables the cross-instance visibility and
|
|
24
|
+
* reopen-continuation tests; a backend without shared storage omits it and
|
|
25
|
+
* those tests self-skip.
|
|
26
|
+
*/
|
|
27
|
+
reopen?: () => Promise<ContractBackendInstance>;
|
|
28
|
+
/**
|
|
29
|
+
* Inject a torn physical tail after the committed log of one stored session,
|
|
30
|
+
* simulating a crash mid-write. Enables the torn-tail tests.
|
|
31
|
+
*/
|
|
32
|
+
corruptTail?: (id: SessionId, cwd: string | undefined) => Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/** Build a minimal {@link SessionHeader} for a session id. */
|
|
18
35
|
declare function meta(id: string, cwd?: string): SessionHeader;
|
|
36
|
+
/** A well-formed one-turn event log (contiguous seqs from 0). */
|
|
19
37
|
declare function oneTurnLog(): SessionEvent[];
|
|
20
38
|
declare function appendLog(session: Session, events: readonly SessionEvent[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Run the backend-agnostic handle contract suite. `make()` MUST return a
|
|
41
|
+
* fresh backend over fresh, empty storage each call.
|
|
42
|
+
* @param name - suite label, e.g. `jsonl-none` / `sqlite`.
|
|
43
|
+
* @param make - factory producing one fresh {@link ContractBackend} per test.
|
|
44
|
+
*/
|
|
21
45
|
declare function runPersistenceContract(name: string, make: () => Promise<ContractBackend>): void;
|
|
22
46
|
//#endregion
|
|
23
47
|
//#region src/testing/coordinator-contract.d.ts
|
|
@@ -26,6 +50,11 @@ interface CoordinatorFixture {
|
|
|
26
50
|
corruptTail?: (id: SessionId, cwd: string | undefined) => Promise<void>;
|
|
27
51
|
cleanup: () => Promise<void>;
|
|
28
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* RDB 特有行为契约:live 会话驱动持久化、seed 边界、fork/resume、HMR
|
|
55
|
+
* dispose drain、冲突拒绝、torn-tail。coordinator 内部状态(ownerless /
|
|
56
|
+
* per-id chain / legacy 迁移)已由新版 handle 模型承担,不再单独测试。
|
|
57
|
+
*/
|
|
29
58
|
declare function runCoordinatorContract(name: string, makeFixture: () => Promise<CoordinatorFixture>): void;
|
|
30
59
|
//#endregion
|
|
31
60
|
export { type ContractBackend, type CoordinatorFixture, EmptySettings, appendLog, meta, oneTurnLog, runCoordinatorContract, runPersistenceContract };
|