The watchdog for New Zealand's spy agencies was thwarted for months when trying to see secret emails about a controversial NZSAS raid in Afghanistan - and says she is prepared to use a legal summons if they continue to frustrate her legal duty.
The Inspector-General of Intelligence and Security, Cheryl Gwyn was eventually given access to "several tens of thousands of emails" - then discovered another 115,000 were apparently overlooked.
Gwyn was given an explanation as to how the emails were missed but has now sought independent advice to establish if more might be missing.
In response to questions about access to information held by our spies, Gwyn said she "would not hesitate" to rely on a legal summons to compel its release.
• Spies warned of gaps in our security and the plan to keep New Zealand safe
• New oversight report critical of spies and highlights legal 'gap' in GCSB practices
• Spies 'unlawfully' accessed data - oversight body
• Exclusive: Our spies disarmed by legal blunder amid 'high threat operations'
• How the GCSB collects data about Kiwis in the Pacific - and why it's legal
Gwyn, who runs the independent oversight body, has the highest of security classifications and the right to penetrate even the thickest veil of secrecy drawn around our spies to ensure they follow the law and have a legal basis for their actions.
She is the first to lead a beefed-up Inspector-General's office, and her terms have been marked by frequent clashes with the Government Communications Security Bureau and the NZ Security Intelligence Service.
Her ability to have unimpeded access to GCSB and NZSIS information is particularly important now given her assistance to the inquiry into the Christchurch massacre, in which close scrutiny will be paid to the actions - or inactions - of our intelligence agencies.
In the current case, Gwyn was investigating the GCSB and NZSIS knowledge and involvement in Operation Burnham, the NZSAS raid which was the focus of the 2017 book, Hit & Run.
Her inquiry runs parallel to the government inquiry, which is currently interviewing military commanders and members of the NZSAS over allegations the Afghanistan raid left six civilians dead and 15 other people wounded which the NZ Defence Force then allegedly covered up.
Gwynn said the agencies had raised issues about her "powers and functions". The Afghanistan inquiry was the most recent.
In that case, she had been challenged over the Inspector-General's right to access "security records" from the GCSB and NZSIS.
"I ultimately received direct access, however, as the legislation intended."
The Intelligence and Security Act 2017 was explicit in defining the "security records" the Inspector General could access.
The law says the oversight office "must be given access to all security records" and defines those as "papers, documents, and records of any kind" whether they were security classified or not.
Gwyn has issued a progress report on the Afghanistan inquiry, which showed she had first sought access to GCSB and NZSIS on October 5, 2018.
But it wasn't until May this year - eight months later - that she received the email databases containing the information she wanted.
Gwynn's report said official records from the time were often in emails, or attached to emails, and stored in staff email accounts rather than a central records system.
"The IGIS's right to directly access these records was initially called into question by the agencies, but eventually resolved.
"Nonetheless, the challenge of accessing all relevant staff emails has remained a recurring point of difficulty."
Gwyn's report said "several tens of thousands of emails" were provided in January.
"The review process for these emails revealed certain anomalies in the document production process, affecting principally the GCSB."
The challenge of accessing all relevant staff emails has remained a recurring point of difficulty.
Gwyn's report said "considerable time" had been spent working to fill the gaps which had been identified leading to the GCSB finding "over 115,000 additional staff emails for our review".
The report said the emails had been left out "due to an oversight".
"Some of these will also be relevant to the government inquiry."
Gwyn's report said the inquiry team met with the GCSB to find out how it had searched for the emails "and the technical reasons for some anomalies in the results".
Despite the explanation from the GCSB, Gwyn said she was now seeking independent advice to understand the methods used to locate the emails. She said this was to "ensure the completeness of the evidence available for my Afghanistan inquiry".
Gwyn said she had the power to issue a formal summons for documents, information or testimony from the agencies.
She said she would use those powers if she had to but preferred to find a co-operative solution "in the context of an ongoing oversight relationship".
Doing so could cause delays "while the agency considers its position in accommodating my requirements".
The Herald approached both intelligence agencies for comment. The agencies responded with comment from GCSB director-general Andrew Hampton.
He said the agency understood the Inspector-General's powers and made access to its systems possible "in a number of ways".
"In regards to the specific matter you have raised, the GCSB is working actively and constructively with the Inspector-General."
Hampton reinforced the missing emails were an "oversight". "Only a small proportion of the emails were connected to the inquiry in any way."
Rebecca Kitteridge, Director-General of Security, said the Inspector-General's oversight was welcome and the NZSIS worked to meet her requirements "while balancing operational needs".
"Some issues require quite a lot of discussion and we work through them with all parties working for the best outcome for New Zealand."
Inquiries by the Inspector-General have previously resulted in tensions; the agencies have disputed her findings or argued over her interpretation of the law.
Even engagement with the agencies has been strained at times.
The Inspector-General unsuccessfully, repeatedly, sought to meet the GCSB and NZSIS about warrants for spying before its new legislation came into force.
Neither agency accepted the invitation, and Gwyn's annual report cited disagreements over how the law was applied and the agencies' willingness to discuss the law. As a result, she said, "significant legal issues have been identified and engaged with too late in the piece".
• David Fisher is a member of a Reference Group set up by the Inspector-General of Intelligence and Security to hear views on developments possibly relevant to the work of the oversight office. The group has a one-way function in offering views to the IGIS and receives no classified or special information.