@lumeweb/sia-testing 0.0.0-stage → 0.0.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.
Files changed (90) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +210 -2
  3. package/dist/esm/client.d.ts +8 -0
  4. package/dist/esm/client.js +6 -0
  5. package/dist/esm/http.d.ts +3 -0
  6. package/dist/esm/http.js +3 -0
  7. package/dist/esm/mock.d.ts +8 -0
  8. package/dist/esm/mock.js +7 -0
  9. package/dist/esm/model/index.js +509 -0
  10. package/dist/esm/model/state.js +188 -0
  11. package/dist/esm/msw.d.ts +2 -0
  12. package/dist/esm/msw.js +3 -0
  13. package/dist/esm/node.d.ts +4 -0
  14. package/dist/esm/node.js +4 -0
  15. package/dist/esm/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_md.js +169 -0
  16. package/dist/esm/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_u64.js +12 -0
  17. package/dist/esm/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/sha2.js +199 -0
  18. package/dist/esm/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/utils.js +220 -0
  19. package/dist/esm/sdk/abort.js +23 -0
  20. package/dist/esm/sdk/control.js +129 -0
  21. package/dist/esm/sdk/index.js +454 -0
  22. package/dist/esm/sdk/link.js +55 -0
  23. package/dist/esm/sdk/object.js +24 -0
  24. package/dist/esm/sdk/payload-store.d.ts +9 -0
  25. package/dist/esm/sdk/payload-store.js +67 -0
  26. package/dist/esm/sdk/state.js +74 -0
  27. package/dist/esm/testing/application-client.d.ts +8 -0
  28. package/dist/esm/testing/application-client.js +295 -0
  29. package/dist/esm/testing/application-metadata.js +17 -0
  30. package/dist/esm/testing/application-transport.js +363 -0
  31. package/dist/esm/testing/auth-client.d.ts +20 -0
  32. package/dist/esm/testing/auth-client.js +63 -0
  33. package/dist/esm/testing/authentication.js +48 -0
  34. package/dist/esm/testing/byte-view.js +28 -0
  35. package/dist/esm/testing/chunked-files.d.ts +12 -0
  36. package/dist/esm/testing/chunked-files.js +50 -0
  37. package/dist/esm/testing/client.d.ts +8 -0
  38. package/dist/esm/testing/client.js +105 -0
  39. package/dist/esm/testing/controls.d.ts +44 -0
  40. package/dist/esm/testing/controls.js +255 -0
  41. package/dist/esm/testing/diagnostics.js +55 -0
  42. package/dist/esm/testing/files.d.ts +9 -0
  43. package/dist/esm/testing/files.js +86 -0
  44. package/dist/esm/testing/http-body.js +33 -0
  45. package/dist/esm/testing/http.d.ts +14 -0
  46. package/dist/esm/testing/http.js +181 -0
  47. package/dist/esm/testing/live/agent.d.ts +1 -0
  48. package/dist/esm/testing/live/agent.js +211 -0
  49. package/dist/esm/testing/live/approval.js +42 -0
  50. package/dist/esm/testing/live/cleanup.js +74 -0
  51. package/dist/esm/testing/live/journal.js +180 -0
  52. package/dist/esm/testing/live/lease.js +56 -0
  53. package/dist/esm/testing/live/private-files.js +50 -0
  54. package/dist/esm/testing/live/process.js +208 -0
  55. package/dist/esm/testing/live/profile.js +214 -0
  56. package/dist/esm/testing/live/recovery.js +164 -0
  57. package/dist/esm/testing/live/resource-limits.js +9 -0
  58. package/dist/esm/testing/live/run.js +390 -0
  59. package/dist/esm/testing/live/session.js +93 -0
  60. package/dist/esm/testing/live/types.d.ts +8 -0
  61. package/dist/esm/testing/mock.d.ts +8 -0
  62. package/dist/esm/testing/mock.js +1364 -0
  63. package/dist/esm/testing/msw.d.ts +21 -0
  64. package/dist/esm/testing/msw.js +61 -0
  65. package/dist/esm/testing/mutations.d.ts +59 -0
  66. package/dist/esm/testing/mutations.js +58 -0
  67. package/dist/esm/testing/node-payload-store.js +353 -0
  68. package/dist/esm/testing/node.d.ts +40 -0
  69. package/dist/esm/testing/node.js +148 -0
  70. package/dist/esm/testing/owner-client.d.ts +9 -0
  71. package/dist/esm/testing/owner-client.js +101 -0
  72. package/dist/esm/testing/owner-shares.js +80 -0
  73. package/dist/esm/testing/packed.d.ts +46 -0
  74. package/dist/esm/testing/packed.js +326 -0
  75. package/dist/esm/testing/reader-lifetime.js +40 -0
  76. package/dist/esm/testing/reply-loss.js +14 -0
  77. package/dist/esm/testing/runtime.d.ts +7 -0
  78. package/dist/esm/testing/runtime.js +13 -0
  79. package/dist/esm/testing/sdk-upload.d.ts +45 -0
  80. package/dist/esm/testing/sdk-upload.js +198 -0
  81. package/dist/esm/testing/streaming-source.js +72 -0
  82. package/dist/esm/testing/transport.d.ts +22 -0
  83. package/dist/esm/testing/transport.js +238 -0
  84. package/dist/esm/testing/types.d.ts +276 -0
  85. package/dist/esm/vitest.d.ts +23 -0
  86. package/dist/esm/vitest.js +34 -0
  87. package/docs/live-auth.md +154 -0
  88. package/docs/live-runs.md +188 -0
  89. package/docs/mock-contracts.md +647 -0
  90. package/package.json +90 -3
@@ -0,0 +1,154 @@
1
+ # Configure live authentication
2
+
3
+ Node runs authenticate an owned SDK process against an existing server. They do not deploy a server or fund an account. Use a private profile with [the live backend](live-runs.md).
4
+
5
+ ## Borrowed authority
6
+
7
+ A version 1 profile contains an API base URL and application metadata. Its authentication mode is one of:
8
+
9
+ - `app-key`: reconnect with an existing 32-byte app-key seed.
10
+ - `register`: use a recovery phrase after approving an SDK request with an existing connect key.
11
+ - `preauthorized`: use a recovery phrase with an existing 32-byte preauthorized-key seed.
12
+
13
+ The profile also supplies upload encoding and resource limits. Loading it requires explicit transfer and mutation consent for the same normalized API URL. HTTPS is required except for numeric loopback HTTP addresses.
14
+
15
+ Profiles must be absolute-path, owner-only regular files outside the checkout. The loader rejects final-component symlinks and multiply linked files. It reads at most 16 KiB and returns an opaque handle whose JSON and inspection output omit credentials. The parsed document is an immutable snapshot.
16
+
17
+ ## Complete profile examples
18
+
19
+ These examples are synthetic and parse offline. They are not working credentials. Replace the reserved `.invalid` URLs, application fields, and authentication values with your own before requesting a live run. Store the resulting JSON outside your checkout in a private directory (`0700`) and an owner-only file (`0600`). Never commit a recovery phrase or journal.
20
+
21
+ All fields shown except `limits` are required. `limits` may be omitted or contain a subset; the values below are the parser defaults. Unknown fields are rejected. `app.id` and the key seeds are 32 bytes written as 64 hexadecimal characters. Application text must be nonempty and at most 4096 characters.
22
+
23
+ ### Reconnect with an app key
24
+
25
+ `appKeyHex` is an existing app-key seed for this application, not a connect key or a recovery phrase.
26
+
27
+ ```json profile=app-key
28
+ {
29
+ "version": 1,
30
+ "apiBaseUrl": "https://indexd.example.invalid/",
31
+ "app": {
32
+ "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
33
+ "name": "Document tests",
34
+ "description": "Owned synthetic fixtures",
35
+ "serviceUrl": "https://app.example.invalid/"
36
+ },
37
+ "encoding": {
38
+ "dataShards": 1,
39
+ "parityShards": 0,
40
+ "maxBufferedSlabs": 1
41
+ },
42
+ "limits": {
43
+ "deadlineMs": 120000,
44
+ "cleanupDeadlineMs": 30000,
45
+ "maxObjects": 8,
46
+ "maxShares": 8,
47
+ "maxLogicalUploadBytes": 16777216,
48
+ "maxDecodedDownloadBytes": 33554432,
49
+ "maxObservedShardBytes": 67108864
50
+ },
51
+ "auth": {
52
+ "kind": "app-key",
53
+ "appKeyHex": "0101010101010101010101010101010101010101010101010101010101010101"
54
+ }
55
+ }
56
+ ```
57
+
58
+ ### Register with a connect key
59
+
60
+ `phrase` is the account recovery phrase. `connectKey` approves the registration request; it is not the app-key seed. The phrase below is deliberately not a valid account recovery phrase. The profile parser checks nonempty text; the SDK validates authentication.
61
+
62
+ ```json profile=register
63
+ {
64
+ "version": 1,
65
+ "apiBaseUrl": "https://indexd.example.invalid/",
66
+ "app": {
67
+ "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
68
+ "name": "Document tests",
69
+ "description": "Owned synthetic fixtures",
70
+ "serviceUrl": "https://app.example.invalid/"
71
+ },
72
+ "encoding": {
73
+ "dataShards": 1,
74
+ "parityShards": 0,
75
+ "maxBufferedSlabs": 1
76
+ },
77
+ "limits": {
78
+ "deadlineMs": 120000,
79
+ "cleanupDeadlineMs": 30000,
80
+ "maxObjects": 8,
81
+ "maxShares": 8,
82
+ "maxLogicalUploadBytes": 16777216,
83
+ "maxDecodedDownloadBytes": 33554432,
84
+ "maxObservedShardBytes": 67108864
85
+ },
86
+ "auth": {
87
+ "kind": "register",
88
+ "phrase": "synthetic recovery phrase replace before live use",
89
+ "connectKey": "synthetic-connect-key-replace-before-live-use"
90
+ }
91
+ }
92
+ ```
93
+
94
+ ### Use a preauthorized seed
95
+
96
+ `preauthorizedKeyHex` is a preauthorized-key seed, not an app key. Registration also needs the account recovery phrase. Replace the synthetic phrase before SDK use. Cleanup reconnects with the acknowledged app key, without consuming a second preauthorization.
97
+
98
+ ```json profile=preauthorized
99
+ {
100
+ "version": 1,
101
+ "apiBaseUrl": "https://indexd.example.invalid/",
102
+ "app": {
103
+ "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
104
+ "name": "Document tests",
105
+ "description": "Owned synthetic fixtures",
106
+ "serviceUrl": "https://app.example.invalid/"
107
+ },
108
+ "encoding": {
109
+ "dataShards": 1,
110
+ "parityShards": 0,
111
+ "maxBufferedSlabs": 1
112
+ },
113
+ "limits": {
114
+ "deadlineMs": 120000,
115
+ "cleanupDeadlineMs": 30000,
116
+ "maxObjects": 8,
117
+ "maxShares": 8,
118
+ "maxLogicalUploadBytes": 16777216,
119
+ "maxDecodedDownloadBytes": 33554432,
120
+ "maxObservedShardBytes": 67108864
121
+ },
122
+ "auth": {
123
+ "kind": "preauthorized",
124
+ "phrase": "synthetic recovery phrase replace before live use",
125
+ "preauthorizedKeyHex": "0202020202020202020202020202020202020202020202020202020202020202"
126
+ }
127
+ }
128
+ ```
129
+
130
+ ### Encoding and limits
131
+
132
+ `dataShards` is an integer from 1 to 255, `parityShards` from 0 to 254, and their sum cannot exceed 255. `maxBufferedSlabs` is from 1 to 8. Encoding has no defaults.
133
+
134
+ Both deadline fields accept 1 through 120000 milliseconds. Object and share limits accept 0 through 64. `maxLogicalUploadBytes` accepts 0 through 16777216, `maxDecodedDownloadBytes` 0 through 67108864, and `maxObservedShardBytes` 0 through 268435456. All limits are safe integers. Observed shard bytes are progress counters, not a hard financial limit.
135
+
136
+ Consent must explicitly set `transfers: true` and `mutations: true` and name the same normalized `apiBaseUrl`. The API URL cannot include credentials, a query, or a fragment. The loader adds a trailing slash. For the examples above, consent uses `https://indexd.example.invalid/`; no request to that reserved host is useful.
137
+
138
+ ## SDK lifetime
139
+
140
+ The installed SDK must be version `0.2.0`. Authority reaches the agent over Node IPC rather than command-line arguments. The agent uses a small environment allowlist, with inherited module-loader and native-loader overrides removed. Its stdout and stderr are discarded; RPC failures contain fixed messages and classified codes.
141
+
142
+ The parent owns the process lifetime. The agent still uses the network and operating-system permissions of the caller. A request deadline or abort stops the process before the request rejects. Shutdown first sends SIGTERM, then SIGKILL if the child remains alive. Failure to confirm exit within the cleanup deadline is reported as uncertain termination.
143
+
144
+ Registration approval validates the response URL's origin and connection path before sending the connect key as the Basic-auth password. Redirects are rejected. The decision body is explicit, including denial. SDK sign-in and account-readiness polling run inside the execution deadline; an app-ID mismatch fails instead of returning an unrelated account.
145
+
146
+ The framework does not own or delete the operator's account. Logical-byte limits and SDK progress counters are not hard limits on encrypted network traffic or charges.
147
+
148
+ ## Offline evidence
149
+
150
+ Tests use synthetic owner-only profiles and owned loopback HTTP listeners. They exercise profile rejection and approval URL restrictions, including redirects. Process tests check that cancellation and channel loss stop children that ignore SIGTERM.
151
+
152
+ Installed-SDK tests cover all authentication entrypoints and account-readiness polling. Their preauthorization fixture checks the supplied key identity and simulates approval; it does not model Indexd's cryptographic proof validation. A separate installed-SDK case blocks an authentication request and confirms that aborting the owner stops its native process.
153
+
154
+ No real-server authentication or transfer was run. These checks do not establish endpoint compatibility or upload readiness on an operator's server.
@@ -0,0 +1,188 @@
1
+ # Managed runs against an existing server
2
+
3
+ `withSiaRun` accepts a private live profile and explicit consent. It owns only the fixture objects and sharing keys that its SDK agent creates. It does not deploy services, fund an account or prune an account's slabs.
4
+
5
+ ```ts
6
+ import { fileFixture, withSiaRun } from "@lumeweb/sia-testing/node";
7
+
8
+ await withSiaRun(
9
+ {
10
+ backend: {
11
+ kind: "live",
12
+ profileFile: "/private/sia/profile.json",
13
+ consent: {
14
+ apiBaseUrl: "https://indexd.example.invalid/",
15
+ mutations: true,
16
+ transfers: true,
17
+ },
18
+ },
19
+ journalFile: "/private/sia/run-unique.jsonl",
20
+ },
21
+ async (run) => {
22
+ const file = await fileFixture("/fixtures/video.mp4");
23
+ const object = await run.objects.upload({
24
+ file,
25
+ name: file.name,
26
+ metadata: new TextEncoder().encode("video fixture"),
27
+ });
28
+ const share = await run.shares.create({ objects: [object] });
29
+ await run.shares.revoke(share);
30
+ },
31
+ );
32
+ ```
33
+
34
+ The application callback must await its work and close resources it creates outside the framework. A run deadline stops owned SDK work; arbitrary JavaScript started by the callback can continue. Mutation methods reject after the run closes.
35
+
36
+ ## Profiles and limits
37
+
38
+ Profiles use the version 1 schema described in [live-auth.md](live-auth.md). Store the profile outside the checkout in an owner-only regular file. The API URL in consent must match the profile's normalized URL. The profile supplies application metadata and upload encoding alongside the authentication mode.
39
+
40
+ Live upload metadata is limited to 16 KiB. Upload mutations reserve room for a sealed object of up to 1 MiB and their journal record fields before calling the SDK. Other concurrent mutations cannot spend those reserved bytes. Insufficient journal capacity therefore rejects creation before the SDK runs; filesystem write failures can still leave an uncertain result.
41
+
42
+ Run-level `maxObjects`, `maxShares` and `maxLogicalUploadBytes` can lower the profile's limits. They cannot raise them. Accepted upload attempts reserve their object count and declared bytes before opening the source, and failed attempts retain those reservations. The source's byte count and SHA-256 digest must match its descriptor before SDK upload starts.
43
+
44
+ The SDK agent checks observed uploaded-shard progress against the profile's `maxObservedShardBytes`. Progress callbacks do not account for every encrypted byte, retry or charge. No hard financial limit is claimed. Nonempty uploads require compatible, funded hosts on the existing server.
45
+
46
+ ## Cleanup and recovery
47
+
48
+ Every mutation records an intent before calling the SDK. An acknowledgement is flushed before a fixture handle is returned. Upload acknowledgements include a sealed SDK object, so cleanup can finish pinning a known upload before deleting it. Cleanup revokes recorded sharing keys before deleting recorded objects, using an acknowledged app key rather than consuming another preauthorization.
49
+
50
+ A clean summary confirms sharing-key revocation and object deletion for the recorded fixtures. Physical sectors and slab pins may remain under the server's retention rules. The framework never invokes account-wide slab pruning.
51
+
52
+ Creation records can use 16 MiB of journal space; cleanup and completion records have a further 1 MiB reserve. A full creation journal can therefore still record revocation and deletion during recovery. Cleanup continues with other recorded resources after a failure, reconnecting with the acknowledged app key when the SDK agent has stopped.
53
+
54
+ Journals contain credentials and sealed object data. They are created exclusively with mode `0600` under a private directory outside the checkout. Do not attach them to CI artifacts. The default journal directory is under the operating system's temporary directory; supply a private persistent path if recovery must survive temporary-directory cleanup. Keep the reported journal path when a run fails.
55
+
56
+ ```ts
57
+ import { recoverSiaRun } from "@lumeweb/sia-testing/node";
58
+
59
+ await recoverSiaRun({
60
+ backend: {
61
+ kind: "live",
62
+ profileFile: "/private/sia/profile.json",
63
+ consent: {
64
+ apiBaseUrl: "https://indexd.example.invalid/",
65
+ mutations: true,
66
+ transfers: true,
67
+ },
68
+ },
69
+ journalFile: "/private/sia/run-unique.jsonl",
70
+ });
71
+ ```
72
+
73
+ Recovery checks the journal's endpoint and application ID against the profile. It deletes only resource IDs and sharing keys established by acknowledged creation records. A creation without an acknowledgement stays uncertain; recovery preserves its journal and fails instead of scanning or deleting other account resources.
74
+
75
+ A `.lease` file prevents concurrent run and recovery owners. The framework never removes an existing lease by PID or age. After a process crash, stop all users of the journal and remove its lease before recovery. Removing a lease while an owner is active can allow concurrent mutations.
76
+
77
+ Offline tests cover the installed SDK's metadata-only pin/share/delete lifecycle on owned loopback services. They do not establish nonempty upload, browser transport or real-server compatibility.
78
+
79
+ ## Application-write recipe (SDK 0.2.0)
80
+
81
+ Managed fixture uploads do not execute an application's writer. There is no public application-write driver or assertion helper. Keep the actual application call in its consumer test, and retain every original acknowledgement inside that call before getters, metadata changes, pinning, sealing or delivery. Wrapping a writer that returns only its first ID cannot establish cleanup of all results. Readable rows, IDs and receipts do not grant cleanup authority.
82
+
83
+ The following Node recipe shows selected SDK calls for one disposable five-byte input. It is an SDK recipe, not proof of a consumer adapter, a live-ready runner or a native completion guarantee. It requires an already authenticated SDK and separately approved endpoint consent, disposable resources and compatible funded services. It has not been executed against a live server. Do not run it as part of ordinary unit or package checks.
84
+
85
+ ```ts
86
+ import type { PackedUpload, PinnedObject, Sdk, SealedObject } from "@siafoundation/sia-storage";
87
+ import { strict as assert } from "node:assert";
88
+
89
+ async function oneDisposableWrite(sdk: Sdk) {
90
+ const expected = Uint8Array.of(0x53, 0x69, 0x61, 0, 0xff);
91
+ const expectedMetadata = Buffer.from([7, 8]);
92
+ const sealed: SealedObject[] = [];
93
+ const failures: { phase: "write" | "cleanup"; error: unknown }[] = [];
94
+ let originals: readonly PinnedObject[] = [];
95
+ let packed: PackedUpload | undefined;
96
+ let creationUncertain = false;
97
+ let sent = false;
98
+ let eof = false;
99
+ const source = new ReadableStream<Uint8Array>(
100
+ {
101
+ pull(controller) {
102
+ if (sent) {
103
+ eof = true;
104
+ controller.close();
105
+ } else {
106
+ sent = true;
107
+ controller.enqueue(expected.slice());
108
+ }
109
+ },
110
+ },
111
+ { highWaterMark: 0 },
112
+ );
113
+ try {
114
+ packed = sdk.uploadPacked({
115
+ dataShards: 1,
116
+ parityShards: 1,
117
+ maxBufferedSlabs: 1,
118
+ }); // synchronous, not a Promise
119
+ creationUncertain = true;
120
+ assert.equal(await packed.add(source), 5n);
121
+ originals = await packed.finalize(); // retain the WHOLE batch before any getter
122
+ creationUncertain = false;
123
+ assert.equal(originals.length, 1); // extra originals remain owned on failure
124
+ const object = originals[0]!;
125
+ object.updateMetadata(Buffer.from(expectedMetadata));
126
+ await sdk.updateObjectMetadata(object);
127
+ await sdk.pinObject(object); // upload and pin are separate
128
+ sealed.push(object.seal(sdk.appKey())); // native seal returns SealedObject
129
+ assert.equal(eof, true);
130
+ const row = await sdk.object(object.id());
131
+ assert.deepEqual(row.metadata(), expectedMetadata);
132
+ const download = sdk.download(row); // synchronous stream, asynchronous reads
133
+ const reader = download.getReader();
134
+ let offset = 0;
135
+ let chunks = 0;
136
+ let complete = false;
137
+ let readFailed = false;
138
+ try {
139
+ for (;;) {
140
+ const next = await reader.read().catch((error: unknown) => {
141
+ readFailed = true;
142
+ throw error;
143
+ });
144
+ if (next.done) {
145
+ assert.equal(offset, expected.length);
146
+ complete = true;
147
+ break;
148
+ }
149
+ assert.ok(++chunks <= 32);
150
+ assert.ok(next.value.byteLength <= 65536);
151
+ assert.ok(next.value.buffer.byteLength <= 65536);
152
+ for (const byte of next.value) {
153
+ assert.ok(offset < expected.length); // fail on the first overflow byte
154
+ assert.equal(byte, expected[offset++]);
155
+ }
156
+ }
157
+ } finally {
158
+ if (!complete && !readFailed) {
159
+ try {
160
+ await reader.cancel();
161
+ } catch (error) {
162
+ failures.push({ phase: "cleanup", error });
163
+ }
164
+ }
165
+ reader.releaseLock();
166
+ }
167
+ } catch (error) {
168
+ failures.push({ phase: "write", error });
169
+ // A rejected native finalize has no declared partial-object error contract.
170
+ // Any unacknowledged creation stays unknown; do not read error.objects.
171
+ }
172
+ // The caller must keep this invocation and its originals owned until all work settles.
173
+ // This return is not a cleanup summary or permission to close the session.
174
+ return { creationUncertain, failures, originals, packed, sealed, source };
175
+ }
176
+ ```
177
+
178
+ Snapshot literal expected bytes and metadata before calling adapter code; never use a writer's returned bytes as the oracle. Count source consumption inline, without an unread tee. The ordinary offline contract profile uses at most 1 MiB combined payload, at most 32 chunks, and 64 KiB chunk/backing buffers; these are test-profile budgets, not new package limits or permission to spend funds. The single-input contract expects one destination. Multiple inputs need an explicit per-input destination mapping; an unexpected result count is not permission to discard acknowledged references.
179
+
180
+ The returned source and packed operation reference remain available to the caller even when add or finalize rejects; `packed` is undefined if its creation failed. The caller already owns the SDK. Retaining these references does not supply asynchronous join, cancellation completion or native completion, and it does not recover a reader held inside the SDK.
181
+
182
+ This example awaits exposed SDK calls and download cancellation, but SDK 0.2.0's Node declarations provide no asynchronous packed disposal or SDK close/join method. Browser `free`/`Symbol.dispose` and Node `cancel` are not declared completion joins. Before any live execution, the test owner must establish how source finalization, late acknowledgements, SDK/session and physical work settle on every failure path. Retain that work after caller abort or observation timeout; a discarded `Promise.race` or force-closing the session cannot supply this evidence. Do not treat the example's return as a complete-cleanup summary. If an interrupted source remains locked, its owner must settle it before final reset; the example does not recover a lost reader.
183
+
184
+ Only after the owner has established that work has settled may its disposable-resource cleanup call `await sdk.deleteObject(object.id())` once for each original retained by this invocation. Keep the original write failures and every observed delete error, and continue with independent objects after a delete failure. Do not take IDs from readable rows or another invocation as ownership claims. The code deliberately does not start deletion or close the session without that missing completion evidence.
185
+
186
+ Deletion acknowledges an indexer operation, not physical slab reclamation. Unpinned objects may not have a deletable indexer row; record the failure or uncertainty without pinning them for cleanup. Do not retry, resend, inspect, recover or prune automatically. An explicit deletion readback, if required by a future live test, needs its own approved selected-ID observation. The ephemeral application recipe has no crash-recovery journal. The managed agent's journal, lease and forced process deadlines remain managed-fixture policy and do not track external application commits or join arbitrary caller JavaScript.
187
+
188
+ Private offline tests exercise actual public mock byte/metadata readback and separate controlled bookkeeping failures. Compile-only Node/browser fixtures check selected 0.2.0 declarations without importing native code at runtime. None establishes nonempty native transfer, complete consumer acknowledgement visibility, SDK 0.0.12 compatibility or a live browser/worker path.