codewhale.history 2.10.1 → 2.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,6 +21,8 @@ tools_for_codewhale/
21
21
  ```
22
22
 
23
23
  ## Install
24
+ ### IMPORTANT
25
+ If you already have codewhale.history installed in a folder and want to update to the lastest version in that folder, delete the .codewhale/instructions.md file before running `npm install -g codewhale.history`
24
26
 
25
27
  ```bash
26
28
  npm install -g codewhale.history
@@ -88,6 +90,7 @@ current project. Two independent dimensions across five difficulty levels:
88
90
  - **Standard** (default) — Code comprehension or line reconstruction.
89
91
  - **SOLID** (`teach me solid`) — Anti-pattern detection and design restoration.
90
92
  - **Spec** (`teach me spec`) — Spec-to-code traceability using office docs as source.
93
+ - **BA-Gates** (`teach me ba`) — BA documentation quality analysis (ambiguity, AC completeness, edge case coverage).
91
94
 
92
95
  | Trigger | Response | Theme | What happens |
93
96
  |---------|----------|-------|-------------|
@@ -97,6 +100,8 @@ current project. Two independent dimensions across five difficulty levels:
97
100
  | `teach me solid interactive` | interactive | solid | Degraded code; you edit to fix it |
98
101
  | `teach me spec` | passive | spec | Spec or code presented; you trace the link |
99
102
  | `teach me spec interactive` | interactive | spec | Trace spec to code; you edit code to match |
103
+ | `teach me ba` | passive | ba-gates | BA doc fragment; you identify quality gate violations |
104
+ | `teach me ba interactive` | interactive | ba-gates | BA doc with issues; you edit to fix them |
100
105
 
101
106
  **Triggers:** `teach me` · `quiz me` · `test my knowledge` · `code quiz` ·
102
107
  `drill me`
@@ -110,6 +115,7 @@ current project. Two independent dimensions across five difficulty levels:
110
115
  | Response | `teach me interactive` | Edit the file instead of describing |
111
116
  | Theme | `teach me solid` | Anti-pattern detection — fix degraded design |
112
117
  | Theme | `teach me spec` | Spec-to-code traceability via office docs |
118
+ | Theme | `teach me ba` | BA documentation quality analysis |
113
119
  | Scope | `teach me services/` | Narrow to a specific file or folder |
114
120
  | Concept | `teach me decorators` | Target: decorators, async, generators, context managers, comprehensions, error handling, type hints, threading |
115
121
 
@@ -125,7 +131,7 @@ current project. Two independent dimensions across five difficulty levels:
125
131
 
126
132
  **Mid-round commands:** `hint` (get a nudge) · `skip` (see the answer) ·
127
133
  `next` (draw a new snippet) · `level N` · `easier` · `harder` ·
128
- `interactive` · `passive` · `solid` · `spec` · `done` (verify work) · `stop`
134
+ `interactive` · `passive` · `solid` · `spec` · `ba` · `done` (verify work) · `stop`
129
135
 
130
136
  **At the end** you get a session summary: rounds completed, mode, files covered,
131
137
  what you're strong on, what to review, and a suggested next level.
@@ -142,6 +148,17 @@ spec?" or "what spec does this code satisfy?" — testing whether you truly
142
148
  understand how requirements map to implementation. In interactive mode, you
143
149
  edit the code to satisfy the spec; in passive mode, you describe the link.
144
150
 
151
+ In **BA-Gates theme**: the model runs a two-pass analysis over your BA documentation
152
+ files (`.docx`, `.pptx`, `.xlsx`, `.md`, `.feature`, `.txt`). Pass 1 uses regex
153
+ triage to flag fragments against three quality gates — **Ambiguity**
154
+ (unmeasurable terms, passive states), **Acceptance Criteria Completeness**
155
+ (missing structure, unverifiable outcomes), and **Edge Case Coverage** (missing
156
+ negative scenarios, error states). Pass 2 runs an LLM interpretation per
157
+ fragment at round time to generate quiz material and concrete improvement
158
+ options. You identify which gates a fragment triggers and describe the developer
159
+ impact. On skip or strike-3, the model presents 2–3 domain-specific rewrites per
160
+ issue with a best-fit recommendation.
161
+
145
162
  ## Requirements
146
163
  - Node.js (for the `codewhale-history` command)
147
164
  - [CodeWhale](https://codewhale.net/en/docs)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codewhale.history",
3
- "version": "2.10.1",
3
+ "version": "2.11.1",
4
4
  "description": "CodeWhale utility commands: session history, tool listing, file snapshot, interactive code quiz — global install",
5
5
  "bin": {
6
6
  "codewhale-history": "./_list_sessions.js",
@@ -1,23 +1,28 @@
1
1
  ---
2
2
  name: teach-me
3
- description: Interactive code-teaching quiz. Selects random snippets from the current project and quizzes the user on application logic and language semantics. Triggered by 'teach me', 'quiz me', 'test my knowledge', 'code quiz', or 'drill me'. Supports difficulty levels 1–5 and three modes: passive (explain), interactive (reconstruct), and solid (anti-pattern detection).
3
+ description: Interactive code-teaching quiz. Selects random snippets from the current project and quizzes the user on application logic, language semantics, or BA documentation quality. Triggered by 'teach me', 'quiz me', 'test my knowledge', 'code quiz', or 'drill me'. Supports difficulty levels 1–5 and four themes: passive (explain), interactive (reconstruct), solid (anti-pattern detection), spec (spec-to-code traceability), and ba-gates (BA documentation quality analysis).
4
4
  ---
5
5
 
6
6
  # Teach Me — Interactive Code Quiz
7
7
 
8
- An interactive teaching session that randomly selects code snippets from the
8
+ An interactive teaching session that randomly selects code snippets or BA documentation fragments from the
9
9
  current project. Two independent dimensions combine to form each exercise:
10
10
 
11
11
  **Response mode** (how you answer — mid-session commands `passive` / `interactive`):
12
12
  - **`passive`** (default) — You describe your answer in the console.
13
13
  - **`interactive`** — You edit the actual file, then say `done` for verification.
14
14
 
15
- **Content theme** (what the exercise is about — trigger keywords `solid`, `spec`):
15
+ **Content theme** (what the exercise is about — trigger keywords `solid`, `spec`, `ba`):
16
16
  - **Standard** (default) — Code comprehension or line reconstruction.
17
17
  - **`solid`** / **`SOLID`** — Anti-pattern detection and design restoration.
18
18
  - **`spec`** — Spec-to-code traceability. Exercise shapes alternate randomly:
19
19
  spec → code (show a requirement, ask what code implements it) or code → spec
20
20
  (show code, ask what requirement it satisfies).
21
+ - **`ba`** / **`ba-gates`** / **`requirements`** — BA documentation quality analysis.
22
+ Scans requirements documents (.docx, .pptx, .xlsx, .md, .feature, .txt) and
23
+ quizzes on three quality gates: ambiguity, acceptance criteria completeness,
24
+ and edge case coverage. Uses two-pass analysis: regex triage then LLM
25
+ interpretation per fragment. On skip, presents concrete improvement options.
21
26
 
22
27
  | Trigger | Response | Theme | What happens |
23
28
  |---------|----------|-------|-------------|
@@ -27,6 +32,8 @@ current project. Two independent dimensions combine to form each exercise:
27
32
  | `teach me solid interactive` | interactive | solid | Code rewritten with anti-patterns; you edit the file to restore good design, say `done` |
28
33
  | `teach me spec` | passive | spec | Present spec or code; you describe the link between them |
29
34
  | `teach me spec interactive` | interactive | spec | Spec-to-code traceability; you edit code to satisfy a spec, say `done` |
35
+ | `teach me ba` | passive | ba-gates | Present BA doc fragment; you identify quality gate violations |
36
+ | `teach me ba interactive` | interactive | ba-gates | BA doc with quality issues; you edit the doc to fix them, say `done` |
30
37
 
31
38
  Level, scope, language, and concept modifiers combine freely with any
32
39
  combination above.
@@ -54,13 +61,18 @@ Optionally followed by modifiers:
54
61
  - `teach me interactive` — edit the file (instead of describing)
55
62
  - `teach me solid` / `teach me SOLID` — anti-pattern restoration theme
56
63
  - `teach me spec` — spec-to-code traceability theme
64
+ - `teach me ba` / `teach me ba-gates` / `teach me requirements` — BA documentation quality analysis theme
65
+ - `quiz me on requirements` / `ba quality check` — alternative ba-gates triggers
57
66
 
58
67
  Modifiers combine freely: `teach me decorators level 4`,
59
68
  `teach me async services/`, `teach me generators l2`,
60
69
  `teach me level 2 interactive`, `teach me interactive decorators`,
61
70
  `teach me solid level 3`, `teach me SOLID`,
62
71
  `teach me solid interactive`,
63
- `teach me spec`, `teach me spec interactive`
72
+ `teach me spec`, `teach me spec interactive`,
73
+ `teach me ba`, `teach me ba level 3`,
74
+ `teach me ba interactive`, `teach me ba <file>`,
75
+ `teach me requirements level 4`
64
76
 
65
77
  If no level is specified, default to **level 3** and adjust based on
66
78
  performance across rounds.
@@ -423,13 +435,345 @@ Type `hint` for a clue, `skip` to see the answer, or `stop` to end.
423
435
  ---
424
436
  ```
425
437
 
438
+ ### 2e. BA-Gates Theme — BA Documentation Quality Analysis
439
+
440
+ When content theme is `ba-gates` (triggered by `teach me ba`, `teach me ba-gates`,
441
+ `teach me requirements`, `quiz me on requirements`, or `ba quality check`), the model
442
+ scans BA documentation across all supported formats and quizzes the user on three
443
+ quality gates: **ambiguity**, **acceptance criteria completeness**, and
444
+ **edge case coverage**. The goal is to surface documentation quality gaps and
445
+ present concrete improvement options.
446
+
447
+ BA-Gates theme supports both response modes:
448
+ - **passive + ba-gates** (`teach me ba`): User describes gate violations in console.
449
+ - **interactive + ba-gates** (`teach me ba interactive`): User edits the document to
450
+ fix the issues, says `done`.
451
+
452
+ #### Discovery (BA-Gates Theme) — Two-Pass Architecture
453
+
454
+ The discovery phase runs two passes: a fast heuristic triage (Pass 1) followed by
455
+ LLM interpretation of flagged fragments (Pass 2 at round time).
456
+
457
+ #### Pass 1: Regex Triage
458
+
459
+ Purpose: narrow the field. Cheap, fast pattern matching to answer "which fragments
460
+ probably have quality issues?" Not an answer — a filter.
461
+
462
+ 1. **Scan for BA documents.** Use `file_search` and `list_dir` to find files in the workspace:
463
+ - Office formats: `.docx`, `.pptx`, `.xlsx`
464
+ - Plaintext formats: `.md`, `.feature`, `.txt` (filter to those containing requirements/spec keywords: `feature`, `scenario`, `user story`, `requirement`, `acceptance`, `given`, `when`, `then`, `background`, `example`)
465
+ - Do NOT scan source code files (`.py`, `.js`, `.ts`, `.java`, `.cs`, `.go`, `.rs`, `.c`, `.cpp`, `.h`).
466
+
467
+ 2. **Extract text** from office files:
468
+ - Run `codewhale-doc-extract <file>` for `.docx` and `.pptx` files
469
+ - For `.xlsx` files: use `codewhale-doc-extract` to extract table data
470
+ - If extraction fails for any file, note it and skip that file
471
+
472
+ 3. **Read plaintext files** directly with `read_file`.
473
+
474
+ 4. **Split into fragments:**
475
+ - Feature blocks (Gherkin `Feature:` through the examples table)
476
+ - Scenario blocks (individual `Scenario:` or `Scenario Outline:` sections)
477
+ - Background blocks (`Background:` sections)
478
+ - Requirement paragraphs (standalone lines with "shall", "must", "should", "will")
479
+ - User story blocks (lines matching "As a... I want... So that...")
480
+ - Acceptance criteria lists (bullet points under a story)
481
+ - Example/Data tables (tabular data in `.feature` or `.md` files)
482
+ - Slide content (per-slide extracts from `.pptx`)
483
+ - Spreadsheet row groups (per-sheet or per-section from `.xlsx`)
484
+
485
+ 5. **Run the three heuristic gate scans** against each fragment. These are
486
+ pattern-based, not semantic — they catch surface signals only.
487
+
488
+ **Gate 1 — Ambiguity patterns:**
489
+ - Vague qualifiers: `should`, `maybe`, `perhaps`, `generally`, `typically`, `normally`, `usually`, `approximately`, `about`, `roughly`, `ideally`, `preferably`, `optionally`
490
+ - Unmeasurable adjectives: `fast`, `slow`, `good`, `bad`, `intuitive`, `user-friendly`, `robust`, `reliable`, `scalable`, `flexible`, `easy`, `simple`, `clean`, `nice`, `attractive`, `modern`, `efficient`, `powerful`, `seamless`, `smooth`, `responsive`, `high-quality`, `performant`
491
+ - Vague nouns (without specifics): `stuff`, `things`, `data`, `information`, `details`, `content`, `items`, `results`
492
+ - Passive/unattributed states: `is ready`, `is configured`, `is loaded`, `is set up`, `is available`, `is enabled`, `is active`
493
+ - Missing quantifiers: `a list of` without pagination/ordering/format spec, `results` without count or structure, `some`, `several`, `various`
494
+ - Ambiguous connectives: `and/or`, `etc.`, `and so on`, `...`, `such as`
495
+
496
+ **Gate 2 — AC Completeness patterns:**
497
+ - Missing Given/When/Then markers in scenario blocks
498
+ - Unmeasurable outcomes (Then steps with Gate 1 ambiguity terms, or outcomes that restate the story)
499
+ - Blank or empty cells in example tables
500
+ - Example table rows with populated input columns but empty expected-output columns
501
+ - Stories with body text but no AC bullet points
502
+
503
+ **Gate 3 — Edge Case patterns:**
504
+ - Fragment contains only positive-case examples (no error, invalid, or failure scenarios)
505
+ - No examples at value boundaries (zero, empty string, max length, null, negative values)
506
+ - Edge case scenario rows where expected outcomes are blank (acknowledged but unresolved)
507
+ - No examples of: empty input, no results, invalid format, expired state, concurrency, timeout
508
+
509
+ 6. **Build the candidate index.** Store for each flagged fragment:
510
+ ```
511
+ fragment_id → {
512
+ source: file + line range,
513
+ text: fragment content,
514
+ regex_flags: [which patterns matched and where],
515
+ gate_triggers: [which of the 3 gates fired]
516
+ }
517
+ ```
518
+ Discard fragments with zero gate triggers — they are not quiz candidates.
519
+
520
+ 7. Report: "Scanned N BA documents → M fragments. Pass 1 flagged X candidates across Y documents. Starting at level X. Ready."
521
+
522
+ #### Pass 2: LLM Interpretation (at Round Time)
523
+
524
+ Pass 2 runs **per fragment, at the start of each round, before presentation**.
525
+ The regex said "this fragment has a flag." Pass 2 asks: "is this flag meaningful,
526
+ and if so, what's the best way to quiz on it?"
527
+
528
+ This is deep-thinking work. The model must understand the fragment before it can
529
+ teach from it.
530
+
531
+ When a candidate fragment is selected for a round:
532
+
533
+ 1. **Read the fragment in context.** Re-read the surrounding file: the full feature,
534
+ adjacent scenarios, the feature title and description. What is this document
535
+ trying to specify? What domain is it in? What would the implementing developer
536
+ need to know?
537
+
538
+ 2. **Interpret the regex flags semantically.** For each regex flag:
539
+ - Is this actually a problem, or a false positive? (e.g., "should" in "the user
540
+ should see an error message" is fine — it's an observable outcome. "Should" in
541
+ "the system should be fast" is a problem.)
542
+ - What would a developer be confused by? What would they have to guess?
543
+ - What would they have to go back and ask the BA about?
544
+ - What edge cases are implied by the domain but not stated?
545
+ - What's the **most important gap** — not the most numerous, but the one that
546
+ would cause the most rework or the most ambiguity?
547
+
548
+ 3. **Generate the quiz material:**
549
+
550
+ a. **Question** — framed to test whether the BA can see the gap and understand
551
+ why it matters. Not "spot the vague word" but "what's missing that would
552
+ prevent a developer from implementing this deterministically?"
553
+
554
+ b. **Expected answer** — the specific gate(s) violated, the specific fragment
555
+ location, and why it matters to downstream development.
556
+
557
+ c. **Strike-1 hint** — category nudge (name the gate, not the issue).
558
+
559
+ d. **Strike-2 hint** — near-explicit (name the gate AND point to the location,
560
+ hint at the nature of the gap).
561
+
562
+ e. **Improvement options** — 2–3 concrete, domain-specific rewrites of the
563
+ fragment with a "best fit" recommendation. Prefer specific data, concrete
564
+ assertions, and verifiable preconditions over abstract advice.
565
+
566
+ f. **What the developer would trip over** — a one-line summary of the practical
567
+ impact. This is revealed as part of the improvement options, not in the
568
+ question itself.
569
+
570
+ 4. **Verify the fragment is quiz-worthy.** If Pass 2 determines all regex flags
571
+ are false positives and there is no meaningful quality gap, discard the
572
+ fragment and select another. Do not fabricate issues.
573
+
574
+ 5. **Store the generated material** in memory for evaluation. Do NOT include it
575
+ in reasoning_content from this point forward — switch to Skip thinking before
576
+ presenting to the user.
577
+
578
+ #### Difficulty Levels (BA-Gates)
579
+
580
+ | Level | Fragment scope | What the regex flags | What Pass 2 interprets | What the user must do |
581
+ |-------|---------------|---------------------|----------------------|----------------------|
582
+ | 1 | Single requirement line or story title (1–3 lines) | 1 obvious surface flag | Confirm the flag is real; generate a direct question | Identify the gate and the flagged term |
583
+ | 2 | Single scenario or AC block (3–10 lines) | 1–2 gate triggers | Assess false positives; pick the most meaningful gap | Identify all gate violations and the specific offending terms |
584
+ | 3 | Full feature or story with examples (10–30 lines) | Multiple triggers across at least 2 gates | Distinguish surface flags from structural gaps; identify domain implications | All violations + explain why the most important one matters to development |
585
+ | 4 | Multi-scenario feature or cross-document fragment (20–60 lines) | Cross-cutting patterns | Identify systemic documentation debt; what pattern recurs? | Systemic issues + propose fixes for each gate with rationale |
586
+ | 5 | Full document or multi-document comparison | Architectural documentation debt | Structural weaknesses across the document set; what's the root cause? | Prioritised improvement plan with concrete rewrites across multiple fragments |
587
+
588
+ #### BA-Gates Per-Round Flow
589
+
590
+ 0. **Snapshot git state.** Run `git status --porcelain` on BA document files. If the workspace is NOT a git repo, run `//snapshot on` for interactive mode.
591
+ 1. **Select** a candidate fragment from the Pass 1 index, weighted by:
592
+ - Prioritize fragments that trigger multiple gates over single-gate fragments
593
+ - Prioritize higher-confidence flags at higher difficulty levels
594
+ - Avoid repeating the same fragment unless all candidates are exhausted
595
+ 2. **Run Pass 2 LLM interpretation.** Deep thinking — read context, interpret flags, assess false positives, identify the most important gap, generate quiz material.
596
+ 3. **Verify quiz-worthiness.** If Pass 2 finds no meaningful gap, discard and loop to step 1.
597
+ 4. **Suppress thinking.** Switch to Skip thinking depth from this point through presentation.
598
+ 5. **Present** the fragment with its source, line/cell reference, and a gate-count hint — but do NOT reveal which gates or where.
599
+ 6. **Instruct** (depends on response mode):
600
+ - *Passive:* "Which of the three BA quality gates does this fragment trigger — Ambiguity, Acceptance Criteria Completeness, or Edge Case Coverage? Describe what specifically is the problem and how a developer would be affected."
601
+ - *Interactive:* "The document has quality issues flagged by the BA gates. Open `<file>`, find and fix the issues. Say `done` when ready." For interactive with office files (`.docx`, `.pptx`, `.xlsx`), present extracted text inline and ask the user to describe the fix since they cannot edit binaries directly.
602
+ 7. **Wait.** Do not evaluate until the user signals completion.
603
+ 8. **Evaluate** against the Pass 2 generated answer. Use the three-strikes system with the generated hints.
604
+ 9. **Feedback + Improvement Options.** On success, highlight what they got right and what they could sharpen. On skip or strike-3, present the Pass 2 generated improvement options with the "what the developer would trip over" summary.
605
+ 10. **Restore** (interactive only for plaintext files). For office files, no restoration needed.
606
+
607
+ #### Thinking Suppression (BA-Gates Theme)
608
+
609
+ - **Pass 2 analysis (step 2):** Use **Deep** or **High** thinking. This is where the model reasons about the fragment and generates quiz material. The thinking block will contain the generated answer — this is acceptable since the user has not yet seen the fragment.
610
+ - **Presentation onward (steps 4–10):** Use **Skip** thinking. Never reveal the specific gates triggered, their locations, or the generated answer in reasoning once the fragment is presented.
611
+
612
+ #### BA-Gates Presentation Format
613
+
614
+ ```
615
+ ---
616
+ ## Round N — Level X · passive · ba-gates | `timesheet.feature.txt` (lines 1–5)
617
+
618
+ **From:** `timesheet.feature.txt` — Background section
619
+
620
+ ```gherkin
621
+ Feature: Timesheet Calculations from FitNesse
622
+ Background:
623
+ Given the timesheet system is ready
624
+ And hourly rates are configured
625
+ ```
626
+
627
+ ⚠️ **BA-Gates Mode.** This fragment triggers one or more BA documentation quality
628
+ gates (Ambiguity, Acceptance Criteria Completeness, or Edge Case Coverage).
629
+
630
+ **Your turn:** (Passive) Which gate(s) does this fragment trigger? Describe
631
+ what specifically is the problem and how a developer would be affected.
632
+
633
+ Type `hint` for a clue, `skip` to see the full analysis and improvement options, or `stop` to end.
634
+ ---
635
+ ```
636
+
637
+ #### BA-Gates Interactive Presentation Format
638
+
639
+ For plaintext files (`.md`, `.feature`, `.txt`), the model does NOT edit the file — the user edits it:
640
+
641
+ ```
642
+ ---
643
+ ## Round N — Level X · interactive · ba-gates | `qa_cinemas_ac_scenarios.md`
644
+
645
+ **From:** `qa_cinemas_ac_scenarios.md` — Scenario: "Return relevant results for valid keyword searches"
646
+
647
+ ```gherkin
648
+ Scenario Outline: Return relevant results for valid keyword searches
649
+ When the user clicks the search box
650
+ Then the placeholder text is removed
651
+ When the user types <keyword> into the search box
652
+ And clicks the Search button
653
+ Then the typed text remains visible in the search box
654
+ And <expected_result>
655
+ ```
656
+
657
+ ⚠️ **BA-Gates Interactive.** This fragment has quality issues. Open
658
+ `qa_cinemas_ac_scenarios.md`, find and fix the issues. When you're done,
659
+ say **`done`** or **`check my work`**.
660
+
661
+ Type `hint` for a clue, `skip` to see the full analysis, or `stop` to end.
662
+ ---
663
+ ```
664
+
665
+ For office files (`.docx`, `.pptx`, `.xlsx`), interactive mode presents the extracted text inline and asks the user to describe the fix since they cannot edit the binary directly.
666
+
667
+ #### BA-Gates Evaluation
668
+
669
+ Score across three dimensions aligned to the gates. Use the Pass 2 generated expected answer as the reference:
670
+
671
+ | Dimension | What to check |
672
+ |-----------|--------------|
673
+ | **Ambiguity detection** | Did the user identify vague qualifiers, unmeasurable adjectives, passive/unverifiable states? |
674
+ | **AC completeness** | Did the user spot missing structure, unmeasurable outcomes, blank table cells, circular AC? |
675
+ | **Edge case coverage** | Did the user identify missing negative scenarios, boundary tests, error states, unresolved edge cases? |
676
+
677
+ **Outcome levels:**
678
+
679
+ | Outcome | Criteria | Feedback approach |
680
+ |---------|----------|-------------------|
681
+ | **Complete** | Identified all gate triggers at the current level with specific references | Highlight what they caught + 1–2 things to sharpen |
682
+ | **Partial** | Identified some triggers, or named gates without specifics | Strike-1 or strike-2 nudge toward the missed gate |
683
+ | **Missed** | Did not identify the primary gate trigger(s) | Strike-2 or strike-3 with full improvement options |
684
+
685
+ #### Strikes in BA-Gates Mode
686
+
687
+ Use the Pass 2 generated hints:
688
+
689
+ **Strike 1** — Category nudge (name the gate, not the issue):
690
+ ```
691
+ Good effort. Think about Gate 1 (Ambiguity) — are there any terms in this
692
+ fragment that can't be measured, verified, or tested programmatically?
693
+ ```
694
+
695
+ **Strike 2** — Near-explicit hint (name the gate AND point to the location):
696
+ ```
697
+ You're getting there. Look at "the timesheet system is ready" on line 3.
698
+ This is a passive state — what observable condition would prove readiness?
699
+ Also check line 4 — same pattern.
700
+ ```
701
+
702
+ **Strike 3** — Reveal full analysis with improvement options (see below). Move to next round automatically.
703
+
704
+ #### Improvement Options on Skip or Strike-3
705
+
706
+ When the user skips or reaches strike-3, present the Pass 2 generated improvement options. Structure:
707
+
708
+ ```
709
+ ⚑ Gate 1 — Ambiguity (2 issues)
710
+
711
+ Issue 1: "the timesheet system is ready" (line 3)
712
+ Problem: Passive state — no observable condition. "Ready" is not verifiable.
713
+ Developer impact: A developer writing the test harness can't assert
714
+ "readiness" without guessing what condition to check.
715
+
716
+ → Option A: "the TimesheetService health endpoint returns HTTP 200"
717
+ → Option B: "the time_normalizer module is initialised with a valid rate table"
718
+ → Option C: "the database connection pool reports status 'active'"
719
+ → Best fit: Option B (directly tests the component under test)
720
+
721
+ Issue 2: "hourly rates are configured" (line 4)
722
+ Problem: Passive state — no verifiable precondition. "Configured" is not testable.
723
+ Developer impact: A developer must either hardcode a rate (fragile) or ask
724
+ the BA what specific rate to use.
725
+
726
+ → Option A: "a rate of $25.00 exists for employee E001 in the rates table"
727
+ → Option B: "the /api/rates endpoint returns at least one active rate with amount > 0"
728
+ → Option C: "the rates configuration file contains at least one entry with key 'default_rate'"
729
+ → Best fit: Option A (concrete data, directly usable in the test)
730
+
731
+ 💡 Pattern: Replace Background preconditions with programmatically verifiable
732
+ states. Every Given step should map to an assertion that can pass or fail
733
+ deterministically in the test harness.
734
+ ---
735
+
736
+ ⚑ Gate 2 — Acceptance Criteria Completeness (1 issue)
737
+
738
+ Issue: Both Background steps lack verifiable structure — they are preconditions
739
+ but cannot be asserted against.
740
+ Developer impact: The test setup phase has no concrete fixture to build.
741
+
742
+ → Improve: Rewrite as:
743
+ Given the TimeNormaliser service is running on localhost:8080
744
+ And the rates table contains {"E001": 25.00, "E002": 18.50}
745
+ And the time_normalizer module reports status "ready"
746
+
747
+ 💡 Pattern: Background steps create the test fixture. Every step should
748
+ create a specific, named piece of state that subsequent steps can reference.
749
+ ---
750
+
751
+ ⚑ Gate 3 — Edge Case Coverage (1 issue)
752
+
753
+ Issue: Background section defines no edge cases for system state.
754
+ What happens if the system is NOT ready? If rates are NOT configured?
755
+ Developer impact: Error paths are undefined — a developer must guess what
756
+ error to return for each failure state.
757
+
758
+ → Improve: Add an edge-case scenario:
759
+ Scenario: Timesheet calculation fails when system is not ready
760
+ Given the timesheet system reports status "degraded"
761
+ When an employee attempts to check in at 09:00 AM
762
+ Then the system returns error "SYSTEM_NOT_READY"
763
+ And no hours are recorded
764
+ ```
765
+
766
+ The improvement options MUST be concrete and domain-specific. Prefer specific data values, concrete assertions, and verifiable preconditions over abstract advice. For each issue, present 2–3 options with a "best fit" recommendation.
767
+
768
+ ---
769
+
426
770
  ### 3. Presentation — Show the Snippet
427
771
 
428
772
  For each round, present the snippet with its filename:
429
773
 
430
774
  ```
431
775
  ---
432
- ## Round N — Level X · [passive|interactive] · [concept|solid] | `path/to/file.py` (lines A–B)
776
+ ## Round N — Level X · [passive|interactive] · [concept|solid|spec|ba-gates] | `path/to/file.py` (lines A–B)
433
777
 
434
778
  ```python
435
779
  42 def calculate_position_size(
@@ -459,7 +803,7 @@ Guidelines:
459
803
  - Show the function/class signature with its decorators
460
804
  - Show the filename and line range in the header
461
805
  - The response mode tag (`· passive` or `· interactive`) always appears in the header
462
- - The theme/concept tag (`· solid` for SOLID theme, or `· decorators` etc. for targeted concept) appears when applicable; omit during free-play standard rounds
806
+ - The theme/concept tag (`· solid` for SOLID theme, `· spec` for spec theme, `· ba-gates` for BA-Gates theme, or `· decorators` etc. for targeted concept) appears when applicable; omit during free-play standard rounds
463
807
  - If the snippet depends on one obvious external type or constant, include a
464
808
  brief inline note
465
809
  - **Before presenting, scan for secrets.** Redact API keys, tokens, passwords,
@@ -580,6 +924,19 @@ Here's the original design. Compare it with yours to see what was improved.
580
924
  ```
581
925
  Then restore with `git checkout -- <file>` and proceed automatically.
582
926
 
927
+ #### E. BA-Gates Mode Evaluation
928
+
929
+ When theme is `ba-gates`, evaluate the user's ability to identify and diagnose
930
+ documentation quality issues against the Pass 2 generated expected answer:
931
+
932
+ | Outcome | Criteria | Feedback approach |
933
+ |---------|----------|-------------------|
934
+ | **Complete** | Identified all gate triggers at the current level with specific line/cell references | Highlight what they caught + 1–2 things to sharpen |
935
+ | **Partial** | Identified some triggers, or named gates without specifics | Strike-1 or strike-2 nudge toward the missed gate |
936
+ | **Missed** | Did not identify the primary gate trigger(s) | Strike-2 or strike-3 with full improvement options |
937
+
938
+ See section 2e (BA-Gates Theme) for the full strike system and improvement options format.
939
+
583
940
  #### Weighted Evaluation for Targeted Concepts
584
941
 
585
942
  When a concept is targeted (e.g., `teach me decorators`), bias the
@@ -632,7 +989,7 @@ If the user's answer **meets** expectations (any attempt):
632
989
  - Reveal the file context
633
990
  - Ask "Another round?"
634
991
 
635
- #### Feedback structure (success or strike-3)
992
+ #### Feedback structure (success or strike-3 — standard/spec modes)
636
993
 
637
994
  ```
638
995
  **What you got right:**
@@ -648,12 +1005,23 @@ placing any trade. Sits between the signal generator and the exchange adapter.
648
1005
  Keep feedback constructive. The goal is learning, not grading. If they
649
1006
  nailed everything at-level, say so and highlight the nuance they caught.
650
1007
 
1008
+ ### CONTINUE THE SESSION
1009
+
1010
+ **After every single round — success, skip, next, or strike-3 — you MUST
1011
+ either ask "Another round?" or present the next question automatically.
1012
+ Never deliver feedback and then stop. The session only ends when the user
1013
+ explicitly says `stop`.**
1014
+
1015
+ - Success / `next` / `another` → ask: "Another round? (yes / no / level N / ...)"
1016
+ - Strike-3 / `skip` / `reveal` → auto-advance: present the next round header immediately
1017
+ - `stop` / `end` → deliver the end-of-session summary
1018
+
651
1019
  #### Handling commands mid-round
652
1020
 
653
1021
  | Command | Behavior |
654
1022
  |---------|----------|
655
1023
  | `hint` | Give one strike-1 level nudge (counts as an attempt in the strike system) |
656
- | `skip` / `reveal` | Show full evaluation immediately. Move to next round. |
1024
+ | `skip` / `reveal` | Show full evaluation immediately, then present next round without asking. |
657
1025
  | `next` / `another` | Skip this snippet, draw a new one. No strike counted. |
658
1026
  | `level N` / `lN` (e.g. `level 5`, `l2`) | Adjust difficulty for subsequent rounds. |
659
1027
  | `easier` | Decrease level by 1 (minimum 1). |
@@ -662,13 +1030,14 @@ nailed everything at-level, say so and highlight the nuance they caught.
662
1030
  | `passive` | Switch to passive (explanation) mode for subsequent rounds. |
663
1031
  | `solid` / `SOLID` | Switch to SOLID (anti-pattern reconstruction) theme for subsequent rounds. |
664
1032
  | `spec` | Switch to spec (spec-to-code traceability) theme for subsequent rounds. |
665
- | `done` / `check my work` | (Interactive/SOLID/Spec mode) Signal that work is complete. Triggers verification. |
1033
+ | `ba` / `ba-gates` / `requirements` | Switch to BA-Gates (BA documentation quality) theme for subsequent rounds. |
1034
+ | `done` / `check my work` | (Interactive/SOLID/Spec/BA-Gates mode) Signal that work is complete. Triggers verification. |
666
1035
  | `stop` / `end` | End session. Deliver summary. |
667
1036
 
668
1037
  ### 5. Loop — Keep Going
669
1038
 
670
1039
  After a successful evaluation or a `next` skip, ask:
671
- "Another round? (yes / no / level N / interactive / passive / solid / spec / stop)"
1040
+ "Another round? (yes / no / level N / interactive / passive / solid / spec / ba / stop)"
672
1041
 
673
1042
  After a strike-3 reveal, do **not** ask — proceed directly to the next
674
1043
  round with:
@@ -694,6 +1063,22 @@ What to review: [concepts missed across multiple rounds]
694
1063
  Suggested next level: [3 → 4, or stay, or 3 → 2]
695
1064
  ```
696
1065
 
1066
+ For BA-Gates sessions, the summary covers documents and gates instead of code files:
1067
+ ```
1068
+ ## Session Summary
1069
+
1070
+ Rounds completed: 4
1071
+ Theme: ba-gates · Mode: passive · Level: 3
1072
+ Documents covered:
1073
+ - timesheet.feature.txt (rounds 1, 3)
1074
+ - qa_cinemas_ac_scenarios.md (round 2)
1075
+ - QA Cinemas Requirements.pptx (round 4)
1076
+
1077
+ Gates mastered: Ambiguity detection (rounds 1, 4) ✓
1078
+ Gates to strengthen: Edge case coverage (rounds 2, 3)
1079
+ Suggested next level: 3 → 4
1080
+ ```
1081
+
697
1082
  ## Multilingual Projects
698
1083
 
699
1084
  If the project contains multiple languages, let the user's `teach me <lang>`
@@ -742,6 +1127,10 @@ criteria for the Mechanics axis:
742
1127
  - **Spec theme snapshot.** In interactive+spec mode, run `//snapshot on`
743
1128
  before file edits if the workspace is not a git repo. Run `//snapshot off`
744
1129
  after restoration.
1130
+ - **BA-Gates theme file safety.** In interactive+ba-gates mode for plaintext files (`.md`, `.feature`, `.txt`), the model MUST NOT edit the file — the user makes the changes. For office files (`.docx`, `.pptx`, `.xlsx`), present extracted text; the user describes fixes since they cannot edit binaries directly. Run `//snapshot on` before user edits in non-git workspaces; `//snapshot off` after.
1131
+ - **BA-Gates two-pass integrity.** Pass 1 regex results are filters only — do not present them as answers. Pass 2 LLM interpretation MUST run fresh per fragment at round time. If Pass 2 determines all regex flags are false positives, discard the fragment and select another. Do not fabricate issues.
1132
+ - **BA-Gates extraction fallback.** If `codewhale-doc-extract` fails for any office file, note it and skip that file — do not attempt alternative extraction methods. Report skipped files in discovery.
1133
+ - **BA-Gates thinking discipline.** Pass 2 analysis runs with Deep/High thinking. Once presentation begins, switch to Skip thinking — never include generated answers or gate locations in reasoning_content after the fragment is shown.
745
1134
 
746
1135
  ## Verification
747
1136
 
@@ -768,3 +1157,15 @@ After each round, confirm:
768
1157
  - (Spec theme) The trace link was verified in both directions by the model
769
1158
  - (Spec theme) Interactive mode ran `//snapshot on/off` for non-git workspaces
770
1159
  - (Spec theme) Modified files were restored after the round
1160
+ - (BA-Gates theme) BA documents were scanned across all formats (.docx, .pptx, .xlsx, .md, .feature, .txt)
1161
+ - (BA-Gates theme) `codewhale-doc-extract` was used for office files; failures noted and skipped
1162
+ - (BA-Gates theme) Pass 1 regex triage ran against every fragment; fragments with zero triggers excluded
1163
+ - (BA-Gates theme) Pass 2 LLM interpretation ran per fragment at round time with Deep/High thinking
1164
+ - (BA-Gates theme) Pass 2 verified quiz-worthiness before presentation; false positives discarded
1165
+ - (BA-Gates theme) The gate-count hint was stated but specific gates were NOT revealed before evaluation
1166
+ - (BA-Gates theme) On skip or strike-3, concrete domain-specific improvement options (2–3 per issue with best-fit recommendation and developer-impact summary) were presented
1167
+ - (BA-Gates theme) Interactive mode for plaintext files did NOT edit the file — user made changes
1168
+ - (BA-Gates theme) Interactive mode for office files presented extracted text inline — user described fixes
1169
+ - (BA-Gates theme) `//snapshot on/off` was used in interactive mode for non-git workspaces
1170
+ - (BA-Gates theme) Extraction fallback was handled gracefully — skipped files were reported
1171
+ - (BA-Gates theme) Thinking suppression was maintained — Pass 2 material was not leaked into reasoning after presentation