> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sifi.life/llms.txt
> Use this file to discover all available pages before exploring further.

# Gold Layer 집계

## Part C: Gold Layer — 비즈니스 집계

Gold는 **대시보드·Genie·에이전트·ML이 직접 소비**하는 테이블입니다.

> **★ Gold 컬럼 표준 (단일 원본)**
>
> * 아래 컬럼명은 **확정 스펙**입니다.
> * 이후 모듈 4(대시보드)·5(Genie)·7(에이전트)는 **여기 정의된 이름만** 사용합니다.
> * Genie Code에게 프롬프트할 때도 이 이름을 그대로 쓰세요(이름이 어긋나면 대시보드 위젯·Genie SQL이 깨집니다).

| Gold 테이블 | 그레인 | 확정 컬럼 (이름 : 의미) |
| - | - | - |
| `daily_yield_summary` | 라인×모델×근무조×일 | `line_id`, `model_code`, `shift`, `event_date`, `input_qty`(투입), `good_qty`(양품), `defect_qty`(불량), `yield_pct`(=good\_qty/input\_qty\*100), `avg_mtf_center`, `top_defect_category` |
| `first_pass_yield` | 스테이션×일 | `station`, `event_date`, `input_count`, `first_pass_count`, `rework_count`, `fpy_pct`(=first\_pass\_count/input\_count\*100) |
| `defect_pareto` | 불량코드×라인×일 | `defect_code`, `defect_category`, `line_id`, `event_date`, `defect_count`, `scrap_count`, `rework_count`, `critical_count`, `pct_of_total`, `cum_pct`, `top_root_cause` |
| `oee_by_equipment` | 설비×일 | `equipment_id`, `equipment_type`, `line_id`, `event_date`, `availability_pct`, `performance_pct`, `quality_pct`, `oee_pct`, `downtime_min`, `breakdown_min` |
| `spc_process_capability` | 공정×파라미터×모델×일 | `process`, `parameter`, `model_code`, `event_date`, `sample_count`, `mean_value`, `stddev_value`, `usl`, `lsl`, `cpk`, `capability_grade` |
| `aa_quality_trend` | 모델×일 | `model_code`, `event_date`, `mtf_center_avg`, `mtf_center_p5`, `mtf_center_p95`, `mtf_corner_avg`, `tilt_abs_max_avg`, `below_spec_pct`(규격미달 시리얼 비율), `aa_fail_pct`, `sample_count` |
| `equipment_health_score` | 설비×일 | `equipment_id`, `equipment_type`, `line_id`, `event_date`, `health_score`, `health_grade`, `avg_temp`, `max_vibration`, `spike_count`, `breakdown_count`, `risk_factors` |
| `material_defect_correlation` | 자재로트×일 | `material_lot_id`, `supplier`, `material_type`, `event_date`, `used_qty`, `defect_qty`, `defect_rate_pct` |
| `station_cycle_time` | 스테이션×일 | `station`, `event_date`, `avg_cycle_time_sec`, `median_cycle_time_sec`, `p95_cycle_time_sec`, `throughput_count` |
| `product_traceability_360` | 시리얼 | `serial_id`, `model_code`, `line_id`, `wo_id`, `final_result`, `aa_mtf_center`, `final_mtf_sfr_center`, `defect_count`, `material_lot_ids` |

> 💡 `line_id`·`shift`는 원천에서 `work_orders`에만 있으므로, 시리얼→`wo_id`→`work_orders` 경로로 가져옵니다(아래 Gold 1 참조). `event_date`는 각 이벤트 timestamp의 DATE입니다.

### Gold 핵심 6개 프롬프트

#### Gold 1: daily\_yield\_summary

**1단계 —** 뼈대 + 그레인 확정.

```
silver.final_test_clean, silver.serials_cleaned를 결합하여 ccm_factory.gold.daily_yield_summary를 만들려고 해. 그레인은 line_id × model_code × shift × event_date야. 먼저 집계 설계를 제안해줘.
```

**2단계 —** line\_id·shift 조인 경로 지정 (원천에 없으므로).

```
line_id와 shift는 @ccm_factory.silver.final_test_clean(시리얼 최종결과) → @ccm_factory.silver.serials_cleaned(serial_id→wo_id, model_code) → @ccm_factory.bronze.work_orders(wo_id→line_id, shift) 경로로 가져와줘. event_date는 최종검사 timestamp의 DATE로.
```

**3단계 —** 수율 핵심 컬럼 (컬럼 표준 준수).

```
컬럼 추가: line_id, model_code, shift, event_date, input_qty(투입 시리얼 수), good_qty(FINAL 통과 PASS 수), defect_qty(input_qty - good_qty), yield_pct(good_qty / input_qty * 100).
```

**4단계 —** 품질 지표 + 파티션·COMMENT.

```
컬럼 더 추가: avg_mtf_center(최종검사 평균 MTF), top_defect_category(최다 불량 카테고리). event_date 파티셔닝과 테이블/컬럼 COMMENT를 추가해줘.
```

#### Gold 2: first\_pass\_yield (FPY 직행률)

**1단계 —** 뼈대 + 그레인·정의 확정.

```
silver.production_flow, silver.aoi_defects, silver.final_test_clean을 결합하여 ccm_factory.gold.first_pass_yield를 만들려고 해. 그레인은 station × event_date, FPY = (재작업/재검 없이 한 번에 통과한 수) / (해당 스테이션 투입 수) * 100 이야. 먼저 설계를 제안해줘.
```

**2단계 —** 카운트 컬럼.

```
컬럼 추가: station, event_date, input_count, first_pass_count, rework_count, fpy_pct(first_pass_count / input_count * 100).
```

**3단계 —** 라인 전체 직행률 추가.

```
rolled_throughput_yield 컬럼도 추가해줘: 전 스테이션 FPY의 곱(라인 전체 직행률, 별도 컬럼 또는 요약행).
```

**4단계 —** 파티션·COMMENT.

```
event_date 파티셔닝과 COMMENT를 추가해줘.
```

#### Gold 3: defect\_pareto

**1단계 —** 뼈대 + 그레인 확정.

```
silver.defect_normalized를 집계하여 ccm_factory.gold.defect_pareto를 만들려고 해. 그레인은 defect_code × line_id × event_date야. 먼저 설계를 제안해줘.
```

**2단계 —** 카운트 컬럼.

```
컬럼 추가: defect_code, defect_category, line_id, event_date, defect_count, scrap_count, rework_count, critical_count. (disposition별 분해가 필요하면 scrap_count/rework_count로 제공)
```

**3단계 —** 파레토 비율 추가.

```
파레토 80/20 분석용 컬럼 추가: pct_of_total(해당 라인/일 전체 불량 대비 비율), cum_pct(불량 많은 순 누적 비율, Window), top_root_cause(최다 root_cause_code).
```

**4단계 —** 파티션·COMMENT.

```
event_date 파티셔닝과 COMMENT를 추가해줘.
```

#### Gold 4: oee\_by\_equipment (설비 종합효율)

**1단계 —** 뼈대 + 그레인·OEE 정의 확정.

```
silver.downtime_clean, silver.production_flow, silver.final_test_clean, bronze.equipment_master를 결합하여 ccm_factory.gold.oee_by_equipment를 만들려고 해. 그레인은 equipment_id × event_date, OEE = 가용성(Availability) × 성능(Performance) × 품질(Quality)이야. 먼저 설계를 제안해줘.
```

**2단계 —** 세 지표 계산식.

```
세 지표를 이렇게 계산해줘:
- availability = (계획가동시간 - 비가동시간) / 계획가동시간 · 비가동시간 = downtime_clean의 BREAKDOWN+CHANGEOVER+IDLE 합 (PM 제외 또는 옵션)
- performance = (실제 처리수 × 이상택트) / 실제가동시간 또는 실제UPH / rated_capacity_uph
- quality = 양품수 / 총생산수
```

**3단계 —** 컬럼 구성.

```
컬럼 추가: equipment_id, equipment_type, line_id, event_date, planned_time_min, downtime_min, run_time_min, availability_pct, performance_pct, quality_pct, oee_pct(세 값의 곱), breakdown_min, changeover_min, pm_min(유형별 비가동).
```

**4단계 —** 파티션·Z-ORDER·COMMENT.

```
event_date 파티셔닝, (equipment_id) Z-ORDER, COMMENT를 추가해줘.
```

#### Gold 5: spc\_process\_capability (Cpk 공정능력)

**1단계 —** 뼈대 + 그레인 확정.

```
silver.aa_measurements(및 dispensing_clean)를 집계하여 ccm_factory.gold.spc_process_capability를 만들려고 해. 그레인은 process × parameter × model_code × event_date이고 process/parameter 예는 ALIGN/mtf_center_pct, ALIGN/tilt_abs_max, DISPENSE/volume_mg야. 먼저 설계를 제안해줘.
```

**2단계 —** 기초 통계 + 규격.

```
각 파라미터에 대해 n, mean, stddev와 usl, lsl(규격 상/하한, 파라미터별 정의; 예 mtf_center_pct의 LSL = spec_mtf_min, tilt은 USL=5)를 계산해줘.
```

**3단계 —** Cp/Cpk/등급 추가.

```
공정능력지수 추가: cp = (USL - LSL) / (6*stddev), cpk = MIN((USL-mean)/(3*stddev), (mean-LSL)/(3*stddev)), capability_grade(cpk>=1.33 '우수', 1.0~1.33 '보통', <1.0 '개선필요').
```

**4단계 —** 단측 Cpk 처리 + 파티션·COMMENT.

```
한쪽 규격만 있는 경우 단측 Cpk로 계산하고, event_date 파티셔닝과 COMMENT를 추가해줘.
```

#### Gold 6: equipment\_health\_score (예측정비 점수)

**1단계 —** 뼈대 + 그레인 확정.

```
silver.sensor_metrics_5min, silver.downtime_clean, silver.defect_normalized를 결합하여 ccm_factory.gold.equipment_health_score를 만들려고 해. 그레인은 equipment_id × event_date야. 먼저 설계를 제안해줘.
```

**2단계 —** 센서·불량 지표 컬럼.

```
컬럼 추가: equipment_id, equipment_type, line_id, event_date, avg_temp, max_temp, avg_vibration, max_vibration, spike_count, breakdown_count, breakdown_min, defect_attributed_count(해당 설비 스테이션에서 발생한 불량 수).
```

**3단계 —** 건강 점수 산식 추가.

```
health_score(0~100) 추가 — 100에서 감점: max_temp>80 -10, max_vibration>5 -15, spike_count>0 -10, breakdown -20/건, vib 상승추세 -10. health_grade: A(90~100) B(70~89) C(50~69) D(30~49) F(0~29).
```

**4단계 —** 위험요인 배열 + 조인.

```
risk_factors 위험요인 배열(예: ["high_vibration","thermal_spike","frequent_breakdown"])을 추가하고, @ccm_factory.bronze.equipment_master 조인으로 vendor, install_date를 추가해줘.
```

**5단계 —** 파티션·Z-ORDER·COMMENT.

```
event_date 파티셔닝, equipment_id Z-ORDER, COMMENT를 추가해줘.
```

### 나머지 Gold (4개) — 동일 패턴

**1단계 —** 공통 방식 확인.

```
동일 방식으로 나머지 Gold 4개도 만들려고 해 (각 그레인 준수, COMMENT). 2개씩 나눠 요청할게.
```

**2단계 —** 1\~2번 배치 (컬럼 표준 준수).

```
먼저 1~2번, 위 "Gold 컬럼 표준"의 이름을 그대로 써줘:
1. gold.aa_quality_trend (그레인 모델×일): model_code, event_date, mtf_center_avg, mtf_center_p5, mtf_center_p95, mtf_corner_avg, tilt_abs_max_avg, below_spec_pct(silver.aa_measurements에서 mtf_center_pct < spec_mtf_min 인 시리얼 비율), aa_fail_pct, sample_count
2. gold.material_defect_correlation (그레인 자재로트×일): material_lot_id, supplier, material_type, event_date, used_qty(해당 로트 사용 시리얼 수), defect_qty(그중 불량 수), defect_rate_pct — traceability로 로트별 사용 시리얼의 불량을 집계 (Sup_S7/S8 부각). 조인 키는 material_lot_id.
```

**3단계 —** 3\~4번 배치 이어서 (컬럼 표준 준수).

```
이어서 3~4번:
3. gold.station_cycle_time (그레인 스테이션×일): station, event_date, avg_cycle_time_sec, median_cycle_time_sec, p95_cycle_time_sec, throughput_count — silver.production_flow 기반.
4. gold.product_traceability_360 (그레인 시리얼): serial_id, model_code, line_id, wo_id, final_result, aa_mtf_center, final_mtf_sfr_center, defect_count, material_lot_ids — 시리얼별 이력을 한 행으로 (에이전트/ML 소비용).
```

> 💡 `product_traceability_360`은 시리얼 단위 360° 이력 테이블로, 이 워크샵의 대시보드·Genie에서 직접 사용하지는 않지만 **모듈 5 Genie Space나 모듈 7 에이전트에 "시리얼 이력 조회" 소스로 추가**하면 좋은 확장 자산입니다 (예: "이 시리얼의 공정·검사·불량 이력을 한눈에 보여줘").

### Gold 확인

```
ccm_factory.gold의 모든 테이블 목록과 row count, 각 테이블 그레인을 표로 보여줘.
daily_yield_summary의 라인별 평균 수율과, defect_pareto 상위 5개 불량코드도 함께 보여줘.
```

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.