## Summary - implement Spec 177 inventory coverage truth across resolver, badges, KPIs, coverage page, and operation run detail surfaces - add repo-native spec artifacts for the feature under `specs/177-inventory-coverage-truth` - add unit, feature, and browser coverage for truth derivation, continuity, and inventory item filter/pagination smoke paths ## Testing - `vendor/bin/sail bin pint --dirty --format agent` - focused Spec 177 browser smoke file passed with 2 tests / 57 assertions - extended inventory-focused test pack passed with 52 tests / 434 assertions Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #208
5.6 KiB
Phase 1 Data Model: Inventory Coverage Truth (177)
Existing Persisted Truth
OperationRun as coverage basis
Represents the canonical execution record for inventory syncs and remains the source of per-type sync truth.
Relevant existing fields
workspace_idtenant_idtypestatusoutcomesummary_countsfailure_summarycontextstarted_atcompleted_at
Relevant existing inventory context shape
context.inventory.coverage.policy_typescontext.inventory.coverage.foundation_types- each entry stores at minimum
status - optional fields already supported by
InventoryCoveragenormalization:item_counterror_code
Existing invariant
InventoryCoverage::fromContext()is the canonical parser for run coverage payload.
InventoryItem
Represents last observed tenant inventory rows and remains the source of current observed-item counts.
Relevant existing fields
workspace_idtenant_idpolicy_typeexternal_iddisplay_namecategoryplatformmeta_jsonblast_seen_atlast_seen_operation_run_id
Existing invariant
- Observed rows prove last observation only. They do not by themselves prove current tenant coverage completeness.
InventoryPolicyTypeMeta + capability metadata
Represents product support and capability reference for supported and foundation types.
Relevant existing fields and derived attributes
typelabelcategoryplatformrestorerisk- foundation flag
- dependency support from
CoverageCapabilitiesResolver
Existing invariant
- Capability metadata is product support truth, not tenant coverage truth.
New Derived Runtime Contract
TenantCoverageTruth
Derived runtime contract that answers the operator question: which supported types are currently covered for this tenant, which types need follow-up, and which run establishes that statement.
Proposed fields
tenant_idbasis_run_idnullablebasis_run_outcomenullablebasis_completed_atnullablehas_current_coverage_resultbooleansupported_type_countsucceeded_type_countfailed_type_countskipped_type_countunknown_type_countfollow_up_type_countobserved_item_totalrowslist ofTenantCoverageTypeTruth
Derived invariants
- Exactly one row exists for each supported policy type and foundation type currently in the product support catalog.
follow_up_type_count = failed + skipped + unknown.has_current_coverage_resultis true only when a completed inventory-sync basis run with parseable payload exists.- The basis run is chosen independently from current item counts.
TenantCoverageTypeTruth
Derived row contract for one supported type.
Proposed fields
typesegment(policyorfoundation)labelcategoryplatformnullablecoverage_state(succeeded,failed,skipped,unknown)follow_up_requiredbooleanobserved_item_countbasis_error_codenullablerestore_modenullablerisk_levelnullablesupports_dependenciesboolean
Derived invariants
follow_up_requiredis true forfailed,skipped, andunknown; false only forsucceeded.observed_item_count > 0does not changecoverage_state.coverage_state = unknownwhen the type is supported but absent from the basis run payload.basis_error_codeis allowed only for non-succeeded payload-backed states.
Derived State Family
Coverage state family
This feature introduces one derived state family for tenant coverage rows:
Succeeded- the basis run reported the type as successfully processed
Failed- the basis run reported the type as attempted and failed
Skipped- the basis run reported the type as intentionally skipped or not processed during that run
Unknown- no current coverage result exists for the supported type in the basis run
Behavioral consequence
Failed,Skipped, andUnknownall suppress calm claims and increment follow-up counts.Unknownis derived, not persisted.
Relationships
- One
TenantCoverageTruthresolves for one tenant at a time. - One
TenantCoverageTruthmay reference zero or one basisOperationRun. - One
TenantCoverageTruthcontains one row per supported product type fromInventoryPolicyTypeMeta::supported()andInventoryPolicyTypeMeta::foundations(). - Each
TenantCoverageTypeTruthjoins one supported type to zero or one payload-backed status from the basis run and zero or moreInventoryItemrows from the current tenant observation set.
Selection Rules
Basis run selection
- candidate runs are
OperationRunrows where:tenant_idmatches the selected tenanttype = inventory_syncstatus = completed
- candidates are ordered by:
completed_at DESCid DESC
- the selected basis run is the first candidate whose
context.inventory.coveragepayload can be parsed byInventoryCoverage::fromContext() - if no candidate qualifies, the tenant has no current coverage basis run
Unknown derivation
- if a supported type is absent from both
policy_typesandfoundation_typesin the selected basis payload, the type isUnknown - absence from the basis payload is not converted into
Skipped - item presence from older runs does not upgrade
Unknown
Validation Rules
- No schema migration is required.
- No new persisted state is introduced.
- Coverage rows must remain tenant-scoped.
- Capability metadata must not alter the derived coverage state.
- Surfaces may cite the basis run only when they can do so without violating authorization.