Skip to content

Claude iwyu#5160

Open
graydon wants to merge 1 commit intostellar:masterfrom
graydon:claude-iwyu
Open

Claude iwyu#5160
graydon wants to merge 1 commit intostellar:masterfrom
graydon:claude-iwyu

Conversation

@graydon
Copy link
Contributor

@graydon graydon commented Mar 2, 2026

I was doing some experiments with "using subagents in worktrees" and needed a superficial task to test with, so I had claude do some of the IWYU cleanups we have talked about doing from time to time. This time I told it to be a little more aggressive and not just clean up includes but also move implementations to .cpp files and add forward decls. It seems like it worked? I only had it do a handful of directories at this point (util, transactions, overlay, ledger, history, crypto, catchup, bucket) and it seems like there were some subagent turn limits that caused many of the phase 2 / phase 3 code movements to fail. But it got a few!

Copilot AI review requested due to automatic review settings March 2, 2026 21:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR performs an aggressive IWYU-style cleanup across the C++ codebase, reducing transitive header dependencies by pruning includes, adding forward declarations, and moving non-template implementations out of headers into .cpp files.

Changes:

  • Prune/adjust #include usage across util/, transactions/, overlay/, history/, catchup/, bucket/, ledger/, and crypto/.
  • Move several inline/header implementations into .cpp files (notably util/types, util/XDRStream, util/TxResource, and several small utility structs).
  • Add internal documentation for the header-pruning workflow under .claude/skills/.

Reviewed changes

Copilot reviewed 149 out of 149 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/work/test/WorkTests.cpp Add missing include for WorkSequence.
src/util/types.h Move inline helpers to declarations only.
src/util/types.cpp Add out-of-line definitions moved from header; prune includes.
src/util/XDRStream.h Move non-template method bodies out of header.
src/util/XDRStream.cpp New: out-of-line implementation for XDRStream helpers.
src/util/TxResource.h Move Resource method bodies out of header.
src/util/TxResource.cpp Add moved Resource implementations + includes.
src/util/TmpDir.cpp Prune unused include.
src/util/Timer.h Prune unused include.
src/util/Timer.cpp Prune unused include.
src/util/Thread.h Prune unused include.
src/util/TarjanSCCCalculator.h Prune unused include.
src/util/StatusManager.cpp Prune unused includes.
src/util/Scheduler.h Prune unused include.
src/util/RandomEvictionCache.h Prune unused include.
src/util/RandHasher.h Prune unused includes.
src/util/RandHasher.cpp Prune unused include.
src/util/MetaUtils.cpp Prune unused includes.
src/util/Math.h Remove Timer.h dependency; use std::chrono duration type.
src/util/Math.cpp Adjust includes and duration type usage.
src/util/GlobalChecks.h Prune unused include.
src/util/GlobalChecks.cpp Prune unused include.
src/util/Fs.h Prune unused include.
src/util/Fs.cpp Prune unused includes.
src/util/FileSystemException.h Move inline implementations to .cpp; prune includes.
src/util/FileSystemException.cpp Add moved implementations + required includes.
src/util/BitSet.h Prune unused includes.
src/util/Backtrace.cpp Prune unused include.
src/transactions/TransactionUtils.cpp Add needed include after pruning.
src/transactions/TransactionFrameBase.h Prune unused includes.
src/transactions/TransactionFrame.h Prune unused includes.
src/transactions/TransactionFrame.cpp Prune unused includes; adjust dependencies.
src/transactions/SponsorshipUtils.cpp Prune unused includes.
src/transactions/SetTrustLineFlagsOpFrame.cpp Prune unused include.
src/transactions/SetOptionsOpFrame.cpp Prune unused includes.
src/transactions/PaymentOpFrame.cpp Prune unused include.
src/transactions/PathPaymentOpFrameBase.cpp Prune unused include.
src/transactions/OperationFrame.h Prune include; adjust forward decls.
src/transactions/OperationFrame.cpp Prune unused include.
src/transactions/OfferExchange.h Replace heavy include with XDR include.
src/transactions/OfferExchange.cpp Prune unused includes.
src/transactions/MutableTransactionResult.h Replace include with forward decls.
src/transactions/MutableTransactionResult.cpp Prune redundant includes.
src/transactions/MergeOpFrame.cpp Prune unused includes.
src/transactions/ManageSellOfferOpFrame.cpp Prune unused includes.
src/transactions/ManageDataOpFrame.cpp Prune unused includes.
src/transactions/LumenEventReconciler.h Replace includes with forward decl.
src/transactions/LumenEventReconciler.cpp Prune unused include.
src/transactions/InflationOpFrame.cpp Prune unused includes.
src/transactions/FeeBumpTransactionFrame.h Prune unused include.
src/transactions/FeeBumpTransactionFrame.cpp Prune unused includes.
src/transactions/ExtendFootprintTTLOpFrame.cpp Prune unused include.
src/transactions/EndSponsoringFutureReservesOpFrame.cpp Prune unused include.
src/transactions/CreateAccountOpFrame.cpp Prune unused includes.
src/transactions/ClaimClaimableBalanceOpFrame.cpp Prune unused include.
src/transactions/ChangeTrustOpFrame.cpp Prune unused includes.
src/transactions/BumpSequenceOpFrame.h Prune unused includes.
src/transactions/BumpSequenceOpFrame.cpp Prune unused includes.
src/transactions/BeginSponsoringFutureReservesOpFrame.cpp Prune unused include.
src/transactions/AllowTrustOpFrame.cpp Prune unused includes.
src/simulation/Simulation.cpp Add missing include after pruning.
src/overlay/test/ItemFetcherTests.cpp Add missing include after pruning.
src/overlay/TxAdverts.h Add needed includes; adjust dependencies.
src/overlay/TCPPeer.h Prune unused include.
src/overlay/TCPPeer.cpp Prune unused include.
src/overlay/SurveyManager.cpp Prune unused include.
src/overlay/SurveyDataManager.h Prune unused include.
src/overlay/SurveyDataManager.cpp Prune unused include.
src/overlay/PeerManager.cpp Prune unused include.
src/overlay/Peer.h Prune unused includes.
src/overlay/OverlayManagerImpl.h Replace include with forward decl.
src/overlay/OverlayManagerImpl.cpp Add needed includes; move small helper implementation.
src/overlay/OverlayManager.h Move inline method body out of header.
src/main/ApplicationImpl.cpp Add missing include after pruning.
src/ledger/P23HotArchiveBug.cpp Prune unused include.
src/ledger/NetworkConfig.h Prune unused includes.
src/ledger/NetworkConfig.cpp Prune unused include.
src/ledger/LedgerTypeUtils.cpp Prune unused includes.
src/ledger/LedgerTxnOfferSQL.cpp Prune unused include.
src/ledger/LedgerTxnEntry.cpp Prune unused includes.
src/ledger/LedgerTxn.cpp Prune unused include.
src/ledger/LedgerStateSnapshot.cpp Prune unused include.
src/ledger/LedgerRange.h Move inline methods to .cpp.
src/ledger/LedgerRange.cpp Add moved implementations + required includes.
src/ledger/LedgerManagerImpl.cpp Prune unused include.
src/ledger/LedgerHeaderUtils.h Replace include with forward decls + standard headers.
src/ledger/LedgerHeaderUtils.cpp Prune unused include.
src/ledger/LedgerEntryScope.cpp Adjust includes after moving utilities.
src/ledger/LedgerCloseMetaFrame.h Replace include with forward decls.
src/ledger/LedgerCloseMetaFrame.cpp Add needed includes after pruning.
src/ledger/InMemorySorobanState.h Prune unused include.
src/ledger/InMemorySorobanState.cpp Adjust includes after pruning.
src/ledger/FlushAndRotateMetaDebugWork.h Replace includes with forward decls.
src/ledger/FlushAndRotateMetaDebugWork.cpp Add needed includes after pruning.
src/ledger/CheckpointRange.h Move inline methods to .cpp.
src/ledger/CheckpointRange.cpp Add moved implementations + required includes.
src/historywork/WriteVerifiedCheckpointHashesWork.cpp Add missing include after pruning.
src/historywork/DownloadBucketsWork.cpp Add missing includes after pruning.
src/historywork/CheckSingleLedgerHeaderWork.cpp Add missing include after pruning.
src/history/test/HistoryTestsUtils.cpp Add missing include after pruning.
src/history/StateSnapshot.h Prune unused includes.
src/history/HistoryManagerImpl.h Adjust forward decl/include usage.
src/history/HistoryManagerImpl.cpp Move HistoryManager static helpers out of header.
src/history/HistoryManager.h Move inline static helpers to .cpp declarations.
src/history/HistoryArchiveReportWork.cpp Prune unused includes.
src/history/HistoryArchive.cpp Prune unused includes.
src/history/FileTransferInfo.h Move implementations out of header; add forward decls.
src/history/FileTransferInfo.cpp Add moved implementations + needed includes.
src/history/CheckpointBuilder.h Replace include with forward decl.
src/herder/QuorumIntersectionChecker.h Add missing include after pruning.
src/crypto/SecretKey.h Prune unused include.
src/crypto/SecretKey.cpp Prune unused includes.
src/crypto/SHA.h Prune unused include.
src/crypto/SHA.cpp Prune unused includes.
src/crypto/Curve25519.h Prune unused include.
src/crypto/CryptoError.h Prune unused include.
src/crypto/BLAKE2.h Prune unused include.
src/crypto/BLAKE2.cpp Prune unused include.
src/catchup/ReplayDebugMetaWork.h Prune unused include.
src/catchup/ReplayDebugMetaWork.cpp Adjust include usage after pruning.
src/catchup/LedgerApplyManagerImpl.h Move test helper body out of header.
src/catchup/LedgerApplyManagerImpl.cpp Add moved test helper implementation.
src/catchup/LedgerApplyManager.h Replace includes with narrower dependencies + forward decl.
src/catchup/DownloadApplyTxsWork.h Prune unused includes.
src/catchup/DownloadApplyTxsWork.cpp Add missing include after pruning.
src/catchup/CatchupWork.h Move inline method body out of header.
src/catchup/CatchupWork.cpp Add moved implementation; adjust includes.
src/catchup/CatchupRange.h Move inline methods out of header.
src/catchup/CatchupRange.cpp Add moved implementations; adjust includes.
src/catchup/CatchupConfiguration.h Prune unused include.
src/catchup/ApplyCheckpointWork.h Prune unused include.
src/catchup/ApplyCheckpointWork.cpp Prune unused includes.
src/catchup/ApplyBufferedLedgersWork.h Prune unused include.
src/catchup/ApplyBucketsWork.h Prune unused include.
src/catchup/ApplyBucketsWork.cpp Adjust includes after pruning.
src/bucket/LiveBucket.cpp Add missing include after pruning.
src/bucket/HotArchiveBucket.cpp Add missing include after pruning.
src/bucket/BucketUtils.cpp Prune unused include.
src/bucket/BucketSnapshotManager.h Prune unused includes.
src/bucket/BucketOutputIterator.h Adjust includes/forward decls after pruning.
src/bucket/BucketManager.h Replace include with forward decl; prune include.
src/bucket/BucketManager.cpp Prune duplicates/unused includes; add needed include.
src/bucket/BucketListSnapshot.cpp Prune unused include.
src/bucket/BucketListBase.cpp Prune unused includes.
src/bucket/BucketIndexUtils.h Replace include with forward decl.
src/bucket/BucketBase.h Adjust includes after pruning.
src/bucket/BucketBase.cpp Prune unused include.
src/bucket/BucketApplicator.cpp Prune unused include.
.claude/skills/pruning-headers/SKILL.md New: documentation for header pruning workflow.

@graydon graydon force-pushed the claude-iwyu branch 3 times, most recently from cea84c1 to 75fe43a Compare March 3, 2026 02:25
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