File size: 3,866 Bytes
975d390
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Local setup

How to run icat_app on your machine for development.

## Prerequisites

- **Python 3.12** (matches HF Spaces deploy; see `runtime.txt` and `.python-version`).
- **Git** with Git Bash on Windows (the repo's `.githooks/` are bash scripts).
- **gh** (GitHub CLI), optional but recommended for opening PRs.

## One-time setup

```bash
git clone git@github.com:implicitdiagnosticsandsolutions/icat_app.git
cd icat_app
bash scripts/setup.sh          # wires .githooks/ into git via core.hooksPath
python -m venv .venv
source .venv/Scripts/activate  # Windows Git Bash
# or: source .venv/bin/activate    # macOS / Linux
pip install -r requirements.txt
```

`scripts/setup.sh` is idempotent. It is also invoked automatically by the
`ensure-setup.sh` SessionStart hook the next time you open Claude Code in
this repo.

If you prefer the exact pinned versions used in the deploy build (rather than
re-resolving against the latest compatible), install from the lockfile
instead:

```bash
pip install -r requirements.lock
```

`requirements.lock` is generated against Python 3.12 with `uv pip compile`. Do
not regenerate it from Python 3.13+ — the resolution can differ from what HF
Spaces actually installs.

## Running the app

```bash
streamlit run app.py
# opens http://localhost:8501
```

The 8 tabs map 1-to-1 to the 8 files `tab1.py` through `tab8.py`. Shared
helpers live in `helper.py`.

## Verifying changes before commit

Run the structural validator:

```bash
python scripts/repo_validate.py
```

This compiles every `*.py` with `py_compile`, parses `requirements.txt`, and
sanity-checks the README HF Spaces frontmatter. The same script runs on every
PR via `.github/workflows/repo_validate.yml`.

For source-code changes, the reviewer subagent procedure in `CLAUDE.md` is
mandatory before commit. The `commit-msg` hook will block any commit that
modifies substantive files without a fresh `.decode-reviewer-clean` marker,
unless the commit message contains `[override-reviewer: <reason>]`.

## Per-OS notes

### Windows

- Use **Git Bash** (or WSL) for git operations. PowerShell/CMD will not invoke
  the `.githooks/` bash scripts.
- If `pip install` of `opencv-python-headless` is slow, that is expected; it
  ships large native wheels.
- The local Python interpreter should be 3.12. If you only have 3.13, you can
  still run the app for most tabs, but the `requirements.lock` resolution will
  not match HF Spaces. Install Python 3.12 via the official installer or via
  `uv python install 3.12`.

### macOS

- Standard Python 3.12 via Homebrew (`brew install python@3.12`), pyenv, or
  uv works equivalently.
- No additional notes.

### Linux

- HF Spaces itself runs on Linux, so this is the closest match to production.
- Standard `python3.12` + `python3.12-venv` from your distro is enough.

## Troubleshooting

| Symptom | Likely cause | Fix |
|---|---|---|
| Commit blocked by `commit-msg` hook | Reviewer marker stale or missing | Run the reviewer procedure in `CLAUDE.md`, then retry |
| `Sync to Hugging Face hub` workflow fails | `HF_TOKEN` secret expired or scope wrong | Rotate the token in GitHub repo settings; see `SECURITY.md` |
| `pip install -r requirements.lock` fails on transitive | Local Python is not 3.12 | Switch to Python 3.12 (see above) |
| Streamlit complains about port 8501 | Port already in use | `streamlit run app.py --server.port 8502` |
| Hooks silently not running | `core.hooksPath` not set | Re-run `bash scripts/setup.sh` |

## What this runbook does NOT cover

- Deploying to HF Spaces — that happens automatically on push to `main`. See
  `docs/guides/protected-boundary-policy.md`.
- Editing CI workflows — see `docs/guides/git-and-pr-rules.md` and
  `SECURITY.md` for the deploy-boundary rules first.
- Adding a new tool — see `docs/policies/naming-conventions.md` for the
  `tab<N>.py` rule.