Skip to content

Let Cursor and Codex lanes run their shell and kb without stalling - #165

Merged
shanebarakat merged 4 commits into
mainfrom
fix/lane-startup-gaps
Dec 4, 2026
Merged

shanebarakat merged 4 commits into
mainfrom
fix/lane-startup-gaps

Conversation

@shanebarakat

@shanebarakat shanebarakat commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Two Factory lanes stalled on startup in the D07 run (d07-kit, 2026-12-02). This fixes both and adds one small read-only allowance.

Cursor Tester asked before running commands

Even with Shell(*) in the lane's .cursor/cli.json, Cursor asked "Run this command? Not in allowlist" for many commands. The cause is narrower than the allowlist format. Cursor never lets its allowlist approve a redirect whose target it can't resolve, such as cat > "$d/greet.sh", even inside the workspace. That's the shape a Tester uses to write stand-ins into mktemp -d folders. Behaviour is the same on cursor-agent 2026.11.22 and 2026.12.02, so this isn't a new Cursor regression. Older runs just never wrote files that way.

Fix: where agent --help lists --sandbox, a default lane (FACTORY_LANE_SANDBOX=on) now passes --sandbox enabled. Such a command then runs in Cursor's sandbox (writes to the workspace and temp folders, like a Codex lane) instead of asking. Commands the allowlist approves still run outside it, so ordinary commands behave as before. Deny rules and hooks still apply. FACTORY_LANE_SANDBOX=off still passes --sandbox disabled. The flag is kept with the turn, so resumes keep it. --force was ruled out because it also auto-approves every MCP tool.

Codex Coder could not run kb

Kinbase opens its SQLite stores and its sign-in lock for writing on every call, and the Codex workspace sandbox denied that. Kinbase's own chmod fix (kinbase#70) isn't enough on its own. The Codex lane profile (harness/codex_profile.py, used by both launch and resume) now also allows writes to the folders Kinbase's config names for its cache and personal data, plus its config folder, because a token refresh writes a .tmp-* file there and renames it over oidc.json under oidc.lock. Every other entry in that folder (keys, secrets, config.toml) and the names kb trusts there (client.key, maintainer.key, steward-*) are pinned read-only, so a lane can refresh its sign-in but can't change, delete, replace or plant kb's keys or config. Paths count only if they exist and are Kinbase-named folders below HOME. Without a Kinbase config the profile is byte-for-byte the old one.

Also

The Antigravity Orchestrator seat now allows the read-only kindex/status call it asked about in d07-kit.

Evidence

  • Token refresh (Adapt finding): kb's exact refresh file operations (lock, .tmp-* create, fsync, rename over oidc.json, fsync dir) replayed in codex sandbox on a real Kinbase folder: the previous profile fails with "Operation not permitted"; this one succeeds with oidc.json unchanged and mode 0600. Overwrite, delete, rename-over and planting of kb's keys and config are blocked. Same results on Codex 0.172.0 and 0.167.0.

  • Baseline throwaway run on the installed b04c32a: the Cursor Tester asked "Not in allowlist: cat, chmod, echo, grep, mktemp, printf, rm", and the Codex Coder's kb failed.

  • Same run on b04c32a plus this change: the Tester wrote 7 stand-ins with cat > "$var/greet.sh" and got 0 prompts, and the Coder's kb returned Kinbase results.

  • Kinbase under this profile answers on Codex 0.167.0, 0.171.0 and 0.172.0. Cursor's --sandbox exists in 2026.11.22 and later, and the gate skips it on a CLI without the flag.

  • New tests: Cursor gets --sandbox enabled only when its CLI has the flag (fails without the change). The Codex profile is unchanged without Kinbase, adds Kinbase's paths, and refuses a config naming HOME.

  • Full make test gives the same result as on main: the same 2 Codex resume tests time out on this machine in both. purity, wiring, typecheck and glossary pass. ruff reports 2 pre-existing issues on main in files this PR doesn't touch.

Not verified: Cursor versions before 2026.11.22 (none installed). Those are gated by the --help check.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Cursor Tester lanes stopped on "Run this command? Not in allowlist" even
with Shell(*). Cursor's allowlist never approves a redirect it cannot
resolve (e.g. `> "$d/x"`), on 2026.11.22 and 2026.12.02 alike. Where the
CLI has --sandbox, a default lane now passes `--sandbox enabled`: such a
command runs in Cursor's sandbox instead of asking, allowlisted commands
still run outside it, and deny rules and hooks still apply.

Codex Coder lanes could not run `kb`: Kinbase opens its SQLite stores and
sign-in lock for writing, which the workspace sandbox denies. The Codex
profile now also allows the cache and personal folders Kinbase's own
config names, and its oidc.lock file, only when they exist and are
Kinbase folders below HOME. Without Kinbase the profile is unchanged.

The Antigravity Orchestrator seat also allows the read-only kindex/status.
@shanebarakat shanebarakat added the Factory PR opened by the Factory label Dec 3, 2026

@adaptcom adaptcom Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Confidence Score: 4/5

Summary

Gates Cursor lanes into --sandbox enabled when the CLI has the flag and extends the Codex lane profile with Kinbase's config-named paths. Small, tested, profile unchanged without Kinbase; remaining issues are edge cases and a token-refresh gap.

Important Files Changed

File Overview
harness/codex_profile.py New Codex profile builder adding Kinbase cache/data dirs and oidc.lock
harness/tmux_lane.sh Cursor default lane adds --sandbox enabled when agent --help lists it
harness/tmux_lane_message.sh Resume recomputes the profile from current env instead of launch
harness/agents.py start_requires text explains the sandbox flag
harness/run_record.py Antigravity seat allows read-only kindex/status
tests/test_codex_profile.py Covers unchanged, Kinbase-named, and HOME-refusing configs
tests/test_cursor_ended_native_recovery.py Fake agent toggles --sandbox in help; flag asserted both ways

Findings

  • kb without a user config (or data_root) writes ${XDG_STATE_HOME:-~/.local/state}/kinbase, which the profile never opens; state that limit or add it.
  • harness/codex_profile.py is missing from the Makefile lint and typecheck lists (ruff and mypy both pass on it today).
  • docs/HARNESS.md Cursor permissions bullets (217-236) and the CursorAgent docstring still omit --sandbox enabled on default lanes.

Reviewed 2488390...85ea3d8 · ↻ Re-run review · View in Adapt

Comment thread harness/codex_profile.py Resolved
Comment thread harness/codex_profile.py Resolved
Comment thread harness/codex_profile.py Resolved
Comment thread harness/codex_profile.py Resolved
Comment thread harness/codex_profile.py Resolved
Comment thread harness/tmux_lane_message.sh Resolved
Read Kinbase's config from HOME, as kb in the lane does; refuse a path that
is or contains the token folder; ignore a non-table config section; keep
astral characters valid TOML. The launch saves the slot's profile and a
resume reuses it, so the recorded digest describes the resumed turn.
kb refreshes its id token by writing a .tmp-* file in its config folder and
renaming it over oidc.json under oidc.lock, so with only the lock writable it
failed once the token neared expiry. The config folder is now writable, and
every other entry in it (keys, secrets, config.toml) plus the names kb trusts
there are pinned read-only, so a lane can refresh but cannot change, delete,
replace or plant kb's keys. Verified in codex sandbox on 0.172.0 and 0.167.0.
@shanebarakat
shanebarakat merged commit 4bd3fde into main Dec 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Factory PR opened by the Factory

Development

Successfully merging this pull request may close these issues.

1 participant