TenantAtlas/tests/Unit
ahmido 8ae7a7234e feat/040-inventory-core (#43)
Summary

Implements Inventory Core (Spec 040): a tenant-scoped, mutable “last observed” inventory catalog + sync run logging, with deterministic selection hashing and safe derived “missing” semantics.

This establishes the foundation for Inventory UI (041), Dependencies Graph (042), Compare/Promotion (043), and Drift (044).

What’s included
	•	DB schema
	•	inventory_items (unique: tenant_id + policy_type + external_id; indexes; last_seen_at, last_seen_run_id)
	•	inventory_sync_runs (tenant_id, selection_hash/payload, status, started/finished, counts, error_codes, correlation_id)
	•	Selection hashing
	•	Deterministic selection_hash via canonical JSON (sorted keys + sorted arrays) + sha256
	•	Sync semantics
	•	Idempotent upsert (no duplicates)
	•	Updates last_seen_* when observed
	•	Enforces tenant scoping for all reads/writes
	•	Guardrail: inventory sync does not create snapshots/backups
	•	Missing semantics (derived)
	•	“missing” computed relative to latest completed run for same (tenant_id, selection_hash)
	•	Low confidence when latest run is partial/failed or had_errors=true
	•	Selection isolation (runs for other selections don’t affect missing)
	•	deleted is reserved (not produced here)
	•	Safety
	•	meta_jsonb whitelist enforced (unknown keys dropped; never fail sync)
	•	Safe error persistence (no bearer tokens / secrets)
	•	Locking to prevent overlapping runs for same tenant+selection
	•	Concurrency limiter (global + per-tenant) and throttling resilience (429/503 backoff + jitter)

Tests

Added Pest coverage for:
	•	selection_hash determinism (array order invariant)
	•	upsert idempotency + last_seen updates
	•	missing derived semantics + selection isolation
	•	low confidence missing on partial/had_errors
	•	meta whitelist drop (no exception)
	•	lock prevents overlapping runs
	•	no snapshots/backups side effects
	•	safe error persistence (no bearer tokens)

Non-goals
	•	Inventory UI pages/resources (Spec 041)
	•	Dependency graph hydration (Spec 042)
	•	Cross-tenant compare/promotion flows (Spec 043)
	•	Drift analysis dashboards (Spec 044)

Review focus
	•	Data model correctness + indexes/constraints
	•	Selection hash canonicalization (determinism)
	•	Missing semantics (latest completed run + confidence rule)
	•	Guardrails (no snapshot/backups side effects)
	•	Safety: error_code taxonomy + safe persistence/logging

Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local>
Reviewed-on: #43
2026-01-07 14:54:24 +00:00
..
BackupScheduling feat/032-backup-scheduling-mvp (#34) 2026-01-05 04:22:13 +00:00
Inventory feat/040-inventory-core (#43) 2026-01-07 14:54:24 +00:00
AppProtectionPolicyNormalizerTest.php feat/009-app-protection-policy (#11) 2025-12-29 16:11:50 +00:00
AssignmentBackupServiceTest.php fix: improve assignment capture/restore and filter name handling (#8) 2025-12-28 13:59:12 +00:00
AssignmentFetcherTest.php 013-scripts-management (#19) 2026-01-01 22:02:30 +00:00
AssignmentFilterResolverTest.php feat/004-assignments-scope-tags (#4) 2025-12-23 21:49:58 +00:00
AssignmentRestoreServiceTest.php feat/009-app-protection-policy (#11) 2025-12-29 16:11:50 +00:00
BackupItemTest.php feat/004-assignments-scope-tags (#4) 2025-12-23 21:49:58 +00:00
BulkActionPermissionTest.php feat/031-tenant-portfolio-context-switch (#32) 2026-01-04 21:28:08 +00:00
BulkBackupSetDeleteJobTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkBackupSetForceDeleteJobTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkBackupSetRestoreJobTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkOperationAbortMethodTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkOperationRunProgressTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkPolicyDeleteJobTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkPolicyExportJobTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkPolicyVersionForceDeleteJobTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkPolicyVersionPruneJobTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkPolicyVersionRestoreJobTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkRestoreRunDeleteJobTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
BulkRestoreRunRestoreJobTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
CircuitBreakerTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
CompliancePolicyNormalizerTest.php feat(007): device config & compliance snapshot/restore improvements (#9) 2025-12-29 12:46:20 +00:00
DefaultPolicyNormalizerDiffTest.php feat(007): device config & compliance snapshot/restore improvements (#9) 2025-12-29 12:46:20 +00:00
DeviceConfigurationPolicyNormalizerTest.php fix: improve assignment capture/restore and filter name handling (#8) 2025-12-28 13:59:12 +00:00
ExampleTest.php Initial commit from Specify template 2025-12-10 22:27:21 +01:00
FoundationMappingServiceTest.php feat(006): foundations + assignment mapping and preview-only restore guard (#7) 2025-12-26 23:44:31 +00:00
FoundationSnapshotServiceTest.php feat/012-windows-update-rings (#18) 2026-01-01 10:44:17 +00:00
GraphClientEndpointResolutionTest.php feat: endpoint security restore execution (023) (#25) 2026-01-03 22:44:08 +00:00
GraphClientScopeTest.php dev-merges/c709b36 (#3) 2025-12-21 23:15:12 +00:00
GraphContractFallbackTest.php feat: merge 001-filament-json 2025-12-14 20:23:18 +01:00
GraphContractRegistryActualDataTest.php feat/009-app-protection-policy (#11) 2025-12-29 16:11:50 +00:00
GraphContractRegistrySettingsApplySanitizerTest.php feat: merge 001-filament-json 2025-12-14 20:23:18 +01:00
GraphContractRegistrySettingsWriteStrategyTest.php dev-merges/c709b36 (#3) 2025-12-21 23:15:12 +00:00
GraphContractRegistryTest.php feat(007): device config & compliance snapshot/restore improvements (#9) 2025-12-29 12:46:20 +00:00
GroupResolverTest.php feat/004-assignments-scope-tags (#4) 2025-12-23 21:49:58 +00:00
ManagedDeviceAppConfigurationNormalizerTest.php feat/017-policy-types-mam-endpoint-security-baselines (#23) 2026-01-03 02:06:35 +00:00
MicrosoftGraphClientListPoliciesSelectTest.php feat/017-policy-types-mam-endpoint-security-baselines (#23) 2026-01-03 02:06:35 +00:00
MicrosoftGraphClientTest.php Intune RBAC: graceful unsupported-account handling, health-check fixes, tests and docs updates 2025-12-13 01:25:06 +01:00
ODataTypeValidationTest.php feat/011-restore-run-wizard (#37) 2026-01-07 01:40:04 +00:00
PolicyCaptureOrchestratorTest.php feat/017-policy-types-mam-endpoint-security-baselines (#23) 2026-01-03 02:06:35 +00:00
PolicyNormalizerRoutingTest.php fix: improve assignment capture/restore and filter name handling (#8) 2025-12-28 13:59:12 +00:00
PolicyNormalizerSettingsCatalogFlattenTest.php dev-merges/c709b36 (#3) 2025-12-21 23:15:12 +00:00
PolicyNormalizerSettingsCatalogTest.php dev-merges/c709b36 (#3) 2025-12-21 23:15:12 +00:00
PolicyNormalizerTest.php feat/027-enrollment-config-subtypes (#31) 2026-01-04 13:25:15 +00:00
PolicyPickerOptionLabelTest.php 015-policy-picker-ux (#21) 2026-01-02 13:59:15 +00:00
PolicySnapshotServiceTest.php feat/027-enrollment-config-subtypes (#31) 2026-01-04 13:25:15 +00:00
PolicyVersionEligibilityTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
RbacOnboardingServiceTest.php Intune RBAC: graceful unsupported-account handling, health-check fixes, tests and docs updates 2025-12-13 01:25:06 +01:00
RestoreRunDeletableTest.php feat/005-bulk-operations (#5) 2025-12-25 13:32:36 +00:00
RestoreRunTest.php feat/004-assignments-scope-tags (#4) 2025-12-23 21:49:58 +00:00
ScopeTagResolverTest.php feat/004-assignments-scope-tags (#4) 2025-12-23 21:49:58 +00:00
ScriptsPolicyNormalizerTest.php 013-scripts-management (#19) 2026-01-01 22:02:30 +00:00
SettingsCatalogPolicyNormalizerTest.php feat/017-policy-types-mam-endpoint-security-baselines (#23) 2026-01-03 02:06:35 +00:00
TenantCurrentTest.php feat/012-windows-update-rings (#18) 2026-01-01 10:44:17 +00:00
TenantPermissionServiceTest.php feat(006): foundations + assignment mapping and preview-only restore guard (#7) 2025-12-26 23:44:31 +00:00
TenantResourceConsentUrlTest.php dev-merges/c709b36 (#3) 2025-12-21 23:15:12 +00:00
TenantScopeTest.php feat: TenantPilot v1 - Complete implementation (Phases 1-12) 2025-12-12 02:27:54 +01:00
VersionDiffTest.php feat: TenantPilot v1 - Complete implementation (Phases 1-12) 2025-12-12 02:27:54 +01:00
WindowsDriverUpdateProfileNormalizerTest.php feat/018-driver-updates-wufb (#27) 2026-01-04 00:38:54 +00:00