CodeSampleX

Ejemplo

pooch 1.9.0: pooch

Muestra verificada para pypi pooch 1.9.0: pooch. El contrato se ejecutó en python 3.12 · linux debian/x64 · docker y pasó: pooch.__version__ exposes a valid…

sha256:4670ba3b3ab4820df3fb0da3f7a30fee8e4470e6b44dde8d21769bb3198f83cf

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104…
2026-09-05

Caso

HOW
Objetivo
verify pooch in pkg:pypi/pooch@1.9.0
Paquetes
Símbolos
  • pooch
Entorno
python 3.12
Creado
2026-09-05T18:42:56Z

Contrato

  1. pooch.__version__ exposes a valid release version string matching the pinned package version.
  2. pooch.os_cache returns an operating-system specific cache directory as a pathlib.Path containing the provided application namespace.
  3. pooch.file_hash computes cryptographic checksums for local files using sha256 by default and supports alternative algorithms including md5.
  4. pooch.check_version validates PEP440 version strings and replaces unreleased development version strings with the designated fallback string.
  5. pooch.check_version raises packaging.version.InvalidVersion when given an invalid version string.
  6. pooch.get_logger returns the default pooch Logger instance and supports configuring logging levels.
  7. pooch.HTTPDownloader initializes with configurable download parameters including chunk size, progress bar display, and custom request headers.
  8. pooch.DOIDownloader initializes with configurable DOI download options including chunk size and request timeout.

Archivos

  • NOTES.md
  • PROMPT.md
  • csx.json
  • pyproject.toml
  • requirements.txt
  • spec.json
  • test/contract.py

Descargar el artefacto de código fuente (tar.gz)

Código fuente

NOTES.md
# pooch Package Verification

This sample pins `pooch` 1.9.0 and verifies core module functions and classes.

The contract verifies:
- `pooch.__version__` exposes a valid release version string matching the pinned package version.
- `pooch.os_cache` returns an operating-system specific cache directory as a `pathlib.Path` containing the provided application namespace.
- `pooch.file_hash` computes cryptographic checksums for local files using sha256 by default and supports alternative algorithms including md5.
- `pooch.check_version` validates PEP440 version strings and replaces unreleased development version strings with the designated fallback string.
- `pooch.check_version` raises `packaging.version.InvalidVersion` when given an invalid version string.
- `pooch.get_logger` returns the default pooch `Logger` instance and supports configuring logging levels.
- `pooch.HTTPDownloader` initializes with configurable download parameters including chunk size, progress bar display, and custom request headers.
- `pooch.DOIDownloader` initializes with configurable DOI download options including chunk size and request timeout.
PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pooch in pkg:pypi/pooch@1.9.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/pooch@1.9.0
Demonstrate these symbols/APIs:
  - pooch

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:49db6dbea0cb0454336ef0746a19c90232f23ddc700f018bf5f845e0e71a82ab","contract":["pooch.__version__ exposes a valid release version string matching the pinned package version.","pooch.os_cache returns an operating-system specific cache directory as a pathlib.Path containing the provided application namespace.","pooch.file_hash computes cryptographic checksums for local files using sha256 by default and supports alternative algorithms including md5.","pooch.check_version validates PEP440 version strings and replaces unreleased development version strings with the designated fallback string.","pooch.check_version raises packaging.version.InvalidVersion when given an invalid version string.","pooch.get_logger returns the default pooch Logger instance and supports configuring logging levels.","pooch.HTTPDownloader initializes with configurable download parameters including chunk size, progress bar display, and custom request headers.","pooch.DOIDownloader initializes with configurable DOI download options including chunk size and request timeout."],"goal":"verify pooch in pkg:pypi/pooch@1.9.0","kind":"HOW","packages":["pkg:pypi/pooch@1.9.0"],"schemaVersion":1,"symbols":["pooch"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/pooch@1.9.0"],"schemaVersion":1,"subject":"pkg:pypi/pooch@1.9.0","symbols":["pooch"],"verifierAdapter":"python@1"}
pyproject.toml
[project]
name = "sample-pooch"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = [
    "pooch==1.9.0",
]
requirements.txt
certifi==2026.7.22
charset-normalizer==3.5.1
idna==3.19
packaging==26.3
platformdirs==4.11.7
pooch==1.9.0
requests==2.34.2
urllib3==2.7.0
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pooch in pkg:pypi/pooch@1.9.0",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/pooch@1.9.0"
  ],
  "symbols": [
    "pooch"
  ]
}
test/contract.py
import hashlib
import logging
import pathlib
import tempfile
import packaging.version
import pooch

# 1. Verify pooch.__version__
assert hasattr(pooch, "__version__"), "pooch module should export __version__"
assert "1.9.0" in pooch.__version__, f"Unexpected version string: {pooch.__version__}"

# 2. Verify pooch.os_cache
cache_path = pooch.os_cache("sample-app")
assert isinstance(cache_path, pathlib.Path), "os_cache must return a pathlib.Path"
assert "sample-app" in str(cache_path), f"os_cache path should contain project name: {cache_path}"

# 3. Verify pooch.file_hash
with tempfile.TemporaryDirectory() as tmpdir:
    test_file = pathlib.Path(tmpdir) / "test_data.bin"
    test_bytes = b"CodeSampleX offline verification payload"
    test_file.write_bytes(test_bytes)

    # Default algorithm (sha256)
    sha256_hash = pooch.file_hash(str(test_file))
    expected_sha256 = hashlib.sha256(test_bytes).hexdigest()
    assert sha256_hash == expected_sha256, f"sha256 mismatch: {sha256_hash} != {expected_sha256}"

    # Custom algorithm (md5)
    md5_hash = pooch.file_hash(str(test_file), alg="md5")
    expected_md5 = hashlib.md5(test_bytes).hexdigest()
    assert md5_hash == expected_md5, f"md5 mismatch: {md5_hash} != {expected_md5}"

# 4. Verify pooch.check_version with PEP440 compliant and dev versions
v_clean = pooch.check_version("1.9.0")
assert v_clean == "1.9.0", f"Expected '1.9.0', got {v_clean}"

v_dev = pooch.check_version("1.9.0+dev.123", fallback="main")
assert v_dev == "main", f"Expected fallback 'main', got {v_dev}"

# 5. Verify pooch.check_version raises InvalidVersion on malformed versions
try:
    pooch.check_version("invalid_format_version!!!")
    raise AssertionError("pooch.check_version should raise InvalidVersion on invalid input")
except packaging.version.InvalidVersion:
    pass

# 6. Verify pooch.get_logger
logger = pooch.get_logger()
assert isinstance(logger, logging.Logger), "get_logger must return a logging.Logger"
assert logger.name == "pooch", f"Logger name must be 'pooch', got {logger.name}"
orig_level = logger.level
try:
    logger.setLevel(logging.INFO)
    assert logger.level == logging.INFO, "Logger level should be updated"
finally:
    logger.setLevel(orig_level)

# 7. Verify pooch.HTTPDownloader
http_downloader = pooch.HTTPDownloader(chunk_size=4096, progressbar=False, headers={"User-Agent": "sample-agent"})
assert http_downloader.chunk_size == 4096, f"Expected chunk_size 4096, got {http_downloader.chunk_size}"
assert http_downloader.progressbar is False, "Expected progressbar False"
assert http_downloader.kwargs == {"headers": {"User-Agent": "sample-agent"}}, "kwargs mismatch"

# 8. Verify pooch.DOIDownloader
doi_downloader = pooch.DOIDownloader(chunk_size=8192, progressbar=False, timeout=60)
assert doi_downloader.chunk_size == 8192, f"Expected chunk_size 8192, got {doi_downloader.chunk_size}"
assert doi_downloader.progressbar is False, "Expected progressbar False"
assert doi_downloader.timeout == 60, f"Expected timeout 60, got {doi_downloader.timeout}"

print("CONTRACT PASS: pooch verified offline")

Seeder de origen

anónimo