fix: bound git remote resolution under the trails probe timeout · Entire

fix: bound git remote resolution under the trails probe timeout

32c3604→main·

dipree·1mo ago·1 file·+8 added/-8 removed

Create the timeout context before resolveTrailRemote (which shells out to
git) so every step of the enablement check is bounded by
trailsEnabledProbeTimeout, not just client construction and the HTTP probe.

Sessions

fccd5f1af606View transcript

?\
Inject Trail Context into Agent ModelPi·Opus 4.8·1 step

Changes

1

381 unmodified lines

382
383
384
385
386
387
388
385
386
387
388
389
390
391
392
393
390
391
392
393
394
395
396
397
398

381 unmodified lines

// this repo on the API. It resolves the origin remote to a supported forge and
// probes the trails endpoint; a successful response means trails are
// provisioned/enabled. Best-effort and bounded by a single short timeout that
// covers both client construction (which may do /.well-known discovery and a
// token exchange) and the probe — an unresolved remote, missing auth, or any
// API/transport error reports false, so we never advertise trails we can't
// confirm are enabled.
// covers every step — git remote resolution (a subprocess), client
// construction (which may do /.well-known discovery and a token exchange), and
// the probe. An unresolved remote, missing auth, or any API/transport error
// reports false, so we never advertise trails we can't confirm are enabled.
func trailsEnabledForRepo(ctx context.Context) bool {
    forge, owner, repo, err := resolveTrailRemote(ctx)
    if err != nil {
        return false
    }
    probeCtx, cancel := context.WithTimeout(ctx, trailsEnabledProbeTimeout)
    defer cancel()
    forge, owner, repo, err := resolveTrailRemote(probeCtx)
    if err != nil {
        return false
    }
    client, err := NewAuthenticatedAPIClient(probeCtx, false)
    if err != nil {
        return false // not authenticated → trails aren't enabled for us
    }