Not this patch but before, I tried a map where I crowded people in. I think it would have been Immortal with an extra civ and probably 2 extra CS. I go around to explore and see Gilgamesh and Qin near me. As I start walking my warrior home to defend, I notice that Gilgamesh has a lot of warriors around. He declares war, and then a couple turns later has them all at my city. A few turns later, I'm dead. I did not even get the chance to finish Code of Laws.
So if the AI is truly motivated to declare war and take your city, they can do it. Just because you declare war and have no troops it can still take the AI a little bit to essentially do the rolls in their head that they take you out. I mean, if I was playing a game and an AI attacked me without sending any troops, I might continue on my current strategy for a little bit.
You didn't have walls. As soon as the walls go up, the AI is too incompetent to commit to the focused attack necessary to take the city. Instead, they will move a unit next to the city, think "oops, I can't take this city with this unit", retreat, and then repeat this process with all their units for the next dozen turns, occasionally attacking with one of them and no more.
It's pretty funny how Game Boy Advance strategy games like Advance Wars had far better AI than a 2016 AAA PC game.