Implemented deterministic Baseline Result Semantics (Spec 383), introducing CompareSubjectResult and CompareEvidenceResult. Replaced generic arrays with strict Data Transfer Objects for Baseline engine output. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #454
20 KiB
Tasks: Spec 383 - Baseline Compare Result Semantics and Gap Classification v1
Input: Design documents from /specs/383-baseline-result-semantics/
Prerequisites: spec.md, plan.md, completed Specs 381 and 382 close-outs
Tests: Runtime behavior changes require Pest unit and feature tests before or alongside implementation. Browser tests are not required unless implementation changes rendered layout, navigation, actions, or JavaScript behavior.
Test Governance Checklist
- TGC001 Lane assignment is named and is the narrowest sufficient proof for the changed behavior.
- TGC002 New or changed tests stay in the smallest honest family, and any heavy-governance or browser addition is explicit.
- TGC003 Shared helpers, factories, seeds, fixtures, and context defaults stay cheap by default; any widening is isolated or documented.
- TGC004 Planned validation commands cover the change without pulling in unrelated lane cost.
- TGC005 The declared surface test profile or
standard-native-filamentrelief is explicit. - TGC006 Any material budget, baseline, trend, or escalation note is recorded in the active spec or PR.
Phase 1: Preparation And Guardrails
Purpose: Protect completed history, confirm repo truth, and keep the implementation bounded.
- T001 Confirm
specs/381-provider-resource-identity-binding/implementation-close-out.mdandspecs/382-baseline-matching-canonicalization/implementation-close-out.mdexist and treat both as dependency context only. - T002 Confirm no code or artifact changes are made to completed specs
specs/381-provider-resource-identity-binding/,specs/382-baseline-matching-canonicalization/,specs/163-baseline-subject-resolution/,specs/336-baseline-compare-product-process-flow-alignment/,specs/347-review-pack-output-contract-readiness-semantics/,specs/350-operator-resolution-guidance-framework-v1/, orspecs/380-management-report-pdf-staging-runtime-validation/. - T003 Re-read
apps/platform/app/Support/Baselines/Matching/MatchingOutcome.php,apps/platform/app/Services/Baselines/Matching/SubjectMatchingPipeline.php, andapps/platform/app/Services/Baselines/Matching/FoundationCoverageResolver.phpbefore implementation. - T004 Re-read
apps/platform/app/Jobs/CompareBaselineToTenantJob.php,apps/platform/app/Support/Baselines/Compare/CompareSubjectResult.php,apps/platform/app/Support/Baselines/Compare/IntuneCompareStrategy.php, andapps/platform/app/Support/Baselines/Compare/CompareState.phpbefore implementation. - T005 Re-read
apps/platform/app/Support/Baselines/BaselineCompareReasonCode.php,apps/platform/app/Support/Baselines/BaselineCompareEvidenceGapDetails.php,apps/platform/app/Support/Baselines/SubjectResolver.php, andapps/platform/app/Support/Baselines/ResolutionOutcome.phpbefore implementation. - T006 Confirm no new route, navigation entry, destructive action, Filament panel provider, Livewire component, queue name, scheduler entry, env var, storage path, or persisted entity is needed; if any is needed, stop and update
specs/383-baseline-result-semantics/spec.mdandplan.md.
Phase 2: Tests First - Core Semantics
Purpose: Lock the new source of truth before changing runtime code.
- T007 [P] [US1] Add coverage in
apps/platform/tests/Unit/Support/Baselines/CompareSemantics/BaselineCompareOutcomeClassifierTest.phpfor every V1 reason, category, actionability, readiness impact, and trust-level mapping. - T008 [P] [US1] Add coverage in
apps/platform/tests/Unit/Support/Baselines/CompareSemantics/BaselineCompareOutcomeClassifierTest.phpfor clean success rules, drift, no drift, blocker, limitation, unsupported, missing, excluded, and failed outcomes. - T009 [P] [US1] Add
apps/platform/tests/Unit/Support/Baselines/CompareSemantics/BaselineCompareOutcomeClassifierTest.phpcovering trusted no-drift, trusted drift, identity required, duplicate candidates, missing provider resource, missing local evidence, unsupported resource, inventory-only foundation, identity-only foundation, accepted limitation, excluded non-governed, low-trust not no-drift, and compare failure. - T010 [P] [US3] Add coverage in
apps/platform/tests/Unit/Support/Baselines/CompareSemantics/BaselineCompareOutcomeClassifierTest.phpfor completed, completed-with-drift, partial/limited, blocked, and failed run aggregation. - T011 [P] [US1] Add coverage in
apps/platform/tests/Unit/Support/Baselines/CompareSemantics/BaselineCompareOutcomeClassifierTest.phpasserting old overloaded reason values are not authoritative enum/constant values in the new semantics model.
Phase 3: Tests First - Matching And Compare Integration
Purpose: Prove Spec 382 matching outcomes map to final compare semantics without false green or false red output.
- T012 [P] [US2] Update
apps/platform/tests/Unit/Support/Baselines/Matching/MatchingOutcomeTest.phpso matching reasons expected by Spec 383 are provider-neutral and no longer assertambiguous_match,unsupported_subject, orfoundation_not_policy_backedas final result truth. - T013 [P] [US2] Update
apps/platform/tests/Unit/Support/Baselines/Matching/SubjectMatchingPipelineTest.phpto assert active binding, canonical identity, duplicate candidates, missing local evidence, missing provider resource, unsupported, limited, excluded, and identity-required outcomes map through the classifier. - T014 [P] [US2] Update
apps/platform/tests/Unit/Services/Baselines/Matching/FoundationCoverageResolverTest.phpso inventory-only, identity-only, canonical-only, unsupported, and accepted limitation coverage expect the new provider-neutral reason names. - T015 [P] [US2] Update
apps/platform/tests/Feature/Baselines/BaselineCompareProviderResourceBindingCanonicalIdentityTest.phpto assert binding-resolved identity produces trusted comparison eligibility but not no-drift by itself. - T016 [P] [US2] Update
apps/platform/tests/Feature/Baselines/BaselineCompareAmbiguousMatchGapTest.phpto expectunresolved_duplicate_candidatesorunresolved_ambiguous_identityinstead ofambiguous_match. - T017 [P] [US1] Update
apps/platform/tests/Feature/Baselines/BaselineCompareGapClassificationTest.phpto assert missing local evidence, missing provider resource, and foundation limitation states are distinct. - T018 [P] [US3] Update
apps/platform/tests/Feature/Baselines/BaselineCompareExecutionGuardTest.phpso compare strategy exceptions map to compare-failed semantics without relying onstrategy_failedas an authoritative subject reason. - T019 [P] [US3] Update
apps/platform/tests/Feature/Baselines/BaselineCompareResumeTokenTest.phpso resumed full-content gaps use new missing-local-evidence semantics instead ofpolicy_record_missing. - T020 [P] [US1] Update
apps/platform/tests/Feature/Baselines/BaselineCompareGapClassificationTest.phpto prove stale or absent current provider descriptors do not by themselves emitmissing_provider_resource, and that missing-provider semantics require current-provider absence proof or an active binding that marks the expected resource missing.
Phase 4: Tests First - Existing Presentation And Downstream Regressions
Purpose: Keep existing surfaces and downstream consumers honest without implementing Spec 384 or 385.
- T021 [P] [US4] Update
apps/platform/tests/Feature/Filament/BaselineCompareEvidenceGapTableTest.phpto assert existing evidence-gap rows render the new result groups and do not expose old reason strings as primary operator truth. - T022 [P] [US4] Update
apps/platform/tests/Feature/Filament/BaselineCompareExplanationSurfaceTest.phpto assert provider-neutral blocker/limitation/missing/failure explanations. - T023 [P] [US4] Update
apps/platform/tests/Feature/Filament/BaselineCompareLandingWhyNoFindingsTest.phpto prove no-drift explanation appears only when the new clean-success rules allow it. - T024 [P] [US4] Update
apps/platform/tests/Feature/Filament/BaselineCompareSummaryConsistencyTest.phpto assert result group totals stay consistent with OperationRun context counts. - T025 [P] [US3] Update
apps/platform/tests/Feature/Evidence/BaselineDriftPostureSourceTest.phpto prove evidence posture does not treat blockers/limitations as verified no drift before Spec 385. - T026 [P] [US3] Update
apps/platform/tests/Feature/ReviewPack/Spec347ReviewPackReadinessSemanticsTest.phpandapps/platform/tests/Feature/ReviewPack/Spec349ReviewPackResolutionGuidanceTest.phpto prove customer-facing readiness/output wording is unchanged by Spec 383.
Phase 5: Define The Narrow Result Semantics Model
Purpose: Add provider-neutral value families with direct behavioral consequences.
- T027 [US1] Create
apps/platform/app/Support/Baselines/CompareSemantics/CompareResultIdentityStatus.phpwith resolved, binding-resolved, canonicalization-resolved, unresolved, missing, and unsupported identity values. - T028 [US1] Create
apps/platform/app/Support/Baselines/CompareSemantics/CompareResultComparisonStatus.phpwith not-compared, no-drift, drift-detected, compare-failed, and compare-not-supported values. - T029 [US1] Create
apps/platform/app/Support/Baselines/CompareSemantics/CompareResultCoverageStatus.phpwith fully-verified, verified-with-limitations, inventory-only, identity-only, canonical-only, unsupported, missing-local-evidence, missing-provider-resource, excluded, and accepted-limitation values. - T030 [US1] Create
apps/platform/app/Support/Baselines/CompareSemantics/CompareResultActionability.php,CompareResultReadinessImpact.php,CompareResultTrustLevel.php, andCompareResultCategory.phpwith the V1 values fromspecs/383-baseline-result-semantics/spec.md. - T031 [US1] Create
apps/platform/app/Support/Baselines/CompareSemantics/CompareResultReason.phpwith provider-neutral reasons and mapping methods for category, actionability, readiness impact, and default trust. - T032 [US1] Create
apps/platform/app/Support/Baselines/CompareSemantics/CompareSubjectOutcome.phpas a derived result object with sanitizedtoArray()output for OperationRun/context use. - T033 [US1] Create
apps/platform/app/Support/Baselines/CompareSemantics/BaselineCompareOutcomeClassifier.phpto map matching outcomes plus compare strategy outputs intoCompareSubjectOutcome. - T034 [US3] Create
apps/platform/app/Support/Baselines/CompareSemantics/BaselineCompareRunSummaryClassifier.phpto aggregate subject outcomes into run-level completed, partial, blocked, or failed decisions and count buckets.
Phase 6: Replace Legacy Matching And Gap Reasons
Purpose: Stop old matching/gap strings from remaining authoritative.
- T035 [US2] Update
apps/platform/app/Support/Baselines/Matching/MatchingOutcome.phpso factory methods use new provider-neutral reason names and keep old strings out of authoritative output. - T036 [US2] Update
apps/platform/app/Services/Baselines/Matching/FoundationCoverageResolver.phpso unsupported and foundation coverage returnsunsupported_resource_class,foundation_inventory_only,foundation_identity_only, orfoundation_canonical_onlyas appropriate. - T037 [US2] Update
apps/platform/app/Services/Baselines/Matching/SubjectMatchingPipeline.phpto map duplicate candidates tounresolved_duplicate_candidates, low-trust/identity gaps toidentity_requiredorunresolved_low_trust_match, active binding resolution toresolved_active_binding, and canonical/provider identity to provider-neutral resolved reasons. - T038 [US1] Update
apps/platform/app/Support/Baselines/SubjectResolver.php,apps/platform/app/Support/Baselines/ResolutionOutcome.php, andapps/platform/app/Support/Baselines/ResolutionOutcomeRecord.phpso legacy policy-shaped reasons are no longer final compare result truth; retain only non-authoritative helper behavior if still needed by capture flows and document any boundary in code/tests. - T039 [US1] Update
apps/platform/app/Support/Baselines/BaselineCompareReasonCode.phpso run-level reasons are either provider-neutral summary reasons or delegated to the new run summary classifier.
Phase 7: Compare Strategy And OperationRun Integration
Purpose: Make runtime compare output and proof payloads use the new truth.
- T040 [US2] Update
apps/platform/app/Support/Baselines/Compare/CompareState.phpor its mapping layer so unsupported, incomplete, ambiguous, failed, drift, and no-drift states map toCompareSubjectOutcomewithout old reason strings. - T041 [US2] Update
apps/platform/app/Support/Baselines/Compare/CompareSubjectResult.phpto expose structured semantic payloads or enough diagnostics forBaselineCompareOutcomeClassifierwithout duplicating result truth. - T042 [US2] Update
apps/platform/app/Support/Baselines/Compare/IntuneCompareStrategy.phpso missing current evidence, unsupported subjects, ambiguous conditions, and compare failures emit provider-neutral diagnostics and keep drift/no-drift limited to trusted comparable subjects. - T043 [US2] Update
apps/platform/tests/Feature/Baselines/Support/FakeCompareStrategy.phpto emit provider-neutral diagnostics used by Spec 383 tests. - T044 [US3] Update
apps/platform/app/Jobs/CompareBaselineToTenantJob.phpto build structuredCompareSubjectOutcomerecords from matching outcomes and strategy results before gap aggregation. - T045 [US3] Update
apps/platform/app/Jobs/CompareBaselineToTenantJob.phpsobaseline_compare.evidence_gapsincludes structured counts by reason, category, actionability, readiness impact, and subject outcome payloads. - T046 [US3] Update
apps/platform/app/Jobs/CompareBaselineToTenantJob.phpso run outcome andsummary_countsderive fromBaselineCompareRunSummaryClassifierand stay compatible withOperationSummaryKeys::all(). - T047 [US3] Update
apps/platform/app/Support/OpsUx/OperationSummaryKeys.phpandapps/platform/tests/Feature/OpsUx/OperationSummaryKeysSpecTest.phponly if Spec 383 needs new count keys not representable by the existing canonical list. - T048 [US3] Add or update a focused test or guard assertion proving baseline compare aggregation does not mutate
OperationRun.statusorOperationRun.outcomeoutsideOperationRunServicewhile summary semantics change.
Phase 8: Existing Surface Labels And Downstream Consumers
Purpose: Render the new truth on existing surfaces without new UI workflows.
- T049 [US4] Update
apps/platform/app/Support/Baselines/BaselineCompareEvidenceGapDetails.phpto render provider-neutral group labels for verified, drift detected, action required, missing evidence, missing provider resource, unsupported, limitations, excluded, and failed. - T050 [US4] Update
apps/platform/app/Support/Baselines/BaselineCompareExplanationRegistry.phpandapps/platform/app/Support/ReasonTranslation/ReasonPresenter.php; search for OperationRun baseline-compare presentation helpers directly touched by the implementation and update any matches so primary operator text no longer uses old reason strings. - T051 [US4] Confirm
apps/platform/app/Livewire/BaselineCompareEvidenceGapTable.phpuses existing data paths and does not add a new action, route, modal, drawer, or layout pattern. - T052 [US3] Update
apps/platform/app/Services/Evidence/Sources/BaselineDriftPostureSource.phponly if needed to avoid treating blocked/limited compare runs as complete before Spec 385. - T053 [US4] If implementation changes route/layout/action structure instead of labels/groups only, update the active spec/plan plus
docs/ui-ux-enterprise-audit/route-inventory.md,docs/ui-ux-enterprise-audit/design-coverage-matrix.md, anddocs/ui-ux-enterprise-audit/page-reports/ui-015-baseline-compare.mdbefore continuing.
Phase 9: Legacy Removal And Scope Guard
Purpose: Remove old authoritative truth and prevent accidental compatibility scope.
- T054 [US1] Search
apps/platform/appandapps/platform/testsforambiguous_match,policy_record_missing,foundation_not_policy_backed,missing_policy,missing_current,unsupported_subject,unsupported_subjects,coverage_unproven, andstrategy_failed; remove or convert compare-result usages to the new semantics. - T055 [US1] Keep any old string that remains only if it is outside baseline compare result truth or is explicitly transitional fixture input; document the boundary in the nearest test or close-out note.
- T056 [US1] Confirm no legacy result-code mapper, old OperationRun context reader, dual old/new result reader, or compatibility alias is introduced.
- T057 [US4] Confirm no Spec 384 resolution UI, manual bind/exclude/accept-limitation workflow, or operator decision screen is implemented.
- T058 [US3] Confirm no Spec 385 Evidence Snapshot readiness final mapping, Review Pack publication blocker mapping, or customer-facing wording is implemented.
- T059 [US4] Confirm no Management Report/PDF runtime or report wording work is included.
Phase 10: Validation And Close-Out
Purpose: Prove the implementation and document the exact operational impact.
- T060 Run
cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Unit/Support/Baselines/CompareSemantics. - T061 Run
cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Unit/Support/Baselines/Matching tests/Unit/Baselines/CompareStrategyRegistryTest.php. - T062 Run
cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Baselines/BaselineCompareGapClassificationTest.php tests/Feature/Baselines/BaselineCompareAmbiguousMatchGapTest.php tests/Feature/Baselines/BaselineCompareProviderResourceBindingCanonicalIdentityTest.php tests/Feature/Baselines/BaselineCompareExecutionGuardTest.php tests/Feature/Baselines/BaselineCompareResumeTokenTest.php. - T063 Run
cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Filament/BaselineCompareExplanationSurfaceTest.php tests/Feature/Filament/BaselineCompareLandingWhyNoFindingsTest.php tests/Feature/Filament/BaselineCompareSummaryConsistencyTest.php tests/Feature/Filament/BaselineCompareEvidenceGapTableTest.php. - T064 Run
cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Evidence/BaselineDriftPostureSourceTest.php tests/Feature/ReviewPack/Spec347ReviewPackReadinessSemanticsTest.php tests/Feature/ReviewPack/Spec349ReviewPackResolutionGuidanceTest.php. - T065 Run a PostgreSQL lane only if implementation adds migrations, JSONB indexes/query behavior, locks, or constraints.
- T066 Run a browser smoke test only if implementation changes rendered layout, navigation, actions, or JavaScript behavior beyond labels/groups.
- T067 Run
cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent. - T068 Run
git diff --check. - T069 Record
specs/383-baseline-result-semantics/implementation-close-out.mdwith Livewire v4 compliance, provider registration location, global search status, destructive/high-impact action status, asset strategy, tests run, browser decision, and deployment impact.
Dependencies
- Phase 1 must finish before runtime work.
- Phases 2-4 should be written before or alongside implementation changes.
- Phase 5 unblocks Phases 6 and 7.
- Phase 6 must complete before OperationRun/gap aggregation can be trusted.
- Phase 7 unblocks Phase 8.
- Phase 9 and Phase 10 validate the completed implementation.
Parallel Opportunities
- T007-T011 can be drafted in parallel.
- T012-T020 can be drafted in parallel if each test file remains scoped.
- T021-T026 can be drafted in parallel with the core semantics tests.
- T027-T034 can be implemented in parallel after names are agreed, but mapping methods should converge before integration.
- T035-T039 and T040-T048 should be coordinated because they touch shared reason mappings.
- T060-T064 can be run independently after implementation, but close-out should cite the complete targeted set.
Explicit Non-Goals
- Do not add new persisted entities/tables/artifacts without updating spec and plan first.
- Do not add new routes, navigation entries, Filament actions, modals, drawers, wizards, panel providers, or assets.
- Do not add operator resolution UI.
- Do not change final Evidence Snapshot readiness, Review Pack readiness, or customer-facing report/review wording.
- Do not add historical payload mappers, OperationRun context compatibility readers, or old reason aliases.
- Do not create a generic workflow engine, report engine, provider framework, badge framework, or evidence readiness framework.