@devflow-tools/database 0.18.56 → 0.18.58
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/database.js +52 -0
- package/package.json +2 -2
package/dist/database.js
CHANGED
|
@@ -1131,6 +1131,58 @@ class DevFlowDatabase {
|
|
|
1131
1131
|
}
|
|
1132
1132
|
}
|
|
1133
1133
|
catch { }
|
|
1134
|
+
// Retrieval plans are immutable per session, but host supplied expansion
|
|
1135
|
+
// terms can create a second auditable plan for the same task revision.
|
|
1136
|
+
// Older databases keyed this table only by task identity and rejected that
|
|
1137
|
+
// valid replay. Rebuild the table once with plan_hash in the uniqueness
|
|
1138
|
+
// boundary; all existing rows retain their identifiers and receipts.
|
|
1139
|
+
try {
|
|
1140
|
+
const indexes = this.db.prepare('PRAGMA index_list(devflow_retrieval_sessions_v2)').all();
|
|
1141
|
+
const legacyUnique = indexes.find(index => {
|
|
1142
|
+
if (index.unique !== 1)
|
|
1143
|
+
return false;
|
|
1144
|
+
const columns = this.db.prepare(`PRAGMA index_info(${JSON.stringify(index.name)})`).all();
|
|
1145
|
+
return columns.map(column => column.name).join(',')
|
|
1146
|
+
=== 'project_root,task_session_id,turn_id,task_revision,coordinator_version';
|
|
1147
|
+
});
|
|
1148
|
+
if (legacyUnique) {
|
|
1149
|
+
this.db.exec('ALTER TABLE devflow_retrieval_sessions_v2 RENAME TO devflow_retrieval_sessions_v2_legacy');
|
|
1150
|
+
this.db.exec(`
|
|
1151
|
+
CREATE TABLE devflow_retrieval_sessions_v2 (
|
|
1152
|
+
id TEXT PRIMARY KEY,
|
|
1153
|
+
project_root TEXT NOT NULL,
|
|
1154
|
+
project_id TEXT NOT NULL,
|
|
1155
|
+
host_id TEXT NOT NULL,
|
|
1156
|
+
task_session_id TEXT NOT NULL,
|
|
1157
|
+
turn_id TEXT NOT NULL,
|
|
1158
|
+
request_id TEXT NOT NULL,
|
|
1159
|
+
execution_id TEXT,
|
|
1160
|
+
task_revision INTEGER NOT NULL CHECK(task_revision > 0),
|
|
1161
|
+
facts_hash TEXT NOT NULL,
|
|
1162
|
+
plan_hash TEXT NOT NULL,
|
|
1163
|
+
activation_snapshot_hash TEXT NOT NULL,
|
|
1164
|
+
coordinator_version TEXT NOT NULL,
|
|
1165
|
+
state TEXT NOT NULL CHECK(state IN ('open','sufficient','gap_actionable','gap_unavailable','abstain')),
|
|
1166
|
+
cycle INTEGER NOT NULL DEFAULT 0 CHECK(cycle BETWEEN 0 AND 3),
|
|
1167
|
+
no_gain_count INTEGER NOT NULL DEFAULT 0 CHECK(no_gain_count BETWEEN 0 AND 2),
|
|
1168
|
+
max_cycles INTEGER NOT NULL DEFAULT 3 CHECK(max_cycles = 3),
|
|
1169
|
+
initial_token_budget INTEGER NOT NULL CHECK(initial_token_budget >= 0),
|
|
1170
|
+
remaining_token_budget INTEGER NOT NULL CHECK(remaining_token_budget >= 0),
|
|
1171
|
+
final_receipt_hash TEXT,
|
|
1172
|
+
created_at INTEGER NOT NULL,
|
|
1173
|
+
updated_at INTEGER NOT NULL,
|
|
1174
|
+
expires_at INTEGER NOT NULL,
|
|
1175
|
+
UNIQUE(project_root, task_session_id, turn_id, task_revision, coordinator_version, plan_hash)
|
|
1176
|
+
);
|
|
1177
|
+
INSERT INTO devflow_retrieval_sessions_v2
|
|
1178
|
+
SELECT * FROM devflow_retrieval_sessions_v2_legacy;
|
|
1179
|
+
DROP TABLE devflow_retrieval_sessions_v2_legacy;
|
|
1180
|
+
CREATE INDEX IF NOT EXISTS idx_retrieval_sessions_v2_owner
|
|
1181
|
+
ON devflow_retrieval_sessions_v2(project_root, task_session_id, state, updated_at);
|
|
1182
|
+
`);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
catch { }
|
|
1134
1186
|
// Migration: add session_id to skill_executions (SQLite compat — ignore if exists)
|
|
1135
1187
|
try {
|
|
1136
1188
|
this.db.exec('ALTER TABLE skill_executions ADD COLUMN session_id TEXT REFERENCES sessions(id)');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devflow-tools/database",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.58",
|
|
4
4
|
"description": "SQLite persistence primitives shared by DevFlow runtime packages.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"test": "vitest run"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@devflow-tools/sdk": "0.18.
|
|
15
|
+
"@devflow-tools/sdk": "0.18.58"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "^22.15.0",
|