containment 2/2: kind 10050 (inbox relays) + drafts summary in supervisor DM + grants suspended, BTCPay priority-1
ci / lint-test-leaks (pull_request) Canceled after 0s

- publish-10050.mjs: publishes Cayce kind 10050 (NIP-65 message-relays/
  inbox) listing the 6 relays where the listener actually reads DMs.
  EXECUTED once with operator authorization: event id
  188ef397824e8f29b5e1bea661ae65b1f8532ee97617747b9fbde57c6e8dfce9,
  accepted 6/6 relays.
- initiative.mjs: the cycle DM to the supervisor now includes a summary
  of outbound_drafts from the last 24h (id, type, first 15 words) so the
  operator reviews what the agent WANTED to publish.
- initiative.mjs: supervisor directive (CAYCE_DIRECTIVE_BTCPAY=1,
  reversible) injected into the cycle prompt: grants/opportunity search
  SUSPENDED, single priority = consolidate the BTCPay Server proposal
  (opportunity #106 / draft #33) ready for HUMAN sending. MANDATE text
  untouched (only the supervisor can change it).
- initiative.mjs: add_opportunity now rejects duplicates (the agent had
  re-registered OpenSats ×10, HRF ×6).
- opportunity #106 status -> priority-1.
- check-relay-silence.mjs: queries the relays for Cayce-signed events
  since a timestamp; allows only kind 10050 and supervisor DMs; exits 1
  on any violation. Verified: 0 events, 0 violations since deployment.
- deploy.sh: sudo for the daemon restart, optional files tolerated.

Gate: make check green (96 tests).
This commit is contained in:
2026-10-31 16:48:54 +00:00
parent e06cb85ce8
commit 058126b80d
4 changed files with 122 additions and 4 deletions
+24 -1
View File
@@ -52,6 +52,13 @@ async function toolWebFetch({ url }) {
}
async function toolAddOpportunity(a) {
// directiva supervisor 2026-10-31: sin dedup el agente re-registraba la
// misma oportunidad (OpenSats ×10, HRF ×6). Ahora: si existe, se rechaza.
const dup = await pgc.query('SELECT id FROM opportunities WHERE lower(source_name) = lower($1) LIMIT 1', [a.source_name])
if (dup.rowCount) {
await log('yellow', 'opportunity_duplicate_rejected', { source_name: a.source_name, existing_id: dup.rows[0].id })
return { duplicate: true, existing_id: dup.rows[0].id, note: 'ya registrada — no se duplica; continuá con el resto del ciclo' }
}
await pgc.query(
`INSERT INTO opportunities (source_name, url, mechanic, fit, effort, expected, first_action)
VALUES ($1,$2,$3,$4,$5,$6,$7)`,
@@ -165,10 +172,21 @@ Una acción por respuesta. El sistema ejecuta y te devuelve el resultado. Si tu
// ── el loop
async function runCycle() {
const state = await stateSummary()
// directiva del supervisor (2026-10-31): grants suspendidos, BTCPay prioridad 1.
// No modifica el MANDATE (eso es 🔴); es una orden operativa reversible con
// CAYCE_DIRECTIVE_BTCPAY=0 en el .env.
const DIRECTIVE = process.env.CAYCE_DIRECTIVE_BTCPAY === '1' ? `
=== DIRECTIVA DEL SUPERVISOR (2026-10-31 — prevalece sobre §7b hasta nuevo aviso) ===
1. SUSPENDIDA la búsqueda y registro de grants y nuevas oportunidades. NO uses add_opportunity salvo para la excepción del punto 2.
2. PRIORIDAD 1 ÚNICA: la propuesta de BTCPay Server — oportunidad #106 "BTCPay Server Deployment & Content Service" y draft #33 "BTCPay Server Plugin: Event & Travel Integration". Trabajo esperado: consolidar UNA propuesta final lista para envío humano (alcance, arquitectura, presupuesto, plan de entrega) como draft nuevo marcado claramente. NO la envíes: la envía el operador.
3. La contención está activa: publish_note crea BORRADORES, no publica. Sigue contando como acción productiva.
` : ''
const messages = [
{
role: 'user',
content: `${MANDATE}
${DIRECTIVE}
=== TU ESTADO ACTUAL ===
${JSON.stringify(state, null, 2)}
@@ -261,7 +279,12 @@ Empieza ahora. Cuando hayas cumplido §7b, responde finish con un summary honest
const finalSummary = summary ?? 'max steps'
await log(s7b_ok ? 'green' : 'red', 'initiative_cycle',
{ steps, productive, repairs, trace, summary: finalSummary }, s7b_ok ? 'done' : 'error')
await dm(`INITIATIVE ${new Date().toISOString().slice(0, 10)} — ciclo ${s7b_ok ? 'cumplido' : 'falló'} · ${steps} pasos · ${productive} productivas · ${trace.map(t => t.action).join(' → ') || 'sin acciones'}\n\n${finalSummary}`)
const drafts24 = (await pgc.query(
`SELECT id, type, content FROM outbound_drafts WHERE ts > now() - interval '24 hours' ORDER BY id`
).catch(() => ({ rows: [] }))).rows
const draftLines = drafts24.map(d => `#${d.id} [${d.type}] ${String(d.content).replace(/\s+/g, ' ').split(' ').slice(0, 15).join(' ')}`)
const draftBlock = `\n\nBORRADORES contención (24h: ${draftLines.length}) — revisión y aprobación pendientes del operador:\n${draftLines.join('\n') || 'ninguno'}`
await dm(`INITIATIVE ${new Date().toISOString().slice(0, 10)} — ciclo ${s7b_ok ? 'cumplido' : 'falló'} · ${steps} pasos · ${productive} productivas · ${trace.map(t => t.action).join(' → ') || 'sin acciones'}\n\n${finalSummary}${draftBlock}`)
return { steps, productive, s7b_ok, summary: finalSummary, trace }
}