Skip to content

Release 0.23.0 - #134

Merged
Mx-Iris merged 57 commits into
mainfrom
next
Oct 15, 2026
Merged

Mx-Iris merged 57 commits into
mainfrom
next

Conversation

@Mx-Iris

@Mx-Iris Mx-Iris commented Oct 15, 2026

Copy link
Copy Markdown
Member

Merges next into main for the 0.23.0 release: 57 commits ahead of main. The user-facing summary is Changelogs/0.23.0.md, which also becomes the GitHub Release body.

What ships

  • Offline generic specialization: GenericSpecializer and TypeDefinition.specialize(...) work on a MachOFile.
  • SE-0491 module selectors: interface --module-selectors, dump --enable-module-selectors, SwiftDeclarationPrintConfiguration.usesModuleSelectors.
  • Local types named after the function or closure that declares them; ABI snapshot format 7.
  • Node.privateDeclarations and the new SwiftPrivateDiscriminators product.
  • marksNestedDefinitions, concurrent printing of definitions read from a MachOImage, RuntimeFieldLayoutMemo.removeAll().
  • Much faster indexing and printing of large images, especially in parallel.
  • Fixes: generic parameter depth (A2 for A1), same-named local types merging, protocols declared in an extension of another module's type, objc on dyld shared caches (MachOObjCSection 0.8.111 and 0.8.200), and more.

Breaking

  • Removed TypeDefinition.attributes; SymbolicDemangler.isCacheEnabled is a constant; OpaqueTypeResolving.opaqueType gains usesModuleSelectors; snapshots written before format 7 must be regenerated.
  • The deprecated reading forms stay until 0.24.0 instead of 0.23.0: MachOKitUI and swift-decompiler have not migrated yet.

Release checklist

  • Sources/Executables/swift-section/Version.swift = 0.23.0; both agent plugin manifests = 0.23.0
  • Changelogs/0.23.0.md present
  • Proposals 0062–0069 numbered and Implemented; evolution log sections 87–98 marked 0.23.0
  • Dependency floors: swift-demangling 0.7.2, swift-semantic-string 0.5.0, MachOObjCSection 0.8.200 (all tagged today)
  • Tag 0.23.0 after merge to trigger the release workflow

Verification (local, remote dependencies only)

  • Full suite (swift test --skip IntegrationTests, Xcode 26.6) on a git archive copy of this code with a fresh scratch: 2442 tests in 468 suites, raw exit code 1 from the two MultiPayloadEnumDescriptorCacheTests that already fail on this machine (enumLayout → nil at :101 and :130).
  • Release builds of swift-section on Xcode 26.6: x86_64 and arm64, 0 warnings, both run and report 0.23.0.
  • claude plugin validate (the marketplace with --strict) passes; every flag the agent skill names appears in the CLI's --help.

Mx-Iris added 30 commits October 2, 2026 13:57
… printing

RuntimeViewer builds a search corpus by printing every type of an image, and
a sample of that build spent 61% of a Swift type's print in the in-process
nested field-offset expansion and 9% of it scanning a stripped symbol table
for anonymous-context discriminators, neither of them cached.

- draft-nested-field-offset-memoization: cache one level of the expansion per
  metatype (field name, type name, relative offset, child metatype, isLast)
  and leave the walk itself untouched, so the output stays byte-identical by
  construction; memoize the discriminator per descriptor address.
- draft-concurrent-definition-printing: definitions index lazily behind an
  unlocked check-then-set and the printer writes their attributes on every
  print, so two tasks printing the same image race. RuntimeViewer already
  does that today. Index once behind a lock with synchronous index bodies,
  and pass the inferred attributes as a local instead of storing them.

Both drafts went through two independent review rounds; their decision logs
record what each round changed. Neither is accepted yet.
A definition indexed itself on its first print behind an unlocked
check-then-set, and the printer wrote TypeDefinition.attributes on every
print, so two tasks printing one image raced. RuntimeViewer already does
that: its display path and its search corpus both await into the
printer's nonisolated entries, which leave the section actor while they
print.

- index(in:) is synchronous and runs once through DefinitionIndexing: one
  process-wide lock over a table of passes in flight and each
  definition's completion flag. Callers arriving during a pass wait on
  the claimer's promise (SharedCacheBuildPromise with a Result payload)
  and share its outcome; a failed pass leaves the definition unindexed
  for a retry. Claiming or waiting from a thread already running a pass
  traps instead of risking a wait cycle.
- Printing writes nothing to a definition: type-level attributes are
  inferred into a local per print, and TypeDefinition.attributes is
  removed (RuntimeViewer, REAgent and swift-decompiler never read it).
  TypeAttributeInferrer drops its three reads of TypeDefinition.extensions,
  which nothing ever fills, and documents the gap they hid.
- TypeDefinition, ProtocolDefinition and ExtensionDefinition are
  @unchecked Sendable, with the reason on each type;
  SymbolicDemangler.isCacheEnabled becomes a constant.
- ConcurrentDefinitionPrintingTests prints the SymbolTestsCore fixture in
  process from many tasks, two printers, and a type together with its
  nested types, comparing every output with a serial print. Before the
  fix it crashed on a released attributes array and release+TSan
  reported 28 races; after it, debug, release+TSan (no reports) and a
  one-thread cooperative pool, with and without the large-stack executor,
  all pass. CI runs it in the main filter and in the strict-pool step.

The full suite passes (2163 tests, exit 0) and the rendering A/B against
4fd4049 is byte-identical over 92 pairs. Proposal
draft-concurrent-definition-printing is In Progress;
draft-nested-field-offset-memoization is Accepted.
… per metatype

RuntimeViewer's search corpus prints every type of an image in process,
and each print expanded every stored field's nested layout from runtime
metadata again: the same field type (String, UInt64, …) was re-resolved
and re-demangled at every occurrence. Release timing puts the expansion
at about a tenth of the print time.

- NestedFieldOffsetLevel records what one level of the walk reads about a
  metatype: each row's field name, type name and relative offset, the
  metatype one level down, and whether the row draws the closing branch,
  counted over every field record as before. NestedFieldOffsetLevelMemo
  keeps one per metatype for the process, built outside its lock with the
  first store winning. The walk keeps everything positional, so the output
  is byte-identical by construction.
- A level records which types failed to resolve, and an image loaded later
  can change that, so hosts get RuntimeFieldLayoutMemo.removeAll() (public,
  SwiftDeclarationRendering) to call after loading an image; a generation
  count keeps a build that straddles it from being stored.
- storedFieldComments resolves a field's metatype at most once, and only
  when the end offset, the expansion or the type layout will use it.
- InProcessContext memoizes the private discriminator of an anonymous
  context by address; resolving it otherwise rebuilt the owning image and
  scanned a symbol table that a dyld shared cache image has stripped.

NestedFieldOffsetMemoizationTests compares memoized and unmemoized
expansions of every stored field in the fixture and pins removeAll() and
the generation guard; AnonymousContextPrivateDiscriminatorTests checks the
memoized discriminators against AppKit's Objective-C runtime names. The
full suite passes (2168 tests), release+TSan reports nothing, and the
rendering A/B against 9f5ffa9 is byte-identical over 92 pairs, plus 16
in-process pairs with expanded field offsets on. Proposal
draft-nested-field-offset-memoization is In Progress.
RuntimeViewer prints a nested type twice for its search corpus: inline in
its parent's print and again as its own object. Its timing probe puts
that at about two fifths of the print time on Foundation and SwiftUI, so
it wants to cut each child's text out of the parent's print instead.
NestedDeclaration flattens a child's atoms into the parent and leaves no
boundary to cut at.

draft-nested-definition-regions proposes a marksNestedDefinitions switch
that wraps every inlined nested definition in a DefinitionRegion keyed by
the mangled name of its name node (what RuntimeViewer names the object
by), a matching region table and line-wise de-indentation in
swift-semantic-string, and a tested promise that a definition printed
inline reads byte for byte as printed alone apart from indentation. It
first needs a protocol nested in an extension to stop printing its
default-implementation extensions inside the enclosing extension's braces.
Draft only: four choices are left to the user, and nothing is implemented
before it is accepted.
…on without nesting its extensions

A protocol declared in an extension of another module's type keeps an
extension context and no parent, so the printer took it for a top-level
protocol and printed its default-implementation extensions right after it:
inside the enclosing extension's braces, at column 0. Swift cannot nest an
extension there; Foundation's interface read

    extension __C.NSNotificationCenter {
        protocol AsyncMessage { … }
    extension __C.NSNotificationCenter.AsyncMessage { … }
    …
    }

Only a top-level protocol now trails its extensions. The interface prints
those of a protocol declared in an extension in its top-level block for
nested protocols, beside the ones of protocols nested in a type. A protocol
declared in an extension of the module's own type is parented on the type
by the compiler and already printed right.

ProtocolInExtensionTests compiles a fixture with both kinds and failed
before the fix: the interface opened an extension inside another, and the
protocol printed on its own carried its extensions.

Proposal: draft-nested-definition-regions (the fix it calls for first).
…f their parent's print

RuntimeViewer prints every nested type twice for its Find corpus: inline in
its parent, and again as its own object — about forty percent of the print
time on Foundation and SwiftUI. With the new marksNestedDefinitions, each
nested type or protocol printed inside its parent (a type's nested
definitions, an extension's) is wrapped in swift-semantic-string's
DefinitionRegion, named by its name node's mangled name, the identity
RuntimeViewer names its objects by. The host prints the parent once and
takes each nested definition out instead of printing it again.

The contract, for a parent printed at level 1: a region at depth d, taken
out of the frozen print with content(ofDefinitionRegion:) and
removingIndentation(levels: d + 1), equals the definition printed on its
own by the same printer, in text, spans, identifiers and the tables both
separations produce. A child that throws is dropped as before and leaves no
region, and a name that does not remangle prints unmarked; the host prints
those on their own. Off, the output is unchanged.

NestedDefinitionRegionContractTests checks every nested definition of the
SymbolTestsCore fixture, in process and from the file, plain, marked, and
with every option and the Transformer templates on, and that each parent
has one region per nested definition. ProtocolInExtensionTests gains the
case the previous fix enabled. The full suite passes (2174 tests) and the
rendering A/B is byte-identical over 92 pairs.

This needs swift-semantic-string's feature/definition-regions; it cannot
land before that is released and the floor raised.

Proposal: draft-nested-definition-regions (In Progress).
…ine mode

GenericSpecializer.specialize calls the image's metadata accessor, so it
only works on a MachOImage loaded in the current process; RuntimeViewer's
planned offline mode reads MachOFile and cannot specialize at all. The draft
proposes a MachOFile execution path that never touches the runtime: the
instantiated type name and the per-depth argument binding built the way the
runtime's _buildDemanglingForContext builds them, an offline requirement
check that rejects only the violations it can prove, and interface printing
of the specialized definition with a bound header, substituted field types
and layout comments computed by the static layout engine.

It also records two existing problems the work would fix: generic parameter
depths miscounted when a non-generic level sits between generic ones, and
runtime-specialized nested type names flattened into the innermost level.
GenericSpecializer.specialize calls the image's metadata accessor, so only
a MachOImage loaded in the current process could be specialized;
RuntimeViewer's planned offline mode reads a MachOFile and could not
specialize at all. GenericSpecializer<MachOFile> now has
specialize(_:with:) and staticPreflight(selection:for:), mirroring the
in-process steps without touching the runtime:

- The selected arguments become type nodes, the parameters a same-type
  requirement fixes are filled in from it (GenericInstantiation), and the
  arguments are grouped by depth into a GenericArgumentBinding. The
  instantiated type name is built the way the runtime's
  _buildDemanglingForContext builds it
  (SymbolicDemangler.instantiatedTypeNode). The result is a
  StaticSpecializationResult.
- The requirement check rejects only what it can prove violated: a value
  type given for AnyObject, a known class outside the required subtree,
  an associated-type same-type pair resolving to two different types.
  What it cannot prove offline is a warning. Both reuse the existing
  SpecializationValidation cases, which RuntimeViewer switches over
  exhaustively.
- TypeDefinition.specialize(with:in:) takes the result. The specialized
  definition carries the binding in staticSpecialization where an
  in-process one carries metadata, and the interface printer renders
  from it the bound header, the substituted field types (associated
  types projected through their witnesses) and every layout comment,
  which the static layout engine now computes for a binding of any
  depth.

Fixed on the way:

- A generic parameter's depth counts only the contexts that declare
  parameters (GenericParameterDepthLayout). Five places counted
  ancestors instead: the specializer, the dump and interface headers,
  RuntimeMetadataTypeBuilder and AccessorThunkOwnerLayout named B in
  Outer<A>.Middle.Inner<B> "A2" while every field and requirement read
  "A1", and GenericArgumentEnvironment's walk of an instantiated type
  name stopped at an extension node.
- An in-process specialization's typeName hangs each argument on its own
  level: Outer<Int>.Inner<String>, not Outer.Inner<Int, String>.
- An offline request dropped every requirement on another image's
  protocol: read from a file, that reference is a bind.
- The static expanded field-offset tree projects a concrete type's
  associated types before naming them and descending into them.
- The in-process path gives a specialized generic enum its Enum Layout
  comment as well, so the two paths compare byte for byte.

OfflineSpecializationParityTests compiles a dylib, specializes it once
read as a MachOFile and once dlopened as a MachOImage, and prints both
with every layout comment on: byte-identical. Each fix above has a test
that failed before it; 39 tests are new. The full suite passes on top of
feature/runtime-viewer/find-navigator (2224 tests, exit 0).
The rendering A/B against the proposal commit, before this branch was
rebased onto find-navigator, covers 132 pairs: 90 identical, and the 42
that differ show only the corrected header depths, the projected
expanded offsets, and a constrained extension's type substituted with
the right argument.

Proposal: draft-offline-generic-specialization (In Progress).
…r/find-navigator

# Conflicts:
#	.github/workflows/macOS.yml
#	AGENTS.md
#	Documentations/Evolutions/README.md
#	Documentations/Internal/ProjectEvolutionLog.md
#	Documentations/README.md
An opaque type reference carries one generic argument list per
declaration around the opaque result, outermost first, and the mangler
writes a list for every such declaration: an empty one for a level that
declares no parameter (ASTMangler::appendBoundGenericArgs). The rewriter
took a list's position for its depth, so every list after a non-generic
level was read as one level further out. The argument of a generic
function in a non-generic type was looked up in the empty list and never
substituted - Xcodes' MainToolbarModifier.Body printed
SwiftUI.TupleToolbarContent<A> - and an inner level took an outer
level's argument, printing a real but wrong type.

The runtime's resolveOpaqueType flattens the lists and regroups them by
the descriptor's own depths (_gatherGenericParameters).
opaqueTypeGenericArgumentsByDepth now does the same with the opaque type
descriptor's GenericParameterDepthLayout, which ReadOpaqueType already
computes. Without a layout the lists stay keyed by position, which the
reference spelling, flattening them anyway, still relies on.

OpaqueTypeArgumentDepthTests failed before (ProbeWrapper<A> and
ProbePair<A, Swift.Int>) and passes now. PR #131 review finding 1; the
bug predates the PR.
The opaque type provider counted the depths around an opaque result as
the parent levels that grow the parameter count. An extension of a
nested generic type brings several depths at once - `extension
Outer.SecondMiddle where A: Hashable` brings Outer's A and
SecondMiddle's C - and was counted as one, so a constraint on τ_2_0 lay
beyond the computed depth: a debug build trapped in the provider, and a
release build printed a bare `some`.

Take the depth count of the nearest type or extension up the
descriptor's parent chain from GenericParameterDepthLayout, which splits
an extension by the type it extends, as the runtime's
_gatherGenericParameterCounts does. An anonymous context in between is
where a generic declaration's own signature lives and is passed over:
its depth is the one declaresOwnGenericParameters adds.

OpaqueParameterInMultiDepthExtensionTests trapped before and passes now.
PR #131 review finding 8; the bug predates the PR.
ThunkTypeNodeBuilder bound the arguments a kind-9 accessor thunk passes
by walking the type contexts and counting each level's own key
parameters. An extension context is no type level of that walk, so the
accessor of `extension Outer where A: Hashable { struct Inner<B> }`,
which takes A and B, counted one parameter, the counts did not match,
and the field printed as `accessor function at ...`.

When every parameter of the type's whole generic context takes a key
argument, the arguments are one per parameter: group them with
GenericParameterDepthLayout and name the instantiation the way the
runtime does (SymbolicDemangler.instantiatedTypeNode). Otherwise keep
the walk. It is what names a type in a same-type-constrained extension,
which receives its own parameters' arguments alone; replacing the walk
outright turned that field into `accessor function at ...` as well, so a
guard test pins the shape.

AccessorThunkTypeInGenericExtensionTests: the first test failed before
and passes now; the guard test passes before and after, and failed on
the replacement. PR #131 review finding 13; the bug predates the PR.
The offline check took ConformanceProvider.subclasses(of:) for proof.
That class hierarchy links only indexed Swift classes, so a Swift class
below an Objective-C class - FixtureOperation: Operation for
<Subject: NSObject> - fell out of the subtree, and as the class itself
was indexed, the check reported a definite violation: staticPreflight
failed and specialize threw, where the runtime accepts the selection.

Walk up the superclass chain the indexed images describe instead,
comparing unbound class names. Reaching the base proves the requirement,
a root class reached without it proves the violation, and a link no
indexed image describes - an Objective-C class, or a class of an image
the indexer does not hold - only warns. ConformanceProvider gains
superclassLink(of:), defaulting to .unknown, and the public
SuperclassLink enum; the warning branch no input reached goes.

OfflineObjectiveCBaseClassTests failed before and passes now. PR #131
review finding 2.
When a same-type requirement ties two parameters (`First == Second`),
the compiler writes the one that keeps its key argument on the left, and
the runtime's _gatherWrittenGenericParameters copies its argument to the
right-hand one. fillFixedParameters read the requirement from the left
only, so Second was never bound: the offline specialization threw
unresolvedFixedParameter, and the runtime one fell back to a flat name,
TiedParameterPair<Swift.Int>, while its header printed the runtime's
TiedParameterPair<Swift.Int, Swift.Int>.

Read such a requirement both ways. And when naming a runtime
specialization still fails, log why before falling back to the flat
name, which names no instantiation.

GenericSpecializationFixture gains TiedParameterPair. Both
TiedParameterInstantiationTests failed before and pass now. PR #131
review findings 3 and 10.
A protocol declared in an extension of another module's type prints,
and is indexed, only in the interface's extensions block, while its
default-implementation extensions print in the nested-protocol block
before it. Under library evolution a default that comes from a parent
protocol's extension is a witness named after the requirement itself;
prepare()'s symbol scan misses it, and the protocol's own index pass
synthesizes its extension. The block read the list before that pass, so
the extension printed nowhere, and a second print of the same builder
showed it.

Index the protocol before reading the list: index(in:) is synchronous,
idempotent and runs once.

ProtocolInExtensionDefaultWitnessTests failed before and passes now.
PR #131 review finding 4.
The indexer records a conformance under the type's unbound name and
drops its conditions, so the offline check took Array's Hashable record
for proof that [FixtureUnmarked] is Hashable: no warning, and specialize
built an instantiation that cannot exist, which the runtime path
rejects.

When the recorded conformance is conditional - its descriptor counts
conditional requirements - warn instead. Checking the conditions
against the binding is left for later. ConformanceProvider gains
isConditionalConformance(of:to:), defaulting to false.

OfflineConditionalConformanceTests failed before and passes now.
PR #131 review finding 5.
The static expanded field-offset tree projects a concrete type's
associated type through its witness record. A record keeps an opaque
type reference for the result of a `dynamic` declaration or of an
availability-conditional `some`, and the projection spliced it into the
row: `() -> opaque type symbolic reference 0x1A60.0`, where 0.21.0
printed the member, `DynamicConcrete.Shape.Body`.

Do not project a witness holding an opaque type or a kind-9 accessor
reference; the member name stays.

NestedFieldOffsetOpaqueWitnessTests failed before for both shapes and
passes now. PR #131 review finding 6.
specializedChildren lives in a non-atomic associated object that
specialize(...) reads, appends to and writes back. TypeDefinition is
@unchecked Sendable, and RuntimeViewer awaits specialize(...) from its
section actor: a nonisolated async method, which runs off the actor
while the actor goes on reading the list. Two specializations at once
lost one, and a read overlapping a write could retain an array the
write had just released.

Read and append under one process-wide lock. The storage stays an
associated object: moving it into TypeDefinition would change the
instance size DeclarationModelInstanceSizeTests pins. AGENTS.md and
TypeDefinition's documentation no longer call the append unlocked.

ConcurrentSpecializationTests specializes one definition from 512 tasks
in a child process: 445 to 467 were kept before, all 512 now. PR #131
review finding 7.
Printing an offline specialization projected its fields' associated
types through search paths taken from the thunk resolver, or inferred
from where the binary sits plus the host's cache, never from the
print's staticLayoutDependencyResolution. The host's macOS images are
no candidates for an iOS binary, so with an iOS simulator cache
configured the layout comment was computed for Int? while the field
still read [Int].Element?.

When the print has a static field-layout provider, project through it.
StaticFieldLayoutProvider gains projectingConcreteMembers(in:),
defaulting to nil, which the MachOFile provider answers over the images
its layouts are computed from, through StaticLayoutCalculator's new
public method of the same name. staticPreflight has no print
configuration and keeps the default path.

OfflineProjectionDependencyResolutionTests runs only where
/Volumes/DyldSharedCaches/iOS-Simulator/27.0 exists; there it failed
before and passes now. PR #131 review finding 11.
Both associated-type projection entries did their work for every node.
The rendering one inferred search paths (listing directories), took two
locks and, on its first call, built a whole dependency closure even for
a plain Swift.Int; the image universe one rebuilt every node on the way.
Return a node holding no dependentMemberType untouched.

PR #131 review finding 14.
Rename param, paramName, protocolRef, swiftProto, proto and info in the
lines the offline specialization rewrote, and compile
ProtocolInExtensionTests' fixture in an explicit Swift 5 mode.

Both were cut from the PR #131 review by its findings cap.
…eads

MachOFile's and DyldCache's file mappings and handles are created on
their first read and stored in non-atomic associated objects, with no
lock. One DyldCache is read by many readers at once: a FullDyldCache
hands the same sub-cache instances to every image read from it, and
FullDyldCache.cachedHost is opened once per process, so diff and
evolution, preparing their inputs concurrently, make a sub-cache's first
read from several roots together. Each racing reader mapped the file
again and stored its mapping over the others', and one holding a
replaced mapping unretained could read through a file already unmapped.

Create each under a lock and store it once; every later read still
takes it without the lock. Found in the cross-check of PR #131 review
finding 7: the same unlocked write to a non-atomic associated object.

ConcurrentFileMappingTests races 32 threads on a fresh instance's first
read, 20 rounds per accessor. Before, 12 to 19 of the rounds handed the
readers 2 to 7 distinct objects, for each of the four accessors; now
every round hands out one.
The main filter now includes the offline specialization and depth
suites, the review's repro suites and ConcurrentFileMappingTests - all
but OfflineProjectionDependencyResolutionTests, which needs an archived
iOS simulator cache. And the one-thread cooperative pool step could not
catch an index pass waiting on a pool thread: on the runner every print
runs on the demangler's large-stack executor, whose threads the strict
pool does not shrink. A new step runs ConcurrentDefinitionPrintingTests
there with the executor off, the way prints run below macOS 15.

PR #131 review finding 15. These suites have not run on the CI's Xcode
26.6 yet; locally they pass under its Swift 6.3.3.
- Roadmaps/2026-10-08-pr131-review-findings.md: the 15 findings, each
  with the four questions, its repro test, the fix and before and after
  examples, and the landing record: the commits, the verification on
  this machine and the rendering A/B.
- ReviewAdjudications A53-A59: findings 9 and 12, the intended name
  difference in finding 10, three minor items the findings cap cut, and
  the four candidates the review's verifiers refuted.
- The decision logs of the four proposals the fixes touch; the offline
  specialization note (the superclass walk, conditional conformances,
  tied parameters, projection through the print's images); the opaque
  return type note (argument lists regrouped by depth, the provider's
  depth count); the SwiftThunkAnalysis and MachODependencies module
  notes.
- AGENTS.md: eight readers, not five, once counted depths wrongly.
- ProjectEvolutionLog: a section for this batch, numbered at landing.

Verified on JHs-Mac-Studio with Xcode 26.6 (Swift 6.3.3): the full
suite runs 2358 tests in 448 suites and fails only the two
MultiPayloadEnumDescriptorCacheTests tests that fail the same way on
beae202 here, besides the registered known issue. The rendering A/B
against beae202 is byte-identical over 90 pairs.
…default implementations

RuntimeViewer's Find corpus and content pane print a protocol's
default-implementation extensions themselves whenever the printer does
not trail the declaration with them, so they need the printer's rule.
It was private, so RuntimeViewer copied it; when bca9594 added
`extensionContext == nil` to it, the copy was wrong until RuntimeViewer
followed in a commit of its own (74c349c7). This package held two
copies as well: the printer's condition, and its negation in
SwiftInterfaceBuilder's block for nested protocols.

ProtocolDefinition.printsDefaultImplementationExtensionsAfterDeclaration
now states the rule once: true only for a protocol declared at the top
level, neither nested in a type nor declared in an extension of another
module's type. Three places change:

- ProtocolDefinition gains the public property. Its documentation gives
  the rule, why a nested protocol and one declared in another module's
  extension print their extensions at the top level instead, and that
  the printer, the interface builder and hosts all read it.
- SwiftDeclarationPrinter.printProtocolDefinition trails the declaration
  with the extensions when the property is true.
- SwiftInterfaceBuilder prints, in its block for nested protocols, the
  extensions of every protocol for which it is false.

Behavior is unchanged. On JHs-Mac-Studio with Xcode 27.0 and the local
sibling dependencies, SwiftInterfaceTests, SwiftSectionKitTests and
SwiftPrintingTests (without EnumCaseRenderingParityTests) give the same
per-test results before and after: 289 -> 290, 64 and 42 tests, all
passing, raw exit code 0. The added one is the new test; the
whole-module SymbolTestsCore interface snapshot is among the rest.
EnumCaseRenderingParityTests crashes (SIGSEGV) in its first test in
this environment, before and after alike.

ProtocolInExtensionTests' fixture gains a top-level protocol, and a new
test pins the property true / false / false for a protocol declared at
the top level, in a type, and in an extension of Int. With the property
set back to `parent == nil` alone, the rule before bca9594, that test
fails along with the suite's three existing ones, so the printer and
the interface builder both go through the property.

Docs: the decision log of draft-nested-definition-regions, a note in
the evolution log's section for it, and ExtensionContainerUnification's
description of the trailing path.

RuntimeViewer PR #121 review finding PR121.27.
LLVM 23 gives objc_direct methods a stable `-[Class sel]D` symbol and
Swift is pitching `@objcDirect` on top of it. Such methods have no
method list entry, so the ObjC member recovery would silently miss them.
Record the upstream status, the binary shape and the constraints a
future reader must respect, in a new section for ObjC-side changes.
A type declared in a function or closure sits under a chain of anonymous
contexts, which have no name of their own. SymbolicDemangler dropped the
chain, so the type read as a member of its outer type and same-named ones
merged: SwiftUI's TableDataSource declares seven Visitors, and its
interface printed one of them six times. In a private function's body the
type borrowed the function's private discriminator and became a private
type that does not exist. Its members, whose symbols spell the real name,
then matched nothing and were lost. Debug builds went wrong too.

- SymbolicDemangler names an anonymous context from the descriptor's own
  mangled name, the `$s<context>MXX` symbol on the descriptor, or a
  `_symbolic` symbol naming the type it wraps, in that order.
  AnonymousContextNameIndex (was AnonymousContextPrivateDiscriminatorIndex)
  collects the last. A local type's function and closures replace the
  chain; a private discriminator is read from the wrapped type's own name
  only.
- With none of the three, a local type is named after its anonymous
  context's address, `Holder.(Visitor in $1a2b3c)`, as the runtime and
  Remote Mirror do. The new public LocalTypeNaming tells the compiler's
  name from such a placeholder, whose shape is a private type's.
- RuntimeTypeNameDemangling and NodeTypeNaming give runtime names and
  qualified names the same function context.
- The interface prints a local type's short name where a type is
  referenced, a comment naming its function above its declaration, and
  the compiler's full name in a conformance's extension header.
- ABISnapshotDocument's formatVersion goes from 6 to 7: every local type
  is keyed by a new name, so an older baseline is rejected rather than
  reporting each one removed.

With the names matching, five whole-tree searches over member nodes found
the local type's enclosing declaration first, since a member node's first
child is its context: conformance members were bucketed by it and lost to
deduplication, a synthesized hash(into:) printed twice in the body,
@dynamicMemberLookup went uninferred, unlabeled parameters took their
`_:` count from the enclosing function, and a static stored property of a
type declared in a getter printed as computed. These now read the
member's own node (memberSubtree, accessorKind).

LocalTypeFixture compiles local types in five variants, each keeping a
different name source, beside twins declared outside any function body.
The four new suites and each of the five member fixes failed before the
change and pass after it. The full suite passes (2383 tests); see
ProjectEvolutionLog section 87 for the system-framework A/B.
- The proposal, with the three choices the user made: local types stay
  nested in their outer type, the interface prints their short name with
  a comment naming the function, and a local type no source names gets a
  position-based name.
- SymbolicManglingSymbols: `_symbolic` symbols are one of three sources of
  a local type's name, and the AppKit known issue is gone.
- Glossary: position-based name.
- AGENTS.md: an anonymous context's name is the compiler's whole mangling,
  and a whole-tree search over a member node meets its context first
  (memberSubtree, accessorKind).
- ReviewAdjudications A60: three searches of that shape left as they are.
- swift-section agent skill: how dump and interface spell local types, and
  why snapshot format 7 rejects format-6 baselines.
- FixtureTestingAndContinuousIntegration: re-record a snapshot by deleting
  its file; the suites' `.snapshots(record: .missing)` overrides
  SNAPSHOT_TESTING_RECORD.
- The 2026-09-24 roadmap entry, the evolution log and MachOCaches follow.
Numbers the proposal against the shared branches (origin/next and
origin/main at 0061), marks it Implemented with the closing judgements,
updates every link to the draft, and records the batch as section 87 of
the evolution ledger.
RuntimeViewer tags a private type in its sidebar and lists the private
discriminators its name carries, with the source file each one was
derived from. Both computations lived in RuntimeViewer; they move here
so that the host only presents them.

- SwiftInspection: `Node.privateDeclarations` and
  `NodeReference.privateDeclarations` return the `PrivateDeclaration`s
  (name and discriminator) a name reads, in reading order. The search
  covers the whole tree but skips the signature of a function or closure
  context and the `$` address of a position-based name: RuntimeViewer's
  search took that address for a discriminator and counted the private
  types in a local type's function signature. A nameless private
  initializer or subscript reads as `init` / `subscript`.
- SwiftDeclaration: `DefinitionName.localTypeDisplayName`, a local type's
  name without modules or parameter types (`Visitor #1 in
  TableDataSource.performDrop(to:)`). The interface's comment above a
  local type's declaration now takes it from there.
- New target and product SwiftPrivateDiscriminators. A discriminator is
  MD5(module name + file name), so candidate file names are hashed until
  one matches. `PrivateDiscriminatorSourceFiles` is that search, moved
  from RuntimeViewer unchanged, with its generated list of known file
  names and the script generating it. `PrivateDiscriminatorSourceFileIndex`
  takes one image's candidates from a prepared indexer, reads them once,
  outside its lock and in one large-stack hop, then lets the indexer go,
  and remembers every answer, recovered or not.
- Tests: the shapes a private declaration takes, on both readers of a
  compiled fixture; a whole-tree oracle over the fixture's and
  SymbolTestsCore's names; the display name; the search; and the
  per-image index (stack size, overlapping first requests, letting the
  indexer go). The two system-image cases, whose discriminators were
  taken on macOS 27.2, stay out of CI; the other new suites join its
  filter.
…tions

- The proposal, with the choices the user made: RuntimeViewer calls the
  recovery in its engine process, while the library takes the candidates
  from the image and keeps the answers per image; a local type's display
  name leaves out modules and parameter types; a private function's
  discriminator counts for the local types it declares. The six review
  findings and their fixes are in its decision log.
- Modules/SwiftPrivateDiscriminators: the search, the known file names
  and the per-image index, and how the index's candidates differ from
  RuntimeViewer's sidebar list.
- AGENTS.md: the new module, and `privateDeclarations` in SwiftInspection.
- Documentations/README, the module index and the proposal index.
Numbers the proposal against the shared branches (origin/next at 0062,
origin/main at 0061), marks it Implemented with the closing judgements
and the user's choice not to re-measure the recovery rate, updates every
link to the draft, registers "private declaration" in the glossary, and
records the batch as section 88 of the evolution ledger.
On a 512 KB thread every demangle and print hops to a large-stack worker
and blocks on it, so a lock held across one makes every waiter wait
behind the hop. RuntimeViewer reaches two such locks from an actor:

- IndexerConformanceProvider.classHierarchy() built its class maps under
  the cache's lock, demangling each class's superclass and printing two
  names per class, each a hop of its own. A miss now moves to a large
  stack first, in one hop, and takes the lock there, so the walk runs
  inline and nothing hops while the lock is held. A hit never hops. Both
  maps still come from one walk and are stored together.
- The four async TypeDefinition.specialize overloads are library entry
  points but never ran on the large-stack task executor. RuntimeViewer
  calls the deriving one from an actor, and through GenericInstantiation
  it takes DependentMemberProjection's per-image lock and hops per
  demangle under it. They now run through LargeStackTaskExecution.run
  like the other async entry points.

Tests, both red before the fix on a 536,576-byte stack: the class-map
build reports an injected unreadable class from inside the walk, and a
forwarding conformance provider is asked for candidates while a nested
type is derived; each records the stack it runs on. Both suites join
CI's filter.
- AGENTS.md: "Do not hold a lock across a demangle" becomes "never let a
  demangle or print hop while you hold a lock": be on a large stack
  already (an executor-wrapped entry point, or one withLargeStack taken
  before locking), or demangle outside the lock and insert-if-absent.
- ReviewAdjudications A61: the five other locks the sweep found (the
  printer's one-time builds, the static field layout provider, the
  dependent member projection, the property wrapper catalog, the ObjC
  ancestor resolver) stay as they are; every caller in the library and
  in RuntimeViewer reaches them through an executor-wrapped entry point.
- LargeStackTaskExecutorAdoption: the specialize overloads join the table
  of wrapped entry points.
- Evolution ledger section 89.
…dump

Swift 6.4 writes a .swiftinterface with module selectors (Swift::Int), and the
Xcode 27 SDK interfaces are spelled that way. Add an opt-in to match:
SwiftDeclarationPrintConfiguration.usesModuleSelectors and
'interface --module-selectors' for the interface, swift-demangling's
DemangleOptions.useModuleSelectors and 'dump --enable-module-selectors' for the
dump. Both are off by default, and off the output is unchanged.

The interface printer follows the compiler's rules, as swift-demangling now
does: every nested type carries the module that declared it, so a type another
module adds in an extension keeps its origin
(Swift::Duration.Foundation::TimeFormatStyle), and a C type imported as a
member is qualified level by level; local types and the associated types of
type parameters carry none.

Names the printers used to write as text now go through the type printer:
~Swift.Copyable / ~Swift.Escapable print long-lived protocol nodes through the
caller's resolver, and the extension header no longer shows the dotted lookup
key ExtensionName.name, which a sweep test over a compiled fixture caught.
OpaqueTypeResolving.opaqueType takes the flag, so the opaque constraint text
follows it while the names it matches protocol facts by stay dotted.

Evolution proposal: module-selectors. Needs swift-demangling's
feature/module-selectors (unreleased).
90 pairs byte-identical across the archived caches, the simulator runtimes and
the in-process reader, so the output with the option off is unchanged.
Rebasing the module-selector option onto next met proposal 0062's
renderExtendedTypeName, which spells a local type no source names by its
position (Holder.(Visitor in $1a2b3c)). That spelling now follows the option
too; left dotted, it was the one old-style qualification in an interface
spelled Module::Name. The new test fails without it on all three
expectations and passes with it.
Number the proposal 0064 and section 90 of the evolution log, point every
reference at the numbered file and at swift-demangling's proposal 0017, and
record the rebase onto next: the two conflicts with proposal 0062, the
position-based extension header test, and the full suite (2436 tests, only
the two MultiPayloadEnumDescriptorCacheTests failures this machine always
has).
Identical code folding piles the witnesses of many conformances onto one
address: a single SwiftUI `_destroySelf` or value witness implementation
carries well over a thousand names. Extension and protocol indexing, and
both protocol dumpers, picked the symbol belonging to a conformance or a
protocol by demangling, searching and printing every name at the address
in turn, once per conformance asking. That is quadratic in the group's
size: printing SwiftUI made 15,047 such calls, 451 candidates each on
average, 3.65 million checks over only 17,852 distinct names, and it took
half the time RuntimeViewer spends building an image's Find corpus.

`SymbolIndexStore.symbols(for:ownedBy:ownerKind:printedWith:in:)` answers
the question from a grouping of the address's rows by owner -- the type
the first protocol conformance names, or the first protocol -- built once
per address, owner rule and print preset on the image's storage, outside
its lock, first finisher kept. The rule, the presets, the candidate order
and the queried offset stamped on each value are the ones the four call
sites used, which now only filter out what an earlier witness claimed.

Verified by `SymbolOwnerGroupingSwiftUITests`: every multi-name address of
SwiftUI in process, both rules under both presets, answers exactly as a
one-by-one reference implementation kept in the test; eight tasks asking
an address first at once agree. Proposal: draft-faster-lazy-definition-indexing.
`PropertyWrapperTypeCatalog.evidence(forWrapperCandidate:)` held its lock
across the whole lookup: the export-trie searches of the root image and of
its dependency closure, the demangling of their hits, and the first
resolution of the closure itself. Printing an image four ways at once,
every caller queued there, even for a prefix whose verdict was already
known -- 8% of the time a Find corpus took. The lock now guards only the
verdict cache: searches run outside it, concurrent first searches of one
prefix each finish and the first stored verdict wins. The dependency
lookups are resolved once under a lock of their own.

With the lock gone, what remained was resolving the closure:
`InProcessDependencyLocator` called `MachOImage(name:)` per dependency,
which splits the path of every image mapped in the process, so a closure
of a few hundred dependencies in a process with a thousand images mapped
split paths hundreds of thousands of times while the other printing tasks
waited. The locator now builds a bare-name table from one pass over the
mapped images, keeping the first image per name -- the one
`MachOImage(name:)` picks. An image mapped after the locator was made is
not one it knows; `DependencyClosure(root: MachOImage)` makes a new
locator each time.

`PropertyWrapperTypeCatalogLockTests` holds one search in its lookup and
requires an answered prefix to return meanwhile: it times out after 10
seconds on the old shape and passes now. `InProcessDependencyLocatorTests`
compares the locator with `MachOImage(name:)` for every mapped image.
ReviewAdjudications A61 item four is re-adjudicated: it weighed only
thread hops under the lock, not the long critical section itself.
Proposal: draft-faster-lazy-definition-indexing.
0.8.111 reads the property and protocol lists a macOS 26.4+ dyld cache
keeps in another file than the image's header. Those caches keep each
group of images' data in .dylddata files, and the reader looked for a
class's relative lists only in the file holding the header, so `objc`
lost every instance property and adopted protocol of a class other
images extend: NSView printed none of its 355 properties offline, and
NSWindow, NSString and NSBundle lost theirs too. Methods were unaffected.

Verified with the sibling dependencies (USING_LOCAL_DEPENDENCIES=1,
MachOObjCSection next at 8e4cc08): the full suite (2442 tests, without
IntegrationTests) fails only the two MultiPayloadEnumDescriptorCacheTests
this machine already fails on next, and swift-section built from this
branch prints NSView's 355 properties, 9 class properties and protocol
list on macOS 26.7. Remote dependencies resolve 0.8.111, but next does
not build on them yet: DemangleOptions.useModuleSelectors is only on
swift-demangling's next.
…d MachOObjCSection 0.8.200

next already uses DemangleOptions.useModuleSelectors (swift-demangling 0.7.2) and DefinitionRegion (swift-semantic-string 0.5.0); with the old floors it resolved releases that lack them and did not compile against remote dependencies. MachOObjCSection 0.8.200 merges upstream 0.8.2 and reads every list an image attaches to a class, not just its first.
The four proposals that landed with PR #131 (concurrent definition printing, nested field offset memoization, nested definition regions, offline generic specialization) were still drafts In Progress. They take 0066-0069, the next numbers after 0065 on every shared branch, and become Implemented now that the swift-semantic-string release they waited for is out; every link to them follows the rename.

Their five evolution log sections had no number either. They take 93-97 and move after section 92, so the log stays in number order; sections 87-97 now say they ship in 0.23.0.
0057 set their removal for 0.23.0, with the downstream repositories migrated first. RuntimeViewer's next has moved off them; MachOKitUI (from: "0.19.0", so it resolves 0.23.0 on its own) and swift-decompiler (tracking next) have not, and removing them now would break both on their next resolution. The forwarders stay for one more release: AGENTS.md, the glossary, the implementation note and the index say 0.24.0, and 0057 records the decision.
Bumps BundledVersion and both agent plugin manifests to 0.23.0, adds
Changelogs/0.23.0.md in the one-sentence-per-entry style and points the
README's package snippet at 0.23.0. The agent skill dates
interface --module-selectors, dump --enable-module-selectors and
snapshot format 7 to 0.23.0.

The evolution log gains section 98 for the release. Verification of
this code with remote dependencies only (MachOKit 0.54.101,
MachOKitExtensions 1.2.0, MachOObjCSection 0.8.200, swift-demangling
0.7.2, swift-semantic-string 0.5.0, swift-capstone 6.0.1) on Xcode 26.6:
full suite 2442 tests / 468 suites, raw exit code 1 from the two
MultiPayloadEnumDescriptorCacheTests that already fail on this machine
(enumLayout -> nil at :101 and :130); release builds for x86_64 and
arm64 with 0 warnings, both run; Claude Code plugin validation passes
and every flag the agent skill names is in the CLI's --help.
Copilot AI balanced review requested due to automatic review settings October 15, 2026 03:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T03:59:35.706752Z b7be58e 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Mx-Iris
Mx-Iris merged commit 7a94358 into main Oct 15, 2026
3 checks passed
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.

2 participants