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

# nora causal

> 폴더별 인과 그래프. 설정, 부트스트랩, 스테이지 리뷰, 라이브 승인

Nora의 인과 그래프는 **폴더별**. 문서 폴더에 그래프를 붙이고, 그 문서에서 인과 트리플을 **staged** 영역으로 추출한 뒤, **live**로 승인.

`causal` CLI가 staged/live 워크플로우 표면. 그래프를 문서에서 띄우고, 좋은 트리플을 승인하고, 승인된(라이브) 것만 검증과 추론에 씀.

## 명령

| 명령                              | 설명                              |
| ------------------------------- | ------------------------------- |
| `causal get <folder>`           | 폴더의 전체 그래프 가져오기(LIVE + STAGED). |
| `causal settings show <folder>` | 폴더 그래프 설정 + 스테이지 통계 출력.         |
| `causal settings set <folder>`  | 그래프 설정 업데이트.                    |
| `causal bootstrap <folder>`     | 인과 트리플을 STAGED로 추출.             |
| `causal refresh <folder>`       | 델타를 STAGED로 다시 계산.              |
| `causal approve <folder>`       | STAGED 줄을 LIVE로 올림.             |
| `causal reject <folder>`        | STAGED 줄을 안 올리고 버림.             |

폴더 식별자가 문서 폴더 태그(예: `billing`, `product-docs`).

## `causal get`

```bash theme={null}
nora causal get billing
```

전체 그래프 출력:

* `live_nodes`와 `live_edges` 검증과 추론에 쓰임.
* `staged_nodes`와 `staged_edges` 리뷰 대기.

구조화 출력은 `--json`을 붙임.

흔한 빠른 점검:

```bash theme={null}
nora causal get billing --json | jq '{live: .live_nodes | length, staged: .staged_nodes | length}'
```

## `causal settings show` / `set`

```bash theme={null}
nora causal settings show billing
```

설정 + 스테이지 수를 표시.

```bash theme={null}
nora causal settings set billing \
  --connection documents_folder:billing \
  --retrieval-preset high-precision \
  --dedup-policy merge \
  --auto-restage true
```

넘긴 플래그만 바뀜.

* `--connection <kind:id>` 그래프를 특정 데이터 소스에 잇기(예: `documents_folder:billing`).
* `--retrieval-preset <preset-id>` 추출이 컨텍스트를 끌어올 때 쓰는 프리셋.
* `--dedup-policy <policy>` 중복 처리 방식(`merge`, `keep_newer`, `keep_older`, `keep_all`).
* `--auto-restage true|false` 연결된 소스가 바뀌면 자동으로 다시 부트스트랩.

## `causal bootstrap`

```bash theme={null}
nora causal bootstrap billing --model gpt-4o
```

폴더의 모든 문서에서 인과 트리플을 STAGED로 추출. `approve` 할 때까지 LIVE 로는 아무것도 안 감.

* `--model <m>` 추출에 쓰는 모델. 워크스페이스 기본이 기본.

부트스트랩은 멱등. 이미 채워진 폴더에 다시 돌려도 LIVE 데이터를 안 잃음. 재추출이 새 STAGED 줄을 만들고 기존 LIVE는 그대로.

새 폴더: bootstrap → 앱에서 STAGED 영역 리뷰 → 좋은 것 승인. 기존 폴더: `refresh`가 대개 원하는 것.

## `causal refresh`

```bash theme={null}
nora causal refresh billing
```

델타만 다시 계산. 마지막 부트스트랩 이후 더해진 새 문서, 바뀐 기존 문서. 전체 부트스트랩보다 쌈.

Refresh 출력이 STAGED에 쌓임. 기존 LIVE는 그대로.

`--auto-restage`가 안 맞으면 스케줄로(또는 문서 변경으로 걸어) 돌림.

## `causal approve` / `reject`

```bash theme={null}
# 모든 STAGED 줄 승인
nora causal approve billing

# 특정 줄만 승인
nora causal approve billing --ids node_1,edge_a,node_5

# 나머지 거부
nora causal reject billing
```

* `--ids <id,…>` 특정 스테이지 줄 ID. 생략하면 모든 STAGED에 적용.

`approve` 뒤:

* 줄이 LIVE로 이동.
* 검증이 바로 그것들을 쓰기 시작.
* STAGED에는 이 명령이 안 건드린 것이 여전히 남음.

`reject`가 안 올리고 줄을 버림. 다음 부트스트랩이나 refresh로 다시 만들 수 있음.

## 레시피

### CLI로 폴더를 처음부터 끝까지 부트스트랩

```bash theme={null}
folder="billing"

# 1. 설정
nora causal settings set $folder \
  --connection documents_folder:$folder \
  --retrieval-preset high-precision \
  --auto-restage true

# 2. STAGED로 추출
nora causal bootstrap $folder

# 3. 리뷰 (보통 앱에서), 그 뒤 스테이지된 것 한꺼번에 승인
nora causal approve $folder

# 4. 쿼리가 그래프를 쓰는지 확인
nora retrieval search "some question" --filters '{"tag":"'$folder'"}' --include-subgraph
```

### CI: STAGED가 너무 크면 실패

무제한 백로그를 막음:

```bash theme={null}
threshold=200
staged=$(nora causal get billing --json | jq '.staged_nodes | length')
if [ "$staged" -gt "$threshold" ]; then
  echo "STAGED 백로그가 너무 큼 ($staged > $threshold). 리뷰 필요."
  exit 1
fi
```

### 사람 리뷰 뒤 골라 승인

리뷰 흐름이 외부 시스템에서 줄 ID로 승인 표시한다고 하면, 한꺼번에 승인:

```bash theme={null}
ids=$(cat approved-ids.txt | tr '\n' ',' | sed 's/,$//')
nora causal approve billing --ids "$ids"
```

### 감사용 LIVE 그래프 스냅샷

```bash theme={null}
nora causal get billing --json | jq '{live_nodes, live_edges}' > audit/billing-graph-$(date +%Y%m%d).json
```

## STAGED / LIVE 모델

인과 추출이 최선을 다하는 것이라 스테이지가 둘. 모델이 제안하고 여러분이 처리. LIVE 직접 편집은 CLI에서 안 됨(그건 앱의 그래프 캔버스를 씀). 다만 한꺼번에 승인/거부가 CLI가 맡는 일.

라이브 그래프를 손으로 고치고 싶으면(특정 엣지 추가, 잘못된 노드 제거) 앱에서. CLI의 역할은 대량 부트스트랩/refresh/승인.

## 관련

* [인과 그래프 개요](/ko/build/causal-graph/overview) 개념과 용도.
* [에이전트 답변 검증](/ko/build/causal-graph/verification) LIVE 그래프를 쓰는 방법.
* [`nora retrieval`](/ko/cli/retrieval) `--include-subgraph`이 그래프를 써서 검색을 넓힘.
