Skip to content

Commit 4c0eede

Browse files
committed
Fix intermixed steering arguments on Python 3.11
The first cross-platform CI run exposed a pre-existing argparse difference: steer RUN --mode queue "guidance" rejects the guidance on Python 3.11, although local Python 3.14 accepts it. Dispatch the subcommand before using intermixed argument parsing, preserving root options and command help. Add a platform regression for guidance before/after options and literal leading-dash guidance. Refresh CI actions to current Node 24 releases. Validation: reproduced the parser failure on Python 3.11 before the fix; all 18 platform tests pass there (4 Windows-only skips); actionlint passed. Full Python 3.11 offline suite and cross-platform CI are pending. Agent: Codex
1 parent 118347b commit 4c0eede

4 files changed

Lines changed: 35 additions & 4 deletions

File tree

‎.github/workflows/consilium-smoke.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
PYTHONDONTWRITEBYTECODE: '1'
3333
PYTHONIOENCODING: utf-8
3434
steps:
35-
- uses: actions/checkout@v4
36-
- uses: actions/setup-python@v5
35+
- uses: actions/checkout@v7.0.1
36+
- uses: actions/setup-python@v7.0.0
3737
with:
3838
python-version: '3.11'
3939

‎skills/agents-consilium/references/testing.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ native Python (3.11+). These tests spend no model tokens and cover all steer
4848
imports, non-destructive PID probes, locks shared by two processes, nonblocking
4949
wait deadlines, exclusive session claims/no replay, process-tree cleanup,
5050
terminal-guard shutdown, and native supervisor Codex continuation. Windows also
51-
checks Python/shell/batch launcher argument handling. Symlink rejection is
51+
checks Python/shell/batch launcher argument handling. Steering guidance after
52+
options is tested on Python 3.11 as well as newer runtimes. Symlink rejection is
5253
checked where the OS permits creating symlinks.
5354

5455
GitHub Actions runs these checks on Windows, Linux, and macOS, plus LF-only

‎skills/agents-consilium/scripts/lib/steer/control.py‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,23 @@ def main(argv: Optional[list] = None) -> int:
928928
ls.add_argument("--json", action="store_true")
929929
ls.set_defaults(func=cmd_list)
930930

931-
args = p.parse_args(argv)
931+
# Python 3.11's ordinary subparser rejects optional positional guidance
932+
# after flags (steer RUN --mode queue "text"). Intermixed parsing supports
933+
# that public syntax, but cannot itself handle subparsers. Dispatch the
934+
# command first, keeping its remaining arguments opaque, then parse them.
935+
dispatch = argparse.ArgumentParser(prog=p.prog, add_help=False)
936+
dispatch.add_argument("-h", "--help", action="store_true")
937+
dispatch.add_argument("--registry-root", default=os.environ.get("CONSILIUM_STEER_DIR", ""))
938+
dispatch.add_argument("cmd", nargs="?", choices=sub.choices)
939+
dispatch.add_argument("command_args", nargs=argparse.REMAINDER)
940+
header = dispatch.parse_args(argv)
941+
if header.help or header.cmd is None:
942+
# Preserve the complete top-level help and missing-command diagnostic.
943+
args = p.parse_args(argv)
944+
else:
945+
args = sub.choices[header.cmd].parse_intermixed_args(header.command_args)
946+
args.cmd = header.cmd
947+
args.registry_root = header.registry_root
932948
if not args.registry_root:
933949
args.registry_root = ""
934950
# empty --client-id → None so mailbox generates one

‎skills/agents-consilium/scripts/tests/platform_test.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ def test_all_modules_import(self):
4646
importlib.import_module(module.name)
4747
importlib.import_module("terminal_guard")
4848

49+
def test_steer_guidance_after_flags_and_root_option(self):
50+
from steer import control
51+
for tail in (["guidance text", "--mode", "queue"],
52+
["--mode", "queue", "guidance text"],
53+
["--mode", "queue", "--", "--literal guidance"]):
54+
captured = []
55+
with patch.object(control, "cmd_steer", side_effect=lambda args: captured.append(args) or 0):
56+
result = control.main(["--registry-root", str(self.root), "steer", "run_test", *tail])
57+
self.assertEqual(result, 0)
58+
self.assertEqual(captured[0].guidance, "--literal guidance" if "--" in tail else "guidance text")
59+
self.assertEqual(captured[0].mode, "queue")
60+
self.assertEqual(captured[0].registry_root, str(self.root))
61+
self.assertEqual(captured[0].run_id, "run_test")
62+
4963
def test_liveness_does_not_kill(self):
5064
child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(30)"])
5165
try:

0 commit comments

Comments
 (0)