Fix Agent Help Trail Availability

agent-help trail is claiming trails is not available but it should actually check the availability of it. The reason it says that is becaue the feature is not generally available but we do have an elaborate check whether trails is enabled for a repo and we should just use that instead of saying it's not available.
Implemented the trails availability fix.
entire agent-helpnow refreshes missing or stale repo-specific trails enablement before deciding availability.- Uses the existing cached/API enablement mechanism with a bounded timeout.
- Added regression coverage for an unknown cache becoming enabled.
- Full
./cmd/entire/clitest suite passes.
Committed, pushed, and created PR:
Does this make any sense?
"This refresh call gives entire agent-help (and the agent_help MCP tool via mcp.go:221) a hard network/auth dependency it previously didn't have: refreshTrailsEnabledCacheIfStaleForScope → NewAuthenticatedAPIClient → auth.ResolveDataAPIToken always performs a /.well-known/entire-api.json discovery GET before it even checks whether any login context exists, so on a cold cache (first run, or hourly TTL expiry) agent-help can now block for up to the full trailEnablementRefreshTimeout (3s) whenever the user is offline or not yet logged in — exactly the situation where an agent is most likely to reach for agent-help as a first step. Previously this call was cache-only and instant regardless of auth/network state. Consider keeping the fast cache-only read as the default for agent-help and only triggering the network refresh in a non-blocking/best-effort way (as refreshTrailsEnabledCacheBestEffort already does elsewhere), or shortening/bounding this specific path more aggressively."
Yes—mostly.
The review correctly identifies a latency regression:
- On a missing/stale cache,
agent-helpand MCP synchronously perform auth discovery and an API probe. - Offline users can wait up to 3 seconds.
- Users with no login context may still incur discovery before auth fails.
Two nuances:
- It is not a hard functional dependency: refresh errors are swallowed and help still renders. It is a synchronous latency dependency.
refreshTrailsEnabledCacheBestEffortis also synchronous; “best effort” does not make it non-blocking.
Keeping agent-help cache-only would recreate the original bug. Better mitigations are:
- Skip refresh immediately when
scope.AuthKey == "". - Probe primarily for explicit trail help requests.
- Use a shorter agent-help-specific timeout.
- Report availability as unknown rather than “not enabled” when probing fails.
Yes. scope.AuthKey == "" reliably indicates no local login identity, so skipping refresh avoids the worst first-run case without reintroducing the original bug for authenticated users.
Offline-but-logged-in users could still wait up to 3 seconds on stale cache, but that is less common and necessary to obtain a fresh answer. I’d implement option 1 and keep the bounded refresh for authenticated users.
Implemented and pushed to PR #1762.
- Skips trails refresh when no local auth identity exists.
- Added regression coverage ensuring no refresh/network path is invoked.
- Full CLI package tests pass.
Entire Trail review comment ID: 019f65e8-e907-7f5e-b401-c2cbb611404c URL: https://entire.io/gh/entireio/cli/trails/864/fix-agent-help-refresh-trails-availability Severity: medium Context: cmd/entire/cli/agent_help_cmd.go:102 Selected context:
agentHelpRepoContextWithRefresh now makes entire agent-help do a network round trip (via refreshTrailsEnabledCacheIfStaleForScope → NewAuthenticatedAPIClient → auth.ResolveDataAPIToken) whenever the local trails cache is unknown/stale and the user is logged in, blocking for up to trailEnablementRefreshTimeout (3s). If that call fails (e.g. offline, DNS/API discovery failure), refreshTrailsEnabledCacheIfStaleForScope returns an error without writing anything to the cache, so the decision stays trailEnablementCacheUnknown and every subsequent agent-help invocation repeats the same blocking network attempt instead of negatively caching the failure — turning a previously instant, offline-safe introspection command into one with a recurring multi-second stall on every call in degraded-network environments.
Addressed and pushed to PR #1762.
- Failed refreshes now create a five-minute negative cache.
- Repeated
agent-helpcalls avoid recurring three-second stalls. - Definitive disabled results retain the normal one-hour TTL.
- Added regression coverage for failure backoff and retry expiry.
- Full CLI and settings tests pass.
Entire Trail review comment ID: 019f65f0-e225-7982-a723-a851bb95f596 URL: https://entire.io/gh/entireio/cli/trails/864/fix-agent-help-refresh-trails-availability Severity: medium Context: cmd/entire/cli/agent_help_cmd.go:111 Selected context:
agentHelpRepoContextWithRefresh now writes to the shared trails-enablement cache (.entire clone preferences) on a failed refresh, which previously only SessionStart/trail commands ever mutated. refreshTrailsEnabledCacheIfStaleForScope (called from lifecycle.go at SessionStart) treats any non-trailEnablementCacheUnknown cache entry as fresh and skips its own refresh — so a transient failure surfaced only by an entire agent-help call can plant a 5-minute-backoff "disabled" entry that suppresses SessionStart's real probe. If emitContextInjection finalizes ContextInjectionDecided during that window it locks in disabled for the rest of the session (it never re-checks once decided), even though trails may actually be enabled and reachable moments later.
Addressed and pushed.
The five-minute failure backoff is now stored separately from the shared trails-enablement decision. Therefore:
- Repeated
agent-helpcalls still avoid network stalls. SessionStartcontinues its authoritative probe.- Context injection is never finalized as disabled due to an
agent-helpnetwork failure.
Tests verify the shared cache remains unknown after failure.
Fixed and pushed.
CI reported:
- Unchecked
saveAgentHelpTrailsRefreshFailureerror — now debug-logged. - Repeated
"gh/acme/app"test string — replaced with a constant.
Relevant tests pass; CI is rerunning.