feat: Firestore同期コストガードをCLIに統合 - #575
Conversation
There was a problem hiding this comment.
Code Review
This pull request integrates a Firestore cost guard client and usage policy validation into the realtime sync service. It introduces policy sanitization, query limit capping, and reconnect cooldown enforcement, along with corresponding CLI formatting updates, tests, and documentation. The reviewer feedback highlights a critical bug where state is saved at the end of polling, potentially overwriting newer cursor data, and suggests cleaning up an unused sync_enabled parameter in the usage policy sanitization function.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| _record_firestore_poll(state, str(account_id)) | ||
| _save_state(state_file, state) |
| effective_sync_enabled = bool(sync_enabled and sync_mode != "off") | ||
| firestore_summary = _sanitize_firestore_public_config(firestore, sync_enabled=sync_enabled) | ||
| usage_policy = payload.get("usage_policy") if isinstance(payload.get("usage_policy"), Mapping) else None | ||
| usage_summary = _sanitize_firestore_usage_policy(usage_policy, sync_enabled=sync_enabled) |
There was a problem hiding this comment.
| } | ||
|
|
||
|
|
||
| def _sanitize_firestore_usage_policy(policy: Mapping[str, object] | None, *, sync_enabled: bool) -> dict[str, object]: |
There was a problem hiding this comment.
クリーンアップの提案
引数 sync_enabled は関数内で使用されていません。コードのクリーンアップと可読性向上のため、このパラメータを削除することを検討してください。
| def _sanitize_firestore_usage_policy(policy: Mapping[str, object] | None, *, sync_enabled: bool) -> dict[str, object]: | |
| def _sanitize_firestore_usage_policy(policy: Mapping[str, object] | None) -> dict[str, object]: |
|
Review intake for current head
Classification:
Non-claims: not |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 40f5100aa4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| _record_firestore_poll(state, str(account_id)) | ||
| _save_state(state_file, state) |
There was a problem hiding this comment.
Preserve cursor state before saving Firestore cooldown
When a Firestore poll processes events, each build_realtime_sync_listener_once_report call loads and saves the cursor/idempotency updates independently, but this final _save_state writes the parent’s stale pre-loop state back over that file after adding only last_firestore_poll_at. In any successful Firestore poll with events, the state file loses the saved cursor and duplicate history, so the next poll after cooldown resumes without the cursor and can re-read/reprocess old events.
Useful? React with 👍 / 👎.
40f5100 to
facdd97
Compare
|
Review intake update for current head
Classification:
Non-claims: not |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: facdd9765d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "token_issuance_allowed", | ||
| "projection_write_allowed", | ||
| "kill_switch", |
There was a problem hiding this comment.
Honor deny flags in Firestore usage policy
When the private config returns a usage_policy with token_issuance_allowed: false or kill_switch: true, these fields are admitted here but never evaluated; _sanitize_firestore_usage_policy still returns firestore_usage_policy_accepted: True, and the Firestore poll path only checks that accepted flag plus firestore_sync_enabled before signing in and reading metadata. In that misconfigured or emergency-off state the CLI can still attach to Firestore instead of failing closed, defeating the cost guard.
Useful? React with 👍 / 👎.
概要
Firestore realtime sync の closed-alpha cost guard を Public CLI に統合します。
このPRで追加すること:
yonerai.firestore_usage_policy.v1の受け入れ検証sync_mode=offを最優先の hard stop として扱う挙動sync_mode=off中の projection write 許可を拒否sync listener firestore-pollの limit cap と cooldown guard検証
python -m pytest tests\test_realtime_sync_client_service.py tests\test_realtime_sync_event_service.py tests\test_official_sync_cli.py tests\test_conversation_sync_policy.py tests\test_native_run_client.py tests\test_control_spine_client.py -q→ 129 passedpython -m ruff check clients\cli\yonerai_cli\services\realtime_sync_client_service.py clients\cli\yonerai_cli\commands\sync.py tests\test_realtime_sync_client_service.py tests\test_official_sync_cli.py→ passedpython -m compileall -q clients\cli\yonerai_cli tests→ passedgit diff --check→ passedpython scripts\ci_quality_scans.py --changed→ passedレビュー/同期状態
[AWS-FIRESTORE-COST-GUARD-READY]/[AWS-AUTH-POLL-COMPAT-READY]/[AWS-OFF-MODE-GUARD-READY]を受けて実装。非主張
[PUBLIC-SYNC-SMOKE-PREPARED]はこのPR作成時点では未送信です。merge後に live staging の sync-off gate を再検証してから送ります。[PUBLIC-SYNC-CLIENT-READY]ではありません。sync_mode=off/firestore_sync_enabled=falseの間は listener を開始しません。