docs/plans/2026-01-05-plan-check-run-runtime-derivation.md
Refactor plan check run to derive configuration from the associated plan at runtime, rather than storing a self-contained copy of the configuration.
getPlanCheckRunFromPlan()Plan check run stores duplicated fields from the plan:
| Field | In Plan | In Plan Check Run |
|---|---|---|
sheet_sha256 | ChangeDatabaseConfig | CheckTarget |
enable_prior_backup | ChangeDatabaseConfig | CheckTarget |
enable_ghost | ChangeDatabaseConfig | CheckTarget |
ghost_flags | ChangeDatabaseConfig | CheckTarget |
targets | Spec level | Expanded per CheckTarget |
The config column stores PlanCheckRunConfig which contains these duplicated fields. The payload column is unused.
There is only one plan check run per plan (unique constraint on plan_id). When plan checks are rerun, the old run is replaced. This means:
Remove from plan_check_run table:
config column (JSONB storing PlanCheckRunConfig)payload column (unused, reserved)Keep in plan_check_run table:
id (primary key)created_at, updated_atplan_id (foreign key to plan)status (RUNNING/DONE/FAILED/CANCELED)result (JSONB storing PlanCheckRunResult)Proto changes:
PlanCheckRunConfig message from proto/store/store/plan_check_run.protoCheckTarget message (only used in config)Store layer:
Config field from PlanCheckRunMessagegetPlanCheckRunFromPlan() becomes a pure derivation function:
Instead of creating a persisted config, it returns an in-memory struct:
type DerivedCheckTarget struct {
Target string // database resource name
SheetSHA256 string // from plan spec
EnablePriorBackup bool
EnableGhost bool
GhostFlags map[string]string
Types []storepb.PlanCheckType
}
Executor flow:
plan_id, status)plan_idresult fieldALTER TABLE plan_check_run DROP COLUMN config;
ALTER TABLE plan_check_run DROP COLUMN payload;
| Layer | File(s) | Change |
|---|---|---|
| Proto (store) | proto/store/store/plan_check_run.proto | Remove PlanCheckRunConfig, CheckTarget |
| Proto (API) | proto/v1/plan_service.proto | Remove config from PlanCheckRun if exposed |
| Migration | backend/migrator/migration/LATEST.sql + new | Drop columns |
| Store | backend/store/plan_check_run.go | Remove Config field, update CRUD |
| API | backend/api/v1/plan_service.go | Simplify creation, extract derivation |
| Runner | backend/runner/plancheck/runner.go | Fetch plan, derive targets at runtime |
| Executors | backend/runner/plancheck/*.go | Receive derived config |
PlanCheckRunResult proto (stores actual results per target)