mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-04 00:28:14 +01:00
* chore(aoz): rename the repo to aoz-begleitung, and record why `bitbaum/aoz-housing` is now `bitbaum/aoz-begleitung`. It was the last public place the product was still called Housing: registers/retired.json retired "AOZ Housing" as the PRODUCT name on 2026-09-10, but the repo kept it, and the repo is PUBLIC — so the retired name sat on the org page, in every clone URL, and in ~55 references across this repo alone. The deploy name `aoz-wohnen` is deliberately NOT renamed with it, and that is the decision, not an omission. It is an infrastructure identifier — systemd unit, /opt path, database — and nothing on the box keys on the repo name; renaming it would touch a live site for no visible gain. Two names now instead of three. The registers are DERIVED and were regenerated, not hand-edited: origin.json (aoz's `stamped` and `swh` drop to null, correctly and temporarily — Software Heritage archived the old origin URL and the OpenTimestamps manifest names the old repo; the nightly origin-proof re-stamps) and packages.json. proofs/origin/*.json are untouched on purpose. They are hash-chained and append-only, so a past proof naming bitbaum/aoz-housing is correct history; rewriting one would both falsify the record and break the chain. retired.json gains the `repo` row, which is what makes the old name traceable — and what makes org-drift-audit.sh start flagging documents that still use it. Three were flagged: this repo's AGENTS.md (fixed here), the renamed repo's README (fixed in aoz-begleitung#243) and its CLAUDE.md, which is BASELINED with a reason rather than fixed: `JWT_ISSUER` is still the literal string `aoz-housing` and must stay so — src/proxy.ts and src/lib/auth/config.ts pass it as the JWT issuer, and changing it invalidates every live session. A live auth value, not a name. Verified across the rename: bitbaum/aoz-housing redirects to the new repo, https://aoz.orangecat.ch still 200, aoz-wohnen-app still active, and the new clone URL resolves to 431bae7 — the same tip as before. Tests green: deploy-freshness 24, deploy-reconciler 34, repo-metadata 17, model-pin, version-currency, product-identity 45, verify-predicates 29. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2 * chore(aoz): defer the retired-name row until the docs it polices have landed org-drift-audit.sh reads the org's DEFAULT BRANCHES, not the working tree. So adding the `aoz-housing -> aoz-begleitung` row to retired.json in the same PR that fixes AGENTS.md is a deadlock by construction: the audit judges main, where AGENTS.md is still unfixed, so `--check` fails — and the fix cannot merge while it fails. The row is a POST-condition, not a co-requisite. Fix the documents first, let them reach the default branches, then declare the name retired and let the audit hold the line from there. The row returns in its own PR once this and loki#732 are on main. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2 * chore(aoz): the baseline exception belongs with the row that creates it Same sequencing lesson, mirrored. Without the retired-name row nothing flags aoz-begleitung/CLAUDE.md, so a baseline entry for it matches no violation — and org-drift rejects that correctly: "baseline entries with no matching violation — the ratchet fell". A baseline full of entries that match nothing is a ratchet that cannot fall, which the file's own header already says. So the row and its one exception land together, in the PR after this one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2 --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
210 lines
8.2 KiB
Bash
Executable File
210 lines
8.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Negative tests for the verify-contract WIRING rules.
|
|
#
|
|
# The rules live in verify-predicates.sh precisely so they can be tested without
|
|
# reaching GitHub — the audit that uses them is remote-only, and a rule that can
|
|
# only be exercised by a live API call is a rule nobody re-tests after changing
|
|
# one of its regexes.
|
|
#
|
|
# Both directions are tested on purpose. Proving a rule BITES is half the job;
|
|
# proving it stays quiet on a conforming repo is the other half, and skipping it
|
|
# is how a checker starts crying wolf and gets ignored — the same end state as
|
|
# having no checker, reached more expensively.
|
|
|
|
set -uo pipefail
|
|
|
|
# shellcheck source=scripts/ci/verify-predicates.sh
|
|
. "$(cd "$(dirname "$0")" && pwd)/verify-predicates.sh"
|
|
|
|
PASS=0
|
|
FAIL=0
|
|
|
|
ok() { printf ' ✓ %s\n' "$1"; PASS=$((PASS + 1)); }
|
|
no() { printf ' ✗ %s\n' "$1"; FAIL=$((FAIL + 1)); }
|
|
|
|
# assert <expected pass|fail> <predicate> <input> <description>
|
|
assert() {
|
|
local want="$1" pred="$2" input="$3" desc="$4"
|
|
if "$pred" "$input"; then got=pass; else got=fail; fi
|
|
[ "$got" = "$want" ] && ok "$desc" || no "$desc (expected $want, got $got)"
|
|
}
|
|
|
|
CALLS='jobs:
|
|
verify:
|
|
steps:
|
|
- name: Verify
|
|
run: npm run verify'
|
|
|
|
HANDCOPIED='jobs:
|
|
verify:
|
|
steps:
|
|
- name: Lint
|
|
run: npm run lint --if-present
|
|
- name: Test
|
|
run: npm run test --if-present'
|
|
|
|
SOFTENED='jobs:
|
|
verify:
|
|
steps:
|
|
- name: Verify
|
|
run: npm run verify --if-present'
|
|
|
|
BENIGN_IFPRESENT='jobs:
|
|
verify:
|
|
steps:
|
|
- name: Optional docs
|
|
run: npm run docs --if-present
|
|
- name: Verify
|
|
run: npm run verify'
|
|
|
|
echo "ci_invokes_verify"
|
|
assert pass ci_invokes_verify "$CALLS" 'npm run verify is detected'
|
|
assert pass ci_invokes_verify 'run: pnpm verify' 'pnpm implicit-run is accepted (was a false positive once)'
|
|
assert pass ci_invokes_verify 'run: yarn verify' 'yarn implicit-run is accepted'
|
|
assert pass ci_invokes_verify 'run: bun run verify' 'bun is accepted'
|
|
assert fail ci_invokes_verify "$HANDCOPIED" 'hand-copied steps do NOT count as calling verify'
|
|
assert fail ci_invokes_verify 'run: npm run verify-deploy' 'a longer script name is not mistaken for verify'
|
|
assert fail ci_invokes_verify '' 'an empty workflow body is not a call'
|
|
|
|
echo "ci_verify_softened"
|
|
assert pass ci_verify_softened "$SOFTENED" '--if-present ON the verify step is caught'
|
|
assert fail ci_verify_softened "$CALLS" 'a clean verify step is not flagged'
|
|
assert fail ci_verify_softened "$BENIGN_IFPRESENT" '--if-present on an UNRELATED step is not flagged'
|
|
|
|
echo "verify_softens_itself"
|
|
assert pass verify_softens_itself 'eslint . || true' '|| true inside verify is caught'
|
|
assert pass verify_softens_itself 'npm run typecheck --workspaces --if-present' '--if-present inside verify is caught'
|
|
assert fail verify_softens_itself 'pnpm lint && pnpm typecheck && pnpm test' 'a clean verify is not flagged'
|
|
assert fail verify_softens_itself '' 'an empty verify is not flagged here — absence is the audit job'
|
|
|
|
# assert2 <expected pass|fail> <predicate> <arg1> <arg2> <description>
|
|
assert2() {
|
|
local want="$1" pred="$2" a="$3" b="$4" desc="$5"
|
|
if "$pred" "$a" "$b"; then got=pass; else got=fail; fi
|
|
[ "$got" = "$want" ] && ok "$desc" || no "$desc (expected $want, got $got)"
|
|
}
|
|
|
|
VERIFY_NPM='npm run lint && npm run typecheck && npm run test'
|
|
|
|
# aoz-begleitung's real shape: the same three scripts, split across parallel jobs
|
|
# for speed, none of them softened. This is the case that proved the
|
|
# string-match rule wrong.
|
|
AOZ_WF=' - name: Lint
|
|
run: npm run lint
|
|
- name: Type check
|
|
run: npm run typecheck
|
|
- name: Run unit tests
|
|
run: npm test -- --ci --coverage
|
|
- name: Build
|
|
run: npm run build'
|
|
|
|
# Same split, but one gate quietly absent.
|
|
AOZ_MISSING_TYPECHECK=' - name: Lint
|
|
run: npm run lint
|
|
- name: Run unit tests
|
|
run: npm test -- --ci --coverage'
|
|
|
|
echo "verify_gate_scripts"
|
|
got=$(verify_gate_scripts "$VERIFY_NPM" | tr '\n' ' ')
|
|
[ "$got" = "lint test typecheck " ] \
|
|
&& ok "decomposes verify into its named gates" \
|
|
|| no "decomposes verify into its named gates (got '$got')"
|
|
got=$(verify_gate_scripts 'eslint . && tsc --noEmit && jest')
|
|
[ -z "$got" ] \
|
|
&& ok "a verify that shells out directly decomposes to nothing" \
|
|
|| no "a verify that shells out directly decomposes to nothing (got '$got')"
|
|
|
|
echo "ci_runs_verify_gates"
|
|
assert2 pass ci_runs_verify_gates "$AOZ_WF" "$VERIFY_NPM" \
|
|
'aoz-begleitung: gates run individually, unsoftened → satisfied'
|
|
assert2 fail ci_runs_verify_gates "$AOZ_MISSING_TYPECHECK" "$VERIFY_NPM" \
|
|
'a gate in verify that CI never runs → NOT satisfied'
|
|
assert2 fail ci_runs_verify_gates "$HANDCOPIED" 'npm run lint && npm run test' \
|
|
'botsmann: hand-copied AND --if-present on every step → still caught'
|
|
assert2 fail ci_runs_verify_gates "$AOZ_WF" 'eslint . && tsc --noEmit' \
|
|
'an undecomposable verify is unproven, not waved through'
|
|
assert2 fail ci_runs_verify_gates '' "$VERIFY_NPM" \
|
|
'no workflows at all → NOT satisfied'
|
|
assert2 pass ci_runs_verify_gates 'run: pnpm lint
|
|
run: pnpm typecheck
|
|
run: pnpm test' 'pnpm lint && pnpm typecheck && pnpm test' \
|
|
'pnpm implicit-run spelling works on both sides'
|
|
|
|
# --- gh_get: the three states ------------------------------------------------
|
|
# This is the test that would have caught the 2026-08-16 miscount. `gh` is
|
|
# stubbed so the FAILURE path is reachable without a real outage — which is
|
|
# exactly why the bug survived: nothing could exercise it.
|
|
|
|
GH_GET_BACKOFF=0 # do not actually sleep through the retries in tests
|
|
|
|
echo "gh_get"
|
|
|
|
gh() { printf 'ok-body'; return 0; }
|
|
out=$(gh_get 'any/path'); rc=$?
|
|
[ "$rc" = 0 ] && [ "$out" = "ok-body" ] \
|
|
&& ok "success returns 0 and the body" \
|
|
|| no "success returns 0 and the body (rc=$rc out='$out')"
|
|
|
|
gh() { echo 'gh: Not Found (HTTP 404)' >&2; return 1; }
|
|
gh_get 'missing/path' >/dev/null; rc=$?
|
|
[ "$rc" = 2 ] \
|
|
&& ok "a real 404 is ABSENT (2), distinct from a failure" \
|
|
|| no "a real 404 is ABSENT (2) (rc=$rc)"
|
|
|
|
gh() { echo 'gh: HTTP 403 rate limit exceeded' >&2; return 1; }
|
|
gh_get 'blocked/path' >/dev/null; rc=$?
|
|
[ "$rc" = 1 ] \
|
|
&& ok "a 403 is COULD-NOT-LOOK (1), never mistaken for absence" \
|
|
|| no "a 403 is COULD-NOT-LOOK (1) (rc=$rc)"
|
|
|
|
gh() { echo 'gh: HTTP 502 Bad Gateway' >&2; return 1; }
|
|
gh_get 'flaky/path' >/dev/null; rc=$?
|
|
[ "$rc" = 1 ] \
|
|
&& ok "a 5xx is COULD-NOT-LOOK (1), not absence" \
|
|
|| no "a 5xx is COULD-NOT-LOOK (1) (rc=$rc)"
|
|
|
|
# Transient then success: the retry must actually rescue the call, otherwise
|
|
# every blip still costs a repo its verdict.
|
|
ATTEMPTS_FILE=$(mktemp)
|
|
echo 0 > "$ATTEMPTS_FILE"
|
|
gh() {
|
|
local n; n=$(cat "$ATTEMPTS_FILE"); n=$((n + 1)); echo "$n" > "$ATTEMPTS_FILE"
|
|
if [ "$n" -lt 2 ]; then echo 'gh: HTTP 502' >&2; return 1; fi
|
|
printf 'recovered'; return 0
|
|
}
|
|
out=$(gh_get 'flaky/path'); rc=$?
|
|
[ "$rc" = 0 ] && [ "$out" = "recovered" ] \
|
|
&& ok "a transient failure is retried and recovers" \
|
|
|| no "a transient failure is retried and recovers (rc=$rc out='$out')"
|
|
|
|
# A 404 must NOT burn retries — it is an answer, and retrying it would triple
|
|
# the cost of every genuinely-absent file across the fleet.
|
|
echo 0 > "$ATTEMPTS_FILE"
|
|
gh() {
|
|
local n; n=$(cat "$ATTEMPTS_FILE"); n=$((n + 1)); echo "$n" > "$ATTEMPTS_FILE"
|
|
echo 'gh: Not Found (HTTP 404)' >&2; return 1
|
|
}
|
|
gh_get 'missing/path' >/dev/null
|
|
[ "$(cat "$ATTEMPTS_FILE")" = 1 ] \
|
|
&& ok "a 404 is not retried (costs one call, not three)" \
|
|
|| no "a 404 is not retried (took $(cat "$ATTEMPTS_FILE") calls)"
|
|
|
|
# An exhausted rate limit is not retried either: seconds of backoff cannot
|
|
# outlive an hour-long window, and retrying burns calls when they're scarcest.
|
|
# It is still COULD-NOT-LOOK (1) — a transport fact, never absence.
|
|
echo 0 > "$ATTEMPTS_FILE"
|
|
gh() {
|
|
local n; n=$(cat "$ATTEMPTS_FILE"); n=$((n + 1)); echo "$n" > "$ATTEMPTS_FILE"
|
|
echo 'gh: HTTP 403 API rate limit exceeded for user' >&2; return 1
|
|
}
|
|
gh_get 'starved/path' >/dev/null; rc=$?
|
|
[ "$rc" = 1 ] && [ "$(cat "$ATTEMPTS_FILE")" = 1 ] \
|
|
&& ok "a rate-limited call fails fast as COULD-NOT-LOOK (1 call, rc=1)" \
|
|
|| no "a rate-limited call fails fast (rc=$rc, took $(cat "$ATTEMPTS_FILE") calls)"
|
|
rm -f "$ATTEMPTS_FILE"
|
|
unset -f gh
|
|
|
|
printf '\n%d passed, %d failed\n' "$PASS" "$FAIL"
|
|
[ "$FAIL" -eq 0 ]
|