Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Standalone Bun project for discovering and ranking public [Kalshi](https://kalsh
- `bun install --frozen-lockfile`
- Optional secrets via [Proton Pass CLI](https://protonpass.github.io/pass-cli/) — see [`docs/PROTONPASS.md`](docs/PROTONPASS.md)
- Authorized execution operators: [`docs/AUTHORIZED_EXECUTION.md`](docs/AUTHORIZED_EXECUTION.md)
- Partner/Telegram/provider expansion map: [`docs/PARTNER-EXECUTION-EXPANSION.md`](docs/PARTNER-EXECUTION-EXPANSION.md) (`bun run partner:map`)
- Documentation hub: [GitHub Wiki](https://github.com/brendadeeznuts1111/Kalshi-bot/wiki) (index only; repository docs remain canonical)

## Quick start

Expand Down Expand Up @@ -293,6 +295,7 @@ Details: [`docs/CRON.md`](docs/CRON.md) · Bun map: [`docs/BUN_NATIVE.md`](docs/
- [`docs/PLAN.md`](docs/PLAN.md) — as-built design
- [`docs/BUN_NATIVE.md`](docs/BUN_NATIVE.md) — API map
- [`docs/BUN_SHELL.md`](docs/BUN_SHELL.md) — `Bun.$` patterns
- [`docs/PARTNER-EXECUTION-EXPANSION.md`](docs/PARTNER-EXECUTION-EXPANSION.md) — Telegram → partner authorization → Kalshi, with honest Polymarket expansion gates

## Dependency rule

Expand Down
1 change: 1 addition & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions docs/AUTHORIZED_EXECUTION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Authorized Partner Execution

Architecture map: [`PARTNER-EXECUTION-EXPANSION.md`](PARTNER-EXECUTION-EXPANSION.md) ·
CLI: `bun run partner:map`

Status: implemented, default off. This is the operator contract and runbook for the
authorization, Telegram approval, exposure reservation, Kalshi mapping, and live
HTTP orchestration layers.
Expand Down Expand Up @@ -283,3 +286,10 @@ live in
- Keep Fantasy402 unwired until provider-side idempotency is proven.
- Add credit-line or dedicated-wallet accounting only when an owned domain
contract and ledger source exist.

## See also

- [Partner execution expansion map](PARTNER-EXECUTION-EXPANSION.md)
- [Partner domain architecture](PARTNER-DOMAIN.md)
- [Demo proof schema](EXECUTION_DEMO_PROOF_SCHEMA.md)
- [Regulatory agents and Polymarket intelligence](regulatory-agents.md)
6 changes: 3 additions & 3 deletions docs/AUTHORIZED_EXECUTION_REMAINING_WORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pass.

Implementation update (2026-08-06): Waves 0–2 and the Wave 3 authoritative demo
evidence collector, deterministic failure-scenario runner, daily evidence
compiler, and seven-day chain verifier are implemented on the
authorized-execution branch: operator principals, regulatory lifecycle/sync,
compiler, and seven-day chain verifier are merged into `main`: operator
principals, regulatory lifecycle/sync,
leased reconciliation and stale recovery, full Kalshi evidence binding,
fail-closed risk health, authorized cancellation, independent workers, canonical
provider lifecycle, and the immutable journal. The collector binds
Expand Down Expand Up @@ -52,7 +52,7 @@ integration.
| W1 authenticated cancellation | closed | `executeAuthorizedCancel`, scoped credentials, current grant/risk recheck, durable intent/receipt |
| W1 stale placement/evidence | closed | stale placing recovery plus cursor-complete active/historical exact-term reconciliation |
| W1 workers/alerts | closed | independent reconcile/lifecycle/receipt jobs, Bun cron register/remove/preview, deduplicated breaker receipts |
| W2 provider lifecycle | closed | cursor-complete account order/fill ingestion and provider-positive settlement accounting |
| W2 provider lifecycle | closed | cursor-complete account order/fill ingestion, canonical provider direction, strict primary-account identity, exact minor-unit fees, and provider-positive settlement accounting |
| W2 immutable projections | closed | append-only integer journal, deterministic source keys, reversals, partner/out/skin projections and drift |
| W3 tooling | closed | authoritative demo collector, deterministic service scenarios, daily compiler, seven-day chain verifier |
| W3 elapsed graduation | **open** | seven consecutive real passing demo days and human artifact review have not elapsed |
Expand Down
7 changes: 4 additions & 3 deletions docs/BUN_NATIVE.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,12 @@ Deep dive: [`BUN_SHELL.md`](BUN_SHELL.md) (`Bun.$` patterns)
| Agent CLI | status / patterns / blueprint / tennis over `cache.db` + event-store | [`cli.ts`](../src/agent/cli.ts), [`docs/AGENT.md`](../docs/AGENT.md) |
| Kalshi live poll | `dns.prefetch` + `fetch.preconnect` + `mapPool` + `Bun.nanoseconds` | [`kalshi-network.ts`](../src/bot/kalshi-network.ts), [`live-scores.ts`](../src/institutions/event-store/live-scores.ts) |
| Tennis canary artifacts | `Bun.write` + `Bun.hash` under `research/cache/tennis-canary/` | [`live-canary-store.ts`](../src/institutions/event-store/live-canary-store.ts) |
| Tennis WS dashboard ground | `Bun.WebView` (`backend`: webkit on macOS, chrome elsewhere; `url` + `data:text/html`) + `Bun.file().image()` chain | [`tennis-ws-ground.ts`](../src/institutions/event-store/tennis-ws-ground.ts), [`tennis-ws-dashboard.ts`](../src/institutions/event-store/tennis-ws-dashboard.ts), [`tennis-book-coverage.ts`](../src/institutions/event-store/tennis-book-coverage.ts) |
| Match liquidity ground | Same WebView + Image pipeline over `match_liquidity` KPIs | [`match-liquidity-ground.ts`](../src/institutions/event-store/match-liquidity-ground.ts), [`match-liquidity-dashboard.ts`](../src/institutions/event-store/match-liquidity-dashboard.ts), `bun run liquidity:ground` · snapshot: `tools/snapshot-data-plane.ts` `liquidity` block |
| Tennis WS dashboard ground | `Bun.WebView` (`backend`: webkit on macOS, chrome elsewhere; `url` + `data:text/html`) + `Bun.file().image()` chain; persisted `snapshotMeta` uses native WebView constructor and `Bun.Image.metadata()` return types | [`tennis-ws-ground.ts`](../src/institutions/event-store/tennis-ws-ground.ts), [`visual-snapshot-meta.ts`](../src/institutions/event-store/visual-snapshot-meta.ts), [`tennis-ws-dashboard.ts`](../src/institutions/event-store/tennis-ws-dashboard.ts), [`tennis-book-coverage.ts`](../src/institutions/event-store/tennis-book-coverage.ts) |
| Match liquidity ground | Same typed WebView + Image metadata pipeline over `match_liquidity` KPIs | [`match-liquidity-ground.ts`](../src/institutions/event-store/match-liquidity-ground.ts), [`visual-snapshot-meta.ts`](../src/institutions/event-store/visual-snapshot-meta.ts), [`match-liquidity-dashboard.ts`](../src/institutions/event-store/match-liquidity-dashboard.ts), `bun run liquidity:ground` · snapshot: `tools/snapshot-data-plane.ts` `liquidity` block |
| Partner WebView CDP capture | Native `Bun.WebView.addEventListener<T>()`; a local structural adapter validates `data`/`detail` because Bun 1.3.14 exposes the documented callback event as `typeof MessageEvent` during TS resolution. No ambient `Bun` augmentation. | [`webview-ws-capture.ts`](../src/partner/webview-ws-capture.ts), [`webview-cdp-events.ts`](../src/partner/webview-cdp-events.ts), `bun run partner:webview-ws-capture` |
| Match liquidity pipeline cron | In-process `Bun.cron` + OS `export default { scheduled }` | [`match-liquidity-pipeline.ts`](../src/institutions/event-store/match-liquidity-pipeline.ts), [`match-liquidity-scheduled.ts`](../tools/match-liquidity-scheduled.ts), `cron:start` · `liquidity:pipeline:register` |
| Match liquidity db watch | `fs.watch` on **cache dir** for `event-store.db` (+ `-wal`/`-shm`) → debounced recompute + HTML ground | pure: [`match-liquidity-db-watch.ts`](../src/institutions/event-store/match-liquidity-db-watch.ts) · CLI: [`tools/match-liquidity-db-watch.ts`](../tools/match-liquidity-db-watch.ts) · `bun run liquidity:ground:watch-db` · `--once` · `--fetch-volume` |
| Kalshi WS orderbook | Bun client `WebSocket` + RSA handshake headers; JSON-only wire; official error codes 1–25; ping keepalive; reconnect jitter; `NO_PROXY` + proxy/TLS env | [`kalshi-ws.ts`](../src/bot/kalshi-ws.ts), [`kalshi-ws-errors.ts`](../src/bot/kalshi-ws-errors.ts), [`kalshi-ws-recorder.ts`](../src/institutions/event-store/kalshi-ws-recorder.ts), [`tennis-ws-recorder-store.ts`](../src/institutions/event-store/tennis-ws-recorder-store.ts) |
| Kalshi WS orderbook | Bun client `WebSocket` + RSA handshake headers; proxy/TLS types derive from `Bun.WebSocketOptions`. A local constructor cast is isolated at creation because `lib.dom` hides Bun 1.3.14's options overload during TypeScript resolution; JSON-only wire; official error codes 1–25; ping keepalive; reconnect jitter; `NO_PROXY` + proxy/TLS env | [`kalshi-ws.ts`](../src/bot/kalshi-ws.ts), [`kalshi-ws-errors.ts`](../src/bot/kalshi-ws-errors.ts), [`kalshi-ws-recorder.ts`](../src/institutions/event-store/kalshi-ws-recorder.ts), [`tennis-ws-recorder-store.ts`](../src/institutions/event-store/tennis-ws-recorder-store.ts) |
| Cadence / scoreboard tables | `Bun.inspect.table` | [`terminal-out.ts`](../src/research/terminal-out.ts), tennis CLI + `agent tennis` |
| Terminal reports | `Bun.markdown.ansi` + `Bun.wrapAnsi` | [`report-term.ts`](../src/agent/report-term.ts) |
| TTY tables + OSC 8 links | `Bun.inspect.table` + `Bun.stringWidth` / `wrapAnsi` / `stripANSI` | [`terminal-out.ts`](../src/research/terminal-out.ts) |
Expand Down
20 changes: 20 additions & 0 deletions docs/GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ Categories: `market` · `model` · `tournament` · `warehouse` · `trading` · `

Add new terms only in `GLOSSARY_ENTRIES` (ids are stable tip keys).

The partner execution flow is represented by connected canonical concepts, not
by a separate documentation-only vocabulary:

`partner.authorization.request` → `partner.authorization.grant` →
`partner.execution.gate` → `partner.execution.reservation` →
`partner.execution.provider_lifecycle` → `partner.execution.journal` →
`partner.execution.receipt`.

`provider.polymarket.intelligence_only` records the current read-only boundary;
it is deliberately linked to market-data concepts and the execution gate, but
does not represent a Polymarket order adapter. See the
[partner execution expansion map](PARTNER-EXECUTION-EXPANSION.md).

`snapshot.visual.provenance` describes the audit-only metadata emitted by the
native WebView/Image visual-ground pipeline. It records Bun version/revision,
browser backend and viewport, capture outcome, and decoded image dimensions and
format, plus artifact byte length and SHA-256 integrity. Persisted WebView/CDP
summary URLs omit query/hash credentials. It never substitutes for an executable quote, authorization, or
provider lifecycle evidence.

HQ fragment routing uses `URLPattern.hash`; patterns match the fragment without
the leading `#`. A literal colon before a named group must be escaped:
`new URLPattern({ hash: "glossary\\::concept" })`.
Expand Down
23 changes: 22 additions & 1 deletion docs/OFFICIAL_URLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Canonical external links for this repo. **Code SSOT:** [`src/institutions/official-urls.ts`](../src/institutions/official-urls.ts).

Last verified: **2026-07-31**
Last verified: **2026-08-06**

**Liveness:**

Expand Down Expand Up @@ -65,6 +65,27 @@ feeCents = ceil(rate × contracts × P × (1 − P) × 100)

Set `ODDS_API_KEY` in env for live fetches.

## Telegram

| Resource | URL | Notes |
| --- | --- | --- |
| Bot API | [core.telegram.org/bots/api](https://core.telegram.org/bots/api) | HTTP bot methods, message/topic identifiers, and request shapes |
| Bot platform introduction | [core.telegram.org/bots](https://core.telegram.org/bots) | BotFather setup and token-safety guidance |

The partner authorization boundary stores numeric chat, topic, message, and
approver IDs as validated strings and never stores the bot token in SQLite.

## Polymarket

| Resource | URL | Notes |
| --- | --- | --- |
| API introduction | [docs.polymarket.com/api-reference/introduction](https://docs.polymarket.com/api-reference/introduction) | Gamma public market/event metadata surface |
| Quickstart | [docs.polymarket.com/quickstart](https://docs.polymarket.com/quickstart) | Current public API examples |

Polymarket is currently a read-only regulatory market-intelligence source in
this repository. It is not an authorized partner execution provider; see
[`PARTNER-EXECUTION-EXPANSION.md`](PARTNER-EXECUTION-EXPANSION.md).

**Tennis coverage:** named ATP/WTA tournaments only — no Challenger/ITF sport keys. That boundary defines the two tennis program archetypes — see [`TENNIS_PROGRAM_ARCHETYPES.md`](TENNIS_PROGRAM_ARCHETYPES.md).

## Bun (runtime)
Expand Down
9 changes: 9 additions & 0 deletions docs/PARTNER-DOMAIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ the local SSOT for registry + Fantasy Ultra until a separate seat-capital
service is the only writer.

Machine status: `bun run partner:domain` · `bun run partner:domain -- --json`
Expansion map: `bun run partner:map` · [`PARTNER-EXECUTION-EXPANSION.md`](PARTNER-EXECUTION-EXPANSION.md)
Code map: [`src/partner/domain.ts`](../src/partner/domain.ts)

---
Expand Down Expand Up @@ -189,6 +190,7 @@ bun run serve
| Command | Layer |
| ----------------------------------------------------- | --------------------------------------------------------------------- |
| `partner:domain` | All (status) |
| `partner:map` | Telegram → authorization → provider expansion map (Mermaid) |
| `partner:toml` | Partner + Accounts (Bun.TOML config seed/export) |
| `partner:health` | Registry + env + risk + ledger freshness |
| `partner:desk-smoke` | Per-out secret readiness + optional signed `login()` |
Expand Down Expand Up @@ -224,6 +226,13 @@ bun run serve
| devDependencies | Reproducible CI (`typescript`, types) |
| `bunx` | One-off CLIs (`drizzle-kit`, generators) |

## See also

- [Partner execution expansion map](PARTNER-EXECUTION-EXPANSION.md)
- [Authorized partner execution](AUTHORIZED_EXECUTION.md)
- [Regulatory agents and Polymarket intelligence](regulatory-agents.md)
- [Partner/Fantasy Ultra provider boundary](PARTNER-FANTASY-ULTRA.md)

### Partners TOML (`Bun.TOML`)

Non-secret registry on disk (v1.1 TOML via Bun native parse/stringify + **Zod**
Expand Down
Loading