docs: make technical prose concrete

This commit is contained in:
Turtle
2026-08-09 15:27:21 +08:00
parent 673e7cddc5
commit a27efdef36
459 changed files with 1342 additions and 1329 deletions

View File

@@ -1,6 +1,6 @@
/**
* Meta validation: check the caller-provided {@link WorkflowMeta} DATA against the shape
* contract and reject everything else loud, every violation named. Meta arrives as schema-checked
* Meta validation checks caller-provided DATA against the {@link WorkflowMeta}
* contract and rejects every violation by name. Meta arrives as schema-checked
* JSON data, never evaluated script text; evaluating it on the host could run getters outside the
* worker timeout that exists to isolate model-written code.
* @module @deepseek-ai/dsh-workflow-workerthread/meta

View File

@@ -1,7 +1,7 @@
/**
* Materializes values leaving the script vm into plain JSON before they cross the worker
* boundary, and renders thrown script values without rejecting the run. The walk rejects
* lossy JSON shapes but trusts model-written workflow scripts: getters and proxy traps may
* values that JSON cannot preserve but trusts model-written workflow scripts: getters and proxy traps may
* run, and the vm is not a security boundary. The worker provides host-loop isolation and
* forced termination, not hostile-value containment. See
* .agents/notes/implemented/feature/2026-07-05-dynamic-workflows.md for the isolation rationale.
@@ -22,7 +22,7 @@ export class MaterializeError extends Error {
* fall back to `message`, then `String()`. Reading those properties MAY run
* script code (a getter, `toString`) — accepted under the module's trust
* premise; if that code itself throws, a fixed label is returned instead.
* @param error - the thrown value, of any shape and any realm.
* @param error - any value thrown in the host or worker realm.
* @returns human-readable text for the failure report; prefers the stack.
*/
export function renderThrown(error: unknown): string {
@@ -40,7 +40,7 @@ export function renderThrown(error: unknown): string {
}
/**
* Whether an object's prototype chain is data-shaped: `null`, or a prototype
* Whether an object's prototype chain represents a plain data object: `null`, or a prototype
* whose own prototype is `null` (the realm's `Object.prototype` — which we
* cannot compare by identity across realms). A `Date`/`Map`/class instance
* has a longer chain and is rejected.
@@ -87,9 +87,9 @@ function materialize(value: unknown, path: string, seen: Set<object>): unknown {
case 'bigint':
throw new MaterializeError(path, 'bigints are not JSON data')
case 'function':
throw new MaterializeError(path, 'functions cannot cross the workflow value boundary')
throw new MaterializeError(path, 'functions are not plain JSON data')
case 'symbol':
throw new MaterializeError(path, 'symbols cannot cross the workflow value boundary')
throw new MaterializeError(path, 'symbols are not plain JSON data')
case 'undefined':
throw new MaterializeError(path, 'undefined is not JSON data')
case 'object':
@@ -122,7 +122,7 @@ function materializeArray(value: unknown[], path: string, seen: Set<object>): un
}
}
if (Object.getOwnPropertySymbols(value).length > 0) {
throw new MaterializeError(path, 'symbol-keyed properties cannot cross the workflow value boundary')
throw new MaterializeError(path, 'symbol-keyed properties are not plain JSON data')
}
return out
}
@@ -132,7 +132,7 @@ function materializeObject(value: object, path: string, seen: Set<object>): Reco
throw new MaterializeError(path, 'only plain objects and arrays are JSON data (exotic prototype)')
}
if (Object.getOwnPropertySymbols(value).length > 0) {
throw new MaterializeError(path, 'symbol-keyed properties cannot cross the workflow value boundary')
throw new MaterializeError(path, 'symbol-keyed properties are not plain JSON data')
}
const out: Record<string, unknown> = {}
// Object.keys = own enumerable string keys, matching JSON.stringify's

View File

@@ -1,5 +1,5 @@
/**
* Per-run worker-side vm hooks, child RPC, concurrency/caps, cancellation, and result shaping; it
* Per-run worker-side vm hooks, child RPC, concurrency/caps, cancellation, and result serialization; it
* never touches Cordis. Script values leaving the realm are materialized as plain JSON before
* messaging. Values entering the trusted model-written realm are passed directly; `args` alone is
* cloned so script mutation cannot alter initialization data. See `./realm.ts` for the trust model.