Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
LightAxe
force-pushed
the
feat/jev-opponent
branch
from
September 20, 2026 01:46
3473e23 to
8891acc
Compare
This was referenced Sep 20, 2026
LightAxe
force-pushed
the
feat/jev-opponent
branch
2 times, most recently
from
September 21, 2026 16:10
4f4d02d to
74fce26
Compare
LightAxe
added a commit
that referenced
this pull request
Sep 21, 2026
#312) * feat(settings): persist the last-used difficulty tier (#304) Add `difficulty` to the render-side settings blob so the new-game screen can reopen on the tier the player last started a round with. Default Normal; the stored value is accepted only when it is exactly one of the three tier names, otherwise it falls back to the default without touching its siblings. A pre-#304 blob without the key loads as before. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh * feat(ui): new-game screen — radio difficulty rows and a single Start button (#304) Options first, one Start button last. The boot-time "Choose Difficulty" overlay becomes a "New Game" screen: three radio-style rows (Easy / Normal / Hard, default Normal, visible selected state) each carrying a plain-language line about what the tier changes, and a single "Start game" button. Only Start — or Enter — begins the round; clicking a row just moves the selection. The screen reopens on the persisted last-used tier (settings.difficulty), which is written on Start. - boot-overlay-layout.ts: the screen is a section stack (title → difficulty → opponent slot → start) computed purely from the LayoutContext, centered as a group (#213/#238 discipline). The opponent slot has height 0 on main; the Jev opponent picker (PR #298) inserts its section by passing the height it needs, and nothing else moves. - difficulty-copy.ts: the row copy DERIVES its numbers from the sim's [Easy, Normal, Hard] triplets (egg-interval numerator, WarFooting / Invading fighter thresholds, spider hunger threshold at 50 ms/tick), so it cannot drift from the constants; the wording is pinned by a test so a retune shows up in review. - ui-scene.ts: re-render-in-place rows (the survey overlay's shape), an Enter binding scoped to the screen, `__phase9_ui.selectedDifficulty` for Playwright, and a scene-level pointer guard so clicks on the boot overlays no longer fall through to the HUD chain beneath the scrim. - game-scene.ts: onStart callbacks (persist, then bootFresh) on both the fresh-boot and restart paths; the SavePrompt path is unchanged. The dev-only `__phase9_test.getRoundDifficulty()` lets a spec prove Start booted the selected tier. Render-only: no sim change, no simVersion bump. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh * test(e2e): drive the new-game screen through one shared boot helper; add #304 spec Every spec that starts a round used to carry its own "poll-click Normal" loop. The screen is now two steps (pick a row, press Start), so the loop lives once in tests/helpers/boot.ts (settleToPlaying, plus the activeOverlay / bootScreen / selectedDifficulty reads) and the four boot-flow specs — phase-09-session, menu-and-dialog, survey-overlay, touch-smoke — use it. The helper also refuses to mistake the pre-overlay frame (activeOverlay defaults to 'none' before any boot overlay has been shown) for Playing. Rects come from tests/helpers/geometry.ts, which evaluates the pure layout function at the default layout (DIFFICULTY_ROW_RECTS, NEW_GAME_START_RECT) — no inline pixels in specs. New tests/new-game-screen.spec.ts: default selection is Normal; a row click moves the selection without starting; Start boots the selected tier; Enter starts on the current selection; the last-used tier persists across a reload; an unknown stored tier falls back to Normal. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh * fix(ui): new-game screen review follow-ups (#304) Adversarial-review findings on the #304 screen, all render/test-side: - Dispatch: the rows and the Start button no longer carry per-object pointerdown handlers. Phaser fires those BEFORE the scene-level handler, so a Start handler that hid the screen let the very same dispatch reach the HUD chain beneath the scrim with the screen already gone (harmless at today's geometry, the speed/pause widget once the Jev opponent section pushes Start down). Hit-testing now lives in the scene-level pointerdown handler (dispatchNewGameClick: Start → commit, row → select, else absorbed), the pause menu's rule. Regression assertion: after Start, speedMultiplier is still 1×, the view is the surface, no overlay is up. - smoke.spec's "underground screenshot" was vacuous once the boot overlays absorbed clicks (both screenshots byte-identical): it now starts a round, clicks VIEW_TOGGLE and asserts activeView === 'underground' first. - Copy precision: hungerTicks accrues only outside Feeding, so the line reads "Spider gets hungry N s after a meal" (clock starts when the meal ends); pinned strings updated. - Negative coverage: Enter on a real Continue/New Game SavePrompt leaves it up (SCEN-04); the touch project drives the screen with page.touchscreen taps (settleToPlaying `via: 'touch'`) so the touch path is pinned. - Website embed: the Enter Key handler ignores events typed into an input, textarea, select or contenteditable (the keydown bubbles to Phaser's window listener); e2e injects a host-page <input> and proves Enter there does not start a round while Enter on the game still does. - Save-fallback paths (corrupt / pre-V22 / future-build save on Continue) boot fresh on the persisted tier instead of a hard-coded Normal; the bootFresh default parameter is gone so every caller states the tier. - Stale "Choose Difficulty" comments in the specs updated. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh * fix(ui): dispatch every boot overlay from the scene-level handler (#304) 77d7062 moved the new-game screen's rows and Start onto the scene-level pointerdown handler but left the GameOver "Restart" and SavePrompt "Continue" / "New Game" buttons on per-object handlers. Those run BEFORE the scene-level handler for the same pointer, and both Restart and New Game synchronously OPEN the new-game screen — so the same click was then hit-tested against the freshly built rows. Before 77d7062 objects created mid-dispatch were not in Phaser's hit list, so this could not happen. Confirmed: GAME_OVER_RESTART_RECT lies inside the Hard row (every Restart selected Hard regardless of the persisted tier); SAVE_PROMPT_NEW_GAME_RECT straddles the Normal/Hard rows. Fix: the single-dispatcher rule now covers all three boot overlays. The GameOver and SavePrompt buttons keep setInteractive() only; their callbacks are captured at show time and dispatched by the scene-level handler (dispatchGameOverClick / dispatchSavePromptClick, checked BEFORE the new-game branch in recomputeActiveOverlay precedence), each branch returning whether or not it hit a button — an opening click can never reach the screen it opened. Specs (tests/new-game-screen.spec.ts): with a persisted Easy (Start on Easy → Save Now → reload), New Game clicked inside the Hard band and inside the Normal band opens on Easy and stays there; GameOver Restart (inside the Hard band) opens on Easy and Start then boots Easy. Game over is reached deterministically through a dev-only __phase9_test.forceGameOver() seam that drives the SAME render-side transition a terminal tick outcome takes — the onTickOutcome body is extracted verbatim into GameScene.enterGameOver(outcome); the sim is never touched. Band points are derived from the exported rects (button ∩ row), so the test throws rather than passing vacuously if a future layout removes the overlap. GAME_OVER_RESTART_RECT is re-exported from tests/helpers/geometry.ts and clickCanvasPoint added to tests/helpers/boot.ts. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
LightAxe
force-pushed
the
feat/jev-opponent
branch
3 times, most recently
from
September 22, 2026 17:34
b0d4a0d to
64d1d6f
Compare
LightAxe
force-pushed
the
feat/jev-opponent
branch
4 times, most recently
from
October 4, 2026 06:45
b0b4c63 to
62d7a65
Compare
This was referenced Oct 4, 2026
LightAxe
force-pushed
the
feat/jev-opponent
branch
3 times, most recently
from
October 10, 2026 16:27
6f4bb8e to
5a34716
Compare
Render-layer only: nothing here touches src/sim/ and no simVersion gate is
involved. These are the pure pieces the Jev opponent is assembled from,
ported from the validated headless spike (plan/jev-player-spike):
- jev-types.ts seat-agnostic vocabulary ({ mySeat, opponentSeat }); no
module here ever names PLAYER_COLONY_ID/ENEMY_COLONY_ID
- jev-candidates.ts raw facts + every legal move this beat, each one mirroring
the tick.ts gate that would accept it
- jev-encode.ts digit-free bucketed state + questions + decode. Jev cannot
count, so every number becomes a word here and the raw
values never leave the render layer
- jev-commands.ts the player-surface allowlist (a hard throw, not a filter)
plus an applied/rejected/no-op ledger. Classification is a
closure captured at push time and asked on the next tick
seam, which drops the spike's PreState union and its
unreachable narrowing guards
- jev-opening.ts the code-owned opening: reuses ai-controller.ts's exported
aiInitialSetup/aiDigHeuristic/aiChamberPlacement verbatim at
the fixed 7:3 forage:fight ratio, so both colonies open
identically. Handoff is a pure predicate over WorldState,
so a resumed save lands in the right phase
- jev-orders.ts standing-orders presets + normalizeOrders (trim, collapse,
300-char cap); balanced = empty = no standing_orders field
- opponent-config.ts OpponentConfig / DEFAULT_OPPONENT, shared by boot, the
save envelope and the playtrace envelope
- jev-client.ts plain fetch against the same-origin proxy. No SDK, no API
key in the browser. Validates ids/keys/state size before
spending a request, and turns every non-200, malformed body,
network error and timeout into a throw
Tests are colocated and offline (the client's fetch is injected). The
candidates/opening tests drive real createScenario worlds through real ticks
and assert that every offered candidate is one tick.ts actually accepts.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
Sits beside runAIController and replaces it for a seat. `onBeforeTick(world)`
is synchronous because the game loop's seam is: the beat request is
fire-and-forget and its decision is stashed by the promise handler, then
applied on a LATER tick seam. No world write ever happens inside a promise
callback. Candidates can go stale in that window; tick.ts rejects those and the
ledger records it, which is the designed behavior rather than an error path.
Shape of a round:
opening — replay the rule-based opening until Queen + Nursery + first
FoodStorage exist, detected from the world (so bootFromSave resumes
mid-round instead of restarting the opening)
live — mark frontier tiles every AI_DIG_INTERVAL ticks in the direction
Jev last chose; fire one beat every `beatTicks` (default 100 =
5 s @ 20 Hz) when nothing is in flight, and push only the settings
that actually change
Failure policy: any rejection — non-200, timeout, network, non-JSON body — is
one failed beat, and so is a throw while decoding an untrusted 200 body. Three
consecutive failures flip `status` to 'fallback' for the round on the next tick
seam: `onFallback()` fires once and runAIController takes over every tick. That
works because the controller never touches world.aiState, so the rule-based
state machine has been advancing in tick.ts the whole time.
Exposes status / beats / failedBeats / lastLatencyMs for a HUD label. Wall-clock
latency is measured in the client — allowed here, never in src/sim/.
Tests use a scripted client over real worlds: inert before handoff, fires on a
beat boundary, does NOT apply inside the promise, applies on the next seam,
re-issues nothing when the answers are unchanged, marks dig tiles only on
AI_DIG_INTERVAL boundaries, skips a beat while one is in flight, and reaches
fallback after exactly three consecutive failures (with runAIController spied
through the real import).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
mount() gains `jevEndpoint`, defaulting to VITE_JEV_ENDPOINT ?? '' and threaded
through the Phaser registry exactly like playtraceEndpoint. Empty string is the
feature flag: no endpoint means the enemy colony is always the rule-based AI, no
network traffic, and a save asking for Jev plays rules silently.
GameScene:
- bootFresh(difficulty, opponent = DEFAULT_OPPONENT); `currentOpponent` holds
what is ACTUALLY driving the round (effectiveOpponent downgrades jev → rules
when the endpoint is empty), so getOpponentStatus() never lies
- both new-game paths call bootFresh(d, this.nextOpponent()), which reads
`pendingOpponent ?? DEFAULT_OPPONENT` — the seam the opponent-picker UI
workstream sets. The retry-same-seed path keeps the round's opponent
- onBeforeTick dispatches per AI colony: the Jev controller when one exists for
that seat, runAIController otherwise. The controller does its own fallback, so
this dispatch never has to change
- isJevAvailable() / getOpponentStatus() for a HUD label; the fallback caption
("Jev is unavailable — the standard AI has taken over") goes through the same
showCaption path as the onboarding captions
Save envelope gains an OPTIONAL `opponent`. It is additive and NOT replay truth
— (seed, inputLog) already contains every command the opponent issued, whichever
policy produced them — so parseSaveFile DROPS a malformed value instead of
throwing, rather than costing a player an otherwise-valid save. Absent means the
rule-based AI, which is every pre-feature envelope. bootFromSave restores it and
builds the controller, which detects opening-vs-live from the loaded world.
save.ts takes the OpponentConfig type through a type-only import (erased at
build time) and keeps its own structural validator beside the other envelope
validators, so platform/ gains no runtime dependency on render/.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
Playtrace envelope gains an additive optional `opponent: { kind, orders }`.
PLAYTRACE_SCHEMA_VERSION is deliberately NOT bumped: the receiving Lambda stores
the raw envelope, so an extra key costs nothing and older readers still see a
valid v2 envelope. It is attached on every submission, survey-only included —
it is the join key for "did the Jev opponent play differently?" — and it
survives the size-downgrade stages because it is set before snapshot shaping.
vite.config.ts proxies `/api` to https://subterrans.com on the dev server only,
so `VITE_JEV_ENDPOINT=/api/jev npm run dev` works against the deployed proxy
without standing the Lambda stack up locally. Verified against a running dev
server: POST /api/playtrace still reaches the local mock (Vite installs
configureServer middlewares ahead of its internal proxy) while POST /api/jev is
proxied upstream. .env.example documents the variable.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
W3 groundwork for the new-game opponent picker: the geometry and the
decision logic, both Phaser-free and fully unit-tested, before any scene
code uses them.
boot-overlay-layout.ts gains `opponentPickerLayout(layout, presetCount)` —
the "Opponent:" toggle pair, the standing-orders preset row, the free-text
rect and the counter/hint footer. It follows the CURRENT layout discipline
rather than the grandfathered constants above it: the horizontal centering
of every row derives from `layout.w`, while canvas-independent values (row
Ys measured from the overlay top, button sizes, gaps) stay plain constants
— the same split survey-overlay-layout.ts uses. `presetCount` is passed in
so the module stays free of the orders vocabulary and the row re-centers if
a preset is ever added.
The difficulty row moves UP (y 260 -> 136) to make room for the section
below it; x/w/h and the centered-as-a-group spacing are untouched, and the
Playwright specs pick the new Y up through tests/helpers/geometry.ts. The
title/subtitle/hint baselines move out of ui-scene.ts into exported
constants so the overlay keeps no inline vertical geometry of its own.
opponent-picker-state.ts is the state machine the overlay drives:
selectPreset / editText / toggleKind / toConfig, plus the counter string.
Two rules it enforces — picking a preset overwrites the free text, and
editing the free text un-highlights every preset ("custom") — and one
guard: `jev` can never be selected or committed on a build with no proxy
endpoint, mirroring GameScene's boot-time downgrade. Every transition
returns a new state object; nothing mutates its input.
Tests pin the rects inside the 800x592 canvas, prove they never overlap the
difficulty row or each other, prove the rows reflow with a wider
LayoutContext, and cover every picker transition including a tampered
over-long persisted orders string.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
W3 — `Settings.opponent` remembers which enemy controller the player last
started a game with, including the Jev standing-orders free text, so the
difficulty-select overlay can pre-select it next time. Default
`{ kind: 'rules' }`, so every existing settings blob keeps loading and every
player who never opts into the beta sees no change.
The OpponentConfig import is TYPE-ONLY, mirroring save.ts: the opponent
vocabulary is owned by the render layer and platform/ must not gain a
runtime dependency on it, so the structural validator is a local function
next to the other field validators. Like save.ts's envelope validator it
checks SHAPE only and deliberately does not cap the orders length — a
tampered localStorage value must not brick the settings file, and the render
layer normalizes and caps the text before it can reach the wire.
`opponent` is an object, so freshDefaults() deep-copies it for the same
reason firstUseHints is copied: handing every caller a reference to the
module-level default is a footgun waiting for the first caller that mutates
it. The copy is an explicit branch rather than a spread so the discriminated
union survives.
Tests cover the round-trip (both kinds, including the empty-orders
`balanced` case), a pre-W3 blob filling the default with no version bump,
every malformed shape falling back to `rules` while valid siblings survive,
an over-long orders string surviving the shape-only validator, and the
fresh-copy-per-load invariant.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
W3 — the overlay shown before every new game (including restart) now also chooses the enemy controller. Below the three difficulty buttons sit an "Opponent:" toggle pair (Standard AI / Jev (beta)) and, when Jev is selected, the four standing-orders presets plus an editable free-text field with a live n/300 counter. The difficulty buttons remain the START action: clicking one commits the difficulty AND the configured OpponentConfig. Where the Jev proxy endpoint is not configured the Jev toggle renders disabled with "(unavailable in this build)" and the choice is pinned to the rule-based AI — the same downgrade GameScene.effectiveOpponent already applies at boot, so the overlay never offers what the build cannot run. The free-text field is a real DOM <textarea> positioned over the canvas, the approach the survey overlay already uses (Phaser ships no text-input primitive, and rolling one from keyboard events would mean reimplementing caret, selection, IME composition, paste and accessibility). Deliberately NOT a Phaser DOM GameObject, so `dom.createContainer` stays off in the game config and the element keeps living in the canvas's own stacking context for shadow-DOM embeds. The two overlays now share createOverlayTextarea / positionDomOverRect instead of duplicating ~80 lines of offsetParent arithmetic; the one behavior change is `box-sizing: border-box`, without which the UA's content-box sizing adds the padding and border on top of the assigned width/height and the element overflows its rect by 14px in each axis — visibly covering the counter line beneath it. Interaction re-renders the overlay in place (destroy + rebuild the Phaser group) exactly like the survey overlay. The textarea is not part of that group, so a rebuild never steals focus or resets the caret; typing only rewrites the counter unless the preset highlight actually flips. The element and its resize listener are torn down on hide, on scene shutdown/destroy, and whenever the picker leaves the Jev branch. GameScene arms the existing `pendingOpponent` seam from the callback and persists the preference. Two deliberate rules there: the in-memory `pendingOpponent` wins over storage when seeding the next overlay (Codex round-6 P2 — a blocked localStorage write must not throw away a choice made two minutes ago), and a build with no endpoint does NOT write its forced `rules` choice back, which would silently erase a Jev preference set on a build that has the endpoint. playwright.config pins VITE_JEV_ENDPOINT empty alongside the playtrace pin, for the same reason: a developer's .env.local would otherwise give their run a standing-orders section CI never renders. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
W3 — while a round runs against the Jev opponent, a small monospace readout
sits in the top-right strip:
Opponent: Jev · beat 12 · 130 ms
Opponent: Jev → Standard AI (fallback)
The latency segment is omitted until the first beat completes, and the whole
label is hidden for the rule-based AI — the historical default gains no HUD
chrome at all, so a player who never opts into the beta sees nothing new.
The anchor joins the pure layout table as `hud.OPPONENT_STATUS`, derived
from `layout.w` like every other right-anchored zone. The Text is drawn with
origin (1, 0) at the rect's RIGHT edge so it grows leftwards into the empty
band between the stats row and the save icon instead of running under
either; a test pins that clearance and the reflow.
The string itself is `formatOpponentStatusLabel` in opponent-config.ts,
next to the vocabulary it formats, taking the `OpponentStatus` shape
GameScene.getOpponentStatus() already returned inline (now a named exported
interface — structurally identical, so no behavior changed). Keeping it pure
is what makes both branches and the null case unit-testable, since the scene
files are excluded from the coverage gate.
UIScene refreshes it at most once a second: the beat counters advance on the
order of seconds, so re-laying out a Phaser Text every frame would be pure
waste. The throttle is time-based, not frame-based, so the cadence is the
same at 30 fps and 144 fps.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
Four findings from the mandatory internal review pass on the W3 diff.
1. Choosing "Standard AI" destroyed the player's standing orders. `toConfig`
returns `{ kind: 'rules' }`, whose union arm has nowhere to carry the text,
so persisting only `settings.opponent` threw away up to 300 hand-written
characters the moment someone played one round against the rule-based AI —
and every later overlay then opened with an empty box. The text now lives
in its own `settings.jevOrders` field (plus a session-level
`pendingOrders`, for the same blocked-storage reason `pendingOpponent`
exists), written whenever a Jev round starts and never cleared by choosing
Standard AI. `createOpponentPickerState` consults it only when the stored
preference is `rules` — a `jev` preference is self-describing and wins.
This also makes `toggleKind`'s "the orders survive a round-trip through
rules" promise true ACROSS overlays, not just within one.
2. `editText` dropped the preset highlight on an input event that did not
change the value. A `compositionend`-driven `input` (IME, some autofill
paths) fires with the text unchanged, which un-highlighted a preset the
player never edited AND triggered a full destroy/rebuild of the overlay. It
now returns the same state object for an unchanged edit, which also makes
`applyPickerState`'s identity check meaningful on this path.
3. The overlay's new hint told players to "set the opponent below first" even
on the default open-source build, where everything below it is one disabled
button and "(unavailable in this build)". Gated on the same `jevAvailable`
flag that decides whether to draw the note.
4. `opponentPickerLayout` produced off-canvas geometry below ~520px wide: the
centering arithmetic went negative and the fixed-width preset row overflowed.
The content column now clamps to the canvas, the kind buttons take their
design width as a MAXIMUM, and the preset row divides the column evenly so N
presets always span it exactly — which at 800x592 with four presets still
evaluates to the same 124px buttons, so no shipping geometry moved (the
pinned-value test proves it). The vertical stack is deliberately NOT made
height-relative: it is a top-anchored stack ~410px tall, and centering that
on `layout.h / 2` pushes its head off any shorter canvas — the same shape
survey-overlay-layout.ts uses. Its height requirement is now an exported
`OPPONENT_PICKER_MIN_H` that a test pins against the shipping canvas, so the
deferred reflow (#213 / Phase 6) has a stated lower bound instead of an
unwritten assumption.
Tests cover all four: the jevOrders round-trip and its wrong-type fallback, the
rules-preference seed path, the unchanged-edit identity, a narrow-canvas sweep
at four widths, and an arbitrary preset count spanning the column.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
The internal review's second finding: the whole interactive half of W3 had no
automated coverage of any kind. `ui-scene.ts` and `game-scene.ts` are excluded
from the unit coverage gate on purpose — they are Phaser scenes, covered by
Playwright instead — and every Playwright project boots with VITE_JEV_ENDPOINT
pinned empty, so the Jev toggle renders disabled, the standing-orders section is
never drawn and the DOM <textarea> is never mounted. Nothing in the suite could
see the feature at all.
`chromium-jev` is a new project with its own dev server on :5174 where the
endpoint IS set. The endpoint points at a path that does not exist and is NOT
under `/api` — vite.config proxies `/api` to the deployed site, and an E2E run
must never reach it. Flipping `isJevAvailable()` is the whole job; the decision
beats then fail locally and the controller falls back to the rule-based AI,
which is a path worth exercising anyway. The :5173 server keeps its pins, so
every existing spec still runs against the open-source default.
Three specs, aimed at the failure modes unit tests structurally cannot reach:
- The <textarea> is mounted only while Jev is selected, is positioned over
the rect the overlay drew for it, and is GONE after the game starts. A
leaked element would sit over the running canvas swallowing clicks — the
one bug only a browser can observe, and the reason this project exists.
- Presets overwrite the field, typing appends without the preset→custom
re-render destroying the element or stealing focus, and the committed
orders reach localStorage normalized.
- A round against the Standard AI keeps the remembered standing orders —
the data loss fixed in the previous commit, pinned end to end.
Click targets come from tests/helpers/geometry.ts, which now evaluates
`opponentPickerLayout` alongside the other pure layout modules, so the specs
stay free of inline pixels (check-e2e-geometry.sh, #186).
Also refreshes two spec comments that rotted when the difficulty row moved to
y=136: Normal's rect no longer overlaps the SavePrompt's Continue button, so a
stray poll-click there now hits nothing instead of pressing Continue. The
helpers' precondition is unchanged; only the failure mode is.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
…ndoff JevEnemyController previously sent its first request only at handoff (~3-4 real minutes in), so the HUD showed "beat 0" and a dead /api/jev couldn't trigger the rule-based-AI fallback until then. Now the very first onBeforeTick call fires one lightweight readiness probe (a single yes/no question, answer unread), and while still in the opening it repeats every beatTicks until one succeeds. A failed probe counts as a failed beat through the existing consecutiveFailures counter, so a dead endpoint now falls back ~15s into the round instead of after handoff. The probe never decodes an answer, stashes a decision, or counts toward `beats`. Exposes `probe: 'pending' | 'ok' | 'failed' | null` on the controller and in OpponentStatus (aggregated across controllers in GameScene.getOpponentStatus as the most advanced state seen). The HUD label now shows "Jev · opening · N ms" once a probe succeeds and "Jev · connecting…" while none has, ahead of the existing beat/fallback forms. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
Contract v2 makes the proxy build the beat's questions itself, one per key under `state.candidates`, so it names them after those keys: the split of workers comes back as `fight_ratio`, while this module's own question map (and every fixture written against it) calls that question `ratio`. `decodeAnswers` now accepts either id and keeps reporting the canonical one in `invalid`. Also documents what the wire actually carries now — the state alone — and why `buildQuestions` stays: it is the readable statement of what the proxy will ask, and the other half of the token estimate. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
The proxy endpoint is now a base path with two routes, and the client owns
the session in between them:
POST <base>/session {} -> { token, expiresInSeconds,
beatBudget, minBeatIntervalMs }
POST <base>/beat { token, state }-> { answers, usage, model }
`state` is exactly what `encodeBeat()` produces; no question text goes over
the wire any more, because the proxy builds the questions itself from
`state.candidates`. `createJevClient({ base })` returns `mintSession()` +
`beat(state)`: `beat()` mints lazily (no session, one inside the renew
margin of its expiry, or one whose beat budget is spent) and, on the two
session-death codes — 401 invalid_token and 403 budget_exhausted — mints one
replacement and retries the beat exactly once. A 429 too_fast is never
retried: it is simply a failed beat, like every other non-200, malformed
body, network error and timeout. Per-request timeouts stay at 8 s.
The controller's readiness probe becomes that mint — the cheapest request
that proves the endpoint is alive, and one the round needs anyway, so the
first real beat reuses the session it left behind. Everything else is
unchanged: the opening lock, the dig cadence, apply-on-next-tick, the
three-failure fallback and OpponentStatus.
game-scene builds one client per AI seat rather than sharing one: a client
owns one session, and a session carries a token, an expiry and a budget that
two controllers should not be spending on each other's behalf.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
VITE_JEV_ENDPOINT / MountOptions.jevEndpoint now name the proxy's base path and the client POSTs to `<base>/session` and `<base>/beat`. Both still fall under the `/api` prefix the dev server proxies, so `VITE_JEV_ENDPOINT=/api/jev npm run dev` is unchanged, and the chromium-jev E2E project's stub base is still outside `/api` — its first request (the session mint) 404s locally and nothing reaches the deployed site. Comments only; no behavior change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
…ate state
The `balanced` preset used to BE the empty orders string ("send no
standing_orders field"). Now every preset — including `balanced`, which is
the DEFAULT — carries tuned, non-empty text (per the 2026-09-19 sweep), and
an empty orders string is its own deliberate state, "no standing orders at
all", reached only by clearing the text box. Bring the rest of the codebase
in line with that:
- jev-orders.ts: doc the new semantics; export DEFAULT_ORDERS_TEXT (=
balanced's normalized text).
- opponent-picker-state.ts: doc-only — presetMatching/selectPreset/editText
already treat every preset generically, so no behavior change was needed
there; clarified where the "balanced is the default" behavior actually
comes from (settings.ts's default, not this module).
- settings.ts: DEFAULT_SETTINGS.jevOrders now duplicates the balanced text
(mirrors the existing MAX_OPPONENT_ORDERS_LENGTH duplication in save.ts,
to keep platform/ free of a runtime dependency on render/); a
settings.test.ts check cross-references the two so they can't drift.
- ui-scene.ts: the standing-orders hint note now has three states (preset /
custom / "No standing orders — Jev decides on its own.") instead of two,
since custom-with-text and cleared-to-empty are no longer the same thing.
- Updated jev-orders.test.ts, opponent-picker-state.test.ts, settings.test.ts
and tests/jev-opponent.spec.ts (Playwright) for the new semantics; the E2E
spec's "Standard AI" test now fills the textarea instead of typing into it,
since the box is no longer empty by default.
npm run verify, `playwright test --project=chromium-jev`, and npm run build
all pass.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
…sive=opportunist, Economy=steward Jev-vs-Jev round-robin (8 texts × 6 seeds × both seats, 336 matches): boom_then_bust 75.0% (Wilson 64.8–83.0, no losing matchup, 40% of wins by queen kill); opportunist 63.1% with assaults in ~70% of matches; the old 'strike early, accept losses' text finished last (28.6%, zero queen kills — it starved). Steward is the survival-sweep winner (never assaults). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
The Jev opening replayed the rule-based AI's build order: dig an 18-row
shaft five tiles at a time, place Queen -> FoodStorage -> Nursery, and only
hand off once all three had finished excavating. Tick ~4,400 on average —
three real minutes in which the model opponent had no say over its own
colony.
A human does not open like that, and the command surface does not ask it
to. `MarkDigTile` has no reachability requirement at all, and v5+
`PlaceChamber` accepts an anchor on Solid or Marked dirt as long as the
footprint would be connected once every Marked / BeingDug tile is
excavated (`isFootprintReachableAfterDigs`). So the opening now PLANS the
nest and lets the colony catch up:
tick 0 mark the entrance spine, rows 1..13
tick 1 place Queen (5x3) at row 11 beside the spine, Nursery (4x3) and
the first FoodStorage (4x3) at row 4, one either side of it
tick 2 handoff — `isOpeningPlanned` counts a pending chamber as placed
The placements land a tick after the marks because that is the mechanism,
not a schedule: a footprint is only reachable once the spine beside it is
non-Solid, and the marks are still in the command queue when the planner
runs. No phase flag — the gate is the world.
Row 11 rather than the AI's `AI_QUEEN_CHAMBER_DEPTH = 18`: nothing in the
sim reads chamber depth, and the extra rows cost the colony's single
digger ~7 rows of spine before the queen can move in and start laying. The
digger works the plan in the background right through the live phase,
which is why `digDirection` stays 'hold' until Jev's first beat says
otherwise — frontier marks would compete for that one digger.
Measured over seeds 1-5 with a FakeClient answering
economy/recall/hold/none and the rule-based AI on the other seat, old ->
new:
handoff tick 4446 -> 2
FoodStorage built 4151 -> 323
Queen chamber built 4165 -> 592
Nursery built 4446 -> 639
first egg 4447 -> 640
workers @ tick 8000 9 -> 18
The planner is a pure function of WorldState: it re-derives what is
missing every tick and only marks Solid tiles, so a save taken mid-plan
resumes without re-issuing anything, and there is deliberately no
"already issued" flag anywhere — the colony's own state is the latch, so
a push that lost a full drain is simply retried next tick rather than
lost for the round. Everything it pushes, the ratio included, comes out of
one `MAX_COMMANDS_PER_TICK` budget, and it declines to push into a drain
that has no room.
Anchors are validated against a mirror of the tick.ts gates before they
are pushed — extracted out of `findReachableChamberSpot` as
`isChamberAnchorPlaceable` / `chamberFootprints`, which the planner drives
by the plan instead of by spread score, and which
`findReachableChamberSpot` now uses verbatim (differentially proven
behavior-preserving). An anchor that is refused, that the plan's own
mirroring put on top of a neighbour, or that something is permanently
parked on, falls through to the generic search — but never on the tick the
spine is still queued, because a spot chosen against a two-tile component
anchors the nest to the surface. All 128 entrance columns plan by tick 2
with the ledger reporting 0 rejected.
`isHandoffComplete` survives as the stricter "the nest is actually built"
predicate — no longer the handoff gate, but exactly what the candidate and
live-phase test fixtures want to run a world up to.
No `src/sim/` change and no simVersion gate: this is a render-layer policy
issuing the same player commands it always did.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
…#310) main #310 retired the SyncAIState echo and deleted resetAIControllerCache with it, so the three Jev suites that reset the echo's change-detection cache between runs no longer compile after the rebase. Nothing replaces the call: the sim reproduces aiState under tick()-only replay now, so there is no render-side cache to clear. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
…ce, Jev options only when selected (#304) Items 3–4 of #304 on the Jev beta branch, rebuilt on main's new-game screen (#312) instead of the old difficulty-buttons overlay: an explicit Opponent section between Difficulty and Start, the Jev options shown only once Jev is selected, and the free-text box captioned for whose orders they are. The screen, top to bottom, on a build with a Jev endpoint: Difficulty (main's three radio rows, unchanged) Opponent two radio-style rows with a one-liner each — "Standard AI · The built-in rule-based enemy colony." "Jev (beta) · TypeSafe's Jev model plays the enemy; you can instruct it." Jev options ONLY while the Jev row is selected: "Custom instructions for Jev, your opponent" (+ n/300 counter), the four standing-orders presets, and the free-text box Start game (main's single Start; Enter also starts) Defaults are Normal + Standard AI; nothing above Start starts a round. On a build with no endpoint no section is drawn at all — the screen is main's, pixel for pixel — so Standard AI is implied rather than shown disabled (the plain-build specs pass with no geometry change). - boot-overlay-layout.ts: the section is laid out INSIDE the stack's opponentSlot (opponentSectionH / opponentSectionLayout / newGameScreenWithOpponent), so it inherits the LayoutContext discipline and the stack re-centres around it. Its height follows the picker: caption + two 30 px rows collapsed, + caption line / presets / 46 px free-text rect expanded — 190 px, exactly what keeps the fully expanded stack inside the shipping canvas with NEW_GAME_STACK_MIN_TOP clear at both ends (pinned by a test). The old top-anchored opponentPickerLayout (and its hint "Set the opponent below first", moot now that rows do not start the game) is gone. - opponent-copy.ts: the section's strings, pinned by a test that also guards each row's one-liner against wrapping. - ui-scene.ts: the section draws from the same re-render-in-place path as the difficulty rows; ALL clicks dispatch through dispatchNewGameClick (Start → commit, difficulty row → select, opponent row → toggleKind, preset → selectPreset, else absorbed — no per-object pointer handlers). The free-text box is a DOM <textarea> from the shared overlay-field factory (keydown stops propagation, so Enter inside it never reaches the Enter-starts binding; the caption doubles as its aria-label), torn down on hide, on leaving the Jev row and on scene shutdown, and never part of the Phaser group so a re-render keeps focus and caret. A canvas click blurs it explicitly — Phaser preventDefault()s the canvas mousedown, so the browser would otherwise leave every later key in the box. commitNewGame reads the picker's config BEFORE hiding. __phase9_ui.selectedOpponent is published alongside selectedDifficulty. The n/300 counter follows the drawn caption rather than sitting at the column's right edge, where the HUD view-toggle shows through the scrim. - opponent-picker-state.ts: re-selecting the lit preset returns the same state object, so the overlay's identity check skips a needless rebuild. - game-scene.ts: dev-only __phase9_test.getRoundOpponent() so a spec can prove Start booted the selected opponent. - tests: geometry.ts exports the Jev-build rect sets for BOTH picker states (the stack moves between them); boot.ts gains selectedOpponent; jev-opponent.spec.ts pins the defaults, options hidden until Jev, the caption, nothing-above-Start-starts, Enter inside the box not starting, persistence across reload, and textarea teardown. Render-only: no sim change, no simVersion bump; settings persistence (opponent / jevOrders) is unchanged from the branch. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
…andard AI (#304 review) The four no-screen boots in bootFromSave (corrupt envelope, future / old simVersion, deserialize failure) passed only the persisted difficulty, so the default opponent applied and a tester whose save failed to load silently got a rules round. They now boot `persistedOpponent()` — the choice armed this session, else the stored preference — and bootFresh still downgrades a Jev request when the build has no endpoint. Spec hardening: the "Enter inside the instructions box does not start" half now also asserts the newline landed in the box. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh
… main Main's food rewrite (#290, V50+) replaced `world.foodPiles` and the `foodStored` scalars with the located food store behind `sim/food/food-api.ts`. The Jev facts now read piles with `forEachPile` (sizes still in whole pickups, `amountFp >> PICKUP_SHIFT`, so the encoded `pileSize` buckets and the /api/jev vocabulary are unchanged), totals with `colonyFoodTotal(world, colony)` and capacity with `colonyFoodCapacity`; the "no food priority" path finds the current pile with `pileSlotById`. Tests use the food test utils instead of the retired fields. Main moved the game loop's onBeforeTick into `beforeSimTick` (sim-tick-hook.ts, #397); the Jev seat now reaches it through an optional per-colony dispatcher argument. The source-text wiring test accepts that sixth argument, and a new case pins that a passed dispatcher replaces runAIController while the snapshot is still taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FYjk3HATGSjFxy9tREbV2W
… the rebase onto V71 main From #400 (V71) a spider priority lasts until it is called off or the spider dies; the sim no longer ends it at a feed, hunt end, rampage end or chase divert. Jev is only asked about the spider while it is within SPIDER_NEAR_TILES of its nest, and the rule-based AI never touches spider priority, so a priority Jev gave would send every surface fighter after the spider across the map for the rest of its life. Jev now calls its own priority off on a beat that did not ask about the spider, and on the tick it falls back to the rule-based AI. A priority the player gave is never touched. Also pins the V71/#412 integration points the rebase crosses: - hud-layout: the opponent-status label stays above the tool palette and the new spider-order chip. - chromium-jev e2e: a Jev round that fell back ends with #389's title and cause line (DRAW, "Both colonies ran out of food — a draw"), Restart clears them and reopens the new-game screen on Jev, and the next round's end screen carries nothing over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FYjk3HATGSjFxy9tREbV2W
All four standing-orders presets rewritten as playtest 5 proposed (plan/playtest-5 RESULTS.md B6): grow first, add a Food Storage when the stores pass three quarters, mass the army at home and attack all at once, come home when an attack stalls or the stores run low, ignore the spider. Balanced is the one a stand-in tested (balanced3: 6/8/6 of 10 against the scripted human and the Normal and Easy novices, half its assaults killed the queen); the other three follow the same rules untested. The 2026-09-19 tuning notes predate V72/V73 and are retired. settings.ts's duplicated default text follows Balanced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
opponent_colony.workers_vs_ours bucketed ours ÷ theirs under the opponent's key, so far_more meant WE have far more. It now sends their workers ÷ ours (same labels, so no proxy change); with no workers of ours it is overwhelmingly more, with none on either side equal. brood_vs_workers (brood ÷ workers) already read the right way round and is the only other ratio field. The spider's prowling_near_us threat word is keyed on SPIDER_NEAR_TILES (24, the radius the spider_priority question is asked within) instead of the bucket table's first distance threshold, which fine buckets put at 12: a spider 13-24 tiles off would otherwise read distant beside distance_to_us near. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
…he egg-reserve bound (#436) expand_storage was offered at 80 % with no other check, so a yes every time built 21-26 larders a game (50-70 for a big colony; the rules AI has 11-14 by 8:00). It is now offered from 75 % of capacity, never while one of our Food Storages is pending, and not once capacity reaches 3x the egg reserve — the rules AI's own bound (aiExtraFoodStorageWanted, AI_STORAGE_RESERVE_MULTIPLE). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
…s, pace beats at 4x (#436) - assault = RaidType.Assault: the rally had no raid type, which tick.ts reads as Loot, so raiders looted the larder before going for the queen. A Loot rally already on their door is re-sent as an Assault. - Muster: an assault answer keeps the rally on our own entrance (guard_home) until at least 14 fighters exist and 80 % of them are home (underground in our nest, or on the surface within 12 tiles of our entrance; a fighter in an enemy nest is away). Once the rally is on an opponent entrance Jev's answers are followed as given. Playtest 5: onset 3 v 11 became 14-18 v 7-9. - Fine buckets by default (every fine label is in the proxy vocabulary). - At 4x a 100-tick beat is 1.25 s of wall clock, under the proxy's 2 s floor, so every other beat came back too_fast. The beat interval is now scaled by game speed so a beat is never less than 2.5 s of wall clock after the last (beatPaceFactor: 100 ticks at 1x and 2x, 200 at 4x), and never fewer ticks after the last than that interval (a switch to 4x right after a beat). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
The counter-attack caption (#429) keys on the rules AI's invasion_end fighter rout plus its Invading -> Recovery transition. Jev attacks with a rally on the player's entrance and the AI state machine it leaves running never ends an invasion it did not start, so the caption fired 0 times in 30 stand-in games. GameScene now names the Jev-driven seats as rally attackers (setRallyAttackers; a seat that falls back to the rules AI leaves the list). For those, noteCounterAttackTick watches the rally: when it leaves the player's entrance (recalled, sent home, retargeted elsewhere) the assault is over, and the caption is owed as of that tick if the seat's whole army is below the tier's base invasion need — the rout path's own broken-army test, cooldown, copy and army gate. "Invades again", which lapses the follow-up, is the rally back on the player's entrance (the ghost AI state reading Invading means nothing for a Jev seat). Rules-AI attackers are unchanged. GameScene also hands each Jev controller the live speed multiplier, which paces its beats. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
… difficulty rows and plays at Normal Rob's decisions (2026-10-09, after playtest 5): - Difficulty under Jev. With Jev selected, the new-game screen leaves the difficulty section out of the stack (boot-overlay-layout difficultyHidden / difficultyHiddenFor) and the match starts at Normal (opponent-config matchDifficulty, applied in bootFresh to the EFFECTIVE opponent, so the save-recovery fallbacks get it too; a Jev request downgraded to the Standard AI keeps its tier). The player's tier is kept, unseen, and comes back with the Standard AI row; a Jev round does not overwrite the persisted tier. Saves are unchanged: a Jev match is created at Normal, so it saves and loads at Normal. - Default opponent. On a build with a Jev endpoint the screen opens on Jev with the Balanced preset (defaultScreenOpponent) unless the player chose an opponent earlier this session (restart, retry, next New Game), which is kept. A choice from an earlier visit (settings.opponent / jevOrders) no longer pre-selects the screen; it still seeds the save-recovery fallbacks. A build with no endpoint still defaults to the Standard AI and never shows Jev. UIScene publishes difficultyRowsVisible for the e2e. The chromium-jev spec covers the default, the hidden rows and Normal, the Standard AI's tier, session retention across Restart, a new visit reopening on the default, and the no-endpoint server (:5173) defaulting to the Standard AI with a Jev preference stored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
…off on fallback, Jev subtitle Fable review of the refresh (round 1): - Counter-attack caption against Jev: an assault by rally is owed the caption only if it was ROUTED — its army at the end no more than half its peak while the rally was on the player's door (COUNTER_ATTACK_RALLY_ROUT_PCT) — as well as below the tier's base need. The muster sends 14 fighters, one under Normal's base need of 15, so an intact army called home before contact read as "broken". - Falling back to the rules AI calls off any rally Jev gave, as it already did the spider priority: an Assault rally on the player's door would otherwise keep feeding every drafted fighter into their nest with nobody directing it. - The storage question also treats a Food Storage PlaceChamber still queued for this tick as pending (a decision applied on a beat tick queues it just before the beat builds its candidates). - The command ledger counts a rally whose raid type changed as applied, not a no-op (diagnostic). - With the difficulty rows hidden, the new-game subtitle (which is about the tiers) gives way to "Jev always plays at Normal difficulty; the presets below set how it plays." - Comments: the beat-pacing margin, the muster's home entrance, and that the playtest-5 muster rates came from the scratch knob. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
…ption Fable review round 2 (verdict clean, two nits): a rally first seen on the player's door with no fighters (peak army 0) that ended would have owed the caption (0 is at most half of 0, and below the base need). The routed test now also needs a non-zero peak. A comment notes that fighters a ratio change re-tasks while the rally is still on the door count as lost, as on the rout path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
…s home (Haiku-vs-Jev findings) - Muster visible: while an assault musters (rally held at home), current_posture now reports 'assault' instead of 'guard_home'. Measured: a stateless Jev could not tell gathering from guarding, so most answers cancelled the muster. A failed/invalid posture answer now also keeps the muster going. - expand_storage noul threshold 0.5 -> 0.4 (JEV_EXPAND_STORAGE_NOUL_MIN). Measured: its noul sat in 0.38-0.58 on every ask, so 59% of offers it should have accepted were declined. spider_priority stays at 0.5. - Stalled assault comes home: after contact, 600 ticks (60 s) with no queen HP drop and no kill of theirs sends the army to the guard tile (or clears the rally). Measured: stalled assaults fed newly drafted fighters into the enemy nest one at a time until Jev called them off. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
…the watch, our-side queen damage only - JEV_ASSAULT_STALL_TICKS 600 -> 1200 (60 s at 20 Hz); comments and tests fixed. - A retarget to another opponent entrance starts a fresh stall watch. - A queen HP drop is progress only with a fighter of ours in their nest. - Kill window is (tick - STALL, tick], matching the HP path. - Guard tile derived on demand (guardHomeTile, shared with buildCandidates). - decodeAnswers posture fallback prefers guard_home over recall. - Real-sequence test through the sim; comment/title nits. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
…mments say what the code does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
…nvaders in our nest (P2 fields) RawFacts gains ownArmy/oppArmy (Fighting anywhere, the sim's aiFighterCount), both queens' HP/max HP, and oppFightersInOurNest. encodeBeat emits our_colony.army, queen_health (both colonies, via enemy-queen-wound's woundLevel so the words match the HP bar/caption), opponent_colony.army_vs_ours and fighters_in_our_nest. workersVsOurs is renamed theirsVsOurs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
…nt test buildQuestions / assault describe carry the same strings the Lambda now forwards. A copy of the server's jev-vocab.json plus a test checks every bucket label, queenHealth word and ratio/dig/posture/food key against it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
Fable round 2: the server's canonical assault text was 204 chars, and the client sends its mirror as the candidate description, which the proxy caps at 200 (a 400 on every beat offering an assault). Shortened to 190 on both sides; a test now encodes beats for both seats and modes and checks every description sent fits the cap. Also: every sim spider state, lower-cased, is a spider behaviour word (exhaustive over the union). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014f19cRizFGHLP5SS7if1Qn
LightAxe
force-pushed
the
feat/jev-opponent
branch
from
October 11, 2026 16:56
5a34716 to
cd3ae03
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Draft / beta — not for merge yet. Lets the player pick a Jev-driven enemy colony instead of the rule-based AI. The enemy is driven through the player command surface by TypeSafe's Jev model behind the website's same-origin
/api/jevproxy; the rule-based state machine stays intact and takes over after 3 failed beats. Playtest build: https://subterrans.com/beta/jev/ (unlisted).src/render/jev-*.ts: seat-agnostic candidate generation, digit-free bucketed state encoding, allowlisted command issue path, opening scaffold (reuses the rule-based opening), fire-and-forget beat client,JevEnemyController(apply-on-next-tick, readiness probe at tick 0, fallback torunAIController).opponent-config.ts+ save envelopeopponentfield (optional; absent → rules) + playtraceopponentfield (additive).mount({ jevEndpoint })/VITE_JEV_ENDPOINTfeature flag (empty → option hidden); Vite dev proxy for/api;chromium-jevPlaywright project.src/sim/change, no simVersion bump; the rules path is byte-identical with the flag off.Origin: the headless Jev-player spike (instructability 7.3× above noise; paired judgment vs random-policy +0.18–0.23, p≈1e-4).
Test plan
npm run verifygreen (3,162 tests);npm run test:coverage90.4% stmts; Playwright 33/33 across chromium / chromium-jev / chromium-touch / webkit./api/jevserved by subterrans-web PR Controls Rework #18.🤖 Generated with Claude Code
https://claude.ai/code/session_01Wnk2sCfgZTMftaaWShvjdh