Initial import of streamline
This commit is contained in:
@@ -0,0 +1,308 @@
|
||||
CREATE TABLE "evidence_capture_events" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"target_type" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"node_id" text,
|
||||
"capture_id" text NOT NULL,
|
||||
"event" text NOT NULL,
|
||||
"out" text,
|
||||
"phase" text,
|
||||
"round" text,
|
||||
"kind" text,
|
||||
"device" text,
|
||||
"intent" text,
|
||||
"expect_moment" text,
|
||||
"verdict" text,
|
||||
"issues" text,
|
||||
"duration_s" double precision,
|
||||
"file_bytes" bigint,
|
||||
"probe" text,
|
||||
"attempt" bigint,
|
||||
"retry_allowed" bigint,
|
||||
"reason" text,
|
||||
"stderr_tail" text,
|
||||
"ts" bigint NOT NULL,
|
||||
"ingested_at" bigint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "evidence_media" (
|
||||
"owner_kind" text NOT NULL,
|
||||
"owner_id" text NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"url" text NOT NULL,
|
||||
"content_type" text,
|
||||
"size" bigint,
|
||||
"uploaded_at" bigint NOT NULL,
|
||||
CONSTRAINT "evidence_media_owner_kind_owner_id_name_pk" PRIMARY KEY("owner_kind","owner_id","name")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "features" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"description" text DEFAULT '' NOT NULL,
|
||||
"platform" text NOT NULL,
|
||||
"remark" text,
|
||||
"review_feedback" text,
|
||||
"execution_plan" text,
|
||||
"regen_context" text,
|
||||
"workspace_path" text,
|
||||
"pinned" bigint DEFAULT 0 NOT NULL,
|
||||
"status" text DEFAULT 'initializing' NOT NULL,
|
||||
"priority_key" double precision NOT NULL,
|
||||
"watchers" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"started_at" bigint,
|
||||
"finished_at" bigint,
|
||||
"duration_ms" bigint,
|
||||
"total_duration_ms" bigint,
|
||||
"branch_name" text,
|
||||
"mr_url" text,
|
||||
"log_path" text,
|
||||
"eval_log_path" text,
|
||||
"before_evidence_path" text,
|
||||
"after_evidence_path" text,
|
||||
"failure_reason" text,
|
||||
"attempts" bigint DEFAULT 0 NOT NULL,
|
||||
"executor_node_id" text,
|
||||
"status_changed_at" bigint,
|
||||
"review_history" text,
|
||||
"creator_email" text,
|
||||
"readable_report_html" text,
|
||||
"readable_report_generated_at" bigint,
|
||||
"readable_report_error" text,
|
||||
"readable_report_prompt_id" text,
|
||||
"readable_report_prompt_name" text,
|
||||
"clusters" text,
|
||||
"lang" text,
|
||||
"linked_feature_id" text,
|
||||
"port_source_id" text,
|
||||
"attachments" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "fix_report_versions" (
|
||||
"task_id" text NOT NULL,
|
||||
"round" bigint NOT NULL,
|
||||
"markdown" text NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
CONSTRAINT "fix_report_versions_task_id_round_pk" PRIMARY KEY("task_id","round")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "lark_users" (
|
||||
"lark_user_id" text PRIMARY KEY NOT NULL,
|
||||
"email" text,
|
||||
"name" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"updated_at" bigint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "logs" (
|
||||
"id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "logs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1),
|
||||
"task_id" text NOT NULL,
|
||||
"ts" bigint NOT NULL,
|
||||
"level" text NOT NULL,
|
||||
"stage" text DEFAULT '' NOT NULL,
|
||||
"message" text NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "node_clusters" (
|
||||
"node_id" text NOT NULL,
|
||||
"cluster" text NOT NULL,
|
||||
CONSTRAINT "node_clusters_node_id_cluster_pk" PRIMARY KEY("node_id","cluster")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "nodes" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"base_url" text NOT NULL,
|
||||
"platform" text NOT NULL,
|
||||
"status" text DEFAULT 'online' NOT NULL,
|
||||
"last_seen_at" bigint NOT NULL,
|
||||
"eval_in_flight" bigint DEFAULT 0 NOT NULL,
|
||||
"eval_capacity" bigint DEFAULT 0 NOT NULL,
|
||||
"fix_in_flight" bigint DEFAULT 0 NOT NULL,
|
||||
"fix_capacity" bigint DEFAULT 0 NOT NULL,
|
||||
"version" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"boot_id" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "readable_batch_jobs" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"status" text DEFAULT 'running' NOT NULL,
|
||||
"prompt_id" text,
|
||||
"prompt_name" text,
|
||||
"prompt_template" text NOT NULL,
|
||||
"items" text NOT NULL,
|
||||
"total" bigint DEFAULT 0 NOT NULL,
|
||||
"processed" bigint DEFAULT 0 NOT NULL,
|
||||
"succeeded" bigint DEFAULT 0 NOT NULL,
|
||||
"failed" bigint DEFAULT 0 NOT NULL,
|
||||
"error" text,
|
||||
"created_by" text,
|
||||
"started_at" bigint NOT NULL,
|
||||
"finished_at" bigint
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "readable_prompts" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"template" text NOT NULL,
|
||||
"notes" text,
|
||||
"kind" text DEFAULT 'both' NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
"created_by" text,
|
||||
"archived" bigint DEFAULT 0 NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "readable_report_runs" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"target_type" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"prompt_id" text,
|
||||
"prompt_name" text,
|
||||
"prompt_template" text NOT NULL,
|
||||
"status" text DEFAULT 'running' NOT NULL,
|
||||
"html" text,
|
||||
"error" text,
|
||||
"model" text,
|
||||
"node_id" text,
|
||||
"duration_ms" bigint,
|
||||
"created_by" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"finished_at" bigint,
|
||||
"is_current" bigint DEFAULT 0 NOT NULL,
|
||||
"batch_id" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "readable_sources" (
|
||||
"target_type" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"markdown" text NOT NULL,
|
||||
"fetched_at" bigint NOT NULL,
|
||||
CONSTRAINT "readable_sources_target_type_target_id_pk" PRIMARY KEY("target_type","target_id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "security" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"description" text DEFAULT '' NOT NULL,
|
||||
"review_spec" text DEFAULT '' NOT NULL,
|
||||
"repro_spec" text DEFAULT '' NOT NULL,
|
||||
"target_ref" text,
|
||||
"platform" text NOT NULL,
|
||||
"remark" text,
|
||||
"review_feedback" text,
|
||||
"review_history" text,
|
||||
"execution_plan" text,
|
||||
"regen_context" text,
|
||||
"workspace_path" text,
|
||||
"pinned" bigint DEFAULT 0 NOT NULL,
|
||||
"status" text DEFAULT 'initializing' NOT NULL,
|
||||
"priority_key" double precision NOT NULL,
|
||||
"watchers" text,
|
||||
"creator_email" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"started_at" bigint,
|
||||
"finished_at" bigint,
|
||||
"duration_ms" bigint,
|
||||
"total_duration_ms" bigint,
|
||||
"branch_name" text,
|
||||
"mr_url" text,
|
||||
"log_path" text,
|
||||
"eval_log_path" text,
|
||||
"before_evidence_path" text,
|
||||
"after_evidence_path" text,
|
||||
"failure_reason" text,
|
||||
"attempts" bigint DEFAULT 0 NOT NULL,
|
||||
"executor_node_id" text,
|
||||
"readable_report_html" text,
|
||||
"readable_report_generated_at" bigint,
|
||||
"readable_report_error" text,
|
||||
"clusters" text,
|
||||
"status_changed_at" bigint,
|
||||
"readable_report_prompt_id" text,
|
||||
"readable_report_prompt_name" text,
|
||||
"lang" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "settings" (
|
||||
"key" text PRIMARY KEY NOT NULL,
|
||||
"value" text NOT NULL,
|
||||
"updated_at" bigint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "task_transitions" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"from_status" text,
|
||||
"to_status" text NOT NULL,
|
||||
"round" bigint,
|
||||
"node_id" text,
|
||||
"source" text NOT NULL,
|
||||
"ts" bigint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "tasks" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"meego_id" text NOT NULL,
|
||||
"meego_url" text NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"description" text DEFAULT '' NOT NULL,
|
||||
"repro_steps" text DEFAULT '' NOT NULL,
|
||||
"bug_type" text NOT NULL,
|
||||
"platform" text NOT NULL,
|
||||
"difficulty" text NOT NULL,
|
||||
"steps_clarity" text NOT NULL,
|
||||
"remark" text,
|
||||
"review_feedback" text,
|
||||
"execution_plan" text,
|
||||
"regen_context" text,
|
||||
"workspace_path" text,
|
||||
"pinned" bigint DEFAULT 0 NOT NULL,
|
||||
"status" text DEFAULT 'initializing' NOT NULL,
|
||||
"priority_key" double precision NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
"started_at" bigint,
|
||||
"finished_at" bigint,
|
||||
"duration_ms" bigint,
|
||||
"branch_name" text,
|
||||
"mr_url" text,
|
||||
"log_path" text,
|
||||
"before_evidence_path" text,
|
||||
"after_evidence_path" text,
|
||||
"failure_reason" text,
|
||||
"attempts" bigint DEFAULT 0 NOT NULL,
|
||||
"total_duration_ms" bigint,
|
||||
"creator_email" text,
|
||||
"creator_lark_id" text,
|
||||
"creator_name" text,
|
||||
"creator_avatar" text,
|
||||
"eval_log_path" text,
|
||||
"watchers" text,
|
||||
"executor_node_id" text,
|
||||
"mr_state" text,
|
||||
"mr_merged_at" bigint,
|
||||
"meego_state" text,
|
||||
"mr_synced_at" bigint,
|
||||
"status_changed_at" bigint,
|
||||
"lang" text DEFAULT 'zh' NOT NULL,
|
||||
"attachments" text,
|
||||
"review_history" text,
|
||||
"fixed_risk" bigint,
|
||||
"readable_report_html" text,
|
||||
"readable_report_generated_at" bigint,
|
||||
"readable_report_error" text,
|
||||
"readable_report_prompt_id" text,
|
||||
"readable_report_prompt_name" text,
|
||||
"clusters" text,
|
||||
CONSTRAINT "tasks_meegoId_unique" UNIQUE("meego_id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "watcher_names" (
|
||||
"wkey" text PRIMARY KEY NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"updated_at" bigint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "fix_report_versions" ADD CONSTRAINT "fix_report_versions_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "logs" ADD CONSTRAINT "logs_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1,58 @@
|
||||
CREATE TABLE "evidmon_criteria" (
|
||||
"version" bigint PRIMARY KEY NOT NULL,
|
||||
"label" text NOT NULL,
|
||||
"config" text NOT NULL,
|
||||
"note" text,
|
||||
"strategy_id" text,
|
||||
"active" bigint NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
"activated_at" bigint
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "evidmon_findings" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"day" text NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"summary" text NOT NULL,
|
||||
"highlights" text,
|
||||
"findings" text,
|
||||
"metrics_snapshot" text,
|
||||
"deltas" text,
|
||||
"author" text NOT NULL,
|
||||
"created_at" bigint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "evidmon_metrics_daily" (
|
||||
"day" text PRIMARY KEY NOT NULL,
|
||||
"generated_at" bigint NOT NULL,
|
||||
"metrics" text NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "evidmon_strategies" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"finding_id" text,
|
||||
"day" text NOT NULL,
|
||||
"code" text NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"rationale" text NOT NULL,
|
||||
"knob" text NOT NULL,
|
||||
"metric_key" text NOT NULL,
|
||||
"baseline_value" double precision,
|
||||
"target_value" double precision,
|
||||
"payload" text,
|
||||
"replay" text,
|
||||
"status" text NOT NULL,
|
||||
"decided_by" text,
|
||||
"decided_at" bigint,
|
||||
"decision_note" text,
|
||||
"effective_at" bigint,
|
||||
"before_value" double precision,
|
||||
"after_value" double precision,
|
||||
"created_at" bigint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
-- NOTE: drizzle-kit also wanted to drop/recreate tasks_meegoId_unique purely to
|
||||
-- rename it to snake_case. That is pre-existing drift between the hand-maintained
|
||||
-- schema and the live DB, unrelated to this change, and churning a unique
|
||||
-- constraint on the busiest table is not worth it — removed by hand.
|
||||
ALTER TABLE "evidence_capture_events" ADD COLUMN "criteria_version" bigint;
|
||||
@@ -0,0 +1,108 @@
|
||||
CREATE TABLE "kb_claims" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"kind" text NOT NULL,
|
||||
"platform" text,
|
||||
"scope_key" text NOT NULL,
|
||||
"scope_label" text,
|
||||
"subject_key" text NOT NULL,
|
||||
"statement" text NOT NULL,
|
||||
"payload" text,
|
||||
"status" text DEFAULT 'active' NOT NULL,
|
||||
"confidence" double precision DEFAULT 0.5 NOT NULL,
|
||||
"support_count" bigint DEFAULT 0 NOT NULL,
|
||||
"refute_count" bigint DEFAULT 0 NOT NULL,
|
||||
"first_seen_at" bigint NOT NULL,
|
||||
"last_validated_at" bigint,
|
||||
"last_refuted_at" bigint,
|
||||
"supersedes_id" text,
|
||||
"version" bigint DEFAULT 1 NOT NULL,
|
||||
"source" text DEFAULT 'distilled' NOT NULL,
|
||||
"created_by" text,
|
||||
"updated_at" bigint NOT NULL,
|
||||
"embedding" text
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "kb_distill_runs" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"target_kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"target_title" text,
|
||||
"trigger" text NOT NULL,
|
||||
"priority" text DEFAULT 'normal' NOT NULL,
|
||||
"status" text DEFAULT 'running' NOT NULL,
|
||||
"prompt_id" text,
|
||||
"prompt_name" text,
|
||||
"model" text,
|
||||
"node_id" text,
|
||||
"raw_output" text,
|
||||
"proposed_count" bigint DEFAULT 0 NOT NULL,
|
||||
"applied_count" bigint DEFAULT 0 NOT NULL,
|
||||
"error" text,
|
||||
"duration_ms" bigint,
|
||||
"created_by" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"finished_at" bigint
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "kb_evidence" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"claim_id" text NOT NULL,
|
||||
"target_kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"round" bigint,
|
||||
"node_id" text,
|
||||
"polarity" text NOT NULL,
|
||||
"outcome" text,
|
||||
"weight" double precision DEFAULT 1 NOT NULL,
|
||||
"excerpt" text,
|
||||
"evidence_ref" text,
|
||||
"distill_run_id" text,
|
||||
"ts" bigint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "kb_injections" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"target_kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"stage" text NOT NULL,
|
||||
"claim_ids" text NOT NULL,
|
||||
"outcome" text,
|
||||
"evaluated_at" bigint,
|
||||
"ts" bigint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "kb_proposals" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"distill_run_id" text,
|
||||
"op" text NOT NULL,
|
||||
"target_claim_id" text,
|
||||
"payload" text NOT NULL,
|
||||
"rationale" text,
|
||||
"status" text DEFAULT 'pending' NOT NULL,
|
||||
"decided_by" text,
|
||||
"decided_at" bigint,
|
||||
"decision_note" text,
|
||||
"created_at" bigint NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "spec_delta_events" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"target_kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"node_id" text,
|
||||
"round" bigint NOT NULL,
|
||||
"source" text NOT NULL,
|
||||
"op" text NOT NULL,
|
||||
"section" text,
|
||||
"original" text,
|
||||
"actual" text,
|
||||
"reason" text,
|
||||
"evidence" text,
|
||||
"kind" text,
|
||||
"confidence" text,
|
||||
"ts" bigint NOT NULL,
|
||||
"ingested_at" bigint NOT NULL,
|
||||
"distilled_at" bigint
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "kb_evidence" ADD CONSTRAINT "kb_evidence_claim_id_kb_claims_id_fk" FOREIGN KEY ("claim_id") REFERENCES "public"."kb_claims"("id") ON DELETE cascade ON UPDATE no action;
|
||||
@@ -0,0 +1,45 @@
|
||||
-- Execution conditions replace spec deltas.
|
||||
--
|
||||
-- Hand-written rather than drizzle-kit generated: the generator sees one table
|
||||
-- removed and one added and asks interactively whether it's a rename. It is NOT
|
||||
-- a rename — the columns changed meaning (from "diff against the draft" to "the
|
||||
-- condition itself"), so a rename would leave rows whose `op`/`original`/`actual`
|
||||
-- semantics no longer exist. An explicit DROP + CREATE says that.
|
||||
--
|
||||
-- Dropping spec_delta_events is safe here: it was verified empty (0 rows) before
|
||||
-- this ran — nothing was ever captured, because every eligible run landed on a
|
||||
-- node whose bundle predated the capture endpoint. Nothing to migrate.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "run_conditions" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"target_kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"node_id" text,
|
||||
"round" bigint NOT NULL,
|
||||
"source" text NOT NULL,
|
||||
"kind" text NOT NULL,
|
||||
"scope" text NOT NULL,
|
||||
"subject" text NOT NULL,
|
||||
"statement" text NOT NULL,
|
||||
"payload" text,
|
||||
"verdict" text NOT NULL,
|
||||
"spec" text NOT NULL,
|
||||
"spec_said" text,
|
||||
"evidence" text,
|
||||
"ts" bigint NOT NULL,
|
||||
"ingested_at" bigint NOT NULL,
|
||||
"promoted_at" bigint
|
||||
);
|
||||
--> statement-breakpoint
|
||||
-- Retrieval filters on (target_kind, target_id) for the per-task view, and on
|
||||
-- (scope, subject, kind) when arbitration looks for a colliding condition.
|
||||
CREATE INDEX IF NOT EXISTS "run_conditions_target_idx"
|
||||
ON "run_conditions" ("target_kind", "target_id");
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "run_conditions_subject_idx"
|
||||
ON "run_conditions" ("scope", "subject", "kind");
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "run_conditions_ts_idx"
|
||||
ON "run_conditions" ("ts");
|
||||
--> statement-breakpoint
|
||||
DROP TABLE IF EXISTS "spec_delta_events";
|
||||
@@ -0,0 +1,21 @@
|
||||
-- Injection → adoption: record which injected claims the drafter actually cited.
|
||||
--
|
||||
-- Hand-written (same convention as 0003): two additive nullable columns on an
|
||||
-- existing table, which drizzle-kit would render identically but with a
|
||||
-- generated name that says nothing about why.
|
||||
--
|
||||
-- NULL vs '[]' is load-bearing and must not be collapsed to a default:
|
||||
-- NULL — nobody reported. Either the run predates the citation contract or
|
||||
-- the node's bundle is older than it. "Unknown", not "zero".
|
||||
-- '[]' — the drafter reported and adopted nothing. That is a real,
|
||||
-- actionable measurement (retrieval returned junk).
|
||||
-- Giving this column a DEFAULT '[]' would silently turn every historical row
|
||||
-- into "adopted nothing" and make the first weeks of hit-rate data a lie.
|
||||
|
||||
ALTER TABLE "kb_injections" ADD COLUMN IF NOT EXISTS "used_claim_ids" text;
|
||||
ALTER TABLE "kb_injections" ADD COLUMN IF NOT EXISTS "used_at" bigint;
|
||||
|
||||
-- recordKbUsage looks up the newest injection for (target_kind, target_id, stage)
|
||||
-- on every citation report, and the drawer reads by (target_kind, target_id).
|
||||
CREATE INDEX IF NOT EXISTS "kb_injections_target_idx"
|
||||
ON "kb_injections" ("target_kind", "target_id", "ts" DESC);
|
||||
@@ -0,0 +1,29 @@
|
||||
-- 无法复现的产出化 — the reporter-facing write-back for an unreproducible run.
|
||||
--
|
||||
-- Keyed on target_id (one row per task) rather than an autonomous id: a ticket
|
||||
-- receives exactly ONE such comment, and making that a primary key is what
|
||||
-- prevents a double-post at the storage layer instead of relying on a check in
|
||||
-- application code that a retry could race past.
|
||||
--
|
||||
-- posted_at is the irreversibility marker: once set, the body on this row is
|
||||
-- what a human on another team actually read, so regeneration and editing are
|
||||
-- both refused past that point (see unrepro_digest.ts).
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "unrepro_digests" (
|
||||
"target_id" text PRIMARY KEY NOT NULL,
|
||||
"category" text NOT NULL,
|
||||
"suggested_category" text NOT NULL,
|
||||
"signals" text,
|
||||
"body" text NOT NULL,
|
||||
"attempts" bigint,
|
||||
"condition_count" bigint,
|
||||
"evidence_count" bigint,
|
||||
"generated_at" bigint NOT NULL,
|
||||
"posted_at" bigint,
|
||||
"posted_by" text,
|
||||
"post_error" text
|
||||
);
|
||||
|
||||
-- The console's "which unrepro tasks still owe the reporter an answer?" query.
|
||||
CREATE INDEX IF NOT EXISTS "unrepro_digests_posted_idx"
|
||||
ON "unrepro_digests" ("posted_at");
|
||||
@@ -0,0 +1,31 @@
|
||||
-- 业务域 — knowledge ownership and subscription.
|
||||
--
|
||||
-- A domain is a MUTABLE many-to-one label over claims. It is deliberately not
|
||||
-- scope_key: that column is the arbitration conflict key, and it must stay
|
||||
-- byte-stable forever or historical "did these two claims collide?" answers
|
||||
-- change retroactively. Org structure does not have that property, so it gets
|
||||
-- its own layer that can be recomputed at will (kb_domains.ts::reattributeAll).
|
||||
--
|
||||
-- Knowledge remains globally shared: nothing in retrieval reads domain_key. This
|
||||
-- table answers "who should look at this when it's contested", never "who may
|
||||
-- use it".
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "kb_domains" (
|
||||
"key" text PRIMARY KEY NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"owner_group" text,
|
||||
"owner_email" text,
|
||||
"match_rules" text NOT NULL,
|
||||
"priority" bigint DEFAULT 100 NOT NULL,
|
||||
"created_by" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"updated_at" bigint NOT NULL
|
||||
);
|
||||
|
||||
-- NULL = unattributed, which is the INPUT to the clustering suggestions rather
|
||||
-- than an error — hence nullable with no default and no FK: deleting a domain
|
||||
-- nulls its claims explicitly (deleteDomain), and a dangling key would hide
|
||||
-- claims from both the domain filter and the unattributed list at once.
|
||||
ALTER TABLE "kb_claims" ADD COLUMN IF NOT EXISTS "domain_key" text;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "kb_claims_domain_idx" ON "kb_claims" ("domain_key");
|
||||
@@ -0,0 +1,44 @@
|
||||
-- 节点健康 — per-minute rollup of satellite host vitals.
|
||||
--
|
||||
-- Granularity is the whole design. Satellites heartbeat every 10s; writing a row
|
||||
-- per heartbeat would be ~60k rows/day for 7 nodes and grow forever. Rolling up
|
||||
-- to one row per node per minute makes it ~10k/day, and the retention sweep
|
||||
-- (node_health.ts::pruneNodeMetrics, 30 days) holds the table at a CONSTANT
|
||||
-- ~300k rows. A table that doesn't grow is one nobody has to deal with later —
|
||||
-- that is worth more here than the resolution we give up.
|
||||
--
|
||||
-- avg AND max because they answer different questions: avg is what a trend line
|
||||
-- plots, max is what a threshold was crossed by. A disk filling up over ten
|
||||
-- seconds is a spike a one-minute average swallows whole.
|
||||
--
|
||||
-- The CURRENT value of each metric is deliberately NOT here. It lives in control
|
||||
-- plane memory (same call as nodes.pendingDeploy): the node owns that truth and
|
||||
-- re-asserts it every ~10s, so a restart re-learns it within one heartbeat, and
|
||||
-- a last-known CPU reading is worthless after a restart anyway.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "node_metrics" (
|
||||
"node_id" text NOT NULL,
|
||||
-- Start of the minute bucket, epoch ms.
|
||||
"at" bigint NOT NULL,
|
||||
"cpu_avg" double precision,
|
||||
"cpu_max" double precision,
|
||||
"mem_avg" double precision,
|
||||
"mem_max" double precision,
|
||||
"disk_avg" double precision,
|
||||
"disk_max" double precision,
|
||||
"load_max" double precision,
|
||||
"swap_max_bytes" bigint,
|
||||
-- Samples folded into this bucket; a value below the expected count is how a
|
||||
-- reader spots a gap rather than misreading it as a flat line.
|
||||
"samples" bigint DEFAULT 0 NOT NULL,
|
||||
CONSTRAINT "node_metrics_node_id_at_pk" PRIMARY KEY("node_id","at")
|
||||
);
|
||||
|
||||
-- Every metric column is nullable on purpose: a probe that failed must record
|
||||
-- "unknown", never 0. A zeroed disk reading would mean "plenty of room" on
|
||||
-- precisely the node we can no longer measure, and the alarm would stay silent.
|
||||
|
||||
-- The primary key already indexes (node_id, at), which is the panel's range
|
||||
-- scan. This second index serves the retention sweep, which deletes by age
|
||||
-- across all nodes and would otherwise seq-scan the whole table every hour.
|
||||
CREATE INDEX IF NOT EXISTS "node_metrics_at_idx" ON "node_metrics" ("at");
|
||||
@@ -0,0 +1,159 @@
|
||||
-- RSI 闭环 — the platform measuring, proposing on, and changing its own method.
|
||||
--
|
||||
-- Five tables, three of which are the evidmon loop's shape re-pointed at fix
|
||||
-- quality (snapshot → finding → strategy → approval → measured effect). They are
|
||||
-- NOT a `domain` column on the evidmon tables: the two loops trend different
|
||||
-- metrics on different cadences, and sharing a table would make every existing
|
||||
-- evidmon query filter for a distinction it never cares about.
|
||||
--
|
||||
-- Nothing here decides anything on its own. A strategy leaves `proposed` only
|
||||
-- because a logged-in owner said so, and `effective_at` is stamped at that
|
||||
-- moment — so a before/after window can never be redrawn afterwards to flatter
|
||||
-- the result. The analyst that WRITES proposals authenticates with the cluster
|
||||
-- secret and is structurally unable to approve them.
|
||||
|
||||
-- One day's fix-quality metric tree (JSON QualitySnapshot). Written by
|
||||
-- control-server/src/rsi_daily.ts on a machine timer, never by the analyst: a
|
||||
-- day nobody analysed must still leave a data point, or the before/after series
|
||||
-- grows holes exactly where an outage was.
|
||||
CREATE TABLE IF NOT EXISTS "rsi_metrics_daily" (
|
||||
"day" text PRIMARY KEY NOT NULL,
|
||||
"generated_at" bigint NOT NULL,
|
||||
"metrics" text NOT NULL
|
||||
);
|
||||
|
||||
-- The research log. `clusters` holds the deterministic failure-mode grouping the
|
||||
-- entry was written on top of, so a finding can always be traced back to the
|
||||
-- concrete rejections that produced it rather than to a model's recollection.
|
||||
CREATE TABLE IF NOT EXISTS "rsi_findings" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"day" text NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"summary" text NOT NULL,
|
||||
"highlights" text,
|
||||
"findings" text,
|
||||
"metrics_snapshot" text,
|
||||
"deltas" text,
|
||||
"clusters" text,
|
||||
"author" text NOT NULL,
|
||||
"created_at" bigint NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "rsi_findings_day_idx" ON "rsi_findings" ("day");
|
||||
|
||||
-- A proposal and its life. `knob` decides what approval DOES: only 'prompt' is
|
||||
-- self-executing (it writes an agent_prompts row and re-points the active
|
||||
-- pointer, live on the next dispatch, no redeploy). 'tool' / 'workflow' /
|
||||
-- 'capability' become tracked todos — that is code someone has to ship.
|
||||
CREATE TABLE IF NOT EXISTS "rsi_strategies" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"finding_id" text,
|
||||
"day" text NOT NULL,
|
||||
"code" text NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"rationale" text NOT NULL,
|
||||
"knob" text NOT NULL,
|
||||
"metric_key" text NOT NULL,
|
||||
"baseline_value" double precision,
|
||||
"target_value" double precision,
|
||||
"payload" text,
|
||||
"replay" text,
|
||||
"status" text NOT NULL,
|
||||
"decided_by" text,
|
||||
"decided_at" bigint,
|
||||
"decision_note" text,
|
||||
"effective_at" bigint,
|
||||
"before_value" double precision,
|
||||
"after_value" double precision,
|
||||
"prompt_id" text,
|
||||
"created_at" bigint NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "rsi_strategies_status_idx" ON "rsi_strategies" ("status");
|
||||
|
||||
-- Versioned agent prompts. Only stages the control plane can HAND DOWN belong
|
||||
-- here (today: eval / regen, which ride with the work item). A stage whose
|
||||
-- template is still compiled into the satellite bundle would give a library
|
||||
-- whose active row and running code disagree — worse than no library.
|
||||
--
|
||||
-- No `active` column: the pointer lives in settings as `rsiActivePrompt:<stage>`.
|
||||
-- A boolean here would need a transaction to move and could represent "two
|
||||
-- actives" as a state; a single settings row cannot.
|
||||
CREATE TABLE IF NOT EXISTS "agent_prompts" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"stage" text NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"template" text NOT NULL,
|
||||
"notes" text,
|
||||
"parent_id" text,
|
||||
"strategy_id" text,
|
||||
"created_by" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"archived" bigint DEFAULT 0 NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "agent_prompts_stage_idx" ON "agent_prompts" ("stage");
|
||||
|
||||
-- One offline replay of a candidate prompt against a historical target, scored
|
||||
-- against what execution later PROVED on a device (run_conditions), never
|
||||
-- against another model's opinion. `output` is kept verbatim so every score
|
||||
-- stays recomputable when the scorer itself changes.
|
||||
CREATE TABLE IF NOT EXISTS "agent_prompt_runs" (
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"batch_id" text,
|
||||
"prompt_id" text,
|
||||
"prompt_name" text,
|
||||
"stage" text NOT NULL,
|
||||
"target_kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"target_title" text,
|
||||
"status" text DEFAULT 'running' NOT NULL,
|
||||
"output" text,
|
||||
"score" text,
|
||||
"error" text,
|
||||
"node_id" text,
|
||||
"model" text,
|
||||
"duration_ms" bigint,
|
||||
"created_by" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"finished_at" bigint
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "agent_prompt_runs_batch_idx" ON "agent_prompt_runs" ("batch_id");
|
||||
CREATE INDEX IF NOT EXISTS "agent_prompt_runs_prompt_idx" ON "agent_prompt_runs" ("prompt_id");
|
||||
|
||||
-- Repeated hand-rolled command sequences mined from session logs: the queue of
|
||||
-- things that should stop being prompt instructions and become tools. Keyed by a
|
||||
-- NORMALISED signature (paths / ids / hashes stripped) so one intent from twenty
|
||||
-- tasks is one row; `sample` keeps a real command, because nobody can build a
|
||||
-- tool from a redacted skeleton.
|
||||
CREATE TABLE IF NOT EXISTS "rsi_tool_gaps" (
|
||||
"signature" text PRIMARY KEY NOT NULL,
|
||||
"sample" text NOT NULL,
|
||||
"category" text,
|
||||
"runs" bigint DEFAULT 0 NOT NULL,
|
||||
"targets" bigint DEFAULT 0 NOT NULL,
|
||||
"nodes" text,
|
||||
"fail_runs" bigint DEFAULT 0 NOT NULL,
|
||||
"first_seen_at" bigint NOT NULL,
|
||||
"last_seen_at" bigint NOT NULL,
|
||||
"updated_at" bigint NOT NULL,
|
||||
"status" text DEFAULT 'open' NOT NULL,
|
||||
"strategy_id" text
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "rsi_tool_gaps_status_idx" ON "rsi_tool_gaps" ("status");
|
||||
|
||||
-- The Fix-Critic's verdict CLASS, alongside the risk score it already stamps.
|
||||
--
|
||||
-- `fixed_risk` alone cannot answer "was this a scenario band-aid": the score is
|
||||
-- a scalar the critic may also default, and until now the class survived only
|
||||
-- inside prose (failure_reason / a review note) that rsi_metrics has to
|
||||
-- regex-match. The column makes 根因率 / 场景旁路率 first-class. Nullable and
|
||||
-- backfill-free on purpose — the metric falls back to parsing for rows written
|
||||
-- before the nodes carry a bundle that fills it.
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "critic_verdict" text;
|
||||
|
||||
-- kb_injections.outcome / evaluated_at already exist (0002_flaky_sprite.sql) and were
|
||||
-- never written. kb_outcome.ts is what finally closes that loop — no DDL needed,
|
||||
-- which is the whole reason those columns were reserved up front.
|
||||
@@ -0,0 +1,18 @@
|
||||
-- readable_prompts 的版本链。
|
||||
--
|
||||
-- 这张表从建起来就少一样东西:`parent_id`。`agent_prompts` 一开始就有它(见
|
||||
-- 0008_rsi.sql),而报告提示词库没有 —— 于是两套本该同构的库里,只有一套答得出
|
||||
-- 「这一版替换掉了什么」。更糟的是编辑路径:lab_db.updatePrompt 直接 UPDATE
|
||||
-- `template`,旧正文当场消失,唯一残留是碰巧用过它的某次运行在
|
||||
-- `readable_report_runs.promptTemplate` 里存下的快照 —— 那是运行记录,不是版本。
|
||||
--
|
||||
-- 加了这一列之后,改正文变成 INSERT + parent_id 指回旧行(copy-on-write),
|
||||
-- 旧正文永远还在。历史行的 parent_id 为 NULL,它们各自是自己血缘的根,这与
|
||||
-- 事实相符:在此之前的确没有链可言。
|
||||
--
|
||||
-- 纯加列,可空,无默认值 —— 不重写任何现有行,也不影响任何现有查询。
|
||||
ALTER TABLE "readable_prompts" ADD COLUMN IF NOT EXISTS "parent_id" text;
|
||||
|
||||
-- 血缘查询走的是「谁的 parent 是我」(算 head)与「我的 parent 是谁」(往上走)。
|
||||
-- 前者是全表扫描,加索引;后者走主键,不用。
|
||||
CREATE INDEX IF NOT EXISTS "readable_prompts_parent_id_idx" ON "readable_prompts" ("parent_id");
|
||||
@@ -0,0 +1,43 @@
|
||||
-- 多轮执行的过程留存:每批的会话摘要 + feature 的 ImplReport 逐批归档。
|
||||
--
|
||||
-- 在这之前,一个跑了 N 批的任务在系统里只留得下「最后一批」的过程:节点上
|
||||
-- `logs/session.log` 每批被 openSync("w") 截断重写,DB 里则什么都没有。生产实测
|
||||
-- 122/358 个 bug 任务、92/183 个 feature 跑过 ≥2 批 —— 也就是说三分之一到一半的
|
||||
-- 任务,其早期批次的执行过程是不可考的。轮次化文件名(session-r{N}.log)解决了
|
||||
-- 同一节点上的互相覆盖,但解决不了节点重装 / 工作区被清 / 任务改派,那一层必须
|
||||
-- 落到 DB。
|
||||
--
|
||||
-- 两张表都是纯新增,不改任何现有表、不重写任何现有行。
|
||||
|
||||
-- 每批执行的会话摘要:卫星就地把几 MB 的 stream-json 压成几 KB 的结构化事实
|
||||
-- (工具调用计数、失败的命令、报错、动过的文件、终止哨兵),控制面在每批结束时
|
||||
-- 拉一次。原始日志仍然只在节点盘上 —— 那里面有工单正文和环境细节,整份搬走是
|
||||
-- 导出而不是归档。
|
||||
--
|
||||
-- 三种任务类型共用一张表(kind 区分):摘要的形状与任务类型无关,这是少数几个
|
||||
-- 真能共用的东西。也因此没有外键 —— target_id 可能指向 tasks / features / security
|
||||
-- 三张表中的任意一张。
|
||||
CREATE TABLE IF NOT EXISTS "round_digests" (
|
||||
"kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"round" bigint NOT NULL,
|
||||
"digest" text NOT NULL,
|
||||
"node_id" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
CONSTRAINT "round_digests_pk" PRIMARY KEY ("kind", "target_id", "round")
|
||||
);
|
||||
|
||||
-- 「这个任务的各批摘要」是唯一的查询形态,主键前缀已经覆盖,不另加索引。
|
||||
|
||||
-- feature 的 ImplReport 逐批归档 —— bug 侧 fix_report_versions 的对应物。
|
||||
-- 节点上只有一份 ImplReport.md,提示词要求 agent 每批往里追加一段,但那是「请它
|
||||
-- 守规矩」不是机制:它整篇重写、或者节点在报告生成前就没了,早期批次就没了。
|
||||
CREATE TABLE IF NOT EXISTS "impl_report_versions" (
|
||||
"feature_id" text NOT NULL,
|
||||
"round" bigint NOT NULL,
|
||||
"markdown" text NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
CONSTRAINT "impl_report_versions_pk" PRIMARY KEY ("feature_id", "round"),
|
||||
CONSTRAINT "impl_report_versions_feature_id_fk"
|
||||
FOREIGN KEY ("feature_id") REFERENCES "features"("id") ON DELETE CASCADE
|
||||
);
|
||||
@@ -0,0 +1,35 @@
|
||||
-- 可读性报告默认双语:每份报告除主语言外,再存一份对照语言版本。
|
||||
--
|
||||
-- 在这之前,一份报告只有一个语种:`tasks.lang` / `features.lang` 决定生成时用中文
|
||||
-- 还是英文,产物落在 `readable_report_html` 这一列上。跨语言的复核方(海外同学看
|
||||
-- 中文任务、国内同学看英文任务)只能对着一份看不懂的报告,或者回去读原始
|
||||
-- FixReport.md —— 而那正是可读性报告存在的理由。
|
||||
--
|
||||
-- 生产实测:tasks 316 zh / 46 en,features 93 zh / 36 en(另有 59 行 lang 为空,
|
||||
-- 按 zh 处理)。也就是说英文任务不是边角料,占了约 15%,所以这里刻意**不**把新列
|
||||
-- 命名为 `_en`:主列存的是该任务自己的语言,新列存的是**另一种**语言,`alt_lang`
|
||||
-- 明确记下它到底是哪一种。一个 lang=en 的任务,主列是英文、alt 列是中文。
|
||||
--
|
||||
-- 纯新增列,不改写任何现有行:存量报告的 alt 列为 NULL(= 只有单语),由报告实验室
|
||||
-- 的「存量更新」按语言维度补齐。
|
||||
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "readable_report_alt_html" text;
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "readable_report_alt_lang" text;
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "readable_report_alt_generated_at" bigint;
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "readable_report_alt_error" text;
|
||||
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "readable_report_alt_html" text;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "readable_report_alt_lang" text;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "readable_report_alt_generated_at" bigint;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "readable_report_alt_error" text;
|
||||
|
||||
-- 版本归档也要分语种:同一个提示词版本现在会产出两条 run(主语言一条、对照语言
|
||||
-- 一条)。报告页的版本切换器按语种过滤,否则切「版本」会切成另一个语言的报告。
|
||||
-- 存量 run 为 NULL —— 读的时候按「该任务的主语言」解释,和它当时的实际行为一致。
|
||||
ALTER TABLE "readable_report_runs" ADD COLUMN IF NOT EXISTS "lang" text;
|
||||
|
||||
-- 批量作业的语言口径:
|
||||
-- primary —— 只重跑主语言(这一列加上之前的全部历史作业都是这个语义)
|
||||
-- both —— 重跑主语言 + 生成对照语言
|
||||
-- alt-only —— 不动现有报告,只补对照语言(存量双语补齐的常用档)
|
||||
ALTER TABLE "readable_batch_jobs" ADD COLUMN IF NOT EXISTS "lang_mode" text NOT NULL DEFAULT 'primary';
|
||||
@@ -0,0 +1,19 @@
|
||||
-- Bug 的 Git 基线:`tasks.base_ref`。
|
||||
--
|
||||
-- 在这之前 bug 的基线是一个进程级常量(satellite 的 `BASE_BRANCH`,生产上是
|
||||
-- develop),所以「工程师在自己的 feature 分支上验收时发现的 bug」根本无法表达:
|
||||
-- 复现会在错误的代码上进行,修完的 MR 也会开回主干。
|
||||
--
|
||||
-- 这一列就是那条基线的任务级覆盖。NULL ⇒ 主干,也就是这一列存在之前的全部行为,
|
||||
-- 因此现有的每一行都不需要回填,也不会有任何语义变化 —— 这是纯新增列,不改约束、
|
||||
-- 不重写任何行。
|
||||
--
|
||||
-- 消费者有四个,且都在代码里而不是提示词里(这也是它必须是一列而不是描述里一句话
|
||||
-- 的原因):修复 runner 的首修检出、Fix-Critic 的 diff 基线、开 MR 的 targetBranch、
|
||||
-- 评估阶段的独立 worktree。
|
||||
--
|
||||
-- 三条 track 平行定义:security 已有语义相近的 `security.target_ref`
|
||||
-- (「构建哪个版本来搜证」),feature 暂时没有对应需求。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "base_ref" text;
|
||||
|
||||
-- 不加索引:base_ref 只被按 id 取出的单行读用到,从不作为查询条件。
|
||||
@@ -0,0 +1,28 @@
|
||||
-- 埋点影响的机械扫描结论:`tasks.tracking_impact` / `features.tracking_impact`。
|
||||
--
|
||||
-- 背景是一类没有任何环节能拦住的破坏:改动碰坏了业务埋点(event tracking,业务代码
|
||||
-- 里的数据上报调用)。它不影响功能验收 —— 删掉一个 onEventV3,App 照跑,复现路径照
|
||||
-- 过,四类门槛一条都不会红,执行 Agent 判 FIXED、Fix-Critic 判 ROOT_CAUSE、可读性
|
||||
-- 报告绿标,全流程绿到底,等到数据周报才有人发现,那时 MR 早已合入。
|
||||
--
|
||||
-- 提示词里加一条「不要破坏埋点」是必要的,但不够:那条规则的执行者正是那个会犯错的
|
||||
-- 模型。所以真值来自卫星收尾时对 `git diff <base>...HEAD` 的一次机械匹配
|
||||
-- (satellite/src/tracking_scan.ts),这一列就是那次扫描的结论。
|
||||
--
|
||||
-- 为什么是列而不是报告里的一段话:消费者是代码,不是人。卡片上的醒目标记、飞书通知
|
||||
-- 里发给提需人的那一行、以及未来按「动过埋点」筛选,都不能依赖模型在报告里写了什么,
|
||||
-- 而这恰恰是最不能依赖模型的一件事。
|
||||
--
|
||||
-- 存 JSON TEXT 而不是拆成若干列,与 review_history / attachments 同一个理由:它整体
|
||||
-- 被读、整体被写,从不作为查询条件,拆开只会换来一堆永远一起出现的空列。
|
||||
--
|
||||
-- NULL ⇒ 没扫过。这包括这一列存在之前的全部历史行,因此不需要任何回填,也不会有语义
|
||||
-- 变化 —— 纯新增列,不改约束、不重写任何行。注意 NULL(没扫过)与
|
||||
-- `{"verdict":"none"}`(扫过了、干净)语义不同,前端不要合并显示。
|
||||
--
|
||||
-- 三条 track 平行定义(见 CLAUDE.md):bug 与 feature 各加一列;security 是只读搜证、
|
||||
-- 明令禁止 commit,没有 diff 可扫,故不加。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "tracking_impact" text;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "tracking_impact" text;
|
||||
|
||||
-- 不加索引:这一列只被按 id 取出的单行读用到,从不作为查询条件。
|
||||
@@ -0,0 +1,17 @@
|
||||
-- Bug 不再强制有 Meego 工单:`tasks.meego_id` / `tasks.meego_url` 去掉 NOT NULL。
|
||||
--
|
||||
-- 背景:bug 此前只能从 Meego 链接导入,全流程都假设工单号非空。这对线上 bug 是对的
|
||||
-- (它们本来就走 buglist),但把「工程师在自己分支上验收时随手发现的问题」挡在了外面 ——
|
||||
-- 那类问题往往一开始就没有单,逼人先去建一个,只会让这条路没人走。
|
||||
--
|
||||
-- 纯放宽约束,不动数据:现有 399 行全部带工单号,一行都不受影响。unique 索引保留,
|
||||
-- 因为「同一个工单不能导入两次」仍然成立;PG 的 unique 允许多个 NULL,所以无单任务
|
||||
-- 之间不冲突。
|
||||
--
|
||||
-- 注意这一步**不可逆**地放宽了约束:一旦有无单任务落库,就不能再简单地加回 NOT NULL。
|
||||
-- 需要回滚时先删掉 meego_id IS NULL 的行(那才是真正的数据决策,不该藏在迁移里)。
|
||||
--
|
||||
-- 工作区目录**不需要迁移**:key 是 `meegoId ?? id`(shared 的 workspaceKeyOf),
|
||||
-- 对每一个历史任务都仍然解析成原来的工单号,盘上一个目录都不用改名。
|
||||
ALTER TABLE "tasks" ALTER COLUMN "meego_id" DROP NOT NULL;
|
||||
ALTER TABLE "tasks" ALTER COLUMN "meego_url" DROP NOT NULL;
|
||||
@@ -0,0 +1,16 @@
|
||||
-- 合回基线的事实:`tasks.merged_into_base_at`。
|
||||
--
|
||||
-- 特性验收 bug 的「复核通过」不只是改状态,它真的把 `bugfix/<slug>` 合回了
|
||||
-- `base_ref`(卫星 merge + push,见 satellite/src/merge_back.ts)。这一列记的就是
|
||||
-- 那件事发生的时刻。
|
||||
--
|
||||
-- 为什么不复用 mr_state / mr_merged_at:那两列归 mr_sync 所有,值来自 Bits 的看法,
|
||||
-- 每轮轮询都会覆写。我们自己推的这一次合并,Bits 未必认得出来(源分支的 commit 落进
|
||||
-- 目标分支不等于它把那条 MR 标成 merged),于是下一轮轮询就会把"已并入"抹回"待合入"。
|
||||
-- 记自己做过的事,和记外部系统怎么说,是两件事,不该挤在一列里。
|
||||
--
|
||||
-- 前端据此在卡片上显示「已并入 feature/xxx」—— 这一行是刻意的:合进特性分支不等于
|
||||
-- 上线,不写清楚一定会有人以为已经进主干了。
|
||||
--
|
||||
-- NULL ⇒ 没合过(包括全部历史行)。纯新增列,不改约束、不重写任何行。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "merged_into_base_at" bigint;
|
||||
@@ -0,0 +1,23 @@
|
||||
-- 分支所在的代码仓:`tasks.repo_key` / `features.repo_key`。
|
||||
--
|
||||
-- 在这之前,「MR 开在哪个 GitLab project」是 platform 的函数(android → 113818,
|
||||
-- ios → 114467,写死在 control-server/src/bits.ts)。这个假设已经破过一次:一个
|
||||
-- android 的 feature 改的是 IM 的 Lynx 前端,代码只可能落在 `tt_im_monorepo`,
|
||||
-- agent 也确实把分支推到了那里;控制面照旧拿这个分支名去 TikTok 主仓建 MR,GitLab 回
|
||||
--
|
||||
-- Branch is not found: merge request source branch not found
|
||||
--
|
||||
-- 报错说的是「分支不存在」,真相是「找错仓库了」—— 两者在面板上长得一模一样,
|
||||
-- 所以这必须是一列事实,而不是提示词里的一句话或事后靠人眼分辨的报错文案。
|
||||
--
|
||||
-- 值由卫星在收尾时**观测**得出(在各候选检出里 `git ls-remote` 查这条分支),语义三分:
|
||||
-- NULL 没探测过 / 探测失败 → 控制面退回 platform 默认仓,也就是这一列存在
|
||||
-- 之前的全部行为。因此现有的每一行都不需要回填,纯新增列。
|
||||
-- 'unpushed' 查过了,所有已知仓库的远端都没有 → 直接判失败,不去打 Bits。
|
||||
-- 其他 仓库 key(见 shared/src/repos.ts),建 MR 用它的 project / group。
|
||||
--
|
||||
-- 三条 track 平行定义:security 不开 MR,故没有这一列。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "repo_key" text;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "repo_key" text;
|
||||
|
||||
-- 不加索引:repo_key 只被按 id 取出的单行读用到,从不作为查询条件。
|
||||
@@ -0,0 +1,24 @@
|
||||
-- 可读性报告是**哪一批执行**的产物:`tasks.readable_report_round` /
|
||||
-- `features.readable_report_round`,值取生成那一刻的 `attempts`。
|
||||
--
|
||||
-- 在这之前,「屏幕上这份报告说的是不是这一批」这个问题在库里没有答案,面板也就
|
||||
-- 没法回答它。live 列(readable_report_html)刻意只前进不清空 —— 一次失败的重生成
|
||||
-- 不该把上一版好报告抹掉(见 db.ts::markTaskReadableReportError)。代价是:第 N+1 批
|
||||
-- 一派发,页面上挂着的仍是第 N 批那份报告,绿标、结论、验证截图一应俱全,而它描述的
|
||||
-- 事情已经被推翻了。看的人没有任何线索能分辨,于是把上一批的结论当成这一批的。
|
||||
--
|
||||
-- `readable_report_generated_at` 顶不上这个位置:失败路径会把它推到 now()
|
||||
-- (只写 error、不写 html),于是「时间很新」和「正文很新」是两回事。批次号只在
|
||||
-- **生成成功**时写,语义单一。
|
||||
--
|
||||
-- NULL ⇒ 这一列存在之前生成的存量报告。不回填:那些行的真实批次没有可靠来源
|
||||
-- (attempts 是当前值,不是生成时的值),猜一个写进去就等于制造假事实。前端对 NULL
|
||||
-- 的退化行为是「按状态判断」—— 正在执行/排队时照样提示过期,只是终态那一档
|
||||
-- (报告还在生成中)对存量行不提示。
|
||||
--
|
||||
-- 三条 track 不平行:security 没有可读性报告流水线(面板直接渲染 EvidenceReport.md),
|
||||
-- 和 0011 的 alt 列组同理,故只有 tasks / features 两张表。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "readable_report_round" bigint;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "readable_report_round" bigint;
|
||||
|
||||
-- 不加索引:这一列只被按 id 取出的单行读用到,从不作为查询条件。
|
||||
@@ -0,0 +1,27 @@
|
||||
-- 可读性报告的生成记录是**哪一批执行**的:`readable_report_runs.round`。
|
||||
--
|
||||
-- 归档这件事本来就有两半,之前只有一半是按批次组织的:
|
||||
--
|
||||
-- - 原始报告(FixReport.md / ImplReport.md)早就按批次存进了
|
||||
-- `fix_report_versions` / `impl_report_versions`(键是 (target, round))——
|
||||
-- 节点上只有一份文件、agent 每批就地重写,不抢在下一批开工前拍下来就没了。
|
||||
-- - 可读性报告(大白话正文)存在 `readable_report_runs` 里,但那张表是按
|
||||
-- **prompt 版本**组织的:面板上的版本切换器回答的是「这份报告是哪版提示词写
|
||||
-- 的」,而不是「第 8 批那次实现,当时的报告长什么样」。
|
||||
--
|
||||
-- 于是「翻回去看上一批的报告」在库里是拼不出来的:raw markdown 有批次、正文没有。
|
||||
-- 这一列把正文也接上同一把尺子——生成开工时目标跑到第几批就记第几批,之后按
|
||||
-- (target, round) 就能把两半对上,前端的批次切换器才有得可选。
|
||||
--
|
||||
-- NULL ⇒ 这一列之前的存量 run。同样不回填:run 行没有留下它当时对着的是第几批,
|
||||
-- 拿目标此刻的 attempts 去补,等于把每一份历史正文都标成「最新那批的」——那正是
|
||||
-- 这套东西要防的事。存量批次仍然能看:raw markdown 的归档是全的,前端对这种批次
|
||||
-- 显示原始报告并标明「该批没有大白话版本」。
|
||||
--
|
||||
-- 三条 track:security 没有可读性报告流水线,这张表里也就没有它的行。
|
||||
ALTER TABLE "readable_report_runs" ADD COLUMN IF NOT EXISTS "round" bigint;
|
||||
|
||||
-- 批次切换器要按 (目标, 批次) 找那一批的 run,列表页从不按它筛,所以只建这一条
|
||||
-- 复合索引,且带上 target_type —— 两条 track 的 id 空间是分开的。
|
||||
CREATE INDEX IF NOT EXISTS "readable_report_runs_target_round_idx"
|
||||
ON "readable_report_runs" ("target_type", "target_id", "round");
|
||||
@@ -0,0 +1,84 @@
|
||||
-- 知识库从「什么都记」走到「只把可复用的喂回去」。
|
||||
--
|
||||
-- ## 为什么要加这三列
|
||||
--
|
||||
-- 2026-08-21 对生产做了一次实测,结论不含糊:
|
||||
--
|
||||
-- - 3,748 条 claim 里,只有 **7 条**拿到过一个以上任务的证据;
|
||||
-- 3,595 个已核实条件的 subject 里,只有 **9 个**在第二个任务里再出现过。
|
||||
-- - 688 次注入里 649 次撞满 K=10 上限(检索是「任一词 LIKE 任一字段」+ 只按
|
||||
-- confidence 排序,等于按置信度取前十),条目级引用率 **3.6%**。
|
||||
-- - 归因回路一次都没闭合过:49,483 对 claim × 真机条件,精确配对命中 0 次。
|
||||
--
|
||||
-- 也就是说这个库当时**几乎是一次性的**:每条知识只在它诞生的那个任务里成立过一次,
|
||||
-- 之后再没被碰到,却仍然每次都被塞进十条给下一个人看。
|
||||
--
|
||||
-- `tier` —— 这条知识**能不能被检索**。episodic 只当证据留着,不进 prompt;
|
||||
-- semantic 才进检索池。凭本事晋升(第二个任务见证过)或
|
||||
-- 凭出身(env / account 这类与具体任务无关的事实、人工录入)。
|
||||
-- `injected_count` —— 被摆到起草者面前过几次。
|
||||
-- `cited_count` —— 其中被引用回来过几次。两者之比就是「有用度」,直接进排序。
|
||||
--
|
||||
-- 前两周的 `kb_injections` 已经攒了真实的引用数据,下面把它回填进计数器 ——
|
||||
-- 新排序上线第一天就有三周的反馈可用,而不是从零开始学。
|
||||
--
|
||||
-- ## 为什么 tier 的默认值是 episodic 而不是 semantic
|
||||
--
|
||||
-- 默认值决定了「漏判往哪边倒」。倒向 episodic 的代价是一条本可复用的知识暂时不被
|
||||
-- 注入(下次同类任务再见证一次就自动晋升);倒向 semantic 的代价是把这 3,741 条
|
||||
-- 一次性事实原样倒回 prompt 里,也就是回到改造前。所以默认关。
|
||||
|
||||
ALTER TABLE "kb_claims" ADD COLUMN IF NOT EXISTS "tier" text NOT NULL DEFAULT 'episodic';
|
||||
ALTER TABLE "kb_claims" ADD COLUMN IF NOT EXISTS "injected_count" bigint NOT NULL DEFAULT 0;
|
||||
ALTER TABLE "kb_claims" ADD COLUMN IF NOT EXISTS "cited_count" bigint NOT NULL DEFAULT 0;
|
||||
ALTER TABLE "kb_claims" ADD COLUMN IF NOT EXISTS "last_injected_at" bigint;
|
||||
|
||||
-- ── 存量分层 ────────────────────────────────────────────────────────────────
|
||||
-- 三条晋升理由,与 kb_db.ts::earnsSemanticTier 里的规则逐条对应(改一处要改两处)。
|
||||
|
||||
-- ① 出身:env / account 天然与具体任务无关 —— 构建命令、设备状态、测试账号,
|
||||
-- 换个 bug 照样成立。实测引用率也印证:env 11.6% / account 6.0%,
|
||||
-- 而 entry_path 0.5% / tricky 0.9%。
|
||||
UPDATE "kb_claims" SET "tier" = 'semantic'
|
||||
WHERE "kind" IN ('env', 'account') AND "status" <> 'deprecated';
|
||||
|
||||
-- ② 出身:人工录入的知识是有人**特意**记下来的,不需要再自证一次。
|
||||
UPDATE "kb_claims" SET "tier" = 'semantic'
|
||||
WHERE "source" = 'human' AND "status" <> 'deprecated';
|
||||
|
||||
-- ③ 本事:被一个以上任务见证过 —— 这是「跨任务复用」唯一的硬证据。
|
||||
UPDATE "kb_claims" SET "tier" = 'semantic'
|
||||
WHERE "status" <> 'deprecated' AND "id" IN (
|
||||
SELECT "claim_id" FROM "kb_evidence" GROUP BY "claim_id"
|
||||
HAVING COUNT(DISTINCT "target_id") > 1
|
||||
);
|
||||
|
||||
-- ── 回填有用度计数 ──────────────────────────────────────────────────────────
|
||||
-- claim_ids / used_claim_ids 是 JSON string[]。展开成行再数,比在应用层跑一遍
|
||||
-- 三周的历史便宜得多,也不需要为回填单独写一个脚本。
|
||||
WITH injected AS (
|
||||
SELECT json_array_elements_text("claim_ids"::json) AS cid, "ts"
|
||||
FROM "kb_injections"
|
||||
), agg AS (
|
||||
SELECT cid, COUNT(*)::bigint AS n, MAX("ts") AS last_ts FROM injected GROUP BY cid
|
||||
)
|
||||
UPDATE "kb_claims" c
|
||||
SET "injected_count" = agg.n, "last_injected_at" = agg.last_ts
|
||||
FROM agg WHERE agg.cid = c."id";
|
||||
|
||||
WITH cited AS (
|
||||
SELECT json_array_elements_text("used_claim_ids"::json) AS cid
|
||||
FROM "kb_injections" WHERE "used_claim_ids" IS NOT NULL
|
||||
), agg AS (
|
||||
SELECT cid, COUNT(*)::bigint AS n FROM cited GROUP BY cid
|
||||
)
|
||||
UPDATE "kb_claims" c SET "cited_count" = agg.n FROM agg WHERE agg.cid = c."id";
|
||||
|
||||
-- ④ 本事(补一条):被起草者真的引用过,就是它有用的直接证据 —— 比「见证过两次」
|
||||
-- 更强,因为那是下游主动采纳。回填完计数器才知道是谁,所以放在这里。
|
||||
UPDATE "kb_claims" SET "tier" = 'semantic'
|
||||
WHERE "cited_count" > 0 AND "status" <> 'deprecated';
|
||||
|
||||
-- 检索每次都按 (tier, status, kind, confidence) 过一遍,且只看没停用的行。
|
||||
CREATE INDEX IF NOT EXISTS "kb_claims_retrieval_idx"
|
||||
ON "kb_claims" ("tier", "status", "kind", "confidence");
|
||||
@@ -0,0 +1,31 @@
|
||||
-- 变更方法对账结论:`tasks.method_coverage` / `features.method_coverage`。
|
||||
--
|
||||
-- 背景是覆盖率这件事上一个结构性缺陷:**分母是模型自己报的**。执行 Agent 用 Frida hook
|
||||
-- 本次改动的方法、记录谁被调用过,然后把结论用散文写进报告的「代码覆盖检查」小节 ——
|
||||
-- 「我改了 6 个方法,其中 4 个跑到了」这句话里的 "6" 没有任何环节校验过。少列两个方法,
|
||||
-- 覆盖率立刻从 4/8 变成好看的 4/6,报告绿标、复核通过,谁也发现不了。
|
||||
--
|
||||
-- 所以真值来自卫星收尾时的一次机械对账(satellite/src/coverage_scan.ts):从
|
||||
-- `git diff <base>...HEAD` 解析出本次改动的每一个方法及其行区间,再与 Agent 落盘的
|
||||
-- Frida 命中并集对上账。这一列就是那次对账的结论。
|
||||
--
|
||||
-- 注意这一列里两种权威度不同的东西**在字段里就被分开**了:每条记录的 `source` 标明
|
||||
-- 状态来自命中文件还是报告自述 —— 机械扫描对「改了哪些方法」是权威的,对「跑没跑到」
|
||||
-- 只是转述。消费方不要把后者当成机器实测,否则就是把模型自述洗成了硬证据。
|
||||
--
|
||||
-- 为什么是列而不是只留在报告里:报告那一节是给人读的,而「对账不一致率」这类指标的
|
||||
-- 消费者是代码。`verdict = 'mismatch'` 是这套东西第一周最有价值的产出,它同时体检了
|
||||
-- 覆盖采集的可靠性和报告的诚实度。
|
||||
--
|
||||
-- 存 JSON TEXT 而不是拆成若干列,与 tracking_impact / review_history 同一个理由:它整体
|
||||
-- 被读、整体被写,从不作为查询条件,拆开只会换来一堆永远一起出现的空列。
|
||||
--
|
||||
-- NULL ⇒ 没对过账。这包括这一列存在之前的全部历史行,因此不需要任何回填,也不会有语义
|
||||
-- 变化 —— 纯新增列,不改约束、不重写任何行。
|
||||
--
|
||||
-- 三条 track 平行定义(见 CLAUDE.md):bug 与 feature 各加一列;security 是只读搜证、
|
||||
-- 明令禁止 commit,没有 diff 可对,故不加。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "method_coverage" text;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "method_coverage" text;
|
||||
|
||||
-- 不加索引:这一列只被按 id 取出的单行读用到,从不作为查询条件。
|
||||
@@ -0,0 +1,25 @@
|
||||
-- 开放平台 v1:外部系统用 API Key 直接建 bug 任务的两个接口(Meego 导入链接 /
|
||||
-- 通用建任务),密钥本身存 settings KV(openplatform_keys.ts),不需要新表。
|
||||
--
|
||||
-- 这里只需要在 tasks 上落三列,把"这条任务是谁、用哪把 key、带着调用方自己的
|
||||
-- 什么 ID 建出来的"记下来:
|
||||
--
|
||||
-- created_via_key_id —— 建任务时鉴权命中的 key 的稳定 id(openplatform_keys.ts
|
||||
-- 里的 id,不是数据库外键 —— key 列表活在 settings KV)。
|
||||
-- created_via_source —— 那把 key 注册时填的来源标签快照(如 "meego" /
|
||||
-- "jira-crm"),纯展示,key 改名不影响历史任务的展示。
|
||||
-- external_id —— 调用方自己的工单/记录 ID(仅通用建任务接口用得到;
|
||||
-- Meego 导入走 meego_id 去重,这一列为 null)。
|
||||
--
|
||||
-- 为什么去重要按 (created_via_key_id, external_id) 这一对而不是 external_id 单列:
|
||||
-- 两个不同接入方各自选的 external_id 可能撞号(比如都用自增整数 "1001"),把去重
|
||||
-- 范围锁定在"调用的那把 key"上就不会互相踩号;global 唯一反而是错的约束。
|
||||
--
|
||||
-- 两者都非空时才生效(PG 允许多个 NULL 并存,不影响非开放平台创建的任务)。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "created_via_key_id" text;
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "created_via_source" text;
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "external_id" text;
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS tasks_created_via_key_external_id_uidx
|
||||
ON "tasks" ("created_via_key_id", "external_id")
|
||||
WHERE "created_via_key_id" IS NOT NULL AND "external_id" IS NOT NULL;
|
||||
@@ -0,0 +1,100 @@
|
||||
-- 附加仓产物(FE / 以后的后端等)。交付仓仍是 tasks/features 上的 repo_key + mr_url,
|
||||
-- 释义固定为 android/ios 客户端仓;附加仓不得再占用那两列。
|
||||
--
|
||||
-- 存量:曾经把 tt_im_monorepo 或开发任务 URL 写进原字段的行,抬进本表并把原字段扳回
|
||||
-- 交付仓释义。没有这类占用的行不插附加记录 —— 涉及集以之后各次运行的 repoList 为准。
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "code_sidecars" (
|
||||
"target_kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"repo_key" text NOT NULL,
|
||||
"branch_name" text,
|
||||
"channel" text NOT NULL,
|
||||
"url" text,
|
||||
"failure_reason" text,
|
||||
"updated_at" bigint NOT NULL,
|
||||
PRIMARY KEY ("target_kind", "target_id", "repo_key")
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS code_sidecars_target_idx
|
||||
ON "code_sidecars" ("target_kind", "target_id");
|
||||
|
||||
INSERT INTO "code_sidecars" (
|
||||
"target_kind", "target_id", "repo_key", "branch_name", "channel", "url", "failure_reason", "updated_at"
|
||||
)
|
||||
SELECT
|
||||
'bug',
|
||||
t.id,
|
||||
'tt-im-monorepo',
|
||||
t.branch_name,
|
||||
'bits-dev-task',
|
||||
CASE
|
||||
WHEN t.mr_url LIKE '%/develop/detail/%' OR t.mr_url LIKE '%devops_space_type=server_fe%' THEN t.mr_url
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN t.failure_reason LIKE 'MR 提交%' AND (t.failure_reason LIKE '%开发任务%' OR t.failure_reason LIKE '%tt_im_monorepo%')
|
||||
THEN t.failure_reason
|
||||
ELSE NULL
|
||||
END,
|
||||
COALESCE(t.status_changed_at, t.created_at)
|
||||
FROM "tasks" t
|
||||
WHERE t.repo_key = 'tt-im-monorepo'
|
||||
OR COALESCE(t.mr_url, '') LIKE '%/develop/detail/%'
|
||||
OR COALESCE(t.mr_url, '') LIKE '%devops_space_type=server_fe%'
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
INSERT INTO "code_sidecars" (
|
||||
"target_kind", "target_id", "repo_key", "branch_name", "channel", "url", "failure_reason", "updated_at"
|
||||
)
|
||||
SELECT
|
||||
'feature',
|
||||
f.id,
|
||||
'tt-im-monorepo',
|
||||
f.branch_name,
|
||||
'bits-dev-task',
|
||||
CASE
|
||||
WHEN f.mr_url LIKE '%/develop/detail/%' OR f.mr_url LIKE '%devops_space_type=server_fe%' THEN f.mr_url
|
||||
ELSE NULL
|
||||
END,
|
||||
CASE
|
||||
WHEN f.failure_reason LIKE 'MR 提交%' AND (f.failure_reason LIKE '%开发任务%' OR f.failure_reason LIKE '%tt_im_monorepo%')
|
||||
THEN f.failure_reason
|
||||
ELSE NULL
|
||||
END,
|
||||
COALESCE(f.status_changed_at, f.created_at)
|
||||
FROM "features" f
|
||||
WHERE f.repo_key = 'tt-im-monorepo'
|
||||
OR COALESCE(f.mr_url, '') LIKE '%/develop/detail/%'
|
||||
OR COALESCE(f.mr_url, '') LIKE '%devops_space_type=server_fe%'
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- 旧卫星 first-hit 写成 sidecar key,等价于交付仓没命中。写成 platform 默认仓会
|
||||
-- 谎称分支在客户端仓上,自动建 MR 就会变成「source branch not found」。
|
||||
UPDATE "tasks"
|
||||
SET "repo_key" = 'unpushed'
|
||||
WHERE "repo_key" = 'tt-im-monorepo';
|
||||
|
||||
UPDATE "features"
|
||||
SET "repo_key" = 'unpushed'
|
||||
WHERE "repo_key" = 'tt-im-monorepo';
|
||||
|
||||
UPDATE "tasks"
|
||||
SET "mr_url" = NULL, "mr_state" = NULL, "mr_merged_at" = NULL, "mr_synced_at" = NULL
|
||||
WHERE "mr_url" LIKE '%/develop/detail/%'
|
||||
OR "mr_url" LIKE '%devops_space_type=server_fe%';
|
||||
|
||||
UPDATE "features"
|
||||
SET "mr_url" = NULL
|
||||
WHERE "mr_url" LIKE '%/develop/detail/%'
|
||||
OR "mr_url" LIKE '%devops_space_type=server_fe%';
|
||||
|
||||
UPDATE "tasks"
|
||||
SET "failure_reason" = NULL
|
||||
WHERE "failure_reason" LIKE 'MR 提交%'
|
||||
AND ("failure_reason" LIKE '%开发任务%' OR "failure_reason" LIKE '%tt_im_monorepo%');
|
||||
|
||||
UPDATE "features"
|
||||
SET "failure_reason" = NULL
|
||||
WHERE "failure_reason" LIKE 'MR 提交%'
|
||||
AND ("failure_reason" LIKE '%开发任务%' OR "failure_reason" LIKE '%tt_im_monorepo%');
|
||||
@@ -0,0 +1,16 @@
|
||||
-- 执行期知识召回 + 显式归因配对(2026-09-02)
|
||||
--
|
||||
-- 两列,对应两个此前无法回答的问题:
|
||||
--
|
||||
-- run_conditions.kb_labels — 「我们注给你的那条知识,你在设备上验证了吗?」
|
||||
-- 归因原先靠比对隔月、跨节点写下的自由散文主题名,1634 次注入只判出 8 条,
|
||||
-- 731 条卡在 inconclusive。agent 记录条件的那一刻手里同时拿着两份文本,
|
||||
-- 它是唯一确定知道配对关系的一方,所以让它直接写下来(conditions record --kb K1)。
|
||||
--
|
||||
-- kb_injections.pulled_ids — 「这条是派发时塞给它的,还是它自己中途查的?」
|
||||
-- 执行期召回把命中的 claim 追加进同一行 claim_ids(K 编号必须连续),
|
||||
-- 这一列记住哪些是「拉」来的,否则两种检索的效果会被混成一个数。
|
||||
--
|
||||
-- 都可空:历史行没有这两个事实,NULL 表示「没说」,不是「没有」。
|
||||
ALTER TABLE run_conditions ADD COLUMN IF NOT EXISTS kb_labels text;
|
||||
ALTER TABLE kb_injections ADD COLUMN IF NOT EXISTS pulled_ids text;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- NULL preserves every legacy task's routing. New tasks store immutable snapshots.
|
||||
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS product_profile text;
|
||||
ALTER TABLE features ADD COLUMN IF NOT EXISTS product_profile text;
|
||||
-- Feature custom branch, aligned with tasks.base_ref.
|
||||
ALTER TABLE features ADD COLUMN IF NOT EXISTS base_ref text;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- TTKB packages are selected per item at creation time and stay independent of
|
||||
-- Streamline's own kbContext. JSON arrays are stored as TEXT, matching clusters.
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "ttkb_packages" text;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "ttkb_packages" text;
|
||||
ALTER TABLE "security" ADD COLUMN IF NOT EXISTS "ttkb_packages" text;
|
||||
@@ -0,0 +1,11 @@
|
||||
-- 本任务已确认涉及的服务端 PSM。JSON 数组存 TEXT,与 clusters / ttkb_packages 一致。
|
||||
--
|
||||
-- 语义上只有两种状态:NULL / 空数组 = 纯客户端任务(线上绝大多数),非空 = 人在
|
||||
-- pending_confirmation 闸上确认过方案里的「服务端范围」。它是字段而不是描述里的一句话,
|
||||
-- 因为消费者是代码:提示词是否注入服务端块、要不要跑 preflight、要不要注入凭据,
|
||||
-- 都按它判断,模型写什么都影响不到。
|
||||
--
|
||||
-- security 不加这一列:那条线是只读搜证、明令禁止 commit,没有服务端交付的语义
|
||||
-- (三条 track 不共用字段,见 CLAUDE.md)。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "psms" text;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "psms" text;
|
||||
@@ -0,0 +1,113 @@
|
||||
-- Eddy(本地 Catalyst 原型运行时)的共享兼容知识:基线登记、问题(signature)、观察遥测、
|
||||
-- 候选/已发布修法、advisory、交接包。设计见 streamline_playground/API.md 与设计文档 §07。
|
||||
--
|
||||
-- 表之间只用字符串键关联(baseline id、signature、fix id@rev),不加外键:客户端先于
|
||||
-- 登记就可能上报观察(离线缓冲后补发),外键会把这类迟到数据整批拒掉。
|
||||
-- JSON 一律存 TEXT(与 clusters / ttkb_packages 一致),载体(guard.js / launch.json /
|
||||
-- pack.zip)按 base64 存 TEXT,上限由路由控制(20 MB);迁到 TOS 是后续优化,不改契约。
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "eddy_baselines" (
|
||||
"id" text PRIMARY KEY,
|
||||
"key" text NOT NULL,
|
||||
"identity" text NOT NULL,
|
||||
"signing" text,
|
||||
"devicesim_commit" text,
|
||||
"eddy_release" text,
|
||||
"adhoc_packs" text,
|
||||
"artifact" text,
|
||||
"registered_at" bigint NOT NULL,
|
||||
"seen_by" text
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "eddy_problems" (
|
||||
"signature" text NOT NULL,
|
||||
"baseline" text NOT NULL,
|
||||
"kind" text NOT NULL,
|
||||
"status" text NOT NULL DEFAULT 'open',
|
||||
"scope" text,
|
||||
"aliases" text,
|
||||
"first_seen" bigint NOT NULL,
|
||||
"last_seen" bigint NOT NULL,
|
||||
PRIMARY KEY ("signature", "baseline")
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "eddy_observations" (
|
||||
"id" text PRIMARY KEY,
|
||||
"ts" bigint NOT NULL,
|
||||
"baseline" text NOT NULL,
|
||||
"signature" text NOT NULL,
|
||||
"kind" text,
|
||||
"machine" text,
|
||||
"user_name" text,
|
||||
"macos" text,
|
||||
"eddy_release" text,
|
||||
"payload" text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "eddy_observations_baseline_sig" ON "eddy_observations" ("baseline", "signature");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "eddy_installs" (
|
||||
"id" text PRIMARY KEY,
|
||||
"ts" bigint NOT NULL,
|
||||
"baseline" text NOT NULL,
|
||||
"fix" text NOT NULL,
|
||||
"rev" bigint NOT NULL,
|
||||
"status" text NOT NULL,
|
||||
"machine" text,
|
||||
"user_name" text,
|
||||
"kind" text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "eddy_installs_fix" ON "eddy_installs" ("fix", "rev");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "eddy_fixes" (
|
||||
"id" text NOT NULL,
|
||||
"rev" bigint NOT NULL,
|
||||
"baseline" text NOT NULL,
|
||||
"tier" text NOT NULL,
|
||||
"problem" text NOT NULL,
|
||||
"title" text,
|
||||
"contract" text,
|
||||
"target" text,
|
||||
"payload_name" text,
|
||||
"payload_sha" text,
|
||||
"payload" text,
|
||||
"manifest" text,
|
||||
"manifest_sha" text,
|
||||
"author" text,
|
||||
"created" bigint NOT NULL,
|
||||
"state" text NOT NULL DEFAULT 'candidate',
|
||||
"evidence" text,
|
||||
"verify" text,
|
||||
"verification" text,
|
||||
PRIMARY KEY ("id", "rev")
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "eddy_fixes_baseline" ON "eddy_fixes" ("baseline");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "eddy_advisories" (
|
||||
"id" text PRIMARY KEY,
|
||||
"baseline" text NOT NULL,
|
||||
"problem" text,
|
||||
"title" text,
|
||||
"body" text NOT NULL,
|
||||
"scope" text,
|
||||
"state" text NOT NULL DEFAULT 'unverified',
|
||||
"author" text,
|
||||
"created" bigint NOT NULL,
|
||||
"manual" bigint NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "eddy_advisories_baseline" ON "eddy_advisories" ("baseline");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "eddy_handoffs" (
|
||||
"id" text PRIMARY KEY,
|
||||
"feature_id" text,
|
||||
"task" text,
|
||||
"key" text,
|
||||
"bundle" text,
|
||||
"area" text,
|
||||
"title" text,
|
||||
"summary" text,
|
||||
"baseline" text,
|
||||
"author" text,
|
||||
"created" bigint NOT NULL,
|
||||
"manifest" text,
|
||||
"zip" text
|
||||
);
|
||||
@@ -0,0 +1,54 @@
|
||||
-- 原型需求(Prototype)—— 第四条 track,见 docs/prototype.md。
|
||||
--
|
||||
-- 与 features 平行、不共用(CLAUDE.md「三种任务类型不要混」现在是四种):没有
|
||||
-- branch / MR / plan / regen / readable 列,因为这条线不交付代码;多出来的四列是它的
|
||||
-- 交付物本身:baseline(在哪个已装 App 上验证)、script / report_markdown(最新一轮的
|
||||
-- Frida 脚本和接手包全文,晋升成 Feature 时要原样带走)、promoted_feature_id。
|
||||
-- 每一轮的脚本 + 报告归档在 prototype_rounds,晋升时能回看演进。
|
||||
CREATE TABLE IF NOT EXISTS "prototypes" (
|
||||
"product_profile" text,
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"description" text DEFAULT '' NOT NULL,
|
||||
"platform" text NOT NULL,
|
||||
"base_ref" text,
|
||||
"remark" text,
|
||||
"attachments" text,
|
||||
"review_feedback" text,
|
||||
"review_history" text,
|
||||
"workspace_path" text,
|
||||
"pinned" bigint DEFAULT 0 NOT NULL,
|
||||
"status" text DEFAULT 'awaiting_prototype' NOT NULL,
|
||||
"priority_key" double precision NOT NULL,
|
||||
"watchers" text,
|
||||
"creator_email" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"started_at" bigint,
|
||||
"finished_at" bigint,
|
||||
"duration_ms" bigint,
|
||||
"total_duration_ms" bigint,
|
||||
"log_path" text,
|
||||
"before_evidence_path" text,
|
||||
"after_evidence_path" text,
|
||||
"failure_reason" text,
|
||||
"attempts" bigint DEFAULT 0 NOT NULL,
|
||||
"executor_node_id" text,
|
||||
"status_changed_at" bigint,
|
||||
"clusters" text,
|
||||
"lang" text,
|
||||
"baseline" text,
|
||||
"script" text,
|
||||
"report_markdown" text,
|
||||
"promoted_feature_id" text
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "prototype_rounds" (
|
||||
"prototype_id" text NOT NULL REFERENCES "prototypes"("id") ON DELETE CASCADE,
|
||||
"round" bigint NOT NULL,
|
||||
"script" text,
|
||||
"markdown" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
PRIMARY KEY ("prototype_id", "round")
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "prototypes_status_idx" ON "prototypes" ("status");
|
||||
@@ -0,0 +1,19 @@
|
||||
-- Eddy 基线:把「有人跑过这个身份」和「官方发布、可下载」拆成两张表。
|
||||
-- eddy_baselines 由客户端层登记(POST /api/eddy/baselines/seen,first-seen、不可变);
|
||||
-- eddy_releases 只由管理员 / 发布流水线写(SSO+admin 或 EDDY_RELEASE_TOKEN),可更新、可下架。
|
||||
-- 下载地址因此永远不会从客户端层进来:0026 里 eddy_baselines.artifact 是客户端可写的,
|
||||
-- 谁先 seen 谁就能给一个新构建塞下载地址——这里把那一列删掉。生产库此时该表还是 0 行。
|
||||
-- 关联只用 baseline_id 字符串,不加外键:发布可能早于任何客户端 seen,也可能晚于。
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "eddy_releases" (
|
||||
"baseline_id" text PRIMARY KEY,
|
||||
"state" text NOT NULL,
|
||||
"artifact" text NOT NULL,
|
||||
"eddy_release" text,
|
||||
"notes" text,
|
||||
"published_by" text,
|
||||
"published_at" bigint NOT NULL,
|
||||
"updated_at" bigint NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE "eddy_baselines" DROP COLUMN IF EXISTS "artifact";
|
||||
@@ -0,0 +1,16 @@
|
||||
-- 原型(prototype)可读性报告 —— media-first。
|
||||
--
|
||||
-- 原设计里 prototype 和 security 一样刻意「不做可读性报告」(面板直接渲染 ProtoReport.md)。
|
||||
-- 现在反悔:原型的价值就是「看效果」,而 media-first 的可读性报告正好把 before/after 截图和
|
||||
-- 演示视频摆到最前面。于是给 prototypes 补上和 features 同一组 readable 列(含双语 alt 组)。
|
||||
-- readable_report_runs / readable_sources 是按 target_type 文本泛化的,不用动。
|
||||
ALTER TABLE "prototypes" ADD COLUMN IF NOT EXISTS "readable_report_html" text;
|
||||
ALTER TABLE "prototypes" ADD COLUMN IF NOT EXISTS "readable_report_generated_at" bigint;
|
||||
ALTER TABLE "prototypes" ADD COLUMN IF NOT EXISTS "readable_report_round" bigint;
|
||||
ALTER TABLE "prototypes" ADD COLUMN IF NOT EXISTS "readable_report_error" text;
|
||||
ALTER TABLE "prototypes" ADD COLUMN IF NOT EXISTS "readable_report_prompt_id" text;
|
||||
ALTER TABLE "prototypes" ADD COLUMN IF NOT EXISTS "readable_report_prompt_name" text;
|
||||
ALTER TABLE "prototypes" ADD COLUMN IF NOT EXISTS "readable_report_alt_html" text;
|
||||
ALTER TABLE "prototypes" ADD COLUMN IF NOT EXISTS "readable_report_alt_lang" text;
|
||||
ALTER TABLE "prototypes" ADD COLUMN IF NOT EXISTS "readable_report_alt_generated_at" bigint;
|
||||
ALTER TABLE "prototypes" ADD COLUMN IF NOT EXISTS "readable_report_alt_error" text;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Eddy 官方基线发布可附带一个「源码快照」包:产品仓在该 App 构建 commit 的全部文本文件
|
||||
-- (baseline-<id>-source.zip,由 build_release.py 用 git archive 切出,接收方不需要 git)。
|
||||
-- 列内容是 JSON {url, sha256, bytes, commit, repo},与 artifact 一样只从管理员层 / 发布流水线进来;
|
||||
-- NULL = 这次发布没有源码包。客户端 `eddy baseline add` 读到它就一起下载校验。
|
||||
|
||||
ALTER TABLE "eddy_releases" ADD COLUMN IF NOT EXISTS "source" text;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- 附加仓产物 JSON:开发任务链接 + bits-pipeline 待跑卡片。
|
||||
-- url 列仍镜像开发任务详情链接(可空),不在这里搬迁。
|
||||
|
||||
ALTER TABLE "code_sidecars"
|
||||
ADD COLUMN IF NOT EXISTS "artifacts" text;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Compatibility knowledge is independent of official baseline releases.
|
||||
-- Preserve legacy records as unclassified/unassessed: never mass-publish on upgrade.
|
||||
ALTER TABLE eddy_problems ADD COLUMN IF NOT EXISTS knowledge text;
|
||||
ALTER TABLE eddy_problems ADD COLUMN IF NOT EXISTS runtime_job text;
|
||||
ALTER TABLE eddy_fixes ADD COLUMN IF NOT EXISTS knowledge text;
|
||||
ALTER TABLE eddy_fixes ADD COLUMN IF NOT EXISTS safety text;
|
||||
ALTER TABLE eddy_advisories ADD COLUMN IF NOT EXISTS knowledge text;
|
||||
ALTER TABLE eddy_advisories ADD COLUMN IF NOT EXISTS safety text;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Catalog availability and model safety assessments are independent decisions.
|
||||
-- Existing rows stay unchanged until an administrator confirms distribution.
|
||||
ALTER TABLE eddy_fixes ADD COLUMN IF NOT EXISTS distribution text;
|
||||
ALTER TABLE eddy_advisories ADD COLUMN IF NOT EXISTS distribution text;
|
||||
@@ -0,0 +1,20 @@
|
||||
CREATE TABLE IF NOT EXISTS eddy_knowledge (
|
||||
id text PRIMARY KEY, latest_revision bigint NOT NULL, enabled bigint NOT NULL DEFAULT 1,
|
||||
author text NOT NULL, updated bigint NOT NULL
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS eddy_knowledge_revisions (
|
||||
knowledge_id text NOT NULL, revision bigint NOT NULL, digest text NOT NULL,
|
||||
document text NOT NULL, author text NOT NULL, created bigint NOT NULL,
|
||||
PRIMARY KEY (knowledge_id, revision)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS eddy_knowledge_assets (sha256 text PRIMARY KEY, data text NOT NULL, bytes bigint NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS eddy_knowledge_refs (
|
||||
knowledge_id text NOT NULL, revision bigint NOT NULL, sha256 text NOT NULL,
|
||||
PRIMARY KEY (knowledge_id, revision, sha256)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS eddy_knowledge_changes (
|
||||
seq bigint PRIMARY KEY, knowledge_id text NOT NULL, revision bigint NOT NULL,
|
||||
enabled bigint NOT NULL, actor text NOT NULL, action text NOT NULL, at bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS eddy_knowledge_changes_latest ON eddy_knowledge_changes(knowledge_id, seq DESC);
|
||||
CREATE INDEX IF NOT EXISTS eddy_knowledge_refs_hash ON eddy_knowledge_refs(sha256);
|
||||
@@ -0,0 +1,15 @@
|
||||
-- One-use PKCE grants and revocable, knowledge-only client sessions. No plaintext secrets.
|
||||
CREATE TABLE IF NOT EXISTS eddy_sso_codes (
|
||||
code_hash text PRIMARY KEY,
|
||||
email text NOT NULL,
|
||||
challenge text NOT NULL,
|
||||
redirect_uri text NOT NULL,
|
||||
expires_at bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS eddy_sso_codes_expiry ON eddy_sso_codes (expires_at);
|
||||
CREATE TABLE IF NOT EXISTS eddy_sso_sessions (
|
||||
token_hash text PRIMARY KEY,
|
||||
email text NOT NULL,
|
||||
expires_at bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS eddy_sso_sessions_expiry ON eddy_sso_sessions (expires_at);
|
||||
@@ -0,0 +1,9 @@
|
||||
-- 「验证」线:feature 的交付物是代码还是报告。
|
||||
--
|
||||
-- 没有另开一张表。验证任务(UI 走查、回归核验、埋点核对)和 feature 共用同一套
|
||||
-- 派发、认领、节点调度和人工复核 —— 差别只在两处:终态不产生分支 / MR,以及
|
||||
-- 可读性报告走确定性渲染而不是模型转述。这两处都由这一列判断。
|
||||
--
|
||||
-- NULL / 'code' = 老行为(实现 + MR);'report' = 只出报告与证据包。
|
||||
ALTER TABLE "features"
|
||||
ADD COLUMN IF NOT EXISTS "deliverable" text;
|
||||
@@ -0,0 +1,18 @@
|
||||
-- Temporary per-feature delivery. Does not publish an official Eddy baseline.
|
||||
CREATE TABLE IF NOT EXISTS eddy_feature_exports (
|
||||
id text PRIMARY KEY,
|
||||
feature_id text NOT NULL REFERENCES features(id) ON DELETE CASCADE,
|
||||
node_id text NOT NULL, commit_sha text NOT NULL, branch text NOT NULL,
|
||||
recipe_hash text NOT NULL, spec text NOT NULL,
|
||||
phase text NOT NULL DEFAULT 'queued',
|
||||
lease text, lease_until bigint,
|
||||
created_at bigint NOT NULL, updated_at bigint NOT NULL, expires_at bigint,
|
||||
error text, result text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS eddy_exports_feature ON eddy_feature_exports(feature_id, created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS eddy_exports_queue ON eddy_feature_exports(node_id, phase, created_at);
|
||||
CREATE TABLE IF NOT EXISTS eddy_export_notifications (
|
||||
export_id text NOT NULL REFERENCES eddy_feature_exports(id) ON DELETE CASCADE,
|
||||
email text NOT NULL, sent_at bigint, next_attempt_at bigint NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (export_id, email)
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
-- 「验证」线的可读性报告是一份**数据**,不是一段 HTML。
|
||||
--
|
||||
-- 第一版做成了静态 HTML,把这条线最值钱的东西丢光了:标注框点不动、问题选不了、
|
||||
-- 选完也回流不到 Streamline。现在节点产出结构化 JSON(覆盖矩阵、逐页问题、截图
|
||||
-- 与标注框、可达性、证据体检),面板用 AuditReportPanel 渲染成可交互视图。
|
||||
--
|
||||
-- readable_report_html 仍然写:里面存的是几 KB 的降级摘要,给飞书卡片/导出用。
|
||||
ALTER TABLE "features"
|
||||
ADD COLUMN IF NOT EXISTS "audit_report" text;
|
||||
@@ -0,0 +1,21 @@
|
||||
-- 走查报告上人写下的东西:「期望怎么改」,以及这条问题最后转成了哪张单。
|
||||
--
|
||||
-- 为什么单开一张表而不是塞进 features.audit_report:那一列是**机器产出**,每次重新
|
||||
-- 生成报告都会被整体覆盖。人写的期望必须活过重新生成 —— 否则复核人边看边写的判断,
|
||||
-- 会在下一次 regen 时静默消失。同理「已转单」也落这里:它是事实,不是视图状态。
|
||||
--
|
||||
-- 主键到 lang:同一条问题在不同语言下是分别核对、分别建单的(见 docs/verify.md)。
|
||||
CREATE TABLE IF NOT EXISTS "audit_notes" (
|
||||
"feature_id" text NOT NULL,
|
||||
"page_id" text NOT NULL,
|
||||
"issue_n" bigint NOT NULL,
|
||||
"lang" text NOT NULL,
|
||||
/** 复核人写的「期望怎么改」。空串等同于没写。 */
|
||||
"note" text,
|
||||
/** 转成了哪张 Bugfix 任务(tasks.id)。非空即「已转」。 */
|
||||
"filed_task_id" text,
|
||||
/** 谁写的 —— 邮箱,和 watchers 同一套标识。 */
|
||||
"author" text,
|
||||
"updated_at" bigint NOT NULL,
|
||||
PRIMARY KEY ("feature_id", "page_id", "issue_n", "lang")
|
||||
);
|
||||
@@ -0,0 +1,10 @@
|
||||
-- 「验证」线的走查规约(JSON)。
|
||||
--
|
||||
-- 为什么要结构化:派发时要按它生成走查 prompt(语言矩阵、用户形态、检查项、报告格式),
|
||||
-- 而不是让人把规约写进自由文本描述里再指望 agent 读懂 —— e5e4c65c 能跑成正是靠后者,
|
||||
-- 那是运气不是机制。
|
||||
--
|
||||
-- 报告格式放在这份 JSON 的 `format` 里(现在只有 'ui-audit'),不单开一列:格式一多,
|
||||
-- 每种自带的字段也不一样,列会长不完。见 shared/src/verify_prompt.ts 的格式注册表。
|
||||
ALTER TABLE "features"
|
||||
ADD COLUMN IF NOT EXISTS "verify_spec" text;
|
||||
@@ -0,0 +1,147 @@
|
||||
-- 「验证」独立成第五条 track(见 docs/verify.md)。
|
||||
--
|
||||
-- 之前它是 `features.deliverable = 'report'` 的 feature:共用表、id、状态机、执行模板,
|
||||
-- 只在报告生成处分叉。代价是它把 Feature 的口径一路污染下去 —— 每日创建 / 完成数、
|
||||
-- 周报、KB 效果、证据指标全都把走查算成 Feature;执行 prompt 是 Feature 模板再在末尾
|
||||
-- 追加一段「前面的规矩这轮不适用」,Feature 模板每次改版都顺带改了验证线的行为。
|
||||
--
|
||||
-- 这份迁移:
|
||||
-- 1. 建 verifications / verification_notes;
|
||||
-- 2. 把现存的验证行(features.deliverable = 'report')连同 audit_report / verify_spec /
|
||||
-- audit_notes 搬过去,id 不变(节点上的工作区 ~/taskLog/<id>/ 和证据路径都按 id 找);
|
||||
-- 3. 把辅表里挂在这些 id 上的 kind / target_type 从 feature 改成 verify / verification;
|
||||
-- 4. 从 features 删掉这些行。
|
||||
--
|
||||
-- 对还在跑的旧进程无害:这里只新建表、搬行、删行,不删 features 的列、不动 audit_notes
|
||||
-- 表结构 —— 旧代码 SELECT 的列都还在。旧列与旧表在新代码上线后由 0037 清掉。
|
||||
--
|
||||
-- 状态映射(feature → verification):
|
||||
-- initializing / info_required / pending_confirmation / awaiting_implementation → awaiting_verify
|
||||
-- implementing → verifying (迁移时若正在跑,该轮结束后由新卫星接不上旧回调 ——
|
||||
-- 见 docs/verify.md「迁移」;线上迁移时两条都在 manual_review)
|
||||
-- manual_review → report_ready
|
||||
-- completed → accepted
|
||||
-- implementation_failed → verify_failed
|
||||
-- archived / cancelled → 同名
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "verifications" (
|
||||
"product_profile" text,
|
||||
"id" text PRIMARY KEY NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"description" text DEFAULT '' NOT NULL,
|
||||
"platform" text NOT NULL,
|
||||
"base_ref" text,
|
||||
"remark" text,
|
||||
"attachments" text,
|
||||
"verify_spec" text,
|
||||
"audit_report" text,
|
||||
"review_feedback" text,
|
||||
"review_history" text,
|
||||
"workspace_path" text,
|
||||
"pinned" bigint DEFAULT 0 NOT NULL,
|
||||
"status" text DEFAULT 'awaiting_verify' NOT NULL,
|
||||
"priority_key" double precision NOT NULL,
|
||||
"watchers" text,
|
||||
"creator_email" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"started_at" bigint,
|
||||
"finished_at" bigint,
|
||||
"duration_ms" bigint,
|
||||
"total_duration_ms" bigint,
|
||||
"log_path" text,
|
||||
"failure_reason" text,
|
||||
"attempts" bigint DEFAULT 0 NOT NULL,
|
||||
"executor_node_id" text,
|
||||
"status_changed_at" bigint,
|
||||
"clusters" text,
|
||||
"ttkb_packages" text,
|
||||
"lang" text,
|
||||
"baseline" text,
|
||||
"readable_report_html" text,
|
||||
"readable_report_generated_at" bigint,
|
||||
"readable_report_round" bigint,
|
||||
"readable_report_error" text,
|
||||
"readable_report_prompt_id" text,
|
||||
"readable_report_prompt_name" text,
|
||||
"readable_report_alt_html" text,
|
||||
"readable_report_alt_lang" text,
|
||||
"readable_report_alt_generated_at" bigint,
|
||||
"readable_report_alt_error" text
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "verifications_status_idx" ON "verifications" ("status");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "verification_notes" (
|
||||
"verification_id" text NOT NULL REFERENCES "verifications"("id") ON DELETE CASCADE,
|
||||
"page_id" text NOT NULL,
|
||||
"issue_n" bigint NOT NULL,
|
||||
"lang" text NOT NULL,
|
||||
"note" text,
|
||||
"filed_task_id" text,
|
||||
"author" text,
|
||||
"updated_at" bigint NOT NULL,
|
||||
PRIMARY KEY ("verification_id", "page_id", "issue_n", "lang")
|
||||
);
|
||||
|
||||
-- ── 搬存量 ──────────────────────────────────────────────────────────────────
|
||||
|
||||
INSERT INTO "verifications" (
|
||||
"product_profile", "id", "title", "description", "platform", "base_ref", "remark", "attachments",
|
||||
"verify_spec", "audit_report", "review_feedback", "review_history", "workspace_path", "pinned",
|
||||
"status", "priority_key", "watchers", "creator_email", "created_at", "started_at", "finished_at",
|
||||
"duration_ms", "total_duration_ms", "log_path", "failure_reason", "attempts", "executor_node_id",
|
||||
"status_changed_at", "clusters", "ttkb_packages", "lang",
|
||||
"readable_report_html", "readable_report_generated_at", "readable_report_round", "readable_report_error",
|
||||
"readable_report_prompt_id", "readable_report_prompt_name",
|
||||
"readable_report_alt_html", "readable_report_alt_lang", "readable_report_alt_generated_at", "readable_report_alt_error"
|
||||
)
|
||||
SELECT
|
||||
"product_profile", "id", "title", "description", "platform", "base_ref", "remark", "attachments",
|
||||
"verify_spec", "audit_report", "review_feedback", "review_history", "workspace_path", "pinned",
|
||||
CASE "status"
|
||||
WHEN 'implementing' THEN 'verifying'
|
||||
WHEN 'manual_review' THEN 'report_ready'
|
||||
WHEN 'completed' THEN 'accepted'
|
||||
WHEN 'implementation_failed' THEN 'verify_failed'
|
||||
WHEN 'archived' THEN 'archived'
|
||||
WHEN 'cancelled' THEN 'cancelled'
|
||||
ELSE 'awaiting_verify'
|
||||
END,
|
||||
"priority_key", "watchers", "creator_email", "created_at", "started_at", "finished_at",
|
||||
"duration_ms", "total_duration_ms", "log_path", "failure_reason", "attempts", "executor_node_id",
|
||||
"status_changed_at", "clusters", "ttkb_packages", "lang",
|
||||
"readable_report_html", "readable_report_generated_at", "readable_report_round", "readable_report_error",
|
||||
"readable_report_prompt_id", "readable_report_prompt_name",
|
||||
"readable_report_alt_html", "readable_report_alt_lang", "readable_report_alt_generated_at", "readable_report_alt_error"
|
||||
FROM "features"
|
||||
WHERE "deliverable" = 'report'
|
||||
ON CONFLICT ("id") DO NOTHING;
|
||||
|
||||
INSERT INTO "verification_notes" ("verification_id", "page_id", "issue_n", "lang", "note", "filed_task_id", "author", "updated_at")
|
||||
SELECT n."feature_id", n."page_id", n."issue_n", n."lang", n."note", n."filed_task_id", n."author", n."updated_at"
|
||||
FROM "audit_notes" n
|
||||
JOIN "verifications" v ON v."id" = n."feature_id"
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- ── 辅表改挂 ────────────────────────────────────────────────────────────────
|
||||
-- 按 target_type / kind 分表的辅表:可读性报告运行记录与来源、状态流转账本、每轮摘要、
|
||||
-- 证据采集事件、证据 TOS 镜像、执行条件。
|
||||
|
||||
UPDATE "readable_report_runs" SET "target_type" = 'verification' WHERE "target_type" = 'feature' AND "target_id" IN (SELECT "id" FROM "verifications");
|
||||
UPDATE "readable_sources" SET "target_type" = 'verification' WHERE "target_type" = 'feature' AND "target_id" IN (SELECT "id" FROM "verifications");
|
||||
UPDATE "task_transitions" SET "kind" = 'verify' WHERE "kind" = 'feature' AND "target_id" IN (SELECT "id" FROM "verifications");
|
||||
UPDATE "round_digests" SET "kind" = 'verify' WHERE "kind" = 'feature' AND "target_id" IN (SELECT "id" FROM "verifications");
|
||||
-- 这张表的主键是 "<target_type>:<target_id>:<captureId>:<event>:<ts>",前缀要一起改,
|
||||
-- 否则下次摄取按新前缀算主键,同一事件会重复入库。
|
||||
UPDATE "evidence_capture_events"
|
||||
SET "target_type" = 'verification', "id" = 'verification' || substr("id", length('feature') + 1)
|
||||
WHERE "target_type" = 'feature' AND "id" LIKE 'feature:%' AND "target_id" IN (SELECT "id" FROM "verifications");
|
||||
UPDATE "evidence_media" SET "owner_kind" = 'verify' WHERE "owner_kind" = 'feature' AND "owner_id" IN (SELECT "id" FROM "verifications");
|
||||
-- run_conditions 的主键里嵌着 kind("<targetKind>:<targetId>:<entry.id>"),改 kind 会让
|
||||
-- 主键与内容不一致;走查不产出 Conditions,直接删掉挂在这些 id 上的行。
|
||||
DELETE FROM "run_conditions" WHERE "target_kind" = 'feature' AND "target_id" IN (SELECT "id" FROM "verifications");
|
||||
|
||||
-- ── 从 features 移走 ─────────────────────────────────────────────────────────
|
||||
-- impl_report_versions 以 ON DELETE CASCADE 跟着走:验证线没有 ImplReport,那几版是
|
||||
-- 借 Feature 管道时的副产物。
|
||||
DELETE FROM "features" WHERE "deliverable" = 'report' AND "id" IN (SELECT "id" FROM "verifications");
|
||||
@@ -0,0 +1,11 @@
|
||||
-- 0036 把「验证」搬出 features 之后,清掉留给旧进程过渡用的列和表。
|
||||
--
|
||||
-- **只在 0036 已执行、且新代码已部署重启之后跑**:在那之前还在跑的旧进程会 SELECT 这些列,
|
||||
-- 先删就是 /api/features 全线 500(2026-08-22 缺列事故的反方向)。
|
||||
--
|
||||
-- 跑之前确认 features 里已经没有验证行,否则这一步会把没搬走的走查报告一起丢掉:
|
||||
-- SELECT count(*) FROM features WHERE deliverable = 'report'; -- 必须是 0
|
||||
ALTER TABLE "features" DROP COLUMN IF EXISTS "deliverable";
|
||||
ALTER TABLE "features" DROP COLUMN IF EXISTS "audit_report";
|
||||
ALTER TABLE "features" DROP COLUMN IF EXISTS "verify_spec";
|
||||
DROP TABLE IF EXISTS "audit_notes";
|
||||
@@ -0,0 +1,9 @@
|
||||
-- bug 的来源标签(JSON 数组存 TEXT,见 shared/src/types.ts::Task.tags)。
|
||||
--
|
||||
-- 为什么不复用 clusters:clusters 是调度条件(哪批机器能接),而标签回答的是
|
||||
-- 「这条是哪一批导进来的」—— 同一个 evaluator 集群里已经混着 9 月的 benchmark
|
||||
-- 和之后各团队交过来的存量 bug,只按集群分不开。
|
||||
--
|
||||
-- 可空、无默认值:历史行读出来就是空数组(db.ts::parseTags),不需要回填。
|
||||
ALTER TABLE "tasks"
|
||||
ADD COLUMN IF NOT EXISTS "tags" text;
|
||||
@@ -0,0 +1,9 @@
|
||||
-- bug 的「无人值守」开关(见 shared/src/types.ts::Task.unattended)。
|
||||
--
|
||||
-- 只由管理面板的批量导入写入:打开时评估结果不停下来等人 —— 出了方案直接入修复队列,
|
||||
-- 评估器判「复现不了 / 信息不足」也带着兜底方案去执行(执行阶段复现不了就以
|
||||
-- UNREPRODUCIBLE 收尾)。基础设施故障(鉴权 / API / 崩溃 / 超时)仍停在 info_required。
|
||||
--
|
||||
-- 可空:历史行为 null,等同关闭,不需要回填。
|
||||
ALTER TABLE "tasks"
|
||||
ADD COLUMN IF NOT EXISTS "unattended" bigint;
|
||||
@@ -0,0 +1,12 @@
|
||||
-- 状态流转的操作人(见 control-server/src/actor_context.ts)。
|
||||
--
|
||||
-- 批次看板的「人工推进」要回答「每天谁推进了几步」,而 task_transitions 只记了
|
||||
-- 从哪到哪、什么时候。人工动作的接口其实拿得到登录人的 SSO 邮箱,只是没存。
|
||||
--
|
||||
-- 取值:登录人的邮箱(人在面板上点的)、`system:<来源>`(平台替人按的,例如无人值守
|
||||
-- 自动执行、MR 已合入自动复核通过)、null(未记录:本列上线之前的所有行,以及卫星
|
||||
-- 回调等没有登录身份的请求)。
|
||||
--
|
||||
-- 可空、不回填:历史行的操作人确实不知道,不按经办人去估。
|
||||
ALTER TABLE "task_transitions"
|
||||
ADD COLUMN IF NOT EXISTS "actor" text;
|
||||
@@ -0,0 +1,22 @@
|
||||
-- 批量任务(见 control-server/src/batches_db.ts 和 shared/src/batch_center.ts)。
|
||||
--
|
||||
-- 以前一个「批次」只是 bug 上的来源标签(tasks.tags),没有名称、没有负责人,
|
||||
-- 所以做不了列表、权限和给负责人的日报。这张表给标签补上这些元数据;成员关系
|
||||
-- 仍然只看 tasks.tags —— 改标签就是改归属,不在这里另存一份名单。
|
||||
--
|
||||
-- 没有这张表里的行的标签照样是一个批次(名称 = 标签、无负责人),第一次保存设置
|
||||
-- 时才落一行。所以不需要回填。
|
||||
CREATE TABLE IF NOT EXISTS "batches" (
|
||||
"tag" text PRIMARY KEY,
|
||||
"name" text NOT NULL,
|
||||
-- 负责人邮箱(JSON 数组存 TEXT)。负责人能看这一批的详情、收日报;导入和给经办人群发仍只限管理员。
|
||||
"owners" text NOT NULL DEFAULT '[]',
|
||||
"description" text,
|
||||
"created_by" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"updated_at" bigint NOT NULL,
|
||||
-- 负责人日报开关(0/1),默认开。每天太平洋时间 14:00 发。
|
||||
"digest_enabled" bigint NOT NULL DEFAULT 1,
|
||||
-- 上一次日报(定时或手动发给负责人)的时刻,定时任务靠它保证一天只发一次。
|
||||
"last_digest_at" bigint
|
||||
);
|
||||
@@ -0,0 +1,47 @@
|
||||
-- 开放平台 v1 的状态推送订阅(见 control-server/src/openplatform_webhooks.ts)。
|
||||
--
|
||||
-- 和管理台那份全局 webhookUrls(settings KV,推全部单子、只发一次)是两套东西:
|
||||
-- 那份留给存量接收端原样用;这里是给接入方的标准方案 —— 订阅挂在一把 API Key
|
||||
-- 下,只推这把 Key 建的任务(tasks.created_via_key_id),每条带 HMAC 签名,失败
|
||||
-- 按退避重试。Key 本身仍在 settings KV 里,这里的 key_id 指向它的稳定 id。
|
||||
--
|
||||
-- 投递单独一张表而不是发完即弃:重试、「最近投递」自查、以及「同一事件对同一
|
||||
-- 订阅只投一次」的去重(唯一索引)都要落地的状态。纯新增,不需要回填。
|
||||
CREATE TABLE IF NOT EXISTS "openplatform_webhooks" (
|
||||
"id" text PRIMARY KEY,
|
||||
"key_id" text NOT NULL,
|
||||
"url" text NOT NULL,
|
||||
-- 只推这些状态(JSON 数组存 TEXT);NULL = 全部状态。
|
||||
"events" text,
|
||||
-- 签名密钥明文。HMAC 需要服务端持有原文,所以不能像 API Key 那样只存哈希;
|
||||
-- 只在创建时返回一次,列表接口永不返回。
|
||||
"secret" text NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
-- 非空 = 已停用(接入方 / 管理员手动停用,或连续投递失败被自动停用)。
|
||||
"disabled_at" bigint,
|
||||
"disabled_reason" text,
|
||||
"consecutive_failures" bigint NOT NULL DEFAULT 0,
|
||||
"last_success_at" bigint,
|
||||
"last_failure_at" bigint
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "openplatform_webhooks_key" ON "openplatform_webhooks" ("key_id");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "openplatform_webhook_deliveries" (
|
||||
"id" text PRIMARY KEY,
|
||||
"webhook_id" text NOT NULL,
|
||||
-- 与 task_transitions.id 同一个值(kind:targetId:toStatus:ts),接收端据此去重。
|
||||
"event_id" text NOT NULL,
|
||||
-- 入队那一刻冻结的请求体;签名在每次发送时按当时的时间戳重算。
|
||||
"payload" text NOT NULL,
|
||||
-- pending | succeeded | failed(重试用尽)| cancelled(订阅停用 / Key 吊销)
|
||||
"state" text NOT NULL,
|
||||
"attempts" bigint NOT NULL DEFAULT 0,
|
||||
"next_attempt_at" bigint,
|
||||
"last_status" bigint,
|
||||
"last_error" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"updated_at" bigint NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "openplatform_webhook_deliveries_event" ON "openplatform_webhook_deliveries" ("webhook_id", "event_id");
|
||||
CREATE INDEX IF NOT EXISTS "openplatform_webhook_deliveries_due" ON "openplatform_webhook_deliveries" ("state", "next_attempt_at");
|
||||
CREATE INDEX IF NOT EXISTS "openplatform_webhook_deliveries_recent" ON "openplatform_webhook_deliveries" ("webhook_id", "created_at");
|
||||
@@ -0,0 +1,86 @@
|
||||
-- RSI 自动实验回路(见 shared/src/rsi_loop.ts、control-server/src/rsi_loop_*.ts)。
|
||||
--
|
||||
-- 四张表,纯新增,不需要回填:
|
||||
-- rsi_experiments 一次「问题 → 猜想 → 改法 → 离线 → 灰度 → 判定」的完整记录
|
||||
-- rsi_experiment_assignments 灰度 / 观察期里每个任务落在哪一组(派单时写,判定时读)
|
||||
-- rsi_round_metrics 每批执行的过程指标(从节点上的 .timing.jsonl 算,算一次缓存)
|
||||
-- rsi_experiment_events 动作时间线:回路进程与判定任务每做一件事都写一行,RSI 页面直接展示
|
||||
CREATE TABLE IF NOT EXISTS "rsi_experiments" (
|
||||
"id" text PRIMARY KEY,
|
||||
"stage" text NOT NULL,
|
||||
"kind" text NOT NULL DEFAULT 'prompt',
|
||||
-- offline_failed | canary | holdback | settled | rolled_back | reverted | inconclusive | stopped
|
||||
"status" text NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
-- 审计分类:DEAD_END | DECISION_ERROR | CONTEXT_MISSING
|
||||
"problem_class" text,
|
||||
-- 问题模式的短标签(审计给的 pattern),同一类问题的实验按它归并
|
||||
"cluster" text,
|
||||
-- AI 写的四段:问题总结 / 猜想 / 优化方式 / 实验结论
|
||||
"summary" text,
|
||||
"hypothesis" text,
|
||||
"method" text,
|
||||
"conclusion" text,
|
||||
-- 事先登记的目标指标(shared/src/rsi_loop.ts 的目录),提交后不可改
|
||||
"target_metric" text NOT NULL,
|
||||
-- 实验开始时的现行版本(NULL = 内置默认);revert 回到它
|
||||
"base_prompt_id" text,
|
||||
"candidate_prompt_id" text,
|
||||
-- JSON:离线重放结果(OfflineResult)/ 最近一次线上判定(两组对比)
|
||||
"offline_result" text,
|
||||
"online_result" text,
|
||||
"decision_reason" text,
|
||||
"share" double precision NOT NULL DEFAULT 0.2,
|
||||
"created_by" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"updated_at" bigint NOT NULL,
|
||||
"canary_started_at" bigint,
|
||||
"promoted_at" bigint,
|
||||
"decided_at" bigint
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "rsi_experiments_stage_status" ON "rsi_experiments" ("stage", "status");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "rsi_experiment_assignments" (
|
||||
"experiment_id" text NOT NULL,
|
||||
"target_kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
-- 灰度期:control | treatment;观察期:holdback(旧版)| current(新版)
|
||||
"arm" text NOT NULL,
|
||||
"phase" text NOT NULL,
|
||||
"prompt_id" text,
|
||||
"assigned_at" bigint NOT NULL,
|
||||
PRIMARY KEY ("experiment_id", "phase", "target_kind", "target_id")
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "rsi_experiment_assignments_target" ON "rsi_experiment_assignments" ("target_kind", "target_id");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "rsi_round_metrics" (
|
||||
"kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"round" bigint NOT NULL,
|
||||
"node_id" text,
|
||||
-- 这批执行的开始时刻(会话摘要的归档时刻 − 时长);分组按它对齐派单时刻
|
||||
"started_at" bigint NOT NULL,
|
||||
"finished_at" bigint NOT NULL,
|
||||
-- JSON:RoundMetrics
|
||||
"metrics" text NOT NULL,
|
||||
-- timing = 从计时插桩算的完整指标;digest = 节点取不到计时文件,只有会话摘要里的部分
|
||||
"source" text NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
PRIMARY KEY ("kind", "target_id", "round")
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "rsi_round_metrics_started" ON "rsi_round_metrics" ("started_at");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "rsi_experiment_events" (
|
||||
"id" text PRIMARY KEY,
|
||||
-- NULL = 回路层面的事件(每日运行摘要等)
|
||||
"experiment_id" text,
|
||||
"at" bigint NOT NULL,
|
||||
-- loop-runner(temp 机上的回路进程)| loop-judge(控制面判定任务)| 人的邮箱前缀
|
||||
"actor" text NOT NULL,
|
||||
-- run | finding | proposal | offline | canary | judge | promote | rollback | revert | settle | conclusion | pause | note
|
||||
"type" text NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"body" text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "rsi_experiment_events_exp" ON "rsi_experiment_events" ("experiment_id", "at");
|
||||
CREATE INDEX IF NOT EXISTS "rsi_experiment_events_at" ON "rsi_experiment_events" ("at");
|
||||
@@ -0,0 +1,20 @@
|
||||
-- 归档反馈(见 shared/src/archive_reasons.ts 和 control-server/src/archive_feedback_db.ts)。
|
||||
--
|
||||
-- 抽屉里点「归档」时可以顺手选一个原因、写一句话(都可选)。用来收集大家不愿意继续
|
||||
-- 在平台上跟这张单的原因。每次归档都记一行,没选原因也记(reason/note 为 null),
|
||||
-- 这样能看出有多少人愿意填。
|
||||
--
|
||||
-- kind 用 WorkItem 的叫法(bug / feature);status_before 和 round 记归档那一刻的状态
|
||||
-- 和第几轮,方便按「复核时放弃」「修失败后放弃」分开看。
|
||||
CREATE TABLE IF NOT EXISTS "archive_feedback" (
|
||||
"id" text PRIMARY KEY,
|
||||
"kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"status_before" text,
|
||||
"round" bigint,
|
||||
"reason" text,
|
||||
"note" text,
|
||||
"by" text,
|
||||
"at" bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "archive_feedback_at_idx" ON "archive_feedback" ("at");
|
||||
@@ -0,0 +1,10 @@
|
||||
-- RSI 自动实验按平台划分(见 shared/src/rsi_loop.ts::LOOP_PLATFORMS)。
|
||||
--
|
||||
-- 回路的问题和改法来自某一个平台的执行记录(Android 的「等 App 就绪」靠 dumpsys /
|
||||
-- uiautomator 判断,iOS 用不上),灰度若落到另一个平台的任务上,既用不上这条纪律,
|
||||
-- 又稀释判定样本。实验带上平台后,派单只给同平台的任务分组;同一个 stage 允许
|
||||
-- Android / iOS 各有一个进行中的实验。
|
||||
--
|
||||
-- NULL = 不限平台(只为兼容加列之前的记录;新提交的实验一律带平台)。纯加列,不回填。
|
||||
ALTER TABLE "rsi_experiments" ADD COLUMN IF NOT EXISTS "platform" text;
|
||||
CREATE INDEX IF NOT EXISTS "rsi_experiments_stage_platform_status" ON "rsi_experiments" ("stage", "platform", "status");
|
||||
@@ -0,0 +1,25 @@
|
||||
-- RSI 真机复跑(见 control-server/src/rsi_lab.ts、shared/src/rsi_loop.ts::judgeLab)。
|
||||
--
|
||||
-- 离线重放通过的候选,先在专用实验机上拿评估集的历史任务新旧 prompt 各完整跑一遍,
|
||||
-- 再决定去留;线上灰度默认关闭(RSI_LOOP_CANARY)。每次复跑是一条从评估集复制出来的
|
||||
-- bug 任务(id 前缀 rsi-lab-,各处据此关掉 MR / 通知 / Meego / 统计 / 知识库),这张表
|
||||
-- 记它属于哪个实验、来源、哪一版、在哪台机器、第几个跑。纯新增,不回填。
|
||||
CREATE TABLE IF NOT EXISTS "rsi_lab_runs" (
|
||||
"task_id" text PRIMARY KEY,
|
||||
"experiment_id" text NOT NULL,
|
||||
"platform" text NOT NULL,
|
||||
"source_task_id" text NOT NULL,
|
||||
-- base = 实验开始时的现行版本;candidate = 候选
|
||||
"arm" text NOT NULL,
|
||||
-- 执行顺序:同一来源的两次复跑交替先后,抵消设备上残留的上一次构建
|
||||
"seq" bigint NOT NULL,
|
||||
"node_id" text NOT NULL,
|
||||
"prompt_id" text,
|
||||
-- 复跑任务的终态(manual_review / fix_failed / unreproducible …);未结束为 NULL
|
||||
"outcome" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"finished_at" bigint
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "rsi_lab_runs_experiment" ON "rsi_lab_runs" ("experiment_id");
|
||||
|
||||
ALTER TABLE "rsi_experiments" ADD COLUMN IF NOT EXISTS "lab_started_at" bigint;
|
||||
@@ -0,0 +1,9 @@
|
||||
-- RSI 执行配置包(见 shared/src/executor_profile.ts)。
|
||||
--
|
||||
-- 回路除了改 prompt,还能拧一组封闭的运行时旋钮(思考强度、等界面稳定……),在实验机上
|
||||
-- 配对复跑判定。这里记三件事:实验的候选配置包、每次复跑实际带的配置包、每次复跑认领时
|
||||
-- 节点的卫星包版本 —— 两组跑在不同版本的卫星包上(中途部署过)就不可比,判定时剔除。
|
||||
-- 纯新增,不回填:之前的实验都是 prompt 实验,配置包为空 = 生产行为。
|
||||
ALTER TABLE "rsi_experiments" ADD COLUMN IF NOT EXISTS "candidate_profile" text;
|
||||
ALTER TABLE "rsi_lab_runs" ADD COLUMN IF NOT EXISTS "profile" text;
|
||||
ALTER TABLE "rsi_lab_runs" ADD COLUMN IF NOT EXISTS "sat_version" text;
|
||||
@@ -0,0 +1,36 @@
|
||||
-- 归档类别的来源(见 shared/src/archive_reasons.ts::ArchiveCategorySource)。
|
||||
--
|
||||
-- 10-06 起归档类别必选。改之前有人只写了一句话、没选类别;这些单的类别由 AI 读那句话
|
||||
-- 推断,之后任何人都可以在面板上手动改。两种都是**追加**一条记录(带上原来那句话),
|
||||
-- 不改原记录:展示和统计取最新一条,原记录留着可查。source 记这条类别从哪来:
|
||||
-- NULL 归档人当场选的,或事后补填的
|
||||
-- 'ai' AI 读那句话推断的
|
||||
-- 'manual' 有人在面板上手动改的
|
||||
ALTER TABLE "archive_feedback" ADD COLUMN IF NOT EXISTS "source" text;
|
||||
|
||||
-- 存量回填:2026-10-06 时全平台只写了一句话、没选类别的归档单共 6 条(都是 bug,都在
|
||||
-- social_relation)。类别是 AI 读那句话推断的,推断依据:
|
||||
-- bba1c22b "Discussed with PM ... this is a won't fix." → not_a_bug
|
||||
-- 9f65574a "more complex than expected ... fix locally" → ai_fix_wrong
|
||||
-- 757cf0fe "The fix is too hacky. I manually fix it ..." → ai_fix_wrong
|
||||
-- fedb7b00 "Still need to confirm with designer on design spec" → not_a_bug(需求未定)
|
||||
-- 982ed6df "This is a feature decision ... owned by profile team" → not_a_bug
|
||||
-- 8c7f4b91 "the feature is not released, thus V5 is not online" → not_a_bug
|
||||
-- 只在这张单最新一条记录仍然没有类别时才写(期间有人手动选过就不覆盖);id 固定,重跑无副作用。
|
||||
INSERT INTO "archive_feedback" ("id", "kind", "target_id", "status_before", "round", "reason", "note", "by", "at", "source")
|
||||
SELECT 'ai-0048-' || v.target_id, f.kind, f.target_id, f.status_before, f.round, v.reason, f.note,
|
||||
'system:ai-infer', (EXTRACT(EPOCH FROM now()) * 1000)::bigint, 'ai'
|
||||
FROM (VALUES
|
||||
('bba1c22b-a2af-4d9b-b198-2d56bd9e33b4', 'not_a_bug'),
|
||||
('9f65574a-b2d2-4290-a184-b929707c6ed3', 'ai_fix_wrong'),
|
||||
('757cf0fe-82ca-4bba-bc62-f88615f06e13', 'ai_fix_wrong'),
|
||||
('fedb7b00-1430-4c7f-b104-67b7d1df5b78', 'not_a_bug'),
|
||||
('982ed6df-4c21-437f-91f2-0c842cd33eec', 'not_a_bug'),
|
||||
('8c7f4b91-7897-42a5-82e0-0a947160d38f', 'not_a_bug')
|
||||
) AS v(target_id, reason)
|
||||
JOIN LATERAL (
|
||||
SELECT * FROM "archive_feedback" a
|
||||
WHERE a.kind = 'bug' AND a.target_id = v.target_id
|
||||
ORDER BY a.at DESC LIMIT 1
|
||||
) f ON f.reason IS NULL
|
||||
ON CONFLICT ("id") DO NOTHING;
|
||||
@@ -0,0 +1,9 @@
|
||||
-- 批次「完成结算」(control-server/src/batch_center.ts::settleBatch)。
|
||||
--
|
||||
-- 负责人或管理员在结算期(进度 ≥ 90%)点「完成结算」,标志这一批进入生命周期末期。它几乎
|
||||
-- 不改变什么:没修完的单照样能在抽屉里操作,进度和效率照常重算;只是记下谁、什么时候结算的,
|
||||
-- 以及结算那一刻的数字(settled_snapshot,JSON,见 shared BatchSettleSnapshot),让面板能写
|
||||
-- 「结算时 92% → 现在 95%」。可以撤回(三列清空)。
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "settled_at" bigint;
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "settled_by" text;
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "settled_snapshot" text;
|
||||
@@ -0,0 +1,49 @@
|
||||
-- 开放平台 v1 的「接入方自己的飞书机器人」(见 control-server/src/openplatform_lark_bots.ts)。
|
||||
--
|
||||
-- 场景:接入方自己有一个自建应用机器人,在话题群里被 @ 后调开放平台建单,希望之后的
|
||||
-- 状态卡片以**它自己的名义**回复进那条 @ 消息所在的话题。他们的机器人走长连接收事件,
|
||||
-- 没有能被我们 POST 的 HTTP 入口,所以 Webhook 订阅那条路走不通,只能由控制面拿着
|
||||
-- 他们的 app 凭据代发。
|
||||
--
|
||||
-- 机器人挂在一把 API Key 下(和 Webhook 订阅同一条归属规则);任务与「回复到哪条
|
||||
-- 消息」的绑定单独一张表,不往 tasks 上加列 —— 只有开放平台建的少数任务才有它。
|
||||
-- 纯新增,不需要回填。
|
||||
CREATE TABLE IF NOT EXISTS "openplatform_lark_bots" (
|
||||
"id" text PRIMARY KEY,
|
||||
"key_id" text NOT NULL,
|
||||
"app_id" text NOT NULL,
|
||||
-- 明文。调飞书换 tenant_access_token 需要原文,不能像 API Key 那样只存哈希;
|
||||
-- 登记后任何接口都不再返回它。
|
||||
"app_secret" text NOT NULL,
|
||||
-- feishu | lark(国际版),决定调哪个开放平台域名。
|
||||
"domain" text NOT NULL DEFAULT 'feishu',
|
||||
-- 登记时从 /bot/v3/info 读到的机器人名字和头像,只做展示。
|
||||
"name" text,
|
||||
"avatar_url" text,
|
||||
"created_by" text NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
-- 非空 = 已停用(登记人 / 管理员手动停用,或连续发送失败被自动停用)。
|
||||
"disabled_at" bigint,
|
||||
"disabled_reason" text,
|
||||
"consecutive_failures" bigint NOT NULL DEFAULT 0,
|
||||
"last_success_at" bigint,
|
||||
"last_failure_at" bigint,
|
||||
"last_error" text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "openplatform_lark_bots_key" ON "openplatform_lark_bots" ("key_id");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "openplatform_lark_threads" (
|
||||
-- 一个任务只回复到一个地方。
|
||||
"task_id" text PRIMARY KEY,
|
||||
"bot_id" text NOT NULL,
|
||||
-- 被回复的那条消息(om_…),通常就是接入方机器人被 @ 的那条。
|
||||
"message_id" text NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
-- 最近一次发出的卡片是哪一张(kind + 进入该状态的时刻),防补发路径重复回复。
|
||||
"last_sent_sig" text,
|
||||
"last_sent_at" bigint,
|
||||
"last_error" text,
|
||||
-- 最近一张「待复核」卡片回复出去的 message_id,可读性报告生成完后据此原地更新。
|
||||
"review_message_id" text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "openplatform_lark_threads_bot" ON "openplatform_lark_threads" ("bot_id");
|
||||
@@ -0,0 +1,22 @@
|
||||
-- QA 打回的核实(见 shared/src/reopen_triage.ts、control-server/src/reopen_triage.ts)。
|
||||
--
|
||||
-- 复核通过后被 QA 在 Meego 上重新打开的单,负责人或管理员在批量任务详情页逐条核实:
|
||||
-- 「修错了」标注原因;「误报」记下原因,并把单子改回「已解决」或归档为不该由平台修。
|
||||
-- 只追加不改:同一张单可能被打回好几次,每次的结论都留着,才能统计误报占多少、都是什么原因。
|
||||
-- 纯新增,不需要回填。
|
||||
CREATE TABLE IF NOT EXISTS "reopen_triage" (
|
||||
"id" text PRIMARY KEY,
|
||||
"task_id" text NOT NULL,
|
||||
-- fix_wrong | false_alarm
|
||||
"verdict" text NOT NULL,
|
||||
-- 封闭清单的 code(FIX_WRONG_REASONS / FALSE_ALARM_REASONS)
|
||||
"reason" text NOT NULL,
|
||||
"note" text,
|
||||
-- 误报流转到哪:resolved(Meego 改回已解决)| archived;修错了为 NULL
|
||||
"action" text,
|
||||
-- 核实那一刻 Meego 的状态,留证
|
||||
"meego_state" text,
|
||||
"by" text,
|
||||
"at" bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "reopen_triage_task_idx" ON "reopen_triage" ("task_id");
|
||||
@@ -0,0 +1,24 @@
|
||||
-- 开放平台命令行 / Skill 的登录会话(见 control-server/src/openapi_cli_sso.ts)。
|
||||
--
|
||||
-- 和 Eddy 的 0032 同一套:浏览器 SSO → 本机回调 + PKCE 的一次性授权码 → 可吊销的 30 天会话。
|
||||
-- 只存哈希不存明文。会话只能做面板「开放平台 API」弹窗里本人能做的事(申请 / 领取 Key、
|
||||
-- 登记机器人),建单仍然只认审批过的 API Key。纯新增,不需要回填。
|
||||
CREATE TABLE IF NOT EXISTS openapi_cli_codes (
|
||||
code_hash text PRIMARY KEY,
|
||||
email text NOT NULL,
|
||||
challenge text NOT NULL,
|
||||
redirect_uri text NOT NULL,
|
||||
expires_at bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS openapi_cli_codes_expiry ON openapi_cli_codes (expires_at);
|
||||
CREATE TABLE IF NOT EXISTS openapi_cli_sessions (
|
||||
token_hash text PRIMARY KEY,
|
||||
email text NOT NULL,
|
||||
expires_at bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS openapi_cli_sessions_expiry ON openapi_cli_sessions (expires_at);
|
||||
|
||||
-- GET /api/openapi/v1/tasks 按 Key 列自己建的单。0020 那个唯一索引只覆盖带 external_id 的行,
|
||||
-- meego-import 建的单 external_id 为空,用不上它。
|
||||
CREATE INDEX IF NOT EXISTS tasks_created_via_key_created
|
||||
ON tasks (created_via_key_id, created_at) WHERE created_via_key_id IS NOT NULL;
|
||||
@@ -0,0 +1,34 @@
|
||||
-- 开放平台 / Skill 的使用痕迹(见 control-server/src/openapi_usage.ts、管理台「开放平台 → 使用情况」)。
|
||||
--
|
||||
-- 1. tasks.created_channel:建单入口。'cli' = 命令行 / Skill 以本人身份建的单;NULL = 面板等网页入口
|
||||
-- (开放平台 Key 建的单仍按 created_via_key_id 非空认,不重复记)。纯新增可空列,PG 上是元数据操作。
|
||||
-- 2. openapi_cli_sessions 补 created_at / last_used_at:授权了多少台电脑、最近还在不在用。
|
||||
-- 0052 上线后发出的会话没有 created_at,按 NULL 处理(统计里算「时间未知」)。
|
||||
-- 3. openapi_usage_events:每次开放平台 / 命令行调用一行,只记谁、哪个接口、结果码、哪个 Agent,
|
||||
-- 不记请求体。保留 180 天,由写入方顺手清理。
|
||||
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS created_channel text;
|
||||
CREATE INDEX IF NOT EXISTS tasks_created_channel_created
|
||||
ON tasks (created_channel, created_at) WHERE created_channel IS NOT NULL;
|
||||
-- GET /api/cli/v1/tasks 按本人列单。
|
||||
CREATE INDEX IF NOT EXISTS tasks_creator_email_created ON tasks (creator_email, created_at);
|
||||
|
||||
ALTER TABLE openapi_cli_sessions ADD COLUMN IF NOT EXISTS created_at bigint;
|
||||
ALTER TABLE openapi_cli_sessions ADD COLUMN IF NOT EXISTS last_used_at bigint;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS openapi_usage_events (
|
||||
id text PRIMARY KEY,
|
||||
at bigint NOT NULL,
|
||||
-- 'openapi'(API Key)| 'cli'(命令行 / Skill 会话)
|
||||
channel text NOT NULL,
|
||||
-- openapi:Key id;cli:登录邮箱
|
||||
actor text NOT NULL,
|
||||
-- 'POST /openapi/v1/tasks' 这样的「方法 + 路由模板」,不带具体 id
|
||||
route text NOT NULL,
|
||||
status bigint NOT NULL,
|
||||
-- 客户端自报的 Agent(claude-code / codex / cursor / terminal),只有命令行会带
|
||||
agent text,
|
||||
client_version text,
|
||||
task_id text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS openapi_usage_events_at ON openapi_usage_events (at);
|
||||
CREATE INDEX IF NOT EXISTS openapi_usage_events_actor ON openapi_usage_events (channel, actor, at);
|
||||
@@ -0,0 +1,79 @@
|
||||
-- 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");
|
||||
@@ -0,0 +1,11 @@
|
||||
-- CI 收尾第二版(见 shared/src/ci_gate.ts 头注释):复核阶段不再扣交付,改为跟着 CI,
|
||||
-- 由「打回时导入 / 一键修复 / 复核通过后自动」三个入口回炉。
|
||||
--
|
||||
-- latest_findings:最近一次 CI 结论里的失败明细(CiFinding[] JSON),一键修复和打回导入用它。
|
||||
-- boost_from:回炉进行中时,是从哪个状态发起的(复核通过后发起的,修完回到这个状态)。
|
||||
-- ci_sig:最近一次判定时 job 列表的签名;红着等人(awaiting)时,签名没变就不重复读明细。
|
||||
--
|
||||
-- 纯新增列,不需要回填。
|
||||
ALTER TABLE "ci_gate_runs" ADD COLUMN IF NOT EXISTS "latest_findings" text;
|
||||
ALTER TABLE "ci_gate_runs" ADD COLUMN IF NOT EXISTS "boost_from" text;
|
||||
ALTER TABLE "ci_gate_runs" ADD COLUMN IF NOT EXISTS "ci_sig" text;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- 走查总表上的「无需修复」(见 docs/verify.md「修复进度」)。
|
||||
--
|
||||
-- 和期望、转单号一样是人留下的判断,所以记在 verification_notes 而不是 audit_report:
|
||||
-- 后者每次重新生成整体覆盖。dismissed_at 为空 = 没有被标「无需修复」;撤销即置空。
|
||||
--
|
||||
-- 纯新增两列,不需要回填,旧进程照常读写(它不认识这两列)。
|
||||
ALTER TABLE "verification_notes" ADD COLUMN IF NOT EXISTS "dismissed_at" bigint;
|
||||
ALTER TABLE "verification_notes" ADD COLUMN IF NOT EXISTS "dismissed_by" text;
|
||||
@@ -0,0 +1,9 @@
|
||||
-- 走查问题的「复现条件」「原因」—— 人补充 / 修正的版本(见 docs/verify.md「面板」)。
|
||||
--
|
||||
-- 报告里新写的问题自带这两格(agent 写进 UI-Audit-Report.md 的问题表),但老报告没有,
|
||||
-- 有的写得不够(复现不出来的那种)。人在问题卡上补的记在 verification_notes:和期望、
|
||||
-- 转单号、无需修复一样是人留下的判断,要活过报告重新生成;展示时人写的优先于报告里的。
|
||||
--
|
||||
-- 纯新增两列,不需要回填,旧进程照常读写(它不认识这两列)。
|
||||
ALTER TABLE "verification_notes" ADD COLUMN IF NOT EXISTS "repro" text;
|
||||
ALTER TABLE "verification_notes" ADD COLUMN IF NOT EXISTS "cause" text;
|
||||
@@ -0,0 +1,69 @@
|
||||
-- 增量托管(口径见 shared/src/batch_watch.ts,实现见 control-server/src/batch_watch.ts)。
|
||||
--
|
||||
-- 一个治理项目(batches 的一行)在存量之外,盯同一个 Meego 视图里新进来的单:每 30 分钟巡检,
|
||||
-- 新单自动建成无人值守的 bug,有了结论才移交给 Meego 经办人。默认关。
|
||||
--
|
||||
-- 全是新增的列和表,不需要回填:旧进程不认识它们,照常读写;没开过托管的批次各列为 null / 0。
|
||||
-- batches.settled_* 三列(0049 遗留)这次不删:旧进程的 schema 还引用它们,迁移在重启前跑,
|
||||
-- 删了旧进程会立刻报错。等这一版上线后再单独删。
|
||||
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_enabled" bigint NOT NULL DEFAULT 0;
|
||||
-- 盯的视图。导入时也会记下(新建向导用的那个视图),开启托管时预填。
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_view_url" text;
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_view_name" text;
|
||||
-- 巡检用谁的 Meego 授权读视图(开启 / 重新授权的那个人的邮箱),和上一次巡检看到的授权状态
|
||||
-- (ok / expired / mismatch)。每次巡检都会刷新,面板不必为了显示它去跑 meegle。
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_identity" text;
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_auth" text;
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_daily_cap" bigint NOT NULL DEFAULT 30;
|
||||
-- 自动建单用的集群(JSON 数组存 TEXT)。开启时取这一批存量最常用的那组。
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_clusters" text;
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_enabled_at" bigint;
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_enabled_by" text;
|
||||
-- 最近一次记基线(开启 / 暂停后重新开启)的时刻。
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_baseline_at" bigint;
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_last_scan_at" bigint;
|
||||
ALTER TABLE "batches" ADD COLUMN IF NOT EXISTS "watch_last_scan_error" text;
|
||||
|
||||
-- 视图里见过的每一张单:导入时列出来的(origin = import,含被人摘掉的)、开启时的基线
|
||||
-- (baseline)、导入之后开启之前新进来的(gap,不自动建,可以补进存量)、巡检看到的新单(scan)。
|
||||
-- 「新单」= 不在这张表里。outcome:created / queued(当天额度用完)/ skipped:<检查桶> /
|
||||
-- backfilled(从 gap 补进存量);基线和 import 行为 null。
|
||||
CREATE TABLE IF NOT EXISTS "batch_view_seen" (
|
||||
"tag" text NOT NULL,
|
||||
"meego_id" text NOT NULL,
|
||||
"url" text NOT NULL,
|
||||
"title" text,
|
||||
"origin" text NOT NULL,
|
||||
"first_seen_at" bigint NOT NULL,
|
||||
"outcome" text,
|
||||
"task_id" text,
|
||||
PRIMARY KEY ("tag", "meego_id")
|
||||
);
|
||||
|
||||
-- 每一次巡检的结果(面板「巡检记录」)。只留最近的,清理在代码里做。
|
||||
CREATE TABLE IF NOT EXISTS "batch_watch_scans" (
|
||||
"id" text PRIMARY KEY,
|
||||
"tag" text NOT NULL,
|
||||
"at" bigint NOT NULL,
|
||||
"in_view" bigint NOT NULL DEFAULT 0,
|
||||
"fresh" bigint NOT NULL DEFAULT 0,
|
||||
"created" bigint NOT NULL DEFAULT 0,
|
||||
"queued" bigint NOT NULL DEFAULT 0,
|
||||
-- 跳过的条数,按导入前检查的桶:{"mr":1,"closed":2}
|
||||
"skipped" text NOT NULL DEFAULT '{}',
|
||||
"error" text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "batch_watch_scans_tag_at" ON "batch_watch_scans" ("tag", "at" DESC);
|
||||
|
||||
-- 增量单:watch_tag = 托管它的批次标签(null = 普通单 / 存量)。存量的进度、阶段、效率都按它排除。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "watch_tag" text;
|
||||
-- 移交给经办人的时刻;只发生一次。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "handed_over_at" bigint;
|
||||
-- 托管期间撤回的原因:meego_closed / mr_bound / owner_archived。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "watch_withdrawn" text;
|
||||
-- 移交时是哪种结论:fixed(修好待复核)/ unrepro(复现不了)/ manual(负责人从待定夺带说明移交)。
|
||||
-- 移交之后可能打回重跑,所以当时就记下来,不按现在的状态倒推。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "handover_kind" text;
|
||||
-- 负责人从「待定夺」带说明移交时写的话,放进移交卡。
|
||||
ALTER TABLE "tasks" ADD COLUMN IF NOT EXISTS "handover_note" text;
|
||||
@@ -0,0 +1,48 @@
|
||||
-- 批量导入的留痕(口径见 shared/src/batch_import_log.ts,实现见 control-server/src/batch_import_log.ts)。
|
||||
--
|
||||
-- 导入 job 只活在控制面内存里,面板一关、控制面一重启,「为什么这几张没导进来」就查不到了。
|
||||
-- 这里把每一次导入和每张单的结果、原因落库,批次详情的「导入记录」读它,重试 / 忽略也写它。
|
||||
--
|
||||
-- 全是新表,不需要回填:留痕上线前导入的批次,第一次打开「导入记录」时由代码按
|
||||
-- batch_view_seen(origin = import)和 tasks 现推一份(kind = legacy),没导进来的再补查原因。
|
||||
|
||||
-- 每一次导入:新建向导(import)、事后重试(retry)、按旧数据现推的(legacy)。
|
||||
CREATE TABLE IF NOT EXISTS "batch_imports" (
|
||||
"id" text PRIMARY KEY,
|
||||
"tag" text NOT NULL,
|
||||
"kind" text NOT NULL,
|
||||
"started_by" text,
|
||||
"started_at" bigint NOT NULL,
|
||||
"finished_at" bigint,
|
||||
"source" text,
|
||||
-- 导入时的设置(集群、通知群、无人值守、语言),JSON。重试沿用最近一次的。
|
||||
"settings" text,
|
||||
"total" bigint NOT NULL DEFAULT 0,
|
||||
"created" bigint NOT NULL DEFAULT 0,
|
||||
"retagged" bigint NOT NULL DEFAULT 0,
|
||||
"set_aside" bigint NOT NULL DEFAULT 0,
|
||||
"failed" bigint NOT NULL DEFAULT 0,
|
||||
"error" text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "batch_imports_tag_started" ON "batch_imports" ("tag", "started_at" DESC);
|
||||
|
||||
-- 每张单最近一次的结果。outcome:created / retagged / set_aside / failed / pending。
|
||||
-- reason:set_aside 时是检查桶或 manual / unknown,failed 时是错误原文。
|
||||
-- evidence:检查时看到的依据(Meego 状态、绑定的 MR……),JSON。
|
||||
-- ignored_at / ignored_by:有人点了「忽略」,不再算进待处理;结果和原因原样保留。
|
||||
CREATE TABLE IF NOT EXISTS "batch_import_items" (
|
||||
"tag" text NOT NULL,
|
||||
"meego_id" text NOT NULL,
|
||||
"url" text NOT NULL,
|
||||
"title" text,
|
||||
"outcome" text NOT NULL,
|
||||
"reason" text,
|
||||
"evidence" text,
|
||||
"task_id" text,
|
||||
"run_id" text,
|
||||
"attempts" bigint NOT NULL DEFAULT 0,
|
||||
"updated_at" bigint NOT NULL,
|
||||
"ignored_at" bigint,
|
||||
"ignored_by" text,
|
||||
PRIMARY KEY ("tag", "meego_id")
|
||||
);
|
||||
@@ -0,0 +1,15 @@
|
||||
-- RSI 实验「批准上线 / 驳回」与按端上线(见 shared/src/rsi_ship.ts、shared/src/prompt_platform.ts)。
|
||||
--
|
||||
-- 复跑通过的实验由管理员批准:批准不改任何指针,只定下上线范围,改动由人提交进代码常量、照常部署;
|
||||
-- 控制面按运行中的代码核对改动在不在,记成「已上线」(promoted_at 复用)/「已撤回」。
|
||||
--
|
||||
-- scope:策略范围。ios / android = 单端策略,只在那一端复跑、只能上那一端;both = 双端策略,
|
||||
-- 两端各一条实验(同一 group_id),两端都复跑通过才能一起上,只有一端通过就只上那一端。
|
||||
-- group_id:双端策略的组。单端为 NULL。
|
||||
-- ship_scope:批准时定下的上线范围(both / ios / android)。
|
||||
--
|
||||
-- 纯新增,不回填:之前的实验都是单端(按 platform),scope 为 NULL 时按 platform 处理。
|
||||
ALTER TABLE "rsi_experiments" ADD COLUMN IF NOT EXISTS "scope" text;
|
||||
ALTER TABLE "rsi_experiments" ADD COLUMN IF NOT EXISTS "group_id" text;
|
||||
ALTER TABLE "rsi_experiments" ADD COLUMN IF NOT EXISTS "ship_scope" text;
|
||||
CREATE INDEX IF NOT EXISTS "rsi_experiments_group" ON "rsi_experiments" ("group_id");
|
||||
@@ -0,0 +1,124 @@
|
||||
-- 一次性补数据:实验 20be5978(bug.run「就绪等待纪律」,Android)补上基线快照。
|
||||
--
|
||||
-- 它是在「提交时存基线快照」(0059 那次上线)之前提交的,base_prompt_id 为空;判定任务退回去拿
|
||||
-- 「现行代码」当基线。改动落进代码(de570667)之后现行代码就带上了它,基线 = 候选,核对不出新增行,
|
||||
-- 面板一直停在「已批准 · 待合入代码」。以后批准时会先补快照(rsi_ship_service.ts::approve),
|
||||
-- 这一条已经批准过,只能补数据。
|
||||
--
|
||||
-- 快照内容 = a04a8cba 的 bug.run 按 android 展开,即它复跑时的现行版;与候选相比恰好新增那 6 行。
|
||||
-- 只在 base_prompt_id 仍为空时生效,重复执行无害。
|
||||
INSERT INTO "agent_prompts" ("id", "stage", "name", "template", "notes", "parent_id", "strategy_id", "created_by", "created_at", "archived")
|
||||
SELECT 'rsi-base-20be5978-android', 'bug.run', '实验基线快照(android)', $rsi_base$你是 TikTok 项目的自主 Bug 修复 Agent。本次任务的工作区在 {{workspaceDir}}。
|
||||
TikTok 代码仓在本会话的 cwd (`{{aiWorkspace}}`) 下,目录名通常是 `TikTok`,自行 `ls` / `cd` 进入,**不要写死绝对路径**。基线分支:{{baseBranch}}。
|
||||
**绝大多数任务改的就是这个仓**;只有当 {{specFile}} 的实现方案**明确指向另一个代码仓**时(例如 IM 的 Lynx 前端 `tt_im_monorepo`,一般在 `~/code/` 下),才去那个仓建分支、改、提交、push —— 规则与下文相同,基线用它自己的主干。不确定时留在这个仓。
|
||||
|
||||
## 步骤 1 — 阅读需求
|
||||
读取以下三处内容来理解 bug:
|
||||
- {{workspaceDir}}/OriginalIntro.md ← 原始 Meego 描述
|
||||
- {{workspaceDir}}/{{specFile}} ← 人工确认的复现路径 + 期望行为 + 回归风险点
|
||||
- 两部分权威性不同:**「期望与实际」「修复后验证」是权威的,判 FIXED 以它为准**;「复现条件」「复现步骤」是评估阶段的推断,**以真机实际为准**(按步骤 3.5 记录){{correctionsNote}}
|
||||
- {{workspaceDir}}/images/ ← 附件截图,需要时加载
|
||||
{{linkNote}}
|
||||
|
||||
## 步骤 2 — 判断本批是否接着上一批修
|
||||
> 术语:一次派发 = **一批执行**;你在本批内部的「复现 → 改 → 验」循环叫**尝试**。两者不要都叫「轮」——下游报告会把它们混成同一个计数。
|
||||
{{stepTwo}}
|
||||
|
||||
{{serverBlock}}{{iosDeviceBlock}}{{waitBlock}}## 步骤 3 — 复现、修复、验证(本批内最多 {{maxRounds}} 次尝试)
|
||||
对每一次尝试:
|
||||
1. **本批第一次尝试使用远程 clean 构建** 出复现产物包;后续尝试尽量使用增量构建
|
||||
2. 按 {{specFile}} 中的「复现路径」操作连接的设备进行复现
|
||||
- 若 3 次尝试仍无法复现,写一份 FixReport.md 说明排查过程与可能原因,最后单独打印 `STATUS: UNREPRODUCIBLE` 并退出
|
||||
3. 复现成功后,先把"修复前"证据落到 `{{workspaceDir}}/evidence/` 目录(**文件名要语义化**,命名规范见步骤 4;下游"可读性报告"靠文件名 + 你在 FixReport 里对每张图的描述来挑图讲图,名字越准、描述越全,报告越好)
|
||||
4. 分析根因 → 改代码 → 重新构建 → 按 {{specFile}}「修复后验证」的四类逐条验证
|
||||
- **判 FIXED 的门槛(必须全过,缺一不可,只满足"症状消失"不得判 FIXED)**:
|
||||
- 负向:坏现象不再出现;
|
||||
- 正向:「期望」里的正确行为确实生效/可用 —— 若你的修法是"在该场景把某功能/分支关掉/旁路掉"(如 `if(场景) return/skip`、置某 flag 为关),它能让负向通过,但通常过不了正向,**这类场景旁路是最后手段**;
|
||||
- 机制级:把根因写成可观测命题(判定点 + 可观测量 + 期望取值),用证据证明该坏机制在修复后**不再触发**(如判定点某状态不再为空、坏分支/多余请求不再执行),而不是"最终结果恰好正确";
|
||||
- 对抗性条件:在冷启动 / 清缓存 / 与默认值不同的输入下复跑,避免"结果恰好相同"的假通过。
|
||||
- 四类全过 → 把"修复后"证据落到 `{{workspaceDir}}/evidence/`(**与"修复前"同场景/同屏,便于给出前后对比**;机制级证据尽量用截图并体现"坏机制未触发"),写 FixReport.md(见步骤 4);否则进入下一次尝试
|
||||
- **变更方法覆盖(Frida,随携带变更的包执行采集)**:每次把**含本次改动的包**装上并跑起来时(四类验证、修后复现、对抗性复跑都算;同一份变更包可能跑多次),用 Frida hook **本次 diff 新增/改动的每一个方法或符号**,记录它有没有被调用过。只用来提醒你是否改了验证过程中根本没跑到的代码,**不作为** `STATUS: FIXED` 的门槛;不要为提高覆盖率改验证路径、重编、或再跑一轮只刷覆盖。
|
||||
- **禁止**:改源码打日志 / 插 tag、为覆盖率重新编译或再装一包。
|
||||
- **多次执行取并集**:命中集合是各次运行的**并集** —— 某方法只要在其中一次跑里进来过就算命中。报告里的「未执行」是:成功 hook 到、但所有运行都没触发。
|
||||
- **三态,不要混**:①**命中** — 至少一次运行里 hook 触发;②**未执行** — hook 已装上,所有运行都没触发 → **尤其注意**这段改动是否无意义;③**没记录到** — attach 失败、找不到符号、hook 没装上、工具不可用 → 记「没记录到」,**不要**写成未执行。
|
||||
- **Frida 同进程只能一次 attach**:不要对同一 App 再开第二个 `frida` / `frida-trace` 进程(第二次常失败,或把第一次的 Java `implementation` 冲掉)。覆盖率 hook 和其他诊断 hook 必须在**同一次 session**里共存:推荐写进同一份脚本,覆盖率部分只把方法名 append 到临时文件;同一方法既要覆盖率又要诊断时,写在**同一个** `implementation` / `Interceptor.attach` 回调里;或一条命令加载多脚本(`frida … -l cov.js -l other.js`)。attach 必须有明确退出条件,禁止裸 `frida ... &`。
|
||||
- **平台**:Android 用 `Java.use` hook Java/Kotlin 方法(含合成 lambda),JNI 用 `Interceptor.attach`。iOS ObjC 用 `ObjC.classes`;Swift 对 Inhouse/Debug 符号 `Interceptor.attach`(mangled name);内联/无符号闭包记没记录到。macCatalyst 按本地进程 attach。
|
||||
- **落盘**:命中可先写临时文件(一行一个符号,append,跨次运行不要清空),结束时读并集写进 FixReport「代码覆盖检查」;给人看的摘要可拷到 `evidence/mech-<run>-method-cov.jsonl`。
|
||||
- **统计**:覆盖率只在成功记录的方法上算 = 命中 / (命中+未执行);没记录到单独列出,不进分母。列出未执行的方法(尤其注意)和没记录到的方法。
|
||||
- **端到端演示视频(核心可视化证据,能录必录)**:统一通过内置的 **`record-evidence` 工具**录制(Android / iOS 真机 / iOS 模拟器 / macCatalyst 同一套命令 —— 底层按目标自动选后端:有设备走 mobilecli,本机跑着被测 macCatalyst 窗口时走 catuse;视频直接落 evidence/ 无需 pull),它会自动用 ffprobe 校验时长/画面/文件完整性,并把每一次尝试(含失败)结构化写入 `evidence/manifest.jsonl`,便于事后定位"没截到关键点 / 太长不够浓缩 / 录空 / 录制失败"等问题——**不要再直接手敲 `adb` / `xcrun` / `catuse record` / `catuse savescreenshot` / `ffmpeg` 录屏截图** —— 那样录出来的文件不带 intent / expect-moment、不进 manifest,事后无法判断它该证明什么。
|
||||
- **录单段演示**:先执行 `{{recordEvidenceCmd}} start --dir {{workspaceDir}}/evidence --out demo-<run>-<slug>.mp4 --intent "<这段要证明什么>" --expect-moment "<必须录到的关键瞬间,如'点击后红点消失'>"` → 按提示在设备上完成复现/验证操作(**务必录到 expect-moment 那一刻**,聚焦关键步骤、控制在 ≤~60s,别录成冗长操作流水)→ 再执行 `{{recordEvidenceCmd}} stop --dir {{workspaceDir}}/evidence --capture <start 返回的 captureId>`。stop 会打印 ✅ 通过 / ⚠️ 告警 / ❌ 未通过。
|
||||
- **最推荐「前后对比视频」(有条件务必优先做)**:分别录"修复前(坏现象)"与"修复后(修复生效)"两段——由同一开关/flag 控制的改动尤其适合,就分别录**关(旧坏行为)/ 开(修复后行为)**,各自 start/stop 存成 `before-<run>-<slug>.mp4` 与 `after-<run>-<slug>.mp4`;再用 `{{recordEvidenceCmd}} compose --dir {{workspaceDir}}/evidence --out demo-<run>-before-after-<slug>.mp4 --left before-<run>-<slug>.mp4 --right after-<run>-<slug>.mp4 --intent "<对比证明什么>"` 拼成左右并排同框对照(一眼看清前后差异)。这段对比视频会被放到可读性报告「媒体证据」的**第一位**作为核心证据。
|
||||
- **失败重录规则**:若 stop/compose 返回 ❌(太长/为空/疑似静止/pull 失败等),按提示**重录一次**(工具仅允许 1 次重试);若重试后仍 ❌ 或工具提示"重试已用尽",**不要再无限重录**,在 FixReport「验证局限」里如实说明该证据未达标及原因。
|
||||
- 仅当无可用设备 / 无法录屏(纯后端改动、活体环境离线)时才跳过,并执行 `{{recordEvidenceCmd}} skip --dir {{workspaceDir}}/evidence --out demo-<run>-<slug>.mp4 --reason "<原因>"` 记录一笔,同时在 FixReport「验证局限」里说明
|
||||
- **例外:性能 / 帧率 / 尺寸(≤4dp)/ 埋点 这四类缺陷不要求演示视频。** 视频拍不出"卡顿"、拍不出 8px 的位移、拍不出埋点参数;这几类改用**可量化对照**(CPU% / Janky% / uiautomator bounds 数值 / 事件参数 dump,前后各一组数写进报告),`skip --reason` 记一笔即可,不按缺证据算
|
||||
- **采集前的声明**:画面本就不该动的场景(长按态 / 静态弹窗 / 低帧率)在 start 时带 `--static-scene "<为什么静止>"`,否则会被判 fail 白吃一次重录;前后对比的两段各带 `--scene "<语言/页面>"`,两边不一致会被标 `scene-mismatch`;重录时改 intent / expect-moment 会被记一条 `redeclare`,**报告里必须说明为什么改**
|
||||
5. 按照修复 {{specFile}} 中的边界用例执行,并确保边界用例符合要求。否则回到步骤 4;
|
||||
- 提醒:你的修复结果会先经过一个**独立评审 Agent** 复核(判别"真根因修复 / 场景旁路 / 仅症状消失但未达期望"),旁路或假通过会被打回重修,所以请直接在源头按"同……一致/对齐"的真实机制去修。
|
||||
6. 若超过 {{maxRounds}} 次尝试仍未修复,写 FixReport.md 总结尝试过的修复路径与残留问题,最后单独打印 `STATUS: FIX_FAILED` 并退出
|
||||
|
||||
{{trackingBlock}}
|
||||
{{conditionsBlock}}
|
||||
{{kbContext}}
|
||||
## 步骤 4 — 交付产物(无论成功失败都要写)
|
||||
全部落在 `{{workspaceDir}}/` 下。**关键铁律:整个 session 中产生的任何截图、调试图、日志文件、构建产物快照,统统输出到 `{{workspaceDir}}/evidence/` 这一个目录,禁止散落到 /tmp、AI_WORKSPACE、TikTok repo 根、或任意其他位置。**
|
||||
|
||||
> 交付物会先喂给一个「可读性报告」生成器,把 FixReport + 截图转成给 PM / 设计 / 复核看的图文报告。**生成器看不到像素,只能读你写的文字和文件名**——所以证据命名的语义、以及你对每张图"证明了什么"的描述,直接决定最终报告的质量。请按下面结构认真写、写全。
|
||||
|
||||
{{conditionsDeliverable}}
|
||||
- **`evidence/`** — 唯一允许的证据落盘位置。**命名规范:`<phase>-<run>[-<NN>]-<slug>.<ext>`**
|
||||
- `<phase>`:`demo`(端到端演示视频 .mp4,**核心可视化证据**)· `before`(修复前坏现象)· `after`(修复后同场景验证)· `flow`(复现/验证分步,配 `<NN>` 两位序号)· `mech`(机制级证据:坏机制未触发的抓包/调试器/日志高亮)· `edge`(对抗性:冷启动/清缓存/异值输入)
|
||||
- `<run>`:**执行批次**序号 —— 本批是第一次派发就写 `1`,是再次执行(接着上一批修)就写 `r2`/`r3`,与你在本批内部的第几次**尝试**无关(别用尝试序号,否则同一批会互相覆盖)
|
||||
- `<slug>`:3-6 词英文 kebab-case,**描述这张图/这段视频证明了什么**,例:`story-btn-overlap-gone`、`bad-request-not-sent`、`cold-start-fixed`;**禁止** `screenshot1`、`img`、`test`、`1` 这类无信息名
|
||||
- `before`/`after` 尽量**同场景成对**,便于报告给出最有说服力的前后对比;后缀:视频用 `mp4`(也接受 `mov`/`webm`),截图用 `png`/`jpg`,文本用 `txt`/`log`/`json`;**主路径尽量录一段 `demo-*.mp4`,机制级证据尽量截图**(演示视频与图片都会进入报告的媒体证据,**视频排在最前作为首要证据**,纯文本不入图)
|
||||
- **设备截图**统一走 `{{recordEvidenceCmd}} shot --dir {{workspaceDir}}/evidence --out <phase>-<run>-<slug>.png --intent "<这张证明什么>"`(同样会校验并写入 manifest);非设备来源的证据(抓包面板、调试器、日志高亮等)按上面命名规范直接存进 `evidence/` 即可。**注意 `flow-*`(排查步骤)与 `probe-*`(探索录制)不算证据**:`probe-*` 不进报告,`flow-*` 只会作为过程记录排在末尾,两者都不会被选成核心证据或前后对比 —— 要支撑结论就用 `demo/before/after/mech/edge`
|
||||
- **`FixReport.md`** {{reportLangNote}},按以下小节组织(每节直接对应下游报告的一个板块,请勿省略;小节标题用加粗或 `##` 独占一行):
|
||||
- 单独一行 `branch: bugfix/<slug>`(便于工具解析,**slug 必须是 step 2 里你造的英文 slug,不要写 meego 数字 id**)
|
||||
- **用户影响**:一句话说清用户实际遇到的坏现象(保留"必现/偶现"等严重度线索)
|
||||
- **大白话总结**:2-4 句,不出现框架/方法/字段名,点出**一个**关键修复思路即可(给 PM / 设计看)
|
||||
- **修复变更摘要**:改动的文件 / 方法 + **净增/删行数**;并**原样引用最能代表本次修复的那一小段代码 hunk(≤25 行,过长处用 `…` 省略)**,不要贴整段 diff
|
||||
- **代码覆盖检查**:给出步骤 3 Frida 方法覆盖的三态——①成功记录的方法上写清**覆盖率**(命中 / (命中+未执行),如 `覆盖率 4/6 个方法`);②**未执行**的方法(验证全程没进来,**尤其注意**是否改了无意义代码);③**没记录到**的方法(工具/符号/attach 失败,不要写成未执行);④全部命中则写一行「变更方法全部命中」。多次跑变更包时按命中**并集**统计。**系统会另行从你的 diff 机械解析出本次改动的每一个方法,与你这一节对账**(不看你写了什么,直接按 diff 算分母),结果连同本节一起发给提需人 —— 对不上时以对账为准,所以这里不要漏列方法,漏列会让覆盖率显得更好看,但会被直接看到。
|
||||
- **埋点影响**:本次 diff 对**业务埋点 / 数据上报**的影响,三选一如实写明——①`本次未触碰任何埋点`;②改动了埋点:逐条写 `事件名` + 改了什么(删除 / 改名 / 改参数 / 改上报时机 / 挪位置)+ **需求为什么要求这么改**;③新增了入口或分支并补齐了上报:列出新增的事件名与所在文件。**系统会另行对你的 diff 做一次机械扫描**(不看你写了什么,直接匹配上报调用的增删),结果会连同本节一起发给提需人 —— 两者对不上时以扫描为准,所以这里不要漏写也不要美化
|
||||
- **根因分析** — **写成可检验命题**:每条根因给出(判定点 + 可观测量 + 修复前取值/坏分支),让审阅者据此核对,而不是一段散文;若存在"本批某次早期尝试引入的次生根因",单独标出
|
||||
- **修复验证对照** — 对每条根因命题,给出"修复后该命题已失效"的机制级证据(如"判定点 X 不再为空 / 坏分支未执行 / 多余请求消失"),注明在何种对抗性条件(冷启动/清缓存/异值输入)下取得,并尽量给**可量化指标**(次数 / 请求数 / 耗时 / 覆盖条数);**不得用"最终结果恰好正确"代替机制级证据**
|
||||
- **测试图清单**:逐个列出你落盘的**演示视频 + 截图**(用 `evidence/<filename>` 相对路径)+ 一句话"此图/此视频证明了……" + 角色(demo/before/after/flow/mech/edge),有前后对比的明确指出哪张是 before、哪张是对应 after;若录了 `demo-*.mp4`,**在清单最前面单列一条**说明它端到端演示了什么(这是报告的首要证据)。**这是下游挑图讲图的唯一依据,务必写全写准**
|
||||
- **方案权衡** — 若采用了"场景旁路/关功能"类修法,必须写明:定位到的源头正确修法是什么、为何未采用、遗留的 tech-debt;若是源头修复则简述为何这是根因所在
|
||||
- **验证局限**:如实写明未覆盖 / 被阻塞(如活体环境离线)的验证点及原因,**不得夸大**;宁可标注"阻塞"也不要假装通过
|
||||
|
||||
### 若本批以 `STATUS: FIX_FAILED` 收尾(修复未成功),FixReport 换成下面这套结构
|
||||
失败的 FixReport **不是"缺了几节的成功报告"**,它的读者与用途完全不同:接手的人要靠它判断「哪些路已经走死了、根因到底定位到哪一步、还差什么才能修」。所以此时**不要**再写「修复变更摘要 / 代码覆盖检查 / 修复验证对照」这三节(没修好的代码不构成"变更成果",对它做覆盖统计与验证对照只会误导),改为按以下小节写(`branch:` 行、`用户影响`、`大白话总结`、`测试图清单`、`验证局限` 仍照上面的要求保留):
|
||||
- **失败结论**:一句话说清当前状态 —— 问题仍然存在,以及卡在哪一步(根因未定位 / 根因已定位但不在本端可修 / 有候选修法但无法验证 / 修法引入回归)
|
||||
- **尝试过程(逐次尝试)**:**这是失败报告最有价值的一节,务必写全**。本批内每一次尝试独立成条(写成「第 N 次尝试」,不要写「第 N 轮」),写清:①这次改了什么(文件/方法,一句话);②**它为什么不成立** —— 必须给出杀死这次尝试的那个具体观测(某判定点仍为空 / 坏分支仍执行 / 抓包里请求根本没发出 / 复核意见指出的现象仍在),**不要只写"未通过"**
|
||||
- **失败原因**:承接上面,给出你目前能站得住的判断,并明确归类:
|
||||
- 根因未定位 —— 写清已经排除到哪个范围、下一个该查的点是什么
|
||||
- **根因已定位但不在本端可修** —— 写清根因实际在哪(服务端 / 其他团队模块 / 需要协议或配置变更)、你据什么这么判断。**这是失败报告里最有价值的结论,有就一定要写明**
|
||||
- 验证环境阻塞 —— 写清缺什么(设备 / 账号 / 权限 / 实验 / 构建)
|
||||
- 修法引入回归 —— 写清坏了什么
|
||||
- **已排除的假设**:逐条列出验证过、已被否决的假设 + 否决它的那一个观测。这节直接决定接手的人会不会重走一遍你的死路,**不要省**
|
||||
- **残留疑点与下一步**:仍然不确定的点,以及给接手的人的具体建议(要可执行可核对,如「确认服务端 `xxx` 接口是否对 `aweme_type=45` 放行」,而不是「继续排查」)
|
||||
|
||||
证据方面:失败场景下 `evidence/` 里**不会有真正的 `after-*`(没有"修复后")**。请把截图/录屏如实命名为 `before-*`(坏现象仍在)、`mech-*`(诊断/机制级观测)、`flow-*`(排查步骤),**不要**为了凑前后对比把"某次尝试之后仍然是坏的"截图命名成 `after-*` —— 下游报告会把 `after-*` 当成"修复后"来讲,那会把结论讲反。
|
||||
语气:如实、具体、不美化,也不必自责。「客户端三条通道均已发出、服务端仍未放行」这种结论,比任何委婉措辞都更有价值。
|
||||
|
||||
## 步骤 5 — 远程交付(**修复成功后、打印 `STATUS: FIXED` 之前执行;UNREPRODUCIBLE / FIX_FAILED 跳过本步**)
|
||||
系统已为本次任务单独注入 git author 环境变量;直接执行 `git commit` 即可,不要手动修改全局或仓库级 `git config user.name/user.email`。
|
||||
{{stepFive}}
|
||||
|
||||
## 输出约束
|
||||
- 整个 session 的最后一行必须是以下三者之一(用于上游解析,**没有这行就视为 FIX_FAILED**):
|
||||
- `STATUS: FIXED`
|
||||
- `STATUS: UNREPRODUCIBLE`
|
||||
- `STATUS: FIX_FAILED`
|
||||
- **打印任何 `STATUS:` 之前,必须已经执行过步骤 3.5 的 `{{conditionsCmd}} done`**(三种 STATUS 都适用 —— 尤其是 `UNREPRODUCIBLE`:复现不了几乎一定意味着真实条件与 spec 不同,那正是最该记录的一次)。
|
||||
- **`STATUS: FIXED` 只能在步骤 5 的 push 之后、作为最后一行打印;收尾前不要提前写出 `STATUS: FIXED` 字面串(会触发上游 watchdog 提前强杀,打断 push)。**
|
||||
- 中间步骤可以打印任何信息,我们会把完整 stdout 持久化到 {{workspaceDir}}/logs/ 下本批的会话日志(session-r<批次>.log)
|
||||
|
||||
任务上下文:
|
||||
- Meego: {{meegoUrl}}
|
||||
- 标题: {{title}}
|
||||
- 平台: {{platform}} 类型: {{bugType}} 难度: {{difficulty}}
|
||||
- 历史尝试次数: {{attempts}}
|
||||
{{reviewFeedback}}{{pastRounds}}$rsi_base$,
|
||||
'补录:a04a8cba 的 bug.run 按 android 展开', NULL, NULL, 'rsi-loop-base', 1792540800000, 1
|
||||
WHERE NOT EXISTS (SELECT 1 FROM "agent_prompts" WHERE "id" = 'rsi-base-20be5978-android');
|
||||
UPDATE "rsi_experiments" SET "base_prompt_id" = 'rsi-base-20be5978-android'
|
||||
WHERE "id" = '20be5978-0a9f-4cb3-b2e9-0aa473841291' AND "base_prompt_id" IS NULL;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- 增量托管「Meego 任务状态」页(shared/src/batch_watch.ts::ViewItem):视图里见过的每一张单,
|
||||
-- 上一次巡检时还在不在视图里。每次巡检成功后把视图里的单号记成这次巡检的时刻;
|
||||
-- 小于上一次成功巡检时刻的就是已经离开视图了。
|
||||
--
|
||||
-- 纯新增,不回填:为 NULL 的行在下一次巡检(最多 30 分钟)之后就分得清了,之前面板显示「未知」。
|
||||
ALTER TABLE "batch_view_seen" ADD COLUMN IF NOT EXISTS "last_seen_at" bigint;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- 增量托管的巡检策略(shared/src/batch_watch.ts::WATCH_EXTRA_STATES):除默认的待修状态外,这个项目还接哪些 Meego 状态。JSON 数组,空 = 只接默认。
|
||||
ALTER TABLE batches ADD COLUMN IF NOT EXISTS watch_extra_states text;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- 修到 alpha(shared/src/alpha_branch.ts)。
|
||||
-- batches.watch_alpha_p1:增量托管新建的 P1 及以上的单走最新 alpha,默认关,存量不受影响。
|
||||
-- tasks.retarget:一次「重做到 alpha」的进度(JSON),没有在挪就是 NULL。
|
||||
ALTER TABLE batches ADD COLUMN IF NOT EXISTS watch_alpha_p1 bigint NOT NULL DEFAULT 0;
|
||||
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS retarget text;
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE security ADD COLUMN IF NOT EXISTS requires_artifacts bigint NOT NULL DEFAULT 0;
|
||||
ALTER TABLE security ADD COLUMN IF NOT EXISTS artifact_url text;
|
||||
ALTER TABLE security ADD COLUMN IF NOT EXISTS artifacts text;
|
||||
@@ -0,0 +1,79 @@
|
||||
-- 复核意见挖掘(口径见 shared/src/review_mining.ts,实现见 control-server/src/review_mining.ts)。
|
||||
--
|
||||
-- 人工复核的打回意见本身在 tasks / features / security.review_history 里(JSON),这里不复制正文,
|
||||
-- 只存三样派生物:每条意见的标签、每周归纳出的候选规范、本人确认过的个人口味。
|
||||
-- 全是新表,不需要回填:回路进程第一次运行时按窗口把历史意见补标一遍。
|
||||
|
||||
-- 每条复核意见一行。key = <target_kind>:<target_id>:<note_at>:<note_source>,与 review_history 里的一条一一对应。
|
||||
-- reviewer 是归属到的复核人(邮箱前缀),reviewer_via 说明怎么认出来的:
|
||||
-- note = ReviewNote.reviewer(11-02 起打回时写入);transition = 打回那一刻的流转 actor(09-30 起有);null = 认不出。
|
||||
-- 个人口味只认 note / transition,不拿建单人顶替(批量导入的单建单人是导入人,不是复核人)。
|
||||
CREATE TABLE IF NOT EXISTS "review_note_labels" (
|
||||
"key" text PRIMARY KEY,
|
||||
"target_kind" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"note_at" bigint NOT NULL,
|
||||
"note_round" bigint,
|
||||
"note_source" text NOT NULL,
|
||||
"platform" text,
|
||||
"reviewer" text,
|
||||
"reviewer_via" text,
|
||||
"creator" text,
|
||||
-- code_practice | process_practice | requirement_change | ui_spec | defect | verification | context_hint | ops | other
|
||||
"cat" text NOT NULL,
|
||||
-- 只在两类 practice 时有值:global | repo | personal
|
||||
"scope" text,
|
||||
"topic" text,
|
||||
"rule" text,
|
||||
"preventable" bigint NOT NULL DEFAULT 0,
|
||||
"why" text,
|
||||
"excerpt" text,
|
||||
"labeler" text NOT NULL,
|
||||
"labeled_at" bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "review_note_labels_target" ON "review_note_labels" ("target_kind", "target_id");
|
||||
CREATE INDEX IF NOT EXISTS "review_note_labels_note_at" ON "review_note_labels" ("note_at" DESC);
|
||||
|
||||
-- 每周归纳出的候选规范。证据只存标签 key,统计由控制面按证据重算(不信模型报的数)。
|
||||
-- status:pending → accepted(全局 / 仓库级:待改 shared/src/code_conventions.ts;个人:已发给本人确认)
|
||||
-- → shipped(已落代码,填 shipped_ref)| rejected | superseded(同一题目有了更新的候选)
|
||||
CREATE TABLE IF NOT EXISTS "convention_candidates" (
|
||||
"id" text PRIMARY KEY,
|
||||
"run_id" text NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
"window_from" bigint NOT NULL,
|
||||
"window_to" bigint NOT NULL,
|
||||
"scope" text NOT NULL,
|
||||
-- repo 级规则落在哪一端的平台段;global / personal 为 null
|
||||
"platform" text,
|
||||
-- personal 时是本人邮箱前缀
|
||||
"owner" text,
|
||||
"family" text NOT NULL,
|
||||
"rule" text NOT NULL,
|
||||
"rationale" text,
|
||||
-- none | partial | full:现行代码规范块是否已经覆盖(模型判断,仅供参考)
|
||||
"covered" text,
|
||||
"evidence" text NOT NULL,
|
||||
"conflicts" text,
|
||||
"stats" text NOT NULL,
|
||||
"status" text NOT NULL DEFAULT 'pending',
|
||||
"decided_by" text,
|
||||
"decided_at" bigint,
|
||||
"decision_note" text,
|
||||
"shipped_ref" text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "convention_candidates_status" ON "convention_candidates" ("status", "created_at" DESC);
|
||||
|
||||
-- 个人口味。只有本人点了确认(status = active)才会在派单时注入;proposed 只是等本人看。
|
||||
CREATE TABLE IF NOT EXISTS "code_style_prefs" (
|
||||
"id" text PRIMARY KEY,
|
||||
"owner" text NOT NULL,
|
||||
"rule" text NOT NULL,
|
||||
"candidate_id" text,
|
||||
-- proposed | active | declined | retired
|
||||
"status" text NOT NULL DEFAULT 'proposed',
|
||||
"created_at" bigint NOT NULL,
|
||||
"updated_at" bigint NOT NULL,
|
||||
"confirmed_at" bigint
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS "code_style_prefs_owner" ON "code_style_prefs" ("owner", "status");
|
||||
@@ -0,0 +1,16 @@
|
||||
-- Private main-Agent conversations; no public feed or administrator bypass.
|
||||
CREATE TABLE IF NOT EXISTS eddy_conversation_events (
|
||||
id text PRIMARY KEY,
|
||||
sequence bigserial NOT NULL UNIQUE,
|
||||
owner text NOT NULL,
|
||||
machine text NOT NULL,
|
||||
task_id text NOT NULL,
|
||||
task_title text NOT NULL,
|
||||
source_id text NOT NULL,
|
||||
provider text NOT NULL,
|
||||
event text NOT NULL,
|
||||
received_at bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS eddy_conversations_owner_sequence ON eddy_conversation_events (owner, sequence);
|
||||
CREATE INDEX IF NOT EXISTS eddy_conversations_task_sequence ON eddy_conversation_events (owner, task_id, sequence);
|
||||
CREATE INDEX IF NOT EXISTS eddy_conversations_source_sequence ON eddy_conversation_events (owner, machine, task_id, source_id, sequence);
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS eddy_usage_events (
|
||||
id text PRIMARY KEY, at bigint NOT NULL, received_at bigint NOT NULL,
|
||||
installation text NOT NULL, name text NOT NULL, action text NOT NULL,
|
||||
source text NOT NULL, release text NOT NULL, macos_major text NOT NULL,
|
||||
outcome text, duration_ms bigint, queue_ms bigint, session text, operation text
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS eddy_usage_at ON eddy_usage_events (at);
|
||||
CREATE INDEX IF NOT EXISTS eddy_usage_release_at ON eddy_usage_events (release, at);
|
||||
CREATE INDEX IF NOT EXISTS eddy_usage_received_at ON eddy_usage_events (received_at);
|
||||
@@ -0,0 +1,45 @@
|
||||
-- Normalize payloads without changing existing task-envelope pagination/ids.
|
||||
-- Run via the deployment migration flow, never against production from a laptop.
|
||||
CREATE TABLE IF NOT EXISTS eddy_conversation_records (
|
||||
id text PRIMARY KEY, owner text NOT NULL, event text NOT NULL,
|
||||
payload_bytes bigint NOT NULL, received_at bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS eddy_conversation_records_received_at ON eddy_conversation_records(received_at);
|
||||
ALTER TABLE eddy_conversation_events ADD COLUMN IF NOT EXISTS record_id text;
|
||||
ALTER TABLE eddy_conversation_events ADD COLUMN IF NOT EXISTS ingestion_bytes bigint NOT NULL DEFAULT 0;
|
||||
ALTER TABLE eddy_conversation_events ALTER COLUMN event DROP NOT NULL;
|
||||
INSERT INTO eddy_conversation_records (id, owner, event, payload_bytes, received_at)
|
||||
SELECT DISTINCT ON (owner, machine, source_id, event::jsonb->>'id')
|
||||
encode(sha256(convert_to(owner || E'\n' || machine || E'\n' || source_id || E'\n' || (event::jsonb->>'id'), 'UTF8')), 'hex'),
|
||||
owner, event, octet_length(event), received_at
|
||||
FROM eddy_conversation_events WHERE event IS NOT NULL
|
||||
ORDER BY owner, machine, source_id, event::jsonb->>'id', received_at
|
||||
ON CONFLICT DO NOTHING;
|
||||
UPDATE eddy_conversation_events SET record_id = encode(sha256(convert_to(
|
||||
owner || E'\n' || machine || E'\n' || source_id || E'\n' || (event::jsonb->>'id'), 'UTF8')), 'hex')
|
||||
WHERE record_id IS NULL AND event IS NOT NULL;
|
||||
UPDATE eddy_conversation_events SET ingestion_bytes = octet_length(jsonb_build_object(
|
||||
'id', id, 'owner', owner, 'machine', machine, 'taskId', task_id, 'taskTitle', task_title,
|
||||
'sourceId', source_id, 'provider', provider, 'receivedAt', received_at, 'recordId', record_id)::text), event = NULL
|
||||
WHERE record_id IS NOT NULL AND event IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS eddy_conversations_record_id ON eddy_conversation_events(record_id);
|
||||
CREATE INDEX IF NOT EXISTS eddy_conversations_received_at ON eddy_conversation_events(received_at);
|
||||
ALTER TABLE eddy_usage_events ADD COLUMN IF NOT EXISTS budget_owner text;
|
||||
ALTER TABLE eddy_usage_events ADD COLUMN IF NOT EXISTS ingestion_bytes bigint NOT NULL DEFAULT 0;
|
||||
UPDATE eddy_usage_events SET ingestion_bytes = octet_length(row_to_json(eddy_usage_events)::text) WHERE ingestion_bytes = 0;
|
||||
CREATE TABLE IF NOT EXISTS eddy_ingestion_budget (
|
||||
key text PRIMARY KEY, bytes bigint NOT NULL DEFAULT 0, rows bigint NOT NULL DEFAULT 0,
|
||||
day bigint NOT NULL DEFAULT 0, day_bytes bigint NOT NULL DEFAULT 0, day_rows bigint NOT NULL DEFAULT 0,
|
||||
tokens double precision, token_at bigint NOT NULL DEFAULT 0
|
||||
);
|
||||
-- Seed existing retained data; migration retries never reset live budgets.
|
||||
WITH entries AS (
|
||||
SELECT owner, payload_bytes AS bytes FROM eddy_conversation_records
|
||||
UNION ALL SELECT owner, ingestion_bytes AS bytes FROM eddy_conversation_events
|
||||
), totals AS (
|
||||
SELECT 'conversation:global' AS key, coalesce(sum(bytes),0) AS bytes, count(*) AS rows FROM entries
|
||||
UNION ALL SELECT 'conversation:owner:' || encode(sha256(convert_to(lower(owner),'UTF8')),'hex'), sum(bytes), count(*) FROM entries GROUP BY owner
|
||||
)
|
||||
INSERT INTO eddy_ingestion_budget (key, bytes, rows) SELECT key, bytes, rows FROM totals ON CONFLICT DO NOTHING;
|
||||
INSERT INTO eddy_ingestion_budget (key, bytes, rows)
|
||||
SELECT 'usage:global', coalesce(sum(ingestion_bytes),0), count(*) FROM eddy_usage_events ON CONFLICT DO NOTHING;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Product usage per account: the uploader's SSO email (lower case) on each new event, for the
|
||||
-- administrator per-user view. Earlier events carry only budget_owner (sha256 of that email).
|
||||
ALTER TABLE eddy_usage_events ADD COLUMN IF NOT EXISTS owner text;
|
||||
CREATE INDEX IF NOT EXISTS eddy_usage_owner_at ON eddy_usage_events (owner, at);
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Bug 的 QA(Meego 创建人):导入时记下,和 watchers 里的经办人一起算这张单的负责人。
|
||||
-- 单独一列而不是并进 watchers:watchers 是状态卡片的收件人,QA 现在只挂名、进经办人排行,不收卡片
|
||||
-- (见 shared/src/types.ts::Task.qaEmail)。存量单为 NULL,不回填。
|
||||
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS qa_email text;
|
||||
@@ -0,0 +1,31 @@
|
||||
-- 开放平台 v1:外部系统用 API Key 建「一句话需求」(feature)。
|
||||
--
|
||||
-- 和 0020 给 tasks 加的三列同一个道理:只有把「哪把 key 建的、带着调用方什么单号」
|
||||
-- 记在 features 上,归属闸(一把 Key 只看得到 / 只能执行自己建的需求)、按 Key 查单、
|
||||
-- 以及面板上「开放平台 · 申请人」的标记才成立。
|
||||
--
|
||||
-- created_via_key_id —— 建需求时鉴权命中的 key 的稳定 id(openplatform_keys.ts 里的
|
||||
-- id,不是数据库外键 —— key 列表活在 settings KV)。
|
||||
-- created_via_source —— 那把 key 注册时填的来源标签快照,纯展示,key 改名不影响历史。
|
||||
-- external_id —— 调用方自己的需求/工单 ID;与该 key 组合去重(见下)。
|
||||
--
|
||||
-- 去重按 (created_via_key_id, external_id) 这一对而不是 external_id 单列:两个接入方
|
||||
-- 各自选的 external_id 可能撞号,去重范围锁定在调用的那把 key 上就不会互相踩号。
|
||||
-- 两者都非空时才生效;非开放平台创建的需求三列全为 NULL,不受影响。
|
||||
--
|
||||
-- ⚠️ 部署顺序:**先跑这条迁移,再上新代码**。新代码的每一次 feature 读(项目列表/详情
|
||||
-- 的列投影都从 getTableColumns 派生)和每一次 feature 写(insertFeature 无条件写这三列)
|
||||
-- 都会带新列 —— 反过来的话不是「新接口不可用」,而是整个需求看板/详情报 SQL 错。
|
||||
-- deploy.sh 的 check-migrations 会拦,手工 apply-migration 时别忘了。
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "created_via_key_id" text;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "created_via_source" text;
|
||||
ALTER TABLE "features" ADD COLUMN IF NOT EXISTS "external_id" text;
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS features_created_via_key_external_id_uidx
|
||||
ON "features" ("created_via_key_id", "external_id")
|
||||
WHERE "created_via_key_id" IS NOT NULL AND "external_id" IS NOT NULL;
|
||||
|
||||
-- GET /api/openapi/v1/features 按 Key 列自己建的需求。上面那个唯一索引只覆盖带
|
||||
-- external_id 的行,没传 external_id 的需求用不上它(同 0052 给 tasks 补的索引)。
|
||||
CREATE INDEX IF NOT EXISTS features_created_via_key_created
|
||||
ON "features" ("created_via_key_id", "created_at") WHERE "created_via_key_id" IS NOT NULL;
|
||||
@@ -0,0 +1,46 @@
|
||||
-- Ideas:大家愿意公开的「想法 demo」墙(shared/src/ideas.ts)。
|
||||
--
|
||||
-- 一行 = 一条公开的想法。来源三种:feature / bug(Streamline 单子,关注人或管理员手动发布)
|
||||
-- 和 eddy(Eddy 任务,作者在 Eddy 里发布,截图 / 录屏 / 代码包转存在 TOS 的 ideas/ 前缀下)。
|
||||
-- 同一来源只保留一条(重复发布 = 更新),撤回 = 删行,原单子不受影响。
|
||||
-- media 是 JSON 数组 [{type:"image"|"video", url}],第一项是封面。
|
||||
--
|
||||
-- 只建新表(ideas / idea_likes / feature_relays),不动已有表:先跑迁移再上代码即可,反过来也只是 Ideas 页报错,不影响看板。
|
||||
CREATE TABLE IF NOT EXISTS "ideas" (
|
||||
"id" text PRIMARY KEY,
|
||||
"source" text NOT NULL,
|
||||
"source_id" text NOT NULL,
|
||||
"title" text NOT NULL,
|
||||
"summary" text NOT NULL DEFAULT '',
|
||||
"platform" text,
|
||||
"media" text NOT NULL DEFAULT '[]',
|
||||
"author" text NOT NULL,
|
||||
"published_by" text NOT NULL,
|
||||
"bundle_url" text,
|
||||
"created_at" bigint NOT NULL,
|
||||
"updated_at" bigint NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS ideas_source_uidx ON "ideas" ("source", "source_id");
|
||||
CREATE INDEX IF NOT EXISTS ideas_created_at_idx ON "ideas" ("created_at");
|
||||
|
||||
-- 点赞:一人一条,取消 = 删行。想法撤回时一起删。
|
||||
CREATE TABLE IF NOT EXISTS "idea_likes" (
|
||||
"idea_id" text NOT NULL,
|
||||
"email" text NOT NULL,
|
||||
"created_at" bigint NOT NULL,
|
||||
PRIMARY KEY ("idea_id", "email")
|
||||
);
|
||||
|
||||
-- Streamline 接力:从 Ideas 把别人的 Feature 复制一张到自己名下(新单以对方已推送的分支为基线,
|
||||
-- 走正常的评估 → 待确认,确认后出新的 MR)。这里记新单是从谁的哪一版接力来的,详情里关注人处展示。
|
||||
CREATE TABLE IF NOT EXISTS "feature_relays" (
|
||||
"feature_id" text PRIMARY KEY,
|
||||
"source_kind" text NOT NULL,
|
||||
"source_id" text NOT NULL,
|
||||
"source_round" integer NOT NULL DEFAULT 1,
|
||||
"source_owner" text NOT NULL,
|
||||
"idea_id" text,
|
||||
"created_by" text NOT NULL,
|
||||
"created_at" bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS feature_relays_source_idx ON "feature_relays" ("source_id");
|
||||
@@ -0,0 +1,27 @@
|
||||
-- Ideas 详情的评论和审阅章(docs/ideas.md)。0071 已上线,这两张表另起一个迁移。
|
||||
--
|
||||
-- 只建新表,不动已有表:先跑迁移再上代码即可,反过来只有评论区 / 盖章报错,不影响看板和 Ideas 墙。
|
||||
|
||||
-- 评论:想法详情里的评论区。想法从 Ideas 移除时一起删。
|
||||
CREATE TABLE IF NOT EXISTS "idea_comments" (
|
||||
"id" text PRIMARY KEY,
|
||||
"idea_id" text NOT NULL,
|
||||
"email" text NOT NULL,
|
||||
"text" text NOT NULL,
|
||||
"created_at" bigint NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idea_comments_idea_idx ON "idea_comments" ("idea_id", "created_at");
|
||||
|
||||
-- 审阅章:详情弹窗上盖的 PASS / CONDITIONAL PASS / NO PASS。每人每条想法一个,盖新的替换旧的;
|
||||
-- x / y 是弹窗内的相对位置(0..1)。NO PASS / CONDITIONAL PASS 要求盖章人在这条下留过评论(写原因)。
|
||||
-- 想法从 Ideas 移除时一起删。
|
||||
CREATE TABLE IF NOT EXISTS "idea_stamps" (
|
||||
"idea_id" text NOT NULL,
|
||||
"email" text NOT NULL,
|
||||
"kind" text NOT NULL,
|
||||
"x" double precision NOT NULL,
|
||||
"y" double precision NOT NULL,
|
||||
"rot" double precision NOT NULL DEFAULT 0,
|
||||
"created_at" bigint NOT NULL,
|
||||
PRIMARY KEY ("idea_id", "email")
|
||||
);
|
||||
@@ -0,0 +1,10 @@
|
||||
-- Product usage schema 2: the Mac an event came from (sha256(IOPlatformUUID)[:16], the value every Eddy request
|
||||
-- already sends as X-Eddy-Machine), how it was derived, the Mac app build, closed props (enums, flags, bounded
|
||||
-- numbers, version strings) and whether it was uploaded without a sign-in (owner NULL, budget per device).
|
||||
-- Additive: schema 1 rows keep NULLs and anonymous = false.
|
||||
ALTER TABLE eddy_usage_events ADD COLUMN IF NOT EXISTS device text;
|
||||
ALTER TABLE eddy_usage_events ADD COLUMN IF NOT EXISTS device_source text;
|
||||
ALTER TABLE eddy_usage_events ADD COLUMN IF NOT EXISTS app_version text;
|
||||
ALTER TABLE eddy_usage_events ADD COLUMN IF NOT EXISTS props jsonb;
|
||||
ALTER TABLE eddy_usage_events ADD COLUMN IF NOT EXISTS anonymous boolean NOT NULL DEFAULT false;
|
||||
CREATE INDEX IF NOT EXISTS eddy_usage_device_at ON eddy_usage_events (device, at);
|
||||
@@ -0,0 +1,17 @@
|
||||
-- Named leases for Eddy maintenance jobs that must run in one place at a time (the scheduled auto-release).
|
||||
-- token_hash is the SHA-256 of the holder's secret token; NULL means free. Times are epoch milliseconds.
|
||||
-- `status` is the holder's latest heartbeat progress; `last` the previous run (released with a result, or expired).
|
||||
-- Additive: a new table only.
|
||||
CREATE TABLE IF NOT EXISTS eddy_locks (
|
||||
name text PRIMARY KEY,
|
||||
token_hash text,
|
||||
holder text,
|
||||
info jsonb,
|
||||
actor text,
|
||||
acquired_at bigint,
|
||||
heartbeat_at bigint,
|
||||
expires_at bigint,
|
||||
status jsonb,
|
||||
last jsonb,
|
||||
updated_at bigint NOT NULL
|
||||
);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"entries": [
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "7",
|
||||
"when": 1785046717787,
|
||||
"tag": "0000_init",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 1,
|
||||
"version": "7",
|
||||
"when": 1785181676938,
|
||||
"tag": "0001_secret_doorman",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 2,
|
||||
"version": "7",
|
||||
"when": 1785275394764,
|
||||
"tag": "0002_flaky_sprite",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user