Repository navigation
fix(core): restore protocol Rust integration tests (#915) - #928
LIghtJUNction merged 2 commits into
Conversation
The official runtime grant script used psql \quit with an exit status, which psql ignores, so a refused grant exited 0 after rollback. Browser session tests then checked an unprovisioned role and failed with UnsafePrivileges. Create the required NOLOGIN installation owner first, and make refusal fail under ON_ERROR_STOP. The OAuth recovery case started on a one-second lease that CI can expire before dispatch. Start on the normal lease, then expire it explicitly. Wire sealed Core, Go host, and payment bootstrap binaries into the protocol Rust test step so the non-ignored payment recovery case runs. Co-authored-by: LIghtJUNction <lightjunction.me@gmail.com>
Charging updates reject read committed. The recovery test moves lease_until inside a serializable transaction after a successful start. Co-authored-by: LIghtJUNction <lightjunction.me@gmail.com>
Bot follow-up (2026-10-17 00:45 Asia/Taipei)CI on head
已在同一分支启动 CloudAgent |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
a901a60
into
wip/rust-core-go-extensions
变更说明
问题与关联 Issue/PR:
Fixes #915。
默认分支
wip/rust-core-go-extensionstip278ef81e上,clippy::result_large_err已经不存在。protocol 作业仍在cargo test退出 101,证据是 PR #925 headf452cdb4d/ run 38921283189 的Rust checks and real database tests:tests/browser_sessions_independent.rs三个用例在runtime_database::check报UnsafePrivilegestests/payments_process.rs的非忽略用例缺少密封输入LMM_PAYMENT_CORE_BIN(302 秒用例保持#[ignore])oauth2_pi_independent::revoked_expired_stream_retains_original_hold_until_authoritative_reconciliation在start_oauth返回StaleWorker本 PR 不改 #925 的 RPC Docker 脚本。
MK-01 identity(run 38928672624)在 head
51d79011上失败。对照基线278ef81e与该 head、在 PostgreSQL 17 上复现后,这些失败在基线上同样存在,与本 PR 的授权脚本改动无关,因此不在这里改测试、目录指纹或 MK-01 workflow。为什么采用此方案:
grant-core-runtime.sql。该脚本在安装 owner 不存在时会ROLLBACK,但\quit 1被当前 psql 忽略(extra argument "1" ignored),进程仍以 0 退出。测试因此把未授权角色当成授权成功。未执行REVOKE TEMP时,has_database_privilege(..., 'CREATE,TEMP')为真,runtime_database::check返回UnsafePrivileges。在补上 NOLOGINlmm_core_owner并真正提交 GRANT 之后,同一套官方授权能通过web_identity + oauth2的运行时检查。拒绝路径改为在ON_ERROR_STOP下RAISE EXCEPTION,退出码 3。reserve用秒级clock_timestamp()记下租约,随后的start_oauth只要跨过这一秒就会按围栏返回StaleWorker。CI 上 reserve 加串行事务很容易跨秒。同一文件里使用 30 秒默认租约的start_oauth是通过的。修复保持“先成功派发,再过期,撤销后的持仓要保留到权威对账”:使用正常租约完成start_oauth,然后在SERIALIZABLE事务里把lease_until拨到过去(charging 写入拒绝 read committed)。金额、保留额度、退款和oauth_source断言没有放宽。LMM_MODEL_PROCESS_*。这里复用同一次编译的lmm-core、前面已经构建的 Go 宿主,以及go test -c得到的 payments 测试二进制,不把该用例改成 skip。302 秒用例仍然忽略。复用了什么,替代或删除了什么:
复用官方授权脚本、现有
runtime_database::check、charging 的显式租约过期,以及 workflow 里已经构建的 Core / Go 宿主。删除的是无效的\quit 1。没有删除测试或断言。可能破坏的行为、外部契约或数据路径:
不安全运行时角色执行
grant-core-runtime.sql时,进程现在以非零退出,而不是回滚后仍显示成功。安全角色的 GRANT 语句没有改。支付用例会在 protocol 的cargo test里实际启动 Core 和 Go 进程。上游来源与许可证影响(不适用时说明):
不适用。没有引入新依赖。
验证证据
审查基点 SHA:
278ef81e6e87364891c80de6b03a2c8724934fe1实际测试的 HEAD 与工作区摘要:
HEAD
51d79011aa9b2b8eb31564f199e86630ad4c70c1,工作区干净,没有新的代码提交。本地agcc不可用,未做写监视。Rust 1.99.0。先前的 protocol 自测使用 PostgreSQL 18.6。下面的 MK-01 对照使用 PostgreSQL 17.11(Ubuntu 17.11-1.pgdg24.04+2),监听127.0.0.1:5432,连接串与 MK-01 workflow 相同。修复前失败、修复后通过的命令与日志:
修复前:run 38921283189 中上述三个测试目标失败。
授权脚本拒绝路径(超级用户运行时角色):
MK-01 失败:基线与 PR head 对照
git diff 278ef81e6..51d79011只改了core-protocol.yml、grant-core-runtime.sql、browser_sessions_independent.rs、oauth2_pi_independent.rs。失败用例的源码、services/core/schema、oauth2_balance和mk-01-identity.yml两边相同。目录指纹查询明确不含 owner 与 GRANT。这些失败用例走tests/common/runtime.rs里的测试授权,不执行官方grant-core-runtime.sql。同一套命令在基线 detached worktree
278ef81e6和 PR head51d79011上各跑一次。Rust+1.99.0,cargo test --locked,PostgreSQL 17.11:cliusage_index_owner_cli_upgrades_only_fresh_prior_fixture_and_rejects_runtimeError: Storageattests/cli.rs:1093model_processtests/model_process.rs:94Option::unwrap()onNone(LMM_MODEL_PROCESS_ROOT未设置)oauth2_lmm_authorUnavailable/balance(...).is_ok()为假oauth2_lmm_httptcp_readonly_...payments_process非忽略用例LMM_PAYMENT_CORE_BIN同一 head 的 protocol 作业使用固定的
postgres:18-alpine@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873,并导出LMM_MODEL_PROCESS_*与LMM_PAYMENT_*。run 38928672599 的cargo test中,index predecessor、usage_index_owner_cli_...、model_process(7 passed)、oauth2_lmm_author(11 passed)、oauth2_lmm_http(4 passed)、payments_process(1 passed, 1 ignored)都通过。MK-01 使用未固定的postgres:17-alpine,且不导出这些密封变量。目录钉660ddf6f...对得上 PostgreSQL 18,对不上 PostgreSQL 17 的反解析结果25dd8365...。CLI 的Storage是同一枚钉被升级过程拒绝。OAuth 的Unavailable/ 503 也只在 PostgreSQL 17 上出现。model_process与payments_process则是 MK-01 没有 protocol 那组环境变量。因此没有把目录钉改成 PostgreSQL 17 的哈希(那会让 protocol 的 PostgreSQL 18 作业变红),也没有放宽断言或改 MK-01 的数据库大版本。
重构的行为保持证据,或明确的业务语义差异:
运行时权限矩阵没有放宽。1 秒租约仍会被
live()判为StaleWorker;变的是这个恢复用例不再用 1 秒租约去完成派发。支付 302 秒用例仍被忽略,非忽略用例实际跑过 Core/Go 重启入账。quick / related / full 的报告、失败、受阻及未执行项目:
未跑
just check、在 PostgreSQL 18 上重跑完整cargo test --all-targets、Go race、RPC Docker。MK-01 对照只跑了上面列出的失败目标,没有在基线上重跑整个--all-targets。自测通过的是本 PR 自己的 protocol 用例;MK-01 这些失败保持为基线既有失败。独立验收未执行。当前 CI(head 仍是
51d79011,本次没有新提交):cargo test通过。随后python3 -B scripts/test-core-rpc-docker.py因缺少--output-root退出 2。这是 ci(protocol): 「Native protobuf round trips」步骤新失败 — test-core-rpc-docker.py 缺少必填 --output-root #923,由 fix(ci): pass --output-root and wait for HTTP 200 in the core RPC check #925 另修,本 PR 不改该脚本。用户可见变化的浏览器证据;核心变化的同环境资源对比(适用时):
无前端变化。
必须独立审查的内容
门禁、测试断言、类型配置、阈值、锁文件、基线或例外的变更与理由:
grant-core-runtime.sql的失败退出方式LMM_PAYMENT_*密封输入;未使用--skip或--ignored高风险业务、临时方案的责任人、到期时间与退出条件:
授权脚本和计费恢复属于高风险路径。没有临时开关。
独立审查者与证据(尚未执行请写 pending,作者不能自行批准):
pending
提交前核对