feat(metering): new content starts a change-driven scan (t72) #930

Merged
sharang merged 1 commits from feat/t72-upload-scan into main 2026-11-06 16:14:27 +00:00
Owner

Part (c), item 2 of t72: answer 5 of the contract decisions. An upload starts a change scan right away. It's free on an included target and counted on an extra one.

Why

  • Until now, the wizard's first scan of a new target was a requested Prüfung, so it counted against the quota.
  • An upload to an existing target started no scan at all; the customer had to click "Prüfung starten", which counts too.
  • For archive-upload customers, every new version would therefore have used up quota.

What changes

  • New trigger: ScanTrigger::NewContent. It isn't started "by a person" in the change-detection sense, so it runs only when something changed, the same as a scheduled scan. Change detection then attributes it as change.
  • API: POST /api/v1/targets/{id}/scan?reason=new_content selects it.
    • Without reason, the scan is still a requested Prüfung that always runs in full.
    • Staff sessions stay support.
    • It can't be abused for free scans: if nothing changed, nothing runs.
  • Dashboard:
    • The wizard's first scan (both paths) uses it.
    • An upload on the target page now starts it once the file and any archive password are stored. The note says the scan starts, or, if the start failed, that the next scheduled scan reads the file.
    • Starting the scan isn't done in the upload endpoint itself, because the archive password is set in a separate call right after the upload.
  • Docs: docs/guide/scanning.md describes the scan after new content and the API parameter.

Tests

  • Trigger: requested_trigger (no reason / new_content / another value / staff).
  • Attribution: NewContent with a change is attributed as change.
  • Scan gate: a new-content scan starts at once.

Not built locally, per the CI-only rule.

🤖 Generated with Claude Code

Part (c), item 2 of t72: answer 5 of the contract decisions. An upload starts a change scan right away. It's free on an included target and counted on an extra one. ## Why - Until now, the wizard's first scan of a new target was a **requested** Prüfung, so it counted against the quota. - An upload to an existing target started no scan at all; the customer had to click "Prüfung starten", which counts too. - For archive-upload customers, every new version would therefore have used up quota. ## What changes - **New trigger:** `ScanTrigger::NewContent`. It isn't started "by a person" in the change-detection sense, so it runs only when something changed, the same as a scheduled scan. Change detection then attributes it as `change`. - **API:** `POST /api/v1/targets/{id}/scan?reason=new_content` selects it. - Without `reason`, the scan is still a requested Prüfung that always runs in full. - Staff sessions stay `support`. - It can't be abused for free scans: if nothing changed, nothing runs. - **Dashboard:** - The wizard's first scan (both paths) uses it. - An upload on the target page now starts it once the file and any archive password are stored. The note says the scan starts, or, if the start failed, that the next scheduled scan reads the file. - Starting the scan isn't done in the upload endpoint itself, because the archive password is set in a separate call right after the upload. - **Docs:** `docs/guide/scanning.md` describes the scan after new content and the API parameter. ## Tests - **Trigger:** `requested_trigger` (no reason / `new_content` / another value / staff). - **Attribution:** `NewContent` with a change is attributed as `change`. - **Scan gate:** a new-content scan starts at once. Not built locally, per the CI-only rule. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-06 15:25:08 +00:00
feat(metering): new content starts a change-driven scan (t72)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 4m16s
CI / Check (pull_request) Successful in 16m34s
63ceba34d2
The contract counts change-driven Prüfungen on an included target as
free, and an upload is the customer's change. Until now the wizard's
first scan was a requested one (counted), and an upload to an existing
target started no scan at all.

- A new trigger, `new_content`: like a scheduled scan it runs only when
  something changed, and change detection attributes it as a change,
  so it is free on an included target and counted on an extra one.
- POST /api/v1/targets/{id}/scan takes `?reason=new_content`; without
  it the scan is a Prüfung the customer requests, as before. Support
  stays support.
- The wizard's first scan and an upload on the target page use it; the
  upload note says the scan starts, or that the next scheduled scan
  reads the file if it could not start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit 9f2e78c6c4 into main 2026-11-06 16:14:27 +00:00
Sign in to join this conversation.