mirror of
https://github.com/garrytan/gstack.git
synced 2026-10-31 22:14:25 +01:00
* fix(windows): shell bins pass NUL as Bun's empty config when MSYS path conversion is off (#3415) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(windows): detect Git Bash/MSYS2/Cygwin from OSTYPE, as gstack-doctor does, so uname stubs in setup fixtures stay untouched Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (#3415) - Choose NUL only when cygpath is also on PATH, so an OSTYPE=msys inherited by a POSIX bash keeps /dev/null instead of a cwd-relative NUL file. - gstack-developer-profile --log-session reports a Bun failure instead of skipping it as invalid input, like gstack-timeline-log. - learnings-injection tests check that their anchored bun -e block exists. - CHANGELOG names the callers this fix does not cover; curation reason fixed. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes, cycle 2 (#3415) - timeline-log and developer-profile validators print their verdict; any non-zero Bun exit is a reported failure (a Bun crash on Windows exits 3). - timeline-log keeps the original event when ts stamping fails. - The definition ratchet scopes a local GSTACK_BUN_CONFIG to its function. - The shell-bins fixture clears its preload marker per test. - CHANGELOG states the callers that discard the report and the Bun 1.3.x case. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CHANGELOG notes Bun 1.3.10 evidence and remaining literal /dev/null callers (#3415) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
71 lines
2.8 KiB
Bash
Executable File
71 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# gstack-specialist-stats — compute per-specialist hit rates from review history
|
|
# Usage: gstack-specialist-stats
|
|
#
|
|
# Reads all *-reviews.jsonl files across branches, parses specialist fields,
|
|
# and outputs hit rates. Tags specialists as GATE_CANDIDATE (0 findings in 10+
|
|
# dispatches) or NEVER_GATE (security, data-migration, state-machines — insurance policy).
|
|
# Fix-range passes (scope "fix-range", #3339) are skipped: a narrowed dispatch
|
|
# says nothing about a specialist's hit rate on a whole branch.
|
|
set -euo pipefail
|
|
GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v cygpath >/dev/null 2>&1; then GSTACK_BUN_CONFIG=NUL; fi ;; esac
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
eval "$("$SCRIPT_DIR/gstack-slug" 2>/dev/null)"
|
|
. "$(dirname "$0")/gstack-state-root.sh" 2>/dev/null || { echo "$0: cannot resolve the gstack state root: $(dirname "$0")/gstack-state-root.sh is missing. fix: reinstall with ./setup or /gstack-upgrade (docs/state-root.md)" >&2; exit 1; }
|
|
gstack_state_root_select
|
|
GSTACK_HOME="$_gstack_sr_root"
|
|
PROJECT_DIR="$GSTACK_HOME/projects/$SLUG"
|
|
|
|
if [ ! -d "$PROJECT_DIR" ]; then
|
|
echo "SPECIALIST_STATS: 0 reviews analyzed"
|
|
exit 0
|
|
fi
|
|
|
|
# Collect all review JSONL files (strip ---CONFIG--- and ---HEAD--- footers)
|
|
COMBINED=""
|
|
for f in "$PROJECT_DIR"/*-reviews.jsonl; do
|
|
[ -f "$f" ] || continue
|
|
COMBINED="$COMBINED$(sed '/^---/,$d' "$f" 2>/dev/null)
|
|
"
|
|
done
|
|
|
|
if [ -z "$COMBINED" ]; then
|
|
echo "SPECIALIST_STATS: 0 reviews analyzed"
|
|
exit 0
|
|
fi
|
|
|
|
printf '%s' "$COMBINED" | bun --no-env-file --config="${GSTACK_BUN_CONFIG:-/dev/null}" -e "
|
|
const lines = (await Bun.stdin.text()).trim().split('\n').filter(Boolean);
|
|
const NEVER_GATE = new Set(['security', 'data-migration', 'state-machines']);
|
|
const stats = {};
|
|
let reviewed = 0;
|
|
|
|
for (const line of lines) {
|
|
try {
|
|
const e = JSON.parse(line);
|
|
if (!e.specialists || e.scope === 'fix-range') continue;
|
|
reviewed++;
|
|
for (const [name, info] of Object.entries(e.specialists)) {
|
|
if (!stats[name]) stats[name] = { dispatched: 0, findings: 0 };
|
|
if (info.dispatched) {
|
|
stats[name].dispatched++;
|
|
stats[name].findings += (info.findings || 0);
|
|
}
|
|
}
|
|
} catch {}
|
|
}
|
|
|
|
console.log('SPECIALIST_STATS: ' + reviewed + ' reviews analyzed');
|
|
const sorted = Object.entries(stats).sort((a, b) => a[0].localeCompare(b[0]));
|
|
for (const [name, s] of sorted) {
|
|
const pct = s.dispatched > 0 ? Math.round(100 * s.findings / s.dispatched) : 0;
|
|
let tag = '';
|
|
if (NEVER_GATE.has(name)) {
|
|
tag = ' [NEVER_GATE]';
|
|
} else if (s.dispatched >= 10 && s.findings === 0) {
|
|
tag = ' [GATE_CANDIDATE]';
|
|
}
|
|
console.log(name + ': ' + s.dispatched + '/' + reviewed + ' dispatched, ' + s.findings + ' findings (' + pct + '%)' + tag);
|
|
}
|
|
" 2>/dev/null || { echo "SPECIALIST_STATS: 0 reviews analyzed"; exit 0; }
|