Skip to content

Commit bb54753

Browse files
feat: enable trusted-lan device review
1 parent 739b12d commit bb54753

5 files changed

Lines changed: 101 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ with `Ctrl+C`; the launcher cleans up the API process it created. See
254254
`docs/human_accessibility_media_review.md` for the separate screen-reader, real-device,
255255
privacy-safe recording, and human-attestation gate.
256256

257+
The physical-device review can use `-AllowLan -NoBrowser` on a trusted Private network.
258+
This explicitly exposes only the Streamlit UI to the LAN; FastAPI remains loopback-only.
259+
Use synthetic samples and stop the launcher immediately after the review.
260+
257261
Text is session-only and file upload is intentionally disabled in v1. For manual startup,
258262
run `skillpulse-api` and `skillpulse-ui` in separate terminals and set
259263
`SKILLPULSE_API_URL` when the API uses another host or port.

‎docs/demo_checklist.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ Run a headless start-health-stop check without leaving either service running:
3131
powershell -ExecutionPolicy Bypass -File scripts/run_demo.ps1 -SmokeTest
3232
```
3333

34+
For the human physical-device gate only, `-AllowLan` explicitly binds the Streamlit UI
35+
to the computer's private LAN while keeping FastAPI on loopback:
36+
37+
```powershell
38+
powershell -ExecutionPolicy Bypass -File scripts/run_demo.ps1 -AllowLan -NoBrowser
39+
```
40+
41+
Use the printed physical-device URL only on a trusted Private network with synthetic
42+
samples, then stop with `Ctrl+C`. Do not use public Wi-Fi, port forwarding, or a public
43+
tunnel. See `docs/human_accessibility_media_review.md` for the required human evidence.
44+
3445
## Pre-demo gate
3546

3647
Before recording or sharing:

‎docs/human_accessibility_media_review.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@ Run the local demo using `docs/demo_checklist.md`, then record all three environ
3030

3131
`screen_reader` and `mobile_real_device` cannot be waived.
3232

33+
### Physical-device access on a trusted LAN
34+
35+
The default launcher remains loopback-only. For the physical-device check, connect the
36+
computer and phone/tablet to the same trusted private network, then run:
37+
38+
```powershell
39+
powershell -ExecutionPolicy Bypass -File scripts/run_demo.ps1 -AllowLan -NoBrowser
40+
```
41+
42+
Open one of the printed `SkillPulse UI (physical device)` URLs on the phone/tablet. The
43+
API remains bound to `127.0.0.1`; only Streamlit is reachable on the LAN. This temporary
44+
review mode has no TLS or authentication, so use only the built-in synthetic/public-safe
45+
samples, never enter a real CV or personal data, and stop it with `Ctrl+C` immediately
46+
after review. If Windows Firewall asks, allow only a trusted **Private network**, never a
47+
Public network.
48+
49+
If no private-device URL is printed, do not create a public tunnel or port-forwarding rule.
50+
Keep `mobile_real_device` incomplete until an approved trusted-LAN environment is available.
51+
3352
## Required human checks
3453

3554
For every check, set `status` to `pass` or `fail` and write a short `evidence_note` that

‎scripts/run_demo.ps1‎

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ param(
33
[switch]$Install,
44
[switch]$NoBrowser,
55
[switch]$SmokeTest,
6+
[switch]$AllowLan,
67
[ValidateRange(1, 65535)]
78
[int]$ApiPort = 8000,
89
[ValidateRange(1, 65535)]
@@ -26,9 +27,40 @@ function Invoke-PythonChecked {
2627
}
2728
}
2829

30+
function Get-PrivateIPv4Addresses {
31+
$addresses = foreach ($networkInterface in [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()) {
32+
if (
33+
$networkInterface.OperationalStatus -ne [System.Net.NetworkInformation.OperationalStatus]::Up -or
34+
$networkInterface.NetworkInterfaceType -eq [System.Net.NetworkInformation.NetworkInterfaceType]::Loopback
35+
) {
36+
continue
37+
}
38+
foreach ($unicastAddress in $networkInterface.GetIPProperties().UnicastAddresses) {
39+
$address = $unicastAddress.Address
40+
if ($address.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetwork) {
41+
continue
42+
}
43+
$bytes = $address.GetAddressBytes()
44+
$isPrivate = (
45+
$bytes[0] -eq 10 -or
46+
($bytes[0] -eq 172 -and $bytes[1] -ge 16 -and $bytes[1] -le 31) -or
47+
($bytes[0] -eq 192 -and $bytes[1] -eq 168)
48+
)
49+
if ($isPrivate) {
50+
$address.ToString()
51+
}
52+
}
53+
}
54+
return @($addresses | Sort-Object -Unique)
55+
}
56+
2957
try {
3058
Set-Location -LiteralPath $projectRoot
3159

60+
if ($AllowLan -and $SmokeTest) {
61+
throw "-AllowLan cannot be combined with -SmokeTest. Use the default loopback smoke test."
62+
}
63+
3264
if ($Install) {
3365
Write-Host "Installing SkillPulse API and UI dependencies..."
3466
Invoke-PythonChecked -Arguments @("-m", "pip", "install", "-e", ".[api,ui]")
@@ -76,15 +108,29 @@ try {
76108
}
77109

78110
$env:SKILLPULSE_API_URL = $apiUrl
79-
$headlessValue = if ($NoBrowser -or $SmokeTest) { "true" } else { "false" }
111+
$headlessValue = if ($NoBrowser -or $SmokeTest -or $AllowLan) { "true" } else { "false" }
112+
$uiBindAddress = if ($AllowLan) { "0.0.0.0" } else { "127.0.0.1" }
80113
$uiUrl = "http://127.0.0.1:$UiPort"
81114
Write-Host "SkillPulse API: $apiUrl/docs"
82-
Write-Host "SkillPulse UI: $uiUrl"
115+
Write-Host "SkillPulse UI (this computer): $uiUrl"
116+
if ($AllowLan) {
117+
Write-Warning "LAN review mode exposes the Streamlit UI without TLS or authentication."
118+
Write-Warning "Use only a trusted private network and synthetic/redacted inputs; stop immediately after review."
119+
$lanAddresses = @(Get-PrivateIPv4Addresses)
120+
if ($lanAddresses.Count -eq 0) {
121+
Write-Warning "No private LAN IPv4 address was found. Do not use port forwarding or a public tunnel."
122+
}
123+
else {
124+
foreach ($lanAddress in $lanAddresses) {
125+
Write-Host "SkillPulse UI (physical device): http://${lanAddress}:$UiPort"
126+
}
127+
}
128+
}
83129
Write-Host "Press Ctrl+C to stop the demo and its API process."
84130

85131
$uiArguments = @(
86132
"-m", "streamlit", "run", "src/skillpulse/ui/app.py",
87-
"--server.address", "127.0.0.1",
133+
"--server.address", $uiBindAddress,
88134
"--server.port", $UiPort.ToString(),
89135
"--server.headless", $headlessValue,
90136
"--browser.gatherUsageStats", "false"

‎tests/test_human_review.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from skillpulse.release.human_review import validate_human_review
66

77
TEMPLATE = Path("configs/human_accessibility_review.template.json")
8+
DEMO_LAUNCHER = Path("scripts/run_demo.ps1")
89

910

1011
def _template() -> dict:
@@ -118,3 +119,20 @@ def test_wrong_choice_types_return_validation_errors_instead_of_crashing() -> No
118119

119120
assert result["structurally_valid"] is False
120121
assert len(result["errors"]) == 4
122+
123+
124+
def test_physical_device_mode_is_explicit_and_keeps_api_on_loopback() -> None:
125+
launcher = DEMO_LAUNCHER.read_text(encoding="utf-8")
126+
127+
assert "[switch]$AllowLan" in launcher
128+
assert '"--host", "127.0.0.1"' in launcher
129+
assert '$uiBindAddress = if ($AllowLan) { "0.0.0.0" } else { "127.0.0.1" }' in launcher
130+
assert '"--server.address", $uiBindAddress' in launcher
131+
132+
133+
def test_physical_device_mode_fails_closed_for_automation_and_warns_about_exposure() -> None:
134+
launcher = DEMO_LAUNCHER.read_text(encoding="utf-8")
135+
136+
assert "if ($AllowLan -and $SmokeTest)" in launcher
137+
assert "without TLS or authentication" in launcher
138+
assert "Do not use port forwarding or a public tunnel" in launcher

0 commit comments

Comments
 (0)