chore: add send file sandbox evidence package

This commit is contained in:
zhaoyilun
2026-07-11 00:08:56 +08:00
parent fab0f0f5c0
commit 7db022469c
6 changed files with 843 additions and 6 deletions

View File

@@ -240,8 +240,8 @@ Continuous execution plan R6f-R14 is approved and execution has started:
- Plan file: `docs/superpowers/plans/2026-07-10-r6f-r14-continuous-execution-plan.md`. - Plan file: `docs/superpowers/plans/2026-07-10-r6f-r14-continuous-execution-plan.md`.
- Scope: 15 ordered rounds covering send-message connector/gate hardening, send-file preview/idempotency/package, receive-file download preview, receive-message reconciliation, end-to-end business smoke, and release-candidate report. - Scope: 15 ordered rounds covering send-message connector/gate hardening, send-file preview/idempotency/package, receive-file download preview, receive-message reconciliation, end-to-end business smoke, and release-candidate report.
- Execution rule after approval: one round at a time, status-card update, verification, commit, push, then continue automatically until an evidence-only blocker requires user action. - Execution rule after approval: one round at a time, status-card update, verification, commit, push, then continue automatically until an evidence-only blocker requires user action.
- Last completed round: R8 send-file idempotency and audit hardening. - Last completed round: R9 send-file upload evidence package.
- Next active round: R9 send-file upload evidence package. - Next active round: R10 receive-file download resolver v2 diagnostic.
R6g send audit and idempotency replay diagnostics is complete: R6g send audit and idempotency replay diagnostics is complete:
@@ -315,3 +315,14 @@ R8 send-file idempotency and audit hardening is complete:
- Production file upload remains blocked with `production_send_enabled=false` and `real_send_attempted=false`. - Production file upload remains blocked with `production_send_enabled=false` and `real_send_attempted=false`.
- Verification passed: focused send-file tests, `go test ./...`, `go build ./cmd/isphere-mcp`, `scripts\verify-go-mcp.ps1`, and `go run ./cmd/isphere-capability-smoke`. - Verification passed: focused send-file tests, `go test ./...`, `go build ./cmd/isphere-mcp`, `scripts\verify-go-mcp.ps1`, and `go run ./cmd/isphere-capability-smoke`.
- Next node: R9 send-file upload evidence package. - Next node: R9 send-file upload evidence package.
R9 send-file upload evidence package is complete:
- Added `scripts\package-send-file-sandbox-gate.ps1` to build `runs\send-file-sandbox-gate-package.zip`.
- Added `scripts\verify-send-file-sandbox-gate-package.ps1` to assert package contents and required operator markers.
- Added `scripts\validate-returned-send-file-sandbox-package.ps1` to validate returned online/internal sandbox file-send evidence.
- Added `docs\source-discovery\2026-07-10-send-file-sandbox-gate.md`.
- Package includes read-only live probe recorder, `capability\isphere-capability-smoke.exe`, `FILE-SEND-INPUTS.template.json`, `CREATE-FILE-RETURN-ZIP.ps1`, and `RUN-FILE-RECORDING-SUITE.bat`.
- Local verification generated and validated `runs\send-file-sandbox-gate-package.zip`; no production file upload connector was enabled.
- Verification passed: git diff --check, scripts\verify-send-file-sandbox-gate-package.ps1, go test ./..., go build ./cmd/isphere-mcp, and scripts\verify-go-mcp.ps1.
- Next node: R10 receive-file download resolver v2 diagnostic.

View File

@@ -0,0 +1,68 @@
# 2026-07-10 R9 Send-file sandbox evidence gate
## Decision
Local development still cannot log in to iSphere/IMPlatformClient, so real file upload must not be enabled from local-only evidence.
R9 prepares a one-pass online/internal sandbox package for collecting the missing evidence. The package is intentionally operator-driven:
- it does not click, type, upload, hook, inject, or send automatically;
- the operator manually sends exactly one approved sandbox file;
- before/after read-only recorder output and completed operator fields are returned for validation;
- production `isphere_send_file` remains blocked until the returned package passes validation.
## Package
Builder:
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\package-send-file-sandbox-gate.ps1
```
Verifier:
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-send-file-sandbox-gate-package.ps1
```
Expected generated zip:
```text
runs\send-file-sandbox-gate-package.zip
```
## Returned-package validator
Use this after an online/internal sandbox operator returns a zip:
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\validate-returned-send-file-sandbox-package.ps1 -ZipPath <returned-zip> -Strict
```
The validator checks only sanitized booleans/counts/metadata:
- target fields are present;
- `ISPHERE_SEND_FILE_ALLOWED_DIR` is recorded;
- `sandbox_file_path`, `file_sha256`, `file_size_bytes`, and `idempotency_key` are present;
- before and after recorder output exists;
- operator timestamps are present;
- file upload/sent-record evidence is present;
- duplicate second file send was not attempted;
- `production_file_send_enabled=false`.
## Current status
No returned R9 package has been reviewed in this repository state.
`isphere_send_file` remains preview/idempotency/audit only:
- `send_file_preview_tool_present=true`
- `send_file_duplicate_detected=true`
- `send_file_conflict_blocked=true`
- `send_file_production_enabled=false`
## Next decision
If a returned package passes `strict_file_gate_pass`, the next implementation round may design a gated file-upload connector path.
If no returned package is available, keep file sending at preview only and continue local-safe rounds.

View File

@@ -651,7 +651,7 @@ git push gitea main
- WinHelper recorder executable and dependencies - WinHelper recorder executable and dependencies
- Capability smoke executable if already built - Capability smoke executable if already built
- [ ] **Step 1: Build verifier first** - [x] **Step 1: Build verifier first**
```powershell ```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-send-file-sandbox-gate-package.ps1 powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-send-file-sandbox-gate-package.ps1
@@ -659,15 +659,15 @@ powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-send-file-san
Expected before implementation: FAIL because package builder does not exist. Expected before implementation: FAIL because package builder does not exist.
- [ ] **Step 2: Implement package builder** - [x] **Step 2: Implement package builder**
The builder outputs `runs/send-file-sandbox-gate-package.zip` and includes only executables/scripts/docs needed by an online operator. The builder outputs `runs/send-file-sandbox-gate-package.zip` and includes only executables/scripts/docs needed by an online operator.
- [ ] **Step 3: Implement returned-package validator** - [x] **Step 3: Implement returned-package validator**
Validator requires file send attempt timestamps, before/after recorder output, file SHA256, observed upload/sent status, and duplicate-send confirmation. Validator requires file send attempt timestamps, before/after recorder output, file SHA256, observed upload/sent status, and duplicate-send confirmation.
- [ ] **Step 4: Verify and commit** - [x] **Step 4: Verify and commit**
```powershell ```powershell
git diff --check git diff --check
@@ -682,6 +682,16 @@ git push gitea main
**Acceptance gate:** 用户可以把一个包带到可登录环境采集发文件证据。 **Acceptance gate:** 用户可以把一个包带到可登录环境采集发文件证据。
**R9 Result:**
- Added `scripts/package-send-file-sandbox-gate.ps1`, which builds `runs/send-file-sandbox-gate-package.zip`.
- Added `scripts/verify-send-file-sandbox-gate-package.ps1`; the first run failed before the builder existed, then passed after implementation.
- Added `scripts/validate-returned-send-file-sandbox-package.ps1` for future returned online/internal sandbox packages.
- Added `docs/source-discovery/2026-07-10-send-file-sandbox-gate.md`.
- The package includes recorder binaries, capability smoke executable, `FILE-SEND-INPUTS.template.json`, operator instructions, `CREATE-FILE-RETURN-ZIP.ps1`, and `RUN-FILE-RECORDING-SUITE.bat`.
- Local verifier generated and validated the package; production `isphere_send_file` remains blocked.
- Returned-package validator was checked with a temporary strict-pass fixture.
--- ---
### R10: Receive-file download resolver v2 diagnostic ### R10: Receive-file download resolver v2 diagnostic

View File

@@ -0,0 +1,423 @@
param(
[string]$OutputDir = "runs/send-file-sandbox-gate-package",
[switch]$NoZip
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$repo = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path
$packageDir = Join-Path $repo $OutputDir
$zipPath = "$packageDir.zip"
$recorderRelative = Join-Path $OutputDir "recorder"
$recorderDir = Join-Path $packageDir "recorder"
$capabilityDir = Join-Path $packageDir "capability"
$capabilityExe = Join-Path $capabilityDir "isphere-capability-smoke.exe"
if (Test-Path -LiteralPath $packageDir) {
Remove-Item -LiteralPath $packageDir -Recurse -Force
}
if (Test-Path -LiteralPath $zipPath) {
Remove-Item -LiteralPath $zipPath -Force
}
New-Item -ItemType Directory -Force -Path $packageDir | Out-Null
New-Item -ItemType Directory -Force -Path $capabilityDir | Out-Null
New-Item -ItemType Directory -Force -Path (Join-Path $packageDir "return-evidence") | Out-Null
& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $repo "scripts\package-live-probe-recorder.ps1") -OutputDir $recorderRelative -NoZip
if ($LASTEXITCODE -ne 0) {
throw "package-live-probe-recorder.ps1 failed with exit code $LASTEXITCODE"
}
if (-not (Test-Path -LiteralPath (Join-Path $recorderDir "ISphereLiveProbeRecorder.exe"))) {
throw "recorder package was not created under $recorderDir"
}
Push-Location $repo
try {
& go build -o $capabilityExe ./cmd/isphere-capability-smoke
if ($LASTEXITCODE -ne 0) {
throw "go build ./cmd/isphere-capability-smoke failed with exit code $LASTEXITCODE"
}
}
finally {
Pop-Location
}
if (-not (Test-Path -LiteralPath $capabilityExe)) {
throw "capability smoke executable was not created: $capabilityExe"
}
@'
iSphere Send-File Sandbox Gate Package
LOCAL_LOGIN_UNAVAILABLE: the development machine cannot log in to iSphere.
ONLINE_SANDBOX_REQUIRED: run this package only on a machine/network where iSphere/IMPlatformClient can log in.
Goal:
- collect one operator-approved sandbox file-send evidence package;
- keep production file send disabled in the repository;
- return enough evidence to decide whether real file-upload connector work can start later.
What this package does:
- runs the read-only live probe recorder before the manual sandbox file send;
- asks the operator to manually send exactly one sandbox file in the official client;
- runs the same read-only recorder after the manual file send;
- optionally runs the offline capability smoke executable;
- zips the returned evidence folder.
What this package does not do:
- it does not send messages automatically;
- it does not send or upload files automatically;
- it does not click or type;
- it does not hook or inject into the client;
- it does not enable production_file_send_enabled.
Required rule:
- MANUAL_ONE_FILE_SEND_ONLY: send exactly one sandbox file manually.
- DO_NOT_SEND_SECOND_FILE: do not send a second file with the same idempotency_key.
- Put the chosen file under the local ISPHERE_SEND_FILE_ALLOWED_DIR you record in FILE-SEND-INPUTS.json.
- Record sandbox_file_path, file_sha256, file_size_bytes, and idempotency_key in FILE-SEND-INPUTS.json.
- Fill file_upload_or_sent_record after the operator sees upload success, sent-file record, or recipient-visible file evidence.
Return:
- preferred one-file flow: run RUN-FILE-RECORDING-SUITE.bat and follow the pauses.
- or run before/after batch files and then CREATE-FILE-RETURN-ZIP.ps1.
'@ | Set-Content -LiteralPath (Join-Path $packageDir "README.txt") -Encoding UTF8
@'
# R9 Online Sandbox File-Send Gate - Operator Steps
This package is for an online/internal sandbox only.
Markers:
- LOCAL_LOGIN_UNAVAILABLE: do not run this on the local development machine for proof.
- ONLINE_SANDBOX_REQUIRED: run on a machine where iSphere/IMPlatformClient can log in.
- MANUAL_ONE_FILE_SEND_ONLY: send exactly one test file manually.
- DO_NOT_SEND_SECOND_FILE: do not repeat the file send with the same idempotency_key.
## Step 1 - Prepare inputs
1. Copy `FILE-SEND-INPUTS.template.json` to `FILE-SEND-INPUTS.json`.
2. Put the sandbox file in a folder dedicated to the test.
3. Fill `sandbox_target_type`, `sandbox_target_id`, `ISPHERE_SEND_FILE_ALLOWED_DIR`, `sandbox_file_path`, and `idempotency_key`.
4. Compute file hash and size:
```powershell
$file = "<full path to sandbox file>"
(Get-FileHash -Algorithm SHA256 -LiteralPath $file).Hash.ToLowerInvariant()
(Get-Item -LiteralPath $file).Length
```
5. Copy the results into `file_sha256` and `file_size_bytes`.
## Step 2 - Before-file-send recording
1. Open and log in to iSphere/IMPlatformClient normally.
2. Open the sandbox target conversation.
3. Do not send any file yet.
4. Run `run-before-file-recorder.bat`.
Alternative one-file flow: run `RUN-FILE-RECORDING-SUITE.bat`.
## Step 3 - Manual one-file-send action
1. In the official iSphere client, manually send exactly the `sandbox_file_path` file.
2. Send it only to the declared sandbox target.
3. Do not send a second copy.
4. Fill `operator_started_at_local`, `operator_clicked_send_file_at_local`, `operator_observed_file_success_at_local`, `before_recorder_present`, `after_recorder_present`, `file_upload_or_sent_record_present`, `duplicate_second_file_send_attempted`, `manual_file_send_started_at_local`, `manual_file_send_finished_at_local`, `operator_observed_file_success`, `file_upload_or_sent_record`, and `do_not_send_second_file_confirmed` in `FILE-SEND-INPUTS.json`.
## Step 4 - After-file-send recording
Run `run-after-file-recorder.bat`.
## Step 5 - Optional capability smoke
Run:
```powershell
.\capability\isphere-capability-smoke.exe *> .\return-evidence\capability-smoke.txt
```
Expected fields include `tool_count=10`, `send_file_preview_tool_present=true`, and `send_file_production_enabled=false`.
## Step 6 - Return package
Run:
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .\CREATE-FILE-RETURN-ZIP.ps1
```
Send back the generated zip file. You can also run `03-create-file-return-zip.bat`.
The repository must keep production file send disabled until this evidence is reviewed.
'@ | Set-Content -LiteralPath (Join-Path $packageDir "OPERATOR-FILE-STEPS.md") -Encoding UTF8
@'
{
"gate": "R9 online sandbox file-send evidence gate",
"LOCAL_LOGIN_UNAVAILABLE": true,
"ONLINE_SANDBOX_REQUIRED": true,
"MANUAL_ONE_FILE_SEND_ONLY": true,
"DO_NOT_SEND_SECOND_FILE": true,
"sandbox_target_type": "direct-or-group",
"sandbox_target_id": "<sandbox target id only>",
"ISPHERE_SEND_FILE_ALLOWED_DIR": "<folder that contains only files approved for this test>",
"sandbox_file_path": "<full path to the one sandbox file>",
"file_sha256": "<sha256 hex of sandbox_file_path>",
"file_size_bytes": 0,
"idempotency_key": "<one unique idempotency key>",
"operator_started_at_local": "",
"operator_clicked_send_file_at_local": "",
"operator_observed_file_success_at_local": "",
"before_recorder_present": false,
"after_recorder_present": false,
"file_upload_or_sent_record_present": false,
"duplicate_second_file_send_attempted": false,
"manual_file_send_started_at_local": "",
"manual_file_send_finished_at_local": "",
"operator_observed_file_success": false,
"file_upload_or_sent_record": "",
"do_not_send_second_file_confirmed": false,
"production_file_send_enabled": false,
"notes": ""
}
'@ | Set-Content -LiteralPath (Join-Path $packageDir "FILE-SEND-INPUTS.template.json") -Encoding UTF8
@'
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "iSphere R9 sandbox file-send inputs",
"type": "object",
"required": [
"sandbox_target_type",
"sandbox_target_id",
"ISPHERE_SEND_FILE_ALLOWED_DIR",
"sandbox_file_path",
"file_sha256",
"file_size_bytes",
"idempotency_key",
"operator_started_at_local",
"operator_clicked_send_file_at_local",
"operator_observed_file_success_at_local",
"before_recorder_present",
"after_recorder_present",
"file_upload_or_sent_record_present",
"duplicate_second_file_send_attempted",
"production_file_send_enabled"
],
"properties": {
"sandbox_target_type": { "type": "string" },
"sandbox_target_id": { "type": "string" },
"ISPHERE_SEND_FILE_ALLOWED_DIR": { "type": "string" },
"sandbox_file_path": { "type": "string" },
"file_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
"file_size_bytes": { "type": "integer", "minimum": 1 },
"idempotency_key": { "type": "string" },
"operator_started_at_local": { "type": "string" },
"operator_clicked_send_file_at_local": { "type": "string" },
"operator_observed_file_success_at_local": { "type": "string" },
"before_recorder_present": { "type": "boolean" },
"after_recorder_present": { "type": "boolean" },
"file_upload_or_sent_record_present": { "type": "boolean" },
"duplicate_second_file_send_attempted": { "type": "boolean" },
"production_file_send_enabled": { "type": "boolean", "const": false }
}
}
'@ | Set-Content -LiteralPath (Join-Path $packageDir "FILE-SEND-INPUTS.schema.json") -Encoding UTF8
@'
# RETURN-FILE-CHECKLIST
Fill `FILE-SEND-INPUTS.json` and run `CREATE-FILE-RETURN-ZIP.ps1`.
Required fields:
- `operator_started_at_local`
- `operator_clicked_send_file_at_local`
- `operator_observed_file_success_at_local`
- `before_recorder_present=true`
- `after_recorder_present=true`
- `file_upload_or_sent_record_present=true`
- `duplicate_second_file_send_attempted=false`
- `production_file_send_enabled=false`
Return rule:
- One sandbox target only.
- One sandbox_file_path only.
- One file_sha256 only.
- One idempotency_key only.
- MANUAL_ONE_FILE_SEND_ONLY.
- DO_NOT_SEND_SECOND_FILE.
- Do not send a second copy.
- `CREATE-FILE-RETURN-ZIP.ps1` refuses to build a return zip when after-recorder output or required fields are missing.
'@ | Set-Content -LiteralPath (Join-Path $packageDir "RETURN-FILE-CHECKLIST.md") -Encoding UTF8
@'
Expected return files for R9:
1. FILE-SEND-INPUTS.json
- sandbox_target_type is filled.
- sandbox_target_id is filled.
- ISPHERE_SEND_FILE_ALLOWED_DIR is filled.
- sandbox_file_path is filled.
- file_sha256 is filled.
- file_size_bytes is greater than 0.
- idempotency_key is filled.
- file_upload_or_sent_record is filled.
- MANUAL_ONE_FILE_SEND_ONLY is true.
- DO_NOT_SEND_SECOND_FILE is true.
- do_not_send_second_file_confirmed is true.
- operator_started_at_local is filled.
- operator_clicked_send_file_at_local is filled.
- operator_observed_file_success_at_local is filled.
- before_recorder_present is true.
- after_recorder_present is true.
- file_upload_or_sent_record_present is true.
- duplicate_second_file_send_attempted is false.
- production_file_send_enabled is false.
2. return-evidence/before/*
3. return-evidence/after/*
4. Optional: return-evidence/capability-smoke.txt with tool_count=10, send_file_preview_tool_present=true, send_file_production_enabled=false.
'@ | Set-Content -LiteralPath (Join-Path $packageDir "EXPECTED-FILE-RETURN-FILES.txt") -Encoding UTF8
@'
param(
[string]$InputsPath = ".\FILE-SEND-INPUTS.json",
[string]$EvidenceDir = ".\return-evidence",
[string]$OutputZip = ""
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
function Test-NonEmptyString($Value) {
if ($null -eq $Value) { return $false }
return -not [string]::IsNullOrWhiteSpace([string]$Value)
}
if (-not (Test-Path -LiteralPath $InputsPath)) { throw "missing FILE-SEND-INPUTS.json: copy FILE-SEND-INPUTS.template.json first" }
if (-not (Test-Path -LiteralPath $EvidenceDir)) { throw "missing evidence dir: $EvidenceDir" }
$inputs = Get-Content -LiteralPath $InputsPath -Raw | ConvertFrom-Json
$beforeDir = Join-Path $EvidenceDir "before"
$afterDir = Join-Path $EvidenceDir "after"
$missing = New-Object System.Collections.Generic.List[string]
foreach ($name in @("sandbox_target_type", "sandbox_target_id", "ISPHERE_SEND_FILE_ALLOWED_DIR", "sandbox_file_path", "file_sha256", "idempotency_key", "operator_started_at_local", "operator_clicked_send_file_at_local", "operator_observed_file_success_at_local", "manual_file_send_started_at_local", "manual_file_send_finished_at_local", "file_upload_or_sent_record")) {
$prop = $inputs.PSObject.Properties[$name]
if ($null -eq $prop -or -not (Test-NonEmptyString $prop.Value)) { $missing.Add($name) }
}
if ($null -eq $inputs.file_size_bytes -or [int64]$inputs.file_size_bytes -le 0) { $missing.Add("file_size_bytes") }
if ($inputs.before_recorder_present -ne $true) { $missing.Add("before_recorder_present") }
if ($inputs.after_recorder_present -ne $true) { $missing.Add("after_recorder_present") }
if ($inputs.file_upload_or_sent_record_present -ne $true) { $missing.Add("file_upload_or_sent_record_present") }
if ($inputs.duplicate_second_file_send_attempted -ne $false) { $missing.Add("duplicate_second_file_send_attempted_false") }
if ($inputs.do_not_send_second_file_confirmed -ne $true) { $missing.Add("do_not_send_second_file_confirmed") }
if ($inputs.production_file_send_enabled -ne $false) { $missing.Add("production_file_send_enabled_false") }
if (-not (Test-Path -LiteralPath $beforeDir)) { $missing.Add("return-evidence/before") }
if (-not (Test-Path -LiteralPath $afterDir)) { $missing.Add("return-evidence/after") }
if ($missing.Count -gt 0) { throw ("cannot create return zip; missing: " + ($missing -join ", ")) }
if ([string]::IsNullOrWhiteSpace($OutputZip)) {
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$OutputZip = "isphere-send-file-return-$timestamp.zip"
}
if (Test-Path -LiteralPath $OutputZip) { Remove-Item -LiteralPath $OutputZip -Force }
$items = @($InputsPath, $EvidenceDir) | ForEach-Object { Resolve-Path -LiteralPath $_ }
Compress-Archive -LiteralPath $items.Path -DestinationPath $OutputZip -Force
[ordered]@{
ok = $true
zip = (Resolve-Path -LiteralPath $OutputZip).Path
production_file_send_enabled = $false
duplicate_second_file_send_attempted = $false
} | ConvertTo-Json -Depth 4 -Compress
'@ | Set-Content -LiteralPath (Join-Path $packageDir "CREATE-FILE-RETURN-ZIP.ps1") -Encoding UTF8
@'
@echo off
setlocal
cd /d "%~dp0"
if not exist return-evidence mkdir return-evidence
if not exist return-evidence\before mkdir return-evidence\before
recorder\ISphereLiveProbeRecorder.exe --no-pause > return-evidence\before\recorder-before.txt 2>&1
echo before recorder exit code: %ERRORLEVEL% > return-evidence\before\exit-code.txt
pause
exit /b 0
'@ | Set-Content -LiteralPath (Join-Path $packageDir "run-before-file-recorder.bat") -Encoding ASCII
Copy-Item -LiteralPath (Join-Path $packageDir "run-before-file-recorder.bat") -Destination (Join-Path $packageDir "01-run-before-file-recorder.bat") -Force
@'
@echo off
setlocal
cd /d "%~dp0"
if not exist return-evidence mkdir return-evidence
if not exist return-evidence\after mkdir return-evidence\after
recorder\ISphereLiveProbeRecorder.exe --no-pause > return-evidence\after\recorder-after.txt 2>&1
echo after recorder exit code: %ERRORLEVEL% > return-evidence\after\exit-code.txt
pause
exit /b 0
'@ | Set-Content -LiteralPath (Join-Path $packageDir "run-after-file-recorder.bat") -Encoding ASCII
Copy-Item -LiteralPath (Join-Path $packageDir "run-after-file-recorder.bat") -Destination (Join-Path $packageDir "02-run-after-file-recorder.bat") -Force
@'
@echo off
setlocal
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy Bypass -File .\CREATE-FILE-RETURN-ZIP.ps1
pause
exit /b %ERRORLEVEL%
'@ | Set-Content -LiteralPath (Join-Path $packageDir "03-create-file-return-zip.bat") -Encoding ASCII
@'
@echo off
setlocal
cd /d "%~dp0"
echo R9 send-file recording suite
echo Step 1: before recorder
call 01-run-before-file-recorder.bat
echo.
echo Step 2: manually send exactly one sandbox file now.
echo Fill FILE-SEND-INPUTS.json before continuing.
pause
echo Step 3: after recorder
call 02-run-after-file-recorder.bat
echo.
echo Step 4: optional capability smoke
if not exist return-evidence mkdir return-evidence
capability\isphere-capability-smoke.exe > return-evidence\capability-smoke.txt 2>&1
echo capability smoke exit code: %ERRORLEVEL% > return-evidence\capability-smoke-exit-code.txt
echo.
echo Step 5: create return zip
call 03-create-file-return-zip.bat
exit /b %ERRORLEVEL%
'@ | Set-Content -LiteralPath (Join-Path $packageDir "RUN-FILE-RECORDING-SUITE.bat") -Encoding ASCII
@'
{
"package": "send-file-sandbox-gate",
"LOCAL_LOGIN_UNAVAILABLE": true,
"ONLINE_SANDBOX_REQUIRED": true,
"MANUAL_ONE_FILE_SEND_ONLY": true,
"DO_NOT_SEND_SECOND_FILE": true,
"entrypoint": "RUN-FILE-RECORDING-SUITE.bat",
"input_template": "FILE-SEND-INPUTS.template.json",
"return_zip_script": "CREATE-FILE-RETURN-ZIP.ps1",
"recorder_exe": "recorder/ISphereLiveProbeRecorder.exe",
"capability_smoke_exe": "capability/isphere-capability-smoke.exe",
"expected_tool_count": 10,
"production_file_send_enabled": false
}
'@ | Set-Content -LiteralPath (Join-Path $packageDir "FILE-RECORDING-PACKAGE-MANIFEST.json") -Encoding UTF8
if (-not $NoZip) {
Compress-Archive -Path (Join-Path $packageDir "*") -DestinationPath $zipPath -Force
}
[ordered]@{
ok = $true
package_dir = (Resolve-Path -LiteralPath $packageDir).Path
zip = if (Test-Path -LiteralPath $zipPath) { (Resolve-Path -LiteralPath $zipPath).Path } else { $null }
recorder_exe = (Resolve-Path -LiteralPath (Join-Path $recorderDir "ISphereLiveProbeRecorder.exe")).Path
capability_smoke_exe = (Resolve-Path -LiteralPath $capabilityExe).Path
local_login_required = $false
online_sandbox_required = $true
production_file_send_enabled = $false
} | ConvertTo-Json -Depth 4 -Compress

View File

@@ -0,0 +1,223 @@
param(
[string]$PackagePath = "",
[string]$ZipPath = "",
[string]$WorkDir = "",
[switch]$Strict
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
function Test-NonEmptyString($Value) {
if ($null -eq $Value) {
return $false
}
return -not [string]::IsNullOrWhiteSpace([string]$Value)
}
function Get-JsonPropertyValue($Object, [string]$Name) {
if ($null -eq $Object) {
return $null
}
$property = $Object.PSObject.Properties[$Name]
if ($null -eq $property) {
return $null
}
return $property.Value
}
function Read-FirstJsonLine([string]$Path) {
if (-not (Test-Path -LiteralPath $Path)) {
return $null
}
foreach ($line in Get-Content -LiteralPath $Path) {
$trimmed = $line.Trim()
if ($trimmed.StartsWith("{") -and $trimmed.EndsWith("}")) {
return ($trimmed | ConvertFrom-Json)
}
}
return $null
}
if (-not [string]::IsNullOrWhiteSpace($ZipPath)) {
$PackagePath = $ZipPath
}
if ([string]::IsNullOrWhiteSpace($PackagePath)) {
throw "PackagePath or ZipPath is required"
}
if (-not (Test-Path -LiteralPath $PackagePath)) {
throw "package not found: $PackagePath"
}
$resolvedPackage = (Resolve-Path -LiteralPath $PackagePath).Path
$cleanup = $false
if ([string]::IsNullOrWhiteSpace($WorkDir)) {
$WorkDir = Join-Path ([System.IO.Path]::GetTempPath()) ("isphere-returned-send-file-sandbox-" + [guid]::NewGuid().ToString("N"))
$cleanup = $true
}
if (Test-Path -LiteralPath $WorkDir) {
Remove-Item -LiteralPath $WorkDir -Recurse -Force
}
New-Item -ItemType Directory -Force -Path $WorkDir | Out-Null
try {
if ($resolvedPackage.EndsWith(".zip", [System.StringComparison]::OrdinalIgnoreCase)) {
Expand-Archive -LiteralPath $resolvedPackage -DestinationPath $WorkDir -Force
$root = $WorkDir
}
else {
$root = $resolvedPackage
}
$allFiles = @(Get-ChildItem -LiteralPath $root -Recurse -File)
$inputsFile = $allFiles | Where-Object { $_.Name -like "FILE-SEND-INPUTS*.json" } | Sort-Object FullName | Select-Object -First 1
if (-not $inputsFile) {
throw "missing FILE-SEND-INPUTS json"
}
$inputs = Get-Content -LiteralPath $inputsFile.FullName -Raw | ConvertFrom-Json
$capabilityLog = $allFiles | Where-Object { $_.Name -like "*capability-smoke*.txt" -or $_.Name -like "*capability*.log" } | Sort-Object FullName | Select-Object -First 1
$capability = $null
if ($capabilityLog) {
$capability = Read-FirstJsonLine $capabilityLog.FullName
}
$beforeMarkers = @($allFiles | Where-Object { $_.FullName -match "\\before\\" -or $_.FullName -match "/before/" -or $_.Name -like "*before*" })
$afterMarkers = @($allFiles | Where-Object { $_.FullName -match "\\after\\" -or $_.FullName -match "/after/" -or $_.Name -like "*after*" })
$targetTypePresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "sandbox_target_type")
$targetIDPresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "sandbox_target_id")
$allowedDirPresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "ISPHERE_SEND_FILE_ALLOWED_DIR")
$filePathPresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "sandbox_file_path")
$fileHash = [string](Get-JsonPropertyValue $inputs "file_sha256")
$fileHashPresent = ($fileHash -match "^[0-9a-f]{64}$")
$fileSize = Get-JsonPropertyValue $inputs "file_size_bytes"
$fileSizePresent = ($null -ne $fileSize -and [int64]$fileSize -gt 0)
$idempotencyKeyPresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "idempotency_key")
$operatorStartedAtLocalPresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "operator_started_at_local")
$operatorClickedSendFileAtLocalPresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "operator_clicked_send_file_at_local")
$operatorObservedFileSuccessAtLocalPresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "operator_observed_file_success_at_local")
$manualStartPresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "manual_file_send_started_at_local")
$manualFinishPresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "manual_file_send_finished_at_local")
$operatorObservedFileSuccess = ((Get-JsonPropertyValue $inputs "operator_observed_file_success") -eq $true)
$fileUploadOrSentRecordPresent = Test-NonEmptyString (Get-JsonPropertyValue $inputs "file_upload_or_sent_record")
$fileUploadOrSentRecordPresentFlag = ((Get-JsonPropertyValue $inputs "file_upload_or_sent_record_present") -eq $true)
$beforeRecorderPresentFlag = ((Get-JsonPropertyValue $inputs "before_recorder_present") -eq $true)
$afterRecorderPresentFlag = ((Get-JsonPropertyValue $inputs "after_recorder_present") -eq $true)
$duplicateSecondFileSendAttemptedFalse = ((Get-JsonPropertyValue $inputs "duplicate_second_file_send_attempted") -eq $false)
$doNotSendSecondFileConfirmed = ((Get-JsonPropertyValue $inputs "do_not_send_second_file_confirmed") -eq $true)
$productionFileSendEnabledFalse = ((Get-JsonPropertyValue $inputs "production_file_send_enabled") -eq $false)
$capabilityOK = $false
$capabilityToolCount = 0
$capabilitySendFilePreview = $false
$capabilityProductionFileEnabled = $false
if ($null -ne $capability) {
$capabilityOK = ($capability.ok -eq $true)
if ($null -ne $capability.tool_count) {
$capabilityToolCount = [int]$capability.tool_count
}
if ($null -ne $capability.send_file_preview_tool_present) {
$capabilitySendFilePreview = [bool]$capability.send_file_preview_tool_present
}
if ($null -ne $capability.send_file_production_enabled) {
$capabilityProductionFileEnabled = [bool]$capability.send_file_production_enabled
}
}
$hasBeforeProbe = ($beforeMarkers.Count -gt 0)
$hasAfterProbe = ($afterMarkers.Count -gt 0)
$missing = New-Object System.Collections.Generic.List[string]
if (-not $targetTypePresent) { $missing.Add("sandbox_target_type") }
if (-not $targetIDPresent) { $missing.Add("sandbox_target_id") }
if (-not $allowedDirPresent) { $missing.Add("ISPHERE_SEND_FILE_ALLOWED_DIR") }
if (-not $filePathPresent) { $missing.Add("sandbox_file_path") }
if (-not $fileHashPresent) { $missing.Add("file_sha256") }
if (-not $fileSizePresent) { $missing.Add("file_size_bytes") }
if (-not $idempotencyKeyPresent) { $missing.Add("idempotency_key") }
if (-not $operatorStartedAtLocalPresent) { $missing.Add("operator_started_at_local") }
if (-not $operatorClickedSendFileAtLocalPresent) { $missing.Add("operator_clicked_send_file_at_local") }
if (-not $operatorObservedFileSuccessAtLocalPresent) { $missing.Add("operator_observed_file_success_at_local") }
if (-not $manualStartPresent) { $missing.Add("manual_file_send_started_at_local") }
if (-not $manualFinishPresent) { $missing.Add("manual_file_send_finished_at_local") }
if (-not $operatorObservedFileSuccess) { $missing.Add("operator_observed_file_success") }
if (-not $fileUploadOrSentRecordPresent) { $missing.Add("file_upload_or_sent_record") }
if (-not $fileUploadOrSentRecordPresentFlag) { $missing.Add("file_upload_or_sent_record_present") }
if (-not $beforeRecorderPresentFlag) { $missing.Add("before_recorder_present") }
if (-not $afterRecorderPresentFlag) { $missing.Add("after_recorder_present") }
if (-not $duplicateSecondFileSendAttemptedFalse) { $missing.Add("duplicate_second_file_send_attempted_false") }
if (-not $doNotSendSecondFileConfirmed) { $missing.Add("do_not_send_second_file_confirmed") }
if (-not $productionFileSendEnabledFalse) { $missing.Add("production_file_send_enabled_false") }
if (-not $hasBeforeProbe) { $missing.Add("before_recorder_output") }
if (-not $hasAfterProbe) { $missing.Add("after_recorder_output") }
$strictPass = (
$targetTypePresent -and
$targetIDPresent -and
$allowedDirPresent -and
$filePathPresent -and
$fileHashPresent -and
$fileSizePresent -and
$idempotencyKeyPresent -and
$operatorStartedAtLocalPresent -and
$operatorClickedSendFileAtLocalPresent -and
$operatorObservedFileSuccessAtLocalPresent -and
$manualStartPresent -and
$manualFinishPresent -and
$operatorObservedFileSuccess -and
$fileUploadOrSentRecordPresent -and
$fileUploadOrSentRecordPresentFlag -and
$beforeRecorderPresentFlag -and
$afterRecorderPresentFlag -and
$duplicateSecondFileSendAttemptedFalse -and
$doNotSendSecondFileConfirmed -and
$productionFileSendEnabledFalse -and
$hasBeforeProbe -and
$hasAfterProbe
)
$summary = [ordered]@{
ok = $true
package = $resolvedPackage
input_file_name = $inputsFile.Name
strict_gate_pass = $strictPass
target_type_present = $targetTypePresent
target_id_present = $targetIDPresent
allowed_dir_present = $allowedDirPresent
sandbox_file_path_present = $filePathPresent
file_sha256_present = $fileHashPresent
file_size_bytes_present = $fileSizePresent
idempotency_key_present = $idempotencyKeyPresent
operator_started_at_local_present = $operatorStartedAtLocalPresent
operator_clicked_send_file_at_local_present = $operatorClickedSendFileAtLocalPresent
operator_observed_file_success_at_local_present = $operatorObservedFileSuccessAtLocalPresent
manual_file_send_started_at_local_present = $manualStartPresent
manual_file_send_finished_at_local_present = $manualFinishPresent
operator_observed_file_success = $operatorObservedFileSuccess
file_upload_or_sent_record_present = $fileUploadOrSentRecordPresent
file_upload_or_sent_record_present_flag = $fileUploadOrSentRecordPresentFlag
before_recorder_present_flag = $beforeRecorderPresentFlag
after_recorder_present_flag = $afterRecorderPresentFlag
duplicate_second_file_send_attempted_false = $duplicateSecondFileSendAttemptedFalse
do_not_send_second_file_confirmed = $doNotSendSecondFileConfirmed
production_file_send_enabled = -not $productionFileSendEnabledFalse
has_before_probe = $hasBeforeProbe
has_after_probe = $hasAfterProbe
capability_test_ok = $capabilityOK
capability_tool_count = $capabilityToolCount
capability_send_file_preview_tool_present = $capabilitySendFilePreview
capability_send_file_production_enabled = $capabilityProductionFileEnabled
missing_for_full_gate = @($missing)
decision = if ($strictPass) { "strict_file_gate_pass" } else { "not_usable_for_production_file_send" }
}
$summary | ConvertTo-Json -Depth 6 -Compress
if ($Strict -and -not $strictPass) {
exit 1
}
}
finally {
if ($cleanup -and (Test-Path -LiteralPath $WorkDir)) {
Remove-Item -LiteralPath $WorkDir -Recurse -Force
}
}

View File

@@ -0,0 +1,102 @@
param(
[string]$OutputDir = "runs/send-file-sandbox-gate-package"
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$repo = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path
$packageScript = Join-Path $repo "scripts\package-send-file-sandbox-gate.ps1"
if (-not (Test-Path -LiteralPath $packageScript)) {
throw "missing package script: $packageScript"
}
$packageRoot = Join-Path $repo $OutputDir
$zipPath = "$packageRoot.zip"
if (Test-Path -LiteralPath $packageRoot) {
Remove-Item -LiteralPath $packageRoot -Recurse -Force
}
if (Test-Path -LiteralPath $zipPath) {
Remove-Item -LiteralPath $zipPath -Force
}
& powershell -NoProfile -ExecutionPolicy Bypass -File $packageScript -OutputDir $OutputDir
if ($LASTEXITCODE -ne 0) {
throw "package-send-file-sandbox-gate.ps1 failed with exit code $LASTEXITCODE"
}
$requiredFiles = @(
"README.txt",
"OPERATOR-FILE-STEPS.md",
"RETURN-FILE-CHECKLIST.md",
"FILE-SEND-INPUTS.schema.json",
"FILE-SEND-INPUTS.template.json",
"EXPECTED-FILE-RETURN-FILES.txt",
"RUN-FILE-RECORDING-SUITE.bat",
"01-run-before-file-recorder.bat",
"02-run-after-file-recorder.bat",
"03-create-file-return-zip.bat",
"FILE-RECORDING-PACKAGE-MANIFEST.json",
"run-before-file-recorder.bat",
"run-after-file-recorder.bat",
"CREATE-FILE-RETURN-ZIP.ps1",
"capability\isphere-capability-smoke.exe",
"recorder\ISphereLiveProbeRecorder.exe",
"recorder\variants\ISphereLiveProbeRecorder-x86.exe"
)
foreach ($relative in $requiredFiles) {
$path = Join-Path $packageRoot $relative
if (-not (Test-Path -LiteralPath $path)) {
throw "missing package file: $relative"
}
}
$instructionText = @(
Get-Content -LiteralPath (Join-Path $packageRoot "README.txt") -Raw
Get-Content -LiteralPath (Join-Path $packageRoot "OPERATOR-FILE-STEPS.md") -Raw
Get-Content -LiteralPath (Join-Path $packageRoot "RETURN-FILE-CHECKLIST.md") -Raw
Get-Content -LiteralPath (Join-Path $packageRoot "EXPECTED-FILE-RETURN-FILES.txt") -Raw
Get-Content -LiteralPath (Join-Path $packageRoot "FILE-SEND-INPUTS.template.json") -Raw
) -join "`n"
foreach ($needle in @(
"LOCAL_LOGIN_UNAVAILABLE",
"ONLINE_SANDBOX_REQUIRED",
"MANUAL_ONE_FILE_SEND_ONLY",
"DO_NOT_SEND_SECOND_FILE",
"RUN-FILE-RECORDING-SUITE.bat",
"FILE-SEND-INPUTS.json",
"ISPHERE_SEND_FILE_ALLOWED_DIR",
"sandbox_file_path",
"file_sha256",
"file_size_bytes",
"idempotency_key",
"operator_started_at_local",
"operator_clicked_send_file_at_local",
"operator_observed_file_success_at_local",
"before_recorder_present",
"after_recorder_present",
"file_upload_or_sent_record_present",
"duplicate_second_file_send_attempted",
"production_file_send_enabled"
)) {
if ($instructionText -notmatch [regex]::Escape($needle)) {
throw "package instructions missing required phrase: $needle"
}
}
if (-not (Test-Path -LiteralPath $zipPath)) {
throw "missing package zip: $zipPath"
}
[ordered]@{
ok = $true
package_dir = (Resolve-Path -LiteralPath $packageRoot).Path
zip = (Resolve-Path -LiteralPath $zipPath).Path
required_file_count = $requiredFiles.Count
local_login_required = $false
online_sandbox_required = $true
production_file_send_enabled = $false
} | ConvertTo-Json -Depth 4 -Compress