Telemetry can count gstack's own use on Capy, opt-in and kept out of public numbers (GST-3311) (#4576)

Agent-driven Capy sessions still send no telemetry. If the owner's
`preferences.yaml` holds `telemetry_capy: anonymous`, each skill run
sends one anonymous row labelled `source=capy`, or `source=gt` from
Garry's own machines.

Why: we couldn't see our own gstack use on Capy, and if we had sent it,
it would have been counted as real use.

Nothing to do yet: nothing changes until the owner adds that line, and
the ingest change ships in a separate deploy.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-20 22:27:26 +00:00
1 parent 87a473e5aa
commit 14a84980ee
15 files changed
+250 -19

No files matched your search

+7 -4
View File
@@ -46,11 +46,13 @@ _GH="$_gstack_sr_root"
_TEL=$("$_BIN/gstack-config" get telemetry 2>/dev/null || echo off)
# Plan B1: an unattended session writes no usage, sends no telemetry and never
# drains or pushes the artifacts queue, whatever the inherited settings say. The
# upgrade offer it skipped at start becomes one line here, read from the
# one exception is gstack's own use on Capy: the owner's preferences file can
# opt Capy sessions in at the anonymous tier (gstack-telemetry-tier --capy).
# The upgrade offer it skipped at start becomes one line here, read from the
# update-check cache (no network) so the parent can act on it.
_SESSION_KIND=$("$_BIN/gstack-session-kind" 2>/dev/null || echo "interactive")
if [ "$_SESSION_KIND" = "unattended" ]; then
_TEL="off"
_TEL=$("$_BIN/gstack-telemetry-tier" --capy 2>/dev/null || echo off)
_CACHED_UPD=$(head -1 "$_GH/last-update-check" 2>/dev/null | tr -cd 'A-Za-z0-9._+ ' || true)
case "$_CACHED_UPD" in
UPGRADE_AVAILABLE*) echo "UPGRADE_AVAILABLE: $(printf '%s\n' "$_CACHED_UPD" | awk '{ print $3 (NF >= 4 ? " (main at " $4 ")" : "") }'); run /gstack-upgrade"
@@ -79,8 +81,9 @@ if [ "$_SESSION_KIND" != "unattended" ]; then
"$_BIN/gstack-brain-sync" --once 2>/dev/null || true
fi
# Local analytics (gated on telemetry setting).
if [ "$_TEL" != "off" ]; then
# Local analytics (gated on telemetry setting; an opted-in Capy session sends
# its one telemetry row below and still records no usage of its own).
if [ "$_TEL" != "off" ] && [ "$_SESSION_KIND" != "unattended" ]; then
echo '{"skill":"'"$SKILL_NAME"'","duration_s":"'"$_TEL_DUR"'","outcome":"'"$OUTCOME"'","browse":"'"$USED_BROWSE"'","session":"'"$SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> "$_GH/analytics/skill-usage.jsonl" 2>/dev/null || true
fi
+7 -3
View File
@@ -94,17 +94,21 @@ while [ $# -gt 0 ]; do
done
# Source: flag > GSTACK_TELEMETRY_SOURCE > an eval run (the eval harness sets
# EVALS_RUN_ID or GSTACK_EVAL_DIR) > CI > live. An explicit value always wins,
# so CI=true never relabels a row a test marked source=test.
# EVALS_RUN_ID or GSTACK_EVAL_DIR) > CI > Capy (GSTACK_CAPY=1, gstack's own
# use on Capy: capy, or gt from the owner's preferences file, never free text)
# > live. An explicit value always wins, so CI=true never relabels a row a test
# marked source=test, and an eval lane on Capy stays eval.
if [ -z "$SOURCE" ]; then
if [ -n "${GSTACK_TELEMETRY_SOURCE:-}" ]; then SOURCE="$GSTACK_TELEMETRY_SOURCE"
elif [ -n "${EVALS_RUN_ID:-}" ] || [ -n "${GSTACK_EVAL_DIR:-}" ]; then SOURCE="eval"
elif [ "${CI:-}" = "true" ]; then SOURCE="ci"
elif [ "${GSTACK_CAPY:-}" = "1" ]; then SOURCE="$("$GSTACK_DIR/bin/gstack-telemetry-tier" --source 2>/dev/null || echo capy)"
else SOURCE="live"; fi
fi
# ─── Read telemetry tier ─────────────────────────────────────
TIER="$("$CONFIG_CMD" get telemetry 2>/dev/null || true)"
# gstack-telemetry-tier adds the Capy opt-in to this machine's setting.
TIER="$("$GSTACK_DIR/bin/gstack-telemetry-tier" 2>/dev/null || "$CONFIG_CMD" get telemetry 2>/dev/null || true)"
TIER="${TIER:-off}"
# Validate tier
+2 -1
View File
@@ -45,7 +45,8 @@ if [ -f "$RATE_FILE" ]; then
fi
# ─── Read tier ───────────────────────────────────────────────
TIER="$("$CONFIG_CMD" get telemetry 2>/dev/null || true)"
# gstack-telemetry-tier adds the Capy opt-in to this machine's setting.
TIER="$("$GSTACK_DIR/bin/gstack-telemetry-tier" 2>/dev/null || "$CONFIG_CMD" get telemetry 2>/dev/null || true)"
TIER="${TIER:-off}"
[ "$TIER" = "off" ] && exit 0
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# gstack-telemetry-tier — the tier this session's telemetry goes out at, and
# the label a Capy session's rows carry.
#
# gstack-telemetry-tier → off | anonymous | community
# gstack-telemetry-tier --capy → the Capy opt-in alone: anonymous | off
# gstack-telemetry-tier --source → the Capy label: capy | gt
#
# A Capy session (GSTACK_CAPY=1) is opted in only by the owner's preferences
# file (GSTACK_PREFERENCES_FILE, beside the Capy skill's SKILL.md) holding
# exactly one `telemetry_capy: anonymous` line. It then sends at the anonymous
# tier whatever this machine's `telemetry` setting says. Only anonymous:
# community's installation_id is a stable device id, and Capy's consent rules
# one out (docs/privacy.md). No file, no line, two lines, another value or a
# file over 4 KB is off. Without the opt-in this prints the machine's setting.
# Unattended sessions stay silent unless opted in: gstack-skill-end asks --capy.
#
# gstack-telemetry-log labels a Capy session's rows from a fixed list:
# `telemetry_capy_source: gt` (gstack's maintainer's own machines) gives gt,
# and anything else, a missing line included, gives capy.
# pref KEY → the value of the file's one `KEY:` line, empty when there is not exactly one.
pref() {
local f="${GSTACK_PREFERENCES_FILE:-}" bom lines
[ "${GSTACK_CAPY:-}" = "1" ] && [ -n "$f" ] && [ -f "$f" ] || return 0
[ "$(wc -c < "$f" 2>/dev/null || echo 4097)" -le 4096 ] || return 0
bom=$(printf '\357\273\277')
lines=$(LC_ALL=C sed -e "1s/^$bom//" "$f" 2>/dev/null | tr -d '\r' | grep -E "^$1:" || true)
[ -n "$lines" ] && [ "$(printf '%s\n' "$lines" | wc -l | tr -d ' ')" = 1 ] || return 0
printf '%s' "${lines#"$1":}" | sed -e 's/[[:space:]]#.*$//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e "s/^\([\"']\)\(.*\)\1\$/\2/"
}
if [ "${1:-}" = "--source" ]; then
case "$(pref telemetry_capy_source)" in gt) echo gt ;; *) echo capy ;; esac
exit 0
fi
capy=off
[ "$(pref telemetry_capy)" = anonymous ] && capy=anonymous
if [ "${1:-}" = "--capy" ] || [ "$capy" != off ]; then
echo "$capy"
exit 0
fi
tier=$("$(dirname "$0")/gstack-config" get telemetry 2>/dev/null || true)
case "$tier" in
anonymous|community) echo "$tier" ;;
*) echo off ;;
esac