Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/prometheus-exec-binary.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"sourcePath": "crates/prometheus-exec/target/release/prometheus-exec",
"installPath": "~/.local/bin/prometheus-exec",
"expectedVersion": "prometheus-exec 1.7.0",
"expectedBuildSha256": "a67de3b6c4f41a471e00bcfb683de5afa3164ddbf96af6b1ed4e434d9d079b56",
"expectedBuildSha256": "97c6b5bdb853f2db9aaabe918d9e09beecf6ac2141705e0b9181e0e19fe5958f",
"installReceipt": "~/.prometheus/install/manifests/prometheus-exec.json"
}
60 changes: 30 additions & 30 deletions dist/plugins/claude/prometheus-skill-pack/hooks/hooks.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
{
"path": "shared/scripts/enqueue-learning-job.py",
"sha256": "ead5ceb1c815c154500415b00c80722e18bd4df86e1f0ced8887c861e27ce28c",
"sha256": "fff1f6132b40bdeb82033528de3e52611cd6ca90adfeeea52dd73930ace61e05",
"mode": "0755"
},
{
Expand Down Expand Up @@ -316,5 +316,5 @@
"mode": "0755"
}
],
"bundleId": "1e45626629cdce87b6cced49acc1bb5efbfbf0076b6eeb8fbd5d4fa25a202d68"
"bundleId": "7cf81b78dcdc1cce7734d4d6cdc3db0629a10edf622ffd91bee1e9437e97f391"
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,22 @@
<string>local</string>
<key>LOCAL_EMBEDDING_MODEL</key>
<string>BAAI/bge-small-en-v1.5</string>
<key>LOCAL_EMBEDDING_MODEL_REVISION</key>
<string>5c38ec7c405ec4b44b94cc5a9bb96e735b38267a</string>
<key>LOCAL_EMBEDDING_DIMENSIONS</key>
<string>384</string>
<key>LOCAL_EMBEDDING_BACKEND</key>
<string>__LOCAL_EMBEDDING_BACKEND__</string>
<key>LOCAL_EMBEDDING_DEVICE</key>
<string>__LOCAL_EMBEDDING_DEVICE__</string>
<key>LOCAL_EMBEDDING_EXECUTOR</key>
<string>__SURREAL_MLX_EXECUTOR__</string>
<key>MODEL_CACHE_DIR</key>
<string>__PROMETHEUS_HOME__/.cache/huggingface</string>
<key>HF_HUB_CACHE</key>
<string>__PROMETHEUS_HOME__/.cache/huggingface/hub</string>
<key>SURREAL_EXECUTOR_STARTUP_MS</key>
<string>120000</string>

<!-- Retry / reconnection config -->
<key>SURREAL_MAX_CONNECT_RETRIES</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,25 @@ def main() -> int:
payload, "session_id", "sessionId", "conversation_id", "conversationId"
) or os.environ.get("CLAUDE_SESSION_ID") or os.environ.get("CODEX_THREAD_ID") or "unknown"
transcript_path = first(payload, "transcript_path", "transcriptPath")
# Transcript length is the turn cursor: it advances once per completed turn
# and is identical for the twin hooks that fire for the same turn.
try:
transcript_bytes = str(Path(transcript_path).stat().st_size) if transcript_path else ""
except OSError:
transcript_bytes = ""
payload_digest = hashlib.sha256(raw).hexdigest()
# ~keep The turn identity deliberately EXCLUDES `event` and `payload_digest`.
# Claude Code fires both `stop` and `subagent-executor-karpathy-learning`
# (`executor_complete`) for the same turn — measured 549 vs 548 across all
# recorded sessions, i.e. ~1:1 on ordinary turns with no subagent involved —
# and their payloads are structurally identical (same keys, sessionId,
# transcriptPath), differing only in the event name. Including either field
# made every turn unique, so the queue emitted one wiki record per hook per
# turn. Keying on the transcript position instead collapses the twins and
# still distinguishes genuinely different turns, because `transcript_bytes`
# grows monotonically as the session advances.
identity = "\0".join(
(harness, event, session_id, str(project_root), transcript_path, payload_digest)
(harness, session_id, str(project_root), transcript_path, transcript_bytes)
).encode()
event_id = hashlib.sha256(identity).hexdigest()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,38 @@ else
fail "duplicate delivery is idempotent across durable states"
fi

# Revert line: restore `event` or `payload_digest` to the `identity` tuple in
# enqueue-learning-job.py to make this test fail.
# ~keep Claude Code fires stop AND executor_complete for the SAME turn with
# structurally identical payloads (measured ~1:1, 549 vs 548, across all
# recorded sessions). Both must collapse to one job, or the worker writes two
# near-identical wiki records per turn.
mkdir -p "$TMP/twin"
printf 'line one\n' > "$TMP/twin-transcript.jsonl"
twin_payload="$(printf '{"session_id":"twin-session","cwd":"%s","transcript_path":"%s"}' \
"$TMP/project" "$TMP/twin-transcript.jsonl")"
for ev in stop executor_complete; do
printf '%s' "$twin_payload" | HOME="$TMP/home" PATH="$TMP/bin:$PATH" \
PROMETHEUS_LEARNING_QUEUE="$TMP/twin" "$DISPATCH" "$ev" claude-code
done
twin_jobs="$(find "$TMP/twin/pending" -type f -name '*.json' | wc -l | tr -d ' ')"
if [ "$twin_jobs" = 1 ]; then
pass "stop and executor_complete for one turn collapse to a single job"
else
fail "stop and executor_complete for one turn collapse to a single job (got $twin_jobs)"
fi

# Revert line: drop `transcript_bytes` from the `identity` tuple to make this
# test fail (all turns would collapse into one job).
printf 'line two\n' >> "$TMP/twin-transcript.jsonl"
printf '%s' "$twin_payload" | HOME="$TMP/home" PATH="$TMP/bin:$PATH" \
PROMETHEUS_LEARNING_QUEUE="$TMP/twin" "$DISPATCH" stop claude-code
next_jobs="$(find "$TMP/twin/pending" -type f -name '*.json' | wc -l | tr -d ' ')"
if [ "$next_jobs" = 2 ]; then
pass "a genuinely later turn still enqueues its own job"
else
fail "a genuinely later turn still enqueues its own job (got $next_jobs)"
fi

printf '\nPASS=%d FAIL=%d\n' "$PASS" "$FAIL"
[ "$FAIL" -eq 0 ]
Loading