Repository navigation
feat(phase-6): Publishing & Insights - #7
Merged
Merged
Conversation
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 6 Completion Report — Publishing & Insights
Branch:
feat/phase-6-publishing-and-insightsMigration:
0007_phase5_meta_connections->0008_phase6_publishing_and_insightsMonthly Cloud Spend:
$0/month(Supabase Free + Render Free + Cloudflare Pages Free + Sentry Free)1. Delivered Capabilities
1.1 Database Schema & Tenant Isolation (
database/migrations/versions/0008_phase6_publishing_and_insights.py,database/models.py)content_calendars: client-scoped planning calendars with timezone and composite(workspace_id, client_id)foreign key.content_items: approval-gated content items bound to(workspace_id, creative_version_id)and(workspace_id, connected_asset_id)withmedia_type,status,scheduled_for, caption, carousel items, and approval snapshot metadata.publishing_jobs: execution tracking table with partial unique idempotency indexuq_publishing_jobs_ws_idempotencyon(workspace_id, idempotency_key) WHERE idempotency_key IS NOT NULL,container_id,container_status,remote_state_checked_at, andattempt_count.publishing_results: immutable publish receipts with unique(workspace_id, connected_asset_id, remote_media_id)constraint (uq_publishing_results_remote_media), permalink, and raw response snapshot.insights_snapshots: account- and media-level analytics snapshots attributed to(workspace_id, client_id, connected_asset_id)with optional(workspace_id, publishing_result_id)link.updated_attriggers, least-privilegemetuse_appCRUD grants, andENABLE+FORCE ROW LEVEL SECURITYpolicies across all 5 tables.1.2 Shared Contracts, Config & RBAC
packages/shared/enums.py: addedContentItemStatus,PublishMediaType,PublishingJobStatus, Phase 6AuditActionentries (CONTENT_ITEM_CREATED,CONTENT_ITEM_SCHEDULED,PUBLISHING_JOB_CREATED,PUBLISHING_JOB_PUBLISHED,PUBLISHING_JOB_FAILED,INSIGHTS_SYNCED), andErrorCodevalues (CONTENT_APPROVAL_REQUIRED,PUBLISHING_LIMIT_EXCEEDED,CONTAINER_EXPIRED).packages/shared/config.py: addedpublishing_kill_switch: bool = False(exposed insafe_summary()).packages/auth/rbac.py: addedpublishing:*,publishing:read,publishing:write,analytics:*,analytics:read, andanalytics:syncpermissions.1.3 Publishing Engine, Duplicate Prevention & Insights Sync (
packages/meta_integrations/publishing.py,workers/meta_publishing/,workers/analytics/)CreativeVersionhasis_approved = Trueandqa_passed = True(403 CONTENT_APPROVAL_REQUIRED).instagram_publish/instagram_insightsMeta capability flags, carousel item ceiling (max 20 items), dynamic 24-hour publishing rate limit check, andPUBLISHING_KILL_SWITCH.#15):Idempotency-Key(rejecting mismatched payloads with409 Conflict).CONTAINER_EXPIRED).workers/meta_publishing/__init__.py:execute_due_scheduled_publishesruns due scheduled content items safely under workspace RLS and records remote media IDs (Acceptance #14).workers/analytics/__init__.py:sync_workspace_insightssyncs account- and media-level insights intoinsights_snapshotswith client attribution.1.4 FastAPI Endpoints & Next.js
/publishingUIapps/api/routes/publishing.py(wired inapps/api/deps.pyandapps/api/main.py):GET/POST /api/v1/calendarsGET/POST /api/v1/contentPOST /api/v1/content/{content_item_id}/schedulePOST /api/v1/content/{content_item_id}/publish(supportsIdempotency-Key)GET /api/v1/publishing-jobs/{job_id}GET /api/v1/clients/{client_id}/analytics&POST /api/v1/clients/{client_id}/analytics/syncGET /api/v1/analytics&POST /api/v1/analytics/syncapps/web/src/lib/publishing-api.ts,apps/web/src/app/(app)/publishing/page.tsx, andapps/web/src/components/layout/app-shell.tsx:2. Verification Results
ruff format --check .ruff check .mypy apps packages database workers testspytest tests/unit -q57 passed in 1.60s)alembic heads0008_phase6_publishing_and_insights (head)alembic upgrade head0007_phase5_meta_connections->0008_phase6_publishing_and_insights)pytest tests/integration/test_phase6_publishing_rls.py -v2 passed in 28.73s): 5-tableFORCE RLS, unapproved publish blocked (403), Acceptance#14scheduled worker publish + remote ID stored, Acceptance#15ambiguous timeout remote-state verification (strictly 1 publish call, zero duplicates), client-attributed insights sync, and cross-tenant 0-rowFORCE RLSisolationpnpm --dir apps/web lintpnpm --dir apps/web typecheckpnpm --dir apps/web build15/15static routes exported including/publishing)