{"id":50300483,"url":"https://github.com/kantegger/mast","last_synced_at":"2026-05-28T12:34:21.669Z","repository":{"id":355090721,"uuid":"1226725911","full_name":"kantegger/mast","owner":"kantegger","description":"Make deviation harder. A behavior-constraint system for investment judgment.","archived":false,"fork":false,"pushed_at":"2026-05-01T19:14:42.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-01T21:23:18.479Z","etag":null,"topics":["audit","behavioral-finance","decision-making","discipline","investment","nextjs","pre-commitment","prisma","sqlite","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kantegger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"docs/roadmap.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-05-01T19:00:29.000Z","updated_at":"2026-05-01T19:14:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kantegger/mast","commit_stats":null,"previous_names":["kantegger/mast"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/kantegger/mast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kantegger%2Fmast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kantegger%2Fmast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kantegger%2Fmast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kantegger%2Fmast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kantegger","download_url":"https://codeload.github.com/kantegger/mast/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kantegger%2Fmast/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33609237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audit","behavioral-finance","decision-making","discipline","investment","nextjs","pre-commitment","prisma","sqlite","typescript"],"created_at":"2026-05-28T12:34:21.599Z","updated_at":"2026-05-28T12:34:21.662Z","avatar_url":"https://github.com/kantegger.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mast\n\n## 投资判断审计\n\n**Make deviation harder.**\n\nMast is a behavior-constraint system for investment judgment.\n\nIt does not give buy/sell advice, predict markets, or optimize returns. It helps you bind yourself to a thesis, make deviations visible, and add friction before your future self rewrites the story.\n\nThe name is from the Ulysses metaphor — tying yourself to the mast so you can hear the sirens without acting on them. The V3.1 spine implemented here is exactly that, applied to investment judgment.\n\nThe original spec (V3) was an audit ledger — *record what you deviated*. V3.1 is an operating system with brakes — *make deviation harder*. The full spec lives in [`docs/`](docs/).\n\n---\n\n## What's actually here\n\nA Next.js + Prisma + SQLite app organised around three constructs:\n\n**TradeGate** — every trade flows through one ordered rule pipeline. First non-null decision wins:\n\n```text\nDiscipline → OverrideFlow → Path → Trigger → ThesisStatus\n```\n\nDiscipline runs first so its blocks are non-overrideable. OverrideFlow runs second so a confirmed flow can short-circuit Path/Trigger/ThesisStatus blocks but cannot bypass Discipline.\n\n**OverrideFlow** — multi-stage friction state machine for trades the gate would block:\n\n```text\nreason ≥30 chars  →  cooldown (low 0s / medium 300s / high 900s)  →  second confirm  →  execute\n```\n\nCooldowns multiply ×2 when discipline score \u003c 60 and ×4 when \u003c 40. Each stage is a separate API call; conditional `updateMany where: { id, status: \u003cexpected\u003e }` closes TOCTOU.\n\n**ViewPnLFlow** — symmetric friction for *seeing* P\u0026L. The user types the current price themselves (no fake market feed); unlock holds for 60 seconds, then auto-expires on next read.\n\n**Behavior signals** feed back automatically:\n\n- gated trades → `unplanned_trade` deviation\n- opening attempts blocked before a Position exists → `unplanned_trade` (with null `tradeId`/`positionId`)\n- exit executed before any path exit trigger fired → `early_exit` deviation\n- self-tagged `emotional` / `no_action` via `POST /api/deviation`\n\nDiscipline score = `100 − Σ(weighted deviations)` over the last 30 days. Drives the dashboard, the `buy`-without-positionId block, and the override cooldown multiplier.\n\n**Auto Exit Trigger** — when a Variable update flips its Thesis to `broken` (core variable invalid, or any variable with `aiBreakRisk: high`, or literal `up↔down` reversal of an `assumedDir`), the system auto-inserts a `priority=1000` Exit Trigger on every open Position's path. ThesisStatusRule then permits only `reduce`/`exit`/`sell` on that thesis.\n\n---\n\n## Stack\n\n- **Next.js 16** (App Router) + **React 19**\n- **Prisma 7** + **SQLite** via `@prisma/adapter-better-sqlite3`\n- **Vitest** for unit tests\n- **Tailwind 4**\n\n---\n\n## Setup\n\n```bash\nnpm install\nnpx prisma generate\nnpx prisma migrate dev\nnpm run dev          # http://localhost:3000\n```\n\nOptional demo data (idempotent; only touches rows whose thesis name starts with `DEMO:`):\n\n```bash\ncurl -X POST http://localhost:3000/api/dev/seed\n```\n\n---\n\n## Commands\n\n```bash\nnpm run dev          # dev server\nnpm test             # Vitest\nnpm run lint         # ESLint\nnpx tsc --noEmit     # typecheck\nnpm run build        # production build\n```\n\n---\n\n## Project structure\n\n```text\napp/\n  api/\n    trade/                   POST → runs through TradeGate\n    override-flow/           create / [id]/confirm / [id]/abort\n    view-pnl-flow/           create / [id]/confirm / [id]/pnl\n    variables/[id]/          PATCH → triggers thesis transition\n    deviation/               POST manual deviations\n    dev/seed/                idempotent demo data\n  positions/                 de-financialized position list + view-pnl page\n  dashboard/                 Discipline · By-Type · Trends · Heatmap · Patterns\nlib/\n  trade-gate/                rule pipeline + 5 rules\n  thesis/                    nextThesisStatus + auto-exit-trigger insertion\n  path-step/                 nextPathStepStatus\n  discipline/                score / weights / dashboard helpers\n  view-pnl-flow.ts           P\u0026L math + unlock helpers\n  api-hardening.ts           Prisma error detection\nprisma/\n  schema.prisma\n  migrations/\ndocs/\n  spec v3.1.docx             current spec\n  spec v3.docx               historical\n```\n\n---\n\n## Non-goals (spec §8)\n\n- No buy/sell recommendations\n- No market prediction\n- No return optimisation\n\nThese are hard project boundaries. Any feature that crosses them belongs in a different project.\n\n---\n\n## Status\n\nV3.1 spine is complete and runs without any AI keys. The only environment variable is `DATABASE_URL`. The TradeGate is a deterministic rule pipeline; DisciplineScore is a weighted aggregation; Pattern Detection is a database aggregation; Thesis/PathStep/OverrideFlow/ViewPnLFlow are deterministic state machines. Nothing here calls an LLM.\n\nThe only spec section not implemented is **§7 Behavior Stability** — the spec names the metric but does not numerically define it. Deferred deliberately.\n\nForward plans (Management UI, Behavior Stability, **V3.2 candidate: AI integration at four specific seams**) are scoped in [`docs/roadmap.md`](docs/roadmap.md).\n\n---\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkantegger%2Fmast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkantegger%2Fmast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkantegger%2Fmast/lists"}