fix(hook-augment): cache the build fingerprint so the startup deadline is met - #1767
fix(hook-augment): cache the build fingerprint so the startup deadline is met#1767bmcnaboe wants to merge 2 commits into
Conversation
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
|
Thank you for measuring the fingerprint cost, covering cache rollover, and making missed hook deadlines observable. Runtime identity caching and platform SHA paths touch startup and trust boundaries, so we need more time to review them carefully. The contribution queue is quite full, but we will return with grounded feedback as soon as possible. |
|
Reviewed. The diagnosis is excellent and it closes the other half of a symptom this repo has chased before. One CI failure I am not willing to call environmental, and I would rather say why than wave it through. The substanceThis is the second cause of the same silent failure. The comment above Keying the cache on (device, inode, size, mtime, ctime) is the right identity. A rebuilt binary rolls every one of those, so the cache cannot serve a stale fingerprint for a different image — which is the failure mode that would make this worse than no cache. Asserting the CommonCrypto path bit-identical to the scalar one is what makes the hardware path safe to take. A faster hash that disagrees on one input would be a very unpleasant bug to find later, and But the most valuable line in this PR is the third bullet. Recording a missed deadline on both the timeouts log and stderr, "never a silent 0-byte exit 0", is what turns this class of problem from invisible into reportable. Even with the cache, some future machine will be slow enough; the difference is whether anyone can tell. The failure I am not attributing
I checked, and I cannot honestly call this unrelated:
That is a plausible mechanism, and "adds no config code" does not rule it out. The run is also from 20 August, and Please rebase and let it re-run. If it clears, it was the base. If it persists, the place to look is fingerprint acquisition on a cold cache directory — a startup path failing before This is also Three well-argued fixes to the hook-augment path from you now. Thank you — this one has the most user-visible payoff of the three. |
…e is met Every process start SHA-256s its own ~295 MB executable to build the build-identity fingerprint (~2.3 s, software path), which pushes the PreToolUse hook past its default deadline on large graphs so it emits 0 bytes and exits 0. - Cache the fingerprint keyed by (device, inode, size, mtime, ctime) at runtime_process_image_reference_acquire, covering both the self- fingerprint and the per-peer rendezvous; a rebuilt binary rolls the key. - Back the streaming SHA-256 with CommonCrypto on Apple (hardware path), dropping even a cache miss to ~0.25 s; asserted bit-identical to scalar. - A missed deadline is now recorded on BOTH the timeouts log and stderr (never a silent 0-byte exit 0); CBM_HOOK_DEADLINE_MS still honored; and `daemon <start|stop|status>` is documented in --help. Fixes DeusData#1335 Signed-off-by: Brian McNaboe <bmcnaboe@gmail.com>
fde7929 to
0657651
Compare
|
The What the smoke seesPhase 3z3 runs What stderr actually saysMechanism (measured)The MCP stdio session auto-starts
The next one-shot CLI (
Linux/Windows keep the scalar hash, so the mask stays in place there — which is exactly why only the macOS leg goes red. Why this is yours to close, and howThe smoke assertion is a real production race that your speed-up exposes deterministically: any command under a different
What is not on the table is a Local repro that reproduces it 2/2 ( export CBM_RUNTIME_DIR=$(mktemp -d)
python3 - "$BIN" <<'PY' # the smoke's own Phase 3z2 snippet
import json, subprocess, sys
BIN=sys.argv[1]; rpc=lambda i,m,p: json.dumps({"jsonrpc":"2.0","id":i,"method":m,"params":p})
lines=[rpc(1,"initialize",{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"smoke-pipe","version":"0"}}),
json.dumps({"jsonrpc":"2.0","method":"notifications/initialized"})]
lines+=[rpc(100+i,"tools/call",{"name":"list_projects","arguments":{}}) for i in range(24)]
subprocess.run([BIN],input="\n".join(lines)+"\n",capture_output=True,text=True,timeout=300)
PY
CBM_CACHE_DIR=$(mktemp -d) "$BIN" config get auto_watch; echo "rc=$?"Everything else on your branch is green apart from the standing |
|
Closing the loop on the macOS pr-smoke red: it is not your change, but your change is what exposed it — and that turned out to be useful. The failing The fix lives in #2047 (the cohort acquire now retries a mismatched holder until the caller's deadline, the same handoff wait Thanks for the patience on this one, and for a change that flushed out a real lifecycle bug on its way in. |
…line A participant admitted to the version cohort holds the cohort lifetime lock SH until its lease is released at exit. An internal daemon that has just lost its last stdio client keeps that lock through its teardown, so a local CLI (`config get`, `index_status`, ...) arriving in that few-hundred-ms window met a holder whose cache root differed and was refused immediately with "active account daemon uses a different cache directory" — a pure lifecycle race, previously masked by the slow scalar self-hash and exposed as soon as the hash got fast (DeusData#1767 pr-smoke on macOS). cbm_version_cohort_acquire now retries a CONFLICT until the caller's finite deadline_ms, holding no guard between attempts, exactly as host.c already waits out the same handoff for the daemon claim marker. Every production caller passes a finite deadline; UINT64_MAX keeps failing fast so a genuine conflict against a long-lived peer is never waited on indefinitely. Tests (deterministic, no timing assertions on transient windows): one proves the retry runs until the deadline and a UINT64_MAX caller still fails immediately; one proves a waiter that met the mismatched holder is admitted the moment the holder releases. Both fail with the retry removed. Fixes DeusData#2046 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Every process start SHA-256s its own ~295 MB executable to build the build-identity fingerprint (~2.3 s, software path), pushing the PreToolUse hook past its default deadline on large graphs so it emits 0 bytes and exits 0.
runtime_process_image_reference_acquire, covering the self-fingerprint and per-peer rendezvous; a rebuilt binary rolls the key.CBM_HOOK_DEADLINE_MSstill honored;daemon <start|stop|status>documented in --help.Tests: daemon_runtime_fingerprint_cache_hit_miss_key_roll, cli_sha256_platform_path_matches_scalar, and the extended deadline-breadcrumb test. Opened as a draft.
Fixes #1335