7.0 KiB
7.0 KiB
Tasks — add-drive-plugin-cache
Every checkbox MUST reflect work actually done in this change.
1. Spec authoring
- 1.1 Read
openspec/specs/drive/spec.mdand confirmDrivePlugin/DriveMiddlewareshape - 1.2 Read
openspec/specs/cache/spec.mdand confirmAbstractCache<T>contract - 1.3 Read
openspec/archive/2026-05-16-add-cache-storage-redis-backends/for the cache-family conventions - 1.4 Read
openspec/AGENTS.md§0c, §2b, §6a, §7, §11, §13 - 1.5 Read
packages/drive/drive/src/types/drive.types.tsto confirmMiddlewareContextandMiddlewareNext<T>signatures - 1.6 Draft
proposal.md,design.md,tasks.md,specs/drive-plugin-cache/spec.md - 1.7 Every requirement in the spec delta carries a
**Verified by:**line naming concrete plannedit(...)titles - 1.8 Build the numbered Requirement/Scenario implementation checklist (§0c step 6) — 12 requirements, 29 scenarios
2. Scaffolding
- 2.1 Create
packages/drive/drive-plugin-cache/mirroringpackages/drive/drive-uri/conventions - 2.2 Write
package.jsonv0.0.0,"sideEffects": false, subpath exports for every feature module - 2.3 Wire deps:
@suaveplan/error,@suaveplan/drive,@suaveplan/cache,@suaveplan/types,@opentelemetry/api,tslib(allworkspace:^/catalog:) - 2.4 Wire devDeps:
@suaveplan/testing,@suaveplan/storage,@suaveplan/storage-file,@suaveplan/cache-storage,@vitest/coverage-istanbul,fast-check,typescript,vite,vite-plugin-dts,vitest - 2.5 Write
tsconfig.json,tsconfig.lib.json,vite.config.ts,vitest.config.ts(viacreateTestConfig) - 2.6 Write
tests/setup/polyfills.tsandREADME.mdskeleton
3. Implementation
- 3.1
src/error-codes/error-codes.ts—defineCodes("DRIVE_CACHE", ["INVALID_OPTIONS", "CACHE_TOO_LARGE", "INSTALL_FAILED"] as const),DriveCacheErrorclass,path?/namespace?discriminants - 3.2
src/types/options.types.ts—DriveCacheOptions,DriveCacheHandle,DriveCacheStatsinterfaces (no inline shapes per §11) - 3.3
src/handle/handle.ts—createHandle(cache, stats), exposesgetStats()/invalidate(path)/clear()/cache - 3.4
src/middleware/middleware.ts—read(ctx, next)with hit short-circuit, miss + populate,shouldCachegate - 3.5
src/middleware/middleware.invalidation.ts—write(ctx, next)anddelete(ctx, next)post-success invalidation,invalidateOnWrite/invalidateOnDeletetoggles - 3.6
src/middleware/middleware.signal.ts—AbortSignalshort-circuit helper used by all three intercepts - 3.7
src/otel/otel.ts— meter + tracer wiring, counterhits/misses/populations/invalidations/errors, histogramentry_bytes, span attribute helpers - 3.8
src/plugin/plugin.ts—driveCachePlugin(options): DrivePlugin<DriveCacheHandle>factory with construction-timeINVALID_OPTIONScheck - 3.9
src/index.ts— explicit named re-exports per §6a
4. Tests (every it(...) carries { timeout: 5000 }, 30000 for async integration)
- 4.1
src/error-codes/error-codes.test.ts— every code reachable from a real call site, discriminants populated - 4.2
src/plugin/plugin.test.ts— install registers middleware, install returns handle with same cache reference, INVALID_OPTIONS on missing cache, INVALID_OPTIONS on malformed cache - 4.3
src/middleware/middleware.test.ts— hit short-circuits, custom namespace used in key, miss populates, shouldCache gate, default 16 MiB ceiling, stat/list passthrough, cache.get rejection falls through, cache.set rejection swallowed - 4.4
src/middleware/middleware.invalidation.test.ts— write invalidates post-success, write failure does not invalidate, invalidateOnWrite:false skips, delete symmetric, delete failure does not invalidate, cache.delete rejection swallowed - 4.5
src/middleware/middleware.signal.test.ts— pre-aborted signal skips cache work, live signal forwarded to cache.get/set/delete - 4.6
src/handle/handle.test.ts— getStats monotonic, invalidate deletes one entry, clear clears cache - 4.7
src/otel/otel.test.ts— hit/miss/populate/invalidate/error counters increment, entry_bytes histogram observed on populations, errors_total carriesoplabel, span outcome attribute populated - 4.8
tests/integration/with-memory-cache.test.ts— realDrive+ realMemoryCache: write bytes, read twice, asserthits === 1on second read - 4.9
tests/integration/with-storage-cache.test.ts— realDrive+ realStorageCacheover realstorage-fileFileStorage: cache survives plugin reinstall (disk-backed) - 4.10
tests/integration/with-namespaced-caches.test.ts— two plugin instances with distinct namespaces share oneAbstractCachereference but do not see each other's entries - 4.11 No imports from
vitestorbun:testin test files — all via@suaveplan/testing/runner(rule 11) - 4.12 No
vi.mock/jest.mock; all dependencies are real per CLAUDE.md rule 2
5. Documentation
- 5.1 Sibling
.mdfor every implementation.ts(≥200 words, basic + advanced examples, full API reference) - 5.2
README.mdlinks every module under## Modules - 5.3 README documents the five composition recipes from
design.md(memory / OPFS / file / Redis /wrap()stale-while-revalidate) - 5.4 README documents the
shouldCache/maxEntryBytesdefaults and the rationale (16 MiB matchesdrive-mesh-protocol's frame ceiling)
6. Gates
- 6.1
bun run check - 6.2
bunx turbo lint typecheck test --filter=@suaveplan/drive-plugin-cache - 6.3
bunx turbo test:coverage --filter=@suaveplan/drive-plugin-cache— 100/100/100/100 Istanbul - 6.4
bunx turbo build --filter=@suaveplan/drive-plugin-cache - 6.5
bun scripts/lint/check-test-runner-imports.ts(rule 11) - 6.6 Tier-purity grep —
grep -rnE "from ['\"](node:|bun:)" packages/drive/drive-plugin-cache/src/returns empty - 6.7 Banned-pattern scan returns empty (§2)
- 6.8 Missing-
.mdscan returns empty (§4) - 6.9 Non-root
export *scan returns empty (§6a) - 6.10 Bare-version scan returns empty (§1)
- 6.11 Folder-naming scan (§10) — children under
plugins/,middleware/,handle/do not include the parent's singular/plural form as a suffix - 6.12 Spec-reconciliation gate — every
### Requirementis implemented; every**Verified by:**test name exists verbatim (§13 step 0)
7. Manifest & archival
- 7.1 Add package to
MANIFEST.mdviabun scripts/folder-reorg/generate-manifest.ts - 7.2 Update
STATUS.md(genesis-original — add to "Completed" once shipped) - 7.3 Update
SUMMARY.mdwith the one-paragraph description - 7.4
bunx markdownlint-cli2 --fixon touched docs - 7.5 Fold
specs/drive-plugin-cache/spec.mdintoopenspec/specs/drive-plugin-cache/spec.md - 7.6 Move
openspec/changes/add-drive-plugin-cache/→openspec/archive/<yyyy-mm-dd>-add-drive-plugin-cache/