Skip to content

🐛 fix(core): matcher includeAll/excludeAny/excludeAll 字段在路由匹配中生效 - #55

Merged
Lands-1203 merged 1 commit into
double-coding-lab:mainfrom
chyuan-cuihongyuan:fix/matcher-consume-all-fields
Sep 3, 2026
Merged

🐛 fix(core): matcher includeAll/excludeAny/excludeAll 字段在路由匹配中生效#55
Lands-1203 merged 1 commit into
double-coding-lab:mainfrom
chyuan-cuihongyuan:fix/matcher-consume-all-fields

Conversation

@chyuan-cuihongyuan

Copy link
Copy Markdown

Fixes #54

问题

matcher 分片 schema(flow2spec.matcher.v1)定义并校验了 includeAll / excludeAny / excludeAll,但 routing.match() 只消费 includeAny——写了排除词/组合词的词表形同虚设(详见 #54 现象与根因)。

修复内容

  • 否决门excludeAny 任一命中(OR)或 excludeAll 全部命中(AND)→ 整条规则否决,且优先于 task 精确命中(排除词表达「此请求不属于该任务域」);
  • 资格门includeAny 任一命中 includeAll 全部命中 → 具备候选资格;纯 includeAll(无 includeAny)的词表首次可表达;
  • 打分与置信级零变化includeAll 短语并入既有命中池,得分仍取最高短语分,存量 matcher 行为逐字不变(黄金样本回归断言覆盖)。

测试

  • 新增 scripts/test-routing-semantics.js:公共 API 契约 seam(createFlow2Spec().routing.match() + 临时 .Knowledge 夹具),10 组用例——黄金样本回归 / 否决 / 否决恒胜 exact / excludeAll AND 与半命中 / 纯 AND 资格与不资格 / 打分池合并 / 被否决规则不进 candidates / 归一化大小写 / exact 保持 10000·high;
  • 挂入 npm test 链,全量测试全绿(含本仓自举 kb check),version:check 绿。

文档

docs 中英文六处同步四字段语义(体系与原理 / architecture、目录与路径约定 / directory-conventions、命令说明 / commands-reference)。

兼容性

公共 API 返回结构零变化、零新增运行时依赖、protocolVersion 不变;「路由命中明细(explain)」为后续独立提案,将在 Discussions 单独对齐。

(背景基准:对标 mem0 / OpenViking / TencentDB-Agent-Memory 的路由可观测与治理机制后选定的最小切口,详见 #54。)

schema(flow2spec.matcher.v1)早已定义并校验这三个字段,但 routing.match()
只消费 includeAny——写了排除词/组合词的词表形同虚设。

- 否决门:excludeAny 任一命中或 excludeAll 全部命中即整条规则否决,
  恒胜于 task 精确命中(排除词表达"此请求不属于该域")
- 资格门:includeAny 任一命中或 includeAll 全部命中即具备候选资格;
  纯 includeAll(无 includeAny)的 matcher 也可表达
- 打分与置信级零变化:includeAll 短语并入命中池,得分仍取最高短语分,
  存量 matcher 行为逐字不变(黄金样本回归覆盖)
- 新增 scripts/test-routing-semantics.js(公共 API seam:临时 .Knowledge
  夹具 + createFlow2Spec().routing.match()),挂入 npm test 链
- docs 中英文六处同步四字段语义

Fixes double-coding-lab#54

知识库核查:.Knowledge 各 topic 无"仅 includeAny 生效"类失真表述,无需 delta。
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.

【Bug】matcher 的 includeAll / excludeAny / excludeAll 字段已在 schema 定义,但 routing.match() 未消费

2 participants