Skip to content

fix(recall): end a link at the first character a URL cannot hold - #110

Merged
forrestlinfeng merged 4 commits into
mainfrom
fix/prompt-link-cjk
Nov 23, 2026
Merged

forrestlinfeng merged 4 commits into
mainfrom
fix/prompt-link-cjk

Conversation

@forrestlinfeng

Copy link
Copy Markdown
Contributor

Summary

promptTextOf drops links from the prompt before recall. The link pattern ran to the next whitespace, and Chinese is written right after a link with no space, so the rest of the sentence went with the link. A link now ends at the first character RFC 3986 does not allow in a URL:

-const LINK = /\b(?:https?:\/\/|www\.)\S+/gi;
+const LINK = /\b(?:https?:\/\/|www\.)[A-Za-z0-9\-._~:/?#[\]@!$&'()*+,;=%]+/gi;

The recall query and the task context the Hub judges fit by both come from promptTextOf, so both keep the text written after a link.

Found in a dsh session: a Chinese video request with the site URL in parentheses was recalled as 我们新官网( 20 秒…, losing 本周上线,帮我做一条.

Evidence

  • Before (@evomap/dsh-evolver 1.0.16):

    • 我们新官网(https://canary.evomap.work/zh)本周上线,帮我做一条 20 秒的展示视频 → 我们新官网( 20 秒的展示视频
    • 照着这个视频https://v.douyin.com/abc123/复刻一条我们瑜伽App的版本 → 照着这个视频
    • 把 https://github.com/nexu-io/looper/pull/42这个PR接管到合并 → 把

    After:

    • → 我们新官网( 本周上线,帮我做一条 20 秒的展示视频
    • → 照着这个视频 复刻一条我们瑜伽App的版本
    • → 把 这个PR接管到合并
  • RED: the new test a link ends where the Chinese text written right after it begins failed on main (actual 我们新官网( 20 秒的展示视频), and passes with the change. The existing link test (see https://example.sentry.io/issues/?project=1 → see) still passes.

  • npm test: 1223 pass, 10 skipped, 3 fail. The 3 failures are in test/runtime/desktop-engine.test.js ("The Evolver Desktop installation could not be verified") and fail the same way on origin/main (1e13d18) on the same machine, so they come from that machine's Desktop install, not from this change.

Merge Danger

Door: two-way. One regex, reverted by reverting this commit.

Blast Radius: recall text

Every host's recall query and task context pass through promptTextOf. A link with non-ASCII characters in its path (https://zh.wikipedia.org/wiki/中文) now leaves the non-ASCII part in the recall text where it was dropped before. Users get the fix with the next host releases. EvoMap/evolver-claude-code-mods has the same pattern in lib/recall.js and is not changed here.

🤖 Generated with Claude Code

promptTextOf drops links from the prompt before recall. The pattern ran to
the next whitespace, and Chinese is written right after a link with no
space, so the rest of the sentence went with the link:
"官网(https://canary.evomap.work/zh)本周上线,帮我做一条 20 秒的展示视频"
was recalled as "官网( 20 秒的展示视频". A link now stops at the first
character RFC 3986 does not allow in a URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@evomap-aiqa-bot

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

Copy link
Copy Markdown

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

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

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

由 Sentinel 审核 · 目标提交 6a60b8fe1249

@evomap-aiqa-bot

Copy link
Copy Markdown

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

  • [P3] 含中文路径的链接不再被完整移除 — 新正则仅匹配 ASCII RFC 3986 字符;实际常见的 Unicode IRI 路径或域名在第一个非 ASCII 字符处终...(truncated) · lib/recall.js · advisory_a43387e594cdbd7e8da9dc03
  • [P3] Unicode URL 路径未被完整剥离,可能泄露敏感地址内容 — 新正则只接受 ASCII URL 字符,并在首个 Unicode 字符处终止。但 Unicode 路径本身是合法 URL 内...(truncated) · lib/recall.js · advisory_5648ecd445da9d51209319ba
  • [P3] 国际化 URL 不再被完整移除 — 新正则只允许 ASCII URL 字符。遇到合法的国际化域名时会完全匹配失败;遇到 Unicode 路径时...(truncated) · lib/recall.js · advisory_0ae06548a1a2313e03d528b6

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

由 Sentinel 审核 · 目标提交 6a60b8fe1249

… structure follows them

The ASCII-only link pattern stopped at the first non-ASCII character, so an
IDN host (`https://例子.测试/docs`) was not removed at all. A Unicode path
(`https://example.com/患者张三/病例?access_code=ABC123`) lost only its ASCII
prefix, and its segments and query went into the recall text and the Hub's
task context.

A non-ASCII run now stays in the link when URL structure follows it: `/`,
`?`, `#`, `:`, or a dot and a letter of any script. The Chinese sentence
written right after a link has none of that, so it is still kept
(`…/abc123/复刻一条…`, `evomap.ai这个网站`). A non-ASCII last segment with
nothing after it (`/wiki/中文`) cannot be told from that sentence, and is
kept as the person's text.

The two alternatives use disjoint character sets, so the pattern stays
linear: 200k CJK characters after a link take a few milliseconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@evomap-aiqa-bot

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

Copy link
Copy Markdown

Sentinel 已审核此变更,并发现 2 个已核验问题。

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

由 Sentinel 审核 · 目标提交 46eab582805d

Comment thread lib/recall.js Outdated
const MARKUP_TAG = /<\/?[a-z][\w-]*(?:\s[^<>]*)?>/gi;
const LINK = /\b(?:https?:\/\/|www\.)\S+/gi;
const URL_ASCII_RUN = "[A-Za-z0-9\\-._~:/?#[\\]@!$&'()*+,;=%]+";
const URL_NON_ASCII_SEGMENT = '[^\\x00-\\x7F\\s\\u3000-\\u303F\\uFF00-\\uFFEF]+(?=[/?#:]|\\.[\\p{L}\\p{N}])';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

末尾 Unicode 路径未被识别为链接内容

🟠 严重程度:中(P2)
URL_NON_ASCII_SEGMENT 仅在非 ASCII 字符后还有 /、?、#、: 或“.加字母/数字”时才将其计入 URL。因此位于 URL 末尾、空白或中文标点之前的合法 Unicode 路径段不会被删除。旧实现使用 \S+,会删除该路径;当前测试反而将残留行为固定为预期。

Finding:finding_b50d2cc1628d767fd215a088

Comment thread lib/recall.js Outdated
const MARKUP_TAG = /<\/?[a-z][\w-]*(?:\s[^<>]*)?>/gi;
const LINK = /\b(?:https?:\/\/|www\.)\S+/gi;
const URL_ASCII_RUN = "[A-Za-z0-9\\-._~:/?#[\\]@!$&'()*+,;=%]+";
const URL_NON_ASCII_SEGMENT = '[^\\x00-\\x7F\\s\\u3000-\\u303F\\uFF00-\\uFFEF]+(?=[/?#:]|\\.[\\p{L}\\p{N}])';

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)
新正则要求每段非 ASCII 文本后必须仍有 /、?、#、:,或“. 加字母”。因此完整 IDN 域名在 Unicode 顶级域名处结束时,最后一个标签不匹配并残留在清洗结果中。

Finding:finding_cab6693f50227277bfa30d74

…D leaves nothing behind

`https://例子.测试` and `https://sub.例子.测试` left their last label in the
recall text: after the host there was no `/`, `?` or `.` to keep it in the
link. The host is now matched on its own as dot-joined labels of any script,
so an IDN host goes whole. A single label is only ASCII, so a Chinese
sentence written right after an ASCII host (`https://evomap.ai这个网站`)
is still kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@evomap-aiqa-bot

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

Copy link
Copy Markdown

Sentinel 已审核此变更,并发现 2 个已核验问题。

无法定位到 diff 的已核验问题

Unicode URL 的末尾路径段会残留并进入召回文本

🟠 严重程度:中(P2)
URL_NON_ASCII_SEGMENT 要求非 ASCII 段后必须还有 /、?、#、: 或“点号加字母/数字”。因此 URL 末尾的合法 Unicode 路径段,或其后只有中文标点的路径段,不会被 LINK 匹配。清洗只删除 URL 前缀和 ...(truncated)

Finding:finding_152c665e12b5d7be2816082d · 文件:[lib/recall.js](/workspace/lib/recall.js:73) · 详情:/api/v1/aiqa/findings/finding_152c665e12b5d7be2816082d

当前为 advisory 仓库:这些 item 会逐条保留,但不阻塞合并。

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

由 Sentinel 审核 · 目标提交 74a294c55e70

Comment thread lib/recall.js Outdated
const HOST_LABEL = `(?:[A-Za-z0-9-]+|${NON_ASCII_RUN})`;
const DOTTED_HOST = `${HOST_LABEL}(?:\\.${HOST_LABEL})+`;
const URL_ASCII_RUN = "[A-Za-z0-9\\-._~:/?#[\\]@!$&'()*+,;=%]+";
const URL_NON_ASCII_SEGMENT = `${NON_ASCII_RUN}(?=[/?#:]|\\.[\\p{L}\\p{N}])`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

末尾 Unicode 查询值会残留到召回请求

🟠 严重程度:中(P2)
URL_NON_ASCII_SEGMENT 仅在非 ASCII 字符后仍有 /、?、#、: 或“.加字母/数字”时才匹配。对于 ?q=中文、#章节名称 这类结构明确且位于链接末尾的合法 IRI 内容,正则只删除到 q= 或 #,把 Unicode 值错误保留为用户提示。旧正则 \S+ 会删除完整链接,因此属于当前 PR 引入的兼容性回归。

Finding:finding_e5b87c4fbadafc2f6b90c2ec

`?q=患者张三` and `#章节名称` at the end of a link were cut after `=` or `#`,
and the value went into the recall text. A non-ASCII run right after `=`,
`?`, `#` or `&` is a query value or fragment and stays in the link. Text
after an ASCII value (`?b=1帮我总结`) is still the person's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@evomap-aiqa-bot

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

Copy link
Copy Markdown

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

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

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

由 Sentinel 审核 · 目标提交 a791c742998c

@evomap-aiqa-bot

Copy link
Copy Markdown

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

  • [P3] URL 末尾的 Unicode 路径段绕过链接清洗 — URL_NON_ASCII_SEGMENT 只在 Unicode 路径段后仍有 URL 结构字符时将其纳入链接;若合法 Unicode 段...(truncated) · lib/recall.js · advisory_48cd8325b75769caf1607974

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

由 Sentinel 审核 · 目标提交 a791c742998c

@forrestlinfeng
forrestlinfeng merged commit 5affe27 into main Nov 23, 2026
13 checks passed
@forrestlinfeng

Copy link
Copy Markdown
Contributor Author

Sentinel review items: resolution at a791c74

The Sentinel review of head a791c74 reports 0 verified findings, 1 yellow advisory and merge_blocked: false. All CI checks pass. The resolution API answered "review session not found" for this head, so the conclusion for each item is recorded here.

Item Conclusion
IDN host not removed / last label left behind (https://例子.测试, https://sub.例子.测试) Fixed. The host is matched on its own as dot-joined labels of any script and removed whole. 访问 https://例子.测试 → 访问
Unicode query value or fragment left behind (?q=患者张三, #章节名称) Fixed. A non-ASCII run right after =, ?, # or & stays in the link. 搜 https://example.com/search?q=患者张三 看结果 → 搜 看结果
Unicode path leaking sensitive content (/患者张三/病例?access_code=ABC123) Fixed. A segment followed by URL structure stays in the link. 分析 https://example.com/患者张三/病例?access_code=ABC123 并给建议 → 分析 并给建议
A trailing non-ASCII path segment with nothing after it (/wiki/中文, /records/患者张三) Deferred, deliberate trade-off. It has the same shape as the case this PR fixes (…/abc123/复刻一条我们瑜伽App的版本). Plain text can't tell the last path segment from the sentence written right after a link; Sentinel's verifier on 46eab58 said the same. It is kept as the person's text, documented in the LINK comment and pinned by a test. Follow-up owner: @forrestlinfeng. They decide whether to drop it, and if so, add a signal beyond the regex.

The pattern stays linear: 200k CJK characters after a link take a few ms. Regression tests are in test/recall.test.js.

🤖 Generated with Claude Code

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