A rigorous multi-file software-engineering benchmark. Agents plan, then build complex projects,
scored on a transparent rubric mixing automated tooling (Tier A) with an agent panel (Tier B). The rubric is
public and handed to agents upfront. Click any build to play it inline.
Two distinct quadtrees by purpose: a region QuadTree in graph-core for range-query picking (F8) and a separate pooled SoA Barnes-Hut tree in barnes-hut.ts for force aggregation β clean separation rather than overloading one structure.
Barnes-Hut is fully allocation-free per frame: structure-of-arrays Int32/Float64 node pool with iterative stack traversal (reused Int32Array stack), growKeeping() only on pathologically deep inputs β genuinely controls GC (F11).
Render-on-demand decouples idle FPS from active cost: needsRender flag means a settled graph idles near-free, and SELF.md honestly separates the inflated idle 60fps from the real workload() number instead of gaming the metric.
Edge rendering is two-pass batched: one beginPath/stroke for all 10k dim edges, a second path only for highlighted edges β keeps the whole frame to ~1 stroke + ~N_group fills.
Two distinct spatial structures: a clean pure-TS QuadTree in graph-core.ts for the acceptance contract, plus a separate flat typed-array BarnesHutTree (SoA: centerX/massX/firstChild Int32Array) used in the hot sim loop β avoids object-per-node GC churn.
CSR adjacency layout (adjacencyStarts + adjacency Uint32Array built via cursor scatter) gives O(1) neighbor lookup for hover/click focus instead of scanning edges each frame.
Mask-based rendering pipeline: separate visibleMask/searchMask/focusMask Uint8Arrays composed per-frame, with edges dimmed (rgba alpha drop) when focus is active for visual emphasis.
Seeded deterministic graph generation (mulberry32) with clustered communities placed on a ring + intra/inter-group edge mix (~82% local), plus guaranteed ring spanning edges and a fallback filler to always hit the edge target.
Two quadtree implementations: a clean public `QuadTree` class in graph-core.ts for the contract, plus an internal flat-array Barnes-Hut tree (TreeCell with Int32Array children, theta=0.72) in simulation.ts tuned for speed.
Phased/rotating Barnes-Hut repulsion: `stride` scales with node count (4 at >3000) and `repulsionPhase` rotates the sampled subset each tick, trading exactness for sustained FPS while still using full springs/centering every frame.
Fully typed-array (SoA) simulation state β x/y/vx/vy as Float32Array, sources/targets as Uint32Array, groupIndexes as Uint16Array, adjacency as sorted per-node Uint32Array β minimizing GC pressure (F11).
Search matches both label and id (`Node 42` or `n42`), caps highlights to 250 and auto-focuses/centers the viewport on the first match.
Deliberately maintains TWO quadtrees with a documented rationale: the contract-pure QuadTree (range query, for the hidden acceptance suite) vs an internal BHNode tree carrying mass/center-of-mass for Barnes-Hut force approx β avoids contorting the public contract to fit the sim.
neighbors() memoizes adjacency by stashing a __adj Map on the graph object (cast through Graph & {__adj?}), so repeated lookups are O(1) after first build while keeping the function signature pure.
Renderer does cheap edge culling (skip if BOTH endpoints off-screen) and node culling with a 5px margin, plus zoom-dependent radii (3.0/sqrt(zoom)) β keeps draw cost bounded when zoomed in.
zoomAt recomputes cam.cx/cy after clamping zoom so the world point truly stays under the cursor even at the 0.01/200 zoom limits, rather than naive pre-clamp math.
Functions receive UNEVALUATED arg nodes plus a FuncApi (scalar/collect), so IF/AND/OR genuinely short-circuit and untaken branches never evaluate β most agents eagerly evaluate args.
Incremental recalc is correctly scoped: collectAffected() walks only the transitive dependent subgraph from the edited seed, then Kahn topo-sorts just that subgraph (O(V+E)); leftover non-zero in-degree cells become #CIRC! β cycle detection falls out of the topo sort for free, no separate DFS.
Single overlay <input> editor for the whole 100Γ100 grid (not 10,000 inputs) positioned via getBoundingClientRect β keeps the DOM light and is the key to no-jank.
Bijective base-26 column math (colToIndex/indexToCol) handling AA/AB correctly, a common off-by-one trap.
Cycle detection uses a full Tarjan SCC (findCycleNodes) restricted to the affected set, marking every node in a multi-node component as #CIRC! and also catching self-references β more robust than naive DFS-color cycle checks.
Clean split engine architecture (refs/parser/ast/evaluator/graph/engine) with a pure AST type, keeping the public Sheet API thin.
Incremental recalc unions previous AND new transitive dependents before recomputing, so cells that *stop* depending on a precedent are still correctly refreshed when a formula changes.
Deterministic recalc ordering via compareRefs (row-major) everywhere, giving stable lastRecalculatedRefs() β which doubles as the measurement surface for the window.__buildoff workload() perf hook.
True incremental recalc: collectDownstreamInto walks only the transitive reverse-dependency set, then topo-sorts just that affected subset β not a whole-sheet sweep (engine.ts recalculate/collectDownstream).
Cycle isolation during the topo visit: members of a detected cycle are stamped #CIRC! while non-cyclic affected cells in the same batch still evaluate correctly (recalculate uses a visiting/stack to pinpoint exactly the cyclic refs).
Comparison operators (>, <, >=, <=, =, <>) are folded into the expression precedence chain (parseComparison) so IF conditions parse as real AST, not special-cased strings.
Tokenizer normalizes alternate operator spellings β '!=' β '<>' and '==' β '=' β a forgiving touch most parsers skip.
Tarjan SCC over the *induced subgraph* of only the affected cells (graph.findSCCs takes an iterable) rather than scanning the whole sheet β cycle detection is O(affected) not O(all cells).
Bidirectional dep graph (fwd + rev edge maps) with reference-counted cleanup: empty Sets are deleted from both maps on edge removal, keeping memory tight on large sheets.
recalc.ts snapshots the PRE-edit reverse closure before mutating the graph, plus re-adds old cycle members that fell out β correctly recomputes cells that stop being circular when a cycle is broken.
Two distinct numeric coercions: toNumber treats ''β0 while toNumericValue treats ''βnull, so SUM/AVG/MIN/MAX skip empty cells instead of counting them as zero β a subtle correctness detail many implementations get wrong.
Inverted index intersects posting lists starting from the RAREST term (lists.sort by size, seed from smallest) so search cost scales with match count, not corpus size β genuinely the 'real index' F10 asks for, not a linear scan.
monotonicNow() clock guarantees `updated` never repeats within the same ms, making all()/recency ordering deterministic and stable β caught a real test-flake edge case others would miss (documented as a PLAN deviation).
XSS-safe markdown renderer parses structure from raw source but escapes every user-text emit point; link hrefs are allowlisted to ^(https?:|mailto:|#|/) and anything else collapses to '#', so javascript: URLs are neutralized.
Inline-code is extracted to private-use-area sentinel placeholders (\uE000) before other inline rules run, so backtick contents never get re-parsed as bold/italic/links β a correctness subtlety most tiny renderers get wrong.
Inverted index intersects AND-terms by seeding from the SHORTEST posting list (sortedPostings sorted by size), so multi-term search cost scales with the rarest term, not total notes (notes-core.ts:251-260).
Monotonic timestamps: nextUpdated() forces strictly-increasing `updated` via max(now, lastUpdated+1, previous+1), so ordering never collides even on same-ms edits (notes-core.ts).
XSS-hardened markdown: safeHref allow-lists protocols, escapeAttribute neutralizes backticks, and the search highlighter escapes every text slice before wrapping matches in <mark> (markdown.ts safeHref, view.ts:228-246).
Real inverted index (SearchIndex) with per-note posting maps AND a reverse #termsByNote map, giving O(#terms) index removal instead of scanning all postings.
AND-intersection sorts postings by size and iterates the smallest posting first (set-intersection optimization) β scales well past 1,000 notes.
Three-tier ranking weights: title +4, tags +2, body +1, so tag matches rank between title and body rather than being ignored.
Monotonic timestamps via now() = max(Date.now(), last+1) guarantee strictly increasing 'updated' even under rapid edits, making sort order deterministic.
Inverted-index AND search sorts posting lists by size and intersects starting from the smallest, minimizing comparison work (store SearchIndex.search).
Scoring uses a bounded recency tiebreaker (0..1) that can never outweigh even one extra body hit, so title>body ranking stays correct while newest notes break ties.
Markdown renderer stashes inline `<code>` spans behind a unicode sentinel before applying bold/italic regex, preventing formatting from leaking into code spans β then restores them.
safeHref() whitelists http(s)/mailto/relative/anchor and rejects any other scheme (e.g. javascript:), and all text routes through escapeHTML β XSS-safe preview with no raw-HTML echo.
engine-core.ts is a genuinely reusable, side-effect-free infra layer (ECS + A*) cleanly separated from game logic β the World uses sparse-set Map stores with free-list id recycling and query() iterates the smallest component store for speed.
A* runs on flat typed arrays (Int32Array g/cameFrom, Uint8Array closed) with a hand-rolled binary MinHeap using lazy decrease-key β stale heap entries filtered by closed-set check on pop.
canPlace() does a real wall-off check: temporarily sets the tile blocked, re-runs findPath, and rejects placements that would disconnect spawn from goal β towers can never trap enemies.
Live re-routing re-snaps in-flight ground enemies to the nearest waypoint of the recomputed path on every place/sell (resnapEnemies/nearestWaypoint), and the author honestly flags the cosmetic stutter this can cause in SELF.md.
A* uses flat typed arrays keyed by y*width+x (Float64Array gScore, Int32Array cameFrom, Uint8Array closed) instead of object maps β cache-friendly and GC-free per pathfind.
Tie-breaking is deterministic and well thought out: A* prefers higher-g nodes on equal f, and nearestInRange breaks distance ties by lowest entity id β stable target selection.
placeTower validates connectivity before committing: it runs findPath on a hypothetical blockedGrid({x,y}) and refuses placements that would fully wall off the goal, preventing softlocks.
Three distinct tower archetypes encoded as data (cannon=splash, sniper=long-range/high-dmg, frost=slow) plus per-tower upgrade leveling that scales range preview and cost (45*level).
Binary MinHeap with explicit (priority, tie) comparator gives deterministic A* tie-break biased up-left β most agents use array.sort or no tie-break.
query() sorts component maps by size and iterates the smallest archetype first, minimizing membership checks β a real ECS perf optimization, not just naive intersection.
Keeps both a boolean[][] `blocked` and a parallel Uint8Array `blockedU8` plus a `pathCells` Uint8Array so placement validity (occupied vs on-path) is an O(1) typed-array lookup in the render/hover hot path.
Self-contained perf probe runs engine-core directly, tops up to 200 live enemies each tick, and also spawns projectiles + touches nearestInRange to keep the full API exercised under load.
We vary how agents are asked (prompt variant) and the process harness (methodology: baseline / gsd / ralph-loop / skills), then watch what lifts composite, feature coverage, and plan-adherence. Build time = launch β SELF.md.