Skip to content

chore(desktop): stop rebuilding a git repo for every question-relay test - #95851

Open
posthog[bot] wants to merge 1 commit into
masterfrom
posthog-self-driving/fixdesktopagent-scope-the-git-repo-8880c4
Open

chore(desktop): stop rebuilding a git repo for every question-relay test#95851
posthog[bot] wants to merge 1 commit into
masterfrom
posthog-self-driving/fixdesktopagent-scope-the-git-repo-8880c4

Conversation

@posthog

@posthog posthog Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Problem

  • Desktop agent engineers see "Verify agent release build" go red on a PR that has no defect in it: the job failed and passed on a rerun of the same commit 7 times in the last 7 days. It is the second flake class in this job, so the check is losing its meaning.
  • The confirmed sample is not the msw leak fixed earlier. It is Error: Hook timed out in 10000ms. from the beforeEach in question-relay.test.ts, taking 2 of 2,337 tests down while 125 of 126 files passed.
  • createTestRepo() spawns six sequential git subprocesses plus file writes. The hook ran it for all 51 tests in the file, so one file paid for 306 process spawns. On a shared 4-vCPU runner that setup sometimes passes Vitest's 10s default hook budget, and retry: 0 turns the raw failure into a red check.

Changes

  • The repo those 51 tests were paying for was never used as a repo. No test in question-relay.test.ts starts a session, reads a file, or runs git — repo.path is only passed as a repositoryPath config value. The fixture now runs once per file in beforeAll, and beforeEach builds only the AgentServer, which touches no disk.
  • agent-server.test.ts keeps its per-test repo, because its tests do write into it, and gets the longer hook budget instead.
  • Hooks that build a repo declare TEST_REPO_HOOK_TIMEOUT_MS (30s), a shared constant next to createTestRepo that records why the default is not enough.
  • retry is untouched. vitest.config.base.ts holds retry: 0 on purpose so Trunk sees raw pass/fail.
git subprocesses per run hook budget
question-relay.test.ts before 306 (51 tests × 6) 10s, per test
question-relay.test.ts after 6 (once per file) 30s, once per file
agent-server.test.ts after unchanged (per test) 30s

How did you test this code?

  • No new tests. The change moves an existing fixture and widens a hook budget, so the regression it guards against is a timeout, which a test cannot assert cheaply or deterministically.
  • Ran vitest run src/server/question-relay.test.ts in the sandbox: 51 passed, and the file's test time fell from 1218ms to 109ms.
  • Ran vitest run src/server/agent-server.test.ts: 204 passed, 6 failed. Those 6 (buildCloudSystemPrompt) fail identically on unmodified master in this sandbox, so they are environment-dependent and not caused by this change.
  • tsc --noEmit and biome check are clean on the package.
  • Not verified: that the flake stops. That is only observable over rerun history on the real runner.
Sandbox note

createTestRepo commits in a throwaway temp repo, so the suite needs POSTHOG_ALLOW_UNSIGNED_GIT=1 to run inside the cloud sandbox, where a git guard blocks commit.

Automatic notifications

  • Publish to changelog?

Docs update

None. No user-facing behavior, API, or documented workflow changes.

🤖 Agent context

Autonomy: Fully autonomous

  • Written by Claude Opus 5 in PostHog Desktop, from the linked inbox report. No repo skills applied to a test-only change of this shape; the /simplify pass was done by rereading the diff, since the skill was not available in the session.
  • The report proposed moving the fixture into the describes that use it. Reading the file showed a stronger answer: every describe except the pure classification cases uses server, so per-describe scoping would have created several repos per file rather than fewer. Checking AgentServer showed the constructor never reads repositoryPath — only session start and PR flows do, and this file exercises neither — so one repo per file is both cheaper and safe.
  • Sharing one repo across tests is safe here only because no test mutates it. That is why agent-server.test.ts, whose tests write into the repo, kept its per-test fixture.
  • resume-saga.test.ts has the same per-test createTestRepo shape and was left alone: it has not been observed failing, and widening past the reported symptom was not warranted. It is the next candidate if this flake class returns.
  • Duplicate check: gh pr list --state open --search for this area found no existing PR.
  • Public artifact: the diff, this description, and the commit message carry no material from the agent session beyond what the linked report already states.

Created with PostHog Desktop from this inbox report.

The question-relay suite built a throwaway git repo in `beforeEach`, but no test in the file runs git or starts a session - the repo only supplies a `repositoryPath` value. Build it once per file instead, and give the hooks that still need a repo per test a 30s budget, because the six sequential git subprocesses can pass Vitest's 10s default on a loaded runner.

Generated-By: PostHog Desktop
Task-Id: c4419abc-ad95-4cd6-a227-209119aa8881
@trunk-io

trunk-io Bot commented Sep 7, 2026

Copy link
Copy Markdown

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@posthog

posthog Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

🦔 PostHog Review reviewed this pull request

Nothing worth raising this time, so here's a calming picture instead:

A panda relaxing and waving

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit c1bbab6.

@github-actions github-actions Bot added the feature/desktop Feature Tag: Desktop label Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🤖 CI report

Trunk lane — non-backend lane

This PR is assigned to the non-backend lane. It does not run backend Python tests and may merge in parallel with PRs in other lanes.

@stamphog stamphog 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.

Approved.

Test-only refactor confined to one package: moves a git-repo fixture from per-test to per-file setup where no test in question-relay.test.ts actually touches the filesystem, and widens hook timeouts for the git-repo-writing suite. No production code, CI config, or API/data-model changes; diff matches the description.

  • 3 of the 3 changed files are governed by products/desktop/AGENT_APPROVALS.md.
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 0L, 0F substantive, 26L/3F incl. docs/generated/snapshots — within ceiling
tier T0 auto-approve: T0-deterministic (26L, 3F, single-area, chore)
stamphog 2.0.0b4 .stamphog/policy.yml @ c1bbab6 · reviewed head c1bbab6

@hosthog

hosthog Bot commented Sep 7, 2026

Copy link
Copy Markdown

HostHog preview — posthog-desktop-web

Latest build (c1bbab6): https://f2c1647b06f5445aa3d1b5bcc86945c9.hosthog.dev

Employee-gated; every push gets a fresh URL whose content never changes. All previews stop serving when the PR closes.

@posthog
posthog Bot marked this pull request as ready for review September 7, 2026 00:50
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team September 7, 2026 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature/desktop Feature Tag: Desktop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants