hermetic-agent 0.1.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 (150) hide show
  1. hermetic_agent-0.1.0/.claude/settings.json +18 -0
  2. hermetic_agent-0.1.0/.dockerignore +10 -0
  3. hermetic_agent-0.1.0/.gitattributes +3 -0
  4. hermetic_agent-0.1.0/.githooks/pre-commit +4 -0
  5. hermetic_agent-0.1.0/.github/CODEOWNERS +12 -0
  6. hermetic_agent-0.1.0/.github/dependabot.yml +33 -0
  7. hermetic_agent-0.1.0/.github/workflows/ci.yml +70 -0
  8. hermetic_agent-0.1.0/.github/workflows/code-check-pin.yml +149 -0
  9. hermetic_agent-0.1.0/.github/workflows/code-check.yml +39 -0
  10. hermetic_agent-0.1.0/.github/workflows/release.yml +112 -0
  11. hermetic_agent-0.1.0/.github/workflows/security.yml +61 -0
  12. hermetic_agent-0.1.0/.gitignore +230 -0
  13. hermetic_agent-0.1.0/CLAUDE.md +40 -0
  14. hermetic_agent-0.1.0/CONTRIBUTING.md +31 -0
  15. hermetic_agent-0.1.0/LICENSE +21 -0
  16. hermetic_agent-0.1.0/PKG-INFO +100 -0
  17. hermetic_agent-0.1.0/README.md +71 -0
  18. hermetic_agent-0.1.0/docker/Dockerfile +22 -0
  19. hermetic_agent-0.1.0/docker/docker-compose.yml +18 -0
  20. hermetic_agent-0.1.0/docs/architecture.md +154 -0
  21. hermetic_agent-0.1.0/docs/writing-sinks.md +93 -0
  22. hermetic_agent-0.1.0/examples/petclinic/LICENSE +201 -0
  23. hermetic_agent-0.1.0/examples/petclinic/README.md +36 -0
  24. hermetic_agent-0.1.0/examples/petclinic/docs/architecture.md +21 -0
  25. hermetic_agent-0.1.0/examples/petclinic/expected/dependencies.json +19 -0
  26. hermetic_agent-0.1.0/examples/petclinic/expected/docker-compose.hermetic.yml +26 -0
  27. hermetic_agent-0.1.0/examples/petclinic/openapi.yml +2392 -0
  28. hermetic_agent-0.1.0/examples/sockshop/LICENSE +201 -0
  29. hermetic_agent-0.1.0/examples/sockshop/README.md +52 -0
  30. hermetic_agent-0.1.0/examples/sockshop/docs/architecture.md +23 -0
  31. hermetic_agent-0.1.0/examples/sockshop/expected/carts-stubs.json +86 -0
  32. hermetic_agent-0.1.0/examples/sockshop/expected/dependencies.json +52 -0
  33. hermetic_agent-0.1.0/examples/sockshop/expected/docker-compose.hermetic.yml +64 -0
  34. hermetic_agent-0.1.0/examples/sockshop/expected/payment-stubs.json +48 -0
  35. hermetic_agent-0.1.0/examples/sockshop/expected/user-stubs.json +446 -0
  36. hermetic_agent-0.1.0/examples/sockshop/specs/carts.json +197 -0
  37. hermetic_agent-0.1.0/examples/sockshop/specs/orders.json +360 -0
  38. hermetic_agent-0.1.0/examples/sockshop/specs/payment.json +102 -0
  39. hermetic_agent-0.1.0/examples/sockshop/specs/user.json +755 -0
  40. hermetic_agent-0.1.0/pyproject.toml +84 -0
  41. hermetic_agent-0.1.0/scripts/check.sh +27 -0
  42. hermetic_agent-0.1.0/scripts/install-git-hooks.sh +18 -0
  43. hermetic_agent-0.1.0/src/hermetic/__init__.py +3 -0
  44. hermetic_agent-0.1.0/src/hermetic/agent/__init__.py +8 -0
  45. hermetic_agent-0.1.0/src/hermetic/agent/claude.py +145 -0
  46. hermetic_agent-0.1.0/src/hermetic/agent/infer.py +141 -0
  47. hermetic_agent-0.1.0/src/hermetic/agent/prompt.py +15 -0
  48. hermetic_agent-0.1.0/src/hermetic/cli.py +605 -0
  49. hermetic_agent-0.1.0/src/hermetic/diffing/__init__.py +23 -0
  50. hermetic_agent-0.1.0/src/hermetic/diffing/manifest.py +112 -0
  51. hermetic_agent-0.1.0/src/hermetic/diffing/plan.py +67 -0
  52. hermetic_agent-0.1.0/src/hermetic/discover/__init__.py +46 -0
  53. hermetic_agent-0.1.0/src/hermetic/discover/engine.py +140 -0
  54. hermetic_agent-0.1.0/src/hermetic/discover/hints.py +59 -0
  55. hermetic_agent-0.1.0/src/hermetic/discover/infer.py +63 -0
  56. hermetic_agent-0.1.0/src/hermetic/discover/models.py +57 -0
  57. hermetic_agent-0.1.0/src/hermetic/discover/store.py +62 -0
  58. hermetic_agent-0.1.0/src/hermetic/execute/__init__.py +88 -0
  59. hermetic_agent-0.1.0/src/hermetic/execute/plugin.py +293 -0
  60. hermetic_agent-0.1.0/src/hermetic/generate/__init__.py +18 -0
  61. hermetic_agent-0.1.0/src/hermetic/generate/author.py +33 -0
  62. hermetic_agent-0.1.0/src/hermetic/generate/suite.py +219 -0
  63. hermetic_agent-0.1.0/src/hermetic/generate/validate.py +280 -0
  64. hermetic_agent-0.1.0/src/hermetic/history/__init__.py +47 -0
  65. hermetic_agent-0.1.0/src/hermetic/history/file_store.py +265 -0
  66. hermetic_agent-0.1.0/src/hermetic/history/http_store.py +128 -0
  67. hermetic_agent-0.1.0/src/hermetic/history/models.py +125 -0
  68. hermetic_agent-0.1.0/src/hermetic/history/store.py +56 -0
  69. hermetic_agent-0.1.0/src/hermetic/ingest/__init__.py +49 -0
  70. hermetic_agent-0.1.0/src/hermetic/ingest/docs.py +112 -0
  71. hermetic_agent-0.1.0/src/hermetic/ingest/errors.py +5 -0
  72. hermetic_agent-0.1.0/src/hermetic/ingest/models.py +74 -0
  73. hermetic_agent-0.1.0/src/hermetic/ingest/openapi.py +459 -0
  74. hermetic_agent-0.1.0/src/hermetic/ingest/swagger2.py +357 -0
  75. hermetic_agent-0.1.0/src/hermetic/net.py +9 -0
  76. hermetic_agent-0.1.0/src/hermetic/provision/__init__.py +39 -0
  77. hermetic_agent-0.1.0/src/hermetic/provision/compose.py +141 -0
  78. hermetic_agent-0.1.0/src/hermetic/provision/images.py +31 -0
  79. hermetic_agent-0.1.0/src/hermetic/provision/stack.py +340 -0
  80. hermetic_agent-0.1.0/src/hermetic/provision/stubs.py +267 -0
  81. hermetic_agent-0.1.0/src/hermetic/provision/validate.py +391 -0
  82. hermetic_agent-0.1.0/src/hermetic/publish/__init__.py +25 -0
  83. hermetic_agent-0.1.0/src/hermetic/publish/archive.py +128 -0
  84. hermetic_agent-0.1.0/src/hermetic/publish/github_pr.py +364 -0
  85. hermetic_agent-0.1.0/src/hermetic/publish/publishers.py +67 -0
  86. hermetic_agent-0.1.0/src/hermetic/py.typed +0 -0
  87. hermetic_agent-0.1.0/src/hermetic/redact.py +285 -0
  88. hermetic_agent-0.1.0/src/hermetic/report/__init__.py +30 -0
  89. hermetic_agent-0.1.0/src/hermetic/report/curl.py +44 -0
  90. hermetic_agent-0.1.0/src/hermetic/report/html_sink.py +66 -0
  91. hermetic_agent-0.1.0/src/hermetic/report/json_sink.py +17 -0
  92. hermetic_agent-0.1.0/src/hermetic/report/markdown.py +86 -0
  93. hermetic_agent-0.1.0/src/hermetic/report/sinks.py +68 -0
  94. hermetic_agent-0.1.0/src/hermetic/runner.py +67 -0
  95. hermetic_agent-0.1.0/src/hermetic/service.py +45 -0
  96. hermetic_agent-0.1.0/src/hermetic/web/__init__.py +5 -0
  97. hermetic_agent-0.1.0/src/hermetic/web/app.py +220 -0
  98. hermetic_agent-0.1.0/src/hermetic/web/static/app.js +379 -0
  99. hermetic_agent-0.1.0/src/hermetic/web/static/favicon.svg +5 -0
  100. hermetic_agent-0.1.0/src/hermetic/web/static/index.html +18 -0
  101. hermetic_agent-0.1.0/src/hermetic/web/static/style.css +328 -0
  102. hermetic_agent-0.1.0/tests/__init__.py +0 -0
  103. hermetic_agent-0.1.0/tests/conftest.py +97 -0
  104. hermetic_agent-0.1.0/tests/factories.py +35 -0
  105. hermetic_agent-0.1.0/tests/fakes.py +57 -0
  106. hermetic_agent-0.1.0/tests/fixtures/compose/all-kinds.yml +109 -0
  107. hermetic_agent-0.1.0/tests/fixtures/conduit/LICENSE +28 -0
  108. hermetic_agent-0.1.0/tests/fixtures/conduit/README.md +14 -0
  109. hermetic_agent-0.1.0/tests/fixtures/conduit/docs/architecture.md +23 -0
  110. hermetic_agent-0.1.0/tests/fixtures/conduit/expected/dependencies.json +41 -0
  111. hermetic_agent-0.1.0/tests/fixtures/conduit/expected/docker-compose.hermetic.yml +62 -0
  112. hermetic_agent-0.1.0/tests/fixtures/conduit/expected/mail-stubs.json +59 -0
  113. hermetic_agent-0.1.0/tests/fixtures/conduit/mail-openapi.yml +62 -0
  114. hermetic_agent-0.1.0/tests/fixtures/conduit/openapi.yml +926 -0
  115. hermetic_agent-0.1.0/tests/fixtures/petstore/README.md +6 -0
  116. hermetic_agent-0.1.0/tests/fixtures/petstore/openapi.json +1 -0
  117. hermetic_agent-0.1.0/tests/integration/__init__.py +0 -0
  118. hermetic_agent-0.1.0/tests/integration/helpers.py +28 -0
  119. hermetic_agent-0.1.0/tests/integration/test_conduit_docker.py +68 -0
  120. hermetic_agent-0.1.0/tests/integration/test_stack_docker.py +82 -0
  121. hermetic_agent-0.1.0/tests/live/__init__.py +0 -0
  122. hermetic_agent-0.1.0/tests/live/test_claude_author.py +23 -0
  123. hermetic_agent-0.1.0/tests/unit/__init__.py +0 -0
  124. hermetic_agent-0.1.0/tests/unit/test_agent.py +146 -0
  125. hermetic_agent-0.1.0/tests/unit/test_cli.py +304 -0
  126. hermetic_agent-0.1.0/tests/unit/test_compose.py +740 -0
  127. hermetic_agent-0.1.0/tests/unit/test_conduit.py +108 -0
  128. hermetic_agent-0.1.0/tests/unit/test_curl.py +64 -0
  129. hermetic_agent-0.1.0/tests/unit/test_diffing.py +95 -0
  130. hermetic_agent-0.1.0/tests/unit/test_discover.py +690 -0
  131. hermetic_agent-0.1.0/tests/unit/test_execute.py +700 -0
  132. hermetic_agent-0.1.0/tests/unit/test_generate.py +396 -0
  133. hermetic_agent-0.1.0/tests/unit/test_github_pr.py +549 -0
  134. hermetic_agent-0.1.0/tests/unit/test_http_store.py +220 -0
  135. hermetic_agent-0.1.0/tests/unit/test_ingest_docs.py +211 -0
  136. hermetic_agent-0.1.0/tests/unit/test_ingest_openapi.py +867 -0
  137. hermetic_agent-0.1.0/tests/unit/test_petclinic.py +84 -0
  138. hermetic_agent-0.1.0/tests/unit/test_publish.py +419 -0
  139. hermetic_agent-0.1.0/tests/unit/test_redact.py +246 -0
  140. hermetic_agent-0.1.0/tests/unit/test_report.py +206 -0
  141. hermetic_agent-0.1.0/tests/unit/test_run_command.py +546 -0
  142. hermetic_agent-0.1.0/tests/unit/test_run_store.py +529 -0
  143. hermetic_agent-0.1.0/tests/unit/test_service.py +61 -0
  144. hermetic_agent-0.1.0/tests/unit/test_sockshop.py +137 -0
  145. hermetic_agent-0.1.0/tests/unit/test_stack.py +728 -0
  146. hermetic_agent-0.1.0/tests/unit/test_stubs.py +549 -0
  147. hermetic_agent-0.1.0/tests/unit/test_swagger2.py +630 -0
  148. hermetic_agent-0.1.0/tests/unit/test_validate.py +273 -0
  149. hermetic_agent-0.1.0/tests/unit/test_web.py +609 -0
  150. hermetic_agent-0.1.0/uv.lock +1582 -0
@@ -0,0 +1,18 @@
1
+ {
2
+ "hooks": {
3
+ "PreToolUse": [
4
+ {
5
+ "matcher": "Bash",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "if": "Bash(git commit*)",
10
+ "command": "D=\"${CLAUDE_PROJECT_DIR:-.}\"; C=\"$D/scripts/check.sh\"; if [ ! -x \"$C\" ]; then echo \"$C not found; skipping checks\" >&2; exit 0; fi; \"$C\" >&2 || { echo 'lint, format or type check failed: fix the findings above before committing' >&2; exit 2; }",
11
+ "timeout": 300,
12
+ "statusMessage": "Running ruff and mypy..."
13
+ }
14
+ ]
15
+ }
16
+ ]
17
+ }
18
+ }
@@ -0,0 +1,10 @@
1
+ .git
2
+ .github
3
+ .venv
4
+ .hermetic
5
+ .mypy_cache
6
+ .pytest_cache
7
+ .ruff_cache
8
+ __pycache__
9
+ tests
10
+ docs
@@ -0,0 +1,3 @@
1
+ # The golden tests hash and compare these files byte for byte, so a checkout must not convert them.
2
+ examples/** text eol=lf
3
+ tests/fixtures/** text eol=lf
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ # Lint, format and type-check before every commit (scripts/check.sh).
3
+ # Install with scripts/install-git-hooks.sh.
4
+ exec "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts/check.sh"
@@ -0,0 +1,12 @@
1
+ # Code owners are asked to review pull requests that touch their paths.
2
+ # It only blocks a merge if branch protection enables "Require review from Code Owners".
3
+
4
+ * @subhiandrews
5
+
6
+ # Paths that run with elevated trust: the CI and release workflows, the commit gates, and the
7
+ # Docker image that mounts the host Docker socket.
8
+ /.github/ @subhiandrews
9
+ /.githooks/ @subhiandrews
10
+ /.claude/settings.json @subhiandrews
11
+ /scripts/ @subhiandrews
12
+ /docker/ @subhiandrews
@@ -0,0 +1,33 @@
1
+ version: 2
2
+ # Every entry waits 7 days after a release is published before proposing it, so hijacked
3
+ # action tags and malicious package uploads are usually caught before they reach a PR.
4
+ updates:
5
+ # Keeps the SHA-pinned actions in .github/workflows current.
6
+ - package-ecosystem: github-actions
7
+ directory: /
8
+ schedule:
9
+ interval: weekly
10
+ cooldown:
11
+ default-days: 7
12
+ groups:
13
+ actions:
14
+ patterns: ["*"]
15
+
16
+ # Keeps the digest-pinned base images in docker/Dockerfile current.
17
+ - package-ecosystem: docker
18
+ directory: /docker
19
+ schedule:
20
+ interval: weekly
21
+ cooldown:
22
+ default-days: 7
23
+
24
+ # Keeps uv.lock (the image's runtime dependencies and the dev tools) current.
25
+ - package-ecosystem: uv
26
+ directory: /
27
+ schedule:
28
+ interval: weekly
29
+ cooldown:
30
+ default-days: 7
31
+ groups:
32
+ python:
33
+ patterns: ["*"]
@@ -0,0 +1,70 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+ workflow_call: # reused by release.yml as the gate before publishing
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ python-version: ["3.12", "3.13"]
18
+ steps:
19
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
20
+ with:
21
+ persist-credentials: false
22
+ - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+ - run: uv sync --locked --group dev
26
+ - run: uv run ruff check .
27
+ - run: uv run ruff format --check .
28
+ - run: uv run mypy
29
+ - run: uv run pytest --cov --cov-report=term-missing
30
+
31
+ integration:
32
+ # Starts real containers (Postgres, MySQL, Redis, Mongo, WireMock) from the generated compose
33
+ # files and talks to them. Needs the Docker daemon the runner already has.
34
+ runs-on: ubuntu-latest
35
+ timeout-minutes: 20
36
+ steps:
37
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
38
+ with:
39
+ persist-credentials: false
40
+ - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
41
+ with:
42
+ python-version: "3.12"
43
+ - run: uv sync --locked --group dev
44
+ - name: Pull the images the tests start, retried so a registry hiccup is not a test failure
45
+ run: |
46
+ images="$(uv run python -c 'from hermetic.provision import APPROVED_IMAGES; print("\n".join(sorted(APPROVED_IMAGES)))')"
47
+ for image in $images; do
48
+ for attempt in 1 2 3; do
49
+ docker pull --quiet "$image" && break
50
+ [ "$attempt" = 3 ] && exit 1
51
+ sleep 10
52
+ done
53
+ done
54
+ - run: uv run pytest -m integration --no-cov
55
+
56
+ docker:
57
+ runs-on: ubuntu-latest
58
+ steps:
59
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
60
+ with:
61
+ persist-credentials: false
62
+ - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
63
+ - uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
64
+ with:
65
+ context: .
66
+ file: docker/Dockerfile
67
+ push: false
68
+ tags: hermetic:ci
69
+ cache-from: type=gha
70
+ cache-to: type=gha,mode=max
@@ -0,0 +1,149 @@
1
+ name: code-check-pin
2
+
3
+ # Opens a draft PR when `code-check-ref` in code-check.yml is behind the newest code-check release
4
+ # tag. It never merges anything: review the draft, then mark it ready and merge it.
5
+ #
6
+ # The PR is a draft on purpose. code-check.yml skips drafts, so a new upstream release does not run
7
+ # with this repository's CLAUDE_CODE_OAUTH_TOKEN until a maintainer has looked at it and marked
8
+ # the PR ready. The pin is written as the release's commit SHA plus its tag (`<sha> # v1.2.3`), so
9
+ # the diff shows exactly what will run and a tag moved later cannot change it.
10
+ on:
11
+ schedule:
12
+ # 06:00, 12:00 and 18:00 Pacific Standard Time (UTC-8). Cron is UTC only, so on the clock
13
+ # these run an hour later in summer (Pacific Daylight Time). Runs can start a few minutes late.
14
+ - cron: "0 2,14,20 * * *"
15
+ workflow_dispatch:
16
+
17
+ permissions: {}
18
+
19
+ concurrency:
20
+ group: code-check-pin
21
+ cancel-in-progress: false
22
+
23
+ jobs:
24
+ pin:
25
+ runs-on: ubuntu-latest
26
+ timeout-minutes: 10
27
+ permissions:
28
+ contents: read
29
+ env:
30
+ SOURCE: subhiandrews/codecheck
31
+ BRANCH: bot/code-check-pin
32
+ steps:
33
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
34
+ with:
35
+ ref: main
36
+ persist-credentials: false
37
+
38
+ - name: Bump the pin when a newer release exists
39
+ id: bump
40
+ env:
41
+ GH_TOKEN: ${{ github.token }} # read-only: lists the public tags of the source repository
42
+ run: |
43
+ set -euo pipefail
44
+ workflow=.github/workflows/code-check.yml
45
+ tag_re='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$'
46
+
47
+ # The pin is a tag (`v1.2.3`) or a commit SHA followed by its tag (`<sha> # v1.2.3`).
48
+ line="$(grep -E '^[[:space:]]*code-check-ref:' "$workflow" | head -n1)"
49
+ value="$(sed -E 's/^[[:space:]]*code-check-ref:[[:space:]]*([^[:space:]#]+).*$/\1/' <<<"$line")"
50
+ commented="$(sed -nE 's/^[^#]*#[[:space:]]*(v[^[:space:]]+).*$/\1/p' <<<"$line")"
51
+ if grep -qE "$tag_re" <<<"$value"; then current="$value"; else current="$commented"; fi
52
+
53
+ # A failed API call (rate limit, outage, wrong SOURCE) must fail the job, not pass
54
+ # silently, so it is not swallowed: only "no tag matched" is tolerated below.
55
+ tags="$(gh api "repos/${SOURCE}/tags" --paginate --jq '.[] | "\(.name) \(.commit.sha)"')"
56
+ newest="$(awk '{print $1}' <<<"$tags" | grep -E "$tag_re" | sort -V | tail -n1 || true)"
57
+ sha="$(awk -v tag="$newest" '$1 == tag {print $2}' <<<"$tags")"
58
+ echo "pinned: ${current:-none}, newest: ${newest:-none} (${sha:-no commit})"
59
+
60
+ action=none
61
+ if ! grep -qE "$tag_re" <<<"$current"; then
62
+ echo "::notice::the pin is neither a vX.Y.Z tag nor '<sha> # vX.Y.Z', so it is left alone"
63
+ elif [ -z "$newest" ]; then
64
+ echo "::warning::no release tags found in ${SOURCE}"
65
+ elif ! grep -qE '^[0-9a-f]{40}$' <<<"$sha"; then
66
+ echo "::error::could not resolve ${newest} to a commit SHA"
67
+ exit 1
68
+ elif [ "$current" != "$newest" ] && [ "$(printf '%s\n%s\n' "$current" "$newest" | sort -V | tail -n1)" = "$newest" ]; then
69
+ # only a strictly newer tag replaces the pin, so this can never downgrade it
70
+ sed -i -E "s|^([[:space:]]*code-check-ref:[[:space:]]*).*$|\1${sha} # ${newest}|" "$workflow"
71
+ action=bump
72
+ fi
73
+ {
74
+ echo "action=$action"
75
+ echo "from=$current"
76
+ echo "to=$newest"
77
+ echo "sha=$sha"
78
+ } >> "$GITHUB_OUTPUT"
79
+
80
+ - name: Commit, push and open or update the draft PR
81
+ if: steps.bump.outputs.action == 'bump'
82
+ env:
83
+ # A fine-grained PAT limited to THIS repository, with Contents, Pull requests
84
+ # and Workflows write. It is the owner's personal token, so the bot's pushes and PRs are made
85
+ # as that account; a classic PAT or one covering every repository would give this scheduled
86
+ # job write access to all of them. The default GITHUB_TOKEN cannot push changes under
87
+ # .github/workflows, and a PR it opens would not trigger CI.
88
+ GH_TOKEN: ${{ secrets.GH_TOKEN_PERSONAL }}
89
+ REPO: ${{ github.repository }}
90
+ FROM: ${{ steps.bump.outputs.from }}
91
+ TO: ${{ steps.bump.outputs.to }}
92
+ SHA: ${{ steps.bump.outputs.sha }}
93
+ run: |
94
+ set -euo pipefail
95
+ if [ -z "$GH_TOKEN" ]; then
96
+ echo "::error::A bump needs the repository secret GH_TOKEN_PERSONAL (a fine-grained PAT for this repository only, with Contents, Pull requests and Workflows write)."
97
+ exit 1
98
+ fi
99
+ # Fail closed on classic PATs (ghp_), which cannot be limited to one repository.
100
+ case "$GH_TOKEN" in
101
+ github_pat_*) ;;
102
+ *) echo "::error::GH_TOKEN_PERSONAL must be a fine-grained PAT (github_pat_...), not a classic PAT."; exit 1 ;;
103
+ esac
104
+ url="https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git"
105
+ git config user.name "github-actions[bot]"
106
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
107
+ git checkout -q -B "$BRANCH"
108
+ git commit -q -am "ci: pin code-check to $TO"
109
+
110
+ # Skip when the branch already holds this pin, so repeat runs do not re-run CI. Compare only
111
+ # the pin line: the tree changes whenever unrelated work merges to main.
112
+ remote_pin=""
113
+ if git fetch --quiet --depth=1 "$url" "refs/heads/$BRANCH" 2>/dev/null; then
114
+ remote_pin="$(git show FETCH_HEAD:.github/workflows/code-check.yml | grep -E '^[[:space:]]*code-check-ref:' | head -n1 || true)"
115
+ fi
116
+ local_pin="$(grep -E '^[[:space:]]*code-check-ref:' .github/workflows/code-check.yml | head -n1)"
117
+ if [ -n "$remote_pin" ] && [ "$remote_pin" = "$local_pin" ]; then
118
+ proposed="$(gh pr list --repo "$REPO" --head "$BRANCH" --state all --json number --jq length)"
119
+ if [ "$proposed" -gt 0 ]; then
120
+ echo "$TO is already proposed (open, merged or closed); nothing to do."
121
+ exit 0
122
+ fi
123
+ else
124
+ # The draft gate must hold for every new release, not only the first. A PR a maintainer
125
+ # already marked ready would run the review (and the new code-check) with the
126
+ # repository secret as soon as the push lands, so turn it back into a draft first.
127
+ open_pr="$(gh pr list --repo "$REPO" --head "$BRANCH" --state open --json number --jq '.[0].number // empty')"
128
+ if [ -n "$open_pr" ]; then
129
+ # Its own statement, so a failed lookup stops the job (set -e does not see a failed
130
+ # command substitution inside `[ ]`). Anything but "true" is treated as not a draft.
131
+ is_draft="$(gh pr view "$open_pr" --repo "$REPO" --json isDraft --jq .isDraft)"
132
+ [ "$is_draft" = "true" ] || gh pr ready "$open_pr" --repo "$REPO" --undo
133
+ fi
134
+ expect="$(git ls-remote "$url" "refs/heads/$BRANCH" | cut -f1)"
135
+ git push --force-with-lease="refs/heads/$BRANCH:$expect" "$url" "HEAD:refs/heads/$BRANCH"
136
+ fi
137
+
138
+ body="Bot-made. CI reviews pull requests with code-check \`$FROM\`; the newest release is \`$TO\` (\`$SHA\`), so this moves \`code-check-ref\` in \`.github/workflows/code-check.yml\` from \`$FROM\` to that commit.
139
+
140
+ Release: https://github.com/${SOURCE}/releases/tag/${TO}
141
+ Changes: https://github.com/${SOURCE}/compare/${FROM}...${TO}
142
+
143
+ This is a **draft** on purpose: drafts are not reviewed (code-check.yml skips them), so the new release does not run with the repository's secrets until you have read the changes above. Mark it ready for review to run it, then merge. If a newer release lands while this is open, the bot turns it back into a draft before updating it. Opened by \`.github/workflows/code-check-pin.yml\`; not auto-merged."
144
+ existing="$(gh pr list --repo "$REPO" --head "$BRANCH" --state open --json number --jq '.[0].number // empty')"
145
+ if [ -n "$existing" ]; then
146
+ gh pr edit "$existing" --repo "$REPO" --title "ci: pin code-check to $TO" --body "$body"
147
+ else
148
+ gh pr create --repo "$REPO" --base main --head "$BRANCH" --draft --title "ci: pin code-check to $TO" --body "$body"
149
+ fi
@@ -0,0 +1,39 @@
1
+ name: code-check
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, reopened, ready_for_review]
6
+
7
+ # A new push cancels the review of the previous commit.
8
+ concurrency:
9
+ group: code-check-${{ github.event.pull_request.number }}
10
+ cancel-in-progress: true
11
+
12
+ permissions:
13
+ contents: read
14
+ pull-requests: write
15
+
16
+ jobs:
17
+ review:
18
+ # Drafts are not reviewed. code-check-pin.yml opens its version-bump PRs as drafts so a new
19
+ # code-check release does not run with the repository secret until a maintainer marks the
20
+ # PR ready; this condition makes this repository enforce that, not only the action.
21
+ if: github.event.pull_request.draft == false
22
+ runs-on: ubuntu-latest
23
+ timeout-minutes: 45
24
+ env:
25
+ # Full review: every reviewer on the panel, security and performance included, no routing.
26
+ CODE_CHECK_REVIEW__FULL: "true"
27
+ CODE_CHECK_REVIEW__SECURITY: "true"
28
+ CODE_CHECK_REVIEW__PERFORMANCE: "true"
29
+ steps:
30
+ - uses: subhiandrews/code-check-action@c7ea220d8033092d50d1ff10306d84dd24d64aac # v1 (v0.1.3)
31
+ with:
32
+ code-check-ref: a50ddf4ac2511cd7d997d0dc55f44d59679f935b # v1.5.0
33
+ # Token from `claude setup-token`, stored as a repository secret.
34
+ # To bill API credits instead, pass `anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}`.
35
+ claude-code-oauth-token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
36
+ security: "true"
37
+ # A failed review shows as a red check, not a silent green one.
38
+ fail-on-error: true
39
+ # No github-token: the default GITHUB_TOKEN posts as github-actions[bot].
@@ -0,0 +1,112 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ jobs:
8
+ # Publishing is irreversible (PyPI versions cannot be re-uploaded), so nothing ships
9
+ # unless the tag matches the package version and the full CI workflow passes.
10
+ check-version:
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: read
14
+ steps:
15
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
16
+ with:
17
+ persist-credentials: false
18
+ - name: Tag must match the package version
19
+ run: |
20
+ version=$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' src/hermetic/__init__.py)
21
+ if [ -z "$version" ] || [ "v$version" != "$GITHUB_REF_NAME" ]; then
22
+ echo "::error::tag $GITHUB_REF_NAME does not match package version '$version'"
23
+ exit 1
24
+ fi
25
+
26
+ ci:
27
+ permissions:
28
+ contents: read
29
+ uses: ./.github/workflows/ci.yml
30
+
31
+ image:
32
+ needs: [check-version, ci]
33
+ runs-on: ubuntu-latest
34
+ permissions:
35
+ contents: read
36
+ packages: write
37
+ steps:
38
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
39
+ with:
40
+ persist-credentials: false
41
+ - uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
42
+ - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
43
+ - uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
44
+ with:
45
+ registry: ghcr.io
46
+ username: ${{ github.actor }}
47
+ password: ${{ secrets.GITHUB_TOKEN }}
48
+ - id: meta
49
+ uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
50
+ with:
51
+ images: ghcr.io/${{ github.repository }}
52
+ tags: |
53
+ type=semver,pattern={{version}}
54
+ type=semver,pattern={{major}}.{{minor}}
55
+ type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}
56
+ - uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
57
+ with:
58
+ context: .
59
+ file: docker/Dockerfile
60
+ platforms: linux/amd64,linux/arm64
61
+ push: true
62
+ tags: ${{ steps.meta.outputs.tags }}
63
+ labels: ${{ steps.meta.outputs.labels }}
64
+ # Own cache scope: never reuse layers written by the PR/CI docker job.
65
+ cache-from: type=gha,scope=release
66
+ cache-to: type=gha,scope=release,mode=max
67
+
68
+ # Build in a job without id-token: the build backend executes code, and must not be able
69
+ # to mint the PyPI OIDC token. The publish job only uploads the finished artifacts.
70
+ build:
71
+ needs: [check-version, ci]
72
+ runs-on: ubuntu-latest
73
+ permissions:
74
+ contents: read
75
+ steps:
76
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
77
+ with:
78
+ persist-credentials: false
79
+ - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
80
+ with: { enable-cache: false } # never restore a cache written by CI into the publishing build
81
+ - run: uv build
82
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
83
+ with:
84
+ name: dist
85
+ path: dist/
86
+ if-no-files-found: error
87
+
88
+ pypi:
89
+ needs: build
90
+ runs-on: ubuntu-latest
91
+ environment: pypi
92
+ permissions:
93
+ id-token: write # PyPI trusted publishing
94
+ steps:
95
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
96
+ with:
97
+ name: dist
98
+ path: dist/
99
+ - uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
100
+
101
+ github-release:
102
+ needs: [image, pypi]
103
+ runs-on: ubuntu-latest
104
+ permissions:
105
+ contents: write
106
+ steps:
107
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
108
+ with:
109
+ persist-credentials: false
110
+ - run: gh release create "$GITHUB_REF_NAME" --generate-notes
111
+ env:
112
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,61 @@
1
+ name: security
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+ schedule:
8
+ - cron: "17 5 * * 1"
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ codeql:
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ contents: read
18
+ security-events: write
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ language: [python, actions]
23
+ steps:
24
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25
+ with: { persist-credentials: false }
26
+ - uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
27
+ with: { languages: "${{ matrix.language }}" }
28
+ - uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
29
+ with: { category: "/language:${{ matrix.language }}" }
30
+
31
+ dependency-review:
32
+ if: github.event_name == 'pull_request'
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
36
+ with: { persist-credentials: false }
37
+ - uses: actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec # v4
38
+ with: { fail-on-severity: moderate }
39
+
40
+ # Known-vulnerable runtime dependencies, from the lockfile. Not run on pull requests: a new
41
+ # advisory against an unchanged dependency would fail an unrelated change.
42
+ audit:
43
+ if: github.event_name != 'pull_request'
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
47
+ with: { persist-credentials: false }
48
+ - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
49
+ with: { enable-cache: false } # the release build must not restore a cache this job wrote
50
+ - run: uv export --frozen --no-dev --no-emit-project -o requirements.txt
51
+ - run: uvx 'pip-audit==2.10.1' --disable-pip -r requirements.txt
52
+
53
+ # Static analysis of the workflows themselves (injection, excessive permissions, unpinned actions).
54
+ workflows:
55
+ runs-on: ubuntu-latest
56
+ steps:
57
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
58
+ with: { persist-credentials: false }
59
+ - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
60
+ with: { enable-cache: false } # the release build must not restore a cache this job wrote
61
+ - run: uvx 'zizmor==1.32.0' --min-severity medium .github/workflows