Skip to content

fix(lore-memory): do not mine sessions a program started - #416

Merged
hsusul merged 2 commits into
mainfrom
fix/mine-skips-automated-sessions
Nov 9, 2026
Merged

hsusul merged 2 commits into
mainfrom
fix/mine-skips-automated-sessions

Conversation

@hsusul

@hsusul hsusul commented Nov 9, 2026

Copy link
Copy Markdown
Owner

What

  • The Claude Code adapter marks a session automated when its lines record an sdk-* entrypoint (claude -p, the Agent SDK). The Codex adapter does so when session_meta records source: "exec", a subagent source, or originator codex_exec.
  • Ingest stores {"automated":true} in agent_session.metadata_json (no migration; the column was always NULL).
  • The miner (mem mine and MCP mine_candidates) skips automated sessions.
  • PARSER_VERSION 18 → 19 so existing sessions get the mark on the next scan (a one-time full re-parse, like earlier bumps).

Why

The miner's only origin filter was is_sidechain = 0, so every user turn of a scripted run read as the person's words. A short scripted first prompt with a rule phrase ("Make sure you always run tests") is flagged as a rule with no agent turn before it. 40 of 123 Codex first turns in the owner's archive are under the 300-character limit, and Lore's own lessons runs are archived as ordinary sessions. No leak was found in today's data (all 540 receipts come from interactive sessions), so this is preventive.

Test

  • New crates/lore-memory/tests/mine_automated.rs: codex exec, subagent, and originator-only sessions, and sdk-cli/sdk-ts Claude sessions yield nothing, while the interactive control (source: cli, entrypoint: cli) still yields its rule and correction. Both tests fail without the miner filter.
  • cargo test --no-fail-fast -p lore-core -p lore-memory -p lorectl passes; clippy -D warnings clean; scripts/egress-check.sh ok.

claude -p and Agent SDK runs (Lore's own Find lessons runs among them),
codex exec runs, and Codex subagent threads hold prompts a program wrote.
The adapters now mark them automated in agent_session.metadata_json from
the entrypoint, source, and originator the logs record, and the miner skips
them. PARSER_VERSION 19 re-parses existing sessions so they get the mark.
…ay so

The mark was set only when a session was first stored, so one a person
started and claude -p --resume continued stayed unmarked until a re-parse.
Appended lines now set it; nothing clears it.
@hsusul
hsusul merged commit 8552ded into main Nov 9, 2026
5 checks passed
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.

1 participant