TenantAtlas/apps/platform/app/Support/OperationalControls/OperationalControlDecision.php
ahmido d96abc65fb
Some checks failed
Main Confidence / confidence (push) Failing after 1m23s
Remove Findings lifecycle backfill operational surface (controls slice) (#280)
Removes the Findings lifecycle backfill from the Operational Controls UI and OperationalControlCatalog.

This patch is a safe, controls-only change; runbooks, jobs and other runtime artifacts are NOT removed yet. Follow-up work will delete the runbook service/scope, jobs, commands, and update tests.

Files changed:
- apps/platform/app/Filament/System/Pages/Ops/Controls.php
- apps/platform/app/Support/OperationalControls/OperationalControlCatalog.php
- apps/platform/tests/Feature/System/OpsControls/OperationalControlManagementTest.php
- apps/platform/tests/Unit/Support/OperationalControls/OperationalControlCatalogTest.php
- apps/platform/tests/Unit/Support/OperationalControls/OperationalControlScopeResolutionTest.php

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #280
2026-04-26 15:43:47 +00:00

81 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\OperationalControls;
use Carbon\CarbonInterface;
final class OperationalControlDecision
{
public function __construct(
public readonly string $controlKey,
public readonly string $effectiveState,
public readonly string $matchedScopeType,
public readonly ?int $workspaceId,
public readonly ?string $reasonText,
public readonly ?CarbonInterface $expiresAt,
public readonly ?int $sourceActivationId,
) {}
public static function enabled(string $controlKey): self
{
return new self(
controlKey: $controlKey,
effectiveState: 'enabled',
matchedScopeType: 'none',
workspaceId: null,
reasonText: null,
expiresAt: null,
sourceActivationId: null,
);
}
public static function paused(
string $controlKey,
string $matchedScopeType,
?int $workspaceId,
?string $reasonText,
?CarbonInterface $expiresAt,
?int $sourceActivationId,
): self {
return new self(
controlKey: $controlKey,
effectiveState: 'paused',
matchedScopeType: $matchedScopeType,
workspaceId: $workspaceId,
reasonText: $reasonText,
expiresAt: $expiresAt,
sourceActivationId: $sourceActivationId,
);
}
public function isEnabled(): bool
{
return $this->effectiveState === 'enabled';
}
public function isPaused(): bool
{
return $this->effectiveState === 'paused';
}
public function hasWorkspaceScope(): bool
{
return $this->matchedScopeType === 'workspace' && $this->workspaceId !== null;
}
public function scopeLabel(): string
{
return match ($this->matchedScopeType) {
'global' => 'Global',
'workspace' => $this->workspaceId !== null ? 'Workspace #'.$this->workspaceId : 'Workspace',
default => 'No active pause',
};
}
public function expiresAtIso8601(): ?string
{
return $this->expiresAt?->toIso8601String();
}
}