toilscript 0.1.41 → 0.1.43

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,7 +1,7 @@
1
1
  {
2
2
  "imports": {
3
- "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.41/dist/toilscript.js",
4
- "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.41/dist/cli.js",
3
+ "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.43/dist/toilscript.js",
4
+ "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.43/dist/cli.js",
5
5
  "binaryen": "https://cdn.jsdelivr.net/npm/binaryen@130.0.0-nightly.20260609/index.js",
6
6
  "long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
7
7
  }
@@ -607,7 +607,8 @@ declare module "types:toilscript/src/diagnosticMessages.generated" {
607
607
  Scheduled_requires_a_single_string_schedule_argument = 9010,
608
608
  Scheduled_spec_0_is_not_a_valid_interval_or_cron_expression = 9011,
609
609
  Scheduled_handler_0_must_take_no_arguments_and_return_void = 9012,
610
- Stream_scope_must_be_a_StreamScope_enum_member = 9013
610
+ Stream_scope_must_be_a_StreamScope_enum_member = 9013,
611
+ Stream_connect_handler_0_has_an_invalid_signature = 9014
611
612
  }
612
613
  /** Translates a diagnostic code to its respective string. */
613
614
  export function diagnosticCodeToString(code: DiagnosticCode): string;
@@ -2989,6 +2990,8 @@ declare module "types:toilscript/src/parser" {
2989
2990
  toildbCodecClasses: Map<string, ClassDeclaration>;
2990
2991
  /** Guards `weaveDataMigrations` so it runs exactly once (before element creation). */
2991
2992
  toildbWoven: boolean;
2993
+ /** Guards `weaveDeriveHandlers` so the module-level `derive_run` export is emitted once. */
2994
+ toildbDerivesWoven: boolean;
2992
2995
  /** Current overridden module name. */
2993
2996
  currentModuleName: string | null;
2994
2997
  /** Compiler options. */
@@ -3011,6 +3014,12 @@ declare module "types:toilscript/src/parser" {
3011
3014
  getDependee(dependent: string): string | null;
3012
3015
  /** Finishes parsing. */
3013
3016
  finish(): void;
3017
+ /** Synthesize the hot/default module-level `derive_run(derive_id)` export for
3018
+ * `@database` classes with `@derive` methods. Runs before element creation
3019
+ * from `initializeProgram`, so generated members/exports are compiled as
3020
+ * ordinary program symbols. Cold artifacts intentionally do not export
3021
+ * request-path derive runners and do not emit `toildb.derives`. */
3022
+ weaveDeriveHandlers(): void;
3014
3023
  weaveDataMigrations(): void;
3015
3024
  /** Enforce the migration-file convention (folder AND extension): every `@migrate`
3016
3025
  * must live in a `*.migration.ts` file under a `migrations/` directory. Keeping
@@ -3184,6 +3193,25 @@ declare module "types:toilscript/src/parser" {
3184
3193
  * shape; gating already rejects a hook outside a `@stream`.
3185
3194
  */
3186
3195
  private injectStreamHandler;
3196
+ /** True if `node` is a non-nullable named type whose identifier is exactly `name`
3197
+ * (e.g. a `StreamPacket` parameter or a `StreamOutbound` return on a raw @message). */
3198
+ private isNamedType;
3199
+ /**
3200
+ * The injected stream ring runtime (spec 05 sections 5-6; byte layouts in 10), emitted once per
3201
+ * program under the `stream_dispatch` export gate. Provides two fixed 128 KiB rings in linear
3202
+ * memory (ingress host->guest, egress guest->host), each a 32-byte `RingControl` + frame region,
3203
+ * exported via `stream_ring_offset/capacity` + `stream_egress_offset/capacity` (the host reads
3204
+ * these at box build, stamps both RingControls, and owns the ingress write_cursor / egress
3205
+ * read_cursor; the guest owns the ingress read_cursor / egress write_cursor - SPSC on the one
3206
+ * resident-box thread). `StreamPacket` drains ONE ingress `RingFrame` (raw @message arg);
3207
+ * `StreamOutbound.reply` stages ONE DATA_RELIABLE frame into the egress ring (bounds-checked ->
3208
+ * `0x0205`); `__encode` lowers to the packed i64 (0 for accept/empty/reply; `-(0x10000 + 0x02xx)`
3209
+ * for a reject, normalized to `0x0208`). The `.d.ts` declares these for the editor only (not
3210
+ * compile-loaded); these injected `@global` classes are the real impls, like `AuthUser`.
3211
+ * RingControl(32B): u32 magic|u16 version|u16 flags|u32 capacity|u32 write|u32 read|u32 dropped|2xu32.
3212
+ * RingFrame(12B): u8 version|u8 type|u16 flags|u32 length|u32 msg_seq|payload.
3213
+ */
3214
+ private streamRuntimeSource;
3187
3215
  /** True if a function signature takes no parameters and returns `void` (the
3188
3216
  * required `@scheduled` handler shape, spec 03 section 3.5). A missing or
3189
3217
  * non-`void`-named return type, or any parameter, is false. */
@@ -4458,8 +4486,8 @@ declare module "types:toilscript/src/dbcatalog" {
4458
4486
  * toildb's `SchemaDescriptor::layout_hash` (the runtime side): the algorithm,
4459
4487
  * the `seen` add/remove, and the declaration-order traversal are pinned in lock
4460
4488
  * step. A FLAT type (no field whose type is in `typeMap`) hashes to the SAME
4461
- * value as the old flat hash, so existing pinned vectors stay green; an absent
4462
- * `typeMap` (undefined) is flat/back-compatible.
4489
+ * value as the flat hash; an absent `typeMap` (undefined) is treated as a flat
4490
+ * descriptor.
4463
4491
  *
4464
4492
  * `typeMap` MUST contain the SAME set of `@data` types as the runtime's
4465
4493
  * `toildb.types` registry (collection value types + their nested types, EXCLUDING
@@ -4574,6 +4602,23 @@ declare module "types:toilscript/src/dbcatalog" {
4574
4602
  * missing/non-string arg or an unparseable spec.
4575
4603
  */
4576
4604
  export function buildToilDaemonCatalog(program: Program): Uint8Array | null;
4605
+ /** Build the `toildb.derives` section bytes, or `null` if no `@database` class
4606
+ * declares a `@derive` materializer. The section wires each `@derive` method to
4607
+ * the database class that owns it, so the host runner can, after a write to one
4608
+ * of a database's source collections, re-run that database's derives (each
4609
+ * recomputes + `view.publish`es its materialized view). `derive_id` is assigned
4610
+ * globally in source-declaration order across every `@database` class, matching
4611
+ * the single module-level `derive_run(derive_id)` dispatcher synthesized by the
4612
+ * parser 1:1. Format (LE):
4613
+ *
4614
+ * u16 format_version = 1
4615
+ * u16 n_derives
4616
+ * per derive:
4617
+ * u16 derive_id (global declaration order in the hot/default module)
4618
+ * str db_name (the @database class name; the write -> derive key)
4619
+ * str method_name (the @derive method, for diagnostics)
4620
+ */
4621
+ export function buildToilDbDerives(program: Program): Uint8Array | null;
4577
4622
  /** Build the `toil.surface` section bytes (always emitted per artifact). Per
4578
4623
  * Part 5 (LE):
4579
4624
  *
@@ -4587,22 +4632,21 @@ declare module "types:toilscript/src/dbcatalog" {
4587
4632
  * u32 data_coherence_hash
4588
4633
  * u32 pair_coherence_hash
4589
4634
  *
4590
- * `targetMode` "cold" -> 1; "hot" or null (legacy single artifact, treated as
4591
- * hot per Part 5) -> 0. The two coherence hashes use the SAME `layoutHash` /
4635
+ * `targetMode` "cold" -> 1; "hot" or null (default request artifact, treated
4636
+ * as hot per Part 5) -> 0. The two coherence hashes use the SAME `layoutHash` /
4592
4637
  * `recursionTypeMap` machinery as the toildb catalog, so a hot pass and a cold
4593
4638
  * pass over the same sources compute identical `data_coherence_hash` and
4594
4639
  * `pair_coherence_hash` independently (doc 02 AN-4). `build_id` is empty and
4595
4640
  * `abi_version` is 1 in this increment (the toiljs build-identity plumbing and
4596
4641
  * the export-name fingerprint component land with the codegen increment).
4597
4642
  *
4598
- * Returns `null` (no section) for a bare AssemblyScript module compiled in
4599
- * LEGACY mode (`targetMode == null`) that declares NO Toil surface at all
4643
+ * Returns `null` (no section) for a bare AssemblyScript module compiled with
4644
+ * `targetMode == null` that declares NO Toil surface at all
4600
4645
  * (`@rest`/`@stream`/`@daemon`/`@scheduled`/`@database`/`@data`), so an ordinary
4601
4646
  * AS compile stays byte-identical (the same gating philosophy as the existing
4602
4647
  * `toildb.catalog`, which is absent without `@database`). Part 5 / doc 02 AN-2
4603
- * requires the section in every TOIL artifact (including a legacy single-artifact
4604
- * toil build, which always carries a toil surface); a non-toil module is not a
4605
- * toil artifact. An explicit `--targetMode hot|cold` always emits the section.
4648
+ * requires the section in every TOIL artifact; a non-toil module is not a toil
4649
+ * artifact. An explicit `--targetMode hot|cold` always emits the section.
4606
4650
  */
4607
4651
  export function buildToilSurface(program: Program, targetMode: string | null): Uint8Array | null;
4608
4652
  }
@@ -5051,8 +5095,8 @@ declare module "types:toilscript/src/compiler" {
5051
5095
  constructor();
5052
5096
  /** WebAssembly target. Defaults to {@link Target.Wasm32}. */
5053
5097
  target: Target;
5054
- /** Toil compile surface mode. null = legacy single-artifact build (all surfaces allowed,
5055
- * matching pre-split behavior). "hot" = request + stream surface. "cold" = daemon surface. */
5098
+ /** Toil compile surface mode. null = default request artifact. "hot" = request + stream surface.
5099
+ * "cold" = daemon surface. */
5056
5100
  targetMode: string | null;
5057
5101
  /** Runtime type. Defaults to Incremental GC. */
5058
5102
  runtime: Runtime;
@@ -9964,7 +10008,7 @@ declare module "types:toilscript/src/index-wasm" {
9964
10008
  export function setExportStart(options: Options, exportStart: string | null): void;
9965
10009
  /** Sets the `noUnsafe` option. */
9966
10010
  export function setNoUnsafe(options: Options, noUnsafe: boolean): void;
9967
- /** Sets the `targetMode` option ("hot", "cold", or null for legacy single-artifact). */
10011
+ /** Sets the `targetMode` option ("hot", "cold", or null for the default request artifact). */
9968
10012
  export function setTargetMode(options: Options, targetMode: string | null): void;
9969
10013
  /** Sets the `lowMemoryLimit` option. */
9970
10014
  export function setLowMemoryLimit(options: Options, lowMemoryLimit: number): void;