Skip to content

feat: add aiModerated flag to moderateSourcePosts mutation#3777

Closed
pnvasanth wants to merge 1 commit intomainfrom
feat/ai-moderated-flag
Closed

feat: add aiModerated flag to moderateSourcePosts mutation#3777
pnvasanth wants to merge 1 commit intomainfrom
feat/ai-moderated-flag

Conversation

@pnvasanth
Copy link
Copy Markdown
Contributor

Summary

Add an optional aiModerated: Boolean parameter to the moderateSourcePosts GraphQL mutation. When set to true, the mutation merges { "aiModerated": true } into the JSONB flags column of the moderated posts.

Motivation

We're running an automated squad moderation agent that approves/rejects pending posts. We need a way to distinguish AI-made decisions from human ones for:

  • Traceability: easily query which posts were AI-moderated
  • Auditing: compare AI vs human decision quality over time
  • Filtering: the agent can skip already AI-moderated posts using (flags->>'aiModerated')::boolean IS NOT TRUE

Changes

File Change
src/entity/SourcePostModeration.ts Add aiModerated: boolean to SourcePostModerationFlags type
src/schema/posts.ts Add aiModerated: Boolean param to GraphQL schema + resolver

How it works

  • The flag is optional and defaults to false — zero impact on existing callers
  • Uses the existing updateFlagsStatement utility for JSONB merge (same pattern as vordr, promoteToPublic, etc.)
  • Flag is set for both approvals and rejections — full traceability
  • No migration needed — JSONB column already exists, new key is additive

Usage

mutation {
  moderateSourcePosts(
    postIds: ["uuid-1", "uuid-2"]
    status: "approved"
    aiModerated: true
  ) {
    id
    status
  }
}

Testing

  • Existing moderation flows are unaffected (param is optional, defaults false)
  • When aiModerated: true, verify flags column contains {"aiModerated": true} merged with existing flags

Add an optional `aiModerated` Boolean parameter to the `moderateSourcePosts`
GraphQL mutation. When set to `true`, the mutation merges
`{ aiModerated: true }` into the JSONB `flags` column of the moderated posts.

This enables traceability for AI-automated moderation decisions vs human ones,
used by the squad-moderation automation agent.

Changes:
- Add `aiModerated` to `SourcePostModerationFlags` type
- Add `aiModerated: Boolean` parameter to GraphQL schema
- Merge flag into JSONB using existing `updateFlagsStatement` utility
@pulumi
Copy link
Copy Markdown

pulumi Bot commented Apr 8, 2026

🍹 The Update (preview) for dailydotdev/api/prod (at 0c1047e) was successful.

✨ Neo Explanation

Routine application release bumping all workloads from commit `f0e4dd8e` to `8cd23b8f`, with accompanying DB and ClickHouse migration Jobs — ✅ Low Risk, assuming migrations are backward-compatible with the current schema.

This is a standard application release rolling out commit 8cd23b8f (replacing f0e4dd8e) across all deployments and cron jobs. Every change is a container image tag bump and matching version label update — no configuration, resource sizing, or scheduling changes are involved.

The two migration Jobs (PostgreSQL via TypeORM and ClickHouse) follow the expected pattern for this codebase: old Jobs from the previous commit are deleted and new ones are created for the incoming commit. This means database and ClickHouse schema migrations will run as part of this deployment. The new Job specs are not shown in detail, but the pattern matches the deleted Jobs exactly — same runner commands, same secret references, just a new image tag.

🔵 Info — The GCP provider warning about missing ADC credentials is a diagnostic noise issue in the CI runner environment; it does not affect the Kubernetes resources being deployed.

Resource Changes

    Name                                                       Type                           Operation
~   vpc-native-rotate-daily-quests-cron                        kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-expired-better-auth-sessions-cron         kubernetes:batch/v1:CronJob    update
~   vpc-native-calculate-top-readers-cron                      kubernetes:batch/v1:CronJob    update
-   vpc-native-api-clickhouse-migration-f0e4dd8e               kubernetes:batch/v1:Job        delete
~   vpc-native-daily-digest-cron                               kubernetes:batch/v1:CronJob    update
~   vpc-native-channel-highlights-cron                         kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-images-cron                        kubernetes:batch/v1:CronJob    update
~   vpc-native-expire-super-agent-trial-cron                   kubernetes:batch/v1:CronJob    update
~   vpc-native-user-profile-analytics-history-clickhouse-cron  kubernetes:batch/v1:CronJob    update
~   vpc-native-post-analytics-history-day-clickhouse-cron      kubernetes:batch/v1:CronJob    update
~   vpc-native-update-trending-cron                            kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-user-companies-cron                kubernetes:batch/v1:CronJob    update
~   vpc-native-squad-posts-analytics-refresh-cron              kubernetes:batch/v1:CronJob    update
~   vpc-native-channel-digests-cron                            kubernetes:batch/v1:CronJob    update
-   vpc-native-api-db-migration-f0e4dd8e                       kubernetes:batch/v1:Job        delete
~   vpc-native-sync-subscription-with-cio-cron                 kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-channel-highlights-cron                   kubernetes:batch/v1:CronJob    update
~   vpc-native-user-profile-analytics-clickhouse-cron          kubernetes:batch/v1:CronJob    update
~   vpc-native-bg-deployment                                   kubernetes:apps/v1:Deployment  update
~   vpc-native-update-highlighted-views-cron                   kubernetes:batch/v1:CronJob    update
~   vpc-native-private-deployment                              kubernetes:apps/v1:Deployment  update
~   vpc-native-clean-zombie-opportunities-cron                 kubernetes:batch/v1:CronJob    update
+   vpc-native-api-clickhouse-migration-8cd23b8f               kubernetes:batch/v1:Job        create
~   vpc-native-post-analytics-clickhouse-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-update-views-cron                               kubernetes:batch/v1:CronJob    update
~   vpc-native-generic-referral-reminder-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-ws-deployment                                   kubernetes:apps/v1:Deployment  update
+   vpc-native-api-db-migration-8cd23b8f                       kubernetes:batch/v1:Job        create
~   vpc-native-clean-gifted-plus-cron                          kubernetes:batch/v1:CronJob    update
~   vpc-native-temporal-deployment                             kubernetes:apps/v1:Deployment  update
~   vpc-native-materialize-monthly-best-post-archives-cron     kubernetes:batch/v1:CronJob    update
~   vpc-native-materialize-yearly-best-post-archives-cron      kubernetes:batch/v1:CronJob    update
~   vpc-native-hourly-notification-cron                        kubernetes:batch/v1:CronJob    update
~   vpc-native-update-tags-str-cron                            kubernetes:batch/v1:CronJob    update
~   vpc-native-deployment                                      kubernetes:apps/v1:Deployment  update
~   vpc-native-worker-job-deployment                           kubernetes:apps/v1:Deployment  update
~   vpc-native-user-posts-analytics-refresh-cron               kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-stale-user-transactions-cron              kubernetes:batch/v1:CronJob    update
~   vpc-native-user-profile-updated-sync-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-rotate-weekly-quests-cron                       kubernetes:batch/v1:CronJob    update
~   vpc-native-personalized-digest-cron                        kubernetes:batch/v1:CronJob    update
... and 11 other changes

@pnvasanth pnvasanth closed this Apr 8, 2026
@pnvasanth pnvasanth deleted the feat/ai-moderated-flag branch April 8, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant