From 5184cc9a95074f96f7c3ceef8203f86cdc857475 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 17:14:29 +0100 Subject: [PATCH] docs: daemon scope, snapshot privacy and per-group auto_materialize Co-Authored-By: Claude Sonnet 5.5 --- CLAUDE.md | 1 + docs/phase2.md | 7 ++++--- docs/phase6.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 806b95d..6a11374 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -26,6 +26,7 @@ user's branch or index. - Dependencies: serde+toml, clap+anyhow, notify+serde_json, ureq, keyring, age, tauri v2 (GUI shell), approved. Ask before adding more. - Everything in the repo is English. Open questions go to `docs/DECISIONS.md`. - Never destroy local work; divergence is surfaced, never auto-merged. +- The daemon manages only bare-layout repos at `root//` and pushes WIP snapshots only to private repos by default (`sync.snapshots`, per-group override); see `docs/phase6.md`. ## Workflow quirks - Remote: Gitea `git.zenvairo.es`, owner `dasemu` (section `DarĂ­o`), CLI `tea`. SSH (port 22) diff --git a/docs/phase2.md b/docs/phase2.md index 654f186..82530c7 100644 --- a/docs/phase2.md +++ b/docs/phase2.md @@ -5,8 +5,9 @@ is `grove_core::sync::sync_repo`, the same code the CLI runs. The daemon only de ## Behaviour -- **Repos**: every directory `root/` or `root//` that has a `.bare` or `.git` - (dot-directories skipped). Rediscovered at every full pass, so new repos are picked up. +- **Repos**: bare-layout repos (`.bare`) at `root//` for configured groups only; see + `docs/phase6.md` (Daemon scope and snapshot privacy). Rediscovered at every full pass, so new repos + are picked up. - **Watching**: inotify (crate `notify`), recursive per repo. Changes under `.git`, `.bare`, `.grove-stage` and anything matching `sync.ignore_extra` (exact component name or `*suffix`) are ignored. If a watch cannot be set (typically `ENOSPC`, raise `fs.inotify.max_user_watches`) it is @@ -58,7 +59,7 @@ socket is refused; a stale socket file left by a crash is replaced. JSON lines in `/activity.jsonl` (rotated at 5 MiB to `.jsonl.1`), the last 500 events in memory, and live via `subscribe`. Kinds: `start`, `stop`, `snapshot`, `fast_forward`, `applied`, -`declined`, `state` (worktree state changed), `materialized`, `archived`, `error`, `watch_error`, +`declined`, `snapshots_withheld`, `snapshots_enabled`, `state` (worktree state changed), `materialized`, `archived`, `error`, `watch_error`, `pause`, `resume`. ## CLI diff --git a/docs/phase6.md b/docs/phase6.md index ed18939..e6182f2 100644 --- a/docs/phase6.md +++ b/docs/phase6.md @@ -61,4 +61,58 @@ is the broad-scope `tea`/`gh` token; use `grove login` with a narrower token to ## 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. +- Daemon scope and snapshot privacy (below) are verified with local bare remotes and mocks only, not against a real forge. + +## Daemon scope and snapshot privacy + +### Scope + +`groved` manages only repos in the bare + worktrees layout (a `.bare` directory) at +`//` for groups present in the config. Everything else under the root is +ignored: plain clones (never migrated with `grove add`), directories that are not configured +groups, repos directly under the root. Ignored plain clones inside a configured group are listed as +"not migrated (run grove add)" by `grove daemon status` and `grove doctor`. Discovery reads one +directory per configured group, so it stays cheap. Group names must be plain directory names. + +### Snapshot policy + +WIP snapshots (`refs/sync//`) contain uncommitted work, so on a public repo anyone +could read them. New key, global default under `[sync]` and optional override per group: + +```toml +[sync] +snapshots = "private-only" # default: "private-only" | "all" | "none" + +[[groups]] +name = "Zenvairo" +primary = "gitea" +snapshots = "all" # optional per-group override +``` + +- `private-only`: push snapshots only when the forge says the repo is private. +- `all`: always push. `none`: never push. +- When snapshots are withheld the daemon neither takes nor pushes them for that repo. Fetching, fast + forwarding and applying other machines' snapshots are unaffected. The reason shows in + `grove daemon status` ("snapshots withheld: ...") and once per change in the daemon log + (`snapshots_withheld` / `snapshots_enabled`). +- `grove sync` (manual) still pushes snapshots regardless of this setting. + +### How visibility is resolved + +For `private-only` the daemon matches the repo's `origin` URL (https, `ssh://` or scp-like) against +the configured providers by host (port ignored; GitHub without a URL is `github.com`), gets the +token with `token::resolve` (so the `tea`/`gh` fallback applies) and calls +`GET /repos/{owner}/{repo}` (`Provider::get_repo`, Gitea/Forgejo and GitHub). The answer is cached in +`/visibility.json` for 6 hours; a failed lookup is retried at most every 5 minutes. A +cached answer older than 6 hours is never used when the refresh fails. + +Unknown visibility counts as **public**: no matching provider, no token, network error, 404 (e.g. a +token without access to a private GitHub repo), a reply without the `private` flag, or no `origin`. +No lookup happens during an offline (backoff) pass, since nothing is pushed then. + +### auto_materialize + +`auto_materialize` (default `true`) makes the daemon create a worktree directory for every remote +branch of a repo, including long-merged ones, and archive worktrees whose branch is gone. It is +decided **per group** (it used to apply only when every group enabled it): set +`auto_materialize = false` in a group to stop that for its repos. The default is unchanged.