Skip to content

Implement #185: [MCP Sink] 支持从零开始发现 InKCre 类型、资源与数据 - #189

Merged
xiaoland merged 5 commits into
mainfrom
braid-agent/issue-185/impl-py-issue-g2
Nov 12, 2026
Merged

xiaoland merged 5 commits into
mainfrom
braid-agent/issue-185/impl-py-issue-g2

Conversation

@braid-of-inkcre

Copy link
Copy Markdown
Contributor

Closes #185

Implementation request: #185 (comment)

@braid-of-inkcre

Copy link
Copy Markdown
Contributor Author

Braid Agent · Braid pr (impl-py)
PR Implementation Agent

已实现 #185,候选提交 e087bde;建议合并标题:feat(core): add bounded MCP metadata discovery。

  • 新增第八个 MCP Tool inkcre_discover,分开投影本地 Resolver registry、持久 Resolver 值、Source/Storage 类型目录与实例,以及 exact Resolver 下的 Block 引用。历史未加载 Resolver 不阻断发现。
  • 默认 20、最多 100 项,scope-bound keyset cursor;SQL 只读白名单列,不加载 config/state/schema/content,不构造 handler 或触发外部读取/materialization。
  • 新增 blocks(resolver,id) 索引迁移、契约/运维说明、release fragment;修复历史 NULL Block 时间戳的发现与既有 preview 衔接。

验证:

  • pdm run check 通过(全套 hermetic tests:138 passed、63 skipped)。
  • disposable PostgreSQL 上 info-base/MCP/migration suites:12 passed、6 skipped;这 6 项因本机无 PostgreSQL initdb binaries,未宣称通过。
  • 新 MCP/PG 旅程覆盖空目录、多类型/实例、分页、负 Storage ID、历史 Resolver、NULL 时间戳、秘密哨兵与只读事务;并继续调用既有实体/内容/Resolver tools。
  • mounted Streamable HTTP/PAT 手动探测通过;新增迁移 upgrade → downgrade → upgrade 通过;独立只读 review 无未解决问题。
  • 10 万 synthetic Blocks 的 EXPLAIN 确认索引支持 seek;distinct 仍非恒定成本,不作全库扫描成本保证。

影响发布项目:core-py。无外部凭据/生产部署变更。风险:普通事务内索引构建可能阻塞 Block 写入,大库需维护窗口。回滚可撤回应用 Tool,保留或独立删除新增索引,不删除业务数据。

请按仓库 required checks 完成 PR 审阅/合并;未执行真实 ChatGPT/tunnel 或生产环境验收。当前 Braid pr ensure 自动生成 Draft 标题/正文且无 edit 子命令,故完整实现与验证交接记录在本评论。

@braid-of-inkcre

Copy link
Copy Markdown
Contributor Author

Braid Agent · Braid pr (impl-py)
PR Implementation Agent

已推送修复 71e3e41:

  • 修复 required CI 的 CREATE SCHEMA 权限失败:测试建表、造数和清理由迁移角色承担;MCP 调用仍使用业务角色,只授予临时 schema 的 USAGE/SELECT,并保持只读事务。不扩大运行时权限。
  • 拒绝超出 PostgreSQL INTEGER 范围的分页 cursor,返回 invalid_arguments;补充真实 MCP 回归验证,保留负 Storage ID。

在 disposable PostgreSQL 中复现 CI 的角色分离后,pdm run test:database 45 passed;pdm run check 通过(138 passed、63 skipped),迁移 append-only 与 release-intent 检查通过。临时 schema 已清理。

新提交的 GitHub required checks 待完成;原有索引维护窗口风险与回滚方案不变。请维护者在 checks 通过后审阅/验收,尚未合并或部署。

@xiaoland
xiaoland marked this pull request as ready for review November 11, 2026 02:57

@xiaoland xiaoland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please address the inline finding: the current Resolver catalog must come from the peer-local registry, not from persisted Block values.

Comment thread app/business/sink/discovery.py Resolved
@braid-of-inkcre

Copy link
Copy Markdown
Contributor Author

Braid Agent · Braid pr (impl-py)
PR Implementation Agent

实现范围已按 #185 的四条新 Human 评论更新;当前验收基线见 #185 (comment) 。请在本 PR 继续实现,不另建 PR:

  1. 统一八个无前缀工具名,recall → query、发现入口 → meta_discover,无旧名 alias;meta 收敛为四类类型/identity 信息。
  2. 将 resolver/storage exact AND filters 下沉到 lexical/semantic 数据库候选查询,先于 ranking/top-K;纯条件由 info-base 直接分页查询,不依赖检索索引,不混入 Relations。
  3. 补正常 Core/SinkManager 生命周期、真实挂载 Streamable HTTP/PAT、独立 MCP Client 的 meta → query → open → read E2E;增加高排名非匹配候选超过 K 的回归,不能以“返回项都匹配”的空集断言替代。
  4. 同步技术/运维文档、release fragment 与验证记录。既有 SQL 白名单/角色隔离回归继续保留;检查 storage-only 查询计划,不顺带扩大 Peer 协议或查询运算符范围。

这是对现有实现的后续修订任务;旧 CI/手动探测尚未证明新验收完成。Issue 工作树本轮仅做设计/交接,未修改产品代码。

@xiaoland

Copy link
Copy Markdown
Member

@braid 请继续在本 PR 实现 #185 更新后的验收基线,按 Issue 评论 #185 (comment) 和上方 Braid 交接评论执行。完成代码、必要测试、文档与 release fragment 后推送到当前 PR,并在这里报告验证结果及剩余风险。

@braid-of-inkcre

Copy link
Copy Markdown
Contributor Author

Braid Agent · Braid pr (impl-py)
PR Implementation Agent

已按 #185 当前验收基线完成修订并推送 9877750;以下取代旧提交对应的范围/验证记录。

  • 统一八个无前缀工具名,无旧名 alias;meta_discover 仅保留四类类型/identity,Resolver 只来自本 Peer registry,Storage 仅返回 id/type/nullable nickname。
  • query 支持文本检索和纯条件 Block keyset 分页。resolver/storage exact AND 条件下沉至 lexical/semantic 候选 SQL、先于 ranking/top-K;有实际 Block 条件时不查询 Relations。纯条件查询不依赖检索索引、不调用 embedding/Resolver。SDK、REST/Peer inbound 保留过滤条件。
  • 更新技术/运维文档、OpenAPI、release fragment;追加 blocks(storage,id) 索引迁移 bb5dcb562587,不改既有迁移历史。发布项目:core-py。建议合并标题:feat(core): add metadata discovery and filtered MCP query。

验证:

  • disposable PostgreSQL、迁移/业务角色分离:pdm run test:database 46 passed,无跳过。新增正常 Core/SinkManager 生命周期、独立 MCP Client、真实 TCP HTTP/PAT 的 initialize/tools/list → 四类 meta → storage/resolver/AND query → 跨 HTTP 分页 → open → solved read;覆盖未索引 Block、历史 Resolver、无/错 PAT,以及 disable 和 active shutdown 清理。
  • 两种检索模式各有 5 个排名更高但不匹配的 Block(K=2),另有高分 Relation;过滤后断言两个目标 Block 的实际 ID/数量。语料经 graph/Storage 生产路径、索引经真实 Manager maintain 建立,仅 embedding dialect 确定化;无 retrieval Manager mock 或直接 SQL 索引造数。保留 SQL 白名单、只读事务和不构造 handler 回归。
  • pdm run check 通过(138 passed、64 skipped;数据库项已单独实际执行);append-only、release-intent、diff 检查通过。新增迁移 upgrade → downgrade → upgrade 通过;10 万 synthetic Blocks 的 EXPLAIN 确认 storage-only seek 使用新增索引、无 Sort,造数已回滚。

剩余风险:Client 需刷新 tools;事务内索引构建可能阻塞写入,大库需维护窗口;分页非快照、AND 成本取决于选择性。回滚应用可恢复旧工具面,索引可保留或单独 downgrade,不删业务数据。未执行真实 ChatGPT/tunnel 或生产验收,未合并/部署;新 HEAD 的 required checks 待完成。

@xiaoland xiaoland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two follow-up items to address before merge: align the internal query-mode terminology, and make the MCP Sink lifecycle E2E verify public transport behavior rather than private implementation state.

Comment thread app/business/sink/mcp.py Resolved
@braid-of-inkcre

Copy link
Copy Markdown
Contributor Author

Braid Agent · Braid pr (impl-py)
PR Implementation Agent

已处理本轮两条评审意见,推送 fb95bed:

  • RecallMode 改为 RetrievalMode,更新 import/annotations;lexical | semantic wire values 和行为不变。
  • 生命周期 E2E 移除针对 Sink 私有 running/session/mount 状态的断言。现在验证:启用后独立 Client initialize/tools/list 八个工具;禁用后原 URL 404、普通 DB-backed Core API 仍返回 200;重新启用后新建独立 Client 在同 URL/PAT 完成初始化及八工具发现;shutdown 后外部连接失败,且 transport/Sink 普通日志无关闭错误。关闭验证发生在 fallback cleanup 之前。
  • 更新原 tasks/knowledge-lifecycle-capabilities/units/mcp-sink/acceptance.md 的八工具、公开生命周期与 meta → query 旅程,同步技术文档。

已复核远端 HEAD 并重跑验证:disposable PostgreSQL 上 pdm run test:database 46 passed,无跳过;pdm run check 通过(138 passed、64 skipped);release-intent、migration append-only、diff 检查通过。该 HEAD 的 GitHub impl-py checks、impl-py e2e tests、inkcre-cli checks 已成功,preview deployment 仍在运行。

无新增迁移或运行时权限变化;既有索引维护窗口、非快照分页及 ChatGPT/tunnel 手动验收风险不变。未合并或生产部署。

@xiaoland
xiaoland merged commit 9f75cbb into main Nov 12, 2026
8 checks passed
@braid-of-inkcre

Copy link
Copy Markdown
Contributor Author

Braid Agent · Braid pr (impl-py)
PR Implementation Agent

合并收尾:已核对 #189 已合并,#185 已完成关闭。最终实现与验证记录见 #189 (comment) 。发布时仍需关注索引迁移的写入阻塞风险,并刷新 MCP Client 的 tools;真实 ChatGPT/tunnel 与生产验收尚未执行。本轮仅核对收尾状态,未追加代码或重跑测试。

This branch was successfully deployed

1 active deployment
preview — fb95bed3 Deployed Nov 12, 2026 by xiaoland via impl-py preview cleanup #570
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.

[MCP Sink] 支持从零开始发现 InKCre 类型、资源与数据

1 participant