codeterrain 0.3.0__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 (95) hide show
  1. codeterrain-0.3.0/.gitattributes +1 -0
  2. codeterrain-0.3.0/.github/workflows/ci.yml +52 -0
  3. codeterrain-0.3.0/.github/workflows/release.yml +61 -0
  4. codeterrain-0.3.0/.gitignore +12 -0
  5. codeterrain-0.3.0/AGENTS.md +78 -0
  6. codeterrain-0.3.0/CHANGELOG.md +558 -0
  7. codeterrain-0.3.0/CLAUDE.md +1 -0
  8. codeterrain-0.3.0/LICENSE +201 -0
  9. codeterrain-0.3.0/NOTICE +4 -0
  10. codeterrain-0.3.0/PKG-INFO +295 -0
  11. codeterrain-0.3.0/README.md +257 -0
  12. codeterrain-0.3.0/SECURITY.md +87 -0
  13. codeterrain-0.3.0/docs/charts/make_charts.py +239 -0
  14. codeterrain-0.3.0/docs/commands.md +169 -0
  15. codeterrain-0.3.0/docs/configuration.md +82 -0
  16. codeterrain-0.3.0/docs/design-v0.2.md +112 -0
  17. codeterrain-0.3.0/docs/extractor-protocol.md +167 -0
  18. codeterrain-0.3.0/docs/how-it-works.md +52 -0
  19. codeterrain-0.3.0/docs/img/accuracy-dark.svg +32 -0
  20. codeterrain-0.3.0/docs/img/accuracy-light.svg +32 -0
  21. codeterrain-0.3.0/docs/img/field-dark.svg +31 -0
  22. codeterrain-0.3.0/docs/img/field-light.svg +31 -0
  23. codeterrain-0.3.0/docs/img/logo.svg +5 -0
  24. codeterrain-0.3.0/docs/img/speed-dark.svg +41 -0
  25. codeterrain-0.3.0/docs/img/speed-light.svg +41 -0
  26. codeterrain-0.3.0/docs/img/tokens-dark.svg +53 -0
  27. codeterrain-0.3.0/docs/img/tokens-light.svg +53 -0
  28. codeterrain-0.3.0/docs/limits.md +80 -0
  29. codeterrain-0.3.0/docs/sandbox.md +115 -0
  30. codeterrain-0.3.0/docs/why-codeterrain.md +269 -0
  31. codeterrain-0.3.0/packages/codeterrain-terraform/README.md +27 -0
  32. codeterrain-0.3.0/packages/codeterrain-terraform/pyproject.toml +26 -0
  33. codeterrain-0.3.0/packages/codeterrain-terraform/src/codeterrain_terraform/__init__.py +470 -0
  34. codeterrain-0.3.0/packages/codeterrain-terraform/tests/test_terraform.py +519 -0
  35. codeterrain-0.3.0/packages/codeterrain-typescript/README.md +32 -0
  36. codeterrain-0.3.0/packages/codeterrain-typescript/pyproject.toml +33 -0
  37. codeterrain-0.3.0/packages/codeterrain-typescript/src/codeterrain_typescript/__init__.py +736 -0
  38. codeterrain-0.3.0/packages/codeterrain-typescript/tests/test_typescript.py +298 -0
  39. codeterrain-0.3.0/pyproject.toml +65 -0
  40. codeterrain-0.3.0/src/codeterrain/__init__.py +3 -0
  41. codeterrain-0.3.0/src/codeterrain/_guard.py +243 -0
  42. codeterrain-0.3.0/src/codeterrain/_pytest_dump_plugin.py +253 -0
  43. codeterrain-0.3.0/src/codeterrain/_routes_runner.py +119 -0
  44. codeterrain-0.3.0/src/codeterrain/budget.py +128 -0
  45. codeterrain-0.3.0/src/codeterrain/cache.py +618 -0
  46. codeterrain-0.3.0/src/codeterrain/calls_join.py +416 -0
  47. codeterrain-0.3.0/src/codeterrain/calls_static.py +1099 -0
  48. codeterrain-0.3.0/src/codeterrain/cli.py +1447 -0
  49. codeterrain-0.3.0/src/codeterrain/code_static.py +2411 -0
  50. codeterrain-0.3.0/src/codeterrain/config.py +331 -0
  51. codeterrain-0.3.0/src/codeterrain/executables.py +130 -0
  52. codeterrain-0.3.0/src/codeterrain/fixtures_order.py +77 -0
  53. codeterrain-0.3.0/src/codeterrain/fixtures_static.py +501 -0
  54. codeterrain-0.3.0/src/codeterrain/hookspecs.py +25 -0
  55. codeterrain-0.3.0/src/codeterrain/impact.py +725 -0
  56. codeterrain-0.3.0/src/codeterrain/languages.py +293 -0
  57. codeterrain-0.3.0/src/codeterrain/plugins/__init__.py +0 -0
  58. codeterrain-0.3.0/src/codeterrain/plugins/fastapi_routes.py +193 -0
  59. codeterrain-0.3.0/src/codeterrain/plugins/manifest_join.py +107 -0
  60. codeterrain-0.3.0/src/codeterrain/protocol.py +138 -0
  61. codeterrain-0.3.0/src/codeterrain/routes_view.py +61 -0
  62. codeterrain-0.3.0/src/codeterrain/sandbox.py +565 -0
  63. codeterrain-0.3.0/src/codeterrain/views.py +198 -0
  64. codeterrain-0.3.0/tests/conftest.py +86 -0
  65. codeterrain-0.3.0/tests/sample_repo/docs/route-access.json +9 -0
  66. codeterrain-0.3.0/tests/sample_repo/pyproject.toml +9 -0
  67. codeterrain-0.3.0/tests/sample_repo/sampleapp/__init__.py +0 -0
  68. codeterrain-0.3.0/tests/sample_repo/sampleapp/main.py +81 -0
  69. codeterrain-0.3.0/tests/sample_repo/sampleapp/other.py +8 -0
  70. codeterrain-0.3.0/tests/sample_repo/tests/api/conftest.py +11 -0
  71. codeterrain-0.3.0/tests/sample_repo/tests/api/test_items.py +28 -0
  72. codeterrain-0.3.0/tests/sample_repo/tests/conftest.py +41 -0
  73. codeterrain-0.3.0/tests/sample_repo/tests/test_root.py +11 -0
  74. codeterrain-0.3.0/tests/test_budget.py +117 -0
  75. codeterrain-0.3.0/tests/test_cache.py +607 -0
  76. codeterrain-0.3.0/tests/test_calls_join.py +340 -0
  77. codeterrain-0.3.0/tests/test_calls_static.py +683 -0
  78. codeterrain-0.3.0/tests/test_cli.py +1261 -0
  79. codeterrain-0.3.0/tests/test_code_static.py +2269 -0
  80. codeterrain-0.3.0/tests/test_config.py +340 -0
  81. codeterrain-0.3.0/tests/test_executables.py +255 -0
  82. codeterrain-0.3.0/tests/test_fastapi_routes.py +227 -0
  83. codeterrain-0.3.0/tests/test_fixtures_order.py +632 -0
  84. codeterrain-0.3.0/tests/test_fixtures_static.py +624 -0
  85. codeterrain-0.3.0/tests/test_hookspecs.py +74 -0
  86. codeterrain-0.3.0/tests/test_impact.py +873 -0
  87. codeterrain-0.3.0/tests/test_languages.py +238 -0
  88. codeterrain-0.3.0/tests/test_manifest_join.py +165 -0
  89. codeterrain-0.3.0/tests/test_protocol.py +178 -0
  90. codeterrain-0.3.0/tests/test_pytest_dump_plugin.py +282 -0
  91. codeterrain-0.3.0/tests/test_routes_runner.py +127 -0
  92. codeterrain-0.3.0/tests/test_routes_view.py +125 -0
  93. codeterrain-0.3.0/tests/test_sandbox.py +1159 -0
  94. codeterrain-0.3.0/tests/test_views.py +519 -0
  95. codeterrain-0.3.0/uv.lock +578 -0
@@ -0,0 +1 @@
1
+ * text=auto eol=lf
@@ -0,0 +1,52 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ lint:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
16
+ with:
17
+ persist-credentials: false
18
+ - uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
19
+ - run: uv run --locked --python 3.12 --extra dev ruff check .
20
+
21
+ test:
22
+ needs: lint
23
+ runs-on: ${{ matrix.os }}
24
+ defaults:
25
+ run:
26
+ shell: bash
27
+ strategy:
28
+ fail-fast: false
29
+ matrix:
30
+ os: [ubuntu-latest]
31
+ python: ["3.12"]
32
+ fastapi: ["<0.137", ">=0.137"]
33
+ pytest: ["8.*", "9.*"]
34
+ include:
35
+ - os: windows-latest
36
+ python: "3.12"
37
+ fastapi: ">=0.137"
38
+ pytest: "9.*"
39
+ name: ${{ matrix.os }} py${{ matrix.python }} fastapi${{ matrix.fastapi }} pytest${{ matrix.pytest }}
40
+ steps:
41
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
42
+ with:
43
+ persist-credentials: false
44
+ - uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
45
+ - name: install
46
+ # Everything from uv.lock; only the two matrix axes are then moved to the cell's range.
47
+ run: |
48
+ uv sync --locked --extra dev --python ${{ matrix.python }}
49
+ uv pip install "fastapi${{ matrix.fastapi }}" "pytest==${{ matrix.pytest }}"
50
+ - name: versions
51
+ run: uv run --no-sync python -c "import fastapi, pytest; print(fastapi.__version__, pytest.__version__)"
52
+ - run: uv run --no-sync pytest
@@ -0,0 +1,61 @@
1
+ name: release
2
+
3
+ # A tag `vX.Y.Z` builds the core and both packs and publishes them to PyPI through trusted
4
+ # publishing: no token is stored. Each package publishes from its own environment, which is
5
+ # what PyPI's trusted publisher for that package names. A pack whose version is already on PyPI
6
+ # is skipped, so a core release does not need a pack release.
7
+
8
+ on:
9
+ push:
10
+ tags: ["v*"]
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ build:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
20
+ with:
21
+ persist-credentials: false
22
+ - uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
23
+ - name: the tag is the core's version
24
+ run: |
25
+ version=$(uv run --no-project --python 3.12 python -c \
26
+ "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
27
+ test "v$version" = "$GITHUB_REF_NAME"
28
+ - run: uv build --python 3.12 --out-dir dist/core .
29
+ - run: uv build --python 3.12 --out-dir dist/terraform packages/codeterrain-terraform
30
+ - run: uv build --python 3.12 --out-dir dist/typescript packages/codeterrain-typescript
31
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
32
+ with:
33
+ name: dist
34
+ path: dist/
35
+
36
+ publish:
37
+ needs: build
38
+ runs-on: ubuntu-latest
39
+ strategy:
40
+ max-parallel: 1
41
+ matrix:
42
+ include:
43
+ - package: core
44
+ environment: pypi
45
+ - package: terraform
46
+ environment: pypi-terraform
47
+ - package: typescript
48
+ environment: pypi-typescript
49
+ name: publish ${{ matrix.package }}
50
+ environment: ${{ matrix.environment }}
51
+ permissions:
52
+ id-token: write
53
+ steps:
54
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
55
+ with:
56
+ name: dist
57
+ path: dist/
58
+ - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
59
+ with:
60
+ packages-dir: dist/${{ matrix.package }}/
61
+ skip-existing: ${{ matrix.package != 'core' }}
@@ -0,0 +1,12 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ .codeterrain/
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+
11
+ # Local, private overlays (not part of the project)
12
+ CLAUDE.local.md
@@ -0,0 +1,78 @@
1
+ # codeterrain: instructions for coding agents and contributors
2
+
3
+ codeterrain is a local, LLM-free, network-free command line tool (`terrain`) that answers questions about
4
+ a repository's code from a cache, in under a second. Python first: pytest fixture order, FastAPI routes,
5
+ definitions and references; plus the HTTP calls of a JavaScript or TypeScript front end. See
6
+ [README.md](README.md) for what it does and [docs/extractor-protocol.md](docs/extractor-protocol.md) for
7
+ the extractor protocol.
8
+
9
+ ## Code review rules
10
+
11
+ These rules set severity for every review of this repository, by people or by automated reviewers
12
+ (the GitHub Codex code and security reviews included). codeterrain is a local developer tool: it has
13
+ no server, no network access and no stored credentials, and [SECURITY.md](SECURITY.md) states what it
14
+ guarantees and what it does not.
15
+
16
+ ### Severity
17
+
18
+ - **P1** only for a break of a guarantee in [SECURITY.md](SECURITY.md) (the static tier runs target
19
+ code, the child gets something the user did not opt into, the child writes into the repository, a
20
+ program is resolved from inside the target, a secret reaches output or the cache), or a write
21
+ outside the cache directory.
22
+ - **P2** for a wrong answer on ordinary code: a definition, reference, fixture order or route that
23
+ codeterrain reports wrongly for code a real project writes, or a crash on such code.
24
+ - **P3 at most** for:
25
+ - resource use (time, memory, disk) driven by a file crafted for it, when a limit already bounds
26
+ that kind of work: say which input defeats which limit, by how much;
27
+ - a wrong or missing answer for Python whose meaning depends on run-time state (rebinding in
28
+ branches, `exec`, monkeypatching, dynamic attributes): static resolution is an approximation, and
29
+ leaving a name unresolved is the intended answer when it cannot be known;
30
+ - a missing regression lock.
31
+ - No style, naming, lint or formatting findings: CI owns them.
32
+
33
+ ### Scope
34
+
35
+ - Review the changed lines and the code they call or are called by. A defect in untouched code is a
36
+ finding only if the diff newly exposes it; name what in the diff exposes it.
37
+ - One finding per root cause, with every affected call site in that one finding.
38
+
39
+ ### Settled threads
40
+
41
+ - A thread resolved with a reply that links a commit or an issue ("deferred to #NNN"), or that
42
+ rebuts the premise, is settled. Do not raise it or a variant of it again unless a later commit
43
+ changes that code or you have a new concrete failure the reply does not address.
44
+
45
+ ### Every finding
46
+
47
+ - States the input, the command run, and the wrong outcome; for resource findings, the measured
48
+ cost against the limit that should have bounded it. No scenario, no finding.
49
+
50
+ For contributors answering a review: two findings of one class in a round means stop patching
51
+ instances and sweep the class (every visitor, query or limit of that kind) before the next push.
52
+
53
+ ## Development
54
+
55
+ ```
56
+ uv run --extra dev ruff check .
57
+ uv run --extra dev pytest
58
+ ```
59
+
60
+ - Python 3.12 or newer. The only runtime dependency of the core is `pluggy`.
61
+ - Run pytest as a single process (no `-n`). The suite spawns real pytest and interpreter subprocesses.
62
+ - CI runs the two commands above (lint, then the tests against FastAPI below and above 0.137 and pytest 8
63
+ and 9, plus a Windows job). There is no format gate: do not run `ruff format` over existing files.
64
+ - The tree uses the 100-column limit (`ruff` rules `E`, `F`, `I`, `UP`, `B`).
65
+
66
+ ## Conventions
67
+
68
+ - **LF line endings** in every file, in the index and the working copy.
69
+ - **The static tier never imports target code.** `fixtures_static.py` reads files with `ast` only.
70
+ Anything that has to import the target runs in the sandbox, in the target's own interpreter.
71
+ - **Every sandbox or security change ships a regression test and a CHANGELOG note**, and the list in
72
+ [docs/sandbox.md](docs/sandbox.md) of what the guard does and does not cover stays true.
73
+ - **Generic code.** Project specifics live in configuration, never in the code, the defaults, the tests
74
+ or the fixtures. Tests build `tmp_path` repositories or use `tests/sample_repo`.
75
+ - **Naming rule for the docs:** the origin story names the project and company codeterrain grew out of in
76
+ `README.md`, `docs/why-codeterrain.md` and the CHANGELOG, and nowhere else. Other projects are described
77
+ by shape, never by name.
78
+ - Every fix ships its regression test in the file that owns the behaviour, as a new case or function.