Skip to content

Agency: agency-report helper + SQLite suggestion DB + dedupe#89

Open
MagMueller wants to merge 1 commit intomainfrom
agency-report-db
Open

Agency: agency-report helper + SQLite suggestion DB + dedupe#89
MagMueller wants to merge 1 commit intomainfrom
agency-report-db

Conversation

@MagMueller
Copy link
Copy Markdown
Contributor

@MagMueller MagMueller commented May 4, 2026

Summary

Persistent suggestion store: every Agency post is recorded in /var/lib/bux/agency.db so future runs can dedupe, and a button tap records the decision against the source row.

  • agent/agency_db.py (new) — SQLite store. One row per suggestion: title, description, importance, source slug, prompt that runs on accept, buttons_json, TG identifiers, status, decision label, worker_topic_id, timestamps.
  • agent/agency-report (new) — Python CLI. Inserts row, posts TG with inline buttons. --skip-if-exists dedupes by --source slug. --button repeatable for custom label sets.
  • agent/telegram_bot.py_handle_agency_callback records each tap via agency_db.record_decision(...). Out-of-band buttons no-op.
  • agent/bootstrap.sh — symlink + /var/lib/bux install dir.

Default buttons

✅ Yes, do it · ❌ No · ✏️ Just do it differently · 🔄 Regenerate

Magnus's principle

"If I didn't respond to something, you can ignore it." A pending row > 48h is implicit dismissal.

🤖 Generated with Claude Code


Summary by cubic

Adds a persistent SQLite-backed suggestion store and a new agency-report CLI that posts Agency suggestions to Telegram with inline buttons. Button taps are recorded for dedupe and status tracking across runs.

  • New Features

    • agent/agency_db.py: SQLite DB at /var/lib/bux/agency.db with helpers to insert suggestions, update message IDs, record decisions, set status/worker topic, and search.
    • agent/agency-report: records a suggestion, posts to Telegram with default or custom buttons, links back the message_id, and supports --skip-if-exists dedupe by --source.
    • telegram_bot.py: on callback, writes the tapped label to the DB; ignores out-of-band buttons.
    • bootstrap.sh: adds /usr/local/bin/agency-report and ensures /var/lib/bux exists and is writable.
    • Default buttons: ✅ Yes, do it · ❌ No · ✏️ Just do it differently · 🔄 Regenerate
  • Migration

    • Re-run bootstrap to install the symlink and create the data directory.
    • Configure TG_BOT_TOKEN (env or /etc/bux/tg.env) and ensure /etc/bux/tg-allowed.txt has the chat ID; optionally set TG_THREAD_ID.

Written for commit 025e497. Summary will update on new commits.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="agent/agency_db.py">

<violation number="1" location="agent/agency_db.py:154">
P1: Decision classification order is wrong: labels like “Just do it differently” are saved as `accepted` because `"do it"` is checked before `"different"`.</violation>
</file>

<file name="agent/agency-report">

<violation number="1" location="agent/agency-report:78">
P2: Handle missing `/etc/bux/tg-allowed.txt` in `chat_id()` to avoid an uncaught traceback on first-run/unbound setups.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread agent/agency_db.py
Comment on lines +154 to +162
if any(w in low for w in ("yes", "do it", "ship", "send", "merge", "approve")):
status = "accepted"
elif any(w in low for w in ("regen", "redo", "rethink")):
status = "regenerated"
elif any(w in low for w in ("different", "differently")):
status = "differently"
elif "no" in low or "skip" in low or "don't" in low or "ignore" in low:
status = "dismissed"
else:
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Decision classification order is wrong: labels like “Just do it differently” are saved as accepted because "do it" is checked before "different".

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At agent/agency_db.py, line 154:

<comment>Decision classification order is wrong: labels like “Just do it differently” are saved as `accepted` because `"do it"` is checked before `"different"`.</comment>

<file context>
@@ -0,0 +1,245 @@
+    if row is None:
+        return None
+    low = decision.lower()
+    if any(w in low for w in ("yes", "do it", "ship", "send", "merge", "approve")):
+        status = "accepted"
+    elif any(w in low for w in ("regen", "redo", "rethink")):
</file context>
Suggested change
if any(w in low for w in ("yes", "do it", "ship", "send", "merge", "approve")):
status = "accepted"
elif any(w in low for w in ("regen", "redo", "rethink")):
status = "regenerated"
elif any(w in low for w in ("different", "differently")):
status = "differently"
elif "no" in low or "skip" in low or "don't" in low or "ignore" in low:
status = "dismissed"
else:
if any(w in low for w in ("regen", "redo", "rethink")):
status = "regenerated"
elif any(w in low for w in ("different", "differently")):
status = "differently"
elif "no" in low or "skip" in low or "don't" in low or "ignore" in low:
status = "dismissed"
elif any(w in low for w in ("yes", "do it", "ship", "send", "merge", "approve")):
status = "accepted"
else:
status = "accepted" # custom labels like "Send draft A" → treat as accept
Fix with Cubic

Comment thread agent/agency-report


def chat_id() -> int:
raw = Path("/etc/bux/tg-allowed.txt").read_text().splitlines()
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Handle missing /etc/bux/tg-allowed.txt in chat_id() to avoid an uncaught traceback on first-run/unbound setups.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At agent/agency-report, line 78:

<comment>Handle missing `/etc/bux/tg-allowed.txt` in `chat_id()` to avoid an uncaught traceback on first-run/unbound setups.</comment>

<file context>
@@ -0,0 +1,195 @@
+
+
+def chat_id() -> int:
+    raw = Path("/etc/bux/tg-allowed.txt").read_text().splitlines()
+    for line in raw:
+        line = line.strip()
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant