nebula-notebook 0.2.16 → 0.2.18

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 (40) hide show
  1. package/dist/assets/{errorwidget-DfcjRDKM.js → errorwidget-t1RLHQYw.js} +1 -1
  2. package/dist/assets/{index-CyyuPG9B.js → index-BMuaZuus.js} +1 -1
  3. package/dist/assets/index-Bvhz0ltE.css +32 -0
  4. package/dist/assets/{index-LZ-zzybU.js → index-Cq1BG1_T.js} +205 -200
  5. package/dist/assets/{index-DrhpYYGt.js → index-DTGJj27s.js} +1 -1
  6. package/dist/assets/{index-COAUb-T8.js → index-DzeeB-u3.js} +1 -1
  7. package/dist/assets/{services-shim-CCJm9nl7.js → services-shim-Dg9Zi6xv.js} +1 -1
  8. package/dist/index.html +2 -2
  9. package/node-server/dist/auth/auth-middleware.js +3 -1
  10. package/node-server/dist/fs/fs-service.js +104 -8
  11. package/node-server/dist/fs/index.d.ts +1 -0
  12. package/node-server/dist/fs/index.js +1 -0
  13. package/node-server/dist/fs/sealed-path.d.ts +41 -0
  14. package/node-server/dist/fs/sealed-path.js +228 -0
  15. package/node-server/dist/fs/types.d.ts +4 -2
  16. package/node-server/dist/fs/types.js +2 -2
  17. package/node-server/dist/index.js +22 -13
  18. package/node-server/dist/kernel/kernel-service.d.ts +2 -2
  19. package/node-server/dist/kernel/kernel-service.js +15 -5
  20. package/node-server/dist/kernel/types.d.ts +16 -0
  21. package/node-server/dist/notebook/operation-router.js +13 -2
  22. package/node-server/dist/provenance/canonical-json.d.ts +36 -0
  23. package/node-server/dist/provenance/canonical-json.js +218 -0
  24. package/node-server/dist/provenance/provenance-store.d.ts +63 -0
  25. package/node-server/dist/provenance/provenance-store.js +598 -0
  26. package/node-server/dist/provenance/replay-seal-service.d.ts +223 -0
  27. package/node-server/dist/provenance/replay-seal-service.js +1702 -0
  28. package/node-server/dist/provenance/types.d.ts +65 -0
  29. package/node-server/dist/provenance/types.js +2 -0
  30. package/node-server/dist/routes/fs.js +27 -0
  31. package/node-server/dist/routes/kernel.js +15 -0
  32. package/node-server/dist/routes/notebook.js +54 -0
  33. package/node-server/dist/routes/replay-seal.d.ts +9 -0
  34. package/node-server/dist/routes/replay-seal.js +66 -0
  35. package/node-server/dist/server/bind-host.d.ts +12 -0
  36. package/node-server/dist/server/bind-host.js +56 -0
  37. package/node-server/dist/server/cors-origin.d.ts +1 -0
  38. package/node-server/dist/server/cors-origin.js +32 -0
  39. package/package.json +1 -1
  40. package/dist/assets/index-Czch8hB-.css +0 -32
@@ -0,0 +1,223 @@
1
+ import type { ExecutionQueueInfo, ExecutionResult, InternalExecutionOptions, KernelOutput, StartKernelOptions } from '../kernel/types';
2
+ import { CANONICAL_HASH_PROFILE, type CanonicalJsonValue } from './canonical-json';
3
+ import { ProvenanceStore } from './provenance-store';
4
+ export type ReplaySealState = 'pending' | 'running' | 'completed' | 'failed';
5
+ export interface ReplaySealArtifactRequest {
6
+ path: string;
7
+ sha256: string;
8
+ size_bytes: number;
9
+ }
10
+ export interface ReplaySealRequest {
11
+ notebook_path: string;
12
+ run_id: string;
13
+ task_id: string;
14
+ source_id: string;
15
+ source_notebook_sha256: string;
16
+ artifacts: ReplaySealArtifactRequest[];
17
+ kernel_name?: string;
18
+ input_manifest: Record<string, CanonicalJsonValue>;
19
+ environment_manifest: Record<string, CanonicalJsonValue>;
20
+ }
21
+ export interface SealCellManifest {
22
+ cell_id: string;
23
+ source_sha256: string;
24
+ exploratory_outputs_sha256: string;
25
+ outputs_sha256: string;
26
+ replay_comparison_outputs_sha256: string;
27
+ outputs_match_exploratory: boolean;
28
+ exploratory_execution_count: number | null;
29
+ execution_id: string;
30
+ execution_count: number;
31
+ status: 'completed';
32
+ }
33
+ export interface SealArtifactManifest {
34
+ source_path: string;
35
+ path: string;
36
+ sha256: string;
37
+ size_bytes: number;
38
+ }
39
+ export interface RuntimeEnvironment {
40
+ schema_version: 1;
41
+ python: {
42
+ executable: string;
43
+ executable_realpath: string;
44
+ implementation: string;
45
+ version: string;
46
+ platform: string;
47
+ };
48
+ python_no_user_site: true;
49
+ base_packages: Record<string, string>;
50
+ base_packages_sha256: string;
51
+ task_local: {
52
+ package_directory: string;
53
+ packages: Record<string, string>;
54
+ packages_sha256: string;
55
+ } | null;
56
+ }
57
+ export interface ReplaySealManifest {
58
+ schema_version: 1;
59
+ hash_profile: typeof CANONICAL_HASH_PROFILE;
60
+ seal_id: string;
61
+ source_notebook: {
62
+ path: string;
63
+ sha256: string;
64
+ };
65
+ notebook: {
66
+ path: string;
67
+ sha256: string;
68
+ };
69
+ input_manifest_sha256: string;
70
+ environment_manifest_sha256: string;
71
+ runtime_environment: RuntimeEnvironment;
72
+ runtime_environment_sha256: string;
73
+ event_chain_head_sha256: string;
74
+ event_ledger: {
75
+ path: string;
76
+ prefix_size_bytes: number;
77
+ prefix_sha256: string;
78
+ head_sha256: string;
79
+ head_seq: number;
80
+ };
81
+ cells: SealCellManifest[];
82
+ artifacts: SealArtifactManifest[];
83
+ isolation: {
84
+ fresh_kernel: true;
85
+ network_isolated: false;
86
+ filesystem_isolated: false;
87
+ };
88
+ bootstrap?: {
89
+ package_directory: string;
90
+ source_sha256: string;
91
+ outputs_sha256: string;
92
+ execution_id: string;
93
+ execution_count: number;
94
+ status: 'completed';
95
+ };
96
+ manifest_sha256: string;
97
+ }
98
+ export type ReplaySealStatusResponse = {
99
+ seal_id: string;
100
+ status: 'pending' | 'running';
101
+ } | {
102
+ seal_id: string;
103
+ status: 'completed';
104
+ manifest: ReplaySealManifest;
105
+ } | {
106
+ seal_id: string;
107
+ status: 'failed';
108
+ error: string;
109
+ };
110
+ export interface ReplayKernelService {
111
+ startKernel(options?: StartKernelOptions): Promise<string>;
112
+ executeCode(sessionId: string, code: string, onOutput: (output: KernelOutput, cellId?: string | null) => Promise<void>, onQueueInfo?: (info: ExecutionQueueInfo) => void, cellId?: string | null, internalOptions?: InternalExecutionOptions): Promise<ExecutionResult>;
113
+ stopKernel(sessionId: string): Promise<boolean>;
114
+ }
115
+ export interface ReplaySealServiceOptions {
116
+ rootDirectory: string;
117
+ kernelService: ReplayKernelService;
118
+ provenanceStore?: ProvenanceStore;
119
+ durable?: boolean;
120
+ idFactory?: () => string;
121
+ clock?: () => Date;
122
+ }
123
+ export declare class ReplaySealValidationError extends Error {
124
+ readonly code = "REPLAY_SEAL_VALIDATION_ERROR";
125
+ constructor(message: string);
126
+ }
127
+ export declare class ReplaySealConflictError extends Error {
128
+ readonly code = "IDEMPOTENCY_CONFLICT";
129
+ constructor();
130
+ }
131
+ /**
132
+ * Normalize only nbformat's equivalent text encodings for replay comparison.
133
+ *
134
+ * - stream.text: an array of strings is joined, a string is unchanged;
135
+ * - data values for text/*, application/javascript, and image/svg+xml use the
136
+ * same array-to-string join;
137
+ * - every other JSON value, including binary MIME arrays and traceback, is
138
+ * preserved exactly.
139
+ *
140
+ * This is intentionally separate from outputs_sha256, which hashes the exact
141
+ * output JSON written to the immutable executed notebook.
142
+ */
143
+ export declare function normalizeNotebookOutputsForComparison(value: unknown): CanonicalJsonValue[];
144
+ /**
145
+ * Fresh-kernel, top-to-bottom replay and immutable evidence sealing.
146
+ *
147
+ * The service deliberately makes no network/filesystem-isolation claim. A
148
+ * dedicated kernel prevents state inheritance from an exploratory session;
149
+ * the immutable copies, hashes, and server-authored event prefix bind what ran.
150
+ */
151
+ export declare class ReplaySealService {
152
+ private static readonly queues;
153
+ private readonly rootDirectory;
154
+ private readonly registryDirectory;
155
+ private readonly kernelService;
156
+ private readonly provenanceStore;
157
+ private readonly durable;
158
+ private readonly idFactory;
159
+ private readonly clock;
160
+ private readonly processInstanceId;
161
+ private readonly activeJobs;
162
+ private readonly attemptedJobs;
163
+ constructor(options: ReplaySealServiceOptions);
164
+ submit(rawRequest: ReplaySealRequest, idempotencyKey: string): Promise<ReplaySealStatusResponse>;
165
+ getStatus(sealId: string): Promise<ReplaySealStatusResponse | null>;
166
+ private ensureRunning;
167
+ private runJob;
168
+ private failJob;
169
+ private executeNotebookCell;
170
+ private executeServerCode;
171
+ private executeAndCapture;
172
+ private appendExecutionEvent;
173
+ private buildSealedNotebook;
174
+ private preflightArtifacts;
175
+ private sealArtifacts;
176
+ private copyRegularFileImmutable;
177
+ private baseEnvironmentProbeSource;
178
+ private taskLocalBootstrapSource;
179
+ private parseBaseEnvironmentProbe;
180
+ private parseTaskLocalProbe;
181
+ private compareBaseEnvironment;
182
+ private compareTaskLocalEnvironment;
183
+ private taskLocalDeclaration;
184
+ private validateEnvironmentDeclaration;
185
+ private parseFrozenNotebook;
186
+ private normalizeRequest;
187
+ private validateIdempotencyKey;
188
+ private responseFor;
189
+ private verifiedResponseFor;
190
+ private verifyCompletedSeal;
191
+ private verifyLedgerPrefix;
192
+ private verifyManifestCells;
193
+ private hashRegularFile;
194
+ private registryPath;
195
+ private ensureRegistryDirectory;
196
+ private createSafeSealDirectory;
197
+ private ensureSafeDirectoryChain;
198
+ private hardenSealDirectory;
199
+ private sealRequestEventKey;
200
+ private persistJob;
201
+ private updateJob;
202
+ private readJob;
203
+ private writeJsonAtomic;
204
+ private writeImmutable;
205
+ private readNotebookSource;
206
+ private captureLedgerPrefix;
207
+ private toJupyterOutput;
208
+ private markerPayload;
209
+ private parseObject;
210
+ private stringMap;
211
+ private plainRecord;
212
+ private optionalRecord;
213
+ private nonempty;
214
+ private cellSource;
215
+ private relativeInside;
216
+ private assertNoSymlinkComponents;
217
+ private assertNoSymlinkComponentsSync;
218
+ private syncDirectory;
219
+ private cloneJson;
220
+ private errorMessage;
221
+ private isNodeError;
222
+ private runSerialized;
223
+ }