Skip to content

refactor(process): take the host from HOST_PLATFORM and require the platform in process helpers - #11038

Merged
morluto merged 2 commits into
mainfrom
refactor/host-platform-process-reads
Nov 15, 2026
Merged

morluto merged 2 commits into
mainfrom
refactor/host-platform-process-reads

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Removes every remaining process.platform / process.arch read from src/process (26 platform reads, 4 architecture reads; src/process leaves both counted baselines). Pure helpers take the platform as a required parameter; operations bound to the running host (spawning, /proc/self, the live process table, lease pipes) read HOST_PLATFORM. Tests that redefined process.platform for these modules now inject the platform. Follows #11028.

Problem and expected behavior

src/process decided host behavior from ambient process.platform in 17 files, partly as platform = process.platform defaults. A caller describing another platform could get the running host's rules, and tests selected Linux or Darwin branches by redefining global process properties. Expected: helpers name the platform they apply; host-bound operations take the host from its one owner.

Change and scope

  • Required parameter (callers pass the platform they hold): matchesOwnedProcessCommand, privateRuntimeRootCapability, resolveProcessScenarioRuntimePaths, captureProcessScenario (its signal becomes AbortSignal | undefined so the platform can follow), createSystemProcessOwnershipHost, observeSettlement, readLaunchNodeOptions, readLaunchExecArgv.
  • captureProcessScenario now passes its platform to resolveProcessScenarioRuntimePaths, which previously fell back to the ambient host.
  • Host-bound reads use HOST_PLATFORM: spawnOwnedProviderProcess (Windows job only on a Windows host), execFileOutput detach, OwnedLease pipe selection, Linux /proc start-time reads, Darwin helper cache, systemProcessOwnershipHost, launcher identity matching against the live process table, capture manifests and cleanup host, and optional options.platform ?? HOST_PLATFORM.platform seams that ~250 callers leave unset.
  • Tests: ProcessSampling.procReadCoverage, ProcessSamplingShutdown and processObservationCommandFinalization pass the sampler platform instead of redefining process.platform; ProcessOwnership.movedProbe selects Linux by mocking HostPlatform instead of the global. New RegexMatcher case: Darwin and Windows launch flags are unrecoverable on any host.
  • Not included: lifecycle logic (W4); provider and application call sites outside src/process; tests in other folders that stub process.platform (androidGuardianObservation, artifactSelectedCommand, pwntools, hostRestrictedAvailabilityMcp, ...) move with their modules.
  • 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; src/process helpers own platform rules for a named platform.
  • Contribution scope fit and linked maintainer decision: not applicable (approved cleanup plan, W8).
  • CLI and MCP/tool-catalog contract: unchanged.
  • Provider, bridge, target-format, or platform compatibility: unchanged on a real host; only a caller-selected platform that differs from the host now reaches scenario path resolution.
  • Evidence, artifact, provenance, or reconstruction contract: capture manifests still record the running host.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged.
  • 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: listed above; the converted tests keep their Linux/Darwin/FreeBSD branches through the injected platform.
  • Base reproduction or other evidence: source-derived (refactor); guard counts: ambient-host-platform 178 reads / 106 files, ambient-host-architecture 18 / 12 after this PR (from 204 / 122 after refactor(process): require the platform for environment snapshots instead of reading the host #11028).
  • User-visible CLI/MCP output (if applicable): none.
  • Remaining proof gaps: Windows and Linux hosts not run locally.

Validation performed

  • npx tsc --noEmit -p . — passed.
  • npm run test:focused -- src/process/RegexMatcher.test.ts src/process/capture/ProcessScenarioRuntimeValidation.test.ts tests/boundary/cli/ghidraJavaDoctor.test.ts tests/boundary/process/packedBridgeVerification.test.ts tests/boundary/process/processCaptureLifecycle.test.ts tests/boundary/process/processCaptureNormalization.test.ts tests/boundary/process/processCaptureSensitiveInput.test.ts tests/boundary/process/processCaptureTerminal.test.ts tests/boundary/process/regexMatcher.test.ts src/process/ProcessOwnership.movedProbe.test.ts src/process/capture/ProcessSamplingShutdown.test.ts src/process/capture/ProcessSampling.procReadCoverage.test.ts tests/boundary/process/androidGuardianObservation.test.ts tests/boundary/process/artifactSelectedCommand.test.ts tests/process-global/processObservationCommandFinalization.test.ts — 195 passed, 2 skipped (before the test conversions); converted files rerun — 47 passed, procReadCoverage 36 passed.
  • npm run test:focused -- 14 ownership/provider-process/lease/cgroup/helper-cache/exec files — 286 passed, 1 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 processes are spawned, owned or cleaned up.

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

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T10:38:38.648755Z
We couldn’t complete this review. Comment @codex review to try again.
9f069a8 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@RuijieRG180GD

Copy link
Copy Markdown

Requested labels: ubuntu-24.04
Job defined at: morluto/rea/.github/workflows/ci.yml@refs/pull/11038/merge
Waiting for a runner to pick up this job...
Evaluating changes.if
Evaluating: success()
Result: true

@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 reviewed changes appear safe to merge, with both earlier findings addressed.

Summary

Centralizes host checks on HOST_PLATFORM and requires callers to name the platform used by process helpers.

  • Process helpers now keep host facts separate from platform rules callers choose.

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

@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Correction to both thread replies: the fix commit is 9eb7a54 (not 8418a4d1cb).

@morluto
morluto merged commit 530faf4 into main Nov 15, 2026
7 checks passed
@morluto
morluto deleted the refactor/host-platform-process-reads branch November 15, 2026 11:35
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 22, 2026
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.

2 participants