Skip to main content

Polyguard

A fail-closed verification gate for AI-generated code across multiple programming languages.

Polyguard discovers supported project types, checks that a real test suite is present, executes the project's test/build commands, and reports a one-word verdict by default. It reports PASS only when every detected or explicitly required language has test evidence and every configured command exits successfully.

Install

python -m pip install --upgrade polyglot-code-guard

Run

From the target repository:

polyguard verify

Normal output is exactly one verdict:

PASS

or:

FAIL

Useful diagnostic modes:

polyguard verify --details
polyguard verify --json
polyguard verify --path ./my-project --timeout 180
polyguard verify --config ./ci/polyguard.toml
polyguard --version

Exit code is 0 for PASS and 1 for FAIL. A missing project, malformed configuration, missing test suite, missing toolchain, command error, or timeout fails closed.

Configure project-specific test commands

Automatic detection is useful for conventional projects, but real repositories often use custom layouts and test runners. Put a .polyguard.toml file in the project root, or pass a file with --config.

Example:

[project]
# Every listed language is required for an overall PASS.
languages = ["python", "rust"]

[checks.python]
commands = [
  ["python3", "-m", "compileall", "-q", "src"],
  ["python3", "-m", "pytest", "-q"],
]
test_patterns = ["tests/test_*.py", "tests/**/*.py"]

[checks.rust]
commands = [["cargo", "test", "--all-targets"]]
test_patterns = ["tests/**/*.rs", "src/**/*.rs"]

Rules:

  • commands is a non-empty list of argument arrays. Commands are launched without a shell.
  • test_patterns must match at least one file inside the project root.
  • A language under [project].languages is mandatory even if automatic detection misses it.
  • A custom check overrides the built-in commands and test-file heuristic for that language.
  • Patterns containing parent-directory traversal (..) are rejected.
  • Do not use a command that merely prints success; it must execute the actual test suite.

A starter file is available as .polyguard.example.toml.

Initial built-in language support

Language Default command
Python python -m compileall, then python -m pytest
Rust cargo test --all-targets
Go go test ./...
JavaScript / TypeScript npm test; TypeScript also runs tsc --noEmit when configured
Java Maven test or Gradle test
C# dotnet test
PHP PHPUnit
Ruby RSpec or Rake test
Swift swift test
C / C++ CMake build and CTest

Automatic test evidence is detected using language-specific test names, declarations, or annotations. For unconventional frameworks, use .polyguard.toml to define the actual test commands and test file patterns.

AI coding-agent skill

The repository contains SKILL.md. Add it to the coding agent's instruction/skills directory and require the agent to run:

polyguard verify --path . --details

Agents must not claim successful verification unless the command exits 0 and returns PASS. If any language fails, the overall result is FAIL. Agents must not delete, skip, or weaken tests to obtain PASS.

Important limitations and security

Polyguard is a test execution gate, not a formal proof of correctness. PASS means the configured commands completed successfully; it does not guarantee comprehensive test coverage, correct requirements, or absence of defects. Tests can be weak or misleading. Test quality remains a separate responsibility.

The verifier executes project build scripts, package managers, and test commands. Treat repositories and dependencies as untrusted. Run them in a disposable container or VM without credentials, privileged access, or sensitive host mounts. Polyguard does not itself provide operating-system isolation.

Built-in language recognition is intentionally conservative. Use explicit configuration for monorepos, non-standard directory structures, custom test frameworks, or multiple packages in one repository.

Development

python -m pip install -e ".[test]"
python -m pytest -q
python -m build
python -m twine check dist/*

Publishing

The GitHub Actions workflow builds the distributions and publishes using PyPI Trusted Publishing. Configure the PyPI publisher for:

  • Owner: Furox-Art
  • Repository: polyglot-code-guard
  • Workflow: publish.yml
  • Environment: pypi

License

MIT

Metadata

Release files for polyglot-code-guard 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polyglot-code-guard 0.2.0
File Size Uploaded Provenance Actions
polyglot_code_guard-0.2.0.tar.gz 11.8 kB With provenance Details for polyglot_code_guard-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for polyglot-code-guard 0.2.0
File Interpreter ABI Platform Actions
polyglot_code_guard-0.2.0-py3-none-any.whl Python 3 none any Details for polyglot_code_guard-0.2.0-py3-none-any.whl

Total release size: 23.5 kB

Release files / polyglot_code_guard-0.2.0.tar.gz

Download URL polyglot_code_guard-0.2.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4517368e3368c877af297bd9c0711e069d558f384ea1bf89386b66e13514579d
BLAKE2b-256 checksum
How to use checksums
635d4f3b210af30019edc9ec6ec5bbd10db53fa3e02476ef2e6ae3fd908c1ecd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / polyglot_code_guard-0.2.0-py3-none-any.whl

Download URL polyglot_code_guard-0.2.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad3c89bd1e2385717a5c841b54035ca65563e937b04e46f8fadbee0a4bc3fe59
BLAKE2b-256 checksum
How to use checksums
126c073baf1379bb1a69a53c6c04c4e57b7504b896091427ef2a73b557de8341
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for polyglot-code-guard 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for polyglot_code_guard-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page