Automated PR provided by Codex via Gitea API. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #482
15 KiB
Tasks: Spec 415 - Generic Content-Backed Capture
Input: Design documents from /specs/415-generic-content-backed-capture/
Prerequisites: spec.md, plan.md, checklists/requirements.md, completed Spec 414 context
Test Governance Checklist
- Lane assignment is named and is the narrowest sufficient proof for the changed behavior.
- New or changed tests stay in Unit/Feature/PostgreSQL lanes; any heavy-governance or browser addition is explicit and requires spec amendment.
- Shared helpers, factories, seeds, fixtures, provider setup, workspace context, membership context, and Graph fakes stay explicit and opt-in.
- Planned validation commands cover the change without pulling in unrelated lane cost.
- Browser proof is explicitly
N/A - no rendered UI surface changed. - Human Product Sanity is
N/A - no product surface changed. - Any material budget, baseline, trend, or escalation note is recorded in the implementation report.
Phase 1: Preflight And Repo Verification
Purpose: Confirm the active repo truth before runtime implementation starts.
- T001 Capture branch, HEAD,
git status --short, and Spec 414 dependency status inspecs/415-generic-content-backed-capture/implementation-report.md. - T002 Confirm
specs/414-tcm-first-coverage-core-cutover/is completed/validated context only and do not modify any Spec 414 artifact. - T003 Inspect
apps/platform/app/Models/TenantConfigurationResourceType.php,apps/platform/app/Models/TenantConfigurationSupportedScope.php,apps/platform/app/Services/TenantConfiguration/ResourceTypeRegistry.php,SupportedScopeResolver.php, andClaimGuard.phpto map the existing kernel dependency surface. - T004 Inspect
apps/platform/database/migrations/2026_06_25_000414_create_tenant_configuration_kernel_tables.phpfor the initial resource types, source classes, supported scopes, and no-tenant_idkernel posture. - T005 Confirm whether
tenant_configuration_resources/tenant_configuration_resource_evidenceor repo-equivalent models/tables already exist; if they do, document the exact equivalent and adjust implementation without duplicate tables. - T006 Inspect
apps/platform/config/graph_contracts.phpandapps/platform/app/Services/Graph/GraphContractRegistry.phpfor explicit contracts related to the initial 414 resource types. - T007 Confirm no rendered UI surface, route, navigation entry, Filament provider/panel, review/report/evidence output, or customer-visible v2 activation is required. If it is required, stop and patch
spec.md,plan.md, andtasks.md.
Phase 2: Tests First - Pure Behavior
Purpose: Prove source resolution, normalization, hashing, redaction, and outcomes before implementation.
- T008 [P] Add resolver unit tests in
apps/platform/tests/Unit/Support/TenantConfiguration/Spec415CoverageSourceContractResolverTest.phpcovering explicit contract, missing contract, beta blocked by default, unsupported/out-of-scope skip, and no endpoint guessing. - T009 [P] Add normalizer/hash unit tests in
apps/platform/tests/Unit/Support/TenantConfiguration/Spec415GenericPayloadNormalizerTest.phpcovering stable key ordering, configured volatile-field handling, metadata separation, and deterministic hash. - T010 [P] Add redaction unit tests in
apps/platform/tests/Unit/Support/TenantConfiguration/Spec415CoverageRedactionTest.phpcovering token/secret-like keys and sanitized permission/source context. - T011 [P] Add outcome unit tests in
apps/platform/tests/Unit/Support/TenantConfiguration/Spec415CoverageCaptureOutcomeTest.phpcovering allowed v2 outcomes and absence of old v1 gap vocabulary. - T012 [P] Add OperationRun summary unit/guard coverage ensuring Spec 415 uses existing
OperationSummaryKeyskeys unless a tested canonical key-list extension is explicitly implemented.
Phase 3: Tests First - Runtime And Persistence
Purpose: Prove the end-to-end safety contract with fake provider calls.
- T013 [P] Add persistence feature tests in
apps/platform/tests/Feature/TenantConfiguration/Spec415CoverageEvidencePersistenceTest.phpfor concrete resource upsert, append-only evidence writes, JSONB raw/normalized payloads, payload hash, source metadata, and OperationRun link. - T014 [P] Add provider connection scope tests in
apps/platform/tests/Feature/TenantConfiguration/Spec415ProviderConnectionScopeTest.phpproving same workspace/environment allowed and cross-workspace or cross-environment provider connections rejected. - T015 [P] Add authorization tests in
apps/platform/tests/Feature/TenantConfiguration/Spec415CoverageCaptureAuthorizationTest.phpproving non-member 404, missing environment entitlement 404, missing capability 403, readonly denial, and authorized start. - T016 [P] Add OperationRun tests in
apps/platform/tests/Feature/TenantConfiguration/Spec415CoverageCaptureOperationRunTest.phpprovingtenant_configuration.capturerun creation/reuse, queued job dispatch, service-owned transitions, sanitized context, and numeric summary counts. - T017 [P] Add fake Graph capture tests in
apps/platform/tests/Feature/TenantConfiguration/Spec415GenericContentBackedCaptureTest.phpprovingGraphClientInterfaceis used and real Graph/TCM is never called. - T018 [P] Add no-legacy/no-UI guard tests in
apps/platform/tests/Feature/TenantConfiguration/Spec415NoLegacyNoUiActivationTest.phpproving notenant_idownership field, no v1 adapter/dual-write/fallback reader/old snapshot promotion, no old gap outcomes, and no Filament resource/page/route/navigation activation.
Phase 4: Persistence Implementation
Purpose: Add durable v2 resource/evidence truth only if missing.
- T019 Add migration under
apps/platform/database/migrations/fortenant_configuration_resourcesif no equivalent exists, withworkspace_id,managed_environment_id,provider_connection_id,resource_type_id, source class, canonical identity fields, latest coverage/evidence/identity/claim state, timestamps, and notenant_id. - T020 Add migration under
apps/platform/database/migrations/fortenant_configuration_resource_evidenceif no equivalent exists, with resource/workspace/environment/provider/run links, source endpoint/version/schema metadata, JSONB raw payload, JSONB normalized payload, payload hash, redacted permission context, coverage/evidence state, captured timestamp, and notenant_id. - T021 Add same-scope provider-connection enforcement through database constraints where practical and service validation where cross-table constraints cannot safely express the rule.
- T022 Add targeted indexes only for known query paths: ownership lookup, resource latest evidence lookup, captured timestamp lookup, and payload hash lookup. Do not add broad JSONB GIN indexes unless a real query path exists.
- T023 Add models
apps/platform/app/Models/TenantConfigurationResource.phpandapps/platform/app/Models/TenantConfigurationResourceEvidence.phpwith casts, relationships, guarded/fillable convention matching sibling models, and no Filament Resource. - T024 Add factories under
apps/platform/database/factories/for new models with explicit workspace/managed-environment/provider-connection setup only.
Phase 5: Source Contracts, Normalization, Redaction, Outcomes
Purpose: Implement bounded capture mechanics without provider endpoint guessing.
- T025 Add
apps/platform/app/Support/TenantConfiguration/CaptureOutcome.phpor repo-equivalent bounded result type with onlycaptured,capture_blocked_missing_contract,capture_blocked_permission,capture_blocked_beta,capture_blocked_unsupported, andcapture_failed. - T026 Add
apps/platform/app/Services/TenantConfiguration/CoverageSourceContractResolver.phpto resolve capture contracts from Coverage v2 resource types andGraphContractRegistry/config/graph_contracts.php, return an explicit contract-or-block decision for each of the 8 initial Spec 414 resource types, block beta by default, block missing contracts, and expose source metadata without hardcoding endpoints. - T027 Add
apps/platform/app/Services/TenantConfiguration/GenericPayloadNormalizer.phpfor deterministic generic normalization and hash input creation without semantic compare/render/restore mapping. - T028 Add redaction handling in a focused TenantConfiguration helper or reuse an existing repo sanitizer if present; cover required secret/token keys and sanitized exception context.
- T029 Add
apps/platform/app/Services/TenantConfiguration/CoverageCaptureOutcomeSummarizer.phpto map outcomes to canonical OperationRun summary keys (total,processed,succeeded,skipped,failed,errors_recorded) unless a testedOperationSummaryKeysextension is explicitly justified.
Phase 6: Start Service, Authorization, Queue, OperationRun
Purpose: Make capture observable and authorized without rendered UI.
- T030 Add
tenant_configuration.capturetoapps/platform/app/Support/OperationRunType.phpand any current repo operation catalog/config path required for operation labels/capabilities. - T031 Implement
apps/platform/app/Services/TenantConfiguration/StartTenantConfigurationCapture.phpor repo-equivalent action service that authorizes actor/scope, validates provider connection scope, creates/reuses OperationRun, dispatches the capture job, and writes safe audit metadata. - T032 Use
Capabilities::EVIDENCE_MANAGEas the default start capability; if implementation adds a more specific capability, updateapps/platform/app/Support/Auth/Capabilities.php,apps/platform/app/Services/Auth/RoleCapabilityMap.php, and related capability tests in this spec. - T033 Add
apps/platform/app/Jobs/TenantConfiguration/CaptureTenantConfigurationEvidenceJob.phpor repo-equivalent queued job that loads the OperationRun, marks it running and then terminalcompletedwith the correctOperationRunOutcome/ failure summary throughOperationRunService, and never persists raw payloads in job-visible context. - T034 Ensure queued remote/provider work uses idempotent inputs, sanitized context, and no queued DB notification outside the central OperationRun lifecycle.
- T035 Add or extend audit recording through the existing
AuditRecorder/AuditEventBuilderpath for capture start/completion/failure attempts, using stable action IDstenant_configuration.capture.started,tenant_configuration.capture.completed, andtenant_configuration.capture.failed, with actor, workspace, managed environment, provider connection, OperationRun, resource type counts, and no raw payloads/secrets.
Phase 7: Capture Implementation
Purpose: Fetch eligible payloads and write v2 evidence.
- T036 Add
apps/platform/app/Services/TenantConfiguration/GenericContentEvidenceCaptureService.phpto orchestrate per-type resolution, fakeable GraphClientInterface fetch, normalization, upsert, evidence write, and outcome collection. - T037 Add
apps/platform/app/Services/TenantConfiguration/CoverageResourceUpserter.phpto upsert concrete resource rows by workspace/environment/provider/resource type/canonical key and reject display-name-only identity. - T038 Add
apps/platform/app/Services/TenantConfiguration/CoverageEvidenceWriter.phpto append evidence rows, link OperationRun, persist raw/normalized payload, hash, source metadata, redacted permission context, and coverage/evidence state. - T039 Implement source behavior for all 8 Spec 414 initial resource types only: each TCM-aligned type captured or blocked with missing-contract reason, the Graph v1 fallback type captured or blocked with contract reason, and
roleScopeTagbeta blocked by default. - T040 Ensure no old v1 gap reason (
policy_record_missing,foundation_not_policy_backed,meta_fallback,ambiguous_match,raw_gap_count,primary_gap_count) appears in v2 capture outcomes.
Phase 8: Product Surface, No-Legacy, And Report
Purpose: Prove the slice stayed bounded and inactive.
- T041 Confirm no files under
apps/platform/app/Filament,apps/platform/resources/views, route files, panel providers, navigation definitions, customer outputs, review/report/evidence pages, or restore readiness surfaces changed. If any changed, stop and amend spec/plan/tasks before continuing. - T042 Confirm any visible OperationRun completion notification or Monitoring -> Operations row uses the existing generic lifecycle path only, with no feature-local notification copy, custom run link, rendered capture control, or custom operation UI.
- T043 Complete
specs/415-generic-content-backed-capture/implementation-report.mdwith candidate gate, dirty state, files changed, tables/models added, source contracts used/blocked, capture eligibility matrix, OperationRun behavior, RBAC proof, redaction/log proof, no-tenant_id, no-legacy/no-dual-truth, tests run, browser/no-browser, deployment impact, and deferred work. - T044 Confirm no completed historical spec was rewritten or stripped of close-out/validation/task history.
- T045 Confirm deployment impact: migrations yes, queue worker yes, env vars no unless discovered, scheduler no unless discovered, storage no unless discovered, assets no,
filament:assetsnot required.
Phase 9: Validation
Purpose: Run the narrowest proof set.
- T046 Run
cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent. - T047 Run
cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Unit/Support/TenantConfiguration. - T048 Run
cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/TenantConfiguration. - T049 Run
cd apps/platform && ./vendor/bin/sail php vendor/bin/pest -c phpunit.pgsql.xml tests/Feature/TenantConfigurationif migrations add JSONB fields, PostgreSQL checks, composite FKs, partial indexes, or same-scope provider constraints. - T050 Run
git diff --check. - T051 Record validation results, unrelated failures if any, and final dirty state in
specs/415-generic-content-backed-capture/implementation-report.md.
Dependency And Ordering Notes
- T001-T007 must finish before implementation.
- T008-T018 should be written before or alongside the implementation they prove.
- T019-T024 block persistence-dependent service tests.
- T025-T029 block capture service implementation.
- T030-T035 block queue/OperationRun tests.
- T041 is a hard stop check before final validation.
Non-Goals For Implementers
- Do not activate Coverage v2 in any customer/operator UI.
- Do not create Filament resources/pages/actions or routes.
- Do not implement compare, render, restore/apply, identity engine, full TCM catalog, legacy removal, or browser-visible proof.
- Do not read v1 snapshots as v2 evidence.
- Do not add compatibility aliases, fallback readers, dual writes, or old gap vocabulary.