First part of t72, Prüfwerk metering (LB §2 Abs. 4–5, §7). This PR records what a scan is metered by. Nothing is counted or enforced yet; counters, the 6-per-day limit and the Prüftag cap come in the next PR.
What changes
Included vs extra targets. Each target stores billing: included | extra.
The oldest active targets by created_at are included, up to the plan's limits.included_targets from the registry entitlement. The rest are extra.
The split is refreshed before each scan and when a target is created. Archiving an included target moves the oldest extra one up.
A plan without that key includes every target, which is every plan until the registry sends the limits. So this PR changes nothing for existing tenants.
Run attribution. Each run records an attribution:
request: the customer started it (dashboard or API).
support: staff started it.
change: something the customer changed, i.e. new commits, other uploads, or a live URL.
rescan: only the Prüfwerk build changed.
For scheduled and webhook scans it's set where change detection decides, so our rescan after an update is no longer counted as a customer change. uploads_changed / content_changed don't depend on UPLOAD_CHANGE_SKIP.
chargeable. Says whether the run counts once it completes:
a request always counts;
a change counts only on an extra target;
rescans and support scans never count.
scan.completed now carries attribution and counted as properties.
Dashboard. The targets list shows a "Zusätzliches Prüfobjekt" badge on an extra target.
Tests
Core: the included/extra split, attribution, and the contract table of what counts.
Agent:content_changed/uploads_changed, the included_targets limit, reading a stored target's billing, and a Mongo integration test (tests/target_billing.rs): the oldest are included, and an extra target moves up on archive.
Not built locally, per the CI-only rule; CI is the compiler here.
First part of t72, Prüfwerk metering (LB §2 Abs. 4–5, §7). This PR records what a scan is metered by. Nothing is counted or enforced yet; counters, the 6-per-day limit and the Prüftag cap come in the next PR.
## What changes
- **Included vs extra targets.** Each target stores `billing: included | extra`.
- The oldest active targets by `created_at` are included, up to the plan's `limits.included_targets` from the registry entitlement. The rest are extra.
- The split is refreshed before each scan and when a target is created. Archiving an included target moves the oldest extra one up.
- A plan without that key includes every target, which is every plan until the registry sends the limits. So this PR changes nothing for existing tenants.
- **Run attribution.** Each run records an `attribution`:
- `request`: the customer started it (dashboard or API).
- `support`: staff started it.
- `change`: something the customer changed, i.e. new commits, other uploads, or a live URL.
- `rescan`: only the Prüfwerk build changed.
For scheduled and webhook scans it's set where change detection decides, so our rescan after an update is no longer counted as a customer change. `uploads_changed` / `content_changed` don't depend on `UPLOAD_CHANGE_SKIP`.
- **`chargeable`.** Says whether the run counts once it completes:
- a request always counts;
- a change counts only on an extra target;
- rescans and support scans never count.
`scan.completed` now carries `attribution` and `counted` as properties.
- **Dashboard.** The targets list shows a "Zusätzliches Prüfobjekt" badge on an extra target.
## Tests
- **Core:** the included/extra split, attribution, and the contract table of what counts.
- **Agent:** `content_changed`/`uploads_changed`, the `included_targets` limit, reading a stored target's billing, and a Mongo integration test (`tests/target_billing.rs`): the oldest are included, and an extra target moves up on archive.
Not built locally, per the CI-only rule; CI is the compiler here.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
The first part of Prüfwerk metering (LB §2 Abs. 4-5, §7): what a scan
is metered by, without counting or enforcing anything yet.
- A target is included or extra (`billing`). The oldest active targets
are included, up to the plan's `limits.included_targets` from the
registry; the rest are extra. The split is stored, refreshed before
each scan and when a target is created, so archiving an included
target moves the oldest extra one up. A plan without the limit (all
plans today) includes every target.
- Each scan run records its `attribution`: request (the customer
started it), support, change (new commits, other uploads, a live
URL) or rescan (only the Prüfwerk build changed). Change detection
sets it for scheduled and webhook scans, so our rescan after an
update is told apart from a customer's change.
- `chargeable` says whether the run counts once it completes: a
request always, a change only on an extra target, a rescan or a
support scan never. scan.completed carries both as properties.
- The targets list badges an extra target.
Counters, the daily limit and the cap follow in the next PR.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
First part of t72, Prüfwerk metering (LB §2 Abs. 4–5, §7). This PR records what a scan is metered by. Nothing is counted or enforced yet; counters, the 6-per-day limit and the Prüftag cap come in the next PR.
What changes
Included vs extra targets. Each target stores
billing: included | extra.created_atare included, up to the plan'slimits.included_targetsfrom the registry entitlement. The rest are extra.Run attribution. Each run records an
attribution:request: the customer started it (dashboard or API).support: staff started it.change: something the customer changed, i.e. new commits, other uploads, or a live URL.rescan: only the Prüfwerk build changed.For scheduled and webhook scans it's set where change detection decides, so our rescan after an update is no longer counted as a customer change.
uploads_changed/content_changeddon't depend onUPLOAD_CHANGE_SKIP.chargeable. Says whether the run counts once it completes:scan.completednow carriesattributionandcountedas properties.Dashboard. The targets list shows a "Zusätzliches Prüfobjekt" badge on an extra target.
Tests
content_changed/uploads_changed, theincluded_targetslimit, reading a stored target's billing, and a Mongo integration test (tests/target_billing.rs): the oldest are included, and an extra target moves up on archive.Not built locally, per the CI-only rule; CI is the compiler here.
🤖 Generated with Claude Code