Skip to content

feat(format): run the generated apps' autocorrecting formatters after the rename - #153

Merged
dadachi merged 1 commit into
mainfrom
feat/autoformat-after-rename
Oct 18, 2026
Merged

dadachi merged 1 commit into
mainfrom
feat/autoformat-after-rename

Conversation

@dadachi

@dadachi dadachi commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Closes #149

What

After rename.rb, each worker runs the substrate's autocorrecting formatter on its generated project and records what's left:

platform command notes
rails bin/rubocop -a mise exec -- when mise is on PATH (same rule as Layer 2); bundle check → bundle install first. Exit ≠ 0 = offenses left
android ./gradlew spotlessApply --no-daemon fails when ktlint finds something it can't autocorrect
ios swiftformat <Product> skipped when swiftformat isn't on PATH
  • src/validation/run-step.ts: small runner (pipe, interleaved stdout+stderr, timeout, scrubbedEnv() so ANTHROPIC keys are stripped, never throws: a missing binary, crash or timeout becomes a failed result). The opt-in test suites in SPEC Operation 3: test suites aren't run #150 reuse it.
  • src/validation/autoformat.ts: the three formatters. Result type StepResult (pass / fail / skipped + command, exit, duration, output tail, note).
  • WorkerResult.format → PlatformDetail.format → report.json, new "Formatters" section in the HTML report (shown only when present), a trace line in tmp/trace/<platform>.log (output tail on failure) and in the judge's per-platform line.
  • NATIVEAPPTEMPLATE_FORMAT=off skips the formatters. README, SPEC §4, docs/validation-report.md, docs/OUTPUT-CHECKLIST.md §3 updated.

Design decisions (please check)

  • Reported, not gated. Leftover lint doesn't change overallPass/verdict. It isn't one of the three layers, and gating would fail runs whose builds and UI pass. Easy to flip later if you want it to gate.
  • On by default, opt-out flag. Spotless costs a Gradle run (about 9 s warm on the paid substrate here, longer cold).
  • iOS formats <Product>/, not .: the template's make format is swiftformat NativeAppTemplate, and its test targets aren't SwiftFormat-clean (swiftformat --lint . on the paid substrate reports 39/348 files, almost all in NativeAppTemplateTests). swiftformat . would rewrite dozens of test files the rename never touched. Falls back to . when there's no <Product>/ next to the .xcodeproj.
  • SwiftLint isn't run (no autocorrect in scope here). Its checks stay in the output checklist.
  • Runs in the workers (before Layer 1/2) so the builds and token scan see the formatted code.

Tests

  • Fake bin/rubocop / gradlew / swiftformat scripts: the right args, fail with the offense in outputTail on exit 1, pass on 0, iOS targets the app dir, skipped when swiftformat isn't on PATH or the tool is missing, NATIVEAPPTEMPLATE_FORMAT=off doesn't run the tool, runStep with a missing command or timeout doesn't throw. Report renders the section only when present.
  • Saw all 5 new tests red by breaking the target (wrong task/args, . target, flag ignored, section removed).
  • Manual against the real substrates (copies in /tmp): mise exec -- bin/rubocop -a → pass (277 files, no offenses), ./gradlew spotlessApply → pass, swiftformat BarbershopQueue on an older generated app → pass, 1/201 files formatted.
  • npm run ci: 165/165 pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UZJxUoubntzu7Ec7DPVfAr

… the rename

The rename changes identifier lengths and alphabetical order, which the
substrates' lint configs flag although the builds pass: RuboCop
Layout/HashAlignment after shopkeeper_auth -> teammate_auth, ktlint import
ordering after ShopkeeperLocaleUpdate -> TeammateLocaleUpdate.

Each worker now runs, after rename.rb:
- rails: bin/rubocop -a (mise exec when available, bundle install first
  if bundle check fails)
- android: ./gradlew spotlessApply --no-daemon
- ios: swiftformat <Product> (the app sources, as the template's
  make format does), skipped when swiftformat isn't on PATH

A shared runStep helper captures output with a timeout and the scrubbed
env and never throws. Results land in WorkerResult/PlatformDetail.format,
report.json, a "Formatters" section of the HTML report and the platform
trace. They are reported, not gated. NATIVEAPPTEMPLATE_FORMAT=off skips
them.

Closes #149

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UZJxUoubntzu7Ec7DPVfAr
@dadachi
dadachi force-pushed the feat/autoformat-after-rename branch from 5ab2ec3 to 5102367 Compare October 18, 2026 00:19
@dadachi
dadachi merged commit b472ece into main Oct 18, 2026
1 check passed
@dadachi
dadachi deleted the feat/autoformat-after-rename branch October 18, 2026 00:22
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.

Run the generated apps' linters (with autocorrect) after the rename

1 participant