But Locke wasn't careful. That was the point of the story. Chains was always trying to teach Locke discipline, carefulness and leadership, as shown in the flashbacks. Whereas Locke was impulsive, tempermental, over-confident, grandiose and often lacked leadership smarts, and thus often made mistakes. In the wake of Chains' death and Sabetha leaving, Locke and his crew had become careless. The Grey King relentlessly studied both the criminals of Camorr and the nobility whom Locke was fleecing for his revenge. He didn't always follow Chains' rules correctly. Therefore, it was relatively easy for the Grey King to twig to what Locke was up to and choose him as his patsy. From the events of the story, Locke learns to be more careful and what it costs if you do not (the loss of his friends.)
Lynch does give very clear portraits of how Locke, Jean and a few others think. But he does not give you the inner workings of every character, nor should he logically in a crime thriller. The Grey King is meant to be partially mysterious, though at the end, we do get to see inside his mind with his history. We don't know exactly how the spy mistress of Camorr gets all her info either, but we do know that she has spies at every level of society. So it's not a deus ex machina or handwaving. It's logical that Locke's secret is uncovered by some because he takes more and more risks that reveal that secret. To say that when a character says, I found out about your secret that this is impossible when the gist of the story is that Locke keeps acting before he thinks and making mistakes would seem more wishful thinking than discovering a plothole.
I do think that Lynch has some minor problems with plotting. The barrel incident with Locke was striking but not very logically done. Locke's elaborate con to get a set of clothes instead of just stealing them quickly didn't make a lot of sense to me, though I enjoyed the con. And there is a major plot problem with Red Seas, though it doesn't come up until the end and most of the book is very interesting regardless of it. But Lynch's writing, descriptions, characters, dialogue, and use of crime and fantasy elements more than makes up for the quibbles. And the crime revenge plot of Lies I found pretty logical.