Cogley seems to have NO defense strategy until Spock & McCoy burst into the court room with info to save Kirk's hide.
At one point someone in the court room asks him if he's ready to begin his defense and his reply is very cryptic: "No... but I may be getting ready..."
What did THAT mean???
Right. Just after Jame Finney shows up an apologizes for her emotional outburst earlier, Cogley starts to smell a rat. After Kirk asks Cogley if he's ready to go back into court, the script says:
CLOSE - COGLEY
Can't put his finger on it, but something is nagging at him. For the time being, however, he'll let it germinate.
COGLEY
Not entirely. But I may be getting ready.
The episode then cuts to Spock winning at chess and then he and McCoy rushing to beam down to inform Cogley. (Well, they rushed, but they stopped to change into their dress uniforms first.) But there was another scene between Kirk and Cogley just before the dinging of the courtroom bell gets the court going again:
ANGLE - KIRK, COGLEY
Kirk is doodling on a pad. Impatient, he throws down the pencil. Cogley doesn't seem to notice.
COGLEY
Jim...how well do you know that
girl? Jame - Finney's daughter.
KIRK
Since she was a child.
COGLEY
(musing)
I suppose that might explain her
attitude. Curious though -
children don't usually take such
a dispassionate view of the death
of a parent.
KIRK
She didn't at first. She was
out for my blood. Almost
hysterical. She kept saying
murderer - murderer.
COGLEY
(almost a take)
Why didn't you tell me that
before?
KIRK
I didn't think it was important.
Is it?
ANGLE IN ON Cogley.
COGLEY
(thoughtfully)
I don't know... yet.
WIDER ANGLE
Stone rings the court to order.
Later, after the court reconvenes on the Enterprise, just before they start the heartbeat, white sound experiment, Cogley has to leave on a "atter of vital importance to the purpose of this court." But the script has a moment of quiet dialog between Kirk and Cogley that no one else can hear, just before Cogley leaves.
TWO SHOT - COGLEY, KIRK
A conference between lawyer and client in the courtroom, which no one else can hear.
COGLEY
It's in your hands now.
KIRK
At this point I'll try anything.
(incredulously)
But the idea of Finney being
alive --
COGLEY
I began to suspect that when
you told me about the change of
heart his daughter had about
you. If she knew he wasn't dead,
she had no reason to blame you
for anythin.
KIRK
But how could she know?
COGLEY
You said she had been reading
her father's papers... probably
the general tone of what he had
written. A man suffering delusions
of persecution wants to set down
his complaints. She read them
... she know the kind of man you
are... and she's fundamentally
fair and decent.
(beat)
Or maybe it was just instinct.
Thank God there's that much
of the animal left in us.
So, Spock was able to figure out that the computer was reprogrammed--either accidentally or deliberately. But I think it was Cogley who figured out who did it. If things hadn't all worked out and Kirk had been found guilty, I think he probably would have been exonerated at some point. Relisticalkly, how long could Finney have stayed disappeared?