The #465 change key for uploaded files (pipeline/change.rs::upload_inputs) is a digest of each upload's artifact id and content_hash. Nothing ever stored content_hash on an uploaded artifact: upload_artifact sets only stored_path and size_bytes, and ingest hashes the blob into IngestedArtifact but never persists the hash. So the key never described the bytes that were actually uploaded.
I could not reproduce the stage symptom from the code. On origin/main, with every upload hash None, upload_inputs returns None and upload_unchanged can never return true, so "Uploaded files unchanged, skipping scan" cannot come from this path as main stands. Either stage runs a build that differs from main, or the skip that was seen came from a different run. This PR makes the comparison what #465 intended: the bytes uploaded now against the bytes the last completed scan read. It does not claim to explain the stage observation.
The other things I checked:
The baseline (last_scan) is written only when a scan completes, and from the target snapshot that scan started with. Neither the upload handler nor /detect touches it, so an upload that lands during a scan is not recorded as scanned.
An upload does not start a scan by itself. The dashboard's "Prüfung starten" sends Manual, which always scans. One gap remained in the scan gate: when a scheduled/webhook follow-up was already pending, a person's request was dropped, leaving the skip-eligible follow-up in place. That is fixed here.
What changed
Upload (api/handlers/onboarding.rs): stores the sha256 of the uploaded bytes on the artifact (content_hash).
Scan (orchestrator.rs::record_upload_hashes, change::unrecorded_hashes): an older upload without a hash gets the sha256 that ingest computed. Existing targets therefore become comparable: their next two scheduled runs scan, and from the third on an unchanged target skips.
Scan gate (scan_gate.rs): a person's request (Manual/Support) takes over a pending Scheduled/Webhook follow-up instead of being dropped.
Docs: docs/guide/scanning.md says uploads are compared by SHA-256.
Behaviour to be aware of (decision for the promotion)
On main the upload skip never fired, so scheduled runs of upload targets always scanned and always counted as usage. After this PR, upload targets that do not change start skipping scheduled runs and emit no scan.completed usage. This is #465's documented intent, but in practice it is new.
Re-uploading identical bytes creates a new artifact (new id), and that counts as a change: it scans again.
A known gap that this PR does not widen to cover: a password-protected PlcProject whose password is missing still completes its run (the PLC stage passes over it). Entering the password later does not change the key, so scheduled runs skip until someone clicks Prüfung starten.
retention.rs blob cleanup keys on content_hash, so it now actually removes the blob cache of deleted targets. The blobs are a re-creatable cache.
The upload handler reads the file once more to hash it (up to 512 MiB). Hashing while streaming would be a possible follow-up.
Tests
New tests/upload_change.rs (Mongo; run against a capped mongo:7) runs the real upload API: upload A, which stores sha256(A). The same files with a completed scan of A are unchanged (scheduled skip allowed). Upload B to the same target: not unchanged. A removed and only B left: not unchanged. Written first; it failed on main (content_hash was None).
Also re-run: tests/archive_password.rs (2 passed), scan_gate and pipeline::change lib tests (9 passed). cargo fmt --all --check and cargo clippy -p compliance-agent --all-targets -- -D warnings are clean.
Not covered by a test: the orchestrator end to end (run_target writing last_scan with the hash, and the backfill). Both are verified by reading only.
Stage re-test
Open an existing Prüfobjekt with an uploaded archive, go to Bearbeiten and upload a ZIP with different content, then click Prüfung starten. The run goes through all phases, and Nicht ausgeführt has no Änderungserkennung.
Upload another, different ZIP and do not click anything. The next scheduled run (6-hourly) scans in full.
Change nothing. The scheduled run after that lists Änderungserkennung under Nicht ausgeführt ("Die hochgeladenen Dateien und die Prüfwerk-Version sind … unverändert").
A Prüfobjekt uploaded before this deploy: its first two scheduled runs scan, the third skips.
Added after the stage logs (SigNoz, 2026-10-07): the skip seen on stage was the git path. A ZIP had been uploaded to the git-created target bp-test/dotnet-fixture, and the scheduled run skipped with "No new commits". Changes in this commit:
A git target with a file uploaded since its last completed scan is no longer skipped for "no new commits".
An archive uploaded to a git target is listed under Nicht ausgeführt (DE/EN): the code scan reads the repository only, so the archive must be uploaded as a target of its own. Scanning both trees in one run is a follow-up.
UPLOAD_CHANGE_SKIP=false turns the skipping of unchanged uploads off. It is on by default, as the user decided for the 2026-10-09 promotion.
Stage re-test (git target): upload a ZIP to a git-created Prüfobjekt. The next scheduled run is not skipped, and Nicht ausgeführt names the archive as not scanned.
## What was wrong
The #465 change key for uploaded files (`pipeline/change.rs::upload_inputs`) is a digest of each upload's artifact id and `content_hash`. Nothing ever stored `content_hash` on an uploaded artifact: `upload_artifact` sets only `stored_path` and `size_bytes`, and ingest hashes the blob into `IngestedArtifact` but never persists the hash. So the key never described the bytes that were actually uploaded.
**I could not reproduce the stage symptom from the code.** On `origin/main`, with every upload hash `None`, `upload_inputs` returns `None` and `upload_unchanged` can never return `true`, so "Uploaded files unchanged, skipping scan" cannot come from this path as main stands. Either stage runs a build that differs from main, or the skip that was seen came from a different run. This PR makes the comparison what #465 intended: the bytes uploaded now against the bytes the last completed scan read. It does not claim to explain the stage observation.
The other things I checked:
- The baseline (`last_scan`) is written only when a scan completes, and from the target snapshot that scan started with. Neither the upload handler nor `/detect` touches it, so an upload that lands during a scan is not recorded as scanned.
- An upload does not start a scan by itself. The dashboard's "Prüfung starten" sends `Manual`, which always scans. One gap remained in the scan gate: when a scheduled/webhook follow-up was already pending, a person's request was dropped, leaving the skip-eligible follow-up in place. That is fixed here.
## What changed
- **Upload** (`api/handlers/onboarding.rs`): stores the sha256 of the uploaded bytes on the artifact (`content_hash`).
- **Scan** (`orchestrator.rs::record_upload_hashes`, `change::unrecorded_hashes`): an older upload without a hash gets the sha256 that ingest computed. Existing targets therefore become comparable: their next two scheduled runs scan, and from the third on an unchanged target skips.
- **Scan gate** (`scan_gate.rs`): a person's request (Manual/Support) takes over a pending Scheduled/Webhook follow-up instead of being dropped.
- Docs: `docs/guide/scanning.md` says uploads are compared by SHA-256.
## Behaviour to be aware of (decision for the promotion)
- On main the upload skip never fired, so scheduled runs of upload targets always scanned and always counted as usage. After this PR, upload targets that do not change **start skipping scheduled runs** and emit no `scan.completed` usage. This is #465's documented intent, but in practice it is new.
- Re-uploading identical bytes creates a new artifact (new id), and that counts as a change: it scans again.
- A known gap that this PR does not widen to cover: a password-protected `PlcProject` whose password is missing still completes its run (the PLC stage passes over it). Entering the password later does not change the key, so scheduled runs skip until someone clicks **Prüfung starten**.
- `retention.rs` blob cleanup keys on `content_hash`, so it now actually removes the blob cache of deleted targets. The blobs are a re-creatable cache.
- The upload handler reads the file once more to hash it (up to 512 MiB). Hashing while streaming would be a possible follow-up.
## Tests
- New `tests/upload_change.rs` (Mongo; run against a capped `mongo:7`) runs the real upload API: upload A, which stores sha256(A). The same files with a completed scan of A are unchanged (scheduled skip allowed). Upload B to the same target: not unchanged. A removed and only B left: not unchanged. Written first; it failed on main (`content_hash` was `None`).
- `pipeline::change::tests::only_uploads_without_a_hash_take_the_one_ingest_computed`
- `scan_gate::tests::a_persons_request_takes_over_a_pending_scheduled_follow_up`
- Also re-run: `tests/archive_password.rs` (2 passed), `scan_gate` and `pipeline::change` lib tests (9 passed). `cargo fmt --all --check` and `cargo clippy -p compliance-agent --all-targets -- -D warnings` are clean.
- Not covered by a test: the orchestrator end to end (`run_target` writing `last_scan` with the hash, and the backfill). Both are verified by reading only.
## Stage re-test
1. Open an existing Prüfobjekt with an uploaded archive, go to **Bearbeiten** and upload a ZIP with different content, then click **Prüfung starten**. The run goes through all phases, and **Nicht ausgeführt** has no **Änderungserkennung**.
2. Upload another, different ZIP and do not click anything. The next scheduled run (6-hourly) scans in full.
3. Change nothing. The scheduled run after that lists **Änderungserkennung** under **Nicht ausgeführt** ("Die hochgeladenen Dateien und die Prüfwerk-Version sind … unverändert").
4. A Prüfobjekt uploaded before this deploy: its first two scheduled runs scan, the third skips.
---
**Added after the stage logs (SigNoz, 2026-10-07):** the skip seen on stage was the **git** path. A ZIP had been uploaded to the git-created target bp-test/dotnet-fixture, and the scheduled run skipped with "No new commits". Changes in this commit:
- A git target with a file uploaded since its last completed scan is no longer skipped for "no new commits".
- An archive uploaded to a git target is listed under **Nicht ausgeführt** (DE/EN): the code scan reads the repository only, so the archive must be uploaded as a target of its own. Scanning both trees in one run is a follow-up.
- `UPLOAD_CHANGE_SKIP=false` turns the skipping of unchanged uploads off. It is on by default, as the user decided for the 2026-10-09 promotion.
**Stage re-test (git target):** upload a ZIP to a git-created Prüfobjekt. The next scheduled run is not skipped, and **Nicht ausgeführt** names the archive as not scanned.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
#465's change key for uploaded files is a digest of each upload's
artifact id and content_hash, but nothing ever stored content_hash on an
uploaded artifact (ingest hashed the blob and dropped it). So the key
never described the files actually uploaded.
- the upload handler stores the sha256 of the uploaded bytes on the
artifact
- a scan stores the sha256 ingest computed on older uploads that have
none, so existing targets become comparable (a scheduled run skips from the third scan on)
- a person's scan request takes over a pending scheduled/webhook
follow-up in the scan gate instead of being dropped, so "Prüfung
starten" right after an upload always scans in full
Unchanged scheduled rescans still skip (identical uploads, same build).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Stage: a ZIP uploaded to a git-created target was followed by a scheduled
run that skipped with "no new commits" (the git path), so the new upload
seemed ignored. It was: the code scan reads the repository only.
- A git target with a file uploaded since its last completed scan is not
skipped for "no new commits"; with no uploads nothing changes.
- An archive uploaded to a git target is listed under "Nicht ausgeführt"
as not scanned (upload it as a target of its own), in DE and EN.
- UPLOAD_CHANGE_SKIP=false turns the skipping of unchanged uploads off
(on by default).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang
merged commit a22b4497a5 into main2026-10-08 21:45:33 +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.
What was wrong
The #465 change key for uploaded files (
pipeline/change.rs::upload_inputs) is a digest of each upload's artifact id andcontent_hash. Nothing ever storedcontent_hashon an uploaded artifact:upload_artifactsets onlystored_pathandsize_bytes, and ingest hashes the blob intoIngestedArtifactbut never persists the hash. So the key never described the bytes that were actually uploaded.I could not reproduce the stage symptom from the code. On
origin/main, with every upload hashNone,upload_inputsreturnsNoneandupload_unchangedcan never returntrue, so "Uploaded files unchanged, skipping scan" cannot come from this path as main stands. Either stage runs a build that differs from main, or the skip that was seen came from a different run. This PR makes the comparison what #465 intended: the bytes uploaded now against the bytes the last completed scan read. It does not claim to explain the stage observation.The other things I checked:
last_scan) is written only when a scan completes, and from the target snapshot that scan started with. Neither the upload handler nor/detecttouches it, so an upload that lands during a scan is not recorded as scanned.Manual, which always scans. One gap remained in the scan gate: when a scheduled/webhook follow-up was already pending, a person's request was dropped, leaving the skip-eligible follow-up in place. That is fixed here.What changed
api/handlers/onboarding.rs): stores the sha256 of the uploaded bytes on the artifact (content_hash).orchestrator.rs::record_upload_hashes,change::unrecorded_hashes): an older upload without a hash gets the sha256 that ingest computed. Existing targets therefore become comparable: their next two scheduled runs scan, and from the third on an unchanged target skips.scan_gate.rs): a person's request (Manual/Support) takes over a pending Scheduled/Webhook follow-up instead of being dropped.docs/guide/scanning.mdsays uploads are compared by SHA-256.Behaviour to be aware of (decision for the promotion)
scan.completedusage. This is #465's documented intent, but in practice it is new.PlcProjectwhose password is missing still completes its run (the PLC stage passes over it). Entering the password later does not change the key, so scheduled runs skip until someone clicks Prüfung starten.retention.rsblob cleanup keys oncontent_hash, so it now actually removes the blob cache of deleted targets. The blobs are a re-creatable cache.Tests
tests/upload_change.rs(Mongo; run against a cappedmongo:7) runs the real upload API: upload A, which stores sha256(A). The same files with a completed scan of A are unchanged (scheduled skip allowed). Upload B to the same target: not unchanged. A removed and only B left: not unchanged. Written first; it failed on main (content_hashwasNone).pipeline::change::tests::only_uploads_without_a_hash_take_the_one_ingest_computedscan_gate::tests::a_persons_request_takes_over_a_pending_scheduled_follow_uptests/archive_password.rs(2 passed),scan_gateandpipeline::changelib tests (9 passed).cargo fmt --all --checkandcargo clippy -p compliance-agent --all-targets -- -D warningsare clean.run_targetwritinglast_scanwith the hash, and the backfill). Both are verified by reading only.Stage re-test
Added after the stage logs (SigNoz, 2026-10-07): the skip seen on stage was the git path. A ZIP had been uploaded to the git-created target bp-test/dotnet-fixture, and the scheduled run skipped with "No new commits". Changes in this commit:
UPLOAD_CHANGE_SKIP=falseturns the skipping of unchanged uploads off. It is on by default, as the user decided for the 2026-10-09 promotion.Stage re-test (git target): upload a ZIP to a git-created Prüfobjekt. The next scheduled run is not skipped, and Nicht ausgeführt names the archive as not scanned.
🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p