|
| 1 | + |
| 2 | +# TODO |
| 3 | + |
| 4 | +## 1) Security and Integrity |
| 5 | +- Enforce signature verification on every read of snapshots and ledger |
| 6 | + - storage.readIssueSnapshot: verify with verifySnapshot; reject if invalid |
| 7 | + - ledger.readLedger: already verifies; keep consistent |
| 8 | +- Add optimistic concurrency retries (seq-based) |
| 9 | + - On trade: read -> compute -> write (seq+1); re-read and compare seq; retry N times (e.g., 3) on mismatch |
| 10 | + - Apply same pattern for ledger writes |
| 11 | +- Add write receipts for partial failures |
| 12 | + - If ledger updated but market snapshot write fails, post a bot comment noting partial update and suggesting retry/reconcile |
| 13 | +- Harden snapshot block parsing |
| 14 | + - Ensure only one snapshot block exists; if multiple, prefer the first and remove extras; always re-render at top of body |
| 15 | + |
| 16 | +## 2) Permissions and Governance |
| 17 | +- Trading permissions |
| 18 | + - Restrict to repo collaborators or org members (octokit.repos.getCollaboratorPermissionLevel) |
| 19 | + - Optional: team-based allowlist via config |
| 20 | +- Conflict-of-interest flags |
| 21 | + - If commenter can close the target issue, flag their trades in comments and (optionally) cap trade size |
| 22 | +- Max exposure per user per market |
| 23 | + - Cap shares per side (e.g., 1,000) to limit manipulation |
| 24 | + |
| 25 | +## 3) Market Discovery and Metadata |
| 26 | +- Label market issues on creation |
| 27 | + - Labels: `forecast-market`, `target-issue-<n>` |
| 28 | + - Store target linkage in snapshot (already present) |
| 29 | +- Fast lookup by label |
| 30 | + - In resolution and helpers, query by labels instead of scanning titles |
| 31 | +- Support multiple markets per target |
| 32 | + - Encode `marketId` in a label (e.g., `market-id:<id>`) and in the title to disambiguate |
| 33 | + |
| 34 | +## 4) UX: Commands and Feedback |
| 35 | +- Add `/help` command listing supported commands and examples |
| 36 | +- Add `/sell yes|no <shares>` (optional) |
| 37 | + - MVP: model sell as buying the opposite side; display cost/refund at current price |
| 38 | +- Improve trade feedback |
| 39 | + - Show pre-trade and post-trade price, slippage, and remaining balance |
| 40 | +- Balance/portfolio |
| 41 | + - `/portfolio` to list all open market positions and total exposure |
| 42 | +- Leaderboard |
| 43 | + - Scheduled (GitHub Actions cron) job posts top balances to the Ledger Issue |
| 44 | + |
| 45 | +## 5) PR Integration |
| 46 | +- For PR-targeted markets, update a "Forecast" check on relevant events |
| 47 | + - On trade and on PR sync, call checks.upsertForecastCheck with latest probability |
| 48 | +- Optionally display a badge in PR description via a bot comment that updates on trades |
| 49 | + |
| 50 | +## 6) Resolution Improvements |
| 51 | +- Deadline handling |
| 52 | + - Use explicit timezone (UTC) and display local time hints |
| 53 | +- Manual override command |
| 54 | + - `/market resolve <yes|no> reason:"..."` with audit log in the market issue |
| 55 | +- Auto-resolve scheduler |
| 56 | + - GitHub Actions workflow that hits a maintenance endpoint or uses the API to scan and resolve past-deadline markets periodically |
| 57 | + |
| 58 | +## 7) Reliability and Performance |
| 59 | +- Add retry with backoff on GitHub API 5xx / rate limits |
| 60 | +- Add minimal request queueing to avoid burst writes on hot markets |
| 61 | +- Cache repo metadata (collaborator permission levels) in-memory with TTL |
| 62 | +- Paginate issue listing calls (currently per_page=100) and/or filter via labels |
| 63 | + |
| 64 | +## 8) Data Model Extensions |
| 65 | +- Record trade receipts |
| 66 | + - Append a small JSON receipt inside the market issue as a separate block or dedicated comments with a `trade-receipt` marker |
| 67 | + - Include: user, side, shares, cost, pre/post price, seq, timestamp |
| 68 | +- Transaction IDs |
| 69 | + - Include a monotonic `txId` field in comments to assist audit/reconciliation |
| 70 | + |
| 71 | +## 9) Configuration and Policy |
| 72 | +- Repo-level config via a `.ganttmarket.yml` |
| 73 | + - startingCredits, b parameter, rate limits, allowed roles/teams, max shares |
| 74 | +- Environment variables validation with human-friendly errors |
| 75 | +- Toggle features via labels (e.g., `forecast-enabled`) |
| 76 | + |
| 77 | +## 10) Testing and Tooling |
| 78 | +- Add unit tests for lmsr, parsing, and snapshot/ledger signing |
| 79 | +- Add integration tests using nock to stub GitHub API |
| 80 | +- Prettier/ESLint minimal setup for consistency |
| 81 | + |
| 82 | +## 11) Observability |
| 83 | +- Structured logging (JSON) with request IDs and event types |
| 84 | +- Optional webhook delivery logging for debugging signature/headers |
| 85 | +- Health endpoint to verify env and GitHub App configuration (without secrets) |
| 86 | + |
| 87 | +## 12) Documentation |
| 88 | +- Expand README with: |
| 89 | + - Resolution criteria and edge cases (reopen after deadline, edited titles) |
| 90 | + - Governance policies (who can trade, caps) |
| 91 | + - Security model (signed blocks, seq) |
| 92 | + - Troubleshooting guide (common webhook errors) |
| 93 | + |
| 94 | +## 13) Enterprise/Privacy Options |
| 95 | +- Redact PII in logs (only show GitHub login when necessary) |
| 96 | +- Data residency note (all state is in GitHub; no external DB) |
| 97 | +- Optional export command `/export` to produce CSV summary of markets, trades, balances |
| 98 | + |
| 99 | +## 14) Future Features |
| 100 | +- Conditional/scenario markets ("If +2 engineers, probability?") |
| 101 | +- Milestone and release markets with auto-deadlines from GitHub metadata |
| 102 | +- Slack/Teams notifications on big price moves |
| 103 | +- Visualization: tiny sparkline image rendered and posted as a comment (optional) |
0 commit comments