Skip to content

refactor(devtools): consolidate commands, probes, and one-off tools #625

Closed

Description

@Sinity

Scope

Composite issue for compacting the devtools/control-plane surface: command registration/execution, pipeline-probe architecture, one-off scripts, unused showcase/CLI helpers, and campaign metadata contracts.

Problem

devtools is the repo control plane, but several command-like or verification-lab surfaces are still organized as local mini-frameworks or one-off scripts:

  • top-level devtools dispatch is hand-rolled argparse over COMMAND_SPECS instead of a generated Click group;
  • devtools/pipeline_probe.py is a 1,400+ line command, engine, schema, staging, sampling, execution, budget, regression, and rendering module;
  • unused or marginal helpers such as ShowcaseContext and the CLI filter picker are command-like surfaces with no durable consumer;
  • campaign result metadata contracts are repeated across campaign tooling.

Already completed

Filter picker decision

The old CLI filter picker should not be deleted purely as unused one-off code. Evaluate it as a seed for query-backed fuzzy selection (polylogue select) with fzf when available and a Python fallback. If it cannot evolve cleanly into that role, delete with no shim.

Devtools command catalog (~40 commands)

Current CommandSpec categories partition the commands:

Category Count Examples
Core loop 5 status, verify, render-all, mutmut-campaign, benchmark-campaign
Generated surfaces 8 render-agents, render-cli-reference, render-topology-status
Verification 23 verify-topology, verify-layering, proof-pack, obligation-diff
Campaigns 3 benchmark-campaign, mutmut-campaign, run-benchmark-campaigns
Maintenance 5 build-package, witness-discover/minimize/promote

Target command groups

devtools verify
devtools render
devtools schema
devtools scenario
devtools witness
devtools campaign
devtools probe pipeline
devtools commands --format json

Proof/verifiability names should be integrated with #635: proof-pack → confidence/verification report, affected-obligations → verify impact.

Suggested package split

Use CommandSpec categories as the migration map:

devtools/
  control_plane.py        # dispatch, rendering, catalog (stays)
  verify/                 # all verify-* commands (23)
  render/                 # all render-* commands (8)
  proof/                  # proof-pack, obligation-diff, affected-obligations
  campaigns/              # mutmut, benchmark
  lab/                    # lab-corpus, lab-scenario, schema-*
  maintenance/            # build-package, witness-*

Acceptance criteria

  • Every command-like thing is either registered in the command catalog, moved behind a real product CLI surface, or deleted.
  • One-off scripts do not live as importable devtools modules unless they have tests, docs, and a command spec.
  • pipeline_probe split around stable responsibilities: input selection, staging, execution, budget/regression capture, and rendering.
  • Generated Click dispatch preserves typed option parsing, machine-output contracts, and generated docs.
  • devtools --list-commands --json is a parity witness for command catalog entries and executable imports.
  • devtools render-all --check and command catalog tests cover the new organization.

Consolidated findings

This issue absorbs and supersedes:

Ref #578
Ref #635
Ref #717 — filter picker may become seed for polylogue select

Activity

  1. added
    type:refactor
    area:devtools
    on May 1, 2026
  2. changed the title [-]refactor(devtools): split pipeline-probe into command and library[/-] [+]refactor(devtools): consolidate commands, probes, and one-off tools[/+] on May 1, 2026
  3. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Devtools compactness guard: consolidate by command ownership and lifecycle, not by hiding everything behind a generated command table.

    Useful acceptance additions:

    • every command-like thing is either registered in the command catalog, moved behind a real product CLI surface, or deleted;
    • one-off scripts should not live as importable devtools modules unless they have tests, docs, and a command spec;
    • pipeline_probe should split around stable responsibilities: input selection, staging, execution, budget/regression capture, and rendering;
    • generated Click dispatch is fine only if it preserves typed option parsing, machine-output contracts, and generated docs;
    • unused helpers such as interactive pickers or context objects should be wired to a real command workflow or removed in the same PR.

    This issue should reduce the number of command/probe concepts. A generated dispatcher that still points at the same scattered mini-frameworks would not close it.

  4. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Implementation anchors and acceptance additions from the 2026-05-01 follow-up audit.

    Code anchors:

    • devtools/__main__.py:43-80: top-level execution is hand-rolled argparse dispatch over COMMANDS, including special --json forwarding.
    • devtools/command_catalog.py: command metadata already exists; pipeline-probe is cataloged.
    • devtools/pipeline_probe.py: 1,468-line module mixing CLI parsing, request/schema, staging, sampling, execution, budgets, regression, and reporting.
    • Repo scan found roughly 60 argparse.ArgumentParser sites under devtools/.

    Acceptance additions:

    • Top-level command help, unknown-command behavior, JSON forwarding, command listing, and command importability are tested against one command framework/source of truth.
    • Split pipeline_probe into request, staging, engine, result, report, and CLI adapter modules.
    • One-off review scripts get a deletion list or become one cataloged command. Candidate names from devtools-style audits: extract_cr_outside_diff.py, extract_pr_reviews.py, parse_review_findings.py if present in the full repo.
    • devtools --list-commands --json becomes a parity witness for command catalog entries and executable imports.
  5. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Devtools control-plane decision from 2026-05-01 bundle

    Integrated decisions:

    • Use a Click group generated from CommandSpec categories.
    • Keep probe pipeline, but split internals.
    • Devtools is source-checkout-only.
    • Expose machine inventory and recommended gates.

    Target groups:

    devtools verify
    devtools render
    devtools schema
    devtools scenario
    devtools witness
    devtools campaign
    devtools probe pipeline
    devtools commands --format json
    

    Proof/verifiability names should be integrated with #635. Avoid preserving opaque command names such as proof-pack and affected-obligations; rename toward confidence/verification report and verify impact.

    The command inventory should explain why each gate exists and when to run it.

    Ref #594
    Ref #635

  6. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Integrated UX/fuzzy-selection direction from the 2026-05-01 feedback pass.

    Do not delete the old CLI filter picker purely as unused one-off code until it is evaluated as a seed for query-backed fuzzy selection.

    Decision point for this issue:

    • If kept, it must become a real descriptor/query-backed selector with fzf when available and a Python fallback.
    • It should reuse the existing query-first grammar and selection/read models, not define a parallel app surface.
    • Plausible target examples: polylogue select conversation, polylogue select repo, polylogue select cwd, polylogue select tag, or equivalent names that fit the query grammar.
    • If it cannot evolve cleanly into that role, delete it with no shim.
  7. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    C3 status check after #677/master sync:

    The PR-review extraction scripts called out in #610 are already deleted on current master:

    • devtools/extract_pr_reviews.py
    • devtools/extract_cr_outside_diff.py
    • devtools/parse_review_findings.py

    Reference scan:

    git ls-tree -r --name-only HEAD devtools scripts .github | rg 'extract|review|pr|cr|rabbit|comment|finding'

    Only normal workflow/proof/devtools names remain (.github/workflows/pr-policy.yml, .github/workflows/proof-comment.yml, and unrelated devtools modules such as proof_pack.py, pipeline_probe.py, etc.).

    So the PR-review extraction part of this composite should be treated as already satisfied by prior cleanup; remaining #625 work is command/probe consolidation, campaign metadata, and the filter-picker/select decision.

  8. Sinity commented on May 2, 2026

    @Sinity
    OwnerAuthor

    devtools command catalog (2026-05-02)

    Current command breakdown from devtools/command_catalog.py:

    Category Count Examples
    Core loop 5 status, verify, render-all, mutmut-campaign, benchmark-campaign
    Generated surfaces 8 render-agents, render-cli-reference, render-topology-status, etc.
    Verification 23 verify-topology, verify-layering, verify-file-budgets, proof-pack, obligation-diff, etc.
    Campaigns 3 benchmark-campaign, mutmut-campaign, run-benchmark-campaigns
    Maintenance 5 build-package, witness-discover/minimize/promote

    ~40 commands in a flat devtools/ package. The CommandSpec categories already partition them — use those as the migration map.

    Suggested package split

    devtools/
      control_plane.py        # dispatch, rendering, catalog (stays)
      verify/                 # all verify-* commands (23)
      render/                 # all render-* commands (8)
      proof/                  # proof-pack, obligation-diff, affected-obligations
      campaigns/              # mutmut, benchmark
      lab/                    # lab-corpus, lab-scenario, schema-*
      maintenance/            # build-package, witness-*
    

    The CommandSpec category field already assigns each command to one of these groups — the split is a mechanical move + import update, not a redesign.

  9. Sinity commented on May 2, 2026

    @Sinity
    OwnerAuthor

    Click dispatch design for #625 (2026-05-03 agent analysis)

    Approach: two-layer with backward-compatible shim

    Layer 1: thin main() shim handles --list-commands (byte-identical output), --json relocation, then delegates to Click group.

    Layer 2: Click group registers one subcommand per CommandSpec. Each subcommand wraps spec.resolve_main() — per-command argparse parsers are never touched.

    Key trick: --json relocation

    Current argparse allows devtools --json verify-topology. Click expects per-subcommand options after the subcommand name. The shim relocates --json to position 1 (after command name) before handing control to Click.

    Command wrapper

    def _make_command(spec):
        @click.command(name=spec.name, help=spec.description,
                       context_settings={"ignore_unknown_options": True, "allow_extra_args": True})
        @click.option("--json", is_flag=True)
        @click.argument("args", nargs=-1)
        def cmd(json, args):
            argv = ["--json"] if json else []
            argv.extend(args)
            raise SystemExit(spec.resolve_main()(argv))
        return cmd

    What changes in command_catalog.py

    Move _print_command_inventory from __main__.py to command_catalog.py as a public function. Optionally add parent_group/nested_name fields to CommandSpec for future nested aliases.

    Backward compatibility

    All current dispatch patterns preserved (flat devtools verify-topology, --json before or after command, --list-commands, unknown command → exit 2). Existing tests pass. Only --help formatting changes (Click style).

    Reversibility

    Fully incremental. Step 1: replace dispatch only. Step 2 (optional): add nested group aliases. Step 3 (future): convert individual commands from argparse to Click one at a time.

  10. Sinity commented on May 3, 2026

    @Sinity
    OwnerAuthor

    Closed by #763. pipeline_probe monolith split into 6-module package. Click dispatch generated from CommandSpec catalog. --list-commands --json parity witness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:devtoolsarea:qatype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions