Skip to content

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

Closed

Description

@chyuan-cuihongyuan

现象

matcher 分片 schema(flow2spec.matcher.v1)定义了四个字段,kb check 也会校验其结构,但路由匹配实际只消费 includeAny,另外三个字段静默失效:

  • 写了 excludeAny: ["预演"],请求里带「预演」照样命中该任务域(误路由);
  • 写了 includeAll: ["数据","迁移"],缺少 AND 语义,纯组合词词表无法表达;
  • 维护者面对误路由只有两个坏选项:删触发词(伤召回)或忍受。

根因

packages/core/lib/routing.js 的 match() 只读取 matcher 的 includeAny 字段;includeAll/excludeAny/excludeAll 仅存在于 schema 归一化与校验,检索侧无消费点。

修复方案(已在 fork 实现并通过全量测试)

  • 否决门:excludeAny 任一命中或 excludeAll 全部命中 → 整条规则否决,且优先于 task 精确命中(排除词表达「此请求不属于该任务域」);
  • 资格门:includeAny 任一命中 或 includeAll 全部命中 → 具备候选资格;纯 includeAll(无 includeAny)的 matcher 首次可表达;
  • 打分与置信级零变化:includeAll 短语并入既有命中池,存量 matcher 行为逐字不变(黄金样本回归断言覆盖);
  • 新增公共 API 契约测试 scripts/test-routing-semantics.js(临时 .Knowledge 夹具 + createFlow2Spec().routing.match(),10 组用例)挂入 npm test 链;docs 中英文六处同步四字段语义;npm test 与 version:check 全绿。

PR 稍后开出(链接将补充在评论里)。另外还有一个「路由命中明细(explain)」的后续提案,方向确认后会在 Discussions 单独开帖对齐。

Activity

  1. chyuan-cuihongyuan commented on Aug 28, 2026

    @chyuan-cuihongyuan
    Author

    补充说明:后续修复 PR 将以 main 为目标分支(base = main)。

    依据:

    修复分支:chyuan-cuihongyuan/Flow2Spec 的 fix/matcher-consume-all-fields(基于最新 main 8339dc1)。PR 开出后仅请求审阅,是否合并、何时合并完全由维护者决定。

    PR 链接将在开出后补充在本评论下方。

  2. chyuan-cuihongyuan commented on Aug 28, 2026

    @chyuan-cuihongyuan
    Author

    修复 PR 已开出:#55(chyuan-cuihongyuan:fix/matcher-consume-all-fields → main)。含公共 API 契约测试 10 组用例与中英文档同步,npm test / version:check 全绿,仅请求审阅,合并由维护者决定。

  3. Lands-1203 commented on Sep 3, 2026

    @Lands-1203
    Collaborator

    好的 我看看。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions