From f4d97cf55a2739de541fd07bd840f37526a6f8c3 Mon Sep 17 00:00:00 2001 From: anansutiawan Date: Fri, 17 Apr 2026 09:34:24 +0700 Subject: [PATCH] fix(loop): tags as comma-string + MAX_REPLY negative guard - Phase 3 News Signals: add note that tags must be a comma-separated string ("bitcoin,aibtc,agents"), not an array. Fixes #29. - daemon/pillars/news.md: add same tags format note inline in step 3. - Phase 5 Deliver: guard MAX_REPLY <= 3 to skip reply with warning instead of producing a bash error or malformed truncation. Fixes #31. - Reply Mechanics section: document the guard and explain why it is needed (negative/zero slice index causes bash error). Co-Authored-By: Claude Sonnet 4.6 --- daemon/loop.md | 8 +++++++- daemon/pillars/news.md | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/daemon/loop.md b/daemon/loop.md index b80ccac..cbe4b9a 100644 --- a/daemon/loop.md +++ b/daemon/loop.md @@ -124,6 +124,7 @@ If you've claimed a beat on aibtc.news, file research-based signals to build rep 3. Tie external news to what AIBTC agents are doing 4. Include source URLs. If no genuinely newsworthy story found, skip — quality over quantity. 5. Rate limit: 1 signal per 4 hours. File daily to maintain streak. +6. **Tags format:** `tags` must be a comma-separated string: `"bitcoin,aibtc,agents"` — NOT an array. Signals filed with array tags have no tags on aibtc.news. --- @@ -156,7 +157,11 @@ Send all queued replies from Phase 2/3. export MSG_ID="" REPLY_TEXT="" PREFIX="Inbox Reply | ${MSG_ID} | " MAX_REPLY=$((500 - ${#PREFIX})) -if [ ${#REPLY_TEXT} -gt $MAX_REPLY ]; then REPLY_TEXT="${REPLY_TEXT:0:$((MAX_REPLY - 3))}..."; fi +if [ $MAX_REPLY -le 3 ]; then + echo "WARNING: messageId too long, skipping reply for $MSG_ID" >&2 +else + if [ ${#REPLY_TEXT} -gt $MAX_REPLY ]; then REPLY_TEXT="${REPLY_TEXT:0:$((MAX_REPLY - 3))}..."; fi +fi # Sign the full string: "${PREFIX}${REPLY_TEXT}" # Write JSON to temp file, POST with -d @file ``` @@ -496,6 +501,7 @@ wSTX rewards accrue continuously. Claim when profitable, not on a fixed schedule - Use `-d @file` NOT `-d '...'` — shell mangles base64 - ASCII only — em-dashes break sig verification - One reply per message — outbox API rejects duplicates +- **Guard against negative MAX_REPLY:** if `MAX_REPLY <= 3` (messageId is extremely long), skip the reply and log a warning — do not attempt truncation, as `${REPLY_TEXT:0:$((MAX_REPLY - 3))}` produces a bash error or empty string when MAX_REPLY is 0, 1, 2, or 3. --- diff --git a/daemon/pillars/news.md b/daemon/pillars/news.md index 965bf77..338e1ba 100644 --- a/daemon/pillars/news.md +++ b/daemon/pillars/news.md @@ -12,6 +12,7 @@ File research-based signals on aibtc.news to build reputation and earn inclusion 1. Research external sources BEFORE writing (WebSearch/WebFetch required, minimum 2 sources) 2. Pick a newsworthy story about the AIBTC ecosystem 3. Write signal: headline (<80 chars), body (<1000 chars), sources, tags, disclosure + - **tags** must be a comma-separated string: `"bitcoin,aibtc,agents"` — NOT an array. Signals filed with array tags have no tags on aibtc.news. 4. Sign and submit via v2 auth: - Sign: `"POST /api/signals:{unix_seconds}"` - Headers: `X-BTC-Address`, `X-BTC-Signature`, `X-BTC-Timestamp`