fix: treat Claude safeguards refusals as failures, reset the session

Claude Code returns "API Error: <model>'s safeguards flagged this message"
as a success-typed result. EJClaw delivered it as the owner's answer,
handed it to reviewer/arbiter, resumed the refused session (refused again)
and carried the banner forward into the next task.

Now it is a `safety-refusal` trigger: the raw banner is suppressed, the
Claude session is cleared, the paired task closes as
`claude_safety_refusal`, the room gets a short Korean notice, and refusal
banners are never carried forward. Global memory gains a rule not to read
thinking blocks from session transcripts (the reasoning_extraction trigger
of the 2026-10-12 incident).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-10-12 13:17:22 +09:00
parent e22feb0215
commit f579b4f406
11 changed files with 240 additions and 13 deletions

View File

@@ -32,6 +32,7 @@ Stored at `/home/claude/.config/ejclaw/secrets.json` (read with the Read tool wh
- All rooms are `tribunal` (owner + reviewer + arbiter) unless the user asks for single mode in that room ("리뷰어 끄자", "single로 바꿔줘"). Commands: `ops/ejclaw-ops.md`.
- "채널 등록 해제 <id>" means a full purge with `bun scripts/deregister-room.ts` (dry-run first, DB backup first). Details: `ops/ejclaw-ops.md`.
- A short stop-only message ("그만해", "멈춰", "중단", "stop") stops the room's running work; this is built in.
- Resuming interrupted work: rebuild context from chat messages, `conversations/`, git state and visible tool results only. Never read or dump `thinking` blocks from Claude session transcripts (`data/sessions/**/*.jsonl`); that trips Opus safeguards (`reasoning_extraction`) and the whole turn is refused (incident 2026-10-12).
# CLAUDE.md
@@ -44,6 +45,7 @@ Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-s
**Don't assume. Don't hide confusion. Surface tradeoffs.**
Before implementing:
- State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them - don't pick silently.
- If a simpler approach exists, say so. Push back when warranted.
@@ -66,12 +68,14 @@ Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, sim
**Touch only what you must. Clean up only your own mess.**
When editing existing code:
- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it - don't delete it.
When your changes create orphans:
- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.
@@ -82,11 +86,13 @@ The test: Every changed line should trace directly to the user's request.
**Define success criteria. Loop until verified.**
Transform tasks into verifiable goals:
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"
For multi-step tasks, state a brief plan:
```
1. [Step] → verify: [check]
2. [Step] → verify: [check]