feat(form-builder): FORM-02 TAG_PICKER sync listener (ARCH §31.10)

Rebuilds the tag-sync flow purged in S2a, now listener-driven against the
universal FormBuilder (ARCH §31.10).

- SyncTagPickerSelectionsOnSubmit listener: ShouldQueue on connection=redis
  queue=default. Filters to event_registration + person subjects with at
  least one TAG_PICKER form_value. Logs on failure, never rethrows so
  sibling listeners keep running.
- AppServiceProvider registers the listener via Event::listen alongside
  the existing S1 observers.
- PersonIdentityService::confirmMatch now calls
  FormTagSyncService::rebuildForPerson after setting person.user_id — the
  deferred-sync path for persons who filled in TAG_PICKER fields before
  their account was linked.
- ARCH-FORM-BUILDER.md §31.10 rewritten with the authoritative contract
  block from this session. Header bumped to v1.2.1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-17 21:00:17 +02:00
parent b3eab6e0c8
commit 4495ab017e
4 changed files with 158 additions and 17 deletions

View File

@@ -11,6 +11,7 @@ use App\Models\Event;
use App\Models\Person;
use App\Models\PersonIdentityMatch;
use App\Models\User;
use App\Services\FormBuilder\FormTagSyncService;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@@ -18,6 +19,11 @@ use Illuminate\Validation\ValidationException;
final class PersonIdentityService
{
public function __construct(
private readonly ?FormTagSyncService $tagSyncService = null,
) {}
/**
* Calculate whether two name strings are a fuzzy match using Levenshtein distance
* with a length-adaptive threshold.
@@ -344,6 +350,12 @@ final class PersonIdentityService
$person->user_id = $match->matched_user_id;
$person->save();
// ARCH §31.10 — deferred TAG_PICKER sync: previously submitted
// event_registration forms now have a user account to attach
// self_reported tags to. No-op if null path surfaces.
($this->tagSyncService ?? app(FormTagSyncService::class))
->rebuildForPerson($person->fresh() ?? $person);
// Dismiss other pending matches for this person
PersonIdentityMatch::where('person_id', $person->id)
->where('id', '!=', $match->id)