7.3 KiB
7.3 KiB
Tasks: complete-drive
All tasks land in
packages/drive/drive/. Follow CLAUDE.md### Qualityandopenspec/AGENTS.md§13 pre-ship gates. Coverage gate is 100/100/100/100.
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each) - 0.2 If any worktrees exist under
.claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - 0.3 Confirm the package set in
MANIFEST.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Audit & spec lock-in
- 1.1 Snapshot current public surface —
bunx turbo build --filter=@suaveplan/drivethen grepdist/index.d.tsfor the exported symbol list; paste into design.md## Today's surface. - 1.2 Confirm sibling-change scope boundaries with
complete-drive-uri(URI/locator owner) andcomplete-types-drive-promotion(cross-package types owner) — no duplicate requirements.
2. Error-code registry
- 2.1 Extend
src/error-codes.tsDRIVE_CODESwithCOPY_FAILED,MOVE_FAILED,WATCH_FAILED,QUOTA_EXCEEDED,OPERATION_ABORTED,STORAGE_READONLY(keepsdefineCodes("DRIVE", [...])frozen). - 2.2 Update
src/error-codes.mdand the conformance testsrc/error-codes.spec-conformance.test.tsto assert the wider set.
3. Op surface widening
- 3.1 Add
DeleteOptions,StatOptions,ReadStreamOptions,WriteStreamOptionstosrc/types/drive.types.ts; export them fromsrc/index.ts. - 3.2 Add overload signatures on
Drive.delete/Drive.stat/Drive.createReadStream/Drive.createWriteStreamaccepting the options bundle (positionalsignal?kept as a second overload for one minor cycle). - 3.3 Implement range-read in
src/file-operations/streams.tsusingstorage.createReadStream({ offset, length })whencapabilities.rangeReads === true, else slice in the default fallback.
4. Copy / move
- 4.1 New module
src/file-operations/copy.ts+.md: middleware-wrapped copy; usesstorage.copy?when available, else read-then-write; emitsdrive:copy:before/drive:copy:after. Errors surface asDriveError(DRIVE.COPY_FAILED, { cause }). - 4.2 New module
src/file-operations/move.ts+.md: same shape; usesstorage.move?(rename), else copy + delete with rollback on failure; emitsdrive:move:before/drive:move:after. Errors surface asDriveError(DRIVE.MOVE_FAILED, { cause }). - 4.3 Wire
Drive.copy(src, dst, opts?)andDrive.move(src, dst, opts?)throughPluginRegistry.runMiddleware. Addcopy?/move?slots toDriveMiddleware.
5. List typing
- 5.1 Replace
Promise<unknown>return onDrive.listwithPromise<DriveListPage>whereDriveListPage = { entries: DriveEntry[]; cursor?: string }. - 5.2 Add
Drive.scan(prefix?, opts?): AsyncIterable<DriveEntry>that auto-paginates and respectssignal.
6. Watch
- 6.1 New module
src/file-operations/watch.ts+.md:Drive.watch(path, opts?)returns{ events: AsyncIterable<DriveChangeEvent>; unsubscribe(): void }. Backed by the injectedEventBusLike. Falls back to a per-drive in-memory bus when none injected (drive-local fan-out only). - 6.2 Emitters on
write/delete/copy/movepublishDriveChangeEventto bus topicdrive:change:<path>.
7. Plugin lifecycle
- 7.1 Extend
PluginRegistrywithunload(name),list(),find(name)and an ordered handle map keyed byplugin.name. - 7.2 Expose
Drive.unloadPlugin(name),Drive.listPlugins(),Drive.findPlugin(name)on the class. Unload is idempotent; unknown name throwsDriveError(DRIVE.PLUGIN_FAILED, ...). - 7.3 Document install/unload ordering invariants in
src/plugins/registry.md.
8. Quota / usage
- 8.1 New module
src/observability/usage.ts+.md:Drive.usage(): Promise<DriveUsage>aggregating per-storage byte counts viastorage.usage?()when available, else by summingstat().sizeoverscan(). Cached foroptions.usageCacheMs(default 5s). - 8.2 New module
src/observability/quota.ts+.md:Drive.setQuota({ soft?, hard? }). On everywrite/copy/move, post-opusage()check; emitdrive:quota:warningon soft trip and throwDriveError(DRIVE.QUOTA_EXCEEDED)on hard.
9. Sharing-integration hook
- 9.1 In
src/types/drive.types.tsaddDriveShareLikeinterface (share(path, audience): Promise<ShareHandle>,revoke(handle): Promise<void>,listShares(path?): Promise<ShareHandle[]>). Drive owns the interface; concrete impl lives indrive-sharing. - 9.2 Add
options.shareHook?: DriveShareLiketoDriveOptions; exposeDrive.share/Drive.revoke/Drive.listSharesthat delegate to the hook or throwDriveError(DRIVE.PLUGIN_FAILED, "no share hook").
10. Hydration progress events
- 10.1 In
src/drive/hydrate-from.ts, alongside the existingonProgresscallback, publishdrive:hydrate:progressevents to the EventBus when injected. Adddrive:hydrate:completeanddrive:hydrate:aborted. - 10.2 Update
hydrate-from.mdexamples + add a watch-the-bus advanced example.
11. OTEL spans
- 11.1 Wrap each public op (
read,write,delete,stat,list,scan,copy,move,watch,hydrateFrom,usage) in a span nameddrive.<op>with attributesdrive.path,drive.storage.id,drive.byteswhere applicable. Use@opentelemetry/apidirectly; no-op when no exporter registered.
12. Tests
- 12.1 Per-feature unit tests (
.test.ts) for every new module. - 12.2 Extend
drive.spec-conformance.test.tswith scenarios for every new requirement (one scenario per**Verified by:**line in the spec delta). - 12.3 fast-check property tests:
copy(a,b);read(b) === read(a),moveinvariant(after) !exists(a) && exists(b),usage()monotonicity across N writes,watchdelivers every change. - 12.4 Verify
bunx turbo test:coverage --filter=@suaveplan/drivereports 100/100/100/100 (istanbul). Noc8 ignore.
13. Docs
- 13.1 Sibling
.mdfor every new.ts, ≥200 words, basic + advanced examples (CLAUDE.md### Documentation). - 13.2 Update
packages/drive/drive/README.mdModules section with every new feature. - 13.3 Refresh
src/drive/drive.mdto list the widened surface and the new option fields.
14. Pre-ship gate
- 14.1
bunx turbo lint typecheck test --filter=@suaveplan/drivegreen. - 14.2
bunx turbo test:coverage --filter=@suaveplan/drive100%. - 14.3
bunx turbo build --filter=@suaveplan/drivegreen. - 14.4 Banned-pattern + barrel-shape + test-runner-import scans clean (AGENTS §13 steps 4, 4a, 4b).
- 14.5 Dependent sweep:
bunx turbo test --filter=...@suaveplan/drivegreen. - 14.6
bun scripts/folder-reorg/generate-manifest.ts+bun scripts/generate-missing.ts; refreshSTATUS.md/SUMMARY.md;bunx markdownlint-cli2 --fix.
15. Archive
- 15.1 Fold
specs/drive/spec.mdintoopenspec/specs/drive/spec.md. - 15.2 Move
openspec/changes/complete-drive/→openspec/archive/<yyyy-mm-dd>-complete-drive/.