rspace-online/backlog/tasks/task-150 - Coalition-simula...

51 lines
1.8 KiB
Markdown

---
id: TASK-150
title: Coalition simulator UI
status: To Do
assignee: []
created_date: '2026-04-16 18:57'
labels:
- rnetwork
- governance
- power-indices
dependencies:
- TASK-144
references:
- src/encryptid/power-indices.ts
- modules/rnetwork/components/folk-graph-viewer.ts
priority: low
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Interactive coalition builder using the existing `/api/power-indices/simulate` endpoint.
## What
Let users select a group of voters and instantly see: "Can this coalition pass a vote? Who is the swing voter?" Uses the simulate endpoint already built in TASK-144.
## Primitive: Coalition Picker Component
- New `<folk-coalition-sim>` element (or inline in power panel)
- Checkbox list of top N voters (sorted by Banzhaf)
- As checkboxes toggle: POST to simulate endpoint, show result:
- ✅ "Winning coalition (67% of weight, needs 50%+1)"
- Per-member: "Alice: swing voter ⚡" / "Bob: not swing (coalition wins without them)"
- "Add 1 more voter to win" suggestion when losing
## Implementation
- Can be embedded in the power panel of `folk-graph-viewer.ts` as a collapsible section
- Or standalone `folk-coalition-sim.ts` for embedding in delegation manager
- POST `/rnetwork/api/power-indices/simulate` with `{ space, authority, coalition: [did1, did2...] }`
- Response already returns `isWinning`, `marginalContributions[].isSwing`
- ~80 lines, zero backend changes (endpoint exists)
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Checkbox selection of voters from top-N list
- [ ] #2 Live POST to simulate endpoint on selection change
- [ ] #3 Shows winning/losing status with weight vs quota
- [ ] #4 Identifies swing voters in the coalition
- [ ] #5 Suggests minimum additions to form winning coalition
<!-- AC:END -->