DEV Community

Cover image for Deferring Publication After a Budget-Safe Draft Revision
Raylabs
Raylabs

Posted on Originally published at raylabs.app

Deferring Publication After a Budget-Safe Draft Revision

A Cloudflare Workflow can spend most of its bounded external request budget before publication begins, risking partial failures when generation and publishing share a single run.

Quick solution:

if (!hasPublicationBudget) {
  await commitDraftOnly(revisionData);
  return { promotionDeferred: true, readyPath: revisionData.path };
}
Enter fullscreen mode Exit fullscreen mode

Reserving candidate commit, promotion preflight, live checks, site writes, and vault finalization before model calls prevents generation from creating a draft that the same run cannot safely publish. When an explicit revision-only run cannot reserve the full tail, retain only the five-request draft commit reserve.

Understanding the Request Budget Conflict

Cloudflare documents strict subrequest ceilings on its free plan, while GitHub documents base tree writes for atomic tree changes via REST API endpoints for Git trees as outlined in the GitHub REST API Git trees documentation. When a workflow handles candidate commits, promotion preflights, and final vault writes, it can exhaust its budget before publishing.

For more details on platform limits, consult the Cloudflare Workflows limits documentation. The five-request commit budget and the later publish-only step are application safeguards rather than limits specified by either provider. For related architectural guidance, you can also review Managing Concurrent Git Commits During Automated Publishing.

Implementing a Deferred Publication Fallback

When a revision-only repair occurs, you have a different recovery option available. Instead of failing the entire run, commit the reviewed revision and promote that exact ready draft in a later run.

  • Keep the full publication reserve unchanged for normal candidates and same-run promotion.
  • When an explicit revision-only run cannot reserve the full tail, retain only the five-request draft commit reserve.
  • Generate and review the revision, commit its Markdown, quality record, and raster metadata, then return the resulting ready-draft path with an explicit deferred publication result.
  • Skip publication selection in that run. After it completes, use a separate publish-only run scoped to the exact ready-draft path.
  • Keep manual live runs serial so a second workflow cannot race the vault SHA guard.

Verification and Execution Checklist

  • Verify the five-request reserve constraint during low-budget execution.
  • Confirm generation and commit succeed after the full publication reserve fails.
  • Validate that the exact-path deferred result is correctly returned.
  • Ensure manual live runs remain serial to prevent race conditions on the vault SHA guard.

Top comments (0)