From e7eada4802ceebd86c83bcd6e3eca70152e7f331 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Thu, 11 Jun 2026 21:12:03 +0900 Subject: feat(lsp,cwd): LSP integration + per-conversation cwd; fix cache-warming cache bust MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LSP + per-conversation CWD feature: - new bundled `lsp` extension: hand-rolled JSON-RPC codec (framing/rpc), lazy one-server-per-(serverID,root), per-cwd config resolution, on-demand `lsp` tool - `conversation-store`: getCwd/setCwd (cwdKey); `session-orchestrator` defaults a turn's cwd from the store - `transport-http`: cwd + lsp status endpoints; wire types in transport-contract - host-bin: register lsp; config wiring Cache-warming fix (the warm read 0% on the first reheat after a message): - warm assembled tools under a different cwd than the real turn (a reheat sends no cwd, and the warm service had no store fallback). The skills filter rewrites the cwd-sensitive `load_skill` description, so the tools block โ€” the first bytes of the prompt-cache prefix โ€” diverged and the cache missed entirely. Warm now resolves cwd as opts.cwd ?? conversationStore.getCwd(), mirroring handleMessage. - capture warm sends as `provider.request` spans flagged `warm:true` (thread a child logger into providerOpts) so warm vs real bodies are diffable (obs ยง3.1). - kernel logger: span-close now merges child-bound attrs like span-open, so a `warm:true` query finds the closed span (with usage/status), not just the open. Tests: warm forwards a warm-flagged logger; warm falls back to stored cwd; logger open/close attr consistency. Full suite green (873). --- packages/kernel/src/logging/logger.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'packages/kernel/src/logging/logger.ts') diff --git a/packages/kernel/src/logging/logger.ts b/packages/kernel/src/logging/logger.ts index 70bc18c..4d2a609 100644 --- a/packages/kernel/src/logging/logger.ts +++ b/packages/kernel/src/logging/logger.ts @@ -194,6 +194,15 @@ export function createLogger( } const hasAttrs = Object.keys(spanAttrsMutable).length > 0; + // Merge child-bound default attrs (state.attrs) the SAME way span-open + // does (buildSpanOpen). Without this, an attribute bound via + // `logger.child({ attrs })` appears on the span-open record but NOT the + // span-close record โ€” so a query like `warm = true` can't find the + // closed span (with its usage/status). Open and close must agree. + const mergedCloseAttrs = mergeAttributes( + state.attrs, + hasAttrs ? spanAttrsMutable : undefined, + ); const hasLinks = links.length > 0; const base = { kind: "span-close" as const, @@ -209,7 +218,7 @@ export function createLogger( ...(ctx.conversationId !== undefined ? { conversationId: ctx.conversationId } : {}), ...(ctx.turnId !== undefined ? { turnId: ctx.turnId } : {}), ...(mergedParent !== undefined ? { parentSpanId: mergedParent } : {}), - ...(hasAttrs ? { attributes: { ...spanAttrsMutable } } : {}), + ...(mergedCloseAttrs !== undefined ? { attributes: mergedCloseAttrs } : {}), ...(hasLinks ? { links: [...links] } : {}), ...(outcome?.body !== undefined ? { body: outcome.body } : {}), }; -- cgit v1.2.3