mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 19:53:50 +00:00
feat(managed): project call and field-access edges into the application graph (#6260)
project_managed_application_graph dropped the call_edges and field_accesses that member Evidence already decodes, so the graph was a containment tree that could not answer who calls a P/Invoke wrapper or which methods touch a field, while reporting complete-within-inputs. In-module call/callvirt/newobj/jmp sites now become one calls edge per caller and target, and field loads, stores and address-takes become one accesses edge per method and field, each with site and per-opcode counts and member Evidence links. MemberRef and MethodSpec targets, unknown targets, ldftn/ldvirtftn loads, recursive self-calls (the graph has no self-loops), MemberRef fields and sites whose node is absent are counted by reason in limitations, and the graph is partial with that omitted_count. Add the provider-neutral accesses relation. Graph Evidence projected before these counters existed still parses, with null calls and field_accesses summaries. Fixes #4056 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
86357bad54
commit
c9b4cae9dc
9 files changed
+492
-19
No files matched your search
@@ -8,6 +8,35 @@ import { managedTokenScopesMatch } from "./managedInspectionEvidence.js";
|
||||
|
||||
type ManagedCoverageState = "complete" | "partial" | "unavailable";
|
||||
|
||||
/** Why a call site did not become a `calls` edge. */
|
||||
export type OmittedCallReason =
|
||||
| "member-ref"
|
||||
| "method-spec"
|
||||
| "unknown-target"
|
||||
| "method-reference"
|
||||
| "absent-node"
|
||||
| "self-call";
|
||||
|
||||
/** Why a field-access site did not become an `accesses` edge. */
|
||||
export type OmittedFieldAccessReason = "member-ref" | "absent-node";
|
||||
|
||||
/** Member-Evidence sites the projection counted but did not turn into edges. */
|
||||
export interface ManagedRelationOmissions {
|
||||
readonly callSites: Readonly<Record<OmittedCallReason, number>>;
|
||||
readonly fieldAccessSites: Readonly<Record<OmittedFieldAccessReason, number>>;
|
||||
}
|
||||
|
||||
/** Total sites counted but not projected. */
|
||||
export const omittedRelationSites = (
|
||||
omissions: ManagedRelationOmissions | null,
|
||||
): number =>
|
||||
omissions === null
|
||||
? 0
|
||||
: [
|
||||
...Object.values(omissions.callSites),
|
||||
...Object.values(omissions.fieldAccessSites),
|
||||
].reduce((total, count) => total + count, 0);
|
||||
|
||||
/** Source observations used to derive managed graph coverage. */
|
||||
export interface ManagedGraphCoverageSources {
|
||||
readonly artifact: ManagedArtifactInspection | null;
|
||||
@@ -21,13 +50,19 @@ export interface ManagedGraphProjectionOmissions {
|
||||
readonly unscopedTokenRelationships: boolean;
|
||||
/** Declaring types the member Evidence selected; null when it inspected every type. */
|
||||
readonly selectedTypes: readonly string[] | null;
|
||||
/** Counted call and field-access sites without edges; null without member Evidence. */
|
||||
readonly relations: ManagedRelationOmissions | null;
|
||||
}
|
||||
|
||||
const omitsAny = (omissions: ManagedGraphProjectionOmissions): boolean =>
|
||||
/** Omissions whose size is unknown, unlike counted relation sites. */
|
||||
const omitsUncounted = (omissions: ManagedGraphProjectionOmissions): boolean =>
|
||||
omissions.partialInput ||
|
||||
omissions.unscopedTokenRelationships ||
|
||||
omissions.selectedTypes !== null;
|
||||
|
||||
const omitsAny = (omissions: ManagedGraphProjectionOmissions): boolean =>
|
||||
omitsUncounted(omissions) || omittedRelationSites(omissions.relations) > 0;
|
||||
|
||||
const completeCoverage = (): ApplicationGraphEvidence["coverage"] => ({
|
||||
status: "complete",
|
||||
truncated: false,
|
||||
@@ -51,7 +86,9 @@ export const managedSourceCoverage = (
|
||||
/** Determine whether any supplied managed inspection was partial. */
|
||||
export const assessManagedGraphOmissions = (
|
||||
sources: ManagedGraphCoverageSources,
|
||||
relations: ManagedRelationOmissions | null,
|
||||
): ManagedGraphProjectionOmissions => ({
|
||||
relations,
|
||||
unscopedTokenRelationships:
|
||||
sources.members !== null &&
|
||||
sources.boundaries !== null &&
|
||||
@@ -79,7 +116,9 @@ export const managedGraphEvidenceCoverage = (
|
||||
? {
|
||||
status: "partial",
|
||||
truncated: false,
|
||||
omitted_count: null,
|
||||
omitted_count: omitsUncounted(omissions)
|
||||
? null
|
||||
: omittedRelationSites(omissions.relations),
|
||||
limits: [],
|
||||
}
|
||||
: completeCoverage();
|
||||
|
||||
Reference in new issue
Block a user