principles-disciple 1.155.0 → 1.156.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.
@@ -69,6 +69,8 @@ function applyTrajectorySchema(db) {
69
69
  empathy_signal_json TEXT NOT NULL,
70
70
  blob_ref TEXT,
71
71
  raw_excerpt TEXT,
72
+ stop_reason TEXT,
73
+ thinking_blocks_count INTEGER,
72
74
  created_at TEXT NOT NULL
73
75
  );
74
76
  CREATE TABLE IF NOT EXISTS user_turns (
@@ -95,6 +97,7 @@ function applyTrajectorySchema(db) {
95
97
  gfi_before REAL,
96
98
  gfi_after REAL,
97
99
  params_json TEXT NOT NULL,
100
+ result_preview TEXT,
98
101
  created_at TEXT NOT NULL
99
102
  );
100
103
  CREATE TABLE IF NOT EXISTS pain_events (
@@ -107,6 +110,8 @@ function applyTrajectorySchema(db) {
107
110
  origin TEXT,
108
111
  confidence REAL,
109
112
  text TEXT,
113
+ canonical_pain_id TEXT,
114
+ runtime_task_id TEXT,
110
115
  created_at TEXT NOT NULL
111
116
  );
112
117
  CREATE TABLE IF NOT EXISTS gate_blocks (
@@ -185,6 +190,12 @@ function applyTrajectorySchema(db) {
185
190
  started_at TEXT,
186
191
  completed_at TEXT,
187
192
  resolution TEXT,
193
+ task_kind TEXT,
194
+ priority TEXT,
195
+ retry_count INTEGER,
196
+ max_retries INTEGER,
197
+ last_error TEXT,
198
+ result_ref TEXT,
188
199
  created_at TEXT NOT NULL,
189
200
  updated_at TEXT NOT NULL
190
201
  );
@@ -2,7 +2,7 @@
2
2
  "id": "principles-disciple",
3
3
  "name": "Principles Disciple",
4
4
  "description": "Evolutionary programming agent framework with strategic guardrails and reflection loops.",
5
- "version": "1.155.0",
5
+ "version": "1.156.0",
6
6
  "activation": {
7
7
  "onCapabilities": [
8
8
  "hook"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "1.155.0",
3
+ "version": "1.156.0",
4
4
  "description": "Native OpenClaw plugin for Principles Disciple",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,11 +0,0 @@
1
- /**
2
- * Shared type definitions for database operations.
3
- * Kept separate to avoid circular dependencies between schema-definitions and migration-runner.
4
- */
5
- /** Minimal interface for better-sqlite3 Database instances. */
6
- export interface Db {
7
- exec(_sql: string): unknown;
8
- get<T = unknown>(_sql: string, ..._params: unknown[]): T | undefined;
9
- run(_sql: string, ..._params: unknown[]): unknown;
10
- close(): void;
11
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Shared type definitions for database operations.
3
- * Kept separate to avoid circular dependencies between schema-definitions and migration-runner.
4
- */
5
- export {};
@@ -1,17 +0,0 @@
1
- /**
2
- * Schema Management — Unified database schema definitions and migrations.
3
- *
4
- * Usage:
5
- * // In a database class constructor:
6
- * import { ensureDatabaseSchema } from './schema';
7
- * ensureDatabaseSchema(db, 'trajectory.db');
8
- *
9
- * CLI:
10
- * node scripts/db-migrate.mjs status
11
- * node scripts/db-migrate.mjs run
12
- */
13
- export { MigrationRunner, ensureDatabaseSchema } from './migration-runner.js';
14
- export { SCHEMAS, getCatalog, DB_TYPES } from './schema-definitions.js';
15
- export { ALL_MIGRATIONS } from './migrations/index.js';
16
- export type { Db } from './db-types.js';
17
- export type { Migration, DbType, TableDefinition, ViewDefinition, FtsDefinition, SchemaCatalog, } from './migration-runner.js';
@@ -1,15 +0,0 @@
1
- /**
2
- * Schema Management — Unified database schema definitions and migrations.
3
- *
4
- * Usage:
5
- * // In a database class constructor:
6
- * import { ensureDatabaseSchema } from './schema';
7
- * ensureDatabaseSchema(db, 'trajectory.db');
8
- *
9
- * CLI:
10
- * node scripts/db-migrate.mjs status
11
- * node scripts/db-migrate.mjs run
12
- */
13
- export { MigrationRunner, ensureDatabaseSchema } from './migration-runner.js';
14
- export { SCHEMAS, getCatalog, DB_TYPES } from './schema-definitions.js';
15
- export { ALL_MIGRATIONS } from './migrations/index.js';
@@ -1,53 +0,0 @@
1
- /**
2
- * Migration Runner — Executes and tracks schema migrations.
3
- *
4
- * Each migration is versioned. The runner reads the current version from
5
- * the `schema_version` table and only executes migrations with higher IDs.
6
- *
7
- * Usage:
8
- * const runner = new MigrationRunner(db);
9
- * runner.run(allMigrations.filter(m => m.db === 'trajectory.db'));
10
- */
11
- import type { Migration } from './schema-definitions.js';
12
- import { type DbType } from './schema-definitions.js';
13
- import type { Db } from './db-types.js';
14
- export declare class MigrationRunner {
15
- private readonly db;
16
- constructor(db: Db);
17
- /**
18
- * Run all pending migrations for a given database type.
19
- * @returns Array of migration names that were applied
20
- */
21
- runMigrations(migrations: Migration[], _dbType: DbType): string[];
22
- /**
23
- * Apply all schema definitions (tables, indexes, views, FTS) for a database.
24
- * This is a convenience method that creates everything from the schema catalog.
25
- * Used for initial setup when no migrations exist yet.
26
- */
27
- applySchemaCatalog(dbType: DbType): void;
28
- /**
29
- * Get the current migration version.
30
- * Returns '000' if no version is set (fresh database).
31
- */
32
- getCurrentVersion(): string;
33
- /**
34
- * Get all available migration info for a database type.
35
- */
36
- getMigrationInfo(migrations: Migration[], dbType: DbType): {
37
- id: string;
38
- name: string;
39
- applied: boolean;
40
- }[];
41
- /**
42
- * Rollback the latest migration (if down migration is defined).
43
- */
44
- rollback(migrations: Migration[], dbType: DbType): string | null;
45
- private ensureVersionTable;
46
- private setVersion;
47
- }
48
- /**
49
- * Factory: create a MigrationRunner and apply schema catalog for a given database.
50
- * This is the main entry point for database classes.
51
- */
52
- export declare function ensureDatabaseSchema(db: Db, dbType: DbType): void;
53
- export type { Migration, DbType, TableDefinition, ViewDefinition, FtsDefinition, SchemaCatalog } from './schema-definitions.js';
@@ -1,170 +0,0 @@
1
- /**
2
- * Migration Runner — Executes and tracks schema migrations.
3
- *
4
- * Each migration is versioned. The runner reads the current version from
5
- * the `schema_version` table and only executes migrations with higher IDs.
6
- *
7
- * Usage:
8
- * const runner = new MigrationRunner(db);
9
- * runner.run(allMigrations.filter(m => m.db === 'trajectory.db'));
10
- */
11
- import { getCatalog } from './schema-definitions.js';
12
- export class MigrationRunner {
13
- db;
14
- constructor(db) {
15
- this.db = db;
16
- }
17
- /**
18
- * Run all pending migrations for a given database type.
19
- * @returns Array of migration names that were applied
20
- */
21
- runMigrations(migrations, _dbType) {
22
- // NOTE: _dbType is kept for API signature compatibility but migrations are pre-filtered by caller
23
- void _dbType;
24
- // Ensure schema_version table exists before anything else
25
- this.ensureVersionTable();
26
- const currentVersion = this.getCurrentVersion();
27
- const applied = [];
28
- // Filter to pending migrations (higher ID than current)
29
- const pending = migrations
30
- .filter(m => m.id > currentVersion)
31
- .sort((a, b) => a.id.localeCompare(b.id));
32
- for (const migration of pending) {
33
- console.log(`[MigrationRunner] Applying ${migration.id}-${migration.name}...`);
34
- try {
35
- migration.up(this.db);
36
- this.setVersion(migration.id);
37
- applied.push(`${migration.id}-${migration.name}`);
38
- }
39
- catch (err) {
40
- throw new Error(`Migration ${migration.id}-${migration.name} failed: ${String(err)}`, { cause: err });
41
- }
42
- }
43
- if (applied.length > 0) {
44
- console.log(`[MigrationRunner] Applied ${applied.length} migration(s): ${applied.join(', ')}`);
45
- }
46
- return applied;
47
- }
48
- /**
49
- * Apply all schema definitions (tables, indexes, views, FTS) for a database.
50
- * This is a convenience method that creates everything from the schema catalog.
51
- * Used for initial setup when no migrations exist yet.
52
- */
53
- applySchemaCatalog(dbType) {
54
- this.ensureVersionTable();
55
- const catalog = getCatalog(dbType);
56
- // Tables
57
- for (const [key, table] of Object.entries(catalog.tables)) {
58
- try {
59
- this.db.exec(table.ddl);
60
- }
61
- catch (err) {
62
- throw new Error(`Failed to create table ${key}: ${String(err)}`, { cause: err });
63
- }
64
- // Indexes
65
- for (const indexDdl of table.indexes ?? []) {
66
- try {
67
- this.db.exec(indexDdl);
68
- }
69
- catch (err) {
70
- throw new Error(`Failed to create index for ${key}: ${String(err)}`, { cause: err });
71
- }
72
- }
73
- }
74
- // Views
75
- for (const [key, view] of Object.entries(catalog.views)) {
76
- try {
77
- this.db.exec(view.ddl);
78
- }
79
- catch (err) {
80
- throw new Error(`Failed to create view ${key}: ${String(err)}`, { cause: err });
81
- }
82
- }
83
- // FTS5 virtual tables
84
- for (const [key, fts] of Object.entries(catalog.fts)) {
85
- try {
86
- this.db.exec(fts.ddl);
87
- }
88
- catch (err) {
89
- throw new Error(`Failed to create FTS table ${key}: ${String(err)}`, { cause: err });
90
- }
91
- }
92
- }
93
- /**
94
- * Get the current migration version.
95
- * Returns '000' if no version is set (fresh database).
96
- */
97
- getCurrentVersion() {
98
- try {
99
- const row = this.db.get('SELECT version FROM schema_version ORDER BY version DESC LIMIT 1');
100
- return row?.version ?? '000';
101
- }
102
- catch {
103
- return '000';
104
- }
105
- }
106
- /**
107
- * Get all available migration info for a database type.
108
- */
109
- getMigrationInfo(migrations, dbType) {
110
- const currentVersion = this.getCurrentVersion();
111
- return migrations
112
- .filter(m => m.db === dbType)
113
- .sort((a, b) => a.id.localeCompare(b.id))
114
- .map(m => ({
115
- id: m.id,
116
- name: m.name,
117
- applied: m.id <= currentVersion,
118
- }));
119
- }
120
- /**
121
- * Rollback the latest migration (if down migration is defined).
122
- */
123
- rollback(migrations, dbType) {
124
- const currentVersion = this.getCurrentVersion();
125
- if (currentVersion === '000')
126
- return null;
127
- const migration = migrations.find(m => m.db === dbType && m.id === currentVersion);
128
- if (!migration)
129
- return null;
130
- if (!migration.down) {
131
- throw new Error(`Migration ${migration.id}-${migration.name} has no down migration`);
132
- }
133
- console.log(`[MigrationRunner] Rolling back ${migration.id}-${migration.name}...`);
134
- migration.down(this.db);
135
- // Set version to previous migration
136
- const previousMigrations = migrations
137
- .filter(m => m.db === dbType && m.id < currentVersion)
138
- .sort((a, b) => b.id.localeCompare(a.id));
139
- const newVersion = previousMigrations[0]?.id ?? '000';
140
- this.setVersion(newVersion);
141
- console.log(`[MigrationRunner] Rolled back to ${newVersion}`);
142
- return migration.id;
143
- }
144
- // -----------------------------------------------------------------------
145
- // Private helpers
146
- // -----------------------------------------------------------------------
147
- ensureVersionTable() {
148
- this.db.exec(`
149
- CREATE TABLE IF NOT EXISTS schema_version (
150
- version TEXT NOT NULL DEFAULT '000'
151
- )
152
- `);
153
- // Ensure at least one row exists
154
- const count = this.db.get('SELECT COUNT(*) as cnt FROM schema_version');
155
- if (!count || count.cnt === 0) {
156
- this.db.exec("INSERT INTO schema_version (version) VALUES ('000')");
157
- }
158
- }
159
- setVersion(version) {
160
- this.db.exec(`UPDATE schema_version SET version = '${version}'`);
161
- }
162
- }
163
- /**
164
- * Factory: create a MigrationRunner and apply schema catalog for a given database.
165
- * This is the main entry point for database classes.
166
- */
167
- export function ensureDatabaseSchema(db, dbType) {
168
- const runner = new MigrationRunner(db);
169
- runner.applySchemaCatalog(dbType);
170
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Migration: Initialize trajectory.db tables
3
- * This creates all core event store tables.
4
- */
5
- import type { Migration } from '../migration-runner.js';
6
- export declare const migration: Migration;
@@ -1,190 +0,0 @@
1
- /**
2
- * Migration: Initialize trajectory.db tables
3
- * This creates all core event store tables.
4
- */
5
- export const migration = {
6
- id: '001',
7
- name: 'init-trajectory',
8
- db: 'trajectory.db',
9
- up(db) {
10
- // Core tables
11
- db.exec(`CREATE TABLE IF NOT EXISTS sessions (
12
- session_id TEXT PRIMARY KEY,
13
- started_at TEXT NOT NULL,
14
- updated_at TEXT NOT NULL
15
- )`);
16
- db.exec(`CREATE TABLE IF NOT EXISTS assistant_turns (
17
- id INTEGER PRIMARY KEY AUTOINCREMENT,
18
- session_id TEXT NOT NULL,
19
- run_id TEXT NOT NULL,
20
- provider TEXT NOT NULL,
21
- model TEXT NOT NULL,
22
- raw_text TEXT,
23
- sanitized_text TEXT NOT NULL,
24
- usage_json TEXT NOT NULL,
25
- empathy_signal_json TEXT NOT NULL,
26
- blob_ref TEXT,
27
- raw_excerpt TEXT,
28
- created_at TEXT NOT NULL
29
- )`);
30
- db.exec(`CREATE INDEX IF NOT EXISTS idx_assistant_turns_session_id ON assistant_turns(session_id)`);
31
- db.exec(`CREATE INDEX IF NOT EXISTS idx_assistant_turns_created_at ON assistant_turns(created_at)`);
32
- db.exec(`CREATE TABLE IF NOT EXISTS user_turns (
33
- id INTEGER PRIMARY KEY AUTOINCREMENT,
34
- session_id TEXT NOT NULL,
35
- turn_index INTEGER NOT NULL,
36
- raw_text TEXT,
37
- blob_ref TEXT,
38
- raw_excerpt TEXT,
39
- correction_detected INTEGER NOT NULL DEFAULT 0,
40
- correction_cue TEXT,
41
- references_assistant_turn_id INTEGER,
42
- created_at TEXT NOT NULL
43
- )`);
44
- db.exec(`CREATE INDEX IF NOT EXISTS idx_user_turns_session_id ON user_turns(session_id)`);
45
- db.exec(`CREATE TABLE IF NOT EXISTS tool_calls (
46
- id INTEGER PRIMARY KEY AUTOINCREMENT,
47
- session_id TEXT NOT NULL,
48
- tool_name TEXT NOT NULL,
49
- outcome TEXT NOT NULL,
50
- duration_ms INTEGER,
51
- exit_code INTEGER,
52
- error_type TEXT,
53
- error_message TEXT,
54
- gfi_before REAL,
55
- gfi_after REAL,
56
- params_json TEXT NOT NULL,
57
- created_at TEXT NOT NULL
58
- )`);
59
- db.exec(`CREATE INDEX IF NOT EXISTS idx_tool_calls_session_id ON tool_calls(session_id)`);
60
- db.exec(`CREATE INDEX IF NOT EXISTS idx_tool_calls_created_at ON tool_calls(created_at)`);
61
- db.exec(`CREATE TABLE IF NOT EXISTS pain_events (
62
- id INTEGER PRIMARY KEY AUTOINCREMENT,
63
- session_id TEXT NOT NULL,
64
- source TEXT NOT NULL,
65
- score REAL NOT NULL,
66
- reason TEXT,
67
- severity TEXT,
68
- origin TEXT,
69
- confidence REAL,
70
- text TEXT,
71
- created_at TEXT NOT NULL
72
- )`);
73
- db.exec(`CREATE INDEX IF NOT EXISTS idx_pain_events_session_id ON pain_events(session_id)`);
74
- db.exec(`CREATE INDEX IF NOT EXISTS idx_pain_events_created_at ON pain_events(created_at)`);
75
- // pain_events_fts FTS5 virtual table removed (PRI-451 Wave 1): the only
76
- // reader (searchPainEvents) was dead code. Existing DBs keep the orphan
77
- // table harmlessly (CREATE was IF NOT EXISTS); new DBs simply don't create it.
78
- db.exec(`CREATE TABLE IF NOT EXISTS gate_blocks (
79
- id INTEGER PRIMARY KEY AUTOINCREMENT,
80
- session_id TEXT,
81
- tool_name TEXT NOT NULL,
82
- file_path TEXT,
83
- reason TEXT NOT NULL,
84
- plan_status TEXT,
85
- gfi REAL,
86
- gfi_after REAL,
87
- trust_stage INTEGER,
88
- gate_type TEXT,
89
- created_at TEXT NOT NULL
90
- )`);
91
- db.exec(`CREATE INDEX IF NOT EXISTS idx_gate_blocks_created_at ON gate_blocks(created_at)`);
92
- db.exec(`CREATE TABLE IF NOT EXISTS trust_changes (
93
- id INTEGER PRIMARY KEY AUTOINCREMENT,
94
- session_id TEXT,
95
- previous_score REAL NOT NULL,
96
- new_score REAL NOT NULL,
97
- delta REAL NOT NULL,
98
- reason TEXT NOT NULL,
99
- created_at TEXT NOT NULL
100
- )`);
101
- db.exec(`CREATE TABLE IF NOT EXISTS principle_events (
102
- id INTEGER PRIMARY KEY AUTOINCREMENT,
103
- principle_id TEXT,
104
- event_type TEXT NOT NULL,
105
- payload_json TEXT NOT NULL,
106
- created_at TEXT NOT NULL
107
- )`);
108
- db.exec(`CREATE TABLE IF NOT EXISTS task_outcomes (
109
- id INTEGER PRIMARY KEY AUTOINCREMENT,
110
- session_id TEXT NOT NULL,
111
- task_id TEXT,
112
- outcome TEXT NOT NULL,
113
- summary TEXT,
114
- principle_ids_json TEXT NOT NULL,
115
- created_at TEXT NOT NULL
116
- )`);
117
- db.exec(`CREATE TABLE IF NOT EXISTS correction_samples (
118
- sample_id TEXT PRIMARY KEY,
119
- session_id TEXT NOT NULL,
120
- bad_assistant_turn_id INTEGER NOT NULL,
121
- user_correction_turn_id INTEGER NOT NULL,
122
- recovery_tool_span_json TEXT NOT NULL,
123
- diff_excerpt TEXT NOT NULL,
124
- principle_ids_json TEXT NOT NULL,
125
- quality_score REAL NOT NULL,
126
- review_status TEXT NOT NULL,
127
- export_mode TEXT NOT NULL,
128
- created_at TEXT NOT NULL,
129
- updated_at TEXT NOT NULL
130
- )`);
131
- db.exec(`CREATE INDEX IF NOT EXISTS idx_correction_samples_review_status ON correction_samples(review_status)`);
132
- db.exec(`CREATE TABLE IF NOT EXISTS sample_reviews (
133
- id INTEGER PRIMARY KEY AUTOINCREMENT,
134
- sample_id TEXT NOT NULL,
135
- review_status TEXT NOT NULL,
136
- note TEXT,
137
- created_at TEXT NOT NULL
138
- )`);
139
- db.exec(`CREATE TABLE IF NOT EXISTS exports_audit (
140
- id INTEGER PRIMARY KEY AUTOINCREMENT,
141
- export_kind TEXT NOT NULL,
142
- mode TEXT NOT NULL,
143
- approved_only INTEGER NOT NULL,
144
- file_path TEXT NOT NULL,
145
- row_count INTEGER NOT NULL,
146
- created_at TEXT NOT NULL
147
- )`);
148
- db.exec(`CREATE TABLE IF NOT EXISTS evolution_tasks (
149
- id INTEGER PRIMARY KEY AUTOINCREMENT,
150
- task_id TEXT UNIQUE NOT NULL,
151
- trace_id TEXT NOT NULL,
152
- source TEXT NOT NULL,
153
- reason TEXT,
154
- score INTEGER DEFAULT 0,
155
- status TEXT DEFAULT 'pending',
156
- enqueued_at TEXT,
157
- started_at TEXT,
158
- completed_at TEXT,
159
- resolution TEXT,
160
- task_kind TEXT,
161
- priority TEXT,
162
- retry_count INTEGER,
163
- max_retries INTEGER,
164
- last_error TEXT,
165
- result_ref TEXT,
166
- created_at TEXT NOT NULL,
167
- updated_at TEXT NOT NULL
168
- )`);
169
- db.exec(`CREATE INDEX IF NOT EXISTS idx_evolution_tasks_trace_id ON evolution_tasks(trace_id)`);
170
- db.exec(`CREATE INDEX IF NOT EXISTS idx_evolution_tasks_status ON evolution_tasks(status)`);
171
- db.exec(`CREATE INDEX IF NOT EXISTS idx_evolution_tasks_created_at ON evolution_tasks(created_at)`);
172
- db.exec(`CREATE TABLE IF NOT EXISTS evolution_events (
173
- id INTEGER PRIMARY KEY AUTOINCREMENT,
174
- trace_id TEXT NOT NULL,
175
- task_id TEXT,
176
- stage TEXT NOT NULL,
177
- level TEXT DEFAULT 'info',
178
- message TEXT NOT NULL,
179
- summary TEXT,
180
- metadata_json TEXT,
181
- created_at TEXT NOT NULL
182
- )`);
183
- db.exec(`CREATE INDEX IF NOT EXISTS idx_evolution_events_trace_id ON evolution_events(trace_id)`);
184
- db.exec(`CREATE INDEX IF NOT EXISTS idx_evolution_events_created_at ON evolution_events(created_at)`);
185
- db.exec(`CREATE TABLE IF NOT EXISTS ingest_checkpoint (
186
- source_key TEXT PRIMARY KEY,
187
- imported_at TEXT NOT NULL
188
- )`);
189
- },
190
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * Migration: Initialize central.db (aggregated multi-workspace) tables
3
- */
4
- import type { Migration } from '../migration-runner.js';
5
- export declare const migration: Migration;
@@ -1,108 +0,0 @@
1
- /**
2
- * Migration: Initialize central.db (aggregated multi-workspace) tables
3
- */
4
- export const migration = {
5
- id: '001',
6
- name: 'init-central',
7
- db: 'central.db',
8
- up(db) {
9
- db.exec(`CREATE TABLE IF NOT EXISTS workspaces (
10
- name TEXT PRIMARY KEY,
11
- path TEXT NOT NULL,
12
- last_sync TEXT
13
- )`);
14
- db.exec(`CREATE TABLE IF NOT EXISTS workspace_config (
15
- workspace_name TEXT PRIMARY KEY,
16
- enabled INTEGER NOT NULL DEFAULT 1,
17
- display_name TEXT,
18
- sync_enabled INTEGER NOT NULL DEFAULT 1,
19
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
20
- updated_at TEXT NOT NULL DEFAULT (datetime('now'))
21
- )`);
22
- db.exec(`CREATE TABLE IF NOT EXISTS global_config (
23
- key TEXT PRIMARY KEY,
24
- value TEXT NOT NULL,
25
- updated_at TEXT NOT NULL DEFAULT (datetime('now'))
26
- )`);
27
- db.exec(`CREATE TABLE IF NOT EXISTS aggregated_sessions (
28
- session_id TEXT PRIMARY KEY,
29
- workspace TEXT NOT NULL,
30
- started_at TEXT NOT NULL,
31
- updated_at TEXT NOT NULL
32
- )`);
33
- db.exec(`CREATE INDEX IF NOT EXISTS idx_sessions_workspace ON aggregated_sessions(workspace)`);
34
- db.exec(`CREATE TABLE IF NOT EXISTS aggregated_tool_calls (
35
- id INTEGER PRIMARY KEY AUTOINCREMENT,
36
- workspace TEXT NOT NULL,
37
- session_id TEXT NOT NULL,
38
- tool_name TEXT NOT NULL,
39
- outcome TEXT NOT NULL,
40
- duration_ms INTEGER,
41
- error_type TEXT,
42
- error_message TEXT,
43
- created_at TEXT NOT NULL
44
- )`);
45
- db.exec(`CREATE INDEX IF NOT EXISTS idx_tool_calls_workspace ON aggregated_tool_calls(workspace)`);
46
- db.exec(`CREATE INDEX IF NOT EXISTS idx_tool_calls_outcome ON aggregated_tool_calls(outcome)`);
47
- db.exec(`CREATE INDEX IF NOT EXISTS idx_tool_calls_created ON aggregated_tool_calls(created_at)`);
48
- db.exec(`CREATE TABLE IF NOT EXISTS aggregated_pain_events (
49
- id INTEGER PRIMARY KEY AUTOINCREMENT,
50
- workspace TEXT NOT NULL,
51
- session_id TEXT NOT NULL,
52
- source TEXT NOT NULL,
53
- score REAL NOT NULL,
54
- reason TEXT,
55
- created_at TEXT NOT NULL
56
- )`);
57
- db.exec(`CREATE INDEX IF NOT EXISTS idx_pain_workspace ON aggregated_pain_events(workspace)`);
58
- db.exec(`CREATE INDEX IF NOT EXISTS idx_pain_created ON aggregated_pain_events(created_at)`);
59
- db.exec(`CREATE TABLE IF NOT EXISTS aggregated_user_corrections (
60
- id INTEGER PRIMARY KEY AUTOINCREMENT,
61
- workspace TEXT NOT NULL,
62
- session_id TEXT NOT NULL,
63
- correction_cue TEXT,
64
- created_at TEXT NOT NULL
65
- )`);
66
- db.exec(`CREATE TABLE IF NOT EXISTS aggregated_principle_events (
67
- id INTEGER PRIMARY KEY AUTOINCREMENT,
68
- workspace TEXT NOT NULL,
69
- principle_id TEXT,
70
- event_type TEXT NOT NULL,
71
- created_at TEXT NOT NULL
72
- )`);
73
- db.exec(`CREATE TABLE IF NOT EXISTS aggregated_thinking_events (
74
- id INTEGER PRIMARY KEY AUTOINCREMENT,
75
- workspace TEXT NOT NULL,
76
- session_id TEXT NOT NULL,
77
- model_id TEXT NOT NULL,
78
- matched_pattern TEXT NOT NULL,
79
- created_at TEXT NOT NULL
80
- )`);
81
- db.exec(`CREATE INDEX IF NOT EXISTS idx_thinking_workspace ON aggregated_thinking_events(workspace)`);
82
- db.exec(`CREATE INDEX IF NOT EXISTS idx_thinking_model ON aggregated_thinking_events(model_id)`);
83
- db.exec(`CREATE TABLE IF NOT EXISTS aggregated_correction_samples (
84
- sample_id TEXT PRIMARY KEY,
85
- workspace TEXT NOT NULL,
86
- session_id TEXT NOT NULL,
87
- bad_assistant_turn_id INTEGER NOT NULL,
88
- quality_score REAL,
89
- review_status TEXT,
90
- created_at TEXT NOT NULL
91
- )`);
92
- db.exec(`CREATE INDEX IF NOT EXISTS idx_corrections_workspace ON aggregated_correction_samples(workspace)`);
93
- db.exec(`CREATE TABLE IF NOT EXISTS aggregated_task_outcomes (
94
- id INTEGER PRIMARY KEY AUTOINCREMENT,
95
- workspace TEXT NOT NULL,
96
- session_id TEXT NOT NULL,
97
- task_id TEXT,
98
- outcome TEXT NOT NULL,
99
- created_at TEXT NOT NULL
100
- )`);
101
- db.exec(`CREATE TABLE IF NOT EXISTS sync_log (
102
- id INTEGER PRIMARY KEY AUTOINCREMENT,
103
- workspace TEXT NOT NULL,
104
- synced_at TEXT NOT NULL,
105
- records_synced INTEGER NOT NULL
106
- )`);
107
- },
108
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * Migration: Initialize workflow.db (subagent workflow tracking) tables
3
- */
4
- import type { Migration } from '../migration-runner.js';
5
- export declare const migration: Migration;