Skip to content

fix: keep stale session cleanup from closing a replacement range - #80

Open
imxyanua wants to merge 2 commits into
EvoMap:mainfrom
imxyanua:codex/fence-range-cleanup
Open

imxyanua wants to merge 2 commits into
EvoMap:mainfrom
imxyanua:codex/fence-range-cleanup

Conversation

@imxyanua

Copy link
Copy Markdown
Contributor

Summary

An old SessionEnd can remain in cleanup while a prompt opens through the lifecycle lock's ELOCKED fallback. If the old range is distilled and the new turn creates a replacement, the old cleanup could close that replacement.

Capture the range before asynchronous cleanup and close only a range with the same start, session epoch and source turn. The existing lock fallback and ended-range due behavior are preserved.

Evidence

  • A real-store regression uses the original two-second lifecycle lock. It consumes the old range, creates a replacement at the same clock timestamp, then releases the old cleanup.
  • Before the fix, the replacement became closed. After the fix, it remains available for normal accumulation.
  • Targeted lifecycle, domain and architecture tests passed 22/22 on Windows Node 22.23.4 and 26.13.0.

Merge Danger

Two-way. Only the existing session-end caller closes a range, now with the source it read. No state migration or timeout change.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T03:45:37.897232Z 11a416c PR opened
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11a416c598

ℹ️ 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".

Comment thread lib/distill/range.js
/** A session end keeps the range it found due, leaving a replacement range alone. */
export function withClosedRange(pending, sessionId, expected) {
const range = rangeOf(pending, sessionId);
if (!range || !expected || range.at !== expected.at || range.sessionEpoch !== expected.sessionEpoch

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Close late same-session ranges when the snapshot is empty

If the final turnEnded has already set open=false but is still awaiting its record or evidence, the bounded settling wait can expire before it writes a candidate. If that write lands after this snapshot but before the later candidate update, endingRange is null and this guard skips closing the new range; while its owner is still live, the range remains pending until an idle or error-episode trigger instead of becoming immediately due at session end. Preserve the ending turn and epoch so late writes from that turn can be closed without closing a new-prompt replacement.

Useful? React with 👍 / 👎.

@evomap-aiqa-bot

Copy link
Copy Markdown

Sentinel 正在审核此变更,尚未形成最终结论。

Sentinel 审核中

  • 当前 PR 已进入 reviewer;这是进行中状态,不是绿色通过,也不是红色阻塞。

开发 agent 查询详情: 调用 MCP 工具 sentinel_pr_review_context,传入 owner_repo="evomap/evolver-agent-plugin"、pr_number=80、head_sha="11a416c59840765b3a7941f21f53ce94fdfd0de4",并按条目追加 finding_id 或 finding_key。

由 Sentinel 审核 · 目标提交 11a416c59840

@evomap-aiqa-bot

evomap-aiqa-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Sentinel 已审核此变更,未发现已核验问题,但发现需要人工确认的风险。

另有 2 个需要人工确认的风险;黄色 advisory 不阻塞合并,建议开发 agent review advisory 评论并逐条确认。

开发 agent 查询详情: 调用 MCP 工具 sentinel_pr_review_context,传入 owner_repo="evomap/evolver-agent-plugin"、pr_number=80、head_sha="38d2ac4530ce1c6b8fd13b623efb5c637e7c3fb9",并按条目追加 finding_id 或 finding_key。

由 Sentinel 审核 · 目标提交 38d2ac4530ce

@evomap-aiqa-bot

Copy link
Copy Markdown

Sentinel 保留了 2 个尚未确认的审核候选。这些黄色条目不阻塞合并;红色 P0/P1 与其他独立硬门禁不受影响。 单一猜测、缺少变更行证据或纯 checklist 的候选会统一降为 P3。
开发 agent:请 review 以下 advisory,并逐条给出“已验证无风险 / 已修复 / 转为后续事项”的结论;不要只做整体确认。

  • [P2] 旧范围保留工作轮次时,迟到清理仍会关闭包含新轮次的范围 — withClosedRange 将“任意一个 turn 编号重叠”当作旧范围身份匹配。若旧范围因蒸馏失败、跳...(truncated) · lib/distill/range.js · advisory_d0d5972c76fc07bfd1ed7f22
  • [P3] 部分重叠判断可能把包含新 turn 的范围误判为旧范围 — 新保护只比较 at、sessionEpoch,并要求存在任意重叠 turn。若蒸馏失败或取消后旧 turn 仍保...(truncated) · lib/distill/range.js · advisory_19dd4a733efe22e4dae798d4

需要完整证据时,可用行末 finding_key 查询 Sentinel PR review context。

由 Sentinel 审核 · 目标提交 38d2ac4530ce

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