Freshness-gate completeness: url-routes + Kotlin regenerate-and-diff

Merged
JE
4mo ago
+131-22

Extends #456 (regenerate-and-diff freshness gates for TS/Ruby/Go) to close the two remaining gaps in the generated-artifact gating surface. Behavior-neutral hardening — no runtime change.

Part A — url-routes.json

scripts/generate-url-routes produces go/pkg/basecamp/url-routes.json (consumed via //go:embed in url.go). A non-mutating url-routes-check target already existed but was wired into neither make check nor CI, so the artifact could silently drift while every other generated artifact is gated. This adds it to the make check prerequisites (a fast, non-mutating script run) and to the test-go CI job.

Part B — Kotlin regenerate-and-diff

Root make check ran only the fast, coverage-only kt-check-drift (operationId-set compare); the authoritative regenerate-and-diff ran solely in CI as a mutating git status --porcelain. This adds:

  • scripts/check-kotlin-generated-drift.sh — the Kotlin sibling of the other five service-drift scripts. It regenerates the whole generated/ tree into a temp dir and diff -rqs, so it is non-mutating and detects both missing and extra files. The whole @generated tree is generated (base class lives outside it) and nothing embeds a wall-clock stamp, so no exclusions or timestamp normalization are needed. Includes a java-toolchain guard that exits 2 when the JVM is absent, mirroring the Swift sibling.
  • kt-check-generated-drift Make target — deliberately kept out of the default make check (a :generator:run is a heavy JVM/Gradle-daemon startup). The fast kt-check-drift stays in make check unchanged.
  • The test-kotlin CI step now invokes make kt-check-generated-drift, so CI exercises both the target and the shared non-mutating script.

Verification

  • make url-routes-check and make kt-check-generated-drift exit 0 on clean main and are non-mutating (git status --porcelain empty after each).
  • Negative proofs: a throwaway edit to url-routes.json fails url-routes-check; a throwaway edit to a generated Kotlin file fails the fresh gate; both restore cleanly.
  • java-absent → the Kotlin script exits 2 (proven).
  • make check green; shellcheck clean; lint-actions clean.

Summary by cubic

Adds non-mutating freshness gates for url-routes.json and the Kotlin SDK to prevent drift and align with other generated artifacts. Wired into make check and CI; no runtime changes.

  • New Features

    • Added url-routes-check to make check and the Go CI job to gate go/pkg/basecamp/url-routes.json.
    • Added Kotlin regenerate-and-diff gate: scripts/check-kotlin-generated-drift.sh and kt-check-generated-drift (non-mutating; regenerates into a temp dir and diffs; catches missing and extra files). CI now runs it via make kt-check-generated-drift; kept out of default make check to avoid JVM startup cost. Updated SPEC.md to list both url-routes-check and Kotlin’s standalone gate.
  • Bug Fixes

    • Hardened Kotlin script: quote each Gradle --args path, honor JAVA_HOME first (fallback to PATH), treat missing committed tree as drift, and distinguish diff exit 1 (drift) vs ≥2 (tool error). Message now guides pruning unexpected extra files.