Some checks failed
Main Confidence / confidence (push) Failing after 50s
## Summary - add a config-seeded canonical control catalog plus shared resolution primitives and Microsoft subject bindings - propagate canonical control references into findings-derived evidence snapshots and tenant review composition - add the feature spec artifacts and focused Pest coverage, plus the supporting workspace and Sail helper adjustments included in this branch ## Testing - cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Unit/Governance/CanonicalControlCatalogTest.php tests/Unit/Governance/CanonicalControlResolverTest.php tests/Feature/Governance/CanonicalControlResolutionIntegrationTest.php tests/Feature/Evidence/EvidenceSnapshotCanonicalControlReferenceTest.php tests/Feature/TenantReview/TenantReviewCanonicalControlReferenceTest.php tests/Feature/PlatformRelocation/CommandModelSmokeTest.php - cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #272
89 lines
2.4 KiB
PHP
89 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Governance\Controls;
|
|
|
|
final readonly class CanonicalControlResolutionResult
|
|
{
|
|
/**
|
|
* @param list<string> $candidateControlKeys
|
|
*/
|
|
private function __construct(
|
|
public string $status,
|
|
public ?CanonicalControlDefinition $control,
|
|
public ?string $reasonCode,
|
|
public array $bindingContext,
|
|
public array $candidateControlKeys = [],
|
|
) {}
|
|
|
|
public static function resolved(CanonicalControlDefinition $definition): self
|
|
{
|
|
return new self(
|
|
status: 'resolved',
|
|
control: $definition,
|
|
reasonCode: null,
|
|
bindingContext: [],
|
|
);
|
|
}
|
|
|
|
public static function unresolved(string $reasonCode, CanonicalControlResolutionRequest $request): self
|
|
{
|
|
return new self(
|
|
status: 'unresolved',
|
|
control: null,
|
|
reasonCode: $reasonCode,
|
|
bindingContext: $request->bindingContext(),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param list<string> $candidateControlKeys
|
|
*/
|
|
public static function ambiguous(array $candidateControlKeys, CanonicalControlResolutionRequest $request): self
|
|
{
|
|
sort($candidateControlKeys, SORT_STRING);
|
|
|
|
return new self(
|
|
status: 'ambiguous',
|
|
control: null,
|
|
reasonCode: 'ambiguous_binding',
|
|
bindingContext: $request->bindingContext(),
|
|
candidateControlKeys: array_values(array_unique($candidateControlKeys)),
|
|
);
|
|
}
|
|
|
|
public function isResolved(): bool
|
|
{
|
|
return $this->status === 'resolved' && $this->control instanceof CanonicalControlDefinition;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
if ($this->isResolved()) {
|
|
return [
|
|
'status' => 'resolved',
|
|
'control' => $this->control?->toArray(),
|
|
];
|
|
}
|
|
|
|
if ($this->status === 'ambiguous') {
|
|
return [
|
|
'status' => 'ambiguous',
|
|
'reason_code' => $this->reasonCode,
|
|
'candidate_control_keys' => $this->candidateControlKeys,
|
|
'binding_context' => $this->bindingContext,
|
|
];
|
|
}
|
|
|
|
return [
|
|
'status' => 'unresolved',
|
|
'reason_code' => $this->reasonCode,
|
|
'binding_context' => $this->bindingContext,
|
|
];
|
|
}
|
|
}
|