Files
agentic-labs-challenge/adaptive-loop/SPEC.md
T

35 KiB

Adaptive Loop — Implementation Specification

1. Reader and required outcome

This specification is for the autonomous Pi parent and its implementation/review subagents.

After reading it, they must be able to build, verify, and freeze a complete browser game without requesting product decisions from the human or inventing incompatible rules.

The game is successful only when it is playable from campaign start through campaign victory, contains five distinct scenarios, has clear win and lose states, demonstrates interacting deterministic systems, restores exact persisted state, and passes automated plus black-box browser checks.

2. Product vision

Adaptive Loop is a calm deterministic strategy puzzle set in a fictional microfluidic culture dish.

The board is three concentric hexagonal rings — an outer ring, a middle ring, and an inner ring — each a closed loop of hex culture tiles. The player rotates a whole ring clockwise or counter-clockwise; the outer ring has more tiles than the inner ring. Six fixed radial gates connect the three rings at the hex vertices: when a tile from each ring sits on the same gate, they form a radial channel.

A rotation does two things at once:

  1. It moves that ring's tile payloads around the loop.
  2. It changes which tiles sit on the six gates, and therefore how nutrient and toxin flow inward and how organisms migrate between rings.

The resulting tick resolves flow, growth, feeding, migration, selective pressure, adaptation, and environmental fixtures in a fixed order. Species counter repeated strategies through visible adaptations. Every adaptation has a benefit, a cost, and ecological spillover. The player wins by provoking useful counter-adaptations, then exploiting their weaknesses.

The intended feeling is precise, quiet, and legible: a scientific instrument built from three turning glass rings.

3. Hard scope

Required

  • Browser game, desktop-first, responsive down to 390 CSS pixels.
  • TypeScript, HTML, CSS, SVG board.
  • Five handcrafted scenarios in one campaign.
  • Standalone replay for every unlocked scenario.
  • Deterministic simulation with no runtime randomness.
  • Pure state transition shared by preview and commit.
  • Exact save/load and deterministic action replay.
  • Win, ecosystem-collapse loss, turn-limit loss, retry, and campaign victory.
  • Mouse, touch, and keyboard operation.
  • Accessible labels, visible focus, non-color encodings, live status announcements, and reduced-motion support.
  • Procedural SVG/CSS visuals only.
  • Unit/behavior tests, scenario solver/replay tests, and black-box browser tests.

Forbidden

  • Backend, accounts, analytics, ads, netcode, or online dependency after install.
  • Game engine.
  • Downloaded art, music, fonts, or commercial assets.
  • Random event deck or procedural board generation.
  • Individual autonomous microbe agents.
  • Continuous/floating-point population simulation.
  • UI-owned game rules or separate preview logic.
  • Bespoke simulation branch per named species when a data rule suffices.
  • Purely beneficial permanent upgrades.
  • Placeholder screens, claimed-but-unplayable mechanics, or demo-only content.

The board is three concentric hexagonal rings of hex tiles, centered on a common point:

Inner ring  (radius 1): 6  tiles  — I0 I1 I2 I3 I4 I5            (I0 at top, clockwise)
Middle ring (radius 2): 12 tiles  — M0 .. M11                    (M0 at top, clockwise)
Outer ring  (radius 3): 18 tiles  — O0 .. O17                     (O0 at top, clockwise)

36 tiles total. Each ring is a closed cyclic loop. Tile order around a ring is the clockwise visual order starting from the top. The outer ring has more tiles than the middle ring, which has more than the inner ring.

Six radial gates

Six fixed gates sit at the six hex vertices (top, upper-right, lower-right, bottom, lower-left, upper-left), indexed g0..g5 clockwise from the top. A tile is on a gate when its current ring position is that vertex:

  • Inner: I_g is on gate g (every inner tile is always on its gate).
  • Middle: M_{2g} is on gate g (every second middle tile is on a gate; the others are mid-arc).
  • Outer: O_{3g} is on gate g (every third outer tile is on a gate).

The three on-gate tiles at the same gate g (inner + middle + outer) form a radial channel. Tiles not on a gate are only connected tangentially within their ring.

Render

Render the board as three concentric hexagonal rings of hex tiles (regular pointy-top hexagons), clearly nested, with the six gates drawn as luminous radial connectors between the rings at the vertices. Never render the board as a network of connected spheres or a numbered wiring diagram. Each ring has a distinct color (inner/middle/outer). The board is one SVG that scales to the viewport.

There are exactly six gameplay actions — rotate each ring clockwise or counter-clockwise:

  • Rotate Inner clockwise / counter-clockwise.
  • Rotate Middle clockwise / counter-clockwise.
  • Rotate Outer clockwise / counter-clockwise.

No pass action exists.

What a rotation does

  1. Cyclically permutes that ring's tile payloads by one position. Clockwise moves the payload at track index i to (i + 1) mod size; counter-clockwise moves it to (i + size - 1) mod size.
  2. Sets that ring's direction to the chosen direction.
  3. Does not move fixtures or objective markers (they stay attached to their tiles).

Because gate membership is by track index, rotating a ring changes which payloads sit on the gates — this reconnects the rings and is the core of every puzzle.

Legal/illegal

  • Actions in terminal states are rejected without changing domain state.
  • A rotation is always legal in a non-terminal state (there is no pass and no partial rotation).

Board layout reference

A reference coordinate construction (tile centers per ring, gate connector geometry) and an ASCII schematic are provided in docs/board-layout.md. The implementer may nudge coordinates for legibility as long as the board reads as three nested hexagonal rings, the six gates sit at the vertices, and the cyclic tile order above is preserved.

5. Domain model

Use serializable plain data. Keep UI animation, hover, focus, wall-clock time, and ephemeral notifications outside domain state.

A compatible model includes:

type RingId = "inner" | "middle" | "outer";
type Direction = "cw" | "ccw";
type LineageId = "producer" | "grazer";
type PressureId = "heat" | "hunger" | "toxin" | "immunity";
type Mode = "campaign" | "standalone";
type Outcome = "playing" | "won" | "collapsed" | "expired";

type Chamber = {
  nutrient: number; // 0..6
  heat: number;     // 0..6
  toxin: number;    // 0..6
  producer: number; // 0..6
  grazer: number;   // 0..6
  phage: number;    // 0..6
};

type Ring = { direction: Direction; tiles: Chamber[] }; // tiles in clockwise track order; tiles[0] at top

type Lineage = {
  pressure: Record<PressureId, number>; // 0..3
  unlocked: Record<PressureId, boolean>;
};

type GameState = {
  schemaVersion: 1;
  mode: Mode;
  scenarioId: string;
  turn: number;
  rings: Record<RingId, Ring>;
  lineage: Record<LineageId, Lineage>;
  inheritedAtStart: Record<LineageId, PressureId[]>;
  consecutiveObjectiveTurns: number;
  environmentActive: Record<PressureId, boolean>;
  // turn starts at 0; each accepted action resolves turn + 1
  outcome: Outcome;
  actionLog: RotationAction[];
};

Gate membership is derived from track index (inner tiles[g], middle tiles[2g], outer tiles[3g]), so it is never stored separately and is always consistent with the rings.

All capped quantities use integer clamp 0..6. Pressure tracks use 0..3. Overflow is discarded and must be shown in previews/event attribution.

The transition must not mutate its input.

Canonical equality means deep equality after stable-key JSON serialization of domain state. Never include transient UI/time data in this comparison.

6. Organisms and fixtures

Movable tile values

ID Name Food Base rule
producer Agent may choose a memorable fictional species name nutrient If population and nutrient are present, consume 1 nutrient and gain 1 population.
grazer Agent may choose a memorable fictional species name producer Remove 1 edible producer and gain 1 grazer.
phage Phage grazer Remove 1 edible grazer and gain 1 phage; if unable to feed, lose 1 phage.

Producer and grazer are persistent campaign lineages. Phage is not.

Fixed fixtures

Fixtures stay attached to tiles when rings rotate.

  • Nutrient inlet: add 2 nutrient.
  • Heat source: add 2 heat.
  • Toxin inlet: add 2 toxin.
  • Drain: remove 2 toxin.
  • Immune node: selects and damages producer/grazer exactly once through the Section 8 immunity algorithm.
  • Objective marker: no simulation effect; marks a target tile.

Fixtures may coexist only when explicitly defined by scenario data.

7. Fixed turn pipeline

nextState(state, rotationAction) executes exactly this order:

  1. Rotate

    • Move the rotated ring's payloads.
    • Update that ring's direction.
    • (Gate membership is derived; it updates implicitly.)
  2. Channel flow — resources move tangentially around each ring and inward through gates.

    • Snapshot all nutrient/toxin values at phase start.
    • Tangential: every tile with nutrient sends 1 nutrient to the next tile in its own ring's current direction; same for toxin.
    • Radial (inward through gates): for each gate g, the outer on-gate tile sends 1 nutrient to the middle on-gate tile; the middle on-gate tile sends 1 nutrient to the inner on-gate tile. Same for toxin.
    • For each value, commit clamp(start - sent + sum(received), 0, 6) simultaneously.
    • Discarded overflow is attributed.
  3. Producer growth

    • Snapshot this phase after flow.
    • Process tiles in a fixed deterministic order (outer, then middle, then inner; each in track order).
    • Each occupied producer colony with nutrient consumes 1 nutrient.
    • It normally gains 1 producer.
    • A locally active trait cost may suppress reproduction or impose its defined payment.
  4. Biological interactions

    • Run a grazer subphase, then a phage subphase.
    • Each subphase reads a snapshot taken after the prior subphase and commits simultaneously.
    • Feeding is local to a tile (a grazer eats producers on its own tile; a phage eats grazers on its own tile).
    • Each occupied grazer colony may consume one edible local producer and gain one grazer.
    • Each occupied phage colony may consume one edible local grazer and gain one phage; otherwise it loses one phage.
  5. Migration — organisms chase food tangentially around a ring and radially through gates.

    • Run producer, grazer, then phage migration subphases.
    • Each species subphase reads a fresh snapshot after the prior species committed.
    • A source population of at least 2 sends one unit one step toward strictly-greater food. A step is either:
      • Tangential: to the next tile in the source tile's ring direction, or
      • Radial: through a gate, to the on-gate tile in the adjacent ring (outer↔middle, middle↔inner), only when the source tile is itself on that gate.
    • Producer food is nutrient; grazer food is producer; phage food is grazer.
    • Within each species subphase, commit aggregate transfers simultaneously as clamp(start - sent + sum(received), 0, 6) and attribute overflow.
  6. Evolution and environmental response activation

    • For each pressure whose track already equals 3, unlock the matching lineage trait.
    • If any lineage has that pressure at 3, activate the matching global environmental response for the remainder of this scenario.
    • Lineage order for any contention is producer, then grazer.
  7. Fixtures, exposure, and pressure consequences

    • Apply nutrient inlets: +2 normally, +1 while Hunger Response is active.
    • Apply heat sources: +2 normally, +3 while Heat Response is active; then reduce every tile's heat by 1.
    • Apply toxin inlets: +2 normally, +3 while Toxin Response is active.
    • Apply drains: toxin -2.
    • Resolve the single immunity algorithm defined in Section 8; immune damage is 2 normally or 3 while Immunity Response is active.
    • Snapshot heat, hunger, toxin, and immunity qualification plus occupied populations after fixtures and immune target selection.
    • Increment global lineage pressure tracks from that snapshot before applying population consequences.
    • Resolve heat, hunger, toxin, then immunity consequences in that order.
    • At the start of each pressure subphase, skip a lineage/tile whose current population is already zero, even if it qualified in the exposure snapshot.
    • Toxin carrier payments process producer then grazer on each tile; each pays from current nutrient, so later lineages lose population when earlier payment exhausted it.
    • Apply adapted heat/toxin spillover only after both lineages' carrier consequences for that pressure.
  8. Outcome and turn finalization

    • Initial state has turn = 0.
    • For an accepted action, define resolvedTurn = prior.turn + 1.
    • Before win evaluation, set consecutiveObjectiveTurns to prior +1 when the scenario's sustained predicate is true, otherwise reset it to 0.
    • Ecosystem collapse takes precedence: if total producer + grazer equals 0, lose as collapsed.
    • Otherwise evaluate scenario win using resolvedTurn and updated consecutive count.
    • Otherwise, if resolvedTurn >= turnLimit, lose as expired.
    • Store turn = resolvedTurn, append the action, and produce deterministic phase-ordered event attribution.

The implementation may represent events separately from canonical state, but event generation must be deterministic from prior state plus action.

8. Selective pressure and adaptations

Each lineage has four global tracks. A track gains exactly +1 on a turn if that lineage occupied at least one qualifying tile in the exposure snapshot. Multiple qualifying tiles do not accelerate a track. Tracks cap at 3. During the following turn's evolution phase, the lineage trait unlocks and the matching global environmental response activates.

Pressure Local qualifying condition Unadapted effect Adapted benefit Carrier cost Spillover Global response
Heat heat ≥ 2 lose 2 population Heat Shield prevents heat loss While hot, growth/feeding cannot add population After both lineages resolve heat, reduce local heat by 1 per adapted surviving lineage, maximum 2 Heat sources add 3 instead of 2
Hunger mapped food equals 0 lose 1 population Dormancy prevents hunger loss Dormant population cannot migrate Dormant population is inedible, denying food to its predator Nutrient inlets add 1 instead of 2
Toxin toxin ≥ 2 lose 1 population Efflux prevents toxin loss Pay 1 nutrient; if none, lose 1 population After carrier payments, reduce local toxin by 1 per adapted surviving lineage, maximum 2 Toxin inlets add 3 instead of 2
Immunity selected by immune node lose immune damage once Cloak excludes the lineage from immune selection At an immune node, predator feeding removes one extra cloaked prey Immune node retargets the other eligible lineage Immune damage becomes 3 instead of 2

Immunity algorithm

  1. During biological interactions, an unlocked Cloak is locally active whenever its carrier occupies an immune-node tile. A predator feeding on that cloaked prey removes 2 prey instead of 1; this is the carrier cost.
  2. During fixtures, inspect current populations at each immune node in fixed deterministic tile order.
  3. Eligible targets are occupied producer/grazer lineages without unlocked Cloak. Choose largest population; tie chooses producer.
  4. If no eligible lineage exists, the node does nothing. Otherwise record the selected lineage as immunity-qualified, attribute any retargeting caused by Cloak as spillover, and schedule exactly one immune damage event.
  5. Pressure tracks use the recorded selection snapshot. During the later immunity consequence subphase, apply the scheduled damage only if that target still has population; never apply a second immune loss.

Rules:

  • Global unlock does not mean always active. Heat, Hunger, and Toxin traits activate only under their qualifying condition. Cloak activates locally at immune nodes.
  • Each effect applies once per lineage per tile per phase.
  • Population loss floors at zero.
  • Environment response flags reset at scenario start even when traits are inherited; pressure can reactivate them.
  • UI must attribute unlock, local activation, prevented loss, paid cost, spillover, and global response with text plus visual encoding.
  • "Avoid an adaptation" means win a relevant pressure scenario while the matching trait remains locked (its track never enters an evolution phase at 3).
  • At least one solver route must deliberately provoke and exploit a trait; another must satisfy the defined avoidance condition.

9. Scenario contracts

Scenario definitions are immutable declarative data. Sparse tile notation below is:

tile: nutrient / producer / grazer / phage / heat / toxin

Tiles use the ring labels I#, M#, O# (Section 4). Omitted tiles and omitted values are zero. All rings initially clockwise.

Universal collapse is total producer + grazer = 0. Universal terminal precedence is collapse, then win, then turn-limit expiration.

The autonomous implementation must build a bounded deterministic solver or state-space search that proves at least one winning sequence and one losing sequence for each baseline scenario. Store those sequences as test fixtures and use them to generate RECORDING.md. It must also verify every campaign inheritance combination reachable from prior scenarios. If a scenario is impossible or trivial, the agent may adjust only starting populations/resources, fixture locations, or numeric objective thresholds by at most 1 per tuning pass. It must document every adjustment and rerun all solver tests. Board topology (three concentric rings + six gates), turn order, caps, trait semantics, and objective type may not change.

The five scenarios below are concrete targets. The implementer must solver-verify each and apply the documented §9 tuning budget as needed.

Scenario 1 — Heat: Cultivation Quota

  • Turn limit: 8.
  • Fixtures: nutrient inlets at O0 and O6; heat sources at O3 and O9.
  • Start:
    • O0: 3/2/0/0/0/0
    • O6: 3/2/0/0/0/0
    • M2: 2/1/0/0/0/0
    • I0: 1/0/0/0/0/0
  • Win: producer at I0 ≥ 4 and total producer ≥ 12.
  • Teaches: ring rotation, gate alignment, inward nutrient flow, growth, preview, and the first pressure: heat.

Scenario 2 — Hunger: Endurance

  • Turn limit: 10.
  • Fixtures: nutrient inlet at O0.
  • Start:
    • O0: 2/3/0/0/0/0
    • M2: 1/2/1/0/0/0
    • M8: 2/3/1/0/0/0
    • I4: 0/2/2/0/0/0
  • Win when resolvedTurn === 10 and:
    • total producer ≥ 8;
    • total grazer ≥ 4;
    • producer occupies at least 3 tiles;
    • grazer occupies at least 2 tiles.
  • Teaches: competition, migration through gates, dormancy, deliberate denial of predator food.

Scenario 3 — Toxin: Cleansing

  • Turn limit: 9.
  • Fixtures: nutrient inlet at O0; toxin inlets at O3 and O9; drains at I1 and I3.
  • Start:
    • O0: 3/3/0/0/0/0
    • O3: 0/0/0/0/0/2
    • M4: 2/3/0/0/0/0
    • O9: 0/0/0/0/0/2
    • I5: 2/2/1/0/0/0
  • Win when resolvedTurn is 6 through 9, total toxin ≤ 2, and total producer + grazer ≥ 8.
  • Teaches: routing contaminants inward to drains, resistance payment, shared detoxification spillover.

Scenario 4 — Immunity: Escort

  • Turn limit: 8.
  • Fixtures: nutrient inlets at O0 and O2; immune nodes at I1 and I3; sanctuary objective marker at I0.
  • Start:
    • M2: 2/3/0/0/0/0
    • M8: 2/3/2/0/0/0
    • O5: 0/0/0/1/0/0
    • O11: 1/0/2/1/0/0
  • Win: grazer at I0 ≥ 3 and total producer ≥ 6.
  • Teaches: immune targeting, cloak, retargeting spillover, predator vulnerability.

Scenario 5 — Convergence: Stable Equilibrium

  • Turn limit: 12.
  • Fixtures:
    • nutrient inlets at O0 and O6;
    • heat sources at O3 and O9;
    • toxin inlet at O2;
    • drain at I3;
    • immune node at I2;
    • assay objective markers at I0, M0, O0 (a vertical spoke through gate 0).
  • Start:
    • O0: 3/3/0/0/0/0
    • O2: 0/0/0/0/0/2
    • M2: 2/2/1/0/0/0
    • O6: 3/2/0/0/0/0
    • O8: 0/0/0/0/2/0
    • I3: 0/0/0/0/0/1
    • M8: 2/2/2/1/0/0
  • Sustained predicate:
    • the three assay tiles (I0, M0, O0) each contain producer + grazer ≥ 1;
    • total producer is 8 through 16;
    • total grazer is 3 through 7;
    • total phage ≤ 3;
    • total toxin ≤ 6.
  • Win when the updated consecutiveObjectiveTurns >= 2 before resolvedTurn exceeds 12.
  • Teaches: all systems plus inherited gift-and-burden consequences.

10. Campaign and standalone progression

Campaign

  • Scenario 1 starts with no inherited traits.
  • Winning unlocks the next scenario.
  • After each win, the player may preserve zero or one trait that unlocked during that scenario and was not already inherited.
  • Declining is allowed. Already inherited traits are not offered again.
  • Preserved traits carry both benefit and cost into later scenarios; previously inherited traits remain.
  • Pressure counters and global environment-response flags reset between scenarios.
  • Scenario retry restores the exact inheritance snapshot from first entry to that scenario.
  • Campaign victory occurs after winning Scenario 5.
  • Reachability verification enumerates every cumulative inheritance set produced by choosing zero or one newly unlocked eligible trait after each prior scenario.

Standalone

  • Unlocked scenarios may be replayed individually.
  • Standalone always clones immutable baseline scenario data.
  • No traits or pressure counters carry in or out.
  • Standalone completion does not change campaign progression.

Menu semantics

  • Continue: restore exact active run if one exists; otherwise enter next campaign scenario.
  • New Campaign: clear campaign progress only after confirmation.
  • Retry: restore current scenario baseline plus its campaign-entry inheritance snapshot.
  • Replay Standalone: select any unlocked scenario with baseline lineages.
  • Save & Quit: persist and return to title/menu without altering state.

11. Persistence and replay

Use localStorage with a versioned save envelope containing:

  • schema version;
  • mode;
  • scenario ID;
  • canonical game state;
  • campaign unlocked scenarios;
  • inherited lineage traits;
  • scenario-entry inheritance snapshot;
  • action log;
  • outcome;
  • saved-at metadata outside canonical comparison.

Requirements:

  • Save after every committed turn and on Save & Quit.
  • Restore exact canonical state and exact next transition.
  • Validate schema and values at load boundary.
  • Malformed or unsupported saves fail safely with a visible recovery choice; never crash or silently corrupt progress.
  • Replay is primarily a testing/debugging seam. It need not be a full player-facing replay viewer.
  • Replaying action log from immutable baseline plus inheritance snapshot must reproduce canonical current state.

12. Preview and event attribution

Hover, focus, or touch-selecting a rotation shows an exact one-turn preview produced by calling the same pure transition on cloned state.

Preview must show:

  • tile payload destinations (which tile each payload lands on);
  • updated ring directions and the resulting gate alignment;
  • tangential and inward-radial flow arrows;
  • exact population/resource deltas;
  • overflow discarded;
  • pressure increments;
  • trait unlocks and local activations;
  • adaptation benefit, carrier cost, and spillover;
  • predicted objective progress or terminal result.

Commit must produce canonical state equal to previewed canonical state.

The event panel should explain the tick in phase order. It must be concise enough to scan during a video and detailed enough to explain a collapse.

13. User interface and visual direction

Visual world

  • Dark laboratory glass and restrained near-black background.
  • Three concentric luminous glass rings with crisp beveled hex tiles; the six gates read as luminous radial connectors.
  • Microfluidic channels read as instrument paths, not fantasy pipes.
  • Motion is subtle and causal: ring rotation, inward flow pulse, growth/decline, trait activation.

Entity art (procedural SVG — intricate, not primitive)

Species and fixtures must be distinct, detailed procedural SVG glyphs — more intricate than a plain circle or square. Each species uses shape + short label + color; each pressure uses distinct iconography + color. Reference designs (the implementer may elaborate while keeping them legible at tile size):

  • Producer — "Lumiflora" (photosynthetic diatom): a 6-petal / double-triangular flower or diatom — nested rotated ellipses forming a petal ring around a bright chloroplast center. Green family.
  • Grazer — "Vellea" (ciliated crescent): a segmented crescent body with 3 pairs of cilia/leg strokes along one edge and a small mouth notch. Amber family.
  • Phage: a classic lunar-lander virus — a hexagonal/icosahedral capsid head on 6 leg spikes with base pins. Pink family.
  • Nutrient inlet: a pipette/valve dropping a bead. Heat source: a coiled filament radiating warm rays. Toxin inlet: a dropper of greenish droplet. Drain: a funnel siphon. Immune node: a sentinel eye/lens. Objective marker: a targeting reticle.
  • Pressures (iconography + color): Heat = radiating sun rays (warm), Hunger = waning crescent (violet), Toxin = skull-and-drop (green), Immunity = shield (cyan).
  • Tile state: nutrient as a blue liquid level at the tile base; toxin as a greenish level; heat as a warm rim glow; adapted state as a ring/border treatment plus a ✓-style tag in addition to color.

Avoid generic dashboard card grids, excessive gradients, stock icons, or decorative particle noise. Never encode by color alone.

Layout

Desktop:

  • Center: SVG culture board (three concentric rings).
  • Left or upper rail: scenario objective, turn, campaign state.
  • Right or lower rail: pressure tracks, lineage traits, exact preview/event log.
  • Persistent controls: menu, Save & Quit, retry where relevant, help/legend.

Narrow viewport:

  • Board remains primary.
  • Information rails stack below.
  • No horizontal page scrolling.
  • All controls remain reachable and labels readable at 200% zoom.

Input

  • Pointer/touch: select ring and direction, preview, then commit. Selecting a rotation (focus/hover/tap) shows the preview and enables Commit; the selection persists until the player commits, selects a different rotation, or cancels (Escape). Never disable Commit merely because the pointer leaves the rotation control or focus moves to the Commit button.
  • Keyboard: focusable controls for each ring direction; Enter/Space commits; Escape cancels preview.
  • Visible focus on every actionable control.
  • No hover-only information.

Accessibility

  • Semantic headings and landmarks; an h1 per view.
  • Real buttons for actions.
  • Accessible names include ring, direction, and predicted high-level result.
  • Live region announces committed turn result and terminal outcomes.
  • Text/symbols supplement every color encoding.
  • Contrast meets WCAG AA for normal text and controls.
  • prefers-reduced-motion removes nonessential animation and renders final states immediately.

14. Architecture

Prefer the smallest boring stack that supports reliable testing. A suitable default is Vite + TypeScript + Vitest + Playwright, but the autonomous agent may choose an equally small established stack already supported by the environment.

Required module boundaries:

  1. Domain: types, canonical serialization, validation, pure transitions, event derivation.
  2. Content: immutable species/trait tables and declarative scenarios.
  3. Persistence: versioned save validation and localStorage adapter.
  4. Presentation: SVG rendering, controls, preview, status/event UI.
  5. Verification: behavior fixtures, solver/replay checks, browser user flows.

Do not create factories, plugin systems, dependency injection containers, generic ECS frameworks, or abstractions with one implementation.

15. Autonomous implementation gates

The run must complete gates in order. A failing gate blocks later work except the smallest repair needed to pass it.

Gate 0 — legality and evidence preflight

  • Record initial tree and confirm only permitted human-authored context exists.
  • Record PI_SESSION_FILE absolute path.
  • Record effective model/provider.
  • Generate CONTEXT-MANIFEST.md listing the one prompt, all local context files, extension/package versions, relevant extension configuration, and their original/effective paths.
  • Authoritative private prompt path: /Users/alex/Projects/scripting/agentic-labs-challenge/adaptive-loop/PROMPT.md.
  • Each real attempt starts in a fresh standalone directory outside every existing Git worktree, containing only SPEC.md and the three .agents/skills/*/SKILL.md instruction files; the initial human message is supplied from the private prompt and is not copied into the public game repository by default. The agent may initialize Git during the run.
  • The final public repository discloses all staged context files plus a CONTEXT-MANIFEST.md that records the exact isolated launch flags, loaded extension/package versions, effective steering/configuration text or immutable public source hashes, and original/effective paths; the prompt is DM'd with submission unless the operator deliberately chooses publication.
  • Copying and validating the final session JSONL is an operator post-exit submission step, explicitly excluded from the in-session game-code freeze.
  • Because Pi Goal continuation messages are persisted as role:user, post-exit validation must classify provenance rather than require one raw user-role entry: one initial pi-goal-prompt kickoff reconstructs PROMPT.md, and every later user-role entry must be a matching disclosed pi-goal-continuation for the same objective and goal ID. Any unmarked or mismatched user entry fails compliance.
  • Do not copy the live session log during the run.

Gate 1 — runnable shell

  • Production app starts.
  • Title, new campaign, continue state, and scenario shell render.
  • No browser console errors.

Gate 2 — complete Scenario 1

  • Ring rotations move tiles and reconnect gates.
  • Preview equals commit.
  • Heat scenario has playable win, collapse, expiration, and retry.
  • Save/reload preserves exact state.

Gate 3 — simulation truth

Literal worked tests cover:

  • both directions for all three rings;
  • gate alignment after rotation;
  • tangential and inward-radial flow, contention, and overflow;
  • population/resource caps;
  • every pipeline phase;
  • all four adaptations including benefit/cost/spillover;
  • input immutability;
  • canonical determinism;
  • terminal precedence;
  • preview/commit equality;
  • replay reproduction.

Gate 4 — scenario solvability

  • Solver or bounded search proves and stores one winning and one losing route for each baseline scenario.
  • Every reachable campaign inheritance set can complete subsequent scenarios.
  • At least one route requires a gate-alignment change to route flow or migration between rings.
  • At least one route exploits an adaptation.
  • At least one route avoids an adaptation.

Gate 5 — campaign and persistence

  • Five scenarios unlock in order.
  • Lineage choice carries gift and cost.
  • Retry uses scenario-entry inheritance snapshot.
  • Standalone uses clean baseline.
  • Malformed save recovery works.
  • Campaign victory works.

Gate 6 — black-box browser proof

Against the production build, public controls only:

  • start a campaign;
  • preview and commit a rotation;
  • observe tile movement plus tangential/radial flow interaction;
  • trigger and visibly attribute an adaptation benefit, cost, and spillover;
  • trigger a global pressure response and observe its strengthened fixture effect;
  • lose, retry, then win;
  • Save & Quit;
  • close/reopen page and Continue exact state;
  • operate core actions by keyboard;
  • check narrow viewport, 200% zoom, and reduced motion;
  • never inject domain state or localStorage to fake gameplay.

Gate 7 — bounded polish and independent review

  • One visual QA pass at desktop and narrow viewport.
  • Fresh-context reviewers inspect correctness/determinism, user flow/accessibility, and simplicity/scope.
  • One writer applies accepted fixes.
  • Maximum three broad review rounds. If a floor blocker remains, drop optional polish and perform one final focused repair/verification cycle; never declare success with a failing floor gate.

Gate 8 — repository freeze

  • Aggregate verification passes after final code edit.
  • README contains exact install, run, build, test, and play instructions.
  • ASSETS.md discloses that visuals are procedural and lists any allowed generated asset if one was created during the run.
  • RECORDING.md contains a short deterministic uncut-video route.
  • All steering context remains at original project-local paths.
  • Record final commit/tree hash or, if no commit is appropriate, a deterministic file manifest and hashes.
  • Print the authoritative PI_SESSION_FILE path and post-exit copy/validation command.
  • Make no more game-code edits after freeze.

16. Recording route requirements

RECORDING.md must be generated from verified solver/browser routes, not invented prose.

One continuous take should be short but show:

  1. Title/campaign start.
  2. Exact preview of a rotation.
  3. Rotation causing both tile movement and (tangential or radial) flow.
  4. Pressure causing a species adaptation.
  5. The adaptation's benefit, cost, and spillover.
  6. Global pressure response strengthening an environmental fixture.
  7. Ecosystem collapse and retry.
  8. A scenario win and preserved lineage choice.
  9. Save & Quit.
  10. Page/tab close and reopen.
  11. Continue restoring exact state.
  12. Visible access to multiple scenarios.

Automated tests must validate all five scenarios and campaign victory; the recording need not play all five unless the verified route remains concise.

17. Repository deliverables

Required at freeze:

  • Complete game source.
  • Production build configuration.
  • Automated tests and black-box browser tests.
  • README.md.
  • ASSETS.md.
  • RECORDING.md.
  • CONTEXT-MANIFEST.md.
  • This SPEC.md.
  • Original one prompt at its submitted path only if disclosure strategy calls for it; otherwise preserve privately and DM it per competition rules.
  • .agents/skills/pi-game-factory/SKILL.md.
  • .agents/skills/deterministic-game-core/SKILL.md.
  • .agents/skills/game-ui-proof/SKILL.md.
  • Exact authoritative session JSONL is an operator-owned post-exit submission artifact, not an in-session freeze deliverable.

18. Completion definition

Do not stop at a plan, architecture, prototype, attractive board, or one scenario.

Adaptive Loop is complete only when:

  • five scenarios are playable;
  • campaign and standalone modes work;
  • win and both loss types work;
  • two or more systems visibly interact (rings + gates + adaptations);
  • adaptation benefit/cost/spillover is playable and visible;
  • deterministic preview, replay, and persistence are proven;
  • scenario solver routes and browser tests pass;
  • the production UI is readable, accessible, and stable;
  • the repository deliverables exist;
  • the recording route is verified;
  • the final aggregate gate passes after the last code edit;
  • the authoritative prompt/context boundary, session path, and operator-owned post-exit log procedure are reported.