fix(codegen/cloudflare): format README before change-detection compare (#488) #18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "worktree-488"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The Cloudflare codegen pipeline bumped every service's
manifest.yamlmicro version on every regeneration, even when zero models changed — causing dead-publish churn and drift between model and manifest versions.Root cause:
codegen/cloudflare/pipeline.tscomputedhasChangesby comparing the on-diskREADME.mdagainst the rawgenerateCloudflareReadme()output. Butcommands/generate.tsrunsdeno fmtover the output dir after writing, so the on-disk README is reformatted. The generated README is not deno-fmt-clean (the intro prose re-wraps at 80 cols), soexistingReadme !== readmeCodewas perpetually true →hasChangesalways true →computeManifestVersionbumped the micro every run.Why Cloudflare-only: The hetzner / digitalocean / aws / gcp pipelines all
formatFile(readme, ".md")before comparing. Cloudflare was the only pipeline missing that step (and didn't importformatFile).Fix
Format the candidate README with
deno fmtbefore the change-detection comparison, mirroring the four sibling pipelines and the behavior already documented incodegen/designs/cloudflare.md§14 ("Before comparing, the pipeline formats the candidate with deno fmt … ensures idempotent regeneration").Verification
generate:cloudflare→ 0 manifest version bumps across all 70 services (Models: 0 changed, 168 unchanged).deno check/deno lint/deno fmt --checkpass incodegen/.model/files hand-edited; no doc change needed.Fixes swamp-club #488.
🤖 Generated with Claude Code
Code Review
Blocking Issues
None.
Suggestions
codegen/cloudflare/pipeline.ts, lines 403–405): The three-line comment block explaining the formatting comparison is accurate and the non-obvious constraint warrants a note, but CLAUDE.md asks for one short line max. Consider condensing to something like// Format first — the on-disk README has already been run through deno fmt.The extra detail about why the on-disk file is formatted (pipeline runs fmt after writing) is already implied byformatFile's name and the surrounding context.The change is correct and well-scoped. The root issue — comparing a raw-generated README against an already-
deno fmt-formatted on-disk file, causing spurious change detection — is real, and the fix (formatting the candidate before the comparison) directly addresses it. TheformatFileerror path is handled correctly: ifformatFilethrows, the outercatchconservatively setshasChanges = true, which is the right fallback.Adversarial Review
Critical / High
None.
Medium
None.
Low
None.
Verdict
PASS — Small, targeted fix that formats the candidate README with
deno fmtbefore comparing it against the on-disk version, eliminating false-positivehasChangeson every regeneration. The change mirrors the exact pattern already used in the AWS, GCP, Hetzner, and DigitalOcean pipelines.formatFilegracefully falls back to the original content ifdeno fmtfails, so there is no new failure mode introduced. The fix is correct and idempotent.