Skip to content

test: stabilize task wait and session reload checks - #4901

Merged
sailist merged 1 commit into
mainfrom
bug-362-11-12-task-reload-ci-flakes
Nov 13, 2026
Merged

sailist merged 1 commit into
mainfrom
bug-362-11-12-task-reload-ci-flakes

Conversation

@sailist

@sailist sailist commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Requirement or Bug

Related to #4820. Its CI run 43237351561 failed two unrelated tests on attempt 1 and passed both on rerun. This PR makes the two tests deterministic without changing production behavior.

Bug Reproduction Steps

  • test (2) (attempt 1 job): the zero-timeout task wait test expected running but received completed.
  • test (5) (attempt 1 job): the workspace reload test expected an instructions reload failed rejection, but reloadSession() resolved.

Both outcomes depend on asynchronous ordering, so repeated runs can pass or fail with the same code.

Root Cause

  • The task fixture uses file-backed output. Tool execution reaches its terminal state after output flush/close, while wait(0) races that completion against a zero-millisecond timer. The test did not control which finished first, so either running or completed could be returned.
  • The reload test installed a one-shot rejection on a shared instructions.reload method. Watcher-driven reloads can invoke the same method before the explicit reloadSession() call, consume the rejection, and let the explicit call succeed.

This is a fundamental fix for the test non-determinism: control the terminal-state precondition and the lifetime of the injected failure. No production workaround is introduced.

Code Changes

  • packages/agent-core-v2/test/agent/task/taskManager.test.ts: wait for the task to reach completed through manager.wait() before checking the zero-timeout completed fast path. The adjacent test continues to cover the pending running result.
  • packages/node-sdk/test/sdk-rpc-client-v2.test.ts: keep the instructions reload rejection active until the rejection assertion finishes, then restore the original method and verify successful recovery.
  • Test counts remain unchanged at 53 and 105. There are no runtime code, API, configuration, or shipped-asset changes.

Behavior Changes and Affected Users

None. This PR changes tests only; users and production callers observe no behavior change. No defaults are flipped and no behavior is removed, so no escape hatch or changeset is needed.

Affected coverage:

  • Task wait behavior: pending and already-completed zero-timeout snapshots.
  • Session reload behavior: deterministic failure propagation, unchanged live-session ownership on failure, reminder deduplication, and successful reload after recovery.

Verification

  • m0-dev full files: taskManager.test.ts 53/53; sdk-rpc-client-v2.test.ts 105/105.
  • Each affected test passed 30/30 focused repetitions.
  • Each affected test passed with its original CI shard import load (--shard=2/5 and --shard=5/5).
  • @moonshot-ai/agent-core-v2 and @moonshot-ai/kimi-code-sdk typecheck passed.
  • Focused type-aware oxlint: 0 errors, 2 pre-existing warnings outside the changed lines.
  • Full monorepo suite was not run.

Checklist

  • I have read the CONTRIBUTING document.
  • Related context is linked (refactor(core): extract loop, llm, and tool into a DI-free package #4820); no separate issue was created for these CI-only test fixes.
  • I updated existing tests that prove the affected behavior.
  • The behavior-change assessment above is complete; no behavior was removed and no default was flipped.
  • Checked gen-changesets rules: no changeset is needed for this tests-only PR.
  • No documentation update is needed for this tests-only PR.

@changeset-bot

changeset-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 783d0a7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T03:21:20.399752Z 783d0a7 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 13, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@783d0a7
npx https://pkg.pr.new/@moonshot-ai/kimi-code@783d0a7

commit: 783d0a7

@sailist
sailist merged commit 29bc56d into main Nov 13, 2026
17 checks passed
@sailist
sailist deleted the bug-362-11-12-task-reload-ci-flakes branch November 13, 2026 03:30
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 15, 2026
Port MoonshotAI#4901, MoonshotAI#4909 and MoonshotAI#4911: complete the task before asserting a
zero-timeout wait sees the completed snapshot, restore the instructions
reload spy after the failure assertion, poll the search index until it is
ready before asserting the page, and run remote-session git probes
through a host process that refuses gh.

Record MoonshotAI#4840 as equivalent (the refresh path already rebuilds from the
effective binding here) and pin it with a regression case, record MoonshotAI#4883
as ported with the compaction profile already present, and record MoonshotAI#4830
as blocked on the absent loop requester/request-attribution layering.
Clear the generated-bundle, release-sync and working-notes rows with
their applicable verdicts.
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.

2 participants