Skip to content

refactor: enforce canonical uniqueStrings helper and remove local copies #1890

Description

@thymikee

Problem

uniqueStrings already has a canonical implementation in @agent-device/kernel/collections, but three production modules still carry equivalent local copies:

  • packages/selectors/src/internal/build.ts
  • src/platforms/apple/core/perf-frame.ts
  • src/platforms/web/agent-browser-lifecycle.ts

The duplication survived a prose-only AGENTS.md instruction, demonstrating that contributor guidance is the wrong enforcement layer. All three owners can consume the kernel helper; @agent-device/selectors already depends on @agent-device/kernel.

Outcome

Make the canonical helper the only production implementation and enforce that boundary mechanically, so another local copy cannot silently appear.

Acceptance criteria

  • Replace the three local implementations with @agent-device/kernel/collections imports without changing ordering or deduplication behavior.
  • Remove the local helper declarations and any tests made redundant by the shared implementation.
  • Add the smallest owning lint, fallow, or structural rule that rejects a production reimplementation of this exact helper pattern without reconstructing general semantic equivalence.
  • Plant a representative duplicate and observe the owning check fail before restoring the fixed tree.
  • Run pnpm check:affected --run and report the resulting gate plan.

This is a follow-up from PR #1888's agent-context review; it is intentionally separate because that PR changes contributor guidance and gate wiring, not unrelated production modules.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions