ADR-0018: Web UI KB Management via Git Forks
Context
Pyrite's web UI needs multi-user KB management where users can browse, edit, and contribute to knowledge bases. The core challenge: multiple users editing the same git-backed KB creates conflicts, and we need a workflow that preserves Pyrite's git-native storage model (ADR-0001) while enabling concurrent collaboration.
Key requirements:
Decision
Architecture: Per-User Forks with Shallow Clones
``` server filesystem/ ├── orgs/ │ └── acme-corp/ │ ├── repos/ │ │ └── knowledge/ ← upstream (bare or working) │ │ ├── kb/ ← KB 1 │ │ └── research/ ← KB 2 │ └── config.yaml ├── users/ │ └── alice/ │ ├── forks/ │ │ └── acme-corp--knowledge/ ← shallow fork │ │ ├── kb/ │ │ └── research/ │ └── config.yaml ```
Hierarchy: 1. Organizations own repos. Each org gets a filesystem directory. 2. Repos are git repositories. A repo can contain multiple KBs in different base directories. 3. Users get their own directory with shallow forks of repos they access. 4. Forks are `git clone --depth=1` of the upstream repo. They share git objects where possible.
Fork Lifecycle
1. First access: User visits a KB → system creates a shallow fork (`git clone --depth=1 --branch main
UI Divergence Indicators
When the user's fork diverges from upstream:
The UI always shows the user's fork by default. Upstream content is fetched on-demand for comparison.
Existing Infrastructure
Pyrite already has building blocks for this:
| Component | Location | Capability | |-----------|----------|------------| | `RepoService.fork_and_subscribe()` | `pyrite/services/repo_service.py` | GitHub fork + clone + remote setup | | `RepoService.subscribe()` | `pyrite/services/repo_service.py` | Clone with remote tracking | | `RepoService.sync()` | `pyrite/services/repo_service.py` | Pull upstream changes | | `GitService.fork_repo()` | `pyrite/services/git_service.py` | GitHub API fork creation | | `GitService.clone()` | `pyrite/services/git_service.py` | Git clone with token injection | | `GitService.pull()` / `push()` | `pyrite/services/git_service.py` | Push/pull with auth | | `UserService` | `pyrite/services/user_service.py` | User identity and auth |
Conflict Resolution
Storage Efficiency
Consequences
Positive
Negative
Neutral
Implementation Phases
1. Phase 1: Org/user directory structure, fork creation, basic read/write 2. Phase 2: Sync and divergence detection, UI indicators 3. Phase 3: PR creation and merge workflow 4. Phase 4: Conflict resolution UI, storage optimization