CRITICAL RULE: After finishing any work (feature implementation, refactoring, bugfix, or migration), the agent MUST ALWAYS spawn a subagent to verify and review the work before concluding the task.
- Never finalize work without subagent review: Do not present a task as complete until a verification subagent has executed and confirmed correctness.
- Subagent Verification Responsibilities:
- Automated Validation: Execute
bun run check:shaders,bun run typecheck,bun run build, andbun run test:mock. - Contract & Regression Check: Inspect modified and newly created files to verify public contracts, type symmetry, error handling, and edge cases.
- Cross-Platform & Portability Audit: Ensure library code contains no unguarded DOM references (
document,window) to maintain 100% Web Worker, Node.js, and SSR safety. - Clean Diff Audit: Ensure no temporary test files, debug console logs, or dead scripts remain.
- Automated Validation: Execute
- Resolve Findings Before Sign-off: Any actionable defects or regressions flagged by the verification subagent must be resolved before presenting the final response to the user.
Skip the verification subagent for trivial, low-risk changes: copy/text edits, dropdown option lists, single-line config or constant tweaks, and other edits with no logic, contract, or control-flow impact. For these, a local typecheck + build pass by the agent itself is sufficient sign-off.
- Turborepo Workspace Isolation:
packages/webgpu-search: The core, zero-dependency library published to npm. Must remain portable across browser main thread, Web Workers, Node.js, and SSR.apps/benchmark: Interactive evaluation dashboard. Consumeswebgpu-searchvia workspace linking (workspace:*) and Vite dev source aliasing.
- Shader Integrity:
- Every WGSL compute shader edit must be validated offline via
bun run check:shaders(vgpu check). - Keep
.wgslshaders and their inlined export strings synchronized.
- Every WGSL compute shader edit must be validated offline via
- Device & Context Safety:
- Always route WebGPU device acquisition through
WebGPUContextManageror accept injected custom devices. Never callnavigator.gpu.requestDevice()directly inside repeated index allocations to avoid browser context exhaustion.
- Always route WebGPU device acquisition through
- Scoring Symmetry:
- Both WebGPU compute passes and CPU fallbacks (
uFuzzy/ native) must conform to the unifiedSearchResultIteminterface with descending normalized integer scores.
- Both WebGPU compute passes and CPU fallbacks (