fix: abort on a partial kanidm read and cover the actions-degraded path #66

Sammanfogat
supernaut sammanfogade 2 incheckningar från chore/59-verify-h3-m8 in i main 2026-10-02 09:52:59 +00:00
Ägare

What

Verify H3 and M8 from the infra hardening review (bitborg-infra#125) against the rewrite.

H3 (partial-scope token silently no-ops CI enforcement): already handled. applyRepoActions sets actionsDegraded on a non-200 repo listing and on a refused setRepoActions write (network errors map to status 0). main.ts exports it as bitborg_reconciler_actions_enforcement_degraded. Non-fatal by design so a short scope cannot take quota enforcement down. Added a regression test for the refused write; the listing 403 was already covered.

M8 (partial Kanidm read mis-tiers users): still applied, fixed. getGroupMembers returns [] for a 200 with no member attribute, which is what an ACL-filtered read looks like, and nothing stopped the run. New assertNotPartialRead runs after the Kanidm reads and before any Forgejo write: if participant, basic, pro and trial ALL read empty while Forgejo lists a non-exempt user, the run throws and makes no writes. It never fires while any tier group has a member (production has members in paid and participant today), or when only exempt accounts exist.

An earlier version floored only tier_participant; dropped because trials and exempt accounts are not in that group, so a legitimately empty participant group would have stopped every run.

Tests

122/122. New: refused has_actions write flags degraded; all tier groups empty with a non-exempt user aborts with zero writes; only exempt users with empty groups proceeds; empty participant but populated trial proceeds.

Not verified

Live token scopes and the Kanidm service account's read ACL (need production access).

Closes #59

## What Verify H3 and M8 from the infra hardening review (bitborg-infra#125) against the rewrite. **H3 (partial-scope token silently no-ops CI enforcement): already handled.** `applyRepoActions` sets `actionsDegraded` on a non-200 repo listing and on a refused `setRepoActions` write (network errors map to status 0). `main.ts` exports it as `bitborg_reconciler_actions_enforcement_degraded`. Non-fatal by design so a short scope cannot take quota enforcement down. Added a regression test for the refused write; the listing 403 was already covered. **M8 (partial Kanidm read mis-tiers users): still applied, fixed.** `getGroupMembers` returns `[]` for a 200 with no `member` attribute, which is what an ACL-filtered read looks like, and nothing stopped the run. New `assertNotPartialRead` runs after the Kanidm reads and before any Forgejo write: if participant, basic, pro and trial ALL read empty while Forgejo lists a non-exempt user, the run throws and makes no writes. It never fires while any tier group has a member (production has members in paid and participant today), or when only exempt accounts exist. An earlier version floored only `tier_participant`; dropped because trials and exempt accounts are not in that group, so a legitimately empty participant group would have stopped every run. ## Tests 122/122. New: refused `has_actions` write flags degraded; all tier groups empty with a non-exempt user aborts with zero writes; only exempt users with empty groups proceeds; empty participant but populated trial proceeds. ## Not verified Live token scopes and the Kanidm service account's read ACL (need production access). Closes #59
supernaut lade till 2 incheckningar 2026-10-02 09:40:18 +00:00
An ACL-filtered Kanidm read returns 200 with no members. Every account
is a participant, so an empty participant group means a partial read.
Abort before any Forgejo write instead of demoting paid users.

Also add a regression test that a refused has_actions write raises the
actions degraded flag (H3).

Verifies H3 and M8 from bitborg-infra#125.

Closes #59
fix: replace the participant floor with a union-of-tiers floor
Alla kontroller lyckades
ci / ci (pull_request) Successful in 1m7s
c61898be70
An empty tier_participant is legitimate: trials, exempt accounts and a
near-empty instance all produce it. Abort before any write only when
participant, basic, pro and trial all read empty while Forgejo lists a
non-exempt user. That is the signature of an ACL-filtered read.

Closes #59
supernaut sammanfogade incheckning 04ee1ec588 till main 2026-10-02 09:52:59 +00:00
supernaut tog bort grenen chore/59-verify-h3-m8 2026-10-02 09:52:59 +00:00
supernaut refererade denna ändringsförfrågan från en incheckning 2026-10-02 09:57:23 +00:00
supernaut refererade denna ändringsförfrågan från en incheckning 2026-10-02 09:59:47 +00:00
supernaut refererade denna ändringsförfrågan från en incheckning 2026-10-02 17:57:03 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-auth-reconciler!66
Ingen beskrivning angiven.