fix(metrics): give identity projection its own degraded signal #23

Sammanfogat
supernaut sammanfogade 1 incheckning från fix/identity-degraded-signal in i main 2026-08-02 16:03:35 +00:00
Ägare

Closes #22.

reconcileIdentity set the same degraded flag the Actions step uses, and the metric writer
published that single boolean as the Actions enforcement gauge. So a failed profile write or a failed
rename raised an alert saying the reconciler was not applying CI tier enforcement, and told the
operator to broaden a token scope — when the token was fine and an identity value had been refused.

It was also permanent: the projection recomputes the same diff every run, so a value the git host will
never accept produced one warning per tick and a stuck flag, under the wrong name. The two identity
gauges that existed counted successes only; nothing counted failures.

The mix-up is now structurally impossible, not merely fixed. reconcileIdentity no longer
receives the Actions flag at all — it returns its own outcome — and the shared reference is renamed so
the two cannot be silently crossed again.

Publishes gitborg_reconciler_identity_projection_degraded and gitborg_reconciler_identity_failures,
both unlabelled gauges rewritten in full each run, with HELP text naming the likely cause: a value the
identity provider accepts and the git host will not — a reserved or already-taken username, or an
over-length email. The Actions gauge keeps its value and meaning; only its HELP gained a pointer
saying identity failures are not counted there. Identity warnings lost their misleading token-scope
wording and now name the refused fields.

Three properties the dependent alert rule needs to respect, spelled out in the HELP text:

  • …_identity_failures is per-run, not cumulative — hence no _total suffix. A steady 1 means
    one account failing every tick, not one failure since boot. rate()/increase() are meaningless.
  • The degraded flag never self-clears; it holds until someone fixes the value.
  • A fatal run resets both flags to zero, shared pre-existing behaviour with the Actions gauge, so the
    alert should also require a clean last run or let the status alert own that case.

Verification

pnpm lint / typecheck / build   clean
pnpm test                       7 files, 108 tests passing (was 97)

Thirteen new assertions, all red before the fix. The key cases: identity degrades without touching
the Actions gauge on a refused profile write and on a refused rename; and a forbidden repo listing
degrades Actions without touching identity.

Additive only — no existing metric renamed, no environment-variable contract change — so current
alert rules are unaffected. Version bumped; the tag is the release trigger and was deliberately not
created here.

Closes #22. `reconcileIdentity` set the same `degraded` flag the Actions step uses, and the metric writer published that single boolean as the Actions enforcement gauge. So a failed profile write or a failed rename raised an alert saying the reconciler was not applying CI tier enforcement, and told the operator to broaden a token scope — when the token was fine and an identity value had been refused. It was also permanent: the projection recomputes the same diff every run, so a value the git host will never accept produced one warning per tick and a stuck flag, under the wrong name. The two identity gauges that existed counted successes only; nothing counted failures. **The mix-up is now structurally impossible, not merely fixed.** `reconcileIdentity` no longer receives the Actions flag at all — it returns its own outcome — and the shared reference is renamed so the two cannot be silently crossed again. Publishes `gitborg_reconciler_identity_projection_degraded` and `gitborg_reconciler_identity_failures`, both unlabelled gauges rewritten in full each run, with HELP text naming the likely cause: a value the identity provider accepts and the git host will not — a reserved or already-taken username, or an over-length email. The Actions gauge keeps its value and meaning; only its HELP gained a pointer saying identity failures are not counted there. Identity warnings lost their misleading token-scope wording and now name the refused fields. Three properties the dependent alert rule needs to respect, spelled out in the HELP text: - `…_identity_failures` is **per-run, not cumulative** — hence no `_total` suffix. A steady `1` means one account failing every tick, not one failure since boot. `rate()`/`increase()` are meaningless. - The degraded flag **never self-clears**; it holds until someone fixes the value. - A fatal run resets both flags to zero, shared pre-existing behaviour with the Actions gauge, so the alert should also require a clean last run or let the status alert own that case. ### Verification ``` pnpm lint / typecheck / build clean pnpm test 7 files, 108 tests passing (was 97) ``` Thirteen new assertions, all red before the fix. The key cases: identity degrades without touching the Actions gauge on a refused profile write and on a refused rename; and a forbidden repo listing degrades Actions without touching identity. Additive only — no existing metric renamed, no environment-variable contract change — so current alert rules are unaffected. Version bumped; the tag is the release trigger and was deliberately not created here.
supernaut lade till 1 incheckning 2026-08-02 15:56:18 +00:00
fix(metrics): give identity projection its own degraded signal
Alla kontroller lyckades
ci / ci (pull_request) Successful in 30s
a32e4cb555
reconcileIdentity shared the `degraded` flag with the Actions step, and the
metric writer published that one boolean as
gitborg_reconciler_actions_enforcement_degraded. A refused full_name/email
write or a refused rename therefore raised an alert reading "Reconciler is
not applying Actions (CI) tier enforcement", sending the operator after a
token scope that was never the problem — and raised it on every tick, since
the projection recomputes the same diff each run and a value the git host
will not accept never stops being refused.

The identity projection now reports its own outcome:

  gitborg_reconciler_identity_projection_degraded  gauge, 0/1, unlabelled
  gitborg_reconciler_identity_failures             gauge, per-run count

Both carry HELP text naming the likely cause — a value Kanidm accepts and
Forgejo refuses (reserved or taken username, over-length e-mail) — and the
fact that it will not clear on its own. The Actions gauge keeps its exact
former meaning and now says in its HELP that identity failures are not
counted there. Warnings on the identity path lost their misleading
token-scope wording.

IdentityCounts becomes IdentityOutcome (it now carries failures + degraded),
and the shared ref in reconcile() is renamed actionsDegraded so the mix-up
that caused this cannot be made silently again.

Tests: an identity failure must not move the Actions gauge (and the
converse), refusals counted per call, dry-run degrades nothing, and the
metric file asserts both gauges independently plus the HELP wording.

Version bumped to 1.3.0 — additive metrics, no contract change; the alert
rule keyed on these names is gitborg-infra#326.

Closes #22
supernaut sammanfogade incheckning 77694feed8 till main 2026-08-02 16:03:35 +00:00
supernaut tog bort grenen fix/identity-degraded-signal 2026-08-02 16:03:36 +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!23
Ingen beskrivning angiven.