@deepseek-ai/dsh-session-query-sqlite 0.1.2-alpha.3 → 0.1.2-alpha.4
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.i18n.yaml +2 -2
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/lib/index.js +13 -10
- package/package.json +9 -16
- package/lib/invariant.js +0 -23
- package/lib/types/invariant.d.ts +0 -16
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/session-query/session-query-sqlite/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 1db3999186beebc10a6a3c6874122fa65f2787a3
|
|
6
|
+
README.zh.md: f6ef419293ab0df3a3edfd171cc60bc62ee4bcb0
|
package/README.md
CHANGED
|
@@ -97,11 +97,11 @@ The design history lives in the [SQLite FTS5 session search note](../../../.agen
|
|
|
97
97
|
| [`src/index.ts`](src/index.ts) | Service: config, openAt lifecycle, serialized reconciliation, query execution, cursors |
|
|
98
98
|
| [`src/query.ts`](src/query.ts) | Request normalization, parameterized predicates, snippets, predicate and binding budgets |
|
|
99
99
|
| [`src/schema.ts`](src/schema.ts) | Database schema, application-id ownership, in-place reset, owner-only file creation |
|
|
100
|
-
|
|
|
100
|
+
| — | No runtime invariant companion is published; reconciliation, cursor generations, and derived-index ownership are validated at each serialized query boundary. |
|
|
101
101
|
|
|
102
102
|
### Index lifecycle
|
|
103
103
|
|
|
104
|
-
Persisted FTS rows live in a dedicated derived database and survive restarts; live sessions use connection-local TEMP tables that shadow the durable base for the same session and reveal it again when the live owner detaches. Each search runs one serialized observation: list persistence snapshots, compare per-session revisions with the indexed rows, inspect only new or changed logs, extract semantic documents, and commit the reconciliation in one transaction before running the query. Repeated queries and unchanged reopens inspect nothing; switching stores or observing new, changed, deleted, or externally repaired sources reconciles on the next stable observation. Source or transaction failure commits nothing and the next search retries.
|
|
104
|
+
Persisted FTS rows live in a dedicated derived database and survive restarts; live sessions use connection-local TEMP tables that shadow the durable base for the same session and reveal it again when the live owner detaches. Both tables retain the exact inherited cut in numeric `seed_length`; reconstructed headers expose only `isSeeded`, while the cut participates in live fingerprints and persisted source revisions. Each search runs one serialized observation: list persistence snapshots, compare per-session revisions with the indexed rows, inspect only new or changed logs, extract semantic documents, and commit the reconciliation in one transaction before running the query. Repeated queries and unchanged reopens inspect nothing; switching stores or observing new, changed, deleted, or externally repaired sources reconciles on the next stable observation. Source or transaction failure commits nothing and the next search retries.
|
|
105
105
|
|
|
106
106
|
### Schema ownership
|
|
107
107
|
|
package/README.zh.md
CHANGED
|
@@ -97,11 +97,11 @@ kind: "package-reference"
|
|
|
97
97
|
| [`src/index.ts`](src/index.ts) | 服务:配置、openAt 生命周期、串行化对账、查询执行、游标 |
|
|
98
98
|
| [`src/query.ts`](src/query.ts) | 请求规范化、参数化谓词、摘录、谓词与绑定预算 |
|
|
99
99
|
| [`src/schema.ts`](src/schema.ts) | 数据库 schema、application id 归属、原地重置、仅所有者文件创建 |
|
|
100
|
-
|
|
|
100
|
+
| — | 不发布运行时不变式伴生入口;边界在每次串行化查询时校验。 |
|
|
101
101
|
|
|
102
102
|
### 索引生命周期
|
|
103
103
|
|
|
104
|
-
持久化 FTS 行存放在专用派生数据库中并跨重启保留;实时会话使用连接本地 TEMP
|
|
104
|
+
持久化 FTS 行存放在专用派生数据库中并跨重启保留;实时会话使用连接本地 TEMP 表,遮蔽同一会话的持久化基库,并在实时所有者脱离后再次显示基库。两类表都在数字 `seed_length` 中保留精确继承切点;重建的 header 只公开 `isSeeded`,而切点参与实时 fingerprint 与持久来源修订。每次搜索执行一次串行化观察:列出持久化快照、把逐会话修订与已索引行比较、只检查新增或已更改日志、提取语义文档,并在运行查询前于一个事务中提交对账。重复查询与不变的重新打开不会检查任何内容;切换存储或观察到新增、已更改、已删除或经外部修复的来源时,会在下次稳定观察时对账。来源或事务失败不提交任何内容,下一次搜索重试。
|
|
105
105
|
|
|
106
106
|
### Schema 归属
|
|
107
107
|
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { Service } from "@deepseek-ai/cordis";
|
|
3
3
|
import z from "@deepseek-ai/schemastery";
|
|
4
|
+
import { SessionSeq } from "@deepseek-ai/dsh-session";
|
|
4
5
|
import SessionQueryEngine, { SESSION_QUERY_DEFAULT_PERSISTED_INSPECT_CONCURRENCY, SESSION_QUERY_READ_WINDOW_MAX, SessionQueryError, SessionSearchCursor, assertSessionHeadersCompatible, buildSessionEventSearchDocuments, materializeSessionEventResultFilters, materializeSessionResultFilters } from "@deepseek-ai/dsh-session-query";
|
|
5
6
|
import { mkdir, open } from "node:fs/promises";
|
|
6
7
|
import { dirname, resolve } from "node:path";
|
|
@@ -721,7 +722,7 @@ var SqliteSessionQueryEngine = class extends SessionQueryEngine {
|
|
|
721
722
|
const loaded = await persistence.inspect(entry.header.id, signal);
|
|
722
723
|
assertNotAborted(signal);
|
|
723
724
|
assertSessionHeadersCompatible(entry.header, loaded.meta);
|
|
724
|
-
entry.loaded = observeSession(loaded.meta, loaded.events);
|
|
725
|
+
entry.loaded = observeSession(loaded.meta, loaded.inheritedEventCount, loaded.events);
|
|
725
726
|
}
|
|
726
727
|
assertNotAborted(signal);
|
|
727
728
|
const afterSnapshots = await persistence.listSnapshots(signal);
|
|
@@ -771,7 +772,7 @@ var SqliteSessionQueryEngine = class extends SessionQueryEngine {
|
|
|
771
772
|
INSERT INTO persisted_sessions
|
|
772
773
|
(id, version, created_at, cwd, parent_session, seed_length, delegation_depth, agent_preset, revision, generation)
|
|
773
774
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
774
|
-
`).run(...headerBindings(entry.header), revision, generation);
|
|
775
|
+
`).run(...headerBindings(entry.header, entry.inheritedEventCount), revision, generation);
|
|
775
776
|
const insert = db.prepare(`
|
|
776
777
|
INSERT INTO persisted_docs (text, session_id, seq, type, time, surface, codepoint_length)
|
|
777
778
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
@@ -788,7 +789,7 @@ var SqliteSessionQueryEngine = class extends SessionQueryEngine {
|
|
|
788
789
|
INSERT INTO temp.live_sessions
|
|
789
790
|
(id, version, created_at, cwd, parent_session, seed_length, delegation_depth, agent_preset, fingerprint, persisted, generation)
|
|
790
791
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
791
|
-
`).run(...headerBindings(entry.header), entry.fingerprint, persisted ? 1 : 0, generation);
|
|
792
|
+
`).run(...headerBindings(entry.header, entry.inheritedEventCount), entry.fingerprint, persisted ? 1 : 0, generation);
|
|
792
793
|
const insert = db.prepare(`
|
|
793
794
|
INSERT INTO temp.live_docs (text, session_id, seq, type, time, surface, codepoint_length)
|
|
794
795
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
@@ -884,7 +885,7 @@ var SqliteSessionQueryEngine = class extends SessionQueryEngine {
|
|
|
884
885
|
_eventHit(row) {
|
|
885
886
|
return {
|
|
886
887
|
sessionId: row.session_id,
|
|
887
|
-
seq: row.seq,
|
|
888
|
+
seq: SessionSeq(row.seq),
|
|
888
889
|
type: row.type,
|
|
889
890
|
time: row.time,
|
|
890
891
|
surface: row.surface,
|
|
@@ -906,14 +907,14 @@ var SqliteSessionQueryEngine = class extends SessionQueryEngine {
|
|
|
906
907
|
* @param header - the session header being written.
|
|
907
908
|
* @returns one bound value per header column.
|
|
908
909
|
*/
|
|
909
|
-
function headerBindings(header) {
|
|
910
|
+
function headerBindings(header, inheritedEventCount) {
|
|
910
911
|
return [
|
|
911
912
|
header.id,
|
|
912
913
|
header.version,
|
|
913
914
|
header.createdAt,
|
|
914
915
|
header.cwd ?? null,
|
|
915
916
|
header.parentSession ?? null,
|
|
916
|
-
header.
|
|
917
|
+
header.isSeeded ? inheritedEventCount : null,
|
|
917
918
|
header.delegationDepth ?? null,
|
|
918
919
|
header.agentPreset ?? null
|
|
919
920
|
];
|
|
@@ -989,16 +990,18 @@ function selectedDocumentsParams(query, persistenceVisible) {
|
|
|
989
990
|
];
|
|
990
991
|
}
|
|
991
992
|
function observeLive(session) {
|
|
992
|
-
return observeSession(session.header, session.
|
|
993
|
+
return observeSession(session.header, session.inheritedEventCount, session.snapshotEvents());
|
|
993
994
|
}
|
|
994
|
-
function observeSession(header, events) {
|
|
995
|
+
function observeSession(header, inheritedEventCount, events) {
|
|
995
996
|
const detachedHeader = structuredClone(header);
|
|
996
997
|
const detachedEvents = events.map((event) => structuredClone(event));
|
|
997
998
|
return {
|
|
998
999
|
header: detachedHeader,
|
|
1000
|
+
inheritedEventCount,
|
|
999
1001
|
documents: buildSessionEventSearchDocuments(detachedHeader.id, detachedEvents),
|
|
1000
1002
|
fingerprint: createHash("sha256").update(JSON.stringify({
|
|
1001
1003
|
header: detachedHeader,
|
|
1004
|
+
inheritedEventCount,
|
|
1002
1005
|
events: detachedEvents
|
|
1003
1006
|
})).digest("base64url")
|
|
1004
1007
|
};
|
|
@@ -1031,7 +1034,7 @@ function sameSessionIds(before, after) {
|
|
|
1031
1034
|
return true;
|
|
1032
1035
|
}
|
|
1033
1036
|
function sameHeader(a, b) {
|
|
1034
|
-
return a.version === b.version && a.id === b.id && a.createdAt === b.createdAt && a.cwd === b.cwd && a.parentSession === b.parentSession && a.
|
|
1037
|
+
return a.version === b.version && a.id === b.id && a.createdAt === b.createdAt && a.cwd === b.cwd && a.parentSession === b.parentSession && a.isSeeded === b.isSeeded && (a.delegationDepth ?? 0) === (b.delegationDepth ?? 0) && a.agentPreset === b.agentPreset;
|
|
1035
1038
|
}
|
|
1036
1039
|
function rowHeader(row) {
|
|
1037
1040
|
return {
|
|
@@ -1040,7 +1043,7 @@ function rowHeader(row) {
|
|
|
1040
1043
|
createdAt: row.created_at,
|
|
1041
1044
|
...row.cwd === null ? {} : { cwd: row.cwd },
|
|
1042
1045
|
...row.parent_session === null ? {} : { parentSession: row.parent_session },
|
|
1043
|
-
|
|
1046
|
+
isSeeded: row.seed_length !== null,
|
|
1044
1047
|
...row.delegation_depth === null ? {} : { delegationDepth: row.delegation_depth },
|
|
1045
1048
|
...row.agent_preset === null ? {} : { agentPreset: row.agent_preset }
|
|
1046
1049
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-session-query-sqlite",
|
|
3
3
|
"description": "Concrete ctx.sessionQuery backend with SQLite FTS5 search",
|
|
4
|
-
"version": "0.1.2-alpha.
|
|
4
|
+
"version": "0.1.2-alpha.4",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -18,24 +18,18 @@
|
|
|
18
18
|
"types": "./lib/types/index.d.ts",
|
|
19
19
|
"default": "./lib/index.js"
|
|
20
20
|
},
|
|
21
|
-
"./invariant": {
|
|
22
|
-
"types": "./lib/types/invariant.d.ts",
|
|
23
|
-
"default": "./lib/invariant.js"
|
|
24
|
-
},
|
|
25
21
|
"./src/*": "./src/*",
|
|
26
22
|
"./package.json": "./package.json"
|
|
27
23
|
},
|
|
28
24
|
"files": [
|
|
29
25
|
"lib/index.js",
|
|
30
|
-
"lib/invariant.js",
|
|
31
26
|
"lib/types/**/*.d.ts"
|
|
32
27
|
],
|
|
33
28
|
"license": "MIT",
|
|
34
29
|
"peerDependencies": {
|
|
35
|
-
"@deepseek-ai/dsh-
|
|
36
|
-
"@deepseek-ai/dsh-session": "^0.1.2-alpha.
|
|
37
|
-
"@deepseek-ai/dsh-session-persistence": "^0.1.2-alpha.
|
|
38
|
-
"@deepseek-ai/dsh-session-query": "^0.1.2-alpha.3",
|
|
30
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.4",
|
|
31
|
+
"@deepseek-ai/dsh-session-query": "^0.1.2-alpha.4",
|
|
32
|
+
"@deepseek-ai/dsh-session-persistence": "^0.1.2-alpha.4",
|
|
39
33
|
"@deepseek-ai/cordis": "^4.0.2"
|
|
40
34
|
},
|
|
41
35
|
"peerDependenciesMeta": {
|
|
@@ -48,12 +42,11 @@
|
|
|
48
42
|
},
|
|
49
43
|
"devDependencies": {
|
|
50
44
|
"@deepseek-ai/cordis-plugin-loader": "^1.0.3",
|
|
51
|
-
"@deepseek-ai/dsh-
|
|
52
|
-
"@deepseek-ai/dsh-session": "^0.1.2-alpha.
|
|
53
|
-
"@deepseek-ai/dsh-session-persistence": "^0.1.2-alpha.
|
|
54
|
-
"@deepseek-ai/dsh-session-
|
|
55
|
-
"@deepseek-ai/dsh-session-query": "^0.1.2-alpha.3",
|
|
45
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.4",
|
|
46
|
+
"@deepseek-ai/dsh-session-persistence": "^0.1.2-alpha.4",
|
|
47
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "^0.1.2-alpha.4",
|
|
48
|
+
"@deepseek-ai/dsh-session-query": "^0.1.2-alpha.4",
|
|
56
49
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
57
|
-
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.
|
|
50
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.4"
|
|
58
51
|
}
|
|
59
52
|
}
|
package/lib/invariant.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region lib/types/invariant.js
|
|
2
|
-
/**
|
|
3
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-session-query-sqlite`.
|
|
4
|
-
* @module @deepseek-ai/dsh-session-query-sqlite/invariant
|
|
5
|
-
*/
|
|
6
|
-
const PACKAGE_NAME = "@deepseek-ai/dsh-session-query-sqlite";
|
|
7
|
-
/** Cordis companion plugin name. */
|
|
8
|
-
const name = "session-query-sqlite-invariant";
|
|
9
|
-
/** Service required before the companion can reserve package ownership. */
|
|
10
|
-
const inject = ["invariants"];
|
|
11
|
-
/**
|
|
12
|
-
* No runtime invariant: reconciliation, cursor generations, and derived-index
|
|
13
|
-
* ownership are validated at each serialized query boundary.
|
|
14
|
-
*/
|
|
15
|
-
const install = () => {};
|
|
16
|
-
/**
|
|
17
|
-
* Register this package's invariant companion.
|
|
18
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
19
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
20
|
-
*/
|
|
21
|
-
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
22
|
-
//#endregion
|
|
23
|
-
export { apply, inject, name };
|
package/lib/types/invariant.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-session-query-sqlite`.
|
|
3
|
-
* @module @deepseek-ai/dsh-session-query-sqlite/invariant
|
|
4
|
-
*/
|
|
5
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
-
/** Cordis companion plugin name. */
|
|
7
|
-
export declare const name = "session-query-sqlite-invariant";
|
|
8
|
-
/** Service required before the companion can reserve package ownership. */
|
|
9
|
-
export declare const inject: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Register this package's invariant companion.
|
|
12
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
-
*/
|
|
15
|
-
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
-
//# sourceMappingURL=invariant.d.ts.map
|