@aryasaatvik/scratchpad 0.2.0 → 0.3.0
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.
- package/CHANGELOG.md +20 -0
- package/README.md +32 -5
- package/SECURITY.md +1 -1
- package/dist/scratchpad.js +2580 -2115
- package/docs/adr/0002-bun-effect-sqlite.md +1 -1
- package/docs/adr/0009-worker-multipart-uploads.md +83 -0
- package/docs/adr/README.md +1 -0
- package/docs/release.md +2 -2
- package/package.json +6 -6
|
@@ -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/
|
|
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.
|
package/docs/adr/README.md
CHANGED
|
@@ -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aryasaatvik/scratchpad",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Local-first GitHub issue and milestone tracking, hosted artifacts and uploads, and local architecture codemaps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -107,11 +107,11 @@
|
|
|
107
107
|
},
|
|
108
108
|
"catalogs": {
|
|
109
109
|
"effect": {
|
|
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
|
|
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": {
|