AI Agents & Developer Guide for ReqivoΒΆ
Master Guide for AI Agents and Developers on How to Operate in the Reqivo Codebase
β οΈ CRITICAL INSTRUCTION FOR AGENTS: This is your primary instruction manual. Follow it strictly.
Last updated: 2026-01-29 Version: 0.1.0
π€ QUICK AGENT DIRECTIVE (Read First)ΒΆ
You are an expert software engineer working on Reqivo.
Your Core Directives:
Zero Dependencies: NEVER add external libraries (except dev tools). Use only Python 3.9+ stdlib.
Coverage β₯97%: NO negotiation. If you change code, you MUST update/add tests to maintain 97%+.
Strict Typing: NO
Any. NOtype: ignore(unless fully justified). Use explicitOptional,Union, etc.Google-Style Docstrings: REQUIRED for all public modules, classes, and functions. English only.
3-Layer Architecture: Respect Client -> Protocol -> Transport boundaries.
No Git Commands: NEVER execute
git commitorgit push. Suggest commands to the user.
Before writing a single line of code:
Read
ARCHITECTURE.md(Blueprints).Read
ADR/0000-ADR.md(Rules).Read
TEST_MAPPING.md(Where to test).
π Full Manual Table of ContentsΒΆ
π¦ BEFORE STARTINGΒΆ
1. Mandatory ReadingΒΆ
Before making ANY change, you must have read:
β ARCHITECTURE.md - Documentation Index
β 0000-ADR.md - Architectural Decisions (14 ADRs)
β ROADMAP.md - Current status and future
β TEST_MAPPING.md - Tests mapping
β CONTRIBUTING.md - Contribution guide
2. Verify Alignment with ADRsΒΆ
CRITICAL: Every change must respect existing architectural decisions.
Verify that your change is compatible with:
ADR |
Decision |
Does your change respect it? |
|---|---|---|
Zero Dependencies |
β Adding external deps? β β NOT ALLOWED |
|
Async-First |
β Async code is primary, sync is wrapper? |
|
Session-Based |
β Session holds state, Request is stateless? |
|
LIFO Pooling |
β Connection pool uses LIFO strategy? |
|
HTTP/1.1 First |
β No HTTP/2 added before v1.0.0? |
|
Granular Exceptions |
β Using specific existing exceptions? |
|
|
β Using |
|
Strict Types |
β Complete type hints, strict mypy? |
|
97% Coverage |
β Tests maintain β₯97% coverage? |
|
Limited API |
β Only adding to public API if necessary? |
|
3 Layers |
β Respecting Client/Protocol/Transport? |
|
Manual Parsing |
β Not using external libs for HTTP? |
|
Python 3.9+ |
β Code compatible with Python 3.9+? |
|
Test Structure |
β Tests follow 1:1 structure? |
If any answer is NO: You must create a new ADR or justify why one is being broken.
3. Identify Change TypeΒΆ
Classify your change:
π New Feature β Requires: Tests, Docs, roadmap update, possible version bump
π Bug Fix β Requires: Regression test, CHANGELOG entry
π§ Refactoring β Requires: Maintain existing tests passing, no API changes
π Documentation β Requires: Verify consistency with code
π§ͺ Tests β Requires: Update TEST_MAPPING.md
β‘ Performance β Requires: Benchmarks before/after
π Security β Requires: Impact analysis, possible hotfix
π COMPLETE WORKFLOWΒΆ
Step 0: PreparationΒΆ
# 1. Ensure clean environment
# 2. Have Python 3.9+ installed
# 3. Development dependencies installed
pip install -e ".[test,docs]"
pip install black isort pylint mypy bandit
Step 1: Read ContextΒΆ
β Read relevant ADRs
β Review ROADMAP.md for current status - ROADMAP.md
β Review TEST_MAPPING.md for existing tests
β Read related existing code
Step 2: Plan ChangeΒΆ
Before writing code:
β Identify files to be modified
β Identify new files to be created
β Identify tests to be created/modified
β Identify documentation to be updated
β Determine if itβs a breaking change
Key Question: Does this change break backward compatibility?
YES β Major version bump (1.0.0 β 2.0.0)
NO, adds features β Minor version bump (0.1.0 β 0.2.0)
NO, only bug fix β Patch version bump (0.1.0 β 0.1.1)
Step 3: Implement ChangeΒΆ
Recommended Order (TDD):
1. Write tests first (if feature or bug fix)
2. Implement code
3. Pass tests
4. Refactor
5. Repeat
WHILE IMPLEMENTING:
β Type hints on EVERYTHING
β English Google-style docstrings on EVERYTHING
β
__slots__on frequent classesβ Error handling with specific exceptions
β Logging (when supported in v0.5.0+)
Step 4: TestingΒΆ
# 1. Format code
black src/reqivo tests/
isort src/reqivo tests/
# 2. Type check
mypy src/reqivo --strict
# 3. Lint
pylint src/reqivo
# 4. Security scan
bandit -r src/reqivo
# 5. Run tests
pytest --cov=reqivo --cov-report=term --cov-report=html
# 6. Verify coverage β₯97%
coverage report --fail-under=97
ALL CHECKS MUST PASS.
Step 5: DocumentationΒΆ
Update the following files as appropriate:
Document |
When to update |
|---|---|
README.md |
If public API or installation changed |
CHANGELOG.md |
ALWAYS (every visible change) |
ROADMAP.md |
If completed/started a feature |
TEST_MAPPING.md |
If added/modified tests or modules |
ADR/0000-ADR.md |
If architectural decision taken |
docs/ |
If documented behavior changed |
PROJECT_ANALYSIS.md |
If major architecture changed |
See Documentation Section for details.
Step 6: VersioningΒΆ
IMPORTANT: Update version according to Semantic Versioning.
# src/reqivo/version.py
__version__ = "0.X.Y" # Update per change type
See Versioning Section for rules.
Step 7: Prepare Commit (DO NOT EXECUTE)ΒΆ
β οΈ CRITICAL: NEVER execute git commit or git push automatically.
Instead, RECOMMEND to the user the commands and commit messages. See Git Workflow.
π CODE STANDARDSΒΆ
1. Type Hints (MANDATORY)ΒΆ
β CORRECT:
from typing import Optional, Dict, List, Union
def send_request(
url: str,
headers: Optional[Dict[str, str]] = None,
timeout: Optional[float] = None,
) -> Response:
"""Send HTTP request.
Args:
url: Target URL.
headers: Optional headers dict.
timeout: Optional timeout in seconds.
Returns:
Response object.
Raises:
NetworkError: If connection fails.
TimeoutError: If request times out.
"""
pass
β INCORRECT:
def send_request(url, headers=None, timeout=None): # No types
pass
def send_request(url: Any, headers: Any) -> Any: # Abused Any
pass
Rules:
β All parameters typed
β All returns typed
β Variables typed when not obvious
β NO
Any(useUnionor generics)β NO
# type: ignorewithout strong justification
2. Docstrings (MANDATORY)ΒΆ
Format: Google Style, in ENGLISH
β CORRECT:
def parse_headers(data: bytes) -> Dict[str, str]:
"""Parse HTTP headers from raw bytes.
This function parses HTTP headers following RFC 7230 spec.
Header names are case-insensitive and normalized to lowercase.
Args:
data: Raw HTTP header bytes including CRLF separators.
Returns:
Dictionary with header name (lowercase) as key and value as string.
Raises:
InvalidResponseError: If headers are malformed or exceed size limit.
Example:
>>> data = b"Content-Type: application/json\\r\\n\\r\\n"
>>> headers = parse_headers(data)
>>> headers["content-type"]
'application/json'
Note:
Duplicate headers are combined into a list value.
"""
pass
Mandatory Sections:
Description: What it does (simple present, 3rd person)
Args: Each parameter with description
Returns: What it returns
Raises: What exceptions it raises
Example: (optional but recommended) Usage example
3. FormattingΒΆ
Black (line length 88, Python 3.9+ target):
black src/reqivo tests/
isort (import sorting, Black profile):
isort src/reqivo tests/
4. Naming ConventionsΒΆ
Type |
Convention |
Example |
|---|---|---|
Modules |
lowercase_with_underscores |
|
Classes |
PascalCase |
|
Functions |
lowercase_with_underscores |
|
Variables |
lowercase_with_underscores |
|
Constants |
UPPERCASE_WITH_UNDERSCORES |
|
Private |
_leading_underscore |
|
5. Memory OptimizationΒΆ
Use __slots__ in frequently instantiated classes:
class Response:
__slots__ = (
"raw",
"status_line",
"status_code",
"headers",
"body",
"_text",
"_json",
)
def __init__(self, raw: bytes):
self.raw = raw
self.status_line: str = ""
# ...
6. Error HandlingΒΆ
Use existing specific exceptions:
# β
CORRECT
from reqivo.exceptions import ConnectTimeout, TlsError, InvalidResponseError
try:
conn.open()
except socket.timeout:
raise ConnectTimeout(f"Connection to {host}:{port} timed out")
except ssl.SSLError as e:
raise TlsError(f"TLS handshake failed: {e}")
β INCORRECT:
# DO NOT create generic new exceptions
raise Exception("Connection failed") # NO
raise ValueError("Invalid response") # NO (use InvalidResponseError)
7. ImportsΒΆ
Order (isort does automatically):
# 1. Standard library
import socket
import ssl
from typing import Optional, Dict
# 2. Reqivo imports (absolute)
from reqivo.exceptions import NetworkError, ConnectTimeout
from reqivo.http.headers import Headers
from reqivo.transport.connection import Connection
π§ͺ TESTING REQUIREMENTSΒΆ
1. Minimum Coverage: 97%ΒΆ
NON-NEGOTIABLE: Every change must maintain coverage β₯97%.
# Verify coverage
pytest --cov=reqivo --cov-report=term --cov-report=html
# Must show:
# TOTAL 1966 XX 97%
If coverage drops below 97%:
β Change rejected
β Add tests until 97%+ reached
2. Test StructureΒΆ
1:1 Rule: Every source file has its unit test.
src/reqivo/client/session.py β tests/unit/test_session.py
src/reqivo/http/http11.py β tests/unit/test_http_parser.py
See TEST_MAPPING.md for full structure.
3. Unit TestsΒΆ
Template:
"""tests/unit/test_<module>.py
Unit tests for reqivo.<layer>.<module>
"""
import pytest
from reqivo.<layer>.<module> import <Class>
class Test<Class>Init:
"""Tests for <Class>.__init__()"""
def test_init_<scenario>(self):
# ...
class Test<Class><Method>:
"""Tests for <Class>.<method>()"""
def test_<method>_<normal_case>(self):
# ...
4. Integration TestsΒΆ
Location: tests/integration/test_<feature>_flow.py
5. Coverage TypesΒΆ
Each module must have tests for:
β Happy path: Normal usage
β Edge cases: Limits, special values (0, None, ββ, etc.)
β Error paths: Exceptions, timeouts, failures
β Async variant: If async version exists
β Integration: Full end-to-end flow
π REQUIRED DOCUMENTATIONΒΆ
1. README.md & CHANGELOG.mdΒΆ
Update when: Public API changes or visible features added.
2. ROADMAP.mdΒΆ
Update when: Completed or started a feature.
3. TEST_MAPPING.mdΒΆ
Update when: Added or modified tests.
4. ADR/0000-ADR.mdΒΆ
Update when: Significant architectural decision taken.
π¦ SEMANTIC VERSIONINGΒΆ
Rules (Semantic Versioning 2.0.0):
MAJOR (X.0.0): Breaking changes.
MINOR (0.X.0): New features (backward compatible).
PATCH (0.0.X): Bug fixes, internal improvements.
Version 0.x.x (Pre-1.0.0):
0.1.0 β 0.2.0: Can include breaking changes.
1.0.0 β 1.1.0: CANNOT include breaking changes.
π GIT WORKFLOWΒΆ
β οΈ CRITICAL RULE: NO GIT COMMANDSΒΆ
NEVER execute git commit or git push automatically.
Instead, RECOMMEND to the user what to do using markdown code blocks.
Commit RecommendationΒΆ
Group changes logically:
Implementation:
feat(scope): ...Tests:
test(scope): ...Docs:
docs: ...
β CHECKLIST BY CHANGE TYPEΒΆ
π NEW FEATUREΒΆ
[ ] Feature in ROADMAP.md
[ ] Code with type hints and docstrings
[ ] Unit and integration tests created
[ ] Coverage β₯97%
[ ] Quality checks pass (mypy, pylint, black)
[ ] Docs updated (CHANGELOG, ROADMAP, TEST_MAPPING)
[ ] Version updated (MINOR)
π BUG FIXΒΆ
[ ] Test reproducing bug
[ ] Fix implemented (without breaking API)
[ ] Tests pass
[ ] CHANGELOG updated (Fixed)
[ ] Version updated (PATCH)
π§ REFACTORINGΒΆ
[ ] Clear objective
[ ] Existing tests pass without changes
[ ] Coverage maintained
[ ] NO version change (unless major)
π SPECIAL CASESΒΆ
Case 1: Breaking Change (v1.0.0+)ΒΆ
Only with MAJOR bump.
Requires deprecation path.
Case 2: Dependencies (PROHIBITED)ΒΆ
ADR-001: Zero dependencies.
Only stdlib allowed.
Exception: Dev tools.
β FAQΒΆ
Q: Can I use external libraries? A: β NO. ADR-001 establishes zero dependencies.
Q: Can I commit on my own? A: β NO if you are AI. Always recommend to user.
Q: What if coverage drops below 97%? A: β Not accepted. Add tests.
Q: Can I use Any?
A: β NO. mypy strict doesnβt allow Any.
Q: Tests in Spanish? A: β NO. Everything (docstrings, commits, tests) in ENGLISH.