## Summary - replace the legacy Tenant and TenantMembership core models with ManagedEnvironment and ManagedEnvironmentMembership - propagate the managed environment naming and key changes across Filament resources, pages, controllers, jobs, models, and supporting runtime paths - add feature 279 spec artifacts and focused managed-environment test coverage for model behavior, route binding, panel context, authorization, and legacy guardrails ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/ManagedEnvironment/LegacyTenantCoreGuardTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentAuthorizationTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentPanelContextTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentRouteBindingTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentContextResolverTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentModelTest.php` - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` ## Notes - branch pushed from commit `1123b122` - browser smoke test file was added but not run in this pass Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #335
82 lines
3.0 KiB
PHP
82 lines
3.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Baselines\Compare;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
final class CompareOrchestrationContext
|
|
{
|
|
/**
|
|
* @param array<string, mixed> $normalizedScope
|
|
* @param array<string, mixed> $coverageContext
|
|
* @param array<string, mixed> $launchContext
|
|
*/
|
|
public function __construct(
|
|
public readonly int $workspaceId,
|
|
public readonly int $tenantId,
|
|
public readonly int $baselineProfileId,
|
|
public readonly int $baselineSnapshotId,
|
|
public readonly int $operationRunId,
|
|
public readonly array $normalizedScope,
|
|
public readonly CompareStrategySelection $strategySelection,
|
|
public readonly array $coverageContext = [],
|
|
public readonly array $launchContext = [],
|
|
) {
|
|
if ($this->workspaceId <= 0 || $this->tenantId <= 0 || $this->baselineProfileId <= 0 || $this->baselineSnapshotId <= 0 || $this->operationRunId <= 0) {
|
|
throw new InvalidArgumentException('Compare orchestration contexts require positive workspace, tenant, profile, snapshot, and operation run identifiers.');
|
|
}
|
|
}
|
|
|
|
public function strategyKey(): CompareStrategyKey
|
|
{
|
|
if (! $this->strategySelection->strategyKey instanceof CompareStrategyKey) {
|
|
throw new InvalidArgumentException('Compare orchestration context requires a supported strategy selection before execution.');
|
|
}
|
|
|
|
return $this->strategySelection->strategyKey;
|
|
}
|
|
|
|
public function inventorySyncRunId(): ?int
|
|
{
|
|
$value = $this->coverageContext['inventory_sync_run_id'] ?? $this->launchContext['inventory_sync_run_id'] ?? null;
|
|
|
|
return is_numeric($value) ? (int) $value : null;
|
|
}
|
|
|
|
/**
|
|
* @return array{
|
|
* workspace_id: int,
|
|
* managed_environment_id: int,
|
|
* baseline_profile_id: int,
|
|
* baseline_snapshot_id: int,
|
|
* operation_run_id: int,
|
|
* normalized_scope: array<string, mixed>,
|
|
* strategy_selection: array{
|
|
* selection_state: string,
|
|
* strategy_key: ?string,
|
|
* matched_scope_entries: list<array<string, mixed>>,
|
|
* rejected_scope_entries: list<array<string, mixed>>,
|
|
* operator_reason: string,
|
|
* diagnostics: array<string, mixed>
|
|
* },
|
|
* coverage_context: array<string, mixed>,
|
|
* launch_context: array<string, mixed>
|
|
* }
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'workspace_id' => $this->workspaceId,
|
|
'managed_environment_id' => $this->tenantId,
|
|
'baseline_profile_id' => $this->baselineProfileId,
|
|
'baseline_snapshot_id' => $this->baselineSnapshotId,
|
|
'operation_run_id' => $this->operationRunId,
|
|
'normalized_scope' => $this->normalizedScope,
|
|
'strategy_selection' => $this->strategySelection->toArray(),
|
|
'coverage_context' => $this->coverageContext,
|
|
'launch_context' => $this->launchContext,
|
|
];
|
|
}
|
|
} |