Skip to content

feat(search): replace default lexical analyzer with Rust - #2735

Open
AlexStocks wants to merge 35 commits into
oceanbase:masterfrom
AlexStocks:codex/rust-lexical-pilot
Open

AlexStocks wants to merge 35 commits into
oceanbase:masterfrom
AlexStocks:codex/rust-lexical-pilot

Conversation

@AlexStocks

@AlexStocks AlexStocks commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

No existing public issue is closed. The bounded migration unit and contract are documented in the port plan.

Rationale for this change

Replace the production analyze_text(str) -> str Python projection with Rust. Normal PowerContext installations now import and execute the native function directly, reducing analyzer time while preserving ordered projection terms, duplicates and backend-safe encoding.

What changes are included in this PR?

  • Place the production crate beside its owning artifact search module at src/powercontext/builtin/artifacts/lexical/. Remove the Python projection wrapper and experimental activation plugin. Retain Python span/query helpers for their existing offset and admission responsibilities.
  • Build powercontext._lexical into the root Hatchling wheel using maturin and cp311-abi3; include the complete build inputs in the sdist. Pin Rust 1.95.0, matching gateway, and preserve locked dependencies.
  • Preserve the current analyzer version, schema and persisted projections. Match CPython 3.11–3.14 Unicode semantics and Python Jieba's internal scoring boundaries, including the 丁丁丁㐀 review regression.
  • Add real manylinux x86_64/aarch64, macOS x86_64/arm64 and Windows x86_64 wheel builds/install tests; connect them to Main packaging checks and release publication. Prepare Rust for existing source-build workflows and Docker builder stages. Preserve the existing candidate wheel/sdist upgrade gate.
  • Keep evaluation material under evaluation/performance/lexical/, with production evidence, all timing samples and validation summaries.
  • Retain the existing bounded two-worker unit/E2E CI configuration used to address the earlier runner-contention failures.

Are there any user-facing changes?

The default runtime now executes Rust. Compatible binary wheels need no compiler. Source/editable installation requires Rust 1.95.0 and a platform C toolchain; Windows uses MSVC. There is no runtime opt-in or Python fallback.

Python support is explicitly 3.11–3.14 (>=3.11,<3.15), tightened from <4.0: the native module implements the corresponding Unicode 14/15/15.1/16 semantics. Future versions need tables and validation before this bound can expand. Installation documentation is updated in both languages. Public callable signatures, span/query behavior, projection identity and storage schema are preserved.

How was this change tested?

Validation of the corrected production binary on 2026-11-21:

  • Focused behavior/delivery suite: 447 passed, 44 skipped (85.02s). Includes 36 native-interface cases and search/admission/persistence/e2e/CI/release/Docker contract tests.
  • Seven scoring-boundary regressions: faulty build 6 failed, 1 passed; corrected build 7 passed.
  • Same root Windows wheel installed under CPython 3.11.15/3.12.13/3.13.12/3.14.3: 12,548 / 12,610 / 12,610 / 12,693 unique comparisons, zero mismatches, native default identity and non-string errors checked with python -I.
  • Independent four-interpreter comparison: 4,924,563 comparisons, zero mismatches, including every Unicode codepoint, 71,178 Han characters outside Jieba's DAG range, scoring-boundary combinations and seeded mixed strings.
  • Final sdist rebuilt through the existing acceptance function: 813 wheel members excluding RECORD match byte for byte. Core-only clean installation works without Python Jieba/httpx. Installed SQLite write/close/reopen/read/search smoke passed on 3.11 and 3.14.
  • Rust 1.95.0 MSVC fmt, locked clippy -D warnings, and 4 Rust tests passed; 4 tests passed on WSL/Linux. Lock consistency, changed-file Ruff/type checks, content hooks and 315 pinned action references passed.

Production-default warm analyzer timings, including the native bridge, nine alternating rounds, Intel Core Ultra 5 225H / Windows x64 / CPython 3.14.3:

Workload Python median Rust median Speedup
12 Chinese documents / 101,280 characters 115.9114 ms 9.7368 ms 11.90×
12 English documents / 140,040 characters 11.3287 ms 3.4048 ms 3.33×
Short query repeated 1,000 times / 26,000 characters 11.0113 ms 1.3363 ms 8.24×

Limitations: actual GitHub manylinux/macOS wheel jobs and Docker execution remain unverified locally. CPython 3.12/3.13 SQLite smoke is blocked by a Windows stdlib asyncio socketpair stall reproduced without PowerContext. Whole-repository ty retains 93 existing Windows/platform diagnostics; full make check, full pytest/tox, real OceanBase/seekDB/host acceptance and whole-server speedup are not claimed. CPU clock/affinity/background activity were uncontrolled; full samples are retained. New-Head CI results are tracked separately from local results.

AI usage statement

Implemented and validated with OpenAI Codex (GPT-6), including an independent agent review. rust-anything assisted the initial port; final production packaging, compatibility and delivery were verified against the repository's normal installation and search paths.

Add an isolated PyO3 implementation of analyze_text with Unicode16 and
fixed Jieba dictionary compatibility, strict replay checks and native test activation.
Include reproducible warm benchmark samples and installed-wheel validation identities.

Constraint: Production defaults, persistence and root Python packaging are unchanged.
Scope-risk: Windows CPython 3.14 pilot; final independent review and wider platform validation remain pending.
Tested: rust-anything diff (2033/2033) and gate (12 checks); locked Cargo tests and clippy; strict direct/wheel replay (2637 strings plus type/boundary checks); native pytest (13 passed, 20 calls); Ruff and scoped ty passed. Prek whole-repository ty reports 93 existing Windows diagnostics, also present with rust excluded.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 11:51

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@AlexStocks

AlexStocks commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

PowerContext 文本分析 Rust 试点:实现、测试、性能和复现报告

测试日期:2026-11-20。对应 PR 提交:0a25fb629a8d5f3c17d595cad7f8fdd9cc1aa8a7。

Python 参考提交:5b557788c33b57b8ef55a3f3446ee72d693270a4,其已跟踪文件树与本 PR 基线 6763b07661846c19934044184995adf9183c28cc 相同。参考函数为 src/powercontext/builtin/artifacts/search.py 中的 analyze_text(str) -> str;参考源码、词典和原生构建的 SHA-256 见下文。

1. 结论与验收状态

这个独立 Rust 实现已经通过本轮 rust-anything 门禁、严格行为比较、既有测试的原生装配,以及干净环境中的 wheel 安装验证。在相同离线语料上,计入 Python↔Rust 调用和数据转换成本后,三组负载均测得性能改善。

技术结果支持继续评估产品接入,但当前交付仍是一个有明确版本和平台边界的试点。默认 PowerContext 运行路径仍使用 Python;正常安装主项目 wheel 不会自动使用此扩展,也不会直接获得表中的提速。

维度 状态 依据与边界
窄单元的本地行为验证 PASS 录制回放、严格字符串比较、错误类型、固定预期和负控通过
本地 Rust 构建与代码检查 PASS locked build/test/clippy、fmt 和 rust-anything gate 通过
独立 wheel 的安装验证 PASS 干净环境安装后,以 Python -I 执行严格验证通过
本地微基准 测得改善 三组工作负载的初测和最终复测均保留原始样本;不代表固定生产性能
全仓提交检查 未全部通过 全仓 ty 在 Windows 上报告 93 条既有路径诊断;新增试点目录自身检查通过
最终独立审查 尚未完成 开工方向核查不等于最终实现审查;另外尝试的最终只读审查在模型执行前被远端服务拒绝,没有产生最终审查结论
CI、合并和发布 单独判断 本报告描述执行者的本地证据;CI 以 PR Checks 为准,不据此声称已批准、可合并或可发布

2. 实现范围和保持的契约

实现位于独立的 rust/lexical-rs/。rust-anything 对真实的 search.py 生成了 PyO3 桥接,本次只迁移 analyze_text,其余导出继续保留在 Python。算法位于 src/port.rs,Python 字符串入口适配位于 src/lib.rs,独立 wheel 使用 maturin 打包。

迁移需要保留以下现有语义,不能仅以“分词结果看起来差不多”作为正确依据:

  • 先做 NFC,再做 casefold,保持二者的先后顺序。
  • 保持原有 Han 范围,只将 Han 连续片段交给 Jieba,关闭 HMM。
  • 对齐 Jieba 0.42.1 默认词典的有效词条与总频次。
  • 对齐 Python 单词字符分类、单引号和弯引号处理。
  • 保留 token 的顺序、重复次数和频率,不做额外去重或排序。
  • 保持 pcu / pch 保留前缀的转义、UTF-8 字节长度阈值和 SHA-256 编码。
  • 运行时不调用原 Python 分析器,也不在 native 失败后重试 Python。原生路径缺失时要明确失败。

本 PR 没有修改 query/spans/admission、分析器版本、数据库 schema 或投影、gateway、desktop、HTTP 契约和根 SDK 的 Hatchling 打包。原生装配只发生在显式探针或测试进程中。

依赖使用 jieba-rs = 0.11.0、unicode-normalization = 0.1.24、PyO3 和 SHA-256;解析版本保存在独立 Cargo.lock 中。Unicode normalization 与导出的 casefold/word 数据都限定在 Unicode 16,不能把依赖名称相似当作行为等价证据。

3. 两处需要额外处理的兼容问题

词典内容相同,不代表分词概率权重自动相同。

准备脚本比较了 Python 和 Rust 默认词典的完整有效 word → frequency/tag 映射,结果相同;原始字节却不相同。Python 词典额外重复了一行 B超 3 n,这行对有效映射没有新增贡献,却会让 Python 计算的总频次多 3,参考总频次为 60,101,967。

Rust 实现在 NUL 词上补入频次 3。NUL 不可能出现在送给 Jieba 的 Han-only 片段中,因此该处理用于对齐总权重,同时不增加这个单元可以命中的词。它只针对本次已核对的固定默认词典;不据此承诺自定义词典和运行时词典修改的兼容性。

来源 SHA-256
Python Jieba 0.42.1 默认词典 7197c3211ddd98962b036cdf40324d1ea2bfaa12bd028e68faa70111a88e12a8
jieba-rs 0.11.0 bundled 词典 139519822fe8ab9e10d9d07e68ea0451045380aedaf54ecc51e2a28c6b42a13f

Python 字符串中的代理项需要单独验证。

Python str 可以包含不能正常编码成 UTF-8 的孤立代理项。这里使用 PyString 入口,把这些码点转换成非词分隔符,再释放 GIL 执行 Rust 计算。这一处理适用于丢弃偏移的 str -> str 单元;不能据此替换保留 spans/offsets 的接口。

固定预期中包含:

analyze_text("ABC ab ABC") == "abc pcu6162 abc"
analyze_text("a\ud800b") == "pcu61 pcu62"
analyze_text("\ud800\udc00") == ""
analyze_text("ǰ") == "pcu6a"

最后一项用于守住 NFC-before-casefold 和后续单词提取行为。casefold 和 word 分类通过固定数据导出,不在运行时回调 Python,也没有直接拿 Rust 默认 Unicode 单词分类替代 Python \w。

注意:rust-anything refresh 会覆盖这个手工适配过的入口。README 已说明,使用刷新结果前必须重新应用并验证这一适配。

4. 行为语料如何生成,分母如何计算

参考结果由未修改的 Python 函数生成,准备脚本固定校验 Unicode 版本、Jieba 版本和默认词典 SHA-256,然后生成严格语料。输入包括:

  • 空串、短词、大小写、下划线、保留前缀、引号、换行和 NUL。
  • UTF-8 编码阈值附近的字符串,覆盖不同字符宽度和长度组合。
  • Unicode 全范围内存在 casefold 变换的码点组合,而不只检查几个常见拉丁字母。
  • 扩展 Han、组合字符、零宽连接字符、数字类别,以及孤立和相邻代理项。
  • 固定随机种子 90210 生成的 1,000 组混合文本,再与其他输入一起去重。
  • 24 篇仓库公开中英文文档,每种语言 12 篇,每篇最多前 16,000 个字符。

两种录制用途不同:工具 cases.jsonl 包含生成边界用例与补充输入,最终为 2,033 条;严格录制使用码点数组表达包含代理项的 Python 字符串,去重后为 2,637 条字符串。普通工具 JSON 不能完整承载代理项,因此不能用工具的分母替代严格比较的分母。

输入 / 执行类别 数量 预期与实际结果
去重字符串 2,637 每项输出值和字符串类型精确一致,无 mismatch
非字符串输入 7 None、True、整数、浮点数、列表、字典、bytes 均为 TypeError
str 子类 1 正常调用并返回预期字符串
唯一验证输入合计 2,645 2,637 + 7 + 1
额外独立固定预期 3 次 检查代理项和 NFC/casefold;对应已有输入,不再增加唯一输入分母
执行总数 2,648 包含上述 3 次重复独立检查

验证脚本报告 N=2645、R=2645、F=0、E=0,这是该验证输入集的统计,不能解释为整个 PowerContext 的覆盖率。非字符串输入的异常类型额外核验;异常文本不属于本试点承诺的兼容范围。

5. 测试、负控和门禁的具体结果

验证项 结果 它证明什么 / 不能证明什么
原 Python 参考基线 13 个既有相关用例通过 基线使用显式选择的当前 checkout 源码;不是依赖其他 editable checkout 的偶然结果
Rust 红性证据 未实现骨架上 2 个算法单测失败 失败位置为 analyze_text 的未实现入口;实现后相同测试通过
rust-anything diff 2,033/2,033 录制输入上的精确回放一致,不替代代理项和错误类型的额外检查
严格直接扩展验证 2,637/2,637 字符串一致,其余类型检查通过 直接加载真实 native 模块,验证输出值、返回类型及构建身份
错误输出负控 PASS 对 abc 注入故意错误的预期,严格比较器确实拒绝它
native 缺失负控 PASS 临时包只保留 Python 入口、不包含原生模块,在隔离子进程中导入失败,未回退 Python
错误构建身份负控 PASS 指定不匹配的 native SHA 后退出码为 1,报 Unexpected native build identity
既有测试原生装配 13 passed,20 次真实原生调用 原断言未改;测试插件只在该进程中替换入口,输出 native 哈希;零 native 调用会导致失败
Cargo 算法单测 2 passed 守住编码/重复频率和 NFC/casefold/单词边界;不是仅靠编译通过
locked release build PASS MSVC release 构建完成;链接器打印创建 import library 的非致命 warning,未将其隐瞒为完全无 warning
fmt / clippy PASS 格式检查与 locked --all-targets -- -D warnings 通过
rust-anything gate 12 项全部通过 细项如下
Ruff / 试点 ty PASS Ruff check、format check 和 ty check rust/lexical-rs 通过
独立 wheel PASS 单独安装与严格验证通过,见下一节
最终独立审查 尚未完成 不把执行者自查记作独立审查,也不把开工方向意见记作最终批准

rust-anything gate 的 12 项为:fmt、clippy、cargo test、unsafe、lockfile、ported、size、error cases、panics、build、api、behavior。工具报告无 unsafe、无未实现占位,API 导出存在,录制行为全部一致。size 是工具按文件计算的检查,不等于只迁移函数本身的复杂度度量。

工具对异常比较较宽松,所以没有把工具 diff 作为唯一错误 oracle。严格比较器、固定输出和错误类型检查用于补充这一边界;没有为了迁移通过而放宽字符串相等、忽略顺序或给 mismatch 加容差。

6. 独立打包与安装验证

根 Python 应用继续使用 Hatchling,本试点使用自己的 maturin wheel,不改变主项目的安装方式,也没有为普通用户增加 Rust 编译要求。

wheel 的验证过程为:单独构建 release wheel → 在干净环境安装该 wheel → 使用该环境的 Python,以 -I 运行严格验证。导入扩展不需要 PowerContext 源包、Jieba 或 Pydantic,且 package.analyze_text 必须就是原生函数本身,没有 Python 包装回退。

直接扩展与 wheel 内扩展由不同构建选项产生,SHA 不同。两份二进制分别通过严格检查,不能把其中一份的哈希用作另一份的身份,也不能把直接扩展的性能数据说成最终 wheel 的性能数据。

最终 wheel 文件为 pc_lexical_pilot-0.1.0-cp39-abi3-win_amd64.whl,2,487,466 字节。Requires-Python 限制为 >=3.14,<3.15;文件名中的 abi3/cp39 不代表已经验证 Python 3.9 或整个 3.11–3.14 支持矩阵。

7. 性能测量方法和结果

硬件:Intel Core Ultra 5 225H。系统:Windows x64。Python:CPython 3.14.3,Unicode 16.0.0。Rust:1.97.1 MSVC,release 构建。单线程,不使用 batch 并行。

测量步骤:先比较两端输出完全一致并预热 → 预先读入相同文本 → 每轮交替两端先后顺序 → 共 9 轮 → 对每端分别取中位数。计时包括 Python 调用、跨原生边界、输入转换和输出分配,不包括读盘、HTTP 或服务请求。

最终复测负载 Python 中位数 Rust 中位数 Python / Rust 耗时减少
12 篇中文文档,共 101,036 字符 133.866 ms 15.118 ms 8.85× 88.7%
12 篇英文文档,共 140,040 字符 22.399 ms 5.774 ms 3.88× 74.2%
同一短查询连续调用 1,000 次 36.630 ms 3.431 ms 10.67× 90.6%

短查询内容为 PowerContext Server 地址是什么?。第三行是 1,000 次调用的总耗时,不是单次延迟。

最终复测的全部 9 轮样本,单位 ms:

轮次 中文 Python 中文 Rust 英文 Python 英文 Rust 短查询×1000 Python 短查询×1000 Rust
1 135.064 15.509 17.030 5.196 26.200 2.884
2 137.795 15.118 22.399 5.297 23.754 3.843
3 146.002 15.289 23.138 5.835 36.630 4.334
4 123.134 15.820 20.365 5.774 31.506 3.180
5 116.811 15.118 18.342 6.660 39.945 3.559
6 133.866 13.262 16.792 4.847 37.568 3.431
7 100.872 12.252 25.591 4.892 38.840 3.377
8 109.195 12.587 24.484 6.207 36.909 4.274
9 146.149 11.750 29.402 8.145 32.989 3.364

初测的数据也完整保留,便于判断波动:

相同负载的初测 Python 中位数 Rust 中位数 Python / Rust
12 篇中文文档 60.021 ms 7.967 ms 7.53×
12 篇英文文档 14.495 ms 3.422 ms 4.24×
同一短查询调用 1,000 次 12.557 ms 1.722 ms 7.29×

初测使用直接扩展 ae017b92…,最终复测使用 f71d3be9…,完整哈希见下文。最终复测在试点构建和 hook 命令完成后执行。桌面环境没有固定 CPU 亲和性、频率和其他系统活动,两轮绝对耗时与比值都有波动。因此这里报告本地观测和全部样本,不把最高比值写成固定生产承诺,也不声称两轮差异是某个额外优化带来的收益。

另外,初测 rust-anything 基于 2,033 条录制用例执行的工具 bench 为 Python 约 41,077.816 ns、Rust 约 7,050.357 ns,工具报告约 5.83×。该口径不同于文档分组及重复短查询,不与表中倍数混合;它也没有作为最终构建的重新测量结果。

8. 冷启动观察单独记录

初测中,每种实现各启动 3 个新进程,分别计时模块导入和第一次中文分析。输入为 中文文本 数据库查询 南京市长江大桥,两端输出相同。

实现 / 次数 模块导入 首次中文分析
Python 1 144.159 ms 335.939 ms
Python 2 145.431 ms 331.909 ms
Python 3 137.241 ms 325.250 ms
Rust 1 2.462 ms 63.645 ms
Rust 2 2.181 ms 60.569 ms
Rust 3 1.889 ms 76.542 ms

这些是初测构建上的小样本观察,没有对最终 wheel 重做。导入时间还包含两种模块各自不同的依赖导入成本,不能解释为纯分词算法耗时,也不作为服务启动 SLA。

以上性能结果没有测量 HTTP、数据库、推理、完整召回和真实宿主调用延迟。特别是,默认应用路径未接入原生扩展,不能据此声称整个 PowerContext 请求快 8.85 倍。

9. 构建身份与语料清单

对象 SHA-256
最终直接扩展(严格比较、既有测试和最终性能复测) f71d3be9567267d80d4f7ebb976842165123448868f9e8da0d57f271bb50bd92
最终 wheel 内扩展(干净环境严格验证) 95f91b24e78cfe2ec0e3f7d52fe276d98421c0df07eab2971ee7e318da151892
最终 wheel 文件 76f534ccbd988db4be14fb70827ee088451900e0179aabe9d8217f13ffbafe48
初测直接扩展 ae017b9209e72a05b34e095d05bbb244a8525091b2b703417eeb99a909be3c83
src/powercontext/builtin/artifacts/search.py b2f6fc10c8c90c09b9ee0b41fade0541c75b2175b7728af386f0de0b4682c230
rust/lexical-rs/src/lib.rs dc91b3c3560e660347117c1068ad8a02a8da85d751a677a5bde1e570841bef5b
rust/lexical-rs/src/port.rs 98142901ab9d303ea9736099ad8cbfaf0d0f0dff3039cafcc7737ababfed7e45
rust/lexical-rs/data/unicode16.json fb5050103409ed5fc057b39e209a8f584c3721efc84ed523322808d3b31b5a4c
rust/lexical-rs/Cargo.lock 390168612acbad6e1f16a1e239d089fb5d1fd65ca43caedf28056c8f32d6ebb1

初测试点报告中的 wheel 内扩展为 0b6657dfaf27b74fc920e9bc32cfb444d16a60ed63bcfd19037a4b7f4baace57;最终提交前重新构建并安装验证后的 wheel 内扩展为上表 95f91b24…。性能表、严格验证和 wheel 的身份已分开记录。

中文语料与英文语料采用对应的 12 个相对路径:

每种语言均选用的文档路径
develop/api-quickstart.md
develop/http-api.md
develop/index.md
develop/interfaces.md
develop/plugins.md
get-started/configure-models.md
get-started/configure-server-environment.md
get-started/core-concepts.md
get-started/faq.md
get-started/install-and-run.md
get-started/manual-start.md
get-started/quickstart.md

完整路径的前缀分别是 docs/zh/docs/ 和 docs/en/docs/。语料只来自仓库公开文档,不涉及私有查询、业务数据或自定义词典。

10. 可复现命令

准备 CPython 3.14 / Unicode16 环境,安装根项目锁定依赖、Jieba 0.42.1、pytest,以及单独的 maturin、rust-anything。Windows 上需要明确选择 MSVC 工具链;仓库或系统默认 Rust 版本可能低于本试点要求。rust-anything 的 Python 驱动优先选择 python3,需确认它与预期的 python 环境一致。

以下命令从仓库根目录执行,python 指向上述准备好的环境。先生成严格语料,再验证已经提交的工具录制;无需重新生成录制就可以 replay:

$env:RUSTUP_TOOLCHAIN = '1.97.1-x86_64-pc-windows-msvc'
$env:PYO3_PYTHON = (Get-Command python).Source

cargo fetch --locked --manifest-path rust/lexical-rs/Cargo.toml
python rust/lexical-rs/scripts/prepare.py
cargo fmt --manifest-path rust/lexical-rs/Cargo.toml --check
cargo test --locked --manifest-path rust/lexical-rs/Cargo.toml
cargo clippy --locked --manifest-path rust/lexical-rs/Cargo.toml --all-targets -- -D warnings

rust-anything build rust/lexical-rs
python rust/lexical-rs/scripts/verify.py
rust-anything diff rust/lexical-rs
rust-anything gate rust/lexical-rs
rust-anything bench rust/lexical-rs
python rust/lexical-rs/scripts/benchmark.py

如需重新录制工具用例,准备脚本生成的输入文件可用于:

rust-anything record rust/lexical-rs --count 200 --inputs output/lexical-pilot/inputs.jsonl

强制装配原生函数运行既有测试:

$env:PYTHONPATH = "$PWD\src;$PWD\rust\lexical-rs\scripts"
python -m pytest -p native_pytest tests/builtin/artifacts/test_text_search_admission.py tests/builtin/artifacts/topic_memory/test_chunking.py -q

独立 wheel 验证:

python -m maturin build --locked --release --manifest-path rust/lexical-rs/Cargo.toml --out output/lexical-pilot/wheels
python -m venv output/lexical-pilot/clean-runtime
uv pip install --python output/lexical-pilot/clean-runtime/Scripts/python.exe output/lexical-pilot/wheels/pc_lexical_pilot-0.1.0-cp39-abi3-win_amd64.whl
& output/lexical-pilot/clean-runtime/Scripts/python.exe -I rust/lexical-rs/scripts/verify.py --installed

准备脚本在源码树生成严格语料;隔离环境中的验证脚本读取这些数据,但不通过源码路径导入扩展。生成数据和日志位于被忽略的 output/lexical-pilot/;源码、公开结果和基准原始样本已提交到 PR。

11. 未通过、未验证和下一步边界

本机最终执行了 changed-file prek。文件冲突、TOML/JSON、JSON 格式、文件结尾、尾空白、Ruff check 和 format 等内容检查通过;完整 prek 中的全仓 ty check 失败,报告 93 条诊断。执行 ty check --exclude rust 仍得到相同数量的既有路径诊断,涉及 Windows 下缺失的 POSIX API、以普通文本检出的符号链接等。uv run --locked ty check rust/lexical-rs 单独通过;没有为让提交通过而关闭检查或修改无关文件。

本地验证中的非致命输出还包括 release 链接器创建 import library 的 warning,以及一次新环境加载 Jieba 时出现的上游 Python SyntaxWarning;它们未导致上述测试失败。不据此把“构建完成”扩展成“全仓所有质量门禁通过”。

没有运行完整仓库全部 make check 目标、全量 pytest、跨版本 tox、真实后端/宿主验收或生产部署。最终独立审查尚未完成;远端审查尝试在执行前被拒绝,未修改账户、计费或 provider 设置来绕过限制。该事实意味着当前没有最终独立审查结论。

已验证范围为 固定默认词典 + Windows x64 + CPython 3.14 / Unicode16 + 窄 analyze_text(str) -> str 接口。以下内容仍需单独验证或设计:Python 3.11–3.13、其他 Unicode 版本、Linux/macOS、free-threaded Python、自定义词典或词典运行时修改、并发压力、spans/offsets,以及完整服务调用链。

继续评估默认接入时,需要明确主项目 wheel 的发布矩阵、旧 Python/Unicode 的语义、后端选择与回滚契约,并完成最终独立审查。本 PR 提交的试点证据不代表这些后续工作已经完成。

公开证据索引

本评论直接展开了实现、测试、性能和复现材料;链接用于核查具体源码、逐轮样本和构建身份。仓库中的结果 JSON 与这里的计时、分母和哈希对应。

The failed Python 3.11 job started 32 xdist workers with -n auto and hit
Server startup and spawned-worker deadlines. The same base tree passed
its end-to-end matrix with two workers. Pin only the remaining E2E step
to two workers so visible host CPUs do not multiply subprocess pressure.

Constraint: Keep test selection, assertions, deadlines and serial Hook checks unchanged.
Scope-risk: CI scheduling only; Linux rerun must establish the outcome.
Tested: CI pipeline tests (50 passed, 7 platform skips); Make dry-run using the actual workflow environment emits -n 2 and keeps -n 0 for serial Hook tests; 307 action pins verified; YAML/content hooks passed. Whole-repository ty still reports 93 existing Windows diagnostics.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 12:30

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@AlexStocks

Copy link
Copy Markdown
Contributor Author

CI 排查与更新,对应提交 b20f578a29dfdb4fb1e9fa3184f4e6a4c5499042。

失败日志中的事实

首次运行 44730982822 / Python 3.11 e2e 的结果为 15 failed、1571 passed、654 skipped。日志显示 created: 32/32 workers,失败主要为服务未在启动截止前就绪、派生 worker 等待超时和 HTTP 读取超时。Python 3.11 unit 已通过;其他 Python 矩阵任务随后因 fail-fast 被取消。Upgrade release gate 当时读取到 UPGRADE_SELECTED=true、UPGRADE_RESULT=skipped 而失败,这是前置测试失败后的阻塞结果,不是本试点触发了数据库迁移错误。

作为对照,同一基线 6763b07661846c19934044184995adf9183c28cc 的 Python 3.11 e2e 使用 2 个 worker,结果为 1587 passed、653 skipped。这只能说明该次基线 e2e 通过,不代表基线整条 CI 都通过。

本次调整

原命令通过 Make 使用 -n auto,其 worker 数随 runner 可见 CPU 数变化。测试还会派生 Server 和后台进程,因此 32 个 pytest worker 会进一步放大进程竞争。该差异支持资源竞争导致截止时间失败的判断,尚不能单凭日志证明每个失败都只有这一原因。

新提交只在 .github/workflows/master.yml 的 Run remaining end-to-end tests 步骤增加 PYTEST_WORKERS: "2",固定这一 CI 步骤的并行度。保留测试选择、断言、原有超时、fail-fast,以及单独的 -n 0 Hook 测试。没有修改 Rust/Python 算法、业务代码或性能样本。

实际验证

  • 工作流环境传入 Make 的 dry-run:并行 E2E 命令为 pytest -n 2 ...,串行 Hook 命令仍为 pytest -n 0 ...。
  • python -X utf8 -m pytest tests/test_ci_pipeline.py -q:50 passed、7 skipped。7 项为现有 Windows 平台跳过。
  • python -m pytest -n 2 tests/e2e/test_langgraph_chain.py tests/e2e/test_worker_logging.py -q:37 passed;本地 Windows / CPython 3.14.3,源码确认为当前 checkout。该结果不替代远端 Linux / Python 3.11 验证。
  • scripts/check_workflow_actions.py:307 action references checked;YAML、文件结尾和尾空白检查通过。
  • 完整 prek 的全仓 ty 仍报告此前已披露的 93 条既有 Windows 诊断;没有为本次提交关闭检查。第一次本地 CI 契约测试因 Windows 默认 GBK 读 UTF-8 文件失败,明确使用 UTF-8 后相同用例通过,未改动测试断言。

新运行:44736400188。提交后核查时 preflight 尚在排队,不能把本地通过写成远端 CI 已恢复。

Review 状态

本次读取到的 review 是 Copilot 的额度不足提示,它未执行代码审查。REST 行内评论列表和 GraphQL review threads 均为空,目前没有代码评审意见可以逐项修改或回复。没有调整 Copilot 的账户、计费或组织配置。

此前完整性能报告仍对应 0a25fb62 的试点构建;新增提交只调整 CI 调度,原报告的构建身份和计时口径保持独立。

@AlexStocks AlexStocks added the 1.6.0 v1.6.0 release tracking label Nov 20, 2026

@happy-v587 happy-v587 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.

Independently verified locally (macOS ARM, CPython 3.14.7 / Unicode 16), using my own maturin build of this crate at b20f578 rather than the author's Windows artifacts:

  • Recorded oracle: 2,033/2,033 recorded cases match on both the Python 3.14 reference and my locally built native extension.
  • Beyond the recorded corpus: exhaustive per-codepoint comparison (all 1,114,112 scalar values as X'xyz X inputs), ~6,000 adversarial fuzz cases (Han/Latin interleaving, pcu/pch 40/41/80/81 byte thresholds, NFC recomposition, 100k-char inputs), 16-thread concurrent calls against the GIL-detached entry, and a full 375-file / 6.47M-char repository docs diff — zero mismatches in all of them.
  • Effective jieba dictionaries compared independently: 349,045 entries identical, total-weight delta exactly the recorded frequency_correction=3.
  • Focused admission/chunking tests re-run with native_pytest.py against my locally built .so: 13 passed, 20 native calls.
  • cargo test, cargo fmt --check and locked clippy -D warnings pass with Rust 1.97.1.

No correctness findings. Two non-blocking design notes below. The pending CI matrix should still be green before merge.

Comment thread rust/lexical-rs/Cargo.toml Resolved
The unit job still auto-detected 32 workers and missed short runtime and
subprocess deadlines. Bound it to two workers, matching the successful
base run and the existing E2E bound, without changing test assertions.
Document the pilot-specific Rust toolchain and LF-only JSONL parsing.

Constraint: No runtime, corpus, benchmark or timeout changes.
Scope-risk: Full Linux matrix remains to be verified by the new run.
Tested: Four formerly failing tests passed locally with two workers; one POSIX-only test skipped on Windows. CI pipeline tests: 50 passed, 7 platform skips. Actual workflow environments produce -n 2 for unit and E2E commands; README reader parses 2033 records. 307 action pins and YAML/content hooks passed. Whole-repository ty still reports 93 existing Windows diagnostics.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 15:05

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@AlexStocks

Copy link
Copy Markdown
Contributor Author

针对第二轮 CI 和两条新 review 的更新,提交为 51116a2f1503fe2a1e3b25be633667b23261cb22。

第二轮失败发生在 unit,不能把 e2e 的取消记作验证通过。

44736400188 / Python 3.11 unit 启动了 32 个 worker,结果 5 failed、9342 passed、327 skipped。失败项为:

  • test_open_bounded_enforces_the_deadline_while_headers_trickle:耗时 2.507 秒,超过 < 1.0 的断言。
  • test_native_sqlite_deadline_stops_vm_work_and_preserves_in_memory_database:后续正常写入未在 30 ms 预算内留下记录,读取空结果时报 IndexError;日志中两次写入均报告失败。
  • test_overflow_flush_cannot_advance_retry_and_cached_failures_cannot_extend_gate:等待超时。
  • test_spawn_launcher_runs_a_real_child_process:真实子进程等待超时。
  • test_recorded_virtualenv_python_can_import_service_launcher:launcher --help 子进程超过 10 秒。

同一基线的 Python 3.11 unit 使用 2 个 worker,结果 9347 passed、327 skipped。本轮 e2e 已采用上一提交固定的并行度,但在 unit 失败后被矩阵 fail-fast 取消,因此其完整远端结果仍未验证。升级门禁和最终 CI 汇总随后失败,不能当作额外独立的业务缺陷。

新提交给 unit 步骤也设置 PYTEST_WORKERS: "2",与 e2e 一致。自动按 host CPU 启动 32 个 pytest 进程,而测试还有派生进程和短 deadline,是当前证据支持的资源竞争原因;固定并行预算后仍需 Linux CI 确认。未修改测试断言、deadline、业务实现或录制/性能数据。

本地检查

  • 上述 5 个失败用例以 -n 2 运行:4 passed、1 skipped。跳过项为明确标记 POSIX-only 的虚拟环境符号链接测试;本机是 Windows / CPython 3.14.3,不能用此跳过代替 Linux 验证。
  • tests/test_ci_pipeline.py:50 passed、7 个既有平台跳过。
  • 把真实 workflow env 传入 Make dry-run,确认 unit 和 e2e 都执行 -n 2,Hook 串行步骤仍为 -n 0。
  • Action pin 检查:307 references;YAML、文件结尾、尾空白检查通过。全仓 ty 仍为已披露的 93 条 Windows 既有诊断。

Review 逐条处理

  1. Rust 工具链差异:README 明确试点最低 Rust 1.97、实测 1.97.1 MSVC,与 gateway CI 的 1.95.0 独立;给出显式工具链选择命令,说明当前 CI 不编译试点,未来接入需使用自己的工具链。已在原线程回复。
  2. JSONL 的 Unicode 换行字符:实际复现 str.splitlines() 因原始 U+2028 / U+0085 拆坏 JSON。按 review 建议在 results/README.md 提供 split("\n") 读取示例,并从 crate README 链接。示例已运行,2033 条全部解析成功,不吞掉错误、不改写原始输入。严格 corpus 的 ensure_ascii=True 仍保持不变。已在原线程回复。

两个线程保留 reviewer 自行确认;没有将作者回复等同于 reviewer 接受。

新运行为 44759823908,发布时 preflight 正在执行。当前是修复已推送、相关本地检查通过,完整远端 CI 仍待结果。

The generated manifest inherited rust-anything's own Rust 1.97 minimum.
The pilot itself builds and passes strict validation with Rust 1.95.0.
Declare Rust 1.95 and use the gateway's 1.95.0 toolchain in instructions.
Keep published 1.97.1 benchmark identities and measurements explicit.

Constraint: No dependency, algorithm, recorded behavior or performance data changes.
Scope-risk: Validation is Windows MSVC with CPython 3.14.3; pilot Linux compilation remains outside current CI.
Tested: Rust 1.95.0 fmt, locked cargo test (2 passed), locked clippy --all-targets -- -D warnings, release maturin wheel, clean environment isolated strict replay (2637 strings; type and negative controls passed). TOML/content hooks passed; full ty retains 93 existing Windows diagnostics.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 15:19

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@AlexStocks AlexStocks closed this Nov 21, 2026
Master commit 3441a37 changed managed startup admission diagnostics without refreshing the persistence review digest. Record the resulting digest and document that the change is guidance-only with no schema or persisted-encoding impact.

Constraint: Compatibility-review metadata only; no persistence behavior changes.
Scope-risk: Upgrade release gate digest and rationale.
Tested: make upgrade-policy-check.
Copilot AI balanced review requested due to automatic review settings November 28, 2026 03:46

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@NeverENG NeverENG 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

@NeverENG

Copy link
Copy Markdown
Collaborator

复检结论(head 13f7f34dd)

当前 CI 检查基本全绿,但 PR 仍有阻塞项:reviewDecision 仍为 CHANGES_REQUESTED,mergeStateStatus 为 BLOCKED。

1. Unicode 实现方案仍未关闭(阻塞)

src/powercontext/builtin/artifacts/lexical/src/port.rs 目前仍加载 unicode14.json / unicode15.json / unicode15_1.json / unicode16.json 这套按 CPython 版本生成的自定义表,未采用请求的成熟 Rust Unicode 库语义;search.py 中的 TEXT_ANALYZER_VERSION 也仍未变化。

维护者要求的不只是“当前输出一致”,还包括:

  • 使用统一的 Rust Unicode library contract 处理 casefold、character classification、assignment properties;
  • 保证 indexing、query analysis、span handling 在同一 analyzer contract 下;
  • 如果库语义导致输出变化,升级 analyzer version,并提供明确的 migration/reprojection 路径,保证已有数据仍可检索。

如果继续保留当前“逐版本表 + 精确复刻 CPython”方案,需要请求方明确豁免;否则该 review thread 仍然是合并阻塞项。

2. 后续 release 的 upgrade matrix 会失败(需要修复)

scripts/upgrade_release_matrix.py:43 只接受:

powercontext-{version}-py3-none-any.whl

本 PR 发布后只有平台 native wheel 和 sdist,不再产生 universal wheel。我用包含 powercontext-1.6.0-cp311-abi3-manylinux_2_28_x86_64.whl 的 catalog 复现了:

ValueError: Required source 1.6.0 has no unique non-yanked universal wheel

当前 release/upgrade-support.json 的 source 还是 1.3.0,所以本次 CI 没有暴露;等 1.6.0 成为后续版本的 upgrade source 时,升级验收会直接失败。建议让该脚本支持从平台 wheel/sdist 选择可安装的 source,并更新 tests/release_upgrades/README.md 与回归测试。

3. 一个验证缺口(非阻塞)

arm64 Docker/QEMU workflow 只在 b1b77d62 成功运行过;之后切换到 Rust 1.97.1 尚未在最终 head 上重新 dispatch。建议在最终提交上补跑一次,保证验证记录与最终 head 一致。

本地独立验证

我在当前 head 上实际构建并检查了 native extension:

  • Rust 单测:4 passed
  • native 接口测试:36 passed
  • CPython 3.11 / 3.12 / 3.14 下遍历全部 Unicode 标量批量比较,并做随机字符串与 Han fuzz:零 mismatch
  • 根 wheel 与 sdist 独立重建的 wheel 内容逐字节一致(macOS arm64)

因此我没有发现新的 analyzer 输出 mismatch;剩余问题主要是 Unicode 设计评审未关闭,以及 release/upgrade 链路对 native wheel 的适配。

@hidb4ai hidb4ai 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.

Re-reviewed 13f7f34. CI is green and the previous Windows packaging finding remains fixed. The pre-merge Unicode-library requirement in #2735 (comment) is still open; the analyzer implementation and compatibility tables are unchanged. Please implement that requirement or obtain explicit resolution from the requesting maintainer. I found no new analyzer-output defect.

I also independently reproduced the source-artifact limitation discussed in #2735 (comment): source_artifact accepts a universal wheel but rejects an otherwise valid cp311-abi3-manylinux_2_28_x86_64 wheel for the same version. This becomes a release-gate failure when a native-only release is selected as an upgrade source. The current policy still selects 1.3.0, so this is a concrete follow-up before adopting a native source, not a failure of the current matrix. Artifact resolution and its platform/backend consumers need compatible handling together.

The current source passed a real SQLite + configured embedding/LLM flow: persistent write, native FTS recall, Server lifespan restart, context preparation, and the model recovering a random stored fact. HTTP routing was in-process. OceanBase was exercised in the previous review, not rerun on this head. Approval remains withheld while the explicit pre-merge requirement is unresolved.

@Fengzdadi Fengzdadi 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.

Re-reviewed 13f7f34dd. My earlier points are resolved, so this approval replaces my change request.

  • Windows candidate. 01053c1 moves the lexical notices to LICENSES/lex/ under shorter names and keeps every file. With the CI staging root (114 characters) and a 0.0.0+candidate.<40 hex> version, the longest notice path is now 251 UTF-16 units (py-jieba.LICENSE and rs-jieba.LICENSE), under the 259 limit. test_native_license_payload_fits_candidate_staging_budget pins this, and managed-resource-candidates / Candidate windows-x86_64 passes at this head.
  • Analyzer. Nothing under src/powercontext/builtin/artifacts/lexical/ or in search.py has changed since b02bd477c, so my earlier reading of the port still holds.

The branch now conflicts with master in four files: three from #2909 (the candidate workflow, prepare_managed_resources.py and test_managed_resource_producer.py) and #2630's digest change in release/upgrade-support.json. None of them changes the Windows staging root or the candidate version, so the budget still holds; please keep the new test when resolving.

This approval is for this head. It doesn't settle frf12's pre-merge Unicode-library requirement (#2735 (comment)). If the analyzer changes for it, I'll review that change.

Non-blocking:

  • source_artifact in scripts/upgrade_release_matrix.py still accepts only a py3-none-any wheel, as NeverENG and hidb4ai reproduced. Nothing fails today because the policy's source is 1.3.0, but this needs fixing before a native-only release becomes an upgrade source.
  • Five integration READMEs (OpenClaw, LangChain, DSH and its plugin, OpenCode) still install from master or a local checkout without --python ">=3.11,<3.15" and without the Rust 1.97.1 and C toolchain note that the integration guides now have.
  • The arm64 image was built at b1b77d62, before the 1.97.1 base image. As NeverENG suggested, a run on the final head would close that gap.

@AlexStocks AlexStocks added 1.6.2 v1.6.2 release tracking and removed 1.6.1 v1.6.1 release tracking labels Nov 30, 2026
@hidb4ai

hidb4ai commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Status refresh for unchanged head 13f7f34: GitHub now reports CONFLICTING / DIRTY against current master. Please reconcile the conflicts, preserve the native notice path regression and complete license payload, refresh the persistence review digest against the merged tree, and validate that result. The existing green checks do not validate a future conflict resolution.

The Unicode-library/analyzer-contract requirement in #2735 (comment) remains open. The native-only upgrade-source resolver limitation remains a follow-up before selecting such a release as a source; it is not a failure of today's 1.3.0 matrix. No new code was pushed, so I did not rerun the previously passing real SQLite/embedding/LLM flow on the same head. Approval remains withheld pending resolution of the pre-merge requirement and validation of the reconciled branch.

# Conflicts:
#	.github/workflows/managed-resource-candidates.yml
#	README.md
#	README_CN.md
#	README_JP.md
#	docs/en/docs/get-started/install-and-run.md
#	docs/en/docs/get-started/manual-start.md
#	docs/zh/docs/get-started/install-and-run.md
#	docs/zh/docs/get-started/manual-start.md
#	release/upgrade-support.json
#	scripts/prepare_managed_resources.py
#	tests/test_managed_resource_producer.py
Replace per-version Unicode snapshots with unicode-normalization, caseless and unicode-properties; serve text, terms, normalization and spans from one native analyzer, and bump the analyzer version so projections rebuild. Correct Rust/Python version documentation and stale evaluation claims.
…ct-merge-20261201

# Conflicts:
#	.github/workflows/desktop.yml
#	tests/test_ci_pipeline.py
@AlexStocks
AlexStocks requested a review from frf12 December 1, 2026 11:53

@frf12 frf12 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.

Re-reviewed e6deff67b63b3751bce0261270f07d0d599f616a. The Unicode-library adoption requirement is addressed: the custom tables are removed, and indexing, queries and spans use the shared Unicode 16 implementation. I am not requesting a different library or per-CPython compatibility scheme.

Requesting changes for the existing-database upgrade blocker below: the analyzer version changes, but an already-current managed database has no executable transition to the new projection version. Please verify the supported upgrade, restart and retrieval path before merge.

Separately, Main CI exceeded its 45-minute preflight limit after checkout alone took 37m23s; environment setup did not finish and the downstream tests did not run. This is not evidence of an analyzer-output failure and can be handled separately from the migration defect.


# Bump when document segmentation or token encoding changes; query stopwords do not affect projections.
TEXT_ANALYZER_VERSION = "jieba-0.42.1-words-v1"
TEXT_ANALYZER_VERSION = "unicode16-caseless0.2.2-jieba0.42.1-words-v2"

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.

[P1] Provide an executable migration path for existing managed databases

A managed database already at schema revision v1_6_0 retains the jieba-0.42.1-words-v1 projection markers. This version bump makes the readiness check raise projection_migration_required. Managed startup only validates these projections, while db-migrate apply encounters the same check during planning, before it can perform maintenance. At the unchanged schema revision, the domain registry also selects no pending steps.

Consequently, an existing installation cannot start or complete the supported migration command, even with empty user tables if the previous markers are present. Please provide a supported transition that rebuilds the affected projections/search indexes and records the new analyzer version, then verify upgrade, restart and retrieval against existing data.

Validation: I executed the exact Python marker check against a SQLite table populated with the previous analyzer markers: the base check passes, the new check raises projection_migration_required, and the current domain registry selects no pending steps at v1_6_0. The startup and db-migrate apply failure paths were traced in source; I did not execute a full Server/native or real seekDB/OceanBase upgrade.

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.

Independently reproduced the complete managed-database transition at e6deff6. Using the base c54a50a, I initialized a real SQLite Server database through the supported migration runner, created a Scope and remembered a fact through HTTP, verified FTS recall, then closed/reopened the Server and verified recall again. No projection markers were edited. Running the PR head against that same database fails during Server lifespan startup with MigrationError: projection_migration_required; invoking the supported deployment runner plan also raises the same error, so it cannot produce a plan for apply. The old v1 markers remain intact.

The PR changes TEXT_ANALYZER_VERSION to the v2 Unicode-library contract but adds no registered persistence transition. Please add the required reprojection/data-migration step through the shared unpublished 000 workflow (without changing frozen revisions), preserve authoritative records, and verify existing-data upgrade, restart and retrieval. This is real SQLite/source-code and in-process HTTP validation; it is not an installed-release wheel or OceanBase/LLM acceptance result.

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.

Confirmed on e6deff6 with the actual Server and migration runner, extending the evidence above:

  • Created a managed SQLite database at v1_6_0 using the previous analyzer (b02bd47), wrote two memories through the HTTP app with a real configured embedding provider, then verified FTS recall, lifecycle restart, context preparation and a real LLM answer.
  • Opened a copy of that database with the newly built native extension at this head. Server lifespan startup, deployment_runner.plan(), and deployment_runner.apply() all fail with projection_migration_required in plugin_artifact_readiness.py:100. The persisted v1 markers remain unchanged. This was a real database transition, not a mocked marker check; it was not an installed-release-wheel or OceanBase upgrade test.
  • A fresh SQLite database at this head completes the same HTTP-app/embedding/FTS/restart/prepare/LLM flow. Thus fresh initialization does not establish upgrade safety.

Please add the executable projection transition under the cumulative unpublished 000 workflow, preserve frozen revisions, and verify that existing records remain retrievable after migration and restart. The library-based analyzer direction addresses the earlier implementation concern, but this upgrade blocker remains.

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.

Reproduced again at the new head a0a3573 after syncing its locked environment. Opening the same real v1_6_0 SQLite database created and populated through the base Server still fails at Server lifespan startup with projection_migration_required; the supported deployment runner plan fails with the same error. The new commits merge master and adjust native-wheel CI routing, but do not change the analyzer or add a registered projection migration. Please implement the transition through the cumulative unpublished 000 workflow and verify upgrade, restart and recall. The runner-policy checker passes locally; that does not resolve this existing-data upgrade blocker.

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.

Extended the reproduction to the real configured OceanBase backend at a0a3573:

  • Created an isolated OceanBase CE 4.3.5.4 database with base c54a50a using the supported managed initializer. Through a real loopback HTTP listener, wrote two facts with the configured embedding provider and verified both Chinese-query and random-marker FTS recall.
  • Stopped/restarted the Server lifespan, prepared context, and called the real generation provider. The answer contained the stored random marker and port; the no-context control did not contain the random marker.
  • Opened this unchanged database at the PR head: Server lifespan startup, migration plan, and migration apply each failed with MigrationError: projection_migration_required. No projection markers were manually altered.
  • As a separate control, a fresh SQLite database at this head passed the real HTTP/embedding/FTS/restart/prepare/LLM flow, including the no-context control. This does not establish a fresh OceanBase run at the head.

The isolated OceanBase database was removed after testing. These are real-backend/provider source-checkout results, not an installed-release-wheel upgrade claim. The existing-data migration blocker is confirmed on OceanBase as well as SQLite.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Implemented in bdad24ff3.

Draft 000 carries the transition

  • migrations/server_resources/lexical_reprojection.py is a projection domain step that re-derives Atomic Memory, active Topic title/summary/chunk, Experience and Skill searchable_text, and the SQLite/OceanBase full-text helpers from their authoritative records, then records the analyzer version of the running build. It reuses the registered primitives (refresh_lexical_projections, rebuild_experience_projections/rebuild_skill_projections, SQLiteExperienceFTSIndex.rebuild, SQLiteAtomicMemoryIndex.rebuild_fts, SQLite/OceanBaseTopicMemoryFTSIndex.initialize).
  • The Topic FTS refresh has to call SQLiteTopicMemoryFTSIndex.initialize() rather than TopicMemoryRepository.initialize(): the repository initializer also reconfigures the retrieval shape and raises embedding_profile_mismatch when the historical space differs from the configured profile. Rebuilding projections is not a deployment-profile transition.
  • versions/000.py plus schemas/{sqlite,mysql}-000.json register no schema object. MySQLSchema._load_state_layouts previously rejected an empty statement list, which made a derived-data-only revision impossible to register on the OceanBase/seekDB chain; it now accepts an exact empty pair, and 000's resulting layout is identical to v1_6_0's.
  • 000 also carries the analyzer readiness validator, so a database that reaches the head without the rebuild still fails admission with projection_migration_required instead of opening stale projections.
  • DomainRegistry.admit defers exactly that one code, and only while a pending projection step exists. This is the part that was actually unreachable: both runners validate the source revision before computing pending steps, so plan and apply never reached the step that repairs. Every other rejection, and every rejection without a pending projection step, still refuses.

Verified (SQLite)

tests/builtin/persistence/test_lexical_reprojection_migration.py builds a managed database through the 1.6.0 bundle, writes v1 analyzer markers with released searchable_text, then asserts plan.target_revision == "000" and plan.domain_steps == ("lexical_reprojection",); apply reprojects the texts to analyze_text(...), records the v2 versions, leaves the authoritative records untouched, verify() is ready and a repeated apply reports no change. A second test drives check_server_schema: the released database is refused until the revision ran and is admitted afterwards, and stale markers after the head keep plan blocked. A third asserts 000 registers with no operation on both backends.

The new head was propagated through the existing suites: tests/builtin/persistence plus the schema and revision-name tests report 1085 passed, 136 skipped, 15 failed. All 15 failures reproduce on a0a357300 in this environment: twelve are the installed pydantic_ai 2.29.0 lacking ModelContextWindowExceededError (they fail at import of builtin/inference/pydantic_ai.py, which this change does not touch), and test_cancelled_sqlite_connection_initialization_does_not_leave_a_worker_running fails identically on the base commit. scripts/schema_release.py check passes and ruff/ty report nothing in the changed files.

Not verified here

OceanBase/seekDB execution of 000. I have no such backend in this environment, and the import failures above block every create_server_app test, so the vector-profile and managed-startup paths on OceanBase are covered only by bundle-level assertions (the registered 000 layout equals v1_6_0, statements("000") == ()). Your OceanBase reproduction is the acceptance I cannot produce.

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.

Verified the migration fix at bdad24f on real OceanBase 4.3.5.4. Starting from base 0b60e52, I initialized a managed v1_6_0 database, wrote Atomic Memory and Topic Memory through a loopback HTTP Server using the configured embedding provider, then stopped that Server. Preserving its original external migration evidence, the new runner planned v1_6_0 → 000 with lexical_reprojection, applied it and verified ready. The new Server then started successfully; Chinese/random-marker FTS, prepared-context recall and a real generation-provider response passed, while the no-context control lacked the random marker. Authoritative artifact IDs/revisions/content were byte-identical across the transition, and all four projection markers moved to the new analyzer. The isolated database was removed. This addresses the reproduced OceanBase migration blocker; it is source-checkout backend acceptance, not an installed-release upgrade matrix or all-platform release qualification. The separate current CI test failure remains in the new review.

@hidb4ai hidb4ai 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.

The Unicode-library implementation addresses the previous design direction, but existing managed databases cannot start or obtain a migration plan after the analyzer-version change. I reproduced this with real SQLite data written and recalled through the base Server, then reopened by this head. Please provide the registered migration/reprojection path; execution details are in #2735 (comment) .

…ct-merge-20261201

# Conflicts:
#	.github/workflows/desktop.yml
#	.github/workflows/gateway-distribution.yml
#	.github/workflows/gateway.yml
#	.github/workflows/managed-resource-candidates.yml
#	.github/workflows/release.yml
#	.github/workflows/upgrade-release.yml
#	README.md
#	README_CN.md
#	README_JP.md
#	desktop/src-tauri/src/connections/compatibility.json
#	desktop/src-tauri/src/transport/operations.json
#	desktop/ui/src/generated/operations.ts
#	docs/en/docs/get-started/install-and-run.md
#	docs/en/docs/get-started/manual-start.md
#	docs/zh/docs/get-started/install-and-run.md
#	docs/zh/docs/get-started/manual-start.md
Run the production analyzer checks and the x86_64 manylinux wheel build on the
internal Linux pools. Keep the native aarch64 wheel on GitHub-hosted ARM64 and
record it as a capability exception because the internal pools provide only
x86_64 workers; QEMU emulation is not native wheel acceptance.

Constraint: PR CI Linux jobs must use the internal pools unless a capability
gap is recorded in .github/ci-runners.toml.
Scope-risk: Runner routing and the documented exception only; lexical and
wheel build behavior are unchanged.
Tested: make ci-runners-check; 105 CI-policy tests passed, 11 skipped.
@hidb4ai hidb4ai added module:core Core: PR changes under src/ module:desktop Primary module: desktop app and platform integration module:gateway Primary module: model gateway, protocols and context injection labels Dec 2, 2026
The registered projection identity carries the lexical analyzer version, and
frozen readiness validators resolve that constant from the installed build. A
database created by 1.6.0 therefore keeps `jieba-0.42.1-words-v1` markers while
the new native analyzer reports v2, and managed startup, `plan` and `apply` all
refuse it with `projection_migration_required` before any revision can run.

Register unreleased draft `000` as the supported transition. It changes no
schema object; its `lexical_reprojection` domain step re-derives Atomic Memory,
active Topic title/summary/chunk, Experience and Skill searchable text and the
SQLite/OceanBase full-text helpers from their authoritative records, then
records the analyzer version that produced them before the revision advances.
`000` also registers the analyzer readiness validator, so a database that
reaches the head without the rebuild keeps failing admission.

Admission now defers exactly one rejection: `projection_migration_required`
while a pending projection step exists. Without that, a released database could
never reach the step that repairs it. Every other readiness rejection and every
rejection without a pending projection step still refuses plan and apply.

A revision without MySQL schema operations is now representable: the state
layout loader required a non-empty statement list, which made a derived-data
draft impossible to register on the OceanBase/seekDB chain.

Constraint: no frozen revision, resource, checksum, SQLite fingerprint or
upgrade-support mapping is edited; `000` is frozen as the next release revision.
Scope-risk: migrations framework admission plus draft registration; the
analysis, search and retrieval paths are unchanged.
Tested: tests/test_schema_draft.py, tests/test_schema_release.py,
tests/test_migration_revision_names.py, tests/builtin/persistence (1085 passed,
136 skipped; 15 failures reproduce on a0a3573 for the installed pydantic_ai
2.29.0 and one SQLite cancellation test). scripts/schema_release.py check;
ruff check/format; ty check reports nothing in the changed files.
Not verified: OceanBase/seekDB execution of `000` (no backend available here).
@hireview001

Copy link
Copy Markdown
Collaborator

The affected modules are Core, Desktop, Gateway. @hidb4ai, please coordinate follow-up. Core: @hidb4ai @frf12 @Fengzdadi @beatenevo; Desktop: @PsiACE @knqiufan; Gateway: @frf12 @happy-v587 @NeverENG. Please coordinate the review of the affected changes.

@hidb4ai hidb4ai 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.

The added compiler-setup check currently fails against this PR’s Desktop workflow and blocks the Python unit matrix. Please update it to validate the actual source-build jobs and their setup path. The database transition is being checked separately against real OceanBase.

("desktop.yml", "windows"),
("desktop.yml", "macos"),
("desktop.yml", "linux"),
("desktop.yml", "installed-package"),

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.

[P2] Match the compiler check to the current Desktop workflow

The new parameter list still includes desktop.yml/installed-package, which no longer exists, and assumes desktop.yml/linux contains a directly detectable source-install command. Running this test at bdad24f gives KeyError: installed-package and StopIteration, exactly matching the failures in all four Python unit jobs of run 46844166136. Update the check to cover the current source-build jobs and shared setup path without requiring removed job/step shapes; otherwise the unit matrix remains red and dependent acceptance cannot run.

@NeverENG NeverENG 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.

Reviewed head bdad24ff331d95184b4b058914c9d57ff571176f, reconciling the complete 164-file list and reviewing the native search entry points/Unicode and span contract, derived-projection migration and readiness paths, wheel/sdist build and release selection/staging, affected CI/installer paths, and the Gateway startup/test changes.

One existing P2 remains: the compiler-presence test still targets obsolete Desktop workflow shapes. The current source still enumerates desktop.yml/installed-package and assumes a directly detectable install step in desktop.yml/linux. The current-head Python 3.11 CI log, actually checked out at merge 7b012f4 of this head into 0b60e52a, confirms KeyError: installed-package and StopIteration at lines 501–502. This is the existing root cause, so I have not opened a duplicate inline thread. No additional actionable defect established by this source review.

The earlier P1 managed-database migration finding is addressed in current source: cumulative revision 000 follows v1_6_0, admission permits the registered pending projection repair, and lexical_reprojection rebuilds the derived projections/FTS and verifies the new markers. The thread's unresolved state alone does not make that old finding current. The reported source-checkout OceanBase exercise is useful evidence, but I did not independently repeat it or treat it as the installed-release upgrade matrix.

Please also reconcile the PR description with this head: production now explicitly uses the Unicode 16 analyzer identity and Rust 1.97.1 and includes a projection migration. Statements about preserving the old analyzer identity or per-CPython Unicode behavior do not describe the current source; older performance/equivalence records are not current-head validation.

Validation limits: the unit matrix is red, the upgrade acceptance gate is unsuccessful, Gateway validation is skipped, and GitHub currently reports merge conflicts (DIRTY). I inspected source and associated CI evidence without executing PR code locally. The installed multi-platform native wheels, released-version upgrade matrix, and real host/provider workflows therefore remain unestablished by this review. Reconcile with the current base and validate the resulting head/merge before relying on them. Comment-only review; no merge approval.

This branch has not been deployed

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

Labels

1.6.2 v1.6.2 release tracking module:core Core: PR changes under src/ module:desktop Primary module: desktop app and platform integration module:gateway Primary module: model gateway, protocols and context injection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants