{
  "schema_version": 1,
  "run_id": "1ad3819c80e7",
  "started_at": "2026-05-06T18:08:14Z",
  "finished_at": "2026-05-06T18:08:15Z",
  "git_commit_at_start": "2881026b1f575b1ee6556bd67876270bd5f77236",
  "tasks_json_commit_before_curation": "03d811e7978c932e2e11996b2acc8b7f9a158bb7",
  "no_tasks_added_before_curation": true,
  "tasks_json_entry_count_at_curation": 20,
  "selection_algorithm": {
    "version": 1,
    "description": "Deterministic objective ranker over the existing dogfood brain. No task content was visible to the operator at selection time — tasks.json was at its pre-Phase-3 state with 20 entries unchanged. Selection criteria are product-level (severity, recurrence, frequency, file co-occurrence with other lessons), NOT predictive of any specific upcoming task.",
    "formula": "score(l) = severity_weight[l.severity] + 0.6 * times_seen + 2.5 * (1 if 'recurring' in lesson.tags else 0) + 0.8 * sum(file_freq[f] - 1            for f in lesson.files_affected            if file_freq[f] > 1)",
    "constants": {
      "severity_weight": {
        "1": 3.0,
        "2": 1.5,
        "3": 0.5
      },
      "recurring_bonus": 2.5,
      "times_seen_weight": 0.6,
      "bug_magnet_multiplier": 0.8
    },
    "source": "benchmarks/_apply_curation_2026_05_07.py (this file)"
  },
  "sidecar_runtime": {
    "data_dir": "data/brain_v2",
    "brain_db_path": "data/brain_v2/brain.db",
    "activity_log_path": "data/brain_v2/mcp_activity.jsonl",
    "lesson_mirror_enabled": true,
    "is_benchmark_sandbox": false,
    "env_overrides_set": []
  },
  "operator_approval": {
    "method": "row-by-row chat approval",
    "approved_rows": 5,
    "approval_message_excerpt": "approve as-is ทั้ง 5 rows ครับ"
  },
  "library_size_before": 12,
  "library_size_after": 12,
  "lessons": [
    {
      "lesson_id": "4cd762e0-a76d-42c8-904e-60f71eead859",
      "title": "Vite optimizeDeps barrel pattern → ErrorBoundary on default-import",
      "patch_attempted": {
        "pinned": true,
        "scope_globs": [
          "vite.config.ts",
          "package.json"
        ]
      },
      "rationale": "Selected by objective score (highest in pool, 7.70). Has explicit `recurring` tag — lesson body documents 4 prior occurrences (tiptap → r3f → lucide → react-force-graph-2d). vite.config.ts appears in 3 separate lessons, the highest bug-magnet count in the project. Pin earns +0.6 ranker bias on every recall; scope_globs earns +1.5 when the AI's current_path matches package.json or vite.config.ts.",
      "leakage_note": null,
      "result": "applied",
      "before": {
        "pinned": false,
        "disabled": false,
        "severity": 1,
        "scope_globs": [],
        "times_seen": 1
      },
      "after": {
        "pinned": true,
        "disabled": false,
        "severity": 1,
        "scope_globs": [
          "vite.config.ts",
          "package.json"
        ],
        "times_seen": 1
      },
      "diff": {
        "pinned": {
          "before": false,
          "after": true
        },
        "scope_globs": {
          "before": [],
          "after": [
            "vite.config.ts",
            "package.json"
          ]
        }
      }
    },
    {
      "lesson_id": "01933dc9-fdef-4b5d-a12f-1d78f13f7db0",
      "title": "Graph focus-node click → FPS dive / app freeze (R3F + Zustand)",
      "patch_attempted": {
        "pinned": true,
        "scope_globs": [
          "src/components/GraphView/**"
        ]
      },
      "rationale": "Severity 1 user-blocking. NeuralMap.tsx is bug-magnet (2 lessons). Root cause has 3 simultaneous sources (Zustand global selectors + per-frame Float32Array allocs + duplicate OrbitControls). Generic R3F docs cover none of these together; AI without this lesson would debug each cause sequentially = re-derive from scratch.",
      "leakage_note": null,
      "result": "applied",
      "before": {
        "pinned": false,
        "disabled": false,
        "severity": 1,
        "scope_globs": [],
        "times_seen": 1
      },
      "after": {
        "pinned": true,
        "disabled": false,
        "severity": 1,
        "scope_globs": [
          "src/components/GraphView/**"
        ],
        "times_seen": 1
      },
      "diff": {
        "pinned": {
          "before": false,
          "after": true
        },
        "scope_globs": {
          "before": [],
          "after": [
            "src/components/GraphView/**"
          ]
        }
      }
    },
    {
      "lesson_id": "77b13dd3-0592-48f0-b991-7b618fac1863",
      "title": "MCP code_search FTS5 plain-string coverage gap",
      "patch_attempted": {
        "pinned": true,
        "scope_globs": [
          "core/code_indexer/**",
          "core/api/mcp_server.py"
        ]
      },
      "rationale": "Multi-symptom lesson covering 3 distinct gaps (file-level coverage, function-body recursion, Thai tokenization). Two of four affected files are bug-magnets (mcp_server.py × 2, project_summarizer.py × 2). Schema/coverage class — hardest for AI to re-derive without the indexer source. Recent (2026-05-02), still relevant to the current FTS5 schema.",
      "leakage_note": null,
      "result": "applied",
      "before": {
        "pinned": false,
        "disabled": false,
        "severity": 2,
        "scope_globs": [],
        "times_seen": 1
      },
      "after": {
        "pinned": true,
        "disabled": false,
        "severity": 2,
        "scope_globs": [
          "core/code_indexer/**",
          "core/api/mcp_server.py"
        ],
        "times_seen": 1
      },
      "diff": {
        "pinned": {
          "before": false,
          "after": true
        },
        "scope_globs": {
          "before": [],
          "after": [
            "core/code_indexer/**",
            "core/api/mcp_server.py"
          ]
        }
      }
    },
    {
      "lesson_id": "78c5b62a-e3c7-4113-81fb-7ab899b9f281",
      "title": "MCP stdio call hangs (idle, no error) on long-running server",
      "patch_attempted": {
        "pinned": false,
        "scope_globs": [
          "core/api/mcp_server.py"
        ]
      },
      "rationale": "Severity 2, mcp_server.py bug-magnet. Symptom-vs-cause mismatch (process LOOKS idle but is broken pipe / stale stdin) — class of bug AI commonly misdiagnoses. Caught only because operator dogfooded for 12h+ uptime. Active + scope_glob (no pin) so file overlap with mcp_server.py earns the +0.4–0.8 file bonus without biasing every recall.",
      "leakage_note": "MEDIUM risk during task extension: avoid wording near 'MCP stdio hang' verbatim. Will be flagged in §11 after tasks are drafted.",
      "result": "applied",
      "before": {
        "pinned": false,
        "disabled": false,
        "severity": 2,
        "scope_globs": [],
        "times_seen": 1
      },
      "after": {
        "pinned": false,
        "disabled": false,
        "severity": 2,
        "scope_globs": [
          "core/api/mcp_server.py"
        ],
        "times_seen": 1
      },
      "diff": {
        "scope_globs": {
          "before": [],
          "after": [
            "core/api/mcp_server.py"
          ]
        }
      }
    },
    {
      "lesson_id": "ca204c2e-bbd2-415b-ab36-8d541dc24444",
      "title": "project_summarizer race + watcher self-trigger creates dup summaries",
      "patch_attempted": {
        "pinned": false,
        "scope_globs": [
          "core/code_indexer/project_summarizer.py",
          "core/code_indexer/watcher.py"
        ]
      },
      "rationale": "Severity 2, project_summarizer.py bug-magnet. Cross-cutting race condition across 3 files. Subtle enough that fixing on disk did not stop the bug — exactly the class of lesson where re-derive cost is high. Active + scope_glob (no pin) to avoid biasing every code_indexer query toward this one subtle race.",
      "leakage_note": null,
      "result": "applied",
      "before": {
        "pinned": false,
        "disabled": false,
        "severity": 2,
        "scope_globs": [],
        "times_seen": 1
      },
      "after": {
        "pinned": false,
        "disabled": false,
        "severity": 2,
        "scope_globs": [
          "core/code_indexer/project_summarizer.py",
          "core/code_indexer/watcher.py"
        ],
        "times_seen": 1
      },
      "diff": {
        "scope_globs": {
          "before": [],
          "after": [
            "core/code_indexer/project_summarizer.py",
            "core/code_indexer/watcher.py"
          ]
        }
      }
    }
  ],
  "policy_notes": [
    "All 5 candidates pre-existed in the dogfood brain. No new lessons were added during curation.",
    "Sibling lessons (e9d5fe1b, 28fd4c7c, 25ef5d4a) intentionally left untouched per operator policy on benchmark stadium-tuning.",
    "Curation precedes any tasks.json extension. No Phase 3 task was visible at selection time.",
    "REST PATCH path triggers .cosmos/lessons.{md,json} mirror rebuild for each affected project (production sidecar has lesson_mirror_enabled=true). Mirror state will be visible in the next git commit."
  ]
}
