feat(kap-server): enable multi-server shared home by default#1826
feat(kap-server): enable multi-server shared home by default#1826sailist wants to merge 1 commit into
Conversation
- always register kap-server instances under server/instances and drop the legacy single-instance lock (acquireLock/getLiveLock/ServerLockedError) - remove the multi_server experimental flag and its KIMI_CODE_EXPERIMENTAL_MULTI_SERVER env var from agent-core-v2 - discover running servers via the instance registry in server ps/kill/rotate-token, kimi web daemon reuse, and the desktop app - remove the pending minidb changesets
🦋 Changeset detectedLatest commit: 04762f1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04762f1fb4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const deadline = Date.now() + SPAWN_TIMEOUT_MS; | ||
| while (Date.now() < deadline) { | ||
| const live = getLiveLock(); | ||
| const live = await getLiveServerInstance(); |
There was a problem hiding this comment.
Probe every registered daemon before timing out
When an older registry entry has a live pid but is not answering /healthz, this loop keeps selecting only that oldest entry because getLiveServerInstance() returns live[0]. After spawning a replacement, the new healthy daemon has a later startedAt, so kimi web/server run will ignore it until the 20s timeout and leave the user with a failed startup despite a usable server being registered. In this fallback path, iterate listLiveServerInstances() and return the first healthy origin instead of polling only the oldest entry.
Useful? React with 👍 / 👎.
| @@ -1,6 +0,0 @@ | |||
| --- | |||
| "@moonshot-ai/minidb": minor | |||
There was a problem hiding this comment.
Restore the dropped minidb changesets
This commit deletes the pending minidb changesets while only adding the multi-server changeset, and there is no release-version update in the diff that would have consumed them. On the next Changesets release, the minidb durability/perf/reader-catchup/review hardening changes will no longer bump @moonshot-ai/minidb or appear in the changelog, so these unrelated changeset files should be restored unless they were already released in this same commit.
Useful? React with 👍 / 👎.
Related Issue
No linked issue — the problem is explained below.
Problem
Multi-server shared-home support in kap-server shipped behind the experimental env var
KIMI_CODE_EXPERIMENTAL_MULTI_SERVER. With the flag off (the default), every server takes the single-instance home-dir lock, so a second server on the same home directory fails fast withServerLockedError; meanwhile CLI and desktop consumers (kimi webdaemon reuse,kimi server ps/kill) still only knew how to read that legacy lock file. The feature is ready to become the default, so the flag gate — and the legacy lock it was protecting — need to go away, and all server-discovery consumers must learn the instance registry.What changed
startServernow always registers itself under<home>/server/instances/; theKIMI_CODE_EXPERIMENTAL_MULTI_SERVERenv check is gone. The legacy single-instance lock (acquireLock/getLiveLock/ServerLockedErrorand thelockPathoption) is removed from the package surface; port-conflict handling stays theport + 1walk, which doubles as the multi-instance coexistence mechanism. AninstancesDiroption replaceslockPathfor test isolation.multi_serverexperimental flag domain is deleted (definition, barrel contribution, domain-layer map entry, docs example now points at another flag).kimi webdaemon reuse andkimi server ps/kill/rotate-tokendiscover running servers through the instance registry (longest-running live instance), matching the server's new registration-only behavior.ensure-serverreads<home>/server/instances/*.json(live pid, longest-running) instead of the lock file.kimi-inspect's dev discovery keeps reading the legacy lock as a fallback for pre-registry builds only.dev:kap-server:multi(rootdev:v2) no longer needs the env var; related comments/docs updated.Checklist
servercommand and boot/port-retry suites — 649 kap-server tests and 477 CLI tests pass locally.)gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update. (The env var was never documented in user docs; no user-facing doc change needed.)