Seven targeted fixes from the gemini / qwen3 / gemma4 cross-AI reviews of
Phase 8. Risk LOW per all three reviewers; these were ranked as 1.x
candidates rather than ship-blockers, so each is a forward-compatible
extension of an existing surface, not a behavioural change.
1. Corpora/injection/manifest.json — add manifest_version=1; loader
surfaces it via loadFromBundleWithVersion(); jarvis-eval prints
"manifest_version=N" alongside the corpus count so each gate run
records which corpus was exercised. (Gemma4 #3)
2. MCPCrashRunner.swift — inline comments on each FD-whitelist pattern
explaining why it persists across helper restarts (PIPE / FIFO /
systm / KQUEUE / unix / /tmp/jarvis- / -wal / -shm). Future
contributors won't accidentally tighten the whitelist. (Gemma4 #4)
3. DriftReport.swift / DriftClassifier.swift — DriftItem now carries a
`reason` string ("alwaysExcluded membership",
"nondeterministicUnderSampling@temperature=0.7", etc.) so growth of
the exclusion set is visible at every gate run. (Gemma4 #5)
4. .planning/phases/03-hud/checklist.yaml — new P3-09 grep_positive
guard asserting JarvisHUDPanel.swift sets `self.level` to one of
statusBar/mainMenu/screenSaver/popUpMenu (occlusion regression
guard). (Gemini #6)
5. scripts/check-corpus-secrets.sh — extends the D-07 pre-commit hook
to scan .replay / .evaluation / .sqlite session files. Uses
`sqlite3` when available (queries events.tool_* rows directly) and
falls back to plain grep on the binary blob otherwise. (Gemini #7)
6. WakeHysteresisRunner.swift / main.swift — splits the single
"passed" verdict into `pipelineStatus` (ok / notWired) and
`performanceStatus` (pending / pass / warn / fail). Synthetic-only
corpora always report PERFORMANCE: PENDING so an operator never
mistakes a TTS-seed pass for a real-voice pass.
(Gemini + Gemma4 #2)
7. ReplayMCPAdapter.swift — substrate for side-effect-marker
verification. Recorded `tool_result_full` envelopes may now carry
an optional `side_effects: [String]` array; new public APIs
`recordedSideEffects(toolUseId:)` and `sideEffectDelta(toolUseId:
liveMarkers:)` let callers compare live vs recorded markers,
mitigating the byte-equal false-green risk. Helper-side emission
remains a follow-up. (Gemini #1, MEDIUM)
Tests: 63/63 across 9 Harness suites (3 new — manifest version exposure,
sampling-reason carries temperature, synthetic-corpus detection).
Build: clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
98 lines
3.5 KiB
Bash
Executable File
98 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# check-corpus-secrets.sh — D-07 pre-commit guard.
|
|
#
|
|
# Greps packages/Harness/Corpora/ for live API key patterns. Non-zero
|
|
# exit aborts the commit. The four patterns covered:
|
|
# sk-ant-[A-Za-z0-9]{40,} Anthropic
|
|
# AKIA[0-9A-Z]{16} AWS access key
|
|
# ghp_[A-Za-z0-9]{36} GitHub PAT
|
|
# sk-[A-Za-z0-9]{32,} Generic OpenAI-style
|
|
#
|
|
# Install as a pre-commit hook (option A: symlink template):
|
|
# ln -sf ../../scripts/precommit-template.sh .git/hooks/pre-commit
|
|
#
|
|
# Or option B: invoke directly from .git/hooks/pre-commit:
|
|
# "${REPO}/scripts/check-corpus-secrets.sh"
|
|
#
|
|
# Variable indirection per S-6:
|
|
# REPO=... override repo root detection
|
|
# CORPORA_PATH=... override Corpora/ path
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
: "${REPO:=$(cd "$SCRIPT_DIR/.." && pwd)}"
|
|
: "${CORPORA_PATH:=$REPO/packages/Harness/Corpora}"
|
|
# Replay/eval session SQLite files may carry a tool_call body that
|
|
# accidentally inlines an API key. Scan them too — D-07 review-followup.
|
|
: "${REPLAY_GLOB:=$REPO/Corpora/replay-golden}"
|
|
: "${EVAL_GLOB:=$REPO/Corpora/evaluation}"
|
|
|
|
PATTERNS=(
|
|
"sk-ant-[A-Za-z0-9]{40,}"
|
|
"AKIA[0-9A-Z]{16}"
|
|
"ghp_[A-Za-z0-9]{36}"
|
|
"sk-[A-Za-z0-9]{32,}"
|
|
)
|
|
|
|
HITS=0
|
|
|
|
if [[ -d "$CORPORA_PATH" ]]; then
|
|
for pat in "${PATTERNS[@]}"; do
|
|
if grep -rE "$pat" "$CORPORA_PATH" 2>/dev/null; then
|
|
echo "ERROR: D-07 violation — pattern '$pat' detected in Corpora/" >&2
|
|
HITS=$((HITS + 1))
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# Scan recorded SQLite session files. SQLite is a binary container — `grep`
|
|
# against the file works because key patterns are ASCII and stored verbatim.
|
|
# We scan only files matching well-known suffixes so a stray DB elsewhere in
|
|
# the tree (e.g. dev caches) isn't gated. `sqlite3` is preferred when
|
|
# available (it dumps tool_call rows as text) but plain grep is the
|
|
# acceptable fallback so the hook stays portable.
|
|
scan_sqlite() {
|
|
local target_dir="$1"
|
|
[[ -d "$target_dir" ]] || return 0
|
|
while IFS= read -r -d '' db; do
|
|
local hits_in_db=0
|
|
if command -v sqlite3 >/dev/null 2>&1; then
|
|
local dump
|
|
dump=$(sqlite3 -readonly "$db" \
|
|
"SELECT payload_text, tool_call_args, tool_result_text FROM events WHERE kind LIKE 'tool_%';" \
|
|
2>/dev/null || true)
|
|
for pat in "${PATTERNS[@]}"; do
|
|
if echo "$dump" | grep -qE "$pat"; then
|
|
echo "ERROR: D-07 violation — pattern '$pat' detected in SQLite events of $db" >&2
|
|
hits_in_db=$((hits_in_db + 1))
|
|
fi
|
|
done
|
|
else
|
|
for pat in "${PATTERNS[@]}"; do
|
|
if grep -aE "$pat" "$db" >/dev/null 2>&1; then
|
|
echo "ERROR: D-07 violation — pattern '$pat' detected in SQLite blob $db" >&2
|
|
hits_in_db=$((hits_in_db + 1))
|
|
fi
|
|
done
|
|
fi
|
|
HITS=$((HITS + hits_in_db))
|
|
done < <(find "$target_dir" \
|
|
\( -name "*.sqlite" -o -name "*.sqlite3" -o -name "*.db" \
|
|
-o -name "*.replay" -o -name "*.evaluation" \) \
|
|
-type f -print0 2>/dev/null)
|
|
}
|
|
|
|
scan_sqlite "$REPLAY_GLOB"
|
|
scan_sqlite "$EVAL_GLOB"
|
|
# Also scan the Harness-bundled corpora (golden replays staged inside SPM).
|
|
scan_sqlite "$REPO/packages/Harness/Corpora"
|
|
|
|
if [[ $HITS -gt 0 ]]; then
|
|
echo "" >&2
|
|
echo "Aborting commit. Redact the secret(s) above and re-stage." >&2
|
|
echo "If this is a false positive, scrub the byte sequence and re-run." >&2
|
|
exit 1
|
|
fi
|
|
|
|
exit 0
|