codapact 0.5.0__tar.gz → 0.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. {codapact-0.5.0 → codapact-0.5.1}/.github/workflows/mutation.yml +14 -5
  2. codapact-0.5.1/.release-please-manifest.json +1 -0
  3. {codapact-0.5.0 → codapact-0.5.1}/CHANGELOG.md +7 -0
  4. {codapact-0.5.0 → codapact-0.5.1}/PKG-INFO +1 -1
  5. {codapact-0.5.0 → codapact-0.5.1}/docs/configuration.md +3 -1
  6. {codapact-0.5.0 → codapact-0.5.1}/docs/testing.md +1 -1
  7. {codapact-0.5.0 → codapact-0.5.1}/pyproject.toml +1 -1
  8. {codapact-0.5.0 → codapact-0.5.1}/pyproject.toml.orig +1 -1
  9. {codapact-0.5.0 → codapact-0.5.1}/scripts/mutation_score.py +25 -7
  10. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/__init__.py +1 -1
  11. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/core/errors.py +9 -0
  12. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/core/net.py +2 -2
  13. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/__init__.py +2 -0
  14. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/cli.py +49 -4
  15. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/cli_tools.py +4 -0
  16. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/client.py +10 -1
  17. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/errors.py +2 -1
  18. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/selftest.py +3 -1
  19. codapact-0.5.1/tests/unit/test_cli_auth.py +331 -0
  20. codapact-0.5.1/tests/unit/test_cli_options.py +316 -0
  21. codapact-0.5.1/tests/unit/test_live_ynab_findings.py +157 -0
  22. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_mutation_score.py +22 -0
  23. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_public_api_findings.py +2 -0
  24. {codapact-0.5.0 → codapact-0.5.1}/uv.lock +1 -1
  25. codapact-0.5.0/.release-please-manifest.json +0 -1
  26. {codapact-0.5.0 → codapact-0.5.1}/.github/workflows/ci.yml +0 -0
  27. {codapact-0.5.0 → codapact-0.5.1}/.github/workflows/codeql.yml +0 -0
  28. {codapact-0.5.0 → codapact-0.5.1}/.github/workflows/nightly.yml +0 -0
  29. {codapact-0.5.0 → codapact-0.5.1}/.github/workflows/release.yml +0 -0
  30. {codapact-0.5.0 → codapact-0.5.1}/LICENSE +0 -0
  31. {codapact-0.5.0 → codapact-0.5.1}/README.md +0 -0
  32. {codapact-0.5.0 → codapact-0.5.1}/docs/architecture.md +0 -0
  33. {codapact-0.5.0 → codapact-0.5.1}/docs/branding/README.md +0 -0
  34. {codapact-0.5.0 → codapact-0.5.1}/docs/branding/mark.svg +0 -0
  35. {codapact-0.5.0 → codapact-0.5.1}/docs/branding/wordmark.svg +0 -0
  36. {codapact-0.5.0 → codapact-0.5.1}/examples/library/codapact.yaml +0 -0
  37. {codapact-0.5.0 → codapact-0.5.1}/examples/library/operations.graphql +0 -0
  38. {codapact-0.5.0 → codapact-0.5.1}/examples/library/schema.graphql +0 -0
  39. {codapact-0.5.0 → codapact-0.5.1}/examples/petstore/codapact.yaml +0 -0
  40. {codapact-0.5.0 → codapact-0.5.1}/examples/petstore/openapi.yaml +0 -0
  41. {codapact-0.5.0 → codapact-0.5.1}/release-please-config.json +0 -0
  42. {codapact-0.5.0 → codapact-0.5.1}/scripts/extract_openapi_subset.py +0 -0
  43. {codapact-0.5.0 → codapact-0.5.1}/scripts/verify_dist.py +0 -0
  44. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/__main__.py +0 -0
  45. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/commands/__init__.py +0 -0
  46. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/commands/derive.py +0 -0
  47. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/commands/model.py +0 -0
  48. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/core/__init__.py +0 -0
  49. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/core/diagnostics.py +0 -0
  50. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/core/naming.py +0 -0
  51. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/model/__init__.py +0 -0
  52. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/model/api.py +0 -0
  53. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/model/authspec.py +0 -0
  54. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/model/migrations.py +0 -0
  55. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/model/rewrite.py +0 -0
  56. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/model/serialize.py +0 -0
  57. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/model/types.py +0 -0
  58. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/model/validate.py +0 -0
  59. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/model/values.py +0 -0
  60. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/pipeline/__init__.py +0 -0
  61. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/pipeline/cli.py +0 -0
  62. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/pipeline/config.py +0 -0
  63. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/pipeline/defaults.py +0 -0
  64. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/pipeline/pipeline.py +0 -0
  65. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/pipeline/writer.py +0 -0
  66. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/plugins/__init__.py +0 -0
  67. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/plugins/external.py +0 -0
  68. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/plugins/protocol.py +0 -0
  69. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/plugins/registry.py +0 -0
  70. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/py.typed +0 -0
  71. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/abstractions.py +0 -0
  72. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/arguments.py +0 -0
  73. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/auth.py +0 -0
  74. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/cli_auth.py +0 -0
  75. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/codec.py +0 -0
  76. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/credentials.py +0 -0
  77. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/middleware.py +0 -0
  78. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/oauth.py +0 -0
  79. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/protocols/__init__.py +0 -0
  80. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/protocols/base.py +0 -0
  81. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/protocols/graphql.py +0 -0
  82. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/runtime/protocols/http.py +0 -0
  83. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/shaping/__init__.py +0 -0
  84. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/shaping/base.py +0 -0
  85. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/shaping/engine.py +0 -0
  86. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/shaping/transforms.py +0 -0
  87. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/sources/__init__.py +0 -0
  88. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/sources/base.py +0 -0
  89. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/sources/graphql/__init__.py +0 -0
  90. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/sources/graphql/translator.py +0 -0
  91. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/sources/loader.py +0 -0
  92. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/sources/openapi/__init__.py +0 -0
  93. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/sources/openapi/translator.py +0 -0
  94. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/surface/__init__.py +0 -0
  95. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/surface/derive.py +0 -0
  96. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/surface/model.py +0 -0
  97. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/targets/__init__.py +0 -0
  98. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/targets/python/__init__.py +0 -0
  99. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/targets/python/cli.py +0 -0
  100. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/targets/python/e2e.py +0 -0
  101. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/targets/python/library.py +0 -0
  102. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/targets/python/naming.py +0 -0
  103. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/targets/typescript/__init__.py +0 -0
  104. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/targets/typescript/library.py +0 -0
  105. {codapact-0.5.0 → codapact-0.5.1}/src/codapact/targets/typescript/runtime.ts +0 -0
  106. {codapact-0.5.0 → codapact-0.5.1}/tests/authlab.py +0 -0
  107. {codapact-0.5.0 → codapact-0.5.1}/tests/conftest.py +0 -0
  108. {codapact-0.5.0 → codapact-0.5.1}/tests/e2e/test_auth_e2e.py +0 -0
  109. {codapact-0.5.0 → codapact-0.5.1}/tests/e2e/test_cli_e2e.py +0 -0
  110. {codapact-0.5.0 → codapact-0.5.1}/tests/e2e/test_public_apis.py +0 -0
  111. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/authlab/authlab_plugin.py +0 -0
  112. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/authlab/codapact.yaml +0 -0
  113. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/authlab/fake_browser.py +0 -0
  114. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/authlab/openapi.yaml +0 -0
  115. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/authlab_smoke.ts +0 -0
  116. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/contracts/wire.yaml +0 -0
  117. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/README.md +0 -0
  118. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/countries/codapact.yaml +0 -0
  119. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/countries/operations.graphql +0 -0
  120. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/countries/schema.graphql +0 -0
  121. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/github/codapact.yaml +0 -0
  122. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/github/openapi.json +0 -0
  123. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/pokeapi/codapact.yaml +0 -0
  124. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/pokeapi/openapi.yml +0 -0
  125. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/ynab/README.md +0 -0
  126. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/ynab/codapact.yaml +0 -0
  127. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/corpus/ynab/openapi.yaml +0 -0
  128. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/library_smoke.ts +0 -0
  129. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/outline_plugin.py +0 -0
  130. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/petstore_smoke.ts +0 -0
  131. {codapact-0.5.0 → codapact-0.5.1}/tests/fixtures/wire_parity.ts +0 -0
  132. {codapact-0.5.0 → codapact-0.5.1}/tests/integration/test_cli_conformance.py +0 -0
  133. {codapact-0.5.0 → codapact-0.5.1}/tests/integration/test_cli_conventions.py +0 -0
  134. {codapact-0.5.0 → codapact-0.5.1}/tests/integration/test_contract_properties.py +0 -0
  135. {codapact-0.5.0 → codapact-0.5.1}/tests/integration/test_corpus.py +0 -0
  136. {codapact-0.5.0 → codapact-0.5.1}/tests/integration/test_generated_code_properties.py +0 -0
  137. {codapact-0.5.0 → codapact-0.5.1}/tests/integration/test_generation.py +0 -0
  138. {codapact-0.5.0 → codapact-0.5.1}/tests/integration/test_public_api_cli.py +0 -0
  139. {codapact-0.5.0 → codapact-0.5.1}/tests/integration/test_wire_parity.py +0 -0
  140. {codapact-0.5.0 → codapact-0.5.1}/tests/integration/test_ynab_contract.py +0 -0
  141. {codapact-0.5.0 → codapact-0.5.1}/tests/perf/test_scaling.py +0 -0
  142. {codapact-0.5.0 → codapact-0.5.1}/tests/public_api_contract.py +0 -0
  143. {codapact-0.5.0 → codapact-0.5.1}/tests/strategies.py +0 -0
  144. {codapact-0.5.0 → codapact-0.5.1}/tests/support.py +0 -0
  145. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_architecture.py +0 -0
  146. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_auth_and_graphql_sources.py +0 -0
  147. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_auth_sources.py +0 -0
  148. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_bundle_e2e.py +0 -0
  149. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_cli_builtins.py +0 -0
  150. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_codec_serialize.py +0 -0
  151. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_core.py +0 -0
  152. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_guards.py +0 -0
  153. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_model.py +0 -0
  154. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_oauth.py +0 -0
  155. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_openapi_edges.py +0 -0
  156. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_openapi_translator_units.py +0 -0
  157. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_plugins_pipeline.py +0 -0
  158. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_runtime.py +0 -0
  159. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_runtime_edges.py +0 -0
  160. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_runtime_pagination.py +0 -0
  161. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_shaping_surface_commands.py +0 -0
  162. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_sources.py +0 -0
  163. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_target_rendering.py +0 -0
  164. {codapact-0.5.0 → codapact-0.5.1}/tests/unit/test_usability.py +0 -0
@@ -1,6 +1,6 @@
1
1
  name: Mutation
2
2
  # Mutation testing measures whether the tests notice behavior changes. It is slow
3
- # (~9k mutants), so it runs in parallel shards after merges to main, weekly, and on
3
+ # (~18k mutants), so it runs in parallel shards after merges to main, weekly, and on
4
4
  # demand; it never gates a PR. Each shard must finish and meet the score floor.
5
5
  on:
6
6
  push:
@@ -25,9 +25,17 @@ jobs:
25
25
  - {name: openapi, patterns: 'codapact.sources.openapi.*'}
26
26
  - {name: sources, patterns: 'codapact.sources.graphql.* codapact.sources.loader.* codapact.sources.base.*'}
27
27
  - {name: targets, patterns: 'codapact.targets.*'}
28
- # runtime is split three ways: as one shard it outgrew the 65-minute cap.
29
- # A new codapact.runtime module must be added to one of these patterns.
30
- - {name: runtime-cli, patterns: 'codapact.runtime.cli.* codapact.runtime.cli_*'}
28
+ # runtime is split seven ways: as one shard it outgrew the 65-minute cap, and
29
+ # the CLI modules (~3.8k slow mutants) did too, cli.py alone included. cli.py is
30
+ # split by mutant name: module functions and small classes, CliRuntime's private
31
+ # methods, and its public ones.
32
+ # A new codapact.runtime module, or a cli.py class starting with C, must be added
33
+ # to one of these patterns.
34
+ - {name: runtime-cli, patterns: 'codapact.runtime.cli.x_* codapact.runtime.cli.xǁ[!C]* codapact.runtime.cli.xǁCliParserǁ*'}
35
+ - {name: runtime-cli-run, patterns: 'codapact.runtime.cli.xǁCliRuntimeǁ_*'}
36
+ - {name: runtime-cli-runtime, patterns: 'codapact.runtime.cli.xǁCliRuntimeǁ[!_]*'}
37
+ - {name: runtime-cli-auth, patterns: 'codapact.runtime.cli_auth.*'}
38
+ - {name: runtime-cli-tools, patterns: 'codapact.runtime.cli_tools.*'}
31
39
  - {name: runtime-auth, patterns: 'codapact.runtime.oauth.* codapact.runtime.auth.* codapact.runtime.credentials.*'}
32
40
  - {name: runtime-core, patterns: 'codapact.runtime.arguments.* codapact.runtime.middleware.* codapact.runtime.errors.* codapact.runtime.abstractions.* codapact.runtime.protocols.* codapact.runtime.client.* codapact.runtime.codec.* codapact.runtime.selftest.*'}
33
41
  - {name: pipeline, patterns: 'codapact.pipeline.* codapact.plugins.* codapact.commands.*'}
@@ -59,8 +67,9 @@ jobs:
59
67
  PATTERNS: ${{ matrix.shard.patterns }}
60
68
  run: |
61
69
  test "$run_exit" = 0 || { echo "mutmut did not finish (exit $run_exit)"; exit 1; }
70
+ read -ra patterns <<< "$PATTERNS"
62
71
  args=()
63
- for pattern in $PATTERNS; do args+=(--prefix "${pattern%\*}"); done
72
+ for pattern in "${patterns[@]}"; do args+=(--pattern "$pattern"); done
64
73
  uv run python scripts/mutation_score.py --results mutation-report/results.txt "${args[@]}"
65
74
  - if: always()
66
75
  uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
@@ -0,0 +1 @@
1
+ {".":"0.5.1"}
@@ -2,6 +2,13 @@
2
2
 
3
3
  <!-- markdownlint-configure-file { "MD024": { "siblings_only": true } } -->
4
4
 
5
+ ## [0.5.1](https://github.com/mikejhill/codapact/compare/v0.5.0...v0.5.1) (2026-11-14)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **cli:** configurable response limit, UTF-8 pipes, jsonl records ([#37](https://github.com/mikejhill/codapact/issues/37)) ([f8a3b72](https://github.com/mikejhill/codapact/commit/f8a3b72ac2d95f2d873cfa65db2104a4750b029a))
11
+
5
12
  ## [0.5.0](https://github.com/mikejhill/codapact/compare/v0.4.0...v0.5.0) (2026-11-12)
6
13
 
7
14
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codapact
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Contracts into callable tools: generate libraries, then CLIs, from OpenAPI, GraphQL, and other API contracts.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -104,6 +104,7 @@ Precedence: flag, then environment, then settings file.
104
104
  | Timeout | `--timeout` | `<PREFIX>_TIMEOUT` | `timeout` |
105
105
  | Private network | `--allow-private` | `<PREFIX>_ALLOW_PRIVATE` | `allow_private` |
106
106
  | Response validation | `--response-validation strict\|warn\|off` | `<PREFIX>_RESPONSE_VALIDATION` | `response_validation` |
107
+ | Response size limit | none | `<PREFIX>_MAX_RESPONSE_BYTES` | `max_response_bytes` (default 100 MB) |
107
108
  | Output format | `-o`/`--output json\|jsonl\|yaml\|table\|raw` | `<PREFIX>_OUTPUT` | `output` |
108
109
  | Error format | `--error-format text\|json` | `<PREFIX>_ERROR_FORMAT` | `error_format` |
109
110
  | Credentials | none | `<PREFIX>_<SCHEME>`; basic uses `_USERNAME`/`_PASSWORD`; full chain under [Authentication](#authentication) | `auth_plugin`; secrets are never read from the file |
@@ -119,7 +120,8 @@ result is the item list, so `[].name`), `--dry-run`, `-v/--verbose`, `--error-fo
119
120
  `--allow-private`, and `--response-validation`. Command help lists them in one line;
120
121
  `<program> --help` describes each.
121
122
  `table` renders a list of objects, unwrapping single-list envelopes such as `{"data": {"items": [...]}}`.
122
- `jsonl` prints one JSON value per line and streams `--all` results page by page.
123
+ `jsonl` prints one JSON value per line, unwrapping the same envelopes as `table`, and streams
124
+ `--all` results page by page. Output to a pipe or file is UTF-8 on every platform.
123
125
 
124
126
  ### Conventions every generated CLI follows
125
127
 
@@ -28,7 +28,7 @@ make sure they keep running.
28
28
  | Auth | `e2e/test_auth_e2e.py` | Generated CLIs, bundle suites, and TypeScript clients authenticate against AuthLab (`tests/authlab.py`), a loopback server that answers 401 unless the scheme is satisfied: API keys (header, query, cookie), basic, bearer, OAuth 2.0 client credentials, device code, authorization code + PKCE, refresh, and an HMAC-signing plugin | every PR |
29
29
  | Live | marker `live`, `CODAPACT_LIVE=1` | PokeAPI and Countries GraphQL respond as the generated CLI expects; the GitHub corpus bundle runs its own live suite with `GITHUB_TOKEN` (authenticated quota, invalid token rejected) | nightly |
30
30
  | Performance | `tests/perf`, `perf` | Translation, generation, and decoding scale linearly; throughput floors | every PR |
31
- | Mutation | `mutmut`, 8 parallel shards | Tests notice behavior changes in `src/codapact` | after merge to main, weekly |
31
+ | Mutation | `mutmut`, 12 parallel shards | Tests notice behavior changes in `src/codapact` | after merge to main, weekly |
32
32
 
33
33
  Suite markers come from the directory (`tests/conftest.py`); a new file needs no marker.
34
34
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codapact"
3
- version = "0.5.0"
3
+ version = "0.5.1"
4
4
  description = "Contracts into callable tools: generate libraries, then CLIs, from OpenAPI, GraphQL, and other API contracts."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codapact"
3
- version = "0.5.0"
3
+ version = "0.5.1"
4
4
  description = "Contracts into callable tools: generate libraries, then CLIs, from OpenAPI, GraphQL, and other API contracts."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -3,10 +3,11 @@
3
3
  Usage::
4
4
 
5
5
  mutmut results --all true > results.txt
6
- python scripts/mutation_score.py --results results.txt [--prefix codapact.runtime.]
6
+ python scripts/mutation_score.py --results results.txt [--pattern 'codapact.runtime.*']
7
7
 
8
8
  The score is killed / (killed + survived + timeout + suspicious + no tests). Within
9
- ``--prefix`` (one CI shard), mutants left unchecked make the result incomplete,
9
+ ``--pattern`` (one CI shard, matched like ``mutmut run`` arguments) or ``--prefix``,
10
+ mutants left unchecked make the result incomplete,
10
11
  which fails too: a run that did not finish is not evidence of a good suite. Writes
11
12
  a Markdown summary to ``$GITHUB_STEP_SUMMARY`` when set.
12
13
  """
@@ -14,6 +15,7 @@ a Markdown summary to ``$GITHUB_STEP_SUMMARY`` when set.
14
15
  from __future__ import annotations
15
16
 
16
17
  import argparse
18
+ import fnmatch
17
19
  import os
18
20
  import sys
19
21
  from pathlib import Path
@@ -21,12 +23,20 @@ from pathlib import Path
21
23
  DEFAULT_FLOOR = 80.0
22
24
 
23
25
 
24
- def count(results: str, prefix: str | tuple[str, ...] = "") -> dict[str, int]:
25
- """Tally ``mutmut results --all true`` lines (``name: status``) under ``prefix``."""
26
+ def count(
27
+ results: str, prefix: str | tuple[str, ...] = "", patterns: tuple[str, ...] = ()
28
+ ) -> dict[str, int]:
29
+ """Tally ``mutmut results --all true`` lines (``name: status``) under ``prefix``.
30
+
31
+ ``patterns``, when given, also keeps only names matching one of them (fnmatch,
32
+ as ``mutmut run`` selects mutants).
33
+ """
26
34
  stats: dict[str, int] = {}
27
35
  for line in results.splitlines():
28
36
  name, sep, status = line.strip().rpartition(": ")
29
- if sep and name.startswith(prefix):
37
+ if not (sep and name.startswith(prefix)):
38
+ continue
39
+ if not patterns or any(fnmatch.fnmatch(name, pattern) for pattern in patterns):
30
40
  key = status.strip().replace(" ", "_")
31
41
  stats[key] = stats.get(key, 0) + 1
32
42
  return stats
@@ -63,12 +73,20 @@ def main(argv: list[str] | None = None) -> int:
63
73
  parser.add_argument(
64
74
  "--prefix", action="append", default=[], help="only mutants under this name (repeatable)"
65
75
  )
76
+ parser.add_argument(
77
+ "--pattern",
78
+ action="append",
79
+ default=[],
80
+ help="only mutants matching this mutmut name pattern (repeatable)",
81
+ )
66
82
  parser.add_argument(
67
83
  "--floor", type=float, default=float(os.environ.get("MUTATION_FLOOR", DEFAULT_FLOOR))
68
84
  )
69
85
  args = parser.parse_args(argv)
70
86
  try:
71
- stats = count(args.results.read_text("utf-8"), tuple(args.prefix) or "")
87
+ stats = count(
88
+ args.results.read_text("utf-8"), tuple(args.prefix) or "", tuple(args.pattern)
89
+ )
72
90
  except OSError as error:
73
91
  print(f"cannot read mutation results: {error}", file=sys.stderr)
74
92
  return 1
@@ -77,7 +95,7 @@ def main(argv: list[str] | None = None) -> int:
77
95
  target = os.environ.get("GITHUB_STEP_SUMMARY")
78
96
  if target:
79
97
  with Path(target).open("a", encoding="utf-8") as handle:
80
- title = f"Mutation score: {', '.join(args.prefix) or 'codapact'}"
98
+ title = f"Mutation score: {', '.join(args.pattern + args.prefix) or 'codapact'}"
81
99
  handle.write(f"## {title}\n\n{summary}\n")
82
100
  return 0 if passed else 1
83
101
 
@@ -5,4 +5,4 @@ from importlib.metadata import PackageNotFoundError, version
5
5
  try:
6
6
  __version__ = version("codapact")
7
7
  except PackageNotFoundError: # pragma: no cover - running from an unbuilt tree
8
- __version__ = "0.5.0"
8
+ __version__ = "0.5.1"
@@ -41,6 +41,15 @@ class TransportError(CodapactError):
41
41
  """A request could not be sent or the response was rejected before decoding."""
42
42
 
43
43
 
44
+ class ResponseTooLargeError(TransportError):
45
+ """The response body is larger than the client's ``max_bytes`` limit."""
46
+
47
+ def __init__(self, limit: int) -> None:
48
+ """Record the limit that was exceeded."""
49
+ super().__init__(f"response exceeds {limit} bytes")
50
+ self.limit = limit
51
+
52
+
44
53
  def expect[T](value: T | None, what: str) -> T:
45
54
  """Return ``value`` or raise when an internal invariant is broken."""
46
55
  if value is None:
@@ -22,7 +22,7 @@ import urllib.request
22
22
  from dataclasses import dataclass, field
23
23
  from urllib.parse import SplitResult, urlsplit
24
24
 
25
- from codapact.core.errors import ConfigError, TransportError
25
+ from codapact.core.errors import ConfigError, ResponseTooLargeError, TransportError
26
26
 
27
27
  DEFAULT_MAX_BYTES = 10_000_000
28
28
 
@@ -153,7 +153,7 @@ class SafeHttpClient:
153
153
  finally:
154
154
  connection.close()
155
155
  if len(body) > self.max_bytes:
156
- raise TransportError(f"response exceeds {self.max_bytes} bytes")
156
+ raise ResponseTooLargeError(self.max_bytes)
157
157
  if 300 <= response.status < 400:
158
158
  raise TransportError("redirects are not followed")
159
159
  return HttpResponse(response.status, dict(response.getheaders()), body)
@@ -28,6 +28,7 @@ from codapact.runtime.errors import (
28
28
  AuthError,
29
29
  ClientError,
30
30
  GraphQLResponseError,
31
+ ResponseTooLargeError,
31
32
  TransportError,
32
33
  ValidationError,
33
34
  )
@@ -64,6 +65,7 @@ __all__ = [
64
65
  "HttpRequest",
65
66
  "HttpResponse",
66
67
  "Middleware",
68
+ "ResponseTooLargeError",
67
69
  "Retry",
68
70
  "RuntimeClient",
69
71
  "StaticAuth",
@@ -26,12 +26,13 @@ from urllib.parse import quote, quote_plus
26
26
  import yaml
27
27
 
28
28
  from codapact import __version__
29
- from codapact.core.errors import CodapactError, TransportError
29
+ from codapact.core.errors import CodapactError, ResponseTooLargeError, TransportError
30
30
  from codapact.core.net import HttpRequest, HttpResponse, SafeHttpClient
31
31
  from codapact.model.api import Api, AuthKind, AuthScheme
32
32
  from codapact.runtime import cli_auth, cli_tools
33
33
  from codapact.runtime.abstractions import CallContext, Credential, Next, Secret
34
34
  from codapact.runtime.auth import ChainAuth, EnvAuth, FunctionAuthenticator
35
+ from codapact.runtime.client import DEFAULT_MAX_RESPONSE_BYTES
35
36
  from codapact.runtime.credentials import cli_auth as build_cli_auth
36
37
  from codapact.runtime.errors import (
37
38
  ApiError,
@@ -69,6 +70,7 @@ SETTINGS_KEYS = frozenset(
69
70
  "base_url",
70
71
  "timeout",
71
72
  "allow_private",
73
+ "max_response_bytes",
72
74
  "response_validation",
73
75
  "output",
74
76
  "error_format",
@@ -101,6 +103,32 @@ def json_value(text: str) -> Any:
101
103
  raise argparse.ArgumentTypeError("expected JSON or @file") from None
102
104
 
103
105
 
106
+ def _utf8(stream: TextIO) -> TextIO:
107
+ """Write UTF-8 to pipes and files, whatever the locale (cp1252 on Windows).
108
+
109
+ Consoles keep their own encoding; JSON output with non-ASCII text must not depend
110
+ on the code page of whoever redirects it.
111
+ """
112
+ encoding = (getattr(stream, "encoding", None) or "").lower().replace("-", "")
113
+ reconfigure = getattr(stream, "reconfigure", None)
114
+ if encoding != "utf8" and reconfigure is not None and not stream.isatty():
115
+ reconfigure(encoding="utf-8", errors="backslashreplace")
116
+ return stream
117
+
118
+
119
+ def _positive_int(value: Any, name: str) -> int:
120
+ """Parse a byte limit from a flag, environment variable, or settings file."""
121
+ if value is None or value == "":
122
+ return DEFAULT_MAX_RESPONSE_BYTES
123
+ try:
124
+ number = int(value)
125
+ except (TypeError, ValueError):
126
+ raise CodapactError(f"{name} must be a whole number of bytes, not {value!r}") from None
127
+ if number <= 0 or isinstance(value, bool):
128
+ raise CodapactError(f"{name} must be a positive number of bytes")
129
+ return number
130
+
131
+
104
132
  def integer(text: str) -> int:
105
133
  """Parse an integer argument."""
106
134
  try:
@@ -546,6 +574,10 @@ class CliRuntime:
546
574
  )
547
575
  if allow_private in (True, "1", "true", "yes"):
548
576
  options["allow_private"] = True
577
+ limit, sources["max_response_bytes"] = self._setting(
578
+ args, file_settings, "max_response_bytes"
579
+ )
580
+ options["max_response_bytes"] = _positive_int(limit, "max_response_bytes")
549
581
  mode, sources["response_validation"] = self._setting(
550
582
  args, file_settings, "response_validation"
551
583
  )
@@ -755,8 +787,8 @@ class CliRuntime:
755
787
  ) -> int:
756
788
  """Parse ``argv`` and run one generated or built-in command; return the exit code."""
757
789
  words = list(sys.argv[1:] if argv is None else argv)
758
- out = stdout or sys.stdout
759
- err = stderr or sys.stderr
790
+ out = stdout or _utf8(sys.stdout)
791
+ err = stderr or _utf8(sys.stderr)
760
792
  token = _error_format.set(self._error_mode(self._pre_scan(words).error_format))
761
793
  try:
762
794
  parser = build_parser()
@@ -902,6 +934,13 @@ class CliRuntime:
902
934
 
903
935
  def _client_options(self, args: argparse.Namespace, err: TextIO) -> dict[str, Any]:
904
936
  options = self.settings(args)
937
+ # The CLI builds the transport so the response cap also applies to clients
938
+ # generated before ``max_response_bytes`` existed.
939
+ options["transport"] = SafeHttpClient(
940
+ allow_private=bool(options.get("allow_private")),
941
+ timeout=float(options.get("timeout") or 30.0),
942
+ max_bytes=options.pop("max_response_bytes"),
943
+ )
905
944
  if getattr(args, "dry_run", False):
906
945
  options["transport"] = DryRunTransport()
907
946
  options["auth"] = PlaceholderAuth(
@@ -1021,6 +1060,12 @@ class CliRuntime:
1021
1060
  args.placeholders = True # show where the missing credential would go
1022
1061
  return self._run(args, make_client, handler, stdout, stderr)
1023
1062
  return emit_error(p, "auth", str(error), EXIT_AUTH, err, hint=f"run {p} doctor")
1063
+ except ResponseTooLargeError as error:
1064
+ hint = (
1065
+ f"raise the limit with {self.env_prefix}_MAX_RESPONSE_BYTES or "
1066
+ "max_response_bytes in the settings file"
1067
+ )
1068
+ return emit_error(p, "transport", str(error), EXIT_TRANSPORT, err, hint=hint)
1024
1069
  except TransportError as error:
1025
1070
  hint = f"run {p} doctor to check the base URL, proxy, and connectivity"
1026
1071
  return emit_error(p, "transport", str(error), EXIT_TRANSPORT, err, hint=hint)
@@ -1245,7 +1290,7 @@ def render(value: Any, fmt: str, out: TextIO) -> None:
1245
1290
  if isinstance(value, bytes):
1246
1291
  value = value.decode("utf-8", errors="replace")
1247
1292
  if fmt == "jsonl":
1248
- items = value if isinstance(value, list) else [value]
1293
+ items = value if isinstance(value, list) else (_rows(value) or [value])
1249
1294
  for item in items:
1250
1295
  out.write(json.dumps(item, ensure_ascii=False, default=str) + "\n")
1251
1296
  return
@@ -503,6 +503,10 @@ class Doctor:
503
503
  mode = options.get("response_validation", "warn")
504
504
  source = sources.get("response_validation", "default")
505
505
  checks.append(Check("response validation", "info", f"{mode} (from {source})"))
506
+ limit = options.get("max_response_bytes")
507
+ if limit:
508
+ source = sources.get("max_response_bytes", "default")
509
+ checks.append(Check("response limit", "info", f"{limit} bytes (from {source})"))
506
510
  if offline:
507
511
  checks.append(Check("connectivity", "skip", "skipped (--offline)"))
508
512
  elif base_ok:
@@ -28,6 +28,8 @@ from codapact.runtime.protocols.http import HttpAdapter
28
28
  AdapterFactory = Callable[[Exchange], ProtocolAdapter]
29
29
  DEFAULT_ADAPTERS: tuple[AdapterFactory, ...] = (HttpAdapter, GraphQLAdapter)
30
30
  MAX_PAGES = 10_000
31
+ DEFAULT_MAX_RESPONSE_BYTES = 100_000_000
32
+ """Largest response body the default transport accepts (100 MB)."""
31
33
 
32
34
 
33
35
  def load_model(resource: Traversable) -> Api:
@@ -53,12 +55,14 @@ class RuntimeClient:
53
55
  user_agent: str | None = None,
54
56
  response_validation: str = "strict",
55
57
  proxy: str | None = None,
58
+ max_response_bytes: int = DEFAULT_MAX_RESPONSE_BYTES,
56
59
  ) -> None:
57
60
  """Configure the client; ``base_url`` defaults to the model's first server.
58
61
 
59
62
  ``response_validation`` is ``strict`` (mismatching responses raise
60
63
  ``ResponseValidationError``), ``warn`` (emit ``ResponseValidationWarning`` and
61
64
  return the data), or ``off``. ``proxy`` overrides the ``HTTPS_PROXY`` environment.
65
+ ``max_response_bytes`` caps each response body of the default transport.
62
66
  """
63
67
  if response_validation not in RESPONSE_VALIDATION_MODES:
64
68
  raise ConfigError(
@@ -78,7 +82,12 @@ class RuntimeClient:
78
82
  codec=self._codec,
79
83
  base_url=self.base_url,
80
84
  transport=transport
81
- or SafeHttpClient(allow_private=allow_private, timeout=timeout, proxy=proxy),
85
+ or SafeHttpClient(
86
+ allow_private=allow_private,
87
+ timeout=timeout,
88
+ proxy=proxy,
89
+ max_bytes=max_response_bytes,
90
+ ),
82
91
  auth=auth,
83
92
  middleware=tuple(middleware) if middleware is not None else (Retry(),),
84
93
  validate=validate,
@@ -4,13 +4,14 @@ from __future__ import annotations
4
4
 
5
5
  from typing import Any
6
6
 
7
- from codapact.core.errors import CodapactError, TransportError
7
+ from codapact.core.errors import CodapactError, ResponseTooLargeError, TransportError
8
8
 
9
9
  __all__ = [
10
10
  "ApiError",
11
11
  "AuthError",
12
12
  "ClientError",
13
13
  "GraphQLResponseError",
14
+ "ResponseTooLargeError",
14
15
  "ResponseValidationError",
15
16
  "ResponseValidationWarning",
16
17
  "TransportError",
@@ -151,11 +151,13 @@ class Suite:
151
151
  input=stdin,
152
152
  capture_output=True,
153
153
  text=True,
154
+ encoding="utf-8", # generated CLIs write UTF-8 to pipes on every platform
155
+ errors="replace",
154
156
  timeout=TIMEOUT,
155
157
  check=False,
156
158
  )
157
159
  shown = (str(self.data["program"]), *argv)
158
- return Result(shown, completed.returncode, completed.stdout, completed.stderr)
160
+ return Result(shown, completed.returncode, completed.stdout or "", completed.stderr or "")
159
161
 
160
162
  def credential_variables(self) -> list[str]:
161
163
  """Every environment variable that can carry a credential for this CLI."""