Files
fleet/.github/workflows/shared-inventory.yml

134 lines
6.2 KiB
YAML

# Duplication is measured, and the measurement is a ratchet.
#
# Every duplication in this fleet was already known before it was measured —
# orangecat's rate-limiting ADR has sat "Proposed" since January while the count
# went from two to four. Knowing has never changed the number. A weekly report
# that nobody can act on would repeat that mistake, so the report exists to make
# the trend visible and `--check` exists to make it binding.
name: Shared inventory
on:
schedule:
# Weekly. Duplication grows on the timescale of features and new repos, not
# individual commits — a daily run would be noise, and noise gets muted.
- cron: '41 6 * * 1'
workflow_dispatch:
inputs:
strict:
description: 'Fail when duplication has risen'
type: boolean
default: true
permissions:
# write, only so the weekly run can refresh registers/packages.json — the
# derived registry that bitbaum.orangecat.ch renders. A hand-maintained copy
# of a graph that changes underneath it is exactly the drift this repo exists
# to prevent, and a page that types the portfolio is forbidden by AGENTS.md.
contents: write
# dispatch ci.yml on the commit this workflow pushes — see the re-arm below.
actions: write
jobs:
inventory:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- name: Measure the fleet
env:
# Same gap as the verify-floor audit, stated rather than hidden: the
# default token reads public repos only, so private ones are silently
# omitted. The script prints how many repos it inspected — a drop in
# that number is the tell. Set FLEET_READ_TOKEN to cover all of them.
GH_TOKEN: ${{ secrets.FLEET_PAT || secrets.GITHUB_TOKEN }}
run: |
set -uo pipefail
{
echo '## Shared inventory'
echo
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
set +e
bash scripts/ci/shared-inventory.sh 2>&1 | tee -a "$GITHUB_STEP_SUMMARY"
set -e
echo '```' >> "$GITHUB_STEP_SUMMARY"
# The other half of the same question, and the half that was never asked.
# shared-inventory counts the duplication that SHOULD become a package;
# this counts the packages that already exist and cannot be found in the
# registry. bip-kit had eight adopters and no row for weeks — every agent
# told to "check SHARED.md before building" was told to check a file that
# did not mention it. Same job because it is the same file's health, and
# the report is useless split across two summaries.
- name: Every adopted package has a registry row
env:
GH_TOKEN: ${{ secrets.FLEET_PAT || secrets.GITHUB_TOKEN }}
run: |
set -uo pipefail
{
echo '## Shared registry'
echo
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
set +e
node scripts/ci/shared-registry-audit.mjs 2>&1 | tee -a "$GITHUB_STEP_SUMMARY"
set -e
echo '```' >> "$GITHUB_STEP_SUMMARY"
# Refresh the published registry that bitbaum.orangecat.ch renders.
# Commits only when the derived facts actually changed, so a quiet week
# produces no commit at all.
- name: Publish the derived package registry
env:
GH_TOKEN: ${{ secrets.FLEET_PAT || secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
node scripts/ci/shared-registry-audit.mjs --emit registers/packages.json >/dev/null
if git diff --quiet -- registers/packages.json; then
echo "packages.json unchanged"
exit 0
fi
git config user.name "fleet-bot"
git config user.email "noreply@bitbaum.invalid"
git add registers/packages.json
git commit -m "chore(registers): refresh derived package registry"
git push
# Package-adoption and npm-version facts render on the Bitbaum site.
# Dispatch only after a changed registry lands, and carry the exact
# commit so the site cannot race raw/main propagation into stale HTML.
registry_sha="$(git rev-parse HEAD)"
payload="$(printf '{\"event_type\":\"package-registry-updated\",\"client_payload\":{\"packages_sha\":\"%s\"}}' "$registry_sha")"
printf '%s' "$payload" | GH_TOKEN="${{ secrets.FLEET_PAT }}" gh api \
--method POST repos/bitbaum/bitbaum/dispatches --input -
# Re-arm CI on the commit just pushed: a GITHUB_TOKEN push triggers
# nothing, so main gets no CI run and the auto-merge sweep blocks on
# "waiting for CI to catch up" until someone dispatches it by hand.
# Full reasoning in origin-proof.yml, which had the same hole.
# Never fatal — the commit is already pushed.
GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" gh workflow run ci.yml --ref main \
|| echo "could not re-arm ci.yml — the sweep will block until it is dispatched" >&2
# ── the ratchets, last and INDEPENDENT ─────────────────────────────────
#
# Both reports run before either ratchet, and each ratchet carries
# `!cancelled()` so that one going red cannot hide the other. Without
# that, the first failing check ends the job and the second gate never
# runs — it would report green-by-absence forever, which is worse than
# not having it. The duplication ratchet was already red when the
# registry gate was added (ai-provider-client 17 -> 19), so this was the
# live case, not a hypothetical.
- name: The ratchet — duplication may fall, never rise
if: ${{ !cancelled() && inputs.strict != false }}
env:
GH_TOKEN: ${{ secrets.FLEET_PAT || secrets.GITHUB_TOKEN }}
run: bash scripts/ci/shared-inventory.sh --check
- name: The registry must list what the fleet actually depends on
if: ${{ !cancelled() && inputs.strict != false }}
env:
GH_TOKEN: ${{ secrets.FLEET_PAT || secrets.GITHUB_TOKEN }}
run: node scripts/ci/shared-registry-audit.mjs --check