feat(editorial): preserve public editions and add QA review workflow

This commit is contained in:
2026-11-13 22:56:44 +02:00
parent 2f1ef2fdfc
commit b3849d850e
25 changed files with 1963 additions and 55 deletions
@@ -134,8 +134,12 @@ class OpportunityReviewMateriality
/** @param array<string,mixed> $snapshot
* @param array<string,mixed> $review */
public function matches(array $snapshot, string $gate, array $review): bool
public function matches(array $snapshot, string $gate, array $review, bool $exactLegalVersion = false): bool
{
if ($exactLegalVersion && preg_match('/legal|registry|authority|confidentiality|license/', $gate) === 1
&& ($review['hash'] ?? null) !== ($snapshot['hash'] ?? null)) {
return false;
}
if (! isset($review['scope_hash'])) {
return true; // Caller must independently verify the original signed submission hash.
}
@@ -151,7 +155,7 @@ class OpportunityReviewMateriality
* @param array<string,mixed> $reviews
* @param list<string> $gates
* @return array<string,mixed> */
public function reconcile(array $before, array $after, array $reviews, array $gates, bool $force = false): array
public function reconcile(array $before, array $after, array $reviews, array $gates, bool $force = false, bool $exactLegalVersion = false): array
{
$kept = [];
$reopened = [];
@@ -161,7 +165,8 @@ class OpportunityReviewMateriality
// separately validate old scope signatures under their original rule.
$priorHash = $this->hash($before, $gate, $review);
$currentHash = $this->hash($after, $gate, $review);
if (! $force && $before !== [] && ($review['decision'] ?? '') === 'approved' && $this->matches($before, $gate, $review) && hash_equals($priorHash, $currentHash)) {
$changedLegalVersion = $exactLegalVersion && preg_match('/legal|registry|authority|confidentiality|license/', $gate) === 1 && ($review['hash'] ?? null) !== ($after['hash'] ?? null);
if (! $force && ! $changedLegalVersion && $before !== [] && ($review['decision'] ?? '') === 'approved' && $this->matches($before, $gate, $review) && hash_equals($priorHash, $currentHash)) {
$kept[$gate] = [...$review, 'scope_hash' => $priorHash, 'scope_rule' => self::VERSION, 'accepted_submission_hash' => $after['hash'],
'carried_forward' => ['rule' => self::VERSION, 'from_scope_hash' => $review['scope_hash'] ?? null, 'from_scope_rule' => $review['scope_rule'] ?? 'legacy_unspecified', 'from_submission_hash' => $before['hash'] ?? null, 'at' => now()->toIso8601String()]];
} else {