@bjornpagen/bumbledb 1.0.0 → 1.1.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 (102) hide show
  1. package/COOKBOOK.md +64 -27
  2. package/README.md +21 -20
  3. package/dist/capacity.d.ts +1 -1
  4. package/dist/changes.d.ts +4 -5
  5. package/dist/changes.d.ts.map +1 -1
  6. package/dist/changes.js +37 -34
  7. package/dist/changes.js.map +1 -1
  8. package/dist/close.d.ts +2 -2
  9. package/dist/codec.d.ts +5 -6
  10. package/dist/codec.d.ts.map +1 -1
  11. package/dist/codec.js +6 -6
  12. package/dist/codec.js.map +1 -1
  13. package/dist/compile.d.ts +4 -6
  14. package/dist/compile.d.ts.map +1 -1
  15. package/dist/compile.js +6 -6
  16. package/dist/compile.js.map +1 -1
  17. package/dist/db-native.d.ts +43 -56
  18. package/dist/db-native.d.ts.map +1 -1
  19. package/dist/db-native.js.map +1 -1
  20. package/dist/db.d.ts +43 -28
  21. package/dist/db.d.ts.map +1 -1
  22. package/dist/db.js +77 -63
  23. package/dist/db.js.map +1 -1
  24. package/dist/errors.d.ts +4 -8
  25. package/dist/errors.d.ts.map +1 -1
  26. package/dist/errors.js +4 -8
  27. package/dist/errors.js.map +1 -1
  28. package/dist/fields.d.ts +4 -5
  29. package/dist/fields.d.ts.map +1 -1
  30. package/dist/fields.js.map +1 -1
  31. package/dist/index.d.ts +4 -4
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +2 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/internal/log.d.ts +4 -4
  36. package/dist/internal/log.d.ts.map +1 -1
  37. package/dist/internal/log.js +1 -1
  38. package/dist/internal/log.js.map +1 -1
  39. package/dist/law.d.ts +1 -1
  40. package/dist/migration.d.ts +5 -7
  41. package/dist/migration.d.ts.map +1 -1
  42. package/dist/migration.js +8 -9
  43. package/dist/migration.js.map +1 -1
  44. package/dist/native.d.ts +2 -2
  45. package/dist/native.d.ts.map +1 -1
  46. package/dist/native.js.map +1 -1
  47. package/dist/query/lower.d.ts +1 -1
  48. package/dist/result.d.ts +10 -25
  49. package/dist/result.d.ts.map +1 -1
  50. package/dist/result.js +7 -12
  51. package/dist/result.js.map +1 -1
  52. package/dist/rows.d.ts +10 -16
  53. package/dist/rows.d.ts.map +1 -1
  54. package/dist/rows.js +8 -45
  55. package/dist/rows.js.map +1 -1
  56. package/dist/runtime-codes.d.ts +1 -1
  57. package/dist/runtime-codes.d.ts.map +1 -1
  58. package/dist/runtime-codes.js +1 -2
  59. package/dist/runtime-codes.js.map +1 -1
  60. package/dist/runtime-errors.d.ts +3 -15
  61. package/dist/runtime-errors.d.ts.map +1 -1
  62. package/dist/runtime-errors.js +1 -5
  63. package/dist/runtime-errors.js.map +1 -1
  64. package/dist/runtime-native.d.ts +18 -48
  65. package/dist/runtime-native.d.ts.map +1 -1
  66. package/dist/runtime-native.js.map +1 -1
  67. package/dist/runtime.d.ts +12 -29
  68. package/dist/runtime.d.ts.map +1 -1
  69. package/dist/runtime.js +16 -57
  70. package/dist/runtime.js.map +1 -1
  71. package/dist/shape.d.ts +3 -4
  72. package/dist/shape.d.ts.map +1 -1
  73. package/dist/spec.d.ts +2 -2
  74. package/dist/spec.js +1 -1
  75. package/dist/statements.js +2 -2
  76. package/dist/statements.js.map +1 -1
  77. package/pack-provenance.json +3 -3
  78. package/package.json +4 -4
  79. package/src/capacity.ts +1 -1
  80. package/src/changes.ts +50 -48
  81. package/src/close.ts +2 -2
  82. package/src/codec.ts +8 -24
  83. package/src/compile.ts +8 -10
  84. package/src/db-native.ts +37 -83
  85. package/src/db.ts +156 -135
  86. package/src/errors.ts +4 -8
  87. package/src/fields.ts +4 -5
  88. package/src/index.ts +6 -5
  89. package/src/internal/log.ts +2 -7
  90. package/src/law.ts +1 -1
  91. package/src/migration.ts +8 -16
  92. package/src/native.ts +2 -3
  93. package/src/query/lower.ts +1 -1
  94. package/src/result.ts +16 -45
  95. package/src/rows.ts +12 -65
  96. package/src/runtime-codes.ts +1 -2
  97. package/src/runtime-errors.ts +1 -5
  98. package/src/runtime-native.ts +15 -68
  99. package/src/runtime.ts +53 -122
  100. package/src/shape.ts +3 -4
  101. package/src/spec.ts +2 -2
  102. package/src/statements.ts +2 -2
package/src/migration.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  /**
2
- * Private log-migration integration entrypoints (C11): the two read-only
2
+ * Private log-migration integration entrypoints: the two read-only
3
3
  * native migration-codec verbs the `@bjornpagen/bumbledb-log/migrations`
4
- * generator consumes literally (recorded contract in
5
- * implementation/packets/P10.md), wired over the P06 executor onto P09's
6
- * native `schema_file`/`migration::plan`/`migration::manifest` lanes.
4
+ * generator imports, wired over the shared executor onto the native
5
+ * `schema_file`, `migration::plan` and `migration::manifest` modules.
7
6
  *
8
7
  * Both follow `hashChunk`'s shape: bounded owned input, bounded owned JSON
9
8
  * response bytes, ONE registered cancellable operation under the acquired
@@ -15,8 +14,7 @@
15
14
  */
16
15
  import { Effect } from "effect"
17
16
  import { dbNative } from "#db-native.ts"
18
- import type { ExecutionPolicy } from "#runtime.ts"
19
- import { nativeOperationWith, policyWire, runtimeHandle } from "#runtime.ts"
17
+ import { nativeOperationWith, runtimeHandle } from "#runtime.ts"
20
18
  import { DbError, dbError } from "#runtime-errors.ts"
21
19
  import type { SchemaSpec } from "#spec.ts"
22
20
 
@@ -32,14 +30,11 @@ function owned(operation: string, value: Uint8Array | null): Uint8Array {
32
30
  * spec natively and yields bounded JSON bytes carrying the canonical
33
31
  * `schemaId` and the rendered schema snapshot.
34
32
  */
35
- const internalMigrationSchema = Effect.fn("internalMigrationSchema")(function* (
36
- spec: SchemaSpec,
37
- work: ExecutionPolicy
38
- ) {
33
+ const internalMigrationSchema = Effect.fn("internalMigrationSchema")(function* (spec: SchemaSpec) {
39
34
  const runtime = yield* runtimeHandle()
40
35
  return yield* nativeOperationWith(
41
36
  "internalMigrationSchema",
42
- (callback) => dbNative.runtimeMigrationSchema(runtime, policyWire(work, "internalMigrationSchema"), spec, callback),
37
+ (callback) => dbNative.runtimeMigrationSchema(runtime, spec, callback),
43
38
  dbNative.runtimeBytesTake,
44
39
  (bytes) => owned("internalMigrationSchema", bytes)
45
40
  )
@@ -50,17 +45,14 @@ const internalMigrationSchema = Effect.fn("internalMigrationSchema")(function* (
50
45
  * render/digest, manifest verify/append preview, plan-set digests): owned
51
46
  * JSON request bytes in, owned JSON response bytes out.
52
47
  */
53
- const internalMigrationRead = Effect.fn("internalMigrationRead")(function* (
54
- request: Uint8Array,
55
- work: ExecutionPolicy
56
- ) {
48
+ const internalMigrationRead = Effect.fn("internalMigrationRead")(function* (request: Uint8Array) {
57
49
  if (!(request instanceof Uint8Array) || !(request.buffer instanceof ArrayBuffer)) {
58
50
  return yield* Effect.fail(new DbError({ operation: "internalMigrationRead", reason: { _tag: "InvalidArgument" } }))
59
51
  }
60
52
  const runtime = yield* runtimeHandle()
61
53
  return yield* nativeOperationWith(
62
54
  "internalMigrationRead",
63
- (callback) => dbNative.runtimeMigrationRead(runtime, policyWire(work, "internalMigrationRead"), request, callback),
55
+ (callback) => dbNative.runtimeMigrationRead(runtime, request, callback),
64
56
  dbNative.runtimeBytesTake,
65
57
  (bytes) => owned("internalMigrationRead", bytes)
66
58
  )
package/src/native.ts CHANGED
@@ -38,7 +38,7 @@ interface F64IntervalValue {
38
38
 
39
39
  /**
40
40
  * One marshalled cell. An application-owned Uuid crosses as its
41
- * canonical hyphenated UUID string (chapter 32); there is no fresh
41
+ * canonical hyphenated UUID string; there is no fresh
42
42
  * range, reservation counter or issuance value anywhere on this wire.
43
43
  */
44
44
  type FactValue = boolean | bigint | number | string | Uint8Array | IntervalValue | F64IntervalValue
@@ -438,7 +438,7 @@ type Violation =
438
438
  // #runtime-native.ts (accepted | rejected | refused); reads, writes and
439
439
  // queries are worker-affine session verbs there too. The historical
440
440
  // raw-pointer `dbRead`/`dbWrite`/`tx*`/`instance*`/`prepared*` synchronous
441
- // surface — a JS callback inside a native transaction — is deleted (P06),
441
+ // surface — a JS callback inside a native transaction — is deleted,
442
442
  // as are the fresh/reserve issuance verbs (`WireFreshRange`).
443
443
 
444
444
  type ErrorFamilyKind =
@@ -461,7 +461,6 @@ type ErrorFamilyKind =
461
461
  | "foreignWitness"
462
462
  | "param"
463
463
  | "capacityRayMeasure"
464
- | "derivedBudgetExceeded"
465
464
  | "overflow"
466
465
  | "scalar"
467
466
  | "resultBytesOverflow"
@@ -166,7 +166,7 @@ interface QueryRuleScope<Rels extends SchemaRelations, Classes extends SchemaCla
166
166
  ): QueryRuleChain<Rels, BindParamsShape<MatchFields<R>, B>, Classes>
167
167
 
168
168
  /**
169
- * Nonrecursive composition (chapter 34): a typed query template of the
169
+ * Nonrecursive composition: a typed query template of the
170
170
  * SAME schema is a relation expression — its whole body splices as a
171
171
  * derived stage; every head column must be bound to a variable minted
172
172
  * by `v(imported)`. Naming materializes nothing.
package/src/result.ts CHANGED
@@ -5,31 +5,22 @@ import { dbNative } from "#db-native.ts"
5
5
  import type { FindColumn } from "#query/atom.ts"
6
6
  import { decodeAnswers } from "#query/run.ts"
7
7
  import type { CellValue } from "#rows.ts"
8
- import type { ExecutionPolicy } from "#runtime.ts"
9
- import { deliveryResultBytes, nativeOperationWith, policyWire } from "#runtime.ts"
8
+ import { nativeOperationWith } from "#runtime.ts"
10
9
  import type { CloseReport, DbError } from "#runtime-errors.ts"
11
10
 
12
11
  /**
13
- * `CompleteResult<A>` — the sealed owner of one COMPLETED query answer
14
- * (C05): published only after all evaluation/finalization succeeded,
15
- * possibly backed by temporary LMDB scratch. Owned and independent of its
16
- * source snapshot/session.
12
+ * One complete answer set, sealed after evaluation and independent of its
13
+ * source snapshot. collect() explicitly materializes all rows into JS and
14
+ * leaves the result available. pages() consumes it once through bounded
15
+ * delivery batches; it does not stream query execution.
17
16
  *
18
- * `collect` materializes a bounded owned array and leaves the result
19
- * available; it refuses (`ResourceLimit`) before allocating past
20
- * `maxBytes`, and a cap failure leaves the sealed backing available for
21
- * `pages`. `pages` is chapter 35's ONE-SHOT consuming stream over the
22
- * completed result: its first execution atomically spends the result and
23
- * moves the backing storage into a private cursor owned by the stream's
24
- * scope — construction alone spends nothing, a second run fails
25
- * `SpentHandle`, and a run after the result's scope closed fails
26
- * `ClosedHandle`. Early take, downstream failure and interruption all
27
- * close/drain the private cursor; EOF cleanup is identical. There is no
28
- * public cursor, `next`, AsyncIterable, clone or second streaming API.
17
+ * The stream owns its cursor through Effect scope. Early termination,
18
+ * failure, interruption and EOF close/drain it. Creating the stream does
19
+ * not spend the result; running it twice fails with SpentHandle.
29
20
  */
30
21
  interface CompleteResult<A> {
31
- collect(options: { readonly maxBytes: bigint }, work: ExecutionPolicy): Effect.Effect<ReadonlyArray<A>, DbError>
32
- pages(options: { readonly pageBytes: bigint }, work: ExecutionPolicy): Stream.Stream<ReadonlyArray<A>, DbError>
22
+ collect(): Effect.Effect<ReadonlyArray<A>, DbError>
23
+ pages(): Stream.Stream<ReadonlyArray<A>, DbError>
33
24
  close(): Effect.Effect<CloseReport>
34
25
  }
35
26
 
@@ -52,42 +43,27 @@ function decodePage<A>(finds: readonly FindColumn[], rows: readonly (readonly Ce
52
43
 
53
44
  /**
54
45
  * Internal constructor: `db.ts` publishes results through this after
55
- * execution completes. Delivery (`collect`/`pages`) starts a fresh bounded
56
- * operation under the caller's delivery policy — never the completed query's
57
- * expired execution deadline.
46
+ * execution completes. Each delivery has independent cooperative cancellation.
58
47
  */
59
48
  function makeCompleteResult<A>(handle: ResultHandle, finds: readonly FindColumn[]): CompleteResult<A> {
60
- function deliveryWire(operation: string, delivery: ExecutionPolicy, requested: bigint) {
61
- return policyWire({ ...delivery, resultBytes: deliveryResultBytes(requested, delivery) }, operation)
62
- }
63
49
  const value: CompleteResult<A> = {
64
- collect(options, work) {
50
+ collect() {
65
51
  return Effect.suspend(() =>
66
52
  nativeOperationWith(
67
53
  "CompleteResult.collect",
68
- (callback) =>
69
- dbNative.runtimeResultCollect(
70
- handle,
71
- deliveryWire("CompleteResult.collect", work, options.maxBytes),
72
- callback
73
- ),
54
+ (callback) => dbNative.runtimeResultCollect(handle, callback),
74
55
  dbNative.runtimeRowsTake,
75
56
  (rows) => decodePage<A>(finds, rows)
76
57
  )
77
58
  )
78
59
  },
79
- pages(options, work) {
60
+ pages() {
80
61
  return Stream.unwrap(
81
62
  Effect.gen(function* () {
82
63
  const cursor: CursorHandle = yield* Effect.acquireRelease(
83
64
  nativeOperationWith(
84
65
  "CompleteResult.pages",
85
- (callback) =>
86
- dbNative.runtimeResultCursor(
87
- handle,
88
- deliveryWire("CompleteResult.pages", work, options.pageBytes),
89
- callback
90
- ),
66
+ (callback) => dbNative.runtimeResultCursor(handle, callback),
91
67
  dbNative.runtimeCursorTake,
92
68
  (taken) => taken
93
69
  ),
@@ -97,12 +73,7 @@ function makeCompleteResult<A>(handle: ResultHandle, finds: readonly FindColumn[
97
73
  return Stream.paginate(undefined, () =>
98
74
  nativeOperationWith(
99
75
  "CompleteResult.page",
100
- (callback) =>
101
- dbNative.runtimeCursorNext(
102
- cursor,
103
- deliveryWire("CompleteResult.page", work, options.pageBytes),
104
- callback
105
- ),
76
+ (callback) => dbNative.runtimeCursorNext(cursor, callback),
106
77
  dbNative.runtimePageTake,
107
78
  (page) => page
108
79
  ).pipe(
package/src/rows.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { AuthoringError, SdkInvariantError } from "#errors.ts"
2
2
  /**
3
- * The successor row codec: fact object ⇄ positional cell array by field
3
+ * The row codec: fact object ⇄ positional cell array by field
4
4
  * ordinal, schema-directed, in ONE place. The write side lowers named host
5
5
  * objects to rows in the relation's field-declaration order (declaration
6
6
  * order = ordinal ids); the read side decodes owned rows back to named
7
7
  * objects of BARE structural values. This module is the one fact⇄row
8
- * projector. It covers the COMPLETE successor value roster: bool, u64, i64,
8
+ * projector. It covers all value types: bool, u64, i64,
9
9
  * f64, uuid, str, bytes<N>, discrete intervals and dense float intervals,
10
10
  * plus the closed-handle bijection (name ⇄ declaration-order row id).
11
11
  *
@@ -14,20 +14,17 @@ import { AuthoringError, SdkInvariantError } from "#errors.ts"
14
14
  * the pure {@link AuthoringError}; the Effect ingestion boundary catches
15
15
  * and types it (never an untracked partial draft). SharedArrayBuffer-backed
16
16
  * views are refused before any copy. Host length is judged before string
17
- * scans and byte copies (TS-004).
17
+ * scans and byte copies.
18
18
  */
19
19
  import type { AnyClosedRoster, AnyField } from "#fields.ts"
20
20
  import { isFloatIntervalValue, isIntervalValue, literalShapeError, rosterOf } from "#fields.ts"
21
21
  import type { AnyRelation, Fact, RelationData } from "#relation.ts"
22
22
  import { Uuid } from "#uuid.ts"
23
23
 
24
- /** Converter-granularity host cell wall (64 KiB). One oversize cell refuses. */
25
- const HOST_CELL_MAX = 65536n
26
-
27
24
  /**
28
25
  * One owned cell at the private bridge boundary. The declared sealed field
29
26
  * type disambiguates the union: `string` is text, an `uuid` in its
30
- * canonical hyphenated UUID spelling (chapter 35), or a closed handle
27
+ * canonical hyphenated UUID spelling, or a closed handle
31
28
  * before lowering (closed handles cross as `bigint` row ids),
32
29
  * `Uint8Array` is `bytes<N>`, `{ start, end }` bigints are a discrete
33
30
  * interval and numbers a dense float interval.
@@ -44,8 +41,6 @@ type CellValue =
44
41
  interface FlatRows {
45
42
  readonly rows: bigint
46
43
  readonly cells: readonly CellValue[]
47
- /** Conservative charged byte size of the owned cells (input accounting). */
48
- readonly bytes: bigint
49
44
  }
50
45
 
51
46
  function recordOf(fact: object): Readonly<Record<string, unknown>> {
@@ -64,8 +59,8 @@ function refuseShared(context: string, value: Uint8Array): void {
64
59
  }
65
60
 
66
61
  /**
67
- * Cheap host charge before any string scan or byte copy (TS-004). UTF-16
68
- * code units × 2 upper-bounds UTF-8; byte views charge their length.
62
+ * Approximate payload size for host batching, not a memory allowance.
63
+ * Strings use two bytes per UTF-16 code unit, not their UTF-8 wire size.
69
64
  */
70
65
  function hostCellCharge(value: unknown): bigint {
71
66
  if (typeof value === "string") {
@@ -86,16 +81,6 @@ function hostCellCharge(value: unknown): bigint {
86
81
  return 0n
87
82
  }
88
83
 
89
- function assertHostCellFits(context: string, value: unknown, limit: bigint): bigint {
90
- const charge = hostCellCharge(value)
91
- if (charge > limit) {
92
- throw new AuthoringError({
93
- message: `${context}: host cell of ${charge} bytes exceeds the ${limit}-byte converter bound — refuse before copy or scan`
94
- })
95
- }
96
- return charge
97
- }
98
-
99
84
  /**
100
85
  * The write half of the closed bijection: one handle NAME to its u64 row
101
86
  * id (declaration order = row ids). An unknown name is a pointed refusal
@@ -124,26 +109,6 @@ function handleOf(context: string, closed: AnyClosedRoster, cell: unknown): stri
124
109
  return handle
125
110
  }
126
111
 
127
- /** Conservative owned-byte charge of one cell (host accounting, not wire). */
128
- function cellBytes(cell: CellValue): bigint {
129
- if (typeof cell === "boolean") {
130
- return 1n
131
- }
132
- if (typeof cell === "bigint" || typeof cell === "number") {
133
- return 8n
134
- }
135
- if (typeof cell === "string") {
136
- // UTF-16 code units × 2 is a cheap safe upper bound before exact
137
- // UTF-8 conversion is charged natively (chapter 35: reject oversize
138
- // cells with cheap length bounds before costly conversion).
139
- return BigInt(cell.length) * 2n
140
- }
141
- if (cell instanceof Uint8Array) {
142
- return BigInt(cell.byteLength)
143
- }
144
- return 16n
145
- }
146
-
147
112
  function cellOf(context: string, field: AnyField, value: unknown): CellValue {
148
113
  const roster = rosterOf(field)
149
114
  if (roster !== undefined) {
@@ -170,7 +135,6 @@ function cellOf(context: string, field: AnyField, value: unknown): CellValue {
170
135
  if (typeof value !== "string") {
171
136
  throw literalShapeError(context, "string", value)
172
137
  }
173
- assertHostCellFits(context, value, HOST_CELL_MAX)
174
138
  if (!value.isWellFormed()) {
175
139
  throw literalShapeError(context, "well-formed string", value)
176
140
  }
@@ -186,9 +150,7 @@ function cellOf(context: string, field: AnyField, value: unknown): CellValue {
186
150
  if (!Uuid.isUuid(value)) {
187
151
  throw literalShapeError(context, "a UUID (canonical UUID text)", value)
188
152
  }
189
- // Chapter 35: uuid crosses the bridge as the canonical
190
- // canonical hyphenated UUID STRING (the native marshal's spelling),
191
- // never as sixteen raw bytes.
153
+ // UUIDs cross as canonical hyphenated text, not raw bytes.
192
154
  return value
193
155
  }
194
156
  case "bytes": {
@@ -196,7 +158,6 @@ function cellOf(context: string, field: AnyField, value: unknown): CellValue {
196
158
  throw literalShapeError(context, "Uint8Array", value)
197
159
  }
198
160
  refuseShared(context, value)
199
- assertHostCellFits(context, value, HOST_CELL_MAX)
200
161
  if (value.byteLength !== field.width) {
201
162
  throw new AuthoringError({
202
163
  message: `${context}: bytes<${field.width}> takes exactly ${field.width} bytes (got ${value.byteLength})`
@@ -233,14 +194,13 @@ function cellOf(context: string, field: AnyField, value: unknown): CellValue {
233
194
 
234
195
  /**
235
196
  * The flat projector: every fact's cells land in ONE row-major cell array
236
- * (length rows × arity) with the row count and charged byte size counted
237
- * while projecting. Missing-field refusal and per-cell judgment are
197
+ * (length rows × arity), counting rows while projecting.
198
+ * Missing-field refusal and per-cell judgment are
238
199
  * {@link cellOf}'s, byte for byte.
239
200
  */
240
201
  function flatRowsOf(data: RelationData, facts: Iterable<object>): FlatRows {
241
202
  const cells: CellValue[] = []
242
203
  let rows = 0n
243
- let bytes = 0n
244
204
  for (const fact of facts) {
245
205
  rows += 1n
246
206
  const record = recordOf(fact)
@@ -250,11 +210,10 @@ function flatRowsOf(data: RelationData, facts: Iterable<object>): FlatRows {
250
210
  throw new AuthoringError({ message: `relation ${data.name}: fact is missing field ${declared.name}` })
251
211
  }
252
212
  const cell = cellOf(`relation ${data.name} field ${declared.name}`, declared.field, value)
253
- bytes += cellBytes(cell)
254
213
  cells.push(cell)
255
214
  }
256
215
  }
257
- return { rows, cells, bytes }
216
+ return { rows, cells }
258
217
  }
259
218
 
260
219
  function keyCellsOf(
@@ -362,8 +321,7 @@ function isCompleteFact<R extends AnyRelation>(
362
321
 
363
322
  /**
364
323
  * The read half: one owned positional row into a plain frozen record in
365
- * declared field order — the SAME fields and shapes on every row (chapter
366
- * 35's stable row shape rule; no Proxy, no per-cell closures).
324
+ * declared field order: stable field names and shapes, no Proxy or per-cell closures.
367
325
  */
368
326
  function factOfCells<R extends AnyRelation>(relation: R, row: readonly unknown[]): Fact<R> {
369
327
  const data = relation.data
@@ -390,15 +348,4 @@ function factOfCells<R extends AnyRelation>(relation: R, row: readonly unknown[]
390
348
  }
391
349
 
392
350
  export type { CellValue, FlatRows }
393
- export {
394
- assertHostCellFits,
395
- cellBytes,
396
- cellOf,
397
- decodeCell,
398
- factOfCells,
399
- flatRowsOf,
400
- handleOf,
401
- hostCellCharge,
402
- keyCellsOf,
403
- recordOf
404
- }
351
+ export { cellOf, decodeCell, factOfCells, flatRowsOf, handleOf, hostCellCharge, keyCellsOf, recordOf }
@@ -13,6 +13,5 @@ export const runtimeErrorCodes = [
13
13
  "Io",
14
14
  "ResourceLimit",
15
15
  "Engine",
16
- "Cancelled",
17
- "DeadlineExceeded"
16
+ "Cancelled"
18
17
  ] as const
@@ -49,11 +49,7 @@ const Outstanding = Schema.Struct({
49
49
  retained: Schema.BigInt,
50
50
  owners: Schema.BigInt,
51
51
  databases: Schema.BigInt,
52
- natives: Schema.BigInt,
53
- inputBytes: Schema.BigInt,
54
- workingBytes: Schema.BigInt,
55
- scratchBytes: Schema.BigInt,
56
- resultBytes: Schema.BigInt
52
+ natives: Schema.BigInt
57
53
  })
58
54
  export type OutstandingWork = typeof Outstanding.Type
59
55
  const Close = Schema.Union([
@@ -33,20 +33,11 @@ export interface RepositoryLockHandle {
33
33
  readonly __repositoryLock: unique symbol
34
34
  }
35
35
 
36
- /** F0 C7 kind roster for worker-table resources. */
37
- export type NativeKind = "snapshot" | "result" | "cursor" | "draft" | "changes" | "repository-lock"
38
-
39
- /** Worker-routed capability header (C7). Never holds payload bytes. */
40
- export interface ResourceHeader {
41
- readonly runtime: bigint
42
- readonly worker: number
43
- readonly kind: NativeKind
44
- readonly id: bigint
45
- readonly generation: bigint
46
- }
36
+ /** Resource kinds installed in native worker tables. */
37
+ export type NativeKind = "snapshot" | "prepared" | "result" | "cursor" | "draft" | "changes" | "repository-lock"
47
38
 
48
39
  /**
49
- * Checked capability into the native registry (C7). JS tokens validate
40
+ * Checked capability into the native registry. JS tokens validate
50
41
  * these five fields; native re-judges kind/generation/owner on every verb.
51
42
  */
52
43
  export interface Capability {
@@ -57,11 +48,6 @@ export interface Capability {
57
48
  readonly generation: bigint
58
49
  }
59
50
 
60
- /** Coalesced close obligation — already-owned drain, not rejectable work. */
61
- export interface CloseDrain {
62
- readonly header: ResourceHeader
63
- }
64
-
65
51
  export type ManagedDbOutcome =
66
52
  | { readonly tag: "accepted"; readonly db: DbHandle }
67
53
  | { readonly tag: "rejected"; readonly violations: readonly Violation[] }
@@ -71,12 +57,6 @@ export type ManagedDbOutcome =
71
57
  readonly message: string
72
58
  }
73
59
 
74
- // The 0.x five-verb JS filesystem transport (`runtimeFs`/`runtimeFsTake`,
75
- // FsRequestWire/FsResultWire) is DELETED with the TS CAS authority: all
76
- // object-store work is native (C07, P05's store rewrite); the log machine
77
- // drives FsStore/S3Store inside `ts/crate` and no JS layer holds a
78
- // conditional-store verb anymore.
79
-
80
60
  export type LogTakeWire =
81
61
  | { readonly ok: false; readonly kind: LogCommandKind | LogChainKind; readonly message: string }
82
62
  | {
@@ -116,28 +96,13 @@ export type LogTakeWire =
116
96
  readonly digest: Uint8Array
117
97
  }
118
98
 
119
- export interface PolicyWire {
120
- readonly inputBytes: bigint
121
- readonly workingBytes: bigint
122
- readonly scratchBytes: bigint
123
- readonly resultBytes: bigint
124
- readonly rows: bigint
125
- readonly workUnits: bigint
126
- readonly timeoutMs: number
127
- }
128
-
129
99
  export interface OptionsWire {
130
- readonly workers: number
131
- readonly queueCapacity: number
132
- readonly cleanupCapacity: number
133
- readonly ownerCapacity: number
134
- readonly nativeHandleCapacity: number
135
- readonly inputBytes: bigint
136
- readonly workingBytes: bigint
137
- readonly scratchBytes: bigint
138
- readonly resultBytes: bigint
139
- readonly chunkBytes: bigint
140
- readonly cleanupTimeoutMs: number
100
+ readonly workers?: number | undefined
101
+ readonly queueCapacity?: number | undefined
102
+ readonly cleanupCapacity?: number | undefined
103
+ readonly ownerCapacity?: number | undefined
104
+ readonly nativeHandleCapacity?: number | undefined
105
+ readonly cleanupTimeoutMs?: number | undefined
141
106
  }
142
107
 
143
108
  export interface InspectionWire {
@@ -148,10 +113,6 @@ export interface InspectionWire {
148
113
  readonly owners: bigint
149
114
  readonly databases: bigint
150
115
  readonly natives: bigint
151
- readonly inputBytes: bigint
152
- readonly workingBytes: bigint
153
- readonly scratchBytes: bigint
154
- readonly resultBytes: bigint
155
116
  }
156
117
 
157
118
  export type CloseWire =
@@ -162,8 +123,8 @@ export type CloseWire =
162
123
  interface RuntimeNative {
163
124
  runtimeErrorCodes(): readonly string[]
164
125
  runtimeOpen(options: OptionsWire): RuntimeHandle
165
- runtimeReady(runtime: RuntimeHandle, policy: PolicyWire, callback: () => void): OperationHandle
166
- runtimeHash(runtime: RuntimeHandle, policy: PolicyWire, bytes: Uint8Array, callback: () => void): OperationHandle
126
+ runtimeReady(runtime: RuntimeHandle, callback: () => void): OperationHandle
127
+ runtimeHash(runtime: RuntimeHandle, bytes: Uint8Array, callback: () => void): OperationHandle
167
128
  runtimeTake(operation: OperationHandle): Uint8Array | null
168
129
  runtimeCancel(operation: OperationHandle, callback: (report: CloseWire) => void): void
169
130
  runtimeClose(runtime: RuntimeHandle, callback: (report: CloseWire) => void): void
@@ -176,20 +137,14 @@ interface RuntimeNative {
176
137
  * Predelivery: no JS take; cursor stays on row1 so retry does not skip.
177
138
  */
178
139
  runtimeArmPublicationCancel(runtime: RuntimeHandle): void
179
- runtimeDirectoryAcquire(
180
- runtime: RuntimeHandle,
181
- policy: PolicyWire,
182
- path: string,
183
- callback: () => void
184
- ): OperationHandle
140
+ runtimeDirectoryAcquire(runtime: RuntimeHandle, path: string, callback: () => void): OperationHandle
185
141
  runtimeDirectoryTake(operation: OperationHandle): DirectoryHandle
186
- runtimeDirectoryBegin(owner: DirectoryHandle, policy: PolicyWire): OperationHandle
142
+ runtimeDirectoryBegin(owner: DirectoryHandle): OperationHandle
187
143
  runtimeDirectoryCheck(operation: OperationHandle): void
188
144
  runtimeDirectoryEnd(operation: OperationHandle): void
189
145
  runtimeDirectoryClose(owner: DirectoryHandle, remove: boolean, callback: (report: CloseWire) => void): void
190
146
  runtimeDirectoryDbOpen(
191
147
  owner: DirectoryHandle,
192
- policy: PolicyWire,
193
148
  childName: string,
194
149
  spec: SchemaSpec,
195
150
  create: boolean,
@@ -198,12 +153,11 @@ interface RuntimeNative {
198
153
  runtimeDbTake(operation: OperationHandle): ManagedDbOutcome
199
154
  runtimeManagedDbClose(db: DbHandle, callback: (report: CloseWire) => void): void
200
155
 
201
- // --- successor log grammar on the executor (charged hashing over
156
+ // --- successor log grammar on the executor (hashing over
202
157
  // whole canonical change payloads; C06 through C09) ---
203
158
  runtimeLogCommandSeal(
204
159
  runtime: RuntimeHandle,
205
160
  schema: LogSchemaHandle,
206
- policy: PolicyWire,
207
161
  metadata: LogCommandMetadata,
208
162
  changes: Uint8Array,
209
163
  result: Uint8Array | null,
@@ -213,14 +167,12 @@ interface RuntimeNative {
213
167
  runtimeLogCommandParse(
214
168
  runtime: RuntimeHandle,
215
169
  schema: LogSchemaHandle,
216
- policy: PolicyWire,
217
170
  bytes: Uint8Array,
218
171
  limits: LogLimits,
219
172
  callback: () => void
220
173
  ): OperationHandle
221
174
  runtimeLogDecisionDecode(
222
175
  runtime: RuntimeHandle,
223
- policy: PolicyWire,
224
176
  bytes: Uint8Array,
225
177
  parent: LogDecisionStamp | null,
226
178
  limits: LogLimits,
@@ -228,12 +180,7 @@ interface RuntimeNative {
228
180
  ): OperationHandle
229
181
  runtimeLogTake(operation: OperationHandle): LogTakeWire
230
182
  /** L14 mint: `Runtime::mint_repository_lock` stamps `NativeKind::RepositoryLock` at take. */
231
- logRepositoryLockAcquire(
232
- runtime: RuntimeHandle,
233
- policy: PolicyWire,
234
- directory: string,
235
- callback: () => void
236
- ): OperationHandle
183
+ logRepositoryLockAcquire(runtime: RuntimeHandle, directory: string, callback: () => void): OperationHandle
237
184
  logRepositoryLockTake(operation: OperationHandle): RepositoryLockHandle
238
185
  logRepositoryLockRelease(owner: RepositoryLockHandle, callback: (report: CloseWire) => void): void
239
186
  }