-- CI 收尾(见 shared/src/ci_gate.ts、control-server/src/ci_gate.ts)。 -- -- ci_gate_runs:每次交付前 / 交付后跟进的一次收尾,一行到底 —— 阶段、首次 CI 结论、 -- 交付时 CI 结论、回炉 / 重跑 / 保鲜次数、全程事件时间线(events,JSON 数组)。 -- 管理台「CI 收尾」页的收益(交付时全绿率 vs 首次全绿率)与成本(交付推迟时长、额外 -- agent 轮次)都从这里算。outcome 为 NULL 的行就是进行中的收尾。 -- -- ci_sync_jobs:分支保鲜的节点任务队列。节点空闲时来领(和 Eddy 导出同一种拉取模式, -- 有节点入站端口被挡),用 git merge-tree 把目标分支合进任务分支、普通 push,不 force。 -- -- 纯新增,不需要回填。 CREATE TABLE IF NOT EXISTS "ci_gate_runs" ( "id" text PRIMARY KEY, -- bug | feature "kind" text NOT NULL, "item_id" text NOT NULL, "platform" text NOT NULL, -- blocking(bug,扣住交付)| follow(feature,人点出 MR 之后跟进) "mode" text NOT NULL, "mr_id" bigint, "mr_url" text, -- 收尾开始时的执行批次(attempts) "round" bigint NOT NULL, -- waiting_mr | waiting_ci | fixing | syncing | done "phase" text NOT NULL, -- NULL = 进行中;green | red | timeout | no_mr | mr_closed | preempted | fix_failed | disabled "outcome" text, "started_at" bigint NOT NULL, "deadline_at" bigint, "ended_at" bigint, "delivered_at" bigint, "ci_commit" text, "ci_quiet_since" bigint, "first_verdict" text, "first_verdict_at" bigint, "first_failed" text, "final_verdict" text, "fix_rounds" bigint NOT NULL DEFAULT 0, "fix_ms" bigint NOT NULL DEFAULT 0, "fix_started_at" bigint, "retries" bigint NOT NULL DEFAULT 0, "retry_counts" text, "syncs" bigint NOT NULL DEFAULT 0, "sync_job_id" text, -- blocking 下被扣住的 Bits 步骤(启动 CR、加 reviewer)及其身份,交付时补做 "deferred_review" text, "events" text NOT NULL DEFAULT '[]', "updated_at" bigint NOT NULL ); CREATE INDEX IF NOT EXISTS "ci_gate_runs_item_idx" ON "ci_gate_runs" ("kind", "item_id"); CREATE INDEX IF NOT EXISTS "ci_gate_runs_started_idx" ON "ci_gate_runs" ("started_at"); CREATE INDEX IF NOT EXISTS "ci_gate_runs_active_idx" ON "ci_gate_runs" ("outcome") WHERE "outcome" IS NULL; CREATE TABLE IF NOT EXISTS "ci_sync_jobs" ( "id" text PRIMARY KEY, "kind" text NOT NULL, "item_id" text NOT NULL, -- 交付前收尾里发起的保鲜挂在那次收尾上;交付后的巡检发起的为 NULL "run_id" text, "platform" text NOT NULL, "repo_key" text, "branch" text NOT NULL, "target_branch" text NOT NULL, "mr_id" bigint, -- 合并提交的作者(任务的 commitAuthor,JSON);没有就用节点自己的 git 身份 "commit_author" text, -- queued | claimed | merged | up_to_date | conflict | failed "status" text NOT NULL, "node_id" text, "lease" text, "created_at" bigint NOT NULL, "claimed_at" bigint, "heartbeat_at" bigint, "finished_at" bigint, "merged_sha" text, "detail" text ); CREATE INDEX IF NOT EXISTS "ci_sync_jobs_status_idx" ON "ci_sync_jobs" ("status"); CREATE INDEX IF NOT EXISTS "ci_sync_jobs_item_idx" ON "ci_sync_jobs" ("kind", "item_id");