feat(app): R4.3b/c import worker, client, controller; HomeRoute on the disposable worker

Protocol v1 (task → ready → result | failed with phase and kind), the worker entry with
the glue bundled statically and the page's compiled Module posted, the file streamed into
the module's memory; client with start and task timers (paused while hidden), settle-once,
terminate always, error events never masked; module-level controller (one import at a
time, cancel on leaving Home, worker chunk prefetched once the engine is loaded); the
settlement mapped to the B.1.8 messages (OD-5: a trap, a timeout or an unreadable file is
« Erreur de lecture du PDF. », never a corrupt PDF). HomeRoute keeps its routing and size
pre-checks, loads its own index after acceptance, drops a result when the session changed.
Tests: handler and client in-process, the corpus message test (O8 51, O7 stored inputs,
O2/O3/Step 5), the six existing suites migrated to the real worker logic.
This commit is contained in:
bchanot committed 2026-10-18 18:10:42 +02:00
1 parent 52471dbbc0
commit 6d1cce6e06
26 files changed
+2164 -247

No files matched your search

+2
View File
@@ -8,8 +8,10 @@
export {
CoreRuntime,
SheetSession,
closedRefusal,
type CoreSource,
type CoreStatus,
type GlueFileBytes,
type GlueModule,
type GlueSheetHandle,
} from './runtime'
+3 -1
View File
@@ -16,7 +16,9 @@ export const CORE_UNAVAILABLE: CoreFailure = {
}
export function failure(kind: string, detail?: string): CoreFailure {
return detail === undefined ? { ok: false, kind } : { ok: false, kind, detail }
return detail === undefined
? { ok: false, kind }
: { ok: false, kind, detail }
}
/** Parses the JSON text a core call returned. */
+10 -1
View File
@@ -144,6 +144,15 @@ export class CoreRuntime {
if (this.restartable) void this.retry()
}
/**
* The compiled module of this runtime, when a load has started: posted to the import
* worker (R4.3, structured clone) so an import needs no second fetch, offline included;
* `null` before the first load, the worker then fetches the asset itself.
*/
compiledModule(): Promise<WebAssembly.Module> | null {
return this.compiled
}
/** Runs a free operation. */
call<T>(op: string, input: string): CoreOutcome<T> {
return this.invoke((glue) => parseOutcome<T>(glue.call(op, input)))
@@ -246,7 +255,7 @@ export class CoreRuntime {
* `JsError` worded `<kind>: <detail>`), without its `invalid_sheet: ` kind; `null` when the
* error is anything else.
*/
function closedRefusal(error: unknown): string | null {
export function closedRefusal(error: unknown): string | null {
if (!(error instanceof Error) || error.name !== 'Error') return null
const match = /^([a-z_]+): /.exec(error.message)
if (!match) return null