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

@@ -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