Skip to content

Commit 7d5c88d

Browse files
authored
Streamline Privacy Guard onboarding (#27)
1 parent 8463e19 commit 7d5c88d

6 files changed

Lines changed: 178 additions & 321 deletions

File tree

projects/privacy-guard/docs/index.md

Lines changed: 39 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -44,115 +44,91 @@ the provider receives the request.
4444
## Quickstart
4545

4646
This quickstart uses the built-in `RegexEngine` example to replace an email
47-
address and customer ID. It requires:
47+
address and customer ID. Before you start, install:
4848

4949
- Python 3.11 or newer
5050
- `uv` 0.11 or newer
51-
- OpenShell and `openshell-gateway` `v0.0.90`, the version recorded in the
52-
[middleware manifest](https://github.com/NVIDIA/OpenShell-Research/blob/main/projects/privacy-guard/.openshell-middleware-manifest.json)
53-
- a Docker or Podman backend supported by OpenShell
54-
- Claude Code subscription access for the final provider request; the OpenShell
55-
base sandbox supplies the Claude Code binary
51+
- [OpenShell](https://github.com/NVIDIA/OpenShell) `v0.0.90` or a later
52+
compatible version
5653

57-
Confirm the installed command versions:
54+
Privacy Guard is tested with the version recorded in the
55+
[middleware manifest](https://github.com/NVIDIA/OpenShell-Research/blob/main/projects/privacy-guard/.openshell-middleware-manifest.json).
56+
A later version must support the same supervisor middleware contract.
5857

59-
```bash
60-
uv --version
61-
openshell --version
62-
openshell-gateway --version
63-
```
58+
Run the following commands from a checkout of OpenShell Research.
6459

65-
Run the commands from a checkout of OpenShell Research.
60+
### 1. Stop the local gateway
6661

67-
### 1. Prepare the example
62+
First, check the local gateway:
6863

6964
```bash
70-
cd projects/privacy-guard/examples/regex-engine
71-
uv sync --locked
72-
uv run privacy-guard engines
65+
openshell status
7366
```
7467

75-
The engine list should contain:
68+
If the gateway is running, stop it before you change its configuration. Use the
69+
command for your system:
7670

77-
```text
78-
regex detect,replace
79-
```
80-
81-
The example files are:
71+
```bash
72+
# macOS with Homebrew
73+
brew services stop openshell
8274

83-
| File | Purpose |
84-
| --- | --- |
85-
| `patterns.yaml` | Email and customer-ID rules |
86-
| `privacy-guard-config.yaml` | Standalone Privacy Guard policy configuration |
87-
| `policy.yaml` | Complete OpenShell sandbox policy with the same configuration |
75+
# Linux with a Debian or RPM package
76+
systemctl --user stop openshell-gateway
77+
```
8878

8979
### 2. Start Privacy Guard
9080

91-
From the example directory:
92-
9381
```bash
94-
uv run privacy-guard serve --listen 0.0.0.0:50051
82+
cd projects/privacy-guard/examples/regex-engine
83+
uv run --locked privacy-guard serve --listen 0.0.0.0:50051
9584
```
9685

9786
Keep the process running. The development server uses plaintext gRPC and
9887
receives request bodies. Restrict port 50051 to the host and trusted sandbox
9988
network.
10089

101-
### 3. Register Privacy Guard with the gateway
90+
### 3. Configure and start the gateway
10291

10392
Choose a non-loopback host IPv4 address that both the gateway and sandbox
104-
supervisor can reach:
93+
supervisor can reach.
10594

106-
```bash
107-
# macOS
108-
ipconfig getifaddr en0
109-
110-
# Linux
111-
hostname -I
112-
```
113-
114-
Create a local gateway configuration:
95+
Open another terminal and return to the example directory. Replace
96+
`YOUR_HOST_IPV4` with the address you selected. Then update the default gateway
97+
configuration:
11598

11699
```bash
117-
export PRIVACY_GUARD_HOST_IP=YOUR_HOST_IPV4
118-
100+
cd projects/privacy-guard/examples/regex-engine
119101
uv run privacy-guard configure-gateway \
120-
--host-ip "$PRIVACY_GUARD_HOST_IP" \
121-
--name privacy-guard-regex \
122-
--config gateway.local.toml
102+
--host-ip YOUR_HOST_IPV4 \
103+
--name privacy-guard-regex
123104
```
124105

125106
Do not use `127.0.0.1`: loopback inside the sandbox supervisor does not refer to
126107
the host.
127108

128-
Restart the local gateway with `gateway.local.toml`. For a Homebrew
129-
installation:
109+
The command above updates the default OpenShell gateway configuration. Next,
110+
use the command for your system to start the gateway in the background:
130111

131112
```bash
132-
brew services stop openshell
133-
export OPENSHELL_LOCAL_TLS_DIR="$HOME/.local/state/openshell/homebrew/tls"
134-
openshell-gateway --config "$PWD/gateway.local.toml"
135-
```
136-
137-
For a Debian or RPM installation:
113+
# macOS with Homebrew
114+
brew services start openshell
138115

139-
```bash
140-
systemctl --user stop openshell-gateway
141-
export OPENSHELL_LOCAL_TLS_DIR="$HOME/.local/state/openshell/tls"
142-
openshell-gateway --config "$PWD/gateway.local.toml"
116+
# Linux with a Debian or RPM package
117+
systemctl --user start openshell-gateway
143118
```
144119

145-
Keep the foreground gateway running.
146-
147120
### 4. Create a sandbox
148121

149-
In another terminal, return to the example directory and verify the gateway:
122+
Open another terminal, return to the example directory, and check the gateway:
150123

151124
```bash
152-
openshell gateway select openshell
125+
cd projects/privacy-guard/examples/regex-engine
153126
openshell status
154127
```
155128

129+
This walkthrough starts Claude Code in the sandbox. To use a different harness,
130+
replace everything after `--` with its command.
131+
156132
Create the example sandbox:
157133

158134
```bash

projects/privacy-guard/docs/operations.md

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,32 @@ Restrict its listen port to trusted host and sandbox networks.
6767

6868
## Register the service with OpenShell
6969

70-
Choose a non-loopback IPv4 address reachable by both the local gateway and
71-
sandbox supervisors:
70+
First, check the local gateway:
7271

7372
```bash
74-
# macOS
75-
ipconfig getifaddr en0
76-
77-
# Linux
78-
hostname -I
73+
openshell status
7974
```
8075

81-
Add or update a gateway registration:
76+
If the gateway is running, stop it before you change its configuration. Use the
77+
command for your system:
8278

8379
```bash
84-
export PRIVACY_GUARD_HOST_IP=YOUR_HOST_IPV4
80+
# macOS with Homebrew
81+
brew services stop openshell
82+
83+
# Linux with a Debian or RPM package
84+
systemctl --user stop openshell-gateway
85+
```
8586

87+
Choose a non-loopback IPv4 address reachable by both the local gateway and
88+
sandbox supervisors.
89+
90+
Replace `YOUR_HOST_IPV4` with the address you selected. Then add or update the
91+
gateway registration:
92+
93+
```bash
8694
uv run privacy-guard configure-gateway \
87-
--host-ip "$PRIVACY_GUARD_HOST_IP" \
95+
--host-ip YOUR_HOST_IPV4 \
8896
--name privacy-guard \
8997
--port 50051
9098
```
@@ -115,45 +123,23 @@ network_middlewares:
115123
OpenShell does not dynamically reload middleware registrations. Restart the
116124
gateway after changing its configuration.
117125
118-
## Run a local foreground gateway
119-
120-
Stop the package-managed service before starting another gateway on the same
121-
port.
126+
## Start the local gateway
122127
123-
### macOS with Homebrew
124-
125-
```bash
126-
brew services stop openshell
127-
export OPENSHELL_LOCAL_TLS_DIR="$HOME/.local/state/openshell/homebrew/tls"
128-
openshell-gateway --config "$HOME/.config/openshell/gateway.toml"
129-
```
130-
131-
Restore it after testing:
128+
Use the command for your system to start the gateway in the background:
132129
133130
```bash
131+
# macOS with Homebrew
134132
brew services start openshell
135-
```
136-
137-
### Linux with a Debian or RPM package
138133

139-
```bash
140-
systemctl --user stop openshell-gateway
141-
export OPENSHELL_LOCAL_TLS_DIR="$HOME/.local/state/openshell/tls"
142-
openshell-gateway --config "$HOME/.config/openshell/gateway.toml"
143-
```
144-
145-
Restore it after testing:
146-
147-
```bash
134+
# Linux with a Debian or RPM package
148135
systemctl --user start openshell-gateway
149136
```
150137

151-
For a custom gateway path, replace the `--config` argument accordingly.
138+
The gateway reads the default configuration that `configure-gateway` updated.
152139

153140
## Verify connectivity
154141

155142
```bash
156-
openshell gateway select openshell
157143
openshell status
158144
```
159145

@@ -250,8 +236,6 @@ port must be between 1 and 65535.
250236
| Symptom | Check |
251237
| --- | --- |
252238
| Sandbox creation reports unavailable middleware | Confirm Privacy Guard is running, the registration name matches the policy, the host IP is reachable from the sandbox network, and the port is allowed |
253-
| Gateway port is already in use | Stop the package-managed gateway before starting a foreground instance |
254-
| Foreground gateway cannot find certificates | Set `OPENSHELL_LOCAL_TLS_DIR` to the package-specific path shown above |
255239
| Policy config is rejected | Run `privacy-guard configuration-schema` with the same registry factory used by the server |
256240
| Relative Regex catalog is not found | Start Privacy Guard from the directory against which the catalog path is defined |
257241
| Request is denied with `privacy_guard_limit_exceeded` | Inspect Privacy Guard logs, reduce input/output/detections, simplify stages, or increase the processing timeout with OpenShell headroom |
@@ -261,17 +245,15 @@ port must be between 1 and 65535.
261245

262246
## Shutdown and cleanup
263247

264-
Stop foreground Privacy Guard and gateway processes with `Ctrl-C`. Delete test
265-
sandboxes explicitly:
248+
Stop Privacy Guard with `Ctrl-C`. Delete test sandboxes explicitly:
266249

267250
```bash
268251
openshell sandbox delete SANDBOX_NAME
269252
```
270253

271-
Restore the package-managed gateway and verify connectivity:
254+
The gateway continues to run in the background. Verify its connection:
272255

273256
```bash
274-
openshell gateway select openshell
275257
openshell status
276258
```
277259

0 commit comments

Comments
 (0)