Skip to content

resolve.h: IdentityNarrower class walks take their state explicitly (FILE-PILE stage A) - #837

Open
joyful-ii-V-I wants to merge 3 commits into
mainfrom
lane/resolve-walk
Open

joyful-ii-V-I wants to merge 3 commits into
mainfrom
lane/resolve-walk

Conversation

@joyful-ii-V-I

@joyful-ii-V-I joyful-ii-V-I commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

FILE-PILE dogfood, stage 1a: src/resolve.h IdentityNarrower class walks (stage A only). This is a readability refactor and should not change output.

Cause

The cause is shared state. The ancestor walk (step 2) and the subclass dispatch walk (step 3) passed their inputs and results through mutable members:

  • keyScope ("Class::callee") was built by visitAncestor / appendClassDefinitions and read as the real input of appendOwnedDefinitions / appendSpecializationDefinitions.
  • hits was the output channel of 8 methods.
  • classWalk held the nameable classes first and the walk frontier later.
  • The level loop (assign, depth cap, clear next, visit each, swap) was written twice.

Change

  • ClassLevelWalk (level, next, seen, hits) owns the walk state. Every step that changes it takes ClassLevelWalk& explicitly. forEachLevel is the one level loop that both walks use. The instance is still IdentityNarrower scratch, reused across the resolve loop as before.
  • memberKey builds the key. The key is now an explicit parameter.
  • inheritedDefinitions / subclassDefinitions return the memoised answer directly instead of copying it into a shared buffer. It stays valid until the next narrow, the same contract as before.
  • nameable and nameableHits each hold one thing.
  • Visit order and visited-set insertion order are unchanged.

Not in this PR: stage B (Narrower's fieldWalk / guarded walk twins). It waits for lane/d3-swappable, and this diff stays off its hunks.

Numbers

  • byteid vs a main build (9db391d):
    • --deps/map md5, cold and warm, on envoy/cockroach/vscode: 12/12 SAME.
    • fire321 run 1: 264 jobs, because the s1 set was killed by an outside SIGTERM on both sides. 2 changed, both in that partial s1.
    • s1 re-fired on its own: 164 jobs, 5 changed (koa, kysely, nfpm, rake, starlette). Every diff is a history_unread/churn flip, going in both directions. That is the git-history read being cut off under load. None of these repos is C-family, and Rule 2 class identity only runs on C-family code.
    • mf1/d2/ld2/ld: 0 changed.
    • A base-vs-base re-fire of those 5 jobs was not run.
  • llvm canary: PENDING on the M5 (main vs head: --deps/map md5 + peak memory), requested in M2_TO_M5_1127_RESOLVE_CANARY.md.
  • nt (series formula: ccx 5-14, tangle < 6), summed over the touched files (resolve.h only): 1304 → 1297 (−7), over 988 → 988.
  • Coupling (IdentityNarrower methods that use the walk state through hidden members): 18 → 2 (inheritedDefinitions, subclassDefinitions, which start a walk on the owned scratch). 8 methods now take the walk explicitly.
  • quality-delta origin/main..HEAD:
    • 7 api-surface contract-change rows gated. Each is a parameter that replaces a hidden member, on private helpers of one struct, with all callers updated here. They are acked in .ripwire_quality_acks.
    • 2 minor params rows remain.
    • Gating 0 after the ack.
  • Gates: cppextqualcheck, guardedwalkcheck, ifacedispatchcheck, ifacepeelcheck, narrowcheck, chaconecheck, clsrecvcheck, fieldnarrowcheck, receiverevidencecheck, rule3memberguardcheck, namewalkcheck, decltodefcheck and resolverhonestycheck all PASS. prepush_meta: see below.

Blind review

An Opus high reviewer was given only the diff and the file: no scores, no brief. Verdict: BETTER.

  • The split buffers (nameable, nameableHits, ClassLevelWalk) each say what they hold.
  • The walk state is now visible in signatures.
  • The memo answers are returned, not left in a side channel.
  • The shared visited set (classes and definitions) is now documented.
  • It found no behaviour change, and checked visited-set ordering, pointer lifetime and the early return.
  • Noted as moved rather than removed: the forEachLevel lambda plus the captured answered flag, and memberKey's shared buffer.
  • Two nits were applied: markVisited, and a note on the memberKey aliasing.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Class hierarchy searches now avoid duplicate definition matches while continuing to check inheritance levels in order and stop at the shallowest level with a match. Ambiguous class names remain handled as before. These changes improve consistency in how inherited definitions are resolved without changing established search behavior; no new user-facing features or behavior changes are included.

joyful-ii-V-I and others added 2 commits November 27, 2026 15:24
…FILE-PILE stage A)

The ancestor walk (step 2) and the subclass dispatch walk (step 3) shared
hidden members: keyScope was built by one method and read as the input of
another, hits was the output channel of eight methods, and classWalk held
first the nameable classes and then the walk frontier.

- ClassLevelWalk (level, next, seen, hits) owns the walk state and is passed
  as a parameter to every step that changes it; forEachLevel is the one
  level loop both walks use. The instance stays IdentityNarrower scratch.
- memberKey builds "Class::callee"; the key is an explicit parameter of
  appendOwnedDefinitions / appendSpecializationDefinitions.
- inheritedDefinitions / subclassDefinitions return the memoised answer
  instead of copying it into a shared buffer; nameable and nameableHits
  each hold one thing.

Output-neutral by construction (same visit and insertion order).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ey now explicit parameters)

Seven IdentityNarrower helpers gain a ClassLevelWalk& (or the key) in place
of the hidden members they read and wrote; every caller is in the same
struct and updated in the same commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Walkthrough

The change consolidates IdentityNarrower traversal state in ClassLevelWalk, passes walk state and lookup keys explicitly, and returns retained definition lists from inherited and subclass searches. It also separates nameability candidate storage and adds six api-surface acknowledgement records.

Changes: Class-walk lookup

Layer / File(s) Summary
Centralize traversal and candidate state
src/resolve.h
ClassLevelWalk tracks visited classes and deduplicated definition hits. Nameability checks use separate candidate storage.
Collect owned definitions and cache inherited results
src/resolve.h, .ripwire_quality_acks
Owned-definition and specialization helpers receive explicit keys and walk state. Inherited searches return retained definition lists. Six acknowledgement records describe the API-surface changes.
Share state across subclass lookup and callers
src/resolve.h
Subclass searches collect direct and inherited definitions and return retained lists. Lookup claims and inherited-body collection use the updated results and walk state.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Suggested reviewers: barefootski, mpapis

Merge Risk: Minimal · up to b5f2c

This refactors the internal class-walk logic with no intended change in output. The author reports unchanged outputs on large codebases and passing local checks, and no concrete defects were identified, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: IdentityNarrower class walks in src/resolve.h now receive their state explicitly (ClassLevelWalk passed as a parameter), which matches the summarized signature changes…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: IdentityNarrower class walks in src/resolve.h now receive their state explicitly (ClassLevelWalk passed as a parameter), which matches the summarized signature changes and the PR objectives. It also includes the stage label FILE-PILE stage A, which is extra context but not noise that obscures the change.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8b0202f and b5f2cda.

Files selected for processing: 1

  • src/resolve.h

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

…name collision)

portablebuildcheck #7 resolves a range-for's callee by name; a new
by-value queue() made src/backhops.h:841's m_back.queue().putsIn() read
as a range-for over a temporary's member. Rename only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joyful-ii-V-I

Copy link
Copy Markdown
Collaborator Author

CI round 1: the 7 failing jobs were all portablebuildcheck #7. It resolves a range-for's callee by name, so the new by-value ClassLevelWalk::queue made src/backhops.h:841 (m_back.queue().putsIn( u )) look like a range-for over a temporary's member. b5f2cda renames it to queueNext and changes nothing else. portablebuildcheck, narrowcheck and guardedwalkcheck pass locally.

@joyful-ii-V-I

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant