Skip to content

Refactor/kotlin-style-conformance#1

Merged
nficano merged 3 commits into
mainfrom
refactor/kotlin-style-conformance
May 16, 2026
Merged

Refactor/kotlin-style-conformance#1
nficano merged 3 commits into
mainfrom
refactor/kotlin-style-conformance

Conversation

@nficano
Copy link
Copy Markdown
Contributor

@nficano nficano commented May 16, 2026

§9 forbids underscores in package names. Five packages renamed:

lease_revocation → leaserevocation
human_input → humaninput
permission_challenge → permissionchallenge
reasoning_streams → reasoningstreams
capability_negotiation → capabilitynegotiation

Plus three filename fixes for ktlint standard:filename:

_Wire.kt → SampleWire.kt
leaserevocation/Sql.kt → leaserevocation/Classified.kt

samples/build.gradle.kts JavaExec class FQNs updated to match the new
package layout.

Style-pass on the surviving sample bodies:

  • MaxLineLength wraps in heartbeats/Main, handoff/Main, mcp/Main,
    humaninput/Main, SampleWire.
  • Drop unused CompletableDeferred field + import from delegation/JobMux.
  • Type-alias re-wraps in humaninput/Channels per ktlint function-signature.

Per detekt-samples.yml (added in the tooling commit), the size/parameter/
complexity bar is intentionally lower for :samples; forbidden patterns
and naming remain enforced.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

nficano and others added 3 commits May 15, 2026 15:31
Activates the Detekt rules the style guide §11 specifies as hard limits
(LongMethod=30, LongParameterList fn=5/ctor=7, CyclomaticComplexMethod=10,
CognitiveComplexMethod=15, LargeClass=300, NestedBlockDepth=3,
ReturnCount=3, MaxLineLength=100) and turns on UndocumentedPublicClass /
UndocumentedPublicFunction. ForbiddenMethodCall now traps GlobalScope.

Samples are illustrative protocol walkthroughs, not library code, and
trade brevity for clarity (sequential main() functions that narrate the
protocol). A separate detekt-samples.yml relaxes size/parameter/
complexity rules for :samples while keeping naming, line length, and
forbidden patterns enforced. The samples-vs-library split is wired in
the root build by project name.

.editorconfig drops max_line_length from 140 to 100 (style guide §11
target) and disables ktlint's multiline-expression-wrapping rule
globally — it conflicts with function-signature's single-line-body rule
on the common `fun f(): T = expr { ... }` pattern and the two cannot
converge to a stable autocorrect form.

UndocumentedPublicProperty stays off; rationale in STYLE_GUIDE_FEEDBACK.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Decomposes the functions and files Detekt flagged after Phase 2 enabled
the §11 thresholds. Internal-only — public signatures unchanged except
where called out below.

- auth/BearerAuth: extract constantTimeEquals helper (NestedBlockDepth).
- auth/JwtAuth: split verify into parseSignedJwt + verifySignature +
  verifyAudience + verifyTimeBounds (LongMethod, Cyclomatic).
- client/ARCPClient: split open into buildOpener +
  interpretHandshakeReply + rejectionFor (LongMethod).
- envelope/Envelope: split EnvelopeSerializer.serialize/deserialize
  into named seams (buildEnvelopeJson, putOptionalScalars/Ids/Trace,
  decodePayload, buildEnvelope, readPriority); wrap long generic
  signature for serialize body (LongMethod x2, Cyclomatic).
- runtime/ARCPRuntime: single-return form for handleHandshake; reject*
  branches as private helpers; authenticateOrReject wraps the
  ARCPException.Unauthenticated try/catch (LongMethod, ReturnCount).
- runtime/ArtifactStore: replace 5-arg put/putBase64 with parameter
  objects ArtifactPutRequest / ArtifactPutBase64Request (new file);
  extract computeExpiry/persistArtifact/artifactUri (LongParameterList,
  LongMethod, MaxLineLength). PUBLIC API CHANGE — see lib/api/lib.api.
- runtime/CapabilityNegotiation: split negotiate into mergeCapabilities
  + negotiateBooleanFlags + negotiateBinaryEncoding + negotiateExtensions
  (LongMethod, MaxLineLength).
- runtime/SubscriptionManager: extract CompiledSubscriptionFilter
  (new file) to fold the 6-way AND down below the Cyclomatic=10 bar.
- store/EventLog: split append (insertEnvelope, bindEnvelope,
  readGeneratedSeq); flatten findSeq (readSingleSeq); hoist
  INSERT_ENVELOPE_SQL to companion (LongMethod, NestedBlockDepth,
  MaxLineLength).
- ids/Ids: KDoc on the 9 random() companion functions (KOTLIN_STYLE §13).
- trace/TraceContext, error/ErrorCode, json/Json: line-length wraps.
- cli/Main: shorten Context references via import; KDoc on main.

Tests migrated to new ArtifactPutRequest signatures; long-line and
helper-parameter-count fixes in SubscriptionManagerTest, ArtifactStoreTest,
MessageCatalogTest, ExtensionRegistryTest, EnvelopeRoundTripTest,
ErrorCodeTest, ARCPExceptionTest, EventLogTest.

lib/api/lib.api refreshed via :lib:apiDump. Two intentional signature
changes (put, putBase64). The remaining .api delta is Kotlin-compiler
hash re-mangling on inline value class component/copy/getter symbols
(TraceContext, Envelope, Ids) — no logical signature changed.

All gates green: ./gradlew apiCheck ktlintCheck detekt test build.
Forbidden-pattern sweep clean in lib/src/main and cli/src/main: no
'!!', no GlobalScope, no runBlocking, no lateinit var, no catch Throwable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
§9 forbids underscores in package names. Five packages renamed:

  lease_revocation        → leaserevocation
  human_input             → humaninput
  permission_challenge    → permissionchallenge
  reasoning_streams       → reasoningstreams
  capability_negotiation  → capabilitynegotiation

Plus three filename fixes for ktlint standard:filename:

  _Wire.kt                → SampleWire.kt
  leaserevocation/Sql.kt  → leaserevocation/Classified.kt

samples/build.gradle.kts JavaExec class FQNs updated to match the new
package layout.

Style-pass on the surviving sample bodies:
- MaxLineLength wraps in heartbeats/Main, handoff/Main, mcp/Main,
  humaninput/Main, SampleWire.
- Drop unused CompletableDeferred field + import from delegation/JobMux.
- Type-alias re-wraps in humaninput/Channels per ktlint function-signature.

Per detekt-samples.yml (added in the tooling commit), the size/parameter/
complexity bar is intentionally lower for :samples; forbidden patterns
and naming remain enforced.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nficano nficano merged commit c682a35 into main May 16, 2026
1 check passed
nficano added a commit that referenced this pull request May 16, 2026
…issues)

Planning and refactor planning content has moved to per-repo GitHub issues.
The 'v0.1 release-readiness' epics (#1-#8) and 'v1.1 implementation roadmap'
epic plus its milestone sub-issues are the source of truth going forward.
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