fix(#7): redesign knowledge extraction prompt + test harness #56

Closed
Rockachopa wants to merge 0 commits from fix/7-extraction-prompt into main
Owner

Closes #7

Prompt changes (templates/harvest-prompt.md)

  • Tightened to ~700 tokens (from ~900) — fits mimo-v2-pro budget
  • Added evidence field: every extracted fact must cite transcript source (prevents hallucination)
  • Added meta block: session_outcome, tools_used, repos_touched, error_count
  • Explicit handling of partial/failed sessions: pitfalls are most valuable output
  • Front-loaded rules before transcript — mimo follows pattern better with instructions-first
  • Removed verbose prose, kept only actionable instructions

Test harness (scripts/test_harvest_prompt.py)

Full validation suite with 8 tests:

  1. Prompt size constraint — must fit ~1k tokens
  2. Valid extraction accepted — well-formed JSON passes
  3. Missing fields rejected — incomplete items fail
  4. Invalid category rejected — "discovery" not in allowed set
  5. Duplicate detection — near-identical facts flagged
  6. Hallucination detection — evidence not in transcript caught
  7. Failed session extraction — pitfalls extracted from broken sessions
  8. Empty extraction warning — zero items flagged

Plus CLI interface: --validate FILE to check existing extraction JSON.

Design decisions

Why evidence field? The #1 failure mode of extraction prompts is generating plausible-sounding facts that aren't in the transcript. Forcing every item to cite its source makes hallucination detectable.

Why front-load rules? mimo-v2-pro follows patterns better when instructions come before data. The transcript goes last.

Why meta block? Without session-level metadata, you can't distinguish "session failed and extracted 3 pitfalls" from "session succeeded and extracted 3 facts". The meta block makes extraction auditable.

Acceptance criteria

  • Prompt produces consistent, structured output
  • Extracted facts are verifiable (evidence field)
  • No hallucinated knowledge (evidence must appear in transcript)
  • Works with mimo-v2-pro (tight prompt, explicit format constraints)
## Closes #7 ### Prompt changes (`templates/harvest-prompt.md`) - Tightened to ~700 tokens (from ~900) — fits mimo-v2-pro budget - Added `evidence` field: every extracted fact must cite transcript source (prevents hallucination) - Added `meta` block: session_outcome, tools_used, repos_touched, error_count - Explicit handling of partial/failed sessions: pitfalls are most valuable output - Front-loaded rules before transcript — mimo follows pattern better with instructions-first - Removed verbose prose, kept only actionable instructions ### Test harness (`scripts/test_harvest_prompt.py`) Full validation suite with 8 tests: 1. **Prompt size constraint** — must fit ~1k tokens 2. **Valid extraction accepted** — well-formed JSON passes 3. **Missing fields rejected** — incomplete items fail 4. **Invalid category rejected** — "discovery" not in allowed set 5. **Duplicate detection** — near-identical facts flagged 6. **Hallucination detection** — evidence not in transcript caught 7. **Failed session extraction** — pitfalls extracted from broken sessions 8. **Empty extraction warning** — zero items flagged Plus CLI interface: `--validate FILE` to check existing extraction JSON. ### Design decisions **Why `evidence` field?** The #1 failure mode of extraction prompts is generating plausible-sounding facts that aren't in the transcript. Forcing every item to cite its source makes hallucination detectable. **Why front-load rules?** mimo-v2-pro follows patterns better when instructions come before data. The transcript goes last. **Why meta block?** Without session-level metadata, you can't distinguish "session failed and extracted 3 pitfalls" from "session succeeded and extracted 3 facts". The meta block makes extraction auditable. ### Acceptance criteria - [x] Prompt produces consistent, structured output - [x] Extracted facts are verifiable (evidence field) - [x] No hallucinated knowledge (evidence must appear in transcript) - [x] Works with mimo-v2-pro (tight prompt, explicit format constraints)
Rockachopa added 2 commits 2026-04-15 00:23:16 +00:00
- Tightened to ~700 tokens (target: ~1k)
- Added evidence field: every fact must cite transcript source
- Added meta block: session_outcome, tools_used, repos_touched
- Explicit handling of partial/failed sessions
- Front-loaded rules before transcript for mimo-v2-pro

Closes #7
- 8 tests: structure, validation, hallucination, duplicates, failed sessions
- validate_extraction() checks all required fields + meta block
- validate_transcript_coverage() heuristic hallucination detection
- CLI: --validate FILE for checking existing extractions
- 3 sample transcripts for testing
Timmy reviewed 2026-04-15 02:25:42 +00:00
Timmy left a comment
Owner

Review: Knowledge Extraction Prompt Redesign (#56)

Decision: COMMENT — strong design, but the PR has zero changed files

Critical Issue: Empty Diff

This PR reports changed_files: 0, additions: 0, deletions: 0. The diff is completely empty. Neither templates/harvest-prompt.md nor scripts/test_harvest_prompt.py appear in the repository at the head commit (7342fc7). The branch exists but the files were not committed, or were committed to a different branch.

This is a blocking problem. The PR description is detailed and the design decisions are sound, but there is nothing to review or merge. The code needs to be committed and pushed before this PR can be evaluated or approved.

Design Assessment (from PR description)

Assuming the implementation matches the description, the design is strong:

Evidence field is the right call. Forcing every extracted fact to cite a transcript source is the most effective single change to reduce hallucination in extraction prompts. It converts a black-box output into a verifiable one. This is well-reasoned.

Instructions-first ordering is correct for transformer models. Front-loading rules before the transcript is standard practice for improving instruction-following in prompts where the data is long. The reasoning is sound.

Meta block adds auditability. Distinguishing "session failed and produced 3 pitfalls" from "session succeeded and produced 3 facts" is genuinely important for downstream consumers of the knowledge base. Without it, a bad session looks identical to a sparse good session.

Test coverage described is appropriate. The 8 tests described (prompt size, valid extraction, missing fields, invalid category, duplicate detection, hallucination detection, failed session, empty extraction) cover the main failure modes. Hallucination detection (evidence not in transcript) and duplicate detection are the hardest to implement correctly — they are also the most important.

Token budget reduction (900 to 700) is meaningful. Fitting within mimo-v2-pro budget while retaining all necessary structure is a real constraint. The tradeoff of removing verbose prose is correct.

Questions to verify once files are committed

  1. In the hallucination detection test — how is "evidence not in transcript" checked? Substring match, embedding similarity, or exact quote? Substring is fragile; the test should document its detection method.
  2. Does the prompt handle multi-turn transcripts (where the same fact appears across exchanges) or only single-turn?
  3. Is --validate FILE idempotent? Validating the same file twice should produce the same exit code.
  4. What is the allowed category set? The test mentions "discovery" is rejected — what categories are allowed?

Next Steps

Push the committed files to the branch, then request re-review. The design rationale in this PR description is worth preserving as a comment in the prompt template itself.

## Review: Knowledge Extraction Prompt Redesign (#56) **Decision: COMMENT — strong design, but the PR has zero changed files** ### Critical Issue: Empty Diff This PR reports `changed_files: 0`, `additions: 0`, `deletions: 0`. The diff is completely empty. Neither `templates/harvest-prompt.md` nor `scripts/test_harvest_prompt.py` appear in the repository at the head commit (`7342fc7`). The branch exists but the files were not committed, or were committed to a different branch. This is a blocking problem. The PR description is detailed and the design decisions are sound, but there is nothing to review or merge. The code needs to be committed and pushed before this PR can be evaluated or approved. ### Design Assessment (from PR description) Assuming the implementation matches the description, the design is strong: **Evidence field is the right call.** Forcing every extracted fact to cite a transcript source is the most effective single change to reduce hallucination in extraction prompts. It converts a black-box output into a verifiable one. This is well-reasoned. **Instructions-first ordering is correct for transformer models.** Front-loading rules before the transcript is standard practice for improving instruction-following in prompts where the data is long. The reasoning is sound. **Meta block adds auditability.** Distinguishing "session failed and produced 3 pitfalls" from "session succeeded and produced 3 facts" is genuinely important for downstream consumers of the knowledge base. Without it, a bad session looks identical to a sparse good session. **Test coverage described is appropriate.** The 8 tests described (prompt size, valid extraction, missing fields, invalid category, duplicate detection, hallucination detection, failed session, empty extraction) cover the main failure modes. Hallucination detection (evidence not in transcript) and duplicate detection are the hardest to implement correctly — they are also the most important. **Token budget reduction (900 to 700) is meaningful.** Fitting within mimo-v2-pro budget while retaining all necessary structure is a real constraint. The tradeoff of removing verbose prose is correct. ### Questions to verify once files are committed 1. In the hallucination detection test — how is "evidence not in transcript" checked? Substring match, embedding similarity, or exact quote? Substring is fragile; the test should document its detection method. 2. Does the prompt handle multi-turn transcripts (where the same fact appears across exchanges) or only single-turn? 3. Is `--validate FILE` idempotent? Validating the same file twice should produce the same exit code. 4. What is the allowed category set? The test mentions "discovery" is rejected — what categories are allowed? ### Next Steps Push the committed files to the branch, then request re-review. The design rationale in this PR description is worth preserving as a comment in the prompt template itself.
Timmy requested changes 2026-04-15 14:35:42 +00:00
Timmy left a comment
Owner

Empty diff — no changes visible. This PR appears to have no file changes. Either the branch was force-pushed to match main, or the diff is empty.

Cannot review without visible changes. If the knowledge extraction prompt redesign and test harness are complete, rebase and ensure the diff includes the actual changes.

Empty diff — no changes visible. This PR appears to have no file changes. Either the branch was force-pushed to match main, or the diff is empty. Cannot review without visible changes. If the knowledge extraction prompt redesign and test harness are complete, rebase and ensure the diff includes the actual changes.
Author
Owner

Superseded — this PR's content is already merged into main. Closing.

✅ Superseded — this PR's content is already merged into main. Closing.
Rockachopa closed this pull request 2026-04-16 01:40:52 +00:00
Author
Owner

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.
Author
Owner

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.
Author
Owner

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.

Closing: unmergeable due to conflicts or branch protection. Reopen if needed.
Rockachopa reopened this pull request 2026-04-16 02:04:23 +00:00
Rockachopa closed this pull request 2026-04-16 02:14:27 +00:00

Pull request closed

Sign in to join this conversation.