Davemaina1 puts Mike on a Kenyan-law honesty contract

The fork rewires the assistant to refuse rather than guess when it's asked about Kenyan statutes or cases.

searchcompliance

Davemaina1's fork replaces the standard "answer from your legal knowledge" instruction with an eight-rule contract: before citing any Kenyan statute, case, regulation or guidance, the assistant has to actually look it up. Two retrieval tools sit behind it - one searches a local corpus of Kenyan legal material, the other does a web search restricted to a short allowlist of trusted Kenyan and East African legal sites like kenyalaw.org and the judiciary's own portal. Inventing or paraphrasing citations is banned outright, empty results have to be admitted, and pre-1977 East African Court of Appeal cases get flagged as persuasive rather than binding.

The contract was deliberately wired in ahead of the retrieval plumbing, so a misconfigured deployment fails closed: the model refuses instead of hallucinating. Results also carry enough metadata - court, year, binding status - for the assistant to prefer newer authority and flag conflicts between the corpus and the web.

So what Anyone building jurisdiction-specific legal AI should study this pattern: the honesty contract is portable verbatim, and the local-corpus-plus-allowlisted-web design is a clean template for grounding a model in one country's law.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

3 commits from Davemaina1/iroh_, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
7244c0be feat: add Kenyan legal authority grounding contract to system prompt Davemaina1 2026-05-13 ↗ GitHub
commit body
Replaces the open-ended "answer based on your legal knowledge" line with
an 8-rule honesty contract that:
- Requires retrieval via search_kenya_law (local corpus) and
  search_legal_authority_web (approved domains) before citing any
  Kenyan statute, case, regulation, or guidance
- Prohibits citing Kenyan legal authority from training data
- Requires surfacing corpus-vs-web conflicts and preferring newer authority
- Mandates an explicit "no results" admission when both tools come up empty
- Bans invented or paraphrased citations outright
- Flags EA Court of Appeal cases (pre-1977) as persuasive, not binding
- Directs users to kenyalaw.org / relevant regulator for out-of-corpus
  authorities

Retrieval tools (search_kenya_law, search_legal_authority_web) are not yet
registered - contract is placed ahead of implementation intentionally so
the model refuses rather than hallucinates if a retrieval gap occurs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
07e1243e feat: add Kenya Law RAG and trusted web search tools Davemaina1 2026-05-13 ↗ GitHub
commit body
Implements two retrieval tools that ground Iroh's legal responses in
authoritative Kenyan sources rather than training-data recall:

- search_kenya_law: ChromaDB semantic search over the Kenya Law corpus
  using Xenova/all-MiniLM-L6-v2 embeddings (384-dim, mean pool,
  normalized). Lazy-cached embedder and collection. east_africa
  jurisdiction filter applied via where clause; kenya filter omitted
  to avoid silently dropping chunks that predate the metadata field.
  Returns 400-char snippets with distance; notes weak results (>0.6).

- search_legal_authority_web: Tavily search restricted to 12 trusted
  Kenyan/East African legal authority domains (kenyalaw.org,
  parliament.go.ke, judiciary.go.ke, etc.). Never throws - all
  failures surface as { results: [], note }.

Both tools registered in TOOLS[] and dispatched in runToolCalls.
chromadb and @xenova/transformers added as dependencies.
CHROMA_DB_PATH and TAVILY_API_KEY documented in .env.example.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
83f72e57 Fix normalizer metadata projection; verify and expand domain allowlist Davemaina1 2026-05-13 ↗ GitHub

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-378.md from inside the repo you want the changes in.

⬇ Download capture-thread-378.md