Inspired by openai/codex#26966 (closed not planned). codex_goal.py is a standalone CLI that stores one versioned, project-keyed goal per repo outside Codex's own sandbox, and injects it as plain user context on every new or resumed `codex exec` run. Writes are atomic and locked, runs never mutate the goal, Codex is spawned via argv (no shell), and signals are forwarded for normal cancellation behavior. 16 unit tests plus a recorded two-run + crash-recovery demo, verified on macOS and in the project's Colima Linux container. Launch page at ventures/codex-goal/site/index.html uses a self-contained scoreboard/arcade identity (vendored OFL DSEG7 font, no external requests) distinct from the other ventures. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
41 lines
1.1 KiB
Python
Executable File
41 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Deterministic stand-in for the real `codex` binary, used only by tests/demo.
|
|
|
|
Records the exact argv it received (proof there was no shell interpolation),
|
|
optionally sleeps so a test can send SIGINT/SIGTERM and check cancellation
|
|
is forwarded, then exits with a configurable code.
|
|
"""
|
|
import json
|
|
import os
|
|
import signal
|
|
import sys
|
|
import time
|
|
|
|
|
|
def main() -> int:
|
|
record_path = os.environ.get("FAKE_CODEX_RECORD")
|
|
if record_path:
|
|
with open(record_path, "w") as fh:
|
|
json.dump({"argv": sys.argv[1:], "pid": os.getpid()}, fh)
|
|
|
|
sleep_s = float(os.environ.get("FAKE_CODEX_SLEEP", "0"))
|
|
if sleep_s:
|
|
caught = {}
|
|
|
|
def handler(signum, _frame):
|
|
caught["signal"] = signum
|
|
|
|
signal.signal(signal.SIGINT, handler)
|
|
signal.signal(signal.SIGTERM, handler)
|
|
end = time.time() + sleep_s
|
|
while time.time() < end and "signal" not in caught:
|
|
time.sleep(0.02)
|
|
if "signal" in caught:
|
|
return 130
|
|
|
|
return int(os.environ.get("FAKE_CODEX_EXIT", "0"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|