Skip to content

perf(hooks): cut SessionStart blocking git spawns + duplicate briefing reads (#194)#215

Merged
SUaDtL merged 4 commits into
mainfrom
fix/tribunal-sessionstart-latency
Jul 2, 2026
Merged

perf(hooks): cut SessionStart blocking git spawns + duplicate briefing reads (#194)#215
SUaDtL merged 4 commits into
mainfrom
fix/tribunal-sessionstart-latency

Conversation

@SUaDtL

@SUaDtL SUaDtL commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Lane E3 — #194 (performance — sessionstart-latency: performance-002/003). The linchpin SessionStart hook blocked on redundant work before the persona reached the model.

What

  • performance-002: (a) the hooks-install re-probe (_githooks.install) now skips its git spawns when a cheap on-disk cache proves the shims are current — fail-safe (see below); (b) the 5 independent assemble_summary git reads (status/rev-list/branch/worktree/stash) now run concurrently via a ThreadPoolExecutor instead of strictly sequentially — parsing is unchanged, output byte-identical.
  • performance-003: the first-of-day briefing re-read CONTEXT.md/open-tasks.md/open-questions.md via arbiter_state after main() already read them — the already-read text is now threaded through (new optional ctx_text/ot_text/oq_text kwargs, None = original disk-read behavior for all other callers).

Fail-safe hooks-install skip (reviewed hard — this touches the #161 backstop)

The skip fires ONLY when it can positively, spawn-free confirm no hooks redirect: cached dir is exactly <root>/.git/hooks AND _confirmed_no_local_hooks_path (a grammar-free case-insensitive hookspath substring scan of .git/config/config.worktree — cannot under-detect any git-config spelling) finds none AND no [include] AND the shims still match the current enforcer path. Any read failure / hookspath / [include] / cached custom hooksPath / global-config change (~/.gitconfig+XDG mtime token) → fall through to the full install. Fail direction is install-when-unsure, never skip-when-unsure — the fast path can never leave the git-enforce backstop unwired.

Verification

  • 762 hook tests pass (+ new spies: zero-git-spawn second probe, concurrent-not-sequential fan-out timing, exact governance-file open counts, and the same-line/no-space/upper-case core.hooksPath regressions); test_hooks_cold_install.py PASS (a genuine cold install still wires the hooks); existing session-start/wire-statusline/git-enforce assertions UNMODIFIED and green; py_compile clean; LF.
  • security-reviewer: PASS after two fix rounds. The initial skip could leave the [P1] Shell indirection bypasses pre-bash commit, push, staging, and security gates #161 backstop unwired on a post-install core.hooksPath change (CRITICAL) — fixed with the spawn-free .git/config confirmation; a follow-up caught git's same-line config spelling (HIGH) — fixed with the grammar-free substring scan. Both regressions verified to fail against the pre-fix commits. Fan-out (no shared state, best-effort) and thread-through (identical parsing) cleared first pass.

Bumps ca 2.8.9 → 2.8.10. Documents the fast-path posture in security-controls.md §Hook security.

Closes #194

https://claude.ai/code/session_01PVTCDji6bEuf9SifQ8tfsa

SUaDtL added 4 commits July 2, 2026 15:48
…g reads (#194)

Latency-only change: no injected startup state changed. See test additions for eliminated-spawn/read proof.
…nwired (CRITICAL)

Security review found the performance-002 hooks-install re-probe skip
(203d78d) trusted a cached hooks_dir without re-confirming git would still
read hooks from that location. A LOCAL core.hooksPath change after the cache
was written (e.g. adopting husky / pre-commit-framework) left install()
returning [] while the NEW hooks dir got no codeArbiter shim at all --
silently voiding the H-01/H-02/H-09b/H-10b/H-14 git-level backstop.

The fast path (zero git spawns) now additionally requires: the cached dir be
exactly the default <root>/.git/hooks (never a cached custom hooksPath), and
a direct read of .git/config (+ config.worktree, + an [include] safety net)
positively confirms no local core.hooksPath override is set right now. Any
miss/ambiguity falls through to the full git-based probe -- fail direction is
"install when unsure," never "skip when unsure".

Also keys the cache on ~/.gitconfig's mtime so a later global hooksPath edit
invalidates a previously-fast-pathable cache; a system-wide (/etc/gitconfig)
change remains a documented, accepted residual (cold/first install always
resolves it correctly via the full probe regardless).

Regression tests added: local hooksPath added/removed after install must
never be skipped as a no-op; a cached CUSTOM hooksPath is never fast-pathed;
_confirmed_no_local_hooks_path unit coverage (silent/set/include-directive).
…sidual doc (HIGH+MEDIUM)

HIGH (second spelling of the same skip -> backstop-unwire class): the
section/key line parser in _confirmed_no_local_hooks_path missed git's
SAME-LINE config form -- `[core] hooksPath = x`, `[core]hooksPath=x`, and
`[CORE]HooksPath=x` are all valid, real-git-honored spellings that matched
_SECTION_RE and `continue`d, discarding the rest of the line, so the key was
never seen. Replaced the hand-rolled parser with a grammar-free,
case-insensitive substring scan for "hookspath" (and "[include") anywhere in
the config text: any occurrence in any spelling/placement/casing, or any read
failure, returns "not confirmed" and falls through to the real probe. This
can only ever over-trigger a harmless extra git spawn on a false positive
(e.g. a stray comment) -- never falsely confirm an override is absent when
one is present. Strictly "install when unsure."

MEDIUM: the ~/.gitconfig-only mtime invalidation token under-scoped the
residual -- git also reads the XDG `~/.config/git/config` (or
$XDG_CONFIG_HOME/git/config). The cache-validity token now covers both
paths; the module-header residual note now correctly names
GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEM env overrides and /etc/gitconfig as the
remaining (documented, accepted) uncovered cases.

Regression tests added: same-line hooksPath (spaced, no-space, upper
section+key) each proven NOT confirmed via the unit-level helper, plus an
end-to-end test (with a real-git sanity check that the same-line spelling is
actually honored) proving install() lands in the custom dir rather than
being skipped as a no-op. All prior regression tests (git-config-driven
add/remove, cached-custom-never-fast-pathed, include-directive) remain
green.
Version bump + README badge sync for #194; documents the fail-safe hooks-install
re-probe fast-path in security-controls.md §Hook security.

Claude-Session: https://claude.ai/code/session_01PVTCDji6bEuf9SifQ8tfsa
@SUaDtL
SUaDtL merged commit 12c3a08 into main Jul 2, 2026
23 checks passed
@SUaDtL
SUaDtL deleted the fix/tribunal-sessionstart-latency branch July 24, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SessionStart latency: serial git subprocess fan-out and redundant file re-reads

1 participant