Multiplayer agent harness for work.
Drop the retired turn_metrics table (#2490)
Regan Belle23f21c1e55d
diff --git a/package.json b/package.jsonindex 088f2370e..6ed24e134 100644--- a/package.json+++ b/package.json@@ -48,7 +48,7 @@"sandbox:local:build": "bash scripts/local-sandbox-build.sh","sandbox:porter:build": "docker build --platform linux/amd64 -t \"${PORTER_SANDBOX_IMAGE:?Set PORTER_SANDBOX_IMAGE to the registry tag to publish}\" porter && docker push \"$PORTER_SANDBOX_IMAGE\"","deploy:porter-runner-image": "docker build --platform linux/amd64 -t \"${PORTER_DEPLOY_RUNNER_IMAGE:?Set PORTER_DEPLOY_RUNNER_IMAGE to the registry tag to publish}\" -f deploy/porter-runner/Dockerfile . && docker push \"$PORTER_DEPLOY_RUNNER_IMAGE\"",- "test:pg": "node scripts/run-pg-tests.mjs test/batch-paths.test.ts test/session-append-many.test.ts test/cron-queue.test.ts test/postgres-migration-startup.test.ts test/postgres-swarms.test.ts test/postgres-store.test.ts test/postgres-tapeless-store.test.ts test/semantic-memory-pg.test.ts test/semantic-memory-http.test.ts test/semantic-memory-large-pg.test.ts test/postgres-instance-registry.test.ts test/readiness.test.ts test/postgres-grant-store.test.ts test/postgres-acl-file-id-migration.test.ts test/postgres-admin-grants.test.ts test/postgres-teams.test.ts test/postgres-decisions.test.ts test/postgres-file-artifact-store.test.ts test/postgres-file-upload-store.test.ts test/postgres-directory-store.test.ts test/postgres-linked-identity-membership.test.ts test/postgres-map.test.ts test/postgres-background-ownership.test.ts test/postgres-resource-search.test.ts test/deploy-store-pg.test.ts test/postgres-cron-fires.test.ts test/postgres-cron-run-as-migration.test.ts test/postgres-trigger-recipient-consent-migration.test.ts test/postgres-legacy-harness-migration.test.ts test/postgres-migration-adoption.test.ts test/postgres-migrations.test.ts test/sentry-tracing-pg.test.ts test/postgres-error-log.test.ts test/postgres-audit-log.test.ts test/postgres-app-page-views.test.ts test/postgres-budget.test.ts test/postgres-rate-limiter.test.ts test/postgres-credential-usage-sink.test.ts test/postgres-config-store.test.ts test/postgres-delivery-store.test.ts test/postgres-replay-dedupe.test.ts test/postgres-broker-sessions.test.ts test/postgres-egress-audit-sink.test.ts test/postgres-memory-service.test.ts test/run-signal-store.test.ts test/postgres-listener.test.ts test/postgres-run-activity-store.test.ts test/leader-lease.test.ts test/advisory-lock.test.ts test/loop-ingress-pg.test.ts test/persistence-init-retry.test.ts test/migrate-principals.test.ts test/postgres-surface-cache.test.ts test/slack-mirror-fidelity.test.ts test/run-retry-delay.test.ts test/run-priority.test.ts test/postgres-run-stream.test.ts test/postgres-items-migration.test.ts test/postgres-items-contract.test.ts test/pi-harness-replay-fidelity.test.ts test/migrate-main.test.ts",+ "test:pg": "node scripts/run-pg-tests.mjs test/batch-paths.test.ts test/session-append-many.test.ts test/cron-queue.test.ts test/postgres-migration-startup.test.ts test/postgres-swarms.test.ts test/postgres-store.test.ts test/postgres-toolcalls-migration.test.ts test/postgres-tapeless-store.test.ts test/semantic-memory-pg.test.ts test/semantic-memory-http.test.ts test/semantic-memory-large-pg.test.ts test/postgres-instance-registry.test.ts test/readiness.test.ts test/postgres-grant-store.test.ts test/postgres-acl-file-id-migration.test.ts test/postgres-admin-grants.test.ts test/postgres-teams.test.ts test/postgres-decisions.test.ts test/postgres-file-artifact-store.test.ts test/postgres-file-upload-store.test.ts test/postgres-directory-store.test.ts test/postgres-linked-identity-membership.test.ts test/postgres-map.test.ts test/postgres-background-ownership.test.ts test/postgres-resource-search.test.ts test/deploy-store-pg.test.ts test/postgres-cron-fires.test.ts test/postgres-cron-run-as-migration.test.ts test/postgres-trigger-recipient-consent-migration.test.ts test/postgres-legacy-harness-migration.test.ts test/postgres-migration-adoption.test.ts test/postgres-migrations.test.ts test/sentry-tracing-pg.test.ts test/postgres-error-log.test.ts test/postgres-audit-log.test.ts test/postgres-app-page-views.test.ts test/postgres-budget.test.ts test/postgres-rate-limiter.test.ts test/postgres-credential-usage-sink.test.ts test/postgres-config-store.test.ts test/postgres-delivery-store.test.ts test/postgres-replay-dedupe.test.ts test/postgres-broker-sessions.test.ts test/postgres-egress-audit-sink.test.ts test/postgres-memory-service.test.ts test/run-signal-store.test.ts test/postgres-listener.test.ts test/postgres-run-activity-store.test.ts test/leader-lease.test.ts test/advisory-lock.test.ts test/loop-ingress-pg.test.ts test/persistence-init-retry.test.ts test/migrate-principals.test.ts test/postgres-surface-cache.test.ts test/slack-mirror-fidelity.test.ts test/run-retry-delay.test.ts test/run-priority.test.ts test/postgres-run-stream.test.ts test/postgres-items-migration.test.ts test/postgres-items-contract.test.ts test/pi-harness-replay-fidelity.test.ts test/migrate-main.test.ts","livetest": "node scripts/api-livetest.ts","bench:memory": "node --env-file-if-exists=.env scripts/memory-bench.ts","prepare": "node .husky/install.mjs",diff --git a/scripts/migrate-principals-to-email.mjs b/scripts/migrate-principals-to-email.mjsindex c3805338c..cf0bef8c7 100644--- a/scripts/migrate-principals-to-email.mjs+++ b/scripts/migrate-principals-to-email.mjs@@ -94,7 +94,6 @@ const HISTORY_COLUMNS = [["session_llm_requests", ["scope_label", "request"]],["runs", ["request", "result"]],["tool_calls", ["output"]],- ["turn_metrics", ["scope_label"]],["egress_events", ["scope_label", "principal_id"]],["credential_usage", ["scope_label", "principal_id"]],["error_events", ["scope_label"]],diff --git a/src/runs/postgres-run-store.ts b/src/runs/postgres-run-store.tsindex f7ee0014c..3ea9a3007 100644--- a/src/runs/postgres-run-store.ts+++ b/src/runs/postgres-run-store.ts@@ -154,6 +154,10 @@ export function createPostgresRunStore(connectionString: string, opts?: { maxCla`CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_runs_pending_priority ON runs(claim_priority, created_at, seq) WHERE status='pending'`,],},+ {+ id: "runs/store/0010-drop-turn-metrics",+ statements: [`SET LOCAL lock_timeout = '60s'`, `DROP TABLE IF EXISTS turn_metrics`],+ },],[{diff --git a/test/postgres-toolcalls-migration.test.ts b/test/postgres-toolcalls-migration.test.tsindex 7e141154e..9fb13c9e7 100644--- a/test/postgres-toolcalls-migration.test.ts+++ b/test/postgres-toolcalls-migration.test.ts@@ -37,7 +37,7 @@ async function bootAndClose(): Promise<void> {before(async () => {if (!URL) return;const p = await pool();- await p.query("DROP TABLE IF EXISTS runs, tool_calls CASCADE");+ await p.query("DROP TABLE IF EXISTS runs, tool_calls, turn_metrics CASCADE");await p.query("DELETE FROM qm_schema_migrations WHERE id LIKE 'runs/store/%'").catch(() => undefined);await p.end();});@@ -45,7 +45,7 @@ before(async () => {after(async () => {if (!URL) return;const p = await pool();- await p.query("DROP TABLE IF EXISTS runs, tool_calls CASCADE");+ await p.query("DROP TABLE IF EXISTS runs, tool_calls, turn_metrics CASCADE");await p.query("DELETE FROM qm_schema_migrations WHERE id LIKE 'runs/store/%'").catch(() => undefined);await p.end();});@@ -90,3 +90,33 @@ test("tool_calls: a boot with the current key leaves the constraint untouched",assert.equal(afterPk?.oid, beforePk?.oid, "constraint not dropped and recreated on a routine boot");await p.end();});++test("turn_metrics: the retired table drops on boot and run history is untouched", { skip }, async () => {+ const p = await pool();+ await bootAndClose();+ await p.query(+ "INSERT INTO tool_calls(run_id, attempt, call_index, output, created_at) VALUES ('r3', 1, 0, 'out', 100)",+ );+ await p.query("DELETE FROM qm_schema_migrations WHERE id = 'runs/store/0010-drop-turn-metrics'");+ await p.query(`CREATE TABLE turn_metrics(+ id BIGSERIAL PRIMARY KEY, ts BIGINT NOT NULL, scope_label TEXT NOT NULL, run_id TEXT,+ status TEXT NOT NULL, total_ms INT NOT NULL)`);+ await p.query("CREATE INDEX turn_metrics_by_run ON turn_metrics(run_id)");+ await p.query(+ "INSERT INTO turn_metrics(ts, scope_label, run_id, status, total_ms) VALUES (1, 'personal:a', 'r3', 'ok', 5)",+ );+ const snapshot = async () => [+ (await p.query("SELECT * FROM runs ORDER BY id")).rows,+ (await p.query("SELECT * FROM tool_calls ORDER BY run_id, attempt, call_index")).rows,+ ];+ const before = await snapshot();+ const { close } = createPostgresRunStore(URL!);+ await migrateRegisteredPgSchemas(URL!);+ await close();+ const { rows } = await p.query(+ "SELECT to_regclass('turn_metrics') AS t, to_regclass('turn_metrics_id_seq') AS s, to_regclass('turn_metrics_by_run') AS i",+ );+ assert.deepEqual(rows, [{ t: null, s: null, i: null }]);+ assert.deepEqual(await snapshot(), before);+ await p.end();+});