
From the time when we started collaborating as a team in the 1960s, we envisaged not a grammar but a series of grammars. In 1972, there appeared the first volume in this series, A Grammar of Contemporary English (GCE). This was followed soon afterwards by two shorter works, A Communicative Grammar of English (CGE) and A University Grammar of English (UGE), published in the United States with the title A Concise Grammar of Contemporary English. With A Comprehensive Grammar of the English Language, we attempt something much more ambitious: a culmination of our joint work, which results in a grammar that is considerably larger and richer than GCE and hence superordinate to it. Yet, as with our other volumes since GCE, it is also a grammar that incorporates our own further research on grammatical structure as well as the research of scholars worldwide who have contributed to the description of English and to developments in linguistic theory. - Preface.
Is probably either Comprehensive Grammar of the English Language from 1985 or The Cambridge Grammar of the English Language from 2002.
I have no idea which.
But that is not the same thing as "knowing the rules". A writer may be able to write perfectly correctly without being able to enunciate any rules accurately at all.
Perhaps you play one or more sports. Could you write down accurate rules telling you how to hold and move a tennis racquet, or exactly how to flex the relevant joints when kicking a soccer ball? Of course writing is more deliberative than tennis or soccer, but a good writer isn't thinking about grammar and punctuation much more than a good sports player is thinking about joint angles and muscle groups.
Also, of course, there isn't universal agreement about what is and isn't correct, nor about what the best set of rules is for describing what's correct. For instance, if you compare the famous "Comprehensive Grammar of the English Language" by Quirk and Greenbaum, and the more recent "Cambridge Grammar of the English Language" by Huddleston and Pullum, you'll find that their analyses are sometimes very different. Totally different rules, even though they're describing substantially the same language.