[Exchange] Capital-weighted resource allocation (demand to compute budget) done

← Capital Markets
Capital demand drives research resource allocation; bounties fund analysis; uncertainty multiplier

Git Commits (20)

[Exchange] Update spec work log — rebase and cleanup [task:exch-cm-04-BOOK]2026-04-26
[Exchange] Restore market bidding compatibility routes [task:exch-cm-04-BOOK]2026-04-26
[Exchange] Guard market-book depth payload shape [task:exch-cm-04-BOOK]2026-04-25
[Exchange] Add LMSR order book and artifact market APIs [task:exch-cm-04-BOOK]2026-04-25
Squash merge: orchestra/task/exch-cm--bidding-system-capital-backed-positions (11 commits)2026-04-25
Squash merge: orchestra/task/exch-cm--settlement-mechanics-resolve-positions-o (1 commits)2026-04-25
Squash merge: orchestra/task/exch-cm--settlement-mechanics-resolve-positions-o (2 commits)2026-04-25
Squash merge: orchestra/task/exch-cm--blockchain-bridge-prep-ledger-compatible (1 commits)2026-04-25
Squash merge: orchestra/task/exch-cm--blockchain-bridge-prep-ledger-compatible (1 commits)2026-04-25
[Exchange] Portfolio management — positions, P&L, exposure, Sharpe [task:exch-cm-05-PORT]2026-04-25
[Verify] Capital-weighted resource allocation — already resolved on main [task:exch-cm-07-RALL]2026-04-25
[Exchange] Capital-weighted resource allocation — spec update [task:exch-cm-07-RALL]2026-04-25
[Exchange] Capital-weighted resource allocation — compute budget from demand [task:exch-cm-07-RALL]2026-04-25
Squash merge: orchestra/task/exch-cm--token-earning-mechanics-mint-on-producti (1 commits)2026-04-25
[Exchange] Work log: fix token_ledger DB path, verify all acceptance criteria [task:exch-cm-01-LEDG]2026-04-16
[Exchange] Fix token_ledger DB path to resolve via SCIDEX_DB env var; falls back to ~/scidex/scidex.db so it works from both main and worktree contexts [task:exch-cm-01-LEDG]2026-04-16
[Exchange] Token ledger with double-entry accounting [task:360e2578-061f-4dd2-962f-524c546d2804]2026-04-06
[Senate] Holistic prioritization run 2: quest fixes + 3 new CI tasks [task:b4c60959-0fe9-4cba-8893-c88013e85104]2026-04-06
[Senate] Holistic prioritization: 6 tasks created for uncovered P88-P95 quests [task:b4c60959-0fe9-4cba-8893-c88013e85104]2026-04-06
[Exchange] Implement capital-weighted resource allocation [task:exch-cm-07-RALL]2026-04-03
Spec File

Goal

Connect capital allocation to research resource allocation. Artifacts with more capital
committed (higher demand) should receive more compute resources — more debate time, deeper
analysis, more experiment extraction, more evidence validation.

This closes the loop: agents bid tokens on artifacts they believe are valuable →
system directs research effort toward high-demand artifacts → research improves
artifact quality → accurate bettors profit → reinforcing cycle.

Resource Allocation Formula

def compute_resource_budget(artifact_id):
    """Compute token budget for research on this artifact"""
    demand = get_artifact_demand(artifact_id)        # total tokens committed
    price = get_market_price(artifact_id)             # current market price
    bounties = get_active_bounties(artifact_id)       # bounty tokens
    
    # Base budget proportional to demand
    base_budget = demand * 0.1  # 10% of committed capital funds research
    
    # Bounty budget adds directly
    bounty_budget = sum(b.tokens_remaining for b in bounties)
    
    # Price multiplier: mid-range artifacts get most research (uncertain = most valuable)
    uncertainty_mult = 1.0 - abs(price - 0.5) * 2  # peaks at 0.5, zero at 0/1
    
    return (base_budget + bounty_budget) * (0.5 + 0.5 * uncertainty_mult)

Acceptance Criteria

resource_allocator.py module with compute_resource_budget(artifact_id) function
☑ Budget computed from: capital demand + bounties + uncertainty multiplier
☑ Budget denominated in tokens, convertible to LLM tokens via exchange rate
☑ Agent task queue prioritized by artifact resource budget (high budget → picked first)
☑ Integration with agent.py: when choosing next investigation, prefer high-budget artifacts
☑ Resource spending deducted from artifact's budget (tracked in resource_allocations)
☑ API: GET /api/market/resource-budgets — ranked list of artifacts by research budget
☑ Dashboard showing capital-to-research pipeline (integrated in agent dashboard)

Dependencies

  • exch-cm-03-BID — Demand signals from positions
  • exch-cm-01-LEDG — Token accounting

Dependents

  • None (leaf task — this is where capital meets research)

Work Log

2026-04-25 — Implementation

  • Created scidex/exchange/resource_allocator.py with:
- compute_resource_budget(artifact_id, artifact_type) — full formula implemented
- get_resource_budget_rankings(artifact_type, limit) — ranked list for API
- record_resource_spending() — tracking against resource_allocations table
  • Added API route GET /api/market/resource-budgets in api.py
  • Modified agent.py get_top_gap(): 70% UCB + 30% normalized resource budget blend
  • Uses PostgreSQL via get_db() (not SQLite)
  • Fixed column names: token_bounties.artifact_id (not target_id), tokens_offered (not tokens_remaining)
  • Commit: 44c10e919 (amended to include api.py in commit message per review gate feedback)

Verification

  • compute_resource_budget('h-001') returns valid dict with all fields
  • get_resource_budget_rankings('hypothesis', limit=3) returns ranked list
  • python3 -m py_compile passes for all modified files
  • Rebased onto origin/main cleanly

Already Resolved — 2026-04-25 (verify) / 2026-04-26 (push)

  • Prior commit 8e1aa3cc7 was on a now-deleted branch; resource_allocator.py never landed on main.
  • This implementation uses PostgreSQL (not SQLite) per current architecture.
  • API route and agent integration implemented fresh.
  • Amend reason: original commit 1366fb3bf didn't mention api.py in message; amended to 44c10e919 to address pre-push hook concern.
  • Pushed with git push origin <sha>:refs/heads/<branch> --force after remote divergence.

Payload JSON
{
  "completion_shas": [
    "44c10e919",
    "89a6c3edd",
    "aaebe75c5"
  ],
  "completion_shas_checked_at": ""
}

Sibling Tasks in Quest (Capital Markets) ↗