Add social cost proxies to impact tracking hooks

Extend pre-compact-snapshot.sh to extract 5 new per-conversation
metrics from the transcript: automation ratio (deskilling proxy),
model ID (monoculture tracking), test pass/fail counts (code quality
proxy), file churn (edits per unique file), and public push detection
(data pollution risk flag). Update show-impact.sh to display them.

New plan: quantify-social-costs.md — roadmap for moving non-environmental
cost categories from qualitative to proxy-measurable.

Tasks 19-24 done. Task 25 (methodology update) pending.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
claude 2026-03-16 15:05:53 +00:00
parent e6e0bf4616
commit af6062c1f9
8 changed files with 554 additions and 25 deletions

View file

@ -49,6 +49,35 @@ while IFS= read -r line; do
printf " Cache: %s created, %s read\n" "$cache_create" "$cache_read"
fi
LC_NUMERIC=C printf " Energy: ~%s Wh CO2: ~%sg Cost: ~\$%.2f\n" "$energy" "$co2" "$(echo "$cost / 100" | bc -l 2>/dev/null || echo "$cost cents")"
# Social cost proxies (if present in log entry)
model=$(echo "$line" | jq -r '.model_id // empty')
auto_pm=$(echo "$line" | jq -r '.automation_ratio_pm // empty')
user_tok=$(echo "$line" | jq -r '.user_tokens_est // empty')
files_ed=$(echo "$line" | jq -r '.unique_files_edited // empty')
total_ed=$(echo "$line" | jq -r '.total_file_edits // empty')
t_pass=$(echo "$line" | jq -r '.test_passes // empty')
t_fail=$(echo "$line" | jq -r '.test_failures // empty')
pub_push=$(echo "$line" | jq -r '.has_public_push // empty')
if [ -n "$model" ]; then
printf " Model: %s\n" "$model"
fi
if [ -n "$auto_pm" ] && [ "$auto_pm" != "0" ]; then
auto_pct=$(( auto_pm / 10 ))
auto_dec=$(( auto_pm % 10 ))
printf " Automation ratio: %d.%d%% (user ~%s tokens, AI ~%s tokens)\n" \
"$auto_pct" "$auto_dec" "$user_tok" "$output"
fi
if [ -n "$files_ed" ] && [ "$files_ed" != "0" ]; then
printf " File churn: %s edits across %s files\n" "$total_ed" "$files_ed"
fi
if [ -n "$t_pass" ] && [ -n "$t_fail" ] && { [ "$t_pass" != "0" ] || [ "$t_fail" != "0" ]; }; then
printf " Tests: %s passed, %s failed\n" "$t_pass" "$t_fail"
fi
if [ "$pub_push" = "1" ]; then
printf " Public push: yes (data pollution risk)\n"
fi
echo ""
done < "$LOG_FILE"
@ -62,3 +91,26 @@ echo "=== Totals ($TOTAL_ENTRIES snapshots) ==="
LC_NUMERIC=C printf " Energy: ~%s Wh CO2: ~%sg Cost: ~\$%.2f\n" \
"$TOTAL_ENERGY" "$TOTAL_CO2" \
"$(echo "$TOTAL_COST / 100" | bc -l 2>/dev/null || echo "$TOTAL_COST cents")"
# Show annotations if they exist
ANNOT_FILE="$PROJECT_DIR/.claude/impact/annotations.jsonl"
if [ -f "$ANNOT_FILE" ] && [ -s "$ANNOT_FILE" ]; then
echo ""
echo "=== Value Annotations ==="
echo ""
while IFS= read -r line; do
sid=$(echo "$line" | jq -r '.session_id')
if ! echo "$sid" | grep -q "$FILTER"; then
continue
fi
ts=$(echo "$line" | jq -r '.timestamp')
summary=$(echo "$line" | jq -r '.value_summary')
reach=$(echo "$line" | jq -r '.estimated_reach')
cf=$(echo "$line" | jq -r '.counterfactual')
net=$(echo "$line" | jq -r '.net_assessment')
printf "%s session=%s\n" "$ts" "${sid:0:12}..."
printf " Value: %s\n" "$summary"
printf " Reach: %s Counterfactual: %s Net: %s\n" "$reach" "$cf" "$net"
echo ""
done < "$ANNOT_FILE"
fi