Follow-up to #538: the managed Gitea source webhook answers 202 and decides about entitlement in the background, so Gitea's delivery log shows success even when the work was refused. The refusal was only in the agent log.
What
Record: every verified delivery that asks for work is stored as a WebhookDelivery (compliance-core): received_at, receiver, event, result handled | refused | failed, detail (the reason, clipped to 300 chars), elapsed_ms, target_id when known, source_repo (base_url + repo_id) for managed-source deliveries.
gitea_source: process() now returns a typed NotHandled::{Refused, Failed}; the background task records the outcome after logging it. Deliveries the router ignores (other org, other branch) are not recorded: a system webhook sees the whole instance.
per-target github / gitlab / gitea receivers: cheap and consistent, so they record the push (scan queued) or PR/MR review they queue, with the target id. The scan itself shows in the scan runs as before.
Writing never fails the webhook: errors are logged (webhooks::deliveries::record).
Read: GET /api/v1/targets/{id}/webhook-deliveries (tenant-scoped like the other target endpoints), newest 20.
Show: a "Webhook-Zustellungen / Webhook deliveries" box on the target page, result badge (green/amber/red), time, event, reason, ms; texts DE/EN.
Target resolution for refusals before the target exists
An entitlement refusal happens before ensure_target, so it has no target id. Instead of resolving the target at write time, a managed-source delivery always carries its repository (source_repo.base_url + source_repo.repo_id, the same key ensure_target/archive_target use), and the target page queries target_id = id OR (source_repo matches the target's). So a refusal for an existing managed target shows on it, and one for a repository that has no target yet shows on that target as soon as the sync creates it. No separate tenant-level record needed.
Why a capped per-tenant collection (not an array on the target doc)
A refusal before the target exists has no document to $push onto; the collection needs none.
The target doc is read by every target list/detail call; 20 deliveries per target would ride along everywhere.
One insert per delivery, Mongo drops the oldest. Cap: 1000 documents / 2 MiB per tenant (the doc cap bites; a delivery is well under 1 KiB), i.e. the last 20 for 50 busy targets. Trade-off: a very noisy repository can push a quiet target's old deliveries out; acceptable for a "recent deliveries" box.
Created in ensure_indexes (capped first, then indexes {target_id, received_at} and {source_repo.base_url, source_repo.repo_id, received_at}). If a plain collection already exists (an insert raced the first ensure), it is converted with convertToCapped (size-bounded only).
compliance-agent tests/git_source.rs (Mongo): platform_api_webhook_and_sync now polls until the three created deliveries are recorded as handled for the target, asserts the collection is capped, and that the deletion (no target id) matches by repository; new a_plain_deliveries_collection_becomes_capped. tests/credentials.rs still passes.
Follow-up to #538: the managed Gitea source webhook answers `202` and decides about entitlement in the background, so Gitea's delivery log shows success even when the work was refused. The refusal was only in the agent log.
## What
- **Record**: every verified delivery that asks for work is stored as a `WebhookDelivery` (compliance-core): received_at, receiver, event, result `handled | refused | failed`, detail (the reason, clipped to 300 chars), elapsed_ms, `target_id` when known, `source_repo` (base_url + repo_id) for managed-source deliveries.
- `gitea_source`: `process()` now returns a typed `NotHandled::{Refused, Failed}`; the background task records the outcome after logging it. Deliveries the router ignores (other org, other branch) are not recorded: a system webhook sees the whole instance.
- per-target `github` / `gitlab` / `gitea` receivers: cheap and consistent, so they record the push (`scan queued`) or PR/MR review they queue, with the target id. The scan itself shows in the scan runs as before.
- Writing never fails the webhook: errors are logged (`webhooks::deliveries::record`).
- **Read**: `GET /api/v1/targets/{id}/webhook-deliveries` (tenant-scoped like the other target endpoints), newest 20.
- **Show**: a "Webhook-Zustellungen / Webhook deliveries" box on the target page, result badge (green/amber/red), time, event, reason, ms; texts DE/EN.
## Target resolution for refusals before the target exists
An entitlement refusal happens before `ensure_target`, so it has no target id. Instead of resolving the target at write time, a managed-source delivery always carries its repository (`source_repo.base_url` + `source_repo.repo_id`, the same key `ensure_target`/`archive_target` use), and the target page queries `target_id = id OR (source_repo matches the target's)`. So a refusal for an existing managed target shows on it, and one for a repository that has no target yet shows on that target as soon as the sync creates it. No separate tenant-level record needed.
## Why a capped per-tenant collection (not an array on the target doc)
- A refusal before the target exists has no document to `$push` onto; the collection needs none.
- The target doc is read by every target list/detail call; 20 deliveries per target would ride along everywhere.
- One insert per delivery, Mongo drops the oldest. Cap: 1000 documents / 2 MiB per tenant (the doc cap bites; a delivery is well under 1 KiB), i.e. the last 20 for 50 busy targets. Trade-off: a very noisy repository can push a quiet target's old deliveries out; acceptable for a "recent deliveries" box.
- Created in `ensure_indexes` (capped first, then indexes `{target_id, received_at}` and `{source_repo.base_url, source_repo.repo_id, received_at}`). If a plain collection already exists (an insert raced the first ensure), it is converted with `convertToCapped` (size-bounded only).
## Tests
- compliance-core: `a_short_detail_is_kept_as_is`, `a_long_detail_is_clipped_on_a_character_boundary`, `results_are_snake_case_and_round_trip`
- compliance-agent lib: `a_refusal_is_recorded_with_its_reason_and_no_target`, `a_failure_and_the_handled_outcomes_are_recorded`, `a_refusal_reads_as_one_in_the_log`, `a_queued_delivery_is_handled_for_its_target`, `a_plain_target_matches_by_id_only`, `a_managed_target_also_matches_its_repository`, `an_action_names_its_repository_unless_ignored`
- compliance-agent `tests/git_source.rs` (Mongo): `platform_api_webhook_and_sync` now polls until the three `created` deliveries are recorded as handled for the target, asserts the collection is capped, and that the deletion (no target id) matches by repository; new `a_plain_deliveries_collection_becomes_capped`. `tests/credentials.rs` still passes.
- compliance-dashboard: `each_result_has_its_badge_in_both_languages`
- clippy (CI flags) for core, agent, dashboard server+web, mcp; `cargo fmt --check`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
The managed Gitea source webhook answers 202 and decides about entitlement
in the background, so Gitea's delivery log cannot tell a refused delivery
from a handled one. Every verified delivery that asks for work is now
recorded (time, event, handled/refused/failed with the reason, elapsed ms)
in a capped per-tenant collection, read by a new
GET /api/v1/targets/{id}/webhook-deliveries and shown in a box on the
target page.
A managed-source delivery carries its repository (base_url + repo_id), so
one refused before its target exists still shows on the target once the
sync creates it. The per-target GitHub/GitLab/Gitea receivers record the
push or PR review they queue. Recording never fails a webhook; errors are
logged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
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.
Follow-up to #538: the managed Gitea source webhook answers
202and decides about entitlement in the background, so Gitea's delivery log shows success even when the work was refused. The refusal was only in the agent log.What
WebhookDelivery(compliance-core): received_at, receiver, event, resulthandled | refused | failed, detail (the reason, clipped to 300 chars), elapsed_ms,target_idwhen known,source_repo(base_url + repo_id) for managed-source deliveries.gitea_source:process()now returns a typedNotHandled::{Refused, Failed}; the background task records the outcome after logging it. Deliveries the router ignores (other org, other branch) are not recorded: a system webhook sees the whole instance.github/gitlab/giteareceivers: cheap and consistent, so they record the push (scan queued) or PR/MR review they queue, with the target id. The scan itself shows in the scan runs as before.webhooks::deliveries::record).GET /api/v1/targets/{id}/webhook-deliveries(tenant-scoped like the other target endpoints), newest 20.Target resolution for refusals before the target exists
An entitlement refusal happens before
ensure_target, so it has no target id. Instead of resolving the target at write time, a managed-source delivery always carries its repository (source_repo.base_url+source_repo.repo_id, the same keyensure_target/archive_targetuse), and the target page queriestarget_id = id OR (source_repo matches the target's). So a refusal for an existing managed target shows on it, and one for a repository that has no target yet shows on that target as soon as the sync creates it. No separate tenant-level record needed.Why a capped per-tenant collection (not an array on the target doc)
$pushonto; the collection needs none.ensure_indexes(capped first, then indexes{target_id, received_at}and{source_repo.base_url, source_repo.repo_id, received_at}). If a plain collection already exists (an insert raced the first ensure), it is converted withconvertToCapped(size-bounded only).Tests
a_short_detail_is_kept_as_is,a_long_detail_is_clipped_on_a_character_boundary,results_are_snake_case_and_round_tripa_refusal_is_recorded_with_its_reason_and_no_target,a_failure_and_the_handled_outcomes_are_recorded,a_refusal_reads_as_one_in_the_log,a_queued_delivery_is_handled_for_its_target,a_plain_target_matches_by_id_only,a_managed_target_also_matches_its_repository,an_action_names_its_repository_unless_ignoredtests/git_source.rs(Mongo):platform_api_webhook_and_syncnow polls until the threecreateddeliveries are recorded as handled for the target, asserts the collection is capped, and that the deletion (no target id) matches by repository; newa_plain_deliveries_collection_becomes_capped.tests/credentials.rsstill passes.each_result_has_its_badge_in_both_languagescargo fmt --check.🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
The managed Gitea source webhook answers 202 and decides about entitlement in the background, so Gitea's delivery log cannot tell a refused delivery from a handled one. Every verified delivery that asks for work is now recorded (time, event, handled/refused/failed with the reason, elapsed ms) in a capped per-tenant collection, read by a new GET /api/v1/targets/{id}/webhook-deliveries and shown in a box on the target page. A managed-source delivery carries its repository (base_url + repo_id), so one refused before its target exists still shows on the target once the sync creates it. The per-target GitHub/GitLab/Gitea receivers record the push or PR review they queue. Recording never fails a webhook; errors are logged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p1551f232fbto66f96695ba