feat(social): archive posts and restore them (#1299) #1328
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1328"
general
weight: 0.35
claude[bot]
Archived posts and their restore (#1299), as Planable archives a post and restores it.
Protected path: this PR adds a migration (
supabase/migrations/20261030020000_crove_social_post_archive.sql, columns only). The coordinator runs the independent security review.What changed
crove_social.post.archived_at timestamptz,archived_by uuid, CHECKpost_archived_pair(both or neither), partial indexpost_live_idx (org_id, updated_at DESC, id DESC) WHERE archived_at IS NULL. Grants unchanged:crove_tenantkeeps table-level UPDATE onpost, as for every other post column.packages/dbtypes regenerated.- Decision: no foreign key on
archived_by. No_bycolumn of the Social tables has one (author, assignee, removed_by, revoked_by, created_by are plain uuids kept when the person leaves). An FK tocrove_kernel.tenant_memberwould either delete the post with the membership (CASCADE) or break the pair CHECK (SET NULL). This also keeps the migration free of a cross-module waiver.modules/social/src/archive.ts):social.post.archive,social.post.restore(R1; members their own posts, owners and admins any; a member limited to some channels only a post wholly on theirs, #1081), andsocial.post.bulk_archive/social.post.bulk_restore(up to 100, posts locked in id order, the single command run as a nested command per post, outcomesnot_found,not_allowed,unchanged,scheduled,in_flight,removing). New contract routesposts.archive,restore,bulkArchive,bulkRestore;posts.listtakesarchived: true;PostViewcarriesarchivedAt/archivedBy.POST_ARCHIVE_SCHEDULED(scheduled or paused),POST_ARCHIVE_IN_FLIGHT(publishing, processing, ambiguous, needs_attention),POST_ARCHIVE_REMOVING(a takedown asked and not answered, or a planned takedown the sweep will still ask for, #860/#861).updated_atstay as they were. Both are audited and show on the post's timeline (archived/unarchived; a call that changed nothing is audited but left off the timeline).postFilterQuery(lists, board, calendar, undated list, multi-client home figures), the upcoming count, review inbox, attention inbox, plan export, plan links from a date range, digest review and failure lists. Review reminders for an archived post are marked as sent without telling anyone, so the oldest-first reminder scan does not stall on it. Evergreen and recurring sweeps never find them (the rule is cleared, and the worker commands re-check under the lock).409 POST_ARCHIVED: post and variant edits, add channels, restore version, submit, decide, schedule, reschedule, retry, review link create (and plan create with an archived post), set evergreen (turning it off still works), set recurrence, set text variations. Labels, comments and copies still work.docs/plan/social.md: one paragraph.Not in this PR
social.queue.setstill moves it like any queued draft.Tests
apps/kernel/test/social-archive.db.test.ts(PostgreSQL 17, 9 tests): every list and filter leaves archived posts out andarchived: truelists them; restore returnssocial.post.getunchanged; roles (author, other member, viewer, admin, owner, other org); channel scope (single and bulknot_allowed); each refusal (scheduled, paused, publishing, processing, ambiguous, needs_attention, takedown asked, takedown planned) single and bulk; bulk outcomes in id order with audits; evergreen and recurrence cleared andevergreen_due/recurring_dueskip the post, worker commands no-op, set refused; single and plan review links revoked (others untouched), new links refused, range plans skip it; the refused commands; inboxes, plan export, overview figures, reminders (marked, no event) exclude it while metrics keep the published one.apps/app/test/social-archive.test.tsand a BulkBar case insocial-bulk-bar.test.tsx; app, social module and contract unit tests green;pnpm typecheck,pnpm lint,pnpm docs:checkgreen.node tools/ci/migration-order.mjs origin/mainandmigration-lint --since $(git merge-base HEAD origin/main)OK.Closes #1299
🤖 Generated with Claude Code
---
<!-- dos-pr-summary -->
📌 TL;DR
This PR introduces a "Soft Archive" feature for social media posts, allowing users to hide posts from all active lists (calendar, board, drafts) without deleting them. It includes single-post and bulk archive/restore actions, permission checks, state-based blocking rules (e.g., preventing archiving of scheduled or in-flight posts), and a new "Archived" tab in the UI.
🎯 Type of Change
🔍 Changes Walkthrough
| File | Summary of Changes |
| :--- | :--- |
|
apps/app/src/lib/social-archive.ts| New file. Defines client-side logic for archive permissions (mayArchive) and blocking rules (archiveBlock) based on post variant statuses (e.g.,publishing,scheduled). ||
apps/app/src/lib/social-bulk.ts| AddsArchiveActiontype ('archive' \| 'restore') and updatesBulkActionandPostActiontypes to include archive operations. ||
apps/app/src/lib/social.ts| Adds'archived'to theSOCIAL_TABSconstant to enable the new tab in the UI routing. ||
apps/app/src/lib/kernel-errors.ts| Registers new error codes:POST_ARCHIVED,POST_ARCHIVE_IN_FLIGHT,POST_ARCHIVE_SCHEDULED, andPOST_ARCHIVE_REMOVING. ||
apps/app/src/components/social-bulk.tsx| Integrates archive/restore into the bulk action bar. Adds confirmation dialogs, progress tracking, and result display for bulk archive/restore operations. ||
apps/app/src/routes/social-post.tsx| Adds "Archive" and "Restore" buttons to the single post view. Implements read-only mode for archived posts and displays a warning banner with restore options. ||
apps/app/src/routes/social.tsx| Adds the "Archived" tab to the social home page. Configures bulk actions to show "Restore" on the archived tab and "Archive" on other tabs. Filters list queries to include/exclude archived posts based on the active tab. ||
apps/app/src/i18n/messages/en.ts| Adds English translations for archive actions, confirmations, error messages, and the new "Archived" tab. ||
apps/app/src/i18n/messages/vi.ts| Adds Vietnamese translations for archive actions, confirmations, error messages, and the new "Archived" tab. ||
apps/kernel/src/rpc.ts| Exposes new RPC handlers forarchive,restore,bulkArchive, andbulkRestorecommands. ||
apps/app/test/social-archive.test.ts| New file. Unit tests for client-side archive logic (permissions, blocking rules) and tab configuration. ||
apps/app/test/social-bulk-bar.test.tsx| Updates bulk bar tests to verify archive/restore buttons appear correctly in different contexts. ||
apps/kernel/test/social-archive.db.test.ts| New file. Integration tests for the database layer, verifying archive/restore behavior, permissions, state blocking, and list filtering. |📊 Architectural Flow
<!-- /dos-pr-summary -->