feat(managed): select declaring types in inspect_managed_members
Select exact declaring types before managed signatures and CIL bodies are decoded, preserving caller choices in CLI/MCP Evidence. Keep unmatched names and selected coverage explicit; comparisons and graphs retain unknowns outside their observed scope. Reuse existing metadata ownership/accounting and advertise unique selections through the actual SDK Schema. Validated with 229 focused tests across 21 files, 11 managed conformance controls, fullstatic/docs checks and real Linux CLI and fresh MCP inspection of two unchanged DLLs. All 118 selected CIL hashes matched original PE-mapped bytes; result/caller-argument parity and unmatched controls passed. Full artifact/native-boundary metadata is complete; whole-assembly members retain the unchanged 64 MiB resource constraint. No target code executes. Refs #1878 Co-authored-by: skared <190618464+skoodster@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Ysopwnable <161784452+N0zoM1z0@users.noreply.github.com> Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
This commit is contained in:
co-authored by
skared
Claude Opus 5.5
Ysopwnable
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Kaoru0822
parent
f28f338283
commit
a149d183ef
@@ -250,22 +250,74 @@ const groupBy = <Item>(
|
||||
return grouped;
|
||||
};
|
||||
|
||||
/** Whether a side's inventory observed members of this declaring type. */
|
||||
const observedBy =
|
||||
(side: ManagedMemberComparisonSide) =>
|
||||
({ declaring_type }: { readonly declaring_type: string | null }): boolean =>
|
||||
side.result.selection === null ||
|
||||
(declaring_type !== null &&
|
||||
side.result.selection.type_names.includes(declaring_type));
|
||||
|
||||
/**
|
||||
* Pair only members whose declaring type both sides observed. A member outside
|
||||
* the other side's selection stays one-sided, so a type selection never yields
|
||||
* a remap to a member of a type the other side did not inspect.
|
||||
*/
|
||||
const matchObserved = <Item extends { readonly declaring_type: string | null }>(
|
||||
left: readonly Item[],
|
||||
right: readonly Item[],
|
||||
sides: {
|
||||
readonly inLeft: (item: Item) => boolean;
|
||||
readonly inRight: (item: Item) => boolean;
|
||||
},
|
||||
match: (
|
||||
left: readonly Keyed<Item>[],
|
||||
right: readonly Keyed<Item>[],
|
||||
) => ReturnType<typeof matchByKeys<Item>>,
|
||||
key: (item: Item) => Keyed<Item>,
|
||||
): ReturnType<typeof matchByKeys<Item>> => {
|
||||
const matched = match(
|
||||
left.filter(sides.inRight).map(key),
|
||||
right.filter(sides.inLeft).map(key),
|
||||
);
|
||||
return {
|
||||
...matched,
|
||||
leftOnly: [
|
||||
...matched.leftOnly,
|
||||
...left.filter((item) => !sides.inRight(item)).map(key),
|
||||
],
|
||||
rightOnly: [
|
||||
...matched.rightOnly,
|
||||
...right.filter((item) => !sides.inLeft(item)).map(key),
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
export const keyMembers = (
|
||||
left: ManagedMemberComparisonSide,
|
||||
right: ManagedMemberComparisonSide,
|
||||
): {
|
||||
readonly methodMatches: ReturnType<typeof matchMethods>;
|
||||
readonly fieldMatches: ReturnType<typeof matchFields>;
|
||||
} => ({
|
||||
methodMatches: matchMethods(
|
||||
left.result.methods.map(keyMethod),
|
||||
right.result.methods.map(keyMethod),
|
||||
),
|
||||
fieldMatches: matchFields(
|
||||
left.result.fields.map(keyField),
|
||||
right.result.fields.map(keyField),
|
||||
),
|
||||
});
|
||||
} => {
|
||||
const sides = { inLeft: observedBy(left), inRight: observedBy(right) };
|
||||
return {
|
||||
methodMatches: matchObserved(
|
||||
left.result.methods,
|
||||
right.result.methods,
|
||||
sides,
|
||||
matchMethods,
|
||||
keyMethod,
|
||||
),
|
||||
fieldMatches: matchObserved(
|
||||
left.result.fields,
|
||||
right.result.fields,
|
||||
sides,
|
||||
matchFields,
|
||||
keyField,
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
export const parseManagedMemberEvidence = (
|
||||
evidence: unknown,
|
||||
|
||||
Reference in New Issue
Block a user