Skip to content

feat(dotnet): expose parameter constant defaults - #10626

Open
Davmunrey wants to merge 24 commits into
morluto:mainfrom
Davmunrey:claude/dotnet-param-defaults
Open

Davmunrey wants to merge 24 commits into
morluto:mainfrom
Davmunrey:claude/dotnet-param-defaults

Conversation

@Davmunrey

Copy link
Copy Markdown
Contributor

Summary

Fixes #5150. Field defaults landed in #8015. Each selected method now reports parameter_defaults, decoded by the same ECMA-335 Constant owner that fields use.

Change and scope

  • ManagedFieldConstants.ts becomes ManagedConstants.ts. It builds one declaration index for Field and Param parents and reads each HasDefault flag correctly (fields 0x8000, params 0x1000).
  • ManagedParameterDefaults.ts attributes ParamList runs as II.22.26 specifies, including ParamPtr.
  • parameter_defaults can take three forms:
    • []: examined, no defaults;
    • null: unattributable run, with an issue reported;
    • omitted: historical Evidence.
  • Contradictory defaults are reported as unavailable with a limitation.
  • Resource bound: a nonempty run out of order with another is marked unknown. Total work therefore stays linear on malformed metadata, the same approach as the existing TypeDef ownership bound.
  • Not included: property defaults and enum-name mapping.

Evidence and regression coverage

  • ManagedParameterDefaults.test.ts: 12 of 14 failed on the base (the other 2 are negative guards). All pass after the change.
  • The MCP boundary test pages parameter_defaults from retained Evidence.
  • Gap: only source-owned PE fixtures were used. No compiled assembly was inspected.

Validation performed

  • npm run test:local on the dotnet suite: 677 passed.
  • Boundary tests: 102 passed.
  • npm run docs:check and npm run check:fast passed.

Author readiness

Human owner: @Davmunrey

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

inspect_managed_members decoded ECMA-335 Constant rows only for fields.
A Param row with HasDefault had no value anywhere in the result, and the
limitation said parameter and property defaults were not decoded.

The field reader becomes the inspection's single Constant-table owner
(ManagedConstants.ts): it indexes Field and Param parents once, and fields
and methods share it. Each selected method now reports parameter_defaults:
the Param rows of its ParamList run that declare HasDefault or own a
Constant row, with token, row offset, sequence, name, flags and the same
constant record. An empty list means the run was examined; null means the
run cannot be attributed (out-of-range coordinate, a run that ends before
it starts or is out of order with another nonempty run, or an invalid
ParamPtr table), with an issue and partial coverage. ParamPtr positions
resolve through the existing member pointer owner. ParamList coordinates
are read without per-row cursor bookkeeping, so selected inspections are
not charged for unselected MethodDef rows. Out-of-order runs stay unknown
instead of being rescanned, which keeps examined Param positions bounded
by the Param list when malformed coordinates alternate.

managedFieldConstantSchema is renamed managedConstantSchema. The
limitation now names only property defaults and enum-name mappings,
member comparison discloses that parameter defaults are not compared, the
managed guide documents the field, and the managed PE fixture builder can
emit Param and ParamPtr rows and per-method signatures.

Validation: the new ManagedParameterDefaults tests fail on the base (12 of
14; the two passing ones are negative guards) and pass with the change;
all src/dotnet source tests with the member view and output-schema
contract tests (677), the MCP constants boundary test and both managed
comparison boundary tests pass; npm run check:fast and npm run docs:check
pass.

Refs morluto#5150
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T19:16:02.908882Z
We couldn’t complete this review. Comment @codex review to try again.
9c33a34 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no blocking issue remains.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no blocking issue remains.

Summary

Exposes parameter defaults through the same Constant reader used for fields.

  • Managed method reports now include parameter defaults.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  C["Constant table"] --> I["Shared declaration index"]
  F["Selected fields"] --> I
  M["MethodDef ParamList"] --> R["Check parameter ownership"]
  P["ParamPtr, when present"] --> R
  R --> D["Selected parameter defaults"]
  D --> I
  I --> E["Retained member Evidence"]
  E --> V["Field and method pages"]
Loading

Reviews (20) · Last reviewed commit: "refactor(dotnet): read retained Param ro..." · Reviewed by Greptile

Comment thread src/dotnet/ManagedMemberPointers.ts Resolved
Comment thread src/dotnet/ManagedParameterDefaults.ts Resolved
Comment thread scripts/fixtures/managed/pe.mjs Resolved
…wner

Review follow-up for parameter defaults.

With a ParamPtr table, a method owns the Param rows its pointer positions
name. A Param row that no pointer lists has no owning run. If that row
declares a default, it could belong to any method, yet every method
reported an empty, complete defaults list. The member-pointer owner now
keeps its validated positions with the lookup and answers whether a
definition row is listed without throwing per row. The default reader
checks unlisted rows once and reports every method's defaults as unknown,
with one invalid-row issue, when an unlisted row declares a default.
Unlisted rows without a default do not change the result.

One unreadable Param row, such as an invalid #Strings name index, no
longer drops the defaults already read and skips later ones. Each row is
read in isolation, and its failure is reported as a parse issue.

The PE fixture computes ParamList starts with a running counter instead
of rescanning earlier methods, and accepts a raw Param name index.

Tests: the unlisted-default and unreadable-name cases fail before this
change and pass after. src/dotnet and managed domain tests pass (615), as
do 36 managed boundary test files (410). check:fast passes.
Comment thread src/dotnet/ManagedParameterDefaults.ts Resolved
Comment thread src/dotnet/ManagedParameterDefaults.ts Resolved
Current main counts raw Buffer and DataView reads against baselines
that can only shrink, and merged with main this branch failed them:
- ManagedParameterDefaults.ts was new, with four reads.
- readMethodParamList and memberListDefinitionRow each added two.
- The renamed ManagedConstants.ts carried the read baselined under
  ManagedFieldConstants.ts.

Param rows, ParamList coordinates and pointer positions are now read
through the checked BinaryReader. Layout admission still bounds every
row. A retained default reserves its row bookkeeping as its cursor did,
and rows without a default are still neither retained nor charged. The
renamed file keeps its single existing read under its new path.

Tests: src/dotnet and managed domain tests (607) and 36 managed boundary
test files (410) pass. architecture-guards, format:check and
check:ci:fast pass on the branch merged with main.
Comment thread src/dotnet/ManagedParameterDefaults.ts Resolved

@Davmunrey Davmunrey left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status since opening:

  • Greptile findings fixed in fa7e2ee:
    • a default on a Param row that no ParamPtr row lists keeps every method's defaults unknown;
    • one unreadable Param name no longer hides sibling defaults;
    • the fixture counter is linear.
  • Merged current main in 0d46ae3. To pass main's raw-read guard, 821eeb5 reads Param rows, ParamList coordinates and pointer positions through BinaryReader. The renamed ManagedConstants.ts keeps its one baselined read.
  • Validation on the merged branch: dotnet and managed tests (607), managed boundary tests (410), architecture-guards, format:check and check:ci:fast.
  • Related design question about that guard and the checked metadata cursor: #10688.

morluto#10952 made managed Evidence fields required where they were defaulted
only for historical Evidence. parameter_defaults follows the same rule:
it is required and nullable, the historical-omission sentence is gone
from the schema and the guide, the member-comparison disclosure reads
the field directly, the workflow example writes an empty list, and the
historical-omission test now checks that a member record without the
field is refused.
Review follow-up for parameter defaults.

Without ParamPtr, a first ParamList start of 2 leaves Param row 1
outside every method's run. A default on that row had no owning method,
yet every method reported a complete list. Ownership is now checked
through method runs as well as pointer membership. Positions before the
smallest valid ParamList start are scanned once with the unlisted
ParamPtr rows, and a default on any of them keeps every method's
defaults unknown with one invalid-row issue naming the reason. A leading
row without a default changes nothing.

Adds the feature record under docs/specs/managed/parameter-constant-defaults
(spec, plan, tasks) and indexes it, and updates the guide and schema
description for the unowned-row case.

Tests: the leading-default case fails before this change and passes
after; a leading row without a default stays complete. Managed and
contract tests (1003) and managed boundary tests pass. architecture-guards,
check:ci:fast and docs:check pass.
Main keeps each counted guard's baseline in scripts/verify/baselines/<guard>.json and moved BinaryReader to src/domain/binaryContainer. The branch's raw-buffer-read count follows its rename of ManagedFieldConstants.ts to ManagedConstants.ts (still 1), and its three readers import BinaryReader from the new module.
# Conflicts:
#	src/domain/managed/managedMemberPointers.ts
#	src/dotnet/ManagedConstantValue.ts
#	src/dotnet/ManagedFieldConstantsBudget.test.ts
#	src/dotnet/ManagedMemberRows.ts
#	src/dotnet/ManagedMethodDefinitionRows.ts
# Conflicts:
#	src/domain/managed/managedArtifact.ts
# Conflicts:
#	scripts/fixtures/managed/pe.mjs
@Davmunrey

Copy link
Copy Markdown
Contributor Author

The CI failure on 6c66908 came from main, not this branch. The Source tests job failed in 4 files (cliBundleResource, directAnalysisFactories, evidenceSubject, KernelBuildConfigService; 11 tests). Each fails the same way on main 2430b08 alone and passes on main 42cab26.

3c8fc14 merges main 42cab26. The only conflict was scripts/fixtures/managed/pe.mjs, which #11609 typed with JSDoc. The Param rows, ParamPtr rows, per-method signature and ParamList from this branch now follow that style, and the script type check passes. Earlier merges: 66a0889 (072b578, the .NET readers moved to src/domain/managed in #11544) and 6c66908 (2430b08).

On the merged tree, those 4 files pass. So do the managed unit tests (628) and the managed boundary tests (187), along with architecture-guards, check:ci:fast and docs:check.

… presence

The unowned-row scan cached its result with ??=, so a clean scan (null)
ran again for every selected method: the work grew with methods times
Param rows instead of methods plus rows.

The scan also called the Constant reader on each unowned row only to
learn whether a default exists, and that reader decodes and charges the
whole value. A large blob on an unowned row could exhaust the shared
decode budget before the row was reported, dropping facts already read.

The Constant owner now answers declares() from the row flags and its
declaration index without reading the blob, the scan uses it, and a
clean scan is cached. Tests count the scan's checks across two methods
and report an unowned default with less than one KiB of budget left.
# Conflicts:
#	scripts/fixtures/managed/pe.d.mts
# Conflicts:
#	docs/guides/managed/managed-code-analysis.md
#	docs/specs/README.md
#	scripts/verify/baselines/raw-buffer-read.json
Main's #Strings reader no longer takes the heap size; pass the three arguments it reads.
# Conflicts:
#	src/domain/managed/managedArtifact.ts
#	src/dotnet/ManagedConstantValue.ts
#	src/dotnet/ManagedMemberRows.ts
#	src/dotnet/ManagedMethodDefinitionRows.ts
# Conflicts:
#	docs/specs/README.md
Main moved planning records out of the repository in morluto#12856, so this
branch drops its docs/specs/managed/parameter-constant-defaults files and
the docs/specs/README.md entry; the design lives in the PR description.
Main split field and method decoding into decodeFieldRow and
decodeMethodRow with per-call contexts (morluto#13317) and rewrote the field
constant budget test (morluto#13365). Carry the parameter defaults onto that
shape: the inspection's shared Constant reader goes into parseFields and
parseMethods, the field context calls it with the Field table, and the
method context holds the Param default reader so both the full scan and
the selected-interval path report parameter_defaults. The budget test
now calls the shared reader with the Field table.
Comment thread src/domain/managed/managedArtifact.ts Resolved
Comment thread src/dotnet/ManagedParameterDefaults.ts Resolved
@Davmunrey

Copy link
Copy Markdown
Contributor Author

Merged main again after #13317 and #13365 split field and method decoding into decodeFieldRow/decodeMethodRow. The shared Constant reader now goes through those contexts, so both the full scan and the selected-interval path report parameter_defaults. Following #12856 the branch no longer adds docs/specs files; the design is in the PR description. Typecheck, build, 857 tests across src/dotnet, src/domain/managed and the managed MCP/provider boundaries, and docs:check pass, and the branch merges cleanly with main 64d42d2.

@morluto morluto added the enhancement New feature or request label Nov 22, 2026
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@Davmunrey thanks for the PR — there are 2 open review threads here:

Could you address or reply to these? Once they're resolved and CI is green we can take another look.
cc @gensokyo-dev @dandgabr

Main replaced the hand-written append in the field constant index with
appendToMapList (morluto#14548). The branch keeps that index in
ManagedConstants.ts keyed by the parent token, so it uses the helper
with the token key.
…dable

parameter_defaults was a required method field, so retained managed-members Evidence saved by an earlier REA version, whose methods lack it, no longer parsed. The field is now exact-optional: every inspection still reports it, older Evidence loads and pages as before with no parameter-default facts, and member comparison treats a missing field like an empty one. The guide says so.
…cans

readMethodParamList and memberListDefinitionRow allocated a BinaryReader for every MethodDef coordinate and every pointer position. managedMetadataReader caches one reader per artifact buffer, as the tool-design guide asks, and metadataIndexAt reads a 2- or 4-byte index with it for scans that do not retain the rows they examine.
The Param reader decoded Flags, Sequence and Name with its own offsets and index width and charged the row budget by hand, repeating what metadataRowCursor owns for retained metadata rows. Rows that declare a default are now read through the cursor, which checks each column against the admitted row and charges the row once. Rows without one still read only their Flags column, through the shared managed reader, and are neither retained nor charged.
@Davmunrey

Copy link
Copy Markdown
Contributor Author

Thanks @morluto. Both threads are addressed, plus Greptile's new P2:

  • Breaking change: removed rather than declared. parameter_defaults is exact-optional, so Evidence saved before this change still loads (ee81503).
  • Duplicate Param rules: retained Param rows go through metadataRowCursor (8202897).
  • Per-row readers: one shared reader per buffer (ca8c0fe).

Typecheck, build, 871 tests across src/dotnet, src/domain/managed and the managed MCP/provider boundaries, module boundaries, architecture guards and docs:check pass, and the branch merges cleanly with main e8b2578.

@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Expose Constant-table default values for literal fields and parameters in inspect_managed_members

2 participants