feat: centralize send message production gate

This commit is contained in:
zhaoyilun
2026-07-10 20:35:46 +08:00
parent 2a7087218b
commit b08b0e01bd
7 changed files with 187 additions and 22 deletions

View File

@@ -58,7 +58,7 @@ N13/N14/N15 are pre-business validation results. They can help identify UI eleme
## Current loop
Current loop: `R6g send audit and idempotency replay diagnostics complete; next R6h central production gate policy for send message`.
Current loop: `R6h central production gate policy for send message complete; next R6i B-route connector adapter shell`.
Active continuous execution plan: `docs/superpowers/plans/2026-07-10-r6f-r14-continuous-execution-plan.md`.
@@ -239,8 +239,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`.
- 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.
- Last completed round: R6g send audit and idempotency replay diagnostics.
- Next active round: R6h central production gate policy for send message.
- Last completed round: R6h central production gate policy for send message.
- Next active round: R6i B-route connector adapter shell.
R6g send audit and idempotency replay diagnostics is complete:
@@ -250,3 +250,12 @@ R6g send audit and idempotency replay diagnostics is complete:
- Added `TestISphereSendMessageAuditRedactionIsStable` proving file-backed audit JSONL does not store raw message body or raw idempotency key.
- Standard verification still reports 9 tools and `production_send_enabled=false`.
- Next node: R6h central production gate policy for send message.
R6h central production gate policy for send message is complete:
- Added `SendMessageGatePolicy` and `LoadSendMessageGatePolicy`.
- Gate reason codes are now explicit: `send_disabled_by_default`, `send_evidence_missing`, `send_connector_missing`, and `send_gate_passed`.
- Default production-blocked `isphere_send_message` responses and audit events include `gate_reason_code` and `gate_reason_message`.
- `ISPHERE_SEND_PRODUCTION_ENABLED=1` is recognized by policy tests, but it is not enough by itself; evidence and connector gates must also pass.
- Standard verification still reports 9 tools and `production_send_enabled=false`.
- Next node: R6i B-route connector adapter shell.

View File

@@ -285,6 +285,15 @@ powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-send-audit-id
The diagnostic prints sanitized counts and booleans: `audit_records`, `idempotency_records`, `duplicate_detected`, `conflict_detected`, `raw_body_present`, and `raw_idempotency_key_present`. It exits non-zero if a raw message body field or raw idempotency-key field is found.
R6h centralizes the production-send gate. Default `execution_mode="production"` responses include machine-readable `gate_reason_code` and `gate_reason_message`. The valid gate codes are:
- `send_disabled_by_default`
- `send_evidence_missing`
- `send_connector_missing`
- `send_gate_passed`
`ISPHERE_SEND_PRODUCTION_ENABLED=1` is recognized by the gate policy, but it is not sufficient by itself: the evidence gate and connector gate must also pass before production can be allowed. In the default MCP server path, `production_send_enabled` remains `false`.
## 10. Current tool surface and next-stage route
The current runbook verifies nine tools:

View File

@@ -239,7 +239,7 @@ git push gitea main
- Produces: `LoadSendMessageGatePolicy(env map[string]string, evidenceGatePass bool, connectorConfigured bool) SendMessageGatePolicy`.
- Valid reason codes: `send_evidence_missing`, `send_connector_missing`, `send_disabled_by_default`, `send_gate_passed`.
- [ ] **Step 1: Write table tests**
- [x] **Step 1: Write table tests**
Create `TestLoadSendMessageGatePolicy` with cases for default disabled, env set but evidence missing, evidence pass but connector missing, and all pass.
@@ -249,15 +249,15 @@ go test ./internal/tools -run TestLoadSendMessageGatePolicy -v
Expected before implementation: FAIL because the gate type does not exist.
- [ ] **Step 2: Implement gate policy**
- [x] **Step 2: Implement gate policy**
Create `send_message_gate.go` with the exact type/function and reason-code order from the test.
- [ ] **Step 3: Route blocked production through the gate**
- [x] **Step 3: Route blocked production through the gate**
Modify `isphere_send_message.go` so blocked production responses include `gate_reason_code` and `gate_reason_message` from `SendMessageGatePolicy`.
- [ ] **Step 4: Verify and commit**
- [x] **Step 4: Verify and commit**
```powershell
git diff --check
@@ -272,6 +272,13 @@ git push gitea main
**Acceptance gate:** The default runtime stays blocked, but the response explains the exact reason in machine-readable fields.
**R6h Result:**
- Added `internal/tools/send_message_gate.go` with `SendMessageGatePolicy` and `LoadSendMessageGatePolicy`.
- Added table tests for `send_disabled_by_default`, `send_evidence_missing`, `send_connector_missing`, and `send_gate_passed`.
- Default `isphere_send_message` production-blocked responses and audit events now include `gate_reason_code` and `gate_reason_message`.
- `ISPHERE_SEND_PRODUCTION_ENABLED=1` is recognized by policy tests, but the default MCP runtime still has no real connector and reports `production_send_enabled=false`.
---
### R6i: B-route connector adapter shell