Files
CASAN/docs/packaging/DOMAIN_PACK_GUIDE.md
T
2026-07-11 15:56:31 +09:00

53 lines
2.7 KiB
Markdown

# CASAN Domain Pack Guide
A **Domain Pack** is the per-project data the harness needs to govern YOUR domain. It lives
at `apps/<project>/domain/` and is selected via `CASAN_DOMAIN_ROOT`. The harness code
(`packages/casan-harness/`) never contains domain data — this is what makes it reusable.
Scaffold template: `packages/casan-devkit/templates/domain-pack/`.
## Layout
```
apps/<project>/domain/
├── domain-pack.yaml # manifest describing this pack
├── input/
│ ├── requirement.md # FR-xx table drives the traceability gate
│ └── architecture.md # optional tech-stack/context
├── golden-runs/
│ └── <artifact>.golden.txt # baseline for drift detection (H7)
├── corpus/
│ ├── redteam-corpus.jsonl # attack vectors (H4 recall) — one JSON per line
│ ├── redteam-vectors.jsonl # vectors for benign-fp-report / redteam metrics
│ └── benign-corpus/*.txt # benign samples (H4 false-positive budget)
└── traceability-map.json # FR-xx → code files + test files (+ optional symbols/lines)
```
## Each piece
- **input/requirement.md** — must contain a `| FR-xx | ... |` table. The traceability gate
(Plan-10) requires every `FR-xx` to map to ≥1 existing code file and ≥1 test file. No
secrets/PII (the H4 input scan blocks them).
- **golden-runs/** — a canonical "good" artifact per pipeline output. `drift-detect` compares
a run against it; similarity 1.0 = no drift. Real drift detection is proven separately.
- **corpus/** — red-team attack vectors (scored for H4 recall) + a benign corpus (bounds the
false-positive rate). Domain-specific injections make the H4 score meaningful.
- **traceability-map.json** — `{"FR-01": {"name": "...", "code": ["apps/okr/backend/src/...", {"file":"...","symbols":["Foo"],"lines":[12]}], "tests": ["..."]}}`. Symbol/line refs are
optional but tighten the gate.
- **domain-pack.yaml** — documents the above + optional threshold overrides.
## Wire it up
```bash
export CASAN_DOMAIN_ROOT=apps/<project>/domain
bin/casan gate # runs domain-dependent suites against your pack
```
`domain_root` is also recorded per-project in `packages/casan-harness/level5/project-registry.json`
so `bin/casan reuse` can prove multi-project reuse.
## Reference example
The OKR app's own pack is the worked example: `apps/okr/domain/` (golden-runs, corpus,
input, traceability-map). Copy its shape for your domain.
## Toward Plan-12 (Domain Pack SDK)
Today a pack is a directory + `CASAN_DOMAIN_ROOT`. Plan-12 will make it fully declarative
(register a pack by manifest, no manual wiring). The `domain-pack.yaml` here is the seed of
that manifest.