Plan: branes swap CLI Subcommand Set
Context
Section titled “Context”The SWaP-C data models, physical estimators, evaluator, and report generation are now implemented (Phases 1-5 of the prior plan). However, there is no CLI surface for users to interact with SWaP-C analysis. Users need to:
- Quickly estimate system weight/volume/thermal for a design point
- Set SWaP-C budgets and check designs against them
- Run 6-objective optimization with weight/volume
- Compare packaging and cooling alternatives side-by-side
- View BOM breakdowns and thermal assessments
- Bridge from existing specs to SWaP-C analysis
This plan adds branes swap — a Click command group following the same patterns as
branes spec and branes optimize.
Command Design
Section titled “Command Design”Group: branes swap
Section titled “Group: branes swap”branes swap estimate — Quick single-point SWaP-C estimation (Questions)branes swap bom — Detailed BOM breakdown (Questions)branes swap check — Scorecard against budgets (Assertions + Tests)branes swap explore — 6-objective MOO optimization (Tests)branes swap show-front — Display Pareto front from last explore (Tests)branes swap compare — Side-by-side comparison of two configurations (Comparisons)branes swap explain — Tradeoff analysis between two Pareto-front designs (Comparisons)Seven commands covering the four workflow stages: Questions → Assertions → Tests → Comparisons.
1. branes swap estimate — Quick single-point estimation
Section titled “1. branes swap estimate — Quick single-point estimation”Purpose: Answer “what does this design weigh?” without running optimization.
branes swap estimate --area 50 --power 5 --process 28 \ --package BGA --cooling passive --enclosure aluminumOptions:
| Flag | Type | Default | Description |
|---|---|---|---|
--area / -a | float | required | Die area (mm²) |
--power / -p | float | required | SoC TDP (watts) |
--process | int | 28 | Process node (nm) |
--package | choice | BGA | Package type (QFN/BGA/FCBGA/WLCSP) |
--cooling | choice | passive | Cooling type (passive/active_fan/liquid) |
--enclosure | choice | aluminum | Enclosure material (aluminum/abs_plastic/magnesium) |
--volume | int | 10000 | Production volume |
--layers | int | 4 | PCB layer count |
--connectors | int | 0 | Board connectors |
--ambient-temp | float | 40.0 | Ambient temperature (°C) |
--json-output | flag | false | JSON output |
Calls:
estimate_system_bom(area, power, process, package, cooling, enclosure, volume, layers, connectors)compute_thermal_feasibility(bom, power, ambient_temp)
Output (human): Rich Panel with summary metrics:
╭─ SWaP-C Estimate: 50mm² / 28nm / BGA / passive ─╮│ Weight: 142.3 g ││ Volume: 68.5 cm³ ││ Cost: $23.40 ││ Dims: 54×54×32 mm ││ Thermal: Tj=105°C (margin: 20°C) ✓ │╰────────────────────────────────────────────────────╯2. branes swap bom — Detailed BOM breakdown
Section titled “2. branes swap bom — Detailed BOM breakdown”Purpose: Show the full hierarchical BOM tree with per-component weight/volume/cost.
branes swap bom --area 50 --power 5 --process 28 --package BGA --cooling passiveOptions: Same as estimate (shared option decorator).
Calls:
estimate_system_bom(...)→ SystemBOMbom.summary_table()→ flat rows
Output (human): Rich Table with per-level breakdown:
System BOM Breakdown┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┓┃ Component ┃ Level ┃ Weight(g)┃ Vol(cm³) ┃ Cost($) ┃┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━┩│ system │ system │ │ │ ││ ├─ pcb │ pcb │ 12.40 │ 4.20 │ 3.80 ││ │ └─ BGA-256 │ package │ 0.25 │ 0.17 │ 1.50 ││ │ └─ die │ die │ 0.18 │ 0.04 │ 12.30 ││ ├─ heatsink-passive│ system │ 40.00 │ 20.00 │ 0.00 ││ └─ enclosure-alum │ system │ 89.50 │ 44.10 │ 4.48 │├────────────────────┼─────────┼──────────┼──────────┼─────────┤│ TOTAL │ │ 142.33 │ 68.51 │ 22.08 │└────────────────────┴─────────┴──────────┴──────────┴─────────┘3. branes swap check — Scorecard against budgets
Section titled “3. branes swap check — Scorecard against budgets”Purpose: Assert SWaP-C budgets and get PASS/FAIL/WARNING verdicts. Bridges to the spec system: can read budgets from an existing spec.
# Explicit budgetsbranes swap check --area 50 --power 5 --process 28 --package BGA --cooling passive \ --max-weight 500 --max-volume 200 --max-power 10 --max-cost 50
# From a spec (reads constraints from spec store)branes swap check --area 50 --power 5 --process 28 --from-spec my-droneOptions: All estimate options plus:
| Flag | Type | Default | Description |
|---|---|---|---|
--max-weight | float | None | Weight budget (grams) |
--max-volume | float | None | Volume budget (cm³) |
--max-power | float | None | Power budget (watts) |
--max-cost | float | None | Cost budget (USD) |
--max-latency | float | None | Latency budget (ms) |
--from-spec | str | None | Read budgets from a named spec |
Calls:
- If
--from-spec:SpecStore.get(name)→ extract budgets fromspec.power,spec.compute,spec.constraints estimate_system_bom(...)compute_thermal_feasibility(...)assess_design_point(design, bom_summary, constraints, thermal_data)
Output (human): Rich Table scorecard:
SWaP-C Scorecard┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━┳━━━━━━━━━┓┃ Metric ┃ Value ┃ Budget ┃ Util ┃ Verdict ┃┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━╇━━━━━━━━━┩│ weight_grams │ 142.33 │ 500.00 │ 28% │ PASS ││ volume_cm3 │ 68.51 │ 200.00 │ 34% │ PASS ││ power_watts │ 5.00 │ 10.00 │ 50% │ PASS ││ cost_usd │ 22.08 │ 50.00 │ 44% │ PASS │└────────────────┴──────────┴──────────┴──────┴─────────┘ Thermal: Tj=105°C (max 125°C), passive cooling — PASS Overall: PASSExit code: 0 if PASS, 1 if FAIL (enables CI/scripting).
4. branes swap explore — 6-objective MOO optimization
Section titled “4. branes swap explore — 6-objective MOO optimization”Purpose: Run the full 6-objective design space exploration.
branes swap explore --goal "drone perception SoC" \ --power 10 --latency 33 --cost 50 --weight 500 --volume 200 \ --fastOptions:
| Flag | Type | Default | Description |
|---|---|---|---|
--goal / -g | str | required | Design goal |
--power / -p | float | None | Max power (W) |
--latency / -l | float | None | Max latency (ms) |
--cost / -c | float | None | Max cost (USD) |
--area / -a | float | None | Max area (mm²) |
--weight / -w | float | None | Max weight (g) |
--volume | float | None | Max volume (cm³) |
--fast | flag | false | Reduced evaluations |
--layers | str | auto | Optimizer layer selection |
--workers | int | 8 | Thread pool size |
--from-spec | str | None | Read constraints from spec |
--json-output | flag | false | JSON output |
Calls:
create_swap_design_space(constraints)SWaPCEvaluator(design_space, base_state, constraint_bounds, thermal_config)OptimizationEngine(ds, evaluator, config).run()
Output: Pareto front table with 6 objective columns + design params. Saves result
via _save_swap_result() for show-front, compare, explain.
5. branes swap show-front — Display Pareto front
Section titled “5. branes swap show-front — Display Pareto front”Purpose: Show the Pareto front from the last explore run.
branes swap show-front [--top 10]Options:
| Flag | Type | Default | Description |
|---|---|---|---|
--top | int | 10 | Number of designs to show |
Calls: _load_swap_result() → display table.
Output: Rich Table with process, package, cooling, power, latency, area, cost,
weight, volume columns. Knee point marked with *.
6. branes swap compare — Side-by-side configuration comparison
Section titled “6. branes swap compare — Side-by-side configuration comparison”Purpose: Compare two packaging/cooling configurations on the same SoC.
branes swap compare --area 50 --power 5 --process 28 \ --left "QFN,passive,abs_plastic" \ --right "FCBGA,active_fan,aluminum"Options: Core SoC params (--area, --power, --process) plus:
| Flag | Type | Description |
|---|---|---|
--left | str | Comma-separated: package,cooling,enclosure |
--right | str | Comma-separated: package,cooling,enclosure |
Calls:
estimate_system_bom(...)for left configestimate_system_bom(...)for right configcompute_thermal_feasibility(...)for each
Output: Side-by-side Rich Table:
Configuration Comparison (50mm² / 28nm / 5W)┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓┃ Metric ┃ QFN/passive/plastic ┃ FCBGA/active_fan/alum ┃┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩│ Weight (g) │ 62.10 │ 148.30 ││ Volume (cm³) │ 38.20 │ 72.50 ││ Cost ($) │ 14.80 │ 28.60 ││ Tj (°C) │ 118 (7°C) │ 58 (67°C) ││ Thermal │ WARNING │ PASS ││ Dims (mm) │ 42×42×24 │ 62×62×36 │└────────────────┴──────────────────────┴────────────────────────┘ Delta: right is +138% weight, +90% volume, +93% cost, but 60°C cooler7. branes swap explain — Tradeoff between Pareto-front designs
Section titled “7. branes swap explain — Tradeoff between Pareto-front designs”Purpose: Explain the tradeoff between two designs from the last explore run.
Same pattern as branes optimize explain.
branes swap explain --points 0,3Options:
| Flag | Type | Description |
|---|---|---|
--points / -p | str | Two comma-separated point indices |
Calls: _load_swap_result() → compare two points across all 6 objectives.
Output: Objective deltas table (with all 6 objectives including weight/volume)
- parameter change table (including package_type, cooling_type).
Workflow Composition
Section titled “Workflow Composition”Questions: branes swap estimate ... → Quick numbers branes swap bom ... → Where does weight come from?
Assertions: branes swap check ... → Does it pass budgets? branes swap check --from-spec my-drone ... → Against spec budgets
Tests: branes swap explore ... → Find the Pareto front branes swap show-front → View results branes swap check ... → Validate specific point
Comparisons: branes swap compare ... → QFN vs FCBGA side-by-side branes swap explain ... → Why is design #0 better than #3?Typical user session:
# 1. Quick estimatebranes swap estimate --area 50 --power 5 --process 28
# 2. Try different packagesbranes swap compare --area 50 --power 5 --process 28 \ --left "QFN,passive,abs_plastic" --right "BGA,passive,aluminum"
# 3. Check against drone spec budgetsbranes swap check --area 50 --power 5 --process 28 --package BGA \ --from-spec my-drone
# 4. Full optimizationbranes swap explore -g "drone SoC" --power 10 --weight 500 --volume 200 --fast
# 5. Inspect resultsbranes swap show-front --top 5branes swap explain --points 0,2Implementation
Section titled “Implementation”New file: src/embodied_ai_architect/cli/commands/swap.py
Section titled “New file: src/embodied_ai_architect/cli/commands/swap.py”Single file containing the swap Click group and all 7 subcommands.
Internal helpers:
_common_soc_options(f)— Shared Click options decorator for--area,--power,--process,--package,--cooling,--enclosure,--volume,--layers,--connectors,--ambient-temp_save_swap_result(result)/_load_swap_result()— Save/load to$TMPDIR/branes_swap_result.json(same pattern as optimize.py)_parse_config(config_str)— Parse “package,cooling,enclosure” forcompare_read_spec_budgets(spec_name)— Extract SWaP-C budgets from a spec via SpecStore
Functions called from graphs layer:
estimate_system_bom()— estimate, bom, check, comparecompute_thermal_feasibility()— estimate, check, compareassess_design_point()— checkformat_swap_report_text()— check (with —json-output off)create_swap_design_space()— exploreSWaPCEvaluator— exploreOptimizationEngine— explore
Modified file: src/embodied_ai_architect/cli/__init__.py
Section titled “Modified file: src/embodied_ai_architect/cli/__init__.py”Add from .commands.swap import swap; cli.add_command(swap) in main().
New file: tests/test_swap_cli.py
Section titled “New file: tests/test_swap_cli.py”Test each subcommand via Click’s CliRunner:
test_estimate_basic— returns 0, output contains “Weight”test_estimate_json— valid JSON with weight_grams keytest_bom_table— output contains “die”, “package”, “pcb”test_check_pass— exit code 0 when within budgetstest_check_fail— exit code 1 when over budgettest_check_from_spec— reads budgets from spec store (mock)test_compare_two_configs— output contains both config namestest_explore_fast— runs without error (fast mode)test_show_front_no_result— error message when no prior exploretest_explain_basic— shows delta table
File Summary
Section titled “File Summary”| Action | File |
|---|---|
| Create | src/embodied_ai_architect/cli/commands/swap.py |
| Modify | src/embodied_ai_architect/cli/__init__.py — register swap group |
| Create | tests/test_swap_cli.py |
Verification
Section titled “Verification”# Lint + format.venv/bin/black --check src/ tests/ --line-length 100.venv/bin/ruff check src/ tests/
# Tests.venv/bin/pytest tests/test_swap_cli.py -v
# Smoke test.venv/bin/branes swap estimate --area 50 --power 5 --process 28.venv/bin/branes swap bom --area 50 --power 5 --process 28 --package FCBGA.venv/bin/branes swap check --area 50 --power 5 --process 28 --max-weight 500.venv/bin/branes swap compare --area 50 --power 5 --process 28 \ --left "QFN,passive,abs_plastic" --right "FCBGA,active_fan,aluminum".venv/bin/branes swap explore -g "drone" --power 10 --weight 500 --fast.venv/bin/branes swap show-front.venv/bin/branes swap explain --points 0,1