fix(people): resolve stash-away on stale suggestion cards (ISSUE-090) #1002

Merged
chris merged 2 commits from fix/stash-away-already-assigned into main 2026-10-03 14:48:20 +02:00
Owner

Problem

"Stash away" in the people suggestions carousel failed with:

409 Request conflicts with current state: Candidate changed while accepting; decision was not applied

The stash is insert-only by design (spec 045 / ADR 0097: a stash never steals a face). When every ref of a candidate was already occupied by a live occurrence (state IN ('accepted','tentative')), the accept unit legitimately wrote 0 occurrences, and the requireOccurrenceWrites guard (acceptedOccurrences == 0 && !refs.isEmpty()) turned that into a hard failure.

The carousel only hides the stashed-shadow variant of such cards, so a stale card stayed visible with a permanently unusable button.

Fix

New CandidateDecisionContext.resolveFullyAssignedAsRejected flag, set only at the stashed call site — automated/auto-accept paths are untouched.

When a card's refs are all occupied by another decision, the accept unit resolves it before the target resolver runs, so no empty shadow person is minted:

  • candidate state → rejected
  • review decision → sourceType=owner_action, action=stashed, decision=all_faces_already_assigned, real actor
  • caller-supplied detail fields preserved; authoritative fields written last so a client cannot spoof them (test covers this)
  • response → state rejected, classInstanceId: null (frontend already accepts this)

Invariant safety — this path only ever writes

No ownership is ever removed or moved. rejectPendingCandidate and afterRejection are deliberately not called.

  • Occupancy owned by the candidate itself does not qualify. A spec 050 backing card holds its own refs via candidate_id; a mixed own/foreign card likewise. Those keep the pre-existing 409, stay pending, and leave their allocation and review trail byte-identical (verified with transactional rollback).
  • Occurrence identity matches the write path exactly — occurrenceType() + the face-branch key of insertOneOccurrence. So the check cannot disagree with the conflict it exists for: a generic_evidence ref carrying a known faceAnnotationId is recognised as the face occurrence it becomes.
  • Fails open. A ref whose identity cannot be resolved that way returns false → pre-existing conflict is reported, rather than risking a wrong rejection.
  • Zero-row transition → null, i.e. a genuine "candidate changed" conflict, never a silent success.
  • Partially-assigned cards keep the real stash — only unassigned faces land on the new shadow.

Tests

267 targeted tests green (229 discovery H2 + 7 Spec045 PostgreSQL + 31 Spec050 PostgreSQL), including:

  • stashAwayResolvesSuggestionCardWhoseFacesAreAlreadyAssignedElsewhere — production repro; carousel card leaves the list, no shadow minted, audit override + actor asserted
  • stashAwayOnBackingCardPreservesItsOwnTentativeAllocation / stashAwayOnMixedOwnAndForeignOccupiedCardPreservesAllAllocations — 409 retained, pending state, allocations untouched, no review decision
  • stashOnOwnBackingCardRollsBackWithoutChangingOwnershipOrCreatingShadow / ...MixedOwnAndForeign... — PostgreSQL, full-row comparison across rollback
  • stashAwayResolvesGenericEvidenceRefThatResolvesToAnOccupiedFace — identity parity with the writer
  • stashAwayStillAcceptsOwnUnassignedFacesAlongsideAssignedOnes — partial overlap keeps the real stash
  • stashDecisionDoesNotStealLiveAcceptedFaceOnH2 / Spec045StashTentativePostgresTest — no-steal guarantee

Full :apps:api:test result recorded in the PR comments before merge.

Scope note

Also records ISSUE-091 (med, open, area:ci): while verifying this PR I found that scoped PR tests silently skip all JVM tests whenever detect-scopes.sh's catch-all sets run_fallback_smoke, because build-deploy.yml gates the "Run API tests" step on it while the fallback only compiles. Not fixed here — tracked separately.

Refs ISSUE-090.

## Problem "Stash away" in the people suggestions carousel failed with: ``` 409 Request conflicts with current state: Candidate changed while accepting; decision was not applied ``` The stash is **insert-only by design** (spec 045 / ADR 0097: a stash never steals a face). When every ref of a candidate was already occupied by a live occurrence (`state IN ('accepted','tentative')`), the accept unit legitimately wrote **0 occurrences**, and the `requireOccurrenceWrites` guard (`acceptedOccurrences == 0 && !refs.isEmpty()`) turned that into a hard failure. The carousel only hides the *stashed-shadow* variant of such cards, so a stale card stayed visible with a permanently unusable button. ## Fix New `CandidateDecisionContext.resolveFullyAssignedAsRejected` flag, set **only** at the `stashed` call site — automated/auto-accept paths are untouched. When a card's refs are **all occupied by another decision**, the accept unit resolves it before the target resolver runs, so no empty shadow person is minted: - candidate state → `rejected` - review decision → `sourceType=owner_action`, `action=stashed`, `decision=all_faces_already_assigned`, real actor - caller-supplied detail fields preserved; authoritative fields written **last** so a client cannot spoof them (test covers this) - response → state `rejected`, `classInstanceId: null` (frontend already accepts this) ### Invariant safety — this path only ever writes **No ownership is ever removed or moved.** `rejectPendingCandidate` and `afterRejection` are deliberately *not* called. - **Occupancy owned by the candidate itself does not qualify.** A spec 050 backing card holds its own refs via `candidate_id`; a mixed own/foreign card likewise. Those keep the pre-existing 409, stay pending, and leave their allocation and review trail byte-identical (verified with transactional rollback). - **Occurrence identity matches the write path exactly** — `occurrenceType()` + the face-branch key of `insertOneOccurrence`. So the check cannot disagree with the conflict it exists for: a `generic_evidence` ref carrying a known `faceAnnotationId` is recognised as the face occurrence it becomes. - **Fails open.** A ref whose identity cannot be resolved that way returns `false` → pre-existing conflict is reported, rather than risking a wrong rejection. - **Zero-row transition → `null`**, i.e. a genuine "candidate changed" conflict, never a silent success. - **Partially-assigned cards keep the real stash** — only unassigned faces land on the new shadow. ## Tests **267 targeted tests green** (229 discovery H2 + 7 Spec045 PostgreSQL + 31 Spec050 PostgreSQL), including: - `stashAwayResolvesSuggestionCardWhoseFacesAreAlreadyAssignedElsewhere` — production repro; carousel card leaves the list, no shadow minted, audit override + actor asserted - `stashAwayOnBackingCardPreservesItsOwnTentativeAllocation` / `stashAwayOnMixedOwnAndForeignOccupiedCardPreservesAllAllocations` — 409 retained, pending state, allocations untouched, no review decision - `stashOnOwnBackingCardRollsBackWithoutChangingOwnershipOrCreatingShadow` / `...MixedOwnAndForeign...` — PostgreSQL, full-row comparison across rollback - `stashAwayResolvesGenericEvidenceRefThatResolvesToAnOccupiedFace` — identity parity with the writer - `stashAwayStillAcceptsOwnUnassignedFacesAlongsideAssignedOnes` — partial overlap keeps the real stash - `stashDecisionDoesNotStealLiveAcceptedFaceOnH2` / `Spec045StashTentativePostgresTest` — no-steal guarantee Full `:apps:api:test` result recorded in the PR comments before merge. ## Scope note Also records **ISSUE-091** (`med`, `open`, `area:ci`): while verifying this PR I found that scoped PR tests silently skip *all* JVM tests whenever `detect-scopes.sh`'s catch-all sets `run_fallback_smoke`, because `build-deploy.yml` gates the "Run API tests" step on it while the fallback only compiles. Not fixed here — tracked separately. Refs ISSUE-090.
fix(people): resolve stash-away on fully-occupied suggestion cards (ISSUE-090)
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 2s
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 1m34s
a28f69b370
"Stash away" in the people suggestions carousel failed with 409
"Candidate changed while accepting; decision was not applied".

The stash is insert-only by design (spec 045 / ADR 0097: a stash never
steals a face). When every ref of a candidate already held a live
occurrence, the accept unit legitimately wrote 0 occurrences, and the
requireOccurrenceWrites guard turned that into a hard failure. The
carousel only hides the stashed-shadow variant of such cards, so the card
stayed visible with a permanently unusable button.

An insert-only owner decision now resolves a fully-occupied card as
already-handled (candidate state rejected, review decision
action=stashed + decision=all_faces_already_assigned +
releasedCardAllocations) before the target resolver runs, so no empty
shadow person is minted and the card leaves the carousel.

- Occurrence identity is resolved exactly as the write path resolves it
  (occurrenceType() + the face-branch key of insertOneOccurrence), so the
  check can never disagree with the insert-only conflict it exists for; a
  ref that cannot be resolved that way fails open to the previous
  conflict rather than risking a wrong rejection.
- Rejecting a spec 050 backing card releases only that card's own
  tentative allocation (afterRejection supersedes candidate_id-matching
  rows only); foreign assignments are never touched and no face is
  re-homed, so the no-steal invariant is unchanged.
- Partially-assigned cards keep the real stash: only unassigned faces
  land on the new shadow.

Tests: H2 + PostgreSQL coverage for the stale card, the no-steal
guarantee, the backing-card allocation release, generic_evidence ref
parity and the partial-overlap path. Full :apps:api:test green (1491).
chris force-pushed fix/stash-away-already-assigned from a28f69b370
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 2s
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 1m34s
to 7c4ec643a2
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 2s
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 1m32s
2026-10-03 13:51:03 +02:00
Compare
chris force-pushed fix/stash-away-already-assigned from 7c4ec643a2
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 2s
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 1m32s
to ba50998180
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 2s
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 7m5s
2026-10-03 13:56:00 +02:00
Compare
chris force-pushed fix/stash-away-already-assigned from ba50998180
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 2s
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 7m5s
to 5a17bd35b7
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 2s
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 7m5s
2026-10-03 14:29:01 +02:00
Compare
chris changed title from fix(people): resolve stash-away on fully-occupied suggestion cards (ISSUE-090) to fix(people): resolve stash-away on stale suggestion cards (ISSUE-090) 2026-10-03 14:29:08 +02:00
Merge remote-tracking branch 'origin/main' into fix/stash-away-already-assigned
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 2s
Build and Deploy / Build postgres image (push) Has been skipped
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 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 7m51s
3ed86faa11
chris merged commit cdc3a52384 into main 2026-10-03 14:48:20 +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!1002
No description provided.