Skip to content

Python: DCA validation baseline for rebased shared-SSA adapter - #153

Draft
yoff wants to merge 11 commits into
yoff-python-main-22380-dca-snapshotfrom
yoff-python-rebased-ssa-baseline-dca
Draft

Python: DCA validation baseline for rebased shared-SSA adapter#153
yoff wants to merge 11 commits into
yoff-python-main-22380-dca-snapshotfrom
yoff-python-rebased-ssa-baseline-dca

Conversation

@yoff

@yoff yoff commented Sep 2, 2026

Copy link
Copy Markdown
Owner

DCA validation baseline

This draft is an experiment-only baseline for DCA validation. It is not a merge proposal.

Immutable base

Source

Rebased from the current open, non-draft upstream PR github#21923 without modifying it:

  • Source base ref: yoff-fix-shared-cfg-ssa-regressions
  • Source base SHA: 3dfc77e96f525dc742953e7b97e18cd514dcae78
  • Source head ref: yoff/python-add-new-ssa
  • Source head SHA: f49429a4c4fa9c1676ecb70e4ee47bb0d446823a

Included additive content

  • New shared-CFG/shared-SSA Python adapter at semmle.python.dataflow.new.internal.SsaImpl.
  • Adapter coverage for source variables, writes/reads, entry definitions, phi nodes, and the legacy ESSA-shaped compatibility surface.
  • SsaTest inline def/use/phi/exit-use coverage.
  • CmpTest contract comparison against legacy ESSA.

The aggregate patch is byte-for-byte equivalent to the unique additive patch from the exact github#21923 base/head range and is present exactly once.

Exclusions and adaptations

Tests

  • codeql query format --check-only -- python/ql/lib/semmle/python/dataflow/new/internal/SsaImpl.qll python/ql/test/library-tests/dataflow-new-ssa/SsaTest.ql python/ql/test/library-tests/dataflow-new-ssa-vs-legacy/CmpTest.ql
  • codeql test run --search-path . -- python/ql/test/library-tests/dataflow-new-ssa python/ql/test/library-tests/dataflow-new-ssa-vs-legacy
    • SsaTest.ql: passed
    • CmpTest.ql: passed

Stack metadata is intentionally not registered at this layer.

Copilot AI and others added 11 commits September 2, 2026 15:10
Preparatory refactor for the shared-CFG dataflow migration. Adds the
new Python SSA adapter additively, without changing any production
behaviour.

Library additions:

- semmle.python.dataflow.new.internal.SsaImpl — Python SSA
  implementation built on the new (shared) CFG. Mirrors the Java SSA
  adapter (java/ql/lib/semmle/code/java/dataflow/internal/SsaImpl.qll):
  an InputSig is defined in terms of positional (BasicBlock, int)
  variable references, and the shared
  codeql.ssa.Ssa::Make<Location, Cfg, Input> module is then
  instantiated.

  SourceVariable is the AST-level Py::Variable. Variable references
  are looked up via the new CFG facade's NameNode.defines/uses/deletes
  predicates (added in the preceding PR), which themselves are
  one-line bridges to AST-level Name.defines/uses/deletes.

  Implicit-entry definitions are inserted for non-local/global/builtin
  reads, captured variables, and (when needed) parameters.

Test additions:

- library-tests/dataflow-new-ssa/ — exercises the new SSA over a
  representative test corpus and checks expected def/use chains.

- library-tests/dataflow-new-ssa-vs-legacy/ — runs both new SSA and
  legacy ESSA over the same corpus and diffs the results, so any
  semantic divergence shows up as a test failure.

Production impact:

None. The new SSA adapter has zero callers in lib/ and src/ — the
legacy ESSA SSA (semmle/python/essa/*) remains the default. The
dataflow library is not migrated yet; that lands in a follow-up PR.

Verified by:
- All 367 lib + src + consistency-queries compile clean.
- All 641 ControlFlow + PointsTo + dataflow + essa + consistency
  library-tests pass.
- Both new dataflow-new-ssa[/vs-legacy] test packs pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- part of the ESSA adapter layer still refers to the raw SSA (now called Impl)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants