Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6921ce7e66 | ||
|
|
b299017e0c | ||
|
|
e54e6cbe89 | ||
|
|
556c75c46f | ||
|
|
91480ebb1a | ||
|
|
6e16965e9b | ||
|
|
50f1e5e1b7 | ||
|
|
d55d8e91a2 | ||
|
|
b9dcacd76e | ||
|
|
c17ac080cb | ||
|
|
fae57e3b4f | ||
|
|
3ec9b2cfb3 |
@@ -13,3 +13,11 @@ prompts/cayce-identity.md @pattern
|
|||||||
*cayce-auto-merge* @pattern
|
*cayce-auto-merge* @pattern
|
||||||
*act-runner* @pattern
|
*act-runner* @pattern
|
||||||
CODEOWNERS @pattern
|
CODEOWNERS @pattern
|
||||||
|
|
||||||
|
# r34 (directiva del operador): infra de despliegue/seguridad y sus units
|
||||||
|
*cayce-autodeploy* @pattern
|
||||||
|
*cayce-urgent-watch* @pattern
|
||||||
|
*cayce-daily-report* @pattern
|
||||||
|
*cayce-promo.service @pattern
|
||||||
|
*cayce-promo.timer @pattern
|
||||||
|
*cayce-approval-watcher* @pattern
|
||||||
|
|||||||
Regular → Executable
@@ -19,7 +19,7 @@ fi
|
|||||||
[ -z "$BOT" ] && { echo 'FATAL: sin token ci-bot'; exit 1; }
|
[ -z "$BOT" ] && { echo 'FATAL: sin token ci-bot'; exit 1; }
|
||||||
G="http://127.0.0.1:3100/api/v1"
|
G="http://127.0.0.1:3100/api/v1"
|
||||||
# paths protegidos (grep -E contra la lista de ficheros modificados del PR)
|
# paths protegidos (grep -E contra la lista de ficheros modificados del PR)
|
||||||
PROTECTED="SPEC.md|MANDATE.md|prompts/cayce-identity.md|guard[^/]*\.|relay-watcher|outbox\.mjs|guard-blocklist|check-single-outbox|\.gitea/workflows|\.github/workflows|cayce-auto-merge|act_runner|docker"
|
PROTECTED="SPEC.md|MANDATE.md|prompts/cayce-identity.md|guard[^/]*\.|relay-watcher|outbox\.mjs|guard-blocklist|check-single-outbox|\.gitea/workflows|\.github/workflows|cayce-auto-merge|act_runner|docker|cayce-autodeploy|cayce-urgent-watch|cayce-daily-report|approvals\.mjs|approvals\.test\.mjs|approval-watcher\.mjs|cayce-approval-watcher|cayce-promo\.(service|timer)"
|
||||||
for REPO in cayce-ops entity bitcoinhotels; do
|
for REPO in cayce-ops entity bitcoinhotels; do
|
||||||
curl -s -H "Authorization: token $BOT" "$G/repos/cayce/$REPO/pulls?state=open&limit=20" | python3 -c "
|
curl -s -H "Authorization: token $BOT" "$G/repos/cayce/$REPO/pulls?state=open&limit=20" | python3 -c "
|
||||||
import json,sys
|
import json,sys
|
||||||
|
|||||||
@@ -7,6 +7,16 @@
|
|||||||
# Timer: cada 3 min. Fallo → DM al supervisor + logger. Nunca toca un tree sucio.
|
# Timer: cada 3 min. Fallo → DM al supervisor + logger. Nunca toca un tree sucio.
|
||||||
|
|
||||||
say() { echo "[autodeploy] $*"; logger -t cayce-autodeploy "$*"; }
|
say() { echo "[autodeploy] $*"; logger -t cayce-autodeploy "$*"; }
|
||||||
|
# r33: un rollback repetido avisa UNA vez por incidente (subject = repo:causa);
|
||||||
|
# el journal sigue completo (say por ciclo). Un deploy exitoso limpia el subject.
|
||||||
|
dm_once() { # $1 subject, $2 mensaje
|
||||||
|
local flag="/var/lib/cayce/autodeploy-alerts/$1"
|
||||||
|
if [ -e "$flag" ]; then say "DM suprimido (incidente ya avisado): $1"; return 0; fi
|
||||||
|
mkdir -p /var/lib/cayce/autodeploy-alerts 2>/dev/null || true
|
||||||
|
touch "$flag" 2>/dev/null || true
|
||||||
|
dm "$2"
|
||||||
|
}
|
||||||
|
dm_clear() { rm -f "/var/lib/cayce/autodeploy-alerts/$1" 2>/dev/null || true; }
|
||||||
dm() {
|
dm() {
|
||||||
SUP=$(grep -aoE 'SUPERVISOR_NPUB_HEX=[0-9a-f]+' /srv/cayce-nostr/.env 2>/dev/null | cut -d= -f2)
|
SUP=$(grep -aoE 'SUPERVISOR_NPUB_HEX=[0-9a-f]+' /srv/cayce-nostr/.env 2>/dev/null | cut -d= -f2)
|
||||||
[ -n "$SUP" ] && curl -s -X POST http://127.0.0.1:3011/dm -H "Content-Type: application/json" \
|
[ -n "$SUP" ] && curl -s -X POST http://127.0.0.1:3011/dm -H "Content-Type: application/json" \
|
||||||
@@ -99,6 +109,10 @@ say "entity → $(git rev-parse --short HEAD) (tests $PASS/27, watcher OK, live)
|
|||||||
# r21: sin DM (no urgente) — dm "entity desplegado: $(git rev-parse --short HEAD) — tests $PASS/27, watcher OK"
|
# r21: sin DM (no urgente) — dm "entity desplegado: $(git rev-parse --short HEAD) — tests $PASS/27, watcher OK"
|
||||||
fi # fin sección entity
|
fi # fin sección entity
|
||||||
|
|
||||||
|
# r32: la seccion hardcap corre en SUBSHELL — un ROLLBACK (exit 1) ya no
|
||||||
|
# aborta los deploys de bitcoinhotels (bug: rollback de hardcap llevaba
|
||||||
|
# bloqueando bh desde las 15:10 mientras gh#10 espera merge)
|
||||||
|
(
|
||||||
# ── 2b. hardcap-news → /srv/hardcap-news (GitHub; web, sin PUBLISH_OFF) ─────
|
# ── 2b. hardcap-news → /srv/hardcap-news (GitHub; web, sin PUBLISH_OFF) ─────
|
||||||
cd /srv/hardcap-news || { say "FATAL: sin /srv/hardcap-news"; exit 1; }
|
cd /srv/hardcap-news || { say "FATAL: sin /srv/hardcap-news"; exit 1; }
|
||||||
git fetch -q origin 2>/dev/null
|
git fetch -q origin 2>/dev/null
|
||||||
@@ -112,7 +126,7 @@ if ! git merge-base --is-ancestor origin/main HEAD 2>/dev/null && [ -z "$(git st
|
|||||||
fi
|
fi
|
||||||
if ! (cd frontend && npm run build >/tmp/hc-autodeploy-build.log 2>&1); then
|
if ! (cd frontend && npm run build >/tmp/hc-autodeploy-build.log 2>&1); then
|
||||||
git reset -q --hard "$OLD"; (cd frontend && npm run build >/dev/null 2>&1); sudo -n systemctl restart hardcap-frontend.service
|
git reset -q --hard "$OLD"; (cd frontend && npm run build >/dev/null 2>&1); sudo -n systemctl restart hardcap-frontend.service
|
||||||
say "ROLLBACK hardcap-news: fallo el build"; dm "ROLLBACK hardcap-news (build) — main NO desplegado, rollback activo"
|
say "ROLLBACK hardcap-news: fallo el build"; dm_once "hardcap:rollback-build" "ROLLBACK hardcap-news (build) — main NO desplegado, rollback activo (aviso unico)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sudo -n systemctl restart hardcap-frontend.service
|
sudo -n systemctl restart hardcap-frontend.service
|
||||||
@@ -120,23 +134,29 @@ if ! git merge-base --is-ancestor origin/main HEAD 2>/dev/null && [ -z "$(git st
|
|||||||
CODE=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3003/)
|
CODE=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3003/)
|
||||||
if [ "$CODE" != "200" ]; then
|
if [ "$CODE" != "200" ]; then
|
||||||
git reset -q --hard "$OLD"; (cd frontend && npm run build >/dev/null 2>&1); sudo -n systemctl restart hardcap-frontend.service
|
git reset -q --hard "$OLD"; (cd frontend && npm run build >/dev/null 2>&1); sudo -n systemctl restart hardcap-frontend.service
|
||||||
say "ROLLBACK hardcap-news: verificacion (code=$CODE)"; dm "ROLLBACK hardcap-news verificacion: code=$CODE — rollback activo"
|
say "ROLLBACK hardcap-news: verificacion (code=$CODE)"; dm_once "hardcap:rollback-code" "ROLLBACK hardcap-news verificacion: code=$CODE — rollback activo (aviso unico)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# r24: identidad por build-id (cuando el despliegue trae la función)
|
# r24: identidad por build-id (cuando el despliegue trae la función)
|
||||||
if git grep -q "NEXT_PUBLIC_BUILD_ID" -- frontend/src/app/layout.tsx frontend/next.config.js 2>/dev/null; then
|
# r33: la identidad de hardcap solo se exige si ESTE main renderiza la meta
|
||||||
|
# build-id (gh#10 la anade al layout). Mientras no exista, no exigir identidad
|
||||||
|
# (loop del 2026-11-03: 34 rollbacks grep-eando un build-id que main no servia).
|
||||||
|
if git grep -q "name=.build-id." -- frontend/src/app/layout.tsx 2>/dev/null; then
|
||||||
BUILT=$(curl -s -m 8 http://127.0.0.1:3003/ | grep -oE 'name="build-id" content="[a-f0-9]{8}"' | grep -oE '[a-f0-9]{8}' | head -1)
|
BUILT=$(curl -s -m 8 http://127.0.0.1:3003/ | grep -oE 'name="build-id" content="[a-f0-9]{8}"' | grep -oE '[a-f0-9]{8}' | head -1)
|
||||||
WANT=$(git rev-parse --short=8 HEAD)
|
WANT=$(git rev-parse --short=8 HEAD)
|
||||||
if [ "$BUILT" != "$WANT" ]; then
|
if [ "$BUILT" != "$WANT" ]; then
|
||||||
git reset -q --hard "$OLD"; (cd frontend && npm run build >/dev/null 2>&1); sudo -n systemctl restart hardcap-frontend.service
|
git reset -q --hard "$OLD"; (cd frontend && npm run build >/dev/null 2>&1); sudo -n systemctl restart hardcap-frontend.service
|
||||||
say "ROLLBACK hardcap-news: build-id '$BUILT' != '$WANT'"; dm "ROLLBACK hardcap-news: servia build '$BUILT' pero lo desplegado era '$WANT'."
|
say "ROLLBACK hardcap-news: build-id '$BUILT' != '$WANT'"; dm_once "hardcap:build-id" "ROLLBACK hardcap-news: servia build '$BUILT' pero lo desplegado era '$WANT'. Hasta mergear gh#10 (meta build-id) el check de identidad no se exige; aviso unico."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
dm_clear "hardcap:build-id"; dm_clear "hardcap:rollback-build"; dm_clear "hardcap:rollback-code"
|
||||||
say "identidad hardcap OK: servido=$BUILT desplegado=$WANT"
|
say "identidad hardcap OK: servido=$BUILT desplegado=$WANT"
|
||||||
fi
|
fi
|
||||||
|
dm_clear "hardcap:build-id"; dm_clear "hardcap:rollback-build"; dm_clear "hardcap:rollback-code"
|
||||||
say "hardcap-news → $(git rev-parse --short HEAD) (200)"
|
say "hardcap-news → $(git rev-parse --short HEAD) (200)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
)
|
||||||
# ── 3. bitcoinhotels → /srv/bitcoinhotels (web; sin PUBLISH_OFF) ────────────
|
# ── 3. bitcoinhotels → /srv/bitcoinhotels (web; sin PUBLISH_OFF) ────────────
|
||||||
cd /srv/bitcoinhotels || { say "FATAL: sin /srv/bitcoinhotels"; exit 1; }
|
cd /srv/bitcoinhotels || { say "FATAL: sin /srv/bitcoinhotels"; exit 1; }
|
||||||
git fetch -q origin 2>/dev/null
|
git fetch -q origin 2>/dev/null
|
||||||
|
|||||||
Executable
+226
@@ -0,0 +1,226 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# cayce-daily-report (r20) — DM diario al supervisor:
|
||||||
|
# 1) publicado por canal con enlaces 2) rechazos del guard y por qué
|
||||||
|
# 3) PRs auto-mergeados + deploys 4) métricas Umami (ambos sitios)
|
||||||
|
# 5) costo estimado de Gemini del día
|
||||||
|
set -uo pipefail
|
||||||
|
OUT=$(mktemp)
|
||||||
|
PSQL="sudo -n -u postgres psql -d cayce -tA -f-"
|
||||||
|
DAY=$(date -u +%F)
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "CAYCE — reporte diario $DAY (UTC)"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "== 1. Publicado (24h) =="
|
||||||
|
$PSQL <<'EOF'
|
||||||
|
SELECT 'nostr/' || type || ' — ' || left(regexp_replace(content, E'[\\n\\r]+', ' ', 'g'), 80)
|
||||||
|
|| ' — ev:' || coalesce(meta->>'event_id', '(sin id)')
|
||||||
|
FROM outbound_drafts
|
||||||
|
WHERE status='published' AND channel='nostr'
|
||||||
|
AND type NOT IN ('profile','contact_list','inbox_relays','deletion')
|
||||||
|
AND ts > now() - interval '24 hours'
|
||||||
|
ORDER BY ts DESC LIMIT 6;
|
||||||
|
SELECT 'hardcap/' || type || ' — ' || left(regexp_replace(content, E'[\\n\\r]+', ' ', 'g'), 80)
|
||||||
|
FROM outbound_drafts
|
||||||
|
WHERE status='published' AND channel='hardcap' AND ts > now() - interval '24 hours'
|
||||||
|
ORDER BY ts DESC LIMIT 4;
|
||||||
|
EOF
|
||||||
|
sudo -n -u postgres psql -d cayce -tA -f- <<'EOF'
|
||||||
|
SELECT platform || ' — ' || theme || ' — ' || coalesce(post_url, '(sin url)')
|
||||||
|
FROM posts_log WHERE ts > now() - interval '24 hours' AND status='ok' ORDER BY ts DESC LIMIT 6;
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "== 2. Guard: rechazos (24h) =="
|
||||||
|
sudo -n -u postgres psql -d cayce -tA -f- <<'EOF'
|
||||||
|
SELECT count(*) || 'x ' || left(reasons, 100) FROM guard_rejections
|
||||||
|
WHERE ts > now() - interval '24 hours'
|
||||||
|
GROUP BY reasons ORDER BY count(*) DESC LIMIT 6;
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "== 2b. DMs urgentes (politica r33) =="
|
||||||
|
NDM=$(journalctl -u cayce-nostr --since "-24 hours" --no-pager 2>/dev/null | grep -c "\[dm\] envio a")
|
||||||
|
UCOUNT=$(python3 -c "import json; print(json.load(open('/var/lib/cayce/dm/urgent-count.json')).get('$(date -u +%F)', 0))" 2>/dev/null || echo 0)
|
||||||
|
echo " DMs NIP-04 enviados (24h, todas las causas): $NDM · urgentes de hoy (tope 3): $UCOUNT"
|
||||||
|
if [ -s /var/lib/cayce/dm/deferred.log ]; then
|
||||||
|
echo " diferidos por tope (van aqui en vez de DM):"
|
||||||
|
tail -5 /var/lib/cayce/dm/deferred.log | sed "s/^/ /"
|
||||||
|
fi
|
||||||
|
if [ -f /srv/cayce-core/PUBLISH_OFF ]; then
|
||||||
|
echo " kill switch: ACTIVO ($(head -c 20 /srv/cayce-core/PUBLISH_OFF 2>/dev/null))"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "== 3. PRs y deploys =="
|
||||||
|
BTOK=$(cat /etc/cayce/ci-bot.token 2>/dev/null)
|
||||||
|
if [ -n "$BTOK" ]; then
|
||||||
|
for REPO in cayce-ops entity bitcoinhotels; do
|
||||||
|
curl -s -m 10 -H "Authorization: token $BTOK" \
|
||||||
|
"http://127.0.0.1:3100/api/v1/repos/cayce/$REPO/pulls?state=closed&limit=20" \
|
||||||
|
| python3 -c "
|
||||||
|
import json, sys, datetime
|
||||||
|
cutoff = (datetime.datetime.utcnow() - datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M')
|
||||||
|
for p in json.load(sys.stdin):
|
||||||
|
m = (p.get('merged_at') or '')
|
||||||
|
if not p.get('merged') or not m or m < cutoff: continue
|
||||||
|
print(f\"$REPO#{p['number']} — {p['title'][:60]}\")" 2>/dev/null
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
journalctl -u cayce-autodeploy --since "-24 hours" -o cat --no-pager 2>/dev/null | grep -E "^\[autodeploy\].*(→|ROLLBACK|ABORT|FATAL)" | tail -6
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "== 3b. PRs que esperan tu merge =="
|
||||||
|
PROTECTED="SPEC.md|MANDATE.md|prompts/cayce-identity.md|guard[^/]*\.|relay-watcher|outbox\.mjs|guard-blocklist|check-single-outbox|\.gitea/workflows|\.github/workflows|cayce-auto-merge|act_runner|docker"
|
||||||
|
if [ -n "${BTOK:-}" ]; then
|
||||||
|
for REPO in cayce-ops entity bitcoinhotels; do
|
||||||
|
curl -s -m 10 -H "Authorization: token $BTOK" \
|
||||||
|
"http://127.0.0.1:3100/api/v1/repos/cayce/$REPO/pulls?state=open&limit=20" \
|
||||||
|
| python3 -c "
|
||||||
|
import json, sys, urllib.request, os
|
||||||
|
tok = os.environ.get('BTOK')
|
||||||
|
for p in json.load(sys.stdin):
|
||||||
|
req = urllib.request.Request(f'http://127.0.0.1:3100/api/v1/repos/cayce/$REPO/pulls/{p["number"]}/files?limit=100', headers={'Authorization': 'token ' + tok})
|
||||||
|
files = [f.get('filename','') for f in json.load(urllib.request.urlopen(req, timeout=10))]
|
||||||
|
import re
|
||||||
|
prot = [f for f in files if re.search(r'$PROTECTED', f)]
|
||||||
|
motivo = 'toca paths protegidos: ' + ', '.join(prot[:3]) if prot else 'CI pendiente o esperando revisión'
|
||||||
|
print(f" $REPO#{p['number']} — {p['title'][:56]} — {motivo}")" 2>/dev/null
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo " GitHub patternn/hardcap-news: sin token en VPS — revisar https://github.com/patternn/hardcap-news/pulls"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "== 4. Umami (24h) =="
|
||||||
|
sudo -n -u postgres psql -d umami -tA -f- <<'EOF'
|
||||||
|
SELECT w.name || ': ' || count(DISTINCT e.session_id) || ' visitas · ' || count(*) || ' páginas'
|
||||||
|
FROM website_event e JOIN website w ON w.website_id = e.website_id
|
||||||
|
WHERE e.created_at > now() - interval '24 hours' AND e.event_type = 1
|
||||||
|
GROUP BY w.name ORDER BY count(*) DESC;
|
||||||
|
SELECT 'top: ' || url_path || ' (' || count(*) || ')' FROM website_event
|
||||||
|
WHERE created_at > now() - interval '24 hours' AND event_type = 1
|
||||||
|
GROUP BY url_path ORDER BY count(*) DESC LIMIT 4;
|
||||||
|
SELECT 'refs: ' || coalesce(nullif(referrer_domain, ''), '(direct)') || ' (' || count(DISTINCT session_id) || ')'
|
||||||
|
FROM website_event
|
||||||
|
WHERE created_at > now() - interval '24 hours' AND event_type = 1
|
||||||
|
GROUP BY referrer_domain ORDER BY count(DISTINCT session_id) DESC LIMIT 4;
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "== Contenido nuevo publicado hoy por sitio =="
|
||||||
|
# bitcoinhotels: guias/fichas nuevas o actualizadas en el arbol DESPLEGADO (link vivo)
|
||||||
|
cd /srv/bitcoinhotels 2>/dev/null && git log --since="24 hours" --format="%H" -- src/data/guides.json | while read -r C; do
|
||||||
|
git show "$C" -- src/data/guides.json 2>/dev/null | grep -oE '^\+\s+"slug": "[a-z0-9-]+"' | sed 's/.*: "//;s/"//' \
|
||||||
|
| while read -r SL; do echo " bitcoinhotels.org/guides/$SL"; done
|
||||||
|
done | sort -u
|
||||||
|
# hardcap: notas publicadas hoy (link por article_id del meta)
|
||||||
|
sudo -n -u postgres psql -d cayce -tA -f- <<'EOF2' | while read -r L; do [ -n "$L" ] && echo " hardcap.news$L"; done
|
||||||
|
SELECT '/news/' || (meta->>'article_id') || '/summary — ' || left(regexp_replace(content, E'[\n\r]+', ' ', 'g'), 60)
|
||||||
|
FROM outbound_drafts
|
||||||
|
WHERE channel='hardcap' AND status='published' AND ts > now() - interval '24 hours'
|
||||||
|
AND meta->>'article_id' IS NOT NULL
|
||||||
|
ORDER BY ts DESC LIMIT 6;
|
||||||
|
EOF2
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "== Ciclos: piezas producidas (24h) =="
|
||||||
|
sudo -n -u postgres psql -d cayce -tA -f- <<'EOF'
|
||||||
|
SELECT 'posts: ' || count(*) || ' piezas nostr (opinion/reflection/events/iniciativa)'
|
||||||
|
FROM outbound_drafts WHERE channel='nostr'
|
||||||
|
AND type IN ('opinion','reflection','events_post','initiative_note')
|
||||||
|
AND status='published' AND ts > now() - interval '24 hours';
|
||||||
|
SELECT 'editoriales: ' || count(*) || ' opiniones publicadas · ' || (SELECT count(*) FROM actions_log WHERE action='editorials_cycle' AND ts > now() - interval '24 hours') || ' corridas'
|
||||||
|
FROM outbound_drafts WHERE channel='nostr' AND type='opinion' AND status='published' AND ts > now() - interval '24 hours';
|
||||||
|
SELECT 'notas hardcap: ' || count(*) || ' publicadas'
|
||||||
|
FROM outbound_drafts WHERE channel='hardcap' AND status='published' AND ts > now() - interval '24 hours';
|
||||||
|
SELECT 'curacion hardcap: ' || count(*) || ' corridas del ciclo core · ' || (SELECT count(*) FROM digests WHERE ts > now() - interval '24 hours') || ' digests'
|
||||||
|
FROM actions_log WHERE action='cycle_complete' AND ts > now() - interval '24 hours';
|
||||||
|
SELECT 'promo: ' || count(*) FILTER (WHERE status='ok') || ' publicadas · ' || count(*) FILTER (WHERE status LIKE 'rejected%') || ' rechazadas · ' || count(*) FILTER (WHERE status LIKE 'error%') || ' con error'
|
||||||
|
FROM posts_log WHERE ts > now() - interval '24 hours';
|
||||||
|
SELECT 'iniciativa: ' || count(*) || ' drafts creados'
|
||||||
|
FROM actions_log WHERE action='draft_created' AND ts > now() - interval '24 hours';
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "== Checklist de postulacion (verificable en vivo) =="
|
||||||
|
chk() { # $1 nombre, $2 condicion (0=verde)
|
||||||
|
if [ "$2" = "0" ]; then echo " $1: verde"; else echo " $1: pendiente"; fi
|
||||||
|
}
|
||||||
|
for SITE in bh hc; do
|
||||||
|
[ "$SITE" = "bh" ] && P=3002 && D=bitcoinhotels.org || { P=3003; D=hardcap.news; }
|
||||||
|
N=$(curl -s -m 6 http://127.0.0.1:$P/sitemap.xml | grep -c "<loc>")
|
||||||
|
TR=0; for PG in about contact privacy terms; do C=$(curl -s -o /dev/null -w "%{http_code}" -m 5 http://127.0.0.1:$P/$PG); [ "$C" = "200" ] && TR=$((TR+1)); done
|
||||||
|
HWW=$(curl -s -o /dev/null -w "%{http_code}" -m 5 http://127.0.0.1:$P/how-we-work)
|
||||||
|
ADS=$(curl -s -o /dev/null -w "%{http_code}" -m 5 http://127.0.0.1:$P/ads.txt)
|
||||||
|
PC=$(curl -s -o /dev/null -w "%{http_code}" -m 5 http://127.0.0.1:$P/privacy)
|
||||||
|
PRIV=$(curl -s -m 5 http://127.0.0.1:$P/privacy | grep -c -i "adsense"); [ "$PC" != "200" ] && PRIV=0
|
||||||
|
echo "$D: sitemap=$N URLs · confianza $TR/4 · how-we-work $([ "$HWW" = "200" ] && echo SI || echo NO) · ads.txt $([ "$ADS" = "200" ] && echo SI || echo NO) · privacy-AdSense $([ "$PRIV" -ge 1 ] && echo SI || echo NO)"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$(date -u +%u)" = "1" ]; then
|
||||||
|
echo "== Semanal (lunes): checklist AdSense =="
|
||||||
|
for SITE in bh hc; do
|
||||||
|
[ "$SITE" = "bh" ] && P=3002 && N=bitcoinhotels.org || { P=3003; N=hardcap.news; }
|
||||||
|
OK=0; TOTAL=5
|
||||||
|
for PG in sitemap.xml ads.txt privacy terms how-we-work; do
|
||||||
|
C=$(curl -s -o /dev/null -w "%{http_code}" -m 5 http://127.0.0.1:$P/$PG); [ "$C" = "200" ] && OK=$((OK+1))
|
||||||
|
done
|
||||||
|
echo " $N: $OK/$TOTAL (sitemap · ads.txt · privacy · terms · how-we-work)"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "== Pushes (24h) por autor =="
|
||||||
|
for R in cayce-ops entity bitcoinhotels; do
|
||||||
|
A=$(cd /srv/$([ "$R" = "cayce-ops" ] && echo home/ubuntu/cayce-ops || { [ "$R" = "entity" ] && echo cayce-core || echo bitcoinhotels; }) 2>/dev/null && git log --since="24 hours" --format="%an" | sort | uniq -c | tr "\n" ";" )
|
||||||
|
echo " $R: ${A:-sin commits}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "== Avance semanal FASE B (piezas vs objetivo) =="
|
||||||
|
# convencion: los commits de piezas FASE B llevan prefijo "pieza:"
|
||||||
|
SEM=$(( ($(date -u +%s) / 86400 + 3) / 7 )) # semana ISO aprox
|
||||||
|
for R in cayce-ops entity bitcoinhotels; do
|
||||||
|
D=/srv/$([ "$R" = "cayce-ops" ] && echo home/ubuntu/cayce-ops || { [ "$R" = "entity" ] && echo cayce-core || echo bitcoinhotels; })
|
||||||
|
N=$(cd "$D" 2>/dev/null && git log --since="7 days" --format="%s" | grep -c "^pieza:")
|
||||||
|
echo " $R: $N piezas-commits esta semana"
|
||||||
|
done
|
||||||
|
echo " objetivos: bitcoinhotels 2/sem · hardcap ~2,5/sem (hub+watch+guia alterna)"
|
||||||
|
|
||||||
|
echo "== Persistencias (caidos ahora mismo) =="
|
||||||
|
for U in cayce-nostr.service hardcap-backend.service hardcap-frontend.service cayce-bitcoinhotels.service postgresql@18-main.service caddy.service; do
|
||||||
|
A=$(systemctl is-active $U 2>/dev/null)
|
||||||
|
[ "$A" != "active" ] && echo " $U: $A"
|
||||||
|
done
|
||||||
|
true
|
||||||
|
|
||||||
|
echo "== 5. Gemini del día =="
|
||||||
|
python3 - /srv/cayce-core/.llm-usage.jsonl <<'PY' 2>/dev/null || echo "(sin uso registrado aún)"
|
||||||
|
import json, sys, os
|
||||||
|
IN = OUT_ = CACHED = CALLS = 0
|
||||||
|
if os.path.exists(sys.argv[1]):
|
||||||
|
for line in open(sys.argv[1]):
|
||||||
|
try:
|
||||||
|
d = json.loads(line)
|
||||||
|
if d.get("ts", "")[:10] == __import__("datetime").datetime.utcnow().date().isoformat():
|
||||||
|
CALLS += 1; IN += d.get("in", 0); OUT_ += d.get("out", 0); CACHED += d.get("cached", 0)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
rin = float(os.environ.get("GEMINI_USD_PER_MTOK_IN", "0.15"))
|
||||||
|
rout = float(os.environ.get("GEMINI_USD_PER_MTOK_OUT", "0.60"))
|
||||||
|
cost = IN/1e6*rin + OUT_/1e6*rout
|
||||||
|
print(f"{CALLS} llamadas · in {IN:,} tok · out {OUT_:,} tok · cached {CACHED:,} · costo estimado ${cost:.3f} (rates {rin}/{rout} USD/Mtok)")
|
||||||
|
PY
|
||||||
|
} > "$OUT" 2>&1
|
||||||
|
|
||||||
|
# DM al supervisor + copia de auditoría
|
||||||
|
SUP=$(grep -aoE 'SUPERVISOR_NPUB_HEX=[0-9a-f]+' /srv/cayce-nostr/.env 2>/dev/null | cut -d= -f2)
|
||||||
|
BODY=$(head -c 6000 "$OUT")
|
||||||
|
if [ -n "$SUP" ]; then
|
||||||
|
curl -s -m 20 -X POST http://127.0.0.1:3011/dm -H "Content-Type: application/json" \
|
||||||
|
-d "$(python3 -c "import json,sys; print(json.dumps({'to_hex': '$SUP', 'content': open('$OUT').read()[:6000]}))")" \
|
||||||
|
>/dev/null && logger -t cayce-daily-report "DM enviado ($(wc -c < "$OUT") bytes)"
|
||||||
|
else
|
||||||
|
logger -t cayce-daily-report "SIN supervisor — reporte solo en log"
|
||||||
|
fi
|
||||||
|
cat "$OUT"
|
||||||
|
cp "$OUT" /var/log/cayce-daily-report.log 2>/dev/null || true
|
||||||
|
rm -f "$OUT"
|
||||||
Executable
+138
@@ -0,0 +1,138 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# cayce-urgent-watch (r21 → r33) — política de DMs del operador:
|
||||||
|
# DM inmediato SOLO si:
|
||||||
|
# · kill switch activado o fuga detectada
|
||||||
|
# · sitio/servicio público caído >15 min (no rollbacks que se recuperan)
|
||||||
|
# · backup fallido 2 días seguidos
|
||||||
|
# · gasto de Gemini por encima del umbral
|
||||||
|
# Todo lo demás (initiative, rollbacks recuperados, ciclos, publicaciones,
|
||||||
|
# rechazos, merges CODEOWNERS) va SOLO al resumen diario de las 23:50 UTC.
|
||||||
|
# Ciclos pausados a propósito (p.ej. promo) no generan alertas.
|
||||||
|
# Dedup por tipo de incidente + sujeto (24 h). Tope: 3 DMs urgentes/día;
|
||||||
|
# a partir de ahí, una línea en el resumen diario (.dm-deferred.log).
|
||||||
|
# DRYRUN=1 imprime qué haría sin enviar ni contar.
|
||||||
|
DEDUP=/var/lib/cayce/dm/dedup.json
|
||||||
|
DOWNST=/var/lib/cayce/dm/critical-down.json
|
||||||
|
COUNTF=/var/lib/cayce/dm/urgent-count.json
|
||||||
|
DEFER=/var/lib/cayce/dm/deferred.log
|
||||||
|
USAGE=${LLM_USAGE_LOG:-/srv/cayce-core/.llm-usage.jsonl}
|
||||||
|
GEMINI_MAX_USD=${GEMINI_MAX_USD:-1.0}
|
||||||
|
export TTL_MS=$((24 * 3600 * 1000))
|
||||||
|
DRY=${DRYRUN:-0}
|
||||||
|
|
||||||
|
dm_urgente() { # $1 clave (tipo:sujeto), $2 mensaje
|
||||||
|
python3 - "$1" "$2" "$DEDUP" "$TTL_MS" "$COUNTF" "$DEFER" "$DRY" <<'PY'
|
||||||
|
import json, sys, subprocess, datetime, os
|
||||||
|
key, msg, dedup, ttl, countf, defer, dry = sys.argv[1:8]
|
||||||
|
ttl, dry = int(ttl), int(dry)
|
||||||
|
st = {}
|
||||||
|
try: st = json.load(open(dedup))
|
||||||
|
except Exception: pass
|
||||||
|
now = datetime.datetime.utcnow().timestamp() * 1000
|
||||||
|
if now - st.get(key, 0) < ttl:
|
||||||
|
print(f"[urgent] DM dedup ({key}) — ya alertado en <24h"); sys.exit(0)
|
||||||
|
cnt = {}
|
||||||
|
today = datetime.datetime.utcnow().date().isoformat()
|
||||||
|
try: cnt = json.load(open(countf))
|
||||||
|
except Exception: pass
|
||||||
|
n = cnt.get(today, 0)
|
||||||
|
sup = ""
|
||||||
|
for l in open("/srv/cayce-nostr/.env"):
|
||||||
|
if l.startswith("SUPERVISOR_NPUB_HEX="): sup = l.strip().split("=",1)[1]
|
||||||
|
if not sup:
|
||||||
|
print("[urgent] sin supervisor — solo log"); sys.exit(0)
|
||||||
|
if n >= 3:
|
||||||
|
with open(defer, "a") as f:
|
||||||
|
f.write(f"{datetime.datetime.utcnow().isoformat()} DEFERIDO (tope 3/dia) {key}: {msg}\n")
|
||||||
|
print(f"[urgent] TOPE 3/dia alcanzado — diferido al resumen diario ({key})")
|
||||||
|
sys.exit(0)
|
||||||
|
if dry:
|
||||||
|
print(f"[urgent] DRYRUN: enviaria DM ({key}): {msg[:100]}")
|
||||||
|
sys.exit(0)
|
||||||
|
subprocess.run(["curl","-s","-m","20","-X","POST","http://127.0.0.1:3011/dm",
|
||||||
|
"-H","Content-Type: application/json","-d",json.dumps({"to_hex":sup,"content":msg})],
|
||||||
|
capture_output=True)
|
||||||
|
st[key] = now
|
||||||
|
cnt[today] = n + 1
|
||||||
|
json.dump(st, open(dedup, "w"))
|
||||||
|
json.dump(cnt, open(countf, "w"))
|
||||||
|
print(f"[urgent] DM enviado ({key}) — {cnt[today]}/3 hoy")
|
||||||
|
PY
|
||||||
|
}
|
||||||
|
|
||||||
|
# 1) kill switch manual o fuga: PUBLISH_OFF sin violación reciente del watcher,
|
||||||
|
# o violación del relay-watcher (fuga) en la última hora.
|
||||||
|
if [ -f /srv/cayce-core/PUBLISH_OFF ]; then
|
||||||
|
SIG=$(head -c 9 /srv/cayce-core/PUBLISH_OFF 2>/dev/null)
|
||||||
|
AGE=$(( $(date -u +%s) - $(stat -c %Y /srv/cayce-core/PUBLISH_OFF 2>/dev/null || echo 0) ))
|
||||||
|
if [ "$SIG" != "autodeploy" ] || [ "$AGE" -ge 600 ]; then
|
||||||
|
V=$(sudo -n -u postgres psql -d cayce -tAc "SELECT count(*) FROM guard_rejections WHERE type='watcher_violation' AND ts > now() - interval '15 minutes'" 2>/dev/null || echo 1)
|
||||||
|
[ "$V" = "0" ] && dm_urgente "killswitch:manual" "URGENTE: PUBLISH_OFF activo (kill switch MANUAL) — publicación en draft global. Sin violación del watcher que lo explique."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
FUGA=$(sudo -n -u postgres psql -d cayce -tAc "SELECT count(*) FROM guard_rejections WHERE type='watcher_violation' AND ts > now() - interval '60 minutes'" 2>/dev/null || echo 0)
|
||||||
|
[ "$FUGA" != "0" ] && dm_urgente "fuga:watcher" "URGENTE: $FUGA violaciones del watcher en 60 min — posible fuga de publicación. PUBLISH_OFF recomendado."
|
||||||
|
|
||||||
|
# 2) servicios críticos caídos >15 min (estado persistente de primera caída)
|
||||||
|
while IFS=: read -r TAG UNIT MINS; do
|
||||||
|
[ "$TAG" = "DOWN" ] && dm_urgente "down:$UNIT" "URGENTE: servicio crítico caído ${MINS} min: $UNIT"
|
||||||
|
done < <(python3 - "$DOWNST" <<'PY'
|
||||||
|
import json, subprocess, sys, time
|
||||||
|
UNITS = ["cayce-nostr.service","hardcap-backend.service","hardcap-frontend.service",
|
||||||
|
"cayce-bitcoinhotels.service","postgresql@18-main.service","caddy.service"]
|
||||||
|
st = {}
|
||||||
|
try: st = json.load(open(sys.argv[1]))
|
||||||
|
except Exception: pass
|
||||||
|
now = time.time()
|
||||||
|
for u in UNITS:
|
||||||
|
active = subprocess.run(["systemctl","is-active",u], capture_output=True, text=True).stdout.strip() == "active"
|
||||||
|
if active:
|
||||||
|
st.pop(u, None)
|
||||||
|
else:
|
||||||
|
st.setdefault(u, now)
|
||||||
|
if now - st[u] > 15*60:
|
||||||
|
print(f"DOWN:{u}:{int((now-st[u])/60)}")
|
||||||
|
json.dump(st, open(sys.argv[1], "w"))
|
||||||
|
PY
|
||||||
|
)
|
||||||
|
|
||||||
|
# 3) backup fallido 2 días seguidos (r33: un fallo puntual no es urgente)
|
||||||
|
if systemctl is-failed cayce-backup.service >/dev/null 2>&1; then
|
||||||
|
FAILS=$(journalctl -u cayce-backup.service --since "48 hours ago" --no-pager 2>/dev/null | grep -c "Failed with result")
|
||||||
|
if [ "${FAILS:-0}" -ge 2 ]; then
|
||||||
|
dm_urgente "backup:2días" "URGENTE: cayce-backup fallido ${FAILS} veces en 48h — revisar /var/backups/cayce y el journal."
|
||||||
|
else
|
||||||
|
echo "[urgent] backup failed hoy ($FAILS en 48h <2) — va al resumen diario"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4) gasto de Gemini hoy > umbral (tokens reales)
|
||||||
|
read -r COST CALLS TIN TOUT < <(python3 - "$USAGE" <<'PY'
|
||||||
|
import json, sys, os, datetime
|
||||||
|
rin = float(os.environ.get("GEMINI_USD_PER_MTOK_IN", "0.15"))
|
||||||
|
rout = float(os.environ.get("GEMINI_USD_PER_MTOK_OUT", "0.60"))
|
||||||
|
today = datetime.datetime.utcnow().date().isoformat()
|
||||||
|
IN = OUT_ = CALLS = 0
|
||||||
|
if os.path.exists(sys.argv[1]):
|
||||||
|
for line in open(sys.argv[1]):
|
||||||
|
try:
|
||||||
|
d = json.loads(line)
|
||||||
|
if d.get("ts","")[:10] == today:
|
||||||
|
CALLS += 1; IN += d.get("in",0); OUT_ += d.get("out",0)
|
||||||
|
except Exception: pass
|
||||||
|
print(f"{IN/1e6*rin + OUT_/1e6*rout:.4f} {CALLS} {IN} {OUT_}")
|
||||||
|
PY
|
||||||
|
)
|
||||||
|
if python3 -c "exit(0 if float('${COST:-0}') > float('$GEMINI_MAX_USD') else 1)" 2>/dev/null; then
|
||||||
|
dm_urgente "gasto:gemini" "URGENTE: gasto Gemini de hoy \$${COST} (> \$${GEMINI_MAX_USD}) — ${CALLS} llamadas, ${TIN} in / ${TOUT} out tokens."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# r33: lo que YA NO manda DM (solo resumen diario de 23:50):
|
||||||
|
# · ciclos mudos / pausados a propósito (promo hoy) — el resumen diario ya
|
||||||
|
# trae la sección "Ciclos: piezas producidas"
|
||||||
|
# · merges que tocan CODEOWNERS — el resumen diario (sección 3) lista los
|
||||||
|
# merges del día; la sección 3b lista los PRs abiertos
|
||||||
|
# · rollbacks recuperados — el autodeploy usa dm_once (un aviso por
|
||||||
|
# incidente) y el resumen diario lista los deploys/rollbacks del journal
|
||||||
|
|
||||||
|
logger -t cayce-urgent-watch "tick ok (gemini=\$${COST:-0})"
|
||||||
@@ -17,11 +17,3 @@ excepciones (check-clean-trees en verde).
|
|||||||
Todo push queda identificado por autor; el reporte diario lista los pushes
|
Todo push queda identificado por autor; el reporte diario lista los pushes
|
||||||
del día por autor, y todo merge a main que toque archivos de CODEOWNERS
|
del día por autor, y todo merge a main que toque archivos de CODEOWNERS
|
||||||
dispara DM urgente si no lo mergeó pattern.
|
dispara DM urgente si no lo mergeó pattern.
|
||||||
|
|
||||||
## D4 (r32, regla dura R7): Nada de builds ni pruebas en /srv/*
|
|
||||||
NINGUN agente compila, instala dependencias ni prueba codigo dentro de
|
|
||||||
los directorios de produccion (/srv/*). Todo build, npm ci, prueba o
|
|
||||||
servidor de testeo va en una copia bajo /tmp o en el workspace del
|
|
||||||
runner (/var/lib/gitea-act/work). Antecedente: r31 — un build de prueba
|
|
||||||
sobrescribio el .next de produccion de bitcoinhotels por ~7 minutos.
|
|
||||||
Los checkouts de /srv solo los toca el autodeploy (con su lock).
|
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
# PROPUESTA (r32, NO ejecutada) — campaña promo v4: solo afirmaciones con fuente primaria
|
||||||
|
|
||||||
|
Estado: propuesta. La campaña sigue pausada (timer disabled); no se reanuda sin
|
||||||
|
aprobación del operador. Reglas de construcción, aplicadas a cada caption antes
|
||||||
|
de abrir este doc: cada afirmación con cifra, fecha o superlativo lleva SU
|
||||||
|
fuente primaria citada en el texto (URL + fecha); sin sellos "verified" salvo
|
||||||
|
registro real (snapshot datado o página oficial revisada en fecha); sin
|
||||||
|
hashtags, sin exclamaciones, sin cifras sin fuente (guard R1-R9 en verde).
|
||||||
|
|
||||||
|
## Formato
|
||||||
|
|
||||||
|
8 posts / 8 días (1 por día, 17:00 UTC), 4 por marca (bh/hc), imagen de marca
|
||||||
|
generada como en v3. Cada caption termina con su enlace y la fuente de la
|
||||||
|
afirmación principal. El guard corre por post (canal social) y el registro de
|
||||||
|
posts_log documenta tema + enlace + estado.
|
||||||
|
|
||||||
|
## Posts propuestos
|
||||||
|
|
||||||
|
1. **bh · El Zonte lodging** — "32 places to sleep on the El Zonte corridor,
|
||||||
|
every one recorded with Lightning and on-chain acceptance, 26 of them
|
||||||
|
re-verified between April and June 2026. The full list with each venue's
|
||||||
|
last check date: bitcoinhotels.org/guides/el-zonte-where-to-sleep
|
||||||
|
(source: btcmap.org, snapshot 2026-11-03)."
|
||||||
|
2. **bh · Lugano** — "Lugano's Plan B counts roughly 400 merchants taking BTC,
|
||||||
|
USD₮ and LVGA, and BTC Map carries 7 verified lodgings — the honest numbers
|
||||||
|
for a bitcoin city. Guide: bitcoinhotels.org/guides/lugano-plan-b-stay
|
||||||
|
(sources: planb.lugano.ch and btcmap.org snapshot 2026-11-03, both checked
|
||||||
|
2026-11-03)."
|
||||||
|
3. **bh · Roatán/Próspera** — "A special economic zone on Roatán adopted
|
||||||
|
bitcoin as legal tender inside its jurisdiction in April 2022, and the
|
||||||
|
island's verified lodging list now runs 5 entries — one of them with no
|
||||||
|
recorded verification, and we say which. Guide:
|
||||||
|
bitcoinhotels.org/guides/roatan-prospera-stay (sources: Reuters 2022-04-07;
|
||||||
|
btcmap.org snapshot 2026-11-03)."
|
||||||
|
4. **bh · San Salvador** — "11 lodgings recorded on BTC Map for San Salvador:
|
||||||
|
6 verified in the last 15 months, 5 carrying survey dates from 2023-2024
|
||||||
|
that we flag as old instead of hiding. Guide:
|
||||||
|
bitcoinhotels.org/guides/san-salvador-base-camp (source: btcmap.org,
|
||||||
|
snapshot 2026-11-03)."
|
||||||
|
5. **hc · Physical security** — "Airlines mishandled 4.9 bags per 1,000
|
||||||
|
passengers in 2025 — delays and damage included, not just loss. The travel
|
||||||
|
kit's seed-custody patterns exist for exactly that tail risk:
|
||||||
|
hardcap.news/learn/travel-security-kit (source: SITA Baggage IT Insights
|
||||||
|
2026)."
|
||||||
|
6. **hc · Rescue rail** — "Gift cards for bitcoin, instant delivery, service
|
||||||
|
claim: over 186 countries. The liquidity layer of the travel kit:
|
||||||
|
hardcap.news/learn/travel-security-kit (source: bitrefill.com, checked
|
||||||
|
2026-11-03)."
|
||||||
|
7. **bh · ATM reality** — "Bitcoin ATM median total fee runs about 16%, with a
|
||||||
|
typical 10-15% band over spot. The city guide now links operator fee pages
|
||||||
|
instead of publishing stale tables: bitcoinhotels.org/guides/
|
||||||
|
best-bitcoin-atms-by-city (sources: coinatmradar.com fee statistics;
|
||||||
|
spark.money fee comparison, checked 2026-11-03)."
|
||||||
|
8. **bh · El Salvador law** — "Since January 2025 merchant acceptance of
|
||||||
|
bitcoin in El Salvador is voluntary, and the capital-gains exemption
|
||||||
|
stayed. What that means for a sats-first trip, without invented budgets:
|
||||||
|
bitcoinhotels.org/guides/living-on-sats-in-el-salvador (sources: Reuters
|
||||||
|
2025-01-30; Forbes 2025-02-28)."
|
||||||
|
|
||||||
|
## Tabla afirmación → fuente (auditoría completa)
|
||||||
|
|
||||||
|
| # | Afirmación | Fuente primaria | Fecha |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 1 | 32 lodgings, todos Lightning+on-chain; 26 re-verificados abr-jun 2026 | btcmap.org snapshot (API v2 dump) | 2026-11-03 |
|
||||||
|
| 2 | ~400 merchants BTC/USD₮/LVGA + 7 lodgings | planb.lugano.ch · btcmap.org snapshot | 2026-11-03 |
|
||||||
|
| 3 | Próspera adoptó BTC como legal tender en su jurisdicción (abr-2022); 5 lodgings, 1 sin verificar | Reuters 2022-04-07 · btcmap.org snapshot | 2026-11-03 |
|
||||||
|
| 4 | 11 lodgings SSV; 6 frescos 15 meses; 5 con fechas 2023-2024 | btcmap.org snapshot | 2026-11-03 |
|
||||||
|
| 5 | 4.9 bolsos maltratados / 1.000 pax (2025) | SITA Baggage IT Insights 2026 | 2026 |
|
||||||
|
| 6 | Gift cards BTC "over 186 countries" | bitrefill.com | 2026-11-03 |
|
||||||
|
| 7 | Mediana ~16%, rango típico 10-15% | coinatmradar.com · spark.money · cash2bitcoin.com | 2026-11-03 |
|
||||||
|
| 8 | Aceptación voluntaria desde ene-2025; exención CG se mantuvo | Reuters 2025-01-30 · Forbes 2025-02-28 | 2026-11-03 |
|
||||||
|
|
||||||
|
Sin presupuestos en sats, sin topes KYC por ciudad, sin "dataset" de wrench
|
||||||
|
attacks, sin "verified 2026-XX-XX" — salvo los snapshot/evidencias con fecha
|
||||||
|
real listados arriba.
|
||||||
|
|
||||||
|
## Si apruebas
|
||||||
|
|
||||||
|
1. `sudo systemctl enable --now cayce-promo.timer` con la campaña v4 ya en
|
||||||
|
`social/promo.mjs` (PR propio, sin tocar paths protegidos).
|
||||||
|
2. Los 4 IG pendientes de borrado manual (r31) deberían borrarse antes de
|
||||||
|
reactivar IG.
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Ronda 32 — Post-merge P1, FASE B publicada, reporte diario v2, campaña v4 propuesta (OpenCode/GLM, operador patternn)
|
||||||
|
|
||||||
|
Regla nueva aplicada: **R7/D4** (nada de compilar/instalar/probar en /srv/*; copias en /tmp o workspace del runner) — en DECISIONS.md vía PR #62.
|
||||||
|
|
||||||
|
## 1. Post-merge P1 — HECHO
|
||||||
|
|
||||||
|
- Estado migrado a `/var/lib/cayce/promo/` (.env 600 ubuntu, promo-state.json, campaign-start.json, media/) · units instaladas desde el checkout (`deploy/systemd/cayce-promo.{service,timer}`) + daemon-reload · **timer sigue disabled** (campaña pausada, verificado inactive).
|
||||||
|
- `~/cayce-social` archivado: `/var/backups/cayce/forensics/cayce-social-pre-repo-20261103.tar.gz` (194 archivos) y el dir renombrado a `~/cayce-social.archived-pre-repo` (nada borrado).
|
||||||
|
- **Autodeploy de entity incluye social/**: deploy del merge #9 a las 15:03:18 → `entity → 10b1aaf (tests 27/27, watcher OK, live)`; `ls /srv/cayce-core/social/` → promo.mjs, guard12.mjs, social.mjs, README.md.
|
||||||
|
- Código desplegado verificado EN /tmp (R7): `node --check` ×3 OK y guard12 **12/12 aprobados**.
|
||||||
|
|
||||||
|
## 2. FASE B — 4 guías publicadas (PRs auto-mergeados)
|
||||||
|
|
||||||
|
Cada PR: solo `src/data/guides.json` (sin paths protegidos), guard previo contra postgres temporal aislado en /tmp, auditoría factual en el cuerpo del PR, ≥600 palabras propias, ODbL + merchant id + snapshot datado, avisos de verificación antigua.
|
||||||
|
|
||||||
|
| PR | Guía | Guard | Palabras | Estado |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| #16 (1º intento #15 cerrado por type error `heading` vs `title`) | el-zonte-where-to-sleep | APROBADO | 823 | MERGED, deploy 1ed847d, **200 en vivo** |
|
||||||
|
| #17 | san-salvador-base-camp | APROBADO | 670 | MERGED, **200 en vivo** |
|
||||||
|
| #18 | lugano-plan-b-stay | APROBADO | 643 | MERGED (deploy en el pase siguiente) |
|
||||||
|
| #19 | roatan-prospera-stay | APROBADO | 647 | abierto al cierre de este doc (CI/automerge en curso) |
|
||||||
|
|
||||||
|
Fuentes usadas (todas citadas en el texto): btcmap.org snapshot 2026-11-03 (lodging), Reuters 2025-01-30 y Forbes 2025-02-28 (reforma ES), planb.lugano.ch (Lugano), Reuters 2022-04-07 (Próspera), bitcoinbeach.com + wearebitcoin.org (El Zonte 2019). Corrección de honestidad durante la ronda: el sitio de Las Verandas NO documenta pago bitcoin (verificado) — la guía cita solo el survey de BTC Map.
|
||||||
|
|
||||||
|
## 3. Reporte diario — HECHO (PR #63 MERGED + instalado)
|
||||||
|
|
||||||
|
Tres secciones nuevas en `cayce-daily-report`: **3b PRs que esperan tu merge** (Gitea, con motivo calculado contra la lista de paths protegidos; GitHub hardcap referenciado — el VPS no tiene token GitHub), **Contenido nuevo publicado hoy por sitio** con enlaces vivos (guías bh desde el git del árbol desplegado; notas hc por article_id), y **línea semanal AdSense los lunes** (checklist 5 puntos por sitio). Prueba en seco OK.
|
||||||
|
|
||||||
|
## 4. Campaña promo v4 — PROPUESTA (docs/promo-campana-r32.md, este PR)
|
||||||
|
|
||||||
|
8 posts / 8 días, cada afirmación con fuente primaria citada (tabla completa afirmación→fuente en el doc). Sin sellos "verified" salvo snapshot/evidencias reales. NO se reanuda nada: requiere tu aprobación + idealmente borrar antes los 4 IG pendientes.
|
||||||
|
|
||||||
|
## Incidencias de la ronda (encontradas y arregladas)
|
||||||
|
|
||||||
|
1. **hardcap-news llevaba sin desplegar desde el 1-nov**: el VPS no podía hacer `git fetch` de GitHub. Fix: deploy key **read-only** (`deploy-readonly-vm2047`, key id 168607734) + remote SSH. Fetch OK → main c453b2d visible.
|
||||||
|
2. **hardcap entró en rollback eterno**: el check de identidad grep-ea `meta name="build-id"` que main NUNCA tuvo (NEXT_PUBLIC_BUILD_ID existe desde #6 pero no se renderizaba) → todo deploy rueda atrás. Fix: **GitHub PR #10** (meta en layout, patrón bh; CI verde tras re-run de un flaky de Google Fonts) — **espera tu merge**.
|
||||||
|
3. **El rollback de hardcap abortaba el autodeploy completo**: `exit 1` antes de la sección bitcoinhotels → bh #16/#17 mergeados sin desplegar (15:32-15:43). Fix: sección hardcap en **subshell** (PR #64 + instalado). Evidencia de que funciona: 15:52:07 rollback hardcap y 15:52:32 `bitcoinhotels → 1ed847d (200 + umami + 0 marcas)`.
|
||||||
|
4. PR #15 cerrado por mi error de tipo (heading vs title en sections) — reabierto como #16 con fix.
|
||||||
|
|
||||||
|
## Pendientes del operador
|
||||||
|
|
||||||
|
1. **Merge de GitHub #10** (meta build-id) — desbloquea el deploy de hardcap (main lleva desde el 1-nov sin llegar a producción).
|
||||||
|
2. Aprobar/rechazar campaña v4 (docs/promo-campana-r32.md).
|
||||||
|
3. Borrar los 4 IG pendientes (URLs en doc r31) antes de reactivar promo.
|
||||||
|
4. PR #62 (D4/R7 en DECISIONS) y #64 (subshell) esperan tu merge si quieres revisarlos; el resto se auto-mergea.
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
# Ronda 33 — Loop hardcap, política de DMs, directiva BTCPay, inbox 10050, aprobaciones por reacción (OpenCode/GLM, operador patternn)
|
||||||
|
|
||||||
|
> Deuda corregida: el doc de la r32 quedó sin PR al cerrar esa ronda — se
|
||||||
|
> incluye aquí como archivo aparte (2026-11-03-r32-postmerge-faseb-reportes.md).
|
||||||
|
|
||||||
|
## 1. Loop de rollback en hardcap — RESUELTO
|
||||||
|
|
||||||
|
- **Estado al abrir**: producción hardcap en `a5c2f59` (build del 1-nov),
|
||||||
|
sirviendo 200; **34 rollbacks** entre 15:10:06 y 16:09:58 UTC (uno por ciclo
|
||||||
|
de 3 min), todos `build-id '' != 'c453b2df'`.
|
||||||
|
- **Causa raíz** (dos capas): (a) el fetch de GitHub del VPS llevaba roto
|
||||||
|
desde el 1-nov (arreglado en r32 con deploy key read-only); (b) al revivir
|
||||||
|
el fetch, el check de identidad grep-ea `meta name="build-id"` que main
|
||||||
|
**nunca renderizó** (gh#10 lo añade; sigue abierto) → rollback eterno.
|
||||||
|
- **Arreglos** (PR cayce-ops #65 + instalados):
|
||||||
|
1. identidad de hardcap exigida **solo si ESTE main renderiza la meta**
|
||||||
|
(`git grep name=.build-id. layout.tsx`) — con gh#10 mergeado y desplegado
|
||||||
|
el check se reactiva solo;
|
||||||
|
2. `dm_once`/`dm_clear`: **un DM por incidente** (subject `repo:causa`),
|
||||||
|
limpiado por deploy exitoso; journal completo vía `say` (silencio en DM,
|
||||||
|
no en audit).
|
||||||
|
- **Resultado verificado**: deploy manual exit=0 → `hardcap-news → c453b2d
|
||||||
|
(200)` — main del 3-nov EN producción (hubs /topics/* 200, texto del
|
||||||
|
travel-security-kit corregido) — y `bitcoinhotels → 5dbff23` (4ª guía viva).
|
||||||
|
- Sitio caído = urgencia real: cubierto por urgent-watch (caída >15 min),
|
||||||
|
no por el rollback (que mantiene el sitio arriba en el build anterior).
|
||||||
|
|
||||||
|
## 2. Política de DMs — REEMPLAZADA (PR #66 + instalada)
|
||||||
|
|
||||||
|
- urgent-watch v2: DM inmediato SOLO (1) kill switch manual o fuga (violaciones
|
||||||
|
del watcher), (2) servicio/sitio caído >15 min, (3) backup fallido **2 días
|
||||||
|
seguidos**, (4) gasto Gemini > umbral. Fuera: mudos, CODEOWNERS, initiative,
|
||||||
|
rollbacks recuperados, publicaciones, rechazos → SOLO resumen diario 23:50
|
||||||
|
(verificado OnCalendar=23:50). Ciclos pausados a propósito (promo) sin
|
||||||
|
alertas.
|
||||||
|
- Dedup por **tipo:sujeto** (24 h). **Tope 3 urgentes/día**: al 4º,
|
||||||
|
diferido a `.dm-deferred.log` → una línea en el resumen (sección 2b nueva).
|
||||||
|
- **Conteo 24 h (evidencia del antes)**: **83 DMs** — 18 rollback hardcap, 26
|
||||||
|
codeowners, 6 mudos, 6 aborts dirty, 10 copias del reporte diario (bug de
|
||||||
|
reenvío anotado), resto varios.
|
||||||
|
- **Simulación DRYRUN de cada tipo** (estados falsos en /tmp, sin enviar):
|
||||||
|
killswitch:manual ✓ · fuga:watcher ✓ · down:fake-down.service (20 min) ✓ ·
|
||||||
|
backup:2días ✓ · gasto:gemini ($9>$1) ✓ · tope→deferred ✓ (evidencia en
|
||||||
|
`.dm-deferred.log` del simulacro).
|
||||||
|
|
||||||
|
## 3. Directiva BTCPay — DESACTIVADA
|
||||||
|
|
||||||
|
- `CAYCE_DIRECTIVE_BTCPAY=0` en /srv/cayce-core/.env (generación de nuevas
|
||||||
|
oportunidades BTCPay cortada de raíz).
|
||||||
|
- Archivados: drafts **#50, #51, #52** (los tres BTCPay generados HOY por la
|
||||||
|
directiva: 02:00, 08:00 y 16:00) + verificación de que **#33** y la
|
||||||
|
oportunidad **#106** ya estaban archived. Audit: actions_log id 1306.
|
||||||
|
- **Qué publicó initiative hoy**: 3 ciclos (02:00/08:00/16:00) pero **UNA
|
||||||
|
sola nota nostr publicada** — id 381, 08:00:15 UTC, event
|
||||||
|
`7389a478df83e39f0648b6c42295b4205c454ea9277827245923af9578f92417`, texto:
|
||||||
|
"Event ticketing infrastructure that forces custodial payment processors or
|
||||||
|
third-party tracking degrades bitcoiner operational security. Open-source
|
||||||
|
merchant rails like BTCPay Server paired with local, peer-to-peer
|
||||||
|
directories eliminate trusted third parties at the physical layer."
|
||||||
|
**Guard: APROBADO** (canal nostr, tipo initiative_note, postgres temporal
|
||||||
|
aislado) → se queda; no hubo que borrar nada con kind 5.
|
||||||
|
- Pendiente reportado: 20 oportunidades BTCPay en estado `identified`
|
||||||
|
quedan en el pipeline (sin nueva generación); si las quieres archivadas,
|
||||||
|
dilo y lo hago. El producto vive solo en cayce/btcpay-events (repo intacto).
|
||||||
|
|
||||||
|
## 4. Inbox de Cayce (kind 10050) — PUBLICADO
|
||||||
|
|
||||||
|
- Diagnóstico: el daemon **lee** gift wraps NIP-17 (kind 1059 → seal 13 →
|
||||||
|
chat 14 del supervisor, con manejo de comandos) pero **nunca publicó el kind
|
||||||
|
10050** — de ahí "DM inbox relays not found" en tu cliente.
|
||||||
|
- `publish-10050.mjs` (en /srv/cayce-nostr, herramienta operativa): consultó
|
||||||
|
los 5 relays → **0 existentes** → publicó event
|
||||||
|
`7694c0f61b747c45a76555d84a8c2281fa32db25039f5509afa8e4a4ddf05dee`
|
||||||
|
(pubkey 59ef3b5d…, relays damnos/nos.lol/primal/snort/wellorder)
|
||||||
|
**verificado en 5/5**. Idempotente (no república si hay uno <30 días).
|
||||||
|
- **Prueba pendiente tuya**: mándame un DM NIP-17 — en el journal del daemon
|
||||||
|
aparecerá `[DM supervisor NIP-17] …` (24 h últimas: 0, nunca llegó ninguno
|
||||||
|
porque el cliente no encontraba el inbox). Nota: /srv/cayce-nostr no es repo
|
||||||
|
git — drift pendiente de versionar (igual que el daemon).
|
||||||
|
|
||||||
|
## 5. Aprobación por reacción — IMPLEMENTADA (entity PR #10, WIP, LO MERGEAS TÚ)
|
||||||
|
|
||||||
|
Diseño completo en `docs-approvals.md` (dentro del PR). Resumen:
|
||||||
|
- Pregunta por DM NIP-17 con **ID único, acción, efecto y vencimiento 48 h**.
|
||||||
|
- Aprobación = reacción 👍 o **+** a ESE mensaje, **seal NIP-17 firmado por
|
||||||
|
SUPERVISOR_NPUB_HEX** (fallback: kind 7 pública con #e). 👎/otra/nada = no
|
||||||
|
se hace nada.
|
||||||
|
- Ejecución **idempotente** (FOR UPDATE + executed_at): `merge_pr` (ci-bot,
|
||||||
|
para PRs de paths protegidos), `resume_promo`/`pause_promo`, registro
|
||||||
|
`approved:` para campañas/zona roja. Audit en actions_log con el event id
|
||||||
|
de la reacción; confirmación SOLO en el resumen diario.
|
||||||
|
- **Tests 6/6 en CI** (postgres temporal): otra pubkey ignorada · otro
|
||||||
|
mensaje ignorado · 👎 ignorada · vencida no ejecuta · válida ejecuta UNA
|
||||||
|
vez · sweep de vencidas.
|
||||||
|
- **Prueba real preparada**: tras tu merge, abro un PR de prueba tocando un
|
||||||
|
path protegido, te llega la pregunta, reaccionas 👍 y verificamos el merge
|
||||||
|
por ci-bot.
|
||||||
|
|
||||||
|
## Incidencias propias de la ronda
|
||||||
|
|
||||||
|
1. Al instalar el autodeploy parcheado, un pase lo estaba ejecutando (bash
|
||||||
|
lee incrementalmente) → errores transitorios por 1 ciclo (16:13:36,
|
||||||
|
documentados en journal); el pase siguiente y el manual salieron limpios.
|
||||||
|
Lección aplicada: instalar scripts solo tras `flock` o entre ciclos.
|
||||||
|
2. El primer commit del PR entity arrastró el .pgtmp de pruebas → limpieza
|
||||||
|
en el mismo PR antes de que lo tocaras.
|
||||||
|
|
||||||
|
## Pendientes del operador
|
||||||
|
|
||||||
|
1. **Merge gh#10** (meta build-id de hardcap; CI verde) — reactiva el check
|
||||||
|
de identidad de hardcap al desplegarse.
|
||||||
|
2. **Merge entity PR #10** (aprobaciones, WIP a propósito) → instalo la unit
|
||||||
|
y corremos la prueba real de reacción.
|
||||||
|
3. Mándame un DM NIP-17 para cerrar la prueba del inbox.
|
||||||
|
4. PRs cayce-ops #65/#66 (auto-mergeables) y el doc de esta ronda.
|
||||||
Reference in New Issue
Block a user