@aryasaatvik/scratchpad 0.2.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,7 @@ become a second source of truth competing with the files and the provider.
12
12
  ## Decision
13
13
 
14
14
  Build on Bun + Effect v4, using Effect primitives directly (`Context.Service`,
15
- `Layer`, `Schema`, `Effect.fn`, `effect/unstable/cli`). Use SQLite — drizzle-orm
15
+ `Layer`, `Schema`, `Effect.fn`, `effect/cli`). Use SQLite — drizzle-orm
16
16
  rc.4's native `effect-sqlite-bun` integration layered on `@effect/sql-sqlite-bun`'s
17
17
  `SqliteClient` — for local durability only: object mappings, sync cursors, the
18
18
  outbox, and conflict records.
@@ -0,0 +1,83 @@
1
+ # 0009 — Worker-proxied multipart uploads
2
+
3
+ Status: Proposed
4
+
5
+ ## Context
6
+
7
+ The upload endpoint already streams request bodies directly into R2 with its
8
+ native SHA-256 check. Streaming avoids a whole-file memory buffer, but does not
9
+ remove a Worker's per-request ingress limit. Merely increasing the shared size
10
+ constant would also increase buffered text previews and leave browser hashing
11
+ as a full-file allocation.
12
+
13
+ Cloudflare documents [multipart uploads through a Worker and its R2 binding](https://developers.cloudflare.com/r2/api/workers/workers-multipart-usage/).
14
+ This keeps the existing Access authentication boundary and requires no client
15
+ R2 credentials or presigned URLs. Actual ingress and runtime limits remain
16
+ deployment constraints; see [Workers limits](https://developers.cloudflare.com/workers/platform/limits/).
17
+
18
+ ## Decision
19
+
20
+ Preserve the current single-request path through 100 MiB. Add a separate
21
+ multipart path with a 1 GiB product limit, fixed 32 MiB parts except the final
22
+ part, and at most three client requests in flight.
23
+
24
+ The existing catalog Agent owns session metadata and part acknowledgements in
25
+ SQLite. Each action is bound to a verified Access subject or service-token
26
+ identity. Client-generated UUIDs make session creation retry-safe, but clients
27
+ never choose R2 keys, multipart handles, or completion ETags.
28
+
29
+ Parts stream through authenticated Worker routes into a private staging object.
30
+ An accepted part is immutable. A durable claim prevents concurrent replacement;
31
+ unknown outcomes remain busy until the original request succeeds or the session
32
+ is cancelled. We do not infer that an uncertain storage failure stopped writing.
33
+
34
+ After all parts are accepted, the Agent completes staging, checks its size, and
35
+ streams its R2 body into the canonical `sha256/<hash>` object with R2's native
36
+ `sha256` option. Multipart ETags do not substitute for whole-file SHA-256.
37
+ The binding's multipart methods do not offer the equivalent checksum option;
38
+ see the [R2 binding API](https://developers.cloudflare.com/r2/api/workers/workers-api-reference/).
39
+
40
+ Only successful verification publishes the upload row. Conditional promotion
41
+ guards concurrent canonical writes; an existing object's metadata is preserved.
42
+ Even a shared canonical key does not skip verification of the newly staged
43
+ bytes. Failed checksum verification cannot create or overwrite canonical data.
44
+
45
+ ## Recovery and cleanup
46
+
47
+ - Session creation and completion are idempotent for the same session ID and
48
+ unchanged metadata
49
+ - A lost completion response can recover the stored receipt, including after
50
+ the public link has been deleted, without recreating that link
51
+ - A completed staging object can be reused after an interrupted verification
52
+ - Cancellation and expiry are checked again after storage awaits and before
53
+ publication. Link TTL starts when the session is registered
54
+ - Sessions last at most 24 hours; a shorter link TTL can end them sooner
55
+ - Completion and cancellation attempt staging cleanup immediately. Failed
56
+ cleanup remains tracked for `artifact prune --sweep-orphans` to retry
57
+ - Active sessions protect their canonical keys from shared-blob collection
58
+ - Cleaned terminal metadata is retained for at least 24 hours and removed by
59
+ explicit sweep only after its session lifetime and receipt-retention window
60
+ - Incomplete R2 uploads orphaned before their handle can be persisted rely on
61
+ R2's existing incomplete-multipart lifecycle behavior; this change does not
62
+ configure bucket policies, alarms, or production resources
63
+
64
+ ## Consequences
65
+
66
+ Native verification needs one additional streamed R2 read and write, plus
67
+ temporary staging storage. Operation and storage charges still apply; consult
68
+ [R2 pricing](https://developers.cloudflare.com/r2/pricing/) for current rates.
69
+
70
+ Browser hashing uses incremental SHA-256 over bounded slices. The core upload
71
+ schemas have a browser-safe module boundary. Text previews retain their existing
72
+ 100 MiB limit independently of the larger storage limit.
73
+
74
+ The 1 GiB bound was exercised locally with actual Miniflare/workerd R2 bindings,
75
+ including native checksum rejection and preservation of an existing canonical
76
+ object. Production account limits, slow-client behavior, and memory telemetry
77
+ still need deployment-environment validation before raising the limit further.
78
+
79
+ The Worker integration suite defaults to a 128 MiB-plus upload. To exercise the
80
+ full bound locally, run `SCRATCHPAD_UPLOAD_TEST_BYTES=1073741824 bun run test:worker-integration`.
81
+ The suite uses isolated local storage and also requires Chrome for its unrelated
82
+ HTML review bridge. Allow enough temporary disk space for the fixture, staging,
83
+ and verified object.
@@ -11,3 +11,4 @@ Durable record of the decisions behind Scratchpad. Active planning lives in
11
11
  - [0006 — GitHub transport: Octokit, GraphQL for issues, REST for milestones](0006-octokit-graphql-and-rest.md)
12
12
  - [0007 — Explicit remote delete](0007-explicit-remote-delete.md)
13
13
  - [0008 — The CLI classifies notes with an optional decision model](0008-cli-decision-model.md)
14
+ - [0009 — Worker-proxied multipart uploads](0009-worker-multipart-uploads.md)
package/docs/release.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Release
2
2
 
3
- Scratchpad 0.1.0 is prepared as a public GitHub repository and a Bun-first npm
4
- package named `@aryasaatvik/scratchpad`.
3
+ `@aryasaatvik/scratchpad` is a Bun-first npm package. The current version is
4
+ `0.2.1`.
5
5
 
6
6
  ## Preflight and dry-run
7
7
 
8
+ Use Bun 1.4.4 or newer for local development and builds. The publish workflow pins Bun 1.4.4.
9
+
8
10
  ```sh
9
11
  bun install
10
12
  bun run dev:prepare
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aryasaatvik/scratchpad",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Local-first GitHub issue and milestone tracking, hosted artifacts and uploads, and local architecture codemaps.",
5
5
  "keywords": [
6
6
  "bun",
@@ -93,9 +93,9 @@
93
93
  "vitest": "^5.0.2"
94
94
  },
95
95
  "engines": {
96
- "bun": ">=1.3.2"
96
+ "bun": ">=1.4.4"
97
97
  },
98
- "packageManager": "bun@1.4.2",
98
+ "packageManager": "bun@1.4.4",
99
99
  "catalog": {
100
100
  "@tsconfig/bun": "1.0.10",
101
101
  "@types/bun": "^1.3.14",
@@ -107,11 +107,11 @@
107
107
  },
108
108
  "catalogs": {
109
109
  "effect": {
110
- "@effect/ai-typesafe": "4.0.0-rc.117",
111
- "@effect/platform-bun": "4.0.0-rc.117",
112
- "@effect/sql-sqlite-bun": "4.0.0-rc.117",
113
- "effect": "4.0.0-rc.117",
114
- "@effect/vitest": "4.0.0-rc.117"
110
+ "@effect/ai-typesafe": "4.0.0",
111
+ "@effect/platform-bun": "4.0.0",
112
+ "@effect/sql-sqlite-bun": "4.0.0",
113
+ "effect": "4.0.0",
114
+ "@effect/vitest": "4.0.0"
115
115
  }
116
116
  },
117
117
  "patchedDependencies": {