Add comprehensive audit report and improve code quality#7
Merged
Conversation
…tion The spec requires extend_by_ms to be between 1 and 86400000 (1ms to 24h). Previously _build_extend_body passed ttl_ms as extend_by_ms without validation. Added validate_extend_by_ms() to _validation.py and call it in _build_extend_body. https://claude.ai/code/session_01HXikxwPuurjunotYpbmsE7
Added [tool.ruff.lint] select = ["E", "F", "I", "UP"] to pyproject.toml. Fixed all violations: import sorting, unused imports, line length, unused variables, and UP035 (import from collections.abc). https://claude.ai/code/session_01HXikxwPuurjunotYpbmsE7
Previously, every invocation of a @cycles-decorated function created a new CommitRetryEngine and CyclesLifecycle. Now the lifecycle is lazily built on first call and cached for subsequent calls, matching the TypeScript client fix (PR#6/PR#10). Client resolution is deferred to first call to support set_default_client/set_default_config patterns. https://claude.ai/code/session_01HXikxwPuurjunotYpbmsE7
The 260+ tests, strict mypy, and ruff lint rules were configured but never enforced in CI. This workflow runs on push/PR to main with a matrix across Python 3.10 (minimum) and 3.12 (current). https://claude.ai/code/session_01HXikxwPuurjunotYpbmsE7
Maps all 9 endpoints, 6 request schemas, 10 response schemas, 5 enum types, and 8 nested object schemas to their Python implementations. All categories pass. Follows the format from cycles-spring-boot-starter. https://claude.ai/code/session_01HXikxwPuurjunotYpbmsE7
Use separate typed cache cells for sync/async paths and inline the retry engine construction to avoid variable type conflicts. https://claude.ai/code/session_01HXikxwPuurjunotYpbmsE7
…EADME __init__.py listed ExtendStatus in __all__ but never imported it from models, causing ImportError on `from runcycles import ExtendStatus`. Added Development section to README documenting lint, type check, and test commands plus CI coverage. https://claude.ai/code/session_01HXikxwPuurjunotYpbmsE7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a comprehensive audit report documenting full protocol conformance with Cycles Protocol v0.1.23, and makes targeted code quality improvements across the codebase.
Key Changes
Documentation & Audit
Code Quality & Linting
Callablefromtypingtocollections.abc(Python 3.10+ best practice) acrossdecorator.pyandlifecycle.pydecorator.py: Function signatures and docstringslifecycle.py: Function signatures and validation callsclient.py: Error message formattingretry.py: Logger calls_validation.py: Error messagestest_client.py: Removed unusedjsontest_lifecycle.py: Reordered mock imports alphabeticallytest_retry.py: Reordered mock imports alphabeticallyconfig.py&context.py: Removed unusedfieldfrom dataclass importsexamples/: Removed trailing blank linesE,F,I,UP) topyproject.tomlValidation & Testing
validate_extend_by_ms()in_validation.pyto enforce spec bounds (1–86400000 ms)validate_extend_by_ms()into_build_extend_body()inlifecycle.pyTestValidateExtendByMsintest_validation.pywith 6 test casesDecorator & Lifecycle Optimization
@cyclesdecorator to cache lifecycle instances at decoration time (deferred client resolution on first call) rather than recreating on every invocation_build_default_subject()helper function_cached_syncand_cached_asynclists to store singleton lifecycle instancesexcept Exception as ex:toexcept Exception:inCyclesLifecycle.execute()(unused variable)CI/CD
Documentation
Notable Implementation Details
extend_by_msnow happens at both request-building time (lifecycle) and Pydantic model level (for typed requests)https://claude.ai/code/session_01HXikxwPuurjunotYpbmsE7