{
  "version": 1,
  "cases": [
    {
      "id": "reader-discovers-tools",
      "category": "permission-boundaries",
      "principal": "reader",
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/list"
          },
          "expect": {
            "code": "OK",
            "effects": 0,
            "attempts": 1,
            "toolCount": 2
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "reader-reads-owned-note",
      "category": "permission-boundaries",
      "principal": "reader",
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "read_note",
              "arguments": {
                "path": "/workspace/note"
              }
            }
          },
          "expect": {
            "code": "OK",
            "effects": 0,
            "attempts": 1,
            "text": "original"
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "unknown-identity-denied",
      "category": "permission-boundaries",
      "principal": "unknown",
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "read_note",
              "arguments": {
                "path": "/workspace/note"
              }
            }
          },
          "expect": {
            "code": "DENIED",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "missing-identity-denied",
      "category": "permission-boundaries",
      "principal": null,
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note",
              "arguments": {
                "path": "/workspace/note",
                "text": "changed",
                "key": "one"
              }
            }
          },
          "expect": {
            "code": "DENIED",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "reader-write-denied-no-retry",
      "category": "denied-writes",
      "principal": "reader",
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note",
              "arguments": {
                "path": "/workspace/note",
                "text": "changed",
                "key": "one"
              }
            }
          },
          "expect": {
            "code": "DENIED",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 3
        },
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "read_note",
              "arguments": {
                "path": "/workspace/note"
              }
            }
          },
          "expect": {
            "code": "OK",
            "effects": 0,
            "attempts": 1,
            "text": "original"
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "traversal-write-rejected",
      "category": "denied-writes",
      "principal": "writer",
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note",
              "arguments": {
                "path": "/workspace/../secret",
                "text": "changed",
                "key": "one"
              }
            }
          },
          "expect": {
            "code": "INVALID_PARAMS",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "authority-in-arguments-rejected",
      "category": "denied-writes",
      "principal": "reader",
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note",
              "arguments": {
                "path": "/workspace/note",
                "text": "changed",
                "key": "one",
                "principal": "writer"
              }
            }
          },
          "expect": {
            "code": "INVALID_PARAMS",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "malformed-json-rejected",
      "category": "malformed-input",
      "principal": "reader",
      "transientFailures": 0,
      "steps": [
        {
          "request": "{bad json",
          "expect": {
            "code": "PARSE_ERROR",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "wrong-rpc-version-rejected",
      "category": "malformed-input",
      "principal": "reader",
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "1.0",
            "id": 1,
            "method": "tools/list"
          },
          "expect": {
            "code": "INVALID_REQUEST",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "missing-arguments-rejected",
      "category": "malformed-input",
      "principal": "writer",
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note"
            }
          },
          "expect": {
            "code": "INVALID_PARAMS",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "wrong-argument-type-rejected",
      "category": "malformed-input",
      "principal": "writer",
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note",
              "arguments": {
                "path": "/workspace/note",
                "text": 1,
                "key": "one"
              }
            }
          },
          "expect": {
            "code": "INVALID_PARAMS",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "unknown-tool-rejected",
      "category": "malformed-input",
      "principal": "writer",
      "transientFailures": 0,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "delete_everything",
              "arguments": {
                "path": "/workspace/note"
              }
            }
          },
          "expect": {
            "code": "UNKNOWN_TOOL",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "read-retries-once-then-succeeds",
      "category": "retries",
      "principal": "reader",
      "transientFailures": 1,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "read_note",
              "arguments": {
                "path": "/workspace/note"
              }
            }
          },
          "expect": {
            "code": "OK",
            "effects": 0,
            "attempts": 2,
            "text": "original"
          },
          "maxAttempts": 2
        }
      ]
    },
    {
      "id": "read-retry-budget-exhausted",
      "category": "retries",
      "principal": "reader",
      "transientFailures": 3,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "read_note",
              "arguments": {
                "path": "/workspace/note"
              }
            }
          },
          "expect": {
            "code": "UNAVAILABLE",
            "effects": 0,
            "attempts": 2
          },
          "maxAttempts": 2
        }
      ]
    },
    {
      "id": "write-never-automatically-retried",
      "category": "retries",
      "principal": "writer",
      "transientFailures": 1,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note",
              "arguments": {
                "path": "/workspace/note",
                "text": "changed",
                "key": "one"
              }
            }
          },
          "expect": {
            "code": "UNAVAILABLE",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 3
        },
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "read_note",
              "arguments": {
                "path": "/workspace/note"
              }
            }
          },
          "expect": {
            "code": "OK",
            "effects": 0,
            "attempts": 1,
            "text": "original"
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "read-recovers-after-exhausted-budget",
      "category": "recovery",
      "principal": "reader",
      "transientFailures": 2,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "read_note",
              "arguments": {
                "path": "/workspace/note"
              }
            }
          },
          "expect": {
            "code": "UNAVAILABLE",
            "effects": 0,
            "attempts": 2
          },
          "maxAttempts": 2
        },
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "read_note",
              "arguments": {
                "path": "/workspace/note"
              }
            }
          },
          "expect": {
            "code": "OK",
            "effects": 0,
            "attempts": 1,
            "text": "original"
          },
          "maxAttempts": 1
        }
      ]
    },
    {
      "id": "explicit-write-recovery-and-deduplication",
      "category": "recovery",
      "principal": "writer",
      "transientFailures": 1,
      "steps": [
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note",
              "arguments": {
                "path": "/workspace/note",
                "text": "changed",
                "key": "one"
              }
            }
          },
          "expect": {
            "code": "UNAVAILABLE",
            "effects": 0,
            "attempts": 1
          },
          "maxAttempts": 1
        },
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note",
              "arguments": {
                "path": "/workspace/note",
                "text": "changed",
                "key": "one"
              }
            }
          },
          "expect": {
            "code": "OK",
            "effects": 1,
            "attempts": 1,
            "text": "changed"
          },
          "maxAttempts": 1
        },
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note",
              "arguments": {
                "path": "/workspace/note",
                "text": "changed",
                "key": "one"
              }
            }
          },
          "expect": {
            "code": "OK",
            "effects": 1,
            "attempts": 1,
            "text": "changed"
          },
          "maxAttempts": 1
        },
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "write_note",
              "arguments": {
                "path": "/workspace/note",
                "text": "different",
                "key": "one"
              }
            }
          },
          "expect": {
            "code": "KEY_CONFLICT",
            "effects": 1,
            "attempts": 1
          },
          "maxAttempts": 1
        },
        {
          "request": {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
              "name": "read_note",
              "arguments": {
                "path": "/workspace/note"
              }
            }
          },
          "expect": {
            "code": "OK",
            "effects": 1,
            "attempts": 1,
            "text": "changed"
          },
          "maxAttempts": 1
        }
      ]
    }
  ]
}
