Skip to content

refactor: centralize NUL-delimited composite keys - #13532

Merged
marius-kilocode merged 1 commit into
mainfrom
refactor-composite-ids
Aug 28, 2026
Merged

refactor: centralize NUL-delimited composite keys#13532
marius-kilocode merged 1 commit into
mainfrom
refactor-composite-ids

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

NUL-delimited cache and routing keys are built repeatedly across the CLI and VS Code extension. Replacing those expressions independently can change empty fields, nullish coercion, or project/session prefix boundaries and make existing entries unreachable.

Why This Change Was Made

Add a dependency-free zeroID(...parts) helper in core's Kilo-owned source tree, using its existing subpath export and existing consumer dependencies. Preserve domain helpers and their normalization rules while sharing the delimiter construction for local diff caches, project routing, diff state, explicit-abort scopes, and indexing worker/warning identities.

The helper accepts only strings, numbers, and booleans. Callers must keep nullish fallback or string conversion explicit because Array.join and template literals do not coerce null and undefined identically. Short-key fast paths avoid the measured cost of a blanket join replacement.

Add one code-preference bullet for Promise.withResolvers<T>() where the runtime and types support it, while retaining callback/event executors and discouraging async executors and redundant Promise wrapping.

User Impact

No intended behavior or key-format change. Empty fields, numeric/boolean values, Unicode, embedded delimiters, and namespace boundaries retain their existing bytes. Git output parsing, binary formats, persistent hash inputs, and non-NUL key formats are unchanged. No runtime requirement or package dependency is added.

Evidence

  • Root lint and typecheck, extension compile and Knip, and applicable annotation/Markdown/ownership guards passed. Root lint reports existing warnings, with no errors.
  • All 4,361 extension unit tests passed on a full rerun. The initial concurrent run had a PR-render timeout and a shell-environment assertion failure; both passed separately and in the full rerun without compiler load.
  • The 17 focused core/CLI tests passed. Coverage includes byte equivalence and the helper's type contract, worker pooling by directory and root, empty versus named diff bases, project-prefix pruning, and abort-scope isolation.
  • Nine measured samples after warm-up compared the actual helper with legacy expressions, including cache lookups. Node 25.2.1 pair lookups were 95.4 -> 95.4 ns/op; ten-part metadata lookups were 193.7 -> 195.3 ns/op. Chromium 148 pair lookups were 59.5 -> 59.5 ns/op. V8 heap sampling showed no allocation increase for the measured shapes.
  • Bun 1.4 canary pair lookups were 49.8 -> 49.7 ns/op. A separate three-part Bun probe was slower (67.7 -> 79.6 ns/op), so no three-part Bun callers were migrated. These are microbenchmarks, not claims of end-to-end UI speedups.
  • In an isolated VS Code instance, a disposable project-qualified diff fixture rendered and expanded correctly. No prompts were submitted to existing sessions, and the isolated instance was cleaned up.

Remaining candidates such as shared ACP/snapshot keys and three-part Bun callers are outside this focused refactor.

@kilo-code-bot

kilo-code-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (15 files)
  • AGENTS.md
  • packages/core/src/kilocode/zero-id.ts
  • packages/core/test/kilocode/zero-id.test.ts
  • packages/kilo-vscode/src/agent-manager/local-diff-cache.ts
  • packages/kilo-vscode/src/agent-manager/project/route.ts
  • packages/kilo-vscode/src/services/cli-backend/explicit-abort.ts
  • packages/kilo-vscode/tests/unit/agent-manager-worktree-diffs.test.ts
  • packages/kilo-vscode/tests/unit/agent-project-route.test.ts
  • packages/kilo-vscode/tests/unit/explicit-abort.test.ts
  • packages/kilo-vscode/tests/unit/local-diff.test.ts
  • packages/kilo-vscode/webview-ui/agent-manager/worktree-diffs.ts
  • packages/opencode/src/kilocode/indexing-warning.ts
  • packages/opencode/src/kilocode/indexing-worker-client.ts
  • packages/opencode/test/kilocode/indexing-warning.test.ts
  • packages/opencode/test/kilocode/indexing-worker.test.ts

Reviewed by grok-4.6 · Input: 496.2K · Output: 14.2K · Cached: 91K

Review guidance: REVIEW.md from base branch main

Comment thread packages/kilo-vscode/webview-ui/agent-manager/worktree-diffs.ts
@marius-kilocode
marius-kilocode merged commit 788ed40 into main Aug 28, 2026
34 checks passed
@marius-kilocode
marius-kilocode deleted the refactor-composite-ids branch August 28, 2026 08:13
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.

2 participants