Skip to content

feat(farming-analyzer): model encounters, combat styles and map difficulty - #35

Merged
zoeyrose merged 4 commits into
mainfrom
feat/encounter-model
Nov 25, 2026
Merged

zoeyrose merged 4 commits into
mainfrom
feat/encounter-model

Conversation

@zoeyrose

@zoeyrose zoeyrose commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

The farming analyzer now models encounters per map, so a spot's safety depends on how many monsters a pull really brings and on how the character fights.

The motivating case: on 2026-11-25 the playtester character Sera, a level 37 melee fighter with minor healing, died four times in the Burnt Forest. Every Burnt Forest circuit scored safety 1.0. The old estimate, min(1, HP / (danger × max_aggro_pack)), uses only the direct aggro pack. Authored spawns there are more than three tiles apart, so that pack is always 1. In reality packs of 3–8 formed from wanderers (random_move), chases of up to 9 tiles, and retreats past other spawns.

Changes

Encounter model (farming_analyzer/encounter.py). For each map it reads:

  • spawn positions and density;
  • aggressive or passive;
  • detection radius, plus 3 once engaged;
  • chase range max(9, item_power);
  • ally calls: a one-in-monster_signal_chance[Int] chance per AI action, read from server/living.c, answered by allies within 1.5 × item_power − 1 tiles or by spawn points with the same title;
  • wanderers and their item_race × item_level limits;
  • casters, with damage types from their ability spells resolved through include/spellist.h;
  • archers;
  • spawns on tiled neighbour maps, shifted into the map's frame.

It also reads the terrain: walkable regions, open fields, kite room, doorways, corridors, dead ends and crossable seams.

Every heuristic cites the server code it stands for by file and line. The server and content are read as data at runtime, and no GPL code is copied.

How a map is rated.

  • Pull square. For each target, the model picks the best walkable square to pull from.
  • Clear. It clears the map easiest-first, removing each pull's expected joiners. A wanderer that joins one pull is not counted again.
  • Expected and bad pull. It reports the expected and bad-pull (worst-case) attackers. The bad pull uses the engaged radius, the style's worst footprint, and every wanderer or ally call more likely than not to join.
  • Cost. It computes each pull's HP trough on a timeline that knows when each monster arrives, net of --healing-per-second.

Combat styles. --combat-style takes melee, melee-pack, ranged-kite or aoe-kite. Each style has its own footprint.

  • Kiters keep slower melee monsters off only where there is kite room and while escape directions stay open: each attacker beyond the first closes one of eight. Nine or more slow attackers hit a kiter as hard as a melee character.
  • The stepping-away time penalty shrinks with the same open-directions share, so a pinned kiter pays none.
  • Each kiting pull is also costed standing and fighting the same pack, and the cheaper of the two is taken. Kiting therefore never costs more than standing.
  • Casters, archers and monsters at least as fast as the character hit at full rate in every style.
  • Player speed comes from --character-speed through the same server conversion as route timing. Without it, the documented assumption is speed 1.0, which is 8 tiles/s at the default tick.
  • --kite-distance sets how far a kiter moves.

Unkillable targets. An aggressive, damaging target the character cannot hurt (infinite kill time) makes the pull not farmable: its need is infinite and the map's encounter safety is 0. Its spreads, calls and arrival times use a 120 s horizon. An unkillable monster that deals no damage is left alone and never pulled. Single-target styles also leave alone an unkillable passive monster.

AoE provokes passives. Under aoe-kite, passive monsters inside the AoE footprint are hit, turn on the character and join the pull. So a passive, damaging, unkillable one makes the pull not farmable.

Safety. encounter_safety = 0.75 × (1 − need/HP) + 0.25 × 1/(1 + bad-pull need/HP). It is not saturated in either direction.

Backward compatibility. Without --combat-style, safety_score and every existing field are unchanged. The new fields are reported for melee with encounter_applied: false. With a style, spot_safety_score is the lower of the old estimate and encounter_safety. JSON adds "schema_version": 2 (version 1 had none). --ignore-encounters turns the model off.

Designer report. python3 -m farming_analyzer report [--path …] [--levels auto|20,30] [--styles …] [--json] gives per-map and per-zone difficulty by level band and style. Each map lists:

  • terrain;
  • spawns, with pull squares and wander boxes;
  • hotspots: hardest pull, dense clusters, wanderer overlap, casters and archers, guarded chokepoints, seam reach;
  • the reasons behind each rating.

It rates a documented reference character, scaled per level and calibrated on Sera. The JSON schema (atrinik.farming_analyzer.difficulty_report v1) is documented in farming_analyzer/README.md for Tilewright to integrate later; it is not integrated here. The README also lists the next increments: line of sight, retreat paths, ranged cadence, steady state, patrols, zone routes and a Tilewright overlay.

Results on real content. Sera's live kit at L37: HP 333, AC 58, WC 44, DAM 82, 3.0 s weapon, speed 0.8, impact 38 and cleave 39, healing 5.5 HP/s.

Map Monster levels Old safety Melee encounter safety Expected / bad-pull attackers
world_16_74 L31–33 1.00 0.79 1.3 / 9
world_17_74 L32–34 1.00 0.76 1.6 / 7
world_17_72 (two deaths) L38–40 1.00 0.47 1.0 / 8
world_15_75 L26–29 1.00 1.00 1.8 / 4
world_16_75 L27–30 1.00 0.97 2.7 / 5
world_16_76 L26–29 1.00 1.00 1.8 / 6

With kiting crowded by pack size:

  • ranged-kite rates world_16_74 at 0.78, against 0.79 for melee. Both bad pulls hold 9 attackers, which pin a kiter. The kiter's bad pull spans 4 tiles instead of 3, so it gathers slightly different members (2,085 against 1,833 HP).
  • On the L38-40 world_17_72 the kiter rates 0.81 against melee's 0.47. Small slow packs rate far safer for kiters (unit-tested).
  • Accepted limits, documented in the README:
    • the kite-or-stand comparison holds within one pull only. A kiter can still rate below melee across styles because the bad pulls hold different monsters (kite-distance footprint 4 against 3);
    • the standing alternative reuses the kiting timeline for wanderer spread and arrivals.
  • On the review's synthetic hordes the bad-pull need is now ordered. A 20-monster pack costs melee 40,400 HP, ranged-kite 39,744 and aoe-kite 10,500 with 4 targets; a 36-monster pack costs 130,000, 129,044 and 33,300.
  • aoe-kite rates world_16_74 at 0.01, with a 16-attacker bad pull. Before the review fix it rated 1.00.

The Forgotten Graveyard (world_14_74) at night flags its skeleton mages as fire/weaponmagic/cold casters.

Tests

  • python3 -m unittest discover -s farming_analyzer/tests -t .: 94 OK. That's the 53 existing tests plus 41 new ones in farming_analyzer/tests/test_encounter.py:
    • Unit tests: pull cost, safety shapes, terrain (doorway, seams, open field, dead ends), sparse vs dense packs, pull-square choice, wanderers used up by the clear, ally calls by title and faction, walls stopping melee but not casters, the four styles, healing, hotspots and reasons.
    • Synthetic authored world: backward compatibility without a style, the saturated tie broken by --combat-style, kiting, caster damage types from ability, relative mode, CLI JSON schema_version and validation, and the report schema and text.
    • Review regressions:
      • kiting never costs more than standing for the same pack, across speeds, kite room and pack sizes 1–36;
      • 20 and 36 hordes cost a kiter no more than melee;
      • harmless or passive immune monsters are left alone by single-target styles;
      • a passive immune brute next to a normal brute under aoe-kite (4 targets) makes the pull not farmable, and killable passives in the AoE footprint join;
      • an immune target next to a wanderer in every style, a 20-attacker slow pack not rated safe for kiters, static monsters neither calling nor answering, a called passive ally fighting, slow_move idle speed, circuit fields from one member, seams with no crossable tiles omitted, missing living.c/spellist.h warnings, and the firestorm spell index read from the server table rather than assumed.
    • Content-backed BurntForestTest: content-dependent, so it asserts ranges and orderings and is skipped with a CONTENT-DEPENDENT reason without the checkout.
      • World_16_74 forms a pack (bad pull ≥ 2) and rates clearly below its old score for the L37 melee healer.
      • The southern maps rate safer and world_17_72 rates hardest.
      • AoE kiting the big treant packs is not safe.
      • The graveyard casters are flagged.
      • A whole-content scan of a fire-only character finishes, marking the fire-immune maps not farmable. Before the fix this crashed.
  • python3 -m unittest discover -s tests: 12 OK.
  • python3 -W error -m compileall -q -f . and git diff --check are clean.
  • Performance: a full L37 scan takes about 10 s either way. A whole-world report --json takes about 34 s (354 maps, 56 zones).

Follow-up for atrinik/playtester

farm_analyzer.py runs a locked analyzer release, so nothing changes for Sera until:

  1. this merges and the tools release that contains it is published;
  2. the playtester's analyzer lock is bumped to that release's archive digest;
  3. the lock's classic_server.required_paths includes server/living.c and include/spellist.h. Without them the analyzer warns and skips ally calls or spell damage types;
  4. farm_analyzer.py passes her style, healing and speed: --combat-style melee --healing-per-second <measured, about 5.5 with minor healing> --character-speed 0.8. A bow or wand build would pass ranged-kite, an AoE caster aoe-kite with --targets-per-attack.

Optionally:

  • switch the #130 pack cap from max_aggro_pack to expected_pack or worst_pack;
  • surface encounter_reasons in her decision log;
  • read schema_version before relying on the new fields.

Not verified

  • Calibration. The heuristics are calibrated on one character and one zone. With Sera's kit the Burnt Forest ordering matches the deaths, but nothing has been checked against live fights.
  • Report reference character. Its per-level defaults are calibrated on Sera alone. At bands equal to the monsters' level it rates many maps deadly for melee. Designers should review the defaults (--hp-per-level and related flags) before relying on absolute labels.
  • Not modelled: line of sight, doors, scripted AI, patrol move_type, ranged-attack cadence (shooters use their melee cadence), and steady-state respawn order.
  • Documented server deviations:
    • factions allied only through an alliance parent are not linked;
    • sleeping or blind monsters' halved detection is ignored;
    • the bad pull's 3-tile margin on idle bystanders is a deliberate safety margin with no server basis;
    • chase_range is reported but not used by the estimate.
  • CI: CI runs only tests/, so the analyzer suite, including the content-backed test, ran locally only. Adding farming_analyzer/tests to check.yml is deferred scope, not infeasible. The suite needs the classic server source (exp.c, config.h, living.c, spellist.h) and content. check.yml already checks out content pinned by a lock, so a locked atrinik/classic server/src checkout can be added the same way. It is listed as a next increment in the README.
  • Review: an independent review of 7b77dc9 found two P2s and several P3s, addressed in 0de0144 (CI gating deferred). A delta review of 0de0144 found one P2 and three P3s, addressed in bbc87e0. A delta review of bbc87e0 found only P3s, addressed in this head. This last delta has not been reviewed yet.

🤖 Generated with Claude Code

…culty

Safety saturated at 1.0 on every Burnt Forest circuit because the direct
aggro pack of spread-out spawns is one, so the playtester kept choosing
maps where packs of three to eight formed from wanderers, chases and
retreats.

Add an encounter model per map. It reads spawn positions, aggression,
detection and engaged radius, chase range, ally calls by Int and spawn-point
title, random_move wanderers and their limits, casters with spell damage
types, archers, and terrain: walkable regions, kite room, open fields,
doorways, corridors and seams, including spawns on tiled neighbours. It
estimates the expected and bad-pull attackers from the best pull squares in
an easiest-first clear, and the health trough of each pull on an
arrival-aware timeline against the character's healing.

--combat-style (melee, melee-pack, ranged-kite, aoe-kite) with
--healing-per-second and --kite-distance makes that style-aware safety part
of safety_score. Without it, existing outputs are unchanged and the new
fields are reported; JSON gains schema_version 2.

Add a `report` subcommand with a documented JSON schema for map makers and
the Tilewright editor: per-map and per-zone difficulty by level band and
style, hotspots and the reasons behind each rating.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

zoeyrose and others added 3 commits November 25, 2026 16:19
A target the character cannot hurt has an infinite kill time, which
overflowed the wanderer spread and stopped the whole scan whenever an
aggressive wanderer was near. Such pulls now use a finite horizon for
spreads, calls and arrivals and are reported as not farmable.

Kiting uptime ignored pack size, so huge slow packs rated perfectly safe.
Each attacker beyond the first now closes one of eight escape directions,
and the player-speed default is an explicit, documented assumption.

Match the server more closely: slow_move halves only idle speed, called
passive monsters fight, and directly placed monsters neither call nor
answer; the alliance-parent and sleep deviations are documented. Circuits
take all pull and safety fields from one member, seams without crossable
tiles are omitted, and missing living.c or spellist.h warns instead of
silently degrading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Once a pack pinned a kiter, the stepping-away penalty still lengthened
every kill, so nine or more slow attackers cost a kiter more than a melee
character. The penalty now shrinks with the open escape directions, and
each kiting pull also costs the same pack standing and fighting and takes
the cheaper of the two.

An unkillable monster that is passive or deals no damage is now left
alone instead of making the whole map lethal. The README states the CI
gap as deferred scope and the report's map list as attackable
spawn-point monsters, passive ones included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An AoE attack damages every monster in its footprint, and a damaged
monster turns on its attacker, so under aoe-kite a passive monster inside
the footprint joins the pull. An unkillable passive monster that deals
damage is therefore not left alone for AoE styles; only one that deals no
damage is.

Document the accepted limits of the kite-or-stand comparison: it holds
within one pull, not across styles with different bad pulls, and the
standing alternative reuses the kiting timeline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zoeyrose

Copy link
Copy Markdown
Member Author

Self-review of origin/main..401c137: 7b77dc9, 0de0144, bbc87e0 and 401c137.

Reviewed:

  • An independent fresh-context review of the whole diff at 7b77dc9. It checked:
    • the server mechanics it cites;
    • the playtester's parsed fields: the default (no --combat-style) scan is identical for every field the playtester reads, and the only new key is schema_version;
    • the provenance boundary: no GPL code or text copied; tables are parsed at runtime;
    • determinism and performance.
  • Fresh-context delta reviews of 7b77dc9..0de0144 and 0de0144..bbc87e0.
  • My own review of bbc87e0..401c137, including running its new test against bbc87e0's code (it fails there and passes at 401c137).

Findings on 7b77dc9, fixed in 0de0144:

  • P2: int(sweep) crashed on infinite kill time on the default path. Fixed: horizon() caps it at 120 s, and an unkillable damaging target is not farmable. Regression and whole-content tests added.
  • P2: kiters rated huge slow packs perfectly safe. Fixed: avoided uptime shrinks with the number of attackers. Player speed is an explicit, cited assumption.
  • P3s fixed:
    • slow_move 1×/3×;
    • static monsters never call;
    • called passive monsters fight;
    • the +3 is called a margin;
    • README wording;
    • single-member circuit fields;
    • zero-tile seams omitted;
    • source_warnings when living.c or spellist.h is missing;
    • test robustness and read_spell_table.
  • Documented as deviations: alliance-parent factions, and the sleep/blind radius halving.

Findings on 0de0144, fixed in bbc87e0:

  • P2: at 9 or more attackers a kiter cost more than melee. Fixed: the attack-time penalty is scaled by open directions, and _cheaper_pull takes the cheaper of kiting and standing within a pull. Tests: kiting never costs more than standing; hordes of 20 and 36.
  • P3: a harmless unkillable monster made the map lethal. Fixed: it is skipped (left alone).
  • P3: the CI deferral reason is corrected (deferred scope, not infeasible), and the maps[] wording is fixed.

Findings on bbc87e0, fixed in 401c137:

  • P3: "left alone" was unsafe for AoE. Fixed:
    • AoE styles skip only zero-DPS unkillables;
    • passive monsters inside the AoE footprint are provoked and join from the first second (types/monster.c find_enemy attacked_by);
    • a damaging unkillable monster in the footprint is not farmable.
    • Tested.
  • P3, documented as accepted limits: the kite-or-stand comparison holds within one pull only (styles can catch different bad-pull members); the standing alternative reuses the kiting timeline for arrivals.

Accepted and declined:

  • The analyzer suite is not yet in CI. That is deferred scope: a locked atrinik/classic server/src checkout like the content one. It is in the README as the next increment.
  • The model is calibrated on one character and one zone, and the report's reference-character defaults need designer review. Both are documented.

Checks at 401c137:

  • analyzer tests pass (94 OK), and root tests pass (12 OK);
  • compileall -W error and git diff --check are clean;
  • CI is green;
  • Burnt Forest spot-checks: melee 16_74 0.79 against the old 1.00, 15_75 1.00, 17_72 0.47; aoe-kite 16_74 0.01.

Playtester follow-up (separate PR):

  • release tools;
  • bump the analyzer lock and add server/living.c and include/spellist.h to classic_server.required_paths;
  • pass --combat-style melee --healing-per-second <measured> --character-speed <hers>.

@zoeyrose
zoeyrose marked this pull request as ready for review November 25, 2026 23:29
@zoeyrose zoeyrose self-assigned this Nov 25, 2026
@zoeyrose
zoeyrose requested a review from a team November 25, 2026 23:29
@zoeyrose
zoeyrose merged commit 594c759 into main Nov 25, 2026
8 of 9 checks passed
@zoeyrose
zoeyrose deleted the feat/encounter-model branch November 25, 2026 23:35
zoeyrose added a commit to atrinik/playtester that referenced this pull request Nov 26, 2026
…#140)

## Summary

On 2026-11-25 Sera died four times in the Burnt Forest. Every spot there
rated safety 1.0 and direct pack 1. This PR locks the farming analyzer
v3.11.0 (https://github.com/atrinik/tools/releases/tag/v3.11.0, from
atrinik/tools#35) and runs its encounter model
on her real style, healing and speed.

The owner decided to **keep the XP choice and warn only**. That was
shown with what ranking by the model would cost: her estimated XP
falling from 6.1 M to 0.76 M an hour. Her spot ranking, safety, risky
floor, the pack cap from #130
and the seam-exposure adjustment are all identical to main's.

**Lock**
- `farming_analyzer` moves to v3.11.0 (commit `594c759`,
`sha256:650ad637…`).
- `classic_server.required_paths` gains `src/server/living.c`,
`src/include/spellist.h` and `src/include/config.h`. The analyzer reads
these for ally calls, caster damage types and server constants. The
locked v5.99.0 server archive already contains them.
- THIRD_PARTY_NOTICES and the README install line are updated.
`preflight` verifies the release on GitHub.

**Two runs, and why**

With `--combat-style`, v3.11.0 lowers `spot_safety_score` to min(old
estimate, encounter safety). `safety_score`, the balanced and safety
scores, and those views' order follow it, and the old estimate is not
reported separately. So the ranking and the encounter model run
separately.

- **Ranking run.** She chooses by this run. It passes no style, and it
re-runs only when main would: `materially_differs` (which no longer
includes style or healing), a savebed change, or 6 h. It also passes
`--healing-per-second`, which feeds only the encounter model.
- **Encounter run** (`_run_encounters`: its own task and process; her
ranking never waits for it). It passes:
- `--combat-style`: `melee` with her weapon; `ranged-kite` while
Wizardry trains with spells only, mirroring
`FarmTask.spell_only_training`;
- `--healing-per-second`, measured: the median of her landed heal-spell
casts (potions and scrolls excluded), over a swing plus a 1 s cast (the
cadence from #128), capped by
SP regeneration at her cheapest heal's cost. This is documented as an
upper bound. Her live heals have a median of 12 HP, so she passes 3
HP/s;
  - `--character-speed`;
  - `--top 5000`, so every ranked candidate gets a rating.
- **When the encounter run runs.** Not until a heal has landed. With 0
HP/s every pull would rate as unhealed and nearly every spot would warn.
After that it runs for each new ranking, and at most every 10 min for a
new style or a 15% healing change; neither re-runs the ranking. A failed
run keeps the ranking, shows on the Farming tab, and is retried after 15
min. A ranking that falls due first kills a running encounter run, so
the two never share the host's cores. A result that outlives its ranking
attaches nothing.
- **Merge.** Encounter fields attach to spots with the same path and map
paths, because a circuit's path names only basenames. An identity the
run rates two ways is skipped rather than mis-attached. Only schema-2
reports with `encounter_applied` are read.

**Warn only**
- `farm-spot-selected` is unchanged from main.
- Whenever her spot's rating changes, the farm circuit records a
`farm-spot-encounter` decision with the style, encounter safety,
expected and bad-pull packs, and the first three `encounter_reasons`.
That covers the spot it starts on, a switch, and a re-rated spot. A spot
left unrated keeps what was noted for it.
- If the spot's `encounter_safety` is below 0.8 or its `worst_pack` is
above 6, she also records a `farm-spot-encounter-warning`, and the
warning is kept on the client together with its circuit.
- The dashboard's `farm-encounter` warning alert reads that state, and
only while autoplay's child is that circuit. So it ends when autoplay
farms another circuit, leaves farming or stops, and it does not depend
on the 2,000-entry decision history.
- The Farming tab adds an "Encounters" line per spot, flagged when it
warns, with every reason in its tooltip. The thresholds are documented
in COMBAT.md, "Encounter warnings".

**Real-content check** (her live state, locked bundle, the real world
graph, through `FarmAnalyzer._run` and `analyzer_farm_selection`)
- Every view's old fields and order are identical between this branch's
ranking run and main's invocation (no style, no healing).
- Measured: the ranking run takes 26.5 s and the encounter run 26.4 s on
this machine.
- She farms the same spot as main: `circuit[world_16_72 + world_17_72 +
world_17_73 + world_18_73]`, at 6.3 M XP/h.
- It now carries the warning: "encounter safety 0.33 < 0.8, bad pull 8 >
6", with `world_17_72`'s reasons.

## Tests

- Full suite: `run_tests_parallel.py --workers 12` ran 1414 of 1414 OK
(after merging origin/main d8cd223).
- CTest 3/3 passed. compileall, py_compile and `git diff --check` are
clean.
- `doctor` passes against a bundle installed offline from the new lock.
`preflight` passes; its first attempt reported a transient
`lock-availability` error and the rerun passed.
- New or changed tests:
-
`AnalyzerFarmSelectionTests.test_spot_choice_is_unchanged_by_encounter_fields`:
with schema-2 data present, the pick and the seam ranking equal those
for the same spots without encounter fields, for any-pack, cap-2 and
cap-1 kits, and seam exposure folds in as before.
-
`AnalyzerFarmSelectionTests.test_the_selected_spot_records_its_encounter_reasons_and_warning`:
the warning decision and alert appear for a dense spot (worst_pack 9,
encounter safety 0.79) and not for a sparse one, and
`farm-spot-selected` keeps main's text. The alert ends once autoplay's
child is another circuit or none, and survives a cleared decision
history.
-
`AnalyzerFarmSelectionTests.test_the_spot_she_starts_on_is_warned_about_and_re_rated`
covers:
    - the spot a circuit is created on;
    - no re-record while unchanged;
    - re-rated safe, then dangerous;
    - unrated after a failed run;
    - a new circuit on a safe spot.
-
`FarmAnalyzerTests.test_the_analyzer_runs_with_her_style_healing_and_speed`
checks that:
- the ranking run comes alone and has no style, and her ranked fields
stay pre-encounter. The fake analyzer lowers them under a style, as
v3.11.0 does;
- the encounter run's arguments carry `--combat-style melee`,
`--healing-per-second 5.1`, `--character-speed 0.8` and `--top 5000`;
    - a hung encounter run doesn't hold up her ranking;
- a ranking that falls due cancels the hung run, attaches nothing, and
leaves a fresh encounter run due;
- an encounter run that outlives its ranking attaches nothing (this
catches the mutant without the generation check);
- a healing change re-runs only the encounter run, onto the same ranking
report;
    - a failed encounter run is retried after the backoff;
    - no encounter run happens before a heal has landed;
    - healing and style never count as `materially_differs`.
-
`FarmAnalyzerTests.test_encounter_ratings_attach_only_to_the_same_spot`:
two circuits sharing a basename path get their own ratings, and an
identity rated two ways is skipped.
-
`FarmAnalyzerTests.test_encounter_fields_are_read_only_from_a_schema_2_report`:
schema gating, the summary and warning text, and the thresholds.
  - The two Wizardry tests now assert her style.
- The `test_compatibility` lock tests cover the new release, digest and
required paths.
- **Against the previous head aeebdfd's code:**
- `test_encounter_ratings_attach_only_to_the_same_spot` fails (path-only
keying gave both circuits one rating);
  - both alert tests fail (no circuit-bound warning state);
- `test_the_analyzer_runs_with_her_style_healing_and_speed` hangs past a
200 s limit (its ranking waited for the hung encounter run).
- **Against main's code** all of these fail. The choice-equivalence part
of `test_spot_choice_is_unchanged_by_encounter_fields` would pass on
main by design; it is a guard, and it fails there only on the new
`encounter_warning` import. Against this PR's previous head (e73cdf1),
which demoted and capped dense spots, its choice assertions would fail.

## Review

- **Previous design.** Independent reviews of fc3d68c and aec74c5 found
no P1s. Their fixes still apply here: heal attribution reads the whole
time window, the heal and hit text is stripped, the style mirrors
`spell_only_training`, and the dashboard guards `encounter_reasons`.
- **Warn-only rework.** An independent review of a9f0986 confirmed that
her choice is unchanged: `risky_spot`, `spot_safety`, `seam_adjusted`
and `seam_ranking` are byte-identical to main, and
`--healing-per-second` without a style feeds only the encounter fields.
It found one P1, fixed in 5f9b1e8: the warning never fired for the spot
autoplay starts a circuit on. Also fixed there: re-rated spots, the
encounter-run retry and its error line, Python-driven dashboard flags,
and `arguments()` defaulting to unstyled.
- **Declined from that review:**
- path keying across directories with the same basenames, the same
keying main uses;
- a larger `--top` for the encounter run, harmless at about 199
candidates;
  - the cancel window in subprocess creation, the same window main has.
- **5f9b1e8.** A delta review found one P2, fixed in the head commit: a
warning could linger into a new circuit. Its P3s are fixed there too:
the duplicate rating on a switch, the retry re-running the ranking, a
stale error, and a failed run clearing a warning. Those fixes, in
aeebdfd, were checked only by the tests and not reviewed again.
- **aeebdfd.** An independent review found no P0/P1; it confirmed that
healing without a style changes no ranked field, that the merge can't
overwrite ranked fields, and that the lock tarball matches `git archive
v3.11.0`. Fixed in 2ba8e67:
- **P2:** a healing or style change re-ran the ranking, so her pick
could drift from main's. Now only the encounter run re-runs.
- **P3s:** the ranking waited for the encounter run; the first run rated
healing as 0; the healing estimate is now documented as an upper bound
with the cheapest heal's cost; the alert went stale and depended on the
decision history; ratings could attach to the wrong circuit when
basenames collide; spots beyond the encounter run's `--top` went
unrated; the run-time estimate was off.
- **2ba8e67.** A delta review found every fix correct and no P0–P2. Its
three P3s are fixed in the head commit:
  - a ranking that falls due now cancels a running encounter run;
  - the generation guard is now tested;
  - the encounter run's `--top` is now asserted as the literal 5000.

This test fails against 2ba8e67 (`CancelledError not raised`) and
against a mutant without the generation check.
- **60d86c5.** A follow-up found a race. An encounter process that has
exited but hasn't been reaped yet makes `kill()` raise
`ProcessLookupError`, which would have surfaced inside `poll()`. Fixed
in 4bbebbd: the cancel path, the encounter run's own cancel path and the
shared timeout kill now suppress it. Its test, where `kill` raises and
`poll` still starts the ranking, fails against 60d86c5. The head commit
has not been reviewed again.

## Not verified

- **Calibration.** The 0.8 and 6 warning thresholds are calibrated on
one character and one zone, as is the analyzer's model.
- **Cost.** The encounter run is a second `nice`d analyzer process,
about 15 to 30 s, after each ranking and on a healing or style change.
- **Healing estimate.** It is a median of landed heals, and a heal near
full HP reports less, so the estimate is low. Nothing was checked
against live fights.
- **Commit footer.** The merge commit has no Co-Authored-By line. I did
not amend it, as asked.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant