Skip to content

refactor(process): require the platform for environment snapshots instead of reading the host - #11028

Merged
morluto merged 1 commit into
mainfrom
refactor/host-platform-process
Nov 15, 2026
Merged

morluto merged 1 commit into
mainfrom
refactor/host-platform-process

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

snapshotEnvironment and mergeEnvironmentOverrides (src/process) take the platform as a required parameter instead of defaulting to process.platform. Callers that already hold a platform pass it; the others pass HOST_PLATFORM.platform at the call site, so the ambient host choice is visible where it is made. Slice of the HostPlatform migration (W8) after #10911.

Problem and expected behavior

Both helpers decide Windows case-folding of environment names from a platform = process.platform default. A caller describing another host (a Windows client row inspected from macOS) could silently get the running host's folding, and tests could only select a platform by redefining process.platform. Expected: every call names the platform whose environment rules apply.

Change and scope

  • src/process/snapshotEnvironment.ts: platform is required on both helpers; the module no longer reads process.platform (baseline entry removed via --shrink-baselines).
  • Callers with a platform in scope pass it (composition/binary.ts now names HOST_PLATFORM.platform once as platform for the deep binary session and reuses it). Callers without one (providers in adb, android, apktool, browser, evm, firmware, ida, javascript, native, pcap, wasm, server, main, cli, composition, two application modules) pass HOST_PLATFORM.platform; Ghidra passes its optional installation-host platform or HOST_PLATFORM.platform.
  • Two tests pass process.platform explicitly.
  • Not included: the remaining process.platform reads in src/process (next PR) and in each provider folder; those callers will take the platform as a parameter when their folder migrates, replacing the call-site HOST_PLATFORM.platform. No behavior change: every call resolves to the same platform value as before.
  • Scope: internal refactor; no target execution, injection, mutation or protection recovery.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/platform/HostPlatform owns the host read; snapshotEnvironment owns environment folding for a named platform.
  • Contribution scope fit and linked maintainer decision: not applicable (refactor in the approved cleanup plan).
  • CLI and MCP/tool-catalog contract: unchanged.
  • Provider, bridge, target-format, or platform compatibility: unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/filesystem/clientConfigurationEnvironment.test.ts and tests/boundary/native/pwndbgReplyFinalization.test.ts pass the platform explicitly. The type checker enforces the required parameter at every call; the counted ambient-host-platform guard drops one file (2 reads).
  • Base reproduction or other evidence: source-derived (refactor).
  • User-visible CLI/MCP output (if applicable): none.
  • Remaining proof gaps: Windows hosts not run locally.

Validation performed

  • npx tsc --noEmit -p . — passed.
  • npm run test:focused -- src/process/snapshotEnvironment.test.ts src/browser/modules/NativeModuleResolver.test.ts tests/boundary/browser/historicalCaptureDecoder.test.ts tests/boundary/evm/evmCleanupRetry.test.ts tests/boundary/android/jadxDoctor.test.ts tests/process-global/pwntoolsCleanup.test.ts tests/process-global/pwntoolsCliRemediation.test.ts tests/process-global/hostRestrictedAvailabilityMcp.test.ts tests/boundary/filesystem/clientConfigurationEnvironment.test.ts tests/boundary/native/pwndbgReplyFinalization.test.ts src/setupEnvironment.test.ts — 212 passed, 12 skipped.
  • node scripts/verify/architecture-guards.mjs --shrink-baselines — passed.
  • npm run check:fast — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none (internal API).
  • Real Hopper/Ghidra, browser, or OS coverage: macOS only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no change in which environment reaches child processes.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T10:31:44.949021Z 1971ee0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no blocking issue was found.

Summary

snapshotEnvironment and mergeEnvironmentOverrides now require a platform. Callers pass their selected platform or explicitly choose HOST_PLATFORM.platform.

  • Environment snapshots now use the platform named by each caller.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  H["HOST_PLATFORM.platform"] --> C["Caller chooses platform"]
  P["Explicit platform"] --> C
  C --> S["snapshotEnvironment"]
  S --> M["mergeEnvironmentOverrides"]
  M --> E["Frozen environment with platform-specific names"]
Loading

Reviews (2) · Last reviewed commit: "refactor(process): require the platform ..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant