Compare risk factors across two annual reports.
Done by an agent. Checked twice.
Every risk factor heading from two years of a real annual report, sorted into unchanged, reworded, added and removed.
Real files in
- risk_factors_2024.md
Item 1A (Risk Factors) of Chipotle Mexican Grill's annual report for fiscal year 2024, filed with the SEC. Trimmed to the 25 risk factor headings and their section titles. The text under each heading is left out.. 55 lines, 5 KB. - risk_factors_2025.md
Item 1A (Risk Factors) of Chipotle Mexican Grill's annual report for fiscal year 2025, filed with the SEC. Trimmed to the 23 risk factor headings and their section titles. The text under each heading is left out.. 53 lines, 5 KB.
Real public documents. Links below.
Three steps
- 1.Read both years
- 2.Match the headings
- 3.Write the comparison
Claude Sonnet 5.5, 54 seconds. No web. It never saw the check.
Checked twice
- Passed: 23 of 23 new year headings appear word for word exactly once
- Passed: 25 of 25 old year headings appear word for word exactly once
- Passed: 27 of 27 rows carry the status worked out from the two filings (15 unchanged, 6 reworded, 2 added, 4 removed)
- Passed: 27 of 27 rows name the section each heading sits under in its filing
- Passed: 6 of 6 reworded rows name a word that really changed between the years
- Passed: summary.md gives 4 of 4 counts correctly and names 2 of 2 section titles that are new or gone
- Passed: 19 of 19 numbers in summary.md equal a figure worked out from the two filings and 2 of 2 sums in it add up
Second review by Claude Opus 5.5: pass.
Then we broke a copy of the output 5 ways on purpose. The check caught 5.
Old year: 25 headings (risk_factors_2024.md). New year: 23 headings (risk_factors_2025.md). unchanged: 15 reworded: 6 added: 2 removed: 4 Check: 15 + 6 + 4 = 25 old headings, and 15 + 6 + 2 = 23 new headings. The CSV has 27 rows. Statuses come from the word-overlap test (shared distinct words divided by the word count of the shorter heading, 0.75 or more means reworded), run in python3. ## Section titles - New: "Risks Related to Macroeconomic Conditions" - Gone: "General Risk Factors" - No heading moved between sections.
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 real public documents.
Run 2 of 2 on 1 December 2026. The agent took 54 seconds. Run 1 passed both checks and the job was run again later. Each run starts clean. Between runs the written flow was made clearer, or a check was corrected or made stricter. Nobody edits the output.
What the second review verified
- Ran the word test again in python3 on all headings. Old year has 25 and new year has 23. The six reworded pairs scored between 0.914 and 0.963: brand 0.938, hiring 0.958, IT 0.963, breach 0.914, supply chain 0.952, disclosure 0.926. The best match for each added or removed heading scored 0.588 or less, so all four of those statuses are correct.
- risk_changes.csv has 27 rows: unchanged 15, reworded 6, added 2, removed 4. These match the counts in summary.md. Each new-year heading appears once, in filing order. Each old-year heading appears once. The removed rows follow the old year's order: technology/automation, stock price vs peers, economic factors, quarterly results.
- Every heading and section title in the CSV matches the input word for word. Each one sits under the right section, and no matched heading moved to a different section.
- The words-in and words-out notes on the reworded rows match the actual word differences. For example, the breach heading gained chipotle, loss, proprietary, revenue and technology, and lost behalf, material and on. The section changes are also correct: 'Risks Related to Macroeconomic Conditions' is new and 'General Risk Factors' is gone.
What this run does not show
- Only the heading of each risk factor was compared, because the body text under the headings was left out of the input.
- Reworded is decided by a fixed word count rule, so a heading rewritten in all new words shows as one removed plus one added.
- The closing sentences on what the changes mean are 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 5 of 5. 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
# Compare risk factors across two annual reports function: research for: the analyst who reads a company's annual report for what changed since last year goal: Every risk factor heading from both years is accounted for as unchanged, reworded, added or removed, so nothing new slips past. ## 1. Read both years Read the two files in input/. The file with the later year in its name is the new year and the other is the old year. A line that starts with `## ` is a section title. A line that starts with `- ` is one risk factor heading and belongs to the section title above it. ## 2. Match the headings Give every risk factor heading from either year exactly one status: - `unchanged` when the same heading appears word for word in both years. - `reworded` when the heading was edited but is still the same sentence. Test it this way: turn each heading into its set of distinct words (lowercase, letters and digits only, so "and/or" is two words). Count the words the two headings share and divide by the number of words in the heading that has fewer. At three quarters or more, the pair is reworded. Pair each heading with its best match only. - `added` for a new year heading with no unchanged or reworded partner in the old year. - `removed` for an old year heading with no unchanged or reworded partner in the new year. Use python3 for the word test. Do not judge it by eye. ## 3. Write the comparison Write output/risk_changes.csv with columns status,new_heading,old_heading,new_section,old_section,note. One row per unchanged heading, one per reworded pair, one per added heading and one per removed heading. Order: the new year's headings in filing order, then the removed ones in the old year's order. - Headings and section titles are copied word for word. Leave the new columns empty on a removed row and the old columns empty on an added row. - note: for `reworded`, quote the words that came in and the words that went out. For `added` and `removed`, say in a few words what the risk is about. If a heading on the other side covers the same ground, name it as the likely replacement. For `unchanged`, leave it empty unless the heading moved to a different section. - Quote any field that contains a comma. Write output/summary.md with the counts in the form `unchanged: 10`, `reworded: 3`, `added: 2`, `removed: 1`, then any section titles that are new or gone, then two or three sentences on what the changes say about where the company now sees risk. Say only what the headings support. ## Done looks like - Every heading from both years appears exactly once. - Every status follows the word test, not a guess. - The counts in summary.md equal the rows in risk_changes.csv.
input/risk_factors_2024.md · 55 lines, 5 KB
Chipotle Mexican Grill, Inc. Annual report (Form 10-K) for the fiscal year ended December 31, 2024 Item 1A. Risk Factors This file holds the section titles and the bold risk factor headings, in the order they appear in the filing. The paragraphs of text under each heading are left out. Filing: https://www.sec.gov/Archives/edgar/data/1058090/000105809025000014/cmg-20241231.htm ## Risks Related to our Brand Reputation and Restaurant Operations - Food safety and food-borne illness concerns may have an adverse effect on our business by negatively impacting our brand, decreasing sales and increasing costs. - Failure to maintain the reputation and relevance of the Chipotle brand could negatively impact our financial results. - The restaurant industry is highly competitive. If we are not able to compete successfully, our business, financial condition and results of operations would be adversely affected. - Our investments in technology and automation to transform and enhance the experience of our employees and guests may not generate the expected results. - Our use of third-party delivery services may not be profitable and substandard service may negatively impact our reputation. ## Risks Related to Human Capital - If we are not able to hire, develop and retain qualified restaurant employees and/or appropriately plan our workforce, our growth plan and profitability could be adversely affected. - If we fail to comply with applicable employment and labor laws and regulations, it could have a material, adverse impact on our business. - Increases in the cost of labor, including mandated minimum wage increases and increases in the cost of health benefits, could adversely impact our business and profitability. - A failure to recruit, develop and retain effective leaders or the loss or shortage of management personnel with key capacities and skills could impact our strategic growth plans and jeopardize our ability to meet our business performance expectations and growth targets. ## Risks Related to Cybersecurity, Data Privacy and IT Systems - Breaches or other unauthorized access, theft, modification or destruction of guest and/or employee personal, confidential or other material information that is stored in our systems or by third parties on our behalf could damage our reputation and expose us to potential liabilities. - If we fail to fully comply with privacy and data protection laws and regulations, we could incur significant civil and criminal penalties and liabilities, suffer reputational damage, and adverse publicity. - We rely heavily on information technology systems and failures or interruptions in our IT systems could harm our ability to effectively operate our business and/or result in the loss of guests or employees. ## Risks Related to Our Supply Chain - Increases in the costs of ingredients, restaurant equipment and other materials could adversely affect our financial results. - Shortages or interruptions in the supply of ingredients could adversely affect our operating results. - If our supply chain capacity does not expand to match our new restaurant growth, our long-term growth goals could be impaired or delayed. ## Legal and Regulatory Risks - We could be party to litigation or other legal proceedings that could adversely affect our business, results of operations and reputation. - We are subject to extensive laws, government regulation, and other legal requirements and our failure to comply with existing or new laws and regulations could adversely affect our operational efficiencies, ability to attract and retain talent and results of operations. ## Risks Related to Our Growth and Business Strategy - If we are unable to meet our new restaurant opening goals, or maintain the attractiveness of our existing restaurants, our profitability could suffer. - Our failure to effectively manage and support our growth could have a negative adverse effect on our business and financial results. - If we partner with third parties or acquire new businesses that do not align with our core values or that do not fulfill their contractual responsibilities and commitments, our brand reputation and international growth plans could suffer. - The market price of our common stock may be more volatile than the market price of our peers. ## Risks Related to Sustainability Factors - We are subject to evolving public disclosure requirements and expectations, including with respect to sustainability matters, that could expose us to numerous risks and could adversely affect our reputation and results of operations. - Climate change and volatile adverse weather conditions could adversely affect our restaurant sales or results of operations. ## General Risk Factors - Economic and business factors that are largely beyond our control may adversely affect consumer behavior and our financial results. - Our quarterly financial results may fluctuate significantly, including due to factors that are not in our control.
input/risk_factors_2025.md · 53 lines, 5 KB
Chipotle Mexican Grill, Inc. Annual report (Form 10-K) for the fiscal year ended December 31, 2025 Item 1A. Risk Factors This file holds the section titles and the bold risk factor headings, in the order they appear in the filing. The paragraphs of text under each heading are left out. Filing: https://www.sec.gov/Archives/edgar/data/1058090/000105809026000009/cmg-20251231.htm ## Risks Related to our Brand Reputation and Restaurant Operations - Food safety and food-borne illness concerns may have an adverse effect on our business by negatively impacting our brand, decreasing sales and increasing costs. - Failure to maintain the value and reputation of the Chipotle brand could negatively impact our financial results. - The restaurant industry is highly competitive. If we are not able to compete successfully, our business, financial condition and results of operations would be adversely affected. - Our use of third-party delivery services may not be profitable and substandard service may negatively impact our reputation. ## Risks Related to Human Capital - If we are not able to hire, train and retain qualified restaurant employees and/or appropriately plan our workforce, our growth plan and profitability could be adversely affected. - If we fail to comply with applicable employment and labor laws and regulations, it could have a material, adverse impact on our business. - Increases in the cost of labor, including mandated minimum wage increases and increases in the cost of health benefits, could adversely impact our business and profitability. - A failure to recruit, develop and retain effective leaders or the loss or shortage of management personnel with key capacities and skills could impact our strategic growth plans and jeopardize our ability to meet our business performance expectations and growth targets. ## Risks Related to Cybersecurity, Data Privacy and IT Systems - We are heavily dependent on information technology systems and failures or interruptions in our IT systems could harm our ability to effectively operate our business and/or result in the loss of guests or employees. - Breaches or other unauthorized access, theft, modification or destruction of guest and/or employee personal information, or Chipotle confidential or proprietary information that is stored in our information technology systems or by third parties could damage our reputation and expose us to potential liabilities and loss of revenue. - If we fail to fully comply with privacy and data protection laws and regulations, we could incur significant civil and criminal penalties and liabilities, suffer reputational damage, and adverse publicity. ## Risks Related to Our Supply Chain - Increases in the costs of ingredients, restaurant equipment and other materials could adversely affect our financial results. - Shortages or interruptions in the supply of ingredients could adversely affect our operating results. - If our supply chain capacity does not expand to support our new restaurant growth, our long-term growth goals could be impaired or delayed. ## Legal and Regulatory Risks - We could be party to litigation or other legal proceedings that could adversely affect our business, results of operations and reputation. - We are subject to extensive laws, government regulation, and other legal requirements and our failure to comply with existing or new laws and regulations could adversely affect our operational efficiencies, ability to attract and retain talent and results of operations. ## Risks Related to Our Growth and Business Strategy - If we are unable to meet our new restaurant opening goals, or maintain the attractiveness of our existing restaurants, our profitability could suffer. - Our failure to effectively manage and support our growth could have a negative adverse effect on our business and financial results. - If we partner with third parties or acquire new businesses that do not align with our core values or that do not fulfill their contractual responsibilities and commitments, our brand reputation and international growth plans could suffer. ## Risks Related to Sustainability Factors - We are subject to evolving public disclosure obligations, including with respect to sustainability matters, which could expose us to numerous risks and could adversely affect our reputation and results of operations. - Climate change and volatile adverse weather conditions could adversely affect our restaurant sales or results of operations. ## Risks Related to Macroeconomic Conditions - Our financial condition and results of operations have been, and may continue to be, adversely affected by a number of macroeconomic and other factors, many of which are largely outside our control. - Failure to meet market expectations for our financial performance or any announced guidance will likely adversely affect the market price and increase the volatility of our stock, and fluctuations in the stock market as a whole may also impact the market price and volatility of our stock.
output/risk_changes.csv · written by the agent, 28 lines
status,new_heading,old_heading,new_section,old_section,note unchanged,"Food safety and food-borne illness concerns may have an adverse effect on our business by negatively impacting our brand, decreasing sales and increasing costs.","Food safety and food-borne illness concerns may have an adverse effect on our business by negatively impacting our brand, decreasing sales and increasing costs.",Risks Related to our Brand Reputation and Restaurant Operations,Risks Related to our Brand Reputation and Restaurant Operations, reworded,Failure to maintain the value and reputation of the Chipotle brand could negatively impact our financial results.,Failure to maintain the reputation and relevance of the Chipotle brand could negatively impact our financial results.,Risks Related to our Brand Reputation and Restaurant Operations,Risks Related to our Brand Reputation and Restaurant Operations,"Words in: ""value"". Words out: ""relevance""." unchanged,"The restaurant industry is highly competitive. If we are not able to compete successfully, our business, financial condition and results of operations would be adversely affected.","The restaurant industry is highly competitive. If we are not able to compete successfully, our business, financial condition and results of operations would be adversely affected.",Risks Related to our Brand Reputation and Restaurant Operations,Risks Related to our Brand Reputation and Restaurant Operations, unchanged,Our use of third-party delivery services may not be profitable and substandard service may negatively impact our reputation.,Our use of third-party delivery services may not be profitable and substandard service may negatively impact our reputation.,Risks Related to our Brand Reputation and Restaurant Operations,Risks Related to our Brand Reputation and Restaurant Operations, reworded,"If we are not able to hire, train and retain qualified restaurant employees and/or appropriately plan our workforce, our growth plan and profitability could be adversely affected.","If we are not able to hire, develop and retain qualified restaurant employees and/or appropriately plan our workforce, our growth plan and profitability could be adversely affected.",Risks Related to Human Capital,Risks Related to Human Capital,"Words in: ""train"". Words out: ""develop""." unchanged,"If we fail to comply with applicable employment and labor laws and regulations, it could have a material, adverse impact on our business.","If we fail to comply with applicable employment and labor laws and regulations, it could have a material, adverse impact on our business.",Risks Related to Human Capital,Risks Related to Human Capital, unchanged,"Increases in the cost of labor, including mandated minimum wage increases and increases in the cost of health benefits, could adversely impact our business and profitability.","Increases in the cost of labor, including mandated minimum wage increases and increases in the cost of health benefits, could adversely impact our business and profitability.",Risks Related to Human Capital,Risks Related to Human Capital, unchanged,"A failure to recruit, develop and retain effective leaders or the loss or shortage of management personnel with key capacities and skills could impact our strategic growth plans and jeopardize our ability to meet our business performance expectations and growth targets.","A failure to recruit, develop and retain effective leaders or the loss or shortage of management personnel with key capacities and skills could impact our strategic growth plans and jeopardize our ability to meet our business performance expectations and growth targets.",Risks Related to Human Capital,Risks Related to Human Capital, reworded,We are heavily dependent on information technology systems and failures or interruptions in our IT systems could harm our ability to effectively operate our business and/or result in the loss of guests or employees.,We rely heavily on information technology systems and failures or interruptions in our IT systems could harm our ability to effectively operate our business and/or result in the loss of guests or employees.,"Risks Related to Cybersecurity, Data Privacy and IT Systems","Risks Related to Cybersecurity, Data Privacy and IT Systems","Words in: ""are"", ""dependent"". Words out: ""rely""." reworded,"Breaches or other unauthorized access, theft, modification or destruction of guest and/or employee personal information, or Chipotle confidential or proprietary information that is stored in our information technology systems or by third parties could damage our reputation and expose us to potential liabilities and loss of revenue.","Breaches or other unauthorized access, theft, modification or destruction of guest and/or employee personal, confidential or other material information that is stored in our systems or by third parties on our behalf could damage our reputation and expose us to potential liabilities.","Risks Related to Cybersecurity, Data Privacy and IT Systems","Risks Related to Cybersecurity, Data Privacy and IT Systems","Words in: ""chipotle"", ""loss"", ""proprietary"", ""revenue"", ""technology"". Words out: ""behalf"", ""material"", ""on""." unchanged,"If we fail to fully comply with privacy and data protection laws and regulations, we could incur significant civil and criminal penalties and liabilities, suffer reputational damage, and adverse publicity.","If we fail to fully comply with privacy and data protection laws and regulations, we could incur significant civil and criminal penalties and liabilities, suffer reputational damage, and adverse publicity.","Risks Related to Cybersecurity, Data Privacy and IT Systems","Risks Related to Cybersecurity, Data Privacy and IT Systems", unchanged,"Increases in the costs of ingredients, restaurant equipment and other materials could adversely affect our financial results.","Increases in the costs of ingredients, restaurant equipment and other materials could adversely affect our financial results.",Risks Related to Our Supply Chain,Risks Related to Our Supply Chain, unchanged,Shortages or interruptions in the supply of ingredients could adversely affect our operating results.,Shortages or interruptions in the supply of ingredients could adversely affect our operating results.,Risks Related to Our Supply Chain,Risks Related to Our Supply Chain, reworded,"If our supply chain capacity does not expand to support our new restaurant growth, our long-term growth goals could be impaired or delayed.","If our supply chain capacity does not expand to match our new restaurant growth, our long-term growth goals could be impaired or delayed.",Risks Related to Our Supply Chain,Risks Related to Our Supply Chain,"Words in: ""support"". Words out: ""match""." unchanged,"We could be party to litigation or other legal proceedings that could adversely affect our business, results of operations and reputation.","We could be party to litigation or other legal proceedings that could adversely affect our business, results of operations and reputation.",Legal and Regulatory Risks,Legal and Regulatory Risks, unchanged,"We are subject to extensive laws, government regulation, and other legal requirements and our failure to comply with existing or new laws and regulations could adversely affect our operational efficiencies, ability to attract and retain talent and results of operations.","We are subject to extensive laws, government regulation, and other legal requirements and our failure to comply with existing or new laws and regulations could adversely affect our operational efficiencies, ability to attract and retain talent and results of operations.",Legal and Regulatory Risks,Legal and Regulatory Risks, unchanged,"If we are unable to meet our new restaurant opening goals, or maintain the attractiveness of our existing restaurants, our profitability could suffer.","If we are unable to meet our new restaurant opening goals, or maintain the attractiveness of our existing restaurants, our profitability could suffer.",Risks Related to Our Growth and Business Strategy,Risks Related to Our Growth and Business Strategy, unchanged,Our failure to effectively manage and support our growth could have a negative adverse effect on our business and financial results.,Our failure to effectively manage and support our growth could have a negative adverse effect on our business and financial results.,Risks Related to Our Growth and Business Strategy,Risks Related to Our Growth and Business Strategy, unchanged,"If we partner with third parties or acquire new businesses that do not align with our core values or that do not fulfill their contractual responsibilities and commitments, our brand reputation and international growth plans could suffer.","If we partner with third parties or acquire new businesses that do not align with our core values or that do not fulfill their contractual responsibilities and commitments, our brand reputation and international growth plans could suffer.",Risks Related to Our Growth and Business Strategy,Risks Related to Our Growth and Business Strategy, reworded,"We are subject to evolving public disclosure obligations, including with respect to sustainability matters, which could expose us to numerous risks and could adversely affect our reputation and results of operations.","We are subject to evolving public disclosure requirements and expectations, including with respect to sustainability matters, that could expose us to numerous risks and could adversely affect our reputation and results of operations.",Risks Related to Sustainability Factors,Risks Related to Sustainability Factors,"Words in: ""obligations"", ""which"". Words out: ""expectations"", ""requirements"", ""that""." unchanged,Climate change and volatile adverse weather conditions could adversely affect our restaurant sales or results of operations.,Climate change and volatile adverse weather conditions could adversely affect our restaurant sales or results of operations.,Risks Related to Sustainability Factors,Risks Related to Sustainability Factors, added,"Our financial condition and results of operations have been, and may continue to be, adversely affected by a number of macroeconomic and other factors, many of which are largely outside our control.",,Risks Related to Macroeconomic Conditions,,Macroeconomic and other outside factors have hurt and may keep hurting results. Likely replacement for the removed 'Economic and business factors that are largely beyond our control...' heading. added,"Failure to meet market expectations for our financial performance or any announced guidance will likely adversely affect the market price and increase the volatility of our stock, and fluctuations in the stock market as a whole may also impact the market price and volatility of our stock.",,Risks Related to Macroeconomic Conditions,,Missing market expectations or guidance could hurt the stock price and raise its volatility. Likely replacement for the removed 'The market price of our common stock may be more volatile...' heading (and partly the removed quarterly results heading). removed,,Our investments in technology and automation to transform and enhance the experience of our employees and guests may not generate the expected results.,,Risks Related to our Brand Reputation and Restaurant Operations,Technology and automation investments may not deliver expected results. No heading in the new year covers it. removed,,The market price of our common stock may be more volatile than the market price of our peers.,,Risks Related to Our Growth and Business Strategy,Stock price may be more volatile than peers. Likely replaced by 'Failure to meet market expectations for our financial performance...'. removed,,Economic and business factors that are largely beyond our control may adversely affect consumer behavior and our financial results.,,General Risk Factors,"Economic and business factors beyond company control may hurt consumer behavior and results. Likely replaced by 'Our financial condition and results of operations have been, and may continue to be, adversely affected by a number of macroeconomic...'." removed,,"Our quarterly financial results may fluctuate significantly, including due to factors that are not in our control.",,General Risk Factors,"Quarterly results may fluctuate, including from factors outside company control. No close heading; the new macroeconomic and stock-price headings cover nearby ground."
output/summary.md · written by the agent, 23 lines
# Risk factor changes: Chipotle 10-K, FY2024 to FY2025 Old year: 25 headings (risk_factors_2024.md). New year: 23 headings (risk_factors_2025.md). unchanged: 15 reworded: 6 added: 2 removed: 4 Check: 15 + 6 + 4 = 25 old headings, and 15 + 6 + 2 = 23 new headings. The CSV has 27 rows. Statuses come from the word-overlap test (shared distinct words divided by the word count of the shorter heading, 0.75 or more means reworded), run in python3. ## Section titles - New: "Risks Related to Macroeconomic Conditions" - Gone: "General Risk Factors" - No heading moved between sections. ## What changed - Reworded (6): brand "relevance" became "value"; "develop" became "train" in the hiring heading; the IT heading changed from "rely heavily" to "heavily dependent"; the data breach heading now names Chipotle confidential or proprietary information and adds loss of revenue; supply chain capacity must "support" rather than "match" restaurant growth; the disclosure heading now says "obligations" instead of "expectations". - Added (2): both are under the new macroeconomic section. One is about macroeconomic and other outside factors affecting results. The other is about missing market expectations or guidance and the effect on the stock price. - Removed (4): technology and automation investments, stock price volatility versus peers, economic factors beyond company control, and quarterly results fluctuating. ## What it says The old "General Risk Factors" section is replaced by a "Macroeconomic Conditions" section that now holds both the outside-economy risk and the stock price risk, now framed around meeting market expectations and guidance. The technology and automation heading has no counterpart in the new year, and the headings alone don't say why. The body text under each heading is not in the input, so changes there are not covered.
check.py · the check, written before the run
"""Works out the status of every risk heading from the two filings and compares it with the table."""
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)
def norm(s):
for a, b in (("“", '"'), ("”", '"'), ("‘", "'"), ("’", "'"), ("–", "-"), ("—", "-"), (" ", " ")):
s = s.replace(a, b)
return re.sub(r"\s+", " ", s).strip()
def load(path):
out, sec = {}, ""
for ln in path.read_text().splitlines():
if ln.startswith("## "): sec = norm(ln[3:])
elif ln.startswith("- "): out[norm(ln[2:])] = sec
return out
files = sorted((root/"input").glob("risk_factors_*.md"))
old, new = load(files[0]), load(files[-1])
words = lambda s: set(re.findall(r"[a-z0-9]+", s.lower()))
share = lambda a, b: len(words(a) & words(b)) / min(len(words(a)), len(words(b)))
want = {} # (new heading, old heading) -> status
left_new = [h for h in new if h not in old]; left_old = [h for h in old if h not in new]
for h in new:
if h in old: want[(h, h)] = "unchanged"
for h in list(left_new):
best = max(left_old, key=lambda o: share(h, o), default=None)
if best and share(h, best) >= 0.75 and max(left_new, key=lambda n: share(n, best)) == h:
want[(h, best)] = "reworded"; left_new.remove(h); left_old.remove(best)
for h in left_new: want[(h, "")] = "added"
for h in left_old: want[("", h)] = "removed"
path = root/"output/risk_changes.csv"
if not path.exists():
say(False, "output/risk_changes.csv was not written"); sys.exit(1)
rows = list(csv.DictReader(path.open(newline="")))
g = lambda r, k: norm(r.get(k) or "")
seen_new = [g(r, "new_heading") for r in rows if g(r, "new_heading")]
seen_old = [g(r, "old_heading") for r in rows if g(r, "old_heading")]
n_ok = sum(1 for h in new if seen_new.count(h) == 1); o_ok = sum(1 for h in old if seen_old.count(h) == 1)
say(n_ok == len(new) and len(seen_new) == len(new), f"{n_ok} of {len(new)} new year headings appear word for word exactly once")
say(o_ok == len(old) and len(seen_old) == len(old), f"{o_ok} of {len(old)} old year headings appear word for word exactly once")
got = {(g(r, "new_heading"), g(r, "old_heading")): r for r in rows}
right = sum(1 for k, st in want.items() if k in got and g(got[k], "status").lower() == st)
kinds = {st: sum(1 for v in want.values() if v == st) for st in ("unchanged", "reworded", "added", "removed")}
say(right == len(want) and len(rows) == len(want), f"{right} of {len(want)} rows carry the status worked out from the two filings ({kinds['unchanged']} unchanged, {kinds['reworded']} reworded, {kinds['added']} added, {kinds['removed']} removed)")
sec = sum(1 for r in rows if (not g(r, "new_heading") or g(r, "new_section") == new.get(g(r, "new_heading"))) and (not g(r, "old_heading") or g(r, "old_section") == old.get(g(r, "old_heading"))))
say(sec == len(rows) and rows != [], f"{sec} of {len(rows)} rows name the section each heading sits under in its filing")
rew = [k for k, st in want.items() if st == "reworded"]
told = 0
for k in rew:
note = words(g(got.get(k, {}), "note")); diff = words(k[0]) ^ words(k[1])
told += len(note & diff) >= 1
say(told == len(rew), f"{told} of {len(rew)} reworded rows name a word that really changed between the years")
summary = norm((root/"output/summary.md").read_text()) if (root/"output/summary.md").exists() else ""
c_ok = sum(1 for st, n in kinds.items() if re.search(rf"{st}\W{{0,6}}{n}\b", summary.lower()))
secs_new, secs_old = set(new.values()), set(old.values())
changed = (secs_new - secs_old) | (secs_old - secs_new)
s_ok = sum(1 for s in changed if s.lower() in summary.lower())
say(c_ok == 4 and s_ok == len(changed), f"summary.md gives {c_ok} of 4 counts correctly and names {s_ok} of {len(changed)} section titles that are new or gone")
# every number the summary states is compared with a figure worked out from the two filings
low = summary.lower(); bad = set()
known = {str(v) for v in list(kinds.values()) + [len(old), len(new), len(want)]} | {y for f in files for y in re.findall(r"\d{4}", f.name)} | {"0.75", "75"}
for m in re.finditer(r"(unchanged|reworded|added|removed)\W{0,3}(\d+)\b", low):
if int(m.group(2)) != kinds[m.group(1)]: bad.add(m.start(2))
for m in re.finditer(r"(\d+) (?:(old|new) (?:year )?)?headings", low):
side = m.group(2) or (re.findall(r"\b(old|new)\b", low[max(0, m.start() - 40):m.start()]) or [""])[-1]
if int(m.group(1)) not in {"old": [len(old)], "new": [len(new)]}.get(side, [len(old), len(new)]): bad.add(m.start(1))
for m in re.finditer(r"(\d+) rows", low):
if int(m.group(1)) != len(want): bad.add(m.start(1))
sums = re.findall(r"\d+(?: \+ \d+)+ = \d+", low)
sum_ok = sum(1 for s in sums if sum(int(x) for x in re.findall(r"\d+", s.split("=")[0])) == int(s.split("=")[1]))
nums = list(re.finditer(r"(?<![\w.-])\d[\d,]*(?:\.\d+)?(?![\w-])", low))
num_ok = sum(1 for m in nums if m.start() not in bad and (len(m.group(0)) == 1 or m.group(0) in known))
say(nums != [] and num_ok == len(nums) and sum_ok == len(sums), f"{num_ok} of {len(nums)} numbers in summary.md equal a figure worked out from the two filings" + (f" and {sum_ok} of {len(sums)} sums in it add up" if sums else ""))
sys.exit(0 if ok else 1)
risk_factors_2024.md: public document. Fingerprint 52442d1d12a6.
risk_factors_2025.md: public document. Fingerprint f42fe77d8e74.
risk_changes.csv: written by the agent. Fingerprint 5ee37683a3e2.
summary.md: written by the agent. Fingerprint 641f3f556796.