Skip to content

ENG-00000: Make generated code and paths.yaml deterministic - #103

Merged
adranwit merged 1 commit into
masterfrom
ENG-00000-do-not-change-unrelated-files
Aug 5, 2026
Merged

ENG-00000: Make generated code and paths.yaml deterministic#103
adranwit merged 1 commit into
masterfrom
ENG-00000-do-not-change-unrelated-files

Conversation

@and-bezzir

Copy link
Copy Markdown
Collaborator

Summary

Three sources of non-determinism made generated artifacts differ between machines and between runs, producing spurious diffs. Each is fixed at the point where the unordered data enters the pipeline.

  • repository/codegen.go — run generated output through go/format and fix the EmbedFS() snippet's indentation, so emitted code is canonically formatted regardless of how the builder assembled it. A formatting failure leaves the unformatted result untouched.
  • view/column/discover.go — sort information_schema columns by ordinal position. Those queries carry no ORDER BY, so driver-dependent ordering was leaking into generated struct field order. Columns inferred from a result set carry no position and are left alone, preserving the query's own projection order.
  • repository/path/service.go — sort paths.yaml candidates by URL. The recursive listing reflected directory enumeration order, which varies by filesystem and shifts when route files are rewritten, so partial regeneration reshuffled thousands of lines. Route lookup is order-independent (the matcher builds a trie and prefers exact matches), so this is safe.

Test plan

Added focused unit tests alongside each change:

  • repository/codegen_embedfs_test.go — verifies the embed snippet and overall gofmt-stability of generated output
  • view/column/discover_sort_test.go — covers position-ordered sorting and the no-position passthrough case
  • repository/path/sort_test.go — covers URL ordering and stability

🤖 Generated with Claude Code

Generated artifacts differed between machines and between runs, so
regenerating produced large spurious diffs. Fix each source of
non-determinism where the unordered data enters the pipeline.

- codegen: run emitted code through go/format and correct the EmbedFS
  snippet indentation. On a format error the unformatted result is kept.
- column discovery: sort information_schema columns by ordinal position.
  Those queries carry no ORDER BY, so driver ordering leaked into
  generated struct field order. Columns inferred from a result set carry
  no position and are left untouched, preserving the projection order the
  query already established.
- route listing: sort paths.yaml entries by URL. The recursive listing
  reflected directory enumeration order, which varies by filesystem and
  shifts whenever route files are rewritten, so partial regeneration
  reshuffled thousands of lines. Route lookup is order independent: the
  matcher builds a trie and prefers exact matches.

Adds unit tests covering each sort and the gofmt stability of generated
output.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@and-bezzir
and-bezzir force-pushed the ENG-00000-do-not-change-unrelated-files branch from 5229dea to 3bbe151 Compare August 3, 2026 23:26
@and-bezzir and-bezzir changed the title ENG-00000 Make codegen, column discovery, and route listing deterministic ENG-00000: Make generated code and paths.yaml deterministic Aug 3, 2026
@and-bezzir
and-bezzir requested review from Vidhan and adranwit and removed request for Vidhan August 4, 2026 11:21
@adranwit
adranwit merged commit 80f5141 into master Aug 5, 2026
2 checks passed
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.

2 participants