docs: phase 6 (routing, owners, CLI tokens)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-11-16 16:54:07 +01:00
1 parent ed07c0a081
commit b4bc604c8e
3 files changed
+68 -2

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ Do not start new work before the previous results are written to `docs/`.
- Throwaway e2e on a local Forgejo: `spikes/phase4-e2e.sh`
## Architecture
See `docs/` (`phase0-spike.md` ... `phase5.md`, `DECISIONS.md`). Git is the storage layer; shell out to
See `docs/` (`phase0-spike.md` ... `phase6.md`, `DECISIONS.md`). Git is the storage layer; shell out to
system `git`; snapshots use a temp `GIT_INDEX_FILE` + `commit-tree`, never touching the
user's branch or index.
+3 -1
View File
@@ -10,6 +10,7 @@ Service via `keyring` (service `grove`, user = provider id). Tokens are never wr
file. `grove login <id>` reads the token from stdin (never argv), checks it against the forge and
stores it. HTTPS git operations of the wizards authenticate through `http.extraHeader` set in the
process environment only (Gitea/Forgejo); for GitHub they use the user's credential helper.
Since phase 6 the `tea`/`gh` logins are used when grove has no token of its own (`phase6.md`).
## Commands
@@ -33,7 +34,8 @@ clone lives in `<state dir>/config-repo`. It is created on the first registratio
Gitea/Forgejo: the primary creates a push mirror via `POST /repos/{o}/{r}/push_mirrors`
(`sync_on_commit`, 8 h interval) to a repo created on the mirror provider. GitHub has no push
mirrors: `configure_mirror` reports `Unsupported` and `new` warns. The daemon-side fallback (push
branches and tags only, never `refs/sync/*`) is **not implemented**.
branches and tags only, never `refs/sync/*`) is **not implemented**. Phase 6 adds a pull mirror on
the Gitea side for GitHub primaries (`phase6.md`).
## Validation
+64
View File
@@ -0,0 +1,64 @@
# Phase 6: routing by visibility, owners, CLI tokens
## Config
Two optional keys per group, both backward compatible. Nothing is hard-coded: each user decides per
group which forge is primary, where it is mirrored and whether public repos route differently.
Without these keys a group behaves as before (one route for every repo, owned by the token's user).
Example (one person's setup, not a default):
```toml
[[groups]]
name = "Zenvairo"
primary = "gitea" # private repos (and all repos without [groups.public])
mirror_to = []
owners = { gitea = "Zenvairo" } # account/org per provider; unset = authenticated user
[groups.public] # public repos take this route instead
primary = "github"
mirror_to = ["gitea"]
```
- `Group::route(private)` picks the route; `Group::owner(provider)` the owner.
- Validation: the public route follows the same rules as the base one (known providers, primary
not in its own `mirror_to`); `owners` keys must be known providers, values non-empty.
## Flows
- `grove new <group> <name> [--public]` creates the repo on the route's primary, under the
configured owner (`POST /orgs/{owner}/repos`), then sets up each mirror of that route:
- primary can push-mirror (Gitea/Forgejo): target repo created under the mirror's owner, then a
push mirror on the primary (as before);
- otherwise (GitHub primary): a **pull mirror** on the target via Gitea's `POST /repos/migrate`
(`mirror: true`, 8 h interval). Credentials of the source are sent only for private sources.
- `grove import <group>` lists, per route, the primary's repos owned by the configured owner (or
the authenticated user), and with a public route only those of the route's visibility. Repos of
other owners (orgs you belong to) no longer show up in every group: give an org group its
`owners` entry. If one route's provider is unreachable, the whole group's import fails.
- An owner equal to the authenticated login means "my account" (`/user/repos`), not an org.
- Wizard git over HTTPS authenticates with the resolved token on both forge kinds
(`http.extraHeader`, process env only; GitHub as Basic `x-access-token`).
## Tokens
`token::resolve`: `GROVE_TOKEN_<ID>`, then the Secret Service, then the forge CLI's login:
`tea login helper get` for Gitea/Forgejo (matched by the provider URL's host) and
`gh auth token --hostname <host>` for GitHub (`github.com` without a URL). `GROVE_NO_CLI_TOKENS=1`
disables the fallback. Each CLI call is killed after 10 s (e.g. a pending keyring unlock).
`grove doctor` reports the source per provider without contacting the forge.
Mirrors store a token on the forge: the mirror provider's token in the primary's push-mirror
config, and the source's token in a pull mirror of a **private** source. With the CLI fallback that
is the broad-scope `tea`/`gh` token; use `grove login` with a narrower token to avoid that.
## Validation
- `grove-core` config tests: routing, owners, round trip, invalid public routes/owners.
- `grove-providers/tests/api.rs`: migrate request shape (owner, credentials only when private),
GitHub `Unsupported`, tea/gh fallback with fake binaries on `PATH`, opt-out variable.
- `grove` unit test: import filtering by owner (case-insensitive) and visibility.
- Real machine: `grove doctor` found the tea (git.zenvairo.es) and gh (github.com) tokens.
## Not verified
- Pull mirror creation on the real Gitea and push to a real GitHub org (mock-tested only).
- The daemon still syncs every repo under `root.path`, whether or not its directory is a group.