polyglot-code-guard 0.3.0__tar.gz → 0.4.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 (22) hide show
  1. polyglot_code_guard-0.4.0/PKG-INFO +182 -0
  2. polyglot_code_guard-0.4.0/README.md +158 -0
  3. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/pyproject.toml +10 -2
  4. polyglot_code_guard-0.4.0/src/polyglot_code_guard.egg-info/PKG-INFO +182 -0
  5. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/src/polyglot_code_guard.egg-info/SOURCES.txt +1 -0
  6. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/src/polyglot_code_guard.egg-info/requires.txt +1 -0
  7. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/src/polyguard/SKILL.md +5 -5
  8. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/src/polyguard/__init__.py +1 -1
  9. polyglot_code_guard-0.4.0/src/polyguard/runner.py +1351 -0
  10. polyglot_code_guard-0.4.0/tests/test_coverage_paths.py +843 -0
  11. polyglot_code_guard-0.4.0/tests/test_runner.py +1229 -0
  12. polyglot_code_guard-0.3.0/PKG-INFO +0 -170
  13. polyglot_code_guard-0.3.0/README.md +0 -147
  14. polyglot_code_guard-0.3.0/src/polyglot_code_guard.egg-info/PKG-INFO +0 -170
  15. polyglot_code_guard-0.3.0/src/polyguard/runner.py +0 -551
  16. polyglot_code_guard-0.3.0/tests/test_runner.py +0 -277
  17. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/LICENSE +0 -0
  18. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/setup.cfg +0 -0
  19. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/src/polyglot_code_guard.egg-info/dependency_links.txt +0 -0
  20. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/src/polyglot_code_guard.egg-info/entry_points.txt +0 -0
  21. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/src/polyglot_code_guard.egg-info/top_level.txt +0 -0
  22. {polyglot_code_guard-0.3.0 → polyglot_code_guard-0.4.0}/src/polyguard/cli.py +0 -0
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: polyglot-code-guard
3
+ Version: 0.4.0
4
+ Summary: Fail-closed, multi-language test verification for AI-generated code.
5
+ Author: Furox-Art
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Furox-Art/polyglot-code-guard
8
+ Project-URL: Repository, https://github.com/Furox-Art/polyglot-code-guard
9
+ Project-URL: Issues, https://github.com/Furox-Art/polyglot-code-guard/issues
10
+ Keywords: testing,code-verification,polyglot,ai-generated-code,quality-gate
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Software Development :: Testing
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: tomli>=2; python_version < "3.11"
20
+ Provides-Extra: test
21
+ Requires-Dist: pytest>=8.0; extra == "test"
22
+ Requires-Dist: pytest-cov>=6.0; extra == "test"
23
+ Dynamic: license-file
24
+
25
+ # Polyguard
26
+
27
+ **Fail-closed verification for AI-generated code across multiple programming languages.**
28
+
29
+ Polyguard discovers supported project types, checks for a test suite, runs the relevant build/test commands, and returns a one-word verdict by default. A passing command exit code is not enough: Polyguard also requires a positive test-success summary from a recognized runner output format.
30
+
31
+ ## Install
32
+
33
+ \`\`\`bash
34
+ python -m pip install --upgrade polyglot-code-guard
35
+ \`\`\`
36
+
37
+ ## Run
38
+
39
+ From the target repository:
40
+
41
+ \`\`\`bash
42
+ polyguard verify
43
+ \`\`\`
44
+
45
+ Default output:
46
+
47
+ \`\`\`text
48
+ PASS
49
+ \`\`\`
50
+
51
+ or:
52
+
53
+ \`\`\`text
54
+ FAIL
55
+ \`\`\`
56
+
57
+ Diagnostics and automation:
58
+
59
+ \`\`\`bash
60
+ polyguard verify --details
61
+ polyguard verify --json
62
+ polyguard verify --path ./my-project --timeout 180
63
+ polyguard verify --config ./ci/polyguard.toml
64
+ polyguard --version
65
+ \`\`\`
66
+
67
+ Exit code is **0** for PASS and **1** for FAIL. Missing tests, missing toolchains, invalid configuration, a build/test failure, timeout, or missing positive test-execution evidence returns FAIL. On timeout, Polyguard terminates the command's process group/tree to avoid leaving test-runner descendants behind. Captured output is streamed and limited to the final 256 KiB per command.
68
+
69
+ ## Built-in language support
70
+
71
+ | Language | Default build/test plan | Positive execution evidence |
72
+ | --- | --- | --- |
73
+ | Python | \`compileall\`, then \`pytest -q\` | Pytest passed-test summary |
74
+ | Rust | \`cargo test --all-targets\` | Cargo test-result summary |
75
+ | Go | \`go test -json ./...\` | Passing test events in JSON stream |
76
+ | JavaScript / TypeScript | Direct Vitest/Jest/Mocha/TAP CLI when declared, otherwise `node --test`; TypeScript also runs `tsc --noEmit` when configured | Recognized runner pass summary (including Vitest default/minimal, Jest, Mocha, and Node TAP formats) |
77
+ | Java | Maven `clean test` or Gradle `clean test` | Parsed Surefire/Gradle JUnit XML; at least one pass, zero failures |
78
+ | C# | dotnet test with a Polyguard TRX prefix | Parsed TRX counters; at least one pass, zero failures |
79
+ | PHP | PHPUnit with --log-junit | Parsed JUnit XML; at least one pass, zero failures |
80
+ | Ruby | RSpec, or Ruby's Minitest runner | RSpec/Minitest success summary |
81
+ | Swift | `swift test --parallel` | Recognized Swift Testing/XCTest runner summary with a positive passed-test count |
82
+ | C | CMake build and CTest | CTest positive test count |
83
+ | C++ | CMake build and CTest | CTest positive test count |
84
+
85
+ C and C++ are separate language identifiers in configuration. JavaScript and TypeScript share the same project plan; TypeScript type checking does not replace running tests. Project-defined npm `test` scripts are never treated as test-execution evidence.
86
+
87
+ ### Monorepos and workspaces
88
+
89
+ Polyguard recursively discovers independent package roots and runs each package in its own working directory. It also recognizes common aggregator manifests and delegates execution to the native workspace command once, avoiding duplicate child-package runs:
90
+
91
+ - Maven `<modules>` and Gradle `settings.gradle(.kts)`
92
+ - Cargo `[workspace].members`
93
+ - npm `workspaces`
94
+ - .NET solution (`.sln`) files
95
+
96
+ Only projects explicitly declared as Maven modules, Gradle includes, Cargo members, npm workspace packages, or .NET solution projects are coalesced under the aggregator root. Unlisted nested projects remain independent units. Each independently discovered project is reported separately. A failure or incomplete test report in any required project makes the overall result FAIL. For workspace aggregators, native package managers remain responsible for workspace dependency resolution and execution.
97
+
98
+ ## Configure custom test commands
99
+
100
+ For non-standard project layouts or test runners, create \`.polyguard.toml\` in the project root or pass one with \`--config\`.
101
+
102
+ \`\`\`toml
103
+ [project]
104
+ languages = ["python"]
105
+
106
+ [checks.python]
107
+ commands = [
108
+ ["python3", "-m", "compileall", "-q", "src"],
109
+ ["python3", "-m", "pytest", "-q"],
110
+ ]
111
+ test_patterns = ["tests/test_*.py", "tests/**/*.py"]
112
+ \`\`\`
113
+
114
+ Configuration fields:
115
+ - \`commands\`: non-empty argument arrays. Commands are launched without a shell.
116
+ - \`test_patterns\`: at least one matching file must exist inside the project root.
117
+
118
+ **Evidence boundary:** custom \`success_patterns\` are rejected. An arbitrary output regex can be satisfied by a dummy command and cannot establish that tests executed. Custom commands may execute for diagnostics, but they cannot establish PASS: their stdout and generated reports are not trusted execution evidence. PASS requires the exact built-in command plan for the detected language project. A custom command adapter is not currently supported.
119
+
120
+ ## Test evidence and verdict rules
121
+
122
+ A language check returns PASS only when:
123
+ 1. The project and required test suite are detected.
124
+ 2. Every required command completes successfully.
125
+ 3. The exact built-in command plan for the detected project ran; custom commands cannot establish PASS.
126
+ 4. A built-in runner summary or a freshly generated native structured test report proves that at least one test passed.
127
+ 5. No command failure or timeout occurs.
128
+
129
+ A zero-test run, an all-skipped suite, an output with no recognized success summary, inconsistent report counters, a malformed or stale native report, or a non-zero exit code returns FAIL. Java and PHP require freshly generated JUnit XML; C# requires a fresh TRX report. Swift uses a positive test count from the SwiftPM runner summary because Swift Testing does not produce a usable xUnit report in this workflow. A successful command exit alone is insufficient. C# currently targets the VSTest TRX logger contract; Microsoft.Testing.Platform projects that do not emit this TRX report fail closed until an MTP-specific adapter is configured. JSON and detailed output include passed, failed, skipped, and total counts when the runner report exposes them.
130
+
131
+ ## Integration tests
132
+
133
+ The repository includes disposable real-project fixtures for all eleven supported language identifiers, including real Java/JUnit, C#/.NET, PHP/PHPUnit, and SwiftPM/Swift Testing projects. The suite also covers mixed-language and native-workspace monorepos. Run:
134
+
135
+ \`\`\`bash
136
+ python -m pip install -e ".[test]"
137
+ python -m pytest -q
138
+ \`\`\`
139
+
140
+ Integration fixtures are created in temporary directories and run through Polyguard's actual project discovery and command execution path. Missing local toolchains are skipped by local integration tests; required CI jobs install their toolchains explicitly. The CI workflow also runs runner unit tests on Linux, Windows, and macOS, plus a native SwiftPM fixture on macOS.
141
+
142
+ ## AI coding-agent skill
143
+
144
+ The repository includes \`SKILL.md\`, also shipped in the installed package. Agents should run:
145
+
146
+ \`\`\`bash
147
+ polyguard verify --path . --details
148
+ \`\`\`
149
+
150
+ Agents must not report successful verification unless the command exits 0 and returns PASS. They must not delete, skip, or weaken tests to manufacture a passing result.
151
+
152
+ ## Important limitations and security
153
+
154
+ Polyguard is a test-execution gate, **not a formal proof of program correctness**. PASS means that the built-in command plan succeeded and positive test-pass evidence was recognized. It does not guarantee adequate test coverage, correct requirements, or absence of defects.
155
+
156
+ The verifier executes project build scripts, package managers, and tests. Treat repositories and dependencies as untrusted. Run them in a disposable container or VM without secrets, privileged access, or sensitive host mounts. Polyguard does not itself provide operating-system isolation.
157
+
158
+ Automatic language discovery is conservative. Custom frameworks can be configured for diagnostic execution, but custom commands cannot establish PASS. Only the built-in command plan currently produces trusted execution evidence. Polyguard discovers supported package manifests recursively and executes each discovered language package from its own project root. Multiple packages using the same language are reported separately; the overall result is FAIL if any package fails. A root-level .polyguard.toml applies its language configuration to each matching package, with test patterns evaluated relative to that package root. Workspace-specific dependency orchestration remains the responsibility of the native package manager.
159
+
160
+ ## Development
161
+
162
+ The CI unit-test gate requires **100% line and branch coverage** of Polyguard's own Python implementation. This measures Polyguard's code, not the test coverage of projects it verifies.
163
+
164
+ \`\`\`bash
165
+ python -m pip install -e ".[test]"
166
+ python -m pytest -q
167
+ python -m pytest -q --cov=polyguard --cov-branch --cov-report=term-missing --cov-fail-under=100
168
+ python -m build
169
+ python -m twine check dist/*
170
+ \`\`\`
171
+
172
+ ## Publishing
173
+
174
+ GitHub Actions builds the distributions and publishes with PyPI Trusted Publishing. Configure the PyPI publisher for:
175
+ - Owner: \`Furox-Art\`
176
+ - Repository: \`polyglot-code-guard\`
177
+ - Workflow: \`publish.yml\`
178
+ - Environment: \`pypi\`
179
+
180
+ ## License
181
+
182
+ MIT
@@ -0,0 +1,158 @@
1
+ # Polyguard
2
+
3
+ **Fail-closed verification for AI-generated code across multiple programming languages.**
4
+
5
+ Polyguard discovers supported project types, checks for a test suite, runs the relevant build/test commands, and returns a one-word verdict by default. A passing command exit code is not enough: Polyguard also requires a positive test-success summary from a recognized runner output format.
6
+
7
+ ## Install
8
+
9
+ \`\`\`bash
10
+ python -m pip install --upgrade polyglot-code-guard
11
+ \`\`\`
12
+
13
+ ## Run
14
+
15
+ From the target repository:
16
+
17
+ \`\`\`bash
18
+ polyguard verify
19
+ \`\`\`
20
+
21
+ Default output:
22
+
23
+ \`\`\`text
24
+ PASS
25
+ \`\`\`
26
+
27
+ or:
28
+
29
+ \`\`\`text
30
+ FAIL
31
+ \`\`\`
32
+
33
+ Diagnostics and automation:
34
+
35
+ \`\`\`bash
36
+ polyguard verify --details
37
+ polyguard verify --json
38
+ polyguard verify --path ./my-project --timeout 180
39
+ polyguard verify --config ./ci/polyguard.toml
40
+ polyguard --version
41
+ \`\`\`
42
+
43
+ Exit code is **0** for PASS and **1** for FAIL. Missing tests, missing toolchains, invalid configuration, a build/test failure, timeout, or missing positive test-execution evidence returns FAIL. On timeout, Polyguard terminates the command's process group/tree to avoid leaving test-runner descendants behind. Captured output is streamed and limited to the final 256 KiB per command.
44
+
45
+ ## Built-in language support
46
+
47
+ | Language | Default build/test plan | Positive execution evidence |
48
+ | --- | --- | --- |
49
+ | Python | \`compileall\`, then \`pytest -q\` | Pytest passed-test summary |
50
+ | Rust | \`cargo test --all-targets\` | Cargo test-result summary |
51
+ | Go | \`go test -json ./...\` | Passing test events in JSON stream |
52
+ | JavaScript / TypeScript | Direct Vitest/Jest/Mocha/TAP CLI when declared, otherwise `node --test`; TypeScript also runs `tsc --noEmit` when configured | Recognized runner pass summary (including Vitest default/minimal, Jest, Mocha, and Node TAP formats) |
53
+ | Java | Maven `clean test` or Gradle `clean test` | Parsed Surefire/Gradle JUnit XML; at least one pass, zero failures |
54
+ | C# | dotnet test with a Polyguard TRX prefix | Parsed TRX counters; at least one pass, zero failures |
55
+ | PHP | PHPUnit with --log-junit | Parsed JUnit XML; at least one pass, zero failures |
56
+ | Ruby | RSpec, or Ruby's Minitest runner | RSpec/Minitest success summary |
57
+ | Swift | `swift test --parallel` | Recognized Swift Testing/XCTest runner summary with a positive passed-test count |
58
+ | C | CMake build and CTest | CTest positive test count |
59
+ | C++ | CMake build and CTest | CTest positive test count |
60
+
61
+ C and C++ are separate language identifiers in configuration. JavaScript and TypeScript share the same project plan; TypeScript type checking does not replace running tests. Project-defined npm `test` scripts are never treated as test-execution evidence.
62
+
63
+ ### Monorepos and workspaces
64
+
65
+ Polyguard recursively discovers independent package roots and runs each package in its own working directory. It also recognizes common aggregator manifests and delegates execution to the native workspace command once, avoiding duplicate child-package runs:
66
+
67
+ - Maven `<modules>` and Gradle `settings.gradle(.kts)`
68
+ - Cargo `[workspace].members`
69
+ - npm `workspaces`
70
+ - .NET solution (`.sln`) files
71
+
72
+ Only projects explicitly declared as Maven modules, Gradle includes, Cargo members, npm workspace packages, or .NET solution projects are coalesced under the aggregator root. Unlisted nested projects remain independent units. Each independently discovered project is reported separately. A failure or incomplete test report in any required project makes the overall result FAIL. For workspace aggregators, native package managers remain responsible for workspace dependency resolution and execution.
73
+
74
+ ## Configure custom test commands
75
+
76
+ For non-standard project layouts or test runners, create \`.polyguard.toml\` in the project root or pass one with \`--config\`.
77
+
78
+ \`\`\`toml
79
+ [project]
80
+ languages = ["python"]
81
+
82
+ [checks.python]
83
+ commands = [
84
+ ["python3", "-m", "compileall", "-q", "src"],
85
+ ["python3", "-m", "pytest", "-q"],
86
+ ]
87
+ test_patterns = ["tests/test_*.py", "tests/**/*.py"]
88
+ \`\`\`
89
+
90
+ Configuration fields:
91
+ - \`commands\`: non-empty argument arrays. Commands are launched without a shell.
92
+ - \`test_patterns\`: at least one matching file must exist inside the project root.
93
+
94
+ **Evidence boundary:** custom \`success_patterns\` are rejected. An arbitrary output regex can be satisfied by a dummy command and cannot establish that tests executed. Custom commands may execute for diagnostics, but they cannot establish PASS: their stdout and generated reports are not trusted execution evidence. PASS requires the exact built-in command plan for the detected language project. A custom command adapter is not currently supported.
95
+
96
+ ## Test evidence and verdict rules
97
+
98
+ A language check returns PASS only when:
99
+ 1. The project and required test suite are detected.
100
+ 2. Every required command completes successfully.
101
+ 3. The exact built-in command plan for the detected project ran; custom commands cannot establish PASS.
102
+ 4. A built-in runner summary or a freshly generated native structured test report proves that at least one test passed.
103
+ 5. No command failure or timeout occurs.
104
+
105
+ A zero-test run, an all-skipped suite, an output with no recognized success summary, inconsistent report counters, a malformed or stale native report, or a non-zero exit code returns FAIL. Java and PHP require freshly generated JUnit XML; C# requires a fresh TRX report. Swift uses a positive test count from the SwiftPM runner summary because Swift Testing does not produce a usable xUnit report in this workflow. A successful command exit alone is insufficient. C# currently targets the VSTest TRX logger contract; Microsoft.Testing.Platform projects that do not emit this TRX report fail closed until an MTP-specific adapter is configured. JSON and detailed output include passed, failed, skipped, and total counts when the runner report exposes them.
106
+
107
+ ## Integration tests
108
+
109
+ The repository includes disposable real-project fixtures for all eleven supported language identifiers, including real Java/JUnit, C#/.NET, PHP/PHPUnit, and SwiftPM/Swift Testing projects. The suite also covers mixed-language and native-workspace monorepos. Run:
110
+
111
+ \`\`\`bash
112
+ python -m pip install -e ".[test]"
113
+ python -m pytest -q
114
+ \`\`\`
115
+
116
+ Integration fixtures are created in temporary directories and run through Polyguard's actual project discovery and command execution path. Missing local toolchains are skipped by local integration tests; required CI jobs install their toolchains explicitly. The CI workflow also runs runner unit tests on Linux, Windows, and macOS, plus a native SwiftPM fixture on macOS.
117
+
118
+ ## AI coding-agent skill
119
+
120
+ The repository includes \`SKILL.md\`, also shipped in the installed package. Agents should run:
121
+
122
+ \`\`\`bash
123
+ polyguard verify --path . --details
124
+ \`\`\`
125
+
126
+ Agents must not report successful verification unless the command exits 0 and returns PASS. They must not delete, skip, or weaken tests to manufacture a passing result.
127
+
128
+ ## Important limitations and security
129
+
130
+ Polyguard is a test-execution gate, **not a formal proof of program correctness**. PASS means that the built-in command plan succeeded and positive test-pass evidence was recognized. It does not guarantee adequate test coverage, correct requirements, or absence of defects.
131
+
132
+ The verifier executes project build scripts, package managers, and tests. Treat repositories and dependencies as untrusted. Run them in a disposable container or VM without secrets, privileged access, or sensitive host mounts. Polyguard does not itself provide operating-system isolation.
133
+
134
+ Automatic language discovery is conservative. Custom frameworks can be configured for diagnostic execution, but custom commands cannot establish PASS. Only the built-in command plan currently produces trusted execution evidence. Polyguard discovers supported package manifests recursively and executes each discovered language package from its own project root. Multiple packages using the same language are reported separately; the overall result is FAIL if any package fails. A root-level .polyguard.toml applies its language configuration to each matching package, with test patterns evaluated relative to that package root. Workspace-specific dependency orchestration remains the responsibility of the native package manager.
135
+
136
+ ## Development
137
+
138
+ The CI unit-test gate requires **100% line and branch coverage** of Polyguard's own Python implementation. This measures Polyguard's code, not the test coverage of projects it verifies.
139
+
140
+ \`\`\`bash
141
+ python -m pip install -e ".[test]"
142
+ python -m pytest -q
143
+ python -m pytest -q --cov=polyguard --cov-branch --cov-report=term-missing --cov-fail-under=100
144
+ python -m build
145
+ python -m twine check dist/*
146
+ \`\`\`
147
+
148
+ ## Publishing
149
+
150
+ GitHub Actions builds the distributions and publishes with PyPI Trusted Publishing. Configure the PyPI publisher for:
151
+ - Owner: \`Furox-Art\`
152
+ - Repository: \`polyglot-code-guard\`
153
+ - Workflow: \`publish.yml\`
154
+ - Environment: \`pypi\`
155
+
156
+ ## License
157
+
158
+ MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "polyglot-code-guard"
7
- version = "0.3.0"
7
+ version = "0.4.0"
8
8
  description = "Fail-closed, multi-language test verification for AI-generated code."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -21,7 +21,7 @@ classifiers = [
21
21
  dependencies = ["tomli>=2; python_version < '3.11'"]
22
22
 
23
23
  [project.optional-dependencies]
24
- test = ["pytest>=8.0"]
24
+ test = ["pytest>=8.0", "pytest-cov>=6.0"]
25
25
 
26
26
  [project.scripts]
27
27
  polyguard = "polyguard.cli:main"
@@ -44,3 +44,11 @@ polyguard = ["SKILL.md"]
44
44
  [tool.pytest.ini_options]
45
45
  testpaths = ["tests"]
46
46
  addopts = "-ra"
47
+
48
+ [tool.coverage.run]
49
+ branch = true
50
+ source = ["polyguard"]
51
+
52
+ [tool.coverage.report]
53
+ fail_under = 100
54
+ show_missing = true
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: polyglot-code-guard
3
+ Version: 0.4.0
4
+ Summary: Fail-closed, multi-language test verification for AI-generated code.
5
+ Author: Furox-Art
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Furox-Art/polyglot-code-guard
8
+ Project-URL: Repository, https://github.com/Furox-Art/polyglot-code-guard
9
+ Project-URL: Issues, https://github.com/Furox-Art/polyglot-code-guard/issues
10
+ Keywords: testing,code-verification,polyglot,ai-generated-code,quality-gate
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Software Development :: Testing
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: tomli>=2; python_version < "3.11"
20
+ Provides-Extra: test
21
+ Requires-Dist: pytest>=8.0; extra == "test"
22
+ Requires-Dist: pytest-cov>=6.0; extra == "test"
23
+ Dynamic: license-file
24
+
25
+ # Polyguard
26
+
27
+ **Fail-closed verification for AI-generated code across multiple programming languages.**
28
+
29
+ Polyguard discovers supported project types, checks for a test suite, runs the relevant build/test commands, and returns a one-word verdict by default. A passing command exit code is not enough: Polyguard also requires a positive test-success summary from a recognized runner output format.
30
+
31
+ ## Install
32
+
33
+ \`\`\`bash
34
+ python -m pip install --upgrade polyglot-code-guard
35
+ \`\`\`
36
+
37
+ ## Run
38
+
39
+ From the target repository:
40
+
41
+ \`\`\`bash
42
+ polyguard verify
43
+ \`\`\`
44
+
45
+ Default output:
46
+
47
+ \`\`\`text
48
+ PASS
49
+ \`\`\`
50
+
51
+ or:
52
+
53
+ \`\`\`text
54
+ FAIL
55
+ \`\`\`
56
+
57
+ Diagnostics and automation:
58
+
59
+ \`\`\`bash
60
+ polyguard verify --details
61
+ polyguard verify --json
62
+ polyguard verify --path ./my-project --timeout 180
63
+ polyguard verify --config ./ci/polyguard.toml
64
+ polyguard --version
65
+ \`\`\`
66
+
67
+ Exit code is **0** for PASS and **1** for FAIL. Missing tests, missing toolchains, invalid configuration, a build/test failure, timeout, or missing positive test-execution evidence returns FAIL. On timeout, Polyguard terminates the command's process group/tree to avoid leaving test-runner descendants behind. Captured output is streamed and limited to the final 256 KiB per command.
68
+
69
+ ## Built-in language support
70
+
71
+ | Language | Default build/test plan | Positive execution evidence |
72
+ | --- | --- | --- |
73
+ | Python | \`compileall\`, then \`pytest -q\` | Pytest passed-test summary |
74
+ | Rust | \`cargo test --all-targets\` | Cargo test-result summary |
75
+ | Go | \`go test -json ./...\` | Passing test events in JSON stream |
76
+ | JavaScript / TypeScript | Direct Vitest/Jest/Mocha/TAP CLI when declared, otherwise `node --test`; TypeScript also runs `tsc --noEmit` when configured | Recognized runner pass summary (including Vitest default/minimal, Jest, Mocha, and Node TAP formats) |
77
+ | Java | Maven `clean test` or Gradle `clean test` | Parsed Surefire/Gradle JUnit XML; at least one pass, zero failures |
78
+ | C# | dotnet test with a Polyguard TRX prefix | Parsed TRX counters; at least one pass, zero failures |
79
+ | PHP | PHPUnit with --log-junit | Parsed JUnit XML; at least one pass, zero failures |
80
+ | Ruby | RSpec, or Ruby's Minitest runner | RSpec/Minitest success summary |
81
+ | Swift | `swift test --parallel` | Recognized Swift Testing/XCTest runner summary with a positive passed-test count |
82
+ | C | CMake build and CTest | CTest positive test count |
83
+ | C++ | CMake build and CTest | CTest positive test count |
84
+
85
+ C and C++ are separate language identifiers in configuration. JavaScript and TypeScript share the same project plan; TypeScript type checking does not replace running tests. Project-defined npm `test` scripts are never treated as test-execution evidence.
86
+
87
+ ### Monorepos and workspaces
88
+
89
+ Polyguard recursively discovers independent package roots and runs each package in its own working directory. It also recognizes common aggregator manifests and delegates execution to the native workspace command once, avoiding duplicate child-package runs:
90
+
91
+ - Maven `<modules>` and Gradle `settings.gradle(.kts)`
92
+ - Cargo `[workspace].members`
93
+ - npm `workspaces`
94
+ - .NET solution (`.sln`) files
95
+
96
+ Only projects explicitly declared as Maven modules, Gradle includes, Cargo members, npm workspace packages, or .NET solution projects are coalesced under the aggregator root. Unlisted nested projects remain independent units. Each independently discovered project is reported separately. A failure or incomplete test report in any required project makes the overall result FAIL. For workspace aggregators, native package managers remain responsible for workspace dependency resolution and execution.
97
+
98
+ ## Configure custom test commands
99
+
100
+ For non-standard project layouts or test runners, create \`.polyguard.toml\` in the project root or pass one with \`--config\`.
101
+
102
+ \`\`\`toml
103
+ [project]
104
+ languages = ["python"]
105
+
106
+ [checks.python]
107
+ commands = [
108
+ ["python3", "-m", "compileall", "-q", "src"],
109
+ ["python3", "-m", "pytest", "-q"],
110
+ ]
111
+ test_patterns = ["tests/test_*.py", "tests/**/*.py"]
112
+ \`\`\`
113
+
114
+ Configuration fields:
115
+ - \`commands\`: non-empty argument arrays. Commands are launched without a shell.
116
+ - \`test_patterns\`: at least one matching file must exist inside the project root.
117
+
118
+ **Evidence boundary:** custom \`success_patterns\` are rejected. An arbitrary output regex can be satisfied by a dummy command and cannot establish that tests executed. Custom commands may execute for diagnostics, but they cannot establish PASS: their stdout and generated reports are not trusted execution evidence. PASS requires the exact built-in command plan for the detected language project. A custom command adapter is not currently supported.
119
+
120
+ ## Test evidence and verdict rules
121
+
122
+ A language check returns PASS only when:
123
+ 1. The project and required test suite are detected.
124
+ 2. Every required command completes successfully.
125
+ 3. The exact built-in command plan for the detected project ran; custom commands cannot establish PASS.
126
+ 4. A built-in runner summary or a freshly generated native structured test report proves that at least one test passed.
127
+ 5. No command failure or timeout occurs.
128
+
129
+ A zero-test run, an all-skipped suite, an output with no recognized success summary, inconsistent report counters, a malformed or stale native report, or a non-zero exit code returns FAIL. Java and PHP require freshly generated JUnit XML; C# requires a fresh TRX report. Swift uses a positive test count from the SwiftPM runner summary because Swift Testing does not produce a usable xUnit report in this workflow. A successful command exit alone is insufficient. C# currently targets the VSTest TRX logger contract; Microsoft.Testing.Platform projects that do not emit this TRX report fail closed until an MTP-specific adapter is configured. JSON and detailed output include passed, failed, skipped, and total counts when the runner report exposes them.
130
+
131
+ ## Integration tests
132
+
133
+ The repository includes disposable real-project fixtures for all eleven supported language identifiers, including real Java/JUnit, C#/.NET, PHP/PHPUnit, and SwiftPM/Swift Testing projects. The suite also covers mixed-language and native-workspace monorepos. Run:
134
+
135
+ \`\`\`bash
136
+ python -m pip install -e ".[test]"
137
+ python -m pytest -q
138
+ \`\`\`
139
+
140
+ Integration fixtures are created in temporary directories and run through Polyguard's actual project discovery and command execution path. Missing local toolchains are skipped by local integration tests; required CI jobs install their toolchains explicitly. The CI workflow also runs runner unit tests on Linux, Windows, and macOS, plus a native SwiftPM fixture on macOS.
141
+
142
+ ## AI coding-agent skill
143
+
144
+ The repository includes \`SKILL.md\`, also shipped in the installed package. Agents should run:
145
+
146
+ \`\`\`bash
147
+ polyguard verify --path . --details
148
+ \`\`\`
149
+
150
+ Agents must not report successful verification unless the command exits 0 and returns PASS. They must not delete, skip, or weaken tests to manufacture a passing result.
151
+
152
+ ## Important limitations and security
153
+
154
+ Polyguard is a test-execution gate, **not a formal proof of program correctness**. PASS means that the built-in command plan succeeded and positive test-pass evidence was recognized. It does not guarantee adequate test coverage, correct requirements, or absence of defects.
155
+
156
+ The verifier executes project build scripts, package managers, and tests. Treat repositories and dependencies as untrusted. Run them in a disposable container or VM without secrets, privileged access, or sensitive host mounts. Polyguard does not itself provide operating-system isolation.
157
+
158
+ Automatic language discovery is conservative. Custom frameworks can be configured for diagnostic execution, but custom commands cannot establish PASS. Only the built-in command plan currently produces trusted execution evidence. Polyguard discovers supported package manifests recursively and executes each discovered language package from its own project root. Multiple packages using the same language are reported separately; the overall result is FAIL if any package fails. A root-level .polyguard.toml applies its language configuration to each matching package, with test patterns evaluated relative to that package root. Workspace-specific dependency orchestration remains the responsibility of the native package manager.
159
+
160
+ ## Development
161
+
162
+ The CI unit-test gate requires **100% line and branch coverage** of Polyguard's own Python implementation. This measures Polyguard's code, not the test coverage of projects it verifies.
163
+
164
+ \`\`\`bash
165
+ python -m pip install -e ".[test]"
166
+ python -m pytest -q
167
+ python -m pytest -q --cov=polyguard --cov-branch --cov-report=term-missing --cov-fail-under=100
168
+ python -m build
169
+ python -m twine check dist/*
170
+ \`\`\`
171
+
172
+ ## Publishing
173
+
174
+ GitHub Actions builds the distributions and publishes with PyPI Trusted Publishing. Configure the PyPI publisher for:
175
+ - Owner: \`Furox-Art\`
176
+ - Repository: \`polyglot-code-guard\`
177
+ - Workflow: \`publish.yml\`
178
+ - Environment: \`pypi\`
179
+
180
+ ## License
181
+
182
+ MIT
@@ -11,4 +11,5 @@ src/polyguard/SKILL.md
11
11
  src/polyguard/__init__.py
12
12
  src/polyguard/cli.py
13
13
  src/polyguard/runner.py
14
+ tests/test_coverage_paths.py
14
15
  tests/test_runner.py
@@ -4,3 +4,4 @@ tomli>=2
4
4
 
5
5
  [test]
6
6
  pytest>=8.0
7
+ pytest-cov>=6.0
@@ -12,10 +12,10 @@ Use this skill whenever code is generated, changed, refactored, or described as
12
12
  1. Identify every language, build system, package root, and test framework touched by the change.
13
13
  2. Add requirement-based tests for normal behavior, edge cases, invalid inputs, error paths, and regressions.
14
14
  3. Run \`polyguard verify --path . --details\`.
15
- 4. For a non-standard test runner, configure explicit commands, file patterns, and a success-summary parser in \`.polyguard.toml\`.
15
+ 4. For a non-standard test runner, explicit commands and file patterns can be configured for diagnostics; custom commands cannot establish PASS until a trusted runner adapter is implemented.
16
16
  5. Run the complete configured test suite. Do not omit a detected or required language.
17
- 6. Require a positive passed-test count in recognized runner output. A successful command exit code or a test-looking filename alone is not sufficient.
18
- 7. If a command fails, a toolchain is missing, tests cannot be found, the runner reports no passing tests, execution times out, or output evidence is missing, the verdict is FAIL.
17
+ 6. Require a positive passed-test count from the exact built-in command plan. Java and PHP default checks must produce fresh JUnit XML; C# must produce a fresh TRX report. Swift must emit a positive native test-runner summary. A successful command exit code alone is not sufficient.
18
+ 7. If a command fails, a toolchain is missing, tests cannot be found, the runner reports no passing tests, execution times out (the command process tree is terminated), or output evidence is missing, the verdict is FAIL.
19
19
  8. Fix the implementation or tests and rerun all checks. Never delete, skip, weaken, or rewrite a valid test merely to obtain PASS.
20
20
  9. Retain command output and the JSON report when inspectable evidence is requested.
21
21
 
@@ -28,11 +28,11 @@ The CLI exits 0 only for PASS and 1 for FAIL. Default output is exactly one word
28
28
 
29
29
  ## Custom command trust
30
30
 
31
- A custom \`success_patterns\` entry is a trusted assertion by the repository owner about command output. It is not independent proof that the command executed real tests. Do not use a dummy command that prints a success-looking summary. Prefer built-in adapters and native test reports.
31
+ Custom \`success_patterns\` are rejected. Custom commands may execute for diagnostics, but their output and generated reports cannot establish PASS because a command can forge them. Only the exact built-in command plan for the detected project is accepted as execution evidence. Java, C#, and PHP additionally require fresh native reports; Swift uses its runner summary.
32
32
 
33
33
  ## Scope
34
34
 
35
- Built-in support: Python, Rust, Go, JavaScript/TypeScript, Java, C#, PHP, Ruby, Swift, C, and C++ with CMake/CTest. Use explicit configuration for unconventional project layouts and custom runners. Full monorepo orchestration is not implemented; run Polyguard separately from each package root.
35
+ Built-in support: Python, Rust, Go, JavaScript/TypeScript, Java, C#, PHP, Ruby, Swift, C, and C++ with CMake/CTest. Use explicit configuration for unconventional project layouts and custom runners. Polyguard discovers supported package manifests recursively, executes each language package from its own root, and reports multiple packages of the same language separately. A root-level configuration is applied to each matching package with test patterns evaluated relative to that package root. Maven modules, Gradle settings builds, Cargo workspaces, npm workspaces, and .NET solutions are delegated to their native root command once to avoid duplicate child-package execution.
36
36
 
37
37
  ## Security
38
38
 
@@ -1,3 +1,3 @@
1
1
  """Polyguard: fail-closed verification for multi-language projects."""
2
2
 
3
- __version__ = "0.3.0"
3
+ __version__ = "0.4.0"