Add Experience V1 schema migration and agent-run completion extractor.

Extend h5_experience with structured fields, wire mindspace-agent-runner and agent-run-gateway to persist task_outcome records with provenance, and add local migration and verification scripts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-09-02 10:26:46 +08:00
parent 908db04b67
commit b923e54eff
19 changed files with 1340 additions and 131 deletions
+34
View File
@@ -334,13 +334,47 @@ export async function migrateSchema(pool) {
source_user_id CHAR(36) NULL,
use_count BIGINT NOT NULL DEFAULT 0,
embedding JSON NULL,
problem VARCHAR(512) NULL,
environment_json JSON NULL,
hypothesis VARCHAR(512) NULL,
action_json JSON NULL,
result ENUM('success','partial','failure','unknown') NULL,
confidence DECIMAL(4,3) NULL,
evidence_json JSON NULL,
parent_experience_id CHAR(36) NULL,
supersedes_id CHAR(36) NULL,
status ENUM('active','archived','deleted') NOT NULL DEFAULT 'active',
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
KEY idx_h5_experience_scope_updated (scope, updated_at),
KEY idx_h5_experience_status_updated (status, updated_at),
FULLTEXT KEY ftx_h5_experience (title, body)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
`);
const experienceV1Columns = [
['problem', 'VARCHAR(512) NULL'],
['environment_json', 'JSON NULL'],
['hypothesis', 'VARCHAR(512) NULL'],
['action_json', 'JSON NULL'],
["result", "ENUM('success','partial','failure','unknown') NULL"],
['confidence', 'DECIMAL(4,3) NULL'],
['evidence_json', 'JSON NULL'],
['parent_experience_id', 'CHAR(36) NULL'],
['supersedes_id', 'CHAR(36) NULL'],
['status', "ENUM('active','archived','deleted') NOT NULL DEFAULT 'active'"],
];
for (const [column, definition] of experienceV1Columns) {
if (!(await columnExists(pool, 'h5_experience', column))) {
await pool.query(`ALTER TABLE h5_experience ADD COLUMN \`${column}\` ${definition}`);
}
}
if (!(await indexExists(pool, 'h5_experience', 'idx_h5_experience_status_updated'))) {
await pool.query(
'ALTER TABLE h5_experience ADD KEY idx_h5_experience_status_updated (status, updated_at)',
);
}
// Per-user conversation memory: raw dialogue rows plus lightweight extracted
// memory items. This is intentionally additive and can be disabled by env.
await pool.query(`