@ai-ecoverse/slicc-kernel 1.118.1 → 1.119.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.
@@ -30,6 +30,7 @@ export declare class OpfsFs implements KernelFs {
30
30
  private readonly mounts;
31
31
  private readonly locks;
32
32
  private readonly lockPrefix;
33
+ readonly rootName: string | undefined;
33
34
  constructor(root: FileSystemDirectoryHandle, meta?: MetaStore, channel?: string, options?: {
34
35
  ranged?: boolean;
35
36
  locks?: LockManagerLike | null;
@@ -76,6 +76,7 @@ export interface KernelFs {
76
76
  readlink(path: string): Promise<string>;
77
77
  realpath?(path: string, follow: boolean): Promise<string>;
78
78
  createExclusive?(path: string, owner?: NewOwner): Promise<void>;
79
+ readonly rootName?: string;
79
80
  chown?(path: string, change: OwnerChange): Promise<void>;
80
81
  trackOwners?(): void;
81
82
  crossings?(mounted: (path: string) => boolean): void;
@@ -1,5 +1,6 @@
1
1
  import type { SyncFsResult } from '../realm/sync-fs-wire.js';
2
- import { type FlockKind, type LockKind, type LockTable } from './locks.js';
2
+ import type { KernelLocks } from './lock-service.js';
3
+ import { type FlockKind, type LockKind } from './locks.js';
3
4
  export interface LockTarget {
4
5
  path?: string;
5
6
  fd?: number;
@@ -96,7 +97,7 @@ export interface HostOpsContext {
96
97
  key: string;
97
98
  owner: object;
98
99
  }>;
99
- locks: LockTable | undefined;
100
+ locks: KernelLocks | undefined;
100
101
  ops: AsyncOps;
101
102
  blocking: () => AbortSignal;
102
103
  valid: (req: {
@@ -10,7 +10,7 @@ import { type Cred } from './cred.js';
10
10
  import { type FdTable, type OpenFile } from './fd-table.js';
11
11
  import type { FifoTable } from './fifo.js';
12
12
  import type { JobTable } from './jobs.js';
13
- import type { LockTable } from './locks.js';
13
+ import type { KernelLocks } from './lock-service.js';
14
14
  import type { HttpHandles } from './net/http-syscalls.js';
15
15
  import type { Resolver } from './net/resolver.js';
16
16
  import type { MountLine, ProcessListing } from './proc-info.js';
@@ -85,7 +85,7 @@ export interface SpawnWasmOptions {
85
85
  ptys?: PtyTable;
86
86
  net?: LoopbackNet;
87
87
  http?: HttpHandles;
88
- locks?: LockTable;
88
+ locks?: KernelLocks;
89
89
  fifos?: FifoTable;
90
90
  sems?: SemTable;
91
91
  onReap?: (pid: number) => void;
@@ -0,0 +1,92 @@
1
+ import { type LockManagerLike } from '../fs/remote.js';
2
+ import { type FlockKind, type LockKind, type RecordLock } from './locks.js';
3
+ export declare const PRUNE_MS = 1000;
4
+ export declare const LOCKS_PROTOCOL = "v1";
5
+ type Range = {
6
+ start: number;
7
+ end: number;
8
+ };
9
+ type Want = {
10
+ key: string;
11
+ kind: LockKind;
12
+ } & Range;
13
+ export interface KernelLocks {
14
+ readonly flocks: {
15
+ set(key: string, owner: object, kind: FlockKind | 'unlock'): boolean | Promise<boolean>;
16
+ wait(key: string, owner: object, kind: FlockKind, blocking: () => AbortSignal): Promise<void>;
17
+ drop(owner: object): void;
18
+ };
19
+ holder(key: string, owner: number, want: Want): RecordLock | undefined | Promise<RecordLock | undefined>;
20
+ set(key: string, owner: number, kind: LockKind | 'unlock', start: number, end: number): boolean | Promise<boolean>;
21
+ wait(key: string, owner: number, kind: LockKind, range: Range, blocking: () => AbortSignal): Promise<void>;
22
+ holds(owner: number): boolean;
23
+ dropFile(key: string, owner: number): void;
24
+ release(pid: number): void;
25
+ lock(pid: number, path: string, exclusive: boolean, fd: number): boolean;
26
+ unlock(pid: number, path: string): void;
27
+ closed(pid: number, fd: number): void;
28
+ }
29
+ export interface LockServiceOptions {
30
+ root: string;
31
+ locks: LockManagerLike & {
32
+ request(name: string, options: {
33
+ ifAvailable: true;
34
+ }, cb: (lock: unknown) => Promise<void>): Promise<unknown>;
35
+ };
36
+ channel?: (name: string) => BroadcastChannel;
37
+ }
38
+ export declare class LockService implements KernelLocks {
39
+ readonly kernel: `${string}-${string}-${string}-${string}-${string}`;
40
+ private table;
41
+ private leader;
42
+ private readonly role;
43
+ private readonly channel;
44
+ private readonly locks;
45
+ private readonly root;
46
+ private readonly pending;
47
+ private next;
48
+ private readonly owners;
49
+ private readonly ownerOf;
50
+ private nextRemote;
51
+ private readonly tokens;
52
+ private readonly flockIds;
53
+ private readonly flockOwners;
54
+ private nextFlock;
55
+ private readonly granted;
56
+ private readonly waiting;
57
+ private settled;
58
+ private pruner;
59
+ readonly flocks: KernelLocks['flocks'];
60
+ constructor(options: LockServiceOptions);
61
+ private aliveOf;
62
+ private elect;
63
+ private lead;
64
+ private receive;
65
+ private answered;
66
+ private request;
67
+ private ownerFor;
68
+ private tokenFor;
69
+ private serve;
70
+ private signalOf;
71
+ private blockFor;
72
+ private watchRemotes;
73
+ prune(): Promise<void>;
74
+ private reassert;
75
+ private adopt;
76
+ private flockIdOf;
77
+ private ask;
78
+ holder(key: string, owner: number, want: Want): Promise<RecordLock | undefined>;
79
+ set(key: string, owner: number, kind: LockKind | 'unlock', start: number, end: number): Promise<boolean>;
80
+ wait(key: string, owner: number, kind: LockKind, range: Range, blocking: () => AbortSignal): Promise<void>;
81
+ holds(owner: number): boolean;
82
+ dropFile(key: string, owner: number): void;
83
+ release(pid: number): void;
84
+ private flockSet;
85
+ private flockWait;
86
+ private flockDrop;
87
+ lock(pid: number, path: string, exclusive: boolean, fd: number): boolean;
88
+ unlock(pid: number, path: string): void;
89
+ closed(pid: number, fd: number): void;
90
+ }
91
+ export declare function kernelLocks(root: string | undefined): KernelLocks;
92
+ export {};
@@ -23,6 +23,7 @@ export declare class FlockTable {
23
23
  private free;
24
24
  set(key: string, owner: object, kind: FlockKind | 'unlock'): boolean;
25
25
  wait(key: string, owner: object, kind: FlockKind, blocking: () => AbortSignal): Promise<void>;
26
+ entries(): Array<[string, object, FlockKind]>;
26
27
  drop(owner: object): void;
27
28
  }
28
29
  export declare class LockTable {
@@ -41,6 +42,7 @@ export declare class LockTable {
41
42
  private changed;
42
43
  private wake;
43
44
  private store;
45
+ entries(): Array<[string, RecordLock[]]>;
44
46
  holds(owner: number): boolean;
45
47
  dropFile(key: string, owner: number): void;
46
48
  lock(pid: number, path: string, exclusive: boolean, fd: number): boolean;
@@ -14,7 +14,7 @@ import { type DeviceAccess, type FdTable, type HeldMeta, type KernelFdKind, type
14
14
  import type { FifoTable } from './fifo.js';
15
15
  import { type HostSyscall } from './host-ops.js';
16
16
  import type { JobTable } from './jobs.js';
17
- import type { LockTable } from './locks.js';
17
+ import type { KernelLocks } from './lock-service.js';
18
18
  import { type HttpHandles, type HttpSyscall } from './net/http-syscalls.js';
19
19
  import { Resolver } from './net/resolver.js';
20
20
  import type { MountLine, ProcessListing } from './proc-info.js';
@@ -400,7 +400,7 @@ export interface WasmProcessOptions {
400
400
  ptys?: PtyTable;
401
401
  net?: LoopbackNet;
402
402
  http?: HttpHandles;
403
- locks?: LockTable;
403
+ locks?: KernelLocks;
404
404
  fifos?: FifoTable;
405
405
  sems?: SemTable;
406
406
  resolver?: Resolver;
@@ -24,6 +24,7 @@ export interface LockDeps {
24
24
  kernel: LockKernel;
25
25
  flush(): void;
26
26
  }
27
+ export declare const lockPromoters: WeakMap<object, () => (stream: ProcessStream) => void>;
27
28
  export declare function lockTarget(stream: ProcessStream): LockTarget | undefined;
28
29
  export declare function recordLock(fcntl: (fd: number, cmd: number, varargs: number) => number, deps: LockDeps): (fd: number, cmd: number, varargs: number) => number;
29
30
  export declare function closeDropsLocks(Fs: ProcessFs, kernel: LockKernel): void;
@@ -23,7 +23,7 @@ export interface LockHost {
23
23
  file(fd: number): LockedFile;
24
24
  flush(file: LockedFile): void;
25
25
  locked(): void;
26
- promote(fd: number): void;
26
+ promote(fd: number, moved?: boolean): void;
27
27
  calls: LockCalls;
28
28
  }
29
29
  export declare function lockImports(host: LockHost): Record<string, WasiFunction>;
@@ -77,7 +77,7 @@ export declare class WasiFds {
77
77
  dup(fd: number, min: number, cloexec: boolean): number;
78
78
  pipe(): [number, number];
79
79
  chdir(path: string): void;
80
- promote(fd: number): void;
80
+ promote(fd: number, moved?: boolean): void;
81
81
  promoteFiles(only?: FileBuffer): void;
82
82
  snapshot(): WasiForkFd[];
83
83
  restore(fds: readonly WasiForkFd[], cloexec: readonly number[]): void;
@@ -109,6 +109,7 @@ export declare class WasiFds {
109
109
  unlinking(path: string, linked?: SyncFsBridgeStat): void;
110
110
  unlinked(path: string, linked?: SyncFsBridgeStat): void;
111
111
  private openedIno;
112
+ moved(fd: number): boolean;
112
113
  private inoOf;
113
114
  private survives;
114
115
  private detach;
@@ -44,6 +44,7 @@ export declare class FileBuffer {
44
44
  export declare class LocalFile {
45
45
  offset: number;
46
46
  refs: number;
47
+ ino: number | undefined;
47
48
  readonly buffer: FileBuffer;
48
49
  readonly readable: boolean;
49
50
  readonly writable: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-kernel",
3
- "version": "1.118.1",
3
+ "version": "1.119.1",
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",