Skip to content

feat/phase8 faction clocks - #61

Closed
qclayssen wants to merge 115 commits into
Bobby-Gray:mainfrom
qclayssen:feat/phase8-faction-clocks
Closed

qclayssen wants to merge 115 commits into
Bobby-Gray:mainfrom
qclayssen:feat/phase8-faction-clocks

Conversation

@qclayssen

Copy link
Copy Markdown
  • fix(display): check_input drains the queue in --lan mode
  • chore: add Strixhaven map reference page and Kairos level 1 fixture
  • feat(srd): structured monster actions for the combat engine
  • feat(tactics): deterministic grid combat engine core
  • docs: CLAUDE.md for the tactical-combat fork; tactics_rules interface in SYSTEM-PORTING
  • fix(display): check_input only reads the queue file when the display is down
  • fix(tactics): review fixes for sight, diagonals, previews, Dodge and flat damage
  • feat(tactics): battle maps as painted rectangles
  • feat(tactics): GM command line, enemy options, sheet sync and demo
  • docs: grid combat GM loop, /gm combat grid, player guide
  • feat(display): grid combat endpoints
  • fix(tactics): Roll for me keeps the rolls already made
  • feat(display): GM_DISPLAY_PORT to run a display on another port
  • feat(display): the grid combat panel
  • docs(CLAUDE.md): workflow notes for the next milestone sessions
  • docs: one file per milestone; CLAUDE.md keeps only what every session needs
  • scripts/world.py: faction clocks for off-screen NPC actions
  • fix(world): utf-8 file I/O and os.replace for the faction clock files
  • feat(srd): spell mechanics, monster saves and passive Perception, structured riders
  • feat(grid): areas of effect (sphere, cylinder, cone, line, cube)
  • test(grid): fix the wall area expectation
  • feat(tactics): effects, concentration, spell reactions and structured riders
  • feat(tactics): cast spells, area previews, Help, Hide, Escape, Ready, breath weapons
  • feat(cli): cast, preview-area, spells, use, help, hide, escape, ready, trigger, reactions
  • test(tactics): spells, templates, saves, concentration, reactions, riders, Help, Hide, Ready
  • feat(demo): Kairos vs an ice mephit (Frost Breath, Fire Bolt, Shield on auto)
  • docs: milestone 4 (spells and templates), GM loop, player guide, porting interface
  • fix(tactics): review findings on milestone 4
  • feat(display): cast list, area templates with fail % and friendly fire, Help, Hide, Escape, Ready
  • world.py: utf-8 file I/O and os.replace for the atomic write
  • fix: second review pass on milestone 4
  • grid: memoize cover per board
  • tactics: Multiattack, smarter enemy menus, and rules fixes
  • multiattack: pass --react answers from the CLI; never retarget onto a hidden creature
  • fix(tactics): a speed change mid-turn changes the movement left
  • localdm: chat client for OmniRoute combos, with a usage log
  • localdm: parse narration and the escalate/command JSON block
  • localdm: transcript, rolling summary and flags per campaign
  • localdm: DM prompt, state.md digest and a budgeted prompt builder
  • localdm: run tactics commands in-process and snapshot the fight
  • localdm: deterministic advisor triggers from the combat snapshot
  • localdm: boss means 3x the top PC max HP (2x flagged a giant frog)
  • localdm: advisor council on the smarter model, asked in parallel
  • localdm: background summarizer keeps the prompt small
  • localdm: the session loop and REPL (one DM call per turn, advisor on call)
  • localdm: rarer escalations, GM_FAST_MODEL for picks and summaries, advisor /no_think
  • docs: milestone 6 local DM (spec, plan, OmniRoute setup, findings)
  • docs(milestone 6): rerun numbers and the under-escalation finding
  • docs: the dm- OmniRoute combos as created, tiered by cost*
  • localdm: send reasoning_effort=none on local calls (GM_REASONING)
  • localdm: GM_LOCAL_URL sends the local tier straight to Ollama
  • docs(milestone 6): DM benchmark, reasoning_effort and OmniRoute timeout findings
  • localdm: shadow advisor reviews each turn in the background for the next
  • docs(milestone 6): shadow advisor, Ollama settings, open items
  • docs(milestone 6): drop the stale main-branch test note (fixed in Sync arc system, campaign import, and Live State Flags from claude-dnd-skill #5)
  • tactics: fog of war and sight (visible_from, sight.py, players' snapshot hides unseen creatures)
  • cli: sight and fog commands
  • display: sight is a browser read from creatures on the players' map
  • display: fog, cover shading, condition badges, keyboard cursor, accessibility pass
  • tests: fog, sight, leaks and theatre-of-the-mind parity
  • docs: milestone 5 shipped, findings, decisions, open
  • sight: redact whole names only; hide an unseen creature's turn economy (review)
  • tactics: choose auto picks for enemies with no model
  • localdm: grid combat on the engine, the model only at big moments
  • docs(milestone 6): combat autopilot, live runs on 5 maps and 4 local models
  • display: readable move range, enemy reach hatch, panel in the display's palette
  • localdm: mirror narration to the display (display_bridge.py)
  • localdm: grid combat follows the display; --no-display silences it (review)
  • fix(spells): look up a spell again when it was cached from an older SRD build
  • feat(tactics): a playable grid-combat tutorial in the terminal
  • feat(display): start-display.sh --campaign, preflight checks, any port
  • fix(display): player actions and dice results reach the GM; /gm new resets the display
  • docs: how to start a campaign with the display (docs/FIRST-SESSION.md)
  • test(preflight): run preflight.py with the real environment
  • fix(display): review fixes for Windows consoles and the ready queue
  • fix(display): scene words match whole words; waiting badge docks under the scene name
  • fix(display): review findings: atomic .input_queue, preflight finds legacy campaigns, cancelled rolls
  • docs(milestones): 5 and 6 done; review findings from Sync: GM_CAMPAIGN_ROOT, /gm path, /gm update from claude-dnd-skill #8, sync v0.7.0 — campaign-graph implementation + version tracking + two bug fixes #9, sync v0.8.0 — deterministic extractor + Phase 2.5 (supersede-edge + category nodes) #10 recorded as open items
  • fix: playtest fixes for display map scroll, animation, brackets and local DM
  • Playtest fixes: display map scroll, animation, brackets, local DM (sync from claude-dnd-skill: NPC rename + name registry + creation hooks #15)
  • docs(milestones): 5 and 6 done; review findings from Sync: GM_CAMPAIGN_ROOT, /gm path, /gm update from claude-dnd-skill #8, sync v0.7.0 — campaign-graph implementation + version tracking + two bug fixes #9, sync v0.8.0 — deterministic extractor + Phase 2.5 (supersede-edge + category nodes) #10 recorded as open items (sync from claude-dnd-skill: graph init mandatory at /gm load + archive compression #14)
  • localdm: narration guardrails (agency guard + retry), player sheet digest, stricter DM prompt
  • Local DM from the browser: party push, ability checks rolled in the display, display directives, campaign notes and sheet spells for the DM, resume from the shown scene
  • Point SRD build at the live 5e-srd-api repo; add SRD attribution NOTICE
  • NOTICE: state license relied on and modifications; milestone 7
  • fix(build_srd): handle Foundry advancement stored as a dict keyed by id
  • fix(localdm): no live model narration in engine fights; one summary at the end
  • fix(localdm): review fixes: clear fight log on manual end, cap it, guard digits at reaction prompts
  • fix(localdm,tactics): B1 multi-word names, B5 attack then retreat, P1 healthy melee beasts, DM prompt rules
  • feat(skill): add Applied Standard 14 for direct decision-point prompts (probe(persistence_v2): multi-turn story-persistence battery #22)
  • feat: in-fiction wait phrasing during subagent/advisor delays (Bake display-off state persistence into SKILL.md #23)
  • fix(localdm): refuse player-issued system instructions (D1 injection grant) (release: v0.13.0 — system-agnostic character UI + model-agnostic GM hint #28)
  • fix(localdm): keep the first draft when a guardrail retry is also dirty (B3) (Add Chaosium BRP (Basic Roleplaying) system module #31)
  • fix(tactics,localdm): a narrated fight starts without typed placements (B1, B2) (Add systems/brp/ui.json so BRP renders a character sidebar #32)
  • feat: off-screen faction clocks — the world moves on in-game time (Phase 8)

qclayssen and others added 30 commits September 25, 2026 00:27
The drain request sent the LAN token as X-Token, but the app's _token_ok()
reads X-DND-Token, so every drain was rejected with 403 in --lan mode. The
fallback then parsed wrapper.py's plain-text .input_queue as JSON, failed
silently, and never read player_input.json, the file the app persists the
drained queue to. Queued player actions were lost.

Send X-DND-Token, fall back to player_input.json, and wrap the script body
in main() so it can be tested. Tests read the header name and file name
from the app source so the two cannot drift again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The map table page is the visual reference for the tactical grid display
(player-facing copy: DM-only maps and undiscovered places removed). The
Kairos sheet is the player-facing fixture for tactics tests and the demo
encounter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each monster record gains an 'actions' list with attack bonus, reach,
range, damage dice, save DC, area and multiattack parts, parsed from
upstream fields and the fixed SRD phrasing. Anything that does not fit a
known shape keeps its raw text and a flag saying why (rider, targeting,
damage_choice, success_conflict, unparsed, ...). Nothing is guessed:
where upstream's success_type contradicts its own text, on_success is
left empty and flagged.

Damage that only a rider deals (a bite's poison on a failed save) is
moved to rider_damage so it is never applied on every hit.

A golden file generated before this change pins every existing field and
the formatted lookup text byte for byte. The --json dump gains the new
field; nothing else changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The engine owns the rules; the LLM only narrates and chooses.

scripts/tactics/ (stdlib only):
- grid: 5 ft squares, terrain legend, 2014 diagonals or the 5-10-5
  variant, Dijkstra movement with difficult terrain, crawling, swimming
  and creature spaces, no squeezing between corner walls, DMG corner
  line of sight and cover (walls, creatures and features)
- state: encounter.json with validation on load and save, atomic
  writes and a .bak of the previous version
- roller: reuses scripts/dice.py's parser, seedable, tags every roll
  engine / player / verbal, raises PendingRoll instead of inventing a
  player's roll; 'Roll for me' hands one roll back to the engine
- rules: thin system interface (attack, hit chance, save, damage,
  conditions, movement cost, action economy) loaded from
  systems/<system>/tactics_rules.py
- engine: initiative, turns, movement with opportunity attacks
  resolved before leaving reach, Dash/Disengage/Dodge, stand up, undo
  until an action locks movement in, death saves at turn start, and
  BG3-style previews: reachable and dash squares, path cost, OA
  warnings with hit chance, ranked targets with expected damage

systems/dnd5e/tactics_rules.py: 2014 advantage/disadvantage from
conditions, crits and auto-crits, cover, resistances (conditional ones
are surfaced, not applied), temp HP, dropping to 0, massive damage,
death saves, and an SRD monster adapter.

68 hand-checked tests (diagonals, difficult terrain, cover, opportunity
attacks, crits, death saves, player rolls, crash-safe saves).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in SYSTEM-PORTING

CLAUDE.md: the core principle (engine owns the rules), the DM_SEALED rule,
architecture, commands, milestone checklist and decisions on record.
SYSTEM-PORTING.md: how another system plugs into grid combat through
systems/<system>/tactics_rules.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…is down

If the display answers the drain with an HTTP error, or the response times
out, the app still holds the queue in memory. Reading and clearing
player_input.json then would deliver the same actions again on the next
successful drain. Fall back to the file only when the connection itself
fails; otherwise report the error on stderr and print nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…flat damage

- grid: floor() instead of int() when enumerating cells, so a sightline
  along the top or left map edge cannot slip past a wall
- 5-10-5 diagonals: parity is kept in TurnState across move commands
  and restored by undo, so splitting a diagonal move no longer makes
  every diagonal cost 5 ft
- preview_move: opportunity attack hit chance uses the real distance
  (a reach-10 attack on a prone crawler has disadvantage)
- Dodge is a token flag, not a pseudo-condition, and its benefit ends
  at speed 0 as well as when incapacitated (PHB)
- roller: flat damage is never asked of a player; source 'fixed'
- one average() helper in roller replaces two copies; the Grid is
  cached on the Encounter; reachable() runs Dijkstra once for walk
  and dash

Each bug has a regression test that fails on the previous code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
display/maps/*.json holds the five player-facing maps from the
Strixhaven reference page (Mage Tower, Firejolt rooftops, Detention Bog,
Frog Pond, blank 24x16), in the reference's own format: rectangles
painted over a base terrain. scripts/tactics/maps.py compiles them into
the engine grid, validates them and keeps labels, zones and spawn points
for the display. The reference's DM-only maps are not ported.

Adds 'void' terrain (a drop or gap: blocks movement, not sight).
display/maps/README.md documents the format for new maps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/tactics/combat.py (logic in tactics.cli, so it never collides
with scripts/combat.py): one call per command, 1 to 4 plain lines,
--json for the display. start/status/options/choose/move/preview/attack/
dash/disengage/dodge/stand/death-save/undo-move/end-turn/condition/
adjust/log/reachable/end. A player's roll under roll_mode players stops
the command with exit code 2 and nothing changed; re-run with --roll N,
or --for-me. Opportunity attack choices use --react yes|no.

- ai.py: deterministic numbered options with hit chance, expected damage
  and tags (can finish them, lowest AC, stay out of melee, flee below
  25% HP, avoid opportunity attacks); choose runs one
- tactics_sheet.py: reads the markdown character sheet into a token;
  writes back HP, temp HP, spell slots, hit dice, death saves and
  lasting conditions only
- sync.py: tracker.json, display sidebar (/stats) and grid snapshot
  (/combat), state.md Active Combat, and on end the campaign sheet
  (with .bak and a short diff) and a 3 to 5 line session-log summary
- demo.py: Kairos vs two SRD giant frogs on Frog Pond in a throwaway
  campaign, printing every command a GM would run
- the rules interface gains token_from_sheet, token_from_monster,
  write_back and lasting_conditions; riders print as 'GM decides the
  rider'; a PC stopped by an opportunity attack before stepping says so

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- scripts/tactics.md: the loop a small model follows (options, pick a
  number, choose, narrate; wait for the player; re-run on exit code 2),
  loaded only when grid combat starts or resumes
- SKILL-commands.md / SKILL-branches.md: /gm combat grid <map>, a table
  row and a three-line branch; /gm combat start is unchanged
- docs/TACTICAL-COMBAT.md: player guide and GM command reference
- CLAUDE.md: milestone 2 done, decisions on record

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tactical grid combat: engine core and GM command line
- POST /combat: the engine's snapshot after every command, broadcast as
  a 'combat' SSE event and replayed to browsers that connect mid-fight
- GET /combat/state: the current fight for a page opened mid-combat
  (asks the engine if the app restarted)
- POST /combat/do: a player's click runs through the same CLI the GM
  uses, one command at a time. Mutating commands need the LAN token, an
  approved device, the rate limit, and act only for the player whose
  turn it is. Rolls from the browser are logged as the player's own. A
  pending roll or decision returns without changing anything. Each
  result is queued as the player's action, so the GM sees it via
  check_input.py and narrates it.
- CLI: read-only 'targets' (every attack and target with hit chance)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
'Roll for me' switched the whole action to engine dice, so a player who
had rolled the d20 and then asked the engine to roll the damage got
their d20 thrown away and re-rolled. The engine now rolls only what the
player has not supplied, and the log keeps each roll's own source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app and the engine's sync both used localhost:5001 unconditionally,
so a second display (a test or a demo) could not run beside a live one,
and engine pushes could land in whatever else held that port.
GM_DISPLAY_PORT moves both; unset, nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vanilla JS and SVG, no build step (display/static/tactics.js and
tactics.css, colour tokens and terrain palette from the Strixhaven
reference page, light and dark). index.html gains a stylesheet link, a
script tag and one line in the SSE handler.

- appears on the first 'combat' event, hides after 'Combat over'
- map with terrain, labels and zones; tokens with HP bars, current
  actor ring, dead tokens faded; initiative strip; turn banner; log
- on the player's turn: click the token for walking range (shaded by
  cost) and dash range (dashed); hover for the path and feet, red with a
  warning when it provokes; click to move (tap twice on a phone)
- action bar: Attack and Cast highlight every target with hit chance;
  Dash, Disengage, Dodge, Stand, Undo move, End turn; Help and Hide
  greyed out until milestone 4
- roll prompt: type your roll, roll in the browser, or Roll for me;
  opportunity attack choices as Yes / No
- movement animated along the path, damage and healing floaters, a
  toast with each roll and its source
- phone width: the panel sits above the page's sidebar and settings,
  the map scrolls, Hide map folds it

Verified in a real browser at 1400 px and 375 px: start, reach, move,
Cast Fire Bolt with a typed and a browser-rolled die, end turn, GM
turns from the CLI updating live, end of combat hiding the panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tactical grid combat: the battle map in the display (milestone 3)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… needs

docs/milestones/ holds each milestone's goal, what shipped, findings,
decisions and open items (01 to 03), and the plan and open questions for
04 and 05. CLAUDE.md drops the milestone detail (146 to 122 lines) and
points at the file for the milestone in progress.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Faction clocks track progress toward goals (Blades in the Dark style)
- Ticks follow in-game time (days/weeks), not sessions
- Hidden rolls for faction actions (1-3: no progress, 4-5: +1, 6: +2)
- GM hold/release veto for story control
- Progress history log per faction
…uctured riders

build_srd keeps what the engine needs to cast spells on the grid (casting
time, range, attack or save, damage by slot or character level, area),
monster save and skill proficiencies, and structures the common rider shapes
(grapple with escape DC, save or condition, save for damage). Qualified riders
stay text for the GM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTTfx17pXWqfP9pCgSuyFk
Centre-of-square rule, true geometry, walls block line of effect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTTfx17pXWqfP9pCgSuyFk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTTfx17pXWqfP9pCgSuyFk
… riders

- core.py: helpers shared by the engine modules; decide() for reactions
  (per-token ask | auto | off, GM creatures take useful ones)
- effects.py: timed and linked effects (start or end of the source's next
  turn, concentration, repeat saves), grapples, Shield and Silvery Barbs
  as reactions to a hit, concentration saves after damage
- 5e rules: effective AC, advantage from Help, Hide and Silvery Barbs, Mind
  Sliver penalty on the next save, cover on DEX saves, save chance for
  previews, monster save proficiencies, skills and passive Perception,
  recharge and per-day usage
- engine: riders applied (grapple and restrained, save or prone, save for
  damage), recharge rolls at turn start, hidden creatures revealed
- sheet: known spells, spell DC and attack, level, skills, passive Perception

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTTfx17pXWqfP9pCgSuyFk
… breath weapons

- spells.py: cast (spell attacks, saves in areas with one damage roll and a
  save per creature, Magic Missile darts, healing, Mage Armor, narrated
  spells), the bonus-action spell rule, slots, range and sight checked before
  anything is spent; preview with each creature's chance to fail and expected
  damage (allies flagged); castable list; monster area save actions with
  recharge and per-day use
- tactics_spells.py (5e): SRD mechanics plus hand-written numbers for Mind
  Sliver and Silvery Barbs; conditions on a failed save for common spells
- actions.py: Help, Hide (no line of sight, Stealth vs passive Perception,
  ties to the hider), Escape a grapple, Ready an attack, spell or move, and
  trigger it as a reaction
- ai.py: breath weapon options scored by expected damage over save chances,
  recharge tags, grapplers keep their target, hidden creatures untargetable,
  concentrating casters tagged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTTfx17pXWqfP9pCgSuyFk
…, trigger, reactions

A paused command (waiting for a roll or a reaction decision) keeps its seed
and the decisions asked so far in combat/pending.json, so the re-run replays
the same engine dice. --react can be repeated, one answer per decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTTfx17pXWqfP9pCgSuyFk
…ders, Help, Hide, Ready

Hand-checked with scripted dice; the CLI tests cover loose spell words,
read-only previews, and a paused reaction replaying the same enemy roll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTTfx17pXWqfP9pCgSuyFk
…on auto)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTTfx17pXWqfP9pCgSuyFk
…ing interface

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TTTfx17pXWqfP9pCgSuyFk
qclayssen and others added 28 commits September 26, 2026 07:57
display: readable move range, enemy reach hatch, panel in the display's palette
# Conflicts:
#	CLAUDE.md
#	docs/milestones/README.md
#	scripts/tactics/cli.py
Milestone 6: local DM with a smarter advisor
…rded as open items

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ocal DM

- keep board scroll and bring the acting token into view
- clamp move animation frame time (negative k crashed)
- stop stripping plain [bracketed] words from narration
- close the fight once after the last kill; drop enemy menu labels from prose
- bare number with no pending roll never reaches the model; resolve multi-word token names

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* docs(milestones): 5 and 6 done; review findings from #8, #9, #10 recorded as open items

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix: playtest fixes for display map scroll, animation, brackets and local DM

- keep board scroll and bring the acting token into view
- clamp move animation frame time (negative k crashed)
- stop stripping plain [bracketed] words from narration
- close the fight once after the last kill; drop enemy menu labels from prose
- bare number with no pending roll never reaches the model; resolve multi-word token names

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
…rded as open items (#14)

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
…gest, stricter DM prompt

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…isplay, display directives, campaign notes and sheet spells for the DM, resume from the shown scene

Found playing the new campaign (ember-hollow) in the browser with Haiku as DM:
- the party never reached the display, so Party input could not be readied
- [[narration length]] lines from the display were ignored (or read as a target)
- advisors and the DM saw no world/NPC notes and no spells, so they invented facts
- a fireball was cast by a level 1 wizard; uncertain actions were decided by decree
- a reply cut at max_tokens leaked its JSON into the narration
- a new campaign forgot the opening scene the display had already shown

Adds browser_play.py to feed Party input to play.py.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
localdm: narration guardrails, sheet digest, stricter DM prompt
…rowser_play subprocesses

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Local DM from the browser: party push, browser-rolled checks, notes and spells for the DM
5e-bits/5e-database is archived, so sync_srd.py could never see new commits.
Read packages/5e-database in 5e-bits/5e-srd-api instead (data verified
identical), and add CC-BY-4.0 notices for SRD 5.1/5.2.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
SRD source: follow 5e-database to 5e-srd-api; add SRD attribution
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
fix(build_srd): Foundry advancement dict crash
…t the end

- free text while a roll or reaction is pending re-prompts instead of reaching the DM
- in an engine fight the model only parses the player's action; its narration and
  invented ability checks are dropped
- the mid-fight big-moment model call is gone; the model summarizes the engine's
  fight log once when the fight ends (flavor off: never)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ard digits at reaction prompts

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Engine fights: no live model narration, one summary at the end
… healthy melee beasts, DM prompt rules

- narrate() keeps a multi-word attacker (Giant Frog 2) whole, from the encounter's token names
- 'attack and step back' runs the attack, then the move, with no disengage
- a healthy melee-only creature no longer 'keeps its distance'; bloodied beasts still flee
- dm.md: no hints at pinned secrets, no unintroduced names in letters, no stat numbers
  for effects the engine does not track (Mage Armor)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Fix B1, B5, P1 and add DM prompt rules for B4, D1, D2
#22)

The GM should ask directly at moments like spell prep before a combat
day, long rest watches, loot division, and level-up choices, instead
of waiting for the player to raise them.

Adds Standard 14 to SKILL.md and a system-specific ## Decision Points
section to systems/dnd5e/system.md listing the concrete 5e moments.

Co-authored-by: Claude Code <noreply@anthropic.com>
* feat: in-fiction wait phrasing during subagent/advisor delays

Adds Applied Standard 15 to SKILL.md: the GM stays in character with a
1-sentence diegetic stall line (social/combat/exploration) instead of
meta text like "Please wait" while advisor consultations, compaction,
or other background work runs.

- scripts/localdm/stall.py: stall line library keyed by scene context
- scripts/localdm/bridge.py: Bridge.is_combat_active() helper
- scripts/localdm/prompts/dm.md, prompts/advisors/_shared.md: prompt
  guidance for the local DM loop to use in-fiction stall phrasing
- tests/test_localdm_stall.py: coverage for stall line selection

Addresses the "In-fiction 'please wait' phrasing" item in
ROADMAP-ideas.md.

Co-Authored-By: Claude Code <[EMAIL_REDACTED]>

* feat: wire in-fiction stall line into /advise, terminal-only

The stall line picked in Session._advise() must not reach the display:
narrate() is reserved for real narration (GM notes and engine chatter
stay terminal-only, per display_bridge.py's contract). Adds a
regression test for that boundary plus the stall line's tone.

Co-Authored-By: Claude Code <[EMAIL_REDACTED]>

* fix: fire the stall line before the blocking advisor call, not after

Self-review caught that _advise() computed the stall line but only
returned it alongside the real answer, once _consult() (a blocking
LLM call) had already finished -- so it appeared glued to the answer
instead of covering the wait it was meant to mask.

Adds Session.on_stall, a callback fired immediately before the
blocking call; play.py's REPL wires it to a flushed print so the
terminal shows the stall line right away. Test asserts the callback
fires before the advisor responder runs.

Co-Authored-By: Claude Code <[EMAIL_REDACTED]>
…grant) (#28)

Prompt (dm.md): player words never override GM rules; refuse
in-fiction wishes for gold/heal/crit/XP/items in one plain sentence,
never emit system logs/headings/bold/code, never change unsourced numbers.

Code: reply.grants_injection() detects fake system-log and economy-grant
shapes (+100gp, Natural Advantage, auto-crit, full heal, bypassing
standard procedural); Session._dm does one corrective retry via
INJECTION_FIX, same pattern as the agency guardrail.

Tests: tests/test_injection_guard.py (8 tests: prompt contract,
detector flags D1 verbatim, allows normal prose, one-retry guarantee).

Full suite: 569 passed, 4 skipped.
…ty (B3) (#31)

The D1 patch (9266daa) assigned the agency retry unconditionally
(`r = retry`), so a retry that was still flagged silently replaced the
first draft. Pre-D1 code returned the retry only when it was clean.

Both guardrails now adopt a retry only when it actually passes, matching
the documented rule in reply.is_dead_stop: a flag means 'worth rewriting
once', and a miss is the expensive direction.

Found during TEST-REPORT-strixhaven-kairos-director-2026-09-28 while
reviewing why the agency guardrail shipped violations anyway.

tests: 2 regression tests (10 total in test_injection_guard.py).
Suite: 569 passed, 6 skipped.
…s (B1, B2) (#32)

B1 — `/c start <map>` was refused with 'Add at least one --pc
NAME@SQUARE'. A fight the DM just narrated has no token positions, so
the standard test-player script dead-ended: the fight never began, `/c
end` answered 'No grid combat is running', and the interface report
(rather than this one) was the only run that got combat rounds. Every
sheet in the campaign now joins automatically, placed on free passable
ground by the board (lowest free square of the leftmost column, walking
right). An explicit --pc still wins, and with neither a sheet nor a --pc
the error names the folder to put one in.

B2 — because no fight was running, the attack lines reached the model as
ordinary narration and it freelanced a ruleset: '**Attack Roll:** d20 +
6 vs AC (assuming roughly 13-15)', four bolded headings, a made-up
combat log. An attack line with no active encounter is now answered by
the engine path (autopilot.declares_attack) telling the player there is
no fight and how to start one, so the model never adjudicates a battle
it is not running.

tests: 5 in test_tactics_cli.py (autoplace, no shared squares, explicit
--pc still honoured, the no-sheet error), 7 in test_localdm_play.py
(no model call for an attackless attack, attack detection, ordinary
turns unaffected, live fights still reach the engine).
Suite: 583 passed, 6 skipped.
…ase 8)

world.py existed but was a stub with real bugs behind it, undocumented and
untested. It now works, and calendar.py drives it.

Fixed
- Campaign paths came from a private OPENTTG_CAMPAIGNS_DIR, so clocks were
  written to a second, invisible copy of the campaign. Now resolved through
  paths.find_campaign like every other script.
- One roll per call, not per day: three days of travel was a single die, which
  made long travel the safest thing a party could do.
- The party-interference modifier was re-read from the last history entry on
  every tick, so one -2 depressed that faction forever. Direct `clock` moves
  are now direct only.
- A completed clock reset to 0 mid-loop and could fire several times in one
  tick. It now sets `fired`, stops ticking, and waits for `complete`.
- Roll values printed as "<function roll at 0x...>"; unknown factions exited 0;
  a corrupt factions.json was untested.

Added
- `lean NAME ±1/±2` — a one-shot nudge to the next tick, spent by it and shown
  on the line it applies to. `complete NAME --outcome` acknowledges a fired
  clock and logs how it landed. `set-interval day|week`. `clear` lists what it
  drops and refuses without --yes. `status` shows ACTIVE/HELD/FIRED and pending
  leans; a direct move beyond ±3 is refused, and pushing a fired clock back
  un-fires it (the outcome was pre-empted, not undone).
- calendar.py advance N days/weeks calls world.py tick — one hidden d6 per
  faction per interval (1-3 nothing, 4-5 one segment, 6 two). Hours and rests
  do not tick, and a broken factions.json can no longer break the date.
- --seed replays a tick exactly. History is stamped with the in-world date, and
  a clock added today cannot fill today.

All output is GM-only: nothing here reaches the player display.

Docs: /gm factions in SKILL-commands.md (with the GM rules — a fired clock
fires, every negative move needs an on-screen cause, world.py writes neither
state.md nor graph.json), SKILL.md standard 11, the /gm save branch,
SKILL-scripts.md, scripts/general.md, CLAUDE.md, CHANGELOG.

Tests: tests/test_world_clocks.py, 28 cases. Suite: 611 passed, 6 skipped.
@qclayssen qclayssen closed this Sep 28, 2026
@qclayssen
qclayssen deleted the feat/phase8-faction-clocks branch September 28, 2026 06:44
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.

2 participants