Skip to content

原子预占并返还查询配额 - #24

Merged
4evour merged 1 commit into
mainfrom
codex/pr-atomic-query-quota
Aug 22, 2026
Merged

原子预占并返还查询配额#24
4evour merged 1 commit into
mainfrom
codex/pr-atomic-query-quota

Conversation

@4evour

@4evour 4evour commented Aug 21, 2026

Copy link
Copy Markdown
Owner

迁移内容

  • 将用户查询配额从先读后写改为存储层原子预占
  • 基础准入检查通过后才预占,避免限流、请求体过大等请求消耗额度
  • 非 HTTP 200 响应和未捕获异常自动返还额度
  • 退款成功后替换 X-Query-Remaining,避免重复响应头
  • SQLite 与 PostgreSQL 使用带上限条件的单条写语句
  • 增加并发上限、防负数退款和源码契约测试,并更新 API 文档

行为变化

  • 成功的规划或聊天请求:保留预占,计费一次
  • 校验失败、业务错误或异常:返还预占,不计费
  • 并发请求:最多只有配额上限数量能够成功预占

验证

  • node tests/test_reviewed_query_quota_contract.js
  • oxlint 配额契约测试文件
  • MSVC Release 构建通过
  • CTest 1/1 通过,包含 20 线程竞争 7 个额度的回归测试
  • Docker/Linux 构建通过,包含 PostgreSQL 实现编译与链接
  • 容器完整冒烟通过:Agent v2.0.0、9588 个 POI、1758 条边、5 个候选方案
  • 运行时 API 验证:失败请求保持 10 次,成功请求后剩余 9 次
  • git diff --check

依赖关系

这是第 7 个也是最后一个堆叠 PR,基于显式管理员 PR #23。请按 #18#19#20#21#22#23 → 本 PR 的顺序合并;前序合并后将本 PR 的目标分支改回 main。

已知事项

本地 MSVC 使用无 OpenSSL 的开发配置,Docker/Linux 构建启用了 OpenSSL 与 libpq;既有编译警告不在本 PR 范围内。

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@4evour, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7b0c6d7d-6e84-4289-93b4-45e476c02624

📥 Commits

Reviewing files that changed from the base of the PR and between 61dbbfc and 7d1470a.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • docs/api.md
  • include/tourpass/data_store.h
  • include/tourpass/pg_store.h
  • include/tourpass/sqlite_store.h
  • src/api.cpp
  • src/pg_store.cpp
  • src/sqlite_store.cpp
  • tests/test_main.cpp
  • tests/test_reviewed_query_quota_contract.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@4evour
4evour force-pushed the codex/pr-explicit-admin-bootstrap branch from 636010a to 459aacd Compare August 22, 2026 10:12
@4evour
4evour force-pushed the codex/pr-atomic-query-quota branch from 9e1703f to 7d1470a Compare August 22, 2026 10:12
@4evour
4evour changed the base branch from codex/pr-explicit-admin-bootstrap to main August 22, 2026 10:22
@4evour
4evour marked this pull request as ready for review August 22, 2026 10:22
@4evour
4evour merged commit 8a12ada into main Aug 22, 2026
1 check passed
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.

1 participant