Skip to content

fix(render): the stores-filling caption stays quiet during an attack and backs off when ignored (#435) - #437

Merged
LightAxe merged 1 commit into
mainfrom
fix/435-stores-filling-backoff
Oct 9, 2026
Merged

LightAxe merged 1 commit into
mainfrom
fix/435-stores-filling-backoff

Conversation

@LightAxe

@LightAxe LightAxe commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

The "Your stores are nearly full" caption nagged: it could take the screen while an enemy wave was marching in, and it repeated every 60 s once the player stopped adding larders. Render-only: no sim change, no simVersion bump.

Rule 1: quiet during an attack. From the moment the army warning fires for a wave (march, gathering or invasion) until it re-arms (the invasion ended / the army dispersed), the caption is never owed. "Wave under way" is the army-warning module's own state: the new armyWaveUnderWay(state) is !state.armed. A caption owed but not yet shown when the warning fires is dropped like a stale one (freeing its cooldown). The dwell clock keeps running, so a trigger that still holds afterwards owes it again. Judged per sim tick in noteStoresFillingTick (beforeSimTick passes captions.armyWarning); the army warning's armed state itself is advanced once per frame (nextArmyWarning), so a wave's start or end can shift the owe tick by up to one frame, and the frame step drops anything a stale read owed, so it never shows during a wave. Silence lasts until the warning re-arms: the army dispersed (fewer than 4 loitering in the gathering radius, fewer than 3 inside the tunnels) and any invasion ended (rout, or the AI's 1800-tick invasion timeout), plus 200 quiet ticks.

Rule 2: back off when ignored. Each time the caption is shown again with no Food Storage designated since the last show, the next cooldown doubles. The waits after successive ignored shows are 1, 2, 4, 8, 8... min (1200, 2400, 4800, 9600, 9600 ticks; STORES_FILLING_COOLDOWN_MAX_TICKS = 9600 is the cap): the first repeat stays at 1200, doubling starts at the second ignored show. Designating a new Food Storage (designated + completed count goes up since the show) resets it to 1200. A caption dropped unshown does not advance the back-off. The storage hint's last-offer interplay is unchanged (still 1200). State (cooldownTicks, shownStorageCount) lives in StoresFillingCaptionState, reset with the session.

Measurement

Scripted harness (playtest-5 pace5.ts, real render modules), seeds 0-19, before = origin/main f4ab287, after = this branch. "During an attack" = a show between an army warning and that invasion's end (exact show ticks joined against the invasion windows).

Arm Build Shows/game median max Total shows During an attack Wins
Scripted human, Normal before 2.0 39 201 19 (9.5%) 8
after 1.5 8 55 0 8
Turtle, Normal before 26.0 54 539 48 (8.9%) 0
after 6.5 10 114 0 0
Caption-following novice, Normal before 9.5 25 188 9 (4.8%) 9
after 9.0 28 195 1 (0.5%) 10
Caption-following novice, Easy before 10.0 21 201 12 (6.0%) 16
after 10.0 37 219 0 16

The novice builds on every show, so the back-off never engages for it and its show count is unchanged; its win/max differences are run-to-run divergence from the changed timing. The one remaining novice-Normal "during an attack" show is a boundary case of the join (the army warning was armed at every after-build show: 0 shows with it disarmed).

Tests

  • src/render/stores-filling-caption.test.ts: quiet during an attack (not owed while disarmed; owed-unshown dropped; owed again after re-arm; shown caption keeps its cooldown), back-off sequence 1200/2400/4800/9600/9600 and the cap, reset on a new Food Storage, unshown drop does not advance, session reset, and batching invariance (frames of 1, 2, 3, 5 ticks give identical owe ticks) for both rules.
  • Mutation-checked by hand: disabling quiet-during-attack, the doubling, the reset-on-build, or the cap each fails tests.
  • npm run verify passes (5376 passed, 1 skipped); the stores-filling, storage-hint and army-warning e2e specs pass unchanged (20 passed).

Closes #435

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Stores-filling captions no longer appear during an active attack wave. Any pending, unshown caption is dropped, while its dwell timer continues.
    • Repeatedly shown captions now have progressively longer cooldowns, up to eight times the base interval. A new Food Storage designation or completed storage resets the cooldown; captions dropped before being shown do not increase it.

…and backs off when ignored (#435)

Render-only (no sim change, no simVersion bump). The caption is never owed
while the army warning is disarmed (a wave is under way); an owed-unshown
one is dropped. Each time it is shown and no Food Storage is designated
before it would next be owed, the next cooldown doubles (1200 up to 9600
ticks); a new Food Storage resets it.

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

LightAxe commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T15:59:58.152752Z 67d5731 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LightAxe/subterrans/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c87832d3-7cb9-40f2-8fdb-fae9c41c7e47

📥 Commits

Reviewing files that changed from the base of the PR and between f4ab287 and 67d5731.


📒 Files selected for processing (10)
  • CONTEXT.md
  • src/render/army-warning.ts
  • src/render/counter-attack-gate.test.ts
  • src/render/enemy-queen-wound.test.ts
  • src/render/game-scene.ts
  • src/render/queen-danger.test.ts
  • src/render/sim-tick-hook.test.ts
  • src/render/sim-tick-hook.ts
  • src/render/stores-filling-caption.test.ts
  • src/render/stores-filling-caption.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

Stores-filling captions are suppressed during active army-warning waves, and pending unshown offers are cleared while dwell time continues. Repeated shown captions increase their cooldown up to 480 seconds. An increase in designated or completed Food Storage count resets the cooldown. Simulation-tick hooks now provide army-warning state.

Changes

Stores-Filling Caption Behavior

Layer / File(s) Summary
Suppression and repeat cooldown
src/render/army-warning.ts, src/render/stores-filling-caption.ts, src/render/stores-filling-caption.test.ts, CONTEXT.md
The caption checks for an active army-warning wave and clears pending unshown offers during one. Shown captions increase the cooldown up to 9600 ticks unless the Food Storage count increases. Tests cover suppression, cooldown growth and reset, session reset, and batching.
Simulation-tick state wiring
src/render/sim-tick-hook.ts, src/render/game-scene.ts, src/render/*-test.ts
The tick hook accepts and forwards army-warning state. GameScene supplies that state to the tick hook and stores-filling caption logic. Related tests pass the state through their fixtures.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant GameScene
  participant beforeSimTick
  participant noteStoresFillingTick
  participant armyWaveUnderWay
  GameScene->>beforeSimTick: pass caption state and army-warning state
  beforeSimTick->>noteStoresFillingTick: pass tick data and army-warning state
  noteStoresFillingTick->>armyWaveUnderWay: check whether a wave is active
  armyWaveUnderWay-->>noteStoresFillingTick: return wave status
Loading

Merge Risk: ⚪ Minimal · up to 67d57

The caption timing change is mergeable after normal checks; no actionable risk remains identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely summarizes the primary changes: suppressing the stores-filling caption during attacks and adding backoff when captions are ignored.
Linked Issues check Passed Issue #435 requires a render-side fix for repeated stores-filling captions when no new Food Storage is designated. The PR adds per-session cooldown back-off from 1,200 to a capped 9,600 ticks, resets …
Out of Scope Changes check Passed The changes stay within the caption objective in #435. The army-warning state plumbing, render-only session state, related fixture updates, and focused tests support attack suppression or cooldown beh…
Docstring Coverage Passed Docstring coverage is 82.35% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 9 files. (1 skipped: 1 …


✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 67d5731efe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@LightAxe
LightAxe merged commit c597839 into main Oct 9, 2026
4 checks passed
@LightAxe
LightAxe deleted the fix/435-stores-filling-backoff branch October 9, 2026 16:16
LightAxe added a commit that referenced this pull request Oct 10, 2026
LightAxe added a commit that referenced this pull request Oct 10, 2026
LightAxe added a commit that referenced this pull request Oct 11, 2026
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.

playtest-5: the stores-filling caption repeats every 60 s for the rest of a match once the player stops adding Food Storage

1 participant