@ai-ecoverse/slicc-kernel 1.160.3 → 1.162.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.
@@ -1,6 +1,6 @@
1
1
  import { type MetaStore } from './meta.js';
2
- import { type LockManagerLike, type RemoteListener } from './remote.js';
3
- import { type CopyOptions, type FsStat, type KernelFs, type NewOwner, type OwnerChange, type Peers, type Perm, type PwriteOptions } from './types.js';
2
+ import { type KeepHandlers, type LockManagerLike, type RemoteListener } from './remote.js';
3
+ import { type CopyOptions, type FsStat, type KernelFs, type NewOwner, type OwnerChange, type PeerKeeps, type Peers, type Perm, type PwriteOptions } from './types.js';
4
4
  export type OpfsOp = 'lookup' | 'read' | 'write' | 'commit' | 'sidecar';
5
5
  export declare function translate(err: unknown, path: string, op?: OpfsOp, mapped?: boolean): Error;
6
6
  export interface WriteSession {
@@ -40,10 +40,22 @@ export declare class OpfsFs implements KernelFs {
40
40
  });
41
41
  private changed;
42
42
  fileId(path: string): Promise<string>;
43
+ bindId(path: string): Promise<string | undefined>;
44
+ private assignId;
43
45
  private heldUnder;
44
46
  heldBy(held: (dir: string) => readonly string[]): void;
45
47
  private pinHeld;
46
48
  remoteChanges(listener: RemoteListener): () => void;
49
+ announceHolds(add: ReadonlyArray<[string, string | undefined]>, drop: readonly string[], wait: boolean): Promise<void>;
50
+ holdCounts(): {
51
+ mine: number;
52
+ peers: number;
53
+ sent: number;
54
+ held: string[];
55
+ } | undefined;
56
+ peerKeeps(): PeerKeeps | undefined;
57
+ servePeerKeeps(instance: string, handlers: KeepHandlers): void;
58
+ rehold(from: string, to: string): void;
47
59
  announceWatch(paths: readonly string[]): Promise<void>;
48
60
  private committed;
49
61
  private counted;
@@ -19,6 +19,52 @@ export declare const MOURN_TRIES = 5;
19
19
  export declare const MOURN_RETRY_MS = 100;
20
20
  export declare const RENAME_ACK_MAX_MS = 10000;
21
21
  export declare const ANNOUNCE_POLL_MS = 20;
22
+ interface WatchMessage {
23
+ hello?: string;
24
+ here?: string;
25
+ to?: string;
26
+ tab?: string;
27
+ seq?: number;
28
+ paths?: string[];
29
+ ack?: number;
30
+ from?: string;
31
+ changed?: string[];
32
+ renames?: true;
33
+ keeps?: true;
34
+ renaming?: PeerRename;
35
+ renamed?: string;
36
+ flushing?: string;
37
+ holds?: {
38
+ add: Array<[string, string | undefined]>;
39
+ drop: string[];
40
+ instance?: string;
41
+ };
42
+ keeping?: {
43
+ paths: string[];
44
+ };
45
+ kept?: {
46
+ items: PeerKept[];
47
+ paths?: string[];
48
+ };
49
+ instance?: string;
50
+ }
51
+ export interface PeerKept {
52
+ path: string;
53
+ hidden: string | undefined;
54
+ fid: string | undefined;
55
+ undo?: string;
56
+ }
57
+ export interface PeerHolder {
58
+ tab: string;
59
+ path: string;
60
+ fid: string | undefined;
61
+ instance: string | undefined;
62
+ }
63
+ export interface KeepHandlers {
64
+ keeping(tab: string, paths: readonly string[]): Promise<void>;
65
+ kept(tab: string, items: readonly PeerKept[], paths: readonly string[]): Promise<void>;
66
+ left(tab: string): void;
67
+ }
22
68
  export interface LockManagerLike {
23
69
  request(name: string, callback: () => Promise<void>): Promise<unknown>;
24
70
  query(): Promise<{
@@ -39,6 +85,14 @@ export declare class RemoteWatch {
39
85
  private readonly mourned;
40
86
  private readonly others;
41
87
  private readonly union;
88
+ private readonly myHolds;
89
+ private readonly peerHolds;
90
+ private holdsSent;
91
+ private readonly silent;
92
+ private readonly holders;
93
+ private readonly instances;
94
+ instance: string | undefined;
95
+ keeps: KeepHandlers | undefined;
42
96
  private readonly listeners;
43
97
  private readonly waiting;
44
98
  private readonly locks;
@@ -75,6 +129,26 @@ export declare class RemoteWatch {
75
129
  private greeted;
76
130
  private heard;
77
131
  private announced;
132
+ private holdsHeard;
133
+ private readonly keepChains;
134
+ private keepAsked;
135
+ private keepOne;
136
+ private heldBy;
137
+ hold(add: ReadonlyArray<[string, string | undefined]>, drop: readonly string[], wait: boolean): Promise<void>;
138
+ rehold(from: string, to: string): void;
139
+ private sendHolds;
140
+ heldWithin(target: string): PeerHolder[];
141
+ ask(to: string, body: Pick<WatchMessage, 'keeping' | 'kept'>, cap: number): Promise<boolean>;
142
+ peerHeld(path: string): Array<{
143
+ tab: string;
144
+ fid: string | undefined;
145
+ }>;
146
+ peerHeldPaths(): string[];
147
+ holdCounts(): {
148
+ mine: number;
149
+ peers: number;
150
+ sent: number;
151
+ };
78
152
  private acked;
79
153
  private rebuild;
80
154
  prune(): Promise<void>;
@@ -87,3 +161,4 @@ export declare class RemoteWatch {
87
161
  emit(change: RemoteChange): void;
88
162
  listen(listener: RemoteListener): () => void;
89
163
  }
164
+ export {};
@@ -38,6 +38,7 @@ export interface NewOwner extends Owner {
38
38
  parents?: number;
39
39
  socket?: boolean;
40
40
  fifo?: boolean;
41
+ existing?: true;
41
42
  }
42
43
  export interface CopyOptions {
43
44
  exclusive: boolean;
@@ -94,6 +95,7 @@ export interface KernelFs {
94
95
  onPeer?(settle: () => Promise<void>): void;
95
96
  heldBy?(held: (dir: string) => readonly string[]): void;
96
97
  fileId?(path: string): Promise<string>;
98
+ bindId?(path: string): Promise<string | undefined>;
97
99
  remoteChanges?(listener: (change: {
98
100
  paths: readonly string[];
99
101
  trees?: readonly string[];
@@ -134,6 +136,48 @@ export interface KernelFs {
134
136
  };
135
137
  opfsOps?(): number;
136
138
  fileIdWrites?(): number;
139
+ announceHolds?(add: ReadonlyArray<[string, string | undefined]>, drop: readonly string[], wait: boolean): Promise<void>;
140
+ holdCounts?(): {
141
+ mine: number;
142
+ peers: number;
143
+ sent: number;
144
+ held: string[];
145
+ } | undefined;
146
+ rehold?(from: string, to: string): void;
147
+ peerKeeps?(): PeerKeeps | undefined;
148
+ servePeerKeeps?(instance: string, handlers: {
149
+ keeping(tab: string, paths: readonly string[]): Promise<void>;
150
+ kept(tab: string, items: ReadonlyArray<{
151
+ path: string;
152
+ hidden: string | undefined;
153
+ fid: string | undefined;
154
+ undo?: string;
155
+ }>, paths: readonly string[]): Promise<void>;
156
+ left(tab: string): void;
157
+ }): void;
158
+ }
159
+ export interface PeerKeeps {
160
+ shared(): boolean;
161
+ heldWithin(path: string): Array<{
162
+ tab: string;
163
+ path: string;
164
+ fid: string | undefined;
165
+ instance: string | undefined;
166
+ }>;
167
+ ask(to: string, body: {
168
+ keeping?: {
169
+ paths: string[];
170
+ };
171
+ kept?: {
172
+ items: Array<{
173
+ path: string;
174
+ hidden: string | undefined;
175
+ fid: string | undefined;
176
+ undo?: string;
177
+ }>;
178
+ paths?: string[];
179
+ };
180
+ }, cap: number): Promise<boolean>;
137
181
  }
138
182
  export interface PwriteOptions {
139
183
  create?: false;
@@ -1,4 +1,4 @@
1
- import { type KernelFs, type NewOwner } from './types.js';
1
+ import { type KernelFs, type NewOwner, type PeerKeeps } from './types.js';
2
2
  export declare const UNLINKED_DIR = ".slicc-unlinked";
3
3
  export interface Replacements {
4
4
  settled(path: string): Promise<void>;
@@ -50,6 +50,13 @@ export declare function pidOwner(proc: {
50
50
  kill(pid: number, signal: number): unknown;
51
51
  }): UnlinkOwner;
52
52
  export declare function webLocks(): UnlinkLocks | undefined;
53
+ export interface PeerKept {
54
+ whole: boolean;
55
+ undoing<T>(op: () => Promise<T>): Promise<T>;
56
+ }
57
+ export declare const PEER_RM_MS = 1000;
58
+ export declare const PEER_RENAME_MS = 10000;
59
+ export declare const PEER_GATE_MS: number;
53
60
  export declare class PathGate {
54
61
  private readonly tails;
55
62
  acquire(path: string): Promise<() => void>;
@@ -78,12 +85,14 @@ export declare class UnlinkedKeeper {
78
85
  private readonly links;
79
86
  private readonly linked;
80
87
  private readonly dirOwner;
88
+ private readonly peers;
81
89
  constructor(fs: KernelFs, holders: Iterable<UnlinkHolder>, rootOf: (path: string) => string, options?: {
82
90
  locks?: UnlinkLocks | undefined;
83
91
  busy?: (path: string) => boolean;
84
92
  owner?: UnlinkOwner | undefined;
85
93
  dirOwner?: NewOwner;
86
94
  marks?: PathMarks;
95
+ peers?: PeerKeeps | undefined;
87
96
  });
88
97
  private serial;
89
98
  wrap(fs?: KernelFs): KernelFs;
@@ -98,6 +107,17 @@ export declare class UnlinkedKeeper {
98
107
  pin(target: string, gated?: () => void, sealed?: () => void): Promise<Pinned>;
99
108
  private keepAside;
100
109
  private present;
110
+ get id(): string;
111
+ adopt(hidden: string, refs: number): KeptFile;
112
+ peerKeep(target: string, over: boolean, valid?: () => Promise<boolean>): Promise<PeerKept>;
113
+ private setAside;
114
+ private undoing;
115
+ removable(target: string, options?: {
116
+ recursive?: boolean;
117
+ }): Promise<boolean>;
118
+ renamable(source: string, target: string): Promise<boolean>;
119
+ private asideFor;
120
+ private hideFor;
101
121
  private keptFile;
102
122
  private hide;
103
123
  closed(path: string): void;
@@ -101,7 +101,8 @@ export interface SpawnWasmOptions {
101
101
  now: number;
102
102
  renames: Array<[string, string]>;
103
103
  };
104
- fileId?: (path: string) => Promise<string> | undefined;
104
+ fileId?: (path: string) => Promise<string | undefined> | undefined;
105
+ announceHold?: (path: string, fid: string | undefined, created: boolean) => Promise<void> | undefined;
105
106
  renameSeq?: (from: string, to: string) => number | undefined;
106
107
  mounts?: () => MountLine[];
107
108
  mount?: WasmProcessOptions['mount'];
@@ -56,6 +56,12 @@ export interface ProcessListing {
56
56
  cwdChecks?: number;
57
57
  staleFds?: number;
58
58
  fileIds?: number;
59
+ holds?: {
60
+ mine: number;
61
+ peers: number;
62
+ sent: number;
63
+ held?: readonly string[];
64
+ };
59
65
  renameAcks?: {
60
66
  acks: number;
61
67
  busy: number;
@@ -436,6 +436,11 @@ export declare class Launcher {
436
436
  fsFor(tag: string | undefined): KernelFs;
437
437
  isWriter(tags: readonly string[] | undefined, base?: number): boolean;
438
438
  private stackFor;
439
+ private readonly peerGates;
440
+ private peerOptions;
441
+ private peerKept;
442
+ private unadopt;
443
+ private adoptKept;
439
444
  private rootFileId;
440
445
  private flushingPeers;
441
446
  private rewritten;
@@ -51,10 +51,11 @@ interface Mount extends MountEntry {
51
51
  export declare function parseSize(text: string): number;
52
52
  export declare class HeldSet extends Set<HeldPaths> {
53
53
  private readonly idle;
54
- constructor(idle: (path: string) => void);
54
+ private readonly moved;
55
+ constructor(idle: (path: string) => void, moved?: (from: string, to: string) => void);
55
56
  add(holds: HeldPaths): this;
56
57
  doubt(paths: readonly string[], over?: string): void;
57
- bindIds(id: (path: string) => Promise<string> | undefined): Promise<void>;
58
+ bindIds(id: (path: string) => Promise<string | undefined> | undefined): Promise<void>;
58
59
  delete(holds: HeldPaths): boolean;
59
60
  }
60
61
  export declare function heldUnder(held: Iterable<Map<string, number>>, target: string): boolean;
@@ -72,6 +73,7 @@ export declare class HeldPaths extends Map<string, number> implements UnlinkHold
72
73
  private readonly doubted;
73
74
  private doubts;
74
75
  onIdle?: (path: string) => void;
76
+ onMoved?: (from: string, to: string) => void;
75
77
  keyOf(path: string): string;
76
78
  keptAt(path: string): KeptFile | undefined;
77
79
  holding(path: string): boolean;
@@ -84,13 +86,16 @@ export declare class HeldPaths extends Map<string, number> implements UnlinkHold
84
86
  fid?: string;
85
87
  doubt: number;
86
88
  } | undefined;
87
- bindIds(id: (path: string) => Promise<string> | undefined): Promise<void>;
89
+ bindIds(id: (path: string) => Promise<string | undefined> | undefined): Promise<void>;
88
90
  trust(handle: number, doubt: number): void;
89
91
  pathOf(handle: number): string | undefined;
90
92
  keptFor(handle: number): KeptFile | undefined;
91
93
  holdsHandle(handle: number): boolean;
92
94
  keeps(hidden: string): boolean;
95
+ boundAt(path: string, fid: string | undefined): number[];
96
+ keepBound(ids: readonly number[], path: string, file: KeptFile): void;
93
97
  keep(path: string, file: KeptFile): void;
98
+ unkeepAt(path: string, hidden: string): void;
94
99
  unkeep(path: string, file: KeptFile): void;
95
100
  private letGo;
96
101
  releaseAll(): void;
@@ -18,7 +18,8 @@ export interface SyncFsTokenEntry {
18
18
  fid?: string;
19
19
  doubt: number;
20
20
  } | undefined;
21
- fileId?: (path: string) => Promise<string> | undefined;
21
+ fileId?: (path: string) => Promise<string | undefined> | undefined;
22
+ announceHold?: (path: string, fid: string | undefined, created: boolean) => Promise<void> | undefined;
22
23
  trust?: (handle: number, doubt: number) => void;
23
24
  gate?: <T>(path: string, op: () => Promise<T>) => Promise<T>;
24
25
  unlinked?: (path: string) => KeptFile | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-kernel",
3
- "version": "1.160.3",
3
+ "version": "1.162.0",
4
4
  "description": "SLICC's wasm-realm kernel: run Emscripten programs in the browser against OPFS, with fork, spawn, pipes and waitpid",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "devDependencies": {
66
66
  "@ai-ecoverse/py-numpy": "2.5.4-4",
67
- "@ai-ecoverse/slicc-cdp": "1.41.6",
67
+ "@ai-ecoverse/slicc-cdp": "1.41.8",
68
68
  "@ai-ecoverse/slicc-node": "2.5.2",
69
69
  "@ai-ecoverse/slicc-scrub": "1.1.0",
70
70
  "@ai-ecoverse/slicc-shared-web": "2.12.1",