fix(api): cap silent auto-assignment candidate size (Holger bulk incident) #892

Merged
chris merged 2 commits from hotfix/silent-auto-action-size-cap into main 2026-09-26 21:11:27 +02:00
Owner

Incident (prod, 2026-09-26 18:49)

After a 2190-face stash was disbanded, the next recognition run re-formed the identical DBSCAN density-chained blob as one new_person_cluster candidate. Spec 047's new medium tier (auto_assigned_named_target_medium_band) then silently assigned all 2190 faces to named person "Holger" (0ec6cd50-6fda-4b5a-8990-dcc24e7ebe37) because:

  • the consensus check only tests the candidate's best face (trivially satisfied against a 310-face core), and
  • no size limit existed on silent automatic actions.

Fix

persistWorkerCandidates now computes occurrenceRefs.size() <= SILENT_ACTION_MAX_CANDIDATE_FACES once per candidate, before any band/consensus/embedding work (cheap first), and every silent automatic action skips oversized candidates:

path action
named medium tier, policy branch auto_assigned_named_target_medium_band
named medium tier, embedding-match branch auto_assigned_named_target_medium_band
stash absorption (spec 047 band+consensus gate) auto_accepted_stashed_target
strong-band auto-accept, policy branch auto_accepted_existing_instance_candidate
strong-band embedding match auto_accepted_existing_instance_candidate

Semantics: an oversized candidate is not rejected — it stays PENDING and surfaces as a regular suggestion card for explicit owner review. Explicit owner decisions (decideCandidate / acceptCandidateForExistingInstance) are never capped.

Cap value: 25 (code constant, no migration)

Checked discovery_domains up to the latest migration V140 (re-checked on origin/main per ISSUE-071): no column fits the knob (embedding_matching_max_results is a match-result limit, not a face-count cap), so SILENT_ACTION_MAX_CANDIDATE_FACES = 25 is a named constant with a comment referencing this incident. No migration added.

Tests

  • PG Spec047SilentActionCapPostgresTest (5 tests): a 60-face candidate in-band with a consensus-satisfying target stays PENDING with zero occurrences / no review decision on all four silent paths; below-cap 3-face control still auto-assigns. Verified red before the fix (the 4 oversized tests fail on unpatched code) and green after.
  • H2 ClassInstanceDiscoveryServiceTest: oversized 26-face candidate stays pending on medium/stash/strong paths; below-cap control still auto-assigns.

Validation

  • rtk ./gradlew :apps:api:test --no-daemon: BUILD SUCCESSFUL — 122 test classes, 1252 tests, 0 failures, 0 errors, 9 skipped (includes both new test classes and the full Testcontainers suite).
  • No ci/*-api-verify verification-branch workflow exists in .forgejo/workflows on main; the PR lane's scoped detection marks apps/api/* as run_api_tests, so CI runs the full API suite for this PR.

Refs: spec 047. KNOWN_ISSUES entry added in a follow-up commit.

## Incident (prod, 2026-09-26 18:49) After a 2190-face stash was disbanded, the next recognition run re-formed the identical DBSCAN density-chained blob as one `new_person_cluster` candidate. Spec 047's new medium tier (`auto_assigned_named_target_medium_band`) then silently assigned **all 2190 faces** to named person "Holger" (`0ec6cd50-6fda-4b5a-8990-dcc24e7ebe37`) because: - the consensus check only tests the candidate's **best face** (trivially satisfied against a 310-face core), and - no size limit existed on silent automatic actions. ## Fix `persistWorkerCandidates` now computes `occurrenceRefs.size() <= SILENT_ACTION_MAX_CANDIDATE_FACES` once per candidate, **before any band/consensus/embedding work** (cheap first), and every silent automatic action skips oversized candidates: | path | action | |---|---| | named medium tier, policy branch | `auto_assigned_named_target_medium_band` | | named medium tier, embedding-match branch | `auto_assigned_named_target_medium_band` | | stash absorption (spec 047 band+consensus gate) | `auto_accepted_stashed_target` | | strong-band auto-accept, policy branch | `auto_accepted_existing_instance_candidate` | | strong-band embedding match | `auto_accepted_existing_instance_candidate` | Semantics: an oversized candidate is **not rejected** — it stays PENDING and surfaces as a regular suggestion card for explicit owner review. Explicit owner decisions (`decideCandidate` / `acceptCandidateForExistingInstance`) are never capped. ## Cap value: 25 (code constant, no migration) Checked `discovery_domains` up to the latest migration **V140** (re-checked on origin/main per ISSUE-071): no column fits the knob (`embedding_matching_max_results` is a match-result limit, not a face-count cap), so `SILENT_ACTION_MAX_CANDIDATE_FACES = 25` is a named constant with a comment referencing this incident. No migration added. ## Tests - **PG** `Spec047SilentActionCapPostgresTest` (5 tests): a 60-face candidate in-band with a consensus-satisfying target stays PENDING with zero occurrences / no review decision on all four silent paths; below-cap 3-face control still auto-assigns. Verified **red before the fix** (the 4 oversized tests fail on unpatched code) and green after. - **H2** `ClassInstanceDiscoveryServiceTest`: oversized 26-face candidate stays pending on medium/stash/strong paths; below-cap control still auto-assigns. ## Validation - `rtk ./gradlew :apps:api:test --no-daemon`: **BUILD SUCCESSFUL** — 122 test classes, 1252 tests, 0 failures, 0 errors, 9 skipped (includes both new test classes and the full Testcontainers suite). - No `ci/*-api-verify` verification-branch workflow exists in `.forgejo/workflows` on main; the PR lane's scoped detection marks `apps/api/*` as `run_api_tests`, so CI runs the full API suite for this PR. Refs: spec 047. KNOWN_ISSUES entry added in a follow-up commit.
fix(api): cap silent auto-assignment candidate size (Holger bulk incident)
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 4s
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 8m6s
f9b0c062e9
2026-09-26 prod incident: after disbanding a 2190-face stash, the next
recognition run re-formed the identical DBSCAN density-chained blob as one
new_person_cluster candidate and spec 047's medium tier silently assigned
all 2190 faces to named person "Holger": the consensus gate only uses the
candidate's BEST face (trivially satisfied against a 310-face core) and no
size limit capped silent automatic actions.

Every silent automatic action in persistWorkerCandidates now requires
occurrence_refs.size() <= SILENT_ACTION_MAX_CANDIDATE_FACES (25), checked
before any band/consensus/embedding work:
- named-target medium tier (policy + embedding-match branches)
- stash silent absorption (spec 047 band+consensus gate)
- strong-band auto-accept (shouldAutoAcceptExistingInstance + embedding)

Oversized candidates stay PENDING as regular suggestion cards (never
rejected); explicit owner decisions (decideCandidate /
acceptCandidateForExistingInstance) are never capped. No discovery_domains
column fits the knob and no migration is added (latest migration V140,
re-checked on origin/main per ISSUE-071).

Tests: Spec047SilentActionCapPostgresTest (5 PG tests: 60-face candidate
stays pending with zero occurrences on all four silent paths; below-cap
control still auto-assigns) + H2 parity in ClassInstanceDiscoveryServiceTest
(oversized 26-face candidate pending on medium/stash/strong paths; below-cap
control still auto-assigns). All 1252 API tests green locally.
docs: track Holger bulk-assignment incident as ISSUE-074 [PR#892]
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 7m52s
3942fa2491
chris merged commit 18f84deaaf into main 2026-09-26 21:11:27 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!892
No description provided.