AI Market Dashboard project evidence
Trading Brief Eval Harness
This page explains the Neon-backed evaluation harness that checks whether an AI trading brief follows the right trading rules before the result is trusted. It is written twice: once like you are 12, and once like a technical reviewer is reading your portfolio.
Explain It Like I Am 12
The problem
An AI can sound confident even when it is wrong. In trading, a wrong "GO" or a missed risk flag can teach the wrong lesson.
The simple idea
We give the AI a quiz. Each question is a trading setup. The answer must say GO, WATCH, or PASS, plus the right score and risk words.
What Neon does
Neon is the online database. It already stores real dashboard picks, so the quiz can use real examples instead of fake ones.
What the harness does
The harness checks the answer. If the score is too low, the build should fail, like a school test that needs a passing mark.
Professional Explanation
The trading brief eval harness is a deterministic quality gate for LLM-assisted trading analysis. It converts real `AListCandidate` rows from Neon Postgres into eval cases and candidate result files, then scores verdict accuracy, Conviction Score range, setup classification, risk flags, forbidden failure modes, and rationale coverage.
The point is not to predict market outcomes. The point is to prevent regressions in the reasoning contract: a pullback should not be failed only because RVOL is low, a breakout should require volume expansion, and a parabolic chase should not be promoted as a clean GO.
Tech Stack Used
Neon Postgres
Serverless PostgreSQL database that stores the dashboard's real A-list trading rows.
Prisma
Typed database client used by the Node script to query `AListCandidate` safely.
Node.js
Runs the command-line scripts that export eval data and score it.
MJS
JavaScript module files used for Node automation scripts with modern `import` syntax.
JSON
Portable files for eval cases and results. Easy for humans and scripts to inspect.
npm + GitHub Actions
npm runs local commands. GitHub Actions can run the gate on pull requests.
Example Use Cases
| Use case | What it catches | Why it matters |
|---|---|---|
| Prompt change review | A new prompt starts calling weak setups GO. | Stops quiet quality regressions before deployment. |
| Model comparison | Claude, Gemini, DeepSeek, or OpenAI disagree on the same cases. | Lets you compare cost, latency, and quality with a score. |
| Trading-rule change | A pullback rule gets treated like a breakout rule. | Protects the wiki strategy from being accidentally reversed. |
| Portfolio evidence | "I built an AI app" with no quality proof. | Shows production AI engineering: evals, real data, and gates. |
What Is `.mjs`, and Why Use It?
What `.mjs` means
`.mjs` means "JavaScript module." It is still JavaScript, but it tells Node.js to use the modern module system where files can say `import fs from "node:fs"`.
What it is typically used for
Build scripts, command-line tools, data exporters, repo automation, and scripts that need clean imports without changing the whole project configuration.
Why not `.js` here?
A `.js` file can mean old CommonJS or modern modules depending on `package.json`. A `.mjs` file removes the guessing and always runs as a modern module.
Why it fits this project
The exporter and eval runner are Node scripts, not React UI components. `.mjs` is a clean fit for automation that imports Prisma, reads files, writes JSON, and exits.
import fs from "node:fs/promises";
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
Line-by-Line System Walkthrough
| File or command | What it does | Beginner translation |
|---|---|---|
export-neon-trading-eval.mjs | Connects to Neon with Prisma, reads `AListCandidate`, and writes generated JSON fixtures. | Take real dashboard examples out of the database and turn them into quiz questions. |
neon-golden-set.json | Stores the expected answer for each generated case. | The answer key. |
neon-results.json | Stores the baseline output being tested. | The student's answers. |
eval-trading-brief.mjs | Compares each result against the expected verdict, score range, tags, flags, and rationale. | The teacher grading the quiz. |
npm run eval:trading-brief:neon | Exports Neon rows, then immediately runs the eval gate. | Make the quiz from real data, then grade it. |
trading_brief_eval.yml | GitHub Actions workflow that can run the eval gate during code review. | A robot checker in GitHub. |
The Agentic Loop Used
This work follows the agent-loop pattern from the AI engineering wiki: reason, act, observe, then decide whether the work is done.
Validation Target
The working validation target for this project is concrete and machine-checkable:
npm run eval:trading-brief
npm run eval:trading-brief:neon
npm run build
The Neon-backed run exports 24 rows from `AListCandidate`, generates local ignored files, and checks that the aggregate score is at least 80%. The last verified result was 100% over 24 generated cases.