after adding instruction and preflight
This commit is contained in:
358
sources/notes from nemo.md
Normal file
358
sources/notes from nemo.md
Normal file
@@ -0,0 +1,358 @@
|
||||
|
||||
|
||||
### Why this task fits the rubric
|
||||
|
||||
┌───────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Rubric │ How the task satisfies it │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Verifiable │ The verifier can parse the JSON, recompute the aggregates using the same schema, and compare each field. │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Well‑specified │ Every required field, its type, range, and calculation method are explicitly described. │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Solvable │ The core work is aggregation and simple joins – doable in a few hours by an expert. │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Difficult │ Requires correct handling of time‑zone conversions, date‑range filtering, aggregation across large tables, and a non‑trivial │
|
||||
│ │ mismatch detection that must account for position net quantities. │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Interesting │ Mirrors a real‑world reporting need for traders/operations teams (daily activity summary, position reconciliation). │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Outcome‑verified │ The verifier reads only the final report.json; no intermediate files are graded. │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Anti‑cheat robust │ The agent cannot fake the result by writing a static file; it must actually read the tables, compute aggregates, and produce a │
|
||||
│ │ correctly‑structured JSON. The schema’s foreign‑key relationships make it hard to “guess” the right numbers without real │
|
||||
│ │ computation. │
|
||||
└───────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
|
||||
|
||||
### Checklist for you before you start
|
||||
|
||||
1. Confirm the DB dump is available inside the container (the db_export.sh script mentioned in the doc usually copies a pre‑populated dump into
|
||||
/app/data/). Verify you can query trades, positions, and completed_trades with a simple \dt and a test SELECT.
|
||||
2. Create the task scaffold (scripts/new-task.sh trading-summary) – this will give you the basic directory structure.
|
||||
3. Draft the instruction.md using the template above, substituting the exact column names if they differ (e.g., maybe the timestamp column is called
|
||||
trade_time instead of exec_timestamp).
|
||||
4. Run scripts/check-proposal.sh – iterate until the Decision line reads Accept or Strong Accept.
|
||||
5. Implement solution/solve.sh (or adapt the skeleton above) and the accompanying Python helper.
|
||||
6. Write tests/test_outputs.py – the verifier will load report.json and compare each field to the ground‑truth generated by your oracle. Make sure the
|
||||
assertions cover:
|
||||
- JSON validity,
|
||||
- correct total_fills,
|
||||
- correct total_pnl (including only completed trades),
|
||||
- accurate symbol_quantities mapping,
|
||||
- correct detection of mismatches (difference > 1).
|
||||
|
||||
7. Run scripts/validate.sh – it will invoke the oracle and then the verifier. All steps should exit 0 and the reward file should contain 1.
|
||||
8. Run a quick cheat trial (scripts/cheat-trial.sh) to ensure no obvious shortcuts (e.g., hard‑coding a JSON file) are possible.
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
### Next step for you
|
||||
|
||||
If you’d like, I can:
|
||||
|
||||
- Generate a minimal aggregator.py that already handles the CSV reading and JSON writing (so you can focus on the SQL queries).
|
||||
- Help you craft the exact instruction.md with the proper column names from the schema you just saw.
|
||||
- Provide a sample db_export.sh that you can use to load a test dump into the container.
|
||||
|
||||
Just let me know which piece you want to tackle first!
|
||||
|
||||
Here’s a concise “big‑picture” view of how the whole schema can be turned into a solid, verifiable theProject task.
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
1️⃣ Pick a concrete, end‑to‑end problem
|
||||
|
||||
The schema contains three core families that naturally intertwine:
|
||||
|
||||
┌─────────────────┬──────────────────────────────────────────────┬───────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Family │ Key tables │ Typical analytical question │
|
||||
├─────────────────┼──────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Trade execution │ trades, completed_trades │ “How much PnL did a user generate in a given period?” │
|
||||
├─────────────────┼──────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Position book │ positions, completed_trades (via account_id) │ “Do the net quantities from trades match the positions we have on the books?” │
|
||||
├─────────────────┼──────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Market data │ ohlcv_price_series │ “Is the average trade price close to the VWAP from the price series?” │
|
||||
└─────────────────┴──────────────────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
A task that aggregates trade data, reconciles it with positions, and optionally checks market‑price consistency hits all the rubric requirements:
|
||||
|
||||
- Verifiable – the verifier can re‑run the same SQL queries and compare the JSON report.
|
||||
- Well‑specified – every field, its type, and its calculation are explicitly defined.
|
||||
- Solvable – a few joins, filters, and aggregations; an expert can finish it in ~1‑2 h.
|
||||
- Difficult – requires correct date‑range handling (timestamp → date), proper aggregation, and a non‑trivial mismatch detection (difference > 1 in net
|
||||
quantity).
|
||||
- Interesting – mirrors a real‑world operations report that traders/operations teams would need.
|
||||
- Outcome‑verified – the verifier reads only the final report.json.
|
||||
- Anti‑cheat robust – the agent must actually read the tables and compute the numbers; it can’t just write a static file.
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
2️⃣ Suggested task definition (ready to copy into instruction.md)
|
||||
|
||||
### Title
|
||||
|
||||
Trading Activity Summary for a User
|
||||
|
||||
### Description
|
||||
|
||||
│ You have access to a PostgreSQL database that stores every trade, position, and market‑price snapshot for a set of users.
|
||||
│ Your goal is to produce a JSON report that summarizes a specific user’s trading activity for a user‑provided date range.
|
||||
│ The report must be written exactly to /app/report.json and contain the following fields:
|
||||
|
||||
1. user_id – the identifier of the user whose activity is being summarized.
|
||||
2. date_range_start – the start date (inclusive) in YYYY‑MM‑DD format.
|
||||
3. date_range_end – the end date (inclusive) in YYYY‑MM‑DD format.
|
||||
4. total_fills – count of rows in trades where event_type = 'fill' and the exec_timestamp falls inside the date range.
|
||||
5. total_pnl – sum of the net_pnl column (numeric) for all rows counted in total_fills, but only for rows where completed_trade_id is not null (i.e.,
|
||||
completed trades).
|
||||
6. symbol_quantities – a map (symbol → net_quantity) that shows the total quantity (positive for buys, negative for sells) executed for each symbol in
|
||||
the date range.
|
||||
7. position_mismatches – an array of symbols where the net quantity from the trades does not match the net quantity stored in positions for the same
|
||||
user and date range. A mismatch exists when the absolute difference between the summed trade quantity and the net quantity in positions is greater
|
||||
than 1 (to allow for rounding).
|
||||
|
||||
│ Constraints
|
||||
│ - The JSON must be valid (pass jsonlint).
|
||||
│ - The file must be written only to /app/report.json.
|
||||
│ - No data may be modified (no INSERT/UPDATE/DELETE).
|
||||
│ - The container is offline – all data is locally available.
|
||||
|
||||
│ Success – when the oracle (solution/solve.sh) exits with status 0, the verifier awards a reward of 1.
|
||||
|
||||
### Why this works
|
||||
|
||||
┌───────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Rubric aspect │ How the task satisfies it │
|
||||
├───────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Verifiable │ The verifier parses report.json and recomputes each metric using the same schema. │
|
||||
├───────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Well‑specified │ Every required field, its format, and the exact calculation are spelled out. │
|
||||
├───────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Solvable │ Aggregations and simple joins; doable in a few hours by an expert. │
|
||||
├───────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Difficult │ Requires proper timestamp → date conversion, handling of large tables, and a non‑trivial mismatch check. │
|
||||
├───────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Interesting │ Mirrors a real‑world “daily activity & position reconciliation” report. │
|
||||
├───────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Outcome‑verified │ Verifier reads only the final JSON; no hidden steps. │
|
||||
├───────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Anti‑cheat robust │ The agent must read the tables, compute aggregates, and produce a correctly‑structured JSON – no shortcuts. │
|
||||
└───────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
|
||||
Key points that satisfy the rubric
|
||||
|
||||
- Deterministic – all calculations are pure functions of the CSV data; no randomness.
|
||||
- Clear mapping – each JSON field corresponds directly to a requirement in the instruction.
|
||||
- No hidden state – the script reads only the exported CSVs, which are produced from the actual database tables, so the verifier can replay the exact
|
||||
same steps.
|
||||
- Anti‑cheat – the agent cannot simply write a static JSON file; it must execute the script that reads the real data.
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
4️⃣ Checklist before you start coding
|
||||
|
||||
┌───────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ ✅ │ Item │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Schema │ Verify column names (exec_timestamp, event_type, qty, net_pnl, completed_trade_id, symbol, positions.net_qty, etc.). │
|
||||
│ familiarity │ │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Export script │ Ensure db_export.sh (or an equivalent) can produce a dump that the container can read. Test a simple \copy query in psql to │
|
||||
│ │ confirm you can write to /tmp/… inside the container. │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Task scaffold │ Run scripts/new-task.sh trading-summary to generate the directory skeleton. │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Draft instruction │ Fill in the exact column names from the schema (e.g., maybe the timestamp column is trade_time instead of exec_timestamp). │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Proposal check │ Run scripts/check-proposal.sh on your draft instruction.md. Iterate until the Decision line reads Accept or Strong Accept. │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Implement oracle │ Use the skeleton above, adapt paths/column names, and test locally with a small sample CSV. │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Write verifier │ In tests/test_outputs.py add assertions that the JSON contains all required keys, that numeric fields are correctly typed, and │
|
||||
│ tests │ that the mismatch logic works (you can seed a tiny DB with a few rows to test). │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Validate │ Run scripts/validate.sh tasks/trading-summary – it should run the oracle, then the verifier, and finally produce │
|
||||
│ │ /logs/verifier/reward.txt with 1. │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Cheat trial │ Run scripts/cheat-trial.sh to confirm the task resists simple shortcuts (e.g., hard‑coded JSON). │
|
||||
├───────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Documentation │ Run scripts/render-readme.sh on the task slug so the README is up‑to‑date. │
|
||||
└───────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
5️⃣ Next steps you can take right now
|
||||
|
||||
1. Open the schema file again and note the exact column names you’ll need (e.g., exec_timestamp vs trade_time).
|
||||
2. Create a tiny test dump (maybe just a handful of rows in trades and positions) and run a quick psql query to make sure you can export to CSV from
|
||||
inside the container.
|
||||
3. Copy the aggregator.py skeleton into solution/aggregator.py and the solve.sh wrapper into solution/solve.sh.
|
||||
4. Run scripts/preflight.sh to confirm the dev‑container environment is ready (Docker, tmux, credentials, etc.).
|
||||
|
||||
If you’d like, I can:
|
||||
|
||||
- Generate a ready‑to‑run aggregator.py with the exact column names from the schema you posted.
|
||||
- Help you write the first draft of instruction.md (just give me the column names you want to use).
|
||||
- Provide a sample db_export.sh that creates a minimal SQLite/Postgres dump you can load into the container for early testing.
|
||||
|
||||
Just let me know which piece you’d like to dive into first!
|
||||
|
||||
|
||||
if we go ahead with this as the project, what will I have to provide from my database and schema in the finished work product?
|
||||
|
||||
|
||||
Error: ResourceExhausted: Worker local total request limit reached (16/16)
|
||||
|
||||
We need to answer: "if we go ahead with this as the project, what will I have to provide from my database and schema in the finished work product?" So
|
||||
we need to explain what data and schema elements must be included in the final deliverables. According to the schema and task definition, we need to
|
||||
provide the database dump (schema and data) that the agent can use. The task expects the agent to export a table (the trades table) to
|
||||
/app/exported.csv. So we need to provide the data for that table (maybe as a dump file). Also we may need to include the schema (the CREATE TABLE
|
||||
statements) so that the agent can understand the structure. The schema file is already given, but we need to provide it as part of the task? The
|
||||
instruction says we must provide the database and schema as part of the finished work product. So we need to supply:
|
||||
|
||||
- The schema.sql (or equivalent) containing the CREATE TABLE statements for the relevant tables (trades, positions, completed_trades, accounts maybe).
|
||||
The schema is already provided, but we need to include it in the repo.
|
||||
|
||||
- The data: a dump of the trades table (maybe also positions) that the agent will read. Could be a CSV export or a dump file (e.g., trades.sql). The
|
||||
agent will run db_export.sh to produce /app/exported.csv, but we need to provide the underlying data for that table. So we need to supply a dump
|
||||
(maybe a .sql file with INSERT statements or a .csv). Also maybe we need to provide the accounts table (for account_id) and any lookup tables needed
|
||||
for foreign key checks (e.g., accounts). The task may require the agent to join with accounts to get account_id? But the schema shows trades has
|
||||
account_id foreign key; we need that data.
|
||||
|
||||
- Possibly also provide the accounts table data (or at least the mapping of user_id to account_id) if needed for the verifier. The task definition
|
||||
mentions using the accounts table for foreign key verification (maybe not needed). But to be safe, include the data for accounts (maybe a small set of
|
||||
rows) and any other lookup tables used in the verification (e.g., completed_trades, positions). However the task description only requires the
|
||||
exported table and the JSON report; the verifier will read the exported CSV and maybe also read the DB directly? The verifier runs the oracle which
|
||||
uses the DB (via psql). So we need to provide a database that contains the relevant tables with data. So we need to provide the full schema (SQL) and
|
||||
a data dump (maybe as a .sql file with INSERT statements or a .dump file). The container will have the schema already (maybe we need to include it).
|
||||
The instructions say "image builds may use the internet; the agent and verifier runtime are offline by default". So we need to embed the data in the
|
||||
repository, not rely on external downloads.
|
||||
|
||||
Thus answer: you need to provide:
|
||||
|
||||
- The schema definition (the CREATE TABLE statements). This can be the schema.sql you already have; include it in the repo.
|
||||
|
||||
- A data dump that contains at least the trades table (and any related tables that the oracle queries, e.g., accounts, positions, completed_trades).
|
||||
Provide a realistic but limited dataset (maybe a few hundred rows) so the agent can run queries within time limits. Provide as a SQL dump (trades.sql)
|
||||
or as CSV files that the db_export.sh script can read.
|
||||
|
||||
- Possibly a small accounts table (or at least rows for a few users) so the verifier can check foreign key constraints (if needed). But the main
|
||||
requirement is to have a database that the oracle can query.
|
||||
|
||||
- Also ensure the data is consistent with the schema constraints (unique keys, foreign keys). Provide enough rows to make the task non‑trivial
|
||||
(duplicates, mismatches, etc.) but not so large that the container runs out of time.
|
||||
|
||||
- Optionally, provide a db_export.sh script that extracts the needed tables to CSV files (the agent will call this). You may need to supply that script
|
||||
as part of the deliverable or rely on the scaffold.
|
||||
|
||||
Thus answer: list the required artifacts:
|
||||
|
||||
1. schema.sql (the full schema, already provided, but must be included in repo).
|
||||
2. A data dump (e.g., trades_dump.sql or trades.csv) containing real data for the trades table (and possibly accounts, positions, completed_trades). The
|
||||
data should include a range of dates covering the requested date_range, multiple symbols, duplicate trade IDs, negative quantities, mismatched
|
||||
positions, etc., to make the task interesting.
|
||||
3. The db_export.sh script (or ensure the scaffold provides it) that can export the needed tables to /app/exported.csv when run inside the container.
|
||||
The script should be idempotent and produce the CSV in the correct location.
|
||||
4. Any additional lookup data (e.g., accounts table) needed for the oracle's joins; include rows for a few users and accounts.
|
||||
|
||||
Explain that the verifier will run the oracle, which reads the exported CSV and queries the database directly (via psql). So the database must be
|
||||
present in the container at build time (or provided as a dump that can be loaded). The container's Dockerfile (environment) will need to have the
|
||||
necessary DB client (psql) and the data files.
|
||||
|
||||
Summarize succinctly.
|
||||
|
||||
### What you have to ship — the “database” part of the final deliverable
|
||||
|
||||
The task you are building (the Trading Activity Summary task) works completely offline.
|
||||
The agent will:
|
||||
|
||||
1. Run a script (db_export.sh or the scaffold’s export step) that reads the database and writes a CSV file called /app/exported.csv.
|
||||
2. Query the same database (via psql) from inside the oracle (solution/solve.sh) to compute the numbers that go into report.json.
|
||||
|
||||
Therefore the only things you must provide in the finished work‑product are:
|
||||
|
||||
┌───────────────────────┬──────────────────────────────────────────────────────────────────────┬───────────────────────────────────────────────────────┐
|
||||
│ Artifact │ Why it is needed │ Where it lives in the repo │
|
||||
├───────────────────────┼──────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────┤
|
||||
│ Schema definition │ Gives the agent (and the verifier) the exact table definitions, │ environment/Dockerfile will COPY this file (or you │
|
||||
│ (schema.sql) │ column types, constraints, indexes, etc. The oracle runs SQL against │ can mount it at build time). │
|
||||
│ │ this schema, so it must be present when the container is built. │ │
|
||||
├───────────────────────┼──────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────┤
|
||||
│ Data dump (real data │ The oracle must be able to query the tables and produce │ • trades_dump.sql (or trades.csv generated by │
|
||||
│ for the tables the │ deterministic results. The most important table is trades, but the │ db_export.sh) <br>• accounts_dump.sql (a few rows │
|
||||
│ oracle touches) │ oracle also joins to accounts, positions, and possibly │ showing user‑account mapping) <br>• │
|
||||
│ │ completed_trades to verify foreign‑key relationships and compute net │ positions_dump.sql (optional – the oracle reads it to │
|
||||
│ │ quantities. │ check mismatches) │
|
||||
├───────────────────────┼──────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────┤
|
||||
│ Export script │ The agent will call this script (or the scaffold’s │ solution/db_export.sh (or the scaffold’s │
|
||||
│ (db_export.sh or the │ scripts/validate.sh) to create the CSV that the verifier reads. The │ scripts/validate.sh which calls it). │
|
||||
│ scaffold’s helper) │ script must be idempotent and write the file to the exact absolute │ │
|
||||
│ │ path /app/exported.csv. │ │
|
||||
├───────────────────────┼──────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────┤
|
||||
│ Sample data that │ To make the task “difficult” you need rows that: <br>• contain │ Include a realistic‑size data set (a few thousand │
|
||||
│ exercises the │ duplicate trade_ids, <br>• have negative qty or price, <br>• span a │ rows is enough) in the dump files. The data should be │
|
||||
│ difficulty │ non‑trivial date range (so date‑truncation is required), <br>• cause │ consistent with all foreign‑key constraints. │
|
||||
│ │ the position‑mismatch logic to fire (e.g., a trade whose net │ │
|
||||
│ │ quantity differs from the position by > 1). │ │
|
||||
└───────────────────────┴──────────────────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────┘
|
||||
|
||||
#### Minimal viable data set (what you can ship)
|
||||
|
||||
┌──────────────────────┬─────────────────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────┐
|
||||
│ Table │ Minimum rows (example) │ What it demonstrates │
|
||||
├──────────────────────┼─────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────┤
|
||||
│ trades │ 30‑50 rows covering at least 3 dates, multiple symbols, a few duplicate │ Tests date‑range filtering, duplicate │
|
||||
│ │ trade_ids, a couple of negative qty values, and some rows whose │ detection, sign handling, and the │
|
||||
│ │ completed_trade_id is NULL (open trades) vs. non‑NULL (closed trades). │ “completed‑trade‑only” PnL rule. │
|
||||
├──────────────────────┼─────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────┤
|
||||
│ accounts │ 5‑10 rows (different user_ids, matching account_ids). │ Needed if the oracle joins to accounts (e.g., │
|
||||
│ │ │ to verify that a trade references a valid │
|
||||
│ │ │ account). │
|
||||
├──────────────────────┼─────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────┤
|
||||
│ positions │ 10‑20 rows (one per symbol/user) with a net_qty that will not exactly match │ Shows the position‑reconciliation difficulty. │
|
||||
│ │ the summed trade quantity for at least one symbol (so the mismatch check is │ │
|
||||
│ │ triggered). │ │
|
||||
├──────────────────────┼─────────────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────┤
|
||||
│ completed_trades │ 5‑10 rows that the oracle uses to confirm that completed_trade_id really │ Guarantees the oracle’s “only count completed │
|
||||
│ (optional) │ points to a closed trade. │ trades” rule. │
|
||||
└──────────────────────┴─────────────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────┘
|
||||
|
||||
│ Why the data matters:
|
||||
│ The verifier will run the oracle, then re‑execute the same SQL queries on a ground‑truth copy of the database. If your dump contains the edge‑cases
|
||||
│ above, the verifier can automatically check that the JSON report matches the expected numbers. If the data are too clean, the task will be deemed “too
|
||||
│ easy” and may be rejected during the proposal review.
|
||||
|
||||
#### How to package it
|
||||
|
||||
1. schema.sql – copy the whole dump you received (/mnt/c/Users/Eric/Downloads/schema.sql).
|
||||
2. trades_dump.sql – a INSERT‑style dump (or a CSV file) that loads the trades table.
|
||||
3. accounts_dump.sql – a small set of rows for accounts.
|
||||
4. positions_dump.sql – optional but recommended for a realistic mismatch check.
|
||||
5. db_export.sh – a tiny Bash script that runs the appropriate \copy commands (or psql queries) to turn the tables into /app/exported.csv. The script
|
||||
should be part of the scaffold (scripts/validate.sh already calls it), but you can also ship a custom version if you need extra filtering logic.
|
||||
|
||||
All of these files belong under the task directory (task‑trading‑summary/). The Dockerfile in environment/ must install the PostgreSQL client (psql) and
|
||||
any other needed tools (e.g., python3, jq) so the oracle can run its queries.
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
### Quick checklist before you call the task “done”
|
||||
|
||||
- [ ] schema.sql is exactly the same as the one you inspected (no missing columns).
|
||||
- [ ] trades_dump.sql (or CSV) loads cleanly into a fresh PostgreSQL instance and respects all constraints (unique trade_id, proper foreign‑key
|
||||
references, etc.).
|
||||
- [ ] db_export.sh (or the scaffold’s exporter) can be run inside the dev‑container and produces a non‑empty /app/exported.csv whose first line is the
|
||||
CSV header.
|
||||
- [ ] The oracle (solution/solve.sh) runs without error, writes a valid report.json to /app/report.json, and exits 0.
|
||||
- [ ] The verifier (tests/test.sh) reads /app/exported.csv and the database (via the same SQL statements) and awards reward = 1.
|
||||
- [ ] The README (rendered from task.toml) accurately describes the data you supplied and the expected output format.
|
||||
|
||||
Once those items are in place, you’ll have satisfied the “provide from my database and schema” requirement and can move on to the Proposal phase (run
|
||||
scripts/check-proposal.sh on your instruction.md).
|
||||
|
||||
Let me know if you’d like a starter db_export.sh, a sample trades_dump.sql, or any help tweaking the schema to match your actual data!
|
||||
Reference in New Issue
Block a user