chore: harden send sandbox evidence package v2
This commit is contained in:
@@ -60,7 +60,7 @@ Required rule:
|
||||
- Fill success_ack_or_sent_record after the operator sees the sent message, ack, or local sent record.
|
||||
|
||||
Return:
|
||||
- run make-return-zip.ps1 and send back the generated zip.
|
||||
- run CREATE-RETURN-ZIP.ps1 and send back the generated zip.
|
||||
- preferred one-file flow: run RUN-RECORDING-SUITE.bat and follow the pauses.
|
||||
'@ | Set-Content -LiteralPath (Join-Path $packageDir "README.txt") -Encoding UTF8
|
||||
|
||||
@@ -108,6 +108,13 @@ Run `RUN-RECORDING-SUITE.bat`. It will run the before recorder, pause for the ma
|
||||
2. Send it only to the declared sandbox target.
|
||||
3. Do not send a second copy.
|
||||
4. Fill these fields in `SANDBOX-SEND-INPUTS.json`:
|
||||
- `operator_started_at_local`
|
||||
- `operator_clicked_send_at_local`
|
||||
- `operator_observed_success_at_local`
|
||||
- `before_recorder_present`
|
||||
- `after_recorder_present`
|
||||
- `success_ack_or_sent_record_present`
|
||||
- `duplicate_second_send_attempted`
|
||||
- `manual_send_started_at_local`
|
||||
- `manual_send_finished_at_local`
|
||||
- `operator_observed_success`
|
||||
@@ -123,7 +130,7 @@ Run `run-after-recorder.bat`.
|
||||
Run:
|
||||
|
||||
```powershell
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File .\make-return-zip.ps1
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File .\CREATE-RETURN-ZIP.ps1
|
||||
```
|
||||
|
||||
Send back the generated zip file.
|
||||
@@ -139,6 +146,7 @@ The returned evidence should contain:
|
||||
- completed `SANDBOX-SEND-INPUTS.json`;
|
||||
- success_ack_or_sent_record text;
|
||||
- confirmation that there was no second send.
|
||||
- strict-v2 fields proving before/after recorder presence and manual send timestamps.
|
||||
|
||||
The repository must keep production send disabled until this evidence is reviewed.
|
||||
'@ | Set-Content -LiteralPath (Join-Path $packageDir "OPERATOR-STEPS.md") -Encoding UTF8
|
||||
@@ -155,6 +163,13 @@ The repository must keep production send disabled until this evidence is reviewe
|
||||
"content_text_to_send": "<exact one-time sandbox message text>",
|
||||
"content_sha256": "<sha256 hex of content_text_to_send>",
|
||||
"idempotency_key": "<one unique idempotency key>",
|
||||
"operator_started_at_local": "",
|
||||
"operator_clicked_send_at_local": "",
|
||||
"operator_observed_success_at_local": "",
|
||||
"before_recorder_present": false,
|
||||
"after_recorder_present": false,
|
||||
"success_ack_or_sent_record_present": false,
|
||||
"duplicate_second_send_attempted": false,
|
||||
"manual_send_started_at_local": "",
|
||||
"manual_send_finished_at_local": "",
|
||||
"operator_observed_success": false,
|
||||
@@ -164,6 +179,66 @@ The repository must keep production send disabled until this evidence is reviewe
|
||||
}
|
||||
'@ | Set-Content -LiteralPath (Join-Path $packageDir "SANDBOX-SEND-INPUTS.template.json") -Encoding UTF8
|
||||
|
||||
@'
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "iSphere R6j sandbox send inputs",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"sandbox_target_type",
|
||||
"sandbox_target_id",
|
||||
"content_text_to_send",
|
||||
"content_sha256",
|
||||
"idempotency_key",
|
||||
"operator_started_at_local",
|
||||
"operator_clicked_send_at_local",
|
||||
"operator_observed_success_at_local",
|
||||
"before_recorder_present",
|
||||
"after_recorder_present",
|
||||
"success_ack_or_sent_record_present",
|
||||
"duplicate_second_send_attempted"
|
||||
],
|
||||
"properties": {
|
||||
"sandbox_target_type": { "type": "string" },
|
||||
"sandbox_target_id": { "type": "string" },
|
||||
"content_text_to_send": { "type": "string" },
|
||||
"content_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
||||
"idempotency_key": { "type": "string" },
|
||||
"operator_started_at_local": { "type": "string" },
|
||||
"operator_clicked_send_at_local": { "type": "string" },
|
||||
"operator_observed_success_at_local": { "type": "string" },
|
||||
"before_recorder_present": { "type": "boolean" },
|
||||
"after_recorder_present": { "type": "boolean" },
|
||||
"success_ack_or_sent_record_present": { "type": "boolean" },
|
||||
"duplicate_second_send_attempted": { "type": "boolean" }
|
||||
}
|
||||
}
|
||||
'@ | Set-Content -LiteralPath (Join-Path $packageDir "SANDBOX-SEND-INPUTS.schema.json") -Encoding UTF8
|
||||
|
||||
@'
|
||||
# RETURN-CHECKLIST-V2
|
||||
|
||||
Fill `SANDBOX-SEND-INPUTS.json` and run `CREATE-RETURN-ZIP.ps1`.
|
||||
|
||||
Strict-v2 required fields:
|
||||
|
||||
- `operator_started_at_local`: local time when the full operator flow started.
|
||||
- `operator_clicked_send_at_local`: local time when the operator clicked or confirmed the one manual send.
|
||||
- `operator_observed_success_at_local`: local time when the operator observed success, ack, or a local sent record.
|
||||
- `before_recorder_present`: set true after `return-evidence\before` is generated.
|
||||
- `after_recorder_present`: set true after `return-evidence\after` is generated.
|
||||
- `success_ack_or_sent_record_present`: set true when `success_ack_or_sent_record` is filled.
|
||||
- `duplicate_second_send_attempted`: must be false.
|
||||
|
||||
Return rule:
|
||||
|
||||
- One sandbox target only.
|
||||
- One content hash only.
|
||||
- One idempotency key only.
|
||||
- Do not send a second copy.
|
||||
- `CREATE-RETURN-ZIP.ps1` refuses to build a return zip when after-recorder output or strict-v2 fields are missing.
|
||||
'@ | Set-Content -LiteralPath (Join-Path $packageDir "RETURN-CHECKLIST-V2.md") -Encoding UTF8
|
||||
|
||||
@'
|
||||
Expected return files for R6c:
|
||||
|
||||
@@ -174,6 +249,13 @@ Expected return files for R6c:
|
||||
- MANUAL_ONE_SEND_ONLY is true.
|
||||
- DO_NOT_SEND_SECOND_TIME is true.
|
||||
- do_not_send_second_time_confirmed is true.
|
||||
- operator_started_at_local is filled.
|
||||
- operator_clicked_send_at_local is filled.
|
||||
- operator_observed_success_at_local is filled.
|
||||
- before_recorder_present is true.
|
||||
- after_recorder_present is true.
|
||||
- success_ack_or_sent_record_present is true.
|
||||
- duplicate_second_send_attempted is false.
|
||||
|
||||
2. return-evidence/before/*
|
||||
- Read-only recorder output before manual send.
|
||||
@@ -181,7 +263,7 @@ Expected return files for R6c:
|
||||
3. return-evidence/after/*
|
||||
- Read-only recorder output after manual send.
|
||||
|
||||
4. The generated zip from make-return-zip.ps1.
|
||||
4. The generated zip from CREATE-RETURN-ZIP.ps1.
|
||||
|
||||
Decision rule:
|
||||
- If success_ack_or_sent_record is missing, production send remains blocked.
|
||||
@@ -254,6 +336,11 @@ $inputs = Join-Path $root "SANDBOX-SEND-INPUTS.json"
|
||||
if (-not (Test-Path -LiteralPath $inputs)) {
|
||||
throw "missing SANDBOX-SEND-INPUTS.json; copy the template and fill it first"
|
||||
}
|
||||
$json = Get-Content -LiteralPath $inputs -Raw | ConvertFrom-Json
|
||||
function Test-NonEmptyString($Value) {
|
||||
if ($null -eq $Value) { return $false }
|
||||
return -not [string]::IsNullOrWhiteSpace([string]$Value)
|
||||
}
|
||||
$before = Join-Path $root "return-evidence\before"
|
||||
$after = Join-Path $root "return-evidence\after"
|
||||
if (-not (Test-Path -LiteralPath $before)) {
|
||||
@@ -262,13 +349,40 @@ if (-not (Test-Path -LiteralPath $before)) {
|
||||
if (-not (Test-Path -LiteralPath $after)) {
|
||||
throw "missing after recorder output: $after"
|
||||
}
|
||||
if (@(Get-ChildItem -LiteralPath $before -Recurse -File -ErrorAction SilentlyContinue).Count -eq 0) {
|
||||
throw "before recorder output is empty: $before"
|
||||
}
|
||||
if (@(Get-ChildItem -LiteralPath $after -Recurse -File -ErrorAction SilentlyContinue).Count -eq 0) {
|
||||
throw "after recorder output is empty: $after"
|
||||
}
|
||||
foreach ($field in @("sandbox_target_type","sandbox_target_id","content_sha256","idempotency_key","operator_started_at_local","operator_clicked_send_at_local","operator_observed_success_at_local","success_ack_or_sent_record")) {
|
||||
if (-not (Test-NonEmptyString $json.$field)) {
|
||||
throw "missing strict-v2 field: $field"
|
||||
}
|
||||
}
|
||||
if ($json.before_recorder_present -ne $true) {
|
||||
throw "before_recorder_present must be true"
|
||||
}
|
||||
if ($json.after_recorder_present -ne $true) {
|
||||
throw "after_recorder_present must be true"
|
||||
}
|
||||
if ($json.success_ack_or_sent_record_present -ne $true) {
|
||||
throw "success_ack_or_sent_record_present must be true"
|
||||
}
|
||||
if ($json.duplicate_second_send_attempted -ne $false) {
|
||||
throw "duplicate_second_send_attempted must be false"
|
||||
}
|
||||
if ($json.do_not_send_second_time_confirmed -ne $true) {
|
||||
throw "do_not_send_second_time_confirmed must be true"
|
||||
}
|
||||
|
||||
$stamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||
$zip = Join-Path $root ("isphere-send-sandbox-return-" + $stamp + ".zip")
|
||||
$items = @(
|
||||
$inputs,
|
||||
(Join-Path $root "return-evidence"),
|
||||
(Join-Path $root "EXPECTED-RETURN-FILES.txt")
|
||||
(Join-Path $root "EXPECTED-RETURN-FILES.txt"),
|
||||
(Join-Path $root "RETURN-CHECKLIST-V2.md")
|
||||
)
|
||||
Compress-Archive -Path $items -DestinationPath $zip -Force
|
||||
[ordered]@{
|
||||
@@ -276,14 +390,24 @@ Compress-Archive -Path $items -DestinationPath $zip -Force
|
||||
zip = $zip
|
||||
production_send_enabled = $false
|
||||
online_sandbox_required = $true
|
||||
strict_v2_return = $true
|
||||
} | ConvertTo-Json -Depth 4 -Compress
|
||||
'@ | Set-Content -LiteralPath (Join-Path $packageDir "CREATE-RETURN-ZIP.ps1") -Encoding ASCII
|
||||
|
||||
@'
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
& (Join-Path $root "CREATE-RETURN-ZIP.ps1")
|
||||
exit $LASTEXITCODE
|
||||
'@ | Set-Content -LiteralPath (Join-Path $packageDir "make-return-zip.ps1") -Encoding ASCII
|
||||
|
||||
@'
|
||||
@echo off
|
||||
setlocal
|
||||
cd /d "%~dp0"
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0make-return-zip.ps1"
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0CREATE-RETURN-ZIP.ps1"
|
||||
echo exit code: %ERRORLEVEL%
|
||||
pause
|
||||
exit /b %ERRORLEVEL%
|
||||
@@ -307,7 +431,7 @@ echo Step 3: AFTER read-only recorder.
|
||||
call "%~dp0run-after-recorder.bat"
|
||||
echo.
|
||||
echo Step 4: make return zip.
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0make-return-zip.ps1"
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0CREATE-RETURN-ZIP.ps1"
|
||||
echo exit code: %ERRORLEVEL%
|
||||
pause
|
||||
exit /b %ERRORLEVEL%
|
||||
@@ -328,6 +452,9 @@ exit /b %ERRORLEVEL%
|
||||
],
|
||||
"recorder": "recorder/ISphereLiveProbeRecorder.exe",
|
||||
"return_inputs": "SANDBOX-SEND-INPUTS.json",
|
||||
"return_schema": "SANDBOX-SEND-INPUTS.schema.json",
|
||||
"return_checklist_v2": "RETURN-CHECKLIST-V2.md",
|
||||
"return_zip_script": "CREATE-RETURN-ZIP.ps1",
|
||||
"production_send_enabled": false
|
||||
}
|
||||
'@ | Set-Content -LiteralPath (Join-Path $packageDir "RECORDING-PACKAGE-MANIFEST.json") -Encoding ASCII
|
||||
|
||||
Reference in New Issue
Block a user