@nimbus-sh/platform 0.8.2 → 0.13.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.
Files changed (67) hide show
  1. package/dist/composition.d.ts +3 -2
  2. package/dist/composition.d.ts.map +1 -1
  3. package/dist/composition.js +34 -19
  4. package/dist/crc32.d.ts +5 -5
  5. package/dist/crc32.d.ts.map +1 -1
  6. package/dist/crc32.js +8 -12
  7. package/dist/diag-counters.d.ts +18 -10
  8. package/dist/diag-counters.d.ts.map +1 -1
  9. package/dist/diag-counters.js +7 -20
  10. package/dist/heap-estimate.d.ts +5 -20
  11. package/dist/heap-estimate.d.ts.map +1 -1
  12. package/dist/heap-estimate.js +6 -33
  13. package/dist/heavy-alloc-coord.d.ts +131 -11
  14. package/dist/heavy-alloc-coord.d.ts.map +1 -1
  15. package/dist/heavy-alloc-coord.js +241 -22
  16. package/dist/hex.d.ts +20 -0
  17. package/dist/hex.d.ts.map +1 -0
  18. package/dist/hex.js +29 -0
  19. package/dist/install-phase.d.ts +1 -15
  20. package/dist/install-phase.d.ts.map +1 -1
  21. package/dist/lexical-path.d.ts +11 -0
  22. package/dist/lexical-path.d.ts.map +1 -0
  23. package/dist/lexical-path.js +19 -0
  24. package/dist/limits.d.ts +4 -0
  25. package/dist/limits.d.ts.map +1 -1
  26. package/dist/limits.js +25 -0
  27. package/dist/module-source.d.ts.map +1 -1
  28. package/dist/module-source.js +2 -1
  29. package/dist/oom-classify.d.ts +4 -0
  30. package/dist/oom-classify.d.ts.map +1 -1
  31. package/dist/oom-classify.js +6 -0
  32. package/dist/realm-builtin.d.ts +2 -0
  33. package/dist/realm-builtin.d.ts.map +1 -0
  34. package/dist/realm-builtin.js +11 -0
  35. package/dist/utf8.d.ts +13 -1
  36. package/dist/utf8.d.ts.map +1 -1
  37. package/dist/utf8.js +67 -1
  38. package/dist/w7-frame.d.ts +47 -13
  39. package/dist/w7-frame.d.ts.map +1 -1
  40. package/dist/w7-frame.js +42 -24
  41. package/dist/wave-writer.d.ts +11 -6
  42. package/dist/wave-writer.d.ts.map +1 -1
  43. package/dist/wave-writer.js +28 -29
  44. package/dist/weighted-credit-pool.d.ts +43 -0
  45. package/dist/weighted-credit-pool.d.ts.map +1 -1
  46. package/dist/weighted-credit-pool.js +250 -46
  47. package/dist/worker-code.d.ts +48 -0
  48. package/dist/worker-code.d.ts.map +1 -0
  49. package/dist/worker-code.js +10 -0
  50. package/package.json +1 -1
  51. package/src/composition.ts +41 -21
  52. package/src/crc32.ts +9 -12
  53. package/src/diag-counters.ts +23 -22
  54. package/src/heap-estimate.ts +11 -40
  55. package/src/heavy-alloc-coord.ts +275 -20
  56. package/src/hex.ts +29 -0
  57. package/src/install-phase.ts +1 -15
  58. package/src/lexical-path.ts +17 -0
  59. package/src/limits.ts +29 -0
  60. package/src/module-source.ts +3 -1
  61. package/src/oom-classify.ts +8 -0
  62. package/src/realm-builtin.ts +22 -0
  63. package/src/utf8.ts +69 -1
  64. package/src/w7-frame.ts +74 -33
  65. package/src/wave-writer.ts +28 -27
  66. package/src/weighted-credit-pool.ts +256 -51
  67. package/src/worker-code.ts +38 -0
package/dist/utf8.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /**
2
- * utf8.ts — the UTF-8 length of a string, without encoding it.
2
+ * utf8.ts — the UTF-8 length of a string, and the order of two strings by
3
+ * their UTF-8 bytes, without encoding them.
3
4
  *
4
5
  * Bounds on names and payloads are in bytes, and the hot ones (every path a
5
6
  * W7 wave or a listing page carries) were measured by encoding the string
@@ -7,7 +8,14 @@
7
8
  * TextEncoder would write: one to four per code point, and three for a
8
9
  * lone surrogate, which it writes as U+FFFD.
9
10
  */
11
+ /** From this many UTF-16 units, a string is counted natively (longUtf8Length). */
12
+ const LONG_UNITS = 256;
13
+ const encoder = new TextEncoder();
14
+ /** Where longUtf8Length's encodes land: written, never read. */
15
+ let scratch;
10
16
  export function utf8Length(text) {
17
+ if (text.length >= LONG_UNITS)
18
+ return longUtf8Length(text);
11
19
  let bytes = text.length;
12
20
  for (let index = 0; index < text.length; index++) {
13
21
  const unit = text.charCodeAt(index);
@@ -33,3 +41,61 @@ export function utf8Length(text) {
33
41
  }
34
42
  return bytes;
35
43
  }
44
+ /**
45
+ * A long string's UTF-8 length at the engine's speed: encoded a slice at a
46
+ * time into one reused buffer, only the count kept. encodeInto never splits
47
+ * a surrogate pair, so each slice starts on a code point.
48
+ */
49
+ function longUtf8Length(text) {
50
+ scratch ??= new Uint8Array(256 * 1024);
51
+ let bytes = 0;
52
+ for (let read = 0; read < text.length;) {
53
+ const done = encoder.encodeInto(read === 0 ? text : text.slice(read), scratch);
54
+ read += done.read;
55
+ bytes += done.written;
56
+ }
57
+ return bytes;
58
+ }
59
+ /**
60
+ * The code point at `index` of `text`: a pair is one past U+FFFF, and a lone
61
+ * surrogate is its own (as WTF-8 writes it, between U+D7FF and U+E000).
62
+ */
63
+ function codePointAt(text, index) {
64
+ const unit = text.charCodeAt(index);
65
+ if (unit < 0xd800 || unit > 0xdbff || index + 1 >= text.length)
66
+ return unit;
67
+ const next = text.charCodeAt(index + 1);
68
+ return next >= 0xdc00 && next <= 0xdfff ? 0x10000 + ((unit - 0xd800) << 10) + (next - 0xdc00) : unit;
69
+ }
70
+ /**
71
+ * `a` against `b` (negative, 0, positive) as their UTF-8 bytes order them,
72
+ * as SQLite's `ORDER BY` of a text column and git's index do: code point
73
+ * order. A string UTF-8 cannot write (a lone surrogate) is ordered as WTF-8
74
+ * writes it, its surrogate a code point of its own: the order is total, as a
75
+ * listing's cursor needs, and decided at the first code point that differs,
76
+ * so a directory's entries follow it together. Units equal in both are
77
+ * passed as they are; two that differ, neither a surrogate, are their own
78
+ * code points; the rest, rare in a path, is surrogatesAt's.
79
+ */
80
+ export function compareUtf8(a, b) {
81
+ const n = Math.min(a.length, b.length);
82
+ for (let i = 0; i < n; i++) {
83
+ const x = a.charCodeAt(i);
84
+ const y = b.charCodeAt(i);
85
+ if (x === y)
86
+ continue;
87
+ if ((x < 0xd800 || x > 0xdfff) && (y < 0xd800 || y > 0xdfff))
88
+ return x - y;
89
+ return surrogatesAt(a, b, i);
90
+ }
91
+ return a.length - b.length;
92
+ }
93
+ /** compareUtf8 of `a` and `b`, equal before `i`, where they differ at `i` and one unit there is a surrogate. */
94
+ function surrogatesAt(a, b, i) {
95
+ // A low half after a high one the two share: the code points begin at the high one.
96
+ const before = i > 0 ? a.charCodeAt(i - 1) : 0;
97
+ const x = a.charCodeAt(i);
98
+ const y = b.charCodeAt(i);
99
+ const at = before >= 0xd800 && before <= 0xdbff && ((x >= 0xdc00 && x <= 0xdfff) || (y >= 0xdc00 && y <= 0xdfff)) ? i - 1 : i;
100
+ return codePointAt(a, at) - codePointAt(b, at);
101
+ }
@@ -65,12 +65,16 @@ export interface BatchWritePayload {
65
65
  */
66
66
  ops?: W7Op[];
67
67
  }
68
- /** One attribute change (setattr): the mode, the owner, or the times; what chmod, chown and utimes each make. */
68
+ /**
69
+ * One attribute change (setattr): the mode, the owner, or the times; what
70
+ * chmod, chown and utimes each make. An owner side that is null keeps what
71
+ * the file has when the change lands (chown's -1).
72
+ */
69
73
  export type W7Attrs = {
70
74
  mode: number;
71
75
  } | {
72
- uid: number;
73
- gid: number;
76
+ uid: number | null;
77
+ gid: number | null;
74
78
  } | {
75
79
  atime: number;
76
80
  mtime: number;
@@ -84,6 +88,18 @@ export type W7Attrs = {
84
88
  * nothing makes a missing parent. The program-order counterpart of the
85
89
  * syscall, where `file` and `directory` are a checkout's upserts.
86
90
  */
91
+ /** What a W7 open asks of its file, as open(2)'s O_ACCMODE: to read it, to write it, or both. */
92
+ export type W7OpenAccess = 'read' | 'write' | 'readwrite';
93
+ /** The rights an open's access grants its description: what a call through it may do. */
94
+ export declare function openAccessRights(access: W7OpenAccess): {
95
+ read: boolean;
96
+ write: boolean;
97
+ };
98
+ /** The permission bits an open asks of the file it reaches (4 read, 2 write): its access's, and write under `truncate`, as open(2)'s. */
99
+ export declare function openAccessMask(call: {
100
+ access: W7OpenAccess;
101
+ truncate?: true;
102
+ }): number;
87
103
  export type W7Call =
88
104
  /**
89
105
  * `ino`, on a call that makes a name (writeFile, appendFile, mkdir,
@@ -162,6 +178,18 @@ export type W7Call =
162
178
  target: string;
163
179
  ino?: number;
164
180
  }
181
+ /**
182
+ * copyfile as the session copies a file: the file \`from\` names (a link
183
+ * followed) to \`path\` (a link there followed, a file there replaced),
184
+ * by reference within one filesystem and by its bytes across, no byte of
185
+ * it in the wave. The copy's mode is a copy's there: a new file the
186
+ * source's less the umask, a file there its own.
187
+ */
188
+ | {
189
+ call: 'copyFile';
190
+ path: string;
191
+ from: string;
192
+ }
165
193
  /**
166
194
  * rm(1) as fs.rm makes it: a file or link unlinked, a directory with all
167
195
  * it holds when `recursive` (else EISDIR's refusal, as unlink's), and a
@@ -177,8 +205,8 @@ export type W7Call =
177
205
  | {
178
206
  call: 'lchown';
179
207
  path: string;
180
- uid: number;
181
- gid: number;
208
+ uid: number | null;
209
+ gid: number | null;
182
210
  }
183
211
  /** utimes of the link itself (lutimes). */
184
212
  | {
@@ -188,29 +216,35 @@ export type W7Call =
188
216
  mtime: number;
189
217
  }
190
218
  /**
191
- * open(2) of a file to write it (and to read it when `read`), as the
192
- * session's own open decides it: a name made (`create`, `mode` less
193
- * `umask`) or refused (EEXIST when `exclusive`, ENOENT without `create`,
194
- * EISDIR, EACCES for any access asked that the file's mode refuses),
219
+ * open(2) of a file with the access `access` asks, as O_ACCMODE does
220
+ * (W7OpenAccess), as the session's own open decides it: a name made
221
+ * (`create`, `mode` less `umask`) or refused (EEXIST when `exclusive`,
222
+ * ENOENT without `create`, EISDIR, EACCES for any access asked that the
223
+ * file's mode refuses, write too under `truncate`: openAccessMask),
195
224
  * emptied when `truncate`, a link at the name followed unless `nofollow`
196
225
  * (ELOOP). Its answer is the file's stat. With `description` (an id the
197
226
  * process chose), the session keeps the open description under it, its
198
- * access fixed now; the description's write, append and ftruncate calls
199
- * name it, and its `close` ends it. `ino`: the number a name it makes is
200
- * given (a delegation's, as a mkdir's).
227
+ * rights the access's (openAccessRights); the description's write, append
228
+ * and ftruncate calls name it, and its `close` ends it. `ino`: the number
229
+ * a name it makes is given (a delegation's, as a mkdir's). `fchmod`: the
230
+ * file it opened then given exactly this mode (fchmod(2), as libuv's
231
+ * copyfile narrows its destination before a byte reaches it), part of the
232
+ * open: refused (EPERM: another's file), the open is refused and keeps no
233
+ * description, so a write through it is EBADF.
201
234
  */
202
235
  | {
203
236
  call: 'open';
204
237
  path: string;
205
238
  mode: number;
239
+ access: W7OpenAccess;
206
240
  ino?: number;
207
241
  umask?: number;
208
- read?: true;
209
242
  create?: true;
210
243
  truncate?: true;
211
244
  exclusive?: true;
212
245
  nofollow?: true;
213
246
  description?: string;
247
+ fchmod?: number;
214
248
  }
215
249
  /** close(2) of the session's open description `description` (an `open` call's). */
216
250
  | {
@@ -1 +1 @@
1
- {"version":3,"file":"w7-frame.d.ts","sourceRoot":"","sources":["../src/w7-frame.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;AAE5D,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,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sB,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,CAAC,UAAU,CAAC,CA+C7F;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAkBtF;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,eAAe,CAAC,CA6C1B"}
package/dist/w7-frame.js CHANGED
@@ -15,6 +15,19 @@
15
15
  import { crc32 } from './crc32.js';
16
16
  import { CHUNK_SIZE } from './limits.js';
17
17
  import { utf8Length } from './utf8.js';
18
+ import { rootClampedSegments } from './lexical-path.js';
19
+ function isOpenAccess(value) {
20
+ return value === 'read' || value === 'write' || value === 'readwrite';
21
+ }
22
+ /** The rights an open's access grants its description: what a call through it may do. */
23
+ export function openAccessRights(access) {
24
+ return { read: access !== 'write', write: access !== 'read' };
25
+ }
26
+ /** The permission bits an open asks of the file it reaches (4 read, 2 write): its access's, and write under `truncate`, as open(2)'s. */
27
+ export function openAccessMask(call) {
28
+ const rights = openAccessRights(call.access);
29
+ return (rights.read ? 4 : 0) | (rights.write || call.truncate === true ? 2 : 0);
30
+ }
18
31
  export const W7_MAGIC = new Uint8Array([0x4e, 0x57, 0x37, 0x04]);
19
32
  /** v3's magic: decoded, never encoded, for the release that rolls v4 out. Delete with v3 decoding. */
20
33
  const W7_MAGIC_V3 = new Uint8Array([0x4e, 0x57, 0x37, 0x03]);
@@ -372,7 +385,7 @@ v3) {
372
385
  throw new Error(`w7-frame: unknown record tag ${envelope.tag}`);
373
386
  summary.pathCount++;
374
387
  summary.opCount++;
375
- const value = parseObject(payload, 'call', ['call', 'path'], ['mode', 'target', 'ino', 'size', 'existing', 'recursive', 'force', 'uid', 'gid', 'atime', 'mtime', 'umask', 'read', 'create', 'truncate', 'exclusive', 'nofollow', 'description']);
388
+ const value = parseObject(payload, 'call', ['call', 'path'], ['mode', 'target', 'from', 'ino', 'size', 'existing', 'recursive', 'force', 'uid', 'gid', 'atime', 'mtime', 'umask', 'access', 'create', 'truncate', 'exclusive', 'nofollow', 'description', 'fchmod']);
376
389
  yield { type: 'call', call: parsePathCall(value, (path, label) => ownedPaths.claim(canonicalPath(path, label))) };
377
390
  break;
378
391
  }
@@ -513,8 +526,8 @@ async function* encodeFile(file, state) {
513
526
  let fileCheck = 0;
514
527
  let chunkId = 0;
515
528
  const pieces = file.source === null ? givenChunks(file.chunks) : fixedChunks(file.inode, file.source);
529
+ const contentBytes = TEXT_ENCODER.encode(file.contentId);
516
530
  for await (const data of pieces) {
517
- const contentBytes = new TextEncoder().encode(file.contentId);
518
531
  const prefix = new Uint8Array(4 + contentBytes.length + 8);
519
532
  writeU32LE(prefix, 0, contentBytes.length);
520
533
  prefix.set(contentBytes, 4);
@@ -573,16 +586,20 @@ async function* fixedChunks(inode, source) {
573
586
  }
574
587
  }
575
588
  function encodeMetadataRecord(tag, value, state) {
576
- const payload = new TextEncoder().encode(JSON.stringify(value));
589
+ const payload = TEXT_ENCODER.encode(JSON.stringify(value));
577
590
  if (payload.byteLength > MAX_METADATA_BYTES) {
578
591
  throw new Error(`w7-frame: metadata record exceeds ${MAX_METADATA_BYTES} bytes`);
579
592
  }
580
- const header = recordHeader(tag, payload.byteLength);
593
+ // The header and the payload in one buffer, checked as one (crc32 composes).
594
+ const record = new Uint8Array(5 + payload.byteLength);
595
+ record[0] = tag;
596
+ writeU32LE(record, 1, payload.byteLength);
597
+ record.set(payload, 5);
581
598
  if (state && tag !== RecordTag.BatchEnd) {
582
- state.batchCheck = updateRecordCheck(state.batchCheck, header, payload);
599
+ state.batchCheck = updateRecordCheck(state.batchCheck, record);
583
600
  state.summary.recordCount++;
584
601
  }
585
- return [concatBytes(header, payload)];
602
+ return [record];
586
603
  }
587
604
  /**
588
605
  * The payload's operations in the order they are encoded: its `ops` as
@@ -728,7 +745,7 @@ function parseAttrs(value, label) {
728
745
  if (keys === 'mode')
729
746
  return { mode: u32(value.mode, `${label} mode`) };
730
747
  if (keys === 'gid,uid')
731
- return { uid: u32(value.uid, `${label} uid`), gid: u32(value.gid, `${label} gid`) };
748
+ return { uid: ownerId(value.uid, `${label} uid`), gid: ownerId(value.gid, `${label} gid`) };
732
749
  if (keys === 'atime,mtime')
733
750
  return { atime: safeInteger(value.atime, `${label} atime`), mtime: safeInteger(value.mtime, `${label} mtime`) };
734
751
  throw new Error(`w7-frame: ${label} changes the mode, the owner or the times, one of them: got ${keys || 'nothing'}`);
@@ -815,6 +832,10 @@ function parsePathCall(value, path) {
815
832
  call: 'symlink', path: path(value.path, 'symlink path'), target: boundedString(value.target, 'symlink target', MAX_PATH_BYTES),
816
833
  ...(value.ino === undefined ? {} : { ino: inodeNumber(value.ino, 'symlink ino') }),
817
834
  };
835
+ case 'copyFile':
836
+ if (keys !== 'call,from,path')
837
+ break;
838
+ return { call: 'copyFile', path: path(value.path, 'copyFile path'), from: path(value.from, 'copyFile from') };
818
839
  case 'ftruncate':
819
840
  if (keys.replace(',description', '').replace(',ino', '') !== 'call,path,size')
820
841
  break;
@@ -843,28 +864,31 @@ function parsePathCall(value, path) {
843
864
  case 'lchown':
844
865
  if (keys !== 'call,gid,path,uid')
845
866
  break;
846
- return { call: 'lchown', path: path(value.path, 'lchown path'), uid: u32(value.uid, 'lchown uid'), gid: u32(value.gid, 'lchown gid') };
867
+ return { call: 'lchown', path: path(value.path, 'lchown path'), uid: ownerId(value.uid, 'lchown uid'), gid: ownerId(value.gid, 'lchown gid') };
847
868
  case 'open': {
848
- const flags = ['create', 'exclusive', 'nofollow', 'read', 'truncate'];
869
+ const flags = ['create', 'exclusive', 'nofollow', 'truncate'];
849
870
  let required = keys;
850
- for (const flag of ['create', 'description', 'exclusive', 'ino', 'nofollow', 'read', 'truncate', 'umask'])
871
+ for (const flag of ['create', 'description', 'exclusive', 'fchmod', 'ino', 'nofollow', 'truncate', 'umask'])
851
872
  required = required.replace(`,${flag}`, '');
852
- if (required !== 'call,mode,path')
873
+ if (required !== 'access,call,mode,path')
853
874
  break;
854
875
  for (const flag of flags) {
855
876
  if (value[flag] !== undefined && value[flag] !== true)
856
877
  throw new Error(`w7-frame: open ${flag} is true or absent`);
857
878
  }
879
+ const access = value.access;
880
+ if (!isOpenAccess(access))
881
+ throw new Error(`w7-frame: open access is 'read', 'write' or 'readwrite': got ${String(access)}`);
858
882
  return {
859
- call: 'open', path: path(value.path, 'open path'), mode: u32(value.mode, 'open mode'),
883
+ call: 'open', path: path(value.path, 'open path'), mode: u32(value.mode, 'open mode'), access,
860
884
  ...(value.ino === undefined ? {} : { ino: inodeNumber(value.ino, 'open ino') }),
861
885
  ...(value.umask === undefined ? {} : { umask: umaskOf(value.umask, 'open umask') }),
862
886
  ...(value.create === true ? { create: true } : {}),
863
887
  ...(value.truncate === true ? { truncate: true } : {}),
864
888
  ...(value.exclusive === true ? { exclusive: true } : {}),
865
889
  ...(value.nofollow === true ? { nofollow: true } : {}),
866
- ...(value.read === true ? { read: true } : {}),
867
890
  ...(value.description === undefined ? {} : { description: descriptionId(value.description, 'open description') }),
891
+ ...(value.fchmod === undefined ? {} : { fchmod: u32(value.fchmod, 'open fchmod') }),
868
892
  };
869
893
  }
870
894
  case 'lutimes':
@@ -1092,17 +1116,7 @@ class PathOwnership {
1092
1116
  }
1093
1117
  }
1094
1118
  function normalizePath(path) {
1095
- const out = [];
1096
- for (const segment of path.split('/')) {
1097
- if (segment === '..') {
1098
- if (out.length > 0)
1099
- out.pop();
1100
- }
1101
- else if (segment !== '' && segment !== '.') {
1102
- out.push(segment);
1103
- }
1104
- }
1105
- return out.join('/');
1119
+ return rootClampedSegments(path).join('/');
1106
1120
  }
1107
1121
  function parentPath(path) {
1108
1122
  const index = path.lastIndexOf('/');
@@ -1122,6 +1136,10 @@ function safeInteger(value, label) {
1122
1136
  }
1123
1137
  return value;
1124
1138
  }
1139
+ /** A chown side: a uid or gid, or null, which keeps the file's. */
1140
+ function ownerId(value, label) {
1141
+ return value === null ? null : u32(value, label);
1142
+ }
1125
1143
  function u32(value, label) {
1126
1144
  const integer = safeInteger(value, label);
1127
1145
  if (integer > 0xffff_ffff)
@@ -133,7 +133,7 @@ export interface WaveWriterOptions<Meta = undefined> {
133
133
  root: string | null;
134
134
  /** An existing worktree: only directories strictly below it are published. */
135
135
  worktreeRoot?: string | null;
136
- /** Record paths are relative to it (joined with '/'); omitted, they are VFS paths. */
136
+ /** Record paths are relative to it (joined with '/'; '' is the base itself); omitted, they are VFS paths. */
137
137
  base?: string;
138
138
  /** Wall-clock time (ms) after which no new wave starts. */
139
139
  deadline?: number | null;
@@ -192,7 +192,6 @@ export declare class WaveWriter<Meta = undefined> {
192
192
  private ownedPathBytes;
193
193
  private pin;
194
194
  private inFlight;
195
- private cutQueue;
196
195
  private sequence;
197
196
  private failure;
198
197
  /** Owners (records' `meta`) whose records a failed wave carried. */
@@ -277,7 +276,13 @@ export declare class WaveWriter<Meta = undefined> {
277
276
  private tally;
278
277
  private hasBuffered;
279
278
  private ownPath;
280
- /** collectDirectoryPaths' chain from `path` upward, to the first directory already owned. */
279
+ /**
280
+ * The directories a wave publishes for something at or below `dir`:
281
+ * `dir` and each one above it, deepest first, up to the writer's root
282
+ * (included) and inside its worktree root.
283
+ */
284
+ private chain;
285
+ /** The chain from `path` upward, to the first directory already owned. */
281
286
  private walkChain;
282
287
  /**
283
288
  * Send what is buffered when a removal of `path` is pending in it: a wave
@@ -292,11 +297,11 @@ export declare class WaveWriter<Meta = undefined> {
292
297
  private drop;
293
298
  private cutIfFull;
294
299
  /**
295
- * Send the buffered wave once the one in flight has published. Cuts are
296
- * serialised, so at most one wave is in flight and one buffers.
300
+ * Send the buffered wave once the one in flight has published. Only a
301
+ * mutation cuts, and mutations run one at a time, so at most one wave is
302
+ * in flight and one buffers.
297
303
  */
298
304
  private cut;
299
- private cutNow;
300
305
  /**
301
306
  * How a wave of `bytes` content crosses: an attempt's stream, made anew
302
307
  * for each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,CAAC;IAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAA;CAAO,GACxI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBxB;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC,CAElF;AAkHD,wBAAgB,gBAAgB,CAAC,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAErG"}
@@ -145,7 +145,6 @@ export class WaveWriter {
145
145
  ownedPathBytes = 0;
146
146
  pin = null;
147
147
  inFlight = null;
148
- cutQueue = Promise.resolve();
149
148
  sequence = 0;
150
149
  failure = null;
151
150
  /** Owners (records' `meta`) whose records a failed wave carried. */
@@ -355,7 +354,9 @@ export class WaveWriter {
355
354
  }
356
355
  // ── Internals ────────────────────────────────────────────────────────
357
356
  key(path) {
358
- return this.options.base ? this.options.base + '/' + path : path;
357
+ if (!this.options.base)
358
+ return path;
359
+ return path ? this.options.base + '/' + path : this.options.base;
359
360
  }
360
361
  tally() {
361
362
  return { pathCount: this.owned.size, pathBytes: this.ownedPathBytes };
@@ -372,15 +373,26 @@ export class WaveWriter {
372
373
  if (admit)
373
374
  this.owned.add(path);
374
375
  }
375
- /** collectDirectoryPaths' chain from `path` upward, to the first directory already owned. */
376
- walkChain(path, admit, tally) {
376
+ /**
377
+ * The directories a wave publishes for something at or below `dir`:
378
+ * `dir` and each one above it, deepest first, up to the writer's root
379
+ * (included) and inside its worktree root.
380
+ */
381
+ *chain(dir) {
377
382
  const { root, worktreeRoot = null } = this.options;
378
- let current = path;
379
- while (current) {
383
+ for (let current = dir; current; current = parentOf(current)) {
380
384
  if (root && current !== root && !current.startsWith(root + '/'))
381
- break;
385
+ return;
382
386
  if (worktreeRoot !== null && !current.startsWith(worktreeRoot + '/'))
383
- break;
387
+ return;
388
+ yield current;
389
+ if (current === root)
390
+ return;
391
+ }
392
+ }
393
+ /** The chain from `path` upward, to the first directory already owned. */
394
+ walkChain(path, admit, tally) {
395
+ for (const current of this.chain(path)) {
384
396
  this.counters.ownershipVisits++;
385
397
  if (this.ownedDirectories.has(current))
386
398
  break;
@@ -392,9 +404,6 @@ export class WaveWriter {
392
404
  if (admit)
393
405
  this.owned.add(current);
394
406
  }
395
- if (current === root)
396
- break;
397
- current = parentOf(current);
398
407
  }
399
408
  }
400
409
  /**
@@ -467,15 +476,14 @@ export class WaveWriter {
467
476
  }
468
477
  }
469
478
  /**
470
- * Send the buffered wave once the one in flight has published. Cuts are
471
- * serialised, so at most one wave is in flight and one buffers.
479
+ * Send the buffered wave once the one in flight has published. Only a
480
+ * mutation cuts, and mutations run one at a time, so at most one wave is
481
+ * in flight and one buffers.
472
482
  */
473
- cut() {
474
- const run = this.cutQueue.then(() => this.cutNow());
475
- this.cutQueue = run.catch(() => { });
476
- return run;
477
- }
478
- async cutNow() {
483
+ async cut() {
484
+ // A later turn than the mutation that asks: a pin set or cleared by a
485
+ // microtask queued before the cut is the wave's.
486
+ await Promise.resolve();
479
487
  if (this.inFlight) {
480
488
  const waitStarted = Date.now();
481
489
  await this.inFlight.catch(() => { });
@@ -686,20 +694,11 @@ export class WaveWriter {
686
694
  /** The directories the buffered records publish, shallowest first. */
687
695
  publishedDirectories() {
688
696
  const dirs = new Set();
689
- const { root, worktreeRoot = null } = this.options;
690
697
  const collect = (path) => {
691
- let current = path;
692
- while (current) {
693
- if (root && current !== root && !current.startsWith(root + '/'))
694
- break;
695
- if (worktreeRoot !== null && !current.startsWith(worktreeRoot + '/'))
696
- break;
698
+ for (const current of this.chain(path)) {
697
699
  if (dirs.has(current))
698
700
  break;
699
701
  dirs.add(current);
700
- if (current === root)
701
- break;
702
- current = parentOf(current);
703
702
  }
704
703
  };
705
704
  for (const path of this.records.keys())
@@ -4,6 +4,11 @@ export interface CreditLease {
4
4
  }
5
5
  export interface ResizableCreditLease extends CreditLease {
6
6
  shrinkTo(bytes: number): void;
7
+ /**
8
+ * Holds `bytes` in all if the rest can be granted now, in its own lane, as
9
+ * tryAcquire would grant it; else holds what it held and answers false.
10
+ */
11
+ tryGrowTo(bytes: number): boolean;
7
12
  }
8
13
  export interface WeightedCreditPoolStats {
9
14
  readonly current: number;
@@ -23,6 +28,26 @@ export interface WeightedCreditPoolOptions {
23
28
  */
24
29
  readonly reserve?: number;
25
30
  }
31
+ /**
32
+ * How long a waiter woken to its turn keeps it for its own continuation to
33
+ * take the credit. workerd cancels the continuations of a request that has
34
+ * completed or been canceled when another request's code resolves its
35
+ * promise (the cross-request promise rule, on by date since 2024-10-14), so
36
+ * a waiter whose request is gone is woken and never takes: its turn lapses
37
+ * and the next waiter's comes. A live continuation takes it in far less.
38
+ */
39
+ export declare const CREDIT_TURN_MS = 1000;
40
+ /**
41
+ * A place in a lane's queue. `woken` resolves when its turn comes; `take`,
42
+ * called from the waiter's own continuation, holds the credit then, or
43
+ * answers null when the turn lapsed, the credit no longer fits, or it was
44
+ * aborted, and the place waits again. `leave` gives up the place.
45
+ */
46
+ export interface CreditTurn {
47
+ woken(): Promise<void>;
48
+ take(): ResizableCreditLease | null;
49
+ leave(): void;
50
+ }
26
51
  /**
27
52
  * FIFO byte-credit pool shared by concurrent allocation owners.
28
53
  * Capacity is measured in retained bytes, not operation count.
@@ -55,6 +80,24 @@ export declare class WeightedCreditPool {
55
80
  get stats(): WeightedCreditPoolStats;
56
81
  private isSmall;
57
82
  tryAcquire(bytes: number): ResizableCreditLease | null;
83
+ /**
84
+ * A running program's ask (SupervisorAllocationBudget.acquireRunning),
85
+ * ahead of every ordinary ask: granted now if it fits beside what is held,
86
+ * whatever is queued (a small one in its reserve too), or else as soon as
87
+ * it fits in the shared capacity, the credit running work and reclaims
88
+ * free. It never waits on the reserve, which neither frees.
89
+ */
90
+ acquireAhead(bytes: number, signal?: AbortSignal): Promise<ResizableCreditLease>;
91
+ /** Whether a running program's ask (acquireAhead) waits for credit no woken turn is taking (CreditLane.aheadStarved). */
92
+ get aheadStarved(): boolean;
93
+ /** acquireAhead's credit now, or null. */
94
+ tryAcquireAhead(bytes: number): ResizableCreditLease | null;
95
+ /**
96
+ * A place in line for `bytes`, in the lane it would wait in, for a caller
97
+ * that takes its turn itself (CreditTurn): what acquire does once nothing
98
+ * is free.
99
+ */
100
+ queue(bytes: number, signal?: AbortSignal): CreditTurn;
58
101
  acquire(bytes: number, signal?: AbortSignal): Promise<ResizableCreditLease>;
59
102
  private validateRequest;
60
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"weighted-credit-pool.d.ts","sourceRoot":"","sources":["../src/weighted-credit-pool.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAkHD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,kBAAkB;IAKjB,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAJrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C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