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=PreemptColor:#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 β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| Layer | Intercepts | Coverage | Prod Overhead |
|---|---|---|---|
| L1 | ErrorHandler.onUnexpectedError() | 100% of errors | 0% |
| L2 | Emitter.prototype.fire() | 100% of events (474 services) | <1% (sampled) |
| L3 | CancellationTokenSource.cancel() | 100% of cancellations | ~0% |
| L4 | DisposableStore.add/dispose | 100% of resource lifecycle | ~0% |
| L5 | setTimeout0 / queueMicrotask | 100% of async scheduling | 1-2% |
| L8 | StopWatch / performance.now() | 100% of timing data | 2-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
| File | Hook |
|---|---|
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/ErrorHandlerProxy.ts | L1 β Error handler |
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/EmitterFireProxy.ts | L2 β Event emitter |
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/CancellationProxy.ts | L3 β Cancellation chain |
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/DisposableProxy.ts | L4 β Resource lifecycle |
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/AsyncProxy.ts | L5 β Async scheduling |
Land/Element/Output/Source/Service/CEL/Land/Shim/Intercept/TimingProxy.ts | L8 β Performance timing |
π Related Documentation
- Coverage / Telemetry β The high-level application shim (blue)
- Architecture β System architecture overview
- Deep Dive: Mountain β Rust-side intercept infrastructure
β οΈ 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.