[OPTIMIZATION] Utils - Algorithmic & Data Structure Issues - src/lib/utils.ts #62
Labels
No labels
blocked:depends-p1
blocked:gate-research
blocked:lint-failed
blocked:needs-decision
blocked:needs-human
blocked:verify-failed
bug
data-loss
documentation
enhancement
feature-request
in-progress
needs-decompose
needs-triage
pwa
quickfix
security
security/high
security/medium
test
test-coverage
triage-approved
vault
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/kimi_agent_kin_app_sync#62
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Critical Issues (1)
find()inside loops - O(n²)Map<string, Observation>for O(1) keyword lookupsHigh Issues (2)
Multiple
people.find(p => p.id === id)in hot paths (lines 270, 272, 277, 619, 622, 628)peopleMap(already created at line 401)Object.keys().length+ spread intoSetcreates intermediate arraysMap.sizeMedium Issues (2)
getInteractionMetanever used anywhere - remove entirelyexportToJson,importFromJson,parseCsv,generateId,extractKeywords,generateObservationSuggestions,getClosenessLabelLow Issues (1)
generateId()usesMath.random()- not cryptographically securecrypto.randomUUID()⏸ Needs Decision
What needs to be decided?
blocked:needs-decisionlabel to route back to triage.Blocking factors:
Scope: small Risk: low Spec: partial Type: enhancement
Summary: Optimize computeDashboardObservations with Map-based lookups to eliminate O(n²) patterns, remove dead code (getInteractionMeta), apply minor cleanup to utils.ts, and fix generateId() to use crypto.randomUUID().
Suggestion: Replace obsArr.find() inside forEach loops with per-person Map<string, DashboardObservation> for O(1) keyword lookups; use the already-created peopleMap where applicable; remove getInteractionMeta + its tests; move truly test-only functions (exportToJson, importFromJson, parseCsv, generateId) to test file or mark internal; change generateId to crypto.randomUUID(). Keep extractKeywords and getClosenessLabel as they are used in production code (metrics-engine.ts, PersonDetail.tsx).
Rationale: Scope is small — all changes confined to src/lib/utils.ts + test updates. Risk is low — mechanical refactoring (Map for O(1) lookup), dead code removal, and a stdlib swap (crypto.randomUUID()) with existing test coverage. The issue has minor inaccuracies (line numbers stale, mislabels extractKeywords/getClosenessLabel/generateObservationSuggestions as test-only when they're production code), but the core optimization and cleanup recommendations are sound. No AGENTS.md or milestones exist, so it's partial alignment — standard maintenance that doesn't contradict project direction.
To unblock: Remove the
blocked:needs-decisionlabel. The triage will apply the appropriate outcome based on your choice above.