Skip to content

refactor: prune verbose comments, and write down the rule - #230

Merged
jvsena42 merged 10 commits into
mainfrom
refactor/prune-verbose-comments
Sep 4, 2026
Merged

refactor: prune verbose comments, and write down the rule#230
jvsena42 merged 10 commits into
mainfrom
refactor/prune-verbose-comments

Conversation

@jvsena42

@jvsena42 jvsena42 commented Sep 4, 2026

Copy link
Copy Markdown
Owner

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 log already 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.kt alone was 69% comment by line.

The rule applied, now recorded in CLAUDE.md under Coding conventions →
Comments
:

  • The name is the documentation; a KDoc restating it is deleted.
  • No KDoc on private declarations unless it carries something non-obvious — a
    lock precondition, an ordering constraint, a measured number, a bug the shape
    prevents. Those are kept in full.
  • Comment the "why", never the "what".
  • One tight paragraph, not an essay.

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), so
every file was reviewed by hand and only the restatements went.

Bugs found on the way

Seven KDoc blocks documented the wrong declaration. A /** … */ separated
from its declaration by another KDoc silently attaches to whatever follows, and
nothing in the build reports it. LoopkyNavigation had three stranded above
goHomeSignedIn belonging to functions ~200 lines further down;
OnboardingViewModel, FakePubkyClient, Routes and ZipReader had one each.

Stale facts in the docs, all verified against the tree rather than carried
forward:

Claim Was Is
shared tests ~680 1,312 (:shared:jvmTest, all passing)
commonTest files 73 105
numbered journeys 19 (README) / 23 (CLAUDE.md) 25
repositories 9 11 — KeyBackupRepository and SignupRepository were missing from Architecture.md's table entirely
IdentityRepository signInWithRing() exists nowhere in the tree
Pubky FFI impl AndroidPubkyClient (androidMain), an actual UniffiPubkyClient (jvmSharedMain); PubkyClient is a plain Koin-bound interface, not expect/actual

Also 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, :composeApp all compile

No journeys/ re-run: this touches no UI behaviour, and the code is provably
unchanged.

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

jvsena42 and others added 10 commits September 4, 2026 09:53
…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
@jvsena42
jvsena42 enabled auto-merge September 4, 2026 13:34
@jvsena42
jvsena42 merged commit 0633624 into main Sep 4, 2026
4 checks passed
@jvsena42
jvsena42 deleted the refactor/prune-verbose-comments branch September 4, 2026 13:35
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