audit: Nacharbeit Umsetzungsaudit 25.09.2026 — Bildfreigabe, Beweisarchiv, KI-Atomarität, Berichte (Block 8, N01–N05, N07, N08, N10–N21, 5.1, 5.2)
Bilder (N01, N05, N07, N08): gemeinsamer Freigabezustand PressReleaseImage::isPubliclyDeliverable() für Seiten, OG und Medienroute (Bestand bleibt sichtbar, v2 nur mit Bestätigung, Admin-Upload bis zum Kundenklick nicht öffentlich); eigene Ability confirmImageRights nur für den Kontoinhaber, ohne Super-Admin-Kurzschluss, Identität und ausstehende Bestätigung auch im Service; Status-Regel unter der PM-Sperre; Cache-Flush nach dem Commit außerhalb der Dateibereinigung; Snapshot nach Bestätigung an veröffentlichter PM; Bestätigungstexte an die gezeigte Kennung gebunden. Beweisarchiv (N02, N10, N11, N12, N13, 5.1): Tombstone unter Zeilensperre mit erneuter Hold-/Fristprüfung; Dateioperationen ausgewertet, Commands mit FAILURE; record() über .tmp + move; Marker archive_pending_at mit archive:retry-pending und archive:sweep-orphans; Anonymisierung entfernt Bilder über den Remover mit Antragsbezug; Draft-Purge räumt Medien nie veröffentlichter abgelehnter Einreichungen; App-Kopien fallen mit dem Archiv-Tombstone; label_corrected nur für veröffentlichte Bilder; archive_entries.legal_request_id; FileDeletion-Helfer; Systemstatus-Checks. KI und Hintergrund (N03, N04, N14, N20, N21): Ergebnis-UPDATE und Audit in einer Transaktion; erwarteter Hash bis in reject()/holdForManualReview(); Ablaufmail per beanspruchtem Marker in einer Transaktion; strikte Schemaprüfung der Vision-Antwort; Fortschrittsmarke ungecacht. Berichte und Canonical (N15–N19, 5.2): lückenlose Alterskohorten; Feed-Identität mit Portal und Sprache; Sitemap-Rolle in der Kundenansicht; Indexverteilung auf einer Grundgesamtheit; Kopien nach Wegfall der Erstquelle neu bewertet; Kategorie-Admin leert Seiten-Caches; Dry-Run zählt alle Tabellen. Gesamtsuite: 2.122 Tests grün, einer übersprungen; Larastan und Pint sauber. Zwei Migrationen (nullable Spalten, INSTANT). N09 offen. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
34fa342c7f
commit
2a2215b3c3
66 changed files with 3092 additions and 368 deletions
|
|
@ -15,6 +15,7 @@ use App\Services\PressRelease\QuotaExceededException;
|
|||
use App\Services\PressRelease\StaleClassificationException;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
|
|
@ -99,23 +100,54 @@ class ClassifyPressRelease implements ShouldQueue
|
|||
// Bedingtes UPDATE: schreibt nur, wenn der Inhalt noch die geprüfte
|
||||
// Prüfsumme trägt. Altbestand ohne Summe (null) wird unbedingt
|
||||
// geschrieben. 0 Zeilen = Inhalt inzwischen geändert oder PM weg.
|
||||
//
|
||||
// Ergebnis und Audit in EINER Transaktion (Audit N03): Der Scheduler
|
||||
// liest die Klassifikation und den Audit-Hash getrennt; ein Commit
|
||||
// zwischen beiden ließe eine grüne PM kurz ohne Nachweis dastehen —
|
||||
// und „ohne Nachweis" gilt als auditloser Altbestand, der durchgeht.
|
||||
$classifiedAt = now();
|
||||
$stored = PressRelease::withoutGlobalScope(PortalScope::class)
|
||||
->whereKey($pressRelease->id)
|
||||
->when($analyzedHash !== null, fn ($query) => $query->where('content_hash', $analyzedHash))
|
||||
->update([
|
||||
|
||||
/** @var array{stored: bool, current_hash: string|null} $outcome */
|
||||
$outcome = DB::transaction(function () use ($pressRelease, $result, $analyzedHash, $classifiedAt): array {
|
||||
$stored = PressRelease::withoutGlobalScope(PortalScope::class)
|
||||
->whereKey($pressRelease->id)
|
||||
->when($analyzedHash !== null, fn ($query) => $query->where('content_hash', $analyzedHash))
|
||||
->update([
|
||||
'classification' => $result->classification->value,
|
||||
'classified_at' => $classifiedAt,
|
||||
'updated_at' => $classifiedAt,
|
||||
]);
|
||||
|
||||
if ($stored === 0) {
|
||||
$currentHash = PressRelease::withoutGlobalScope(PortalScope::class)->withTrashed()->whereKey($pressRelease->id)->value('content_hash');
|
||||
|
||||
if ($currentHash === null) {
|
||||
// Hart gelöscht: nichts mehr zu binden, kein Audit möglich (FK).
|
||||
return ['stored' => false, 'current_hash' => null];
|
||||
}
|
||||
|
||||
KiAudit::query()->create([
|
||||
'press_release_id' => $pressRelease->id,
|
||||
'type' => KiAudit::TYPE_CLASSIFICATION,
|
||||
'provider' => $result->provider,
|
||||
'model' => $result->model,
|
||||
'result' => $result->classification->value,
|
||||
'reason' => 'Verworfen: Inhalt wurde während der Prüfung geändert. '.$result->reasonText(),
|
||||
'raw_response' => $result->rawResponse,
|
||||
'content_hash' => $analyzedHash,
|
||||
'discarded_at' => now(),
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
return ['stored' => false, 'current_hash' => $currentHash];
|
||||
}
|
||||
|
||||
// Modell auf den geschriebenen Stand bringen, ohne ein zweites
|
||||
// (unbedingtes) UPDATE auszulösen.
|
||||
$pressRelease->forceFill([
|
||||
'classification' => $result->classification->value,
|
||||
'classified_at' => $classifiedAt,
|
||||
'updated_at' => $classifiedAt,
|
||||
]);
|
||||
|
||||
if ($stored === 0) {
|
||||
$currentHash = PressRelease::withoutGlobalScope(PortalScope::class)->withTrashed()->whereKey($pressRelease->id)->value('content_hash');
|
||||
|
||||
if ($currentHash === null) {
|
||||
// Hart gelöscht: nichts mehr zu binden, kein Audit möglich (FK).
|
||||
return;
|
||||
}
|
||||
])->syncOriginal();
|
||||
|
||||
KiAudit::query()->create([
|
||||
'press_release_id' => $pressRelease->id,
|
||||
|
|
@ -123,49 +155,36 @@ class ClassifyPressRelease implements ShouldQueue
|
|||
'provider' => $result->provider,
|
||||
'model' => $result->model,
|
||||
'result' => $result->classification->value,
|
||||
'reason' => 'Verworfen: Inhalt wurde während der Prüfung geändert. '.$result->reasonText(),
|
||||
'reason' => $result->reasonText(),
|
||||
'raw_response' => $result->rawResponse,
|
||||
'content_hash' => $analyzedHash,
|
||||
'discarded_at' => now(),
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
self::dispatch($pressRelease->id, $this->route, $this->providerOverride, $currentHash)->onQueue('classification');
|
||||
return ['stored' => true, 'current_hash' => $analyzedHash];
|
||||
});
|
||||
|
||||
if (! $outcome['stored']) {
|
||||
if ($outcome['current_hash'] !== null) {
|
||||
self::dispatch($pressRelease->id, $this->route, $this->providerOverride, $outcome['current_hash'])->onQueue('classification');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Modell auf den geschriebenen Stand bringen, ohne ein zweites
|
||||
// (unbedingtes) UPDATE auszulösen.
|
||||
$pressRelease->forceFill([
|
||||
'classification' => $result->classification->value,
|
||||
'classified_at' => $classifiedAt,
|
||||
])->syncOriginal();
|
||||
|
||||
KiAudit::query()->create([
|
||||
'press_release_id' => $pressRelease->id,
|
||||
'type' => KiAudit::TYPE_CLASSIFICATION,
|
||||
'provider' => $result->provider,
|
||||
'model' => $result->model,
|
||||
'result' => $result->classification->value,
|
||||
'reason' => $result->reasonText(),
|
||||
'raw_response' => $result->rawResponse,
|
||||
'content_hash' => $analyzedHash,
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
if (! $this->route && ! $this->redRecheckMustReject($pressRelease, $result)) {
|
||||
if (! $this->route && ! $this->redRecheckMustReject($pressRelease, $result, $analyzedHash)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$service->routeByClassification($pressRelease, $result->classification, $result->reasonText());
|
||||
$service->routeByClassification($pressRelease, $result->classification, $result->reasonText(), $analyzedHash);
|
||||
} catch (BlacklistViolationException) {
|
||||
// publish() hat die PM bereits abgelehnt und den Autor benachrichtigt.
|
||||
} catch (StaleClassificationException $exception) {
|
||||
// Inhalt zwischen Audit und Publish-Sperre geändert: publish() hat
|
||||
// bereits eine Prüfung für den aktuellen Stand eingeplant (U02).
|
||||
Log::channel('ki')->info('Auto-Veröffentlichung übersprungen: Klassifikation passt nicht mehr zum Inhalt, Prüfung neu eingeplant.', [
|
||||
// Inhalt zwischen Audit und Sperre geändert: publish() bzw.
|
||||
// reject()/Hold haben bereits eine Prüfung für den aktuellen
|
||||
// Stand eingeplant (U02, N04).
|
||||
Log::channel('ki')->info('Automatisches Routing übersprungen: Klassifikation passt nicht mehr zum Inhalt, Prüfung neu eingeplant.', [
|
||||
'press_release_id' => $pressRelease->id,
|
||||
]);
|
||||
} catch (QuotaExceededException $exception) {
|
||||
|
|
@ -182,9 +201,12 @@ class ClassifyPressRelease implements ShouldQueue
|
|||
* Roter Re-Check ohne Routing einer noch wartenden PM (Audit U03): nur
|
||||
* dann greift der Rot-Zweig der Erstprüfung. Status frisch lesen — der
|
||||
* KI-Aufruf kann gedauert haben, und ein Admin hat womöglich inzwischen
|
||||
* entschieden.
|
||||
* entschieden. Ist der Inhalt seit dem Ergebnis schon wieder geändert
|
||||
* (Audit N04), gehört das Rot zu einer alten Fassung: nicht ablehnen —
|
||||
* die Bearbeitung hat bereits einen Re-Check für den neuen Stand
|
||||
* eingeplant. Verbindlich prüft reject() das noch einmal unter der Sperre.
|
||||
*/
|
||||
private function redRecheckMustReject(PressRelease $pressRelease, ClassificationResult $result): bool
|
||||
private function redRecheckMustReject(PressRelease $pressRelease, ClassificationResult $result, ?string $analyzedHash): bool
|
||||
{
|
||||
if ($result->classification !== PressReleaseClassification::Red) {
|
||||
return false;
|
||||
|
|
@ -192,6 +214,14 @@ class ClassifyPressRelease implements ShouldQueue
|
|||
|
||||
$pressRelease->refresh();
|
||||
|
||||
if ($analyzedHash !== null && $pressRelease->content_hash !== null && $pressRelease->content_hash !== $analyzedHash) {
|
||||
Log::channel('ki')->info('Roter Re-Check übersprungen: Inhalt seit dem Ergebnis geändert, neuer Re-Check läuft.', [
|
||||
'press_release_id' => $pressRelease->id,
|
||||
]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $pressRelease->status === PressReleaseStatus::Review
|
||||
&& ! $pressRelease->requiresManualReview();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue