Skip to content

config: unify the dotbot CLI config into one file (dotbot -c config.toml) - #266

Merged
geonnave merged 36 commits into
DotBots:developfrom
geonnave:config-cli-wiring
Jun 1, 2026
Merged

geonnave merged 36 commits into
DotBots:developfrom
geonnave:config-cli-wiring

Conversation

@geonnave

@geonnave geonnave commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Today dotbot configuration is scattered across three overlapping surfaces -
run controller --config-path, swarm -c (actually swarmit's loader, wrapped),
and ~/.dotbot/config.toml's [fw] table - with three names for the network id
(swarm_id / network_id / swarmit_network_id) and an overloaded -c
(build-config in fw/device, config-file in swarm). This unifies the lot
into one file with a single, documented precedence chain.

The shape

One file, sections mirroring the four-namespace CLI, plus named deployments:

default_deployment = "inria"
conn     = "mqtts://broker.local:8883"   # shared; sections/deployments override
swarm_id = "0001"

[deployment.inria]                       # a deployment you SELECT, not edit
conn = "mqtts://broker.inria.fr:8883"
swarm_id = "0001"

[fw]
board = "dotbot-v3"

[run.controller]
http_port = 8000
  • Precedence (one chain, no exceptions): CLI flag > env
    (DOTBOT_<SECTION>_<KEY>) > file (section > selected deployment > top-level) >
    built-in default. extra='forbid', so a typo'd key fails loud.
  • Discovery: -c PATH > DOTBOT_CONFIG > nearest dotbot.toml
    (cwd-upward) > ~/.dotbot/config.toml.
  • Deployment = one physical site (Inria/100, La Poste/1000), selected with
    --deployment / DOTBOT_DEPLOYMENT / default_deployment. The name was
    chosen by a four-persona review over testbed (overloads with the product
    name "the DotBot Testbed") and instance (clashes with the planned Swarm
    SDK object); deployment is clean against both and reads for the
    education/industry audience. (The simulator is not a deployment; it is
    --conn simulator.)
  • MQTT credentials stay env-only (DOTBOT_MQTT_USER/PASS), never a file key.

What's in this PR

  • The resolver core (dotbot/config.py): pydantic schema, discovery, deployment
    selection, one precedence function; conn validated via the existing
    parse_connection so the file and the --conn flag share one validator.
  • Root dotbot -c/--config + --deployment (loads + selects into the Click
    context). fw/device --config/-c renamed to --build-config to free
    -c (clean break, no alias).
  • fw/device now read their option defaults from the config (an explicit flag
    still wins; with no config, behavior is unchanged).
  • Read-only management commands: dotbot config path/show and
    dotbot deployment list/show.
  • A configuration reference doc page.

Deferred (own follow-ups, called out so they aren't forgotten)

  • run controller consumption - it is also invoked directly by
    run simulator (no root context), and still carries --config-path + the
    conn-translation; migrating it cleanly wants care + bench validation.
  • swarm consumption - dotbot swarm mounts swarmit's own CLI (its own
    -c); unifying it is a cross-repo decision, so it is intentionally untouched
    here.
  • Retiring network_id / swarmit_network_id in favour of one swarm_id -
    touches the adapter layer; separate change.
  • The ~/.dotbot/config.toml auto-fallback is wired but kept OFF for now
    (include_user_file=False): that file is still owned by the legacy fw
    segger_dir reader, and switches on when fw migrates onto the resolver.

Validation

343 tests pass (headless): the resolver's precedence/discovery/deployment
permutations, the root wiring, the build-config rename, the helpers. black /
isort / ruff clean; docs build clean. No runtime/hardware path is changed by
this PR - the consumers either fall back to today's defaults when no config is
present, or are deferred above.

geonnave added 5 commits June 1, 2026 07:28
Phase 1 of the config unification: the pure resolver (pydantic schema +
discovery + testbed selection + the one precedence function). Not wired into
any command yet, so there is no behavior change; fully unit-tested headless.

AI-assisted: Claude Opus 4.8
Phase 2 of the config unification. The root `dotbot` group now takes
`-c/--config` and `--testbed`, loads + validates the file, selects the
testbed, and stashes both on the Click context for subcommands to read. To
free `-c` for that global flag, `fw`/`device` `--config`/`-c` becomes
`--build-config` (clean break, no alias). No command consumes the config
yet, so behavior is otherwise unchanged; the `~/.dotbot/config.toml` fallback
stays off until `fw` migrates onto the resolver.

AI-assisted: Claude Opus 4.8
`fw` build/clean/artifacts and `device flash` now take their option defaults
from the loaded config (board, build_config, sandbox / sn), while an explicit
flag still wins via Click's parameter source. With no config present the
resolved value is the option's own default, so existing behavior is unchanged.

AI-assisted: Claude Opus 4.8
Read-only: `dotbot config path`/`show` reports the resolved config and where
it came from; `dotbot testbed list`/`show` lists the configured deployments
and marks the active one. Writing (`testbed use`) is deferred.

AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
@codecov

codecov Bot commented Jun 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.11482% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.74%. Comparing base (a6f0cda) to head (11fb85e).
⚠️ Report is 193 commits behind head on develop.

Files with missing lines Patch % Lines
dotbot/cli/deployment_cmd.py 94.26% 9 Missing ⚠️
dotbot/cli/config_cmd.py 96.62% 3 Missing ⚠️
dotbot/cli/device.py 81.25% 3 Missing ⚠️
dotbot/cli/swarm.py 75.00% 3 Missing ⚠️
dotbot/config.py 98.03% 3 Missing ⚠️
dotbot/cli/_fw_helpers.py 93.75% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #266      +/-   ##
===========================================
+ Coverage    82.10%   83.74%   +1.64%     
===========================================
  Files          105      116      +11     
  Lines         9677    10815    +1138     
  Branches       571      569       -2     
===========================================
+ Hits          7945     9057    +1112     
- Misses        1729     1754      +25     
- Partials         3        4       +1     
Files with missing lines Coverage Δ
dotbot/cli/_cfg.py 100.00% <100.00%> (ø)
dotbot/cli/_lazy.py 95.23% <100.00%> (+0.50%) ⬆️
dotbot/cli/_swarm_inject.py 100.00% <100.00%> (ø)
dotbot/cli/fw.py 88.80% <100.00%> (+1.20%) ⬆️
dotbot/cli/gateway.py 100.00% <100.00%> (ø)
dotbot/cli/main.py 100.00% <100.00%> (ø)
dotbot/controller_app.py 96.90% <100.00%> (+0.13%) ⬆️
dotbot/tests/test_cli_cfg_helper.py 100.00% <100.00%> (ø)
dotbot/tests/test_cli_config.py 100.00% <100.00%> (ø)
dotbot/tests/test_cli_deployment_fetch.py 100.00% <100.00%> (ø)
... and 15 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

geonnave added 23 commits June 1, 2026 10:07
A four-persona review found `deployment` clearest: it carries no overload with
the product name ("the DotBot Testbed") the way `testbed` does, and no clash
with the planned `Swarm` SDK object ("a swarm instance") the way `instance`
would, and it reads for the education/industry audience too. Renames the config
key, `--deployment` flag, `DOTBOT_DEPLOYMENT` env, `dotbot deployment` command,
and the schema. Develop-phase rename, no backwards-compat.

AI-assisted: Claude Opus 4.8
Turns the empty-config dead end into an on-ramp: `dotbot config init` writes an
annotated `./dotbot.toml` (--global writes ~/.dotbot/config.toml; refuses to
overwrite without --force). The starter is fully commented, so a fresh file
loads as a valid empty config and doubles as schema-by-example; the empty
`config show`/`path` now point at `config init`.

AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
Every swarmit dependency (cryptography, marilib-pkg, ...) is already in
the core install via qrkey/marilib, so the `[swarm]` extra isolated
nothing, and fleet operation is the primary use case rather than an
opt-in. Calibration (opencv + textual) stays the one optional extra.

AI-assisted: Claude Opus 4.8
swarmit (now a core dep) registers payload types 0x80-0xa1 into the shared
dotbot_utils protocol registry on import, so collecting this test raised
"Payload type '0x81' already registered" once swarmit was imported in the
same pytest process. 0xfb/0xfc are clear of both dotbot (<= 0xfa) and swarmit.

AI-assisted: Claude Opus 4.8
@geonnave

geonnave commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Huge PR! But at least half is tests + docs. Worth it in my opinion, as it now enables much much simpler developer experience such as:

dotbot config init --conn mqtts://argus.paris.inria.fr:8883 --swarm-id 1234
dotbot swarm status
dotbot swarm flash ./artifacts/rgbled-sandbox-dotbot-v3.bin -ys
dotbot swarm stop

geonnave added 7 commits June 1, 2026 18:08
AI-assisted: Claude Opus 4.8
fw's segger_dir/firmware_repo were read by a separate ~/.dotbot-only toml
reader, so [fw] keys in a project dotbot.toml were ignored. They now resolve
through the unified config like every other command, and ~/.dotbot is a normal
user-file fallback for ALL commands (include_user_file on) rather than special
fw-only state - so a per-machine ~/.dotbot/config.toml now applies everywhere.

AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
@geonnave
geonnave merged commit 62bf653 into DotBots:develop Jun 1, 2026
14 checks passed
@geonnave
geonnave deleted the config-cli-wiring branch June 1, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant