## Summary - implement Spec 209 heavy-governance cost recovery end to end - add the heavy-governance contract, hotspot inventory, decomposition, snapshots, budget outcome, and author-guidance surfaces in the shared lane support seams - slim the baseline and findings hotspot families, harden wrapper behavior, and refresh the spec, quickstart, and contract artifacts ## Validation - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Guards/TestLaneCommandContractTest.php tests/Feature/Guards/ActionSurfaceContractTest.php tests/Feature/Guards/OperationLifecycleOpsUxGuardTest.php` - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Filament/BaselineProfileCaptureStartSurfaceTest.php tests/Feature/Filament/BaselineProfileCompareStartSurfaceTest.php tests/Feature/Filament/BaselineActionAuthorizationTest.php tests/Feature/Findings/FindingsListFiltersTest.php tests/Feature/Findings/FindingExceptionRenewalTest.php tests/Feature/Findings/FindingWorkflowRowActionsTest.php tests/Feature/Findings/FindingWorkflowViewActionsTest.php tests/Feature/Guards/ActionSurfaceContractTest.php tests/Feature/Guards/OperationLifecycleOpsUxGuardTest.php` - `./scripts/platform-sail artisan test --compact` ## Outcome - heavy-governance latest artifacts now agree on an authoritative `330s` threshold with `recalibrated` outcome after the honest rerun - full suite result: `3760 passed`, `8 skipped`, `23535 assertions` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #242
111 lines
5.7 KiB
PHP
111 lines
5.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Tests\Support\TestLaneManifest;
|
|
use Tests\Support\TestLaneReport;
|
|
|
|
it('keeps the shared fixture slimming pre-migration baselines recorded for the standard lanes', function (): void {
|
|
$fastFeedback = TestLaneManifest::comparisonBaseline('shared-test-fixture-slimming', 'fast-feedback');
|
|
$confidence = TestLaneManifest::comparisonBaseline('shared-test-fixture-slimming', 'confidence');
|
|
|
|
expect($fastFeedback)->toMatchArray([
|
|
'laneId' => 'fast-feedback',
|
|
'wallClockSeconds' => 176.73623,
|
|
'targetImprovementPercent' => 10,
|
|
'maxRegressionPercent' => 5,
|
|
])
|
|
->and($confidence)->toMatchArray([
|
|
'laneId' => 'confidence',
|
|
'wallClockSeconds' => 394.383441,
|
|
'targetImprovementPercent' => 10,
|
|
'maxRegressionPercent' => 5,
|
|
]);
|
|
});
|
|
|
|
it('classifies lane-impact comparison status against the recorded fixture slimming baseline', function (): void {
|
|
$improved = TestLaneReport::buildReport(
|
|
laneId: 'fast-feedback',
|
|
wallClockSeconds: 150.0,
|
|
slowestEntries: [],
|
|
durationsByFile: [],
|
|
comparisonProfile: 'shared-test-fixture-slimming',
|
|
);
|
|
|
|
$stable = TestLaneReport::buildReport(
|
|
laneId: 'fast-feedback',
|
|
wallClockSeconds: 180.0,
|
|
slowestEntries: [],
|
|
durationsByFile: [],
|
|
comparisonProfile: 'shared-test-fixture-slimming',
|
|
);
|
|
|
|
$regressed = TestLaneReport::buildReport(
|
|
laneId: 'fast-feedback',
|
|
wallClockSeconds: 190.0,
|
|
slowestEntries: [],
|
|
durationsByFile: [],
|
|
comparisonProfile: 'shared-test-fixture-slimming',
|
|
);
|
|
|
|
expect(data_get($improved, 'sharedFixtureSlimmingComparison.status'))->toBe('improved')
|
|
->and(data_get($stable, 'sharedFixtureSlimmingComparison.status'))->toBe('stable')
|
|
->and(data_get($regressed, 'sharedFixtureSlimmingComparison.status'))->toBe('regressed');
|
|
});
|
|
|
|
it('defines lane, classification, and family budget targets for heavy-governance attribution', function (): void {
|
|
$budgetTargets = collect(TestLaneManifest::budgetTargets());
|
|
$contract = TestLaneManifest::heavyGovernanceBudgetContract();
|
|
$laneBudgetTarget = $budgetTargets
|
|
->first(static fn (array $target): bool => $target['targetType'] === 'lane' && $target['targetId'] === 'heavy-governance');
|
|
|
|
expect($laneBudgetTarget)->not->toBeNull()
|
|
->and($contract['summaryThresholdSeconds'])->toBe(300.0)
|
|
->and($contract['evaluationThresholdSeconds'])->toBe(200.0)
|
|
->and($contract['normalizedThresholdSeconds'])->toBeGreaterThanOrEqual(300.0)
|
|
->and($laneBudgetTarget['thresholdSeconds'])->toBe($contract['normalizedThresholdSeconds'])
|
|
->and($laneBudgetTarget['lifecycleState'])->toBe($contract['lifecycleState'])
|
|
->and($budgetTargets->contains(static fn (array $target): bool => $target['targetType'] === 'classification' && $target['targetId'] === 'surface-guard'))->toBeTrue()
|
|
->and($budgetTargets->contains(static fn (array $target): bool => $target['targetType'] === 'classification' && $target['targetId'] === 'discovery-heavy'))->toBeTrue()
|
|
->and($budgetTargets->contains(static fn (array $target): bool => $target['targetType'] === 'family' && $target['targetId'] === 'action-surface-contract'))->toBeTrue()
|
|
->and($budgetTargets->contains(static fn (array $target): bool => $target['targetType'] === 'family' && $target['targetId'] === 'ops-ux-governance'))->toBeTrue();
|
|
});
|
|
|
|
it('evaluates heavy-governance budgets against named class and family totals', function (): void {
|
|
$currentRunContract = TestLaneManifest::heavyGovernanceBudgetContract(110.0);
|
|
|
|
$durationsByFile = [
|
|
'tests/Feature/Guards/ActionSurfaceContractTest.php' => 31.2,
|
|
'tests/Feature/Filament/PolicyResourceAdminSearchParityTest.php' => 17.4,
|
|
'tests/Feature/Filament/PolicyVersionAdminSearchParityTest.php' => 16.1,
|
|
'tests/Feature/Filament/Alerts/AlertsKpiHeaderTest.php' => 9.8,
|
|
'tests/Feature/Guards/OperationLifecycleOpsUxGuardTest.php' => 8.7,
|
|
];
|
|
|
|
$slowestEntries = collect($durationsByFile)
|
|
->map(static fn (float $seconds, string $file): array => [
|
|
'label' => $file.'::synthetic',
|
|
'subject' => $file.'::synthetic',
|
|
'filePath' => $file,
|
|
'durationSeconds' => $seconds,
|
|
'wallClockSeconds' => $seconds,
|
|
'laneId' => 'heavy-governance',
|
|
])
|
|
->values()
|
|
->all();
|
|
|
|
$report = TestLaneReport::buildReport(
|
|
laneId: 'heavy-governance',
|
|
wallClockSeconds: 110.0,
|
|
slowestEntries: $slowestEntries,
|
|
durationsByFile: $durationsByFile,
|
|
);
|
|
|
|
expect(collect($report['budgetEvaluations'])->pluck('targetType')->unique()->values()->all())
|
|
->toEqualCanonicalizing(['lane', 'classification', 'family'])
|
|
->and(collect($report['budgetEvaluations'])->contains(static fn (array $evaluation): bool => $evaluation['targetType'] === 'lane' && $evaluation['targetId'] === 'heavy-governance'))->toBeTrue()
|
|
->and(collect($report['budgetEvaluations'])->contains(static fn (array $evaluation): bool => $evaluation['targetType'] === 'classification' && $evaluation['targetId'] === 'surface-guard'))->toBeTrue()
|
|
->and(collect($report['budgetEvaluations'])->contains(static fn (array $evaluation): bool => $evaluation['targetType'] === 'family' && $evaluation['targetId'] === 'action-surface-contract'))->toBeTrue()
|
|
->and($report['budgetContract']['normalizedThresholdSeconds'])->toBe($currentRunContract['normalizedThresholdSeconds'])
|
|
->and($report['budgetOutcome']['decisionStatus'])->toBe($currentRunContract['decisionStatus']);
|
|
}); |