---
name: project-step1087-require-source-diversity
description: STEP 1087 (2026-05-12) requireSourceDiversity option 実装. invention-engine 5th iteration hardening. transplantStructure 3rd 引数 voidIndex で sourceOffset 加算 → batch 内 source axiom が必ず異なる. 5/11 mass-generation 4 例目 systemic 確定 → direct 防止.
metadata: 
  node_type: memory
  type: project
  originSessionId: e5ec4e43-958a-4a47-a6f0-4513f218941f
---

# STEP 1087 — `requireSourceDiversity` Option (Invention Pipeline 5th Iteration Hardening)

**実装日**: 2026-05-12
**Trigger**: 5/11 invention 5 件中 5/5 件 source 全て同一 ∞=無限分岐評価経路 → mass-generation 4 例目 systemic 確定
**Status**: ✅ test/step1087 **10/10 PASS** + regression 0 breaking (39/39 累積)

## Root cause (5/11 incident)

`transplantStructure(voidItem, dateSeed)` で:
- `seed` が batch 内固定 (dateSeed = hashDate(today))
- 5 voids 全て categoryA='logic' 共通
- `theoriesA = kernel.filter(t => t.category === 'logic')` が全 voids で同 list
- `sourceTheory = theoriesA[seed % len]` が batch 内常に同 sourceTheory を返した
- 結果: 5/5 件 source = ∞=無限分岐評価経路 (logic categoryA の 1 つの SeedTheory)

## 修正実装

### 1. Option 追加

```typescript
export interface InventionEngineOptions {
  // ... existing ...
  requireSourceDiversity?: boolean; // STEP 1087: default ON.
                                     // voidIndex を source offset に加算
                                     // 明示 OFF: { requireSourceDiversity: false }
}
```

### 2. transplantStructure シグネチャ拡張

```typescript
transplantStructure(voidItem: TheoryVoid, dateSeed?: number, voidIndex: number = 0): Hypothesis {
  const seed = dateSeed ?? this.computeDateSeed();
  const sourceOffset = (this.opts.requireSourceDiversity !== false) ? voidIndex : 0;
  let sourceTheory = theoriesA[(seed + sourceOffset) % theoriesA.length];
  let targetTheory = theoriesB[(seed + sourceOffset + 1) % theoriesB.length];
  // ... existing requireDifferentTarget + requireDifferentTargetAxiom logic ...
}
```

### 3. invent() で voidIndex を pass

```typescript
const hypotheses = voids.slice(0, maxInventions)
  .map((v, i) => this.transplantStructure(v, dateSeed, i));
```

### 4. E3 Genealogy bias と共存

```typescript
// candidate window も sourceOffset で rotate
for (let off = 0; off < 3; off++) {
  const src = theoriesA[(seed + sourceOffset + off) % theoriesA.length];
  const tgt = theoriesB[(seed + sourceOffset + off + 1) % theoriesB.length];
  ...
}
```

## Test 結果

| # | Test | 内容 | 結果 |
|---|---|---|---|
| 1 | default | 5 voids 全て同 categoryA でも 5 異 sourceTheory | ✅ |
| 2 | 明示 OFF | requireSourceDiversity: false で legacy 動作 (5 voids 全て同 source) | ✅ |
| 3 | **5/11 直接再現** | logic × {5 文明} で 5 異 source axiom | ✅ |
| 4 | backward compat | voidIndex 未指定 (default 0) == voidIndex=0 明示 | ✅ |
| 5 | STEP 1019 共存 | requireDifferentTarget と coexist | ✅ |
| 6 | STEP 1040 共存 | requireDifferentTargetAxiom と coexist | ✅ |
| 7 | STEP 1047 default 共存 | 全 dedup option default ON で連携 | ✅ |
| 8 | invent() e2e | engine.invent(5) で 5 異 source 自動 | ✅ |

★ **test/step1087: 10/10 PASS** (assertion 数, 7 test scenario 内に 10 assert).

## Regression

- step1019: 9/9 PASS (genealogy collision rotation)
- step1040: 11/11 PASS (target literal substring dedup)
- step1047: 9/9 PASS (default ON 化)
- step1087: 10/10 PASS (source diversity)
- **累積 39/39 PASS** / 0 breaking change

## 5th iteration hardening 完成

| iteration | STEP | 目的 |
|---|---|---|
| 1st | 1019 | recentCooldownDays 60 + requireDifferentTarget |
| 2nd | 1040 | requireDifferentTargetAxiom (literal substring) |
| 3rd | 1047 | 全 dedup option default ON 化 |
| **4th** | **1087** | **requireSourceDiversity (voidIndex source offset)** |

★ 4 段重ねの dedup hardening series が同 file (invention-engine.ts) で生存 + 全 default ON.

## 6th iteration 候補 (retained)

- (b) `SeedTheory.cooldownDays` field — 新追加 SEED は 30 日 invention target excluded
- (c) `requireSympatheticDegreeFilter` option — 構造同型度 0.5 以上 require (LLM-free heuristic)

両者とも 5/10 memory `project_invention_2026-05-10_approval_record.md` で「4th iteration hardening 候補」 として記録済. STEP 1087 で (a) を採用 → (b)(c) は 6th iteration retain.

## 関連 file

- `src/aios/invention/invention-engine.ts` (修正 ~30 行 + option doc)
- `test/step1087-require-source-diversity-test.ts` (10 assertion / 8 scenario)
- `package.json` (test:step1087 script)

関連 memory: [[project-invention-2026-05-11-approval-record]] / [[feedback-invention-duplicate-prevention]]
