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:

  1. Zero Dependencies: NEVER add external libraries (except dev tools). Use only Python 3.9+ stdlib.

  2. Coverage β‰₯97%: NO negotiation. If you change code, you MUST update/add tests to maintain 97%+.

  3. Strict Typing: NO Any. NO type: ignore (unless fully justified). Use explicit Optional, Union, etc.

  4. Google-Style Docstrings: REQUIRED for all public modules, classes, and functions. English only.

  5. 3-Layer Architecture: Respect Client -> Protocol -> Transport boundaries.

  6. No Git Commands: NEVER execute git commit or git push. Suggest commands to the user.

Before writing a single line of code:

  1. Read ARCHITECTURE.md (Blueprints).

  2. Read ADR/0000-ADR.md (Rules).

  3. Read TEST_MAPPING.md (Where to test).


πŸ“‹ Full Manual Table of ContentsΒΆ

  1. Before Starting

  2. Complete Workflow

  3. Code Standards

  4. Testing Requirements

  5. Required Documentation

  6. Semantic Versioning

  7. Git Workflow

  8. Checklist by Change Type

  9. Special Cases

  10. FAQ


🚦 BEFORE STARTING¢

1. Mandatory ReadingΒΆ

Before making ANY change, you must have read:

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?

ADR-001

Zero Dependencies

❓ Adding external deps? β†’ ❌ NOT ALLOWED

ADR-002

Async-First

❓ Async code is primary, sync is wrapper?

ADR-003

Session-Based

❓ Session holds state, Request is stateless?

ADR-004

LIFO Pooling

❓ Connection pool uses LIFO strategy?

ADR-005

HTTP/1.1 First

❓ No HTTP/2 added before v1.0.0?

ADR-006

Granular Exceptions

❓ Using specific existing exceptions?

ADR-007

__slots__

❓ Using __slots__ in frequent classes?

ADR-008

Strict Types

❓ Complete type hints, strict mypy?

ADR-009

97% Coverage

❓ Tests maintain β‰₯97% coverage?

ADR-010

Limited API

❓ Only adding to public API if necessary?

ADR-011

3 Layers

❓ Respecting Client/Protocol/Transport?

ADR-012

Manual Parsing

❓ Not using external libs for HTTP?

ADR-013

Python 3.9+

❓ Code compatible with Python 3.9+?

ADR-014

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ΒΆ

  1. βœ… Read relevant ADRs

  2. βœ… Review ROADMAP.md for current status - ROADMAP.md

  3. βœ… Review TEST_MAPPING.md for existing tests

  4. βœ… Read related existing code

Step 2: Plan ChangeΒΆ

Before writing code:

  1. βœ… Identify files to be modified

  2. βœ… Identify new files to be created

  3. βœ… Identify tests to be created/modified

  4. βœ… Identify documentation to be updated

  5. βœ… 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 (use Union or generics)

  • ❌ NO # type: ignore without 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

connection_pool.py

Classes

PascalCase

ConnectionPool

Functions

lowercase_with_underscores

get_connection()

Variables

lowercase_with_underscores

max_size

Constants

UPPERCASE_WITH_UNDERSCORES

MAX_HEADER_SIZE

Private

_leading_underscore

_internal_method()

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:

  1. Implementation: feat(scope): ...

  2. Tests: test(scope): ...

  3. 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.


πŸ“š Quick ReferencesΒΆ