Skip to content

core: 发布精确行序并解耦身份与文档位置 (#169) - #170

Merged
JavaZeroo merged 4 commits into
mainfrom
feat/core-order-query-r169
Oct 29, 2026
Merged

JavaZeroo merged 4 commits into
mainfrom
feat/core-order-query-r169

Conversation

@JavaZeroo

Copy link
Copy Markdown
Owner

本片交付

Screen 成为行结构的唯一发布者:新增 publish(history, live)(拥有值镜像、校验后一次提交)、精确 locate(id)(缺失不落邻行)、order_revision()(只随结构变化前进)与 mark_order_unknown() 保守回退。TextDocument::index_of 改用 locate 并新增 compare,HistoryViewport 的活 anchor 用精确 rank(淘汰 anchor 的 lower_bound 回退保留),TextSearch::navigate 改文档序,CandidateTerminal 导入改经发布口。

固定夹具 [1,3,4,5,7,6]:locate(7)=4、locate(6)=5、locate(2) 缺失、文档序 7 先于 6、强制 Find previous(6)→7 / next(7)→6。

证据:合同与夹具 · 验证身份

实际执行

  • 源码 33b58fa,Windows 11 10.0.26200 / MSVC 19.42.34433.0 / Release / Qt 与 candidate 关闭。
  • 完整默认 Release 构建 exit 0。
  • 核心 CTest 8/8:新增 order_query_core,其余 7 项维持通过。
  • 候选适配器本机未启用:candidate_terminal.cpp 仅 /W4 独立编译(exit 0、无诊断),未链接未运行。
  • 首轮新测试 1/8 的两次失败是夹具/期望缺陷(y 与 x、order_known 期望),只改测试,不作为产品红绿。

明确未做

  • Screen::lines/history 仍公开,未封住直接写入与全部 caller 迁移。
  • 有序增量 Find 内部 emit_from_id_/prune/rewind 与 match() 的 ID 区间假设仍在,运行中跨重排未验收。
  • 无区域 LF、新 VT 模式、reflow 或用户可达重排;未运行 Qt/固定 ConPTY/GUI/TUI,无性能主张。

refs #169(保持开放)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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-29T08:19:33.770690Z ca3c073 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: ca3c073cfa

ℹ️ 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 on lines +277 to +278
if (live_rows.empty() || live_rows.size() > 200)
throw std::invalid_argument("published live rows must be between 1 and 200");

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 Validate the preserved cursor against the published row count

When the incoming image has fewer live rows than the current screen, publish() accepts it while preserving a cursor that may now be out of bounds. For example, Screen(2, 4, 4), move(1, 0), then publishing one valid live row leaves row == 1 and height() == 1; the next put() indexes beyond lines (reproduced with libstdc++ bounds assertions). Since publication explicitly preserves cursor state, reject incompatible geometry or validate the preserved cursor against the incoming image before committing.

Useful? React with 👍 / 👎.

@JavaZeroo
JavaZeroo merged commit 85eb5a0 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