Fix Wrangler sync env parity - #1690
Closed
simple-agent-manager[bot] wants to merge 1 commit into
Closed
Conversation
Contributor
|
30 tasks
30 tasks
Contributor
Author
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
sync-wrangler-config.tsenv mapping indeploy-reusable.ymlwith a sharedwrangler_sync_envmapping.CF_CONTAINER_ENABLED, all consumedCF_CONTAINER_*,SANDBOX_*, and guided setup tunables.sync-wrangler-config.tsand checks direct sync/config env mappings, so future env drift fails in tests..claude/rules/07-env-and-urls.mdto prevent per-step sync env drift.Validation
pnpm lintpnpm typecheckpnpm testAdditional validation:
pnpm vitest run --config scripts/quality/vitest.config.ts scripts/quality/deploy-reusable-workflow.test.ts— passed, 11 testspnpm exec eslint scripts/quality/deploy-reusable-workflow.test.ts scripts/deploy/sync-wrangler-config.ts— passedpnpm quality:wrangler-bindings— passednpx tsx --check scripts/deploy/sync-wrangler-config.ts— passedpnpm build— passedpnpm --filter @simple-agent-manager/providers exec vitest run tests/unit/vultr-lifecycle.test.ts --testNamePattern "warns and returns empty IP"— passed after the full parallel run hit this unrelated flaky failure oncepnpm --filter @simple-agent-manager/ui exec vitest run tests/EmptyState.test.tsx— passed after the full parallel run hit an unrelated worker timeoutpnpm --filter @simple-agent-manager/acp-client exec vitest run tests/unit/components/VoiceButton.test.tsx— passed after the full parallel run hit an unrelated worker timeoutpnpm testnote: full parallelpnpm testdid not complete green locally because of unrelated/flaky full-suite behavior: first run failed one Vultr provider assertion that passed in isolation and on rerun; second run passed providers but timed out in unrelated UI/acp-client first tests after ~8 minutes. The changed workflow quality test passed repeatedly.Staging Verification (REQUIRED for all code changes — merge-blocking)
All checkboxes below are mandatory for any PR that changes runtime code (
.ts,.tsx,.go, etc.). WriteN/A: docs-onlyONLY if the PR contains zero runtime code changes. See.claude/rules/13-staging-verification.md.Staging Verification Evidence
N/A: deploy workflow/config quality change only. This PR does not change application runtime behavior. Verification is by static workflow contract tests plus GitHub CI.
UI Compliance Checklist (Required for UI changes)
End-to-End Verification (Required for multi-component changes)
Data Flow Trace
.github/workflows/deploy-reusable.ymlinitial sync definesenv: &wrangler_sync_envand maps deployment identity, direct sync envs, cf-container vars, sandbox vars, and setup tunables..github/workflows/deploy-reusable.ymlfirst-deploy re-sync uses<<: *wrangler_sync_env, so it cannot drift from the initial sync mapping.scripts/deploy/sync-wrangler-config.ts:getApiWorkerVars()reads optional Worker vars viagetOptionalProcessEnvVars([...]); the quality test derives this list and asserts it is represented in the shared workflow mapping.scripts/deploy/sync-wrangler-config.tsdirect reads (PULUMI_STACK, Cloudflare token aliases,ARTIFACTS_BINDING_ENABLED,SETUP_FORCE) and deployment identity (BASE_DOMAIN,RESOURCE_PREFIX) are covered by explicit test expectations.Untested Gaps
No live staging deploy was triggered for this workflow/config-only PR. CI will validate the repository checks on the PR branch.
Post-Mortem (Required for bug fix PRs)
What broke
First deploys could run the tail-consumer Wrangler re-sync with fewer env inputs than the initial sync. That could silently drop operator overrides such as
CF_CONTAINER_ENABLED=falseand allowsync-wrangler-config.tsdefaults to reappear.Root cause
The reusable deploy workflow duplicated env mappings per sync step. The second sync block drifted behind the initial sync block.
Class of bug
Duplicated deployment env mappings across multi-phase deploy workflows.
Why it wasn't caught
Existing tests checked selected variables on the initial sync and did not derive expected coverage from the env vars consumed by
sync-wrangler-config.ts.Process fix included in this PR
.claude/rules/07-env-and-urls.mdnow requires sync-consumed Worker vars to be added to the centralizedwrangler_sync_envmapping, not ad hoc per-step env blocks.scripts/quality/deploy-reusable-workflow.test.tsnow fails if the shared mapping omits env vars consumed by the sync script or if a sync invocation does not use the shared mapping.Post-mortem file
tasks/archive/2026-07-29-wrangler-sync-env-parity.mdSpecialist Review Evidence (Required for agent-authored PRs)
needs-human-reviewlabel added and merge deferred to human — N/A, all completed. This PR is explicitly do-not-merge by user instruction.Exceptions (If any)
Agent Preflight (Required)
Classification
External References
N/A: no external API/library behavior change. Codebase and workflow evidence only.
Codebase Impact Analysis
Affected components:
.github/workflows/deploy-reusable.yml— central sync env mapping and first-deploy re-sync inheritancescripts/quality/deploy-reusable-workflow.test.ts— workflow-to-sync-script contract tests.claude/rules/07-env-and-urls.md— process guardrailtasks/archive/2026-07-29-wrangler-sync-env-parity.md— task/post-mortem recordDocumentation & Specs
.claude/rules/07-env-and-urls.md.Constitution & Risk Check
Checked Principle XI/no hardcoded values: this change removes duplicated env mapping drift by centralizing the workflow mapping; no new runtime defaults or fixed limits were added. Risk is limited to GitHub workflow YAML/env resolution and covered by static workflow tests plus CI.