Skip to content

fix(cli): share telemetry shutdown deadline - #2333

Open
ousamabenyounes wants to merge 1 commit into
MoonshotAI:mainfrom
ousamabenyounes:fix/issue-2248
Open

fix(cli): share telemetry shutdown deadline#2333
ousamabenyounes wants to merge 1 commit into
MoonshotAI:mainfrom
ousamabenyounes:fix/issue-2248

Conversation

@ousamabenyounes

Copy link
Copy Markdown

Related Issue

Resolve #2248

Problem

CLI entrypoints gave each telemetry owner a fresh shutdown timeout. In kimi web,
the kap-server engine pipeline and the host pipeline could therefore extend total
shutdown latency beyond the configured budget. Cleanup rejection handling also
differed between print and web paths.

What changed

  • Added a shared CLI shutdown-deadline policy that computes one absolute
    deadline, passes only the remaining budget to each pipeline, reports failures,
    and continues even if a pipeline or its reporter fails.
  • Applied the policy to v1 print, v2 print, and web shutdown.
  • Allowed the web host to pass its absolute deadline through
    RunningServer.close() to kap-server's owned engine telemetry.
  • Added lifecycle coverage for multiple pipelines, expired budgets, rejection,
    reporter failure, preserved exit results, and the real kap-server close path.

Test verification (RED → GREEN)

RED on the upstream base:

telemetry shutdown deadline: 3 failed
Error: Cannot find module '#/cli/telemetry-shutdown'

runPrompt:
expected stderr to contain
"Warning: telemetry shutdown failed: telemetry unavailable"

kap-server close with forwarding removed:
expected 3005 to be less than 1500

GREEN with this change:

CLI lifecycle: 118 passed
kap-server telemetry/boot: 23 passed
combined coverage run: 141 passed
changed executable production lines: 25/25 covered (100%)
tsgo: apps/kimi-code and packages/kap-server passed
build: passed
bundle smoke: passed

Full local suite validation used the same five Vitest shards as CI. Shards 3,
4, and 5 passed completely. Shards 1 and 2 reproduced the environment-only
baseline failures from the missing system zip executable; one tree-sitter
budget test that exceeded 50 ms under contention passed in isolation in 16 ms.
The targeted suites, exact changed-package typechecks, build, smoke, sherif, and
pi-tui tests are green. The global type-aware lint process was killed by local
memory pressure, matching the upstream baseline run.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill; added a patch changeset for the CLI package.
  • Ran gen-docs skill; no documentation update is needed for this internal shutdown policy.

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1b99613

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

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

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.

fix(cli): share one deadline across telemetry shutdown pipelines

1 participant