Skip to content

feat(track): add --wait to block until the repo is indexed#170

Merged
zzet merged 1 commit into
mainfrom
feat/track-wait-flag
Jun 25, 2026
Merged

feat(track): add --wait to block until the repo is indexed#170
zzet merged 1 commit into
mainfrom
feat/track-wait-flag

Conversation

@zzet

@zzet zzet commented Jun 25, 2026

Copy link
Copy Markdown
Owner

What

Adds --wait (and --wait-timeout) to gortex track:

gortex track --wait .            # block until the repo is indexed + queryable
gortex track --wait --wait-timeout 5m .

gortex track hands the repo to the daemon and returns immediately — indexing runs asynchronously — so a following gortex analyze / query can race ahead of the graph being ready. --wait blocks until indexing settles, then returns.

Why

The one-shot / CI pattern ("index this path, then analyze it, in one job") currently needs an inline poll loop in every workflow:

gortex track .
for i in $(seq 1 60); do gortex status | grep -qE '[1-9][0-9]* nodes' && break; sleep 2; done
gortex analyze --kind synthesizers --format json

With this flag that collapses to:

gortex track --wait .
gortex analyze --kind synthesizers --format json

Settle semantics

--wait polls the daemon (reusing the same ControlStatus the status command uses) until the tracked repo is present with a non-zero node count that has stopped moving (stable across two consecutive polls) and the daemon reports a resolved, queryable graph (Ready). The per-repo stable-count check is what makes this hold on a warm multi-repo daemon, where the daemon-global Ready flag alone wouldn't tell you this repo finished.

  • --wait-timeout (default 10m, 0 = wait forever) bounds it so CI can't hang.
  • With --wait, a missing/unavailable daemon is an error (the flag promised a queryable graph it can't deliver) rather than the normal offline-safe soft success.

The classifier and poll loop are pure/seam-injected, so the tests exercise them without a running daemon (stubbed status fn + sub-ms poll interval).

Scope

go build ./..., go vet, golangci-lint clean; go test ./cmd/gortex/ passes (531).

🤖 Generated with Claude Code

gortex track hands the repo to the daemon and returns immediately, so a
following gortex analyze / query can race ahead of indexing. --wait blocks
until the daemon reports the repo present with a stable, non-zero node
count and a resolved (Ready) graph, with --wait-timeout (default 10m,
0 = forever) as a CI guard. It errors instead of the soft offline success
when no daemon is available to satisfy the wait.

This collapses the CI one-shot recipe to `gortex track --wait .` followed
by `gortex analyze`, replacing an inline poll-until-nodes shell loop.

The settle check — per-repo node count stable across two polls plus a
global Ready floor — is a heuristic that holds on warm multi-repo daemons
where the global Ready flag alone would be insufficient. Tests stub the
status seam and shrink the poll interval so they run without a daemon.
@zzet zzet merged commit 3d8c6bf into main Jun 25, 2026
10 checks passed
@zzet zzet deleted the feat/track-wait-flag branch June 26, 2026 07:53
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.

1 participant