Skip to content

Architecture: fold TargetGOOS into a Runtime.Shell() abstraction #44

@zpzjzj

Description

@zpzjzj

Context (PR #33 self-review M7): internal/runtime.Runtime has TargetGOOS() string and internal/judge separately calls platform.Host(). When the runtime is NoneRuntime and host==target, the two channels agree. Any future "host=Windows + target=Linux" runtime (Docker, k8s, remote) breaks: the planner uses the host's bash to assemble a command that then runs in the target's shell.

Partial step landed in PR #33: TargetGOOS() was promoted to a required method on the Runtime interface so future runtimes don't silently default to linux. This is a stopgap — the underlying problem (two independent "what platform are we targeting" channels) is unchanged.

Proposal:

  • Add Shell() platform.HostShell to the Runtime interface (or a sub-interface). NoneRuntime returns platform.Host(); OpenSandboxRuntime returns a fixed POSIX descriptor.
  • Fold TargetGOOS() into Shell(): callers that currently do rt.TargetGOOS() == "windows" switch to inspecting the Shell descriptor (rt.Shell().IsBash, or a typed Shell().GOOS field). Then drop the standalone TargetGOOS() method from the interface — the in-PR addition was the cost of incomplete refactoring and should not survive.
  • Switch any remaining GOOS comparisons to use the platform.GOOSWindows / Linux / Darwin consts already added in PR feat: first-class Windows support across CLI, runtime, and judges #33.

Acceptance: every call site that today reads rt.TargetGOOS() either disappears or reads a structured field of rt.Shell(). The Runtime interface shrinks by one method overall (Shell + 0 other = TargetGOOS + nothing).

Tracked from: PR #33 self-review M7. PR #33 added the required-method stopgap; this issue tracks the proper resolution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions