Files
suaveplan/openspec/changes/_superseded-narrow-deferrals-2026-05-17/add-drive-uri-writes/tasks.md
2026-05-27 23:29:53 +01:00

61 lines
5.2 KiB
Markdown

# Tasks — `add-drive-uri-writes`
## 1. Registry
- [ ] 1.1 Add `TEMPLATE_READ_ONLY` to `DRIVE_URI_CODES` in `src/error-codes/error-codes.ts` (8 codes total).
- [ ] 1.2 Update `src/error-codes/error-codes.md` — describe `TEMPLATE_READ_ONLY` and the narrowed role of `WRITE_UNSUPPORTED`.
- [ ] 1.3 Extend `src/error-codes/error-codes.test.ts` to cover the new code and assert `WRITE_UNSUPPORTED` is still present.
## 2. Adapter — `DriveStorageLikeAdapter`
- [ ] 2.1 Widen `set(key, value, signal?)` and `delete(key, signal?)` to accept and forward `AbortSignal` to `Drive.write({ signal })` / `Drive.delete(path, signal)`.
- [ ] 2.2 Update `src/adapter/drive-storage-like.md` for the new signature and note the `TEMPLATE_READ_ONLY` rejection happens in the instrumented override, not here.
- [ ] 2.3 Extend `src/adapter/drive-storage-like.test.ts` — `set` propagates `signal`, `delete` propagates `signal`, pre-aborted signal short-circuits.
## 3. Instrumented adapter — `InstrumentedDriveAdapter`
- [ ] 3.1 Replace the unconditional `set` rejection with per-scheme dispatch: `drive`/`drive+mesh` → delegate to `super.set(key, value, signal)`; `drive+template` → throw `DRIVE_URI.TEMPLATE_READ_ONLY`.
- [ ] 3.2 Override `delete` symmetrically: `drive`/`drive+mesh` → delegate; `drive+template` → throw `TEMPLATE_READ_ONLY`.
- [ ] 3.3 On every successful `drive+mesh://` write, emit span event `drive_uri.mesh_write_local_only` with `{ scheme, path }`.
- [ ] 3.4 Pre-aborted `signal` on `set`/`delete` → throw `DRIVE_URI.ABORTED` before any work.
- [ ] 3.5 OTel counters: increment `drive_uri.writes_total{scheme, outcome}` and `drive_uri.deletes_total{scheme, outcome}` for every success and every rejection.
- [ ] 3.6 Update `src/plugins/drive/drive.streams.md` and `src/plugins/drive-template/drive-template.md`.
## 4. Test suite
- [ ] 4.1 `src/plugins/drive/drive.test.ts` — replace `"rejects writes with DRIVE_URI.WRITE_UNSUPPORTED"` with `"writes succeed and round-trip via Drive.write"` and `"writes propagate AbortSignal to Drive.write"`.
- [ ] 4.2 `src/plugins/drive/drive.test.ts` — add `"removes delegate to Drive.delete and return its boolean"` and `"removes propagate AbortSignal"`.
- [ ] 4.3 `src/plugins/drive-mesh/drive-mesh.test.ts` — add `"writes succeed without triggering mesh.advertise"` and `"writes emit drive_uri.mesh_write_local_only span event"`.
- [ ] 4.4 `src/plugins/drive-template/drive-template.test.ts` — add `"writes reject with DRIVE_URI.TEMPLATE_READ_ONLY"` and `"removes reject with DRIVE_URI.TEMPLATE_READ_ONLY"`.
- [ ] 4.5 `src/otel/otel.test.ts` — `"increments writes_total{outcome:success} on successful drive:// writes"`, `"increments writes_total{outcome:error,code:TEMPLATE_READ_ONLY} on template writes"`, `"increments deletes_total per scheme outcome"`.
- [ ] 4.6 `src/conformance/conformance.test.ts` — re-run `runUriPluginConformance` writes suite against all three plugins. Expected: `drive`/`drive+mesh` pass; `drive+template` continues to fail writes with the new code.
- [ ] 4.7 `tests/integration/drive-roundtrip-write.test.ts` — real local-storage Drive, `resolver.write` then `resolver.read`, assert equality.
- [ ] 4.8 `tests/integration/drive-mesh-roundtrip-write.test.ts` — mesh-configured Drive with a spy transport; assert no implicit `advertise` call; explicit `mesh.advertise(...)` after the write produces a verifiable outbound advertisement.
- [ ] 4.9 `tests/integration/template-write-rejection.test.ts` — wired template-backed Drive, `resolver.write("drive+template://...")` and `resolver.remove(...)` both reject with `TEMPLATE_READ_ONLY`.
## 5. Migration audit
- [ ] 5.1 `grep -rln "DRIVE_URI.WRITE_UNSUPPORTED" packages/ | grep -v "/dist/\|/coverage/\|/drive-uri/"` — every hit is reviewed; non-matching consumers re-routed onto `TEMPLATE_READ_ONLY` where appropriate.
- [ ] 5.2 Update `README.md` Features section to reflect writes/removes via `drive://` and `drive+mesh://`.
## 6. Pre-publish gate (§13)
- [ ] 6.1 Spec reconciliation — walk every `### Requirement` and `#### Scenario` in `specs/drive-uri/spec.md`; confirm the named test exists verbatim.
- [ ] 6.2 `bunx turbo lint typecheck test --filter=@suaveplan/drive-uri` — green.
- [ ] 6.3 `bunx turbo test:coverage --filter=@suaveplan/drive-uri` — 100/100/100/100, including the `TEMPLATE_READ_ONLY` rejection branches.
- [ ] 6.4 `bunx turbo build --filter=@suaveplan/drive-uri` — green.
- [ ] 6.5 Banned-pattern, barrel, test-runner-import, missing-`.md`, bare-version, and secrets scans — all clean.
- [ ] 6.6 Dependent sweep — `bunx turbo test --filter=...@suaveplan/drive-uri` green.
## 7. Root-doc refresh (§13b)
- [ ] 7.1 `bun scripts/folder-reorg/generate-manifest.ts` — refresh `MANIFEST.md`.
- [ ] 7.2 `bun scripts/generate-missing.ts` — refresh `MISSING.yml`.
- [ ] 7.3 Update `STATUS.md` and `SUMMARY.md` paragraphs for `drive-uri` to reflect writes-supported on the two mutable schemes.
- [ ] 7.4 `bunx markdownlint-cli2 --fix` over the touched docs.
## 8. Archive
- [ ] 8.1 Fold `specs/drive-uri/spec.md` (deltas) into `openspec/specs/drive-uri/spec.md`.
- [ ] 8.2 Move `openspec/changes/add-drive-uri-writes/` → `openspec/archive/<yyyy-mm-dd>-add-drive-uri-writes/`.