.plan/issue-2341-reliability-slice.md
Scope: first PR from the consolidated issue triage. This PR should not try to solve the full backlog. It should remove a few high-confidence paper cuts from the first two buckets: install/startup contract and DB/export contract.
Allowed APIs and patterns:
src/npx-cli/install/setup-runtime.ts.
Existing tests are in tests/setup-runtime.test.ts.plugin/scripts/version-check.js.
It currently resolves the plugin root from CLAUDE_PLUGIN_ROOT, then from the
script directory.SettingsDefaultsManager.loadFromFile.
Worker settings must respect CLAUDE_MEM_DATA_DIR, because shared path helpers
and settings defaults already expose that environment override./api/sdk-sessions/batch is registered in
src/services/worker/http/routes/DataRoutes.ts and expects
memorySessionIds. Existing coercion tests are in
tests/worker/http/routes/data-routes-coercion.test.ts.PendingMessageStore writes and reads tool_use_id, but no longer
reads worker_pid, retry_count, failed_at_epoch, or
completed_at_epoch. Current schema guardrails should match code that runs
today, not old migration intent.Anti-pattern guards:
worker_pid in pending_messages unless the current claim
query starts using it again.schema_versions for columns that current SQL references.export-memories.ts fall back to ~/.claude-mem when
CLAUDE_MEM_DATA_DIR is set.What to implement:
readInstallMarker() to parse legacy plain-text marker files that only
contain a version string.plugin/scripts/version-check.js to accept the same legacy marker shape.writeInstallMarker() unchanged so new installs write the canonical JSON
schema.Verification:
tests/setup-runtime.test.ts coverage for a plain-text .install-version.plugin/scripts/version-check.js behavior, or extend an
existing plugin script test if one exists.bun test tests/setup-runtime.test.ts.What to implement:
scripts/export-memories.ts to load settings from
CLAUDE_MEM_DATA_DIR/settings.json instead of always using
~/.claude-mem/settings.json./api/sdk-sessions/batch request body from sdkSessionIds to
memorySessionIds.DataRoutes to accept the legacy sdkSessionIds alias as a
compatibility bridge, but prefer the canonical field in scripts.Verification:
scripts/export-memories.ts no longer sends sdkSessionIds and no longer
hardcodes homedir(), '.claude-mem'.What to implement:
schema_versions claims old
pending-message migrations are applied while pending_messages.tool_use_id is
missing. Constructing SessionStore should still add the missing column
because current enqueue SQL requires it.worker_pid, since the current claim query does not use it.Verification:
SessionStore / PendingMessageStore.worker_pid reads in TypeScript before deciding whether it is
still a required current column.npm run typecheck:root if dependencies are available.git diff --check.