Skip to content

feat: repeatable-arg support, merge refactor, and --flat mode for tools - #111

Merged
k-rister merged 3 commits into
masterfrom
fix-dup-param-collapse
Aug 17, 2026
Merged

k-rister merged 3 commits into
masterfrom
fix-dup-param-collapse

Conversation

@k-rister

Copy link
Copy Markdown
Contributor

Summary

  • Add repeatable: true validation-group flag so args like tool-kernel's sysfs-trace-setup/sysfs-trace-cleanup can appear more than once in a param set without being collapsed. A multi-valued single occurrence is rejected outright (the cartesian-product interaction is undefined and was silently producing wrong results).
  • Refactor the merge/preset infrastructure: replace the old param_exists() inline scan with a shared identity model (_identity_key, _find_by_identity) and a merge-function family (merge_param, merge_param_include, merge_param_own, merge_repeatable_param) that gives include, own-params, defaults, and essentials uniform duplicate-conflict diagnostics.
  • Refactor override_presets() to resolve defaults/essentials once via _resolve_preset_group() (filtering disabled entries before identity claiming), fixing bugs where a disabled essential could block an enabled one and essentials were destructively consumed on the first set in a multi-set input.
  • Fix include-preset handling that iterated every key in presets_dict instead of looking up the named group directly.
  • Add --flat CLI mode and apply_flat_params() as a narrow entry point for tools: validates/converts/transforms a flat {arg, val} list via override_presets() with force_role='all', reusing all existing merge/preset primitives without routing through load_param_sets()'s include handling or the cartesian-product engine.

Test plan

  • 104 tests pass, 5 xfail (87 for Part 1 alone, 17 added by Part 2)
  • Each test file passes in isolation (pytest multiplex.py tests/test-json.py, etc.)
  • End-to-end verified via crucible run with tool-kernel against a live remotehosts endpoint — apply_tool_multiplex() → multiplex.py --flat → tool-kernel's kerneltools-start → turbostat producing real output
  • 12 code-review rounds, all confirmed bugs fixed
  • No changes to the general benchmark pipeline (load_param_sets()/multiplex_set() untouched by Part 2)

🤖 Generated with Claude Code

k-rister and others added 2 commits August 15, 2026 18:26
…ture

Allow validation groups in requirements files to declare args as
repeatable (e.g. tool-kernel's sysfs-trace-setup/-cleanup), so multiple
occurrences survive merging instead of collapsing to one. A multi-valued
single occurrence is rejected outright -- the cartesian-product
interaction is undefined and was silently producing wrong results.

Replace the old param_exists() inline scan with a shared identity model
(_identity_key, _find_by_identity) and a merge-function family
(merge_param, merge_param_include, merge_param_own, merge_repeatable_param)
that gives include, own-params, defaults, and essentials uniform
duplicate-conflict diagnostics.

Refactor override_presets() to resolve defaults/essentials once via
_resolve_preset_group() (which filters disabled entries before identity
claiming, not after) and apply them per-set via merge_param_own(), fixing
a bug where a disabled essential could permanently block an enabled one,
and another where essentials were destructively consumed on the first set
in a multi-set input.

Fix include-preset handling that iterated every key in presets_dict
instead of looking up the named group directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add apply_flat_params() as a narrow entry point for consumers with no
sets/include/sweep concept (i.e. tools). It validates/converts/transforms
a flat {arg, val} list via override_presets() with force_role='all',
reusing the full merge/preset infrastructure without routing through
load_param_sets()'s include handling or the cartesian-product engine.

Add --flat CLI flag that routes main() through apply_flat_params()
instead of the general pipeline, and flat-schema.json for input
validation. apply_flat_params() validates its own inputs (both params
and requirements schemas) so it is safe to call directly as a library
function without relying on CLI-level validation.

Add conftest.py with autouse fixture resetting all module-level state
dicts between tests, and test-flat.py with 14 tests covering own params,
disabled filtering, defaults/essentials, repeatable occurrences, state
isolation between calls, and schema boundary enforcement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@k-rister k-rister self-assigned this Aug 15, 2026
@k-rister
k-rister requested a review from a team August 15, 2026 23:29
@project-crucible-tracking project-crucible-tracking Bot moved this to In Progress in Crucible Tracking Aug 15, 2026
conftest.py is loaded by pytest before multiplex.py is collected as a
test module, so the repo root isn't on sys.path yet when conftest tries
to import multiplex. This worked locally but failed in CI where pytest
runs from a clean checkout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@k-rister
k-rister requested review from rafaelfolco and removed request for a team August 16, 2026 00:42

@rafaelfolco rafaelfolco 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.

looks sane

Comment thread JSON/req-schema.json
@k-rister
k-rister merged commit 424f764 into master Aug 17, 2026
34 checks passed
@k-rister
k-rister deleted the fix-dup-param-collapse branch August 17, 2026 12:47
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Crucible Tracking Aug 17, 2026
k-rister added a commit to k-rister/rickshaw that referenced this pull request Aug 17, 2026
multiplex.py now provides a --flat mode (perftool-incubator/multiplex#111)
purpose-built for consumers with no sets/include/cartesian-product concept.
Tools always have exactly one implicit param set and, per
schema/tool-params.json, never more than one value per param, so the
previous wrap-into-sets-document/unwrap dance and the len(...) == 1
defensive check were ceremony around something structurally impossible.
This writes the tool's flat params directly, invokes --flat, and reads
the result back as-is -- filtering of disabled params and enforcement of
exactly-one-combination now live inside multiplex.py itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
k-rister added a commit to perftool-incubator/tool-kernel that referenced this pull request Aug 17, 2026
…rammar

sysfs-trace-setup/-cleanup shared the generic_string validation group
with no repeatable flag, so a second occurrence of either silently
collapsed onto the first ("last one takes effect") -- data loss for
kerneltools-start/-stop, which both accumulate these into an array and
expect every occurrence to survive. Split them into their own
sysfs_trace_command group with "repeatable": true, now that multiplex
supports it (perftool-incubator/multiplex#111).

Separately, rickshaw.json's param_regex for the perf-gen-local-report
ON/OFF flag hack was written against the old two-token rendering
grammar ('--flag' 'ON'). Rickshaw's param-rendering unification
(perftool-incubator/rickshaw#868) now renders params as a single
--flag=value token, so the old regex silently matched nothing --
verified this let --perf-gen-local-report=OFF pass through unchanged,
which would break kerneltools-stop's getopt parsing (that flag takes
no argument) at runtime. Rewrote both patterns for the new grammar and
verified against the real render_param()/apply_param_regex_and_split()
pipeline: ON renders as a bare flag, OFF is stripped entirely.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants