Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gemini-extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axiomcode",
"version": "0.2.3",
"version": "0.2.4",
"description": "Ask your repository how its code connects: who calls this, what breaks if I change it, which tests an edit reaches, how A reaches B. Answers come from a resolved call graph and are verified against it; nothing is guessed.",
"contextFileName": "plugins/axiomcode/AGENTS.md",
"mcpServers": {
Expand Down
4 changes: 2 additions & 2 deletions graph/bundle/SCHEMA.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ Every callable the graph refers to: all client methods/functions from the IR, pl
| `client` | all | Declared in the analysed project. |
| `lib` | all | Declared in a staged library IR; listed because an edge reaches it. |
| `generated` | java | Declared by a compile-time annotation processor: present in the compiled artefact and in every caller's source, and in no IR, so the bundle synthesises it to give the edge a target. id `generated:<owner qualified name>#<name>/<arity>`, no file and no line numbers. |
| `generated` | csharp | The Invoke of the delegate held in one field or property: id `generated:<owner qualified name>#<member>.Invoke`, no file and no line numbers. Every call through that member is an edge to it (tier boundary_lib, which is also where the compiler binds the call), and what the member holds is in dispatch_candidates with basis `value`. |
| `generated` | csharp | The Invoke of the delegate held in one field or property: id `generated:<owner qualified name>#<member>.Invoke`, no file and no line numbers. Every call through that member is an edge to it (tier boundary_lib, which is also where the compiler binds the call), and what the member holds is in dispatch_candidates with basis `value`. And the parameterless constructor of a staged library type whose IR carries no constructor: id `generated:<type qualified name>#<constructor>/0`. `new T()` compiles only if T has one, so the target exists, but a library IR is a signature subset and cannot say whether T declares it or the compiler supplies it. The `new` site is an edge to it with callee_provenance `lib` and tier boundary_lib, not an `external:` label, because the library WAS staged. |

**Notes**

Expand Down Expand Up @@ -578,7 +578,7 @@ THE GRAPH. One row per (site, resolved target). A site with N possible targets h
|---|---|---|
| `external` | all | The target is outside every staged IR. callee_method_id is NULL and callee_label names it, as `external:<Type>.<Member>`. A client-only run of a C# project reaches the BCL this way for most of its calls. |
| `client` | all | Target is a client method (callee_method_id set). |
| `lib` | all | Target is a method of a staged library IR (callee_method_id set, methods.provenance = lib). |
| `lib` | all | Target is a method of a staged library IR (callee_method_id set, methods.provenance = lib). C# only: or the parameterless constructor of a staged type its IR does not carry, a methods row with provenance `generated`. |
| `generated` | csharp | The target is a member the compiler generated and no source declares (a `boundary_generated` row); callee_label names it. |
| `builtin` | python | Target is a CPython builtin with no Python source (callee_label = `builtin:NAME`). |
| `external` | python, java | Target is outside every staged IR and has no methods row. Python: an import path (callee_label = the written path). Java: a method of an unstaged ancestor type (callee_label = `external:<type>.<name>`), reached through a receiver declared as that type or inherited by a client subclass; see types.provenance external. |
Expand Down
4 changes: 2 additions & 2 deletions graph/bundle/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export const VOCAB: readonly VocabSpec[] = [
{ table: 'methods', column: 'provenance', value: 'client', languages: 'all', meaning: 'Declared in the analysed project.' },
{ table: 'methods', column: 'provenance', value: 'lib', languages: 'all', meaning: 'Declared in a staged library IR; listed because an edge reaches it.' },
{ table: 'methods', column: 'provenance', value: 'generated', languages: J, meaning: 'Declared by a compile-time annotation processor: present in the compiled artefact and in every caller\'s source, and in no IR, so the bundle synthesises it to give the edge a target. id `generated:<owner qualified name>#<name>/<arity>`, no file and no line numbers.' },
{ table: 'methods', column: 'provenance', value: 'generated', languages: C, meaning: 'The Invoke of the delegate held in one field or property: id `generated:<owner qualified name>#<member>.Invoke`, no file and no line numbers. Every call through that member is an edge to it (tier boundary_lib, which is also where the compiler binds the call), and what the member holds is in dispatch_candidates with basis `value`.' },
{ table: 'methods', column: 'provenance', value: 'generated', languages: C, meaning: 'The Invoke of the delegate held in one field or property: id `generated:<owner qualified name>#<member>.Invoke`, no file and no line numbers. Every call through that member is an edge to it (tier boundary_lib, which is also where the compiler binds the call), and what the member holds is in dispatch_candidates with basis `value`. And the parameterless constructor of a staged library type whose IR carries no constructor: id `generated:<type qualified name>#<constructor>/0`. `new T()` compiles only if T has one, so the target exists, but a library IR is a signature subset and cannot say whether T declares it or the compiler supplies it. The `new` site is an edge to it with callee_provenance `lib` and tier boundary_lib, not an `external:` label, because the library WAS staged.' },
{ table: 'types', column: 'provenance', value: 'client', languages: 'all', meaning: 'Declared in the analysed project.' },
{ table: 'types', column: 'provenance', value: 'lib', languages: 'all', meaning: 'Declared in a staged library IR.' },
{ table: 'types', column: 'provenance', value: 'external', languages: J, meaning: 'Named by the client as an ancestor (`extends`/`implements`) but declared in no staged IR: id `external:<qualified name>`, category EXTERNAL_TYPE, no file, no members. Kept so the subtype edge survives; stage the library to replace it with the real declaration.' },
Expand Down Expand Up @@ -617,7 +617,7 @@ export const VOCAB: readonly VocabSpec[] = [

// call_edges.callee_provenance
{ table: 'call_edges', column: 'callee_provenance', value: 'client', languages: 'all', meaning: 'Target is a client method (callee_method_id set).' },
{ table: 'call_edges', column: 'callee_provenance', value: 'lib', languages: 'all', meaning: 'Target is a method of a staged library IR (callee_method_id set, methods.provenance = lib).' },
{ table: 'call_edges', column: 'callee_provenance', value: 'lib', languages: 'all', meaning: 'Target is a method of a staged library IR (callee_method_id set, methods.provenance = lib). C# only: or the parameterless constructor of a staged type its IR does not carry, a methods row with provenance `generated`.' },
{ table: 'call_edges', column: 'callee_provenance', value: 'generated', languages: C, meaning: 'The target is a member the compiler generated and no source declares (a `boundary_generated` row); callee_label names it.' },
{ table: 'call_edges', column: 'callee_provenance', value: 'builtin', languages: P, meaning: 'Target is a CPython builtin with no Python source (callee_label = `builtin:NAME`).' },
{ table: 'call_edges', column: 'callee_provenance', value: 'external', languages: ['python', 'java'], meaning: 'Target is outside every staged IR and has no methods row. Python: an import path (callee_label = the written path). Java: a method of an unstaged ancestor type (callee_label = `external:<type>.<name>`), reached through a receiver declared as that type or inherited by a client subclass; see types.provenance external.' },
Expand Down
11 changes: 11 additions & 0 deletions graph/csharp/engine/call-edge-generation/call_chain.dl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ site_leaves_client(prov, e) :- client_calls_lib(prov, e, _, _).
// a real project that is most of the unresolved sites -- which makes the number that
// matters unreadable.
site_leaves_client(prov, e) :- external_target(prov, e, _).
// And one into a staged type whose parameterless constructor its IR does not carry.
site_leaves_client(prov, e) :- staged_parameterless_ctor(prov, e, _).
// A call through a field or property holding a delegate lands on the delegate's
// Invoke, which the runtime supplies (resolution/delegates.dl). The site gets an edge
// to that member's Invoke node and the stored functions are in the envelope.
Expand Down Expand Up @@ -235,6 +237,14 @@ call_chain_edge(e, caller, "-", label, "external", "boundary_lib", kind) :-
call_from("client", e, caller),
invocation_site("client", e, kind).

// client -> A STAGED TYPE'S PARAMETERLESS CONSTRUCTOR, NOT CARRIED BY ITS IR. The
// target belongs to a staged type, so the provenance is `lib`; it is the `generated:`
// node resolution/external-types.dl names, which the bundle gives a methods row.
call_chain_edge(e, caller, "-", node, "lib", "boundary_lib", kind) :-
staged_parameterless_ctor("client", e, node),
call_from("client", e, caller),
invocation_site("client", e, kind).

// client -> A DELEGATE MEMBER'S INVOKE (#1206). `getPath(url)` on a field holding a
// delegate calls Invoke -- Roslyn's answer too -- and which stored function then runs
// is value flow, recorded in method_dispatch_candidate with basis `value` rather than
Expand Down Expand Up @@ -400,6 +410,7 @@ call_has_edge(prov, e) :- client_calls_lib(prov, e, _, _).
call_has_edge("client", e) :- client_calls_external(e, _).
call_has_edge("client", e) :- delegate_member_call("client", e, _).
call_has_edge("client", e) :- delegate_param_call(e, _).
call_has_edge("client", e) :- staged_parameterless_ctor("client", e, _).

call_chain_edge(e, caller, "-", "-", "-", cls, kind) :-
invocation_site("client", e, kind),
Expand Down
34 changes: 33 additions & 1 deletion graph/csharp/engine/resolution/external-types.dl
Original file line number Diff line number Diff line change
Expand Up @@ -435,20 +435,52 @@ external_target(prov, e, label) :-
// constructor clause above needs the type to be UNSTAGED, so once a library
// declares the type the site had neither a constructor to resolve nor a name to
// carry. Refusing the implicit-constructor claim alone leaves it a blind spot.
//
// NOT FOR `new T()` ON A STAGED TYPE THAT CARRIES NO CONSTRUCTOR AT ALL. That site
// runs T's parameterless constructor, which exists whether the library declares it
// or the compiler supplies it, and T is staged: `external` would say the
// dependency was not supplied, and it was (#1339). staged_parameterless_ctor names
// it inside the library instead. What is left here is a site whose argument count
// no carried constructor accepts although the IR carries some: a member the subset
// IR was not told about, named like an uncarried method.
external_target(prov, e, label) :-
call_needs_ctor_lookup(prov, e),
expr_new_type(prov, e, gk),
type_group("lib", _, gk),
call_argc(prov, e, ac),
!call_ctor_target_accepts(prov, e, ac),
!staged_parameterless_ctor(prov, e, _),
type_decl("lib", n, _, _, _, t), type_group("lib", t, gk),
label = cat("external:", cat(n, ".<constructor>")).

// Whether any constructor of the created type accepts this site's argument
// count. Named rather than inlined because the rule above needs its NEGATION,
// and a negated conjunction over three relations is where a cross-product hides.
//
// call_ctor_target already admits a constructor only where it accepts the site's
// argument count, under the provenance the constructor is DECLARED in. Re-checking
// it here under the SITE's provenance missed every staged constructor -- a client
// `new` reaching a library constructor -- so a resolved site was also labelled an
// unstaged one and had two rows (#1339).
call_ctor_target_accepts(prov, e, ac) :-
call_ctor_target(prov, e, ctor), ctor_accepts_argc(prov, ctor, ac).
call_ctor_target(prov, e, _), call_argc(prov, e, ac).

// staged_parameterless_ctor(Prov, Site, Node) -- `new T()` with no argument, on a
// staged type whose IR carries no constructor. Not known_implicit_ctor: a library IR
// is a signature subset, so it cannot show that T declares none. But `new T()`
// compiles only if T has a parameterless constructor, declared or supplied, so the
// target is known to exist and to be T's. The node is the `generated:` member id the
// bundle gives a methods row (provenance generated, owner T), so the edge points at
// T inside the library rather than at a label for an unsupplied dependency.
staged_parameterless_ctor(prov, e, node) :-
call_needs_ctor_lookup(prov, e),
expr_new_type(prov, e, gk),
type_group("lib", _, gk),
!type_ctor("lib", gk, _),
!type_ctor(prov, gk, _),
call_argc(prov, e, "0"),
type_decl("lib", _, qn, _, _, t), type_group("lib", t, gk),
node = cat("generated:", cat(qn, "#<constructor>/0")).

// ── A PROPERTY READ ON AN EXTERNAL RECEIVER ─────────────────────────────────
// `someString.Length`, `dict.Count`, `ex.Message`. Reading a property IS a call, and
Expand Down
1 change: 1 addition & 0 deletions graph/csharp/souffle/decls_all.dl
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@
.decl site_unresolved_named(c0:symbol,c1:symbol,c2:symbol)
.decl site_unresolved_real(c0:symbol)
.decl sseg(c0:symbol,c1:number,c2:symbol)
.decl staged_parameterless_ctor(c0:symbol,c1:symbol,c2:symbol)
.decl starts_slash(c0:symbol)
.decl static_edge_exists(c0:symbol,c1:symbol)
.decl static_fan_member(c0:symbol,c1:symbol,c2:symbol)
Expand Down
45 changes: 45 additions & 0 deletions graph/test/csharp/staging-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,51 @@ aln=$(awk -F' ' '$6=="boundary_lib"' "$AL" 2>/dev/null | wc -l | tr -d ' ')
[ "${aln:-0}" -eq 2 ] || fail "a keyword-typed receiver did not reach the staged framework type: got ${aln:-0} of 2"
grep -q "external:" "$AL" 2>/dev/null && fail "a keyword-typed receiver was still labelled external although its type is staged"

# ── `new T()` ON A STAGED TYPE IS NOT AN UNSTAGED DEPENDENCY (#1339) ───────
# Two shapes of one site, each in its own run because the library is the variable:
# ctor/ Store declares a constructor. The site has exactly ONE row, the
# resolved one. It used to have a second, `external:Store.<constructor>`,
# because the "no carried constructor accepts this arity" check joined
# the library's constructor under the client's provenance and found
# nothing, so a resolved site was also labelled unstaged.
# noctor/ Store declares none. The parameterless constructor the site runs is
# not carried, but the TYPE is staged, so the row must not say
# `external` -- that provenance means "this dependency was not
# supplied", and it was. Nor is it known_implicit_ctor: a library IR is
# a signature subset, so it cannot prove the type declares none.
for shape in ctor noctor; do
mkdir -p "$WORK/new-$shape-lib" "$WORK/new-$shape-cli"
if [ "$shape" = ctor ]; then decl='public Store() { }'; else decl=''; fi
cat > "$WORK/new-$shape-lib/Store.cs" <<EOF2
namespace Acme;
public class Box { public int Size() { return 0; } }
public class Store { $decl public Box Open(string k) { return new Box(); } }
EOF2
cat > "$WORK/new-$shape-cli/Program.cs" <<'EOF2'
using Acme;
namespace App;
public static class Program { public static int Main() { var s = new Store(); return s.Open("x").Size(); } }
EOF2
node "$REPO/parser/dist/index.js" "$WORK/new-$shape-lib" "new-$shape-lib" false "$WORK/new-$shape-libir" --per-language > "$WORK/new-$shape-parse.log" 2>&1
bash "$REPO/bin/axiomcode" all --language csharp --src "$WORK/new-$shape-cli" --out "$WORK/new-$shape-out" \
--library "$WORK/new-$shape-libir" --version pinned --debug > "$WORK/new-$shape.log" 2>&1
NEW="$WORK/new-$shape-out/csharp/raw/call-chain-edges.csv"
rows=$(awk -F'\t' '$7=="new"' "$NEW" 2>/dev/null | wc -l | tr -d ' ')
ext=$(awk -F'\t' '$7=="new" && $5=="external"' "$NEW" 2>/dev/null | wc -l | tr -d ' ')
libm=$(awk -F'\t' '$7=="new" && $5=="lib" && $4 ~ /^CS_METHOD_/' "$NEW" 2>/dev/null | wc -l | tr -d ' ')
implicit=$(awk -F'\t' '$7=="new" && $6=="known_implicit_ctor"' "$NEW" 2>/dev/null | wc -l | tr -d ' ')
if [ "$shape" = ctor ]; then
[ "${rows:-0}" -eq 1 ] && [ "${libm:-0}" -eq 1 ] || \
fail "\`new Store()\` on a staged type that DECLARES its constructor has ${rows:-0} row(s), ${libm:-0} to the library constructor and ${ext:-0} external; expected exactly the one resolved row"
else
[ "${rows:-0}" -eq 1 ] || fail "\`new Store()\` on a staged type with no carried constructor has ${rows:-0} row(s), expected 1"
[ "${ext:-0}" -eq 0 ] || fail "\`new Store()\` on a STAGED type with no carried constructor is labelled external, as if the library had not been supplied"
[ "${implicit:-0}" -eq 0 ] || fail "\`new Store()\` on a staged type claimed known_implicit_ctor, which a signature-subset IR cannot prove"
fi
[ "${rows:-0}" -ge 1 ] || awk -F'\t' '{print " got: "$4" "$5" "$6" "$7}' "$NEW" 2>/dev/null | head -5
[ "${rows:-0}" -le 1 ] || awk -F'\t' '$7=="new"{print " got: "$4" "$5" "$6" "$7}' "$NEW" 2>/dev/null | head -5
done

# ── STAGING NOTHING CHANGES NOTHING ─────────────────────────────────────────
# The cross-provenance clauses must be inert on a client-only run. Compared
# relation by relation, and then the SAME comparison is run against the staged
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axiomcode/code-graph",
"version": "0.2.3",
"version": "0.2.4",
"description": "AxiomCode Graph: a resolved call graph of your codebase grounded in formal methods, so you and your coding agents can see who calls what, what a change breaks, and which tests it reaches.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -31,11 +31,11 @@
],
"license": "FSL-1.1-Apache-2.0",
"optionalDependencies": {
"@axiomcode/engine-darwin-arm64": "0.2.3",
"@axiomcode/engine-darwin-x64": "0.2.3",
"@axiomcode/engine-linux-x64": "0.2.3",
"@axiomcode/engine-linux-arm64": "0.2.3",
"@axiomcode/engine-win32-x64": "0.2.3"
"@axiomcode/engine-darwin-arm64": "0.2.4",
"@axiomcode/engine-darwin-x64": "0.2.4",
"@axiomcode/engine-linux-x64": "0.2.4",
"@axiomcode/engine-linux-arm64": "0.2.4",
"@axiomcode/engine-win32-x64": "0.2.4"
},
"bin": {
"axiomcode": "bin/axiomcode.js"
Expand Down
2 changes: 1 addition & 1 deletion plugins/axiomcode/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "axiomcode",
"description": "Ask your repository how its code connects: who calls this, what breaks if I change it, which tests an edit reaches, how A reaches B. Answers come from a resolved call graph and are verified against it; nothing is guessed.",
"version": "0.2.3",
"version": "0.2.4",
"author": {
"name": "AxiomCode"
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/axiomcode/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axiomcode",
"version": "0.2.3",
"version": "0.2.4",
"description": "Ask your repository how its code connects: who calls this, what breaks if I change it, which tests an edit reaches, how A reaches B. Answers come from a resolved call graph and are verified against it; nothing is guessed.",
"author": { "name": "AxiomCode", "url": "https://github.com/AxiomCodeAI/axiomcodegraph" },
"homepage": "https://github.com/AxiomCodeAI/axiomcodegraph",
Expand Down
2 changes: 1 addition & 1 deletion plugins/axiomcode/.cursor-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axiomcode",
"version": "0.2.3",
"version": "0.2.4",
"description": "Ask your repository how its code connects: who calls this, what breaks if I change it, which tests an edit reaches, how A reaches B. Answers come from a resolved call graph and are verified against it; nothing is guessed. Java, TypeScript, Python, JavaScript.",
"author": { "name": "AxiomCode" },
"homepage": "https://github.com/AxiomCodeAI/axiomcodegraph",
Expand Down
Loading