Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

ci: gate Dependabot runs on an explicit maintainer rerun (#12229)

[._.]/f4d8397672e2
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 51b2789838..beeb506751 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -72,6 +72,11 @@ jobs:
# ls-files` need. Cloning every commit in the repo buys nothing more.
fetch-depth: 2
+ # A red impact job keeps CI Gate red; skipped test jobs are not evidence.
+ # Re-running this run is GitHub's writer-only, exact-SHA release control.
+ - name: Require maintainer release for Dependabot
+ run: node scripts/ci-dependabot-admission.js
+
# Reads the base commit off HEAD^1 rather than the event payload, so a
# depth-2 clone is enough for every three-dot diff downstream. Exports
# CI_BASE_SHA to the rest of the job.
diff --git a/.github/workflows/supercollider-live.yml b/.github/workflows/supercollider-live.yml
index f16ad1ac01..1135de8b6d 100644
--- a/.github/workflows/supercollider-live.yml
+++ b/.github/workflows/supercollider-live.yml
@@ -53,6 +53,8 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ - name: Require maintainer release for Dependabot
+ run: node scripts/ci-dependabot-admission.js
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24.x
diff --git a/docs/GITHUB_ACTIONS.md b/docs/GITHUB_ACTIONS.md
index 63b11e606b..bf3ff57c42 100644
--- a/docs/GITHUB_ACTIONS.md
+++ b/docs/GITHUB_ACTIONS.md
@@ -3,6 +3,40 @@
PortOS uses a test-impact-aware CI workflow plus a release workflow that cannot
publish until the complete CI suite has passed on the exact tree being released.
+## Release Dependabot CI after review
+
+Dependabot pull requests start with a small checkout/admission check only.
+`Plan test impact` fails with a maintainer-release message before dependency
+installation or tests, so the required `CI Gate` remains red. The optional
+SuperCollider workflow uses the same check before installing or building.
+Other pull requests, scheduled checks, releases and manual dispatches retain
+their existing behavior. No schedule or repository security setting changes.
+
+After reviewing the dependency diff, open the **current commit's** CI workflow
+run and choose **Re-run all jobs**, or run `gh run rerun RUN_ID`. GitHub permits
+reruns only to repository writers. If SuperCollider also ran, release that
+workflow's current run separately. Re-running failed jobs also reruns their
+dependents; re-running only CI Gate cannot release a failed impact check.
+Tests still have to pass before merging.
+
+This approval is **commit-bound**: GitHub preserves the original SHA and ref
+when rerunning. An older run cannot validate a newer commit. Every subsequent
+commit, including a maintainer fix or Dependabot rebase, starts a new run at
+attempt 1 and needs review/release again. Repeated reruns are still subject to
+the same writer-only GitHub control. Labels and PR approval reviews do not
+release CI. Automated bot reruns (including cancellation recovery) cannot
+release held updates. Existing runs created before this workflow change keep
+the workflow version with which they started.
+
+The existing **Run workflow** dispatch remains an explicit writer-controlled
+way to run the full suite on a selected branch/ref. Inspect its exact SHA:
+a dispatch on `main` says nothing about a dependency PR, and a later commit
+needs its own validation. The normal dependency workflow is the PR rerun above.
+No privileged `pull_request_target` execution, writable test token or secrets
+are introduced; reruns retain the original actor's restricted token.
+
+See [GitHub's rerun permissions and revision semantics](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/re-run-workflows-and-jobs).
+
## Where the suite actually runs
Every change reaches `main` through a pull request, and `main` reaches
diff --git a/scripts/ci-dependabot-admission.js b/scripts/ci-dependabot-admission.js
new file mode 100644
index 0000000000..4ff169938f
--- /dev/null
+++ b/scripts/ci-dependabot-admission.js
@@ -0,0 +1,36 @@
+#!/usr/bin/env node
+
+// GitHub permits workflow reruns only to repository writers and preserves the
+// original SHA/ref AND token restrictions. Do not replace this with a label:
+// labels survive synchronize events and would approve unreviewed future code.
+import { readFileSync } from 'node:fs';
+import { isDirectlyInvoked } from './lib/directInvocation.js';
+
+export function requireDependabotAdmission({ eventName, event, attempt, triggeringActor }) {
+ if (eventName !== 'pull_request') return;
+ if (!event?.pull_request?.user?.login) throw new Error('Missing pull request author; refusing CI admission.');
+ if (event.pull_request.user.login !== 'dependabot[bot]') return;
+ const runAttempt = Number(attempt);
+ // Actions cancel recovery is automated, so an attempt counter alone must
+ // never release a held update. Only a writer's explicit rerun may do that.
+ if (!Number.isSafeInteger(runAttempt) || runAttempt < 2
+ || !/^[a-z\d](?:[a-z\d-]*[a-z\d])?$/i.test(triggeringActor ?? '')
+ || ['dependabot', 'github-actions'].includes(triggeringActor.toLowerCase())) {
+ throw new Error('Dependabot CI is held for maintainer review. Review this run’s commit, then choose Re-run all jobs (or gh run rerun RUN_ID). New commits and rebases need a new release.');
+ }
+}
+
+if (isDirectlyInvoked(import.meta.url)) {
+ try {
+ requireDependabotAdmission({
+ eventName: process.env.GITHUB_EVENT_NAME,
+ event: JSON.parse(readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8')),
+ attempt: process.env.GITHUB_RUN_ATTEMPT,
+ triggeringActor: process.env.GITHUB_TRIGGERING_ACTOR,
+ });
+ console.log('CI admission passed.');
+ } catch (error) {
+ console.error(error.message);
+ process.exitCode = 1;
+ }
+}
diff --git a/scripts/ci-dependabot-admission.test.js b/scripts/ci-dependabot-admission.test.js
new file mode 100644
index 0000000000..babe903c7a
--- /dev/null
+++ b/scripts/ci-dependabot-admission.test.js
@@ -0,0 +1,59 @@
+import { readFileSync } from 'node:fs';
+import { describe, expect, it } from 'vitest';
+import { requireDependabotAdmission } from './ci-dependabot-admission.js';
+import { workflowJobs } from './lib/workflowJobs.js';
+import { summarizeGateResults } from './ci-gate-report.js';
+
+const held = {
+ eventName: 'pull_request',
+ event: { pull_request: { user: { login: 'dependabot[bot]' } } },
+ attempt: '1',
+ triggeringActor: 'dependabot[bot]',
+};
+const workflow = (name) => readFileSync(new URL(`../.github/workflows/${name}.yml`, import.meta.url), 'utf8');
+
+describe('Dependabot maintainer release', () => {
+ it('holds opened, synchronized and rebased updates even when a writer pushed the change', () => {
+ for (const action of ['opened', 'synchronize', 'reopened']) {
+ expect(() => requireDependabotAdmission({ ...held, triggeringActor: 'maintainer', event: { ...held.event, action } }))
+ .toThrow('Dependabot CI is held');
+ }
+ });
+
+ it('admits writer-triggered reruns of the same run, but never automatic bot recovery', () => {
+ expect(() => requireDependabotAdmission({ ...held, attempt: '2', triggeringActor: 'maintainer' })).not.toThrow();
+ for (const triggeringActor of ['github-actions[bot]', 'dependabot[bot]', 'some-app[bot]', '', undefined]) {
+ expect(() => requireDependabotAdmission({ ...held, attempt: '2', triggeringActor })).toThrow('held');
+ }
+ // A new head creates a new run, not another attempt of the approved run.
+ expect(() => requireDependabotAdmission({ ...held, attempt: '1', triggeringActor: 'maintainer' })).toThrow('held');
+ });
+
+ it('preserves ordinary PRs and explicit dispatch, schedule and release behavior', () => {
+ expect(() => requireDependabotAdmission({ ...held, event: { pull_request: { user: { login: 'contributor' } } } })).not.toThrow();
+ for (const eventName of ['workflow_dispatch', 'schedule', 'push']) {
+ expect(() => requireDependabotAdmission({ eventName })).not.toThrow();
+ }
+ expect(() => requireDependabotAdmission({ ...held, event: {} })).toThrow('Missing pull request author');
+ });
+
+ it('runs admission before planning/installing and keeps the required gate red on refusal', () => {
+ const ci = workflowJobs(workflow('ci'));
+ expect(ci.impact.indexOf('node scripts/ci-dependabot-admission.js'))
+ .toBeLessThan(ci.impact.indexOf('node scripts/ci-base-sha.js'));
+ expect(ci.impact).not.toContain('continue-on-error: true');
+ for (const name of ['server', 'client', 'lint', 'database', 'browser', 'windows-server', 'node-minimum', 'linux-containment']) {
+ expect(ci[name]).toContain('needs: impact');
+ }
+ expect(ci.gate).toContain('if: always()');
+ expect(ci.gate).toContain('CI_GATE_RESULT_IMPACT: ${{ needs.impact.result }}');
+ expect(summarizeGateResults([{ job: 'impact', result: 'failure' }, { job: 'client', result: 'skipped' }]).verdict).toBe('failure');
+ const native = workflowJobs(workflow('supercollider-live')).native;
+ expect(native.indexOf('node scripts/ci-dependabot-admission.js')).toBeGreaterThan(-1);
+ expect(native.indexOf('node scripts/ci-dependabot-admission.js')).toBeLessThan(native.indexOf('actions/setup-node@'));
+ for (const name of ['ci', 'supercollider-live']) {
+ expect(workflow(name)).not.toContain('pull_request_target:');
+ expect(workflow(name)).not.toMatch(/(?:contents|actions): write/);
+ }
+ });
+});
diff --git a/scripts/pre-install-entrypoints.test.js b/scripts/pre-install-entrypoints.test.js
index 470f73b390..b98cb9505f 100644
--- a/scripts/pre-install-entrypoints.test.js
+++ b/scripts/pre-install-entrypoints.test.js
@@ -26,6 +26,7 @@ const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
/** Run by the CI `impact` job before any dependency install. */
const PRE_INSTALL_ENTRYPOINTS = [
+ 'scripts/ci-dependabot-admission.js',
'scripts/ci-base-sha.js',
'scripts/ci-test-plan.js',
'scripts/scan-diff-hidden-content.js',