Skip to content

feat: persist telemetry queue in ${CLAUDE_PLUGIN_DATA}; fill marketplace description - #83

Merged
minarc merged 1 commit into
feat/local-dev-config-and-signin-notifierfrom
feat/plugin-data-dir-and-marketplace-desc
Jul 8, 2026
Merged

minarc merged 1 commit into
feat/local-dev-config-and-signin-notifierfrom
feat/plugin-data-dir-and-marketplace-desc

Conversation

@minarc

@minarc minarc commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up addressing the two HIGH items from the plugin-vs-docs gap audit.

⛓️ Stacked on #82 (base = feat/local-dev-config-and-signin-notifier). Shows only the incremental diff; retarget to main once #82 merges.

1. Persist the telemetry queue in ${CLAUDE_PLUGIN_DATA} (data-loss fix)

The queue (events.jsonl*, transcripts/pending/*) and lock files lived under PLUGIN_ROOT/logs. PLUGIN_ROOT is the install/cache dir — it changes on every plugin update and the old copy is deleted ~7 days later, stranding any un-drained queue (the new version's retry daemon reads the new path). The docs explicitly warn: "treat it as ephemeral and do not write state here."

  • paths.js: LOG_DIR now roots at ${CLAUDE_PLUGIN_DATA} (host-provided, survives updates) when set; falls back to PLUGIN_ROOT/logs when unset (older Claude Code, direct node, tests) → byte-identical to before. Lock files live under LOG_DIR so they move automatically.
  • transfer.js migrateLegacyQueue(): one-time forward copy of sealed event logs (and seals the legacy active log into a recognized batch) + pending transcripts from PLUGIN_ROOT/logs. Best-effort, copy + skip-existing, skips *.sent. Wired into session_start's prepareSession.
  • Credentials in ~/.skillbench (STATE_DIR) were already durable — only the queue was at risk.

2. Fill marketplace description

marketplace.json: the skillmeter entry had "description": "" (blank card in /plugin, validate warning). Filled it with the plugin description and added a root marketplace description.

Housekeeping

  • Bump plugin version to 0.18.0.

Verification

  • Migration tested: sealed log copied, legacy active log sealed into a new batch, pending transcript copied, *.sent correctly not migrated.
  • LOG_DIR resolution: unset → PLUGIN_ROOT/logs (migration no-op); CLAUDE_PLUGIN_DATA set → <data>/logs (migration active).
  • Golden before/after diff: session_start behavior unchanged apart from the version bump.
  • node --test skillmeter/test/harness.test.js → 20/20; claude plugin validate skillmeter → ✔ passed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a clearer marketplace description for the plugin.
    • Updated the plugin version to 0.18.0.
  • Bug Fixes

    • Improved data storage handling so logs and queued uploads can use a persistent data location when available.
    • Added automatic migration of older queue and transcript files so existing data continues to work after the update.

…ace description

- paths.js: root LOG_DIR (queue + lock files) at ${CLAUDE_PLUGIN_DATA} when
  available, falling back to PLUGIN_ROOT/logs when unset (byte-identical to
  before). Fixes data loss: PLUGIN_ROOT is the install cache dir, wiped ~7 days
  after a plugin update, which stranded any un-drained queue.
- transfer.js: migrateLegacyQueue() copies sealed event logs (and seals the
  legacy active log) + pending transcripts forward from PLUGIN_ROOT/logs on
  first run; best-effort, copy + skip-existing, skips *.sent. Wired into
  session_start's prepareSession.
- marketplace.json: fill the empty skillmeter entry description + add a root
  marketplace description (clears `claude plugin validate` warning / blank card).
- Bump plugin version to 0.18.0.

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

Walkthrough

This PR adds persistent, data-root-based path resolution with legacy path fallback in skillmeter's paths module, introduces a migrateLegacyQueue() function to copy legacy event batches and pending transcripts into new locations, wires it into session start, bumps the plugin version, and updates marketplace descriptions.

Changes

Legacy queue migration to persistent data root

Layer / File(s) Summary
Path resolution with DATA_ROOT
skillmeter/scripts/lib/paths.js
Adds DATA_ROOT (from CLAUDE_PLUGIN_DATA or PLUGIN_ROOT) used for LOG_DIR/TRANSCRIPTS_PENDING_DIR, and exports a new LEGACY_LOG_DIR constant for the previous location.
Legacy queue migration logic
skillmeter/scripts/lib/transfer.js
Adds and exports migrateLegacyQueue(), which copies sealed legacy event batch files, seals/migrates the active legacy events.jsonl, and copies pending transcripts into current directories, skipping existing files and swallowing errors.
Session start wiring
skillmeter/scripts/session_start.js
Imports and calls migrateLegacyQueue() in prepareSession() before license refresh and hook execution.
Version bump and marketplace descriptions
skillmeter/.claude-plugin/plugin.json, .claude-plugin/marketplace.json
Bumps plugin version from 0.17.0 to 0.18.0; adds a top-level marketplace description and a populated skillmeter plugin description.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
    participant SessionStart as session_start.js
    participant Transfer as transfer.js
    participant FS as Filesystem

    SessionStart->>Transfer: migrateLegacyQueue()
    Transfer->>FS: check LEGACY_LOG_DIR exists
    alt legacy dir missing or same as current
        Transfer-->>SessionStart: no-op
    else legacy dir present
        Transfer->>FS: copy sealed events.jsonl.<timestamp> to LOG_DIR
        Transfer->>FS: seal & copy active events.jsonl as new batch
        Transfer->>FS: copy pending transcripts to TRANSCRIPTS_PENDING_DIR
        Transfer-->>SessionStart: migration complete (errors swallowed)
    end
    SessionStart->>SessionStart: refreshLicense() / runSessionStartHook()
Loading

Possibly related PRs

Suggested reviewers: jhunlee-dev

Poem

A rabbit hops through logs of old,
Migrating queues to homes more bold. 🐇
DATA_ROOT now leads the way,
Legacy files won't lose their stay.
Version bumped, descriptions bright—
Hop, hop, hooray, the paths feel right!

🚥 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 main changes: persisting the telemetry queue in ${CLAUDE_PLUGIN_DATA} and filling the marketplace description.
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 feat/plugin-data-dir-and-marketplace-desc

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

@minarc
minarc requested a review from TheStarkor July 8, 2026 13:32
@minarc
minarc merged commit d76d9f6 into feat/local-dev-config-and-signin-notifier Jul 8, 2026
1 check was pending

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skillmeter/scripts/lib/transfer.js`:
- Around line 332-369: The active-log migration in migrateLegacyQueue re-seals
legacy events.jsonl into a new batch name on every run because it uses
Date.now(), so the existsSync check never stabilizes. Change the events.jsonl
branch to derive the destination batch filename from a stable source attribute
such as the file’s mtime (or another deterministic identifier from src) so
repeated sessions map to the same output path. Keep the sealed-batch handling
and skip-existing behavior intact, and make the fix in migrateLegacyQueue where
the legacy active log is copied into LOG_DIR.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cca18132-c0bb-4433-9e2b-17ef1f8e213f

📥 Commits

Reviewing files that changed from the base of the PR and between 18f4e54 and eb3963c.

📒 Files selected for processing (5)
  • .claude-plugin/marketplace.json
  • skillmeter/.claude-plugin/plugin.json
  • skillmeter/scripts/lib/paths.js
  • skillmeter/scripts/lib/transfer.js
  • skillmeter/scripts/session_start.js

Comment on lines +332 to +369
// One-time forward migration of the durable queue. Older versions (and hosts
// without CLAUDE_PLUGIN_DATA) kept sealed event logs + pending transcripts under
// PLUGIN_ROOT/logs, which the host deletes ~7 days after a plugin update. Copy
// any un-uploaded artifacts into the persistent LOG_DIR so an in-place upgrade
// doesn't strand them. Best-effort, copy (not move) + skip-existing, so it's
// safe to run every session and a no-op when the paths coincide.
function migrateLegacyQueue() {
if (LEGACY_LOG_DIR === LOG_DIR) return; // CLAUDE_PLUGIN_DATA unavailable
if (!fs.existsSync(LEGACY_LOG_DIR)) return;
try {
fs.mkdirSync(LOG_DIR, { recursive: true });
for (const f of fs.readdirSync(LEGACY_LOG_DIR)) {
const src = path.join(LEGACY_LOG_DIR, f);
try { if (!fs.statSync(src).isFile()) continue; } catch { continue; }
if (/^events\.jsonl\.\d+$/.test(f)) {
// Already-sealed batch → copy under the same name.
const dest = path.join(LOG_DIR, f);
if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
} else if (f === "events.jsonl") {
// Seal the legacy active log into a batch the drain recognizes.
const dest = path.join(LOG_DIR, `events.jsonl.${Date.now()}`);
if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
}
// Skip *.sent (already delivered) and lock files.
}
const legacyPending = path.join(LEGACY_LOG_DIR, "transcripts", "pending");
if (fs.existsSync(legacyPending)) {
fs.mkdirSync(TRANSCRIPTS_PENDING_DIR, { recursive: true });
for (const f of fs.readdirSync(legacyPending)) {
const src = path.join(legacyPending, f);
try { if (!fs.statSync(src).isFile()) continue; } catch { continue; }
const dest = path.join(TRANSCRIPTS_PENDING_DIR, f);
if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
}
}
} catch {}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Active-log migration re-seals the same content every session, causing duplicate uploads.

The sealed-batch branch (Lines 346-349) is idempotent because the destination filename is stable (events.jsonl.<original-suffix>) and gated by existsSync(dest). The active-log branch (Lines 350-354) is not: dest is named from Date.now(), which is different on every call, so existsSync(dest) never actually prevents re-processing. Since the source events.jsonl is copied (not moved/deleted), it stays in LEGACY_LOG_DIR and will be re-sealed into a brand-new batch file on every subsequent session for as long as the legacy directory exists (up to ~7 days post-update, per host cleanup behavior). Each new batch is picked up by the drain/upload path as unseen data, producing duplicate telemetry uploads and unnecessary file growth in LOG_DIR.

Derive the batch name from the source file's stable mtime instead of the current time so the exists-check is meaningful.

🛠️ Proposed fix
     for (const f of fs.readdirSync(LEGACY_LOG_DIR)) {
       const src = path.join(LEGACY_LOG_DIR, f);
-      try { if (!fs.statSync(src).isFile()) continue; } catch { continue; }
+      let stat;
+      try { stat = fs.statSync(src); if (!stat.isFile()) continue; } catch { continue; }
       if (/^events\.jsonl\.\d+$/.test(f)) {
         // Already-sealed batch → copy under the same name.
         const dest = path.join(LOG_DIR, f);
         if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
       } else if (f === "events.jsonl") {
-        // Seal the legacy active log into a batch the drain recognizes.
-        const dest = path.join(LOG_DIR, `events.jsonl.${Date.now()}`);
+        // Seal the legacy active log into a batch the drain recognizes,
+        // keyed by the file's own mtime (not Date.now()) so re-running
+        // migration on a later session doesn't re-seal the same
+        // un-migrated content under a fresh name every time.
+        const dest = path.join(LOG_DIR, `events.jsonl.${Math.floor(stat.mtimeMs)}`);
         if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
       }
       // Skip *.sent (already delivered) and lock files.
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// One-time forward migration of the durable queue. Older versions (and hosts
// without CLAUDE_PLUGIN_DATA) kept sealed event logs + pending transcripts under
// PLUGIN_ROOT/logs, which the host deletes ~7 days after a plugin update. Copy
// any un-uploaded artifacts into the persistent LOG_DIR so an in-place upgrade
// doesn't strand them. Best-effort, copy (not move) + skip-existing, so it's
// safe to run every session and a no-op when the paths coincide.
function migrateLegacyQueue() {
if (LEGACY_LOG_DIR === LOG_DIR) return; // CLAUDE_PLUGIN_DATA unavailable
if (!fs.existsSync(LEGACY_LOG_DIR)) return;
try {
fs.mkdirSync(LOG_DIR, { recursive: true });
for (const f of fs.readdirSync(LEGACY_LOG_DIR)) {
const src = path.join(LEGACY_LOG_DIR, f);
try { if (!fs.statSync(src).isFile()) continue; } catch { continue; }
if (/^events\.jsonl\.\d+$/.test(f)) {
// Already-sealed batch → copy under the same name.
const dest = path.join(LOG_DIR, f);
if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
} else if (f === "events.jsonl") {
// Seal the legacy active log into a batch the drain recognizes.
const dest = path.join(LOG_DIR, `events.jsonl.${Date.now()}`);
if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
}
// Skip *.sent (already delivered) and lock files.
}
const legacyPending = path.join(LEGACY_LOG_DIR, "transcripts", "pending");
if (fs.existsSync(legacyPending)) {
fs.mkdirSync(TRANSCRIPTS_PENDING_DIR, { recursive: true });
for (const f of fs.readdirSync(legacyPending)) {
const src = path.join(legacyPending, f);
try { if (!fs.statSync(src).isFile()) continue; } catch { continue; }
const dest = path.join(TRANSCRIPTS_PENDING_DIR, f);
if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
}
}
} catch {}
}
// One-time forward migration of the durable queue. Older versions (and hosts
// without CLAUDE_PLUGIN_DATA) kept sealed event logs + pending transcripts under
// PLUGIN_ROOT/logs, which the host deletes ~7 days after a plugin update. Copy
// any un-uploaded artifacts into the persistent LOG_DIR so an in-place upgrade
// doesn't strand them. Best-effort, copy (not move) + skip-existing, so it's
// safe to run every session and a no-op when the paths coincide.
function migrateLegacyQueue() {
if (LEGACY_LOG_DIR === LOG_DIR) return; // CLAUDE_PLUGIN_DATA unavailable
if (!fs.existsSync(LEGACY_LOG_DIR)) return;
try {
fs.mkdirSync(LOG_DIR, { recursive: true });
for (const f of fs.readdirSync(LEGACY_LOG_DIR)) {
const src = path.join(LEGACY_LOG_DIR, f);
let stat;
try { stat = fs.statSync(src); if (!stat.isFile()) continue; } catch { continue; }
if (/^events\.jsonl\.\d+$/.test(f)) {
// Already-sealed batch → copy under the same name.
const dest = path.join(LOG_DIR, f);
if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
} else if (f === "events.jsonl") {
// Seal the legacy active log into a batch the drain recognizes,
// keyed by the file's own mtime (not Date.now()) so re-running
// migration on a later session doesn't re-seal the same
// un-migrated content under a fresh name every time.
const dest = path.join(LOG_DIR, `events.jsonl.${Math.floor(stat.mtimeMs)}`);
if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
}
// Skip *.sent (already delivered) and lock files.
}
const legacyPending = path.join(LEGACY_LOG_DIR, "transcripts", "pending");
if (fs.existsSync(legacyPending)) {
fs.mkdirSync(TRANSCRIPTS_PENDING_DIR, { recursive: true });
for (const f of fs.readdirSync(legacyPending)) {
const src = path.join(legacyPending, f);
try { if (!fs.statSync(src).isFile()) continue; } catch { continue; }
const dest = path.join(TRANSCRIPTS_PENDING_DIR, f);
if (!fs.existsSync(dest)) fs.copyFileSync(src, dest);
}
}
} catch {}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skillmeter/scripts/lib/transfer.js` around lines 332 - 369, The active-log
migration in migrateLegacyQueue re-seals legacy events.jsonl into a new batch
name on every run because it uses Date.now(), so the existsSync check never
stabilizes. Change the events.jsonl branch to derive the destination batch
filename from a stable source attribute such as the file’s mtime (or another
deterministic identifier from src) so repeated sessions map to the same output
path. Keep the sealed-batch handling and skip-existing behavior intact, and make
the fix in migrateLegacyQueue where the legacy active log is copied into
LOG_DIR.

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