Skip to content

feat(load): argument placeholders and --load-args-file so calls are not identical - #2908

Merged
cliffhall merged 4 commits into
v2/mainfrom
v2/feat/2840-load-arg-templates
Nov 5, 2026
Merged

cliffhall merged 4 commits into
v2/mainfrom
v2/feat/2840-load-arg-templates

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #2840

What

Calls in a --load run no longer have to be identical. This adds two mechanisms, usable together, in the one-shot CLI and mcpdo tools/call --load:

  • Placeholders in any string value of a call's arguments: --tool-arg, --tool-args-json, an args-file row, and a scenario step's args and uri (--load: scenario file with a weighted mix of tools, resources/read and prompts/get #2839).
    • {{seq}} is the call's number in start order, from 1. {{worker}} is the worker index, from 0. {{uuid}} is a fresh UUID v4. {{rand:<min>-<max>}} is a random integer, inclusive at both ends.
    • A value that is exactly one numeric placeholder (page={{rand:1-50}}) is sent as a number, so an integer-typed argument gets an integer. A placeholder embedded in other text yields a string.
    • Any other double-brace text ({{name}}) is sent as written, so a Mustache-style argument is untouched.
    • A reversed or unsafe rand range is refused before anything connects, with load_args_invalid (exit 1).
  • --load-args-file <file> (NDJSON, one argument object per line): call n takes row (n-1) mod rows, merged over the flag arguments with the row winning on a key. --load-args-random picks a row at random instead.
    • Rows are validated up front: each line must be a JSON object, a number that overflows to Infinity is refused, and placeholders are checked.
    • It is refused with --load-scenario, whose steps carry their own args.
    • Like the scenario file, it is read by the front-end process (the CLI, or mcpdo's client), so relative paths resolve against the caller's cwd.

How

  • New core/cli/handlers/load-template.ts: placeholder check and compile (once per run, before the clock starts; values with no placeholder are reused rather than copied), args-file parsing and reading, and the per-call argument template for a tool load.
  • Engine: runLoad's call now receives the 1-based seq, and runLoadAcrossConnections hands each call a { seq, worker } context. LoadOptions.argRows carries the rows to the daemon.
  • Templating applies only under --load. A plain tools/call still sends {{seq}} literally.

Tests

  • clients/cli/__tests__/load-template.test.ts: compile, check and args-file unit tests, plus end-to-end runs against the HTTP test server that assert on the arguments the server actually received (call-1..4, row cycling over --tool-arg, random rows), and the refusals.
  • clients/mcpdo/__tests__/load.test.ts: flag rules, and a live-daemon run whose alternating valid/invalid rows show the rows reached the daemon (2 ok, 2 failed).

Docs: CLI README (flag rows + "Varying the arguments" section), mcpdo README, skills/mcpdo/SKILL.md. npm run local:gate green.

🤖 Generated with Claude Code

cliffhall and others added 2 commits November 5, 2026 04:13
…ot identical (#2840)

{{seq}}, {{worker}}, {{uuid}} and {{rand:min-max}} in --load argument values
(and scenario args/uri) are substituted per call; a whole numeric placeholder
becomes a number. --load-args-file supplies NDJSON argument rows merged over
--tool-arg, in turn or (--load-args-random) at random.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Nov 5, 2026
@cliffhall cliffhall linked an issue Nov 5, 2026 that may be closed by this pull request
2 tasks done
@cliffhall
cliffhall requested a balanced review from Copilot November 5, 2026 09:19

Copilot AI 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.

🟡 Changes recommended

Unresolved issues cause oversized datasets to fail at the IPC limit, drop own __proto__ keys during templating, and pass numeric URIs to a resource API that requires strings.

3 open issues
What changed in this PR

Adds per-call argument variation to load testing in the one-shot CLI and mcpdo, helping exercise caching and per-key behavior through the shared load engine.

Changes:

  • Adds placeholders and NDJSON argument rows with sequential or random selection.
  • Passes sequence and worker context through load calls and expands scenario arguments and resource URIs.
  • Adds flag validation, automated coverage, and usage documentation.
File Description
skills/​mcpdo/​SKILL.md Documents varying load arguments.
core/​cli/​handlers/​load-test.ts Threads call context through execution and applies templates.
core/​cli/​handlers/​load-template.ts Implements placeholder expansion and argument-file handling.
core/​cli/​handlers/​load-scenario.ts Validates placeholders in scenario inputs.
clients/​mcpdo/​src/​connection/​mcp.ts Registers argument-file flags.
clients/​mcpdo/​src/​connection/​load-flags.ts Validates options and loads rows before daemon dispatch.
clients/​mcpdo/​README.md Documents new flags and argument variation.
clients/​mcpdo/​__tests__/​load.test.ts Tests flag rules and row delivery through the daemon.
clients/​cli/​src/​cli.ts Integrates flags, validation, and argument-file loading.
clients/​cli/​README.md Explains placeholders and argument-file behavior.
clients/​cli/​__tests__/​load-template.test.ts Adds unit and end-to-end coverage for varying arguments.

Review effort: Balanced

Comment thread core/cli/handlers/load-template.ts Resolved
Comment thread core/cli/handlers/load-test.ts Resolved
- Refuse a scenario or args file too large for one daemon request up front,
  instead of failing as an unreachable daemon.
- Build templated objects with Object.fromEntries so an own __proto__ key is
  copied as data.
- Send a resources/read URI that is one numeric placeholder as a string.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1 (review 5782502661), all three fixed in be13a2f:

  • Oversized args file or scenario vs. the 1 MiB daemon request line: now refused up front in mcpdo (load_args_invalid / load_scenario_invalid), naming the size and the limit.
  • Own __proto__ keys dropped by templating: objects are now built with Object.fromEntries.
  • A numeric-placeholder URI passed as a number: now converted to a string.

local:gate green. Requesting round 2.

Copilot AI 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.

🔵 Needs a closer look

Safe integer endpoints can still yield an unsafe inclusive range size, making the upper bound unreachable; unsafe spans need validation before connecting and a boundary regression test.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Reject unsafe inclusive random range spans

core/​cli/​handlers/​load-template.ts:63

Safe integer endpoints can still produce an unsafe inclusive range size. For example, {{rand:-9007199254740991-1}} passes validation, but rounding makes its upper endpoint 1 unreachable, even with the largest representable random draw below 1. Reject unsafe inclusive spans before connecting, and add a boundary regression test.

3 resolved since last review

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 2 (review 5782718751): no inline comments. The one finding was in the "previously missed issue" block, so it has no thread and is answered here. Fixed in ec24895:

  • Safe endpoints with an unsafe inclusive span ({{rand:-9007199254740991-1}}): the check now also requires max - min + 1 to be a safe integer, so such a range is refused before connecting (load_args_invalid). There are boundary tests for that case and for the widest allowed span ({{rand:0-9007199254740990}}), and the README notes the span rule.

local:gate green. Requesting round 3.

Copilot AI 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.

🟢 Approval recommended

No active review issues block the load-testing argument-variation changes.

No open issues 🎉

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review loop closed: round 3 (review 5782913645) was clean, with no inline comments, no headline finding and no suppressed block. All findings from rounds 1 and 2 were fixed.

@cliffhall
cliffhall merged commit 9a3d6c7 into v2/main Nov 5, 2026
12 checks passed
@cliffhall
cliffhall deleted the v2/feat/2840-load-arg-templates branch November 5, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--load: argument templating or a data file so calls are not identical

2 participants