Implements Spec 075 (V1.5) on top of Spec 074. Highlights - Deterministic report fingerprint (sha256) + previous_report_id linkage - Viewer change indicator: "No changes" vs "Changed" when previous exists - Check acknowledgements (fail|warn|block) with capability-first auth, confirmation, and audit event - Verify-step UX polish (issues-first, primary CTA) Testing - Focused Pest coverage for fingerprint, previous resolver, change indicator, acknowledgements, badge semantics, DB-only viewer guard. Notes - Viewing remains DB-only (no external calls while rendering). Co-authored-by: Ahmed Darrazi <ahmeddarrazi@MacBookPro.fritz.box> Reviewed-on: #93
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Support;
|
|
|
|
use App\Models\OperationRun;
|
|
|
|
final class VerificationReportChangeIndicator
|
|
{
|
|
/**
|
|
* @return array{state: 'no_changes'|'changed', previous_report_id: int}|null
|
|
*/
|
|
public static function forRun(OperationRun $run): ?array
|
|
{
|
|
$report = VerificationReportViewer::report($run);
|
|
|
|
if ($report === null) {
|
|
return null;
|
|
}
|
|
|
|
$previousRun = VerificationReportViewer::previousRun($run, $report);
|
|
|
|
if ($previousRun === null) {
|
|
return null;
|
|
}
|
|
|
|
$previousReport = VerificationReportViewer::report($previousRun);
|
|
|
|
if ($previousReport === null) {
|
|
return null;
|
|
}
|
|
|
|
$currentFingerprint = VerificationReportViewer::fingerprint($report);
|
|
$previousFingerprint = VerificationReportViewer::fingerprint($previousReport);
|
|
|
|
if ($currentFingerprint === null || $previousFingerprint === null) {
|
|
return null;
|
|
}
|
|
|
|
return [
|
|
'state' => $currentFingerprint === $previousFingerprint ? 'no_changes' : 'changed',
|
|
'previous_report_id' => (int) $previousRun->getKey(),
|
|
];
|
|
}
|
|
}
|
|
|