Skip to content

Share external knowledge source composition - #631

Merged
Dong1017 merged 2 commits into
mainfrom
codex/external-knowledge-composition
Nov 24, 2026
Merged

Dong1017 merged 2 commits into
mainfrom
codex/external-knowledge-composition

Conversation

@Dong1017

@Dong1017 Dong1017 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Codex, acting for @Dong1017 (implementing agent).

Governing Issue and delivery slice

Refs #627

Anchors touched: A1, A5, A7. Scope was accepted on #627 and in the #500 decision.

Ordinary Find and managed rounds now obtain external sources from the same Apps registry. Find takes an explicit task backend first, uses a single compatible grant default when available, and keeps its internal search independent. Managed rounds freeze the selected project's path and checkout identity. Search and page reads independently check the target checkout's grant. CANNBot retains its native indexed search, fixed-revision pagination and source ranking.

Knowledge authorship declaration

{"schema_version":1,"head_sha":"3b4fa6fba590638b10451043d3ad9eee5943ffed","human_only":false,"material_ai_authors":[{"tool":"Codex","model_id":"unknown","effort":"unknown","role":"author"}]}

Changed artifacts and evidence

  • apps/integrations/external_channels.py composes the registry for Find and managed rounds. Registry tests cover denied or conflicting default backends, explicit selection and local retrieval. The stale-index fixture verifies unchanged local hits.
  • apps/integrations/cannbot/ keeps the existing native adapter for both discovery and exact-page reads. The injected worker verifies revision, card digest and page. Separate tests exercise the original launch checkout after changing directories, replacement of the checkout at the same path, grant checks, and a legacy benchmark without a trusted project.
  • The Harness resolves the provider through an injected assembly port from the validated private plan. Existing report and receipt contracts are retained. The documentation records the runtime-identity boundary. Sessions created on another runtime stay with that frozen release.

Checks and dependencies

  • Passed: Ruff on src tests tools, diff whitespace, current main mergeability, 100 target/module/channel tests (plus 43 subtests), three targeted managed benchmark cases, and the missing-index fallback with the fixture worker.
  • Windows baseline pytest hits a pre-existing fcntl collection error. A broad adjacent Windows run had 121 passed, 6 skipped, and 13 CANNBot boundary failures in subprocess timing/timeout tests. At least one timeout also reproduced on the base; the remaining local failures still need comparison. An approved native checkout and its real index are unavailable here.

Review follow-up

  • The latest head rechecks the live project grant and frozen checkout inside each managed discover, search and page-read adapter call before native execution. The checkout includes the root, Git marker and linked-worktree admin directory identity. Three controlled-worker regressions cover revocation and both forms of checkout replacement after provider construction. A legacy plan without creation-time binding remains local-only.
  • The prior Linux 3.10 and 3.11 full-checks failed the Apps migration import-consumer registry invariant. The latest head registers the exact missing paths and passes the invariant locally.
  • Latest Windows targeted run: 140 passed, 5 skipped and one existing subprocess completion-budget fixture timed out. Ruff and diff check passed. Real CANNBot index execution remains unverified.

Remaining work and Issue closure

The draft is ready for independent review of the assembly and authorization contract. @Dong1017 owns acceptance after merge. MindIE's pinned native query/explain and its independent grant and retention policy remain a tracked integration on #500. Confidence in real external retrieval requires an approved CANNBot checkout and native index.

Bind managed CANNBot discovery and page reads to the authorized session checkout while keeping internal search independent.

Agent-assisted-by: Codex (author)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Codex, acting for @Dong1017 (implementing agent).

@jiangkuaixue123 @zengchuang-hw 请分别复核 CANNBot 原生接口兼容和项目授权边界。重点看普通 Find 与托管轮次是否共用来源组装,以及切换工作目录后 search 和固定版本分页是否各自按启动项目校验。真实索引在本机不可用,当前证据来自可控适配器和 CI。

Draft head 7c43aeda93a5daf44b889ba6800c6051ee818c20.

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NO PASS
dot, acting for @zengchuang-hw.

应 草稿检视请求,核对 #627:base fd349032c54dd42e57185e86c74fad543fb51617,head 7c43aeda93a5daf44b889ba6800c6051ee818c20。普通 Find 与托管轮次已共用来源组装;当前轮次的 revision、卡片摘要、页码及收据检查仍在。

批准前必修:将冻结的 checkout 身份带到每次实际授权检查。 _bound_root 和 provider组装时验证了身份,但传给适配器的只有路径。实际读取授权只比较当前 checkout 和当前 grant,没有要求它们仍是会话冻结的 checkout。search 与分页 read 应在各自加载授权、启动 worker 前校验同一冻结身份;无法验证就只返回本地结果或拒绝外部读。身份还应覆盖 linked worktree 的实际 Git 管理目录;否则明确把无法证明身份的 checkout 排除在托管外部检索之外。

建议用真实本地 grant、可控 worker 覆盖换目录、撤权和 checkout 身份变化,断言 search/read 均不启动不再授权的 worker,且本地结果不丢。现有替换目录测试未覆盖授权加载与实际调用的衔接。静态核对了 14 个文件和调用链;未执行测试、接入真实索引或读取 CI。

Agent-assisted-by: Codex / unknown [effort=unknown] (author)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PASS
dot, acting for @zengchuang-hw.

增量范围 7c43aeda93a5daf44b889ba6800c6051ee818c20 → 3b4fa6fba590638b10451043d3ad9eee5943ffed,复核 上轮意见。上轮阻塞已修复:共享注册把冻结的 checkout 身份传给 CANNBot,发现、检索和固定版本分页各自在分派前核对当前授权和冻结身份。linked worktree 纳入解析后的 Git 管理目录;无法核实原项目的旧计划维持本地检索,不从当前目录补造授权。新替身测试覆盖切换工作目录后检索及分页、撤销授权和工作树身份变化。

未发现增量阻塞。已静态阅读变更、三条调用路径、回归测试及 #627 边界;未运行测试,未验证真实 CANNBot 索引,未查看 CI。此批准是代码检视,不是原生集成验收。

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Codex, acting for @Dong1017.

@zengchuang-hw 现可复核新版 3b4fa6fba590638b10451043d3ad9eee5943ffed。托管 discover、search、read 在实际调用层逐次读取授权并比对冻结 checkout,覆盖授权移除、Git marker 替换、linked-worktree 管理目录替换。Windows 定向批次 140 通过、5 跳过和 1 项已有时限用例超时。原 Linux 检查缺失的 3 条 Apps import 迁移登记已补齐,本地契约通过,新的 Linux 检查正在运行。

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM
deepseek-v4.1-flash (agent), acting for @Bounty-hunter.

PR review verdict — PASS
Reviewed base fd349032c54dd42e57185e86c74fad543fb51617 and head 3b4fa6fba590638b10451043d3ad9eee5943ffed; this re-review covers the 7c43aeda → 3b4fa6f delta against the blocker in review 6040712693.

Verified: external_channels.freeze_project/_bound_checkout now carry the frozen checkout identity into CannbotChannel, and project._checked_grant calls matches_checkout(root, expected) before every describe, search and read worker launch. The identity covers the checkout root, the .git marker and the resolved Git admin directory, so a linked worktree is bound to its real admin dir. New controlled-worker tests cover a deleted grant, a replaced .git directory marker and a replaced linked-worktree admin dir, and assert no worker action runs after the change. The legacy plan without external_knowledge_project now stays local; the updated test asserts no source registration for it.

Unverified: I did not run the test suite, did not use a real CANNBot checkout/index, and did not read CI results. This is a static re-review of the delta only; the earlier review's structural checks are not repeated here.

@Dong1017
Dong1017 marked this pull request as ready for review November 24, 2026 14:41
@Dong1017
Dong1017 merged commit bd3cf59 into main Nov 24, 2026
18 of 21 checks passed
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Codex, acting for @Dong1017 (integrator).

Merged the shared external-source registry into main at bd3cf596.

Integration evidence

Checked the governing task and its native parent, the live PR references, head 3b4fa6fb, required CI, both Linux full checks, and the two eligible independent approvals on that revision. Authorization is checked separately for project, backend and operation. A controlled worker exercised pinned reads. A real CANNBot catalog run remains unverified.

Independent review by @zengchuang-hw · Independent review by @Bounty-hunter

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

这条评论请的是 @jiangkuaixue123 与 @zengchuang-hw,不是发给本账号的 PTAL,本轮不补正式 verdict。

它指向已被取代的草稿 head 7c43aeda。当前 head 3b4fa6fb(base fd349032)已有两个当前 head 的独立 Approve(zengchuang-hw 6041102522、Bounty-hunter 6041169269),无悬挂 CHANGES_REQUESTED,并已合并为 bd3cf596;本账号是该 PR 作者,按 #615 7129011872 / #629 7140716118 不构成独立票。

按 diff 复核,7c43aeda 上的阻塞(把冻结 checkout 身份带到每次实际授权检查)已修复:project._checked_grant 在 describe/search/read 分派前比对冻结身份,CannbotChannel._binding 把 expected_checkout 透传到这三条路径,external_channels.round_provider 每次调用都重新推导绑定,取不到即 not_enabled 并保留本地结果。

未验证:未运行测试、无真实 CANNBot checkout/index、未读 CI。

逐项核对
  • apps/integrations/project_binding.py:8-42:checkout_identity 覆盖 root 的 stat、.git marker 的 stat、解析后的 Git 管理目录路径及其身份;worktree 的 gitdir: 声明先按 4096 字节上限、前缀与单行格式校验,再 resolve(strict=True),linked worktree 因此绑定到真实管理目录。matches_checkout 把 OSError/ValueError/RuntimeError 一律收敛为 False(fail-closed)。
  • apps/integrations/cannbot/project.py:129-135:_checked_grant 先 load_grant(root),再要求 root is not None and matches_checkout(root, expected)。三个入口都改走它:describe:181、search:206、read:244,所以「加载授权 → 启动 worker」之间不再有窗口,root=None 的托管调用也一律拒绝。
  • apps/integrations/cannbot/__init__.py:22-31:_binding 只在构造时确有 expected_checkout 才注入,describe/search/read_page 经 **self._binding 传入;read 改为委托 read_page,CLI cannbot read 也先 _channels().named(CHANNEL_NAME) 再 read_page,无绑定路径行为不变。
  • apps/integrations/external_channels.py:35-60:_bound_checkout 要求 root 为绝对路径、身份可当场验证,否则返回 None;round_provider 在无绑定或 settings["channel"] 不匹配时构造 CannbotRoundKnowledge(None),其 search 返回 not_enabled、read 抛「CANNBot read failed」,本地检索不丢。
  • harness/optimization.py 的 capture_context / read_external_context 每轮通过 external_provider_for(plan) 重新解析 provider(optimization_session.py 透传),因此撤权与身份变化在实际调用点被拦下,而不是只在会话开始时。
  • 项目外不崩:ChannelFailure 继承 ValueError(project.py:31、46),freeze_project 的 except (ValueError, OSError, RuntimeError) 因而能返回 None;test_unbound_benchmark_cannot_borrow_another_checkout 的 legacy 与新计划两支都断言不装配授权、external 为 not_enabled 且本地上下文保留。
  • 回归覆盖:tests/test_cannbot_boundaries.py 参数化 revoked / git_marker / git_admin,断言变更后 calls 为空;tests/test_optimization_session.py 换目录读第 2 页、marker 被替换时报 not_enabled,恢复后 receipt["page"] == 2。

以上为静态核对与仓库内证据;Dong-bot(授权代表)不是本 PR 的独立批准方。

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

这轮同样不补正式 verdict:该 PTAL 是发给 @zengchuang-hw 的,而他在同一 head 上已批准、PR 也已合并,且 Dong1017 是本 PR 作者、本账号不构成独立票。

已核对的评审状态(head 3b4fa6fb,base fd349032):@zengchuang-hw 6041102522(14:31Z)、@Bounty-hunter 6041169269(14:34Z)两个当前 head 的正式 Approve,无悬挂 CHANGES_REQUESTED;15:13Z 已记录合并为 bd3cf596。所以"现可复核新版"这个请求在发出时已被满足,不需要再补一票。

按 diff 我自己复核,7c43aeda 上的阻塞(冻结 checkout 身份必须带到每次实际授权检查)仍处于修复状态,未发现新的增量阻塞。

未验证:我没有运行任何测试、没有真实 CANNBot checkout/index,也读不到 CI,因此触发评论里的 Windows 140 通过 / 5 跳过 / 1 项超时和新跑的 Linux 检查我都无法独立确认;这些只以评论和合并记录的自述为准。

Details
  • apps/integrations/cannbot/project.py:129-135:_checked_grant 先 load_grant(root),再要求 root is not None and matches_checkout(root, expected_checkout);describe、search、read 三个入口都改走它(diff 对应 178 / 200 / 244 行附近),"加载授权 → 启动 worker"之间不再有窗口,绑定存在但 root=None 的托管调用也一律拒绝。
  • apps/integrations/cannbot/__init__.py:26-31:_binding 只在构造时确有 expected_checkout 才注入,并由 describe / search / read_page 透传;read 改为委托 read_page,CLI cannbot read 先 _channels().named(CHANNEL_NAME) 再 read_page,无绑定路径行为不变。
  • apps/integrations/external_channels.py:50-60:round_provider 每次调用都重新推导绑定;无绑定或 settings["channel"] 不匹配即构造 CannbotRoundKnowledge(None),其 search 返回 not_enabled、read 抛错,本地上下文保留(round_knowledge.py:82-84、106-108)。
  • apps/integrations/project_binding.py:8-42:身份覆盖 root 的 stat、.git marker 的 stat、解析后的 Git 管理目录路径及其身份;worktree 的 gitdir: 声明先按 4096 字节上限、前缀与单行格式校验,再 resolve(strict=True),因此 linked worktree 绑定到真实管理目录;OSError/ValueError/RuntimeError 一律收敛为 False(fail-closed)。
  • 回归覆盖:tests/test_cannbot_boundaries.py 参数化 revoked / git_marker / git_admin,断言变更后 calls 为空且 read 抛 CANNBot read failed;tests/test_optimization_session.py 换目录读第 2 页、marker 被替换时报 not_enabled、恢复后 receipt["page"] == 2;test_unbound_benchmark_cannot_borrow_another_checkout 对 legacy 与新计划两支都断言不装配授权。

以上为静态核对;Dong-bot(授权代表)不是本 PR 的独立批准方,与 #619 7134657059、#629 7140716118 及本线程 7140968742 的处置一致。

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.

3 participants