@@ -5,316 +5,24 @@ py-key-value project. For human developers, see [DEVELOPING.md](DEVELOPING.md).
55
66## Development Workflow
77
8- ### Required Pre-commit Checks
9-
10- All checks must pass before committing:
11-
12- 1 . ` make lint ` - Runs Ruff formatting and linting (Python + Markdown)
13- 2 . ` make typecheck ` - Runs Basedpyright type checking
14-
15- Or run both together:
16-
17- ``` bash
18- make precommit
19- ```
20-
21- ### Testing Requirements
22-
23- - All new features require tests
24- - Run ` make test ` to execute all test suites (verbose output)
25- - Run ` make test-concise ` for minimal output (recommended for AI agents)
26- - Test coverage should be maintained
27-
28- ## Architecture
29-
30- ### Project Structure
31-
32- ``` text
33- src/
34- └── key_value/
35- ├── aio/ # Async key-value library
36- │ ├── adapters/ # Type adapters (Pydantic, Dataclass, etc.)
37- │ ├── protocols/ # Protocol definitions
38- │ ├── stores/ # Backend implementations
39- │ └── wrappers/ # Store wrappers
40- └── shared/ # Shared utilities and errors
41- ├── errors/ # Error classes
42- └── ... # Utility modules (beartype, compound, etc.)
43- tests/ # Test suite
44- scripts/
45- └── bump_versions.py # Version management script
46- ```
8+ @DEVELOPING .md
479
4810## Code Style & Conventions
4911
50- ### Python
51-
52- - ** Formatter/Linter** : Ruff (configured in ` pyproject.toml ` )
53- - ** Line length** : 140 characters
54- - ** Type checker** : Basedpyright (strict mode)
55- - ** Runtime type checking** : Beartype (can be disabled via
56- ` PY_KEY_VALUE_DISABLE_BEARTYPE=true ` )
57- - ** Python version** : 3.10+
58-
59- ### Markdown
60-
61- - ** Linter** : markdownlint (` .markdownlint.jsonc ` )
62- - ** Line length** : 80 characters (excluding code blocks and tables)
63-
64- ## Common Pitfalls
65-
66- ### ManagedEntry Wrapper Objects
67-
68- Raw values are ** NEVER** stored directly in backends. The ` ManagedEntry ` wrapper
69- (from ` key_value.shared.managed_entry ` ) wraps values with metadata
70- like TTL and creation timestamp, typically serialized to/from JSON.
71-
72- When implementing or debugging stores, remember that what's stored is not
73- the raw value but a ` ManagedEntry ` containing:
74-
75- - The actual value
76- - Creation timestamp
77- - TTL metadata
78-
79- ### Optional Backend Dependencies
80-
81- Store implementations have optional dependencies. Install extras as needed:
82-
83- ``` bash
84- pip install py-key-value-aio[redis] # Redis support
85- pip install py-key-value-aio[dynamodb] # DynamoDB support
86- pip install py-key-value-aio[mongodb] # MongoDB support
87- # etc. - see README.md for full list
88- ```
89-
90- ## Working with Code Review Feedback
91-
92- This project uses AI-assisted code review (CodeRabbit) and development (Claude).
93- This section provides guidance for both AI agents and human developers on how
94- to handle automated code review feedback effectively.
95-
96- ### For AI Coding Agents (Claude)
97-
98- When responding to CodeRabbit feedback on pull requests:
99-
100- #### 1. Triage Before Acting
101-
102- Always categorize feedback before implementation:
103-
104- - ** Critical** : Security issues, data corruption, resource leaks, production bugs
105- - ** Important** : Type safety, error handling, performance issues, test failures
106- - ** Optional** : Style preferences, nitpicks, suggestions that conflict with
107- existing patterns
108-
109- Document your triage in the response to the user.
110-
111- #### 2. Evaluate Against Existing Patterns
112-
113- Before accepting suggestions:
114-
115- 1 . Search the codebase for similar patterns
116- 2 . Check if other stores/wrappers handle this differently
117- 3 . Preserve consistency over isolated "best practices"
118- 4 . If uncertain, ask the repository owner
119-
120- ** Example** : Test patterns should match existing ` ContextManagerStoreTestMixin `
121- usage rather than one-off suggestions for individual test files.
122-
123- #### 3. Consider Context and Scope
124-
125- Not all code has the same requirements:
126-
127- - ** Production stores** : Prioritize correctness, performance, security
128- - ** Debug/development tools** : Can defer async optimization, extensive validation
129- - ** Test code** : Clarity and coverage over production patterns
130- - ** Examples** : Simplicity and readability over comprehensive error handling
131-
132- #### 4. Verify Completion
133-
134- Before claiming work is "ready to merge" or "complete":
135-
136- - [ ] All critical issues addressed or documented as out-of-scope
137- - [ ] All important issues addressed or explicitly deferred with rationale
138- - [ ] No unrelated changes from bad merges
139- - [ ] ` make precommit ` passes (lint, typecheck)
140- - [ ] Tests pass
141-
142- Never claim completion with unresolved critical or important issues.
143-
144- #### 5. Document Deferrals
145-
146- If feedback is not implemented, explain why:
147-
148- - Conflicts with established pattern (cite similar code)
149- - Out of scope for this component's purpose
150- - Trade-off not worth the complexity
151- - Requires design decision from repository owner
152-
153- ### For AI Code Reviewers (CodeRabbit)
154-
155- When reviewing pull requests, please consider:
156-
157- #### Project-Specific Patterns
158-
159- - ** Async-only architecture** : All code is in ` src/key_value/aio/ ` .
160- - ** Test patterns** : The project uses ` ContextManagerStoreTestMixin ` for store
161- tests. Look for consistency with existing test implementations.
162- - ** ManagedEntry wrapper** : Values are never stored directly but are wrapped in
163- ` ManagedEntry ` objects. This is by design, not a mistake.
164-
165- #### Prioritization Guidance
166-
167- When providing feedback, please categorize suggestions by severity:
168-
169- - ** Critical** : Issues that could cause data loss, security vulnerabilities,
170- resource leaks, or production failures
171- - ** Important** : Type safety issues, missing error handling, performance problems,
172- test coverage gaps
173- - ** Minor/Optional** : Style preferences, minor optimizations, suggestions that
174- may conflict with existing patterns
12+ @CODE_STYLE.md
17513
176- This helps human developers and AI agents prioritize their work effectively.
14+ ## Contributing Guidelines
17715
178- #### Context Awareness
16+ @ CONTRIBUTING .md
17917
180- Consider the purpose and scope of the code being reviewed:
18+ ## Agent-Specific Guidelines
18119
182- - ** Production stores** (DynamoDB, Redis, PostgreSQL, etc.): Apply strict
183- standards for correctness, performance, security, and resource management
184- - ** Debug/development tools** (FileTreeStore, LoggingWrapper): More lenient on
185- performance optimizations; prioritize clarity and simplicity
186- - ** Test code** : Focus on clarity, coverage, and maintainability over production
187- patterns
188- - ** Example code** : Prioritize readability and educational value over
189- comprehensive error handling
20+ ### Testing
19021
191- #### Pattern Consistency
22+ - Use ` make test-concise ` for minimal output (recommended for AI agents)
23+ - Use ` make test ` when you need verbose output for debugging
19224
193- Before suggesting changes:
194-
195- 1 . Check if similar patterns exist elsewhere in the codebase
196- 2 . If the pattern exists in multiple stores/wrappers, it's likely intentional
197- 3 . Suggest consistency improvements across all implementations rather than
198- one-off changes
199-
200- ### Common Feedback Categories
201-
202- ** Clock usage** : Prefer monotonic clocks (` time.monotonic() ` ) for intervals,
203- especially in wrappers like rate limiters and circuit breakers. Wall-clock time
204- (` time.time() ` ) is vulnerable to system clock changes.
205-
206- ** Connection ownership** : Track whether stores own their client connections to
207- avoid closing externally-provided resources. Use flags like ` _owns_client ` to
208- distinguish between internally-created and externally-provided connections.
209-
210- ** Async patterns** : Production stores should use actual async I/O (not
211- ` asyncio.sleep() ` or ` run_in_executor() ` ). Debug-only tools may use simpler
212- patterns for clarity.
213-
214- ** Test isolation** : Ensure tests clean up resources (connections, temp files,
215- etc.) and don't interfere with each other. Use context managers and proper
216- teardown.
217-
218- ** Type safety** : This project uses strict type checking (Basedpyright). Address
219- type annotation issues to maintain type safety guarantees.
220-
221- ## Make Commands Reference
222-
223- | Command | Purpose |
224- | ------- | ------- |
225- | ` make sync ` | Install all dependencies |
226- | ` make install ` | Alias for ` make sync ` |
227- | ` make lint ` | Lint Python + Markdown |
228- | ` make typecheck ` | Run Basedpyright type checking |
229- | ` make test ` | Run all tests (verbose) |
230- | ` make test-concise ` | Run all tests (concise output for AI) |
231- | ` make precommit ` | Run lint + typecheck |
232- | ` make build ` | Build package |
233-
234- ## Key Protocols and Interfaces
235-
236- ### AsyncKeyValue Protocol
237-
238- The core interface is ` AsyncKeyValue ` protocol from
239- ` key_value.aio.protocols.key_value ` . All stores implement this
240- protocol, which defines:
241-
242- - ` get ` , ` get_many ` - Retrieve values
243- - ` put ` , ` put_many ` - Store values with optional TTL
244- - ` delete ` , ` delete_many ` - Remove values
245- - ` ttl ` , ` ttl_many ` - Get TTL information
246-
247- ## Store Implementations
248-
249- Stores are located in ` src/key_value/aio/stores/ ` .
250-
251- Available backends include: DynamoDB, Elasticsearch, Memcached, Memory, Disk,
252- MongoDB, Redis, RocksDB, Valkey, Vault, Windows Registry, Keyring, and more.
253-
254- ## Wrappers
255-
256- Wrappers add functionality to stores and are located in
257- ` src/key_value/aio/wrappers/ ` .
258-
259- Wrappers include: Compression, DefaultValue, Encryption, Logging, Statistics,
260- Retry, Timeout, Cache, Prefix, TTL clamping, and more.
261-
262- ## Adapters
263-
264- Adapters simplify store interactions but don't implement the protocol directly.
265- Located in ` src/key_value/aio/adapters/ ` .
266-
267- Key adapters:
268-
269- - ` PydanticAdapter ` - Type-safe Pydantic model storage
270- - ` RaiseOnMissingAdapter ` - Raise exceptions for missing keys
271-
272- ## Development Environment
273-
274- ### Option 1: DevContainer (Recommended)
275-
276- The repository includes a DevContainer configuration for consistent development
277- environments. Open in VSCode and select "Reopen in Container" when prompted.
278-
279- ### Option 2: Local Development
280-
281- Prerequisites:
282-
283- - Python 3.10+
284- - ` uv ` for dependency management
285- - Node.js and npm for markdown linting
286-
287- Setup:
288-
289- ``` bash
290- make sync
291- ```
292-
293- ## CI/CD
294-
295- GitHub Actions workflows are in ` .github/workflows/ ` :
296-
297- - ` test.yml ` - Run tests across Python versions and platforms
298- - ` publish.yml ` - Publish package to PyPI
299- - ` claude-mention-pr.yml ` - Claude Code assistant (can make PRs)
300- - ` claude-triage.yml ` - Claude triage assistant (read-only analysis)
301- - ` claude-test-failure.yml ` - Claude test failure analysis
302-
303- ## Version Management
304-
305- To bump version:
306-
307- ``` bash
308- make bump-version VERSION=1.2.3 # Actual bump
309- make bump-version-dry VERSION=1.2.3 # Dry run
310- ```
311-
312- ## Getting Help
313-
314- - For human developer documentation, see [ DEVELOPING.md] ( DEVELOPING.md )
315- - For library usage documentation, see [ README.md] ( README.md )
316-
317- ## Radical Honesty
25+ ### Radical Honesty
31826
31927Agents should be honest! When working with code review feedback:
32028
@@ -328,3 +36,10 @@ Never claim work is complete if you have doubts about correctness or completenes
32836
32937Properly document any problems encountered, share feedback, and be transparent
33038about your AI-assisted work.
39+
40+ ## Getting Help
41+
42+ - For human developer documentation, see [ DEVELOPING.md] ( DEVELOPING.md )
43+ - For contribution guidelines, see [ CONTRIBUTING.md] ( CONTRIBUTING.md )
44+ - For code style conventions, see [ CODE_STYLE.md] ( CODE_STYLE.md )
45+ - For library usage documentation, see [ README.md] ( README.md )
0 commit comments