mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 03:49:26 +00:00
revert: JavaScript one-start build did not deliver in the push path (M2 11.6)
Reverts f04a839 on its own measurement. The seven-class profile rerun recorded
joern_parse_census_incomplete on 12 transactions: the faster build was rejected by
its own census gate and the frontend plus overlay pass ran as well, so those
transactions paid two engine starts instead of one. Every workload kept the same
p50 and the verdict stayed NO-GO.
The cause is an asymmetric gate. The frontend path is not census-gated at build
time, so whatever it produces is accepted, while the joern-parse path was gated and
the same shortfall rejected it. Holding the new path to a standard the old one
never has to meet guarantees the fallback fires. The probe tree and the
materialized push snapshot also differ, so equivalence on the checkout did not
transfer to the real path.
What still stands is the underlying timing fact, measured under the production
retention environment on identical graphs, same 44 files, 579 methods, file names,
overlays, Gruntfile and eighteen test files: 11.0 s against 21.0 s. JavaScript does
pay two engine starts where every other language pays one. A future attempt needs a
gate both paths are held to, or a direct comparison against what the frontend would
produce, and must be measured in the push path rather than on a checkout.
The profile also names the remaining cost plainly: a changed-code transaction
spends its budget before any query runs, head build 25.2 s of a 30 s deadline with
query time 0.0 s. Building one new graph per push is the cost, not querying it.
1,401 tests passed, nine skipped. Rollout stays NO-GO.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
This commit is contained in:
co-authored by
Claude Opus 5
parent
f04a839181
commit
ed0f12b593
@@ -1135,41 +1135,27 @@ def test_the_interpreter_must_read_the_frontend_parser_too(tmp_path: Path, monke
|
||||
assert "php-parser.php" in backend.last_failure and "mounts the repository but not this install" in backend.last_failure
|
||||
|
||||
|
||||
def test_javascript_falls_back_to_the_declared_frontend_when_the_census_is_short(tmp_path, monkeypatch):
|
||||
"""M2 11.6: one engine start is allowed only while the graph still holds every declared file.
|
||||
|
||||
The retention adaptation runs through the declared frontend, and it is what took the Node census
|
||||
from 43 files to 44. So an incomplete graph from the faster path is rebuilt rather than trusted.
|
||||
"""
|
||||
def test_javascript_partition_uses_declared_frontend_not_legacy_autodetection(tmp_path, monkeypatch):
|
||||
from openultrasast.cpg.backend import JoernBackend
|
||||
|
||||
(tmp_path / "tests").mkdir()
|
||||
(tmp_path / "tests/probe.js").write_bytes(b"function first_party_test(x) { return x; }")
|
||||
(tmp_path / "app.js").write_bytes(b"function handler(x) { return x; }")
|
||||
commands = []
|
||||
|
||||
def runner(command, **kwargs):
|
||||
if _is_overlay(command):
|
||||
return _overlaid(command, kwargs.get("cwd"))
|
||||
commands.append(Path(command[0]).name)
|
||||
if command[0].endswith("census.sc") or "census" in " ".join(command):
|
||||
# One file short of the two on disk: the faster path must not be trusted.
|
||||
body = '{"files":"1","methods":"1","overlays":"base,dataflowOss","maxHeapMB":"2048"}'
|
||||
payload = "---OUSAST-CPG-BEGIN---\n" + body + "\n---OUSAST-CPG-END---"
|
||||
return subprocess.CompletedProcess(command, 0, payload, "")
|
||||
target = command[command.index("-o") + 1] if "-o" in command else command[command.index("--output") + 1]
|
||||
Path(target).write_bytes(b"graph")
|
||||
commands.append(command)
|
||||
assert Path(command[0]).name == "jssrc2cpg"
|
||||
Path(command[command.index("-o") + 1]).write_bytes(b"graph")
|
||||
return subprocess.CompletedProcess(command, 0, "", "")
|
||||
|
||||
monkeypatch.setattr("shutil.which", lambda name: f"/opt/joern/{name}")
|
||||
monkeypatch.setenv("OPENULTRASAST_JOERN_PROBE", "on")
|
||||
backend = JoernBackend(runner=runner)
|
||||
result = backend.build(tmp_path, language="javascript")
|
||||
result = JoernBackend(runner=runner).build(tmp_path, language="javascript")
|
||||
try:
|
||||
assert result is not None
|
||||
assert "joern-parse" in commands, "the one-start path should be tried first"
|
||||
assert "jssrc2cpg" in commands, "a short census must rebuild through the declared frontend"
|
||||
assert "joern_parse_census_incomplete" in backend._diagnostics
|
||||
assert len(commands) == 1
|
||||
finally:
|
||||
if result is not None:
|
||||
result.cleanup()
|
||||
|
||||
Reference in New Issue
Block a user