Replace the .git probes in hooks with OsGit RepoRoot #1598

Closed
opened 2026-11-06 16:53:35 +00:00 by jared · 1 comment
Owner

Problem

Eight sites find the repository root by testing for .git without starting git: os/lib/os_hooks/project_root.rb, os-backlog/lib/backlog/config_locator.rb (reads the .git file of a linked worktree), os-backlog/lib/backlog/session_start.rb, os-adr/lib/adr/pre_tool_use.rb, os-adr/lib/adr/session_start.rb, and three Python files in os-doc-hygiene (scanner.py, reminder.py, state_store.py). They repeat one job and run in hooks.

Design: docs/os-git/use-cases-and-domain.md (design) and docs/os-git/call-site-checklist.md (call sites). Settled decisions are in design section 1 (docs/os-git/use-cases-and-domain.md): the gem lives in plugins/os-git with a path: source; git-context and os:worktree merge into os-git; old wrappers go only after all references are updated; design order is use-cases, objects, interfaces; os-context and os-vault become Ruby; ticket tracking stays out of os-git.

Reproduce

n/a: migration of existing call sites; behavior stays the same unless a criterion says otherwise.

Approach

Group A-11. Replace each Ruby site with OsGit::RepoRoot.find(path) (process-free, from the core ticket #1588). config_locator.rb also needs primary_root for a linked worktree: use the same finder. The three Python sites stay until os-doc-hygiene is ported (see #1597): mark rows G-063 to G-065 deferred with that reason. The os-vault probes sit inside rows G-053 to G-055 and belong to the Sync ticket (#1590).

Mark every row in the checklist from the Done column as it is replaced. Mark the matching test rows in the same change. Run bin/refresh-plugins after changes to SKILL.md, hooks, or CLIs.

Required work: none beyond the acceptance criteria.

Acceptance criteria

  1. Given a directory inside a repository, when a hook asks for the root, then it gets the same root as before and no git process starts.
  2. Given a linked worktree, when config_locator resolves the main checkout, then it gets the main checkout path.
  3. Given a directory outside any repository, when a hook asks for the root, then it returns nil as before.
  4. Given the os, os-backlog, and os-adr suites, when they run, then they pass.
  5. Given rows G-058 to G-065, when the ticket closes, then each row is marked - [x] with Replaced by filled in, or marked out of scope with a reason, in docs/os-git/call-site-checklist.md.
  6. Given the touched code, when it is searched for Open3, system(, %x, backticks, and git argv, then no git call remains outside OsGit adapters, except sites marked out of scope with a reason.

Blocking edges

Blocked by the core ticket (#1588).

Origin

  • Trigger: User request in session 1a5b2630-09c9-46cb-aee4-a5a98e2e7d24 on 2026-11-06: one os-git gem for all local git work in cc-os and the user's projects.
  • Improvised this session: none
  • Chain: eight copies of one root-finding job ← no shared RepoRoot ← DESIGN (docs/os-git/call-site-checklist.md group A-11)
  • Root candidate: none found; searched open issues for git, worktree, octokit, ruby port, python, statusline, reset --hard. Related but not a match: #845, #853, #857, #1527, #1554.
  • Where: plugins/os/lib/os_hooks/project_root.rb, plugins/os-backlog/lib/backlog/, plugins/os-adr/lib/adr/
  • Session: 1a5b2630-09c9-46cb-aee4-a5a98e2e7d24
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/1a5b2630-09c9-46cb-aee4-a5a98e2e7d24.jsonl
## Problem Eight sites find the repository root by testing for `.git` without starting git: `os/lib/os_hooks/project_root.rb`, `os-backlog/lib/backlog/config_locator.rb` (reads the `.git` file of a linked worktree), `os-backlog/lib/backlog/session_start.rb`, `os-adr/lib/adr/pre_tool_use.rb`, `os-adr/lib/adr/session_start.rb`, and three Python files in `os-doc-hygiene` (`scanner.py`, `reminder.py`, `state_store.py`). They repeat one job and run in hooks. Design: `docs/os-git/use-cases-and-domain.md` (design) and `docs/os-git/call-site-checklist.md` (call sites). Settled decisions are in design section 1 (`docs/os-git/use-cases-and-domain.md`): the gem lives in `plugins/os-git` with a `path:` source; `git-context` and `os:worktree` merge into `os-git`; old wrappers go only after all references are updated; design order is use-cases, objects, interfaces; `os-context` and `os-vault` become Ruby; ticket tracking stays out of `os-git`. ## Reproduce n/a: migration of existing call sites; behavior stays the same unless a criterion says otherwise. ## Approach Group A-11. Replace each Ruby site with `OsGit::RepoRoot.find(path)` (process-free, from the core ticket #1588). `config_locator.rb` also needs `primary_root` for a linked worktree: use the same finder. The three Python sites stay until `os-doc-hygiene` is ported (see #1597): mark rows G-063 to G-065 deferred with that reason. The os-vault probes sit inside rows G-053 to G-055 and belong to the Sync ticket (#1590). Mark every row in the checklist from the `Done` column as it is replaced. Mark the matching test rows in the same change. Run `bin/refresh-plugins` after changes to `SKILL.md`, hooks, or CLIs. Required work: none beyond the acceptance criteria. ## Acceptance criteria 1. Given a directory inside a repository, when a hook asks for the root, then it gets the same root as before and no `git` process starts. 2. Given a linked worktree, when `config_locator` resolves the main checkout, then it gets the main checkout path. 3. Given a directory outside any repository, when a hook asks for the root, then it returns `nil` as before. 4. Given the os, os-backlog, and os-adr suites, when they run, then they pass. 5. Given rows G-058 to G-065, when the ticket closes, then each row is marked `- [x]` with `Replaced by` filled in, or marked out of scope with a reason, in `docs/os-git/call-site-checklist.md`. 6. Given the touched code, when it is searched for `Open3`, `system(`, `%x`, backticks, and `git` argv, then no git call remains outside `OsGit` adapters, except sites marked out of scope with a reason. ## Blocking edges Blocked by the core ticket (#1588). ## Origin - Trigger: User request in session 1a5b2630-09c9-46cb-aee4-a5a98e2e7d24 on 2026-11-06: one os-git gem for all local git work in cc-os and the user's projects. - Improvised this session: none - Chain: eight copies of one root-finding job ← no shared RepoRoot ← DESIGN (docs/os-git/call-site-checklist.md group A-11) - Root candidate: none found; searched open issues for git, worktree, octokit, ruby port, python, statusline, reset --hard. Related but not a match: #845, #853, #857, #1527, #1554. - Where: plugins/os/lib/os_hooks/project_root.rb, plugins/os-backlog/lib/backlog/, plugins/os-adr/lib/adr/ - Session: 1a5b2630-09c9-46cb-aee4-a5a98e2e7d24 - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/1a5b2630-09c9-46cb-aee4-a5a98e2e7d24.jsonl
Author
Owner

Resolution

Done: RepoRoot at os ProjectRoot, both session_start hooks, and config_locator. Hooks load repo_root.rb alone and warn when the link is missing. pre_tool_use keeps File.exist? so the guard fails closed.

Evidence: main ea19631d. os 242, os-adr 169, os-backlog 413, os-git 291 runs, 0 failures. pre_tool_use cold start unchanged. G-058 to G-060, G-062 marked; G-061 out of scope (ruling 6); G-063 to G-065 deferred to #1597.

Follow-ups: #1630 os-git link setup on a new machine (ticket-skeptic verdict).

## Resolution **Done:** RepoRoot at os ProjectRoot, both session_start hooks, and config_locator. Hooks load repo_root.rb alone and warn when the link is missing. pre_tool_use keeps File.exist? so the guard fails closed. **Evidence:** main ea19631d. os 242, os-adr 169, os-backlog 413, os-git 291 runs, 0 failures. pre_tool_use cold start unchanged. G-058 to G-060, G-062 marked; G-061 out of scope (ruling 6); G-063 to G-065 deferred to #1597. **Follow-ups:** #1630 os-git link setup on a new machine (ticket-skeptic verdict).
jared closed this issue 2026-11-06 22:05:59 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#1598
No description provided.