feat(orchestrator): --book-mode — Planung je Hauptkapitel, Extraktion global (#346) - #349
Merged
Conversation
… global (#346) Neues CLI-Flag --book-mode (mutually exclusive mit dem deprecated --by-chapter). Kapitel partitionieren NUR die Planung, nie die Extraktion — Notes synthetisieren weiterhin über Kapitelgrenzen (Kern-Kontrakt). Ablauf: Planner je Hauptkapitel (nur bei nutzbarem Outline-Split, sonst transparenter Normalpfad-Fallback mit Diagnose) → Kandidaten mit index-alignierten Kapitel-Keys → secondary_mentions kapitelübergreifend dedupliziert in related_mentions → globale dedup_concept_candidates → Skip-Action-Filter vor dem Cap → Budget min(n_Kapitel x 12, 120) → wortanteil-balancierter cap_candidates_balanced → EIN globaler Extractor-Lauf über den Volltext. Background-Extractor aus (wie by-chapter). _run_planner_stage als reiner 1:1-Refactor aus _plan_and_extract (Planner-Call + Halluzinations-Filter); Normal-/by-chapter-Verhalten unverändert. config: BOOK_MODE_CONCEPTS_PER_CHAPTER=12, BOOK_MODE_MAX_TOTAL=120 (ENV-Escape-Hatch). Closes #346.
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.
Closes #346.
PR 3/3 des Implementierungsplans #345/#346 (baut auf PR 1 [Outline-Split, #348] + PR 2 [
dedup_concept_candidates/cap_candidates_balanced, #347] auf).Ablauf (Kurzfassung)
Neues CLI-Flag
--book-mode(argparse mutually-exclusive-Group mit dem deprecated--by-chapter). Kapitel partitionieren nur die Planung, nie die Extraktion — Notes synthetisieren weiterhin über Kapitelgrenzen (Kern-Kontrakt).chunks[0].source == "outline"und len > 1) — sonst transparenter Fallback auf den Normalpfad mit Diagnose-Print._run_planner_stageje Hauptkapitel (plan_text = hall_text = chunk.text).chapter_keysindex-aligned mitführen (Key =chunk.title);secondary_mentionskapitelübergreifend dedupliziert inrelated_mentions.dedup_concept_candidates(Survivor-Keys perid()rückverfolgt, index-aligned rekonstruiert).min(n_Kapitel × BOOK_MODE_CONCEPTS_PER_CHAPTER, BOOK_MODE_MAX_TOTAL)(12/120) undcap_candidates_balancedmitchapter_word_counts.run_extractors_per_concept(text, merged_plan, …)mit Volltext._run_planner_stageist ein reiner 1:1-Refactor aus_plan_and_extract(Planner-Call + Halluzinations-Filter). Der Konzept-Cap bleibt beim Aufrufer, weil book-mode den wortanteil-balancierten Cap fährt. Normal- und by-chapter-Verhalten unverändert.Geänderte Dateien
generative/orchestrator.py—--book-mode-Wiring,_run_book_mode,_run_planner_stage-Refactor, mutually-exclusive-Group,_background_extractor_by_chapter_skip_linemode-aware (rückwärtskompatibel).generative/config.py—BOOK_MODE_CONCEPTS_PER_CHAPTER=12,BOOK_MODE_MAX_TOTAL=120(ENV-Escape-Hatch).generative/ui_strings.py—orch.arg.book_modeneu,orch.arg.by_chaptermit Deprecated-Hinweis.generative/tests/test_book_mode_wiring.py— Contract-Tests (neu).generative/pipeline/pdf_chunker.py(PR-1-Stand) unberührt.Contract-Tests (
test_book_mode_wiring.py, alle grün)test_normal_path_extracts_from_full_texttest_by_chapter_extracts_from_chunk_text--by-chapterplant + extrahiert je Kapitel auschunk.texttest_book_mode_plans_locally_extracts_globallyfull_text == Volltext, Kandidaten aus beiden Kapitelntest_book_mode_without_outline_falls_back_to_normaltest_planner_calls_equal_chapters_and_candidates_within_budgettest_book_mode_filters_skip_actions_before_captest_book_mode_dedups_secondary_mentions_across_chaptersrelated_mentionstest_book_mode_skips_background_extractortest_book_mode_and_by_chapter_are_mutually_exclusiveSystemExittest_cap_budget_zero_keeps_only_secondary_mentionstest_cap_missing_chapter_word_count_no_crashget(k,0)-Fallback, kein CrashRED-Nachweis (TDD)
Vor der Implementierung (nur Testdatei vorhanden): 6 failed, 5 passed — die 6 book-mode-spezifischen Tests failten (u. a.
test_book_mode_plans_locally_extracts_globally→assert 1 == 2,test_planner_calls…→AttributeErroraufBOOK_MODE_CONCEPTS_PER_CHAPTER,test_book_mode_skips_background_extractor→ Background lief). Nach Implementierung: 15 passed (11 neu + 4 by-chapter-Bestandstests unverändert grün).Suite
uv run pytest generative lib/decision_engine/tests shared/tests -q: 6293 passed, 11 skipped, 9 deselected (396 s).ruff check generative/ lib/decision_engine/ shared/: All checks passed.ruff format --check: already formatted.uv sync --extra dev --lockedsauber; Import-Herkunft aus Worktree bestätigt.