Skip to main content

Coverage

Coverage / Telemetry

πŸ”΅ High-level application shim for intercepting and routing VS Code services through Land's service tree

πŸ”΅ Coverage / Telemetry - Application-Level Shim

πŸ”΅ COVERAGE SHIM - Application-level service routing and telemetry Tier gate: TierShim=Proxy | TierShim=Replace Color: #2563EB (Blue) Overhead: <1% (passthrough mode)

The Coverage Shim intercepts VS Code at the application service level - routing IPC commands through Land’s SwallowMap, proxying the ServiceCollection DI container, and tracking coverage across all 474 decorated services. Unlike the 🟠 Low-Level Shim (which operates at the JS engine level), the πŸ”΅ Coverage Shim works at the architectural boundary between Wind (renderer), Cocoon (bridge), and Mountain (native backend).


πŸ”΅ Full Architecture Diagram

graph TD
    subgraph WIND["Wind (Renderer Process)"]
        VS["VS Code Workbench"] --> IS["IInstantiationService"]
        VS --> IPC["Tauri IPC invoke()"]

        subgraph SHIM["πŸ”΅ Coverage Shim"]
            GATE["Gate.ts - IsEnabled/IsProxy/IsReplace"]
            SM["SwallowMap.ts - Pattern Matcher"]
            RB["RedirectBus.ts - Handler Router"]
            AL["AuditLog.ts - Ring Buffer"]
            II["IPCInterceptor.ts - invoke() Wrapper"]
            EI["EventInterceptor.ts - DOM addEventListener"]
            NP["NetworkProxy.ts - fetch/XHR"]
            AP["AsyncProxy.ts - Timers/Rendering"]
        end

        IPC --> II
        II --> SM
        SM --> |"SWALLOW"| RB
        SM --> |"PASSTHROUGH"| IPC
        SM --> |"DISCARD"| DROP["null"]
        SM --> |"MIXED"| BOTH["Land + VS Code"]
        RB --> MOUNTAIN["Mountain"]
        RB --> COCOON["Cocoon"]
        RB --> OUTPUT["Output"]
        AL --> |"30s flush"| IPC
    end

    subgraph COCOON["Cocoon (Bridge Process)"]
        GRPC["gRPC Server"]
    end

    subgraph MOUNTAIN["Mountain (Rust Backend)"]
        DM["DispatchMatch"]
        NB["NativeBus - tokio::fs, PTY, rg"]
        MSM["Shim/SwallowMap.rs"]
        MG["Shim/Gate.rs"]
        DEVLOG["dev_log! macro"]
    end

    subgraph OUTPUT["Output (Build Pipeline)"]
        INJ["InjectShimHook Transform"]
        COMPILE["esbuild - define __LandTier_Shim__"]
        NULLSVC["CEL Null Services"]
    end

    subgraph DIAG["Diagnostics"]
        LD["LandDiagnostics.ts - Unified Tracer"]
        OTLP["OTLP Traces"]
        POSTHOG["PostHog"]
    end

    II --> |"routes"| RB
    RB --> |"Wind handlers"| WIND_SVC["Wind Service Handlers"]
    RB --> |"Cocoon handlers"| GRPC
    RB --> |"Mountain handlers"| DM
    RB --> |"Output handlers"| OUTPUT
    EI --> |"DOM events"| RB
    NP --> |"fetch/XHR"| SM
    AP --> |"timers/RAF"| SM

    SM --> LD
    AL --> LD
    LD --> OTLP
    LD --> POSTHOG

    COMPILE --> |"bakes TierShim"| GATE
    INJ --> |"injects Init.js"| IS

    style SHIM fill:#2563EB20,stroke:#2563EB,stroke-width:2px
    style SM fill:#2563EB,stroke:#1d4ed8,color:#fff
    style RB fill:#2563EB,stroke:#1d4ed8,color:#fff
    style GATE fill:#2563EB,stroke:#1d4ed8,color:#fff
    style NB fill:#7C3AED,stroke:#6d28d9,color:#fff

Three interlocking planes:

  1. Decision Plane (SwallowMap + Gate) - Pattern-matching engine that decides: swallow, passthrough, mixed, or discard
  2. Routing Plane (RedirectBus + IPCInterceptor) - Dispatches swallowed events to Land’s service tree
  3. Audit Plane (AuditLog + LandDiagnostics) - Records every service resolution for coverage analysis

πŸ”΅ IPC Interception Flow

sequenceDiagram
    participant VS as VS Code Service
    participant IPC as IPCInterceptor
    participant SM as SwallowMap.decide()
    participant RB as RedirectBus.route()
    participant Tauri as Tauri invoke()
    participant Mtn as Mountain DispatchMatch

    VS->>IPC: invoke("MountainIPCInvoke", {method:"statusbar:set", params:[...]})
    IPC->>IPC: Gate.IsEnabled? (fast path if disabled)
    IPC->>SM: SwallowMap.decide("statusbar:set")

    alt Decision = SWALLOW
        SM-->>IPC: {action:"SWALLOW", redirectTo:"Wind"}
        IPC->>RB: RedirectBus.route("statusbar:set", [...])
        RB->>RB: Find handler matching "statusbar:"
        RB-->>IPC: result
        IPC-->>VS: Land handler result
        Note over VS,Mtn: VS Code NEVER sees this event
    else Decision = PASSTHROUGH
        SM-->>IPC: {action:"PASSTHROUGH", redirectTo:"None"}
        IPC->>Tauri: originalInvoke("MountainIPCInvoke", {...})
        Tauri->>Mtn: DispatchMatch.handle()
        Mtn-->>VS: VS Code native result
    else Decision = MIXED
        SM-->>IPC: {action:"MIXED", redirectTo:"Wind"}
        par Land handles
            IPC->>RB: RedirectBus.route(...)
            RB-->>IPC: landResult
        and VS Code handles
            IPC->>Tauri: originalInvoke(...) [fire-and-forget]
        end
        IPC-->>VS: Land result (wins)
    else Decision = DISCARD
        SM-->>IPC: {action:"DISCARD", redirectTo:"None"}
        IPC-->>VS: null
        Note over VS,Mtn: Telemetry silently dropped
    end

πŸ”΅ Full Domain Coverage Table

#DomainStatusTierTierShimRedirectNotes
1Status BarπŸ”΅ SWALLOWTierSwallowStatusBar=SwallowReplaceWindLand renders its own status bar via Sky
2SCM / GitπŸ”΅ SWALLOWTierSwallowSCM=SwallowReplaceCocoonNative git operations via Cocoon bridge
3SearchπŸ”΅ SWALLOWTierSwallowSearch=SwallowReplaceMountainNative ripgrep via Mountain NativeBus
4TerminalπŸ”΅ SWALLOWTierSwallowTerminal=SwallowReplaceMountainNative PTY via Mountain
5OutputπŸ”΅ SWALLOWTierSwallowOutput=SwallowReplaceOutputOutput panel rendered by Land
6File SystemπŸ”΅ SWALLOWTierSwallowFile=SwallowReplaceMountaintokio::fs via Mountain NativeBus
7NotificationsπŸ”΅ SWALLOWTierSwallowNotification=SwallowReplaceWindLand notification system
8DialogsπŸ”΅ SWALLOWTierSwallowDialog=SwallowReplaceMountainNative OS dialogs via Mountain
9Quick InputπŸ”΅ SWALLOWTierSwallowQuickInput=SwallowReplaceWindLand quick-pick UI
10KeybindingsπŸ”΅ SWALLOWTierSwallowKeybinding=SwallowReplaceWindLand keybinding system
11ThemesπŸ”΅ SWALLOWTierSwallowTheme=SwallowReplaceWindLand theme engine
12ConfigurationπŸ”΅ SWALLOWTierSwallowConfiguration=SwallowReplaceWindLand settings system
13TelemetryπŸ”΅ DISCARDTierSwallowTelemetry=DiscardReplaceNoneSilently dropped (MS endpoints)
14Extension GalleryπŸ”΅ SWALLOWTierSwallowGallery=SwallowReplaceWindOffline gallery (CEL null service)
15Product IdentityπŸ”΅ SWALLOWTierSwallowProduct=SwallowReplaceMountainLand replaces VS Code product.json
16Debugβšͺ PASSTHROUGH--NoneDebug adapter protocol passes through
17Tasksβšͺ PASSTHROUGH--NoneTask execution passes through
18Extensions (runtime)βšͺ PASSTHROUGH--NoneExtension host runs unmodified
19Editor (core)βšͺ PASSTHROUGH--NoneMonaco editor untouched
20Language Featuresβšͺ PASSTHROUGH--NoneLSP providers pass through
21Remoteβšͺ PASSTHROUGH--NoneRemote development passthrough
22Testingβšͺ PASSTHROUGH--NoneTest runner passthrough

Coverage: 15 of 22 core domains are actively swallowed. 7 remain passthrough because they involve extension-host interactions (Debug, Language Features), the Monaco editor core, or infrastructure that Land does not replace (Tasks, Remote, Testing).


πŸ”΅ Service Coverage Matrix by Category

CategoryTotal ServicesCoveredCoverage %Swallow Strategy
Workbench UI251560%SwallowMap + Wind handlers
Platform Services1003535%ServiceCollection proxy + CEL null services
Editor Core40820%Passthrough (Monaco editor)
Extensions30517%Gallery replaced, runtime passthrough
Terminal12433%PTY passthrough, UI swallowed
Chat/Copilot2500%Passthrough (future)
Testing800%Passthrough
Remote1500%Passthrough
Misc/Specialized21900%Passthrough
Total4746714%Mixed

Coverage growth trajectory:

MilestoneServices Covered%Approach
Current6714%SwallowMap rules + CEL null services
Phase 2~12025%Wind handler registration for UI domains
Phase 3~20042%Cocoon bridge for extension-host services
Full replacement474100%TierShim=Preempt - Land IS the engine

Current coverage focuses on user-facing UI surfaces (status bar, SCM, search, terminal, notifications, dialogs, quick input) and data-safety domains (telemetry discarded, file system native, extension gallery offline). The Monaco editor core and extension host are deliberately left as passthrough to maintain compatibility.


πŸ”΅ SwallowMap Rule Format Specification

// From: Wind/Source/Shim/Type.ts

/** What to do with an intercepted event */
type SwallowAction = "SWALLOW" | "PASSTHROUGH" | "MIXED" | "DISCARD";

/** Where to route a swallowed event */
type RedirectTarget = "Wind" | "Cocoon" | "Mountain" | "Output" | "Sky" | "None";

/** A single rule in the SwallowMap */
interface SwallowRule {
    /** Regex or prefix pattern to match against method names */
    pattern: string;

    /** What to do when this pattern matches */
    action: SwallowAction;

    /** Where to redirect swallowed events */
    redirectTo: RedirectTarget;

    /** Optional runtime condition - if present, must return true to swallow */
    condition?: (method: string, params: unknown[]) => boolean;
}

/** The decision produced by the SwallowMap for a given method */
interface SwallowDecision {
    action: SwallowAction;
    redirectTo: RedirectTarget;
}

Pattern Matching Algorithm

// From: Wind/Source/Shim/SwallowMap.ts

static decide(method: string): SwallowDecision {
    for (const rule of this.rules) {
        let matches = false;
        try {
            if (rule.pattern.startsWith("^") || rule.pattern.includes(".*")) {
                matches = new RegExp(rule.pattern).test(method);  // Regex match
            } else {
                matches = method.startsWith(rule.pattern);         // Prefix match
            }
        } catch {
            continue;  // Invalid regex - skip rule
        }

        if (matches) {
            if (rule.condition && !rule.condition(method, [])) {
                continue;  // Runtime condition failed - try next rule
            }
            return { action: rule.action, redirectTo: rule.redirectTo };
        }
    }
    // Default: PASSTHROUGH to None
    return { action: "PASSTHROUGH", redirectTo: "None" };
}

Two match modes:

ModeTriggerExampleMatches
PrefixPattern starts with plain text"statusbar:""statusbar:set", "statusbar:hide", "statusbar:updateEntry"
RegexPattern contains ^ or .*`”^(scmgit):β€œ`

Rule ordering: Rules are checked in insertion order. First match wins. Rules loaded from loadDefaults() are ordered most-specific to least-specific. The default (no match) is always PASSTHROUGH β†’ None.

Rust Counterpart

// From: Mountain/Source/Shim/SwallowMap.rs
// Identical rule table maintained in Rust for the NativeBus fast path

static RULES: &[Rule] = &[
    Rule { pattern: "statusbar:", action: SwallowAction::Swallow, target: RedirectTarget::Wind },
    Rule { pattern: "scm:",       action: SwallowAction::Swallow, target: RedirectTarget::Cocoon },
    Rule { pattern: "search:",    action: SwallowAction::Swallow, target: RedirectTarget::Mountain },
    // ... 16 more rules ...
    Rule { pattern: "telemetry:", action: SwallowAction::Discard, target: RedirectTarget::None },
];

pub fn decide(method: &str) -> (SwallowAction, RedirectTarget) {
    for rule in RULES {
        if method.starts_with(rule.pattern) {
            return (rule.action, rule.target);
        }
    }
    (SwallowAction::Passthrough, RedirectTarget::None)
}

The TypeScript and Rust SwallowMaps are kept in lockstep - any rule added to one side requires a matching rule on the other. The Rust side handles direct-native IPC calls that bypass Wind entirely; the TypeScript side handles calls originating from the renderer.


πŸ”΅ SwallowMap Rule Reference

Built-in Default Rules

#PatternActionRedirectDomain
1statusbar:SWALLOWWindStatus Bar
2$setStatusBarMessageSWALLOWWindStatus Bar (legacy)
3$disposeStatusBarMessageSWALLOWWindStatus Bar (legacy)
4scm:SWALLOWCocoonSource Control
5$scm:SWALLOWCocoonSource Control (legacy)
6search:SWALLOWMountainSearch
7workspace:findSWALLOWMountainWorkspace Find
8terminal:SWALLOWMountainTerminal
9output:SWALLOWOutputOutput Panel
10sky:outputSWALLOWOutputSky Output Bridge
11file:readSWALLOWMountainFile Read
12file:writeSWALLOWMountainFile Write
13file:statSWALLOWMountainFile Stat
14file:deleteSWALLOWMountainFile Delete
15file:mkdirSWALLOWMountainFile Mkdir
16file:readdirSWALLOWMountainFile Readdir
17notification:SWALLOWWindNotifications
18dialog:SWALLOWMountainDialogs
19showOpenDialogSWALLOWMountainNative Open Dialog
20showSaveDialogSWALLOWMountainNative Save Dialog
21quickInput:SWALLOWWindQuick Input
22quickpick:SWALLOWWindQuick Pick
23keybinding:SWALLOWWindKeybindings
24theme:SWALLOWWindThemes
25workbenchTheme:SWALLOWWindWorkbench Themes
26configuration:SWALLOWWindConfiguration
27telemetry:DISCARDNoneMicrosoft Telemetry
28extensionsGallery:SWALLOWWindExtension Gallery
29extensionGallery:SWALLOWWindExtension Gallery (alt)
30product:SWALLOWMountainProduct Identity

πŸ”΅ AuditLog Buffer Format and Flush Cadence

// From: Wind/Source/Shim/AuditLog.ts

interface AuditEntry {
    /** Performance.now() timestamp */
    timestamp: number;

    /** Service identifier string (e.g., "IStatusbarService") */
    serviceId: string;

    /** What kind of access */
    action: "get" | "set" | "create" | "resolve" | "invoke";

    /** Was the service successfully resolved? */
    resolved: boolean;

    /** Was it served from cache (previously created)? */
    fromCache: boolean;

    /** Duration in ms (for create/resolve actions) */
    duration?: number;
}

class AuditLog {
    /** Ring buffer - maximum 2000 entries, oldest dropped */
    private static entries: AuditEntry[] = [];
    private static readonly maxEntries = 2000;

    /** Flush: drain entries, return copy, increment flush count */
    static flush(): AuditEntry[] { /* ... */ }

    /** Summary: total entries, per-service counts, per-action counts */
    static summary(): { total: number; byService: Record<string, number>; byAction: Record<string, number> }

    /** Top N most-accessed services (for discovery) */
    static topServices(n = 20): Array<{ id: string; count: number }>

    /** Send to Mountain dev log via Tauri IPC */
    static async sendToMountain(): Promise<void> { /* ... */ }
}

Flush cadence:

TriggerIntervalData SentTarget
TimerEvery 30 secondsFull buffer drain + summaryMountain diagnostic:log
CapacityBuffer > 2000 entriesOldest entries dropped silentlyRing buffer compaction
ShutdownOn forceFlush()Final drainMountain diagnostic:log

Flush payload sent to Mountain:

{
    "flush": 42,
    "total": 187,
    "byService": {
        "IStatusbarService": 34,
        "ITelemetryService": 28,
        "IConfigurationService": 15,
        "IFileService": 12,
        "IQuickInputService": 9
    },
    "byAction": {
        "get": 144,
        "set": 23,
        "resolve": 20
    },
    "sample": [
        {
            "timestamp": 18473.2,
            "serviceId": "IStatusbarService",
            "action": "get",
            "resolved": true,
            "fromCache": true
        }
    ]
}

Coverage analysis use case: The topServices() method reveals which services are accessed most frequently, guiding decisions about which services to swallow next. Services with high get counts and low create counts are ideal swallow candidates because they’re heavily read but rarely re-instantiated.


πŸ”΅ Wind Shim Module Map (13 Modules)

#ModuleTypeScript FilePurpose
1GateWind/Source/Shim/Gate.tsReads __LandTier_Shim__ (build-time constant), exports boolean flags (IsEnabled, IsProxy, IsReplace, IsOwn, IsPreempt)
2SwallowMapWind/Source/Shim/SwallowMap.tsPattern-matching decision engine; decide(), shouldSwallow(), shouldPassthrough()
3RedirectBusWind/Source/Shim/RedirectBus.tsHandler registration and routing; register(), route(), unregister()
4IPCInterceptorWind/Source/Shim/IPCInterceptor.tsWraps invoke("MountainIPCInvoke") with SwallowMap check; createInterceptedInvoke()
5AuditLogWind/Source/Shim/AuditLog.tsService resolution auditor; ring buffer, flush, summary, topServices()
6TypeWind/Source/Shim/Type.tsCore types: ShimLevel, SwallowAction, SwallowRule, SwallowDecision, RedirectHandler, ShimEvent
7IndexWind/Source/Shim/Index.tsBarrel export for core shim modules (1-6)
8EventInterceptorWind/Source/Shim/EventInterceptor.tsPatches EventTarget.prototype.addEventListener to route DOM events through RedirectBus
9NetworkProxyWind/Source/Shim/NetworkProxy.tsPatches fetch() and XMLHttpRequest; discards MS telemetry endpoints; routes vscode-file:// through Mountain
10AsyncProxyWind/Source/Shim/AsyncProxy.tsPatches setTimeout, setInterval, requestAnimationFrame, requestIdleCallback; batch coalescing
11FullIndexWind/Source/Shim/FullIndex.tsFull barrel: Index + EventInterceptor + NetworkProxy + AsyncProxy
12Mountain Shim/GateMountain/Source/Shim/Gate.rsRust compile-time gate: env!("TierShim"), exports is_enabled(), is_proxy(), etc.
13Mountain Shim/SwallowMapMountain/Source/Shim/SwallowMap.rsRust pattern-matching engine; identical rule table to TypeScript version

πŸ”΅ Output Shim Module Map (9 Modules)

#ModuleTypeScript FilePurpose
1InitOutput/Source/Service/CEL/Land/Shim/Init.tsEntry point injected by Output Transform; LandShimInit(instantiationService)
2IndexOutput/Source/Service/CEL/Land/Shim/Index.tsBarrel: Init + Diagnostics + 6 Intercept proxies
3DiagnosticsOutput/Source/Service/CEL/Land/Shim/Diagnostics/LandDiagnostics.tsUnified ring-buffer tracer; 7 buffer categories, flush timer, forceFlush()
4ErrorHandlerProxyOutput/Source/Service/CEL/Land/Shim/Intercept/ErrorHandlerProxy.tsL1: errorHandler.onUnexpectedError()
5EmitterFireProxyOutput/Source/Service/CEL/Land/Shim/Intercept/EmitterFireProxy.tsL2: Emitter.prototype.fire()
6CancellationProxyOutput/Source/Service/CEL/Land/Shim/Intercept/CancellationProxy.tsL3: CancellationTokenSource.prototype.cancel()
7DisposableProxyOutput/Source/Service/CEL/Land/Shim/Intercept/DisposableProxy.tsL4: DisposableStore.prototype.add/dispose
8AsyncProxyOutput/Source/Service/CEL/Land/Shim/Intercept/AsyncProxy.tsL5: platform.setTimeout0() batching
9TimingProxyOutput/Source/Service/CEL/Land/Shim/Intercept/TimingProxy.tsL8: StopWatch constructor/stop/elapsed

CEL Null Service Modules (Output πŸ”΅ Replace Tier)

#ModuleTypeScript FileVS Code Module Replaced
10NullTelemetryServiceOutput/Source/Service/CEL/Null/Telemetry/Service.tsvs/platform/telemetry/common/telemetry.ts
11NullExtensionGalleryServiceOutput/Source/Service/CEL/Null/Extension/Gallery/Service.tsvs/platform/extensionManagement/common/
12NullUpdateServiceOutput/Source/Service/CEL/Null/Update/Service.tsvs/platform/update/common/update.ts

These are compiled by Output’s esbuild step and dropped into the VS Code tree via ApplyPipeline.ts. Original module bodies are reduced to one-line re-exports pointing to the CEL null service.


πŸ”΅ Integration Diagram: Wind / Output / Cocoon / Mountain

graph TD
    subgraph PROCESS_WIND["Wind Process (Renderer)"]
        direction TB
        W_GATE["Gate.ts"]
        W_SM["SwallowMap.ts (TS)"]
        W_RB["RedirectBus.ts"]
        W_AL["AuditLog.ts"]
        W_II["IPCInterceptor.ts"]
        W_EI["EventInterceptor.ts"]
        W_NP["NetworkProxy.ts"]
        W_AP["AsyncProxy.ts (Wind)"]

        W_GATE --> W_SM
        W_SM --> W_II
        W_SM --> W_EI
        W_SM --> W_NP
        W_SM --> W_AP
        W_II --> W_RB
        W_EI --> W_RB
        W_RB --> W_AL
    end

    subgraph PROCESS_OUTPUT["Output Pipeline (Build Time)"]
        direction TB
        O_INIT["Init.ts - LandShimInit()"]
        O_LD["LandDiagnostics.ts"]
        O_L1["ErrorHandlerProxy (L1)"]
        O_L2["EmitterFireProxy (L2)"]
        O_L3["CancellationProxy (L3)"]
        O_L4["DisposableProxy (L4)"]
        O_L5["AsyncProxy (L5)"]
        O_L8["TimingProxy (L8)"]
        O_NULL["CEL Null Services"]

        O_INIT --> O_L1
        O_INIT --> O_L2
        O_INIT --> O_L3
        O_INIT --> O_L4
        O_INIT --> O_L5
        O_INIT --> O_L8
        O_L1 --> O_LD
        O_L2 --> O_LD
        O_L3 --> O_LD
        O_L4 --> O_LD
        O_L5 --> O_LD
        O_L8 --> O_LD
    end

    subgraph PROCESS_COCOON["Cocoon Process (Bridge)"]
        direction TB
        C_GRPC["gRPC Server"]
        C_ESBUILD["CocoonEsbuildDefine"]
    end

    subgraph PROCESS_MOUNTAIN["Mountain Process (Rust Native)"]
        direction TB
        M_GATE["Gate.rs"]
        M_SM["SwallowMap.rs (Rust)"]
        M_NB["NativeBus.rs"]
        M_DM["DispatchMatch"]
        M_DL["dev_log!"]

        M_GATE --> M_SM
        M_SM --> M_NB
        M_SM --> M_DM
        M_NB --> M_DL
    end

    W_II --> |"Tauri IPC"| M_DM
    W_II --> |"Tauri IPC"| M_NB
    O_LD --> |"Tauri IPC β†’ diagnostic:log"| M_DL
    W_AL --> |"Tauri IPC β†’ diagnostic:log"| M_DL
    W_RB --> |"Cocoon handlers"| C_GRPC

    C_ESBUILD --> |"define __LandTier_Shim__"| W_GATE
    C_ESBUILD --> |"define __LandTier_Shim__"| O_INIT

    style PROCESS_WIND fill:#2563EB10,stroke:#2563EB
    style PROCESS_OUTPUT fill:#FF6B3510,stroke:#FF6B35
    style PROCESS_COCOON fill:#10B98110,stroke:#10B981
    style PROCESS_MOUNTAIN fill:#7C3AED10,stroke:#7C3AED

Data flow summary:

PathDirectionDataFrequency
Wind β†’ MountainIPC invokeSwallowed events routed via RedirectBusPer user interaction
Wind β†’ Mountaindiagnostic:logAuditLog flush (30s)Every 30 seconds
Output β†’ Mountaindiagnostic:logLandDiagnostics flush (30s)Every 30 seconds
Wind β†’ CocoongRPCSCM operations (git via Cocoon)Per git operation
Cocoon β†’ Wind/Mountainesbuild define__LandTier_Shim__ constantBuild time only

πŸ”΅ TierShim Propagation Chain: .env.Land β†’ esbuild β†’ Runtime

graph LR
    subgraph DEV["Developer Config"]
        ENV[".env.Land\nTierShim=None"]
    end

    subgraph BUILD["Build Pipeline"]
        TES["TierEnvironment.sh\nsources .env.Land\nreads TierShim=Proxy"]
        CED["CocoonEsbuildDefine\nJSON: __LandTier_Shim__ = Proxy"]
        WES["Wind ESBuild.ts\nesbuild define:\nJSON.parse(CocoonEsbuildDefine)"]
        OES["Output ESBuild.ts\nesbuild define:\nJSON.parse(CocoonEsbuildDefine)"]
        CES["Cocoon ESBuild.ts\nesbuild define:\nJSON.parse(CocoonEsbuildDefine)"]
    end

    subgraph RUST["Rust Compilation"]
        MBR["Mountain build.rs\ncargo:rustc-env=TierShim=Proxy"]
        MGATE["Gate.rs\\nconst TIER_SHIM: &str = env!(TierShim);"]
    end

    subgraph RUNTIME["Runtime (TS)"]
        WGATE["Wind Gate.ts\ndeclare const __LandTier_Shim__: string;\nconst Level = __LandTier_Shim__ || None;"]
        OGATE["Output Init.ts\nconst TierShim = __LandTier_Shim__ || None;"]
    end

    ENV --> TES
    TES --> CED
    CED --> WES
    CED --> OES
    CED --> CES
    TES --> MBR
    MBR --> MGATE
    WES --> WGATE
    OES --> OGATE

    style ENV fill:#f0f0f0,stroke:#999
    style CED fill:#7C3AED,stroke:#6d28d9,color:#fff
    style MGATE fill:#7C3AED,stroke:#6d28d9,color:#fff
    style WGATE fill:#2563EB,stroke:#1d4ed8,color:#fff

Step-by-Step Propagation

1. Source: .env.Land

# .env.Land (developer configuration)
TierShim=None          # Options: None | Proxy | Replace | Own | Preempt
TierSwallowStatusBar=Swallow
TierSwallowSCM=Swallow
# ... per-domain toggles ...

2. Shell: TierEnvironment.sh

#!/bin/bash
# Sources .env.Land, exports all Tier* vars
source .env.Land
export TierShim
export TierSwallowStatusBar
# ...

3. JSON: CocoonEsbuildDefine

// Cocoon/Source/Bootstrap/Implementation/Cocoon/Main.ts
// Reads process.env.TierShim and generates esbuild define map
const CocoonEsbuildDefine = JSON.stringify({
    __LandTier_Shim__: JSON.stringify(process.env.TierShim || "None"),
    __LandDevMode__: JSON.stringify(process.env.NODE_ENV !== "production"),
    // ... 15+ TierSwallow* vars ...
});
// Written to disk: CocoonEsbuildDefine = '{"__LandTier_Shim__":"\\\"Proxy\\\""}'

4. esbuild: Wind/Output/Cocoon ESBuild.ts

// Wind ESBuild.ts
const define = JSON.parse(CocoonEsbuildDefine);
await esbuild.build({
    define,  // esbuild substitutes __LandTier_Shim__ β†’ "Proxy"
    treeShaking: true,  // Dead-code-eliminate TierShim=None branches
});

5. Runtime: TypeScript declare const

// Wind/Source/Shim/Gate.ts
declare const __LandTier_Shim__: string;
// At runtime after esbuild: __LandTier_Shim__ is literally the string "Proxy"
const Level: ShimLevel = (__LandTier_Shim__ || "None") as ShimLevel;
const IsEnabled = Level !== "None";

// Output/Source/Service/CEL/Land/Shim/Init.ts
const TierShim = typeof __LandTier_Shim__ !== "undefined" ? __LandTier_Shim__ : "None";
if (TierShim === "None") { /* dead code when TierShim !== None */ }

6. Rust: build.rs β†’ env!

// Mountain/build.rs
fn main() {
    let tier_shim = std::env::var("TierShim").unwrap_or_else(|_| "None".to_string());
    println!("cargo:rustc-env=TierShim={tier_shim}");
}

// Mountain/Source/Shim/Gate.rs
const TIER_SHIM: &str = env!("TierShim");
pub fn is_enabled() -> bool { TIER_SHIM != "None" }

Dead Code Elimination Guarantee

TierShimesbuild defineWind Shim bundleOutput Shim bundle
None"None"0 bytes (tree-shaken)0 bytes (tree-shaken)
Proxy"Proxy"AuditLog + Gate onlyAudit-only
Replace"Replace"Audit + Replace logicNull services + Replace
Own"Own"Full shim (no BrowserMain)Full 6 hooks
Preempt"Preempt"Full shim + BrowserMainFull 6 hooks + Preempt

πŸ”΅ RedirectBus: Central Nervous System

// From: Wind/Source/Shim/RedirectBus.ts
// Every swallowed event flows through here

interface RedirectHandler {
    /** The pattern this handler accepts (prefix or regex) */
    pattern: string;

    /** Handle the swallowed event and return a result */
    handle: (method: string, params: unknown[]) => Promise<unknown>;
}

class RedirectBus {
    private static handlers: RedirectHandler[] = [];

    /** Register a handler. First match wins. More-specific patterns first. */
    static register(handler: RedirectHandler): void {
        const existing = this.handlers.findIndex(h => h.pattern === handler.pattern);
        if (existing >= 0) {
            this.handlers[existing] = handler;  // Replace duplicate
            return;
        }
        this.handlers.push(handler);
    }

    /** Route a swallowed event to the matching handler */
    static async route(method: string, params: unknown[]): Promise<unknown> {
        for (const handler of this.handlers) {
            if (methodMatches(handler.pattern, method)) {
                return await handler.handle(method, params);
            }
        }
        console.warn(`[Shim:RedirectBus] No handler for swallowed method: ${method}`);
        return undefined;
    }
}

Handler registration lifecycle:

  1. App startup β†’ Land services register their handlers on the RedirectBus
  2. User interaction β†’ SwallowMap decides to SWALLOW an IPC method
  3. IPCInterceptor β†’ Routes to RedirectBus.route(method, params)
  4. RedirectBus β†’ Finds first matching handler by pattern
  5. Handler β†’ Processes event, returns result
  6. Result β†’ Returned to the caller as if VS Code handled it

Example: Status bar handler registration:

// During Wind's StatusBarService bootstrap:
RedirectBus.register({
    pattern: "statusbar:",
    handle: async (method: string, params: unknown[]) => {
        switch (method) {
            case "statusbar:set":
                return LandStatusBar.setText(params[0] as string);
            case "statusbar:setEntry":
                return LandStatusBar.setEntry(params[0] as string, params[1]);
            default:
                throw new Error(`Unknown statusbar method: ${method}`);
        }
    },
});

πŸ”΅ NetworkProxy: Telemetry Blackhole

// From: Wind/Source/Shim/NetworkProxy.ts

const TelemetryPatterns = [
    "dc.services.visualstudio.com",
    "vortex.data.microsoft.com",
];

// fetch() interception:
globalThis.fetch = function (input, init) {
    const url = extractUrl(input);

    // πŸ”΄ Discard Microsoft telemetry silently (returns 204)
    if (isTelemetryEndpoint(url)) {
        return Promise.resolve(new Response(null, { status: 204 }));
    }

    // 🟠 Route vscode-file:// through Mountain scheme handler
    if (url.startsWith("vscode-file://")) {
        return handleVscodeFileRequest(url, init);
    }

    // πŸ”΅ Route extension gallery queries to Land's gallery service
    if (isGalleryEndpoint(url)) {
        return handleGalleryRequest(url, init);
    }

    return originalFetch(input, init);
};

// XMLHttpRequest interception:
XMLHttpRequest.prototype.send = function (body) {
    const url = this.__land_url;
    if (isTelemetryEndpoint(url)) {
        this.abort();  // Silent abort
        return;
    }
    return OriginalSend.call(this, body);
};

Three network interception targets:

TargetDetectionActionStatus
Microsoft Telemetrydc.services.visualstudio.com, vortex.data.microsoft.comReturn 204 or abort XHRβœ… Active
Extension Gallerymarketplace.visualstudio.com, open-vsx.orgRoute to Land GalleryServiceπŸ”Ά Placeholder (501)
vscode-file:// URIsURL scheme checkRoute to Mountain scheme handlerπŸ”Ά Placeholder (501)

πŸ”΅ Service Replacement Strategy (TierShim=Replace)

When TierShim=Replace, the LandShimInit() function in Init.ts performs service-level replacement by wrapping ServiceCollection.get():

// From: Output/Source/Service/CEL/Land/Shim/Init.ts

function replaceTelemetryService(sc) {
    const originalGet = sc.get.bind(sc);

    sc.get = function (id) {
        const idStr = String(id);
        if (idStr.toLowerCase().includes("telemetry") ||
            idStr.toLowerCase().includes("itelemetry")) {
            return createNoopTelemetryService();
        }
        return originalGet(id);
    };
}

function createNoopTelemetryService() {
    return {
        setEnabled: function () {},
        telemetryLevel: { value: 0, onDidChange: { Event: () => ({ dispose() {} }) } },
        publicLog: function () {},
        publicLog2: function () {},
        publicLogError: function () {},
        publicLogError2: function () {},
        setExperimentProperty: function () {},
        setCustomEndpoint: function () {},
    };
}

Replace strategy: Instead of replacing the module file (which requires tracking VS Code’s module graph), Land intercepts the ServiceCollection.get() call and returns a no-op shim when VS Code requests a telemetry service. This is less invasive than module replacement and works regardless of how VS Code imports the service.

The CEL Null Service modules provide a second layer of replacement: Output Transform reduces the original VS Code module body to a one-line re-export pointing at the CEL null service. This double-coverage ensures telemetry is neutralized even if some code imports the module directly rather than going through ServiceCollection.


πŸ”΅ COVERAGE TELEMETRY - ACTIVE - This component tracks service resolution, event routing, and domain coverage. All data flows through Land’s diagnostic pipeline (OTLP/PostHog/dev log). No data leaves the local machine.