fix(cli): keep instance context during config validation - #14084
Open
Kush2806 wants to merge 1 commit into
Open
Conversation
Config validation runs from file tools as a plain async helper awaited from an Effect fiber. The ambient instance context is only readable synchronously, so the awaits inside check() dropped it and moved on; markdown() then threw "No context found for instance", which was misreported as a frontmatter parse error on every .kilo/command and .kilo/agent markdown edit. Capture the instance once at entry and thread it through. Fixes Kilo-Org#14040.
Author
|
Hi — small heads-up: the Could a maintainer approve the workflow runs and re-run the review? Happy to address anything it flags once it executes. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14040
What
Editing any
.kilo/command,.kilo/agent, or.kilo/modemarkdown file through the agent appended a bogus validation error to the tool result:It was content-independent (fired even without frontmatter) and only for project markdown.
Root cause
ConfigValidation.checkis a plain async helper invoked from the file tools viaEffect.promise(() => ConfigValidation.check(filepath)). Tools resolve the project instance from the Effect fiber (InstanceState.context->InstanceRef), not from async-local storage.capture()can only read the fiber reference synchronously, so the firstawaitinsidecheck(await existing()) dropped it.markdown()then calledInstance.currentunguarded, which threwLocalContext.NotFound("instance"), and the surroundingcatchmislabelled it as a frontmatter parse error.Change
Capture the instance synchronously at the top of
check()and thread it throughisConfigandmarkdown. Project markdown is skipped when there is genuinely no instance (it cannot be scoped); global/trusted config still validates. The untrusted-markdownfileScopeused for source-read confinement is computed identically, so the #12168 guard is unchanged.Testing evidence
test/kilocode/config-validation.test.tsdrives the fiber-only context (the production tool path) and asserts the file validates. It reproduced the exact reported string before the fix and passes after.bun test ./test/kilocode/config-validation.test.ts-> 11 passbun test ./test/tool/write.test.ts ./test/tool/edit.test.ts ./test/tool/apply_patch.test.ts-> 71 passbun test ./test/config/markdown.test.ts ./test/kilocode/config-validation.test.ts-> 48 passtest/config/config.test.tsexfiltration case passes;test/kilocode/config/variable.test.ts+config/markdown.test.ts-> 15 passbun run typecheck(packages/opencode),bun run lint(0 errors), prettier, and the annotations checker are cleanChangeset included (
patch).Notes
Reproduced on macOS as well as the reported Windows environment, so this is not platform-specific.