Files
ECC/tests/hooks
montjeffrey d2db7871fe perf(clv2): cut observe hook process launches
observe.sh runs before and after every tool call and launched about 50
external processes per run. Each costs a few milliseconds on Linux/macOS
but 80-280 ms under Git Bash on Windows, where one run took 5-7 s.

- Read cwd, agent_id and observer.enabled in one Python start, and parse,
  scrub and write the observation in one more (was six). The redaction
  patterns are unchanged.
- Cache project detection per (CLV2_NO_PROJECT, CLAUDE_PROJECT_DIR, PWD)
  for the rest of the day. An entry is rejected when .git/config is not
  older than it, when the project dir or root is gone, or when the id is
  not a shape detection can produce. Worktrees, submodules and non-git
  roots are never cached. CLV2_PROJECT_CACHE=0 disables it; bash < 4.2
  skips it.
- Run the stdin-independent guards before the first interpreter start.
- Run the find/du housekeeping only when detection was not cached.
- Replace dirname/readlink/subshell calls on the hot path with builtins.

Measured on Windows 11 / Git Bash, warm cache: 5.2-5.8 s -> 1.1-1.2 s
per run. Output compared against the previous script on 19 payloads
(records, redaction, registry, counters, exit codes): identical.

Behavior changes: projects.json last_seen refreshes at least daily
instead of every call; observations.jsonl may exceed the 10 MB cap by up
to a day of records before archiving; the App Installer stub check only
follows symlinks for paths under WindowsApps.
2026-11-17 14:20:54 -05:00
..