fix: isolate minimax m3 backend migration

This commit is contained in:
Codex
2026-06-02 08:11:15 +08:00
parent ab40d86dde
commit 4b9dc79b67
4 changed files with 28 additions and 5 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ Secret 名称和 key 可以在实现时按 Kubernetes 命名限制微调,但
| --- | --- | --- |
| Postgres durable store 规格 | 已定义 | 本文为 v0.1 存储权威。 |
| StatefulSet/Service/PVC | 已实现/已通过主闭环 | `agentrun-v01-postgres` StatefulSet、Service 和 PVC 已由 GitOps runtime 提供,作为 `agentrun-v01` durable store。 |
| migration ledger | 已实现/已通过主闭环 | `agentrun-mgr` 启动 Postgres adapter 时幂等创建 `agentrun_schema_migrations` 并记录 migration id/checksum;当前最新 migration 为 `004_v01_queue_q1`,用于新增 Q1 Queue task 与 read cursor 持久化readiness 必须显示 migration ready。 |
| migration ledger | 已实现/已通过主闭环 | `agentrun-mgr` 启动 Postgres adapter 时幂等创建 `agentrun_schema_migrations` 并记录 migration id/checksum;当前最新 migration 为 `005_v01_minimax_m3_backend_profile`,用于在不改写既有 migration checksum 的前提下新增 `minimax-m3` backend profilereadiness 必须显示 migration ready。 |
| manager Postgres adapter | 已实现/已通过主闭环 | `agentrun-mgr` 通过 `DATABASE_URL` 启用 Postgres adapter,持久化 runs、commands、events、runners、runner_jobs、sessions、backends、leases、Queue task 和 read cursor;缺少 `DATABASE_URL` 时 live runtime fail fastmemory 只允许显式 self-test/dev。 |
| health/readiness store 状态 | 已实现 | health/readiness 返回 adapter、reachable、migrationReady、migrationId、failureKind 和 redacted Secret 状态,不输出 DSN 明文。 |
| file/sqlite durable store | 不采用 | 只可用于临时本地测试,不作为 v0.1 runtime truth。 |
+9 -2
View File
@@ -102,8 +102,15 @@ export function backendCapabilities(): JsonRecord[] {
return backendProfileSpecs.map(backendCapability);
}
export function backendCapabilitiesSqlValues(): string {
return backendProfileSpecs.map((spec) => {
export function backendCapabilitiesSqlValues(profiles?: readonly BackendProfile[]): string {
const specs = profiles
? profiles.map((profile) => {
const spec = backendProfileSpec(profile);
if (!spec) throw new Error(`unknown backend profile for SQL seed: ${profile}`);
return spec;
})
: backendProfileSpecs;
return specs.map((spec) => {
const capabilities = JSON.stringify({
backendKind: spec.backendKind,
protocol: spec.protocol,
+16 -1
View File
@@ -119,7 +119,17 @@ ON CONFLICT (profile) DO UPDATE SET
const backendProfilesMigrationSql = `
INSERT INTO agentrun_backends (profile, capabilities, capacity, health, updated_at)
VALUES ${backendCapabilitiesSqlValues()}
VALUES ${backendCapabilitiesSqlValues(["codex", "deepseek"])}
ON CONFLICT (profile) DO UPDATE SET
capabilities = EXCLUDED.capabilities,
capacity = EXCLUDED.capacity,
health = EXCLUDED.health,
updated_at = EXCLUDED.updated_at;
`;
const minimaxM3BackendProfileMigrationSql = `
INSERT INTO agentrun_backends (profile, capabilities, capacity, health, updated_at)
VALUES ${backendCapabilitiesSqlValues(["minimax-m3"])}
ON CONFLICT (profile) DO UPDATE SET
capabilities = EXCLUDED.capabilities,
capacity = EXCLUDED.capacity,
@@ -239,6 +249,11 @@ const postgresMigrations: MigrationDefinition[] = [
checksum: checksumSql(queueQ1MigrationSql),
sql: queueQ1MigrationSql,
},
{
id: "005_v01_minimax_m3_backend_profile",
checksum: checksumSql(minimaxM3BackendProfileMigrationSql),
sql: minimaxM3BackendProfileMigrationSql,
},
];
export function postgresMigrationContract(): JsonRecord {
+2 -1
View File
@@ -13,7 +13,8 @@ const selfTest: SelfTestCase = async () => {
(error) => error instanceof AgentRunError && error.failureKind === "infra-failed" && error.message.includes("DATABASE_URL is required"),
);
const postgresContract = postgresMigrationContract();
assert.equal(postgresContract.latestMigrationId, "004_v01_queue_q1");
assert.equal(postgresContract.latestMigrationId, "005_v01_minimax_m3_backend_profile");
assert.equal((postgresContract.checksums as Record<string, string>)["002_v01_backend_profiles"], "928b5c490cc4539cb64ecef34784557601b2724fa2870570f16a53576804e49c");
assert.ok(Array.isArray(postgresContract.requiredTables));
assert.ok(postgresContract.requiredTables.includes("agentrun_schema_migrations"));
assert.ok(postgresContract.requiredTables.includes("agentrun_runs"));