Skip to content

feat(analyze): show what analyze learned + where it's anchored in your code (cold-start payoff)#27

Merged
sshanzel merged 2 commits into
mainfrom
feat/analyze-payoff-visible
Jun 17, 2026
Merged

feat(analyze): show what analyze learned + where it's anchored in your code (cold-start payoff)#27
sshanzel merged 2 commits into
mainfrom
feat/analyze-payoff-visible

Conversation

@sshanzel

Copy link
Copy Markdown
Owner

What changed

The cold-start differentiator — Plex learns from your review history — was invisible: plex analyze and the plex init seed 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 + addAnalyzedPitfalls now return learned: LearnedLesson[] — per stored lesson: title, scope, incidents (provenance comments), and files = the distinct source files those comments concern. Computed right where pitfalls are stored (the cluster already carries each comment's path), so it's free.
  • plex analyze, the plex init seed, and the MCP analyze_history / add_pitfalls results now show the top learned lesson titles + "anchored to N files of your code":
Analyzed 25 new PR(s)… → +18 new pitfalls, 2 reinforced, +130 incidents. Distiller: claude-cli.
Learned from your review history (anchored to your code):
  • Validate tenant id on every query  (12 comments · 6 files)
  • Guard credential generation scripts against …  (4 comments · 2 files)
  …and 16 more.

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, not analyze. 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.test asserts the learned summary (title/action/incidents) and the file-anchoring (distinct comment paths, deduped). pnpm typecheck + pnpm build green.
  • Manual: plex analyze (or plex init seed) on a repo with real PR review comments — the summary now lists what it learned + the code it's anchored to. MCP agents see learned in the analyze_history/add_pitfalls result 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

sshanzel and others added 2 commits June 17, 2026 22:18
…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>
@sshanzel sshanzel merged commit c6cbadf into main Jun 17, 2026
1 check passed
@sshanzel sshanzel deleted the feat/analyze-payoff-visible branch June 17, 2026 20:35
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