feat(analyze): show what analyze learned + where it's anchored in your code (cold-start payoff)#27
Merged
Merged
Conversation
…r code (cold-start payoff)
`analyze` / the `plex init` seed reported bare counts ("seeded N lessons, R reinforced") —
the differentiator (Plex learned from YOUR review history) stayed invisible. Surface the
actual payoff:
- DistillResult + addAnalyzedPitfalls now return `learned: LearnedLesson[]` — per stored
lesson: title, scope, incidents (provenance comments), and `files` = the distinct source
files those comments concern. Computed where pitfalls are stored (the cluster carries each
comment's path), so it's free.
- `plex analyze`, the `plex init` seed step, and the MCP analyze_history/add_pitfalls results
now show the top learned lesson titles + "anchored to N files of your code" — so a user
SEES memory populate, tied to their codebase, on day one.
Honest framing (ADR-47): mined lessons anchor to FILES (a comment's path + line); symbol-level
code-path memory accrues from live-review accepts, not analyze — so the payoff says "files",
not "symbols".
Tests: pipeline.test asserts the learned summary (title/action/incidents) and file-anchoring
(distinct comment paths, deduped). 551 unit green, typecheck + build green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…idence (PR #27 review) Address the Plex self-review of PR #27 — the `learned` summary mis-described the REINFORCED case: - It showed the candidate's title, but `addOrReinforcePitfall` keeps the matched pitfall's canonical title (the established principle wins) — so the summary could print wording that isn't what's stored/retrieved. - It reported this-run cluster size as "N comments", but a reinforce UNIONS provenance with the prior incidents — undercounting a recurring lesson's evidence under a "Learned from your review history" header. Fix at the source: `addOrReinforcePitfall` now returns the canonical `title`, `scope`, the resulting `incidents` (the union on a reinforce), and `files` (distinct incident files) — the one place that knows the stored shape. Both call sites (distillHistory, addAnalyzedPitfalls) build the `learned` summary from those, dropping their candidate-based (wrong-for-reinforce) re-derivation. This also resolves the engine-path nit (files no longer read from a separate map that could miss an incident) — `files` comes from the same store read, and the documented precondition (scanHistory persists every inc:analyzed:* before add_pitfalls) guarantees it. Tests: reinforce.test asserts the canonical title + unioned incident count in the result; pipeline.test's file-anchoring case now flows through the store-derived count. 551 unit green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The cold-start differentiator — Plex learns from your review history — was invisible:
plex analyzeand theplex initseed reported bare counts ("seeded N lessons, R reinforced, I incidents"). This surfaces the actual payoff so a new user sees memory populate, tied to their code, on day one.DistillResult+addAnalyzedPitfallsnow returnlearned: LearnedLesson[]— per stored lesson:title,scope,incidents(provenance comments), andfiles= the distinct source files those comments concern. Computed right where pitfalls are stored (the cluster already carries each comment'spath), so it's free.plex analyze, theplex initseed, and the MCPanalyze_history/add_pitfallsresults now show the top learned lesson titles + "anchored to N files of your code":Honest framing (ADR-47)
Mined lessons anchor to files (a comment's
path+line) — not symbols. Symbol-level code-path memory accrues only from live-review accepts, notanalyze. So the payoff line says "files," and the launch narrative should too. (The earlier checklist wording "anchored to M symbols" for analyze was inaccurate; corrected here.)How to test
pnpm test:unit(551) —pipeline.testasserts thelearnedsummary (title/action/incidents) and the file-anchoring (distinct comment paths, deduped).pnpm typecheck+pnpm buildgreen.plex analyze(orplex initseed) on a repo with real PR review comments — the summary now lists what it learned + the code it's anchored to. MCP agents seelearnedin theanalyze_history/add_pitfallsresult JSON.Notes
Part of the cold-start track. The companion item — hardening + framing the memory-less day-one review (first-principles + blast radius + deterministic, before any learning) — is a separate follow-up.
🤖 Generated with Claude Code