# Venkel operator runbook

This runbook is for whoever drives an assessment: an engineer looking at their own company's
estate, a consultant looking at a client's, someone auditing open source, or an assistant
(Claude Code, ChatGPT, or similar) acting for any of them. It is the same for all of them. Everything
here needs only the installed `venkel` command plus `git` and `gh`; no checkout of the Venkel
repository. In Claude Code, `/venkel-operator` walks these steps (the installer sets it up).

Venkel scans local checkouts. It never clones, never calls GitHub, never sends code anywhere.
The operator does acquisition and the GitHub export; Venkel does the scanning, normalization
and reporting; a frontier model interprets the normalized package through the prompt packs.

## 0. Before you start

Make sure you have permission before you download, analyze, or audit source code with
Venkel. Before enabling per-person git analysis, make sure that is permitted too, and that it
does not conflict with your engagement terms, your employment agreement, or what your coworkers
and employer would reasonably expect. Venkel does not request, record, or verify any of this.
That responsibility stays with you.

`venkel init` shows this and two more notes, and waits for ok or quit each time:

- This computer will hold the source code you scan and the findings Venkel produces. Make sure
  that is acceptable for this machine, where it lives, and who can reach it.
- During a scan, may the scanners fetch vulnerability-database updates from the internet? Source
  code is never sent. Answering no sets `offline: true`; missing databases are then recorded as
  coverage gaps rather than fetched.

Your answers to the notices are not written anywhere. The offline answer becomes a setting in
`venkel.yaml` because it is one. Everything Venkel produces stays in the folder you run it in.

## 1. Install (once per machine)

```bash
curl -fsSL https://install.venkel.dev | bash
```

That installs uv, Python 3.12, Venkel, the scanners (via Homebrew where available), the
Claude Code skill if Claude Code is present, and runs `venkel doctor`. Re-run it any time; it
is safe to repeat. Then:

```bash
venkel doctor                      # every tool should be ok; drift is reported, missing tools are coverage gaps
trivy image --download-db-only     # fetches the vulnerability database (network); do this unless you must stay offline
```

`venkel scan` refuses to start an offline assessment while that database is missing, because
the vulnerability results would silently be empty. Download it once, or pass
`--without-vuln-db` to run anyway; vulnerability coverage is then a recorded gap in the report.

## 2. Start the assessment folder, enumerate and acquire repositories

```bash
mkdir -p ~/assessments/ORG && cd ~/assessments/ORG
venkel init                        # notices, then venkel.yaml, notes.md, repos/, sidecars/
```

`venkel init` asks for the assessment name, the organization whose code this is (your
employer, your client, or the project; name, website, optional logo) and who is preparing the
report (company or team, optional logo, your name and email). These go into `venkel.yaml` and
onto the report header. The prepared-by details can be saved on this machine, under
`~/.venkel/preparer.yaml`, so the next assessment starts pre-filled. `notes.md` is a scratch
file for scope and housekeeping; Venkel never reads it.

Then, with GitHub access to the organization, list candidates and decide scope. Prefer `gh` so
the listing is reproducible:

```bash
gh repo list ORG --limit 500 --json name,isArchived,pushedAt,primaryLanguage,visibility \
  --jq '.[] | [.name, .isArchived, .pushedAt, .primaryLanguage.name, .visibility] | @tsv' > repos.tsv
```

Clone into `repos/`. Full history is required for activity and team signals; shallow clones
are recorded as a coverage gap.

```bash
while IFS=$'\t' read -r name archived pushed lang vis; do
  gh repo clone "ORG/$name" "repos/$name" -- --quiet
done < repos.tsv
```

## 3. Export GitHub metadata (sidecars)

Per repository, export the GitHub metadata. It collects pull requests with reviews, workflow
runs, deployments, environments, releases, branch protection and rulesets. No code, no issue
or PR bodies, no comment text; PR titles are the only free text.

```bash
venkel sidecar export $(cut -f1 repos.tsv | sed "s|^|ORG/|") --days 365   # -> sidecars/NAME.github.json
```

Needs `gh` signed in (`gh auth login`) with the `repo` scope, and `jq`. Branch protection
needs admin or maintain rights; without them that field is recorded as a coverage gap, not a
finding. Endpoints that 403/404 are listed under `errors[]` in the file.

## 4. Edit venkel.yaml

`venkel init` wrote a starter with commented examples. Replace the example repositories with
one entry per clone under `repos/`. Decide depth per repository: `inventory` for dormant or
archived, `standard` for most, `deep` for the active, deployed services that will get a deep
dive. Point each repository at its sidecar under `sidecars/`.

```bash
venkel validate venkel.yaml
venkel config effective venkel.yaml   # shows the resolved settings per repository and where each came from
venkel plan venkel.yaml               # what will run, what will be skipped and why, coverage gaps up front
```

## 5. Run

```bash
venkel scan venkel.yaml
```

The run stages under `<output>/.staging/<ulid>/` and is published to
`<output>/<timestamp>_<ulid>/` only when complete. Ctrl-C leaves it in staging;
`venkel resume <staging dir>` continues, reusing completed steps.

Running `venkel scan` again, for instance after adding repositories to `venkel.yaml`, produces a
new complete run. Scanner steps whose inputs did not change since the previous completed run in
the same output directory (same commit on a clean tree, same scan level, adapter, tool versions
and options, and for vulnerability scans the same database build) are carried forward from that
run, checksums verified, and marked as such in the manifest and report. Git history and GitHub
adapters always re-run because their numbers depend on the date. `venkel scan --fresh`
recomputes everything; `--reuse-from <run>` picks the source run. The published run contains
raw tool output, parsed JSONL, `consolidated/assessment.json`, `reports/venkel-report.html`
and `reports/summary.md`, and is read-only. `venkel verify <run>` recomputes every checksum.

```bash
venkel ingest <run>                   # SQLite index next to the runs, for inspect and diff
venkel inspect <output>/assessment.sqlite
venkel diff <output>/assessment.sqlite   # against the previous run, once there are two
```

## 6. Interpret

Hand the frontier model the package, not the code:

1. Open `reports/venkel-report.html` yourself first. It is self-contained and offline.
2. Run the estate prompt pack (`venkel prompts estate-findings`) with
   `consolidated/assessment.json` and `reports/summary.md` as inputs.
3. For each deep-dive candidate it names, run the deep-dive pack
   (`venkel prompts deep-dive`). `venkel evidence <run> --finding <fingerprint>` or
   `--at repo:path:line` serves redacted snippets from the exact revision that was scanned,
   so citations match the findings. What your assistant reads beyond that is your call;
   Venkel does not meter or record it.

## 7. Hand-off and clean-up

Deliver the run directory, or just `reports/` and `consolidated/`, to whoever the
assessment is for. Both report variants carry a "Confidential" banner naming the
organization and the preparer, and a run line with the scan level, run id and date.

When the assessment is over, delete every copy. `notes.md` is the place to record who got
the report, when you plan to delete, and that the deletion happened:

- clones under `repos/`, `repos.tsv`, and the sidecars under `sidecars/`
- staging and published runs under `<output>/`
- the SQLite index `<output>/assessment.sqlite`
- pseudonym key files under `~/.venkel/people-keys/`, unless you still need to re-identify people
- delivered report copies you still hold, and any transcript from the interpretation step

Pseudonymous output is never "anonymous"; say so wherever you describe it.

## Enrichment with Apple fm

`enrichment.enabled: true` with `provider: fm` uses the Apple on-device model (Apple Intelligence
on macOS) to summarize findings. Nothing leaves the machine. Using it means you have confirmed
you can, on this machine and under its software terms. It is off by default.
