docs: document the class vs module-state convention (audit L3) - #576
Conversation
The audit's L3 finding asked for the implicit rule to be written down rather than changed: classes for multi-instance/injectable state and the error hierarchy; module-level state only for process-global concerns, always paired with a test reset helper. https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Review limit reached
More reviews will be available in 18 minutes and 39 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
CodeRabbit's description check flagged that the intro characterised every table row as a unit-test suite while #576 is a convention doc and #577 a version-drift fix; the prose now says so explicitly. https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Summary
Closes out audit finding L3 ("Class vs module-function patterns mixed without documented rule — document the rule; no code change needed"). Adds one CONVENTIONS bullet to
lib/AGENTS.mdwriting down the rule the codebase already follows:AccountManagerper pool,CircuitBreakerper account,SessionAffinityStoreper proxy) and for theCodexErrorhierarchy.reset*ForTests/resetVolatileRuntimeState-style) so suites can isolate it.Doc-only; no code paths touched. With this, the audit's L-tier items are either fixed (L1 partial via #517/#534 line), documented (L3 here), or roadmapped pending maintainer decisions (L2 rename, L4 postinstall, L5 pin rationale).
Validation
https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Generated by Claude Code
note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
doc-only change that closes audit finding L3 by writing down the class-vs-module-state convention the codebase already follows. no runtime code is touched.
lib/AGENTS.mdexplaining when to use a class (multiple independent instances or DI) vs module-level state (genuinely process-global, always paired with a test reset helper)reset*ForTests/resetVolatileRuntimeState-style helper for any module that does carry global stateConfidence Score: 5/5
markdown-only edit to a dev-facing knowledge base file; no runtime code, no token handling, no filesystem paths altered.
the new bullet accurately captures the class-vs-module-state split already present in the codebase, includes concrete class names as examples, mandates the test-reset helper that existing module-level state already ships, and slots cleanly into the existing CONVENTIONS section without contradicting any prior rule.
no files require special attention
Important Files Changed
Class Diagram
%%{init: {'theme': 'neutral'}}%% classDiagram direction LR class AccountManager { +per pool instance +dependency-injected } class CircuitBreaker { +per account instance +dependency-injected } class SessionAffinityStore { +per proxy instance +dependency-injected } class CodexError { +hierarchy root } note for AccountManager "USE A CLASS\nwhen caller may want\nmultiple independent instances" class moduleRateLimits { <<module-level state>> +process-global +resetForTests() } class moduleRoutingMutex { <<module-level state>> +process-global +resetForTests() } class moduleUIRuntimeOptions { <<module-level state>> +process-global +resetVolatileRuntimeState() } note for moduleRateLimits "USE MODULE STATE\nonly when truly global\n+ must have reset helper"Reviews (1): Last reviewed commit: "docs: document the class vs module-state..." | Re-trigger Greptile
Context used: