[claude] fix(chat): temp-HP-first, version-guarded direct HP for untransformed characters - #193
Conversation
…ansformed characters Out-of-combat !damage / !heal / signed !hp on an ordinary (untransformed) character ignored temp_hit_points and wrote hit_points with an unguarded UPDATE. Damage now consumes temp HP before base HP, healing tops up base HP and leaves temp HP alone, and every changed pool lands in one optimistic-lock UPDATE keyed on the selected characters.version. A stale/missing/invalid version, malformed numeric row, or zero-row UPDATE fails closed: private whisper, no fanout, no damage side effects. Absolute !hp set semantics unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 2 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
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 |
|
[CodeX final review] I completed the correction pass on Fable's implementation:
Local gates at head |
Fixes the pre-existing ordinary-character out-of-combat direct HP authority bug in
applyDirectHp(server/src/services/chatCommands/hpHandlers.ts).What changed
!damage/ signed!hp -Nconsumestemp_hit_pointsbefore base HP; positive delta heals base HP up to max and leaves temp HP untouched.UPDATE ... WHERE id = $ AND version = $ RETURNING versionusing the version selected with the row. Stale/missing/invalid version, malformed numeric pools, or a zero-row UPDATE fail closed — private whisper to the caller, no public/stat fanout, no damage side effects, no claimed success.hp,tempHp, and post-writeversionare returned and fanned out through the existingemitToTokenStatViewersowner/DM privacy scoping (unchanged).Absolute
!hpset: left unchanged (requirement 4)setDirectHpis not a read-modify-write on the HP pools — the written value depends only on the max-HP clamp, so the lost-update window the guard closes for delta paths barely exists there, and it already fails closed while wild-shaped. Adding a guard would also force legacy no-version rows (and the existing absolute-set test fixtures) into fail-closed territory for an administrative overwrite command — scope creep for marginal benefit.Tests
New
server/src/__tests__/direct-hp-temp-authority.test.ts: temp HP fully absorbing, partial absorb with base carryover, healing preserving temp HP, signed!hp -Nrouting, version conflict (zero-row) fail-closed with no fanout/side effects, missing-version fail-closed, malformed-numeric-row fail-closed, and full-no-op skip.Updated
hp-command-stat-privacy-version.test.ts(rows now carry a version; the two "omits version but still fans out" tests encoded the old bug and are now fail-closed assertions) and one mock inchat-command-token-fanout.test.ts(its UPDATE must return a version now).Gates
npm test: 1759 passednpm run lint: clean (max-warnings 0)npm run build: cleannpm audit --omit=dev: 0 vulnerabilitiesgit diff --check: clean🤖 Generated with Claude Code