01_regulatory_monitoring_tool.py
runs in your browserSource on GitHubFetches from an approved source registry and rejects authority drift.
your browser01_regulatory_monitoring_tool.py
# Generated from ch16_regulatory_capital/01_regulatory_monitoring_tool.py for in-browser execution.
# Agno agent wiring is removed so the tool runs as a plain function;
# the full version is on GitHub. Do not edit: regenerate with
# scripts/build_demos.py.
# regulatory_monitoring_tool.py
# Book reference: Chapter 16, "Architecture"
# Repo notes:
# - _retrieve_from_source lives in support.py (synthetic, offline).
# - The printed listing's header pins agno==1.0.6 / google-genai==0.8.0 /
# pinecone-client==4.1.2; the repo pins agno 2.x per the root
# pyproject.toml. See ERRATA in the root README.
from datetime import datetime, timezone
import os
import sys
from support import _retrieve_from_source
# Source-of-truth registry — owned by Group Risk.
# Authority verification is structural, not runtime.
SOURCE_OF_TRUTH = {
"iasb": {
"url_pattern": "https://www.ifrs.org/news-and-events/news/",
"publication_id_format": "IFRS-YYYY-NN",
"review_cadence_days": 14,
},
"eiopa": {
"url_pattern": "https://www.eiopa.europa.eu/publications_en",
"publication_id_format": "EIOPA-BoS-YY-NNN",
"review_cadence_days": 7,
},
"irdai": {
"url_pattern": "https://irdai.gov.in/circulars",
"publication_id_format": "IRDAI/REG/CIR/NNN/YYYY-YY",
"review_cadence_days": 7,
},
# ... mas, naic, pra, iais entries follow the same shape
}
def fetch_regulatory_publications(
source_id: str,
cycle_window_days: int = 7,
) -> dict:
"""Return new publications from the named source within the cycle window.
Authority verification is encoded at the tool layer.
Verbatim retrievals truncated to <=14 words per copyright discipline.
"""
if source_id not in SOURCE_OF_TRUTH: # authority drift guard
return {"status": "rejected", "reason": "source_not_in_authority_registry"}
source = SOURCE_OF_TRUTH[source_id]
retrieved_at = datetime.now(timezone.utc).isoformat() # staleness marker
publications = _retrieve_from_source(source, cycle_window_days)
for pub in publications: # copyright discipline
if len(pub["verbatim_excerpt"].split()) > 14:
pub["paraphrase_required"] = True
pub["verbatim_excerpt"] = " ".join(
pub["verbatim_excerpt"].split()[:14]
) + " ..."
return {
"status": "ok",
"source_id": source_id,
"retrieved_at": retrieved_at,
"publications": publications,
"diagnostic_surface": {
"source_authority": source["url_pattern"],
"publication_id_format": source["publication_id_format"],
"review_cadence_days": source["review_cadence_days"],
},
}
if __name__ == "__main__":
# Exercise the tool directly: an in-registry source and the
# authority-drift rejection path.
print(fetch_regulatory_publications("eiopa", cycle_window_days=7))
print(fetch_regulatory_publications("some_blog", cycle_window_days=7))