Repository navigation
feat: model class literals as ClassConstant nodes (tag 16) - #226
Merged
Merged
Conversation
📊 Test Coverage
|
Benchmark reportBase: Workflow and raw evidence · Full report Benchmark correctness and OOM: PASSTiming differences are report-only; correctness, OOM and required coverage decide this gate. GitHub runner timings do not establish performance acceptance. Base: frontend-build-save
native-real64
Full methods, comparability reasons, isolated observations, raw request bodies and logs are retained in the downloadable report/evidence artifacts. UNAVAILABLE never means zero; a zero baseline has no defined percentage change. |
johnsonlee
added a commit
that referenced
this pull request
Nov 16, 2026
johnsonlee
force-pushed
the
feat/class-constant-node
branch
from
November 16, 2026 05:09
c69f543 to
002413a
Compare
johnsonlee
added a commit
that referenced
this pull request
Nov 16, 2026
The JVM frontend turned every class literal (`Payload.class`, `Payload[].class`) into `IntConstant(0)`, the fallback for constants it did not model, so the type was lost at build time and the literal collided with a real 0. A reflective registration (`register(Payload.class, ...)`) could not be proved. - core: `ClassConstant(id, value)` whose value is the JVM type descriptor (`Lsample/Payload;`, `[Lsample/Payload;`, `[[I`); `typeName` spells it as source does. SootUp's ClassConstant maps to it, interned by its own kind so it never merges with a StringConstant of the same text. - persistence: node record tag 16 (string-table index, StringConstant layout) in the JVM writer/reader, the mmap spill format, the type index and the branch definition validator; Rust `NodeKind::ClassConstant`, `TAG_COUNT` 17, `is_constant_tag`/`CONSTANT_TAGS`, and the interchange importer. - query: `ClassConstant` label with `labels(n)` = [ClassConstant, Constant] in both engines; `value` joins the raw string column (Rust, appended slot) and the Kotlin direct/mapped string paths, so =, STARTS WITH, IN, CONTAINS and ENDS WITH use the fast paths. Both parsers now split statements only on semicolons outside literals: a descriptor holds one. - explorer: rendering in both servers and both web UIs. - tests: adapter (descriptors, array literals, string kept distinct, flow through a local), frontend correctness gate cases for Java and DEX, eager and mapped round-trip with local and branch definitions, Kotlin and Rust Cypher (save, load, labels, properties, predicates, dataflow), and a JVM-to-native interop fixture wired into the Rust workflow. The graph parity baseline moves 102 IntConstant(0) fact occurrences to their ClassConstant descriptors; nothing else. - docs: storage format and compatibility (graphs built before this hold IntConstant(0) and must be rebuilt; older readers reject tag 16). Closes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y7fuheyv6BkFkWh5taa18M
johnsonlee
force-pushed
the
feat/class-constant-node
branch
from
November 16, 2026 06:46
002413a to
5c6ab25
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #223
Problem
The JVM frontend mapped every class literal to
IntConstant(0)(the fallback for unmodelled constants inValueNodes.getOrCreateConstant). The type was lost at build time, every literal collided with a real0, and a reflective registration such asregister(Payload.class, parser)could not be proved from the graph.Change
ClassConstant(id, value);valueis the JVM type descriptor (Lsample/Payload;,[Lsample/Payload;,[[I). SootUp'sClassConstantmaps to it, interned under its own key so it never merges with aStringConstantthat spells the same text.StringConstantlayout) in the JVM writer/readers (eager and mapped), the mmap spill format, the type index and the branch-definition validator; RustNodeKind::ClassConstant,TAG_COUNT = 17,is_constant_tag/CONSTANT_TAGS, and the interchange importer. The node data header stays at version 3.MATCH (n:ClassConstant),labels(n)=["ClassConstant", "Constant"],n.valuewith=,STARTS WITH,IN,CONTAINS,ENDS WITH,=~;valuejoins the Rust raw string column (appended slot, earlier slots unchanged) and the Kotlin direct/mapped string paths. Both parsers now split statements only on semicolons outside string literals and escaped names, since a descriptor contains;(previouslyWHERE n.value = 'Lx;'failed to parse in both engines).Payload[].class).docs/webgraph-storage.md(format and compatibility), README, frontend correctness gate, agent skill reference.Compatibility
Graphs built before this change contain
IntConstant(0)for class literals; the type is not in the file, so rebuild to getClassConstantnodes. Readers that predate tag 16 reject a graph containing one (Unknown node tag: 16). Graphs without class literals differ only by one empty entry ingraph.typeindex, which older readers skip.Unchanged by design:
MethodHandle/MethodTypeldcconstants still use the loggedIntConstant(0)fallback (now covered by a test), and fold rules still cannot name a class literal argument (ConstantFoldTestexpectation unchanged).Tests
ClassLiteralNodeTest(SootUp): descriptors incl. arrays andint[][], the equal string stays a separateStringConstant, interning, flow through a local into a call argument, the remaining fallback.class-literalcases for Java and Android/DEX (require descriptor and return flow, forbidint:0and the string),node:ClassConstantcovered.ClassConstantPersistenceTest(webgraph): eager and mapped load of class literals with local and branch definitions; Cypher over both load modes; a SootUp-built graph from both node builders saved for the native interop step.ClassConstantCypherTest(Kotlin engine) andbackend/cypher/tests/class_constant.rs(Rust): save, load (directory and packed container), labels, properties/keys/maps, string predicates, dataflow, and the JVM-written fixture (GRAPHITE_CLASS_CONSTANT_FIXTURE, required inrust.yml).IntConstant(0)fact occurrences become theirClassConstant(...)descriptors; after mapping them back the baseline is identical (no fact lost).Local runs:
cargo fmt --check,cargo clippy --workspace --all-targets -D warnings,cargo test --workspace(incl. the interop test against a freshly written JVM fixture),./gradlew check koverXmlReportandcheck-coverage.py(all seven modules 100%) pass.frontend/web, Apple and CI TypeScript helpers are untouched and were not run.Local benchmark
Ran locally with
graphite-benchmark runon an Apple M3 Max (16 cores, 64 GB, macOS 14.3, OpenJDK 17.0.21). Base ismaind4dd8ee6, head is this PR'sc69f5433, and the trusted controller is base. Nothing else was running.Gate result:
base-head-reviewed-semanticsfails, as expected; every other check passes.IntConstant(0)→ClassConstanttransition, checked row by row against the hosted run's retained bodies:schema-label-histogramIntConstant157,407 → 126,774 and a newClassConstantrow of 30,633; the sum is conserved and all other labels are unchangedschema-relationship-histogram(ORDER BY c DESC LIMIT 40)shape-label-scan-constant(MATCH (n:Constant) RETURN n.value LIMIT 200)0now carry descriptors such asLjavax/xml/validation/SchemaFactory;The controller marks every timing row non-comparable while any response differs. The base and head values it records are listed below with the deltas computed by hand. They are single local runs: observations, not acceptance evidence.
292 query timing rows in all. No case reaches 50 ms locally; the slowest base value is 49.3 ms.
Largest absolute changes:
shape-equalitypressure p95: 6.4 → 2.0 ms (−4.4)shape-group-countpressure p95: 46.0 → 49.0 ms (+3.0)shape-with-aggregatepressure p50: 43.1 → 44.8 ms (+1.6) and p95: 49.3 → 50.6 ms (+1.3)Every other row moves by less than 1.3 ms.
On loading: the
main-vs-main-plus-fix(sootup): read DEX declarations without converting or retaining bodies #225 run on the same machine moved +0.70 s with no change to loading, so +0.5 s is within single-sample run-to-run noise. Loading still countsTAG_CLASS_CONSTANTwith the other constants in the type index.To make the gate pass: exact transition rules for these three cases, bound to the base/head product identities, have to land in the trusted
benchmark/src/transitions.rsonmainin a separate policy PR, as was done for #193 (#195). The current identities are basea6edb466…and headaa06cf4f…. They will be re-read after this branch is rebased onto the finalmain.🤖 Generated with Claude Code
https://claude.ai/code/session_01Y7fuheyv6BkFkWh5taa18M