Expand description
QuickJS runtime bridge for JS-compatible extensions.
This module implements the PiJS runtime with Promise-based hostcall bridge:
- Async QuickJS runtime + context creation
piglobal object with Promise-returning hostcall methods- Deterministic event loop scheduler integration
- call_id → Promise resolver mapping for hostcall completions
- Microtask draining after each macrotask
§Architecture (bd-2ke)
JS Code Rust Host
------- ---------
pi.tool("read", {...}) --> enqueue HostcallRequest
returns Promise generate call_id
store (resolve, reject) track pending hostcall
[scheduler tick] <-- host completes hostcall
delivers MacrotaskKind::HostcallComplete
lookup (resolve, reject) by call_id
resolve(result) or reject(error)
drain microtasks (Promises .then chains)Structs§
- Application
Result - Result of applying a validated proposal.
- Approval
Request - An approval request presented to the human reviewer.
- Audit
Entry - A single entry in the repair audit ledger.
- Audit
Ledger - Append-only audit ledger for repair lifecycle events.
- Canary
Config - Canary configuration for a specific extension/version pair.
- Capability
Proof Report - Full capability monotonicity proof report.
- Checksum
Entry - A single artifact entry in a golden checksum manifest.
- Clock
Handle - Confidence
Reason - An individual reason contributing to the confidence score.
- Confidence
Report - Result of confidence scoring: a score plus explainable reasons.
- Conformance
Fixture - A single conformance fixture for replay.
- Conformance
Replay Report - Result of replaying conformance fixtures.
- Developer
Guide - Developer guide for contributing new repair rules.
- Extension
Repair Event - A structured record emitted whenever the runtime auto-repairs an extension load failure.
- Extension
Tool Def - Tool definition registered by a JS extension.
- Forensic
Bundle - A complete forensic bundle for incident analysis.
- Gating
Reason Code - A structured reason code explaining why a gating decision was made.
- Gating
Verdict - Full gating verdict: decision + confidence + reason codes.
- Golden
Checksum Manifest - A golden checksum manifest for reproducible evidence.
- Governance
Check - A single governance check item.
- Governance
Report - Result of running the governance checklist.
- Health
Report - Health assessment report for a canary window.
- Health
Signal - A health signal observed during canary.
- Hostcall
Request - A hostcall request enqueued from JavaScript.
- Inspection
Record - A formatted inspection record for operator review.
- Intent
Graph - Normalized intent graph for a single extension.
- LisrAdr
- Architecture Decision Record for the LISR system.
- Macrotask
- Manual
Clock - Operator
Playbook - Operational procedure for repair mode selection.
- Overlay
Artifact - An overlay artifact bundle: the unit of repair deployment.
- Patch
Proposal - A model-generated repair proposal.
- PiEvent
Loop - PiJs
Runtime - Integrated PiJS runtime combining QuickJS, scheduler, and Promise bridge.
- PiJs
Runtime Config - PiJs
Runtime Limits - PiJs
Tick Stats - Statistics from a tick execution.
- PiJs
Warm Reset Report - Repair
Context - Curated context provided to the model for repair proposal generation.
- Repair
Rule - A static repair rule with deterministic ordering and versioning.
- Semantic
Parity Report - Full hostcall parity and semantic delta proof report.
- System
Clock - Telemetry
Collector - Telemetry collector for repair lifecycle metrics.
- Telemetry
Point - A single telemetry data point.
- Tick
Result - Tolerant
Parse Result - Result of tolerant parsing: partial analysis even when source has errors.
- Verification
Bundle - Unified verification evidence bundle.
- Warm
Isolate Pool - Configuration holder and factory for pre-warmed JS extension runtimes.
Enums§
- Ambiguity
Signal - A construct in the source that reduces repair confidence.
- Approval
Requirement - Whether a proposal requires human approval before application.
- Approval
Response - Human response to an approval request.
- Audit
Entry Kind - Kind of audit ledger entry.
- Canary
Route - Canary routing decision for a specific request.
- Capability
Delta - A single capability change between before and after
IntentGraphs. - Capability
Monotonicity Verdict - Proof verdict for capability monotonicity.
- Conflict
Kind - Outcome of conflict detection between two proposals.
- Conformance
Replay Verdict - Overall verdict of a conformance replay check.
- Gating
Decision - The repair gating decision: what action the system should take.
- Hostcall
Category - Categories of hostcall surface that an extension can exercise.
- Hostcall
Delta - A delta between before/after hostcall surfaces.
- Hostcall
Kind - Type of hostcall being requested from JavaScript.
- Intent
Signal - A normalized intent signal extracted from an extension.
- Macrotask
Kind - Monotonicity
Verdict - Result of a privilege monotonicity check on a proposed repair.
- Overlay
State - Lifecycle state of an overlay artifact.
- Overlay
Transition Error - State transition error.
- PatchOp
- Primitive patch operations that model-generated repair proposals may use.
- Promotion
Decision - Promotion decision for a canary overlay.
- Proposal
Validation Error - Validation error for a model-generated proposal.
- Repair
Mode - Controls how the auto-repair pipeline behaves at extension load time.
- Repair
Pattern - Classification of auto-repair patterns applied at extension load time.
- Repair
Risk - Risk tier for repair patterns (bd-k5q5.9.1.4).
- Semantic
Drift Severity - Semantic drift severity classification.
- Semantic
Parity Verdict - Overall verdict for hostcall parity and semantic delta proof.
- SloVerdict
- SLO verdict for a canary window.
- Structural
Verdict - Outcome of a structural validation check on a repaired artifact.
- Telemetry
Metric - Telemetry event kind for repair lifecycle metrics.
Constants§
- REPAIR_
REGISTRY_ VERSION - The registry version: bumped whenever rules are added or modified.
Statics§
- REPAIR_
RULES - The canonical, deterministic rule registry.
Traits§
Functions§
- allowed_
op_ tags_ for_ mode - Return the
PatchOptags allowed under the given repair mode. - applicable_
rules - Find all rules applicable under the given mode, in registry order.
- apply_
proposal - Apply a validated proposal (dry-run: only validates and reports).
- available_
virtual_ module_ names - Returns the set of all module specifiers available as virtual modules.
- build_
approval_ request - Build an approval request for human review.
- build_
forensic_ bundle - Build a forensic bundle from available state.
- build_
golden_ manifest - Build a golden checksum manifest from file contents.
- build_
inspection - Build an inspection record from audit ledger and current state.
- check_
approval_ requirement - Determine whether a proposal requires human approval.
- compute_
artifact_ checksum - Compute a SHA-256 checksum for the given byte content.
- compute_
canary_ bucket - Compute a deterministic hash bucket (0–99) from extension ID and environment.
- compute_
capability_ proof - Compute a capability monotonicity proof by diffing two intent graphs.
- compute_
confidence - Compute legibility confidence from intent graph and parse results.
- compute_
gating_ verdict - Compute the gating verdict from intent graph and parse results.
- compute_
semantic_ parity - Compute hostcall parity and semantic delta proof.
- decide_
promotion - Decide whether to promote, hold, or rollback a canary overlay.
- detect_
conflict - Detect conflicts between two
PatchProposals. - evaluate_
health - Evaluate health signals against SLO thresholds.
- execute_
promotion - Execute a promotion: transitions overlay to Stable.
- execute_
rollback - Execute a rollback: transitions overlay to
RolledBack. - explain_
gating - Explain a gating decision in human-readable format.
- extract_
hostcall_ surface - Extract hostcall categories from an intent graph.
- extract_
import_ names - Extract the named imports that a source file pulls from a given specifier.
- format_
proposal_ diff - Format a patch proposal diff for operator review.
- generate_
monorepo_ stub - Generate a synthetic ESM stub module that exports no-op values for each requested name. Uses simple heuristics to choose the export shape:
- is_
env_ var_ allowed - Determine whether an environment variable is safe to expose to extensions.
- replay_
conformance_ fixtures - Replay conformance fixtures and produce a report.
- resolve_
conflicts - Resolve conflicts among a set of proposals.
- rule_
by_ id - Look up a rule by its ID.
- run_
governance_ checklist - Run the governance checklist against current system state.
- select_
best_ candidate - Select the best candidate from a set of proposals.
- should_
auto_ rollback - Automatic rollback trigger: should the canary be rolled back?
- tolerant_
parse - Perform tolerant parsing and ambiguity detection on source text.
- transition_
overlay - Advance an overlay through its lifecycle.
- validate_
proposal - Validate a
PatchProposalagainst policy constraints. - validate_
repaired_ artifact - Validate that a repaired artifact is structurally sound.
- verify_
repair_ monotonicity - Check that a repair-resolved path stays within the extension root.
Type Aliases§
- Artifact
Checksum - SHA-256 checksum of an artifact (hex-encoded, lowercase).
- Hostcall
Queue