Initial import of streamline

This commit is contained in:
2026-11-16 17:26:44 -08:00
commit 8e4aec1855
1221 changed files with 274256 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
#!/bin/zsh
# Daily evidence-quality analyst pass — reads the metric snapshot the machine job
# just wrote, and appends a research-log entry (findings + proposed strategies)
# via POST /api/evidmon/findings.
#
# Runs HERE, on the control-plane host, rather than as a cloud agent: the analysis
# needs the control-plane API and the Postgres, both of which are internal-only.
#
# Same gating idiom as weekly-report.sh — cron invokes this hourly, the script
# self-gates on Asia/Shanghai time. Fires at 09:30 北京时间, half an hour after
# evidmon-daily.sh has written the day's snapshot.
#
# Args:
# (none) cron mode — gate on Beijing 09:30.
# --force bypass the gate and analyse now.
set -e
REPO=${STREAMLINE_REPO:-/Users/fei/BBBBBBug}
CLAUDE=${CLAUDE_BIN:-claude}
LOG=$HOME/.streamline/evidmon_analyst.log
cd "$REPO"
mkdir -p "$(dirname "$LOG")"
if [[ "${1:-}" != "--force" ]]; then
read HOUR MIN <<< "$(TZ=Asia/Shanghai date +'%H %M')"
# cron fires this at :30; the hour gate is what actually selects the run.
if [[ "$HOUR" != "09" ]]; then
exit 0
fi
fi
DAY=$(TZ=Asia/Shanghai date +'%Y-%m-%d')
echo "===== $(TZ=Asia/Shanghai date '+%Y-%m-%d %H:%M:%S %Z') =====" >> "$LOG"
# The brief lives in docs/ so the procedure is reviewable and versioned rather
# than buried in a cron line.
"$CLAUDE" -p "你是 Streamline 证据采集监控的每日分析任务。
严格按 docs/evidmon-daily-analyst.md 的作业书执行,今天是 ${DAY}(北京时间)。
流程:
1. 读 docs/evidmon-daily-analyst.md 了解完整规程
2. 若当天快照尚未生成,先跑 bun run control-server/src/evidmon_daily.ts
3. 通过控制面 API 取指标树、既有研究日志、近两日事件(用 x-cluster-secret 认证,
密钥在 .env 的 CLUSTER_SECRET,控制面地址在 CONTROL_PLANE_URL)
4. 按作业书的标准做分析:先看 L1-E 判定精度,再看变化项、新增 fail/warn 样本、
skip 理由、已生效策略的实测效果
5. 判据类策略必须先调 POST /api/evidmon/criteria/replay 拿到回放结果再提
6. POST /api/evidmon/findings 写入,id 用 ${DAY}
纪律:
- 样本不足就说样本不足,不要把噪声讲成趋势
- evidence 必须引用真实数字和具体产物名
- 没有新发现的日子写一条短条目即可,不要为了填日志而虚构发现
- 你只提出,不批准任何策略;也不要改代码" \
--model claude-opus-5 \
--allowedTools "Bash,Read,Grep,Glob,WebFetch" \
>> "$LOG" 2>&1
echo "----- done $(TZ=Asia/Shanghai date '+%H:%M:%S') -----" >> "$LOG"