Commit d8a5894
fix(mcp): keep REMAINDER flags from swallowing later flags in kwargs_to_argv
The MCP server re-encodes tool-call kwargs into an argv list that is fed to
the same argparse parser the REPL uses, so the two paths must parse to the
same Namespace. Two argv-marshalling bugs broke that parity:
* _argv.py: an append action with nargs=REMAINDER (commit -m, lock -c) was
emitted into the flag list. A flag declared *after* it -- notably
-T/--template added by _add_template_arg for commit/lock -- was then
emitted behind it and swallowed by the REMAINDER, corrupting the
message/comment and leaving template=None (a wrong fan-out across every
loaded template). Route append+REMAINDER into the positional tail, exactly
as the optional-REMAINDER path already does, so later flags stay safe
regardless of parser._actions declaration order.
* session.py start_jobs: a fanned-out job was scoped with
[*argv, "-T", rrid]. For a positional nargs=REMAINDER command (run) the
trailing -T rrid was swallowed into command, so template stayed None and
-T <RRID> leaked into the remote shell command. Prepend the scope flag
(["-T", rrid, *argv]) so it is always parsed as a real flag.
Add tests/test_mcp_repl_parity.py: a reusable parity assertion parametrised
across the command matrix (both paths must parse to equal Namespaces),
dedicated regressions for both fixes (commit/lock -m/-c with a template, and
start_jobs scoping for a REMAINDER run plus a nargs='+' slow command), and a
safety check that a smuggled force kwarg cannot reach approve/reject.1 parent b545d98 commit d8a5894
4 files changed
Lines changed: 476 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
216 | 222 | | |
217 | 223 | | |
218 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
197 | | - | |
198 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
199 | 213 | | |
200 | 214 | | |
201 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1012 | 1012 | | |
1013 | 1013 | | |
1014 | 1014 | | |
1015 | | - | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
1016 | 1021 | | |
1017 | 1022 | | |
1018 | 1023 | | |
| |||
0 commit comments