From 3689b38ca5f5fc4e6a9cd28f8c4c032ce3135080 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:30:23 +0000 Subject: [PATCH 1/3] ci: Bun for gossamer loader smoke; GitHub App tokens replace HYPATIA_DISPATCH_PAT - build-gossamer-gui: actions/setup-node -> oven-sh/setup-bun (bun test) - remediation-sweep, ci-health-sweep, credential-read-check: mint short-lived installation tokens via actions/create-github-app-token - docs and deed: App secrets replace the retired PAT actions.lock is NOT regenerated in this commit. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01J4QvDixKBAqsZv6cTjgS6M --- .github/workflows/build-gossamer-gui.yml | 16 ++++++------- .github/workflows/ci-health-sweep.yml | 22 ++++++++++++++---- .github/workflows/credential-read-check.yml | 23 ++++++++++++++----- .github/workflows/estate-rescan.yml | 2 +- .../workflows/hypatia-remediation-sweep.yml | 15 +++++++++++- docs/operations/credential-roles.adoc | 10 ++++---- .../standards-move-estate-rollout.adoc | 8 +++---- docs/wiki-pages/Operations.md | 2 +- hypatia_chora.deed | 6 ++--- scripts/ci-health/README.adoc | 6 +++-- 10 files changed, 75 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build-gossamer-gui.yml b/.github/workflows/build-gossamer-gui.yml index 175dd7d6..3ac41fa9 100644 --- a/.github/workflows/build-gossamer-gui.yml +++ b/.github/workflows/build-gossamer-gui.yml @@ -112,18 +112,16 @@ jobs: - name: Checkout repository uses: actions/checkout@v7.0.1 - - name: Setup Node.js - uses: actions/setup-node@v7.1.0 - with: - node-version: '22' + # Estate policy: no Node.js/npm; JS runs Bun > Deno > pnpm. + - name: Setup Bun + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 - name: Run loader smoke tests - # Shell-glob picks up every *.test.mjs in test/gossamer/, so + # `bun test ` picks up every *.test.mjs in test/gossamer/, so # adding a new harness (e.g. the panel-surface - # `browser_smoke.test.mjs` added in #220) doesn't need a second - # workflow edit. Node 22's `--test` does not yet support a - # directory argument directly. - run: node --test test/gossamer/*.test.mjs + # `browser_smoke.test.mjs` added in #220) needs no second workflow + # edit. The files import `node:test`, which Bun implements. + run: bun test test/gossamer/ build-ephapax: name: Build Ephapax toolchain (pinned) diff --git a/.github/workflows/ci-health-sweep.yml b/.github/workflows/ci-health-sweep.yml index 8301bfcd..968f74dd 100644 --- a/.github/workflows/ci-health-sweep.yml +++ b/.github/workflows/ci-health-sweep.yml @@ -55,12 +55,26 @@ jobs: api.github.com:443 - uses: actions/checkout@v7.0.1 + + # Short-lived installation token, replacing the long-lived + # HYPATIA_DISPATCH_PAT. Scoped to every repository the App is + # installed on (the sweep walks the whole owner). + - name: Mint sweep token (GitHub App) + id: sweep_app + uses: actions/create-github-app-token@v3.3.0 + with: + app-id: ${{ secrets.HYPATIA_APP_ID }} + private-key: ${{ secrets.HYPATIA_APP_PRIVATE_KEY }} + owner: ${{ inputs.owner || 'hyperpolymath' }} + permission-administration: write # allow-list PUT + permission-contents: write # fix branches + permission-pull-requests: write # PR create + permission-issues: write # issue upsert + permission-workflows: write # branches that touch .github/workflows + - name: Run CI-health sweep env: - # PAT needs classic `repo` + `workflow` scope (repo admin for the - # allow-list PUT, PR create, and issue upsert). Reused from the - # existing remediation pipeline. - GH_TOKEN: ${{ secrets.HYPATIA_DISPATCH_PAT }} + GH_TOKEN: ${{ steps.sweep_app.outputs.token }} OWNER: ${{ inputs.owner || 'hyperpolymath' }} # Scheduled runs remediate live (owner opted into auto-remediation); # manual dispatch defaults to dry-run for safety. diff --git a/.github/workflows/credential-read-check.yml b/.github/workflows/credential-read-check.yml index 15c597ea..8a9563ec 100644 --- a/.github/workflows/credential-read-check.yml +++ b/.github/workflows/credential-read-check.yml @@ -21,8 +21,11 @@ on: HYPATIA_SCAN_PAT: description: Scanner credential to validate against Hypatia's three alert endpoints required: true - HYPATIA_DISPATCH_PAT: - description: Required only when scanner_only is false + HYPATIA_APP_ID: + description: GitHub App ID; required only when scanner_only is false + required: false + HYPATIA_APP_PRIVATE_KEY: + description: GitHub App private key; required only when scanner_only is false required: false permissions: @@ -76,12 +79,20 @@ jobs: with: egress-policy: block allowed-endpoints: api.github.com:443 - - name: Check dispatch identity and observation-store visibility + - name: Mint dispatch token (GitHub App) + id: app + uses: actions/create-github-app-token@v3.3.0 + with: + app-id: ${{ secrets.HYPATIA_APP_ID }} + private-key: ${{ secrets.HYPATIA_APP_PRIVATE_KEY }} + owner: hyperpolymath + repositories: verisimdb-data + permission-contents: read + - name: Check App authentication and observation-store visibility env: - GH_TOKEN: ${{ secrets.HYPATIA_DISPATCH_PAT }} + GH_TOKEN: ${{ steps.app.outputs.token }} run: | set -euo pipefail - [ -n "${GH_TOKEN:-}" ] || { echo '::error::HYPATIA_DISPATCH_PAT is missing'; exit 1; } - gh api user --silent + [ -n "${GH_TOKEN:-}" ] || { echo '::error::the GitHub App token was not minted (HYPATIA_APP_ID / HYPATIA_APP_PRIVATE_KEY)'; exit 1; } gh api 'repos/hyperpolymath/verisimdb-data/git/ref/heads/main' --silent echo 'Dispatch: authentication and store-ref read passed. Write, workflow, administrative and dispatch permissions were not tested.' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/estate-rescan.yml b/.github/workflows/estate-rescan.yml index 936a24c8..4331a324 100644 --- a/.github/workflows/estate-rescan.yml +++ b/.github/workflows/estate-rescan.yml @@ -73,7 +73,7 @@ jobs: # # `scan` builds panic-attack and runs it over ~300 repositories' worth of # third-party content. Until this split it ran in the same job as - # HYPATIA_DISPATCH_PAT, and `Checkout verisimdb-data` left that PAT in the + # the old write-capable PAT, and `Checkout verisimdb-data` left that PAT in the # clone's .git/config, readable by every later step, the freshly built # scanner included. Now `scan` holds no credential and hands its output to # `publish` as an artifact; the two jobs that hold the PAT run no fetched diff --git a/.github/workflows/hypatia-remediation-sweep.yml b/.github/workflows/hypatia-remediation-sweep.yml index 61fba22e..15429270 100644 --- a/.github/workflows/hypatia-remediation-sweep.yml +++ b/.github/workflows/hypatia-remediation-sweep.yml @@ -202,10 +202,23 @@ jobs: | sort -t'|' -k3 -nr >> "$GITHUB_STEP_SUMMARY" fi + # Short-lived (1 h) installation token for the one repository this step + # writes to, replacing the long-lived HYPATIA_DISPATCH_PAT. + - name: Mint dispatch token (GitHub App) + id: dispatch_app + if: steps.query.outputs.target_count != '0' && steps.cfg.outputs.dry != 'true' + uses: actions/create-github-app-token@v3.3.0 + with: + app-id: ${{ secrets.HYPATIA_APP_ID }} + private-key: ${{ secrets.HYPATIA_APP_PRIVATE_KEY }} + owner: hyperpolymath + repositories: gitbot-fleet + permission-contents: write # repository_dispatch needs Contents: write + - name: Dispatch findings to gitbot-fleet if: steps.query.outputs.target_count != '0' && steps.cfg.outputs.dry != 'true' env: - GH_TOKEN: ${{ secrets.HYPATIA_DISPATCH_PAT }} + GH_TOKEN: ${{ steps.dispatch_app.outputs.token }} OWNER: ${{ steps.cfg.outputs.owner }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | diff --git a/docs/operations/credential-roles.adoc b/docs/operations/credential-roles.adoc index ffa8aa52..07657866 100644 --- a/docs/operations/credential-roles.adoc +++ b/docs/operations/credential-roles.adoc @@ -6,8 +6,10 @@ alerts and Secret scanning alerts access for the intended repository selection. Metadata read is automatic; no write or account permissions are needed for these reads. The remediation sweep's query uses this -credential. Its later repository-dispatch step still uses -`HYPATIA_DISPATCH_PAT`; the two values are not fallbacks for one another. +credential. Its later repository-dispatch step uses a short-lived GitHub App +installation token minted from `HYPATIA_APP_ID` and `HYPATIA_APP_PRIVATE_KEY` +(Contents: write on `gitbot-fleet` only); the PAT and the App are not +fallbacks for one another. `HYPATIA_DISPATCH_PAT` has been retired. Run the manual `Credential read check` workflow after replacing either secret. Its separate jobs check authentication and specific read endpoints without @@ -36,7 +38,7 @@ an operator. Pin the reusable to a reviewed full commit SHA and pass only `scanner_only: true`; the dispatch job is skipped and its secret is optional. Manual runs default to checking both roles, with a `scanner_only` checkbox for scanner-only validation. A caller that explicitly checks dispatch must -also pass `HYPATIA_DISPATCH_PAT`. +also pass `HYPATIA_APP_ID` and `HYPATIA_APP_PRIVATE_KEY`. The API targets remain fixed: Hypatia's three alert endpoints and, only for dispatch validation, the observation-store main ref. A successful call from @@ -58,7 +60,7 @@ observation publication requires a qualified receipt in addition to access. `estate-rescan.yml` uses `VERISIMDB_DATA_PUBLISH_PAT` only in its preflight and publication jobs. The scanner job has no publisher credential. There is -no fallback to `HYPATIA_DISPATCH_PAT` or `HYPATIA_SCAN_PAT`. +no fallback to the GitHub App credentials or `HYPATIA_SCAN_PAT`. Provision a fine-grained token with resource owner `hyperpolymath`, only `verisimdb-data` selected, Contents read/write and Pull requests read/write; diff --git a/docs/operations/standards-move-estate-rollout.adoc b/docs/operations/standards-move-estate-rollout.adoc index 0089a0ac..b7e84532 100644 --- a/docs/operations/standards-move-estate-rollout.adoc +++ b/docs/operations/standards-move-estate-rollout.adoc @@ -107,7 +107,7 @@ checks out the current one (#1004). |=== | Item | Owner | Evidence / next step -| Rotate `HYPATIA_DISPATCH_PAT` +| Replace `HYPATIA_DISPATCH_PAT` with the Hypatia GitHub App | *Repository owner* | Every `ci-health-sweep` run from 2026-10-22 to 2026-11-03 died with `HTTP 401: Bad credentials` at `repos to scan: 0` (e.g. runs 40266651942 @@ -118,8 +118,8 @@ checks out the current one (#1004). cannot run from CI. After replacing either secret, run `credential-read-check.yml` to authenticate the scanner and dispatch credentials separately. A remediation-sweep `dry_run: true` now reads - `HYPATIA_SCAN_PAT` and skips dispatch; it cannot validate a rotated - `HYPATIA_DISPATCH_PAT`. The credential read check proves only the reads + `HYPATIA_SCAN_PAT` and skips dispatch; it cannot validate the + App credentials. The credential read check proves only the reads named in its summary. Validate the intended write/dispatch operation and its egress policy separately before claiming rotation complete. See xref:credential-roles.adoc[credential roles and validation limits]. @@ -188,7 +188,7 @@ WF027 and WF028 as well. == When to update this memo -* When `HYPATIA_DISPATCH_PAT` is rotated, or the sweep's first dry run +* When the App credentials are installed or rotated, or the sweep's first dry run reports its results. * When a D transfer batch lands: add its rows to `Hypatia.Rules.MovedRepositories`, and record the batch here. diff --git a/docs/wiki-pages/Operations.md b/docs/wiki-pages/Operations.md index ea9ff53e..6cad5900 100644 --- a/docs/wiki-pages/Operations.md +++ b/docs/wiki-pages/Operations.md @@ -54,7 +54,7 @@ The supervision tree starts Bandit on port 9090 (9099 under `MIX_ENV=test`): | Variable | Purpose | |---|---| -| `HYPATIA_DISPATCH_PAT` | GitHub PAT with `repo` scope for cross-repo dispatch | +| `HYPATIA_DISPATCH_PAT` | Optional local-run token for `mix hypatia.*` tasks. CI no longer uses it: workflows mint GitHub App tokens from `HYPATIA_APP_ID` / `HYPATIA_APP_PRIVATE_KEY` | | `HYPATIA_HTTP_PORT` | Override the Bandit listen port (default 9090) | | `HYPATIA_VERISIM_URL` | verisim-api base URL. No default: unset or blank turns off prover hints, strategy-shift detection and recommender retraining | | `HYPATIA_ECHIDNABOT_URL` | echidnabot base URL (`/graphql` is appended). No default: unset or blank means strategy-shift re-queues are logged and dropped | diff --git a/hypatia_chora.deed b/hypatia_chora.deed index 3e6588a0..fbdeaf45 100644 --- a/hypatia_chora.deed +++ b/hypatia_chora.deed @@ -169,7 +169,7 @@ (job :workflow ".github/workflows/ci-health-sweep.yml" :job "sweep" - :secrets ("HYPATIA_DISPATCH_PAT") + :secrets ("HYPATIA_APP_ID" "HYPATIA_APP_PRIVATE_KEY") :endpoints ("github.com:443" "api.github.com:443") :enforcement harden-runner-block :reason "Checks out this repo, then every call in scripts/ci-health/ is gh against the GitHub API.") @@ -190,7 +190,7 @@ (job :workflow ".github/workflows/hypatia-remediation-sweep.yml" :job "sweep" - :secrets ("HYPATIA_SCAN_PAT" "HYPATIA_DISPATCH_PAT") + :secrets ("HYPATIA_SCAN_PAT" "HYPATIA_APP_ID" "HYPATIA_APP_PRIVATE_KEY") :endpoints ("api.github.com:443" "results-receiver.actions.githubusercontent.com:443" "*.blob.core.windows.net:443") :enforcement harden-runner-block :reason "Reads vulnerability alerts with the read-only scanner credential, sends repository dispatches with the separate dispatch credential, then uploads the target list as an artifact.") @@ -204,7 +204,7 @@ (job :workflow ".github/workflows/credential-read-check.yml" :job "dispatch" - :secrets ("HYPATIA_DISPATCH_PAT") + :secrets ("HYPATIA_APP_ID" "HYPATIA_APP_PRIVATE_KEY") :endpoints ("api.github.com:443") :enforcement harden-runner-block :reason "Checks token identity and reads the observation-store main ref; does not validate dispatch or write permissions.") diff --git a/scripts/ci-health/README.adoc b/scripts/ci-health/README.adoc index 3ee21a85..0a69c2d7 100644 --- a/scripts/ci-health/README.adoc +++ b/scripts/ci-health/README.adoc @@ -92,8 +92,10 @@ from the conclusion alone. == Operating notes / off-switch -* Needs `secrets.HYPATIA_DISPATCH_PAT` (classic `repo` + `workflow` scope — repo - admin for the allow-list PUT, PR create, issue upsert). +* Needs the GitHub App secrets `HYPATIA_APP_ID` and `HYPATIA_APP_PRIVATE_KEY`. + The workflow mints a short-lived installation token with Administration, + Contents, Pull requests, Issues and Workflows write (allow-list PUT, PR + create, issue upsert). See `docs/operations/credential-roles.adoc`. * Scheduled runs remediate **live**; manual `workflow_dispatch` defaults to **dry-run**. To pause auto-remediation, set the schedule run to dry-run or disable the workflow. From c0beffb581398006d6257ec36c17d9d7031e2805 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:31:30 +0000 Subject: [PATCH 2/3] ci: regenerate actions.lock (gh-actions-lock v0.2.0 on a runner; governance gate GATE_RC=0) Lock applied from the runner's diff of run 44126544935; sha256 of the result matches the runner's LOCK-SHA256 (822f6933...). Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01J4QvDixKBAqsZv6cTjgS6M --- .github/workflows/actions.lock | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock index b3434a78..3ec98d28 100644 --- a/.github/workflows/actions.lock +++ b/.github/workflows/actions.lock @@ -11,12 +11,13 @@ workflows: '.github/workflows/build-gossamer-gui.yml': - 'actions/cache@v6.1.0' - 'actions/checkout@v7.0.1' - - 'actions/setup-node@v7.1.0' - 'actions/upload-artifact@v7.0.2' - 'dtolnay/rust-toolchain@v1' + - 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6' - 'taiki-e/install-action@v2.90.3' '.github/workflows/ci-health-sweep.yml': - 'actions/checkout@v7.0.1' + - 'actions/create-github-app-token@v3.3.0' - 'step-security/harden-runner@v2.22.4' '.github/workflows/ci.yml': - 'actions/cache@v6.1.0' @@ -38,6 +39,7 @@ workflows: - 'actions/checkout@v7.0.1' - 'github/codeql-action@v4.38.2' '.github/workflows/credential-read-check.yml': + - 'actions/create-github-app-token@v3.3.0' - 'step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a' '.github/workflows/dependabot-automerge.yml': - 'dependabot/fetch-metadata@v3.1.0' @@ -54,6 +56,7 @@ workflows: '.github/workflows/governance.yml': - 'metadatastician/standards@7641c7fdb01420696b5420ab85d88f599f32f609' '.github/workflows/hypatia-remediation-sweep.yml': + - 'actions/create-github-app-token@v3.3.0' - 'actions/upload-artifact@v7.0.2' - 'step-security/harden-runner@v2.22.4' '.github/workflows/hypatia-scan.yml': From de47d21447d3ce8cbb72f234cfd0cacdae22ad71 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:41:22 +0000 Subject: [PATCH 3/3] ci: address review: pin tested Bun, add Actions/Checks read for ci-health, doc fixes Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01J4QvDixKBAqsZv6cTjgS6M --- .github/workflows/build-gossamer-gui.yml | 2 ++ .github/workflows/ci-health-sweep.yml | 2 ++ docs/operations/credential-roles.adoc | 3 ++- docs/wiki-pages/Operations.md | 2 +- scripts/ci-health/README.adoc | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-gossamer-gui.yml b/.github/workflows/build-gossamer-gui.yml index 3ac41fa9..5bc37089 100644 --- a/.github/workflows/build-gossamer-gui.yml +++ b/.github/workflows/build-gossamer-gui.yml @@ -115,6 +115,8 @@ jobs: # Estate policy: no Node.js/npm; JS runs Bun > Deno > pnpm. - name: Setup Bun uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version: 1.4.4 # the release the gossamer tests were run against - name: Run loader smoke tests # `bun test ` picks up every *.test.mjs in test/gossamer/, so diff --git a/.github/workflows/ci-health-sweep.yml b/.github/workflows/ci-health-sweep.yml index 968f74dd..bdba4d33 100644 --- a/.github/workflows/ci-health-sweep.yml +++ b/.github/workflows/ci-health-sweep.yml @@ -66,6 +66,8 @@ jobs: app-id: ${{ secrets.HYPATIA_APP_ID }} private-key: ${{ secrets.HYPATIA_APP_PRIVATE_KEY }} owner: ${{ inputs.owner || 'hyperpolymath' }} + permission-actions: read # detect.sh lists workflow runs and jobs + permission-checks: read # detect.sh reads check-run annotations permission-administration: write # allow-list PUT permission-contents: write # fix branches permission-pull-requests: write # PR create diff --git a/docs/operations/credential-roles.adoc b/docs/operations/credential-roles.adoc index 07657866..f8cf3535 100644 --- a/docs/operations/credential-roles.adoc +++ b/docs/operations/credential-roles.adoc @@ -8,7 +8,8 @@ Metadata read is automatic; no write or account permissions are needed for these reads. The remediation sweep's query uses this credential. Its later repository-dispatch step uses a short-lived GitHub App installation token minted from `HYPATIA_APP_ID` and `HYPATIA_APP_PRIVATE_KEY` -(Contents: write on `gitbot-fleet` only); the PAT and the App are not +(Contents: write on `gitbot-fleet` only; the App must be installed on both +`gitbot-fleet` and `verisimdb-data`, the latter for the credential read check); the PAT and the App are not fallbacks for one another. `HYPATIA_DISPATCH_PAT` has been retired. Run the manual `Credential read check` workflow after replacing either secret. diff --git a/docs/wiki-pages/Operations.md b/docs/wiki-pages/Operations.md index 6cad5900..f198bf45 100644 --- a/docs/wiki-pages/Operations.md +++ b/docs/wiki-pages/Operations.md @@ -54,7 +54,7 @@ The supervision tree starts Bandit on port 9090 (9099 under `MIX_ENV=test`): | Variable | Purpose | |---|---| -| `HYPATIA_DISPATCH_PAT` | Optional local-run token for `mix hypatia.*` tasks. CI no longer uses it: workflows mint GitHub App tokens from `HYPATIA_APP_ID` / `HYPATIA_APP_PRIVATE_KEY` | +| `HYPATIA_DISPATCH_PAT` | Optional local-run token for `mix hypatia.*` tasks. The remediation, ci-health and credential-check workflows no longer use it: they mint GitHub App tokens from `HYPATIA_APP_ID` / `HYPATIA_APP_PRIVATE_KEY`. The Phase 2 resync fragment (`scripts/sweeps/phase2-canonical.fragment.yml`) still needs it in consuming repos | | `HYPATIA_HTTP_PORT` | Override the Bandit listen port (default 9090) | | `HYPATIA_VERISIM_URL` | verisim-api base URL. No default: unset or blank turns off prover hints, strategy-shift detection and recommender retraining | | `HYPATIA_ECHIDNABOT_URL` | echidnabot base URL (`/graphql` is appended). No default: unset or blank means strategy-shift re-queues are logged and dropped | diff --git a/scripts/ci-health/README.adoc b/scripts/ci-health/README.adoc index 0a69c2d7..11e13c80 100644 --- a/scripts/ci-health/README.adoc +++ b/scripts/ci-health/README.adoc @@ -94,7 +94,7 @@ from the conclusion alone. * Needs the GitHub App secrets `HYPATIA_APP_ID` and `HYPATIA_APP_PRIVATE_KEY`. The workflow mints a short-lived installation token with Administration, - Contents, Pull requests, Issues and Workflows write (allow-list PUT, PR + Contents, Pull requests, Issues and Workflows write, plus Actions and Checks read (allow-list PUT, PR create, issue upsert). See `docs/operations/credential-roles.adoc`. * Scheduled runs remediate **live**; manual `workflow_dispatch` defaults to **dry-run**. To pause auto-remediation, set the schedule run to dry-run or