4 stories
·
0 followers

When TCP sockets refuse to die

1 Comment and 3 Shares
When TCP sockets refuse to die

While working on our Spectrum server, we noticed something weird: the TCP sockets which we thought should have been closed were lingering around. We realized we don't really understand when TCP sockets are supposed to time out!

When TCP sockets refuse to die

Image by Sergiodc2 CC BY SA 3.0

In our code, we wanted to make sure we don't hold connections to dead hosts. In our early code we naively thought enabling TCP keepalives would be enough... but it isn't. It turns out a fairly modern TCP_USER_TIMEOUT socket option is equally as important. Furthermore it interacts with TCP keepalives in subtle ways. Many people are confused by this.

In this blog post, we'll try to show how these options work. We'll show how a TCP socket can timeout during various stages of its lifetime, and how TCP keepalives and user timeout influence that. To better illustrate the internals of TCP connections, we'll mix the outputs of the tcpdump and the ss -o commands. This nicely shows the transmitted packets and the changing parameters of the TCP connections.

SYN-SENT

Let's start from the simplest case - what happens when one attempts to establish a connection to a server which discards inbound SYN packets?

The scripts used here are available on our Github.

$ sudo ./test-syn-sent.py
# all packets dropped
00:00.000 IP host.2 > host.1: Flags [S] # initial SYN

State    Recv-Q Send-Q Local:Port Peer:Port
SYN-SENT 0      1      host:2     host:1    timer:(on,940ms,0)

00:01.028 IP host.2 > host.1: Flags [S] # first retry
00:03.044 IP host.2 > host.1: Flags [S] # second retry
00:07.236 IP host.2 > host.1: Flags [S] # third retry
00:15.427 IP host.2 > host.1: Flags [S] # fourth retry
00:31.560 IP host.2 > host.1: Flags [S] # fifth retry
01:04.324 IP host.2 > host.1: Flags [S] # sixth retry
02:10.000 connect ETIMEDOUT

Ok, this was easy. After the connect() syscall, the operating system sends a SYN packet. Since it didn't get any response the OS will by default retry sending it 6 times. This can be tweaked by the sysctl:

$ sysctl net.ipv4.tcp_syn_retries
net.ipv4.tcp_syn_retries = 6

It's possible to overwrite this setting per-socket with the TCP_SYNCNT setsockopt:

setsockopt(sd, IPPROTO_TCP, TCP_SYNCNT, 6);

The retries are staggered at 1s, 3s, 7s, 15s, 31s, 63s marks (the inter-retry time starts at 2s and then doubles each time). By default the whole process takes 130 seconds, until the kernel gives up with the ETIMEDOUT errno. At this moment in the lifetime of a connection, SO_KEEPALIVE settings are ignored, but TCP_USER_TIMEOUT is not. For example, setting it to 5000ms, will cause the following interaction:

$ sudo ./test-syn-sent.py 5000
# all packets dropped
00:00.000 IP host.2 > host.1: Flags [S] # initial SYN

State    Recv-Q Send-Q Local:Port Peer:Port
SYN-SENT 0      1      host:2     host:1    timer:(on,996ms,0)

00:01.016 IP host.2 > host.1: Flags [S] # first retry
00:03.032 IP host.2 > host.1: Flags [S] # second retry
00:05.016 IP host.2 > host.1: Flags [S] # what is this?
00:05.024 IP host.2 > host.1: Flags [S] # what is this?
00:05.036 IP host.2 > host.1: Flags [S] # what is this?
00:05.044 IP host.2 > host.1: Flags [S] # what is this?
00:05.050 connect ETIMEDOUT

Even though we set user-timeout to 5s, we still saw the six SYN retries on the wire. This behaviour is probably a bug (as tested on 5.2 kernel): we would expect only two retries to be sent - at 1s and 3s marks and the socket to expire at 5s mark. Instead we saw this, but also we saw further 4 retransmitted SYN packets aligned to 5s mark - which makes no sense. Anyhow, we learned a thing - the TCP_USER_TIMEOUT does affect the behaviour of connect().

SYN-RECV

SYN-RECV sockets are usually hidden from the application. They live as mini-sockets on the SYN queue. We wrote about the SYN and Accept queues in the past. Sometimes, when SYN cookies are enabled, the sockets may skip the SYN-RECV state altogether.

In SYN-RECV state, the socket will retry sending SYN+ACK 5 times as controlled by:

$ sysctl net.ipv4.tcp_synack_retries
net.ipv4.tcp_synack_retries = 5

Here is how it looks on the wire:

$ sudo ./test-syn-recv.py
00:00.000 IP host.2 > host.1: Flags [S]
# all subsequent packets dropped
00:00.000 IP host.1 > host.2: Flags [S.] # initial SYN+ACK

State    Recv-Q Send-Q Local:Port Peer:Port
SYN-RECV 0      0      host:1     host:2    timer:(on,996ms,0)

00:01.033 IP host.1 > host.2: Flags [S.] # first retry
00:03.045 IP host.1 > host.2: Flags [S.] # second retry
00:07.301 IP host.1 > host.2: Flags [S.] # third retry
00:15.493 IP host.1 > host.2: Flags [S.] # fourth retry
00:31.621 IP host.1 > host.2: Flags [S.] # fifth retry
01:04:610 SYN-RECV disappears

With default settings, the SYN+ACK is re-transmitted at 1s, 3s, 7s, 15s, 31s marks, and the SYN-RECV socket disappears at the 64s mark.

Neither SO_KEEPALIVE nor TCP_USER_TIMEOUT affect the lifetime of SYN-RECV sockets.

Final handshake ACK

After receiving the second packet in the TCP handshake - the SYN+ACK - the client socket moves to an ESTABLISHED state. The server socket remains in SYN-RECV until it receives the final ACK packet.

Losing this ACK doesn't change anything - the server socket will just take a bit longer to move from SYN-RECV to ESTAB. Here is how it looks:

00:00.000 IP host.2 > host.1: Flags [S]
00:00.000 IP host.1 > host.2: Flags [S.]
00:00.000 IP host.2 > host.1: Flags [.] # initial ACK, dropped

State    Recv-Q Send-Q Local:Port  Peer:Port
SYN-RECV 0      0      host:1      host:2 timer:(on,1sec,0)
ESTAB    0      0      host:2      host:1

00:01.014 IP host.1 > host.2: Flags [S.]
00:01.014 IP host.2 > host.1: Flags [.]  # retried ACK, dropped

State    Recv-Q Send-Q Local:Port Peer:Port
SYN-RECV 0      0      host:1     host:2    timer:(on,1.012ms,1)
ESTAB    0      0      host:2     host:1

As you can see SYN-RECV, has the "on" timer, the same as in example before. We might argue this final ACK doesn't really carry much weight. This thinking lead to the development of TCP_DEFER_ACCEPT feature - it basically causes the third ACK to be silently dropped. With this flag set the socket remains in SYN-RECV state until it receives the first packet with actual data:

$ sudo ./test-syn-ack.py
00:00.000 IP host.2 > host.1: Flags [S]
00:00.000 IP host.1 > host.2: Flags [S.]
00:00.000 IP host.2 > host.1: Flags [.] # delivered, but the socket stays as SYN-RECV

State    Recv-Q Send-Q Local:Port Peer:Port
SYN-RECV 0      0      host:1     host:2    timer:(on,7.192ms,0)
ESTAB    0      0      host:2     host:1

00:08.020 IP host.2 > host.1: Flags [P.], length 11  # payload moves the socket to ESTAB

State Recv-Q Send-Q Local:Port Peer:Port
ESTAB 11     0      host:1     host:2
ESTAB 0      0      host:2     host:1

The server socket remained in the SYN-RECV state even after receiving the final TCP-handshake ACK. It has a funny "on" timer, with the counter stuck at 0 retries. It is converted to ESTAB - and moved from the SYN to the accept queue - after the client sends a data packet or after the TCP_DEFER_ACCEPT timer expires. Basically, with DEFER ACCEPT the SYN-RECV mini-socket discards the data-less inbound ACK.

Idle ESTAB is forever

Let's move on and discuss a fully-established socket connected to an unhealthy (dead) peer. After completion of the handshake, the sockets on both sides move to the ESTABLISHED state, like:

State Recv-Q Send-Q Local:Port Peer:Port
ESTAB 0      0      host:2     host:1
ESTAB 0      0      host:1     host:2

These sockets have no running timer by default - they will remain in that state forever, even if the communication is broken. The TCP stack will notice problems only when one side attempts to send something. This raises a question - what to do if you don't plan on sending any data over a connection? How do you make sure an idle connection is healthy, without sending any data over it?

This is where TCP keepalives come in. Let's see it in action - in this example we used the following toggles:

  • SO_KEEPALIVE = 1 - Let's enable keepalives.
  • TCP_KEEPIDLE = 5 - Send first keepalive probe after 5 seconds of idleness.
  • TCP_KEEPINTVL = 3 - Send subsequent keepalive probes after 3 seconds.
  • TCP_KEEPCNT = 3 - Time out after three failed probes.
$ sudo ./test-idle.py
00:00.000 IP host.2 > host.1: Flags [S]
00:00.000 IP host.1 > host.2: Flags [S.]
00:00.000 IP host.2 > host.1: Flags [.]

State Recv-Q Send-Q Local:Port Peer:Port
ESTAB 0      0      host:1     host:2
ESTAB 0      0      host:2     host:1  timer:(keepalive,2.992ms,0)

# all subsequent packets dropped
00:05.083 IP host.2 > host.1: Flags [.], ack 1 # first keepalive probe
00:08.155 IP host.2 > host.1: Flags [.], ack 1 # second keepalive probe
00:11.231 IP host.2 > host.1: Flags [.], ack 1 # third keepalive probe
00:14.299 IP host.2 > host.1: Flags [R.], seq 1, ack 1

Indeed! We can clearly see the first probe sent at the 5s mark, two remaining probes 3s apart - exactly as we specified. After a total of three sent probes, and a further three seconds of delay, the connection dies with ETIMEDOUT, and final the RST is transmitted.

For keepalives to work, the send buffer must be empty. You can notice the keepalive timer active in the "timer:(keepalive)" line.

Keepalives with TCP_USER_TIMEOUT are confusing

We mentioned the TCP_USER_TIMEOUT option before. It sets the maximum amount of time that transmitted data may remain unacknowledged before the kernel forcefully closes the connection. On its own, it doesn't do much in the case of idle connections. The sockets will remain ESTABLISHED even if the connectivity is dropped. However, this socket option does change the semantics of TCP keepalives. The tcp(7) manpage is somewhat confusing:

Moreover, when used with the TCP keepalive (SO_KEEPALIVE) option, TCP_USER_TIMEOUT will override keepalive to determine when to close a connection due to keepalive failure.

The original commit message has slightly more detail:

To understand the semantics, we need to look at the kernel code in linux/net/ipv4/tcp_timer.c:693:

if ((icsk->icsk_user_timeout != 0 &&
    elapsed >= msecs_to_jiffies(icsk->icsk_user_timeout) &&
    icsk->icsk_probes_out > 0) ||

For the user timeout to have any effect, the icsk_probes_out must not be zero. The check for user timeout is done only after the first probe went out. Let's check it out. Our connection settings:

  • TCP_USER_TIMEOUT = 5*1000 - 5 seconds
  • SO_KEEPALIVE = 1 - enable keepalives
  • TCP_KEEPIDLE = 1 - send first probe quickly - 1 second idle
  • TCP_KEEPINTVL = 11 - subsequent probes every 11 seconds
  • TCP_KEEPCNT = 3 - send three probes before timing out
00:00.000 IP host.2 > host.1: Flags [S]
00:00.000 IP host.1 > host.2: Flags [S.]
00:00.000 IP host.2 > host.1: Flags [.]

# all subsequent packets dropped
00:01.001 IP host.2 > host.1: Flags [.], ack 1 # first probe
00:12.233 IP host.2 > host.1: Flags [R.] # timer for second probe fired, socket aborted due to TCP_USER_TIMEOUT

So what happened? The connection sent the first keepalive probe at the 1s mark. Seeing no response the TCP stack then woke up 11 seconds later to send a second probe. This time though, it executed the USER_TIMEOUT code path, which decided to terminate the connection immediately.

What if we bump TCP_USER_TIMEOUT to larger values, say between the second and third probe? Then, the connection will be closed on the third probe timer. With TCP_USER_TIMEOUT set to 12.5s:

00:01.022 IP host.2 > host.1: Flags [.] # first probe
00:12.094 IP host.2 > host.1: Flags [.] # second probe
00:23.102 IP host.2 > host.1: Flags [R.] # timer for third probe fired, socket aborted due to TCP_USER_TIMEOUT

We’ve shown how TCP_USER_TIMEOUT interacts with keepalives for small and medium values. The last case is when TCP_USER_TIMEOUT is extraordinarily large. Say we set it to 30s:

00:01.027 IP host.2 > host.1: Flags [.], ack 1 # first probe
00:12.195 IP host.2 > host.1: Flags [.], ack 1 # second probe
00:23.207 IP host.2 > host.1: Flags [.], ack 1 # third probe
00:34.211 IP host.2 > host.1: Flags [.], ack 1 # fourth probe! But TCP_KEEPCNT was only 3!
00:45.219 IP host.2 > host.1: Flags [.], ack 1 # fifth probe!
00:56.227 IP host.2 > host.1: Flags [.], ack 1 # sixth probe!
01:07.235 IP host.2 > host.1: Flags [R.], seq 1 # TCP_USER_TIMEOUT aborts conn on 7th probe timer

We saw six keepalive probes on the wire! With TCP_USER_TIMEOUT set, the TCP_KEEPCNT is totally ignored. If you want TCP_KEEPCNT to make sense, the only sensible USER_TIMEOUT value is slightly smaller than:

TCP_KEEPIDLE + TCP_KEEPINTVL * TCP_KEEPCNT

Busy ESTAB socket is not forever

Thus far we have discussed the case where the connection is idle. Different rules apply when the connection has unacknowledged data in a send buffer.

Let's prepare another experiment - after the three-way handshake, let's set up a firewall to drop all packets. Then, let's do a send on one end to have some dropped packets in-flight. An experiment shows the sending socket dies after ~16 minutes:

00:00.000 IP host.2 > host.1: Flags [S]
00:00.000 IP host.1 > host.2: Flags [S.]
00:00.000 IP host.2 > host.1: Flags [.]

# All subsequent packets dropped
00:00.206 IP host.2 > host.1: Flags [P.], length 11 # first data packet
00:00.412 IP host.2 > host.1: Flags [P.], length 11 # early retransmit, doesn't count
00:00.620 IP host.2 > host.1: Flags [P.], length 11 # 1st retry
00:01.048 IP host.2 > host.1: Flags [P.], length 11 # 2nd retry
00:01.880 IP host.2 > host.1: Flags [P.], length 11 # 3rd retry

State Recv-Q Send-Q Local:Port Peer:Port
ESTAB 0      0      host:1     host:2
ESTAB 0      11     host:2     host:1    timer:(on,1.304ms,3)

00:03.543 IP host.2 > host.1: Flags [P.], length 11 # 4th
00:07.000 IP host.2 > host.1: Flags [P.], length 11 # 5th
00:13.656 IP host.2 > host.1: Flags [P.], length 11 # 6th
00:26.968 IP host.2 > host.1: Flags [P.], length 11 # 7th
00:54.616 IP host.2 > host.1: Flags [P.], length 11 # 8th
01:47.868 IP host.2 > host.1: Flags [P.], length 11 # 9th
03:34.360 IP host.2 > host.1: Flags [P.], length 11 # 10th
05:35.192 IP host.2 > host.1: Flags [P.], length 11 # 11th
07:36.024 IP host.2 > host.1: Flags [P.], length 11 # 12th
09:36.855 IP host.2 > host.1: Flags [P.], length 11 # 13th
11:37.692 IP host.2 > host.1: Flags [P.], length 11 # 14th
13:38.524 IP host.2 > host.1: Flags [P.], length 11 # 15th
15:39.500 connection ETIMEDOUT

The data packet is retransmitted 15 times, as controlled by:

$ sysctl net.ipv4.tcp_retries2
net.ipv4.tcp_retries2 = 15

From the ip-sysctl.txt documentation:

The default value of 15 yields a hypothetical timeout of 924.6 seconds and is a lower bound for the effective timeout. TCP will effectively time out at the first RTO which exceeds the hypothetical timeout.

The connection indeed died at ~940 seconds. Notice the socket has the "on" timer running. It doesn't matter at all if we set SO_KEEPALIVE - when the "on" timer is running, keepalives are not engaged.

TCP_USER_TIMEOUT keeps on working though. The connection will be aborted exactly after user-timeout specified time since the last received packet. With the user timeout set the tcp_retries2 value is ignored.

Zero window ESTAB is... forever?

There is one final case worth mentioning. If the sender has plenty of data, and the receiver is slow, then TCP flow control kicks in. At some point the receiver will ask the sender to stop transmitting new data. This is a slightly different condition than the one described above.

In this case, with flow control engaged, there is no in-flight or unacknowledged data. Instead the receiver throttles the sender with a "zero window" notification. Then the sender periodically checks if the condition is still valid with "window probes". In this experiment we reduced the receive buffer size for simplicity. Here's how it looks on the wire:

00:00.000 IP host.2 > host.1: Flags [S]
00:00.000 IP host.1 > host.2: Flags [S.], win 1152
00:00.000 IP host.2 > host.1: Flags [.]

00:00.202 IP host.2 > host.1: Flags [.], length 576 # first data packet
00:00.202 IP host.1 > host.2: Flags [.], ack 577, win 576
00:00.202 IP host.2 > host.1: Flags [P.], length 576 # second data packet
00:00.244 IP host.1 > host.2: Flags [.], ack 1153, win 0 # throttle it! zero-window

00:00.456 IP host.2 > host.1: Flags [.], ack 1 # zero-window probe
00:00.456 IP host.1 > host.2: Flags [.], ack 1153, win 0 # nope, still zero-window

State Recv-Q Send-Q Local:Port Peer:Port
ESTAB 1152   0      host:1     host:2
ESTAB 0      129920 host:2     host:1  timer:(persist,048ms,0)

The packet capture shows a couple of things. First, we can see two packets with data, each 576 bytes long. They both were immediately acknowledged. The second ACK had "win 0" notification: the sender was told to stop sending data.

But the sender is eager to send more! The last two packets show a first "window probe": the sender will periodically send payload-less "ack" packets to check if the window size had changed. As long as the receiver keeps on answering, the sender will keep on sending such probes forever.

The socket information shows three important things:

  • The read buffer of the reader is filled - thus the "zero window" throttling is expected.
  • The write buffer of the sender is filled - we have more data to send.
  • The sender has a "persist" timer running, counting the time until the next "window probe".

In this blog post we are interested in timeouts - what will happen if the window probes are lost? Will the sender notice?

By default the window probe is retried 15 times - adhering to the usual tcp_retries2 setting.

The tcp timer is in persist state, so the TCP keepalives will not be running. The SO_KEEPALIVE settings don't make any difference when window probing is engaged.

As expected, the TCP_USER_TIMEOUT toggle keeps on working. A slight difference is that similarly to user-timeout on keepalives, it's engaged only when the retransmission timer fires. During such an event, if more than user-timeout seconds since the last good packet passed, the connection will be aborted.

Note about using application timeouts

In the past we have shared an interesting war story:

Our HTTP server gave up on the connection after an application-managed timeout fired. This was a bug - a slow connection might have correctly slowly drained the send buffer, but the application server didn't notice that.

We abruptly dropped slow downloads, even though this wasn't our intention. We just wanted to make sure the client connection was still healthy. It would be better to use TCP_USER_TIMEOUT than rely on application-managed timeouts.

But this is not sufficient. We also wanted to guard against a situation where a client stream is valid, but is stuck and doesn't drain the connection. The only way to achieve this is to periodically check the amount of unsent data in the send buffer, and see if it shrinks at a desired pace.

For typical applications sending data to the Internet, I would recommend:

  1. Enable TCP keepalives. This is needed to keep some data flowing in the idle-connection case.

  2. Set TCP_USER_TIMEOUT to TCP_KEEPIDLE + TCP_KEEPINTVL * TCP_KEEPCNT.

  3. Be careful when using application-managed timeouts. To detect TCP failures use TCP keepalives and user-timeout. If you want to spare resources and make sure sockets don't stay alive for too long, consider periodically checking if the socket is draining at the desired pace. You can use ioctl(TIOCOUTQ) for that, but it counts both data buffered (notsent) on the socket and in-flight (unacknowledged) bytes. A better way is to use TCP_INFO tcpi_notsent_bytes parameter, which reports only the former counter.

An example of checking the draining pace:

while True:
    notsent1 = get_tcp_info(c).tcpi_notsent_bytes
    notsent1_ts = time.time()
    ...
    poll.poll(POLL_PERIOD)
    ...
    notsent2 = get_tcp_info(c).tcpi_notsent_bytes
    notsent2_ts = time.time()
    pace_in_bytes_per_second = (notsent1 - notsent2) / (notsent2_ts - notsent1_ts)
    if pace_in_bytes_per_second > 12000:
        # pace is above effective rate of 96Kbps, ok!
    else:
        # socket is too slow...

There are ways to further improve this logic. We could use TCP_NOTSENT_LOWAT, although it's generally only useful for situations where the send buffer is relatively empty. Then we could use the SO_TIMESTAMPING interface for notifications about when data gets delivered. Finally, if we are done sending the data to the socket, it's possible to just call close() and defer handling of the socket to the operating system. Such a socket will be stuck in FIN-WAIT-1 or LAST-ACK state until it correctly drains.

Summary

In this post we discussed five cases where the TCP connection may notice the other party going away:

  • SYN-SENT: The duration of this state can be controlled by TCP_SYNCNT or tcp_syn_retries.
  • SYN-RECV: It's usually hidden from application. It is tuned by tcp_synack_retries.
  • Idling ESTABLISHED connection, will never notice any issues. A solution is to use TCP keepalives.
  • Busy ESTABLISHED connection, adheres to tcp_retries2 setting, and ignores TCP keepalives.
  • Zero-window ESTABLISHED connection, adheres to tcp_retries2 setting, and ignores TCP keepalives.

Especially the last two ESTABLISHED cases can be customized with TCP_USER_TIMEOUT, but this setting also affects other situations. Generally speaking, it can be thought of as a hint to the kernel to abort the connection after so-many seconds since the last good packet. This is a dangerous setting though, and if used in conjunction with TCP keepalives should be set to a value slightly lower than TCP_KEEPIDLE + TCP_KEEPINTVL * TCP_KEEPCNT. Otherwise it will affect, and potentially cancel out, the TCP_KEEPCNT value.

In this post we presented scripts showing the effects of timeout-related socket options under various network conditions. Interleaving the tcpdump packet capture with the output of ss -o is a great way of understanding the networking stack. We were able to create reproducible test cases showing the "on", "keepalive" and "persist" timers in action. This is a very useful framework for further experimentation.

Finally, it's surprisingly hard to tune a TCP connection to be confident that the remote host is actually up. During our debugging we found that looking at the send buffer size and currently active TCP timer can be very helpful in understanding whether the socket is actually healthy. The bug in our Spectrum application turned out to be a wrong TCP_USER_TIMEOUT setting - without it sockets with large send buffers were lingering around for way longer than we intended.

The scripts used in this article can be found on our Github.

Figuring this out has been a collaboration across three Cloudflare offices. Thanks to Hiren Panchasara from San Jose, Warren Nelson from Austin and Jakub Sitnicki from Warsaw. Fancy joining the team? Apply here!

Read the whole story
ruairimccomb
1917 days ago
reply
Share this story
Delete
1 public comment
fxer
1918 days ago
reply
Great primer, I’ve run into VMs from various providers under various circumstances hanging in CLOSE_WAIT to where I’d run out of local ports on a Linux box when doing high speed processing.
Bend, Oregon

Thomas Piketty's new book uses data to trace how inequality changes ideology

4 Shares

French economist Thomas Piketty changed the world in 2014 with his magisterial Capital in the Twenty-First Century, a book that reported out an incredibly ambitious project to map out three centuries' worth of capital flows, and from that, to derive an empirical answer about whether markets are a machine for finding smart people and allocating capital to them so that they can invent things that make us all better off ("meritocracy"), or whether they simply make the people who happened to get rich (possibly by inventing something, more often by inheriting wealth or by being a sociopathic looter) even richer (spoiler: r>g, which means that markets' long-run function is to increase inequality by allocating ever-larger pools of capital to rich people who don't do much that's socially beneficial with it).

Here's an example of how markets -- even ones with lots of growth -- are much better at enriching the rich than making us all richer, from the 2014 edition:

All large fortunes, whether inherited or entrepreneurial in origin, grow at extremely high rates, regardless of whether the owner of the fortune works or not. To be sure, one should be careful not to overestimate the precision of the conclusions one can draw from these data, which are based on a small number of observations and collected in a somewhat careless and piecemeal fashion. The fact is nevertheless interesting.

Take a particularly clear example at the very top of the global wealth hierarchy. Between 1990 and 2010, the fortune of Bill Gates -- the founder of Microsoft, the world leader in operating systems, and the very incarnation of entrepreneurial wealth and number one in the Forbes rankings for more than ten years -- increased from $4 billion to $50 billion. At the same time, the fortune of Liliane Bettencourt -- the heiress of L'Oréal, the world leader in cosmetics, founded by her father Eugène Schueller, who in 1907 invented a range of hair dyes that were destined to do well in a way reminiscent of César Birotteau's success with perfume a century earlier -- increased from $2 billion to $25 billion, again according to Forbes.

In other words, Liliane Bettencourt, who never worked a day in her life, saw her fortune grow exactly as fast as that of Bill Gates, the high-tech pioneer, whose wealth has incidentally continued to grow just as rapidly since he stopped working. Once a fortune is established, the capital grows according to a dynamic of its own, and it can continue to grow at a rapid pace for decades simply because of its size. Note, in particular, that once a fortune passes a certain threshold, size effects due to economies of scale in the management of the portfolio and opportunities for risk are reinforced by the fact that nearly all the income on this capital can be plowed back into investment. An individual with this level of wealth can easily live magnificently on an amount equivalent to only a few tenths of percent of his capital each year, and he can therefore reinvest nearly all of his income. This is a basic but important economic mechanism, with dramatic consequences for the long-term dynamics of accumulation and distribution of wealth. Money tends to reproduce itself.

One of the corollaries of this rich-get-richer phenomenon is that it breeds a belief in "hereditary meritocracy," whose argument goes like this: "I deserve my riches because I did something special. My kids inherited my riches (because rich people have dismantled any mechanisms for preventing intergenerational wealth transfers by the super-wealthy), and they're rich too, even though, objectively, they have not done anything great. But we live in a meritocracy! Otherwise my wealth might be illegitimate. If we live in a meritocracy and my kids are rich despite not having done anything great, it must be because they are great. That is, in addition to inheriting the money I got from doing something great, they also inherited my capacity for greatness. My money doesn't just prove that I did something amazing, it proves that I have amazing blood, which I have passed on, and which the market has recognized by allocating all that capital to my kids."

In other words, inequality needs ideology to stabilize it. When you're starving and someone's useless kids are flaunting their third solid gold Bentley by driving through town, terrorizing you and your starving neighbors, the temptation to build guillotines begins to mount.

Rich people can offset the guillotine risk by buying guard labor, and they are, but this has diminishing returns (including the problem of hiring guards to protect you from your guards), and so the market finds more efficient ways to stabilize inequality.

The most important of these is ideology: inculcating a belief that the system is just. This is hard, and it's a long-term project, but if you can convince people that they're not poor, merely "temporarily embarrassed millionaires", you can get them to do their own guard-labor, in their heads, before they even go looking for lumber to build those guillotines.

The rich people of the world have spent lavishly, over decades, to promote the idea of markets as meritocratic, and, in so doing, have (at least partly inadvertently) kept alive the eugenic idea of "good blood" -- which explains a lot about the rise of neo-aristocratic rich racists who find in Donald Trump (and his cohort around the world) a welcome fusion of racism and plutocratic policies.

Now, Piketty has penned a new book (currently available in France as "Capital et idéologie," forthcoming in English as Capital and Ideology") in which he uses the same data-driven econometric methods combined with history and sociology to build up an account of the relationship between inequality and ideas.

Over at Promarket, Branko Milanovic (previously) reviews Capital and Ideology, making it sound really exciting. In particular, Piketty focuses on the transformation of labor parties into liberal parties whose core constituency is the middle class -- a really pressing issue as left wing parties around the world are riven by internal struggles between leftists and liberals.

I'm interested in the ways that inequality has given rise to conspiratorial thinking. It's not like antivax arguments got better over 70 years: but they somehow got more convincing. There are people who worry about machine learning who attribute this to Big Tech's ability to use targeted advertising and algorithms to change peoples' minds, but I think it's much more productive to look to the material circumstances of people who believe unconvincing ideas than it is to reinvent junk science like "neurolinguistic programming" (dressed up in machine learning hype) to explain how people ended up so distrustful of our states and institutions and their truth-seeking capacity that they're willing to believe that the Earth is flat.

This part of the book looks empirically at the reasons that left-wing, or social democratic parties have gradually transformed themselves from being the parties of the less-educated and poorer classes to become the parties of the educated and affluent middle and upper-middle classes. To a large extent, traditionally left parties have changed because their original social-democratic agenda was so successful in opening up education and high-income possibilities to the people who in the 1950s and 1960s came from modest backgrounds. These people, the “winners” of social democracy, continued voting for left-wing parties but their interests and worldview were no longer the same as that of their (less-educated) parents. The parties’ internal social structure thus changed—the product of their own political and social success. In Piketty’s terms, they became the parties of the “Brahmin left” (La gauche Brahmane), as opposed to the conservative right-wing parties, which remained the parties of the “merchant right” (La droite marchande).

To simplify, the elite became divided between the educated “Brahmins” and the more commercially-minded “investors,” or capitalists. This development, however, left the people who failed to experience upward educational and income mobility unrepresented, and those people are the ones that feed the current “populist” wave. Quite extraordinarily, Piketty shows the education and income shifts of left-wing parties’ voters using very similar long-term data from all major developed democracies (and India). The fact that the story is so consistent across countries lends an almost uncanny plausibility to his hypothesis.

It is also striking, at least to me, that such multi-year, multi-country data were apparently never used by political scientists to study this phenomenon. This part of Piketty’s book will likely transform, or at least affect, how political scientists look at new political realignments and class politics in advanced democracies in the years to come. In the same way that Capital in the Twenty-First Century has transformed how economists look at inequality, Capital and Ideology will transform the way political scientists look at their own field.

Thomas Piketty’s New Book Brings Political Economy Back to Its Sources [Branko Milanovic/Promarket]

(via Naked Capitalis)

Read the whole story
ruairimccomb
1926 days ago
reply
Share this story
Delete

Guantánamo’s Darkest Secret | The New Yorker

1 Share

In 2004, Steve Wood was deployed to Guantánamo Bay, as a member of the Oregon National Guard. He and his comrades were told that many of the detainees were responsible for 9/11 and, given the opportunity, would strike again. “I just remember being super excited, because I thought, I’m going to be doing something important,” Wood told me. For two weeks, he worked as a guard in the cellblocks, monitoring men who had been captured on the battlefields of Afghanistan. Then a sergeant major pulled him aside for a brief interview, and assigned him to work the night shift in Echo Special, a secret, single-occupancy unit that had been built to house the United States military’s highest-value detainee. The International Committee of the Red Cross—which has access to many of the world’s most notorious detention sites, some of them in countries where there is no rule of law—had recently sent representatives to Guantánamo, but the base commander, citing “military necessity,” had refused to allow them into Echo Special. The man confined there was referred to by his detainee number, 760. When Wood tried to search for 760 in Guantánamo’s detainee database, he found nothing.

Wood was the second of three boys. His father died in a plane crash when he was three years old, and his mother brought him and his brothers up in Molalla, Oregon, a lumber town about an hour south of Portland. His mother dated a string of alcoholics and addicts, and took the children to an evangelical church on Sundays; Pat Robertson’s sermons blasted from the living-room TV. In 1999, shortly after graduating from high school, Wood started a job at the local sawmill. Several of his co-workers were missing fingers, and the manager took every opportunity to denigrate the staff. After a few months, he signed up for the Oregon National Guard, on the military-police track. He sought structure and discipline—a life of pride, purpose, and clarity of mission.

After 9/11, patriotism eclipsed restlessness as Wood’s primary motivation to serve. He had spent the morning of the worst terrorist attack in American history lying on his mother’s couch, high on painkillers after a tonsillectomy, but when he emerged from the haze he was angry, focussed, and longing for deployment. He didn’t harbor any particular animosity toward Muslims, but he had absorbed his mother’s belief: “If it’s not from Jesus then it must be from the Devil.” After completing the requirements to become an M.P., Wood enrolled in a criminal-justice program at a nearby community college. He recalled his political views as being “whatever Fox News told us.” He didn’t know the difference between a Hindu, a Sikh, and a Muslim—he had never met one.

Before his first shift in Echo Special, Wood was told to place a strip of electrical tape over the name on his uniform, and to use only nicknames inside the cell, so that if 760 were to somehow sneak a message out of the camp he couldn’t issue fatwas against his guards or their families. “Never turn your back,” the sergeant major warned him. Wood, who was twenty-three, had recently learned that his girlfriend was pregnant. He wouldn’t take any chances. “You trust the handcuffs and everything, but, no matter what, we’d never be with him one on one—there would always be a partner,” Wood told me. Until recently, the guards and the interrogators had worn Halloween masks inside the cell. Wood walked through the camp to Echo Special proud to be part of a serious national-security operation. He thought, It must be somebody really important—the most dangerous person in the world, perhaps—to have this special attention, a guard force just for him.

Echo Special was a trailer that had been divided in two. Wood walked into the main area, which housed the guards; through a door was the prisoner’s sleeping space. A government report describes the facility as having been “modified in such a way as to reduce as much outside stimuli as possible,” with doors that had been “sealed to a point that allows no light to enter the room.” Inside, the walls were “covered with white paint or paper to further eliminate objects the detainee may concentrate on.” There was an eyebolt for shackling him to the floor, and speakers for bombarding him with sound.

An M.P. explained to Wood that the current guard force called Detainee 760 “Pillow,” because when they had arrived, several months earlier, a pillow was the only object in his possession. Then one of them shouted, “Pillow, you can come out now!” A short man in his mid-thirties stepped into the guards’ area, unshackled. He wore a broad smile and a white jumpsuit, and moved cautiously toward Wood. The detainee introduced himself as Mohamedou Salahi, then reached for a handshake, and said, “What’s up, dude?”

Wood is six feet three, with a shaved head, a shy, stoic manner, and the musculature of an élite bodybuilder. Although he towered over Salahi, he hesitated before taking his hand, and when he did he noted how delicate Salahi was. “Nice to meet you,” Wood said. But he thought, What the fuck is this? This is the exact opposite of what’s supposed to happen.

The fragmented image of Mohamedou Salahi that United States military, law-enforcement, and intelligence agencies assembled in a classified dossier was that of a “highly intelligent” Mauritanian electrical engineer, who, “as a key al-Qaida member,” had played a role in several mass-casualty plots. Other men carried box cutters and explosives; Salahi was a ghost on the periphery. The evidence against him lacked depth, but investigators considered its breadth conclusive. His proximity to so many events and high-level jihadi figures could not be explained by coincidence, they thought, and only a logistical mastermind could have left so faint a trail.

The U.S. government gathered that in 1991, when Salahi was twenty, he swore allegiance to Osama bin Laden, and the following year he learned to handle weapons at an Al Qaeda training camp in Afghanistan. Later, Salahi moved to Germany, where, the Americans assessed, “his primary responsibility was to recruit for al-Qaida in Europe.” Among his alleged recruits were three of the 9/11 hijackers, all of whom served as pilots on separate planes. A fourth was Ramzi bin al-Shibh, the attack coördinator; while in C.I.A. custody, bin al-Shibh named Salahi as the man who had arranged his travel to Afghanistan and his introduction to bin Laden.

In 1998, shortly after Al Qaeda detonated truck bombs outside the U.S. Embassies in Kenya and Tanzania, Salahi took a call from a phone number belonging to bin Laden. Then, and on at least one other occasion, a member of Al Qaeda’s Shura Council—its leadership—wired some four thousand dollars to Salahi’s bank account in Germany; Salahi withdrew the cash and handed it to men who were travelling to West Africa, to facilitate what the Americans assessed to be money-laundering and telecommunications “projects for al-Qaida.”

In 1999, the Shura member called Salahi, but U.S. intelligence didn’t know what his instructions were. In November of that year, Salahi moved to Montreal, where he began leading prayers at a prominent mosque. Soon afterward, a jihadi who had attended the same mosque—and who the Americans believed had met Salahi—attempted to smuggle explosives in the trunk of a car across the U.S. border; his plan was to detonate suitcases inside Los Angeles International Airport, in what became known as the Millennium Plot. Canada’s Secret Intelligence Service began a surveillance operation focussing on Salahi and his associates, but Salahi noticed two pinhole cameras poking through his apartment walls and left the country. The U.S. government concluded that he was “the leader of the Montreal-based al-Qaida cell.”

In Guantánamo, Salahi admitted to this and other allegations. “I came to Canada with a plan to blow up the CN Tower in Toronto,” Salahi wrote, in one of his many confessions. He listed his accomplices and added, “thanks to Canadian Intel, the plan was discovered and sentenced to failure.” After years of holding out in interrogations, he had become what the classified dossier described as a “highly cooperative” font of intelligence—“one of the most valuable sources in detention.” He described Al Qaeda’s financial involvement in credit-card fraud and drug smuggling, and also the group’s “investment in unwitting companies in Bosnia, Canada, Chechnya, Denmark, England, Germany, Mauritania, and Spain.” He drew organizational charts, with the names and operational roles of key figures, and supplied intelligence on jihadi cells and safe houses all over Europe and West Africa. Owing to his expertise as an electrical engineer, the dossier concludes, Salahi was also able to describe Al Qaeda’s elaborate communications systems, “including radio relay, couriers, encryption, phone boutiques, and satellite communication links to laptops.” But the U.S. government was sure there was more to be gleaned from him; the dossier says that he “still has useful information” on a variety of subjects, including the 9/11 attacks, and lists twenty-two additional “areas of potential exploitation.” Military officials considered him “the poster child for the intelligence effort at Guantánamo.”

As a result of Salahi’s coöperation, his private cell was now stocked with what the government referred to as “comfort items.” After the pillow came soap, towels, a prayer cap, and prayer beads—by the time Steve Wood arrived, Salahi also had books, a television, a PlayStation, and an old laptop, on which he killed time playing chess and watching DVDs. Eventually, Salahi would be allowed access to a small patch of soil outside his trailer, where he tended sunflowers, basil, sage, parsley, and cilantro. “What I was told was that his information had saved thousands of American lives,” Wood said, “and this is what they’d given him to keep talking.”

Salahi was taken into custody when he was thirty years old, but he had already lived on four continents, and spoke fluent Arabic, French, and German. English was his fourth language. Since he had learned it in captivity, some of his earliest phrases were “I ain’t done nothing,” “cavity search,” “fuck this,” and “fuck that.” “My problem is that I had been picking the language from the ‘wrong’ people—namely, U.S. Forces recruits who speak grammatically incorrectly,” he wrote on a scrap of paper inside his cell. “English accepts more curses than any other language, and I soon learned to curse with the commoners.”

As a matter of professionalism, Wood resolved from the outset to bury in the back of his mind what he had heard of Salahi’s past. “It’s hard to sit there and laugh and chat with the guy, if he’s actually that bad,” Wood told me. The night shift was twelve hours, and he never saw Salahi shackled or restrained. Other Guantánamo prisoners threw punches and feces and urine, but, according to the classified dossier, Salahi’s only disciplinary infraction was that, on May 11, 2003, he “possessed an excessive amount of MRE food.”

Salahi often appeared sullen and withdrawn. But, when he wanted to engage, he spoke with a worldly, provocative humor that Wood found appealing. He liked to rile his guards into debating equality, race, and religion, and he wielded a sophisticated understanding of history and geopolitics to chip away at their beliefs. Before meeting Salahi, Wood had never heard of Mauritania; Salahi told him that, to his great embarrassment, slavery was still practiced there, even among people close to him. Salahi also pushed him to research Western foreign-policy blunders—for example, that in 1953 the American and the British intelligence services had orchestrated a coup in Iran, overthrowing a popular Prime Minister in order to prop up a tyrannical, pro-Western Shah. “Have you heard of Nelson Mandela?” Wood recalled Salahi saying. “Look him up, dude. Look up the prison on Robben Island. See if you think his captivity was just. See what it did to his family.”

A job posting depicts life as an intelligence officer in Guantánamo Bay as “a rewarding challenge with incredible surroundings”—sunsets, beaches, iguanas, pristine Caribbean blue. “After a hustled day of tackling a myriad of issues and directly contributing to the global war on terrorism,” it reads, “fun awaits.” Officers could partake in pottery classes, paintball, rugby, tennis, and softball, or exercise in several pools and gyms. The local dive shop offered gear and certifications for sailing, water-skiing, snorkelling, scuba diving, and more: “No experience, no problem. . . . Relaxing is easy.”

In practice, many military-police officers killed time by watching movies and getting drunk at the Tiki Bar; they also took flights to Afghanistan, to pick up more detainees. But Wood spent his days in the base library, researching topics that Salahi had brought up in the cell. He devoured volumes on history, foreign affairs, politics, civil rights—“pretty much any type of book you could think of, other than, like, romance novels,” he said. “I was educating myself on the world.” But, because Salahi’s trailer was a national secret, Wood kept a cordial distance from most of the other guards. “I’d come home and iron my uniform, and my roommates didn’t know a thing,” he said. “They’d ask me, ‘Who’s in there?,’ and I’d say, ‘I don’t know, probably somebody famous.’ ”

In time, Wood began to think of everything he had known before meeting Salahi as a narrow-minded myth of American superiority, notable for its omissions of overseas misadventures. Meanwhile, the Bush Administration’s pretext for invading Iraq was collapsing, and so was Wood’s trust in government. It was the spring of 2004. There were no weapons of mass destruction. The “mission” had not been “accomplished.” When Wood watched the evening news, he saw photographs of American M.P.s torturing and sexually humiliating Iraqi detainees at Abu Ghraib. He began to wonder whether the case against Mohamedou Salahi was as flimsy and politically motivated as that for the invasion had been. “I was, like, What else have they lied about?” he said.

Salahi underwent daily interrogations. The sessions Wood witnessed were calm and courteous, with Salahi attempting to answer everything asked of him. “It was the pretty blond interrogator bringing in these disks with footage from Al Qaeda and Taliban training camps in Afghanistan,” Wood recalled. The videos had been pulled from jihadi Web sites, or captured by intelligence officers during raids, and Salahi’s role was to identify the people in them. But sometimes, after coöperating, “he’d get depressed and anxious, and say, ‘I’m a bad Muslim,’ ” Wood told me. “And I’d say, ‘No matter what you did in the past, man, you’ve saved thousands of lives.’ I’d always say that, and he’d just shake his head, like, ‘Bullshit.’ ”

One night, when Salahi was asleep, Wood heard sounds that reminded him of a child having a nightmare. He walked into the sleeping area and found Salahi lying in the fetal position, shaking. No adult in Wood’s life had ever looked so frightened and so vulnerable. He gently held Salahi’s shoulder, and said, “Everything’s O.K.” Salahi shook his head, and clicked his tongue in disagreement, but refused to speak. The next day, Wood pressed him to talk about the episode, but Salahi wouldn’t elaborate. He just said, “Dude, they fucked me up.”

The night terrors kept coming. Salahi was on a diet of Ensure nutrition shakes and antidepressants. One day, he complained to Wood that the interrogators were demanding information on events that he couldn’t possibly know about, because they had taken place while he was in custody.

Although Wood had introduced himself to Salahi as Stretch, his nickname from the sawmill, Salahi had quickly learned his real name, as well as those of the other guards. “The tape would fall off our uniforms,” Wood recalled. “We’d try to cover it back up, real quick, but eventually we were, like, fuck it. We knew he wasn’t a threat.” Where once he had struggled to forgive himself for enjoying Salahi’s company, he now felt bad about having to lock the door at the end of each shift. He walked into the morning sunlight in a daze, unable to reconcile his impression of the man in Echo Special with the depiction of the terrorist in the dossier. Had Wood remained as a regular guard, in one of the regular cellblocks, he might have finished his deployment with his understanding of the global war on terror more or less intact. Instead, he began to wonder whether what he was actually protecting at Guantánamo was one of the government’s darkest secrets: that its highest-value military detainee was being held essentially by mistake, and that his isolation in Echo Special was intended to cover up the hell that had been inflicted upon him.

One day, Salahi started requesting paper from his guards. As the result of a recent court ruling, Guantánamo detainees had access to legal representation, and so, during the next several months, Salahi drafted a diary of his detention as a series of harrowing letters to his lawyers, Nancy Hollander, Sylvia Royce, and Theresa Duncan—four hundred and sixty-six pages, sealed in envelopes and mailed to a classified facility near Washington, D.C. No guards or interrogators were allowed to read Salahi’s work. For the first time, he described his experiences without fear of retribution. On one page, he recalled the day he got his nickname, when an interrogator brought him a pillow. “I received the present with a fake overwhelming happiness, and not because I was dying to get a pillow,” he wrote. “No. I took the pillow as a sign of the end of the physical torture.”

The Detainee

Mohamedou Ould Salahi was born in late December, 1970, the ninth child of a Mauritanian camel herder and his wife. Like most countries in West Africa, Mauritania had gained independence from France a decade earlier. Few locals spoke French, but since the country had been arbitrarily drawn up as a vast, mostly desert territory, populated by numerous ethnic groups who spoke different languages, there was no alternative for official documentation. When a nurse, who spoke only Hassaniya Arabic, filled out Mohamedou’s birth certificate in the Latin alphabet, she omitted a syllable from his last name. Salahi became “Slahi.” So began a life in which governments treated Salahi in accordance with their own mistakes.

Salahi was a precocious student; after school, he used to steal chalk from the classroom and return to Bouhdida, a dusty, unplanned neighborhood in Mauritania’s capital, Nouakchott, to re-create the day’s lessons for kids who couldn’t afford an education. Mauritania is an Islamic republic, with rich traditions in poetry and recitation that belie its dismal rates of literacy and economic growth. As a teen-ager, Salahi memorized the entire Quran.

He grew up measuring political eras by military coups—1978, 1979, 1984—changes in power that did little to alter the ways in which Mauritanians experienced power. The lack of progress, development, and freedom in Mauritanian society inspired in Salahi a righteous anger toward autocracy and corruption, and a desire to fight for something bigger than himself.

In the eighties, he and a younger cousin, a slender poet named Mahfouz Ould al-Walid, spent their evenings at a local café, where the owner showed videos of the Palestinian struggle and the jihad in Afghanistan, which the Soviet Union had invaded in 1979. In 1988, the Saudi ideologue Osama bin Laden announced the formation of Al Qaeda. Walid, who was thirteen, started reading bin Laden’s pamphlets. He and Salahi were smitten with the Al Qaeda narrative, that a ragtag group of mujahideen, carrying light weapons and hiding in caves, were taking on a superpower in the defense of all Muslims. They weren’t the only people taken by this struggle—the C.I.A. was funding and equipping many of the mujahideen groups.

In 1988, Salahi graduated from high school and won a scholarship to study engineering in Duisburg, Germany. He was the first person in his family to attend university. But the call to jihad interrupted his studies. By 1990, the Soviets had withdrawn from Afghanistan, but Al Qaeda was still fighting against the Communist Afghan government that the Soviets had installed. That December, shortly before his twentieth birthday, Salahi boarded a flight to Pakistan and crossed into Afghanistan, and although he never met bin Laden, he soon pledged his allegiance to the Al Qaeda leadership.

Walid, who was sixteen, stayed behind. But two months later, when Salahi returned to Mauritania and described his experience of the jihad, Walid resolved to set off on his own for Afghanistan. Walid was a prodigious poet—in Nouakchott, he had won several awards—and when bin Laden met him he was impressed by his eloquence and conviction. Soon afterward, they travelled together to Sudan, where bin Laden ran a construction company and a jihadi training camp, and sped around Khartoum in bin Laden’s white Mercedes.

In the spring of 1992, Salahi returned to Afghanistan. Because he had no experience with weapons, Al Qaeda personnel sent him to the Al Farouq training camp, near Khost, where he learned how to use a Kalashnikov rifle and launch rocket-propelled grenades. But by then the Soviet Union had collapsed, and, while Salahi was in training, the Afghan government lost its Russian support. Afghanistan’s civil war entered a new stage, with rival Islamist groups vying for control, and Salahi wanted no part of it. After three months, he left Afghanistan and returned to Duisburg, where he worked in a computer-repair shop while he finished his degree.

Another two years passed before Salahi’s name caught the attention of Deddahi Ould Abdellahi, the head of Mauritania’s security-intelligence apparatus. In 1994, as the director of state security, he opened an investigation into Nouakchott’s jihadi scene. Several Mauritanians had travelled to battlefields in Afghanistan and Bosnia, and Mahfouz Walid had become an important figure in Al Qaeda; he now went by the nom de guerre Abu Hafs al-Mauritani. In Nouakchott, Abdellahi and his subordinates began to map out the network, detaining people close to Abu Hafs and soliciting the names of other jihadis. Several young men mentioned Salahi as a contact in Germany. With the assistance of German intelligence, Abdellahi told me, “we started collecting the maximum amount of information. How does he live? How does he behave? How does he react to world events?” It was unclear to Abdellahi whether Salahi was still active within Al Qaeda, but he seemed to be someone whom all the Mauritanian Islamists knew.

Abu Hafs ascended to Al Qaeda’s Shura Council, where he served as bin Laden’s personal adviser on Sharia law. In 1996, when Abu Hafs was twenty-one, he drafted bin Laden’s most important fatwa: an eleven-thousand-word document excoriating the Saudi Kingdom and warning the U.S. Secretary of Defense that Al Qaeda’s adherents “have no intention except to enter paradise by killing you.” The fatwa was Al Qaeda’s declaration of war against the United States. According to “The Exile,” a comprehensive account of post-9/11 Al Qaeda, by the investigative journalists Cathy Scott-Clark and Adrian Levy, who gained access to Abu Hafs’s diaries, he ghostwrote “most of Osama’s speeches, religious judgments, and press releases.” In 1998, bin Laden wrote Abu Hafs into his will.

Around that time, after a long period without contact, Abu Hafs called Salahi from bin Laden’s satellite phone. The cousins had married a pair of sisters, and so they were now also brothers-in-law. But, after Salahi returned to Germany, they had scarcely been in touch. While Abu Hafs was handling Al Qaeda’s affairs in East Africa, his father became ill, and so, as both men remember it, Abu Hafs requested Salahi’s help in transferring money to care for his family in Mauritania. Salahi agreed, and Abu Hafs wired around four thousand dollars to his German account. Salahi withdrew the cash and gave it to friends who were travelling to Nouakchott, and they delivered it to Abu Hafs’s family.

A similar phone call, followed by a second transaction, took place in December, 1998. But, after Abu Hafs used bin Laden’s phone to call a different cousin in Nouakchott, Abdellahi’s subordinates took the cousin into custody, and tortured him for two months. So, when Abu Hafs called Salahi for assistance a third time, in early 1999, Salahi refused, and hung up.

Al Qaeda had by this time transformed into an international terrorist organization that was launching attacks in East Africa and the Middle East. The U.S. had fired cruise missiles at Al Qaeda-linked targets in Sudan and Afghanistan, and, in a bid to capture Abu Hafs, the C.I.A. had raided a hotel in Khartoum. (He escaped through a kitchen door.) One night in October, 1999, a friend of Salahi’s asked him to host three Muslims who were passing through Duisburg. Over dinner, they explained that they were heading east, for the jihad. The men slept on his floor and left for Afghanistan at dawn. Salahi didn’t know their real names, and never heard from them again.

By now, Salahi was under surveillance by German intelligence. But the Germans saw no reason to detain or question him. According to an investigation by Der Spiegel, “he preached in gloomy back-yard mosques,” and remained in occasional contact with jihadis—men whose names and cell-phone numbers would turn up in investigations spanning Africa, Europe, North America, and the Middle East. But he did not consider himself a member of Al Qaeda, or a facilitator of its operations. One day, German officers questioned one of Salahi’s friends. When they asked whether Salahi was involved in any terrorist activities, the friend laughed.

But Salahi wanted to live free of surveillance, and he decided to leave the country. One of Salahi’s friends, who was now living in Canada, suggested that he move to Montreal. “He said, ‘Canada is amazing—there is no racism, they speak French, and it is just a very advanced country,’ ” Salahi said years later, in a U.S. military hearing. “You will have a job at the snap of a finger,” his friend told him. Ramadan was approaching—when the men leading prayers read aloud the entire Quran during the course of a lunar cycle—and, Salahi recalled, “my friend said, ‘We need you here in Canada because we have no Hafez,’ ” the Arabic word for a man who can recite the Quran from memory. “In Arabic countries there are oodles, but in Europe and Canada one is very rare.”

Salahi landed in Montreal on November 26, 1999. (His wife returned to Nouakchott.) His friend, Hosni Mohsen, introduced him to the imam at the Al Sunnah mosque. The mosque had thousands of attendees, a few of whom belonged to an Algerian jihadi group that had come to the attention of the French and Canadian intelligence services. “Bad people always want to blend into a crowd,” Salahi explained at the military hearing. Some of Mohsen’s “bad friends,” as Salahi described them, visited Mohsen’s apartment while he was hosting Salahi.

“So look at me,” Salahi said. “I have contact with Osama bin Laden’s operative, who was helping launder money. I’m now in Canada, attending a mosque where we believe a very dangerous group is attending.” And, because it was Ramadan, Salahi was leading prayers. “Something is going on.”

“It’s not looking good,” the presiding military officer replied.

“No, it’s not looking good at all,” Salahi said. “It will look worse.”

One of the Algerian jihadis was Ahmed Ressam, a serial thief who was living in Canada under a false identity. In 1998, he had travelled to Afghanistan, and spent a year in Al Qaeda training camps, where he learned to handle weapons and explosives. In the spring of 1999, French intelligence officers asked their Canadian counterparts if they could question Ressam about jihadi activities in Europe, but the Canadians couldn’t locate him, because he had entered the country on a fake passport.

A week after Salahi began leading prayers at the Al Sunnah mosque, Ressam drove a rental car onto a U.S.-bound ferry in Victoria, British Columbia. When the boat reached Port Angeles, near Seattle, customs officers found in the car more than a hundred pounds of explosives, along with four timed detonators, each fashioned from a nine-volt battery, a circuit board, and a Casio watch. Ressam told investigators that he had planned to detonate suitcases in a crowded terminal at Los Angeles International Airport.

After the failed attack, Canada began to aggressively investigate the Montreal cell. “They were very jumpy,” Salahi recalled at his hearing. “They were everywhere in the mosque, in the police car, twenty-four hours.” Among the targets of the investigation was Mohsen, Salahi’s friend and host. Upon Mohsen’s arrest, according to a court filing, investigators found “pocket litter” that included “both Salahi’s name and Ressam’s phone number.” (Mohsen could not be reached for comment.)

One night, Salahi awoke to the sound of a tiny hole being drilled into his wall. The next morning, he found two pinhole cameras. Salahi called the police to report that his neighbors were spying on him, but they told him that he should just cover the cameras with glue. Soon afterward, Canadian investigators came to the apartment and questioned him about the Millennium Plot. “I was scared to hell,” Salahi recalled at his hearing. “They asked me do I know Ahmed Ressam. I said, ‘No.’ ” (Investigators later determined that Ressam had left Montreal for a safe house in Vancouver on November 17th—nine days before Salahi arrived in Canada.) He began to notice surveillance everywhere. “O.K., screw it, it is not a problem—they can watch me,” he said. “They were afraid that I would kill some people.”

In Mauritania, Abdellahi’s men detained Salahi’s wife and brothers and interrogated them about the Millennium Plot. “They didn’t tell me, because they were scared,” Salahi recalled. But his family members were eager for Salahi to return, and so they told him that his mother was ill.

On January 21, 2000, Salahi boarded a flight to Senegal. It was cheaper to fly to Dakar than to Nouakchott, and his brothers drove three hundred miles to meet him there. As they left baggage claim, Salahi later wrote in his diary, “my hands were shackled behind my back and I was encircled by a bunch of ghosts who cut me off from the rest of my company. At first I thought it was an armed robbery,” but, when the airport police approached, “the guy behind me flashed a magic badge, which immediately made the policemen retreat.” Salahi and his brothers were thrown into the back of a van and driven to a detention site.

Before dawn, Salahi was taken to an interrogation room. An American woman, who he assumed was an intelligence officer, entered the room, and stood by as a Senegalese officer questioned him about the Millennium Plot. Salahi denied knowing Ahmed Ressam, and added that he thought the entire narrative around the attack had been concocted “to unlock the terrorism budget and hurt the Muslims.” At the time, he later wrote, “I believed excessively in Conspiracy Theories—though maybe not as much as the U.S. government does.”

By the following day, the lead Senegalese officer was convinced that there was no reason to hold Salahi. “I was happy because the one-ton stack of paper the U.S. government had provided the Senegalese about me didn’t seem to impress them,” Salahi wrote. “It didn’t take my interrogator a whole lot of time to understand the situation.” Another American official arrived, and took Salahi’s photograph and fingerprints. Soon afterward, Salahi’s brothers were released with instructions to return to Mauritania. They were told not to wait for Salahi.

Several more days of interrogation followed. The Senegalese did the talking, but the Americans provided the questions and reported back to D.C. Eventually, one of the interrogators told Salahi that he was going to be sent to Mauritania for more questioning. He was terrified—he wanted to go back to Canada, where interrogators behaved within the bounds of the law.

Salahi was led to a small private aircraft. The journey to Nouakchott took roughly an hour, tracing the Mauritanian coast—to the left the Atlantic, to the right the Sahara. Salahi, who hadn’t been home since 1993, was filled with nostalgia and dread. “Through the window I started to see the sand-covered small villages around Nouakchott, as bleak as their prospects,” he wrote.

The plane landed at sunset. A security guard handed him a filthy black turban, to hide his face during the drive to the secret-police headquarters. There, an intelligence officer named Yacoub confiscated Salahi’s Quran and left him in a dank cell. He tried to sleep, but his mind was racing with the expectation of torture at dawn. “I’d read about Muslim heroes who faced the death penalty, head up,” he wrote. “How did they do it?”

The next morning, Salahi was led to the office of the Mauritanian intelligence chief, Deddahi Ould Abdellahi. “The room was large and well-furnished,” Salahi wrote, with a portrait of the President “conveying the weakness of the law and the strength of the government.” In the course of the next several days, Abdellahi and his men, citing the concerns of the American government, interrogated Salahi about his time in Afghanistan, his contact with his cousin Abu Hafs, and the Millennium Plot. The men never abused Salahi, but, as the days became weeks, he wished that they would just turn him over to the United States, where, he assumed, he could at least challenge the legal grounds of his detention.

After roughly three weeks, F.B.I. agents visited Salahi’s cell. Their questions were much the same, Salahi wrote, but “the whole environmental setup made me very skeptical toward the honesty and humanity of the U.S. interrogators. It was kind of like, ‘We ain’t gonna beat you ourselves, but you know where you are!’ So I knew the FBI wanted to interrogate me under the pressure and threat of a non-democratic country.”

On February 19, 2000, Abdellahi let him go home. “We had done all our investigations, and we found nothing against Salahi,” Abdellahi told me. Abdellahi’s men confiscated his passport, once again citing a request by the Americans. But a friend helped him find work installing Internet routers for a telecommunications company. “It sucked that I didn’t have the freedom to travel,” Salahi recalled in the military hearing. “But, hey, I have to cope with it. So far, so good.”

Dry Ice

On a Tuesday afternoon in September, 2001, one of bin Laden’s messengers sought out Salahi’s cousin, Abu Hafs, and told him to keep an eye on the news. Abu Hafs was back in Afghanistan, living with his family in Kandahar. It had been five years since the Taliban had taken over most of the country, and televisions were banned. He grabbed his shortwave radio. In the U.S., it was morning. He knew what he expected to hear.

The first rumors of a “planes operation” began circulating among Al Qaeda leaders in 1999. But it wasn’t until two years later that bin Laden shared with the Shura Council the broad outlines of the attack: four planes; two civilian targets; two government targets. In that meeting, Abu Hafs challenged bin Laden on Quranic grounds, arguing that the scale of civilian casualties could not be justified in Islam. He added that such an attack would be a betrayal of Al Qaeda’s agreement with the Taliban government, which had provided sanctuary for the group on the understanding that it would do nothing to provoke a full-scale U.S. invasion. Later that summer, Abu Hafs wrote a twelve-page dissent, but bin Laden bristled at his defiance, and the objections of other Al Qaeda leaders, and moved forward. In July, 2001, according to Scott-Clark and Levy, the authors of “The Exile,” Abu Hafs handed bin Laden his resignation letter. Bin Laden, wary of Al Qaeda’s fragility, urged him not to speak publicly of his departure. For the next two months, Abu Hafs taught jihadi recruits at a madrassa.

After the attacks, Cofer Black, the head of the C.I.A.’s Counterterrorism Center, who had served as the agency’s Khartoum station chief while bin Laden was in Sudan, assured President George W. Bush that men like Abu Hafs would soon “have flies walking across their eyeballs.” The next day, he ordered Gary Schroen, the agency’s former Kabul station chief, to gather a team for a paramilitary mission. “I want to see photos of their heads on pikes,” Black said, according to Schroen’s memoir, “First In,” published in 2005. “I want bin Ladin’s head shipped back in a box filled with dry ice. I want to be able to show bin Ladin’s head to the President.” Black added that he and Bush wanted to avoid the spectacle of a courtroom trial. “It was the first time in my thirty-year CIA career that I had ever heard an order to kill someone,” Schroen wrote.

On September 26th, Schroen and six other officers loaded an aging Soviet helicopter with weapons, tactical gear, and three million dollars in used, nonconsecutive bills. They took off from Uzbekistan and flew into northern Afghanistan, over the snow-capped mountains of the Hindu Kush. There, Schroen contacted the leaders of the Northern Alliance, an armed group that had spent years fighting the Taliban, with little external support. Schroen recalled, “When I began to distribute money—two hundred thousand dollars here, two hundred and fifty thousand dollars for this—I think that they were convinced that we were sincere.” In the next few weeks, Schroen’s C.I.A. team and their Afghan counterparts travelled through much of northern Afghanistan, laying the groundwork for the U.S. military invasion.

In Nouakchott, Abdellahi’s men detained Salahi again in the fall of 2001, at the request of the Americans. “I really have no questions for you, because I know your case,” Abdellahi told him. Salahi had deleted the contents of his phone. “All I had were some numbers of business partners in Mauritania and Germany,” he later wrote, “but I didn’t want the U.S. government harassing those peaceful people just because I had their numbers in my phone.” One of the contacts was listed as “P.C. Laden”—German for “computer shop”—and he figured that, to the Americans, “Laden” would be a red flag.

A couple of weeks into his detention, two F.B.I. agents walked into the cell. “Where is Abu Hafs?” one of them asked.

“I am not in Afghanistan,” Salahi replied. How could he possibly know? The interrogations always circled back to the Millennium Plot. Salahi came to think of his interrogators as acting out a Mauritanian folktale in which a blind man is given the gift of a single, fleeting glimpse of the world. “All he saw was a rat,” Salahi wrote. “After that, whenever anybody tried to explain anything to the guy, he always asked, ‘Compare it with the rat: Is it bigger? smaller?’ ”

One of the F.B.I. agents threatened Salahi with torture, and tried to intimidate him. “He said he was going to bring in black people,” Salahi recalled, in the military hearing. “I don’t have a problem with black people—half my country is black people!” But the agent kept using racial slurs. “This was my first time hearing these words,” Salahi said. “Like, what is a ‘motherfucker’? That is not appropriate language, man. He was very silly. He told me he hated Jews also. . . . I told him I have no problem with the Jews, either, man. Anyway, he said, ‘I know you are part of the Millennium Plot.’ ”

A few days later, Salahi was released. Abdellahi called Salahi’s boss at the telecommunications company, to assure him that Salahi should be allowed to resume work. While in custody, Salahi had befriended Yacoub, the intelligence officer who had been one of his guards. Yacoub had a large family and a small salary, so, when Salahi was released, he started paying Yacoub to do occasional tasks. Though Salahi was a skilled electrician, he hired Yacoub to fix his TV.

Not long afterward, in mid-November, Salahi’s boss sent him to Mauritania’s Presidential palace, to install Internet routers and update the phones. “I thought there would be a lot of formalities, especially for a ‘terrorist suspect’ such as myself, but nothing like that happened,” Salahi wrote. “After all, only the Americans suspect me of terrorism, no other country. The irony is that I have never been in the States, and all the other countries I have been in kept saying, ‘The guy is alright.’ ”

After work, Salahi went to his mother’s house. Two intelligence officers, including Yacoub, arrived and said that Abdellahi needed to see him again. One of the arresting agents suggested that Salahi drive his own car to the station, so that he could drive himself home afterward. Yacoub climbed into the passenger seat. “Salahi, I wish I were not part of this shit,” he said.

Neither of them knew that the United States had asked Mauritania’s President to hand over Salahi to a rendition team. “He was guilty of nothing,” Abdellahi told me, and he had not been charged with a crime. “That’s why we had previously let him go.” But, Abdellahi continued, shrugging, “to refuse a demand from an intelligence agency, in the fight against terrorism—that would have been impossible.”

On the evening of November 28th—Mauritania’s Independence Day—Salahi had been in custody for a week. Abdellahi had bought him a new outfit, but Salahi had refused to eat, and the fabric was loose on his shoulders. They drove to the airport in silence, in Abdellahi’s black Mercedes. “He was not happy—he didn’t want to leave,” Abdellahi told me. “But I wasn’t the decider. I was an agent of the state. I executed orders. And I knew that the request was justified, because he had connections in this milieu, these Islamo-terrorist circles, and he might be able to give his captors some ideas of how to improve security. That was my thinking—that he was sufficiently intelligent and well informed to help any intelligence service that might ask him for help.”

It was Ramadan again. “I pictured my family already having prepared the Iftar fast-breaking food, my mom mumbling her prayers while duly working the modest delicacies, everybody looking for the sun to take its last steps and hide beneath the horizon,” Salahi wrote. He and Abdellahi knelt on the runway, and prayed together.

A private jet landed, and out climbed a Jordanian rendition team. The lead officer couldn’t speak Mauritania’s Hassaniya Arabic, and Abdellahi hardly understood the Jordanian dialect, so Salahi translated for them. “He said he needs fuel,” Salahi explained to Abdellahi. (In his diary, Salahi wrote, “I was eager to let my predator know, I am, I am.”) When the conversation was over, the Jordanians blindfolded Salahi and put a set of soundproof earmuffs on him. Salahi was terrified. “I thought it was a new U.S. method to suck intels out of your brain and send them directly to a main computer which analyzes the information,” he wrote. “It was silly, but if you get scared you are not you anymore. You very much become a child again.”

In Amman, Jordan, Salahi was hooded and taken to a detention facility in the headquarters of the country’s General Intelligence Directorate. (After 9/11, the directorate acted as a proxy jailer for the C.I.A.) The interrogations covered the same topics as before: Abu Hafs; Al Qaeda’s training camps in 1992; the Millennium Plot. The Americans supplied the questions, and the Jordanians extracted the responses, often through coercive means. Salahi was asked about innocuous exchanges from intercepted e-mails and phone calls, as if they had been conducted in code. At other times, the questions originated from material on his hard drive, which the F.B.I. had copied in Nouakchott. Once, on a technical assignment, Salahi had been photographed near the President of Mauritania; now the lead interrogator accused Salahi of having plotted to kill him.

Still, Salahi found his Jordanian interrogators to be highly knowledgeable, and they developed a kind of mutual respect. “It is a fact that they understand this whole concept of terrorism much better than the average American interrogator,” Salahi said, in his military hearing. “They really know who is who,” and, as a result, “they were very reluctant to torture me. It was not every day, the torture—I would say maybe twice a week.” While other detainees were mercilessly beaten, strung up by their limbs, and sexually assaulted, he added, “all they did was strike me at different times in the face, and hit me against the concrete wall.”

The guards, who were officially prohibited from interacting with him, began asking questions. “Where are you from?” one of them said.

“Mauritania.”

“What are you doing in Jordan?”

“My country turned me over.”

“Are you kidding me?”

“No.”

“Your country is fucked up.”

The guards also brought him books from the library, including the Bible, which he had requested, he wrote, “because I wanted to study the book that must more or less have shaped the lives of the Americans.”

Every other week, when Red Cross representatives visited the prison, Salahi and a handful of other C.I.A. detainees were whisked to the cellar, to be hidden from view. In Nouakchott, Abdellahi waited for updates from the C.I.A. and the G.I.D., but received none. “I thought he’d be back in no time,” he told me.

Salahi’s family wasn’t notified of his rendition, and so they were surprised that Abdellahi refused to let them see him. According to one of Salahi’s brothers, Abdellahi told the family that Salahi was being kept in a detention facility in the desert, far from Nouakchott. (Abdellahi says that, after Salahi disappeared, the family never contacted him.) To insure Salahi’s upkeep, the family regularly gave Abdellahi’s men money, food, clothes, and gifts. In return, they passed along messages from Salahi, which they had invented, and assured the family that Salahi was well.

In Kandahar, Abu Hafs felt the Americans closing in. The Taliban was rapidly losing ground. On October 17, 2001, Abu Hafs’s madrassa took a direct hit from a missile. One day in November, after burying several friends, Abu Hafs sought out an Al Jazeera journalist. His turban was still damp from where his wife had cleaned off other people’s blood. “The Americans, with their policies, bore the fruit of the events of September 11th,” Abu Hafs said on camera. “Striking horror, panic, and fear in the hearts of the enemies of Allah is a divine commandment.” He added that American citizens should blame their law-enforcement and intelligence agencies—with their “satellites, ground stations, millions of spies, and huge budgets”—for the fact that the hijackers had “found a security breach as big as a whole fleet of hijacked civilian aircraft, and managed to shove America’s nose into the ground.”

By the second week of December, it was clear that Kandahar would fall. Bin Laden had fled to the mountains, and the remaining Al Qaeda leaders understood that, as Arabs and North Africans, they could never blend in with the locals, who spoke Dari, Pashto, Balochi, and other regional languages. (For the first several weeks of the invasion, Donald Rumsfeld, the Secretary of Defense, believed that everyone spoke “Afghan.”) In a rush to leave Kandahar, two dozen senior Al Qaeda officials boarded a bus, but Abu Hafs, fearful that a single air strike could decapitate the jihadi movement, urged them to disperse.

During the next several days, Abu Hafs travelled toward the Pakistani province of Balochistan. He slept in remote villages, and entrusted his life to Afghan sheepherders who were presumably unaware of the twenty-five-million-dollar bounty on his head. He wrote a letter to his wife and children, but there was no way to send it, and so he kept it in a pocket in his robes.

When Abu Hafs reached Quetta, in Pakistan, he found the city’s private hospital filled with injured Al Qaeda members. Taliban fighters walked the streets, confident in the support they received from Pakistan’s intelligence service. Abu Hafs, however, regarded the Pakistanis as duplicitous. (The C.I.A. came to much the same conclusion.) Bin Laden’s family was en route to Pakistan, and Abu Hafs needed to make arrangements for their protection. In deliberations with Al Qaeda leaders, he decided that the safest place was Iran.

On December 19th, Abu Hafs boarded a bus in Quetta, carrying a fake passport and a suitcase full of cash. An image of bin Laden’s face adorned the windshield, and Abu Hafs spent much of the journey to the Iranian border, some four hundred miles, wondering whether it was a “Wanted” poster or a tribute. At a Pakistani Army checkpoint, he slipped a wad of bills into his passport, and went through unquestioned.

In Iran, Abu Hafs was greeted by representatives of a secretive and élite Revolutionary Guard Corps unit that is responsible for protecting top officials. A few weeks later, Iranian spies told Abu Hafs to call other Al Qaeda officials and inform them that they would be welcome in Iran—although, like him, they would live with their wives and children under a form of house arrest, sometimes in prisons, sometimes in lavish compounds and hotels, always in the company of the Revolutionary Guard. The decision to simultaneously protect and detain Al Qaeda members was apparently made by Iran’s spy chief, Qassem Suleimani. Within a few months, dozens of Al Qaeda members were living in Tehran, undergoing occasional interrogations, aware that their Iranian hosts could betray them at any moment. Abu Hafs spent the next decade in relative luxury, exercising alongside foreign diplomats in one of Tehran’s swankiest gyms, and looking after bin Laden’s sons along with his own. The Pentagon had reported that he was dead.

On the night of July 19, 2002, the Jordanians transported Mohamedou Salahi, blindfolded and in chains, to the airport in Amman, where a new team took over. At first, Salahi was relieved—he assumed that the Americans had come to understand his irrelevance to 9/11 and the Millennium Plot, and that he was being sent back to Mauritania. Instead, the men stripped him naked, strapped a diaper on him, and swapped out his shackles for a heavier set. One of the men momentarily removed Salahi’s blindfold, and shined a flashlight into his eyes. Everyone on the team was dressed entirely in black, their faces obscured by balaclavas. They drove up to the stairs of an airplane, but, Salahi wrote, he was “so exhausted, sick, and tired that I couldn’t walk, which compelled the escort to pull me up the steps like a dead body.”

At sunrise, the plane landed at Bagram Airfield, the largest U.S. military base in Afghanistan. For the first time, Salahi was in the custody of uniformed American soldiers. “Where is Mullah Omar?” they asked. “Where is Osama bin Laden?” They shouted and threw objects against the wall. Salahi had been living in a cell practically since the beginning of the invasion, nine months earlier.

Military personnel took his biometric information, and logged his health problems—including a damaged sciatic nerve—then led him to a cell. The punishment for talking to another detainee was to be hung by the wrists, feet barely touching the ground. Salahi saw a mentally ill old man subjected to this method. “He couldn’t stop talking because he didn’t know where he was, nor why,” Salahi wrote.

During interrogations, an intelligence officer, known among the detainees as William the Torturer, forced Salahi into stress positions that exacerbated his sciatic-nerve issues. “His specialty was in brutalizing detainees who were considered important, but not valuable enough to get them tickets to the secret CIA prisons,” Salahi wrote. Another officer tried to build rapport with Salahi by speaking to him in German. “Wahrheit macht frei,” the officer said—the truth sets you free. “When I heard him say that, I knew the truth wouldn’t set me free, because ‘Arbeit ’ didn’t set the Jews free,” Salahi recalled. (The phrase “Work sets you free” appeared on the gates of Auschwitz and other Nazi concentration camps.)

Each detainee was given a number, and, on August 4th, thirty-four of those numbers were called, including Salahi’s. The men were dragged out of their cells. Military police officers put blackout goggles over their eyes and mittens on their hands, then hooded them, lined them up, and tied each detainee to the one in front of him and the one behind him. Then the men were loaded onto an airplane. “When my turn came, two guards grabbed me by the hands and feet and threw me toward the reception team,” Salahi wrote. “I don’t remember whether I hit the floor or was caught by the other guards. I had started to lose feeling and it would have made no difference anyway.”

For some thirty hours, Salahi was strapped to a board. Medical records indicate that he weighed a hundred and nine pounds—around thirty per cent less than his normal weight. He was belted so tightly that he struggled to breathe, but he didn’t have the English vocabulary to tell the guards.

Then, he wrote, the plane landed, the doors opened, and “the warm Cuban sun hit me gracefully. It was such a good feeling.”

ENEMY COMBATANTS

In the minutes before the first detainees set foot on Guantánamo, “you could literally hear a pin drop,” Brandon Neely, a military-police officer, recalled, in an interview with the Guantánamo Testimonials Project, at the University of California, Davis, in 2008. “Everyone, including myself, was very nervous,” he said. It was January 11, 2002. The Bush Administration had decided that the Geneva Conventions did not apply to the war on terror, which meant that the men captured abroad could be deprived of the rights of prisoners of war. That day, Neely’s job was to haul captives from a bus to a holding area for processing, and then to small, outdoor cages, where they would spend nearly four months sleeping on rocks, and relieving themselves in buckets, while soldiers constructed more permanent cellblocks. “I keep thinking, Here it comes—I am fixing to see what a terrorist looks like face to face,” Neely, who was twenty-one at the time, said.

The first man off the bus had only one leg. He wore handcuffs, leg shackles, earmuffs, blackout goggles, a surgical mask, and a bright-orange jumpsuit. As two M.P.s dragged him to the holding area, someone tossed his prosthetic leg out of the bus. All afternoon, guards screamed at the detainees to shut up and walk faster, called them “sand niggers,” and said that their family members and countries had been obliterated by nuclear bombs.

Later that day, Neely and his partner brought an elderly detainee to the holding area and forced him to his knees. When they removed his shackles, the man, who was shaking with fear, suddenly jerked to the left. Neely jumped on top of him, and forced his face into the concrete floor. An officer shouted “Code Red!” into a radio, and the Internal Reaction Force team raced to the scene and hog-tied him. He was left for hours in the Caribbean sun.

Neely later found out that the elderly detainee had jerked because, when he was forced to his knees, he thought he was about to be shot in the back of the head. In his home country, Neely said, “this man had seen some of his friends and family members executed on their knees.” The man’s response was hardly unique; a military document, drafted ten days later for the base commander, noted that “the detainees think they are being taken to be shot.”

Officially, the job of the Internal Reaction Force was to restrain unruly detainees, to prevent them from injuring themselves or the guards. But, in practice, “IRFing” was often done as a form of revenge, initiated liberally—for example, when a detainee was found to have two plastic cups instead of one, or refused to drink a bottle of Ensure, because he thought that he was being given poison. IRFing typically involved a team of six or more men dressed in riot gear: the first man would pepper-spray the detainee, then charge into the cell and, using a heavy shield and his body weight, tackle the detainee; the rest would jump on top, shackling or binding the detainee until he was no longer moving. Although many of the detainees arrived malnourished, with their bodies marked by bullet wounds and broken bones, some IRF teams punched them and slammed their heads into the ground until they were bloody and unconscious. “You could always tell when someone got IRFed, as the detainees throughout the camp would start chanting and screaming,” Neely recalled. Once, he watched an IRF team leader beat a detainee so badly that he had to be sent to the hospital and the floor of his cell was stained with blood; the next time the team leader was in the cellblock, another detainee yelled out, “Sergeant, have you come back to finish him off?”

In Islam, the Quran is considered the transcribed word of God; some Muslims keep the book wrapped in cloth, never letting it touch unclean surfaces. To dispel notions that the United States was at war with Islam, detainees were allowed to have private meetings with a Muslim military chaplain, and were given copies of the Quran. Some guards saw an opportunity to torment the detainees—by tossing the Quran into the toilet, for example, or by breaking the binding under the guise of searching for “weapons.” Desecration of the Quran provoked riots in the cellblocks, which resulted in IRF teams storming into the cells and beating up detainees.

One day, after an interrogator kicked a Quran across the floor, detainees organized a mass suicide attempt. “Once every fifteen minutes, a prisoner tried to hang himself by tying his sheet around his neck and fastening it through the mesh of the cage wall,” James Yee, an Army captain who served as the Muslim chaplain in Guantánamo, recalled in his memoir, “For God and Country,” from 2005. “As soon as the prisoner was taken to the hospital, another detainee would be found—his sheet wound around his neck and tied to his cage wall. The guards would rush in to save him and the chaos would start again. The protest lasted for several days as twenty-three prisoners tried to hang themselves.”

Military-police officers so frequently abused the Quran during cell searches that detainees demanded that the books be kept in the library, where they would be safe. Yee, who had converted to Islam in the early nineties, sent a request up the chain of command, but was rebuffed. “I felt this decision stemmed from the command’s desire to be able to tell the media that we gave all detainees a Quran out of sensitivity to their religious needs,” he wrote. The detainees protested, and so “it was decided that every detainee who refused the Quran would be IRFed.” While the detainees were receiving medical treatment for their post-IRF injuries, the Qurans were placed back in their cells.

In time, Yee came to believe that “Islam was systematically used as a weapon against the prisoners.” Guards mocked the call to prayer, and manipulated Islamic principles of modesty—by having female guards watch naked detainees in the showers, for example—to create tension as an excuse to exact violence. During interrogations, detainees were forced to perform mock satanic rituals, or were draped in the Israeli flag.

Donald Rumsfeld told reporters that the men in Guantánamo were “among the most dangerous, best-trained, vicious killers on the face of the earth.” But after Brandon Neely’s first shift, on the day the detention camp opened, “no one really spoke much,” he recalled. “I went back to my tent and laid down to go to sleep. I was thinking, Those were the worst people the world had to offer?”

Investigators had the same question. Shortly before the first detainees arrived, Robert McFadden, an N.C.I.S. special agent, was eager to receive the flight manifest. “I just couldn’t wait to see who the detainees were,” he told me. He had spent much of the past fifteen months in Yemen, investigating Al Qaeda’s bombing of the U.S.S. Cole, and hoped that some of the men who were being shipped to Guantánamo would have information about the case. But, when the list of detainees finally arrived, he recalled, “my reaction was, What the fuck? Who are these guys?” Most of the names were Afghan or Pakistani, “and the Arabs who were on the list certainly weren’t recognizable to me and my colleagues who had been working Al Qaeda for years.” A few weeks later, after McFadden visited the detention camp, he concluded that the detainees were “essentially nobodies.” He told me, “There was not anyone approaching even the most liberal interpretation of a ‘high-value detainee.’ ”

In Afghanistan, the U.S. military was inadvertently presiding over a kidnapping-and-ransom industry. Helicopters dropped flyers in remote Afghan villages, offering “wealth and power beyond your dreams” to anyone who turned in a member of Al Qaeda or the Taliban. “You can receive millions of dollars,” one of the flyers said. “This is enough money to take care of your family, your village, your tribe for the rest of your life.” A common bounty was five thousand dollars—far more money than most Afghans earned in a year—and “the result was an explosion of human trafficking” by various armed groups, Mark Fallon, the deputy commander of Guantánamo’s Criminal Investigation Task Force, wrote in his memoir, “Unjustifiable Means,” which was heavily redacted before being published, in 2017. As Michael Lehnert, a Marine Corps major general who briefly served as the detention camp’s first commander, later testified to Congress, “What better way to enrich yourself, while resolving old grudges, than to finger a neighbor who was your enemy, regardless of his support for either Al Qaeda or the Taliban?”

According to Fallon, “The Northern Alliance would jam so many detainees into Conex shipping containers that they started to die of suffocation. Not wanting to lose their bounties, the captors sprayed the tops of the boxes with machine guns to open ventilation holes. A lot of these prisoners were actually looking forward to being handed over to the Americans, figuring it would be pretty obvious they weren’t Al Qaeda.” Yet hundreds of them were sent to Guantánamo Bay, which ended up housing seven hundred and eighty people.

In public, the Bush Administration and its military leadership asserted that Guantánamo was filled with men who would stop at nothing to destroy the U.S. But, on the base, Fallon and his colleagues referred to most detainees as “dirt farmers.” Lehnert lamented, “It takes an Army captain to send someone to Gitmo, and the President of the United States to get them out.”

Salahi was no dirt farmer. But the C.I.A., which spent the next few years shuffling its “high-value detainees” among so-called black sites in Africa, Asia, and Eastern Europe, had seen fit to transfer him into military custody. By the time Salahi arrived at Guantánamo, on August 5, 2002, Fallon’s élite interagency criminal-investigation task force had been sidelined, and Lehnert had been replaced.

The leadership at Guantánamo was more interested in intelligence collection than in prosecuting detainees for terrorism crimes. But, when the new commander asked Stuart Herrington, a retired colonel and Army intelligence officer, to assess operations at the facility, Herrington found that most interrogators lacked the training and the experience required to be effective. Only one of the twenty-six interrogators was capable of working without an interpreter. Herrington later reported that the interrogators were unsure of the real names of more than half the detainees.

According to Fallon, most of the interrogators were “basically conscripts” who would “walk into a room for the first time thinking the detainee was just waiting to be cracked open and they were the next Jack Bauer,” the fictional protagonist of “24,” who used abusive tactics to elicit information and save his city from terrorist attacks. They went through checklists of questions that had been developed by their superiors, and seemed impervious to nuance, or to the notion that some detainees may have been sent there in error. In response, detainees would stop coöperating and start chanting or praying; in an attempt to reassert control, Fallon wrote, “the interrogators would duct-tape their mouths, further guaranteeing that they wouldn’t get any information—and so it would go.” Nevertheless, he recalled, each failed interrogation “was taken as proof that the detainees were both Al Qaeda and trained to resist these methods.” In 2000, investigators in northern England had discovered a jihadi field manual that included advice on lying to captors. Now, faced with their own incompetence, Fallon wrote, interrogators “were quick to blame ‘classic Manchester resistance tactics!’ ”

Salahi’s detainee dossier lists his “reasons for transfer” to Guantánamo: “to provide information” on the Al Qaeda training camp he had attended in 1992; a separate Afghan militia, which had received substantial backing from the C.I.A.; mosques in Duisburg; and his cousin Abu Hafs al-Mauritani. (They were no longer brothers-in-law, as Salahi and his wife had divorced.) Notably absent is any mention of the Millennium Plot, or any allegation that Salahi had committed a crime.

After Salahi was processed, he spent thirty days in a cold isolation cell, a practice that the U.S. government considered “a main building block of the exploitation process,” as it “allows the captor total control over personal inputs.” When the isolation period was over, Salahi learned from other detainees that there was a difference in opinion between those who had lived in European democracies and those who had lived only in Muslim countries, with the latter group arguing that America’s war on terror was an anti-Muslim crusade. Salahi tried to convince the skeptics that their arrival in Cuba was “a blessing,” and that they would be treated fairly and exonerated by the American justice system. But, “with every day going by, the optimists lost ground,” he wrote. Bush Administration lawyers had taken the position that “enemy combatants” could be held indefinitely, without trials, and that in order for something to qualify as “torture” it “must be equivalent in intensity to the pain accompanying serious physical injury, such as organ failure, impairment of bodily function, or even death.” By the end of the following year, Salahi knew more about classified security operations than any private American citizen. The gulf between the U.S. government’s public disclosures and its secret practices was etched into his body and his mind.

In 1967, Martin Seligman, a twenty-four-year-old Ph.D. student in psychology, conducted an experiment that involved delivering electric shocks to dogs in various states of restraint. The goal was to assess whether inescapable pain could condition an animal into “learned helplessness,” whereby it simply accepts its fate. Thirty-five years later, the United States government drew inspiration from this experiment in its approach to interrogating terror suspects.

The plan, conceived by James Mitchell, a psychologist working on contract for the C.I.A., was to induce learned helplessness in humans by combining an individually tailored regimen of torture techniques with environmental manipulation. The techniques—which government documents identify as “omnipotence tactics,” “degradation tactics,” “debilitation tactics,” and “monopolization of perception tactics”—had been developed by Communist forces during the Korean War, to coerce prisoners into making false confessions, for propaganda purposes. Since then, the U.S. military has exposed some élite soldiers to the techniques, to prepare them for the kinds of abuses they might encounter should they be captured by terrorist groups or governments that don’t abide by the Geneva Conventions. Mitchell argued that, by reverse-engineering this program, interrogators could overwhelm whatever resistance training a detainee might have absorbed from the Manchester manual. What followed was a period of experimentation—overseen by psychologists, lawyers, and medical personnel—at C.I.A. black sites and military facilities. In September, 2002, Army officers started referring to Guantánamo as “America’s Battle Lab.”

Early in the afternoon of October 2, 2002, a group of interagency lawyers and psychologists met to come up with a framework that used “psychological stressors” and environmental manipulation to “foster dependence and compliance.” The C.I.A. had been torturing detainees at black sites for several months; now the Guantánamo leadership wanted to understand the legal gymnastics that would be required to implement a program of their own. “Torture has been prohibited by international law, but the language of the statutes is written vaguely,” Jonathan Fredman, a senior C.I.A. lawyer, said, according to the meeting minutes. “It is basically subject to perception. If the detainee dies, you’re doing it wrong.” (Fredman has disputed the accuracy of the meeting minutes.)

Later that month, a military lawyer named Diane Beaver drafted a legal justification—described later by a congressional inquiry on torture as “profoundly in error and legally insufficient”—for a set of abusive interrogation techniques. Among such methods as forced nakedness, dietary manipulation, daily twenty-hour interrogations, waterboarding, exposure to freezing temperatures, and the withholding of medical care, Beaver endorsed “the use of scenarios designed to convince the detainee that death” was “imminent.” (She later expressed surprise that her legal opinion had become “the final word on interrogation policies and practices within the Department of Defense.”) An accompanying memo, drafted by a military psychologist and a psychiatrist, explained that “all aspects of the environment should enhance capture shock, dislocate expectations, foster dependence, and support exploitation to the fullest extent possible.”

In November, 2002, the set of proposed techniques landed on Donald Rumsfeld’s desk. He signed it. “Why is standing limited to 4 hours?” he wrote in the margin, referring to a proposed stress position. “I stand for 8-10.”

By the spring of 2003, Salahi had been visited in Guantánamo by investigators from Canada and Germany, and questioned by various U.S. government agencies. He had come to think of himself as “a dead camel in the desert, when all kinds of bugs start to eat it.” Most of the interrogations were conducted by the F.B.I., whose questions now centered on establishing a connection between Salahi and 9/11. They showed him photos of various hijackers, and one of Ramzi bin al-Shibh, the attack coördinator, who had been captured in Pakistan. “I figured I’ve seen the guy, but where and when?” Salahi wrote in his diary.

Eventually, Salahi understood that bin al-Shibh was one of the three men who had stayed at his apartment in Germany for a night, in October, 1999; the other two had become 9/11 hijackers. Now bin al-Shibh, who was being tortured in C.I.A. custody, claimed that Salahi had recruited him into Al Qaeda. “In fact, I’d say, without you, September 11th would never have happened,” one of Salahi’s interrogators told him. Salahi was horrified. “I was, like, Maybe he’s right.” (In fact, the 9/11 plot was organized more than a year before bin al-Shibh visited Duisburg.) For the rest of the interrogation session, he was forced to look at photos of corpses from the aftermath of the attacks.

On May 22nd, Salahi’s lead F.B.I. interrogator told him that the military would take over his interrogation. “I wish you good luck,” the agent said. “All I can tell you is to tell the truth.” They hugged. The F.B.I. team left Guantánamo, and the torture began.

Special Projects

The cell—better, the box—was cooled down to the point that I was shaking most of the time. I was forbidden from seeing the light of the day; every once in a while they gave me a rec-time at night to keep me from seeing or interacting with any detainees. I was living literally in terror. For the next seventy days I wouldn’t know the sweetness of sleeping.

Twenty-hour interrogations. “You know, when you just fall asleep and the saliva starts to come out of your mouth?” Salahi said. No prayers, no information about the direction of Mecca. No showers for weeks. Force-feeding during the daylight hours of Ramadan, when Muslims are supposed to fast. “We’re gonna feed you up your ass,” an interrogator said.

Medical personnel had noted that Salahi had sciatic-nerve issues; now interrogators kept him in stress positions that exacerbated them. No chairs, no lying down, no more access to his prescription pain medication. “Stand the fuck up!” an interrogator said. But Salahi was shackled to the floor, so he could do so only hunched over. He stayed that way for hours. The next time the Red Cross delegation visited Guantánamo, a representative reported that “medical files are being used by interrogators to gain information in developing an interrogation plan.”

Female interrogators groped him. They stripped, and rubbed their bodies all over his, and threatened to rape him. “Oh, Allah, help me! Oh, Allah, have mercy on me!” one of them said, mockingly. “Allah! Allah! There is no Allah. He let you down!” An interrogation memo listed plans to shave Salahi’s head and beard, dress him in a burqa, and make him bark and perform dog tricks, “to reduce the detainee’s ego and establish control.”

The interrogators head-butted him, and made degrading remarks about his religion and his family. They kept him in alternately hot and cold cells, blasted him with strobe lights and heavy-metal music, and poured ice water on him. One day they would deprive him of food, and the next they’d force him to drink water until he vomited. According to interrogation memos, they decorated the walls with photos of genitalia, and set up a baby crib, because he was sensitive about the fact that he had no children.

On July 17, 2003, a masked interrogator told Salahi that he had dreamed that he saw other detainees digging a grave and tossing a pine casket with Salahi’s detainee number into it. The interrogator added that, if Salahi didn’t start talking, he would be buried on “Christian, sovereign American soil.”

On August 2nd, military records show, an interrogator told Salahi that he and his colleagues “are sick of hearing the same lies over and over and over and are seriously considering washing their hands of him. Once they do, he will disappear and never be heard from again.” Salahi was told to imagine “the worst possible scenario he could end up in,” and that he would “soon disappear down a very dark hole. His very existence will become erased. His electronic files will be deleted from the computer, his paper files will be packed up. . . . No one will know what happened to him, and eventually, no one will care.”

That day, the leader of Salahi’s interrogation came in. He identified himself as Captain Collins, a Navy officer who had been sent to Guantánamo by the White House. (His name was actually Richard Zuley; he was a Chicago police detective, working as a military contractor, who has an extensive record of abusing suspects until they confessed to crimes that they hadn’t committed. He did not respond to requests for comment.) Zuley read Salahi a letter, later shown to be forged, stating that his mother was in U.S. custody and might soon be transferred to Guantánamo. According to government records, “the letter referred to ‘the administrative and logistical difficulties her presence would present in this previously all-male prison environment,’ ” implying that she would be raped.

On August 13th, Donald Rumsfeld authorized the interrogation plan for Salahi. The document he signed listed one aim of the abuse as to “replicate and exploit the ‘Stockholm Syndrome,’ ” in which kidnapping victims come to trust and feel affection for their captors.

Twelve days later, a group of men charged into Salahi’s cell with a snarling German shepherd. They punched Salahi in the face and the ribs, then covered his eyes with blackout goggles, his ears with earmuffs, and his head with a bag. They tightened the chains on his ankles and wrists, then threw him into the back of a truck, drove to the water, and loaded him into a speedboat. “I thought they were going to execute me,” Salahi wrote.

He was driven around for three hours, to make him think that he was being transported to a different facility. He was forced to swallow salt water, and, every few minutes, the men packed ice cubes between his clothes and his skin. When the ice melted, they punched him, then repacked the ice to freeze him again. By the end of the boat ride, Salahi was bleeding from his ankles, mouth, and wrists. Seven or eight of his ribs were broken.

Back on land, Salahi was carried to Echo Special, the trailer, which would be his home for several years. For the next month, he was kept in total darkness; his only way of knowing day from night was to look into the toilet and see if there was brightness at the end of the drain. “To be honest I can report very little about the next couple of weeks,” Salahi wrote, “because I was not in the right state of mind.”

Soon afterward, an interrogator e-mailed Diane Zierhoffer, a military psychologist, with concerns about Salahi’s mental health. “Slahi told me he is ‘hearing voices’ now,” the interrogator wrote. “Is this something that happens to people who have little external stimulus such as daylight, human interaction etc???? Seems a little creepy.”

“Sensory deprivation can cause hallucinations, usually visual rather than auditory, but you never know,” Zierhoffer replied. “In the dark you create things out of what little you have.”

“Had I done what they accused me of, I would have relieved myself on day one,” Salahi wrote in his diary. “But the problem is that you cannot just admit to something you haven’t done; you need to deliver the details, which you can’t when you hadn’t done anything. It’s not just, ‘Yes, I did!’ No, it doesn’t work that way: you have to make up a complete story that makes sense to the dumbest dummies. One of the hardest things to do is to tell an untruthful story and maintain it, and that is exactly where I was stuck.”

On September 8th, Salahi asked to speak to Zuley. By now, he had enough information about the kind of story he had to craft, because, he wrote, “through my conversations with the FBI and the DoD, I had a good idea as to what wild theories the government had about me.”

Zuley walked in, and Salahi started lying. But it wasn’t enough; the government wanted him to link other people in Canada to various plots. Salahi figured that this was how bin al-Shibh had ended up naming him as a high-level Al Qaeda recruiter. He recalled, “I took the pen and paper and wrote all kinds of incriminating lies about a poor person who was just seeking refuge in Canada and trying to make some money so he could start a family. Moreover, he is handicapped. I felt so bad, and kept praying silently, ‘Nothing’s gonna happen to you dear brother.’ ”

The abuse wound down slowly—no more hitting, but no “comfort items,” either, and no uninterrupted periods of rest. James Mitchell, the C.I.A. contract psychologist who devised the enhanced-interrogation program, describes this period as an element of “Pavlovian conditioning,” in which the detainee sees his situation improve or deteriorate in direct accordance with his level of compliance.

One day, Zuley walked into Salahi’s cell, carrying a pillow. In time, he was given back his pain medication. Then he was prescribed antidepressants.

In mid-November, Salahi voluntarily sat for a polygraph test. The examiner described Salahi, whose answers contradicted everything he had confessed to Zuley in the preceding weeks, as “eager to prove that he is providing accurate information.” The results were decisive: “No deception indicated.”

On February 14, 2004, Salahi received a short letter from his mother in Mauritania, informing him that her “health situation is OK.” It had been eight hundred and fifteen days since he had seen her—an ailing woman in the rearview mirror, waving from the street as he drove to Deddahi Abdellahi’s intelligence headquarters. In all this time, his family had had no official confirmation of his whereabouts. Salahi’s brother, who is a German citizen, had read in Der Spiegel that he was in Guantánamo, but Abdellahi insisted that it wasn’t true—that he was looking after Salahi in a Mauritanian prison. Meanwhile, his subordinates continued to collect bribes from Salahi’s family.

Mohamed Elmoustapha Ould Badre Eddine, a left-wing member of the Mauritanian Parliament, conducted inquiries of his own, but made no progress. Badre Eddine had spent some four decades organizing grassroots campaigns against the practice of slavery and other human-rights violations, and for this he had spent years in remote detention sites, under a succession of authoritarian regimes. Throughout 2002 and 2003, whenever the foreign minister visited the parliamentary chamber, Badre Eddine demanded to know Salahi’s whereabouts. Each time, the minister lied—even after the Red Cross had started delivering Salahi’s letters from Guantánamo to his family.

In 2005, Mauritania had a military coup—the typical way in which power has changed hands since independence. “Each government claims that it has come to the rescue of the population, which had been neglected and abused by the previous government,” Badre Eddine told me. “And then it behaves the same way as the last.” When he asked the new regime about Salahi, he said, “they just replied, ‘We didn’t kidnap him—it was the previous government that did it. And now he belongs to the Americans.’ ”

From the floor of Parliament, Badre Eddine noted that Mauritania has no extradition treaty with the United States. “He was a victim of an extremely rare crime: that a country had kidnapped its own citizen and handed it over to a foreign country, outside of the justice system, outside of all legal processes,” Brahim Ebety, the Salahi family’s lawyer in Nouakchott, told me. Under the new regime, Abdellahi, the spy chief, was demoted, and given the task of investigating corruption and malfeasance within the security services; the standard path for accountability required Abdellahi to investigate himself.

Steve Wood walked into Echo Special in the spring of 2004 unaware of everything that had happened before. His was the first guard force that didn’t wear masks, that allowed Salahi to pray. Outside of the political discussions, he and Salahi passed the hours playing rummy, Risk, and chess. When Salahi’s female interrogators came in for a game of Monopoly, Salahi always threw the match. “My interest is not to be tortured,” he said. “And Steve’s interest is to impress the girls. So, completely different goals in life.”

Sometimes Wood opened Salahi’s Quran to a random page and told him the verse number, and Salahi would recite it aloud from memory, first in Arabic, then in English. It was the first time Wood had encountered the Quran. He wanted to ask Salahi more about its contents, but he suspected that there were microphones and cameras in the cell. Outside Echo Special, Wood started reading about Guantánamo on activist Web sites, but a colleague warned him that Internet traffic was monitored on the base. He began to worry that awareness among his co-workers of his increasingly complex feelings toward Salahi might elicit accusations that he was unpatriotic, or an insider threat. “I tried to make my time there morally neutral, without being called a traitor,” he told me. “I was scared to ask too many questions, I was scared to read a book on Islam while I was in there, or show too much interest.”

Wood’s concerns were not unjustified. While Salahi was being tortured, James Yee, the Muslim military chaplain, discovered that he and the interpreters at Guantánamo—many of whom were Muslim Americans, with Middle Eastern backgrounds—were being spied on by law-enforcement and intelligence officers. When Yee went on leave, he flew to Jacksonville, Florida, where he was interrogated and arrested, then blindfolded, earmuffed, and driven to a Navy brig in South Carolina. For seventy-six days, he lived in solitary confinement, in a cold cell with surveillance cameras and the lights always on. Government officials suggested that Yee was running an elaborate spy ring—that he and other Muslims had “infiltrated” the military, and represented the gravest insider threat since the Cold War. Based on a misreading of materials in his possession, and the vague aspersions of Islamophobic military officers, prosecutors accused him of treason and “aiding the enemy,” and threatened to pursue the death penalty. (All charges were later dropped, and Yee was honorably discharged.)

In October, 2004, Wood’s girlfriend gave birth to a daughter, Summer. Seven months later, his deployment ended. Before leaving Guantánamo, he gave Salahi a novel by Steve Martin, “The Pleasure of My Company.” “Pillow, good luck with your situation,” he wrote inside. “Just remember Allah always has a plan. I hope you think of us as more than just guards. I think we all became friends.” But he wasn’t sure that Salahi believed him. “The whole time I was thinking, you know, What does he really think of us?” he recalled. “What if he is, like, ‘I hate these sons of bitches for locking me up’? And Mohamedou probably thought I was thinking the same thing—that, to me, he was just a job, and nothing more.” So, during one of his final shifts, Wood broke protocol and showed Salahi a photo of Summer. “It was my way of telling him, ‘Man, I trust you. This is my daughter. She is my life. This friendship is real.’ ”

Salahi saw no path out of Guantánamo. Even if the military believed he was innocent, he figured that he knew too much about classified torture programs to be let out into the world. By the time Wood left, he had come to accept his guards and interrogators as family. “True, you didn’t choose this family, nor did you grow up with it, but it’s a family all the same,” he wrote in his diary. “Every time a good member of my present family leaves it feels as if a piece of my heart is being chopped off.”

He often turned to a verse by the Iraqi poet Ahmed Matar:

I stood in my cell
Wondering about my situation
Am I the prisoner, or is it that guard standing nearby?
Between me and him stood a wall
In the wall, there was a hole
Through which I see light, and he sees darkness
Just like me he has a wife, kids, a house
Just like me he came here on orders from above.

Having accepted his guards, Salahi wrote, the next phase of captivity was “getting used to the prison, and being afraid of the outside world.”

The Outside World

A year in Echo Special shattered Wood’s ideas about his post-military future. Before his deployment, he had aspired to become a police officer. “But I changed my mind after Guantánamo,” he told me. He wanted no part of a system in which he might have control over another person’s liberty. “I don’t like power,” he said. He left the Oregon National Guard, and started working night shifts at a twenty-four-hour gym near Portland. Few people worked out at two or three in the morning, so he had plenty of time to continue his self-education on global affairs. He started in on the books he had been too afraid to request in Guantánamo—ones about Islam.

Wood had come to see Islam in much the same way that many of the detainees did: as the only thing that couldn’t be stripped from them. The devotion, the routine of the five daily prayers—“that kept Mohamedou going,” Wood told me. Now, as he read, “I saw how beautiful the religion was,” he said. On most days, he searched Salahi’s name online, hoping to learn more about the case, and to make sense of his own deployment to Echo Special, to no avail. He found it almost impossible to reconcile the news coverage of Guantánamo Bay with what he had witnessed there. As he read about Islamic history, he began to seek clarity in the Quran itself.

In 2006, Wood removed his shoes at the entrance to the Masjid As-Saber, Portland’s largest mosque. He wasn’t sure what he wanted out of the visit—he knew only that curiosity eclipsed his misgivings. During the next few months, Wood showed up between prayer times, to avoid any pressure to participate. On his third visit, he told two Saudi students that he wanted to become a Muslim. Conversion to Islam requires only that, in the presence of Muslim witnesses, you declare the Shahada—“There is no God but God, and Muhammad is his prophet”—and that you believe it in your heart. The students acted as Wood’s witnesses.

Wood started sporadically attending prayers. An elderly white convert warned him to avoid a couple of other white converts, who dressed in religious clothing and talked about wanting to participate in the jihad. When Wood told the old man that he had worked at Guantánamo Bay, the man suggested that he keep it to himself. Soon afterward, Wood learned that the imam, a Somali immigrant who practiced a conservative strain of Islam known as Salafism, had been the subject of F.B.I. investigations and was on a no-fly list, and that several men who had attended the Masjid As-Saber had been convicted on terrorism charges. “So that scared me away,” he said. He stopped praying in public. “I just wanted this to be me and God.”

By now, Wood was no longer dating Summer’s mother. In 2008, he met a woman named Wendy at a bar. They married in 2010, and had a child six years later. He never told Wendy about his conversion.

The United States leases the land beneath the Guantánamo Bay detention facility from Cuba, for four thousand and eighty-five dollars a year, under an agreement signed after the Spanish-American War. (For the past sixty years, the Cuban government has sought to nullify the agreement, and it refuses to cash the checks.) Because detainees are not in U.S. territory, the government has not allowed them to be tried in U.S. courts. Instead, they are tried by secret military commissions—if they are tried at all. More detainees have died at Guantánamo than have been convicted of a crime.

The prosecutor assigned to Salahi’s case was a lieutenant colonel named Stuart Couch, who had retired from the military before 9/11. A close friend of his had been the co-pilot of one of the planes that was flown into the World Trade Center, and Couch told the Wall Street Journal that he had reënlisted because he wanted “to get a crack at the guys who attacked the United States.” When he saw the government’s file on Salahi, he considered pursuing the death penalty.

Couch never met Salahi, but, while Zuley was torturing him, Couch received summaries of each new confession. In late 2003—a period that Salahi described in a letter as “where my brake broke loose”—Couch struggled to keep up with the constant stream of information. In time, he became suspicious that Salahi’s confessions had been elicited through torture, and were therefore tainted evidence. When he discovered the forged letter from Zuley’s team, saying that the United States had captured Salahi’s mother, he resigned from the case.

In June, 2004, the Supreme Court ruled that Guantánamo detainees could challenge the grounds for their detention. It became fashionable for high-profile corporate-law firms to represent Guantánamo clients, pro bono, but many detainees rejected representation, because they thought it was a ploy to lend legitimacy to an unjust detention. Defense attorneys have accused the government of denying them access to evidence, leaving secret recording equipment in client meeting rooms, and infiltrating their legal teams; a few years ago, Ramzi bin al-Shibh, who may face the death penalty, recognized a linguist on his own defense team from a C.I.A. black site.

When Salahi’s lawyers wrote to him, asking that he inform them of everything he had told the government, he wrote back, “Are you out of your mind! How can I render uninterrupted interrogation that has been lasting the last 7 years. That’s like asking Charlie Sheen how many women he dated.” The important stuff was in his diary, he said, which they could read only inside a secure facility near Washington, D.C.

In the military hearing, Salahi described the torture program in vivid detail. The transcript omits much of his testimony, noting that, at the moment he started to describe the abuse, “the recording equipment began to malfunction” and that the tapes were “distorted.” The transcript continues, “The Detainee wanted to show the Board his scars and location of injuries, but the board declined the viewing.” (By now, the U.S. government was rolling back authorizations for torture techniques, and the military and the C.I.A. were entering a period of self-reflection; during the next several years, internal and congressional investigations would expose many of the worst abuses that had been inflicted on Salahi and other men in custody.)

The government no longer attempted to prosecute Salahi—nobody had touched the criminal case since Couch withdrew—but it argued that he should nevertheless be detained indefinitely. On March 22, 2010, a U.S. district-court judge named James Robertson ruled on Salahi’s petition to be released. “The government’s case, essentially, is that Salahi was so connected to al-Qaida for a decade beginning in 1990 that he must have been ‘part of’ al-Qaida at the time of his capture,” Robertson wrote. But the government had “abandoned the theory” that Salahi knew about 9/11 before it happened. As for his jihadi connections, Robertson continued, the government’s classified filings “tend to support Salahi’s submission that he was attempting to find the appropriate balance—avoiding close relationships with al-Qaida members, but also trying to avoid making himself an enemy” of the group. In Robertson’s assessment, the government’s evidence about Salahi was “so attenuated, or so tainted by coercion and mistreatment, or so classified, that it cannot support a successful criminal prosecution.” He concluded, “Salahi must be released from custody.”

Steve Wood was elated when he heard the news. But the government appealed, and Salahi stayed in Guantánamo. Wood contacted one of Salahi’s lawyers, using a made-up name and a new e-mail address, to inquire about Salahi’s well-being and the status of his case. But he subsequently forgot the log-in information, and so he never saw a reply. A couple of years later, he considered visiting Mauritania, to track down Salahi’s family and apologize for his role in Salahi’s detention. He no longer derived much solace from Islam, and rarely prayed. The decision to keep his conversion a secret from everyone in his life made him feel at times as if being Muslim were wrong, even though, in his heart, he still believed.

In 2012, Salahi’s lawyers won a seven-year legal battle to declassify his diary. Government censors redacted names, dates, locations, and other sensitive or embarrassing information. When they finished, Salahi’s lawyers delivered a CD-rom with the scanned pages to Larry Siems, a writer and a human-rights advocate, who has written extensively on government misconduct in the aftermath of 9/11. “There was a really profound sense of responsibility and ethical risk which came with editing the manuscript of someone who was alive but unable to participate in that process,” Siems told me. “I petitioned the Defense Department to allow me to show him the edited manuscript, but they turned me down.” In 2015, it was published, by Little, Brown, as “Guantánamo Diary.”

Soon afterward, in Guantánamo Bay, Salahi saw his own face on a TV screen. Siems was doing an interview about the diary, and in that moment Salahi finally felt as if he was beginning to take back the narrative of his life. “My cell expanded, the lights became brighter, colors more colorful, the sun shone warmer and gentler, and everyone around me looked friendlier,” he wrote.

Another year passed. Every time there was a hurricane warning in Guantánamo Bay, Salahi dreamed that the storm had wiped away the prison camp, and everyone, detainees and captors alike, was “fighting side by side to survive,” he wrote. “In some versions I saved many lives, in others I was saved, but somehow we all managed to escape, unharmed and free.”

Wood reconnected with Salahi’s lawyers, this time using his real name. When he learned that a military review board would consider releasing Salahi, he wrote a letter saying that, “based on my interactions with Mr. Slahi in Guantánamo, I would be pleased to welcome him into my home,” and offering to testify in person. He also contacted another guard from Echo Special. According to Wood, the guard drafted a note, but he decided not to submit it. “All his friends and family knew him as the guy who was guarding a high-value detainee, and really proud of it,” Wood told me. “His whole reputation rested on this fiction. But, after the diary came out, they learned that Mohamedou is not high value, he’s just a guy who got fucked over for years.” He added, “Guantánamo has a long shadow for everyone—not just the detainees.”

One night in October, 2016, Wood’s phone rang while he was in a Safeway in Portland. On the other end of the line was a man whose voice he hadn’t heard in more than eleven years. Salahi told him that he was now home. So much had changed since he had been taken into custody, more than fifty-four hundred days earlier. His mother was dead, and so was one of his brothers, but there were teen-age nieces and nephews whom he was meeting for the first time. The proceeds from his book were paying for a niece’s studies in Dubai and a nephew’s master’s degree in applied mathematics at a university in Kuala Lumpur. Salahi told Wood that he had written four more books in detention, but he hadn’t been allowed to take them out of Guantánamo. One was a self-help book about finding happiness in a hopeless place.

Wood told Salahi that he was working for his brother’s construction company, repairing bridges. The hours were unpredictable, with long drives and arduous shifts. As at Guantánamo, he often worked at night. But he derived immense satisfaction from the work, and saw in it the kind of moral clarity that Guantánamo had lacked. When I visited Wood, last August, he and his team were layering the surface of a bridge near Dayton, Oregon, with epoxy, rocks, and primer. “The point is to pave, seal, and waterproof it, to preserve its lifespan,” he said. We got to the site at sunrise; the sky was a hazy, muted orange, from wildfires burning to the south. “It takes a lot of prep to start the job, but, when you’ve done your bit, you’re leaving things better than when you arrived,” he said.

Salahi’s freedom became a strain on Wood’s marriage. Wood became secretive about his calls with Salahi; Wendy began to suspect that he was having an affair. When Wood agreed to talk about Salahi for a TV documentary, Wendy’s parents staged an intervention. “They said I was bringing shame upon the family, and protecting a terrorist,” Wood recalled. When he refused to back out of the interview, Wendy insisted that he wear an on-camera disguise. She told me that she thought he was doing something really dangerous—that people might think Steve was sympathetic to someone who was involved in 9/11, and go after him, her, and their baby daughter. Soon afterward, Steve and Wendy separated.

Last May, one of Salahi’s cousins posted a note on Facebook that referred to Wood’s conversion. When Wendy saw the post, she was outraged—but also somewhat relieved, since it partly explained his secretive behavior. “And I didn’t confirm or deny anything,” Wood told me. “I just kind of shrugged it off, like, What does it matter?” They decided to get a divorce. When I visited their house, a real-estate agent had removed all the family photographs and replaced them with catalogue art, to make it easier for prospective buyers to think of the house as a blank slate.

Dissonance

Larry Siems visited Salahi in Mauritania, and they set about filling in the redactions in the book. In the first edition of “Guantánamo Diary,” Siems had included an author’s note:

In a recent conversation with one of his lawyers, Mohamedou said that he holds no grudge against any of the people he mentions in this book, that he appeals to them to read it and correct it if they think it contains any errors, and that he dreams to one day sit with all of them around a cup of tea, after having learned so much from one another.

In the restored edition, Salahi added, “I want to repeat and affirm this message here, and to say that now that I am home, that dream is also an invitation. The doors of my house are open.”

This winter, Steve Wood set off for Mauritania. The journey to Nouakchott took almost three days, with long layovers in New York and Casablanca. Mauritanian immigration officials detained him for an hour—here was a giant American, all muscle and veins, saying that he had met Salahi in Guantánamo Bay—but eventually one of Salahi’s nephews persuaded them to let Wood in.

Near the airport parking lot, Salahi stood in a light-blue boubou, the traditional Mauritanian robe, with a turban to obscure his identity. “Bet you’ll think twice next time about saying you know me,” he said, laughing. As they walked to the car, Salahi dug into Wood’s personal life. “Man, you’ve had a really tough time of it,” he said. “Like, really stressful.” They slept under mosquito nets in Salahi’s bedroom, and woke up to the sound of a bleating sheep. Salahi noted that “Steve snores like—how do you call it?—a steam train.”

It was January 11, 2019—exactly seventeen years since the first detainees had arrived at Guantánamo Bay. (Forty people remain in the camp, at an annual cost of some ten million dollars a detainee.) Salahi had spent the morning reviewing a speech he had prepared for events hosted by Amnesty International and Physicians for Human Rights. In the two and a half years since his return, he has received several professional visitors—Siems, his lawyers, and the filmmaker Michael Bronner, who is adapting Salahi’s diary—and also personal visits from a lawyer, whom I’ll call Amanda. “We met like any decent person these days—on social media,” Salahi said. After she converted to Islam, they married in a religious ceremony. Now, in a phone call, Amanda suggested edits for Salahi’s speech—that he take out “lynching,” for example, and make his remarks more “gracious”—and Salahi accepted all of them.

Salahi and Wood sat in front of a laptop, with the Webcam on, and Skyped into a room in Washington. “Everything that happened to me—everything I witnessed in Guantánamo Bay—happened in the name of democracy, in the name of security, in the name of the American people,” Salahi told the audience at the Amnesty event. He added that, as the world’s most powerful democracy, the United States had “the means to uphold and pressure other countries to uphold human rights. But instead the United States is stating to the world very clear and loud that democracy does not work—that when you need to get down and dirty, you need a dictatorship. That dictatorship was built in Guantánamo Bay.”

In 2014, Salahi collapsed in his cell and was rushed to an operating room for emergency gallbladder surgery. But the procedure wasn’t carried out properly—he continued to be in pain—and by the summer of 2016 it was clear that he required corrective laparoscopic surgery. Military doctors offered to take care of it, but Salahi declined; his release date was only a couple of months away, and he wanted to get the surgery on his own terms, once he was free. Mauritanian hospitals don’t have the capacity—they typically send such patients to France—but what Salahi didn’t know was that his repatriation would not amount to the restitution of his rights. According to a senior U.S. diplomat, when the United States was negotiating the terms of his return, “the Mauritanians did agree that they would not give him a passport for some x amount of time.” Two and a half years later, Salahi and his lawyers have no clarity about the parameters of “x,” or about why the United States has any say in whether the Mauritanian government issues a passport to a Mauritanian.

In addition to Salahi’s abdominal pain, and regular migraines, he still suffers from night terrors. He often wakes up shaking, crying, and grinding his teeth. A private hospital in Germany has offered to cover the costs of Salahi’s gallbladder surgery, plus a year of physical and psychological rehabilitation, but without a passport he cannot travel to Europe. “I am denied my freedom because I was denied my freedom,” Salahi said. “A lot of wise people tell me, ‘Mohamedou, shut the fuck up, don’t ask for papers, don’t ask. Mauritania is much bigger than Guantánamo Bay—you can move around.’ But I insist on freedom.”

Another liberty Salahi identified as having been taken from him is that of expressing the full range of human feelings. “If you say that you are angry, it is understood as an emotion,” he said. “If I say that I am angry, it is seen as a threat to national security.”

The next day, Salahi brought Wood and me to a friend’s wedding party, hosted by Mauritania’s best radiologist. As we walked to the house, Abu Hafs al-Mauritani came out of a nearby mosque, dressed in a white turban and long robes. “Assalaamu alaikum,” he said to Mohamedou. “Peace be upon you.” They shook hands. Then Abu Hafs greeted Wood, who, appearing paralyzed by confusion, coldly took his hand. Abu Hafs walked into the house ahead of us, and disappeared into the crowd. Salahi generally avoids Abu Hafs—they have fundamentally different views of Islam, and he worries that any association could further complicate his life. (Until 2007, a terrorist sanctions list included Salahi’s name as an alias for Abu Hafs.)

It was a grand compound, white stone decorated with lavish carpets and chandeliers. The anteroom was filled with Mauritanian dignitaries and élites, all men, sitting on couches that lined the perimeter. Salahi and Wood went around the room shaking hands with bankers, merchants, prefects, doctors. There was a famous Mauritanian poet named Taki, the former minister of communications, the current Mauritanian Ambassador to Saudi Arabia.

Salahi and I sat on either side of the leader of a political party that has more than a hundred and fifty seats in Parliament. He was a tall, regal businessman, and wore Ted Baker sunglasses and a Rolex. During a lull in conversation, he turned to Salahi and, gesturing toward Wood and me, said, “So, you studied in the United States?”

“No, I’m an ex-prisoner of Guantánamo Bay,” Salahi replied, instantly ending the conversation.

After lunch, I stood in the reception area, watching Mauritanian politicians and tribal leaders kiss Abu Hafs on both cheeks and thank him for coming. A former leader of several provinces explained to me that Abu Hafs, bin Laden’s former Sharia adviser, is now an adviser to the President.

The next day, Abu Hafs invited me to his house, in one of Nouakchott’s most expensive neighborhoods. Until recently, the former spy chief Deddahi Ould Abdellahi lived directly across the street. I arrived just before the sunset prayers. Thirty or forty of Abu Hafs’s followers filled a small wooden shack next to his home, spilling into the street, while he led prayers through a microphone. It was a temporary facility, he explained, while he raises money to build a mosque.

After the prayer session, Abu Hafs led me into his living room, and for four hours he detailed his falling-out with bin Laden, his whereabouts and activities in the aftermath of 9/11, and his relationship with Mauritania’s President. “It’s not a formal position—there is no contract,” he said. “But I give him advice, and he takes it.”

Mauritania was the site of regular jihadi violence in the second half of the aughts, while Abu Hafs was living in Iran. But it stopped abruptly after a failed assassination attempt against the President, in 2011, which raised questions about whether he was cutting deals with Al Qaeda. That May, U.S. Navy Seals killed bin Laden, and collected more than a million documents from his compound in northern Pakistan; among them was a letter from Al Qaeda in the Islamic Maghreb, seeking the central leadership’s blessing to enter into a “secret agreement” with the Mauritanian government. “The Mujahideen are committed to not carry out any military activity in Mauritania,” the letter says—as long as the Mauritanian government released imprisoned fighters, abstained from attacking Al Qaeda cells abroad, and paid the group between ten and twenty million euros per year, “to compensate and prevent the kidnapping of tourists.” (The Mauritanian government has denied that it negotiates with terrorist groups.)

Around that time, Abu Hafs explained, it became clear to him that the Mauritanian President would be open to his return from Iran. He and his family had spent almost ten years under the protection of the Revolutionary Guard, but, with talk of the Obama Administration’s thaw in relations with Iran, Abu Hafs began to worry that he could be traded into U.S. custody. His wife and children left first; once they had settled in Nouakchott, Abu Hafs said, the challenge was to transport himself thousands of miles without being detected, arrested, or subjected to rendition.

One day in the spring of 2012, Abu Hafs slipped out of custody during a visit to the gym. He bolted through the changing room and into the street, dressed in his gym clothes, and hailed a taxi to the Mauritanian Embassy in Tehran. The Ambassador called Nouakchott, and the foreign minister ordered the Embassy to fabricate a passport, using a fake name.

When the documents were complete, Abu Hafs said, the Mauritanian government booked him on a commercial route that connected through three countries. The Ambassador drove him to Tehran’s international airport in a diplomatic vehicle, and accompanied him through the diplomatic channel, through airport security and immigration, right up until the moment he got on the plane.

Abu Hafs wouldn’t say which countries he had travelled through—only that, in the first two, the Mauritanian Ambassador met him on the tarmac, walked him through the airport, and stayed with him until he got on the next plane. In the third country, the Mauritanian foreign minister greeted Abu Hafs, and accompanied him on the flight to Nouakchott. There, Abu Hafs spent two months in custody, as a formality.

When I shared Abu Hafs’s account of his return with the senior U.S. diplomat, she replied, “It’s the first I’m hearing any of it.” The Mauritanians didn’t inform the United States of his return until “probably weeks later,” she said. “There was no fanfare, no announcement.” The Americans learned only that, “as a condition for return, he agreed that he would renounce his former association and embark on a message of denouncing terrorism and preaching a more tolerant and pacifist message.” I asked whether the United States, after learning of his return, had sought to detain or rendition him. “What would we tell the Mauritanians?” the diplomat replied. “It’s their citizen, and it’s their country.”

The lesson seemed to be that the right mix of atonement and seniority in a terrorist organization can give the kind of leverage that is unavailable to men like Salahi. I asked Abu Hafs to tell me the name printed in his diplomatic passport, assuming that the identity was no longer valid. He refused, saying that he didn’t want to jeopardize his future travel.

Wood stayed with Salahi for four days. They prayed together, ate together, and enjoyed a picnic of bread and tea in the dunes of the Sahara. One day, they had coffee at a hotel, by the pool, with the legal team of a current Guantánamo detainee. Soon afterward, in a room at the same hotel, the U.S. State Department hosted a training session for Mauritania’s security-intelligence apparatus, on “Interdiction of Terrorist Activities.” Salahi suffered night terrors, and Wood suffered a splitting headache from caffeine withdrawal. “Out here, I’m probably only drinking seven or eight coffees per day,” he told me. (During the layover in Casablanca, he had drunk a Red Bull and twenty-two shots of espresso.) Salahi handed him some leftover ibuprofen from the Guantánamo pharmacy.

For Wood, the trip became something more complicated than a visit to a friend. Salahi was on a publicity campaign, to draw attention to the injustice of his withheld passport, and at times it seemed to Wood as if he were a prop—the former guard who recognized Salahi’s innocence. TV crews were present at meals, and an interviewer showed up at Salahi’s apartment, recorder in hand, and asked Wood, who still hadn’t told his brothers that he is a Muslim, to comment on his favorite Quranic passages, and to share his thoughts on the legacy of the Prophet Muhammad. Wood complied—he felt that it was the least he could do for Salahi. During the Amnesty International live stream, someone on Twitter commented that, of the two of them, Wood looked like the detainee.

Another dissonance was that Salahi’s eloquent orations on fundamental human rights stopped short of confronting a reality that Wood noticed on the second day: as guests of Mauritanian élites, they were served lavish meals by people who appeared to be slaves. Although slavery was criminalized in 2007, Mauritanian human-rights advocates told me that the law was drafted to appease international organizations—that virtually nothing has changed. At an event, I exchanged phone numbers with an extremely submissive server who was dressed in ragged clothes and had a cloudy, damaged eye. The host, who was a government official, grew agitated, pulled me aside, and urged me not to mention that I had ever been to his house. “And, by the way, I pay my boy,” he added, unprompted.

I tried to press the topic with Salahi, but it was as if his transfer from Guantánamo had carried with it a kind of transposition of restraint, from shackles to self-policing. In 2005, during the military hearing, Salahi had urged the presiding officer not to send him back to Mauritania. “I want to go to a country where I can enjoy my freedom,” he said.

Wood left for the airport at 4 A.M. Salahi spent much of the day watching YouTube compilations of the worst “American Idol” auditions. “It’s so empty, now that Steve left,” he said to me. “So empty.”

In recent months, the push for Salahi’s passport has taken on new urgency. Amanda, who lives in Europe, was pregnant, and Salahi would miss the birth of his son. “Did you see what Steve brought me?” Salahi said, pointing to some baby clothes. “They look like a prison uniform with stripes! I think he still sees any baby in my family as a future inmate.” Brahim Ebety, Salahi’s Mauritanian lawyer, told me that he is considering a lawsuit against the Mauritanian government. “At the beginning, Mohamedou wanted to be docile and sweet,” he said. “But with these people you cannot be likable. You must be very tough. You must forget your fear to achieve anything.”

Last summer, Salahi completed an online course to become a certified life coach. He now has two American clients, whom he helps to navigate personal and professional woes through weekly Skype meetings. “I want to ask you a favor, if it is O.K. with you, and that is to tell me five things that you are grateful for today,” he told one of them. Sometimes the sessions veer into his own coping mechanisms—the routines he made up to fill his days in Guantánamo, for example, “when we had nothing to look forward to except the world we created inside my cell.”

Earlier this month, Amanda gave birth to a son. They named him Ahmed, and Salahi asked Wood to be the godfather. “There are so many Ahmeds that it’ll be difficult for them to put him on the no-fly list,” Salahi joked. On paper, Salahi is not listed as the father. But Amanda is an American, and so their son is now a citizen of the country whose purported values Salahi wants to believe in but has never seen. ♦

Read the whole story
ruairimccomb
2073 days ago
reply
Share this story
Delete

Java 9 and IntelliJ IDEA

1 Share

Java 9 is released today, so let’s do a quick recap of the Java 9 support in IntelliJ IDEA, and have a peek at some of the upcoming features in IntelliJ IDEA 2017.3 for Java 9.

Jigsaw & the JPMS

The big feature for Java 9 is, of course, the Java Platform Module System (JPMS), which comes under the umbrella Project Jigsaw.  Jigsaw itself is a much bigger undertaking and includes things like the modularisation of the JDK itself, what’s interesting to us as developers is the JPMS.

IntelliJ IDEA supports the Java Platform Module System with a number of features.

You can easily create a module-info.java file for your IntelliJ IDEA modules:

01-new-module-info

This will give you the basic structure of your module declaration, including a module name that matches the name of your IntelliJ IDEA module.  While you’re working in this file you get code highlighting and completion of course.

If you run code from a module with a module-info.java file, IntelliJ IDEA will automatically use the -p argument (module path) instead of -classpath.

03-module-path

IntelliJ IDEA also offers quick fixes for some of the common problems you’ll face as you migrate your code to the JPMS, such as the ability to add a “requires” directive

04-quick-fixes

or detection of duplicate directives or other errors that can be fixed

05-delete-duplicate

IntelliJ IDEA also lets you create module diagrams to help you visualise the modules you’re using.  You can see JDK modules, your own modules and automatic modules in different colours, and transitive requirements are highlighted with a stronger line.

These diagrams are particularly useful when you’re getting started with modularity, as they help you understand which modules you’re using and where they come from.  You can even navigate to the modules from the diagram.

IntelliJ IDEA has inspections to help migrate code to Java 9. For example, you can highlight the use of automatic modules.

07-automatic-modules

This means you can see if you’re dependent on something that isn’t a true Java 9 module. This is important as these automatic modules may change over time.

08-warning-on-automatic-module

Find out more about basic support for modules in IntelliJ IDEA, and module diagrams and additional quick fixes.

Convenience Factory Methods

Java 9 introduces a lot of small API changes that made life easier for developers. One of these is to simplify the creation of Collections with fixed contents.  IntelliJ IDEA has an inspection which can show you where you can use this feature.

07-immutable-collections

This will highlight code that can be simplified by using the Java 9 factory methods

Thread.onSpinWait

Java 9 lets you give hints to the JVM that can help performance.  Specifically, if your code is spinning in a loop waiting for something to happen, you can use Thread.onSpinWait to let the runtime know. IntelliJ IDEA locates code where this hint may be useful, and can add it.

10-on-spin-wait

This inspection and the one for Convenience Factory Methods were covered previously in the blog post and video on Java 9 support in IntelliJ IDEA 2017.2.

Enhanced Deprecation

Another seemingly small feature in Java 9 that makes it easier for developers to understand the impact of their code is enhanced deprecation.  Now instead of merely tagging code as deprecated and (possibly) documenting the reasons in the Javadoc, the @Deprecated tag supports two useful new attributes, “since” and “forRemoval”.  There’s a new inspection in IntelliJ IDEA 2017.3 that highlights any use of code that has been marked “forRemoval”.

11-for-removal-inspection

If you’ve got this inspection turned on and set to “Warning” (which is the default), then when you’re using something that’s been tagged as “forRemoval”, IntelliJ IDEA will strike this method through in red, rather than the usual black.

12-deprecated

JShell

Java 9 comes with a REPL for Java for the first time, called JShell.  You can run this REPL from the command line, or from the terminal inside IntelliJ IDEA.  In addition, IntelliJ IDEA 2017.3 also has a basic console that allows you to work with JShell from inside the IDE, similar to the Groovy Console.

13-jshell-menu

You can use this console to try out code snippets, and you will be able to select the module path for running this code.

This is currently available in the 2017.3 EAP.  Please try it out and give us feedback!

Features that don’t need extra support

There are loads of new features in Java 9, including changes to the Streams API, additions to Optional, private methods on interfaces, and more.

15-streams

Of course these new methods are all available during code completion if your project code level is set to Java 9.

16-project-language

In addition, you can use the usual features of IntelliJ IDEA to take advantage of some of the Java 9 features.  For example, you can generate HTML 5 Javadoc by adding a flag when you generate your documentation.

17-html5

You can even use IntelliJ IDEA to create Multi-Release Jar Files.  This is probably something that’s best left to build tools like Gradle, Maven or Ant, but it is possible in IntelliJ IDEA, and will be the subject of a later blog post.

All that remains is to say “Welcome Java 9!  We’re ready for you!”

Read the whole story
ruairimccomb
2647 days ago
reply
Share this story
Delete