Skip to content

diagnose(shell): 记录选区被丢弃的分支原因 (#156) - #186

Merged
JavaZeroo merged 3 commits into
mainfrom
diag/selection-discard-reason
Oct 29, 2026
Merged

JavaZeroo merged 3 commits into
mainfrom
diag/selection-discard-reason

Conversation

@JavaZeroo

Copy link
Copy Markdown
Owner

内容

为 #156 加只诊断、不改行为的选区丢弃原因观测:

  • TextSelection 增加可选丢弃观察器 set_discard_observer,内部把每次 invalidate() 的分支命名:
    epoch-mismatch、anchor-missing-or-shrunk、row-identity-replaced、row-text-changed、endpoint-unavailable;
  • shell 侧在设置环境变量 TERMFORGE_SELECTION_DIAG=<jsonl 路径> 时安装观察器,向该文件追加
    {"schema":"termforge-selection-discard-v1","reason":"..."};未设置时不写文件、无任何行为变化;
  • selection_core 新增一组契约:安装观察器后触发 epoch 失效,断言收到 epoch-mismatch;
  • experiments/shell/README.md 增加使用说明与分支含义。

验证

  • 本地 Release 构建 selection_test、termforge_shell 通过;selection_test 输出
    selection contracts passed (8 independent groups),exit 0。

动机

hosted 上偶发 actions geometry lost terminal selection(Find 命中在、选区丢)。上一轮已把机制定位到
TextSelection::reconcile + shell.cpp 的 publish 时机;本 PR 让失败时能直接看到是哪一类不一致
(epoch / 锚点 / 身份 / 文本 / 端点),为判定"中间态竞态"还是"确定性裁剪"提供证据。

Refs #156

TextSelection gains an opt-in discard observer with named branches (epoch, anchor, identity, text, endpoint); the shell installs a JSONL writer only when TERMFORGE_SELECTION_DIAG is set. Selection contracts add a group proving the observer receives the epoch branch; behaviour is unchanged without the variable.
@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-29T14:17:53.836062Z
We couldn’t complete this review. Comment @codex review to try again.
fa97005 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

…facts refs #156

The python runner sets TERMFORGE_SELECTION_DIAG inside each scenario output directory so a hosted discard reason lands in build/test-artifacts and survives as failure evidence.
@JavaZeroo
JavaZeroo force-pushed the diag/selection-discard-reason branch 2 times, most recently from 3d20895 to 261ea8d Compare October 29, 2026 14:26
Trailing newline restored after the diagnostic edit; no behaviour change.
@JavaZeroo
JavaZeroo merged commit 4b7d487 into main Oct 29, 2026
10 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