Repository navigation
feat(phase-7): Meta Ads Read, Controlled Execution & 18-Test Acceptance Sign-Off - #8
Merged
Merged
Conversation
… acceptance suite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 7 Completion & Full 18-Test Acceptance Report
Branch:
feat/phase-7-ads-and-acceptanceMigration:
0008_phase6_publishing_and_insights->0009_phase7_ads_and_controlled_executionMonthly Cloud Spend:
$0/month(Supabase Free + Render Free + Cloudflare Pages Free + Sentry Free)1. Phase 7 Delivered Capabilities — Ads Read & Controlled Execution
1.1 Database Schema & Tenant Isolation (
database/migrations/versions/0009_phase7_ads_and_controlled_execution.py,database/models.py)ad_accounts: permission-checked ad account inventory bound to(workspace_id, client_id)and(workspace_id, meta_connection_id)with spend cap and amount spent tracking.ad_campaign_snapshots,ad_set_snapshots,ad_snapshots: read-only campaign -> ad-set -> ad hierarchy and performance snapshots (spend_cents,impressions,clicks,conversions,targeting_json,creative_summary_json).ad_campaign_drafts: version- and SHA-256 content-hash-bound campaign drafts withvalidation_passed,validation_report,approval_id,remote_campaign_id, and partial unique idempotency indexuq_ad_drafts_ws_idempotency.updated_attriggers, least-privilegemetuse_appCRUD grants, andENABLE+FORCE ROW LEVEL SECURITYacross all 5 tables.1.2 Shared Contracts, Config & RBAC
packages/shared/enums.py: addedAdDraftStatus,AdObjective, Phase 7AuditActionentries (ads.accounts_synced,ads.insights_synced,ads.draft_created,ads.draft_updated,ads.draft_validated,ads.draft_approval_requested,ads.campaign_executed,ads.budget_approval_requested,ads.budget_changed,ads.mutation_failed), andErrorCodevalues (ADS_APPROVAL_REQUIRED,ADS_APPROVAL_STALE,ADS_DRAFT_VALIDATION_FAILED,ADS_KILL_SWITCH_ACTIVE,ADS_BUDGET_CONFIRMATION_REQUIRED,ADS_SPEND_CAP_EXCEEDED).packages/shared/config.py: addedads_kill_switch: bool = Falseandads_max_daily_budget_cents: int = 500_000(both exposed insafe_summary()).packages/auth/rbac.py: addedads:*for owner/admin roles,ads:read+ads:write(noads:execute) foragency_member, andads:readforclient_reviewer/client_viewerto preserve separation of duties.1.3 Ads Engine, Workers, FastAPI Routes &
/adsConsolepackages/meta_integrations/ads.py&workers/ads_ops/__init__.py:meta_ads_readcapability and only imports explicitly selectedAD_ACCOUNTassets.version_number, recompute SHA-256content_hash, reset validation, and automatically invalidate any pending/approvedcampaign_executionapproval.ADS_KILL_SWITCH, backendmeta_ads_managecapability, explicit version/hash-bound human approval (campaign_execution/budget_change), explicit human confirmation flag on budget changes (never auto-increases spend), remote-state re-read before retrying ambiguous timeouts, and append-onlyAuditLogentries with exactbefore/aftervalues and actor attribution.apps/api/routes/ads.py(wired inapps/api/deps.pyandapps/api/main.py):GET /ads/accounts,POST /ads/sync,GET /ads/campaignsGET/POST /ads/drafts,PATCH /ads/drafts/{draft_id},POST /ads/drafts/{draft_id}/validatePOST /ads/drafts/{draft_id}/request-approval,POST /ads/drafts/{draft_id}/execute(Idempotency-Key)POST /ads/campaigns/{campaign_id}/budget/request-approval,POST /ads/campaigns/{campaign_id}/budget/applyapps/web/src/lib/ads-api.ts,apps/web/src/app/(app)/ads/page.tsx, andapps/web/src/components/layout/app-shell.tsx(Ads Ops/ads,Agency OS · Phase 7).2. Full 18-Test End-to-End Acceptance Verification Matrix (Section 16)
All 63 unit tests and all 24 live Supabase PostgreSQL 17.12
FORCE RLSintegration tests passed cleanly in a single verification run (pytest tests/unit -q->63 passed;pytest tests/integration -v->24 passed in 238.08s):test_m1_db_rls.py,test_tenancy_services.py,test_phase2..7_*_rls.py(all 7 phases)test_tenancy_services.py::test_creator_onboarding_works_without_ad_account_and_caps_at_onetest_phase5_meta_rls.py+test_phase5_meta_connections.pytest_phase5_meta_rls.pytest_phase5_meta_rls.pytest_phase5_meta_rls.py+test_phase5_meta_connections.pytest_phase2_rls_and_jobs.py+test_phase2_workers_and_muse.pytest_phase2_rls_and_jobs.py+test_phase2_workers_and_muse.pytest_phase3_video_rls.py+test_phase3_video_gateway.pytest_phase3_video_rls.py+test_phase3_video_gateway.pytest_phase4_editing_rls.py+test_phase4_cloud_editing.pytest_phase4_editing_rls.py+test_phase4_cloud_editing.pytest_phase4_editing_rls.py+test_phase7_ads_rls.pytest_phase6_publishing_rls.pytest_phase6_publishing_rls.pytest_phase7_ads_rls.py+test_phase7_ads.pytest_phase2_rls_and_jobs.py,test_phase3_video_rls.py,test_phase4_editing_rls.pyapps/web/out/), frontend source, settings & scrubberstest_acceptance_18_credential_scan.py+test_phase5_meta_rls.py3. Build, Lint & Quality Gate Summary
ruff format --check .: 152 files formattedruff check .: 0 errorsmypy apps packages database workers tests: 123 source files, 0 issuesalembic heads:0009_phase7_ads_and_controlled_execution (head)pnpm --dir apps/web lint&typecheck: 0 errorsNEXT_PUBLIC_API_URL=https://metuse-ai-api-preview.onrender.com pnpm --dir apps/web build: 16/16 static routes exported (including/ads)