Skip to content

Brain Console reports false PreCompact warning because snapshot producer and detector use different paths #85

Description

@sparkling

Summary

The Brain Console's compactionSurvival probe does not recognise the session snapshots emitted by the configured Ruflo PreCompact hook. A project can have persisted session snapshots and still be shown as:

no PreCompact snapshot found for this project yet

This is a producer/detector contract mismatch that creates a false health warning and depresses the memory-quality score.

Verified implementation mismatch

On current main, scripts/onboarding-console.mjs only accepts two files:

const snap = fs.existsSync(path.join(projectDir, 'agentdb-sessions.jsonl')) ||
  fs.existsSync(path.join(projectDir, '.swarm/agentdb-sessions.jsonl'));

The current Ruflo hooks session-end --save-state true implementation instead writes snapshots under:

<project>/.claude/sessions/session-*.json

Existing Ruflo installations can also contain valid archived snapshots under:

<project>/.claude-flow/sessions/session-*.json

A live reproduction had eight snapshots in .claude-flow/sessions/, a configured PreCompact hook invoking ruflo hooks session-end --save-state true, and no recognised agentdb-sessions.jsonl; the Console therefore reported warn despite the persisted artifacts.

Reproduction

  1. Configure Claude Code's PreCompact hook to invoke:

    ruflo hooks session-end --save-state true
    
  2. Run the hook and verify a session snapshot exists under .claude/sessions/, or use a project with existing .claude-flow/sessions/session-*.json snapshots.

  3. Open the Brain Console.

  4. Inspect Your memory, across every project → Compaction survival.

  5. The Console still reports no PreCompact snapshot because it checks only the two agentdb-sessions.jsonl locations.

Impact

  • False warning on a healthy persistence path.
  • The tested dimension receives half credit (warn) instead of full credit (ok).
  • The 0–100 memory-quality score understates observed health.
  • Users are encouraged to repair persistence that may already be working.

Expected behaviour

The snapshot producer and Brain Console detector should share one explicit, versioned artifact contract. The Console should recognise the canonical artifact produced by the configured PreCompact hook and report its location and freshness.

Suggested acceptance criteria

  • Choose and document the canonical PreCompact snapshot path and minimal schema.
  • Make ruflo hooks session-end --save-state true and probeMemory() use that same contract.
  • Recognise or explicitly migrate legacy .claude-flow/sessions/session-*.json snapshots.
  • Validate a snapshot's structure and freshness rather than passing on arbitrary file existence alone.
  • Add fixtures proving:
    • valid canonical snapshot → ok;
    • supported legacy snapshot → ok or a clear migration state;
    • absent snapshot → warn;
    • unrelated or malformed file → does not produce ok.
  • Keep the separate project-state-current* coverage warning unchanged; that probe represents a different invariant.

Source locations

  • scripts/onboarding-console.mjs (probeMemory, compactionSurvival)
  • Ruflo's hooks_session-end implementation in @claude-flow/cli/dist/src/mcp-tools/hooks-tools.js

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