Skip to content

chore: remove dead/redundant code + fix stale docs - #86

Merged
minarc merged 1 commit into
mainfrom
chore/remove-dead-redundant-code
Jul 8, 2026
Merged

minarc merged 1 commit into
mainfrom
chore/remove-dead-redundant-code

Conversation

@minarc

@minarc minarc commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Cleanup from an adversarially-verified dead-code audit. Every change is behavior-neutral — the telemetry-gate golden diff is unchanged, harness tests pass 20/20, and claude plugin validate passes.

Dead / redundant code removed

  • jwt.getEndpointFromToken — getEndpointFromToken(t) || getEndpointFromTokenAllowExpired(t) (transfer.js, 2 sites) always equals the right operand: both read the same telemetry_endpoint claim, and the left call's expiry gate was already defeated by the || fallback. Replaced both sites with getEndpointFromTokenAllowExpired; deleted the now-unused getEndpointFromToken (+ export + import).
  • config.isColorEnabled — dead export; its only consumer disappeared when the banners became plain (no ANSI, since the systemMessage renderer prints escapes literally). Removed function + export.
  • license-activation force param + LICENSE_REFRESH_STALE_MS — force was always false after the 401/403 retry ladder was removed, which made the STALE_MS branch redundant (subsumed by the 60s cooldown check). Dropped force, collapsed shouldRefresh, removed LICENSE_REFRESH_STALE_MS (+ export). Verified identical decisions across all force=false inputs.

Stale docs/comments fixed

These still described the removed client-side org-scoping:

  • README "Repo-Scoped Filtering" opening paragraph → org comes from the license JWT, not a client-fetched/persisted allow-list.
  • repo-scope.js module JSDoc → matches on the JWT-validated org, not signin-time membership capture.
  • credstore.signOut comment → clarifies the allowed_github_orgs delete is legacy-key cleanup.

Deferred

Duplicate-helper consolidation (readStdin, atomic JSON write, timestamp helpers, findGitRoot/findRepoRoot, JWT-expiry helpers, etc.) — real but larger "extract shared helper" refactors that deserve their own reviewed pass with a golden-diff check.

Verification

  • Telemetry-gate golden before/after diff across all modes: byte-identical.
  • shouldRefresh decision table verified unchanged for all force=false inputs.
  • node --test skillmeter/test/harness.test.js → 20/20; claude plugin validate skillmeter → ✔.
  • Net +33 / −59.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Updated repo-scoped filtering guidance to reflect license-based org eligibility.
    • Clarified sign-out behavior and telemetry endpoint handling in the docs.
  • Bug Fixes

    • Improved license refresh behavior to avoid unnecessary refresh attempts and make token handling more consistent.
    • Telemetry uploads now use the endpoint from the license token even if the token is expired.
    • Repo capture now follows the orgs validated by the license, reducing mismatches in scope detection.

Found via an adversarially-verified dead-code audit; all changes behavior-neutral
(telemetry-gate golden diff unchanged, harness tests 20/20, plugin validate ✔).

Dead / redundant code:
- jwt.getEndpointFromToken: the `getEndpointFromToken(t) || getEndpointFromTokenAllowExpired(t)`
  pattern (transfer.js) always equals the right operand — both read the same
  `telemetry_endpoint` claim; the left's expiry gate was already defeated by the
  fallback. Replaced both sites with getEndpointFromTokenAllowExpired and deleted
  the now-unused getEndpointFromToken (+ export + import).
- config.isColorEnabled: dead export — its only consumer went away when the
  banners became plain (no ANSI). Removed the function + export.
- license-activation: the `force` param on ensureFreshLicense/shouldRefresh was
  always false after the 401/403 retry ladder was removed, which also made the
  STALE_MS branch redundant (subsumed by the cooldown check). Dropped `force`,
  collapsed shouldRefresh, and removed LICENSE_REFRESH_STALE_MS (+ export).
  Verified identical decisions for all force=false inputs.

Stale docs/comments (described removed client-side org-scoping):
- README "Repo-Scoped Filtering": rewrote the opening paragraph — the org comes
  from the license JWT, not a client-fetched/persisted allow-list.
- repo-scope.js module JSDoc: match on the JWT-validated org, not signin-time
  membership capture.
- credstore.signOut comment: clarify allowed_github_orgs delete is legacy cleanup.

Deferred (need their own reviewed pass): duplicate-helper consolidation
(readStdin, atomic JSON write, timestamp, findGitRoot/findRepoRoot, etc.).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d47bddac-d944-466e-bb8c-943115407c83

📥 Commits

Reviewing files that changed from the base of the PR and between aeab301 and b63f424.

📒 Files selected for processing (7)
  • skillmeter/README.md
  • skillmeter/scripts/credstore.js
  • skillmeter/scripts/lib/config.js
  • skillmeter/scripts/lib/jwt.js
  • skillmeter/scripts/lib/license-activation.js
  • skillmeter/scripts/lib/repo-scope.js
  • skillmeter/scripts/lib/transfer.js
💤 Files with no reviewable changes (1)
  • skillmeter/scripts/lib/config.js

Walkthrough

This PR shifts telemetry org-eligibility gating from a stored GitHub org allow-list (captured at sign-in) to reliance on the org claim in the license JWT, removes the expiry-gated telemetry endpoint helper in favor of an always-allow-expired variant, and simplifies the license refresh decision logic by dropping force/stale-lock bypass options.

Changes

JWT-driven org scoping and refresh simplification

Layer / File(s) Summary
Repo-scope org eligibility via license JWT
skillmeter/README.md, skillmeter/scripts/lib/repo-scope.js, skillmeter/scripts/credstore.js
Documentation now states eligibility is based on the license JWT org claim rather than a sign-in-captured allow-list; sign-out removes the legacy allowed_github_orgs key while preserving license_jwt deletion and device identity fields.
Config export cleanup
skillmeter/scripts/lib/config.js
Removes isColorEnabled export and adds getBackendUrlOverride to module.exports.
Telemetry endpoint resolution simplified
skillmeter/scripts/lib/jwt.js, skillmeter/scripts/lib/transfer.js
Removes expiry-gated getEndpointFromToken and its export; transferEventLog and uploadPendingTranscript now resolve endpoints solely via getEndpointFromTokenAllowExpired, dropping fallback logic.
License refresh cooldown-only policy
skillmeter/scripts/lib/license-activation.js
shouldRefresh drops force/staleMs bypass behavior in favor of cooldown-only decisions; ensureFreshLicense no longer accepts a force option; LICENSE_REFRESH_STALE_MS removed from exports.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: jhunlee-dev

Poem

A rabbit hops through JWT claims so bright,
No more org lists stored overnight. 🐇
One endpoint now, expired or fair,
Refresh cools down without a care.
Hop, hop—the scope is clean and light! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the cleanup and documentation updates in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/remove-dead-redundant-code

Comment @coderabbitai help to get the list of available commands.

@minarc
minarc requested a review from jhunlee-dev July 8, 2026 15:05
@minarc
minarc merged commit cbe5f34 into main Jul 8, 2026
1 check was pending
@TheStarkor
TheStarkor deleted the chore/remove-dead-redundant-code branch September 21, 2026 18:39
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