Answer a buyer's security questionnaire.
Done by an agent. Checked twice.
Every question is answered from your own policy documents with the exact quote and the gaps go to your security team.
Real files in
- buyer_questionnaire.csv
A buyer's security questionnaire of 32 questions, five of them on subjects the policies do not cover. 33 lines, 2 KB. - access-control-policy.md
A software company's access control policy in seven sections. 42 lines, 2 KB. - data-protection-policy.md
The same company's policy on encryption, backups, deletion and where data is kept. 36 lines, 1 KB. - incident-response-plan.md
The company's incident response plan, including how fast customers are told. 32 lines, 1 KB. - staff-security-handbook.md
An older staff handbook that disagrees with the newer access policy in two places. 32 lines, 979 bytes. - vendor-and-hosting-standard.md
The company's standard for hosting, vendors, testing and recovery. 34 lines, 1 KB.
Sample data written by Atris. Not a real company.
Three steps
- 1.Read the policies and the questions
- 2.Answer each question from the documents
- 3.Hand over what needs a person
Claude Sonnet 5.5, 1 min 12 s. No web. It never saw the check.
Checked twice
- Passed: 32 of 32 questions have one answer row
- Passed: 32 of 32 answers are the answer the policy documents support: 21 yes, 6 no, 5 not stated
- Passed: 27 of 27 yes and no answers quote the section that settles them, word for word
- Passed: 27 of 27 yes and no answers name the right section heading
- Passed: 5 of 5 questions the documents do not cover are marked not stated, with nothing cited
- Passed: 2 of 2 disagreements between documents are settled by the later one with the older document named in the detail
- Passed: 11 of 11 no and not stated answers are handed over in gaps.md and 0 numbers in the answers are not in the documents
- Passed: 2 of 2 disagreements are listed in gaps.md with both documents and both values
- Passed: 38 of 38 numbers and dates in gaps.md come from the question on that line or the policy section that settles it
Second review by Claude Opus 5.5: pass.
Then we broke a copy of the output 6 ways on purpose. The check caught 6.
## Not stated (no policy document covers it) - **Q17**: Buyer asked: Do you hold a current SOC 2 Type II report? Documents give: nothing. No policy document mentions a SOC 2 report. Passed to the security team. - **Q18**: Buyer asked: Are you certified to ISO 27001? Documents give: nothing. No policy document mentions ISO 27001 certification. Passed to the security team. - **Q22**: Buyer asked: Do you carry cyber liability insurance of at least 5 million dollars? Documents give: nothing. No policy document mentions cyber liability insurance. Passed to the security team. - **Q31**: Buyer asked: Do you have a named data protection officer? Documents give: nothing. No policy document names a data protection officer. Passed to the security team. - **Q32**: Buyer asked: Do you run a public bug bounty programme? Documents give: nothing. No policy document mentions a bug bounty programme. Passed to the security team. ## Places where two policy documents disagree Answers use the document with the later effective date. The older one should be corrected. - **Staff password minimum length (Q03)**: Access Control Policy (effective 2026-03-01, section 3) says 14 characters; Staff Security Handbook (effective 2025-06-01, section 2) says 10 characters. Correct the Staff Security Handbook. - **Laptop auto-lock time (Q30)**: Access Control Policy (effective 2026-03-01, section 7) says 5 minutes; Staff Security Handbook (effective 2025-06-01, section 3) says 10 minutes. Correct the Staff Security Handbook.
How this was run
An AI agent on Claude Sonnet 5.5 was given a folder with the files below and a three-step flow, and nothing else. It had no web access and never saw the check. The check was written before the run and made stricter after it. It works the answer out again from the input files. Then Claude Opus 5.5 reviewed the result against the inputs. The input files are sample data written by Atris, with the problems a real week has planted in them.
Run 1 of 1 on 1 December 2026. The agent took 1 min 12 s.
What the second review verified
- All 32 questions have exactly one row in answers.csv, in the order asked (Q01–Q32). Every yes/no quote appears word for word in the section it cites, and the four not_stated rows have source, section and quote left blank.
- Q03 and Q30 conflicts: the Access Control Policy (effective 2026-03-01) says passwords are at least 14 characters and laptops lock after 5 minutes. The older Staff Security Handbook (2025-06-01) says 10 characters and 10 minutes. The work correctly uses the later document, and both conflicts are listed in gaps.md.
- The numbers behind the 'no' answers match the policies: logs kept 12 months (asked 24), backups kept 35 days (asked 90), breach notice within 72 hours (asked 24), pen test once a year (asked every 6 months), recovery time objective 8 hours (asked 4), and storage only in US regions (asked for the EU).
- None of the policies mention SOC 2, ISO 27001, cyber insurance, a data protection officer or a bug bounty, so Q17, Q18, Q22, Q31 and Q32 are correctly not_stated. All 11 no and not_stated questions appear in gaps.md.
What this run does not show
- The check holds a list of right answers marked by hand before the run: the answer to each question and the policy section that settles it. It confirms those words are in that section.
- The five policy documents were written by Atris and are short. A real policy set is far longer and disagrees with itself more often than twice.
- The wording of each answer is read only by the second review.
Would the check catch a wrong answer?
A check that cannot fail proves nothing. After the run we took a copy of the output, broke it one small way at a time and ran the check again. It caught 6 of 6. The check was made stricter after the first try at this, and the same untouched output was graded again.
Open every file
flow.md · the three steps the agent followed
# Answer a buyer's security questionnaire function: sales for: the seller who has to return a buyer's security questionnaire goal: Every question has an answer that the company's own policy documents back word for word. Every question they cannot back is handed to the security team instead of guessed. ## 1. Read the policies and the questions Read every document in input/policies/ in full, noting each one's effective date and its numbered sections. Then read input/buyer_questionnaire.csv. The policy documents are the only source. Do not answer from what companies usually do. Do not promise anything the documents do not say. ## 2. Answer each question from the documents Give every question one answer: - `yes` when a policy says the control is in place and is at least as strong as the question asks. - `no` when the policies cover the subject but fall short of what is asked. Say what the policy does give. - `not_stated` when no policy document covers the subject. Do not stretch a nearby sentence to fit. When two documents disagree, use the one with the later effective date. Answer from it, cite it and say in the detail which older document says something different. Write output/answers.csv with columns question_id,answer,detail,source_file,section,quote. One row per question, in the order asked. detail is one or two plain sentences a buyer can read. For yes and no, source_file is the policy file name, section is the heading of the section that settles it as the document writes it. quote is the sentence or sentences that settle it, copied exactly from that section. For not_stated, leave source_file, section and quote blank. Every number in a detail must come from the policy documents or from the question. ## 3. Hand over what needs a person Write output/gaps.md for the security team: every question answered `no` or `not_stated`, by question_id, with one line on what the buyer asked for and what the documents give. Then list each place where two policy documents disagree, naming both documents and both values, so the older one can be corrected. ## Done looks like - Every question has one row in answers.csv. - Every yes and no can be traced to a quoted sentence in a named section of a policy document. - Nothing is answered yes that the documents do not say.
input/buyer_questionnaire.csv · 33 lines, 2 KB
question_id,topic,question Q01,Access,Does every member of staff have their own named account with no shared logins? Q02,Access,Is multi-factor authentication required for staff on systems that hold customer data? Q03,Access,Is the minimum password length for staff at least 12 characters? Q04,Access,Are staff access rights reviewed at least every quarter? Q05,Access,Is all access removed within 24 hours when a member of staff leaves? Q06,Access,Do you support single sign-on using SAML for our users? Q07,Access,Are access logs kept for at least 24 months? Q08,Encryption,Is customer data encrypted at rest using AES-256 or stronger? Q09,Encryption,Is data in transit protected with TLS 1.2 or higher? Q10,Encryption,Are encryption keys rotated at least once a year? Q11,Backup,Are backups of customer data taken at least daily? Q12,Backup,Are backups kept for at least 90 days? Q13,Backup,Is a restore from backup tested at least once a year? Q14,Data handling,Is our data deleted from live systems within 30 days of the end of the contract? Q15,Data handling,Can our data be stored in a European Union region? Q16,Data handling,Is production customer data kept out of test environments? Q17,Assurance,Do you hold a current SOC 2 Type II report? Q18,Assurance,Are you certified to ISO 27001? Q19,Incidents,Will you notify us within 24 hours of a confirmed breach of our data? Q20,Incidents,Is a security responder on call 24 hours a day? Q21,Incidents,Is the incident response plan tested at least once a year? Q22,Assurance,Do you carry cyber liability insurance of at least 5 million dollars? Q23,Testing,Is an external penetration test carried out at least every 6 months? Q24,Testing,Are critical weaknesses patched within 7 days? Q25,Vendors,Do you tell customers before adding a new sub-processor? Q26,Change,Is every code change reviewed by a second person before release? Q27,Continuity,Is your recovery time objective 4 hours or less? Q28,People,Do all staff complete security training at least once a year? Q29,People,Are background checks carried out on new hires? Q30,Devices,Do staff laptops lock automatically after no more than 5 minutes without use? Q31,People,Do you have a named data protection officer? Q32,Testing,Do you run a public bug bounty programme?
input/policies/access-control-policy.md · 42 lines, 2 KB
# Access Control Policy Halden Works. Document owner: Head of Security. Effective date: 2026-03-01. Reviewed yearly. ## 1. Scope This policy covers every system that stores or processes customer data, and every person who works for Halden Works, including contractors. ## 2. Accounts and access rights Every person has their own named account. Shared accounts and shared passwords are not allowed. Access is given by role and must be approved by the person's manager before it is switched on. Managers review the access rights of their team every quarter and remove anything no longer needed. When someone leaves the company, all of their access is removed within 24 hours of their last day. ## 3. Passwords and sign in Passwords must be at least 14 characters long and must be stored in the company password manager. Multi-factor authentication is required for all staff on every system that holds customer data. Passwords are never sent by email or chat. ## 4. Administrator access Administrator rights on production systems are limited to named engineers on the platform team. Each grant lasts no more than 8 hours and every administrator session is logged. ## 5. Customer sign in Customers can connect their own identity provider. Single sign-on using SAML is available to customers on every plan. Customers who do not use single sign-on can turn on multi-factor authentication for their own users. ## 6. Logs Sign in and access logs for production systems are kept for 12 months and can be searched by the security team. ## 7. Devices Company laptops lock automatically after 5 minutes without use. Only company laptops may be used to reach production systems.
input/policies/data-protection-policy.md · 36 lines, 1 KB
# Data Protection Policy Halden Works. Document owner: Head of Security. Effective date: 2026-01-15. Reviewed yearly. ## 1. Classes of data Customer data is the highest class. It means anything a customer or their users put into the product. Internal data and public data are the two lower classes. ## 2. Encryption Customer data is encrypted at rest using AES-256. Data moving between customers and our service, and between our own systems, is encrypted in transit using TLS 1.2 or higher. Encryption keys are held in the cloud provider's key management service and are rotated once a year. ## 3. Backups Databases holding customer data are backed up every day. Backups are encrypted and stored in a second region. Backups are kept for 35 days and then deleted. A full restore from backup is tested twice a year and the result is recorded. ## 4. Retention and deletion Customer data is deleted from live systems within 30 days of the end of a contract. It drops out of backups as those backups reach the end of their own 35 days. A customer can ask for earlier deletion in writing. ## 5. Where data is kept Customer data is stored only in data centre regions in the United States. We do not offer storage in any other country. ## 6. Test systems Production customer data is never copied into test or development environments. Test systems use made up data.
input/policies/incident-response-plan.md · 32 lines, 1 KB
# Incident Response Plan Halden Works. Document owner: Head of Security. Effective date: 2025-09-01. Reviewed yearly. ## 1. What counts as an incident Any event that harms or could harm the secrecy, accuracy or availability of customer data or of the service. ## 2. Severity Severity 1 is a confirmed loss or exposure of customer data, or the service being down for all customers. Severity 2 is a serious fault with a workaround. Severity 3 is everything else. ## 3. Response A security engineer is on call 24 hours a day, every day of the year. A severity 1 incident is acknowledged within 30 minutes and an incident lead is named. ## 4. Telling customers When we confirm a breach of a customer's data we notify that customer within 72 hours of confirming it. The notice says what happened, what data was involved and what we are doing. ## 5. Review Every severity 1 and severity 2 incident gets a written review within 10 working days. Actions from the review are tracked to completion. ## 6. Practice This plan is exercised once a year with a tabletop drill led by the Head of Security.
input/policies/staff-security-handbook.md · 32 lines, 979 bytes
# Staff Security Handbook Halden Works. Document owner: People team. Effective date: 2025-06-01. ## 1. Why this matters Customers trust us with their schedules, their staff lists and their plans. Every person here is part of keeping that safe. ## 2. Passwords Use a password of at least 10 characters for every work account. Use the company password manager. Never reuse a work password anywhere else. ## 3. Your laptop Your company laptop has full disk encryption switched on. Do not turn it off. The screen locks after 10 minutes without use. Lock it yourself whenever you walk away. ## 4. Training Everyone completes security training in their first week and again every 12 months. Managers are told who is overdue. ## 5. Before you start We run a background check on every new hire before their first day, where the law allows it. ## 6. Reporting If you think something is wrong, tell the security team within 1 hour. You will never be in trouble for reporting.
input/policies/vendor-and-hosting-standard.md · 34 lines, 1 KB
# Vendor and Hosting Standard Halden Works. Document owner: Head of Platform. Effective date: 2026-05-10. Reviewed yearly. ## 1. Hosting The service runs on a public cloud provider in two regions. Halden Works does not run its own data centres. ## 2. Vendors and sub-processors We keep a list of every sub-processor that handles customer data. Customers are told at least 30 days before a new sub-processor is added. Every vendor with access to customer data is reviewed once a year. ## 3. Finding and fixing weaknesses Production systems are scanned for known weaknesses every week. Critical findings are patched within 7 days and high findings within 30 days. ## 4. Penetration testing An independent firm carries out an external penetration test once a year. A summary of the latest test is available to customers under a confidentiality agreement. ## 5. Changes to the product Every code change is reviewed by a second engineer before release. Releases go out only after the automated checks pass. ## 6. Keeping the service running Our recovery time objective is 8 hours and our recovery point objective is 24 hours. The disaster recovery plan is tested once a year.
output/answers.csv · written by the agent, 33 lines
question_id,answer,detail,source_file,section,quote Q01,yes,"Every person has their own named account, and shared accounts and shared passwords are not allowed.",access-control-policy.md,2. Accounts and access rights,Every person has their own named account. Shared accounts and shared passwords are not allowed. Q02,yes,Multi-factor authentication is required for all staff on every system that holds customer data.,access-control-policy.md,3. Passwords and sign in,Multi-factor authentication is required for all staff on every system that holds customer data. Q03,yes,"Staff passwords must be at least 14 characters, which is above the 12 asked. An older document, the Staff Security Handbook (effective 2025-06-01), says 10 characters; the Access Control Policy (effective 2026-03-01) is later and is used.",access-control-policy.md,3. Passwords and sign in,Passwords must be at least 14 characters long and must be stored in the company password manager. Q04,yes,Managers review their team's access rights every quarter and remove anything no longer needed.,access-control-policy.md,2. Accounts and access rights,Managers review the access rights of their team every quarter and remove anything no longer needed. Q05,yes,All access is removed within 24 hours of the person's last day.,access-control-policy.md,2. Accounts and access rights,"When someone leaves the company, all of their access is removed within 24 hours of their last day." Q06,yes,Single sign-on using SAML is available to customers on every plan.,access-control-policy.md,5. Customer sign in,Single sign-on using SAML is available to customers on every plan. Q07,no,"Sign in and access logs for production systems are kept for 12 months, which is shorter than the 24 months asked.",access-control-policy.md,6. Logs,Sign in and access logs for production systems are kept for 12 months and can be searched by the security team. Q08,yes,Customer data is encrypted at rest using AES-256.,data-protection-policy.md,2. Encryption,Customer data is encrypted at rest using AES-256. Q09,yes,"Data in transit between customers and the service, and between our own systems, is encrypted using TLS 1.2 or higher.",data-protection-policy.md,2. Encryption,"Data moving between customers and our service, and between our own systems, is encrypted in transit using TLS 1.2 or higher." Q10,yes,Encryption keys are rotated once a year.,data-protection-policy.md,2. Encryption,Encryption keys are held in the cloud provider's key management service and are rotated once a year. Q11,yes,Databases holding customer data are backed up every day.,data-protection-policy.md,3. Backups,Databases holding customer data are backed up every day. Q12,no,"Backups are kept for 35 days and then deleted, which is shorter than the 90 days asked.",data-protection-policy.md,3. Backups,Backups are kept for 35 days and then deleted. Q13,yes,"A full restore from backup is tested twice a year and the result is recorded, which is more often than once a year.",data-protection-policy.md,3. Backups,A full restore from backup is tested twice a year and the result is recorded. Q14,yes,Customer data is deleted from live systems within 30 days of the end of a contract. It leaves backups as they reach the end of their own 35 days.,data-protection-policy.md,4. Retention and deletion,Customer data is deleted from live systems within 30 days of the end of a contract. Q15,no,"Customer data is stored only in data centre regions in the United States, and no other country is offered, so an EU region is not available.",data-protection-policy.md,5. Where data is kept,Customer data is stored only in data centre regions in the United States. We do not offer storage in any other country. Q16,yes,"Production customer data is never copied into test or development environments, and test systems use made up data.",data-protection-policy.md,6. Test systems,Production customer data is never copied into test or development environments. Q17,not_stated,No policy document mentions a SOC 2 report. Passed to the security team.,,, Q18,not_stated,No policy document mentions ISO 27001 certification. Passed to the security team.,,, Q19,no,"We notify the affected customer within 72 hours of confirming a breach, which is longer than the 24 hours asked.",incident-response-plan.md,4. Telling customers,When we confirm a breach of a customer's data we notify that customer within 72 hours of confirming it. Q20,yes,"A security engineer is on call 24 hours a day, every day of the year.",incident-response-plan.md,3. Response,"A security engineer is on call 24 hours a day, every day of the year." Q21,yes,The plan is exercised once a year with a tabletop drill led by the Head of Security.,incident-response-plan.md,6. Practice,This plan is exercised once a year with a tabletop drill led by the Head of Security. Q22,not_stated,No policy document mentions cyber liability insurance. Passed to the security team.,,, Q23,no,"An independent firm carries out an external penetration test once a year, which is less often than every 6 months. A summary of the latest test is available to customers under a confidentiality agreement.",vendor-and-hosting-standard.md,4. Penetration testing,An independent firm carries out an external penetration test once a year. A summary of the latest test is available to customers under a confidentiality agreement. Q24,yes,Critical findings are patched within 7 days.,vendor-and-hosting-standard.md,3. Finding and fixing weaknesses,Critical findings are patched within 7 days and high findings within 30 days. Q25,yes,Customers are told at least 30 days before a new sub-processor is added.,vendor-and-hosting-standard.md,2. Vendors and sub-processors,Customers are told at least 30 days before a new sub-processor is added. Q26,yes,Every code change is reviewed by a second engineer before release.,vendor-and-hosting-standard.md,5. Changes to the product,Every code change is reviewed by a second engineer before release. Q27,no,"The recovery time objective is 8 hours, which is longer than the 4 hours asked. The recovery point objective is 24 hours and the disaster recovery plan is tested once a year.",vendor-and-hosting-standard.md,6. Keeping the service running,Our recovery time objective is 8 hours and our recovery point objective is 24 hours. Q28,yes,Everyone completes security training in their first week and again every 12 months.,staff-security-handbook.md,4. Training,Everyone completes security training in their first week and again every 12 months. Q29,yes,"A background check is run on every new hire before their first day, where the law allows it.",staff-security-handbook.md,5. Before you start,"We run a background check on every new hire before their first day, where the law allows it." Q30,yes,"Company laptops lock automatically after 5 minutes without use. An older document, the Staff Security Handbook (effective 2025-06-01), says 10 minutes; the Access Control Policy (effective 2026-03-01) is later and is used.",access-control-policy.md,7. Devices,Company laptops lock automatically after 5 minutes without use. Q31,not_stated,No policy document names a data protection officer. Passed to the security team.,,, Q32,not_stated,No policy document mentions a bug bounty programme. Passed to the security team.,,,
output/gaps.md · written by the agent, 27 lines
# Questions for the security team Halden Works buyer security questionnaire. Every question below is answered `no` or `not_stated` in answers.csv and needs a person. ## Answered no (policy covers it but falls short) - **Q07**: Buyer asked: Are access logs kept for at least 24 months? Documents give: Sign in and access logs for production systems are kept for 12 months, which is shorter than the 24 months asked. (access-control-policy.md, section 6. Logs) - **Q12**: Buyer asked: Are backups kept for at least 90 days? Documents give: Backups are kept for 35 days and then deleted, which is shorter than the 90 days asked. (data-protection-policy.md, section 3. Backups) - **Q15**: Buyer asked: Can our data be stored in a European Union region? Documents give: Customer data is stored only in data centre regions in the United States, and no other country is offered, so an EU region is not available. (data-protection-policy.md, section 5. Where data is kept) - **Q19**: Buyer asked: Will you notify us within 24 hours of a confirmed breach of our data? Documents give: We notify the affected customer within 72 hours of confirming a breach, which is longer than the 24 hours asked. (incident-response-plan.md, section 4. Telling customers) - **Q23**: Buyer asked: Is an external penetration test carried out at least every 6 months? Documents give: An independent firm carries out an external penetration test once a year, which is less often than every 6 months. A summary of the latest test is available to customers under a confidentiality agreement. (vendor-and-hosting-standard.md, section 4. Penetration testing) - **Q27**: Buyer asked: Is your recovery time objective 4 hours or less? Documents give: The recovery time objective is 8 hours, which is longer than the 4 hours asked. The recovery point objective is 24 hours and the disaster recovery plan is tested once a year. (vendor-and-hosting-standard.md, section 6. Keeping the service running) ## Not stated (no policy document covers it) - **Q17**: Buyer asked: Do you hold a current SOC 2 Type II report? Documents give: nothing. No policy document mentions a SOC 2 report. Passed to the security team. - **Q18**: Buyer asked: Are you certified to ISO 27001? Documents give: nothing. No policy document mentions ISO 27001 certification. Passed to the security team. - **Q22**: Buyer asked: Do you carry cyber liability insurance of at least 5 million dollars? Documents give: nothing. No policy document mentions cyber liability insurance. Passed to the security team. - **Q31**: Buyer asked: Do you have a named data protection officer? Documents give: nothing. No policy document names a data protection officer. Passed to the security team. - **Q32**: Buyer asked: Do you run a public bug bounty programme? Documents give: nothing. No policy document mentions a bug bounty programme. Passed to the security team. ## Places where two policy documents disagree Answers use the document with the later effective date. The older one should be corrected. - **Staff password minimum length (Q03)**: Access Control Policy (effective 2026-03-01, section 3) says 14 characters; Staff Security Handbook (effective 2025-06-01, section 2) says 10 characters. Correct the Staff Security Handbook. - **Laptop auto-lock time (Q30)**: Access Control Policy (effective 2026-03-01, section 7) says 5 minutes; Staff Security Handbook (effective 2025-06-01, section 3) says 10 minutes. Correct the Staff Security Handbook.
check.py · the check, written before the run
"""Checks every answer against the policy documents.
The list below names, for each question, the answer the documents support and the one section that
settles it, with a few words from that section. The check first confirms those words really are in
that section of the input, so the list cannot drift from the documents. Then it checks the agent's
answer, the section it cites and that its quote is in that section word for word.
"""
import csv, re, sys
from pathlib import Path
root = Path(sys.argv[1]); ok = True
def say(passed, text):
global ok; ok = ok and passed; print(("PASS " if passed else "FAIL ") + text)
A, D, I, V, H = "access-control-policy.md", "data-protection-policy.md", "incident-response-plan.md", "vendor-and-hosting-standard.md", "staff-security-handbook.md"
KEY = {
"Q01": ("yes", A, 2, "own named account"), "Q02": ("yes", A, 3, "Multi-factor authentication is required"), "Q03": ("yes", A, 3, "at least 14 characters"),
"Q04": ("yes", A, 2, "every quarter"), "Q05": ("yes", A, 2, "within 24 hours"), "Q06": ("yes", A, 5, "Single sign-on using SAML"),
"Q07": ("no", A, 6, "kept for 12 months"), "Q08": ("yes", D, 2, "AES-256"), "Q09": ("yes", D, 2, "TLS 1.2 or higher"),
"Q10": ("yes", D, 2, "rotated once a year"), "Q11": ("yes", D, 3, "backed up every day"), "Q12": ("no", D, 3, "kept for 35 days"),
"Q13": ("yes", D, 3, "tested twice a"), "Q14": ("yes", D, 4, "within 30 days of the end of a contract"), "Q15": ("no", D, 5, "only in data centre regions in the United States"),
"Q16": ("yes", D, 6, "never copied into test"), "Q17": ("not_stated",), "Q18": ("not_stated",), "Q19": ("no", I, 4, "within 72 hours"),
"Q20": ("yes", I, 3, "on call 24 hours a day"), "Q21": ("yes", I, 6, "exercised once a year"), "Q22": ("not_stated",),
"Q23": ("no", V, 4, "penetration test once a year"), "Q24": ("yes", V, 3, "patched within"), "Q25": ("yes", V, 2, "at least 30 days"),
"Q26": ("yes", V, 5, "reviewed by a second engineer"), "Q27": ("no", V, 6, "recovery time objective is 8 hours"), "Q28": ("yes", H, 4, "every 12 months"),
"Q29": ("yes", H, 5, "background check on every new hire"), "Q30": ("yes", A, 7, "after 5 minutes"), "Q31": ("not_stated",), "Q32": ("not_stated",),
}
OLDER = {"Q03": (H, 2, "at least 10 characters"), "Q30": (H, 3, "10 minutes")} # where an older document says otherwise
def flat(text): return re.sub(r"\s+", " ", text).strip().lower()
sections = {}
for p in (root/"input/policies").glob("*.md"):
for part in re.split(r"^## ", p.read_text(), flags=re.M)[1:]:
head, _, body = part.partition("\n"); sections[(p.name, int(head.split(".")[0]))] = (head.strip(), flat(body))
for q, k in list(KEY.items()) + list(OLDER.items()):
if len(k) > 1: assert flat(k[-1]) in sections[(k[-3], k[-2])][1], (q, k)
corpus = " ".join(p.read_text() for p in (root/"input/policies").glob("*.md"))
questions = {r["question_id"]: r["question"] for r in csv.DictReader((root/"input/buyer_questionnaire.csv").open())}
assert set(questions) == set(KEY)
path = root/"output/answers.csv"
if not path.exists():
say(False, "output/answers.csv was not written"); sys.exit(1)
rows = list(csv.DictReader(path.open())); got = {(r.get("question_id") or "").strip(): r for r in rows}
def val(q, col): return (got.get(q, {}).get(col) or "").strip()
n = len(KEY)
say(set(got) == set(KEY) and len(rows) == n, f"{len(set(got) & set(KEY))} of {n} questions have one answer row")
right = sum(1 for q, k in KEY.items() if val(q, "answer").lower() == k[0])
counts = {a: sum(1 for k in KEY.values() if k[0] == a) for a in ("yes", "no", "not_stated")}
say(right == n, f"{right} of {n} answers are the answer the policy documents support: {counts['yes']} yes, {counts['no']} no, {counts['not_stated']} not stated")
backed = [q for q, k in KEY.items() if k[0] != "not_stated"]
def quoted(q):
_, name, num, _ = KEY[q]; quote = flat(val(q, "quote"))
return val(q, "source_file").split("/")[-1] == name and len(quote) >= 15 and quote in sections[(name, num)][1]
qs = sum(1 for q in backed if quoted(q))
say(qs == len(backed), f"{qs} of {len(backed)} yes and no answers quote the section that settles them, word for word")
def cited(q):
head = sections[(KEY[q][1], KEY[q][2])][0].lower(); said = val(q, "section").lower().lstrip("# ").strip()
return bool(said) and (said in head or head in said or said.rstrip(".") == str(KEY[q][2]))
cs = sum(1 for q in backed if cited(q))
say(cs == len(backed), f"{cs} of {len(backed)} yes and no answers name the right section heading")
bare = [q for q, k in KEY.items() if k[0] == "not_stated"]
clean = sum(1 for q in bare if val(q, "answer").lower() == "not_stated" and not val(q, "quote") and not val(q, "source_file"))
say(clean == len(bare), f"{clean} of {len(bare)} questions the documents do not cover are marked not stated, with nothing cited")
older = sum(1 for q, (name, _, _) in OLDER.items() if quoted(q) and ("handbook" in val(q, "detail").lower() or name in val(q, "detail")))
say(older == len(OLDER), f"{older} of {len(OLDER)} disagreements between documents are settled by the later one with the older document named in the detail")
known = set(re.findall(r"\d+(?:\.\d+)?", corpus))
loose = [(q, x) for q in KEY for x in re.findall(r"\d+(?:\.\d+)?", val(q, "detail")) if x not in known and x not in re.findall(r"\d+(?:\.\d+)?", questions[q])]
gaps = (root/"output/gaps.md").read_text() if (root/"output/gaps.md").exists() else ""
listed = sum(1 for q, k in KEY.items() if k[0] != "yes" and q in gaps)
say(not loose and listed == n - counts["yes"], f"{listed} of {n - counts['yes']} no and not stated answers are handed over in gaps.md and {len(loose)} numbers in the answers are not in the documents")
DATE = r"\d{4}-\d\d-\d\d"
def figures(t):
t = re.sub(r"\bQ\d+\b|\b[A-Za-z]+-\d+\b|" + DATE, " ", t)
return [float(x.rstrip(",").replace(",", "")) for x in re.findall(r"(?<![\w.])\d[\d,]*(?:\.\d+)?", t)]
def plain(t): return flat(t.replace("-", " "))
def title(name): return name[:-3].replace("-", " ")
both = 0
for q, (old, num, words) in OLDER.items():
new = KEY[q]; pair = set(figures(new[3])) | set(figures(words))
both += any(title(new[1]) in plain(ln) and title(old) in plain(ln) and pair <= set(figures(ln)) for ln in gaps.splitlines())
say(both == len(OLDER), f"{both} of {len(OLDER)} disagreements are listed in gaps.md with both documents and both values")
facts = {}
for q, k in KEY.items():
facts[q] = set(figures(questions[q]))
for name, num in ([(k[1], k[2])] if len(k) > 1 else []) + ([OLDER[q][:2]] if q in OLDER else []):
facts[q] |= set(figures(" ".join(sections[(name, num)]))) | {float(num)}
whole = set(figures(corpus)) | {float(v) for v in counts.values()} | {float(n), float(n - counts["yes"]), float(len(OLDER))}
days = set(re.findall(DATE, corpus)); claims = good = 0
for ln in gaps.splitlines():
named = [q for q in re.findall(r"\bQ\d+\b", ln) if q in KEY]
allowed = set().union(*(facts[q] for q in named)) if named else whole
for x in figures(ln): claims += 1; good += x in allowed
for d in re.findall(DATE, ln): claims += 1; good += d in days
say(claims > 0 and good == claims, f"{good} of {claims} numbers and dates in gaps.md come from the question on that line or the policy section that settles it")
sys.exit(0 if ok else 1)
buyer_questionnaire.csv: sample data written by Atris. Fingerprint 089fc25cff5f.
access-control-policy.md: sample data written by Atris. Fingerprint 23faa001d561.
data-protection-policy.md: sample data written by Atris. Fingerprint c0050f0e6f0b.
incident-response-plan.md: sample data written by Atris. Fingerprint d28c697c662a.
staff-security-handbook.md: sample data written by Atris. Fingerprint 0e00e9202492.
vendor-and-hosting-standard.md: sample data written by Atris. Fingerprint 0ef6039662d6.
answers.csv: written by the agent. Fingerprint 4226fb691880.
gaps.md: written by the agent. Fingerprint e813f86f5078.