Skip to main content

Module extensions_js

Module extensions_js 

Source
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
  • pi global 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§

ApplicationResult
Result of applying a validated proposal.
ApprovalRequest
An approval request presented to the human reviewer.
AuditEntry
A single entry in the repair audit ledger.
AuditLedger
Append-only audit ledger for repair lifecycle events.
CanaryConfig
Canary configuration for a specific extension/version pair.
CapabilityProofReport
Full capability monotonicity proof report.
ChecksumEntry
A single artifact entry in a golden checksum manifest.
ClockHandle
ConfidenceReason
An individual reason contributing to the confidence score.
ConfidenceReport
Result of confidence scoring: a score plus explainable reasons.
ConformanceFixture
A single conformance fixture for replay.
ConformanceReplayReport
Result of replaying conformance fixtures.
DeveloperGuide
Developer guide for contributing new repair rules.
ExtensionRepairEvent
A structured record emitted whenever the runtime auto-repairs an extension load failure.
ExtensionToolDef
Tool definition registered by a JS extension.
ForensicBundle
A complete forensic bundle for incident analysis.
GatingReasonCode
A structured reason code explaining why a gating decision was made.
GatingVerdict
Full gating verdict: decision + confidence + reason codes.
GoldenChecksumManifest
A golden checksum manifest for reproducible evidence.
GovernanceCheck
A single governance check item.
GovernanceReport
Result of running the governance checklist.
HealthReport
Health assessment report for a canary window.
HealthSignal
A health signal observed during canary.
HostcallRequest
A hostcall request enqueued from JavaScript.
InspectionRecord
A formatted inspection record for operator review.
IntentGraph
Normalized intent graph for a single extension.
LisrAdr
Architecture Decision Record for the LISR system.
Macrotask
ManualClock
OperatorPlaybook
Operational procedure for repair mode selection.
OverlayArtifact
An overlay artifact bundle: the unit of repair deployment.
PatchProposal
A model-generated repair proposal.
PiEventLoop
PiJsRuntime
Integrated PiJS runtime combining QuickJS, scheduler, and Promise bridge.
PiJsRuntimeConfig
PiJsRuntimeLimits
PiJsTickStats
Statistics from a tick execution.
PiJsWarmResetReport
RepairContext
Curated context provided to the model for repair proposal generation.
RepairRule
A static repair rule with deterministic ordering and versioning.
SemanticParityReport
Full hostcall parity and semantic delta proof report.
SystemClock
TelemetryCollector
Telemetry collector for repair lifecycle metrics.
TelemetryPoint
A single telemetry data point.
TickResult
TolerantParseResult
Result of tolerant parsing: partial analysis even when source has errors.
VerificationBundle
Unified verification evidence bundle.
WarmIsolatePool
Configuration holder and factory for pre-warmed JS extension runtimes.

Enums§

AmbiguitySignal
A construct in the source that reduces repair confidence.
ApprovalRequirement
Whether a proposal requires human approval before application.
ApprovalResponse
Human response to an approval request.
AuditEntryKind
Kind of audit ledger entry.
CanaryRoute
Canary routing decision for a specific request.
CapabilityDelta
A single capability change between before and after IntentGraphs.
CapabilityMonotonicityVerdict
Proof verdict for capability monotonicity.
ConflictKind
Outcome of conflict detection between two proposals.
ConformanceReplayVerdict
Overall verdict of a conformance replay check.
GatingDecision
The repair gating decision: what action the system should take.
HostcallCategory
Categories of hostcall surface that an extension can exercise.
HostcallDelta
A delta between before/after hostcall surfaces.
HostcallKind
Type of hostcall being requested from JavaScript.
IntentSignal
A normalized intent signal extracted from an extension.
MacrotaskKind
MonotonicityVerdict
Result of a privilege monotonicity check on a proposed repair.
OverlayState
Lifecycle state of an overlay artifact.
OverlayTransitionError
State transition error.
PatchOp
Primitive patch operations that model-generated repair proposals may use.
PromotionDecision
Promotion decision for a canary overlay.
ProposalValidationError
Validation error for a model-generated proposal.
RepairMode
Controls how the auto-repair pipeline behaves at extension load time.
RepairPattern
Classification of auto-repair patterns applied at extension load time.
RepairRisk
Risk tier for repair patterns (bd-k5q5.9.1.4).
SemanticDriftSeverity
Semantic drift severity classification.
SemanticParityVerdict
Overall verdict for hostcall parity and semantic delta proof.
SloVerdict
SLO verdict for a canary window.
StructuralVerdict
Outcome of a structural validation check on a repaired artifact.
TelemetryMetric
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§

Clock

Functions§

allowed_op_tags_for_mode
Return the PatchOp tags 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 PatchProposal against 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§

ArtifactChecksum
SHA-256 checksum of an artifact (hex-encoded, lowercase).
HostcallQueue