@jesdi/skills 0.0.80 → 0.0.82
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.
- package/package.json +2 -1
- package/skills/crap-gate/launcher.sh +104 -0
- package/skills/crap-gate/run.sh +15 -75
- package/skills/crap-gate/test_launcher.py +39 -0
- package/skills/implement-spec/launcher.sh +104 -0
- package/skills/implement-spec/run.sh +10 -89
- package/skills/implement-spec/tests/test_launcher.py +138 -0
- package/skills/test-prune/SKILL.md +4 -2
- package/skills/test-prune/prune_strengthen.py +24 -12
- package/skills/test-prune/tests/test_prune_guards.py +1 -1
- package/skills/test-prune/tests/test_prune_inputs.py +10 -5
- package/skills/test-prune/tests/test_prune_strengthen.py +34 -12
- package/skills/test-weigh-in/SKILL.md +16 -0
- package/skills/test-weigh-in/dashboard.html +112 -0
- package/skills/test-weigh-in/launcher.sh +104 -0
- package/skills/test-weigh-in/rules.toml +134 -0
- package/skills/test-weigh-in/run.sh +21 -0
- package/skills/test-weigh-in/tests/brittle_repo.py +79 -0
- package/skills/test-weigh-in/tests/conftest.py +35 -0
- package/skills/test-weigh-in/tests/fixture_repo.py +99 -0
- package/skills/test-weigh-in/tests/kill_repo.py +87 -0
- package/skills/test-weigh-in/tests/maint_repo.py +139 -0
- package/skills/test-weigh-in/tests/map_fixture.py +56 -0
- package/skills/test-weigh-in/tests/pt_repo.py +46 -0
- package/skills/test-weigh-in/tests/red_repo.py +44 -0
- package/skills/test-weigh-in/tests/rule_repo.py +208 -0
- package/skills/test-weigh-in/tests/rules_fixture.py +65 -0
- package/skills/test-weigh-in/tests/smell_repo.py +138 -0
- package/skills/test-weigh-in/tests/test_brittleness.py +75 -0
- package/skills/test-weigh-in/tests/test_brittleness_history.py +168 -0
- package/skills/test-weigh-in/tests/test_coverage_run.py +201 -0
- package/skills/test-weigh-in/tests/test_coverage_value.py +76 -0
- package/skills/test-weigh-in/tests/test_dashboard_map.py +20 -0
- package/skills/test-weigh-in/tests/test_interpreters.py +115 -0
- package/skills/test-weigh-in/tests/test_kill_matrix.py +126 -0
- package/skills/test-weigh-in/tests/test_maintainability_smells.py +113 -0
- package/skills/test-weigh-in/tests/test_mutation_recovery.py +67 -0
- package/skills/test-weigh-in/tests/test_mutation_sampling.py +53 -0
- package/skills/test-weigh-in/tests/test_mutation_score.py +140 -0
- package/skills/test-weigh-in/tests/test_mutation_stale.py +30 -0
- package/skills/test-weigh-in/tests/test_mutmut_contract.py +43 -0
- package/skills/test-weigh-in/tests/test_ruff_pt_smells.py +45 -0
- package/skills/test-weigh-in/tests/test_runs.py +156 -0
- package/skills/test-weigh-in/tests/test_score.py +26 -0
- package/skills/test-weigh-in/tests/test_scoring.py +154 -0
- package/skills/test-weigh-in/tests/test_smell_rules.py +96 -0
- package/skills/test-weigh-in/tests/test_smells.py +71 -0
- package/skills/test-weigh-in/tests/test_walking_skeleton.py +91 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/demo/__init__.py +0 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/demo/board.py +2 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/demo/config.py +2 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/pyproject.toml +8 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_board.py +19 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_config.py +19 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_parser.py +19 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_render.py +19 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_report.py +17 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_session.py +19 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_store.py +17 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/tests/test_sync.py +17 -0
- package/skills/test-weigh-in/tests/testdata/default_repo/uv.lock +1 -0
- package/skills/test-weigh-in/weigh.py +133 -0
- package/skills/test-weigh-in/weigh_coverage.py +154 -0
- package/skills/test-weigh-in/weigh_dashboard.py +72 -0
- package/skills/test-weigh-in/weigh_env.py +112 -0
- package/skills/test-weigh-in/weigh_git.py +119 -0
- package/skills/test-weigh-in/weigh_inventory.py +49 -0
- package/skills/test-weigh-in/weigh_mutation.py +190 -0
- package/skills/test-weigh-in/weigh_pytest_plugin.py +70 -0
- package/skills/test-weigh-in/weigh_ruff.py +22 -0
- package/skills/test-weigh-in/weigh_rules.py +65 -0
- package/skills/test-weigh-in/weigh_runs.py +134 -0
- package/skills/test-weigh-in/weigh_score.py +80 -0
- package/skills/test-weigh-in/weigh_smells.py +355 -0
- package/skills/test-weigh-in/weigh_snapshot.py +49 -0
- package/skills-manifest.json +13 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jesdi/skills",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.82",
|
|
4
4
|
"description": "jesdi's agent skills (content package consumed by @jesdi/skills-cli)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"crap-gate": "sh skills/crap-gate/run.sh",
|
|
34
34
|
"check": "sh scripts/check.sh",
|
|
35
35
|
"check:fast": "sh scripts/check-fast.sh",
|
|
36
|
+
"sync-launchers": "tsx scripts/sync-launchers.ts",
|
|
36
37
|
"generate-manifest": "tsx scripts/generate-manifest.ts"
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Sourced by a skill wrapper. The wrapper sets: inherited (`export -p` output
|
|
2
|
+
# taken before its first assignment), skill_dir, name (cache dir name,
|
|
3
|
+
# e.g. crap-gate), env_prefix (e.g. CRAP_GATE), prefix (message prefix), fail_code, engine (file in
|
|
4
|
+
# skill_dir; it gets the cached uv's path as <env_prefix>_UV), and optionally defines setup_failed MESSAGE (stdout on failure) and
|
|
5
|
+
# pins (space-separated requirements) with venv_key (e.g. jsonschema-4.26.0, whose
|
|
6
|
+
# first word names the package in errors): the engine then runs in a venv per pin set.
|
|
7
|
+
set -eu
|
|
8
|
+
|
|
9
|
+
fail() {
|
|
10
|
+
printf '%s: %s\n' "$prefix" "$1" >&2
|
|
11
|
+
! command -v setup_failed >/dev/null 2>&1 || setup_failed "$1"
|
|
12
|
+
exit "$fail_code"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
eval "cache_override=\${${env_prefix}_CACHE_DIR:-} offline=\${${env_prefix}_OFFLINE:-0}"
|
|
16
|
+
cache=${cache_override:-${XDG_CACHE_HOME:-$HOME/.cache}/$name}
|
|
17
|
+
case "$cache" in /*) ;; *) fail "${env_prefix}_CACHE_DIR must be an absolute path" ;; esac
|
|
18
|
+
uv_version=0.12.13
|
|
19
|
+
python_version=3.13.7
|
|
20
|
+
case "$(uname -s):$(uname -m)" in
|
|
21
|
+
Darwin:arm64|Darwin:aarch64)
|
|
22
|
+
target=aarch64-apple-darwin
|
|
23
|
+
digest=7e6ddb9316acc00f2296c82ff4d99977870ee34b2f0ddcae9444d714db9364ed ;;
|
|
24
|
+
Darwin:x86_64)
|
|
25
|
+
target=x86_64-apple-darwin
|
|
26
|
+
digest=5e287ef61cb6a9b61b3a83fef124fd143e400468a7dac794230147a810e17119 ;;
|
|
27
|
+
Linux:aarch64|Linux:arm64)
|
|
28
|
+
target=aarch64-unknown-linux-musl
|
|
29
|
+
digest=f44bc1037a17889fe562fffd2002d4ed108e499fbe68b4f022af244dc7b8244f ;;
|
|
30
|
+
Linux:x86_64)
|
|
31
|
+
target=x86_64-unknown-linux-musl
|
|
32
|
+
digest=4e2bfd0c9007b1032a50e539e965fd0a6037d87ad93ae1580d220a92d4c94098 ;;
|
|
33
|
+
*) fail 'Unsupported platform: use macOS or Linux on x86_64 or ARM64 (Windows: WSL)' ;;
|
|
34
|
+
esac
|
|
35
|
+
uv_dir=$cache/uv/$uv_version/$target
|
|
36
|
+
uv=$uv_dir/uv
|
|
37
|
+
if [ ! -x "$uv" ]; then
|
|
38
|
+
[ "$offline" != 1 ] || fail 'uv is not cached; provision this cache online first'
|
|
39
|
+
mkdir -p "$uv_dir" || fail 'Cannot create runtime cache'
|
|
40
|
+
stage=$(mktemp -d "$uv_dir/.download.XXXXXX") || fail 'Cannot create download directory'
|
|
41
|
+
trap 'rm -rf "$stage"' EXIT
|
|
42
|
+
trap 'exit "$fail_code"' HUP INT TERM
|
|
43
|
+
printf '%s: downloading uv %s\n' "$prefix" "$uv_version" >&2
|
|
44
|
+
curl --fail --location --silent --show-error --connect-timeout 15 --max-time 300 \
|
|
45
|
+
"https://github.com/astral-sh/uv/releases/download/$uv_version/uv-$target.tar.gz" \
|
|
46
|
+
-o "$stage/uv.tar.gz" || fail 'Cannot download uv; check network access and retry'
|
|
47
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
48
|
+
actual=$(sha256sum "$stage/uv.tar.gz")
|
|
49
|
+
elif command -v shasum >/dev/null 2>&1; then
|
|
50
|
+
actual=$(shasum -a 256 "$stage/uv.tar.gz")
|
|
51
|
+
else
|
|
52
|
+
fail 'SHA-256 verification requires sha256sum or shasum'
|
|
53
|
+
fi
|
|
54
|
+
[ "${actual%% *}" = "$digest" ] || fail 'uv archive checksum mismatch'
|
|
55
|
+
tar -xzf "$stage/uv.tar.gz" -C "$stage" || fail 'Cannot extract uv'
|
|
56
|
+
# Atomic publication: concurrent first runs never see a partial executable.
|
|
57
|
+
mv -f "$stage/uv-$target/uv" "$uv" || fail 'Cannot install cached uv'
|
|
58
|
+
rm -rf "$stage"
|
|
59
|
+
trap - EXIT HUP INT TERM
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
# Limit uv settings to this subprocess. Do not activate a venv or change PATH:
|
|
63
|
+
# coverage commands inherit the caller's project environment (the engine adds
|
|
64
|
+
# only the repo's own .venv/bin, when no virtualenv is active).
|
|
65
|
+
managed_uv() (
|
|
66
|
+
unset UV_NO_MANAGED_PYTHON UV_PYTHON UV_PYTHON_DOWNLOADS UV_PYTHON_BIN_DIR
|
|
67
|
+
export UV_PYTHON_INSTALL_DIR="$cache/python"
|
|
68
|
+
export UV_CACHE_DIR="$cache/uv-cache"
|
|
69
|
+
export UV_MANAGED_PYTHON=true
|
|
70
|
+
"$uv" --no-config "$@"
|
|
71
|
+
)
|
|
72
|
+
python=$(managed_uv python find --no-project --system --managed-python --no-python-downloads "$python_version" 2>/dev/null) || {
|
|
73
|
+
[ "$offline" != 1 ] || fail 'Python is not cached; provision this cache online first'
|
|
74
|
+
managed_uv python install --no-bin "$python_version" >&2 || fail 'Cannot provision Python; check network access and retry'
|
|
75
|
+
python=$(managed_uv python find --no-project --system --managed-python --no-python-downloads "$python_version") || fail 'Cannot locate managed Python'
|
|
76
|
+
}
|
|
77
|
+
if [ -n "${pins:-}" ]; then
|
|
78
|
+
venv=$cache/venv/$python_version-$venv_key
|
|
79
|
+
if [ ! -x "$venv/bin/python" ]; then
|
|
80
|
+
[ "$offline" != 1 ] || fail "${venv_key%%-*} is not cached; provision this cache online first"
|
|
81
|
+
mkdir -p "$cache/venv" || fail 'Cannot create runtime cache'
|
|
82
|
+
stage=$(mktemp -d "$cache/venv/.build.XXXXXX") || fail 'Cannot create build directory'
|
|
83
|
+
trap 'rm -rf "$stage"' EXIT
|
|
84
|
+
trap 'exit "$fail_code"' HUP INT TERM
|
|
85
|
+
# shellcheck disable=SC2086 # pins is a deliberate word list
|
|
86
|
+
managed_uv venv --quiet --python "$python" "$stage/venv" >&2 &&
|
|
87
|
+
managed_uv pip install --quiet --python "$stage/venv/bin/python" $pins >&2 ||
|
|
88
|
+
fail "Cannot provision ${venv_key%%-*}; check network access and retry"
|
|
89
|
+
# Publish by rename(2): a concurrent first run never sees a partial venv. A run that loses the
|
|
90
|
+
# race fails the rename (mv would move into the winner's directory) and uses the winner's venv.
|
|
91
|
+
[ -x "$venv/bin/python" ] || "$python" -I -c 'import os, sys; os.rename(*sys.argv[1:])' "$stage/venv" "$venv" 2>/dev/null || :
|
|
92
|
+
[ -x "$venv/bin/python" ] || fail 'Cannot install cached venv'
|
|
93
|
+
rm -rf "$stage"
|
|
94
|
+
trap - EXIT HUP INT TERM
|
|
95
|
+
fi
|
|
96
|
+
python=$venv/bin/python
|
|
97
|
+
fi
|
|
98
|
+
# Ignore Python-specific ambient settings for the engine, but preserve them for
|
|
99
|
+
# child coverage processes. -I would also remove the sibling module directory.
|
|
100
|
+
set -- "$python" -E -s "$skill_dir/$engine" "$@"
|
|
101
|
+
eval "$inherited"
|
|
102
|
+
# The engine finds the cached uv here: PATH stays the caller's.
|
|
103
|
+
export "${env_prefix}_UV=$uv"
|
|
104
|
+
exec "$@"
|
package/skills/crap-gate/run.sh
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
|
-
#
|
|
2
|
+
# Wrapper: configures the shared launcher (launcher.sh is a byte-identical copy
|
|
3
|
+
# of shared/launcher.sh).
|
|
3
4
|
set -eu
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[ "$arg" != --json ] || json=true
|
|
8
|
-
done
|
|
9
|
-
fail() {
|
|
10
|
-
printf 'crap: %s\n' "$1" >&2
|
|
11
|
-
if "$json"; then
|
|
12
|
-
printf '%s\n' '{"error":{"kind":"tooling","message":"Runtime setup failed; see stderr. Run the launcher again after resolving the setup error."}}'
|
|
13
|
-
fi
|
|
14
|
-
exit 2
|
|
15
|
-
}
|
|
5
|
+
# Snapshot the caller's environment: the launcher restores it before exec, so
|
|
6
|
+
# its settings never overwrite an inherited variable of the same name.
|
|
7
|
+
inherited=$(export -p)
|
|
16
8
|
|
|
17
9
|
# Resolve file symlinks as well as symlinked skill directories.
|
|
18
10
|
entry=$0
|
|
@@ -22,67 +14,15 @@ while [ -L "$entry" ]; do
|
|
|
22
14
|
case "$entry" in /*) ;; *) entry=$parent/$entry ;; esac
|
|
23
15
|
done
|
|
24
16
|
skill_dir=$(CDPATH= cd -- "$(dirname -- "$entry")" && pwd)
|
|
25
|
-
cache=${CRAP_GATE_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/crap-gate}
|
|
26
|
-
case "$cache" in /*) ;; *) fail 'CRAP_GATE_CACHE_DIR must be an absolute path' ;; esac
|
|
27
|
-
uv_version=0.12.13
|
|
28
|
-
python_version=3.13.7
|
|
29
|
-
case "$(uname -s):$(uname -m)" in
|
|
30
|
-
Darwin:arm64|Darwin:aarch64)
|
|
31
|
-
target=aarch64-apple-darwin
|
|
32
|
-
digest=7e6ddb9316acc00f2296c82ff4d99977870ee34b2f0ddcae9444d714db9364ed ;;
|
|
33
|
-
Darwin:x86_64)
|
|
34
|
-
target=x86_64-apple-darwin
|
|
35
|
-
digest=5e287ef61cb6a9b61b3a83fef124fd143e400468a7dac794230147a810e17119 ;;
|
|
36
|
-
Linux:aarch64|Linux:arm64)
|
|
37
|
-
target=aarch64-unknown-linux-musl
|
|
38
|
-
digest=f44bc1037a17889fe562fffd2002d4ed108e499fbe68b4f022af244dc7b8244f ;;
|
|
39
|
-
Linux:x86_64)
|
|
40
|
-
target=x86_64-unknown-linux-musl
|
|
41
|
-
digest=4e2bfd0c9007b1032a50e539e965fd0a6037d87ad93ae1580d220a92d4c94098 ;;
|
|
42
|
-
*) fail 'Unsupported platform: use macOS or Linux on x86_64 or ARM64 (Windows: WSL)' ;;
|
|
43
|
-
esac
|
|
44
|
-
uv_dir=$cache/uv/$uv_version/$target
|
|
45
|
-
uv=$uv_dir/uv
|
|
46
|
-
if [ ! -x "$uv" ]; then
|
|
47
|
-
[ "${CRAP_GATE_OFFLINE:-0}" != 1 ] || fail 'uv is not cached; provision this cache online first'
|
|
48
|
-
mkdir -p "$uv_dir" || fail 'Cannot create runtime cache'
|
|
49
|
-
stage=$(mktemp -d "$uv_dir/.download.XXXXXX") || fail 'Cannot create download directory'
|
|
50
|
-
trap 'rm -rf "$stage"' EXIT
|
|
51
|
-
trap 'exit 2' HUP INT TERM
|
|
52
|
-
printf 'crap: downloading uv %s\n' "$uv_version" >&2
|
|
53
|
-
curl --fail --location --silent --show-error --connect-timeout 15 --max-time 300 \
|
|
54
|
-
"https://github.com/astral-sh/uv/releases/download/$uv_version/uv-$target.tar.gz" \
|
|
55
|
-
-o "$stage/uv.tar.gz" || fail 'Cannot download uv; check network access and retry'
|
|
56
|
-
if command -v sha256sum >/dev/null 2>&1; then
|
|
57
|
-
actual=$(sha256sum "$stage/uv.tar.gz")
|
|
58
|
-
elif command -v shasum >/dev/null 2>&1; then
|
|
59
|
-
actual=$(shasum -a 256 "$stage/uv.tar.gz")
|
|
60
|
-
else
|
|
61
|
-
fail 'SHA-256 verification requires sha256sum or shasum'
|
|
62
|
-
fi
|
|
63
|
-
[ "${actual%% *}" = "$digest" ] || fail 'uv archive checksum mismatch'
|
|
64
|
-
tar -xzf "$stage/uv.tar.gz" -C "$stage" || fail 'Cannot extract uv'
|
|
65
|
-
# Atomic publication: concurrent first runs never see a partial executable.
|
|
66
|
-
mv -f "$stage/uv-$target/uv" "$uv" || fail 'Cannot install cached uv'
|
|
67
|
-
rm -rf "$stage"
|
|
68
|
-
trap - EXIT HUP INT TERM
|
|
69
|
-
fi
|
|
70
17
|
|
|
71
|
-
|
|
72
|
-
#
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"$
|
|
80
|
-
)
|
|
81
|
-
python=$(managed_uv python find --no-project --system --managed-python --no-python-downloads "$python_version" 2>/dev/null) || {
|
|
82
|
-
[ "${CRAP_GATE_OFFLINE:-0}" != 1 ] || fail 'Python is not cached; provision this cache online first'
|
|
83
|
-
managed_uv python install --no-bin "$python_version" >&2 || fail 'Cannot provision Python; check network access and retry'
|
|
84
|
-
python=$(managed_uv python find --no-project --system --managed-python --no-python-downloads "$python_version") || fail 'Cannot locate managed Python'
|
|
18
|
+
name=crap-gate env_prefix=CRAP_GATE prefix=crap fail_code=2 engine=crap.py
|
|
19
|
+
# No pinned venv: ignore any inherited pins/venv_key.
|
|
20
|
+
pins= venv_key=
|
|
21
|
+
json=false
|
|
22
|
+
for arg in "$@"; do
|
|
23
|
+
[ "$arg" != --json ] || json=true
|
|
24
|
+
done
|
|
25
|
+
setup_failed() {
|
|
26
|
+
! "$json" || printf '%s\n' '{"error":{"kind":"tooling","message":"Runtime setup failed; see stderr. Run the launcher again after resolving the setup error."}}'
|
|
85
27
|
}
|
|
86
|
-
|
|
87
|
-
# child coverage processes. -I would also remove the sibling module directory.
|
|
88
|
-
exec "$python" -E -s "$skill_dir/crap.py" "$@"
|
|
28
|
+
. "$skill_dir/launcher.sh"
|
|
@@ -41,9 +41,48 @@ def test_bad_download_is_rejected_before_execution(tmp_path):
|
|
|
41
41
|
assert "checksum mismatch" in proc.stderr
|
|
42
42
|
assert json.loads(proc.stdout)["error"]["kind"] == "tooling"
|
|
43
43
|
assert not list((tmp_path / "cache").rglob("uv.tar.gz"))
|
|
44
|
+
assert not [f for f in (tmp_path / "cache").rglob("uv") if f.is_file()]
|
|
44
45
|
assert not list((tmp_path / "cache").rglob(".download.*"))
|
|
45
46
|
|
|
46
47
|
|
|
48
|
+
def test_launcher_copy_is_byte_identical_to_shared_launcher():
|
|
49
|
+
root = LAUNCHER.parents[2]
|
|
50
|
+
assert (LAUNCHER.parent / "launcher.sh").read_bytes() == (root / "shared/launcher.sh").read_bytes()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_first_online_run_caches_pinned_runtime_under_xdg_and_second_run_downloads_nothing(tmp_path):
|
|
54
|
+
real_curl = shutil.which("curl")
|
|
55
|
+
# Probe the network apart from the launcher, so a broken download URL or
|
|
56
|
+
# Python install fails this test instead of skipping it.
|
|
57
|
+
probe = subprocess.run([real_curl, "--silent", "--head", "--max-time", "15", "https://github.com"],
|
|
58
|
+
capture_output=True)
|
|
59
|
+
if probe.returncode != 0:
|
|
60
|
+
pytest.skip("network access to github.com is required")
|
|
61
|
+
bin_dir = tmp_path / "bin"
|
|
62
|
+
bin_dir.mkdir()
|
|
63
|
+
log = tmp_path / "curl.log"
|
|
64
|
+
curl = bin_dir / "curl"
|
|
65
|
+
curl.write_text(f'#!/bin/sh\necho "$@" >> "{log}"\nexec "{real_curl}" "$@"\n')
|
|
66
|
+
curl.chmod(0o755)
|
|
67
|
+
xdg = tmp_path / "x"
|
|
68
|
+
env = {k: v for k, v in os.environ.items() if k not in ("CRAP_GATE_CACHE_DIR", "CRAP_GATE_OFFLINE")}
|
|
69
|
+
env.update(PATH=f"{bin_dir}:{os.environ['PATH']}", XDG_CACHE_HOME=str(xdg))
|
|
70
|
+
|
|
71
|
+
def run():
|
|
72
|
+
return subprocess.run(["/bin/sh", str(LAUNCHER), "--help"], env=env, cwd=tmp_path,
|
|
73
|
+
text=True, capture_output=True, timeout=600)
|
|
74
|
+
|
|
75
|
+
first = run()
|
|
76
|
+
assert first.returncode == 0, first.stderr
|
|
77
|
+
assert [f for f in (xdg / "crap-gate/uv/0.12.13").rglob("uv") if f.is_file()]
|
|
78
|
+
assert list((xdg / "crap-gate/python").glob("*3.13.7*"))
|
|
79
|
+
log.write_text("")
|
|
80
|
+
second = run()
|
|
81
|
+
assert second.returncode == 0, second.stderr
|
|
82
|
+
assert "downloading" not in second.stderr
|
|
83
|
+
assert log.read_text() == ""
|
|
84
|
+
|
|
85
|
+
|
|
47
86
|
@pytest.fixture
|
|
48
87
|
def runtime_env():
|
|
49
88
|
cache = os.environ.get("CRAP_GATE_TEST_CACHE")
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Sourced by a skill wrapper. The wrapper sets: inherited (`export -p` output
|
|
2
|
+
# taken before its first assignment), skill_dir, name (cache dir name,
|
|
3
|
+
# e.g. crap-gate), env_prefix (e.g. CRAP_GATE), prefix (message prefix), fail_code, engine (file in
|
|
4
|
+
# skill_dir; it gets the cached uv's path as <env_prefix>_UV), and optionally defines setup_failed MESSAGE (stdout on failure) and
|
|
5
|
+
# pins (space-separated requirements) with venv_key (e.g. jsonschema-4.26.0, whose
|
|
6
|
+
# first word names the package in errors): the engine then runs in a venv per pin set.
|
|
7
|
+
set -eu
|
|
8
|
+
|
|
9
|
+
fail() {
|
|
10
|
+
printf '%s: %s\n' "$prefix" "$1" >&2
|
|
11
|
+
! command -v setup_failed >/dev/null 2>&1 || setup_failed "$1"
|
|
12
|
+
exit "$fail_code"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
eval "cache_override=\${${env_prefix}_CACHE_DIR:-} offline=\${${env_prefix}_OFFLINE:-0}"
|
|
16
|
+
cache=${cache_override:-${XDG_CACHE_HOME:-$HOME/.cache}/$name}
|
|
17
|
+
case "$cache" in /*) ;; *) fail "${env_prefix}_CACHE_DIR must be an absolute path" ;; esac
|
|
18
|
+
uv_version=0.12.13
|
|
19
|
+
python_version=3.13.7
|
|
20
|
+
case "$(uname -s):$(uname -m)" in
|
|
21
|
+
Darwin:arm64|Darwin:aarch64)
|
|
22
|
+
target=aarch64-apple-darwin
|
|
23
|
+
digest=7e6ddb9316acc00f2296c82ff4d99977870ee34b2f0ddcae9444d714db9364ed ;;
|
|
24
|
+
Darwin:x86_64)
|
|
25
|
+
target=x86_64-apple-darwin
|
|
26
|
+
digest=5e287ef61cb6a9b61b3a83fef124fd143e400468a7dac794230147a810e17119 ;;
|
|
27
|
+
Linux:aarch64|Linux:arm64)
|
|
28
|
+
target=aarch64-unknown-linux-musl
|
|
29
|
+
digest=f44bc1037a17889fe562fffd2002d4ed108e499fbe68b4f022af244dc7b8244f ;;
|
|
30
|
+
Linux:x86_64)
|
|
31
|
+
target=x86_64-unknown-linux-musl
|
|
32
|
+
digest=4e2bfd0c9007b1032a50e539e965fd0a6037d87ad93ae1580d220a92d4c94098 ;;
|
|
33
|
+
*) fail 'Unsupported platform: use macOS or Linux on x86_64 or ARM64 (Windows: WSL)' ;;
|
|
34
|
+
esac
|
|
35
|
+
uv_dir=$cache/uv/$uv_version/$target
|
|
36
|
+
uv=$uv_dir/uv
|
|
37
|
+
if [ ! -x "$uv" ]; then
|
|
38
|
+
[ "$offline" != 1 ] || fail 'uv is not cached; provision this cache online first'
|
|
39
|
+
mkdir -p "$uv_dir" || fail 'Cannot create runtime cache'
|
|
40
|
+
stage=$(mktemp -d "$uv_dir/.download.XXXXXX") || fail 'Cannot create download directory'
|
|
41
|
+
trap 'rm -rf "$stage"' EXIT
|
|
42
|
+
trap 'exit "$fail_code"' HUP INT TERM
|
|
43
|
+
printf '%s: downloading uv %s\n' "$prefix" "$uv_version" >&2
|
|
44
|
+
curl --fail --location --silent --show-error --connect-timeout 15 --max-time 300 \
|
|
45
|
+
"https://github.com/astral-sh/uv/releases/download/$uv_version/uv-$target.tar.gz" \
|
|
46
|
+
-o "$stage/uv.tar.gz" || fail 'Cannot download uv; check network access and retry'
|
|
47
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
48
|
+
actual=$(sha256sum "$stage/uv.tar.gz")
|
|
49
|
+
elif command -v shasum >/dev/null 2>&1; then
|
|
50
|
+
actual=$(shasum -a 256 "$stage/uv.tar.gz")
|
|
51
|
+
else
|
|
52
|
+
fail 'SHA-256 verification requires sha256sum or shasum'
|
|
53
|
+
fi
|
|
54
|
+
[ "${actual%% *}" = "$digest" ] || fail 'uv archive checksum mismatch'
|
|
55
|
+
tar -xzf "$stage/uv.tar.gz" -C "$stage" || fail 'Cannot extract uv'
|
|
56
|
+
# Atomic publication: concurrent first runs never see a partial executable.
|
|
57
|
+
mv -f "$stage/uv-$target/uv" "$uv" || fail 'Cannot install cached uv'
|
|
58
|
+
rm -rf "$stage"
|
|
59
|
+
trap - EXIT HUP INT TERM
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
# Limit uv settings to this subprocess. Do not activate a venv or change PATH:
|
|
63
|
+
# coverage commands inherit the caller's project environment (the engine adds
|
|
64
|
+
# only the repo's own .venv/bin, when no virtualenv is active).
|
|
65
|
+
managed_uv() (
|
|
66
|
+
unset UV_NO_MANAGED_PYTHON UV_PYTHON UV_PYTHON_DOWNLOADS UV_PYTHON_BIN_DIR
|
|
67
|
+
export UV_PYTHON_INSTALL_DIR="$cache/python"
|
|
68
|
+
export UV_CACHE_DIR="$cache/uv-cache"
|
|
69
|
+
export UV_MANAGED_PYTHON=true
|
|
70
|
+
"$uv" --no-config "$@"
|
|
71
|
+
)
|
|
72
|
+
python=$(managed_uv python find --no-project --system --managed-python --no-python-downloads "$python_version" 2>/dev/null) || {
|
|
73
|
+
[ "$offline" != 1 ] || fail 'Python is not cached; provision this cache online first'
|
|
74
|
+
managed_uv python install --no-bin "$python_version" >&2 || fail 'Cannot provision Python; check network access and retry'
|
|
75
|
+
python=$(managed_uv python find --no-project --system --managed-python --no-python-downloads "$python_version") || fail 'Cannot locate managed Python'
|
|
76
|
+
}
|
|
77
|
+
if [ -n "${pins:-}" ]; then
|
|
78
|
+
venv=$cache/venv/$python_version-$venv_key
|
|
79
|
+
if [ ! -x "$venv/bin/python" ]; then
|
|
80
|
+
[ "$offline" != 1 ] || fail "${venv_key%%-*} is not cached; provision this cache online first"
|
|
81
|
+
mkdir -p "$cache/venv" || fail 'Cannot create runtime cache'
|
|
82
|
+
stage=$(mktemp -d "$cache/venv/.build.XXXXXX") || fail 'Cannot create build directory'
|
|
83
|
+
trap 'rm -rf "$stage"' EXIT
|
|
84
|
+
trap 'exit "$fail_code"' HUP INT TERM
|
|
85
|
+
# shellcheck disable=SC2086 # pins is a deliberate word list
|
|
86
|
+
managed_uv venv --quiet --python "$python" "$stage/venv" >&2 &&
|
|
87
|
+
managed_uv pip install --quiet --python "$stage/venv/bin/python" $pins >&2 ||
|
|
88
|
+
fail "Cannot provision ${venv_key%%-*}; check network access and retry"
|
|
89
|
+
# Publish by rename(2): a concurrent first run never sees a partial venv. A run that loses the
|
|
90
|
+
# race fails the rename (mv would move into the winner's directory) and uses the winner's venv.
|
|
91
|
+
[ -x "$venv/bin/python" ] || "$python" -I -c 'import os, sys; os.rename(*sys.argv[1:])' "$stage/venv" "$venv" 2>/dev/null || :
|
|
92
|
+
[ -x "$venv/bin/python" ] || fail 'Cannot install cached venv'
|
|
93
|
+
rm -rf "$stage"
|
|
94
|
+
trap - EXIT HUP INT TERM
|
|
95
|
+
fi
|
|
96
|
+
python=$venv/bin/python
|
|
97
|
+
fi
|
|
98
|
+
# Ignore Python-specific ambient settings for the engine, but preserve them for
|
|
99
|
+
# child coverage processes. -I would also remove the sibling module directory.
|
|
100
|
+
set -- "$python" -E -s "$skill_dir/$engine" "$@"
|
|
101
|
+
eval "$inherited"
|
|
102
|
+
# The engine finds the cached uv here: PATH stays the caller's.
|
|
103
|
+
export "${env_prefix}_UV=$uv"
|
|
104
|
+
exec "$@"
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
|
-
#
|
|
2
|
+
# Wrapper: configures the shared launcher (launcher.sh is a byte-identical copy
|
|
3
|
+
# of shared/launcher.sh).
|
|
3
4
|
set -eu
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exit 3
|
|
8
|
-
}
|
|
5
|
+
# Snapshot the caller's environment: the launcher restores it before exec, so
|
|
6
|
+
# its settings never overwrite an inherited variable of the same name.
|
|
7
|
+
inherited=$(export -p)
|
|
9
8
|
|
|
10
9
|
# Resolve file symlinks as well as symlinked skill directories.
|
|
11
10
|
entry=$0
|
|
@@ -15,87 +14,9 @@ while [ -L "$entry" ]; do
|
|
|
15
14
|
case "$entry" in /*) ;; *) entry=$parent/$entry ;; esac
|
|
16
15
|
done
|
|
17
16
|
skill_dir=$(CDPATH= cd -- "$(dirname -- "$entry")" && pwd)
|
|
18
|
-
cache=${IMPLEMENT_SPEC_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/implement-spec}
|
|
19
|
-
case "$cache" in /*) ;; *) fail 'IMPLEMENT_SPEC_CACHE_DIR must be an absolute path' ;; esac
|
|
20
|
-
uv_version=0.12.13
|
|
21
|
-
python_version=3.13.7
|
|
22
|
-
case "$(uname -s):$(uname -m)" in
|
|
23
|
-
Darwin:arm64|Darwin:aarch64)
|
|
24
|
-
target=aarch64-apple-darwin
|
|
25
|
-
digest=7e6ddb9316acc00f2296c82ff4d99977870ee34b2f0ddcae9444d714db9364ed ;;
|
|
26
|
-
Darwin:x86_64)
|
|
27
|
-
target=x86_64-apple-darwin
|
|
28
|
-
digest=5e287ef61cb6a9b61b3a83fef124fd143e400468a7dac794230147a810e17119 ;;
|
|
29
|
-
Linux:aarch64|Linux:arm64)
|
|
30
|
-
target=aarch64-unknown-linux-musl
|
|
31
|
-
digest=f44bc1037a17889fe562fffd2002d4ed108e499fbe68b4f022af244dc7b8244f ;;
|
|
32
|
-
Linux:x86_64)
|
|
33
|
-
target=x86_64-unknown-linux-musl
|
|
34
|
-
digest=4e2bfd0c9007b1032a50e539e965fd0a6037d87ad93ae1580d220a92d4c94098 ;;
|
|
35
|
-
*) fail 'Unsupported platform: use macOS or Linux on x86_64 or ARM64 (Windows: WSL)' ;;
|
|
36
|
-
esac
|
|
37
|
-
uv_dir=$cache/uv/$uv_version/$target
|
|
38
|
-
uv=$uv_dir/uv
|
|
39
|
-
if [ ! -x "$uv" ]; then
|
|
40
|
-
[ "${IMPLEMENT_SPEC_OFFLINE:-0}" != 1 ] || fail 'uv is not cached; provision this cache online first'
|
|
41
|
-
mkdir -p "$uv_dir" || fail 'Cannot create runtime cache'
|
|
42
|
-
stage=$(mktemp -d "$uv_dir/.download.XXXXXX") || fail 'Cannot create download directory'
|
|
43
|
-
trap 'rm -rf "$stage"' EXIT
|
|
44
|
-
trap 'exit 3' HUP INT TERM
|
|
45
|
-
printf 'implement-spec: downloading uv %s\n' "$uv_version" >&2
|
|
46
|
-
curl --fail --location --silent --show-error --connect-timeout 15 --max-time 300 \
|
|
47
|
-
"https://github.com/astral-sh/uv/releases/download/$uv_version/uv-$target.tar.gz" \
|
|
48
|
-
-o "$stage/uv.tar.gz" || fail 'Cannot download uv; check network access and retry'
|
|
49
|
-
if command -v sha256sum >/dev/null 2>&1; then
|
|
50
|
-
actual=$(sha256sum "$stage/uv.tar.gz")
|
|
51
|
-
elif command -v shasum >/dev/null 2>&1; then
|
|
52
|
-
actual=$(shasum -a 256 "$stage/uv.tar.gz")
|
|
53
|
-
else
|
|
54
|
-
fail 'SHA-256 verification requires sha256sum or shasum'
|
|
55
|
-
fi
|
|
56
|
-
[ "${actual%% *}" = "$digest" ] || fail 'uv archive checksum mismatch'
|
|
57
|
-
tar -xzf "$stage/uv.tar.gz" -C "$stage" || fail 'Cannot extract uv'
|
|
58
|
-
# Atomic publication: concurrent first runs never see a partial executable.
|
|
59
|
-
mv -f "$stage/uv-$target/uv" "$uv" || fail 'Cannot install cached uv'
|
|
60
|
-
rm -rf "$stage"
|
|
61
|
-
trap - EXIT HUP INT TERM
|
|
62
|
-
fi
|
|
63
17
|
|
|
64
|
-
|
|
65
|
-
#
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export UV_PYTHON_INSTALL_DIR="$cache/python"
|
|
70
|
-
export UV_CACHE_DIR="$cache/uv-cache"
|
|
71
|
-
export UV_MANAGED_PYTHON=true
|
|
72
|
-
"$uv" --no-config "$@"
|
|
73
|
-
)
|
|
74
|
-
python=$(managed_uv python find --no-project --system --managed-python --no-python-downloads "$python_version" 2>/dev/null) || {
|
|
75
|
-
[ "${IMPLEMENT_SPEC_OFFLINE:-0}" != 1 ] || fail 'Python is not cached; provision this cache online first'
|
|
76
|
-
managed_uv python install --no-bin "$python_version" >&2 || fail 'Cannot provision Python; check network access and retry'
|
|
77
|
-
python=$(managed_uv python find --no-project --system --managed-python --no-python-downloads "$python_version") || fail 'Cannot locate managed Python'
|
|
78
|
-
}
|
|
79
|
-
# The one dependency (design.md): jsonschema with its closure pinned, in a venv built once per pin set.
|
|
80
|
-
jsonschema_version=4.26.0
|
|
81
|
-
venv=$cache/venv/$python_version-jsonschema-$jsonschema_version
|
|
82
|
-
if [ ! -x "$venv/bin/python" ]; then
|
|
83
|
-
[ "${IMPLEMENT_SPEC_OFFLINE:-0}" != 1 ] || fail 'jsonschema is not cached; provision this cache online first'
|
|
84
|
-
mkdir -p "$cache/venv" || fail 'Cannot create runtime cache'
|
|
85
|
-
stage=$(mktemp -d "$cache/venv/.build.XXXXXX") || fail 'Cannot create build directory'
|
|
86
|
-
trap 'rm -rf "$stage"' EXIT
|
|
87
|
-
trap 'exit 3' HUP INT TERM
|
|
88
|
-
managed_uv venv --quiet --python "$python" "$stage/venv" >&2 &&
|
|
89
|
-
managed_uv pip install --quiet --python "$stage/venv/bin/python" "jsonschema==$jsonschema_version" \
|
|
90
|
-
attrs==26.1.0 referencing==0.37.0 rpds-py==2026.9.1 jsonschema-specifications==2025.9.1 >&2 ||
|
|
91
|
-
fail 'Cannot provision jsonschema; check network access and retry'
|
|
92
|
-
# Publish by rename: a concurrent first run never sees a partial venv. A run that loses the race
|
|
93
|
-
# (the rename fails, or lands inside the winner's directory) uses the winner's venv.
|
|
94
|
-
[ -x "$venv/bin/python" ] || mv "$stage/venv" "$venv" 2>/dev/null || :
|
|
95
|
-
[ -x "$venv/bin/python" ] || fail 'Cannot install cached venv'
|
|
96
|
-
rm -rf "$stage"
|
|
97
|
-
trap - EXIT HUP INT TERM
|
|
98
|
-
fi
|
|
99
|
-
# Ignore Python-specific ambient settings for the engine, but preserve them for
|
|
100
|
-
# child processes. -I would also remove the sibling module directory.
|
|
101
|
-
exec "$venv/bin/python" -E -s "$skill_dir/driver.py" "$@"
|
|
18
|
+
name=implement-spec env_prefix=IMPLEMENT_SPEC prefix=implement-spec fail_code=3 engine=driver.py
|
|
19
|
+
# The one dependency (design.md): jsonschema with its closure pinned.
|
|
20
|
+
venv_key=jsonschema-4.26.0
|
|
21
|
+
pins="jsonschema==4.26.0 attrs==26.1.0 referencing==0.37.0 rpds-py==2026.9.1 jsonschema-specifications==2025.9.1"
|
|
22
|
+
. "$skill_dir/launcher.sh"
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"""Launcher acceptance tests, through `sh run.sh` with a temporary cache seeded from a provisioned one."""
|
|
2
|
+
import os
|
|
3
|
+
import re
|
|
4
|
+
import shutil
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
import time
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
SKILL = Path(__file__).resolve().parents[1]
|
|
13
|
+
RUN = SKILL / "run.sh"
|
|
14
|
+
ROOT = SKILL.parents[1]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def setting(path, name):
|
|
18
|
+
"""A `name=value` line of a shell file: the wrapper and the launcher define the pins and the Python."""
|
|
19
|
+
return re.search(rf'^{name}="?([^"\n]*)"?$', path.read_text(), re.M).group(1)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
REQUIREMENTS = setting(RUN, "pins").split()
|
|
23
|
+
VENV = f'{setting(SKILL / "launcher.sh", "python_version")}-{setting(RUN, "venv_key")}'
|
|
24
|
+
# The dist-info names that pip writes for the pins: jsonschema-specifications==2025.9.1 → jsonschema_specifications-2025.9.1.
|
|
25
|
+
PINS = {req.replace("-", "_").replace("==", "-") for req in REQUIREMENTS}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@pytest.fixture
|
|
29
|
+
def seed():
|
|
30
|
+
"""A temporary cache holding uv and Python (symlinked from a provisioned cache) but no venv."""
|
|
31
|
+
source = Path(os.environ.get("IMPLEMENT_SPEC_TEST_CACHE") or Path.home() / ".cache/implement-spec")
|
|
32
|
+
if not (source / "uv").is_dir() or not (source / "python").is_dir():
|
|
33
|
+
pytest.skip("Set IMPLEMENT_SPEC_TEST_CACHE to a cache provisioned by run.sh --help")
|
|
34
|
+
|
|
35
|
+
def make(tmp_path, name="cache", spy=None, barrier=0):
|
|
36
|
+
"""With `spy`, uv is a script that appends each `pip install` argument line to `spy`, runs the real uv, then waits until `barrier` installs have finished, so that concurrent runs reach publication together."""
|
|
37
|
+
cache = tmp_path / name
|
|
38
|
+
cache.mkdir()
|
|
39
|
+
(cache / "python").symlink_to(source / "python")
|
|
40
|
+
if spy is None:
|
|
41
|
+
(cache / "uv").symlink_to(source / "uv")
|
|
42
|
+
return cache
|
|
43
|
+
real = next((source / "uv").glob("*/*/uv"))
|
|
44
|
+
fake = cache / "uv" / real.parent.relative_to(source / "uv") / "uv"
|
|
45
|
+
fake.parent.mkdir(parents=True)
|
|
46
|
+
fake.write_text(f'''#!/bin/sh
|
|
47
|
+
case " $* " in *" pip install "*) echo "$*" >> {spy}
|
|
48
|
+
{real} "$@" || exit $?
|
|
49
|
+
echo done >> {spy}.done
|
|
50
|
+
n=0
|
|
51
|
+
while [ "$(wc -l < {spy}.done)" -lt {barrier} ] && [ $n -lt 600 ]; do sleep 0.1; n=$((n+1)); done
|
|
52
|
+
exit 0 ;; esac
|
|
53
|
+
exec {real} "$@"
|
|
54
|
+
''')
|
|
55
|
+
fake.chmod(0o755)
|
|
56
|
+
return cache
|
|
57
|
+
return make
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def launch(cache, *args, **env):
|
|
61
|
+
full = {k: v for k, v in os.environ.items() if not k.startswith("IMPLEMENT_SPEC_")}
|
|
62
|
+
full.update(IMPLEMENT_SPEC_CACHE_DIR=str(cache), **env)
|
|
63
|
+
return subprocess.run(["/bin/sh", str(RUN), *args], env=full, text=True, capture_output=True, timeout=600)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def need_network():
|
|
67
|
+
if subprocess.run([shutil.which("curl") or "curl", "--silent", "--head", "--max-time", "15", "https://pypi.org"],
|
|
68
|
+
capture_output=True).returncode != 0:
|
|
69
|
+
pytest.skip("network access to pypi.org is required")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def installed(venv):
|
|
73
|
+
site = next((venv / "lib").glob("python*/site-packages"))
|
|
74
|
+
return {p.name.removesuffix(".dist-info") for p in site.glob("*.dist-info")}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_online_run_builds_pinned_venv_and_runs_driver(tmp_path, seed):
|
|
78
|
+
need_network()
|
|
79
|
+
spy = tmp_path / "pip-install.log"
|
|
80
|
+
cache = seed(tmp_path, spy=spy)
|
|
81
|
+
proc = launch(cache, "--help")
|
|
82
|
+
assert proc.returncode == 0, proc.stderr
|
|
83
|
+
assert "usage: implement-spec" in proc.stdout
|
|
84
|
+
assert [p.name for p in (cache / "venv").iterdir()] == [VENV]
|
|
85
|
+
requested = spy.read_text().split()
|
|
86
|
+
for pin in REQUIREMENTS:
|
|
87
|
+
assert pin in requested, f"{pin} is not requested explicitly: {requested}"
|
|
88
|
+
# Equal, not a subset: a dependency that run.sh does not pin still gets installed, and fails here.
|
|
89
|
+
assert installed(cache / "venv" / VENV) == PINS
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_offline_cache_without_venv_exits_3_naming_jsonschema(tmp_path, seed):
|
|
93
|
+
cache = seed(tmp_path)
|
|
94
|
+
proc = launch(cache, "--help", IMPLEMENT_SPEC_OFFLINE="1")
|
|
95
|
+
assert proc.returncode == 3
|
|
96
|
+
assert "jsonschema is not cached" in proc.stderr
|
|
97
|
+
assert not (cache / "venv" / VENV / "bin/python").exists()
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_concurrent_first_runs_share_one_complete_venv_and_leave_no_partial(tmp_path, seed):
|
|
101
|
+
need_network()
|
|
102
|
+
runs = 4
|
|
103
|
+
cache = seed(tmp_path, spy=tmp_path / "pip-install.log", barrier=runs)
|
|
104
|
+
published = cache / "venv" / VENV
|
|
105
|
+
env = {k: v for k, v in os.environ.items() if not k.startswith("IMPLEMENT_SPEC_")}
|
|
106
|
+
env["IMPLEMENT_SPEC_CACHE_DIR"] = str(cache)
|
|
107
|
+
procs = [subprocess.Popen(["/bin/sh", str(RUN), "--help"], env=env, text=True,
|
|
108
|
+
stdout=subprocess.PIPE, stderr=subprocess.PIPE) for _ in range(runs)]
|
|
109
|
+
early = [] # a reader that sees the published venv before its packages are installed
|
|
110
|
+
while any(p.poll() is None for p in procs):
|
|
111
|
+
if (published / "bin/python").exists() and not any(published.glob("lib/python*/site-packages/jsonschema-*.dist-info")):
|
|
112
|
+
early.append("published venv has no jsonschema")
|
|
113
|
+
time.sleep(0.02)
|
|
114
|
+
assert not early, early[0]
|
|
115
|
+
results = [(p.communicate(timeout=600), p.returncode) for p in procs]
|
|
116
|
+
for (out, err), code in results:
|
|
117
|
+
assert code == 0, err
|
|
118
|
+
assert "usage: implement-spec" in out
|
|
119
|
+
assert [p.name for p in (cache / "venv").iterdir()] == [VENV]
|
|
120
|
+
assert installed(cache / "venv" / VENV) == PINS
|
|
121
|
+
assert (cache / "venv" / VENV / "bin/python").exists()
|
|
122
|
+
assert not (published / "venv").exists(), "a losing run's environment was moved inside the published venv"
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def test_crap_gate_without_pinned_packages_builds_no_venv(tmp_path, seed):
|
|
126
|
+
cache = seed(tmp_path)
|
|
127
|
+
env = dict(os.environ, CRAP_GATE_CACHE_DIR=str(cache), CRAP_GATE_OFFLINE="1")
|
|
128
|
+
proc = subprocess.run(["/bin/sh", str(ROOT / "skills/crap-gate/run.sh"), "--help"], env=env,
|
|
129
|
+
text=True, capture_output=True, timeout=120)
|
|
130
|
+
assert proc.returncode == 0, proc.stderr
|
|
131
|
+
assert not (cache / "venv").exists()
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@pytest.mark.parametrize("skill", ["implement-spec", "crap-gate"])
|
|
135
|
+
def test_launcher_copy_is_byte_identical_to_shared_launcher(skill):
|
|
136
|
+
copy = ROOT / "skills" / skill / "launcher.sh"
|
|
137
|
+
assert copy.is_file(), f"{copy} is missing"
|
|
138
|
+
assert copy.read_bytes() == (ROOT / "shared/launcher.sh").read_bytes()
|
|
@@ -138,8 +138,10 @@ when `prune` exited 1 (the status keeps that failure, so the job still goes red)
|
|
|
138
138
|
commit, or a change to a function or a created file another open item already changed: each
|
|
139
139
|
test belongs to one item, so write another item's tests as new functions. Leave the tree clean.
|
|
140
140
|
3. `strengthen-verify` rejects commits without a known trailer or outside `backend/tests/`, then
|
|
141
|
-
proves each item on a cold run:
|
|
142
|
-
head.
|
|
141
|
+
proves each item on a cold run: an item kills a named id that survived on the base and is
|
|
142
|
+
killed on the head. An item that kills at least one is proven for those ids only; the PR
|
|
143
|
+
lists the rest under "Still surviving". An item that kills none is reverted and closed: a
|
|
144
|
+
later commit for a closed item is refused.
|
|
143
145
|
When `git revert` conflicts with a later item's lines, the item's functions are removed or
|
|
144
146
|
restored instead and its created files deleted; an item that changed anything else in a file
|
|
145
147
|
still stops the run with exit 1. It
|