caucus 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. caucus-0.2.2/.github/workflows/evidence-snapshot.yml +73 -0
  2. {caucus-0.2.1 → caucus-0.2.2}/PKG-INFO +1 -1
  3. {caucus-0.2.1 → caucus-0.2.2}/examples/trading-robinhood/README.md +27 -11
  4. caucus-0.2.2/examples/trading-robinhood/com.example.caucus.plist +25 -0
  5. caucus-0.2.2/examples/trading-robinhood/config.yaml +72 -0
  6. caucus-0.2.2/examples/trading-robinhood/news_evidence.py +64 -0
  7. caucus-0.2.2/examples/trading-robinhood/run-caucus.sh +24 -0
  8. {caucus-0.2.1 → caucus-0.2.2}/pyproject.toml +1 -1
  9. {caucus-0.2.1 → caucus-0.2.2}/src/caucus/__init__.py +1 -1
  10. {caucus-0.2.1 → caucus-0.2.2}/uv.lock +1 -1
  11. caucus-0.2.1/examples/trading-robinhood/config.yaml +0 -41
  12. {caucus-0.2.1 → caucus-0.2.2}/.github/codex/prompts/review.md +0 -0
  13. {caucus-0.2.1 → caucus-0.2.2}/.github/codex/review-config.json +0 -0
  14. {caucus-0.2.1 → caucus-0.2.2}/.github/codex/review-rules.md +0 -0
  15. {caucus-0.2.1 → caucus-0.2.2}/.github/codex/scripts/build-review-prompt.mjs +0 -0
  16. {caucus-0.2.1 → caucus-0.2.2}/.github/codex/scripts/normalize-review-output.mjs +0 -0
  17. {caucus-0.2.1 → caucus-0.2.2}/.github/codex/scripts/post-review.cjs +0 -0
  18. {caucus-0.2.1 → caucus-0.2.2}/.github/pull_request_template.md +0 -0
  19. {caucus-0.2.1 → caucus-0.2.2}/.github/workflows/ci.yml +0 -0
  20. {caucus-0.2.1 → caucus-0.2.2}/.github/workflows/codex-review.yml +0 -0
  21. {caucus-0.2.1 → caucus-0.2.2}/.github/workflows/keep-codex-auth-fresh.yml +0 -0
  22. {caucus-0.2.1 → caucus-0.2.2}/.github/workflows/release.yml +0 -0
  23. {caucus-0.2.1 → caucus-0.2.2}/.gitignore +0 -0
  24. {caucus-0.2.1 → caucus-0.2.2}/AGENT_SETUP.md +0 -0
  25. {caucus-0.2.1 → caucus-0.2.2}/DISCLAIMER.md +0 -0
  26. {caucus-0.2.1 → caucus-0.2.2}/LICENSE +0 -0
  27. {caucus-0.2.1 → caucus-0.2.2}/README.md +0 -0
  28. {caucus-0.2.1 → caucus-0.2.2}/SPEC.md +0 -0
  29. {caucus-0.2.1 → caucus-0.2.2}/config.example.yaml +0 -0
  30. {caucus-0.2.1 → caucus-0.2.2}/examples/trading-robinhood/evidence.sample.json +0 -0
  31. {caucus-0.2.1 → caucus-0.2.2}/examples/trading-robinhood/import_campaigns.py +0 -0
  32. {caucus-0.2.1 → caucus-0.2.2}/examples/trading-robinhood/mcp.example.json +0 -0
  33. {caucus-0.2.1 → caucus-0.2.2}/src/caucus/backends.py +0 -0
  34. {caucus-0.2.1 → caucus-0.2.2}/src/caucus/briefing.py +0 -0
  35. {caucus-0.2.1 → caucus-0.2.2}/src/caucus/cli.py +0 -0
  36. {caucus-0.2.1 → caucus-0.2.2}/src/caucus/config.py +0 -0
  37. {caucus-0.2.1 → caucus-0.2.2}/src/caucus/engine.py +0 -0
  38. {caucus-0.2.1 → caucus-0.2.2}/src/caucus/evidence.py +0 -0
  39. {caucus-0.2.1 → caucus-0.2.2}/src/caucus/intents.py +0 -0
  40. {caucus-0.2.1 → caucus-0.2.2}/src/caucus/notify.py +0 -0
  41. {caucus-0.2.1 → caucus-0.2.2}/src/caucus/record.py +0 -0
  42. {caucus-0.2.1 → caucus-0.2.2}/tests/test_briefing.py +0 -0
  43. {caucus-0.2.1 → caucus-0.2.2}/tests/test_cli.py +0 -0
  44. {caucus-0.2.1 → caucus-0.2.2}/tests/test_config.py +0 -0
  45. {caucus-0.2.1 → caucus-0.2.2}/tests/test_engine.py +0 -0
  46. {caucus-0.2.1 → caucus-0.2.2}/tests/test_evidence.py +0 -0
  47. {caucus-0.2.1 → caucus-0.2.2}/tests/test_intents.py +0 -0
  48. {caucus-0.2.1 → caucus-0.2.2}/tests/test_notify.py +0 -0
  49. {caucus-0.2.1 → caucus-0.2.2}/tests/test_record.py +0 -0
@@ -0,0 +1,73 @@
1
+ name: Evidence snapshot
2
+
3
+ # GitHub's traffic API retains only 14 days of views/clones — this weekly
4
+ # snapshot preserves adoption history (stars, forks, traffic, referrers, PyPI
5
+ # downloads) as append-only JSONL on the 'evidence' branch.
6
+
7
+ on:
8
+ schedule:
9
+ - cron: "0 8 * * 1"
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ contents: write
14
+
15
+ jobs:
16
+ snapshot:
17
+ name: Capture adoption metrics
18
+ runs-on: ubuntu-latest
19
+ timeout-minutes: 10
20
+ steps:
21
+ - name: Checkout evidence branch (create if absent)
22
+ uses: actions/checkout@v5
23
+ with:
24
+ ref: main
25
+ fetch-depth: 1
26
+
27
+ - name: Switch to evidence branch
28
+ shell: bash
29
+ run: |
30
+ if git fetch origin evidence:evidence 2>/dev/null; then
31
+ git checkout evidence
32
+ else
33
+ git checkout --orphan evidence
34
+ git rm -rfq . 2>/dev/null || true
35
+ fi
36
+
37
+ - name: Capture snapshot
38
+ shell: bash
39
+ env:
40
+ GH_TOKEN: ${{ github.token }}
41
+ run: |
42
+ repo="$GITHUB_REPOSITORY"
43
+ date=$(date -u +%Y-%m-%d)
44
+ repo_json=$(gh api "repos/$repo")
45
+ views=$(gh api "repos/$repo/traffic/views" 2>/dev/null || echo '{}')
46
+ clones=$(gh api "repos/$repo/traffic/clones" 2>/dev/null || echo '{}')
47
+ referrers=$(gh api "repos/$repo/traffic/popular/referrers" 2>/dev/null || echo '[]')
48
+ pypi=$(curl -fsS "https://pypistats.org/api/packages/caucus/recent" 2>/dev/null || echo '{}')
49
+ jq -cn \
50
+ --arg date "$date" \
51
+ --argjson repo "$repo_json" \
52
+ --argjson views "$views" \
53
+ --argjson clones "$clones" \
54
+ --argjson referrers "$referrers" \
55
+ --argjson pypi "$pypi" \
56
+ '{date: $date,
57
+ stars: $repo.stargazers_count,
58
+ forks: $repo.forks_count,
59
+ open_issues: $repo.open_issues_count,
60
+ views: {count: $views.count, uniques: $views.uniques},
61
+ clones: {count: $clones.count, uniques: $clones.uniques},
62
+ referrers: $referrers,
63
+ pypi_recent: $pypi.data}' >> adoption.jsonl
64
+ tail -1 adoption.jsonl
65
+
66
+ - name: Commit snapshot
67
+ shell: bash
68
+ run: |
69
+ git config user.name "github-actions[bot]"
70
+ git config user.email "github-actions[bot]@users.noreply.github.com"
71
+ git add adoption.jsonl
72
+ git commit -m "Evidence snapshot $(date -u +%Y-%m-%d)"
73
+ git push origin evidence
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: caucus
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Your AI agents, deliberating on the record. MCP-grounded multi-agent consensus with recorded dissent and an auditable decision log.
5
5
  Project-URL: Repository, https://github.com/srinath-jukanti/caucus
6
6
  Author: Srinath Jukanti
@@ -30,22 +30,38 @@ The sample evidence is fictional. The default backend is the locally
30
30
  authenticated Claude Code CLI; add `--backend openai --model llama3.1
31
31
  --base-url http://localhost:11434/v1` to run fully local via Ollama.
32
32
 
33
- ## Live — ground the panel in your broker
33
+ ## Live — the full reference deployment, step by step
34
34
 
35
- 1. Copy `mcp.example.json` to `mcp.json` and complete authentication per your
36
- MCP provider's documentation (for Robinhood, the agentic trading MCP).
37
- 2. Copy `config.yaml` from this directory to the repository root (it is
38
- gitignored there) and adjust the watchlist subjects to your own.
39
- 3. Deliberate:
35
+ Everything below is configuration; no code changes are required.
36
+
37
+ 1. **Install**: `uv tool install caucus` (from PyPI).
38
+ 2. **Broker MCP**: copy `mcp.example.json` to `mcp.json`; run one interactive
39
+ `claude` session with it to complete the provider's authentication.
40
+ 3. **Config**: copy `config.yaml` and `news_evidence.py` from this directory
41
+ into your working directory; set `notify.to` to your address and export
42
+ `GMAIL_ADDRESS`/`GMAIL_APP_PASSWORD` (a Gmail app password).
43
+ 4. **Standing plans**: record your cadenced builds/trims and trigger rules —
44
+ they are injected into every deliberation as evidence:
40
45
 
41
46
  ```bash
42
- uv run caucus deliberate "Trim the QQQ position toward its target this week?"
47
+ caucus intents add "ACME build" --direction build --target 5% \
48
+ --pacing "weekly on dips" --cadence-days 7
49
+ caucus intents add "XYZ exit at breakeven" --direction trim \
50
+ --target "exit full position" --notes "sell all at cost basis 114.94"
43
51
  ```
44
52
 
45
- Each analyst can now call the allowed read-only tools quotes, historicals,
46
- portfolio state and cite what it fetched as evidence. Tool output is
47
- covered by Caucus's system-level data-not-instructions guard; only
48
- **read-only** tools are allowed in this example by design.
53
+ 5. **Run**: `caucus briefing` the agenda's four standing questions are
54
+ deliberated in order, the briefing is rendered and emailed, and every
55
+ decision (with dissent) lands in the hash-chained log.
56
+ 6. **Schedule**: `mkdir -p ~/caucus-live/logs` first (launchd opens its log
57
+ path before the script runs), then adapt `run-caucus.sh` (secrets from an
58
+ env file) and either the launchd template `com.example.caucus.plist`
59
+ (macOS) or the cron line in its comments (Linux).
60
+
61
+ Each analyst calls the allowed read-only tools — quotes, historicals,
62
+ portfolio, option chains, scans — and cites what it fetched as evidence.
63
+ Tool output is covered by Caucus's system-level data-not-instructions guard;
64
+ only **read-only** tools are allowed in this example by design.
49
65
 
50
66
  ## Guardrails carried over from the reference system
51
67
 
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <!-- launchd template (macOS): copy to ~/Library/LaunchAgents/com.example.caucus.plist,
4
+ adjust the script path and times, then:
5
+ launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.caucus.plist
6
+ On Linux, use cron instead:
7
+ 15 8,14 * * 1-5 CAUCUS_DIR=$HOME/caucus-live bash $HOME/caucus-live/run-caucus.sh -->
8
+ <plist version="1.0">
9
+ <dict>
10
+ <key>Label</key>
11
+ <string>com.example.caucus</string>
12
+ <key>ProgramArguments</key>
13
+ <array>
14
+ <string>/bin/bash</string>
15
+ <string>/Users/YOURUSER/caucus-live/run-caucus.sh</string>
16
+ </array>
17
+ <key>StartCalendarInterval</key>
18
+ <array>
19
+ <dict><key>Hour</key><integer>8</integer><key>Minute</key><integer>15</integer></dict>
20
+ <dict><key>Hour</key><integer>14</integer><key>Minute</key><integer>45</integer></dict>
21
+ </array>
22
+ <key>StandardErrorPath</key>
23
+ <string>/Users/YOURUSER/caucus-live/logs/launchd.err</string>
24
+ </dict>
25
+ </plist>
@@ -0,0 +1,72 @@
1
+ # Trading example configuration — a faithful copy of the reference deployment.
2
+ # Copy to your working directory as config.yaml; requires mcp.json (see
3
+ # mcp.example.json) for live broker grounding.
4
+
5
+ log: decisions.jsonl
6
+
7
+ # Standing plans (cadenced builds/trims, trigger rules) — create with
8
+ # 'caucus intents add', e.g.:
9
+ # caucus intents add "ACME build" --direction build --target 5% \
10
+ # --pacing "weekly on dips" --cadence-days 7
11
+ intents: intents.db
12
+
13
+ evidence_sources:
14
+ # Keyless news/macro feeds (Fed press RSS, Hacker News, Polymarket);
15
+ # per-feed tolerant — a dead feed becomes a note, never a blocked briefing.
16
+ - name: news-macro
17
+ command: python3 news_evidence.py
18
+ timeout_seconds: 60
19
+ # Pattern for deterministic indicators: compute MAs/momentum/regime in
20
+ # plain code from your own price cache and print JSON evidence items —
21
+ # the panel reasons over numbers it did not produce.
22
+ # - name: quant-snapshot
23
+ # command: python3 snapshot_evidence.py
24
+ # timeout_seconds: 30
25
+
26
+ backend:
27
+ type: claude
28
+ mcp_config: mcp.json
29
+ # Read-only tools ONLY — this deployment deliberates and records, never trades.
30
+ allowed_tools:
31
+ - mcp__robinhood-trading__get_equity_quotes
32
+ - mcp__robinhood-trading__get_equity_historicals
33
+ - mcp__robinhood-trading__get_portfolio
34
+ - mcp__robinhood-trading__get_equity_positions
35
+ - mcp__robinhood-trading__get_index_quotes
36
+ - mcp__robinhood-trading__get_option_chains
37
+ - mcp__robinhood-trading__get_option_instruments
38
+ - mcp__robinhood-trading__get_option_quotes
39
+ - mcp__robinhood-trading__get_scans
40
+ - mcp__robinhood-trading__run_scan
41
+ - mcp__robinhood-trading__get_earnings_calendar
42
+
43
+ panel:
44
+ - name: macro
45
+ charge: >-
46
+ Assess the macro and market regime relevant to the question. Use the
47
+ news/macro evidence and fetch current quotes rather than assuming;
48
+ state which signals support or undermine the proposal.
49
+ - name: momentum
50
+ charge: >-
51
+ Evaluate trend and momentum from recent historicals; judge against
52
+ moving-average position and price behavior, not narrative.
53
+ - name: risk-officer
54
+ charge: >-
55
+ Argue the downside. Quantify what a bad outcome costs given current
56
+ position sizes (fetch them), concentration, and liquidity. Oppose
57
+ anything that breaches prudent sizing or deviates from standing
58
+ intents without strong cause. For options, insist collateral is
59
+ computed from cash plus liquid reserves, never literal cash alone.
60
+
61
+ # The standing questions every 'caucus briefing' run answers, in order.
62
+ agenda:
63
+ - "Given the open intents, live positions, and current prices: which intent, if any, is due for its next action today, and what exactly should be done?"
64
+ - "Does the current market regime, the news, or any position behavior warrant a defensive action (hedge, trim, or pausing an intent) beyond the standing plans?"
65
+ - "Income: is there an attractive cash-secured put or covered call this run? Use live option chains (~30-45 DTE, ~0.25 delta) on names held or gladly owned per the intents; size against available collateral; skip any name within 14 days of earnings."
66
+ - "Opportunity scan: screen today's market movers for at most one new candidate consistent with the intents and regime; drop anything illiquid or junk-quality. If nothing qualifies, say so plainly."
67
+
68
+ # Delivery — Gmail-friendly SMTP; credentials come from the environment
69
+ # variables GMAIL_ADDRESS and GMAIL_APP_PASSWORD (never from this file).
70
+ notify:
71
+ type: email
72
+ to: you@example.com
@@ -0,0 +1,64 @@
1
+ """Evidence source: keyless news/macro feeds, per-feed tolerant.
2
+
3
+ Always exits 0 with valid JSON — a dead feed becomes a note, not a failure,
4
+ so one outage never blocks the briefing.
5
+ """
6
+
7
+ import json
8
+ import re
9
+ import urllib.request
10
+
11
+ ITEMS = []
12
+
13
+
14
+ def fetch(url, timeout=10):
15
+ req = urllib.request.Request(url, headers={"User-Agent": "caucus-evidence/1.0"})
16
+ with urllib.request.urlopen(req, timeout=timeout) as resp:
17
+ return resp.read().decode("utf-8", "replace")
18
+
19
+
20
+ def add(source, ref, content):
21
+ ITEMS.append({"source": source, "ref": str(ref), "content": str(content)[:400]})
22
+
23
+
24
+ try:
25
+ xml = fetch("https://www.federalreserve.gov/feeds/press_all.xml")
26
+ titles = re.findall(r"<title>(.*?)</title>", xml)[1:6]
27
+ dates = re.findall(r"<pubDate>(.*?)</pubDate>", xml)[:5]
28
+ for title, date in zip(titles, dates):
29
+ add("fed-press", date, title)
30
+ except Exception as err:
31
+ add("fed-press", "unavailable", "Fed press feed fetch failed: " + str(err))
32
+
33
+ try:
34
+ hn = json.loads(
35
+ fetch(
36
+ "https://hn.algolia.com/api/v1/search_by_date?query=semiconductor%20OR%20NVDA%20OR%20AI%20chips&tags=story&hitsPerPage=5"
37
+ )
38
+ )
39
+ for hit in hn.get("hits", [])[:5]:
40
+ title = str(hit.get("title"))
41
+ points = str(hit.get("points"))
42
+ add("hackernews", hit.get("created_at", ""), title + " (" + points + " pts)")
43
+ except Exception as err:
44
+ add("hackernews", "unavailable", "HN fetch failed: " + str(err))
45
+
46
+ try:
47
+ markets = json.loads(
48
+ fetch(
49
+ "https://gamma-api.polymarket.com/markets?closed=false&active=true&order=volumeNum&ascending=false&limit=30"
50
+ )
51
+ )
52
+ kept = 0
53
+ for market in markets:
54
+ question = str(market.get("question", ""))
55
+ if kept < 5 and re.search(r"fed|fomc|cpi|inflation|rate", question, re.I):
56
+ prices = str(market.get("outcomePrices"))
57
+ add("polymarket", question[:60], "active market, implied prices " + prices)
58
+ kept += 1
59
+ if kept == 0:
60
+ add("polymarket", "no-matches", "no active Fed/CPI/inflation markets in top 30 by volume")
61
+ except Exception as err:
62
+ add("polymarket", "unavailable", "Polymarket fetch failed: " + str(err))
63
+
64
+ print(json.dumps(ITEMS))
@@ -0,0 +1,24 @@
1
+ #!/bin/bash
2
+ # Headless scheduled Caucus briefing — the reference deployment's launcher.
3
+ # Adjust CAUCUS_DIR and ENVF, then schedule with cron or the launchd template.
4
+ set -uo pipefail
5
+
6
+ CAUCUS_DIR="${CAUCUS_DIR:-$HOME/caucus-live}"
7
+ ENVF="${CAUCUS_ENV_FILE:-$CAUCUS_DIR/.env}"
8
+
9
+ cd "$CAUCUS_DIR" || exit 1
10
+ export PATH="$HOME/.local/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"
11
+
12
+ # Secrets stay in an env file (never in config.yaml): the Claude Code OAuth
13
+ # token for headless runs and the SMTP credentials for the email notifier.
14
+ for var in CLAUDE_CODE_OAUTH_TOKEN GMAIL_ADDRESS GMAIL_APP_PASSWORD; do
15
+ value=$(grep -E "^${var}=" "$ENVF" 2>/dev/null | head -1 | cut -d= -f2-)
16
+ [ -n "$value" ] && export "$var"="$value"
17
+ done
18
+
19
+ mkdir -p logs
20
+ TS=$(date +%Y%m%d-%H%M)
21
+ caucus briefing >> "logs/run-${TS}.log" 2>&1
22
+ RC=$?
23
+ echo "$(date '+%Y-%m-%d %H:%M:%S') rc=${RC}" >> logs/run-history.log
24
+ exit $RC
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "caucus"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "Your AI agents, deliberating on the record. MCP-grounded multi-agent consensus with recorded dissent and an auditable decision log."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,3 +1,3 @@
1
1
  """Caucus — AI agents deliberating on the record."""
2
2
 
3
- __version__ = "0.2.1"
3
+ __version__ = "0.2.2"
@@ -34,7 +34,7 @@ wheels = [
34
34
 
35
35
  [[package]]
36
36
  name = "caucus"
37
- version = "0.2.1"
37
+ version = "0.2.2"
38
38
  source = { editable = "." }
39
39
  dependencies = [
40
40
  { name = "pyyaml" },
@@ -1,41 +0,0 @@
1
- # Trading example configuration — copy to the repository root as config.yaml.
2
- # Requires mcp.json (see mcp.example.json) for live broker grounding.
3
-
4
- log: decisions.jsonl
5
-
6
- backend:
7
- type: claude
8
- mcp_config: mcp.json
9
- # Read-only tools ONLY — this example deliberates, it never trades.
10
- allowed_tools:
11
- - mcp__robinhood-trading__get_equity_quotes
12
- - mcp__robinhood-trading__get_equity_historicals
13
- - mcp__robinhood-trading__get_portfolio
14
- - mcp__robinhood-trading__get_equity_positions
15
-
16
- panel:
17
- - name: macro
18
- charge: >-
19
- Assess the macro and market regime relevant to the question. Fetch
20
- current quotes and index levels rather than assuming; state which
21
- regime signals support or undermine the proposal.
22
- - name: momentum
23
- charge: >-
24
- Evaluate trend and momentum. Fetch recent historicals; judge the
25
- proposal against moving-average position and recent price behavior,
26
- not narrative.
27
- - name: risk-officer
28
- charge: >-
29
- Argue the downside. Quantify what a bad outcome costs given current
30
- position sizes (fetch them), concentration, and liquidity. Oppose
31
- anything that breaches prudent sizing even if the thesis is good.
32
-
33
- # The standing questions every briefing run answers ('caucus briefing').
34
- agenda:
35
- - "Given the open intents, live positions, and current prices: which intent, if any, is due for its next action today, and what exactly should be done?"
36
- - "Does current market regime or any position's behavior warrant a defensive action (hedge, trim, or pause of an intent) beyond the standing plans?"
37
-
38
- # Delivery — Gmail via an app password; the env vars hold the credentials.
39
- # notify:
40
- # type: email
41
- # to: you@example.com
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes