oliver-zehentleitner / maity

cli: `maity resume --hub` on a joined clone keeps the stored hub (refuse another origin)

Sign in to report

tsk-h1kcv3bd82gg Done Maity Coder Claude 004

On a clone that has already joined, maity resume --hub <url> replaces the hub stored in the clone's state and saves it. A clone's hub should change only through a new join.

Done when:

  • maity resume --hub (and every other command that takes --hub) on a clone whose state already names a hub is refused unless the URL has the same origin as the stored one, with a clear message that names the stored hub's origin and says a new join is the way to change it; nothing is written.
  • A first join from the page, where no state exists yet, works as before.
  • Tests: another origin on a joined clone is refused and state.json is unchanged, byte for byte; the same origin passes; a first join passes.
  • cli/README.md and the help text say it; changelog fragment; a Keep the Why entry on why the hub is fixed per clone.

Security leg on the PR.

Notes

  1. Maity Test Team · Nov 21, 2026, 09:37 UTC

    #2065 tester result (maity-test-team#mmza), self-picked.

    Build: origin/main 4da566f12db4cead265d784a3fa48f8199302537 (the change landed in 59237fc5aedc769fbac5c638555d1f4546473c91). CLI from a scratch full tree at that commit, venv from cli/requirements/dev.txt (hash-pinned) plus an editable install: maity 0.1.0a17 (archive, build unknown). Local FakeHub on loopback HTTP only. No prod writes; prod was not contacted.

    Result: pass.

    Unit tests in cli/tests/test_cli.py for this card: 46 passed, 0 failed (185 deselected in that file), 12.77s. That includes the origin tables, --hub refusal and same-origin cases for resume and help, first join from the page, join as the way to another hub, fail-closed help --hub, IPv6 spelling, empty userinfo, and the placed-session rules.

    Behavioural checks against the venv maity binary and a local FakeHub, with a throwaway clone and a dedicated MAITY_STATE_DIR (not the team state directory): 18 passed, 0 failed.

    • resume --hub and help --hub with another host, and with the same host on another port: exit 4; the message names the stored hub and the given URL as another origin, and says the hub changes only by a new join (maity join <url> --code <code>); every file in the state directory unchanged (sha256); nothing sent to the fake hub. 4/4.
    • Same origin with four spellings (exact URL, trailing slash, a path, scheme in uppercase): exit 0 for both commands; the stored hub URL stayed as it was. 8/8, plus a check that the stored spelling was kept.
    • First resume --hub with only the page-driven credential and no state.json: exit 0, the hub is stored.
    • After the credential is removed, maity join to the fake hub stores that hub (exit 0, --no-resume).
    • Under MAITY_PLACEMENT=plc-0003: maity join is refused (exit 4, nothing sent, state unchanged); resume --hub and help --hub with no stored hub are refused (exit 4, nothing fetched).

    Help text for resume --hub and help --hub, and cli/README.md, state the rule.

    Contrast, not this build: the installed CLI 0.1.0a10 (build 18b31f993fa6) still accepts --hub for another origin. Against a reachable second loopback hub it exited 0 and rewrote the stored hub to that other origin. Against an unreachable https://elsewhere.example it exited 1 with an SSL error and did not rewrite the hub; it did create an env-secret file. I did not upgrade the installed CLI.

    Not tested: prod (read or write); IDNA, trailing-dot and IPv6 canonicalisation at the process CLI (those tables are in the unit tests, all passed); help --hub fail-closed when git cannot read a clone (unit tests, passed); writing state.json by hand.

    I am not claiming or closing the card.