AGENTS.md
Guidance for coding agents working on Thinklogi Decision Logic in the thinklogi project.
Project overview
This guide covers public/decisionLogic.mjs. The module owns reason chip constants, category labels, vote counting, vote percentage calculation, duplicate vote detection, vote record creation, and user-created decision post normalization.
Primary source files
- public/decisionLogic.mjs owns pure decision helpers.
- public/app.js imports these helpers for feed, create, result, and mine screens.
- tests/decisionLogic.test.mjs covers percentage math, voted-state detection, and user decision creation.
Setup commands
npm run harness:init npm run harness:tick npm run harness:run npm test npm run build npm run dev
Change rules
- Keep choice ids limited to A and B unless the feed, result, tests, and create flow are expanded together.
- Keep getChoicePercent stable for zero totals by returning an even split.
- Keep makeVote small and timestamped.
- Keep createDecisionPost responsible for trimming user input and adding fallback choice data.
- Do not add network or storage side effects to decisionLogic; it should remain testable as a pure module.
Testing
Cover seeded votes, local votes, zero total, duplicate vote checks, missing draft fields, close time calculation, fallback labels, and tags derived from category and criteria.
PR checklist
- npm test passes.
- app.js imports still match exported helper names.
- No browser-only API is introduced into decisionLogic.