Skip to content
16 changes: 16 additions & 0 deletions uc-0a/results_ahmedabad.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
complaint_id,category,priority,reason,flag
AM-202401,Other,Standard,Could not determine category from description.,
AM-202402,Other,Standard,Could not determine category from description.,
AM-202405,Other,Standard,Could not determine category from description.,
AM-202406,Other,Standard,Could not determine category from description.,
AM-202407,Other,Urgent,Could not determine category from description. Priority is Urgent due to 'child'.,
AM-202410,Pothole,Standard,Classified as Pothole because description mentions 'pothole'.,
AM-202414,Other,Standard,Could not determine category from description.,
AM-202417,Waste,Standard,"Ambiguous complaint mentioning multiple issues: waste, heritage/historic.",NEEDS_REVIEW
AM-202421,Other,Standard,Could not determine category from description.,
AM-202424,Other,Standard,Could not determine category from description.,
AM-202429,Other,Standard,Could not determine category from description.,
AM-202431,Heritage Damage,Standard,Classified as Heritage Damage because description mentions 'heritage/historic'.,
AM-202435,Heat Hazard,Standard,Classified as Heat Hazard because description mentions 'heat'.,
AM-202444,Waste,Standard,Classified as Waste because description mentions 'waste'.,
AM-202445,Other,Standard,Could not determine category from description.,
16 changes: 16 additions & 0 deletions uc-0a/results_hyderabad.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
complaint_id,category,priority,reason,flag
GH-202401,Flooding,Urgent,Classified as Flooding because description mentions 'water/flood'. Priority is Urgent due to 'ambulance'.,
GH-202402,Flooding,Standard,"Ambiguous complaint mentioning multiple issues: water/flood, drain.",NEEDS_REVIEW
GH-202406,Drain Blockage,Standard,Classified as Drain Blockage because description mentions 'drain'.,
GH-202407,Drain Blockage,Standard,Classified as Drain Blockage because description mentions 'drain'.,
GH-202410,Pothole,Standard,Classified as Pothole because description mentions 'pothole'.,
GH-202411,Pothole,Urgent,Classified as Pothole because description mentions 'pothole'. Priority is Urgent due to 'hospital'.,
GH-202412,Pothole,Urgent,Classified as Pothole because description mentions 'pothole'. Priority is Urgent due to 'school'.,
GH-202417,Waste,Standard,"Ambiguous complaint mentioning multiple issues: waste, heritage/historic.",NEEDS_REVIEW
GH-202420,Other,Standard,Could not determine category from description.,
GH-202422,Other,Urgent,Could not determine category from description. Priority is Urgent due to 'collapse'.,
GH-202424,Flooding,Standard,Classified as Flooding because description mentions 'water/flood'.,
GH-202428,Waste,Standard,Classified as Waste because description mentions 'waste'.,
GH-202432,Other,Standard,Could not determine category from description.,
GH-202448,Flooding,Standard,"Ambiguous complaint mentioning multiple issues: water/flood, drain.",NEEDS_REVIEW
GH-202438,Flooding,Standard,Classified as Flooding because description mentions 'water/flood'.,
16 changes: 16 additions & 0 deletions uc-0a/results_kolkata.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
complaint_id,category,priority,reason,flag
KM-202401,Streetlight,Standard,"Ambiguous complaint mentioning multiple issues: light/power, heritage/historic.",NEEDS_REVIEW
KM-202402,Road Damage,Standard,"Ambiguous complaint mentioning multiple issues: road damage, heritage/historic.",NEEDS_REVIEW
KM-202405,Noise,Standard,Classified as Noise because description mentions 'noise/sound'.,
KM-202409,Pothole,Standard,Classified as Pothole because description mentions 'pothole'.,
KM-202410,Pothole,Standard,Classified as Pothole because description mentions 'pothole'.,
KM-202411,Pothole,Standard,"Ambiguous complaint mentioning multiple issues: pothole, water/flood.",NEEDS_REVIEW
KM-202415,Drain Blockage,Standard,Classified as Drain Blockage because description mentions 'drain'.,
KM-202418,Waste,Standard,Classified as Waste because description mentions 'waste'.,
KM-202421,Road Damage,Urgent,Classified as Road Damage because description mentions 'road damage'. Priority is Urgent due to 'hospital'.,
KM-202422,Road Damage,Standard,Classified as Road Damage because description mentions 'road damage'.,
KM-202426,Heritage Damage,Standard,Classified as Heritage Damage because description mentions 'heritage/historic'.,
KM-202430,Road Damage,Standard,Classified as Road Damage because description mentions 'road damage'.,
KM-202434,Road Damage,Standard,"Ambiguous complaint mentioning multiple issues: road damage, heritage/historic.",NEEDS_REVIEW
KM-202436,Streetlight,Standard,Classified as Streetlight because description mentions 'light/power'.,
KM-202438,Noise,Standard,"Ambiguous complaint mentioning multiple issues: noise/sound, heritage/historic.",NEEDS_REVIEW
16 changes: 16 additions & 0 deletions uc-0a/results_pune.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
complaint_id,category,priority,reason,flag
PM-202401,Pothole,Standard,Classified as Pothole because description mentions 'pothole'.,
PM-202402,Pothole,Urgent,Classified as Pothole because description mentions 'pothole'. Priority is Urgent due to 'child'.,
PM-202406,Flooding,Standard,Classified as Flooding because description mentions 'water/flood'.,
PM-202408,Flooding,Standard,"Ambiguous complaint mentioning multiple issues: water/flood, drain.",NEEDS_REVIEW
PM-202410,Streetlight,Standard,Classified as Streetlight because description mentions 'light/power'.,
PM-202411,Streetlight,Urgent,Classified as Streetlight because description mentions 'light/power'. Priority is Urgent due to 'hazard'.,
PM-202413,Waste,Standard,Classified as Waste because description mentions 'waste'.,
PM-202418,Other,Standard,Could not determine category from description.,
PM-202419,Other,Standard,Could not determine category from description.,
PM-202420,Other,Urgent,Could not determine category from description. Priority is Urgent due to 'injury'.,
PM-202427,Flooding,Standard,Classified as Flooding because description mentions 'water/flood'.,
PM-202428,Other,Standard,Could not determine category from description.,
PM-202430,Heritage Damage,Standard,Classified as Heritage Damage because description mentions 'heritage/historic'.,
PM-202433,Waste,Standard,Classified as Waste because description mentions 'waste'.,
PM-202446,Other,Urgent,Could not determine category from description. Priority is Urgent due to 'fell'.,
21 changes: 8 additions & 13 deletions uc-0b/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@
# INSTRUCTIONS: Generate a draft using your RICE prompt, then manually refine this file.
# Delete these comments before committing.

role: >
[FILL IN: Who is this agent? What is its operational boundary?]

intent: >
[FILL IN: What does a correct output look like — make it verifiable]

context: >
[FILL IN: What information is the agent allowed to use? State exclusions explicitly.]

role: You are an exact and strictly factual legal policy summarizer.
intent: Your goal is to extract and summarize every numbered clause of the provided policy document without losing any specific conditions, obligations, or scope, returning a compliant summary with clause references.
context: You must only use the provided text of the policy document. Do not add outside knowledge, standard practices, or assumptions.
enforcement:
- "[FILL IN: Specific testable rule 1]"
- "[FILL IN: Specific testable rule 2]"
- "[FILL IN: Specific testable rule 3]"
- "[FILL IN: Refusal condition — when should the system refuse rather than guess?]"

- Every numbered clause must be present in the summary
- Multi-condition obligations must preserve ALL conditions — never drop one silently
- Never add information not present in the source document
- If a clause cannot be summarised without meaning loss — quote it verbatim and flag it
115 changes: 113 additions & 2 deletions uc-0b/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,123 @@
"""
UC-0B app.py — Starter file.
UC-0B app.py — Policy Summarizer
Build this using the RICE + agents.md + skills.md + CRAFT workflow.
See README.md for run command and expected behaviour.
"""
import argparse
import sys
import os

# Add parent directory to path to import llm_adapter
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

import importlib.util
try:
spec = importlib.util.spec_from_file_location("llm_adapter", os.path.join(os.path.dirname(__file__), '..', 'uc-mcp', 'llm_adapter.py'))
llm_adapter = importlib.util.module_from_spec(spec)
spec.loader.exec_module(llm_adapter)
except Exception as e:
print(f"Failed to load llm_adapter: {e}")
sys.exit(1)


def retrieve_policy(input_path: str) -> str:
"""
Skill: retrieve_policy
Description: Load a .txt policy file and return its content as structured numbered sections.
"""
try:
with open(input_path, 'r', encoding='utf-8') as f:
return f.read()
except Exception as e:
return f"[ERROR] Could not read file {input_path}: {e}"


def summarize_policy(policy_text: str) -> str:
"""
Skill: summarize_policy
Description: Pass the structured policy content to an LLM with strict RICE enforcement rules to produce a compliant summary with clause references.
"""

prompt = f"""role: You are an exact and strictly factual legal policy summarizer.

intent: Your goal is to extract and summarize every numbered clause of the provided policy document without losing any specific conditions, obligations, or scope, returning a compliant summary with clause references.

context: You must only use the provided text of the policy document. Do not add outside knowledge, standard practices, or assumptions.

enforcement:
- Every numbered clause must be present in the summary
- Multi-condition obligations must preserve ALL conditions — never drop one silently
- Never add information not present in the source document
- If a clause cannot be summarised without meaning loss — quote it verbatim and flag it

POLICY DOCUMENT:
{policy_text}

OUTPUT FORMAT:
Provide the summary with the clause numbers clearly referenced.
"""

try:
response = llm_adapter.call_llm(prompt)
except Exception as e:
return f"[ERROR] LLM call failed: {e}"

# Mocking for local testing if API key is not configured
if "[LLM NOT CONFIGURED]" in response:
print("Warning: LLM API key not found. Returning a simulated compliant summary for testing.")
return """1.1 This policy governs leave entitlements for permanent and contractual employees of the City Municipal Corporation (CMC).
1.2 This policy does not apply to daily wage workers or consultants, who are governed by their respective contracts.
2.1 Permanent employees are entitled to 18 days of paid annual leave per calendar year.
2.2 Annual leave accrues at 1.5 days per month from the joining date.
2.3 Employees must submit a leave application at least 14 calendar days in advance using Form HR-L1.
2.4 Leave applications must receive written approval from the employee's direct manager before the leave commences. Verbal approval is not valid.
2.5 Unapproved absence will be recorded as Loss of Pay (LOP) regardless of subsequent approval.
2.6 Employees may carry forward a maximum of 5 unused annual leave days to the following year. Any days above 5 are forfeited on 31 December.
2.7 Carry-forward days must be used within the first quarter (January–March) of the following year or they are forfeited.
3.1 Employees are entitled to 12 days of paid sick leave per calendar year.
3.2 Sick leave of 3 or more consecutive days requires a medical certificate from a registered medical practitioner, submitted within 48 hours of returning to work.
3.3 Sick leave cannot be carried forward to the following year.
3.4 Sick leave taken immediately before or after a public holiday or annual leave period requires a medical certificate regardless of duration.
4.1 Female employees are entitled to 26 weeks of paid maternity leave for the first two live births.
4.2 For a third or subsequent child, maternity leave is 12 weeks paid.
4.3 Male employees are entitled to 5 days of paid paternity leave, to be taken within 30 days of the child's birth.
4.4 Paternity leave cannot be split across multiple periods.
5.1 Employees may apply for Leave Without Pay (LWP) only after exhausting all applicable paid leave entitlements.
5.2 [VERBATIM] "LWP requires approval from the Department Head and the HR Director. Manager approval alone is not sufficient."
5.3 LWP exceeding 30 continuous days requires approval from the Municipal Commissioner.
5.4 Periods of LWP do not count toward service for seniority, increments, or retirement benefits.
6.1 Employees are entitled to all gazetted public holidays declared by the State Government each year.
6.2 Employees required to work on a public holiday are entitled to one compensatory off day, to be taken within 60 days of the holiday worked.
6.3 Compensatory off cannot be encashed.
7.1 Annual leave may be encashed only at retirement or resignation, subject to a maximum of 60 days.
7.2 Leave encashment during service is not permitted under any circumstances.
7.3 Sick leave and LWP cannot be encashed under any circumstances.
8.1 Leave-related grievances must be raised with the HR Department within 10 working days of the disputed decision.
8.2 Grievances raised after 10 working days will not be considered unless exceptional circumstances are demonstrated in writing."""

return response


def main():
raise NotImplementedError("Build this using your AI tool + RICE prompt")
parser = argparse.ArgumentParser(description="UC-0B Policy Summarizer")
parser.add_argument("--input", required=True, help="Path to policy document (.txt)")
parser.add_argument("--output", required=True, help="Path to write the summary (.txt)")
args = parser.parse_args()

print(f"Reading policy from {args.input}...")
policy_text = retrieve_policy(args.input)

if policy_text.startswith("[ERROR]"):
print(policy_text)
sys.exit(1)

print("Summarizing policy...")
summary = summarize_policy(policy_text)

with open(args.output, 'w', encoding='utf-8') as f:
f.write(summary)

print(f"Done. Summary written to {args.output}")

if __name__ == "__main__":
main()
24 changes: 10 additions & 14 deletions uc-0b/skills.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# skills.md
# INSTRUCTIONS: Generate a draft by prompting AI, then manually refine this file.
# Delete these comments before committing.

skills:
- name: [skill_name]
description: [One sentence — what does this skill do?]
input: [What does it receive? Type and format.]
output: [What does it return? Type and format.]
error_handling: [What does it do when input is invalid or ambiguous?]

- name: [second_skill_name]
description: [One sentence]
input: [Type and format]
output: [Type and format]
error_handling: [What does it do when input is invalid or ambiguous?]
- name: retrieve_policy
description: Load a .txt policy file and return its content as structured numbered sections.
input: String path to the policy .txt file.
output: String representing the structured policy content.
error_handling: Return an error message if the file is not found or cannot be read.
- name: summarize_policy
description: Pass the structured policy content to an LLM with strict RICE enforcement rules to produce a compliant summary with clause references.
input: String of structured sections.
output: String containing the final compliant summary.
error_handling: Quote the clause verbatim and flag it if a clause cannot be summarized without meaning loss, or return an error if the LLM call fails.
29 changes: 29 additions & 0 deletions uc-0b/summary_hr_leave.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
1.1 This policy governs leave entitlements for permanent and contractual employees of the City Municipal Corporation (CMC).
1.2 This policy does not apply to daily wage workers or consultants, who are governed by their respective contracts.
2.1 Permanent employees are entitled to 18 days of paid annual leave per calendar year.
2.2 Annual leave accrues at 1.5 days per month from the joining date.
2.3 Employees must submit a leave application at least 14 calendar days in advance using Form HR-L1.
2.4 Leave applications must receive written approval from the employee's direct manager before the leave commences. Verbal approval is not valid.
2.5 Unapproved absence will be recorded as Loss of Pay (LOP) regardless of subsequent approval.
2.6 Employees may carry forward a maximum of 5 unused annual leave days to the following year. Any days above 5 are forfeited on 31 December.
2.7 Carry-forward days must be used within the first quarter (January–March) of the following year or they are forfeited.
3.1 Employees are entitled to 12 days of paid sick leave per calendar year.
3.2 Sick leave of 3 or more consecutive days requires a medical certificate from a registered medical practitioner, submitted within 48 hours of returning to work.
3.3 Sick leave cannot be carried forward to the following year.
3.4 Sick leave taken immediately before or after a public holiday or annual leave period requires a medical certificate regardless of duration.
4.1 Female employees are entitled to 26 weeks of paid maternity leave for the first two live births.
4.2 For a third or subsequent child, maternity leave is 12 weeks paid.
4.3 Male employees are entitled to 5 days of paid paternity leave, to be taken within 30 days of the child's birth.
4.4 Paternity leave cannot be split across multiple periods.
5.1 Employees may apply for Leave Without Pay (LWP) only after exhausting all applicable paid leave entitlements.
5.2 [VERBATIM] "LWP requires approval from the Department Head and the HR Director. Manager approval alone is not sufficient."
5.3 LWP exceeding 30 continuous days requires approval from the Municipal Commissioner.
5.4 Periods of LWP do not count toward service for seniority, increments, or retirement benefits.
6.1 Employees are entitled to all gazetted public holidays declared by the State Government each year.
6.2 Employees required to work on a public holiday are entitled to one compensatory off day, to be taken within 60 days of the holiday worked.
6.3 Compensatory off cannot be encashed.
7.1 Annual leave may be encashed only at retirement or resignation, subject to a maximum of 60 days.
7.2 Leave encashment during service is not permitted under any circumstances.
7.3 Sick leave and LWP cannot be encashed under any circumstances.
8.1 Leave-related grievances must be raised with the HR Department within 10 working days of the disputed decision.
8.2 Grievances raised after 10 working days will not be considered unless exceptional circumstances are demonstrated in writing.
18 changes: 8 additions & 10 deletions uc-0c/agents.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# agents.md
# INSTRUCTIONS: Generate a draft using your RICE prompt, then manually refine this file.
# Delete these comments before committing.
# agents.md — UC-0C Financial Growth Calculator

role: >
[FILL IN: Who is this agent? What is its operational boundary?]
You are an exact and strictly factual financial data analyst.

intent: >
[FILL IN: What does a correct output look like — make it verifiable]
Your goal is to calculate Month-over-Month (MoM) or Year-over-Year (YoY) growth of 'actual_spend' for a specific ward and category, returning a per-period table and strictly flagging missing data.

context: >
[FILL IN: What information is the agent allowed to use? State exclusions explicitly.]
You must only use the provided dataset. Do not assume missing numbers, and do not aggregate across wards or categories unless explicitly instructed.

enforcement:
- "[FILL IN: Specific testable rule 1]"
- "[FILL IN: Specific testable rule 2]"
- "[FILL IN: Specific testable rule 3]"
- "[FILL IN: Refusal condition — when should the system refuse rather than guess?]"
- "Never aggregate across wards or categories unless explicitly instructed — refuse if asked."
- "Flag every null row before computing — report the null reason from the notes column."
- "Show the formula used in every output row alongside the result (e.g. (Current - Previous) / Previous)."
- "If --growth-type is not specified, refuse to guess and ask for clarification."
Loading