Repository navigation
[ECHO] Enable qualified autonomous Worker publishing with bounded expense reads - #2095
Conversation
This comment has been minimized.
This comment has been minimized.
|
Automatic approval held Kody's assessment:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@kody start-review |
This comment has been minimized.
This comment has been minimized.
|
@kody start-review |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Summary
Enables qualified autonomous Worker publishing via version upload + exact-version deploy, and bounds expenses dashboard D1 reads with a short-lived cache. Both changes are unverified in production in this description.
Changes
scripts/deploy-mapped-worker.py: addstagged_versions()andpublish()to upload a tagged version then deploy exactly that version at100%. Promotion requires exactly one new version tagged with the commit SHA, unchangedmain, un-tripped usage guard, and unchanged live deployment, with exact-version receipt check after deploy. This avoids plainwrangler deployrewriting custom-domain routes. Review reported an unresolved check-to-deploy race that could overwrite a concurrent change, and unresolved first-page-only version listing.scripts/worker-targets.json: switches all mapped Worker commands fromdeploytoversions upload, finalizes guard ceilings, and removeslimits_pending. Expenses subrequest ceiling lowered from 200 to 60; auditor 50/20 and inbox 500/30 confirmed.workers/expenses-site/src/index.mjs: adds 15s per-isolate read cache for dashboard rows, sync state, and total count with in-flight coalescing. Failed reads are not cached,/healthalways queries D1, unknowncategoryreturns 400 without D1 access, and cache is cleared after completed manual or scheduled sync. Dashboard and/api/expensesshare the same cached loader. Review reported an unresolved torn-snapshot risk from independently cached rows and footer.Tests added
scripts/test-deploy-mapped-worker.py: covers exact-version upload/deploy, config parity, same-tag old-version exclusion, fail-closed on missing/ambiguous versions, skip on movedmain, guard-trip refusal, live-changed refusal, post-deploy mismatch, tag filtering, and ceiling mapping. No run results are reported here.workers/expenses-site/src/__tests__/index.test.mjs: covers single D1 read in window, concurrent coalescing, per-filter isolation, 400 for unknown filters, valid filters including empty, no caching of failures, TTL re-read, post-sync invalidation, guard-off 503 precedence, and uncached/health. No run results are reported here.Summary
Enables qualified autonomous Worker publishing with bounded expense reads. Deployment now promotes only an exact uploaded version identified by Wrangler's structured JSONL receipt and direct version API tag check, never by newest-version listing. Adds 600s timeouts on upload and deploy, fail-closed handling for missing, oversized, ambiguous or mismatched receipts, and post-deploy continuity verification that rejects concurrent promotions or traffic changes in the final gap. Expense dashboard read cache now stores one expiring snapshot per known filter holding rows, footer sync time and total count together, preserving 15s TTL and at most 10 filter entries. This prevents pairing rows with a footer or count from a different read across a sync, while still costing 3 D1 statements per filter window and without using a transaction.
Tests added
Updated
scripts/test-deploy-mapped-worker.pymocks fordeployment_head,verify_deployment_continuityanduploaded_version, plus newUploadReceiptChecksandDeploymentContinuityCheckscovering exact receipt identity, refusal on malformed or mismatched receipts, timeout propagation, and concurrent-deployment detection. Addedworkers/expenses-sitetests for per-filter snapshot consistency across ledger moves, no caching on partial failure with full 3-read retry, and shared load between dashboard page and JSON for the all filter. Run status and deployment verification remain unverified in this description.Open review findings
Automated review reported 2 unresolved items, described here as unverified: high — exact versions equality may reject healthy 100% deploys with extra fields in
scripts/deploy-mapped-worker.py:191; medium — per-filter snapshots duplicate shared footer and count reads in `workers/expenses-site/src/index.mjs:67.Summary
Updated deployment continuity verification in
scripts/deploy-mapped-worker.pyto tolerate forward-compatible API responses. The check now compares onlyversion_idandpercentagefor 100% traffic, ignoring extra fields in version entries.Impact
Prevents false concurrent-deployment failures when the deployments API adds new version fields. Fail-closed behavior for differing traffic or mismatched history is retained as unverified beyond added unit coverage.
Tests
Added
test_response_extension_fields_are_ignoredalongside existingtest_clean_serial_promotionandtest_interleaved_promotion_and_changed_traffic_failcases. No test execution results, deployment, or runtime verification are reported.Open risk
Automated review reported 1 medium finding:
scripts/deploy-mapped-worker.py:195may raiseTypeErrorinstead of fail-closedRuntimeErrorwhen the versions list is null. This remains unresolved.Purpose
This change continues the qualified autonomous Worker publishing effort with bounded expense reads. The supplied diff is limited to deployment continuity verification hardening.
Changes
verify_deployment_continuityinscripts/deploy-mapped-worker.pyto fail closed withRuntimeErrorwhen the versions list is missing or malformed. This prevents silently blessing an external promotion in the final API-call gap.test_null_and_malformed_versions_refuse_cleanlyinscripts/test-deploy-mapped-worker.pycovering null and malformed versions values.Tests
Open Risk
AttributeErrorinstead of a fail-closed error atscripts/deploy-mapped-worker.py:195. This remains unresolved in the supplied diff.Summary
Enables qualified autonomous Worker publishing with bounded expense reads. CI now fetches a dedicated deploy-health bearer alongside the existing Fleet credential, uses the Fleet credential for receipt lifecycle verification, and checks live Worker health with the least-privilege bearer. The receipt-inbox
/healthendpoint accepts either the existing reader bearer or the dedicated deployment bearer, while receipt summary, evidence, and status changes remain restricted to existing authorized credentials.Changes
RECEIPT_INBOX_DEPLOY_HEALTH_TOKENand documented the finite read-only deployment service credential model.Tests added
Verification status
Automated code review reported no issues in the changes reviewed. Test execution results, live deployment, and runtime verification are unverified from the provided changes.
Summary
Enables qualified autonomous Worker publishing with bounded expense reads. CI now fetches a dedicated deploy-health credential alongside the existing Fleet deploy credential, and receipt-inbox
/healthaccepts that dedicated bearer for readiness only.Changes
worker-deploy.ymlfetchesRECEIPT_INBOX_DEPLOY_HEALTH_TOKENvia the finite read-only service reader and uses it for deploy health checks, while lifecycle verification reuses the existing Cloudflare deploy credential. No receipt-data bearer enters CI.workers/receipt-inboxaddsdeployHealthAuthorized()backed only by a SHA256 digest in Worker configuration. It authorizesGET /healthwith identical readiness logic, and continues to return 401 for summary, evidence, and status-change routes. Malformed or mismatched digests fail closed.scripts/worker-targets.jsonpoints receipt-inbox health verification at the dedicated deploy-health bearer.scripts/deploy-mapped-worker.pyrefuses to bless a deployment when concurrent deployment history is malformed, instead of proceeding silently.docs/worker-deploy-service-credentials.mddescribing the finite service reader, credential scope, bootstrap/postproof flow, and renewal process.Tests
test_malformed_history_refuses_cleanlyfor deployment continuity, plus unit and workerd tests covering deploy-bearer health success, denial of receipt reads/writes, readiness failure handling, and fail-closed digest cases.Summary
Hardens the final continuity check before Worker promotion to reject malformed deployment history envelopes instead of failing unpredictably. This preserves the existing protection against silently blessing an external promotion in the final API-call gap.
Changes
Testing