Repository navigation
feat(kimi-code): add Hook runtime observations - #1988
Conversation
hidb4ai
left a comment
There was a problem hiding this comment.
One reproducible concurrency issue in runtime observation retention needs fixing.
| let queue = (async () => { | ||
| await mkdir(directory(), { recursive: true }) | ||
| const existing = await names() | ||
| if (existing.length >= LIMIT) { |
There was a problem hiding this comment.
[P2] Allow observation storage to recover after concurrent writes exceed the limit
With 63 valid completed records, two concurrent attempts can both observe a count below LIMIT and publish their own files, leaving 65 records. I reproduced this twice by starting two observations concurrently and awaiting both completions. Subsequent queries throw runtime_capacity_exceeded, and every later attempt fails at names() before reaching the retention branch, so even fully completed history cannot be pruned and observation storage remains unusable until files are manually deleted. Please make capacity admission safe under concurrency or provide bounded recovery that can prune completed records after this overflow while preserving unfinished attempts and unowned files.
Which issue or RFC does this PR close?
Follow-up to #1974 and the Kimi integration tracked in #1963.
Rationale for this change
Kimi's installation/connectivity doctor cannot explain what happened during an actual prompt Hook. Record local stage outcomes so users can distinguish empty recall, rejected or unconfirmed capture, and historical-context output.
What changes are included in this PR?
doctor kimi-code --runtime [--cwd ...] [--session-id ...]and an offline, read-only status script. Exact sessions and latest workspace history are distinct; missing, mismatched, stale and unfinished observations remain explicit.Are there any user-facing changes?
Run
powercontext doctor kimi-code --runtime --jsonfrom the affected workspace after updating the installed plugin. Add--session-idto inspect one session. Optional missing/stale history does not fail healthy connectivity checks; invalid or unavailable observation storage reports a separate failure. Source acceptance does not establish Memory generation, and locally emitted context does not establish model receipt.How was this change tested?
Node Hook and observation tests: 17 passed on Windows and Linux, covering private/read-only queries, independent stage outcomes, storage failure, late concurrent completion, recovery from concurrent retention overflow, and invalid/capacity states. The overflow regression passed 20 consecutive Windows runs; unfinished observations and unowned files remain intact.
CLI tests: 15 passed on Windows and Linux.
Actual Kimi 2.1.1 acceptance with Node 24.21.0 passed on Windows (Python 3.11.15, three consecutive full runs) and isolated Linux (Python 3.12.15). The real CLI loaded the managed plugin and queried an exact native session against a real Server/SQLite, using controlled inference at both model boundaries.
Full Linux
ty check, scoped Windowsty check, Ruff andprek run -apassed. The Windows pre-commit type hook was replaced by the full Linux check.git diff --cached --checkpassed.Desktop contract generation/check and
pnpm --dir desktop lintpassed. The Worker prompt/usage test file passed all 10 tests on Windows and isolated Linux (Python 3.13.12); the GitHub Actions Python 3.13 unit job also passed after the baseline/hash update.CLI message assertions normalize ANSI styling while retaining the option-validation check. The dedicated Kimi acceptance workflow validates the real host on Ubuntu and Windows.
AI usage statement
OpenAI Codex (GPT-6) assisted implementation, documentation and validation.