mari + marilib unification (plan, May 2026)

status: done
validated: ci
created: 2026-05-18
updated: 2026-05-26
shipped_as: mari#152
shipped_at: 2026-05-18
tags: [consolidation, mari, marilib, repo-merge]
related: [dotbot-consolidation-roadmap]

Outcome (2026-05-18): shipped as mari#152, merged into develop. marilib no longer exists as a standalone repo — its Python source lives at repos/mari/marilib/ and ships from mari as the marilib-pkg PyPI package. Workspace repo count went 11 → 10.

mari + marilib unification

Context

First concrete step of the 11→4 consolidation roadmap in dotbot-testbed/AGENTS.md: fold marilib into mari so the protocol firmware and its Python binding/agents ship from one repo. Convention follows swarmit (device/ + swarmit/): firmware-side moves under firmware/, the Python package source lives at marilib/, and pyproject.toml sits at the repo root. The Python package name stays marilib — downstream consumers (PyDotBot, swarmit) keep working unchanged; only the repo layout changes.

Branch: fold-marilib off origin/develop (mari uses gitflow — main is releases, develop is integration).

Downstream impact: any repo that has mari as a git submodule needs both a pointer bump to the post-restructure commit and a path rewrite for anything that traverses mari’s tree (now nested one level deeper under firmware/). Grep across the org confirmed the only consumer is swarmit (.gitmodules entry at repos/swarmit/.gitmodules); both pre-existing swarmit worktrees (wt-swarmit-cli-serve, wt-swarmit-ota-batched-nack) pin earlier mari commits and stay frozen until their owners explicitly bump. Non-submodule consumers — dotbot-provision (pulls mari binaries from GitHub Releases), PyDotBot (consumes marilib via PyPI) — are unaffected by tree layout.

Target layout

mari/
├── AGENTS.md            ← unified, with pointers into the two halves
├── README.md            ← describes both firmware and marilib
├── pyproject.toml       ← marilib's package metadata, at root
├── tox.ini / hatch...   ← whatever marilib currently uses
├── .github/workflows/
│   ├── build.yml                  ← path-filtered: firmware/**
│   ├── clang-format.yml           ← path-filtered: firmware/**
│   └── continuous-integration.yml ← path-filtered: marilib/**, tests/**, pyproject.toml
├── firmware/
│   ├── AGENTS.md        ← firmware-specific guidance
│   ├── app/
│   ├── bsp/
│   ├── drv/
│   └── …                ← everything currently at repos/mari/ root
├── marilib/
│   ├── AGENTS.md        ← Python/host-side guidance
│   ├── __init__.py
│   └── …                ← package source
├── tests/               ← from marilib
└── examples/            ← from marilib

Mari has no submodules (DotBot-libs is not a submodule of mari, despite the surrounding repos — verified .gitmodules absent), so the firmware move is a straight git mv.

Decisions baked in

History preservation: filter-repo + merge

Use git filter-repo --to-subdirectory-filter marilib on a marilib clone, then git merge --allow-unrelated-histories into the mari branch. After unification, git log -- marilib/ walks marilib’s full pre-merge history, git log -- firmware/ walks mari’s. Worth the extra hour for the months-after blame story.

Fallback if filter-repo fights us: single “import marilib at <sha>” commit referencing marilib’s HEAD SHA. Lose individual history but keep moving.

One root AGENTS.md plus per-half stubs

Root AGENTS.md covers the cross-cutting things (build for both halves, where the package publishes from, how the two interact at the protocol level). firmware/AGENTS.md keeps the current mari-specific firmware notes (clang-format, target list, hot spots). marilib/AGENTS.md keeps the marilib-specific Python notes (agents, mqtt, edge/cloud). Matches swarmit’s split-by-area model.

Sequence

Phase 1 — restructure in wt-mari-fold-marilib

  1. git mv all current mari root contents (everything except .git, .github, AGENTS.md, README.md, LICENSE, CHANGELOG.md if present) into firmware/. Commit: repo: relocate firmware sources under firmware/.
  2. Verify firmware still builds: make -C firmware <one target> (or whatever the in-tree Makefile expects post-move; if it has $(CURDIR)-relative paths they may need a one-line fix). Commit any path fixes separately.
  3. Import marilib’s history with subdirectory filter:
  4. Hoist marilib root metadata up: git mv marilib/pyproject.toml ./, same for tests/, examples/, tox.ini, .ruff.toml, etc. Anything that’s logically project-wide (CI config, tooling config) moves to root; anything that’s package-internal (marilib/py.typed, __init__.py, source modules) stays under marilib/. Commit: repo: hoist marilib project metadata to repo root.
  5. Write unified root AGENTS.md. Move firmware-specific bits to firmware/AGENTS.md. Keep marilib/AGENTS.md mostly as-is.
  6. Merge CI: add paths: filters to all three workflows so a Python-only PR doesn’t trigger the firmware build and vice versa. Commit: ci: merge mari + marilib pipelines with path filters.
  7. Rewrite root README.md to describe both halves with install / build / quickstart pointers into each subtree.
  8. Local verification before push:

Phase 2 — cross-workspace updates (separate PRs after Phase 1 merges)

  1. dotbot-testbed: edit AGENTS.md (11 → 10 repos: drop the marilib row, update the dep map’s marilib → PyPI → ... to note it’s now published from mari, leave the 11→4 consolidation roadmap updated). Edit scripts/setup-venv.sh to drop the repos/marilib editable install — marilib gets installed from repos/mari instead. One workspace PR.
  2. swarmit: bump the mari submodule pointer to the unification commit. Then grep swarmit for any hard-coded mari/<path> references in source/build/CI — anything that used to point at mari/<sub> needs to be mari/firmware/<sub> after the move. Likely none, but worth grepping.
  3. PyDotBot: no source change. Marilib’s PyPI release moves to mari’s CI; PyDotBot just bumps its marilib== pin in its next normal version cycle.
  4. GitHub housekeeping (the developer): archive the marilib repo (don’t delete — PyPI README backlinks, paper citations survive); add a banner / README pointing to DotBots/mari.

Things to grep before starting

Critical files

Verification

Follow-ups (not this PR — separate items in the consolidation roadmap)

Public copy of an early DotBots plan (18 May 2026), published for the SED seminar talk. In May, plans were markdown checklists; from July they are HTML pages with a live state and a log.