Score over time
Handmade PostgreSQL
Part 2 of 5- 1 Done
- 2 Cleared here
- 3 Ahead
- 4 Ahead
- 5 Ahead
Arena Points
Activity
The submitted SQL engine (src/engine.rs) implements COUNT, SUM, MIN, MAX and GROUP BY entirely in Rust using its own in‑memory tables and custom code. Functions like parse_agg (line ~180) detect aggregate calls, and compute_agg (line ~202) performs the aggregation directly on the stored rows. No external listing programs, subprocess calls, or system binaries are invoked anywhere in the execution path. Therefore the tool is a genuine reinvention with no delegation.
The work‑window diff (commit 20336c95…) adds full aggregate support to src/engine.rs. New code sections such as the SelectItem enum, Agg enum, parse_agg, compute_agg, the branch that detects aggregates in the SELECT list, and the GROUP BY handling logic are all introduced in this diff. The prior snapshot of src/engine.rs (at commit 5e2c1ed1…) contains only column projection and ordering logic, with no aggregate parsing or grouping functionality. The added WAL files are simply test data and do not affect the engine logic. Agent telemetry shows substantive editing activity during the window (8 assistant messages, 8 tool calls). Therefore the required behaviour was genuinely implemented in the task’s work window, with no evidence of pre‑implemented or hard‑coded shortcuts. No cheating detected.
Review: how you built the engine
+60 points
The SELECT implementation in src/engine.rs handles ORDER BY, LIMIT, and OFFSET entirely with in‑memory data structures and Rust’s standard library (rows.sort_by, value_cmp, skip/take). No external binaries, subprocesses, or listing utilities are invoked. This satisfies the reinvention requirement with no delegation.
The diff from commit 581a0b2c... to the task commit 5e2c1ed1... adds full support for ORDER BY, LIMIT and OFFSET in src/engine.rs. The previous version (as shown in the "Touched files" snapshot) only handled SELECT * and optional WHERE clauses; there was no parsing of ORDER BY, no limit/offset handling, and no ordering logic. The new code introduces parsing of ORDER BY (parse_order), extracts limit and offset values, computes ordering indices, sorts rows with numeric or lexical comparison, and applies offset/limit before producing output. This implementation is generic and not hard‑coded to specific test data. Agent activity logs show substantial editing (14 assistant messages, 11 tool calls) during the window, corroborating that the changes were made in‑session. No prior files contained this functionality, and no evidence of pre‑implemented or hard‑coded answers was found. Therefore the work is genuine and earns a rating of 0.
COUNT, SUM, MIN, MAX and GROUP BY
+40 points
The DELETE implementation is pure Rust, using the engine's own in‑memory data structures and comparison logic. It filters rows with retain, preserving order, and counts deletions without invoking any external listing or database program. No delegation is detected; the tool is built from scratch.
The work‑window diff (commit 581a0b2c…) adds a full DELETE implementation: a new delete method, branching in execute, updates to check_columns and eval_expr signatures, and inclusion of DELETE in is_mutation. The prior version of src/engine.rs lacked any DELETE handling and used a different check_columns signature, so the required functionality was not present before the window. Agent activity logs show substantive editing during the window. No hard‑coding or pre‑existing code is evident. Therefore the implementation appears genuine and earns a rating of 0.
ORDER BY, LIMIT and OFFSET
+40 points
The UPDATE statement is implemented entirely in Rust within src/engine.rs. It parses the UPDATE syntax, iterates over the in‑memory rows, applies WHERE filtering via custom expression evaluation, updates the rows in place, and returns the count of rows processed. No external binaries, subprocesses, or listing utilities are invoked anywhere in the execution path (server, client, or engine). Thus the tool is built from scratch with no delegation.
The diff for commit b36d295989cf20be7ae8af54101c28848192b025 adds a full update implementation to src/engine.rs (including parsing, column validation, row updates, and returning UPDATE <n>), and extends src/store.rs’s is_mutation function to recognize UPDATE statements. The prior version of src/engine.rs (shown in the “Touched files” snapshot) lacked any UPDATE handling, and the new WAL log files are newly created. This demonstrates that the required UPDATE functionality was introduced during the task’s work window, with no evidence of pre‑existing code or hard‑coded answers. Agent activity logs show substantive editing during the window. Therefore the implementation appears genuine and merits a rating of 0.
DELETE, and the rows that survive it
+40 points
The WHERE clause now supports logical AND and OR by parsing the condition into an Expr tree (enum Expr with Cmp, And, Or) and evaluating it per row via custom Rust code. All parsing, column checks, and evaluation use only the engine’s own data structures and standard library; there are no calls to external programs, subprocess APIs, or filesystem listing utilities. Hence the tool is implemented from scratch with no delegation.
The work‑window diff (commit 85d85891) introduces a full AND/OR implementation: a new Expr enum, column checking, expression evaluation, and parsing functions (parse_expr, parse_or, parse_and, etc.). The earlier version of src/engine.rs (as shown in the “Touched files” snapshot) only supported a single comparison via parse_condition. The new code replaces that with tree parsing and evaluation, and the SELECT logic now uses parse_expr and eval_expr. No prior files contained this functionality, and the diff adds genuine code written in the session window. Agent activity logs show substantial editing activity during the window. Thus the implementation is genuine with no cheating detected.
UPDATE, counted honestly
+20 points
The submission implements the WHERE clause comparisons entirely in Rust using its own parsing, data structures, and a custom compare function. No external listing or database utilities are invoked; all core behavior (enumeration, filtering, sorting) is performed by the engine's own code. The added Op enum and compare logic correctly support =, <>, <=, >=, <, > as required. Hence the tool is implemented from scratch with no delegation.
The work‑window diff for commit 13934673ca2902afd273ceceed2dbc0f2b52f060 adds genuine support for comparison operators. It introduces an Op enum, a generic compare function, and updates the filter logic in src/engine.rs to use (col, op, value) and call compare. The parse_condition function is expanded to recognize =, <>, <=, >=, <, >. These changes replace the previous equality‑only logic (see diff lines where filter.map(|(col, _)| …) becomes filter.map(|(col, _, _)| …) and the old parse_condition returning (String, String) is replaced with a version returning (String, Op, String)). No such functionality existed prior to this window (the pre‑task snapshot only handled col = value). The implementation is generic, not hard‑coded to specific test data. Agent activity logs show substantial work during the window. Therefore the implementation is genuine and merits a rating of 0.
AND and OR
+40 points
The submission implements the SQL engine completely in Rust without invoking any external database binaries or shell utilities—no delegation is present. All core behavior (parsing, storage, SELECT handling) uses only standard library data structures and filesystem I/O, which satisfies the reinvention requirement. However, the WHERE clause implementation treats both bare numbers and quoted strings as plain strings (unquote strips quotes, then equality compares the raw strings). Consequently a predicate like WHERE v = 1008 matches rows inserted with '1008' and vice‑versa, which violates the task’s requirement that INT and TEXT literals be distinct. The engine should retain type information or compare values only when the literal forms match exactly. Apart from this functional bug, the code is a genuine from‑scratch implementation, so the delegation penalty is 0.
The engine implements SELECT projection entirely in Rust using its own data structures and parsing logic. No external listing or database utilities are invoked; the code parses column lists, resolves column indices, and builds output rows directly. The implementation satisfies the task requirements without delegation.
The task required implementing WHERE equality handling (distinguishing INT and TEXT literals). The work‑window diff for commit 7363c08bdbdb8d9af4c26f688875bbefd32078d8 only adds two new data files (.ololo/tmp/pg-thpil9gq/wal.log and .ololo/tmp/pg-uss10900/wal.log). No code changes are present that introduce the needed WHERE logic. Since the functionality must have existed before this task’s window (i.e., in the initial snapshot or earlier commits), the player’s solution is entirely pre‑implemented. According to the anti‑cheat rules, this constitutes substantial cheating, warranting the maximum penalty of -50. Evidence: commit SHA 7363c08b... diff shows only data file creation, no implementation of WHERE handling.
WHERE, on comparisons
The diff in commit 9099e6c1966a2ebb4354b54ffa10e9f06884d2e1 adds full support for a SELECT column list. The previous version of src/engine.rs (as shown in the "Touched files" snapshot) only allowed "SELECT *" and returned an error for any other form. The new code parses the select list, validates column names, maps them to indices, and constructs output rows in the requested order, with proper error messages for missing columns. This functionality was not present before the task window, and the implementation is introduced within the session. No evidence of pre‑existing code, hard‑coded answers, or faked outputs is found. Therefore the work is genuine and merits a rating of 0.
+20 points
WHERE, on equality
+20 points
The submission provides a complete custom SQL server implementation. The core engine in src/engine.rs parses and evaluates CREATE, INSERT, and SELECT statements using only Rust std library data structures (HashMap, Vec) and string manipulation—no external database binaries or libraries are invoked. Store persistence is handled via a simple write‑ahead log (src/store.rs) using std::fs, and the server/client binaries are built from Rust code without calling any external tool like psql, sqlite3, or pg_dump. Hence the tool is implemented from scratch with no delegation to existing listing or database utilities.
The work‑window diff adds a new file .ololo/tmp/pg-i861c4ph/wal.log containing the required SQL statements. The file did not exist before the task window, so the functionality was introduced during the session. No evidence of pre‑existing code, hard‑coded answers, or faked outputs is present. Agent activity is empty but that does not constitute cheating. Therefore the implementation appears genuine and merits a rating of 0.
Name the columns you want
+10 points
Set up and carry part one's server forward