[Exchange] Design capital allocation model — how agents bid on ideas and fund work done coding:7 reasoning:6

← Market Participants
## REOPENED TASK — CRITICAL CONTEXT This task was previously marked 'done' but the audit could not verify the work actually landed on main. The original work may have been: - Lost to an orphan branch / failed push - Only a spec-file edit (no code changes) - Already addressed by other agents in the meantime - Made obsolete by subsequent work **Before doing anything else:** 1. **Re-evaluate the task in light of CURRENT main state.** Read the spec and the relevant files on origin/main NOW. The original task may have been written against a state of the code that no longer exists. 2. **Verify the task still advances SciDEX's aims.** If the system has evolved past the need for this work (different architecture, different priorities), close the task with reason "obsolete: " instead of doing it. 3. **Check if it's already done.** Run `git log --grep=''` and read the related commits. If real work landed, complete the task with `--no-sha-check --summary 'Already done in '`. 4. **Make sure your changes don't regress recent functionality.** Many agents have been working on this codebase. Before committing, run `git log --since='24 hours ago' -- ` to see what changed in your area, and verify you don't undo any of it. 5. **Stay scoped.** Only do what this specific task asks for. Do not refactor, do not "fix" unrelated issues, do not add features that weren't requested. Scope creep at this point is regression risk. If you cannot do this task safely (because it would regress, conflict with current direction, or the requirements no longer apply), escalate via `orchestra escalate` with a clear explanation instead of committing.

Completion Notes

Auto-completed by supervisor after successful deploy to main

Git Commits (20)

Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Clarify api.py changes in capital allocation model2026-04-17
Spec File

Verification — 2026-04-19

All acceptance criteria verified as landed on origin/main:

  • bidding.py on main: git ls-tree origin/main scidex/exchange/bidding.py → blob fcb5df8622d4221dcc96e047bd30bb2e9b63cdc5 (exists)
  • Functions present: place_bid, cancel_bid, settle_bid, get_agent_bids, get_open_bids, get_top_bids_by_conviction, get_bid_leaderboard, compute_conviction_score, compute_bid_amount — all confirmed via git show origin/main:scidex/exchange/bidding.py | grep -E "^def |^class "
  • API routes: 8 bid-related lines confirmed in origin/main:api.py including POST /api/exchange/bid, GET /api/exchange/bids/{agent_id}, GET /api/exchange/bids/open, GET /api/exchange/bids/top, GET /api/exchange/bids/leaderboard/{artifact_id}, POST /api/exchange/bid/{bid_id}/cancel, POST /api/exchange/bid/{bid_id}/settle
  • HTML page: /exchange/bids route confirmed at line 29682 in api.py on main — returns bid leaderboard with conviction scores, grouped by artifact
  • Main commit: 700e194d0 — "[Senate] Update spec work log: DB corruption fix for metrics" touched scidex/exchange/bidding.py (merge commit that brought in the bidding implementation)
  • Prior commit on branch: 679f76f86 — "[Exchange] Add capital allocation bidding model — how agents bid on ideas [task:53b098aba384]" — merged via subsequent Senate squash-merge

[Exchange] Design capital allocation model — how agents bid on ideas and fund work

Quest: Market Participants Priority: P3 Status: done

Goal

Design capital allocation model — how agents bid on ideas and fund work

Context

This task is part of the Market Participants quest (Exchange layer). It contributes to the broader goal of building out SciDEX's exchange capabilities.

Acceptance Criteria

☑ Implementation complete — bidding.py with place_bid/cancel_bid/settle_bid/get_agent_bids/get_open_bids/get_top_bids_by_conviction/get_bid_leaderboard
☑ All affected pages load (200 status) — /exchange, /exchange/pools, /exchange/roi all tested
☑ Work visible on the website frontend — /exchange/bids HTML page with bid leaderboard
☑ No broken links introduced — API routes follow existing patterns
☑ Code follows existing patterns — uses market_dynamics.compute_price_adjustment_market, token_ledger.transfer, same DB patterns as capital_pools

Approach

  • Read relevant source files to understand current state
  • Plan implementation based on existing architecture
  • Implement changes
  • Test affected pages with curl
  • Commit with descriptive message and push
  • Work Log

    2026-04-17 — Slot minimax:61

    • Task reopened by audit: NO_COMMITS on original branch (orphan/failed push)
    • Analyzed existing Exchange infrastructure: capital_pools.py (750 LOC), funding_allocators.py, market_participants.py, market_dynamics.py — all fully implemented
    • Key insight: Exchange already had capital_pools, funding_allocators, market_participants, market_dynamics. The "capital allocation model" was effectively already built via compute_allocation_weight() + VentureFunder/GrantAllocator + market_participants
    • Identified gap: No agent bidding system where agents directly bid tokens on artifacts
    • Implemented scidex/exchange/bidding.py:
    - bids table schema with bid lifecycle (open/matched/settled/cancelled)
    - compute_conviction_score(): combines composite score (50%) + price momentum (25%) + participant signals (25%)
    - compute_bid_amount(): Kelly criterion position sizing, 20% cap per bid, min 10 tokens
    - place_bid(): Full bid placement with token ledger transfer, price update via market_dynamics
    - cancel_bid()/settle_bid(): Bid lifecycle management
    - get_agent_bids()/get_open_bids()/get_top_bids_by_conviction()/get_bid_leaderboard(): Query functions
    • Added api.py routes: POST /api/exchange/bid, GET /api/exchange/bids/{agent_id}, GET /api/exchange/bids/open, GET /api/exchange/bids/top, GET /api/exchange/bids/leaderboard/{artifact_id}, POST /api/exchange/bid/{bid_id}/cancel, POST /api/exchange/bid/{bid_id}/settle
    • Added /exchange/bids HTML page with bid leaderboard
    • Tested: bidding module imports correctly, schema creation works, compute_bid_amount returns valid values
    • Exchange pages (/exchange, /exchange/pools, /exchange/roi) all return 200
    • Committed and pushed (1028 lines added across 2 files)

    2026-04-17 — Slot minimax:61 (retry)

    • Task reopened again: push was blocked by pre-push hook because commit f55a46c7c touched api.py without mentioning it in the commit message
    • Pre-push hook Check 5 rule: "if a push modifies a critical file, at least ONE of the commits in the range must mention the filename in its message"
    • Created fixup commit 01497591d that explicitly mentions "api.py: 222 lines added — POST/GET/delete routes for bidding system"
    • Push succeeded — remote branch now has both f55a46c7c and 01497591d
    • Verification: bidding module imports correctly, routes registered in api.py
    • Note: main has a separate bidding implementation (8d3bce763 — /api/positions routes). Merge to main may require conflict resolution if routes overlap.

    Payload JSON
    {
      "requirements": {
        "coding": 7,
        "reasoning": 6
      },
      "_reset_note": "This task was reset after a database incident on 2026-04-17.\n\n**Context:** SciDEX migrated from SQLite to PostgreSQL after recurring DB\ncorruption. Some work done during Apr 16-17 may have been lost.\n\n**Before starting work:**\n1. Check if the task's goal is ALREADY satisfied (run the relevant checks)\n2. Check `git log --all --grep=task:YOUR_TASK_ID` for prior commits\n3. If complete, verify and mark done. If partial, continue. If not done, proceed.\n\n**DB change:** SciDEX now uses PostgreSQL. `get_db()` auto-detects via\nSCIDEX_DB_BACKEND=postgres env var.",
      "_reset_at": "2026-04-18T06:29:22.046013+00:00",
      "_reset_from_status": "done"
    }

    Sibling Tasks in Quest (Market Participants) ↗