Skip to content

Security decision: platform FFI for managed-agent runtime (process identity, Job Objects) #6047

Description

@jlwainwright

Context

PR #5954 (durable managed-agent runtime) needs three platform capabilities with no safe-Rust equivalent in std or existing deps:

  1. Process start-time identity (macOS proc_pidinfo(PROC_PIDTBSDINFO), Windows GetProcessTimes, Linux /proc/<pid>/stat — Linux side is already safe file reads) — used to detect PID reuse before resuming/terminating managed adapters.
  2. Windows Job Objects (CreateJobObjectW, AssignProcessToJobObject, TerminateJobObject) — crash-safe process-tree cleanup; std has nothing comparable.
  3. macOS proc_listpids — enumerate a process group's live members.

Current state

Repo policy (CONTRIBUTING.md § "No Unsafe Code"): all crates #![deny(unsafe_code)], exceptions to be discussed in an issue first. Existing precedent: crates/buzz-dev-mcp/src/shell.rs (git_bash_from_registry, KillGroup) already uses #[cfg(windows)] + fn-scoped #[allow(unsafe_code)] + SAFETY comments.

Proposal

  • Keep crate-level #![deny(unsafe_code)].
  • Allow fn/module-scoped #[allow(unsafe_code)] only in:
    • crates/buzz-runtime/src/artifacts.rs (process identity, macOS/Windows paths)
    • crates/buzz-runtime/src/windows_job.rs (Job Objects, windows-only)
    • crates/buzz-acp/src/job_runner.rs (process_group_has_live_members, macOS)
    • crates/buzz-acp/src/job_windows.rs (windows-only module)
  • Every block carries a SAFETY comment; every #[allow] cites this issue.

@themiguelamador — per your review on #5954: happy to restructure, but stdlib/tokio genuinely lack these APIs. If there's a preferred safe wrapper crate you'd accept instead, name it and I'll switch.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions