Skip to content

refactor: reuse kernel uniqueStrings instead of local copies - #1892

Merged
thymikee merged 1 commit into
mainfrom
claude/infallible-jones-b291ff
Aug 20, 2026
Merged

refactor: reuse kernel uniqueStrings instead of local copies#1892
thymikee merged 1 commit into
mainfrom
claude/infallible-jones-b291ff

Conversation

@thymikee

Copy link
Copy Markdown
Member

What

Replaces three hand-rolled local uniqueStrings helpers with imports of the canonical @agent-device/kernel/collections export, per the AGENTS.md reuse rule:

  • src/platforms/apple/core/perf-frame.ts — identical semantics, direct swap.
  • src/platforms/web/agent-browser-lifecycle.ts — the local copy also filtered empty strings; that filter is now composed at the one call site that receives caller input (openWebSessionNames). The other call site passes path.join results, which are never empty. The [...] spread is gone because the kernel helper accepts readonly string[].
  • packages/selectors/src/internal/build.ts — identical semantics, direct swap.

All three files' packages already depend on @agent-device/kernel and sibling modules import the same subpath.

Why no gate caught this drift (evaluated as part of this task)

  • fallow duplication: fallow audit does include duplication, but the repo floors are minTokens: 50 / minLines: 5 and these helpers are ~2 lines / ~15 tokens. Empirically (scratch run), mild-mode clone detection does group all three bodies at --min-tokens 5 --min-lines 1, but floors that low are unusable repo-wide (the 3-file toy already reports 66.7% duplication). The audit gate is also changed-files-only, so pre-existing drift is invisible until touched. Structural gap, not a config bug.
  • oxlint: no-restricted-syntax and id-denylist are not implemented in oxlint 1.69 (checked the configuration schema), so a declaration-name ban is not expressible in the current lint config. oxlint 1.69 does support experimental custom jsPlugins, which could express "no local uniqueStrings declaration outside packages/kernel" in ~30 lines riding the existing pnpm lint gate.
  • fallow rule packs: only banned-call / banned-import kinds — cannot ban a local declaration.

Notably, the other two helpers protected by the same AGENTS.md rule (inferFillText, evaluateIsPredicate) have exactly one definition each — only the trivially re-typeable one drifted. Whether that recurrence justifies a jsPlugin lane (per the Catches/Evidence/Cost/Kill-criterion bar) is left as a follow-up decision, not bundled here.

Verification

pnpm check:affected --run — all runnable checks passed (lint, typecheck, affected units, changed-line coverage gate).

Three modules hand-rolled local uniqueStrings helpers despite the
AGENTS.md reuse rule and the canonical export in
@agent-device/kernel/collections:

- src/platforms/apple/core/perf-frame.ts (identical semantics)
- src/platforms/web/agent-browser-lifecycle.ts (empty-string filter now
  composed at the one call site that receives caller input; the home
  marker call site passes path.join results that are never empty)
- packages/selectors/src/internal/build.ts (identical semantics)

All three files' packages already depend on @agent-device/kernel and
siblings import the same subpath.
@github-actions

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 2.33 MB 2.33 MB -84 B
JS gzip 765.3 kB 765.3 kB -6 B
npm tarball 890.0 kB 890.0 kB -3 B
npm unpacked 3.10 MB 3.10 MB -84 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.8 ms 26.9 ms -0.9 ms
CLI --help 68.4 ms 68.4 ms +0.0 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/runtime.js -1 B -11 B
dist/src/sdk-batch-runner.js +9 B +7 B
dist/src/script-source-bundle.js -5 B -3 B
dist/src/agent-device-client.js +1 B -3 B
dist/src/internal/daemon.js -79 B -2 B

@thymikee

Copy link
Copy Markdown
Member Author

Reviewed exact head ac3e3953: the three replacements preserve first-occurrence order and deduplication semantics. The web path keeps the prior empty-name filtering at the only caller-input boundary, while the marker values are non-empty path.join results; the shared readonly helper does not mutate input. All reported checks are green and the size report is neutral-to-smaller. Code is ready; please align the PR body to Summary/Validation and note the 3-file, no-expansion scope before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Aug 20, 2026
@thymikee
thymikee merged commit d072819 into main Aug 20, 2026
28 checks passed
@thymikee
thymikee deleted the claude/infallible-jones-b291ff branch August 20, 2026 10:52
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-20 10:52 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant