Skip to content

feat: add native process command inspection - #3

Merged
steipete merged 11 commits into
mainfrom
koffi/p1-inspect
Oct 10, 2026
Merged

steipete merged 11 commits into
mainfrom
koffi/p1-inspect

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Adds the lazy @openclaw/proc-safe/inspect subpath with readProcessCommand() for Darwin and Windows and listProcesses() for Windows. It returns exact argument boundaries, Windows raw command line and cwd, and only requested environment keys. Windows matches environment names case-insensitively and returns the caller's spelling; Darwin matches exactly. Invalid encoding throws rather than replacing bytes.

The Windows census returns every enumerated PID with an optional identity, an explicit same/different/unknown owner, and an optional command. PIDs remain as observation rows when their details are inaccessible or they exit during observation. Each row's facts use one retained process handle, and owner comparison uses validated token SIDs. A relative monotonic timeout and a 65,536-PID cap reject the entire call on timeout or incomplete enumeration. The census never returns environment values.

Darwin parsing follows XNU's executable-path alignment rather than skipping every NUL, preserving an empty argv[0] without consuming environment data. Ambiguous boundaries between envp and Apple startup metadata fail closed. Rust refuses Rosetta inspection before argument reads. Windows validates native and WOW64 layouts and bounds all foreign-memory reads. Results and nested observations are frozen; imports never load native code.

Proof includes real main-thread and Worker inspection of native and 32-bit Windows children; owner comparison; protected process rows retaining unknown facts; forced-short timeout rejection; case-insensitive environment selection; empty, quoted, and Unicode arguments; post-exit behavior; all eight suspended Darwin environment alignments; permission denial; and real Rosetta refusal. Native runtime CI also preserves Linux and FreeBSD import/unsupported behavior. No shell fallback, owner filtering, or application admission policy is added.

Validation: all 24 required checks passed on b5c4466912f22621b7fa5a3a7b07ab52e597f471 in this CI run. Independent review is clean. Local Node and Bun checks passed 78 tests with six platform-specific skips; all 15 inspection tests passed. Host and Windows x64/arm64 Clippy, isolated npm/pnpm package installs, and real Darwin denial checks passed. Cold import medians: Node 3.26 ms, Bun 2.81 ms (10 fresh processes each).

The protected-process fixture waits for startup readiness before denying access. The caller-token fixture initializes both runtime contexts before denying token access, preserving the existing total 30-second budget. These proofs retain every denial and timeout assertion. No merge or release has been performed.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

Adds Darwin and Windows process-command inspection, selected environment reads, and a bounded Windows process census.

Example: Inspect a Windows child with arguments ["spaces stay together", "", "é🦞"] and PROC_SAFE_VISIBLE=chosen.

  • Before: The package has no command-inspection API.
  • After: readProcessCommand preserves the argument boundaries and returns PROC_SAFE_VISIBLE when explicitly requested.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A coherent native feature with no actionable findings; confidence rests on source inspection and real OS harness validation.
Proof confidence 🦐 gold shrimp (3/6) Under the supplied maintainer-authored classification, the ordinary contributor proof gate does not apply; inspected harnesses and reviewed-head jobs cover native inspection, census uncertainty, permission denial, Workers, and Rosetta.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Callers cannot inspect native process commands or enumerate Windows processes through this package.
Reason: The supplied MEMBER classification establishes owner direction, and the capability matches the repository's inspection purpose and existing feature ownership.

Merge readiness

✅ Ready for maintainer review

This PR adds a useful capability absent from current main; source review found no concrete introduced defect.

Priority: P2
Reviewed head: 228916065c1cd8255ae539ae71876977ecbc6958

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence exercises real OS paths through repository harnesses rather than a separate recorded consumer scenario.
Agent review details

How this fits together

The lazy TypeScript inspection subpath passes validated requests to native OS observers and returns frozen process facts or typed errors.

flowchart TD
Caller --> InspectAPI
InspectAPI --> LazyBinding
LazyBinding --> DarwinArguments
LazyBinding --> WindowsHandle
DarwinArguments --> FrozenObservations
WindowsHandle --> FrozenObservations
Loading

Technical review

Best possible solution:

Retain the focused native capability with bounded observations, explicit uncertainty, and lazy loading.

Do we have a high-confidence way to reproduce the issue?

This is an additive feature; current-main source confirms that the requested APIs are absent.

Is this the best way to solve the issue?

The implementation fits the package contract by reporting native observations without adding application admission policy or shell fallbacks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 909a21190b5e.

Provenance checked

  • Windows identity handle reuse keeps the original intent (5852b3e: Retain a process object across birth, parent, and exit observations, including exit-code-259 disambiguation.)
  • Permission-denial fixtures keeps the original intent (feat: add process identity and Darwin coalition capabilities #1: Verify real denial with restricted-token main-thread and Worker observations.)
  • Lazy exports and consumer validation keeps the original intent (346064d: Expose capabilities through separate lazy subpaths and validate installed main-thread and Worker consumers.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 5852b3e adds native/src/identity/windows.rs:60 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5852b3e263bf; files: native/src/identity/windows.rs)

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Useful additive inspection functionality with limited platform scope and no demonstrated urgent regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (8 earlier review cycles)
  • reviewed 2026-10-10T07:03:09.673Z sha 7be7d72 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T07:08:39.635Z sha 3e48355 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T07:34:51.279Z sha 3e48355 :: needs changes before merge. :: none
  • reviewed 2026-10-10T08:10:33.490Z sha ca91daf :: needs changes before merge. :: [P2] Accept the observed Darwin kernel refusal in the oversized-argument proof
  • reviewed 2026-10-10T08:27:55.367Z sha 1e3b6af :: needs changes before merge. :: none
  • reviewed 2026-10-10T08:46:54.964Z sha 3338934 :: needs changes before merge. :: none
  • reviewed 2026-10-10T09:12:37.623Z sha b243948 :: needs changes before merge. :: none
  • reviewed 2026-10-10T09:35:45.952Z sha b5c4466 :: needs maintainer review before merge. :: none

Reviewed October 10, 2026, 6:04 AM ET / 10:04 UTC (Revision 9).

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 10, 2026
@steipete
steipete force-pushed the koffi/p1-inspect branch 2 times, most recently from b243948 to b5c4466 Compare October 10, 2026 09:23
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@steipete
steipete marked this pull request as ready for review October 10, 2026 09:43
@steipete
steipete merged commit f44b488 into main Oct 10, 2026
24 checks passed
@steipete
steipete deleted the koffi/p1-inspect branch October 10, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant