Skip to content

Phase 1: spawn/env plumbing — thread env through rex runtimes + gate agent-cmd override (#89, #80)#97

Open
joctaTorres wants to merge 1 commit into
engine-issuesfrom
erh/phase-1-spawn-env-plumbing
Open

Phase 1: spawn/env plumbing — thread env through rex runtimes + gate agent-cmd override (#89, #80)#97
joctaTorres wants to merge 1 commit into
engine-issuesfrom
erh/phase-1-spawn-env-plumbing

Conversation

@joctaTorres

Copy link
Copy Markdown
Owner

Phase 1 of 4 — stacked batch engine-runtime-hardening. Base: engine-issues (pre-batch).

Closes #89
Closes #80

Stacked-PR note: best-effort per-phase split of entangled work — shared files land on the earliest phase, so this branch may not build standalone; the verified-green tree is the top of the stack (phase 3).

🤖 Generated with Claude Code

…ent-cmd override

Phase 1 of the engine-runtime-hardening batch.
- Both rex runtimes export AgentSpawnRequest.env before launching the agent,
  via one shared spawn-command helper (overlay merge semantics).
- RATCHET_BATCH/EVAL_AGENT_CMD overrides now print a notice, set agentOverride
  in --json, and stamp via:env-override provenance; one shared spawn-request
  helper dedups the override gate across engine/judge/mutation-harness.

Closes #89
Closes #80

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014hATZnT1NQP1STMr6pVxtm
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ratchet 27c10ef Commit Preview URL

Branch Preview URL
Jul 09 2026, 10:24 PM

@joctaTorres joctaTorres left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — observability lands cleanly; the security-relevant half of #80 is deferred

This closes the audit/integrity half of #80 well: the via: 'env-override' provenance on journal entries and eval run records (stamped at both producers — engine host loop and batch report invoked by the spawned stand-in) is what makes a done reached via a synthetic stub distinguishable from real agent work after the fact. The single-helper dedup (buildAgentSpawnRequest / activeAgentCmdOverride) and the agentOverride: true / notice surfacing are clean and well-tested.

Two things I want to flag for the record, since a reader could mistake this for having contained the override rather than surfaced it:

1. The override still fires unconditionally — no gating (deferred). RATCHET_BATCH_AGENT_CMD / RATCHET_EVAL_AGENT_CMD still hijack the agent on any leftover value (.envrc, CI, a prior eval session). #80's fix-proposal #3 (--allow-agent-override, or gate on NODE_ENV / RATCHET_TEST=1) was not implemented. Net effect: silently replacereplace with a warning, not refuse unless opted in. On its own that's a foot-gun rather than a vuln — the env-setter already has your shell privileges — but it crosses a trust boundary in the exact sources the issue names (a hostile repo's .envrc, CI env set by less-privileged config → command execution on the host).

2. Permissions bypass is untouched — this is the actual security concern (#80 problem #2). The override branch returns a bare bash -c <value> request with no adapter and no permission flags, so resolvePermissionFlags posture/deny never applies — while batch config continues to display the locked-down posture as if it were enforced. A safety control that reports itself active while being silently voided is worse than one that's visibly off, because it defeats the operator's ability to reason about what the spawned command can touch. This PR's goals are explicitly "loud, auditable, single-sourced"; permissions never appear in the plan, so the posture-lie survives.

Severity hinge: how bad #2 is depends on whether ratchet's permission flags are an enforced sandbox/containment boundary or advisory. If they're the real containment for autonomous runs, "bypassed while reporting enforced" is a legitimate finding worth a follow-up (or a batch config caveat when an override var is active).

Not blocking the observability work here — flagging that the security-relevant half of #80 (gating + permissions posture integrity) remains open after this closes #80, and should be tracked so it isn't assumed handled.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant