mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 08:47:02 +01:00
* feat(packages): each project's update setting, applied to its Dependabot PRs Package updates reach a project automatically by default, gated by its own tests, with asking as an option. Loki is the policy layer only: Dependabot proposes the pull requests and the fleet auto-merge sweep merges them. - user_projects.package_updates: "auto" (default) | "ask" | "pinned". Values, labels and the one-line consequence of each are SSOT in src/config/package-updates.ts; an unknown stored value reads as "ask". No CHECK constraint, as for entities.auto_inject_mode_override (0023). - package_update_requests: open Dependabot PRs that bump a fleet package — PR, head, packages (from -> to, breaking, fleet), checks state, state, whether Loki holds it, and the person's decision. project_packages.dep_name records the key package.json lists a package under, so an npm alias or a git dependency named by its key is matched back to the catalogue. - Pure Dependabot parsing (single, grouped, `in /dir`, backticked shas, `v` tags) and breaking detection identical to the sweep's: a major, or a minor under 1.0; a version that is not semver counts as breaking. - Enforcement as a pure decision table: hold when the setting is ask or pinned or the bump is breaking; lift only a hold Loki added; a hold a person added stays and blocks Loki's own merge; a hold someone takes off on GitHub is not put back and that PR is never merged by Loki. - Decisions: Update (lift the hold; merge a breaking one once its checks are green, else on the next read), Not now (hidden 7 days), Stay on this version (@dependabot ignore this <part> version, per dependency in a group, close for a sha). - The Phase 1 sync applies the setting after each good read, with the same token rules; the PR listing is a conditional request (304s are free). - Cron sync-package-updates every 15 minutes, so a hold lands before the sweep merges a green PR. PATCH /api/projects/[id]/package-updates (owner only, applies at once when GitHub answers in time) and POST /api/packages/updates/[id] for a decision. - Migration 0099 is additive: one new table, two new columns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf * feat(packages): update setting, open updates and Approvals cards - Project "Built from": the update setting as three choices (Automatic / Ask me / Stay on these versions) with what each will do written under it, and the rule none overrides (a breaking update always waits). A change says whether it reached the open updates already or will within 15 minutes. Each package with an open update shows it under its row: the version it goes to, breaking, held for you / waiting on tests / ready, and the pull request. - /packages/[slug]: the same line under each dependent project. - /approvals: a Package updates card for every held update that needs the person — every update on "Ask me", breaking ones on "Automatic", none on "Stay on these versions". Project, packages from -> to, breaking, checks, why it is asking, link to the PR; Update / Not now / Stay on this version. A refusal stays on the card with the buttons; "no write access" comes with Connect GitHub. They name no private data, so they show behind the PIN too, and the "nothing waiting" empty state steps aside for them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf * docs(packages): changelog entry and update settings in the Views table Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf * fix(packages): read every repository once more to record dependency keys Rows read before dep_name existed match update pull requests by catalogue name only, and the sync skips a repository whose head and catalogue have not moved — so for most projects they would have stayed that way. Folding an observation version into the catalogue key invalidates that skip once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M6u11m24oVkG98wAVbN7nf --------- Co-authored-by: Claude <noreply@anthropic.com>
43 lines
2.6 KiB
SQL
43 lines
2.6 KiB
SQL
-- Migration: package update policy — how shared-package updates reach each
|
|
-- project, and the Dependabot pull requests Loki applies it to
|
|
-- (src/lib/packages/updates.ts, src/config/package-updates.ts).
|
|
--
|
|
-- Generated by `pnpm run db:generate` from the 0098 snapshot; reviewed by hand.
|
|
-- Additive only, nothing existing is rewritten or dropped:
|
|
-- * package_update_requests — new table, one row per (project, PR number).
|
|
-- * user_projects.package_updates — NOT NULL DEFAULT 'auto'. A constant
|
|
-- default is a metadata-only change on PostgreSQL 11+, so no table rewrite.
|
|
-- Every existing project starts on "auto", which is what already happened
|
|
-- to its non-breaking Dependabot PRs (the fleet sweep merges them on green);
|
|
-- breaking ones were already left for a person, and still are. No CHECK
|
|
-- constraint: the values are owned by the TS config, as for
|
|
-- entities.auto_inject_mode_override (0023), and an unknown value reads as
|
|
-- "ask" (readPackageUpdateSetting).
|
|
-- * project_packages.dep_name — nullable; filled by the next read of each
|
|
-- repository.
|
|
CREATE TABLE "package_update_requests" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"user_id" uuid NOT NULL,
|
|
"project_id" uuid NOT NULL,
|
|
"pr_number" integer NOT NULL,
|
|
"pr_url" text NOT NULL,
|
|
"title" text NOT NULL,
|
|
"head_sha" text,
|
|
"packages" jsonb NOT NULL,
|
|
"ci_state" text DEFAULT 'unknown' NOT NULL,
|
|
"state" text DEFAULT 'open' NOT NULL,
|
|
"held_by_loki" boolean DEFAULT false NOT NULL,
|
|
"decision" text,
|
|
"decided_at" timestamp with time zone,
|
|
"snoozed_until" timestamp with time zone,
|
|
"detail" text,
|
|
"opened_at" timestamp with time zone,
|
|
"observed_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "user_projects" ADD COLUMN "package_updates" text DEFAULT 'auto' NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE "project_packages" ADD COLUMN "dep_name" text;--> statement-breakpoint
|
|
ALTER TABLE "package_update_requests" ADD CONSTRAINT "package_update_requests_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "package_update_requests" ADD CONSTRAINT "package_update_requests_project_id_user_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."user_projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "uq_package_update_requests_project_pr" ON "package_update_requests" USING btree ("project_id","pr_number");--> statement-breakpoint
|
|
CREATE INDEX "idx_package_update_requests_user_state" ON "package_update_requests" USING btree ("user_id","state"); |