Parent
Parent EPIC: #243
Problem
python.syntax currently parses with ast.parse but then runs regex/string post-checks that reject valid Python. The audited revision emitted 109 false-positive syntax errors on a repository where python -m compileall -q src scripts tests passed. Repeated false errors included valid multiline def/if/with headers and multiline literals reported as "compound statements must end with a colon."
The syntax check can also probe one interpreter and execute another because resolution and invocation are separate. Parser success followed by heuristic failure is not compiler truth.
Required behavior
- Resolve one concrete interpreter through the canonical Python project resolver and execute that exact command. Do not probe a path and later invoke raw
python3.
- Validate every selected after-state file using compiler-equivalent behavior for the target Python version. Use
py_compile/compile() semantics with stable doraise behavior; do not run source code.
- Remove grammar-breaking regex/string post-validation. Parser success must not be overridden by checks that reinterpret Python grammar. If any supplemental static policy remains, it must have a separate check ID/category and must not emit
python.syntax diagnostics.
- Translate syntax/indentation/null-byte/compiler failures into stable diagnostics with file, 1-based line, column/end location when available, normalized code, severity, message, interpreter path/version, and provenance.
- Distinguish
passed, findings, tool_unavailable, invalid_config, timeout, and infrastructure/tool failure. Unknown nonzero output or malformed machine output must never become a pass.
- Validate the exact overlay/after-state content selected by the request, including new and changed Python files, without mutating the source project.
- Handle
.py and .pyi. Version-specific syntax must be judged by the selected interpreter and declared target policy; unsupported target/interpreter combinations are explicit degraded/unsupported results.
- Keep diagnostics deterministic: normalized workspace-relative paths and stable sort order.
Acceptance fixtures
Must pass:
- multiline
def, class, if, elif, for, while, with, match, and case headers;
- decorators, async forms, type comments, nested f-strings, comprehensions, semicolon-separated simple statements, continuations, triple-quoted strings containing Python-looking text, and
.pyi constructs;
- valid syntax supported only by the selected newer interpreter;
- the audited repository's
src, scripts, and tests corpus when its native compile baseline passes.
Must fail with precise locations:
- missing colon/indentation;
- unterminated strings/brackets;
- invalid target-version syntax under the selected interpreter;
- null bytes and compiler recursion/overflow errors;
- malformed tool output/infrastructure failure as non-pass states.
Must prove overlay semantics:
- baseline file passes while invalid after-state fails;
- invalid baseline file passes when corrected in after-state;
- newly introduced invalid
.py and .pyi files fail.
Scope
Primary implementation surfaces:
packages/validation-python/src/syntax-check.ts
- the canonical resolver/toolchain and process runner used by this check
- Python validation contracts/diagnostics only where required
- fixture-backed tests in the existing Python validation and conformance suites
Non-goals
- type checking, linting, formatting, import resolution, security scanning, notebook execution, or automatic source rewrites;
- installing Python or packages;
- widening launch-facing Python claims.
Verification
At minimum:
npm run build
node --test tests/validation-python.test.mjs tests/graph-extraction-conformance.test.mjs
npm run lint
bash ./scripts/ci/run-local-ci-equivalent.sh
Also run the native compile baseline and python.syntax against a real Python repository, and attach a before/after diagnostic comparison demonstrating that the known false positives are gone while seeded invalid overlay files fail.
Completion evidence
PR must link exact interpreter/version used, machine-readable diagnostic examples, passing fixture matrix, real-repository comparison, and confirmation that no source project files/config/lockfiles/environments were modified.
Parent
Parent EPIC: #243
Problem
python.syntaxcurrently parses withast.parsebut then runs regex/string post-checks that reject valid Python. The audited revision emitted 109 false-positive syntax errors on a repository wherepython -m compileall -q src scripts testspassed. Repeated false errors included valid multilinedef/if/withheaders and multiline literals reported as "compound statements must end with a colon."The syntax check can also probe one interpreter and execute another because resolution and invocation are separate. Parser success followed by heuristic failure is not compiler truth.
Required behavior
python3.py_compile/compile()semantics with stabledoraisebehavior; do not run source code.python.syntaxdiagnostics.passed,findings,tool_unavailable,invalid_config,timeout, and infrastructure/tool failure. Unknown nonzero output or malformed machine output must never become a pass..pyand.pyi. Version-specific syntax must be judged by the selected interpreter and declared target policy; unsupported target/interpreter combinations are explicit degraded/unsupported results.Acceptance fixtures
Must pass:
def,class,if,elif,for,while,with,match, andcaseheaders;.pyiconstructs;src,scripts, andtestscorpus when its native compile baseline passes.Must fail with precise locations:
Must prove overlay semantics:
.pyand.pyifiles fail.Scope
Primary implementation surfaces:
packages/validation-python/src/syntax-check.tsNon-goals
Verification
At minimum:
Also run the native compile baseline and
python.syntaxagainst a real Python repository, and attach a before/after diagnostic comparison demonstrating that the known false positives are gone while seeded invalid overlay files fail.Completion evidence
PR must link exact interpreter/version used, machine-readable diagnostic examples, passing fixture matrix, real-repository comparison, and confirmation that no source project files/config/lockfiles/environments were modified.