Skip to content

test(term-fidelity): harden opencode readiness + isolate opencode data dir#418

Merged
khaliqgant merged 1 commit into
mainfrom
fix/term-fidelity-opencode-readiness
Jul 18, 2026
Merged

test(term-fidelity): harden opencode readiness + isolate opencode data dir#418
khaliqgant merged 1 commit into
mainfrom
fix/term-fidelity-opencode-readiness

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Jul 18, 2026

Copy link
Copy Markdown
Member

What

Two opencode-scoped hardening changes to the real-agent terminal-fidelity matrix harness. Not a #417 fix — this makes the harness reach a live-input opencode deterministically so the divergence hunt has a trustworthy denominator. Keeps the #417 divergence investigation epistemically separate.

Why

The opencode leg intermittently failed at startup with opencode startup did not reach TF_OPENCODE_READY (a blank/idle home screen). Direct probes localized the cause:

  • opencode's OpenTUI takes several seconds to accept input after launch (MCP init, fs watcher / location services, and a scan of the user's global skill + config trees).
  • The broker injects the readiness task once at spawn. An injection landing before opencode's input is live is silently dropped → opencode idles at its home screen until the 90s deadline.
  • Standalone, opencode renders and completes the readiness model turn reliably (replies in 2–5s). So this is purely an injection/boot race — not a renderer or model-backend fault.

Separately, the matrix opencode was writing test sessions into the operator's real, shared ~/.local/share/opencode/opencode.db (multi-GB) — a hygiene problem regardless of the flake.

Changes (opencode only; other CLIs untouched)

  1. Boot re-nudge (workloads.ts): once the home screen is up and the marker is still absent past a grace window, re-submit the idempotent readiness prompt on an interval until the marker appears. Runs strictly before any workload and stops the instant the marker shows, so it cannot bleed into / mask the typing-during-stream observation.
  2. XDG_DATA_HOME isolation (harness.ts): give opencode a fresh, empty data dir under the harness run root (auth.json copied across; model cache in XDG_CACHE_HOME untouched). Removes shared-DB contention and stops polluting the operator's real opencode history.

Verification

  • Forced-drop proof: with the broker delivering an empty task (injection fully dropped), the re-nudge alone drove opencode to readiness and typing-during-stream passed.
  • lsof: the harness opencode holds only the isolated empty DB and never opens the shared one.
  • Happy path: normal runs still reach readiness and pass, with no spurious nudge.
  • Typecheck clean (tsc -p tests/term-fidelity/tsconfig.json).

🤖 Generated with Claude Code

Review in cubic

…a dir

The opencode leg of the real-agent matrix intermittently failed at startup
with "opencode startup did not reach TF_OPENCODE_READY" (a blank/idle home
screen). Direct probes localized it: opencode's OpenTUI takes several seconds
to accept input after launch (MCP init, fs watcher / location services, and a
scan of the user's global skill + config trees), while the broker injects the
readiness task once at spawn. An injection that lands before opencode's input
is live is silently dropped, and opencode then idles at its home screen until
the 90s readiness deadline. Standalone, opencode renders and completes the
readiness model turn reliably (replies in 2-5s), so this is purely an
injection/boot race, not a renderer or model-backend fault.

Two opencode-scoped harness changes (no other CLI's path is touched):

1. Boot re-nudge: once the home screen is up and the marker is still absent
   past a grace window, re-submit the idempotent readiness prompt on an
   interval until the marker appears. It runs strictly before any workload and
   stops the instant the marker shows, so it cannot bleed into or mask the
   typing-during-stream observation that follows.

2. XDG_DATA_HOME isolation: give opencode a fresh, empty data dir under the
   harness run root (auth.json copied across; the model cache in
   XDG_CACHE_HOME is untouched). Independent hygiene win: the matrix was
   otherwise writing test sessions into the operator's real, shared
   ~/.local/share/opencode/opencode.db.

Not a #417 fix — this only makes the harness reach a live-input opencode
deterministically so the divergence hunt has a trustworthy denominator.

Verification:
- Forced-drop (broker delivers an empty task, i.e. the injection is fully
  dropped): the re-nudge alone drives opencode to readiness and the
  typing-during-stream workload passes.
- lsof: the harness opencode holds only the isolated empty DB and never opens
  the shared one.
- Happy path: normal runs still reach readiness and pass with no spurious
  nudge.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@khaliqgant khaliqgant added the no-agent-relay-review Disable agent-relay automated PR review/fixes label Jul 18, 2026
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@khaliqgant, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 111bc040-e3f6-431b-905b-07fce25665d0

📥 Commits

Reviewing files that changed from the base of the PR and between 06137e1 and 4c25f60.

📒 Files selected for processing (2)
  • tests/term-fidelity/harness.ts
  • tests/term-fidelity/workloads.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/term-fidelity-opencode-readiness

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khaliqgant
khaliqgant marked this pull request as ready for review July 18, 2026 01:15
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@cursor

cursor Bot commented Jul 18, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@khaliqgant
khaliqgant merged commit 14a8b54 into main Jul 18, 2026
4 checks passed
@khaliqgant
khaliqgant deleted the fix/term-fidelity-opencode-readiness branch July 18, 2026 01:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c25f60f47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +146 to +150
OPENCODE_HOME_HINT.test(lastScreen) &&
Date.now() - startedAt >= READINESS_NUDGE_GRACE_MS &&
Date.now() - lastNudgeAt >= READINESS_NUDGE_INTERVAL_MS
) {
await submitPrompt(terminal, readinessNudge)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restrict re-nudges to OpenCode's idle composer

When the initial readiness turn takes longer than the 6-second grace period, this condition can submit another prompt while that turn is still streaming: ctrl+p is a persistent OpenCode footer hint rather than an idle-only signal. Additional nudges can therefore be queued every eight seconds; once the first response prints the marker, startup returns and begins the terminal-fidelity workloads while a duplicate readiness turn remains queued or active, contaminating their PTY streams and results. Gate the nudge on a state that proves OpenCode is idle rather than on this footer text.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-agent-relay-review Disable agent-relay automated PR review/fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant