Skip to content

fix(tracker): centralize hidden mark placeholder reconciliation#55

Merged
llsccm merged 2 commits into
devfrom
refactor/mark-space-reconcile
Jul 24, 2026
Merged

fix(tracker): centralize hidden mark placeholder reconciliation#55
llsccm merged 2 commits into
devfrom
refactor/mark-space-reconcile

Conversation

@llsccm

@llsccm llsccm commented Jul 24, 2026

Copy link
Copy Markdown
Owner

变更

  • 新增 reconcileMarkSpace,集中维护暗置标记正 ID 与匿名占位之间的物理名额守恒。
  • 普通 player mark 与木马装备容器统一按“来源手牌物理背书”回收溢出占位,避免错误移入 outside
  • 整手完整揭示路径复用同一守恒原语,删除重复的内联占位搬运。
  • 新增 player mark、木马容器、重复确认、错误 spell 与整手揭示回归,并同步 card_tracker 运行时契约。

原因

暗置标记弱候选同时由正 ID 候选和匿名实体占位表达。此前确认路径各自维护占位回收,且容器分支会把实际来自来源手牌的占位移到 outside,导致手牌物理槽丢失,后续已知牌物化可能退化为 createExternal

本次只收口确认产生的溢出回收;完整揭示前置时序和全明容器快照的孤儿清理职责保持不变。

验证

  • pnpm test:tracker(40 个测试文件,289 项通过)
  • pnpm typecheck:tracker
  • pnpm lint
  • pnpm exec prettier --check ...
  • pnpm build
  • pnpm build:prod
  • serena memories check

Summary by CodeRabbit

  • Bug 修复

    • 优化隐藏标记占位的回收与守恒处理,减少确认卡牌后出现占位溢出或状态缺口的问题。
    • 溢出的匿名占位会正确回到来源手牌,不再错误进入其他区域。
    • 完整揭示手牌后,相关标记状态可稳定收敛,并避免重复回收或错误关联其他标记。
  • 文档

    • 补充隐藏标记候选流程、回收条件及不同清理路径的说明。

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@llsccm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 43dabf78-7870-4d64-8649-8c307ab14a8c

📥 Commits

Reviewing files that changed from the base of the PR and between 73e75ad and a6a18ab.

📒 Files selected for processing (2)
  • src/tracker/roomMovement/hiddenMarks.ts
  • tests/tracker/markSpaceReconcile.test.ts
📝 Walkthrough

Walkthrough

本次变更统一了暗置标记空间的匿名占位回收逻辑,接入整手完整揭示流程,并新增覆盖确认绑定、容器牌、幂等性、不同 spellID 隔离和完整揭示场景的测试。

Changes

暗置标记空间守恒

Layer / File(s) Summary
统一占位回收流程
src/tracker/roomMovement/hiddenMarks.ts
新增 reconcileMarkSpace 及占位判定辅助方法,在正 ID 确认或整手揭示产生溢出时,将匿名占位从账本和约束组移除并挤回来源手牌。
占位守恒测试覆盖
tests/tracker/markSpaceReconcile.test.ts
新增测试验证普通牌、容器牌、重复确认、不同 spellID 占位隔离及整手揭示回收行为。
移动流程说明与表达式整理
src/tracker/roomMovement.ts, docs/agents/card_tracker.md
整理移动解析表达式,并补充候选解析顺序、占位回收条件及约束字段范围说明。

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

Sequence Diagram(s)

sequenceDiagram
  participant Room as Room.moveCards
  participant HiddenMarks as HiddenMarkMethods
  participant Ledger as Mark ledger
  participant Hand as 来源手牌
  Room->>HiddenMarks: 解析完整手牌揭示候选
  HiddenMarks->>HiddenMarks: reconcileMarkSpace(record, reason)
  HiddenMarks->>Ledger: 移除溢出占位和约束记录
  HiddenMarks->>Hand: 挤回匿名占位
Loading

Possibly related PRs

  • llsccm/tracker#20:同样修改了 RoomMovementHiddenMarkMethods 的模块结构与隐藏标记逻辑。
  • llsccm/tracker#54:涉及整手完整揭示路径中的木马、候选收敛和占位回收。
🚥 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 标题准确概括了此次将隐藏标记占位回收逻辑集中到统一 reconciler 的主要改动。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/mark-space-reconcile

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tracker/roomMovement/hiddenMarks.ts`:
- Around line 783-837: Update reconcileMarkSpace so that when overflow is
positive but evictCount is zero, it logs a dedicated warning for the mark-space
quota/invariant violation and returns false before the recycling loop and normal
recovery log. Preserve the existing recycling behavior and true return only when
at least one placeholder is actually removed and rebound.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 35ce9527-0b62-4c0b-910a-e9c33824afb7

📥 Commits

Reviewing files that changed from the base of the PR and between eb4e51b and 73e75ad.

📒 Files selected for processing (4)
  • docs/agents/card_tracker.md
  • src/tracker/roomMovement.ts
  • src/tracker/roomMovement/hiddenMarks.ts
  • tests/tracker/markSpaceReconcile.test.ts

Comment thread src/tracker/roomMovement/hiddenMarks.ts
@llsccm
llsccm merged commit 251bfb1 into dev Jul 24, 2026
3 checks passed
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