Skip to content

KnowledgeHarvester.ts hardcodes a macOS auto-memory path — zero notes graduate on Linux #1366

Description

@stratofax

Component: PAI/TOOLS/KnowledgeHarvester.ts (memory → KNOWLEDGE graduation tool, v5)
Affected source: Releases/v5.0.0/.claude/PAI/TOOLS/KnowledgeHarvester.ts @ 2fde1bb
Severity: High on Linux — the tool runs, exits 0, and graduates nothing. Silent total failure.

Summary

On Linux, KnowledgeHarvester reads auto-memory notes from a hardcoded macOS path
(-Users-${USER}--claude). That directory never exists on Linux (the real slug is
-home-${USER}--claude), so the source directory is missing, the scan returns empty, and
zero memory notes ever graduate to MEMORY/KNOWLEDGE/ — with no error and a success exit code.

Bug — Hardcoded macOS auto-memory path

Lines 39–45:

const CURRENT_USER = process.env.USER;
if (!CURRENT_USER) {
  // ...guard...
}
const AUTO_MEMORY_DIR = path.join(HOME, ".claude", "projects",
  `-Users-${CURRENT_USER}--claude`, "memory");

Root cause: the slug -Users-${CURRENT_USER}--claude is the macOS form of the ~/.claude path
(/Users/<name>/.claude). On Linux the home is /home/<name>, so the real auto-memory directory is
…/projects/-home-<name>--claude/memory. The hardcoded slug points at a path that does not exist on Linux.

Expected: the harvester resolves the auto-memory directory from the actual ~/.claude path on any platform.

Actual (Linux): fs.existsSync(AUTO_MEMORY_DIR) is false → collectAutoMemory() returns []
no candidates → graduation count is 0, exit 0, no warning.

Impact: the memory→KNOWLEDGE graduation pipeline is a silent no-op on every Linux PAI v5 install.
(Pre-v5 installs do not ship KnowledgeHarvester at all — it is a v5-only tool — so this is a v5-Linux
regression, not a historical bug.) Because it fails silently with a success exit code, it reads as
"nothing to graduate" rather than "broken."

Proposed fix

Derive the slug from the live ~/.claude path — the same cross-platform pattern the sibling
SessionHarvester.ts already uses in this release
(see Related below) — and drop the now-unused
CURRENT_USER guard:

const AUTO_MEMORY_SLUG = path.join(HOME, ".claude").replace(/[\/\.]/g, "-");
const AUTO_MEMORY_DIR = path.join(HOME, ".claude", "projects", AUTO_MEMORY_SLUG, "memory");

This yields -Users-<name>--claude on macOS and -home-<name>--claude on Linux from the same code.

Verification (two independent Linux installs)

  • Install A — Linux, PAI 5.x (empirical): with the fix applied, all 23 local auto-memory notes
    graduated successfully where the unpatched tool graduated 0.
  • Install B — Linux (Ubuntu), PAI 4.0.3 (path-derivation corroboration): KnowledgeHarvester.ts
    is not present on this 4.0.3 install (v5-only tool), so this is not a harvest reproduction.
    What was checked: the real auto-memory dir on this host is .../projects/-home-<user>--claude/memory
    (confirmed to exist); the buggy upstream slug resolves to -Users-<user>--claude, which does not
    exist on this Linux host; the proposed fix's slug-derivation resolves to -home-<user>--claude,
    matching the real directory. Independently corroborates the Linux slug mismatch and confirms the fix
    yields the correct path on a second Linux box.

Related issues & precedent

Suggested labels

bug, platform:linux, tool:KnowledgeHarvester

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions