Second part of t72, Prüfwerk metering (LB §2 Abs. 5–6). Builds on #927 (merged); rebased onto main.
A counted Prüfung (the chargeable flag from #927) is checked against the plan when it starts, and charged when it completes.
Rules
Plan: read from the registry entitlement limits: monthly_pruefungen and prueftag_cap, alongside included_targets (tenant-registry #114). A missing or null key means no limit, as for Enterprise. If the registry doesn't answer, counted Prüfungen are neither checked nor charged.
Quota first. Once it is used up, the first counted Prüfung on a target on a calendar day (Europe/Berlin, via chrono-tz) books a Prüftag. That Prüftag allows 6 Prüfungen from then on; Prüfungen charged to the quota earlier that day don't use it up. A 7th that day does not run. Nor does one that would need a Prüftag beyond the customer's cap (a cap of 0 means no Prüftage).
Refused runs. The run ends without scanning and records why, using two new skip codes (prueftag_limit_reached, prueftag_cap_reached) worded in the dashboard. It leaves the commit and upload watermarks alone, so the change still gets scanned once the plan allows it. It emits no scan.completed.
Charging at completion:
A run that fails because of us (internal error, unreachable repository, interruption) is never charged, so nothing ever has to be refunded.
A run that fails on the customer's input (archive password missing or wrong) is charged.
Trade-off: if several targets' scans finish at the same moment, they can push the quota or a Prüftag over its limit by the runs that raced.
Counters: two collections in the tenant DB: metering_months (_id YYYY-MM: pruefungen, prueftage) and metering_days (_id target:YYYY-MM-DD: prueftag_booked, prueftag_pruefungen). Each run records what it was charged to in charge (quota / prueftag).
Usage event:prueftag.booked, quantity 1, idempotency key prueftag:{tenant}:{target}:{YYYY-MM-DD}. Properties: target id and day only, no names.
Tests
Core: the admission rules (quota first, a Prüftag of six, the cap stops new Prüftage but not a booked one, no quota means no limit).
Agent: Berlin month/day boundaries in winter and summer, counter reading, the registry limits, and a Mongo integration test (tests/metering_counters.rs) that runs quota → Prüftag → daily limit → cap → next Berlin day.
Not built locally, per the CI-only rule. Still to come in (c): target.extra, the customer's choice of included targets, and showing usage in the dashboard.
Second part of t72, Prüfwerk metering (LB §2 Abs. 5–6). Builds on #927 (merged); rebased onto main.
A counted Prüfung (the `chargeable` flag from #927) is checked against the plan when it starts, and charged when it completes.
## Rules
- **Plan:** read from the registry entitlement `limits`: `monthly_pruefungen` and `prueftag_cap`, alongside `included_targets` (tenant-registry #114). A missing or null key means no limit, as for Enterprise. If the registry doesn't answer, counted Prüfungen are neither checked nor charged.
- **Quota first.** Once it is used up, the first counted Prüfung on a target on a calendar day (Europe/Berlin, via `chrono-tz`) books a Prüftag. That Prüftag allows 6 Prüfungen from then on; Prüfungen charged to the quota earlier that day don't use it up. A 7th that day does not run. Nor does one that would need a Prüftag beyond the customer's cap (a cap of 0 means no Prüftage).
- **Refused runs.** The run ends without scanning and records why, using two new skip codes (`prueftag_limit_reached`, `prueftag_cap_reached`) worded in the dashboard. It leaves the commit and upload watermarks alone, so the change still gets scanned once the plan allows it. It emits no `scan.completed`.
- **Charging at completion:**
- A run that fails because of us (internal error, unreachable repository, interruption) is never charged, so nothing ever has to be refunded.
- A run that fails on the customer's input (archive password missing or wrong) is charged.
- Trade-off: if several targets' scans finish at the same moment, they can push the quota or a Prüftag over its limit by the runs that raced.
- **Counters:** two collections in the tenant DB: `metering_months` (`_id` YYYY-MM: `pruefungen`, `prueftage`) and `metering_days` (`_id` target:YYYY-MM-DD: `prueftag_booked`, `prueftag_pruefungen`). Each run records what it was charged to in `charge` (quota / prueftag).
- **Usage event:** `prueftag.booked`, quantity 1, idempotency key `prueftag:{tenant}:{target}:{YYYY-MM-DD}`. Properties: target id and day only, no names.
## Tests
- **Core:** the admission rules (quota first, a Prüftag of six, the cap stops new Prüftage but not a booked one, no quota means no limit).
- **Agent:** Berlin month/day boundaries in winter and summer, counter reading, the registry limits, and a Mongo integration test (`tests/metering_counters.rs`) that runs quota → Prüftag → daily limit → cap → next Berlin day.
Not built locally, per the CI-only rule. Still to come in (c): `target.extra`, the customer's choice of included targets, and showing usage in the dashboard.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang
changed target branch from feat/t72-attribution to main2026-11-06 14:30:59 +00:00
The second part of Prüfwerk metering (LB §2 Abs. 5-6): a counted
Prüfung is checked against the plan when it starts and charged when it
completes.
- The plan comes from the registry entitlement: `monthly_pruefungen`
and `prueftag_cap` next to `included_targets`; a missing key is no
limit (Enterprise).
- Charged to the month's quota first. Once it is used up, the first
counted Prüfung on a target on a calendar day (Europe/Berlin) books
a Prüftag, which allows six from then on; the next one that day does
not run, and neither does one needing a Prüftag beyond the cap.
- A refused run ends without scanning, records why (two new skip
codes, worded in the dashboard), and leaves the target's commit and
upload watermarks alone, so the change is scanned once it may be.
- A run that fails because of us is never charged; one that fails on
the customer's input (archive password) is. Charging at completion
means nothing is ever refunded; scans finishing at the same moment
can take the quota over by the ones that raced.
- A booked Prüftag goes to the registry as `prueftag.booked`, keyed
prueftag:{tenant}:{target}:{day}.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang
merged commit a7355ffdc8 into main2026-11-06 14:48:08 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Second part of t72, Prüfwerk metering (LB §2 Abs. 5–6). Builds on #927 (merged); rebased onto main.
A counted Prüfung (the
chargeableflag from #927) is checked against the plan when it starts, and charged when it completes.Rules
limits:monthly_pruefungenandprueftag_cap, alongsideincluded_targets(tenant-registry #114). A missing or null key means no limit, as for Enterprise. If the registry doesn't answer, counted Prüfungen are neither checked nor charged.chrono-tz) books a Prüftag. That Prüftag allows 6 Prüfungen from then on; Prüfungen charged to the quota earlier that day don't use it up. A 7th that day does not run. Nor does one that would need a Prüftag beyond the customer's cap (a cap of 0 means no Prüftage).prueftag_limit_reached,prueftag_cap_reached) worded in the dashboard. It leaves the commit and upload watermarks alone, so the change still gets scanned once the plan allows it. It emits noscan.completed.metering_months(_idYYYY-MM:pruefungen,prueftage) andmetering_days(_idtarget:YYYY-MM-DD:prueftag_booked,prueftag_pruefungen). Each run records what it was charged to incharge(quota / prueftag).prueftag.booked, quantity 1, idempotency keyprueftag:{tenant}:{target}:{YYYY-MM-DD}. Properties: target id and day only, no names.Tests
tests/metering_counters.rs) that runs quota → Prüftag → daily limit → cap → next Berlin day.Not built locally, per the CI-only rule. Still to come in (c):
target.extra, the customer's choice of included targets, and showing usage in the dashboard.🤖 Generated with Claude Code
The second part of Prüfwerk metering (LB §2 Abs. 5-6): a counted Prüfung is checked against the plan when it starts and charged when it completes. - The plan comes from the registry entitlement: `monthly_pruefungen` and `prueftag_cap` next to `included_targets`; a missing key is no limit (Enterprise). - Charged to the month's quota first. Once it is used up, the first counted Prüfung on a target on a calendar day (Europe/Berlin) books a Prüftag, which allows six from then on; the next one that day does not run, and neither does one needing a Prüftag beyond the cap. - A refused run ends without scanning, records why (two new skip codes, worded in the dashboard), and leaves the target's commit and upload watermarks alone, so the change is scanned once it may be. - A run that fails because of us is never charged; one that fails on the customer's input (archive password) is. Charging at completion means nothing is ever refunded; scans finishing at the same moment can take the quota over by the ones that raced. - A booked Prüftag goes to the registry as `prueftag.booked`, keyed prueftag:{tenant}:{target}:{day}. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>