Skip to content

refactor: clarify pop_record removal policy constants#4

Merged
CompilError-bts merged 1 commit intomasterfrom
codex/refactor-removal-loop-for-clarity-t0rtc8
Mar 31, 2026
Merged

refactor: clarify pop_record removal policy constants#4
CompilError-bts merged 1 commit intomasterfrom
codex/refactor-removal-loop-for-clarity-t0rtc8

Conversation

@CompilError-bts
Copy link
Copy Markdown
Owner

Motivation

  • The existing pop_record loop used hard-coded numeric stopping conditions that made the intended policy ("usually remove 2 records, sometimes 3 to preserve atomic units") hard to read, so the review suggested making the policy explicit and parameterized.

Description

  • Introduce named constants TARGET_RECORDS = 2 and MAX_RECORDS = 3 and rewrite the removal loop to use while removed < TARGET_RECORDS and if removed > 0 and removed + next_unit_count > MAX_RECORDS: break, preserving existing behavior while improving readability (astrbot/core/provider/provider.py).

Testing

  • Ran ruff format . and ruff check ., and both checks passed.

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant