<!-- canonical: https://docs.axelabs.ai/ops/runbook/dead-deal-teardown -->
<!-- source: content/ops/runbook/dead-deal-teardown.mdx -->

---
title: 죽은 딜 teardown
description: 죽은 딜(passed/lost/dead)의 OneDrive/Blueprint raw 파일을 index 가 흡수→검증→삭제하는 canonical 4-step 절차. Workspace 는 ARCHIVE 기본, co-deal 공유폴더 가드, dual-mount dataroom 탐색.
playbook: true
---

# 죽은 딜 teardown — canonical 4-step

> SoT 결정 = [D-index-50](/ops/decisions)(Archive 저장) · [D-index-51](/ops/decisions)(orchestrator·역연산·감사) · [D-index-56](/ops/decisions)(**canonical 확정** — ARCHIVE-default + co-deal 가드 + 4-step).
> in-repo 미러 = `~/index/CLAUDE.md` §③ · 서비스 미러 = [/services/index](/services/index) §Archive.

## AI 요청 프롬프트

```
https://docs.axelabs.ai/ops/runbook/dead-deal-teardown 따라 <deal> 죽은 딜 teardown 해줘.
삭제 전 sha256 게이트·co-deal 공유폴더 가드 반드시 확인하고, workspace 는 ARCHIVE(기본).
```

## 핵심 원칙

- **흡수 전엔 절대 삭제 없음.** `evidence_blob` 이 삭제 후 raw 파일의 **유일 사본**([D-index-51](/ops/decisions)) — 단 한 파일이라도 byte-for-byte 미저장이면 삭제 abort, 데이터 손실 0.
- **Workspace 는 ARCHIVE 기본, 삭제 아님**([D-index-56](/ops/decisions)). Blueprint 의사결정 trail(Issue/Session/Artifact)은 raw dataroom 과 별개의 영구 자산. 물리 삭제는 `--purge-workspace` 명시 opt-in.
- **공유폴더는 건드리지 않는다.** 비교/공유 폴더는 여러 딜이 참조 — deal *전용* 폴더만 삭제.

## 0. Pre-flight (삭제 전 점검)

### (a) dual-mount dataroom 전수 (Starnex 교훈)

딜 데이터룸이 두 마운트에 분산될 수 있다 — 빈 stub 만 보고 "흡수할 것 없음"으로 종료하면 진짜 데이터룸을 통째로 놓친다.

```bash
BASE="$HOME/Library/CloudStorage/OneDrive-AXE/AXE - Ventures"
# 양 마운트 + Prj_ prefix + 한/영 명 NFD-safe 전수
find "$BASE/1. Project" "$BASE/1_Project" -iname "*<deal>*" -o -iname "*Prj_<deal>*" 2>/dev/null
```

`1. Project/<deal>` 또는 `Prj_<deal>` = 보통 얇은 stub, `1_Project/Pipeline/<deal>` = 풀 데이터룸인 경우가 있다. **둘 다 흡수 대상**.

### (b) half-done(half-torn) 감지

이미 부분 teardown 된 좀비 딜 점검 — `deal.stage` 가 죽음(passed/lost)인데 evidence 0 또는 workspace 가 아직 PROJECT 면 half-torn:

```sql
-- index-postgres
SELECT d.deal_code, d.stage, count(e.*) AS ev
FROM deal d LEFT JOIN deal_evidence e ON e.deal_id = d.id
WHERE d.stage IN ('Passed','Lost')
GROUP BY d.deal_code, d.stage
HAVING count(e.*) = 0;
-- blueprint-postgres: paraLayer='PROJECT' 인데 deal 이 죽은 workspace
```

## 1~4. teardown 4-step (순서 엄수)

| # | step | 명령 / 게이트 |
|---|---|---|
| 1 | **흡수** | `index ingest-evidence --deal <c> --kind <k> --source-prefix <subdir> <files…>` — per-subdir source-prefix 별, content-addressed sha256 dedup |
| 2 | **검증** | `list_deal_evidence <c>` count == source 파일 수 + `index export-evidence --deal <c> --out /tmp/x` 의 마지막 JSON 줄 `mismatches==[]`. **불일치 = 1 로 복귀, 삭제 금지** |
| 3 | **OneDrive 전용폴더 rm** | capture-first(`teardown_event` audit row 먼저) → 그 딜 *전용* 폴더만 rmtree → **삭제 후 full-tree sweep** (`find <tree> -ipath '*<deal>*' -type f \| grep -v DS_Store \| wc -l` == 0; 라이브싱크 잔존/재수화 대비, 영/한 명 양쪽) |
| 4 | **Workspace ARCHIVE** | `axe workspace close <workspace_id>` (soft — `paraLayer` PROJECT→ARCHIVE + `connectionStatus`→disconnected). **물리 삭제 아님** — `--purge-workspace`(orchestrator) 시에만 행 삭제. 이 step 누락 시 PROJECT 좀비가 ic/ingest dispatch 를 계속 게이트 |

orchestrator 한 명령(코드 정합 후): `axe index teardown <deal>` 이 1~4 + audit 를 감싼다. `--dry-run`(plan) / `--no-delete`(흡수+검증만) / `--force-shared` / `--purge-workspace`.

## ⛔ co-deal 공유폴더 가드

비교/공유 폴더는 **여러 딜이 참조**한다. 죽은 딜 하나를 teardown 한다고 그 폴더를 rm 하면 살아있는(또는 아직 안 떼낸) 다른 딜의 source 가 orphan 된다.

- 실증: `_comparative_20260528_preIPO/` = **Hancom · Novachips · Starnex** 3딜 공유(전부 `Passed`). 가드는 **stage 무관** — "공유"는 폴더 문제이지 deal 상태 문제가 아니다.
- 규칙: rmtree 직전, resolved folder 가 **>1 deal 의 `deal_evidence.source_path`** 에 걸리거나 비교/공유 경로(`_comparative*`, `*공유*`)면 → **ABORT → archive-only**. 그 딜 *전용* 하위폴더만 삭제. override = `--force-shared` + co-deal 명시.

```sql
-- 이 폴더를 참조하는 다른 deal 이 있는가? (있으면 rm 금지)
SELECT DISTINCT d.deal_code FROM deal_evidence de JOIN deal d ON d.id=de.deal_id
WHERE de.source_path LIKE '<folder-rel>%' AND d.deal_code <> '<deal>';
```

## 역연산 (restore)

teardown 은 되돌릴 수 있다 — `evidence_blob` 에서 디스크로 복원 + sha256 round-trip 검증:

```bash
axe index restore <deal> <output_dir>     # = index export-evidence, 마지막 JSON 줄 mismatches==[]
axe index list-archive                     # teardown_event recovery map 조회
```

`teardown_event` 행(`deal · file_count · total_bytes · onedrive_path · blueprint_workspace_id · sha_manifest`)이 "무엇을 언제 떼어냈고 무엇으로 되돌리나"의 단일 기록.

## ⚠️ 코드 lag (2026-06-15 현재)

[D-index-56](/ops/decisions) canonical 과 orchestrator 코드가 아직 발산 — 정합 전까지 **운영자 manual 4-step**:

- orchestrator 기본이 workspace **hard-delete** (archive-mode 부재) → step 4 는 `axe workspace close` 로 수동 ARCHIVE. ([B-index-teardown-archive-default-mode](/ops/backlog))
- **co-deal shared-detector 가드 부재** (step 9 가 blind `rmtree`) → §co-deal 쿼리로 수동 확인 후 진행. ([B-index-teardown-codeguard-shared-folder](/ops/backlog))
- dual-mount 탐색 / post-delete sweep 미내장 → §0(a)·step 3 수동 수행.

## 검증된 사실 (live index DB·seeds, 2026-06-15)

| 딜 | stage | evidence | 비고 |
|---|---|---|---|
| Starnex | `Passed` | 97 | dataroom 은 `1_Project/Pipeline` 실본(흡수 복구). `deal_stage_history` seed-initial 만 `IC`였음 — "live/IC" 는 오류 |
| Hancom | `Passed` | 29 | 2026-06-13 별도 teardown 으로 half-torn→완결 (D-index-51 10-딜 batch 와 무관) |
| Interstellar | `Lost` | 1004 | 2026-06-13 teardown 완료 |
| D-index-51 batch | (mixed) | — | Sendy·apposter·dayton·DeveloperGroup·Eduon·JsEnl·Medistaff·Novachips·OpenResearch·Catalyst (10딜, 2 workspace 삭제) |

`teardown_event` 는 현재 **0 행** — 역대 teardown 은 전부 manual/stopgap, orchestrator audit 경로는 아직 미실행.
