polyglot-code-guard 0.2.0__tar.gz → 0.3.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.
- polyglot_code_guard-0.3.0/PKG-INFO +170 -0
- polyglot_code_guard-0.3.0/README.md +147 -0
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/pyproject.toml +1 -1
- polyglot_code_guard-0.3.0/src/polyglot_code_guard.egg-info/PKG-INFO +170 -0
- polyglot_code_guard-0.3.0/src/polyguard/SKILL.md +39 -0
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/src/polyguard/__init__.py +1 -1
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/src/polyguard/runner.py +168 -31
- polyglot_code_guard-0.3.0/tests/test_runner.py +277 -0
- polyglot_code_guard-0.2.0/PKG-INFO +0 -155
- polyglot_code_guard-0.2.0/README.md +0 -132
- polyglot_code_guard-0.2.0/src/polyglot_code_guard.egg-info/PKG-INFO +0 -155
- polyglot_code_guard-0.2.0/src/polyguard/SKILL.md +0 -34
- polyglot_code_guard-0.2.0/tests/test_runner.py +0 -163
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/LICENSE +0 -0
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/setup.cfg +0 -0
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/src/polyglot_code_guard.egg-info/SOURCES.txt +0 -0
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/src/polyglot_code_guard.egg-info/dependency_links.txt +0 -0
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/src/polyglot_code_guard.egg-info/entry_points.txt +0 -0
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/src/polyglot_code_guard.egg-info/requires.txt +0 -0
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/src/polyglot_code_guard.egg-info/top_level.txt +0 -0
- {polyglot_code_guard-0.2.0 → polyglot_code_guard-0.3.0}/src/polyguard/cli.py +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: polyglot-code-guard
|
|
3
|
+
Version: 0.3.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
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# Polyguard
|
|
25
|
+
|
|
26
|
+
**Fail-closed verification for AI-generated code across multiple programming languages.**
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
\`\`\`bash
|
|
33
|
+
python -m pip install --upgrade polyglot-code-guard
|
|
34
|
+
\`\`\`
|
|
35
|
+
|
|
36
|
+
## Run
|
|
37
|
+
|
|
38
|
+
From the target repository:
|
|
39
|
+
|
|
40
|
+
\`\`\`bash
|
|
41
|
+
polyguard verify
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
Default output:
|
|
45
|
+
|
|
46
|
+
\`\`\`text
|
|
47
|
+
PASS
|
|
48
|
+
\`\`\`
|
|
49
|
+
|
|
50
|
+
or:
|
|
51
|
+
|
|
52
|
+
\`\`\`text
|
|
53
|
+
FAIL
|
|
54
|
+
\`\`\`
|
|
55
|
+
|
|
56
|
+
Diagnostics and automation:
|
|
57
|
+
|
|
58
|
+
\`\`\`bash
|
|
59
|
+
polyguard verify --details
|
|
60
|
+
polyguard verify --json
|
|
61
|
+
polyguard verify --path ./my-project --timeout 180
|
|
62
|
+
polyguard verify --config ./ci/polyguard.toml
|
|
63
|
+
polyguard --version
|
|
64
|
+
\`\`\`
|
|
65
|
+
|
|
66
|
+
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.
|
|
67
|
+
|
|
68
|
+
## Built-in language support
|
|
69
|
+
|
|
70
|
+
| Language | Default build/test plan | Positive execution evidence |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| Python | \`compileall\`, then \`pytest -q\` | Pytest passed-test summary |
|
|
73
|
+
| Rust | \`cargo test --all-targets\` | Cargo test-result summary |
|
|
74
|
+
| Go | \`go test -json ./...\` | Passing test events in JSON stream |
|
|
75
|
+
| JavaScript / TypeScript | \`npm test\`; TypeScript also runs \`tsc --noEmit\` when configured | Recognized runner pass summary |
|
|
76
|
+
| Java | Maven test or Gradle test | Maven/Gradle test summary |
|
|
77
|
+
| C# | \`dotnet test\` | .NET test-runner pass summary |
|
|
78
|
+
| PHP | PHPUnit | PHPUnit success summary |
|
|
79
|
+
| Ruby | RSpec, or Ruby's Minitest runner | RSpec/Minitest success summary |
|
|
80
|
+
| Swift | \`swift test\` | Swift test-result summary |
|
|
81
|
+
| C | CMake build and CTest | CTest positive test count |
|
|
82
|
+
| C++ | CMake build and CTest | CTest positive test count |
|
|
83
|
+
|
|
84
|
+
C and C++ are separate language identifiers in configuration. JavaScript and TypeScript share the npm project plan; TypeScript type checking does not replace running tests.
|
|
85
|
+
|
|
86
|
+
## Configure custom test commands
|
|
87
|
+
|
|
88
|
+
For non-standard project layouts or test runners, create \`.polyguard.toml\` in the project root or pass one with \`--config\`.
|
|
89
|
+
|
|
90
|
+
\`\`\`toml
|
|
91
|
+
[project]
|
|
92
|
+
languages = ["python"]
|
|
93
|
+
|
|
94
|
+
[checks.python]
|
|
95
|
+
commands = [
|
|
96
|
+
["python3", "-m", "compileall", "-q", "src"],
|
|
97
|
+
["python3", "-m", "pytest", "-q"],
|
|
98
|
+
]
|
|
99
|
+
test_patterns = ["tests/test_*.py", "tests/**/*.py"]
|
|
100
|
+
success_patterns = ['(?m)^([0-9]+) passed']
|
|
101
|
+
\`\`\`
|
|
102
|
+
|
|
103
|
+
Configuration fields:
|
|
104
|
+
- \`commands\`: non-empty argument arrays. Commands are launched without a shell.
|
|
105
|
+
- \`test_patterns\`: at least one matching file must exist inside the project root.
|
|
106
|
+
- \`success_patterns\`: optional regular expressions that extract a positive passing-test count from combined command output. If omitted, Polyguard uses the built-in pattern for that language.
|
|
107
|
+
|
|
108
|
+
**Trust boundary:** a user-defined command or output regex is a project-owner assertion. A malicious or incorrect command can print a fake summary. Polyguard cannot independently prove what an arbitrary custom command did. For the strongest built-in verification, use the default language runner or a recognized test-runner adapter and its native report. Do not use \`echo\`, \`print\`, or a dummy process as a test command.
|
|
109
|
+
|
|
110
|
+
The verifier rejects invalid regular expressions and test patterns that traverse outside the project root.
|
|
111
|
+
|
|
112
|
+
## Test evidence and verdict rules
|
|
113
|
+
|
|
114
|
+
A language check returns PASS only when:
|
|
115
|
+
1. The project and required test suite are detected.
|
|
116
|
+
2. Every required command completes successfully.
|
|
117
|
+
3. The runner output contains a positive passing-test count, or a configured custom success pattern matches one.
|
|
118
|
+
4. No command failure or timeout occurs.
|
|
119
|
+
|
|
120
|
+
A zero-test run, an output with no recognized success summary, or a non-zero exit code returns FAIL. In JSON and detailed output, Polyguard includes the parsed test count and the evidence summary when available.
|
|
121
|
+
|
|
122
|
+
## Integration tests
|
|
123
|
+
|
|
124
|
+
The repository includes disposable real-project fixtures for toolchains available in the local environment. Run:
|
|
125
|
+
|
|
126
|
+
\`\`\`bash
|
|
127
|
+
python -m pip install -e ".[test]"
|
|
128
|
+
python -m pytest -q
|
|
129
|
+
\`\`\`
|
|
130
|
+
|
|
131
|
+
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; CI jobs install their required toolchains explicitly.
|
|
132
|
+
|
|
133
|
+
## AI coding-agent skill
|
|
134
|
+
|
|
135
|
+
The repository includes \`SKILL.md\`, also shipped in the installed package. Agents should run:
|
|
136
|
+
|
|
137
|
+
\`\`\`bash
|
|
138
|
+
polyguard verify --path . --details
|
|
139
|
+
\`\`\`
|
|
140
|
+
|
|
141
|
+
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.
|
|
142
|
+
|
|
143
|
+
## Important limitations and security
|
|
144
|
+
|
|
145
|
+
Polyguard is a test-execution gate, **not a formal proof of program correctness**. PASS means that the configured commands succeeded and a positive test-pass summary was recognized. It does not guarantee adequate test coverage, correct requirements, absence of defects, or trustworthy user-defined commands/patterns.
|
|
146
|
+
|
|
147
|
+
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.
|
|
148
|
+
|
|
149
|
+
Automatic language discovery is conservative. Custom frameworks can use explicit commands and success patterns. Full monorepo orchestration is not implemented yet: the current release does not discover every nested package or assign a separate working directory to each package. Run Polyguard separately from each package root until package-level configuration is added.
|
|
150
|
+
|
|
151
|
+
## Development
|
|
152
|
+
|
|
153
|
+
\`\`\`bash
|
|
154
|
+
python -m pip install -e ".[test]"
|
|
155
|
+
python -m pytest -q
|
|
156
|
+
python -m build
|
|
157
|
+
python -m twine check dist/*
|
|
158
|
+
\`\`\`
|
|
159
|
+
|
|
160
|
+
## Publishing
|
|
161
|
+
|
|
162
|
+
GitHub Actions builds the distributions and publishes with PyPI Trusted Publishing. Configure the PyPI publisher for:
|
|
163
|
+
- Owner: \`Furox-Art\`
|
|
164
|
+
- Repository: \`polyglot-code-guard\`
|
|
165
|
+
- Workflow: \`publish.yml\`
|
|
166
|
+
- Environment: \`pypi\`
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
MIT
|
|
@@ -0,0 +1,147 @@
|
|
|
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.
|
|
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 | \`npm test\`; TypeScript also runs \`tsc --noEmit\` when configured | Recognized runner pass summary |
|
|
53
|
+
| Java | Maven test or Gradle test | Maven/Gradle test summary |
|
|
54
|
+
| C# | \`dotnet test\` | .NET test-runner pass summary |
|
|
55
|
+
| PHP | PHPUnit | PHPUnit success summary |
|
|
56
|
+
| Ruby | RSpec, or Ruby's Minitest runner | RSpec/Minitest success summary |
|
|
57
|
+
| Swift | \`swift test\` | Swift test-result summary |
|
|
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 npm project plan; TypeScript type checking does not replace running tests.
|
|
62
|
+
|
|
63
|
+
## Configure custom test commands
|
|
64
|
+
|
|
65
|
+
For non-standard project layouts or test runners, create \`.polyguard.toml\` in the project root or pass one with \`--config\`.
|
|
66
|
+
|
|
67
|
+
\`\`\`toml
|
|
68
|
+
[project]
|
|
69
|
+
languages = ["python"]
|
|
70
|
+
|
|
71
|
+
[checks.python]
|
|
72
|
+
commands = [
|
|
73
|
+
["python3", "-m", "compileall", "-q", "src"],
|
|
74
|
+
["python3", "-m", "pytest", "-q"],
|
|
75
|
+
]
|
|
76
|
+
test_patterns = ["tests/test_*.py", "tests/**/*.py"]
|
|
77
|
+
success_patterns = ['(?m)^([0-9]+) passed']
|
|
78
|
+
\`\`\`
|
|
79
|
+
|
|
80
|
+
Configuration fields:
|
|
81
|
+
- \`commands\`: non-empty argument arrays. Commands are launched without a shell.
|
|
82
|
+
- \`test_patterns\`: at least one matching file must exist inside the project root.
|
|
83
|
+
- \`success_patterns\`: optional regular expressions that extract a positive passing-test count from combined command output. If omitted, Polyguard uses the built-in pattern for that language.
|
|
84
|
+
|
|
85
|
+
**Trust boundary:** a user-defined command or output regex is a project-owner assertion. A malicious or incorrect command can print a fake summary. Polyguard cannot independently prove what an arbitrary custom command did. For the strongest built-in verification, use the default language runner or a recognized test-runner adapter and its native report. Do not use \`echo\`, \`print\`, or a dummy process as a test command.
|
|
86
|
+
|
|
87
|
+
The verifier rejects invalid regular expressions and test patterns that traverse outside the project root.
|
|
88
|
+
|
|
89
|
+
## Test evidence and verdict rules
|
|
90
|
+
|
|
91
|
+
A language check returns PASS only when:
|
|
92
|
+
1. The project and required test suite are detected.
|
|
93
|
+
2. Every required command completes successfully.
|
|
94
|
+
3. The runner output contains a positive passing-test count, or a configured custom success pattern matches one.
|
|
95
|
+
4. No command failure or timeout occurs.
|
|
96
|
+
|
|
97
|
+
A zero-test run, an output with no recognized success summary, or a non-zero exit code returns FAIL. In JSON and detailed output, Polyguard includes the parsed test count and the evidence summary when available.
|
|
98
|
+
|
|
99
|
+
## Integration tests
|
|
100
|
+
|
|
101
|
+
The repository includes disposable real-project fixtures for toolchains available in the local environment. Run:
|
|
102
|
+
|
|
103
|
+
\`\`\`bash
|
|
104
|
+
python -m pip install -e ".[test]"
|
|
105
|
+
python -m pytest -q
|
|
106
|
+
\`\`\`
|
|
107
|
+
|
|
108
|
+
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; CI jobs install their required toolchains explicitly.
|
|
109
|
+
|
|
110
|
+
## AI coding-agent skill
|
|
111
|
+
|
|
112
|
+
The repository includes \`SKILL.md\`, also shipped in the installed package. Agents should run:
|
|
113
|
+
|
|
114
|
+
\`\`\`bash
|
|
115
|
+
polyguard verify --path . --details
|
|
116
|
+
\`\`\`
|
|
117
|
+
|
|
118
|
+
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.
|
|
119
|
+
|
|
120
|
+
## Important limitations and security
|
|
121
|
+
|
|
122
|
+
Polyguard is a test-execution gate, **not a formal proof of program correctness**. PASS means that the configured commands succeeded and a positive test-pass summary was recognized. It does not guarantee adequate test coverage, correct requirements, absence of defects, or trustworthy user-defined commands/patterns.
|
|
123
|
+
|
|
124
|
+
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.
|
|
125
|
+
|
|
126
|
+
Automatic language discovery is conservative. Custom frameworks can use explicit commands and success patterns. Full monorepo orchestration is not implemented yet: the current release does not discover every nested package or assign a separate working directory to each package. Run Polyguard separately from each package root until package-level configuration is added.
|
|
127
|
+
|
|
128
|
+
## Development
|
|
129
|
+
|
|
130
|
+
\`\`\`bash
|
|
131
|
+
python -m pip install -e ".[test]"
|
|
132
|
+
python -m pytest -q
|
|
133
|
+
python -m build
|
|
134
|
+
python -m twine check dist/*
|
|
135
|
+
\`\`\`
|
|
136
|
+
|
|
137
|
+
## Publishing
|
|
138
|
+
|
|
139
|
+
GitHub Actions builds the distributions and publishes with PyPI Trusted Publishing. Configure the PyPI publisher for:
|
|
140
|
+
- Owner: \`Furox-Art\`
|
|
141
|
+
- Repository: \`polyglot-code-guard\`
|
|
142
|
+
- Workflow: \`publish.yml\`
|
|
143
|
+
- Environment: \`pypi\`
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: polyglot-code-guard
|
|
3
|
+
Version: 0.3.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
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# Polyguard
|
|
25
|
+
|
|
26
|
+
**Fail-closed verification for AI-generated code across multiple programming languages.**
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
\`\`\`bash
|
|
33
|
+
python -m pip install --upgrade polyglot-code-guard
|
|
34
|
+
\`\`\`
|
|
35
|
+
|
|
36
|
+
## Run
|
|
37
|
+
|
|
38
|
+
From the target repository:
|
|
39
|
+
|
|
40
|
+
\`\`\`bash
|
|
41
|
+
polyguard verify
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
Default output:
|
|
45
|
+
|
|
46
|
+
\`\`\`text
|
|
47
|
+
PASS
|
|
48
|
+
\`\`\`
|
|
49
|
+
|
|
50
|
+
or:
|
|
51
|
+
|
|
52
|
+
\`\`\`text
|
|
53
|
+
FAIL
|
|
54
|
+
\`\`\`
|
|
55
|
+
|
|
56
|
+
Diagnostics and automation:
|
|
57
|
+
|
|
58
|
+
\`\`\`bash
|
|
59
|
+
polyguard verify --details
|
|
60
|
+
polyguard verify --json
|
|
61
|
+
polyguard verify --path ./my-project --timeout 180
|
|
62
|
+
polyguard verify --config ./ci/polyguard.toml
|
|
63
|
+
polyguard --version
|
|
64
|
+
\`\`\`
|
|
65
|
+
|
|
66
|
+
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.
|
|
67
|
+
|
|
68
|
+
## Built-in language support
|
|
69
|
+
|
|
70
|
+
| Language | Default build/test plan | Positive execution evidence |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| Python | \`compileall\`, then \`pytest -q\` | Pytest passed-test summary |
|
|
73
|
+
| Rust | \`cargo test --all-targets\` | Cargo test-result summary |
|
|
74
|
+
| Go | \`go test -json ./...\` | Passing test events in JSON stream |
|
|
75
|
+
| JavaScript / TypeScript | \`npm test\`; TypeScript also runs \`tsc --noEmit\` when configured | Recognized runner pass summary |
|
|
76
|
+
| Java | Maven test or Gradle test | Maven/Gradle test summary |
|
|
77
|
+
| C# | \`dotnet test\` | .NET test-runner pass summary |
|
|
78
|
+
| PHP | PHPUnit | PHPUnit success summary |
|
|
79
|
+
| Ruby | RSpec, or Ruby's Minitest runner | RSpec/Minitest success summary |
|
|
80
|
+
| Swift | \`swift test\` | Swift test-result summary |
|
|
81
|
+
| C | CMake build and CTest | CTest positive test count |
|
|
82
|
+
| C++ | CMake build and CTest | CTest positive test count |
|
|
83
|
+
|
|
84
|
+
C and C++ are separate language identifiers in configuration. JavaScript and TypeScript share the npm project plan; TypeScript type checking does not replace running tests.
|
|
85
|
+
|
|
86
|
+
## Configure custom test commands
|
|
87
|
+
|
|
88
|
+
For non-standard project layouts or test runners, create \`.polyguard.toml\` in the project root or pass one with \`--config\`.
|
|
89
|
+
|
|
90
|
+
\`\`\`toml
|
|
91
|
+
[project]
|
|
92
|
+
languages = ["python"]
|
|
93
|
+
|
|
94
|
+
[checks.python]
|
|
95
|
+
commands = [
|
|
96
|
+
["python3", "-m", "compileall", "-q", "src"],
|
|
97
|
+
["python3", "-m", "pytest", "-q"],
|
|
98
|
+
]
|
|
99
|
+
test_patterns = ["tests/test_*.py", "tests/**/*.py"]
|
|
100
|
+
success_patterns = ['(?m)^([0-9]+) passed']
|
|
101
|
+
\`\`\`
|
|
102
|
+
|
|
103
|
+
Configuration fields:
|
|
104
|
+
- \`commands\`: non-empty argument arrays. Commands are launched without a shell.
|
|
105
|
+
- \`test_patterns\`: at least one matching file must exist inside the project root.
|
|
106
|
+
- \`success_patterns\`: optional regular expressions that extract a positive passing-test count from combined command output. If omitted, Polyguard uses the built-in pattern for that language.
|
|
107
|
+
|
|
108
|
+
**Trust boundary:** a user-defined command or output regex is a project-owner assertion. A malicious or incorrect command can print a fake summary. Polyguard cannot independently prove what an arbitrary custom command did. For the strongest built-in verification, use the default language runner or a recognized test-runner adapter and its native report. Do not use \`echo\`, \`print\`, or a dummy process as a test command.
|
|
109
|
+
|
|
110
|
+
The verifier rejects invalid regular expressions and test patterns that traverse outside the project root.
|
|
111
|
+
|
|
112
|
+
## Test evidence and verdict rules
|
|
113
|
+
|
|
114
|
+
A language check returns PASS only when:
|
|
115
|
+
1. The project and required test suite are detected.
|
|
116
|
+
2. Every required command completes successfully.
|
|
117
|
+
3. The runner output contains a positive passing-test count, or a configured custom success pattern matches one.
|
|
118
|
+
4. No command failure or timeout occurs.
|
|
119
|
+
|
|
120
|
+
A zero-test run, an output with no recognized success summary, or a non-zero exit code returns FAIL. In JSON and detailed output, Polyguard includes the parsed test count and the evidence summary when available.
|
|
121
|
+
|
|
122
|
+
## Integration tests
|
|
123
|
+
|
|
124
|
+
The repository includes disposable real-project fixtures for toolchains available in the local environment. Run:
|
|
125
|
+
|
|
126
|
+
\`\`\`bash
|
|
127
|
+
python -m pip install -e ".[test]"
|
|
128
|
+
python -m pytest -q
|
|
129
|
+
\`\`\`
|
|
130
|
+
|
|
131
|
+
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; CI jobs install their required toolchains explicitly.
|
|
132
|
+
|
|
133
|
+
## AI coding-agent skill
|
|
134
|
+
|
|
135
|
+
The repository includes \`SKILL.md\`, also shipped in the installed package. Agents should run:
|
|
136
|
+
|
|
137
|
+
\`\`\`bash
|
|
138
|
+
polyguard verify --path . --details
|
|
139
|
+
\`\`\`
|
|
140
|
+
|
|
141
|
+
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.
|
|
142
|
+
|
|
143
|
+
## Important limitations and security
|
|
144
|
+
|
|
145
|
+
Polyguard is a test-execution gate, **not a formal proof of program correctness**. PASS means that the configured commands succeeded and a positive test-pass summary was recognized. It does not guarantee adequate test coverage, correct requirements, absence of defects, or trustworthy user-defined commands/patterns.
|
|
146
|
+
|
|
147
|
+
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.
|
|
148
|
+
|
|
149
|
+
Automatic language discovery is conservative. Custom frameworks can use explicit commands and success patterns. Full monorepo orchestration is not implemented yet: the current release does not discover every nested package or assign a separate working directory to each package. Run Polyguard separately from each package root until package-level configuration is added.
|
|
150
|
+
|
|
151
|
+
## Development
|
|
152
|
+
|
|
153
|
+
\`\`\`bash
|
|
154
|
+
python -m pip install -e ".[test]"
|
|
155
|
+
python -m pytest -q
|
|
156
|
+
python -m build
|
|
157
|
+
python -m twine check dist/*
|
|
158
|
+
\`\`\`
|
|
159
|
+
|
|
160
|
+
## Publishing
|
|
161
|
+
|
|
162
|
+
GitHub Actions builds the distributions and publishes with PyPI Trusted Publishing. Configure the PyPI publisher for:
|
|
163
|
+
- Owner: \`Furox-Art\`
|
|
164
|
+
- Repository: \`polyglot-code-guard\`
|
|
165
|
+
- Workflow: \`publish.yml\`
|
|
166
|
+
- Environment: \`pypi\`
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
MIT
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: polyglot-code-verification
|
|
3
|
+
description: Verify AI-generated code with actual project test runners and fail closed when tests do not execute or fail.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Polyglot Code Verification
|
|
7
|
+
|
|
8
|
+
Use this skill whenever code is generated, changed, refactored, or described as complete.
|
|
9
|
+
|
|
10
|
+
## Required workflow
|
|
11
|
+
|
|
12
|
+
1. Identify every language, build system, package root, and test framework touched by the change.
|
|
13
|
+
2. Add requirement-based tests for normal behavior, edge cases, invalid inputs, error paths, and regressions.
|
|
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\`.
|
|
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.
|
|
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
|
+
9. Retain command output and the JSON report when inspectable evidence is requested.
|
|
21
|
+
|
|
22
|
+
## Output contract
|
|
23
|
+
|
|
24
|
+
- All required checks complete and positive test-pass evidence is present: PASS
|
|
25
|
+
- Any failure or incomplete verification: FAIL
|
|
26
|
+
|
|
27
|
+
The CLI exits 0 only for PASS and 1 for FAIL. Default output is exactly one word; use \`--details\` or \`--json\` for diagnostics.
|
|
28
|
+
|
|
29
|
+
## Custom command trust
|
|
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.
|
|
32
|
+
|
|
33
|
+
## Scope
|
|
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.
|
|
36
|
+
|
|
37
|
+
## Security
|
|
38
|
+
|
|
39
|
+
The verifier executes build tools, package managers, scripts, and tests from the target repository. Run untrusted code in a disposable container or isolated virtual machine without secrets, privileged access, or sensitive host mounts. Polyguard is not an operating-system sandbox.
|