feat(memory): release Mnemo project bridge and schema2 recovery
Official contracts and Windows source CI / windows-source (push) Has been cancelled
Official contracts and Windows source CI / windows-source (push) Has been cancelled
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { randomUUID, createHash } from 'node:crypto';
|
||||
import { DatabaseSync } from 'node:sqlite';
|
||||
import { REQUEST_LEDGER_SQL } from '../storage/request-ledger-schema.mjs';
|
||||
|
||||
const metadataKey = 'modelAttemptLedger';
|
||||
const sha = value => createHash('sha256').update(value).digest('hex');
|
||||
@@ -47,15 +48,7 @@ export class ModelRequestLedger {
|
||||
this.state = { schemaVersion: 1, id: randomUUID(), legacyEntries: entries.length, legacyMetadataSha256: original ? sha(original) : null,
|
||||
originalMetadataPreserved: true, migratedAt: new Date().toISOString() };
|
||||
storage.transaction(() => {
|
||||
this.database.exec(`CREATE TABLE IF NOT EXISTS model_attempts (
|
||||
seq INTEGER PRIMARY KEY AUTOINCREMENT, id TEXT NOT NULL, connection_id TEXT, session_id TEXT, task_id TEXT, run_id TEXT,
|
||||
status TEXT, model TEXT, protocol TEXT, legacy_position INTEGER UNIQUE,
|
||||
payload TEXT NOT NULL CHECK(json_valid(payload)), payload_sha256 TEXT NOT NULL,
|
||||
initial_payload TEXT NOT NULL CHECK(json_valid(initial_payload)), initial_sha256 TEXT NOT NULL);
|
||||
CREATE INDEX IF NOT EXISTS model_attempts_id ON model_attempts(id);
|
||||
CREATE INDEX IF NOT EXISTS model_attempts_connection ON model_attempts(connection_id,seq);
|
||||
CREATE INDEX IF NOT EXISTS model_attempts_session ON model_attempts(session_id,task_id,run_id,seq);
|
||||
CREATE INDEX IF NOT EXISTS model_attempts_status ON model_attempts(status,seq);`);
|
||||
this.database.exec(REQUEST_LEDGER_SQL);
|
||||
for (const [index, entry] of entries.entries()) this.insert(entry, JSON.stringify(entry), index);
|
||||
storage.setMeta(metadataKey, this.state);
|
||||
this.database.exec('PRAGMA user_version=2');
|
||||
|
||||
Reference in New Issue
Block a user