Skip to main content

Low-Level Shim

Low-Level Shim

🟠 Engine-level prototype hooks for intercepting VS Code at the JavaScript runtime layer

🟠 Low-Level Shim β€” Engine-Level Interception

🟠 LOW-LEVEL SHIM β€” JavaScript engine prototype monkey-patches Tier gate: TierShim=Own | TierShim=Preempt Color: #FF6B35 (Orange) Overhead: <2% in production (sampled)

The Low-Level Shim intercepts VS Code at the JavaScript engine level β€” before any service, any contribution, any extension has a chance to execute. It operates via prototype-level monkey-patches on VS Code’s internal infrastructure classes.

🟠 Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  🟠 LOW-LEVEL SHIM β€” 6 Hook Layers                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  L1: ErrorHandler.onUnexpectedError()  β†’ All errors      β”‚
β”‚  L2: Emitter.prototype.fire()          β†’ All events      β”‚
β”‚  L3: CancellationTokenSource.cancel()  β†’ All aborts      β”‚
β”‚  L4: DisposableStore.add/dispose       β†’ All resources   β”‚
β”‚  L5: setTimeout0 / Async Scheduler     β†’ All async work  β”‚
β”‚  L8: StopWatch / performance.now()     β†’ All timing      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Dev-only: Promise constructor, Error.stack capture      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
LayerInterceptsCoverageProd Overhead
L1ErrorHandler.onUnexpectedError()100% of errors0%
L2Emitter.prototype.fire()100% of events (474 services)<1% (sampled)
L3CancellationTokenSource.cancel()100% of cancellations~0%
L4DisposableStore.add/dispose100% of resource lifecycle~0%
L5setTimeout0 / queueMicrotask100% of async scheduling1-2%
L8StopWatch / performance.now()100% of timing data2-3% (dev)

🟠 How It Works

Each hook is a single prototype-level monkey-patch that wraps VS Code’s internal class methods. When TierShim=Own, the shim activates BEFORE any VS Code code runs. All intercepted data flows through LandDiagnostics to OTLP / PostHog / Mountain dev log.

Example: Emitter.prototype.fire()

const originalFire = Emitter.prototype.fire;
Emitter.prototype.fire = function(event) {
    if (LandSwallowMap.shouldSwallowEmitter(this, event)) {
        LandRedirectBus.routeEmitterEvent(event);
        return; // VS Code listeners never fire
    }
    originalFire.call(this, event);
};

This single 8-line patch covers every event in VS Code β€” status bar updates, SCM changes, editor state, extension notifications, everything.

🟠 Source Files

FileHook
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/ErrorHandlerProxy.tsL1 β€” Error handler
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/EmitterFireProxy.tsL2 β€” Event emitter
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/CancellationProxy.tsL3 β€” Cancellation chain
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/DisposableProxy.tsL4 β€” Resource lifecycle
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/AsyncProxy.tsL5 β€” Async scheduling
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/TimingProxy.tsL8 β€” Performance timing

⚠️ EXPERIMENTAL β€” This component operates at the JavaScript engine level. Changes to VS Code’s internal classes may require updates to these hooks. Production overhead: <2% with sampling.