Skip to content

Commit 17ca5de

Browse files
authored
docs(team): simplify shared knowledge sync (#152) (#154)
Release highlights: - make private team knowledge refresh understandable in one safe Git workflow Release details: - Documentation: focus normal sync on reviewed upstream changes and one command - Documentation: move snapshots and MCP internals behind advanced disclosure - Reliability: give slow Git-and-index fixtures the existing 15-second test budget Verification: - pnpm validate - GitNexus detects low-risk documentation and test changes
1 parent a3b071f commit 17ca5de

6 files changed

Lines changed: 97 additions & 42 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pnpm bootstrap
3030
```
3131

3232
`pnpm bootstrap` runs `mise install && pnpm install`. Without mise, install the Node.js 22 release
33-
pinned in `mise.toml` and pnpm, then run `pnpm install` directly. Published packages retain their
34-
documented Node.js 20 runtime support; the repository toolchain itself requires Node.js 22.
33+
pinned in `mise.toml` and pnpm, then run `pnpm install` directly. The published packages and the
34+
repository toolchain require Node.js 22 or later.
3535

3636
Activate mise in your shell (`mise activate`, per the
3737
[mise docs](https://mise.jdx.dev/getting-started.html)) so that entering this repository puts the

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,21 @@ flowchart LR
164164
D --> E["Ready private index"]
165165
```
166166

167-
Git-backed teams build one private index per developer and use one command after reviewed changes
168-
land through a merge request:
167+
Git-backed teams build one private index per developer. The current branch upstream is the only
168+
declared authority: Git carries the reviewed change, Ragmir refreshes the local evidence.
169169

170170
```bash
171171
pnpm exec rgr team sync
172172
```
173173

174-
Ragmir fetches the current branch upstream, fast-forwards only a clean non-divergent branch, then
175-
reindexes changed sources incrementally. Dirty, ahead, diverged, detached, offline, and no-upstream
176-
states never rewrite history and return one action. Use `--no-pull` to keep branch updates manual or
177-
`--check` to preview. Advanced `team snapshot` and `team compare` diagnostics remain available for
178-
non-Git sources or exact drift analysis, including existing v2.19 snapshots. Detailed safeguards
179-
live in the
174+
1. Open and review a pull request (or merge request).
175+
2. Merge it into the declared upstream.
176+
3. Run `rgr team sync` on each workstation that needs fresh evidence.
177+
178+
Ragmir fast-forwards only a clean non-divergent branch and reindexes changed sources incrementally.
179+
Otherwise it leaves history and the valid index alone, then returns one action. `--no-pull` keeps
180+
branch updates manual and `--check` previews. Snapshots are an advanced fallback for non-Git sources
181+
or exact drift analysis, including existing v2.19 snapshots. Detailed safeguards live in the
180182
[team guide](./docs/agent-integration.md#team-knowledge-bases) and
181183
[configuration reference](./docs/configuration.md#stable-team-source-configuration).
182184

docs/agent-integration.md

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,41 +66,69 @@ from different bases labeled rather than silently merging citations.
6666

6767
## Team knowledge bases
6868

69-
Ragmir keeps one private local index per developer. For a Git-backed team, check out the branch the
70-
team declared authoritative, configure its upstream once, then use one command:
69+
Ragmir keeps one private local index per developer. For a Git-backed team, the current branch
70+
upstream is the only declared authority. Configure it once, then use one command:
7171

7272
```bash
7373
rgr team sync
7474
```
7575

76-
The command fetches only that upstream branch, compares Git history, and fast-forwards the checked
77-
out branch only when the worktree is clean, the local branch has no unpublished commit, and history
78-
has not diverged. It then runs incremental ingestion and reports `current`, `updated`, or one clear
79-
action. It never stashes, resets, rebases, creates a merge commit, deletes the active index, or
80-
chooses another branch.
76+
### The everyday workflow
8177

82-
This keeps the normal team loop small:
78+
```mermaid
79+
flowchart LR
80+
A["Push a reviewable change"] --> B["Merge to the declared upstream"]
81+
B --> C["rgr team sync"]
82+
C --> D["Safe fast-forward, if possible"]
83+
D --> E["Incremental local ingest"]
84+
E --> F["Ready private index"]
85+
```
8386

84-
1. A developer pushes a branch and opens or updates the merge request.
87+
1. A developer pushes a branch and opens or updates a pull request (or merge request).
8588
2. The team reviews and merges it into the declared upstream branch.
86-
3. Other developers run `rgr team sync`; safe updates and local reindexing happen together.
89+
3. Other developers run `rgr team sync`; source updates and local reindexing happen together.
90+
91+
Git already shows what changed and where review is needed. Ragmir does not add labels, snapshots,
92+
or another source of truth to this normal path.
93+
94+
| Result | What Ragmir does |
95+
| --- | --- |
96+
| `current` | Keeps the checked-out sources and local index because they are already aligned. |
97+
| `updated` | Fetches only the declared upstream, fast-forwards safely, then ingests changed sources. |
98+
| Needs action | Leaves Git history and the active index untouched, then explains the first next step. |
99+
100+
The automatic path fetches only that upstream and fast-forwards only when the worktree is clean,
101+
the local branch has no unpublished commits, and history has not diverged. It never stashes, resets,
102+
rebases, creates a merge commit, chooses another branch, or deletes the active index.
103+
104+
### Choose the sync mode
105+
106+
| Need | Command | Effect |
107+
| --- | --- | --- |
108+
| Normal team update | `rgr team sync` | Safely update from upstream and ingest incrementally. |
109+
| Keep Git updates manual | `rgr team sync --no-pull` | Fetch and compare, but do not change the checked-out branch. |
110+
| Preview only | `rgr team sync --check` | Report Git and index state without changing either one. |
111+
| Work offline | `rgr team sync --no-fetch` | Use cached Git state and local sources only. |
112+
| Enforce in automation | `rgr team sync --strict --json` | Return a typed report and fail unless freshness and readiness are proven. |
87113

88-
Use `--no-pull` to fetch and compare while keeping branch updates manual. Use `--check` to preview
89-
without changing the worktree or index, `--no-fetch` for an explicitly offline run, `--strict` in
90-
CI, and `--json` for automation. A dirty, ahead, diverged, detached, or untracked branch is never
91-
rewritten. A failed fetch keeps the last valid local index available and reports that upstream
92-
freshness is unverified. A failed ingestion keeps the previous validated index instead of deleting
93-
it first.
114+
Dirty, ahead, diverged, detached, untracked, or no-upstream branches are never rewritten. A failed
115+
fetch keeps the last valid index and marks upstream freshness as unverified. A failed ingestion also
116+
preserves the previous validated index. Resolve the Git state through the normal pull-request or
117+
merge-request workflow, then run the same command again.
94118

95119
The ignored `.ragmir/config.json` remains local. If every workstation needs the exact same source
96120
contract, version a reviewed template in the repository and apply it during setup. `rgr team sync`
97121
synchronizes tracked sources through Git; it does not commit or distribute private Ragmir state.
98122

99-
### Advanced drift diagnostics
123+
### When exact drift diagnosis is genuinely needed
124+
125+
Snapshots are an advanced fallback for a non-Git authority, such as Drive, or for a specific
126+
configuration and per-file investigation. They are not a prerequisite for ordinary Git teams.
100127

101-
Snapshots remain available for a non-Git authority such as Drive, or when the team needs an exact
102-
configuration and per-file comparison. They are not part of the normal Git workflow. On one
103-
authorized workstation:
128+
<details>
129+
<summary>Compare two authorized snapshots without sharing source text</summary>
130+
131+
On one authorized workstation:
104132

105133
```bash
106134
rgr team snapshot --label local --output .ragmir/team/local.json
@@ -135,6 +163,8 @@ ingestion.
135163
Do not synchronize `.ragmir/storage/` between active writers. A team bootstrap can call
136164
`initProject`, `addSourceEntries`, and `syncTeamKnowledge`; each workstation still owns its index.
137165

166+
</details>
167+
138168
### Agent behavior on team drift
139169

140170
An agent using the bundled Ragmir skill should run `rgr team sync --json` before relying on a
@@ -144,7 +174,7 @@ the last valid local index may be older than upstream. It must never resolve Git
144174
reset, rebase, or overwrite source files. Snapshot comparison remains the advanced fallback for an
145175
authorized non-Git source or exact drift investigation.
146176

147-
## MCP tools
177+
## Use Ragmir through MCP
148178

149179
The server exposes `ragmir_status`, `ragmir_route_prompt`, `ragmir_search`, `ragmir_ask`,
150180
`ragmir_research`, `ragmir_expand`, `ragmir_audit`, `ragmir_evaluate`, `ragmir_usage_report`, and
@@ -164,6 +194,8 @@ The TypeScript `sources({ offset, limit })` method can request later pages direc
164194
manifest file snapshot without materializing the complete source list; its default page remains 50
165195
files.
166196

197+
### Retrieve bounded evidence
198+
167199
Use compact retrieval first, then pass a returned citation to `ragmir_expand` when the agent needs
168200
the exact chunk or a bounded neighbor window. Search, ask, research, expansion, audit, and evaluation
169201
accept `maxBytes`. Variable-size tool and resource JSON is bounded by `mcpMaxOutputBytes` and an
@@ -177,6 +209,9 @@ size, audit detail, and returned evaluation case details, while keeping aggregat
177209
`ragmir_ask` returns cited evidence, not a model generated answer. A cloud agent can receive returned
178210
passages, so choose that handoff only when it matches the corpus's confidentiality requirements.
179211

212+
<details>
213+
<summary>Advanced: response contracts, safety annotations, and server lifecycle</summary>
214+
180215
Every tool advertises non-destructive behavior to compatible clients. Search, ask, research, and
181216
evaluation conservatively advertise open-world behavior because explicitly enabled semantic models
182217
may download public weights. The pure prompt router, security audit, and usage report also advertise
@@ -202,6 +237,8 @@ before and after the call. Ragmir does not open an HTTP port; applications that
202237
transport own its authentication and
203238
authorization boundary.
204239

240+
</details>
241+
205242
## Verify
206243

207244
```bash

docs/cli-reference.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,36 @@ report records both configured and consumed budgets.
8383
rgr team sync
8484
```
8585

86-
`team sync` treats the current branch upstream as the declared source of truth. It fetches that
87-
single branch, fast-forwards only a clean branch with no local-only commits or divergence, then runs
88-
incremental ingestion. Git authentication is non-interactive and each Git command is bounded. A
89-
dirty, ahead, diverged, detached, or no-upstream state never changes branch history and returns one
90-
recommended action. Fetch and ingestion failures keep the previous valid local index available
91-
when one exists.
86+
Use this after reviewed source changes merge into the current branch upstream. That upstream is the
87+
declared authority, and Git remains the place where the team reviews differences. `team sync`
88+
fetches only that branch, fast-forwards only a clean non-divergent history with no local-only
89+
commits, then ingests changed sources incrementally. Git authentication is non-interactive and each
90+
Git command is bounded.
91+
92+
| Result | Meaning |
93+
| --- | --- |
94+
| `current` | The checked-out sources and private local index already match upstream. |
95+
| `updated` | A safe fast-forward and incremental ingest completed. |
96+
| Needs action | Git history and the active index were preserved; follow the one recommended action. |
9297

9398
| Option | Behavior |
9499
| --- | --- |
95-
| `--no-pull` | Fetch and compare, but never update the checked-out branch. |
100+
| `--no-pull` | Fetch and compare, but keep branch updates manual. |
96101
| `--no-fetch` | Avoid network access and use only cached Git state plus local sources. |
97102
| `--check` | Fetch and report without changing the worktree or index. |
98103
| `--git-timeout-ms N` | Bound each Git command, from 1 ms to 300,000 ms. |
99104
| `--strict` | Exit with code 1 unless upstream freshness and local index readiness are proven. |
100105
| `--json` | Return the complete typed report. |
101106

102-
Snapshots are an advanced fallback for non-Git sources or exact drift investigation:
107+
A dirty, ahead, diverged, detached, or no-upstream state never rewrites history. Fetch and ingestion
108+
failures preserve the previous valid local index when one exists. Resolve the Git state through the
109+
normal pull-request or merge-request workflow, then rerun the same command.
110+
111+
<details>
112+
<summary>Advanced: diagnose exact drift or a non-Git authority</summary>
113+
114+
Snapshots are not part of the normal Git workflow. Use them for a non-Git authority or a specific
115+
per-file comparison:
103116

104117
```bash
105118
rgr team snapshot --label local --output .ragmir/team/local.json
@@ -120,6 +133,8 @@ do not require deleting or rebuilding the index. Snapshots written by Ragmir v2.
120133
v2.19.2 remain compatible. These advanced commands never change source files or decide which side
121134
is authoritative.
122135

136+
</details>
137+
123138
## Safe upgrades
124139

125140
```bash

docs/troubleshooting.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ updates must remain manual and `--check` for a no-worktree-change preview.
7676

7777
The active `.ragmir/config.json` is intentionally local and ignored. If results still differ after
7878
Git is current, verify that both workstations use the same reviewed source-contract template and
79-
Ragmir version. For an exact diagnosis or a non-Git authority, use the advanced snapshot flow:
79+
Ragmir version. Do not start with snapshots: use them only for an exact diagnosis or a non-Git
80+
authority:
8081

8182
```bash
8283
rgr team snapshot --label local --output .ragmir/team/local.json

packages/ragmir-core/src/team-sync.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe.sequential("team sync", () => {
7979
expect(await readFile(path.join(fixture.local, "docs", "decision.md"), "utf8")).toBe(
8080
"Local draft.\n",
8181
)
82-
})
82+
}, 15_000)
8383

8484
it("should require the merge-request workflow when local and upstream histories diverge", async () => {
8585
const fixture = await createGitFixture()
@@ -153,7 +153,7 @@ describe.sequential("team sync", () => {
153153
"Check mode did not change the worktree or refresh the index.",
154154
)
155155
expect(await git(fixture.local, ["rev-parse", "HEAD"])).toBe(headBefore)
156-
})
156+
}, 15_000)
157157

158158
it("should avoid remote access and branch updates when fetch is disabled", async () => {
159159
const fixture = await createGitFixture()

0 commit comments

Comments
 (0)