Skip to content

Add gated cloud-native Threads publishing using tenant credentials - #25

Draft
AyobamiH wants to merge 3 commits into
mainfrom
feat/cloud-native-threads-20261103
Draft

AyobamiH wants to merge 3 commits into
mainfrom
feat/cloud-native-threads-20261103

Conversation

@AyobamiH

@AyobamiH AyobamiH commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Scope

Add an opt-in cloud-native Threads text publishing path that reuses the existing tenant-encrypted threads_token_enc and scoped token renewal. The previous local relay stays the default. The new path requires THREADS_CLOUD_NATIVE_ENABLED=true in an exact approved controlled tick; general generation and provider dispatch remain disabled.

Direct Graph API transport verifies the intended account, creates a text container, publishes once, and reads back the provider post ID. The existing publication attempt ledger fences execution; uncertain results are not retried by the transport. No credentials were copied, no live post was sent, and production was not changed.

Tests

Full worker npm run ci passed on the final source rebased onto current main 0eb55c2ffc5dd2a4e4dc75dcc82f48c79461b1e1. Four new isolated mocked transport tests passed. The operational rollout and recovery gates are documented in docs/cloud-native-threads-rollout.md.

Remaining acceptance before deployment

This is intentionally a draft. Add production-like concurrency and crash/restart tests, token refresh/rotation integration tests, and provider-side ambiguous-outcome reconciliation. Verify the exact account and encrypted tenant credential in the cloud. Only then enable a single owner-approved controlled live test, verify its receipt, and consider retiring the local relay. Do not merge or deploy solely on these unit tests.

Additional verification (3 November 2026)

The production Supabase project has two nonempty encrypted Threads credential rows, both in the expected enc:v1: envelope. Neither row has token-expiry metadata, so validity/refresh cannot be inferred from storage alone. The active Cloudflare worker has CREDENTIAL_ENCRYPTION_KEY configured; no token values were read or copied.

Expanded mocked direct transport tests to eight passing cases: valid publish/readback, wrong account, missing token, lost publish response, rejected account verification, failed container creation, mismatched provider readback, and rejected publish without retry. The complete worker CI chain passed locally on the updated source.

This PR is not a live publication acceptance: encrypted token decryption, provider validity, actual refresh, concurrent admission and crash recovery still need exact cloud-runtime verification. Keep draft and general dispatch paused.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
oneclickpostfactory-agent 6f361f7 Commit Preview URL

Branch Preview URL
Nov 03 2026, 05:55 PM

@AyobamiH

AyobamiH commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Production-integration investigation (2026-11-03): the active worker remains 3ed0be7fddc3176496c913b2d6a9adcb5694934f, and application source-revision PR #60 is still unmerged. To avoid pulling the pending source-revision migration into the Threads release, a separate exact-production-base candidate was created at 85e47f2bb21b6a9b567e71f694594ecf871b5e50 on branch release/cloud-threads-production-compatible-20261103. It contains only the five cloud-Threads files and passed typecheck and the full local npm run ci chain against the current production worker source. This is not a deployment or a live provider proof.

Read-only production database checks found two encrypted Threads tokens in the expected envelope, but neither has expiry metadata. The production worker has CREDENTIAL_ENCRYPTION_KEY. No plaintext token was accessed or copied, and provider authentication/refresh remains unverified. Before promotion, verify the exact tenant/account via a read-only cloud-runtime credential probe, then prove durable concurrent admission and uncertain publish reconciliation. Keep generation/dispatch disabled; do not infer success from a token row or mocked provider tests.

@AyobamiH

AyobamiH commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Production acceptance verification, 2026-11-03 19:45 UTC: On the authorised web machine, the focused cloud Threads transport, token-refresh, publication executor and ledger suites passed (11 reported tests, no failures). Publication lock-order integration passed. The native publication database integration was not run: its explicit local-only Supabase opt-in was absent; it was not counted as a pass.

Read-only production Supabase query confirms migration head 20261102161500 and zero rows for source revision migration 20261103135010. Read-only publish-now job status aggregation shows no pending/running publish_now jobs, so there is no newly approved job available for a live Threads acceptance send. The schema-compatible candidate 4805c399efb3edc0b87fd0b04789680ff4ad91dd has a successful Cloudflare build; it has not been deployed. The main feature branch 6f361f794c20e8241132c07e02c5859f6fd4be74 has successful hosted readiness, build-test and Cloudflare build checks.

Remaining mandatory evidence: authenticated cloud-runtime read-only tenant credential verification and refresh persistence; real local PostgreSQL concurrent-admission and interrupted-dispatch/restart tests; exact candidate zero-traffic readiness; one newly approved Threads post with provider readback and one durable ledger receipt. Do not reuse the previously completed Threads job or claim production acceptance before these receipts. General generation/dispatch remain paused.

@AyobamiH

AyobamiH commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

2026-11-03 20:11 UTC release evidence: Uploaded exact production-schema-compatible candidate source (4805c399efb3edc0b87fd0b04789680ff4ad91dd) as Cloudflare Worker version 4d83103c-757d-4654-bb90-5d90e732b57a using wrangler versions upload (no production deployment). Preview: https://4d83103c-oneclickpostfactory-agent.woeinvests.workers.dev/healthz returned HTTP 200; generation=false, dispatch=false, active/waiting=0, Threads capability=controlled_only. Independent deployment-list readback confirms original worker 3a687183-73c2-4824-a3a3-503a88826f54 remains at 100%, candidate at 0%. Preview release reports the new version ID but gitSha=null; exact-source metadata attestation remains to be repaired before promotion.

Focused publication executor, lock-order and Threads direct-transport tests passed (10 reported tests). Native DB test still requires isolated local-only Supabase setup. No live Threads publish was performed. No new approved publish_now job is currently available. Pending: read-only tenant-specific cloud credential authentication and refresh, real durable crash/restart test, source identity attestation, approved controlled live post, provider and ledger readback.

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