refactor: prune verbose comments, and write down the rule - #230
Merged
Conversation
…earing why Repositories.kt was 69% comment by line — every method carried a multi-paragraph essay, much of it restating the signature or narrating history that a commit message already holds. Condense each KDoc to the constraint a caller cannot see from the name: the gates, the "must never", the shape decisions and the issue numbers behind them. Also fixes an orphaned KDoc block that sat between SignOutOutcome's doc and the class, so it documented the wrong declaration; its content belongs on KeyBackupRepository, where it now is. No code changed — verified by diffing the comment-stripped file against HEAD. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
…eir why Same pass as the repository interfaces, applied to the four heaviest implementation files. Each comment keeps the fact a reader cannot recover from the code — the lock preconditions, the ordering constraints, the issue numbers — and drops the narration around it. KDoc that only restated a private method's name is removed outright. Also reattaches a second orphaned KDoc: the SpeakPhase doc sat above SpeakTarget, so it documented the wrong declaration. No code changed — verified by diffing the comment-stripped files against HEAD. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
The CLI files carried the longest blocks in the repo — several of them told the whole story of a bug, the measurement behind it and the alternative that was rejected. Keep the invariant and the issue number, drop the retelling. No code changed — verified by diffing the comment-stripped files against HEAD. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
…ments Continues the pass through the remaining long comment blocks. Also removes a stray " *" fragment left mid-KDoc in PublishDeckViewModel, the twin of the one fixed in DeckEditorViewModel. No code changed — verified by diffing the comment-stripped files against HEAD. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
The pruning pass has no lint rule behind it, so without this a fresh session re-grows exactly what was removed — the codebase's own style is the strongest signal a model reads. Records the six rules, including the two that are easy to get wrong: KDoc on a private declaration is only worth keeping when it carries a lock precondition or a measured number, and an orphaned KDoc documents the wrong declaration with nothing in the build reporting it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
…ration A KDoc separated from its declaration by another KDoc silently documents whatever follows it, and nothing in the build reports it. Found by scanning for stacked doc comments: - LoopkyNavigation had three stranded above goHomeSignedIn — the card-editor and signup-flow docs belong to functions ~200 lines further down, and the third duplicated navigateToRedemption's own doc. - OnboardingViewModel's "classify a failed approval" sat on sessionPubkyOrNull instead of toSignInReason. - FakePubkyClient's 404-on-missing-delete note sat on undeletablePaths instead of deleteWithSession. - Routes' signup-flow note sat on RESTORE_START. - ZipReader carried the same comment twice. File-level header docs above a first declaration's own KDoc are left as they are — that pattern is deliberate and reads correctly. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
Numbers verified against the tree rather than carried forward: - ~680 tests -> ~1,300. `:shared:jvmTest` runs 1,312, all passing; commonTest is 105 files, not 73. - 19/23 numbered journeys -> 25. README and CLAUDE.md disagreed with each other and both with journeys/. - 9 repositories -> 11. KeyBackupRepository and SignupRepository were missing from Architecture.md's table entirely. - IdentityRepository's row named signInWithRing(), which exists nowhere in the tree; replaced with the entry points that do. Also rewrites CLAUDE.md's repository bullet, a ~300-word single paragraph that listed nine impls under a heading claiming eleven. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
…rrative AndroidPubkyClient has not existed since the jvmSharedMain split: the impl is UniffiPubkyClient, shared with the desktop/:cli target, and PubkyClient is a plain Koin-bound interface rather than expect/actual. pubkycore.kt moved to jvmSharedMain with it. Both docs still described the old shape, including a file path that resolves to nothing. Also condenses §7.8's account of the Ring-redeems-token path that #147 removed — the decision and its reason stay, the internals of the deleted mechanism go, and with them the last reference to a `TokenRedeemer` type that no longer exists. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
…r comments Same rules: the constraint stays, the narration goes. The classifier rationale in RestorePhraseViewModel and NexusClient's account of why /v0/tags/taggers cannot answer the directory query are both kept in full — they are findings, not retellings. No code changed — verified by diffing the comment-stripped files against HEAD. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
…ndentation Last batch of the prune. Also repairs Repositories.kt, whose interface-member KDoc lost its indentation in the first commit of this series — detekt's Indentation rule caught it (99 findings), which is why the whole tree was re-anchored to the declaration each block precedes. Corrects PubkyClient's own header while there: it described JVM and iOS "actuals", but it is a plain Koin-bound interface, not expect/actual. detektAll clean, :shared:jvmTest 1312/1312 green, all three modules compile. Code verified byte-identical to the pre-refactor baseline across all 37 files. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comments had grown to 19.6% of every Kotlin line. Most of that was not
documentation: it was the signature restated in prose, or a bug's entire
history — how it was found, what was measured, which alternative was rejected —
retold in a KDoc where
git logalready holds it.This prunes the heaviest files and writes the rule down so a fresh session does
not re-grow it.
What changed
37 files, 5,736 → 4,678 comment lines (18%). Across the tree, 16,879 →
15,821 (19.6% → 18.6% of all Kotlin). The files processed are the ones carrying
the long blocks —
Repositories.ktalone was 69% comment by line.The rule applied, now recorded in CLAUDE.md under Coding conventions →
Comments:
lock precondition, an ordering constraint, a measured number, a bug the shape
prevents. Those are kept in full.
Roughly 830 KDocs sit on private declarations. I checked whether they could be
removed mechanically and they could not — most carry real content
(
Guarded by [cacheLock],The caller must hold [Deck.id]'s write lock), soevery file was reviewed by hand and only the restatements went.
Bugs found on the way
Seven KDoc blocks documented the wrong declaration. A
/** … */separatedfrom its declaration by another KDoc silently attaches to whatever follows, and
nothing in the build reports it.
LoopkyNavigationhad three stranded abovegoHomeSignedInbelonging to functions ~200 lines further down;OnboardingViewModel,FakePubkyClient,RoutesandZipReaderhad one each.Stale facts in the docs, all verified against the tree rather than carried
forward:
:shared:jvmTest, all passing)commonTestfilesKeyBackupRepositoryandSignupRepositorywere missing from Architecture.md's table entirelyIdentityRepositorysignInWithRing()AndroidPubkyClient(androidMain), anactualUniffiPubkyClient(jvmSharedMain);PubkyClientis a plain Koin-bound interface, not expect/actualAlso condenses Architecture.md §7.8's account of the Ring-redeems-token path
that #147 removed — the decision and its reason stay, the deleted mechanism's
internals go.
Verification
No code changed. Every file was diffed comment-stripped against the
pre-refactor baseline and is byte-identical; the one thing that did change
shape, comment indentation, was caught by detekt and re-anchored.
./gradlew detektAll— clean./gradlew :shared:jvmTest— 1312/1312:cli,:shared,:composeAppall compileNo
journeys/re-run: this touches no UI behaviour, and the code is provablyunchanged.
Not done
The prune covered the 37 files holding the long blocks. The long tail — ~100
files at 40–90 comment lines each — is untouched; CLAUDE.md says so, and frames
the rules as what to apply when you next touch a file rather than a claim the
tree is finished.
🤖 Generated with Claude Code
https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye