feat: person identity matching with detection, confirmation and audit trail
Implements enterprise-grade identity resolution (detect → suggest → confirm) for Person ↔ User linking. Matches are detected automatically on person creation and user account creation, then surfaced to organisers for explicit confirmation or dismissal. No silent auto-linking. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
51
api/database/factories/PersonIdentityMatchFactory.php
Normal file
51
api/database/factories/PersonIdentityMatchFactory.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\IdentityMatchConfidence;
|
||||
use App\Enums\IdentityMatchMethod;
|
||||
use App\Enums\IdentityMatchStatus;
|
||||
use App\Models\Person;
|
||||
use App\Models\PersonIdentityMatch;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<PersonIdentityMatch> */
|
||||
final class PersonIdentityMatchFactory extends Factory
|
||||
{
|
||||
protected $model = PersonIdentityMatch::class;
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'person_id' => Person::factory(),
|
||||
'matched_user_id' => User::factory(),
|
||||
'matched_on' => IdentityMatchMethod::EMAIL,
|
||||
'confidence' => IdentityMatchConfidence::EXACT,
|
||||
'status' => IdentityMatchStatus::PENDING,
|
||||
'resolved_by_user_id' => null,
|
||||
'resolved_at' => null,
|
||||
];
|
||||
}
|
||||
|
||||
public function confirmed(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'status' => IdentityMatchStatus::CONFIRMED,
|
||||
'resolved_by_user_id' => User::factory(),
|
||||
'resolved_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function dismissed(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'status' => IdentityMatchStatus::DISMISSED,
|
||||
'resolved_by_user_id' => User::factory(),
|
||||
'resolved_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user