In my novel, The Last Good Man, an isolated community governs itself by writing on a large wall. Walk up to this structure, looming on the village’s outskirts, and you’ll find notes and missives about piano lessons and lost cats, but you’ll also find accusations plastered in red paint. Geoff Sharpe the butcher has been stealing cuts of meat, a poster might proclaim. Geoff Sharpe has been slacking on the job. And if there are enough accusations about a person, something is done about it; atonement will be sought.

This novel has come from a period where questions of public writing – and public shaming – have risen to the fore. These have been years when the architecture of social media has had a powerful effect on debate. Newspapers have carried headlines decrying judges as Enemies of the People; conspiracy theories have spread virulently across pockets of the internet and into the mouths of populist politicians. More recently, community tensions have boiled over as we have been forced to live and work in close quarters, when rulebreakers are watched closely by their neighbours.

These are contemporary concerns, but they have deep roots. The Last Good Man started on the wall of a university in China. Between 2011 and 2013 I was teaching in the English language and translation department at Nankai University in Tianjin. In one of the older parts of the university, dating from the first decades of the People's Republic of China, was a series of small buildings that housed photocopy machines. The ground there was overgrown, the walls in disrepair, the lights on the blink.

The back wall of one of these rooms was plastered top to bottom in sheets of paper, covered in Chinese characters. My feeble Mandarin wasn’t able to make sense of this writing, but one morning my girlfriend at the time accompanied me. She didn’t want to talk about what she’d read on the wall until long after we’d left the room, far from the gaze of the old woman who sat on a wooden stool and took money for the photocopy paper. It turns out there were a lot of cruel words on that wall; a lot of hateful slurs about named people who worked on the campus.

I learnt about 大字报 – big-character posters. These are public writings, often anonymous, that are writ large on the walls of public places. They’ve been a part of Chinese culture since its imperial period, but many modern Chinese people will associate them with the very worst of the Cultural Revolution, when names and smears about supposedly bourgeois anti-revolutionaries would be written on the walls of universities and gangs would attack the alleged offenders. What might have started as a political tool descended into neighbours defaming each other, old scores being settled in public places. In one extreme case, a Beijing teacher accused of crimes on a big-character poster was beaten to death by her own students.

I began to write a story about a village community that policed itself with writings on a wall. By then I was working as a journalist in London, and writing a lot about technology. This was around the time that the Gamergate controversy was leading to female video game critics being targeted by sustained misogynistic harassment, rape threats and death threats online. Soon, a similar vein of abuse-based, hashtag-hinged campaigning would appear under the alt-right banner. Then the Brexit vote happened. Then Trump happened. The idea of words on walls leading to violent acts felt very real. Things have only become more complex since.

In my novel, Duncan Peck travels to Dartmoor in search of his cousin, James Hale. In the village, he finds that Hale has become leader of a group that enforces shameful punishments on those who have been accused of wrongdoing, a role that affords him many privileges. But when Hale’s neighbour is accused of horrendous acts, this order of things begins to unravel. Personal transgressions and community tensions spill out. The wall looms as a dark canvas for this drama: “alive with malignancy”, in Peck’s words.

Some people have said that the novel makes them think of “cancel culture”. This term was not around when I was writing the book, which I’ve been working on for at least five years. In any case it seems a difficult phrase, largely used as a pejorative by those seeking to decry perceived wrongdoing on behalf of the “cancellers”. It’s tangled up with questions of who gets to speak and in whose name they speak for; who has been silenced historically and the extent to which social media platforms enable our voices to be heard, or whether our voices are pushed towards outrage by the insidious architecture of these digital spaces.

Modern modes host ancient impulses. Public shaming is nothing new, but the internet has given it new forms. As the narrator writes in Thomas Mann’s Doktor Faustus: “You only need to tell a crowd they are ‘the folk’ to stir them up to all sorts of reactionary evil”, but go online and the edges of “the folk” are difficult to trace. Where does the group begin and end? Perhaps the question is less about the specific ills of Twitter, then, and more how the nature of community is shifting in these perilous times. When the internet is omnipresent, inescapable, what does it mean for how we enforce societal norms?

“Now a book lives, as long as it is unfathomed,” wrote DH Lawrence. “Once it is fathomed, once it is known and its meaning is fixed or established, it is dead.” He’s not wrong. And so I am reluctant to draw too fixed a line between the events of my book and any particular meaning, between the wall in my story a neat equivalence with any particular metaphor. These are complex, knotted quests without easy answers, and The Last Good Man is not a polemic. It is a story about characters contending with responsibility, justice and atonement, and with a world of great uncertainties, teetering around the threat of extinction. Seen against this backdrop, perhaps it is understandable that they seek solace in the sureness of sentiment that is written on the wall.

The Last Good Man by Thomas McMullan in published by Bloomsbury, £16.99