Skip to content

test(workflow): give the eight flaky workflow cases a budget that fits their real work (#1504) - #1522

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
Walternater:fix/1504-workflow-test-flakes
Oct 28, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
Walternater:fix/1504-workflow-test-flakes

Conversation

@Walternater

@Walternater Walternater commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Part 1 of #1504: the three of the eight workflow cases that flake on a loaded macOS runner because of the default 15 s budget get a budget that fits the real work they wait for.

The other five cases in the issue's table are not a budget problem and are filed elsewhere:

What changed

Only timeouts, and a comment each saying what the test waits for:

Test File Budget
continues a copy it took back from the commit the other machine recorded workflow-handoff.test.ts 120 s
kills a cancelled command that ignores SIGTERM after the grace period workflow-local-driver.test.ts 120 s (was 30 s)
kills a descendant that ignores SIGTERM after the cancelled command itself exited workflow-local-driver.test.ts 120 s

No product code changes, and no test logic changes: a test that fails for a reason other than the budget still fails.

Evidence

Each of the three fails on the default 15 s budget, not on a wrong answer. It waits on real work — a git worktree added and pushed, two of them in parallel, a member's copy fetched from another machine, or a child process that ignores SIGTERM and is killed after a five-second grace period. On an idle runner they take 1–3 s; on a loaded one they take tens of seconds.

The failure reproduces locally as a timeout:

$ 6 runs of "does not publish an agent conflict a prompt left untouched", at once
FAIL src/__tests__/workflow-workspace.test.ts > workflow workspaces > does not publish an agent conflict a prompt left untouched
Error: Test timed out in 15000ms.

The same shape for the others: Test timed out in 15000ms, with the case itself taking 70 s under that load (Duration 107.15s, of which 70.18 s the test). With the budget raised, the same six-at-once load passes.

In CI these three fail the same way: run 40683380254 (macOS Node 22) logged Error: Test timed out in 15000ms for the two workflow-local-driver rows and for the workflow-handoff row.

Tests

  • npx tsc --noEmit — passes.
  • npm run lint — 0 warnings, 0 errors.

No real-CLI record: the diff changes test budgets only, not what the CLI does.

Notes for reviewers

@github-actions

Copy link
Copy Markdown
  • [P2 non-blocking] Remove the tracked, machine-specific dependency symlink (node_modules:1). It points to /Users/wcf/IdeaProjects/teamai-cli-pr1513/node_modules, which is unavailable on other machines, and is unrelated to the stated timeout-only change. This violates the requirement that every changed line trace directly to the PR’s goal.

No findings in the eight timeout changes. The description records type-check and lint results; these test-budget changes require no real-CLI verification record.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

@Walternater Thanks for taking Part 1 of #1504. The comments say what each test waits for, which is what the issue asks for when a timeout is raised. Two things before we can approve:

  • [P1 blocking] The node_modules symlink is committed again. It points to /Users/wcf/IdeaProjects/teamai-cli-pr1513/node_modules, like the one #1521 had. Checking out this branch over an existing install deletes the local node_modules/, because .gitignore's node_modules/ doesn't match a symlink. git rm --cached node_modules removes it.

  • [P2 non-blocking, but it fits this PR] Four rows of the #1504 table failed on assertions, not on the 15 s budget. The body says every case fails on the budget and that your repro under load shows timeouts. In CI, though, these four failed differently:

    • workflow-workspace.test.ts, "does not publish an agent conflict a prompt left untouched": an assertion at :1787.
    • The same file, "does not publish conflict markers a prompt left in an agent file": expected undefined to match object { code: 'merge_conflict' } at :2252.
    • The same file, "keeps a modify/delete resolution a prompt staged without editing the file": an assertion at :2452.
    • workflow-skill-driver.test.ts, "stops the setup a killed runner left running": expected true to be false at :891.

    A larger test budget doesn't change an assertion that fails before the budget runs out. That could still be load if something inside these tests has its own deadline (a lock, a poll, a grace period) that gives up and returns early. Can you point to that deadline for each? Or show the four rows passing 20 runs in a row under the same load, which is the issue's other way to close a row? If one of them is a real race, the issue asks for its own issue.

The other four rows (workflow-handoff, the two workflow-local-driver SIGTERM cases, workflow-skill-lock) failed on the 15 s budget, and the comments say what each one waits on. Those look right to us.

@SaulMoro
SaulMoro self-requested a review October 28, 2026 11:45
@Walternater
Walternater force-pushed the fix/1504-workflow-test-flakes branch from 1e6fe83 to 4588a2a Compare October 28, 2026 11:52
@github-actions

Copy link
Copy Markdown

No new findings in the specified diff.

  • Resolved: The machine-specific node_modules symlink is absent from the current diff.
  • The changes only increase test timeouts and add explanatory comments; no test logic or runtime behavior changes.
  • Testing: The description records passing type-check and lint runs. This tests-only diff requires no end-to-end / real-CLI record under the review rules.

No PR code was run, built, or installed.

@SaulMoro

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

@Walternater Thanks. The symlink is gone. Splitting the two skill-driver cases into #1523 makes sense, and the three workflow-local-driver / workflow-handoff cases look right to us.

One point is still open for the three workflow-workspace.test.ts cases. In CI they didn't fail on the 15 s budget. Each one finished, and then failed its last assertion:

// workflow-workspace.test.ts:1783-1787 on main
expect(done).toMatchObject({ data: { done: { outcome: 'failed' } } });   // passed
const join = run.steps.find((step) => step.id === 'join');
expect(join && 'failure' in join ? join.failure : undefined)
  .toMatchObject({ code: 'merge_conflict' });                            // got undefined

So the run failed for some other reason inside the 15 s. Most likely left or right failed, the two parallel workspace: new steps, and join never ran. :2252 (expected undefined to match object { code: 'merge_conflict' }) and :2452 have the same shape. A larger test budget doesn't change that outcome, so these three can still flake after this PR.

Two ways forward:

The rest is ready to approve once that is settled.

…that fits their real work (Tencent#1504)

Three of the eight cases in the table of Tencent#1504 fail the same way: the default
15 s budget, not a wrong answer. Each waits on real work — two git worktrees in
parallel, a child process that ignores SIGTERM and is killed after a grace
period, or a member's copy fetched from another machine. On an idle runner they
take 1-3 s; on a loaded one, tens of seconds.

Each gets a budget that fits, and a comment that says what it waits for. The
three workflow-workspace cases are left out: in CI they end early with a
wrong outcome, which no budget fixes (see the issue filed for them).
@Walternater

Copy link
Copy Markdown
Collaborator Author

@SaulMoro The three workflow-workspace.test.ts cases are out of this PR now, and the answer to your question is in the CI log: it is not an engine deadline, so no budget can change it.

The failing run is the shortest of the three, not the longest. From the reporter of CI run 40601406383 (macOS Node 22, an unrelated PR), the same file, minutes apart:

✓ workflow workspaces > does not publish an agent conflict a prompt left untouched  1445ms
× workflow workspaces > does not publish conflict markers a prompt left in an agent file  684ms
✓ workflow workspaces > keeps a modify/delete resolution a prompt staged without editing the file  1581ms

684 ms against 1445 ms and 1581 ms. The run ended early because a step failed, not because it ran out of time: done.outcome is failed, and join carries no failure at all, so join never ran — it needs left and right, and one of the two parallel workspace: new steps failed before it. A larger budget leaves that outcome exactly as it is.

So they are a race, and #1504's definition of done says a real race gets its own issue. That is #1526: #1526

What I could not do is name the failing step — the test asserts on join and says nothing about the step that failed. I ran the three cases 32 times in a row on an idle machine and 20 rounds of the failing one inside one process with the machine loaded, and it passed every time, so the failure does not reproduce here. #1526 therefore starts with the step you suggested: put the run's steps in the assertion message, so the next failure names the step and its code. Once that is in, the next CI failure shows the cause instead of hiding it.

What is left in this PR is the three rows that do wait on real work, each with a comment saying what it waits for:

Test File Budget
continues a copy it took back from the commit the other machine recorded workflow-handoff.test.ts 120 s
kills a cancelled command that ignores SIGTERM after the grace period workflow-local-driver.test.ts 120 s (was 30 s)
kills a descendant that ignores SIGTERM after the cancelled command itself exited workflow-local-driver.test.ts 120 s

Those three fail on the 15 s budget in CI as well — run 40683380254 (macOS Node 22) logged Error: Test timed out in 15000ms for each of them.

One thing worth knowing about the same run: it also failed two rows that are not in #1504's table, with the same 15 s budget — workflow-handoff.test.ts "refuses a member who no longer owns the run before it pins a base, archives a session, or publishes a record", "continues the plan's session with every turn a step added on either machine, when the run goes back and forth", and score-drain.test.ts "runs at the end of an unattended local run, …". So the table is a sample of a wider problem: on a loaded macOS runner, whichever case is slowest runs into the 15 s budget. I put that in a comment on #1504 so the table can grow if you want it to.

The node_modules symlink is gone, and the branch now touches only the two test files above.

@github-actions

Copy link
Copy Markdown

No new findings in the specified diff.

  • Resolved: The machine-specific node_modules symlink is absent from the current diff.
  • The three changes only increase test timeouts to 120 seconds and add explanatory comments; no test logic or product behavior changes.
  • Testing: The description records passing type-check and lint runs. This tests-only PR requires no end-to-end / real-CLI record under the review rules.

No PR code was run, built, or installed.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

@Walternater Thanks, approving 3c662892, and thanks for running the workspace cases down.

  • What's left. The three rows left here fail on the 15 s budget in CI, and each waits on real work: a second machine's worktree and claim, or a child that ignores SIGTERM until the grace period kills it. Each comment says which. That is the case #1504 allows a raised timeout for.
  • The workspace cases. Your reporter timings settle it: the failing case ended in 684 ms, so the run failed early and no budget would change it. Moving those three to #1526, starting with an assertion message that names the failed step, is the right next step.
  • Housekeeping. The node_modules symlink is gone, and the diff touches only the two test files. It merges cleanly with current main, and CI is green at this head.

The other rows you saw hit 15 s in the same run belong on #1504, as you noted there.

@SaulMoro
SaulMoro merged commit f51e83f into Tencent:main Oct 28, 2026
18 checks passed
Walternater added a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…dget that fits it (Tencent#1522)

Part of Tencent#1504: the workflow-handoff case that continues a copy taken back from another machine, and the two workflow-local-driver cases that kill a command or descendant ignoring SIGTERM, get a 120 s budget with a comment saying what each waits on. The three workflow-workspace cases from Tencent#1504 are a race, tracked in Tencent#1526.
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.

3 participants