perf(check): batch git subprocesses and auto-populate baseBranch on init#347
Merged
rhuanbarreto merged 7 commits intoMay 25, 2026
Merged
Conversation
…nit (#343, #346) Parallelize independent git subprocess calls to reduce `archgate check` latency, and auto-detect the base branch during `archgate init` so subsequent checks skip the 1-4 probe detection entirely. - Parallelize staged + unstaged diff calls in `getChangedFiles()` via `Promise.all` (~25ms saved on Windows per call) - Parallelize `changedFiles` + `trackedFiles` fetch in `runChecks()`, interleaving synchronous work while git I/O runs - Auto-detect and save `baseBranch` to `.archgate/config.json` during `initProject()`, completing the existing config plumbing - Add `resolveBaseRef()` test suite covering priority resolution - Add baseBranch auto-detection tests (save, idempotent re-init, non-git) Closes #343, closes #346 Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Deploying archgate-cli with
|
| Latest commit: |
bd5b509
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cc9e02ab.archgate-cli.pages.dev |
| Branch Preview URL: | https://perf-batch-git-subprocesses.archgate-cli.pages.dev |
Contributor
Code Coverage
Full HTML report available in workflow artifacts. Per-directory breakdown
|
Add baseBranch to the configuration reference (EN + PT-BR) with type, default, description, and manual override example. Document the init command's base branch auto-detection behavior in both locales. Update the config.json intro to reflect that init now creates the file for baseBranch (not just custom domains). Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
When resolveBaseRef() falls back to auto-detection and succeeds, save the detected branch to .archgate/config.json so all subsequent runs skip the 1-4 git probe detection entirely. This benefits users who never run archgate init — the optimization kicks in after the first check invocation. The lazy-save is non-fatal (try/catch) so read-only filesystems and CI environments are unaffected. It also preserves any existing baseBranch value to avoid overwriting manual configuration. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
…ogic The same detect → check config → save pattern was duplicated in init-project.ts and git-files.ts. Extract into ensureBaseBranch() in project-config.ts (where the other baseBranch helpers live). Both init (eager) and resolveBaseRef (lazy) now call the same function, which accepts detectBaseRef as a parameter to avoid a circular dependency between engine and helpers. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
The buildReviewContext tests used bare rmSync for temp dir cleanup, which fails intermittently on Windows when git processes haven't fully released file locks. Switch to safeRmSync (retry with backoff), matching the pattern already used in git-files.test.ts and init-project.test.ts. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
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
getChangedFiles()andrunChecks()viaPromise.all, reducingarchgate checklatency by ~50-150ms (most impactful on Windows where process creation is expensive)baseBranchto.archgate/config.jsonduringarchgate init, so subsequentcheckruns skip the 1-4 sequential git probe detection entirelyresolveBaseRef()test suite covering the full priority resolution chain:--staged→--base→ config → auto-detectCloses #343, closes #346
Details
Git subprocess batching (#343)
getChangedFiles()ran staged and unstaged diff calls sequentially — now concurrent viaPromise.all. InrunChecks(), the changed files fetch and tracked files fetch were also sequential despite being independent — now started concurrently with synchronous work (filtering loadResults, resolving filterFiles) interleaved while the git I/O runs.baseBranch auto-population (#346)
The
baseBranchconfig field, reader (getConfiguredBaseBranch), and consumer (resolveBaseRef) already existed but nothing populated the field.initProject()now callsdetectBaseRef()after directory creation and saves the result toconfig.json. The detection is:baseBranchis already configured (safe for re-init)Test plan
resolveBaseRef()tests: staged short-circuit, explicit base priority, configBase priority, fallback to detectBaseRef, non-git fallbackgetChangedFilesanddetectBaseReftests still pass (behavior unchanged)bun run validatepasses (lint, typecheck, format, test, ADR check, knip, build)