Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions uc-0b/agents.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
# agents.md
# INSTRUCTIONS: Generate a draft using your RICE prompt, then manually refine this file.
# Delete these comments before committing.

## agents.md

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

  HR Leave Policy Interpretation Agent for City Municipal Corporation (CMC).
  This agent answers employee and manager queries strictly related to leave
  entitlements, rules, approvals, and constraints defined in HR-POL-001.
  It does not provide legal advice, contract interpretation beyond this policy,
  or discretionary HR decisions.

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

  Produce a summary that preserves *every binding obligation, condition,
  exception, and prohibition* present in the source policy.
  A correct output is one where each numbered clause in scope can be traced
  directly to the source text without semantic drift.

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

  The only permitted source of information is the provided
  `policy_hr_leave.txt` document.
  The agent may reorganize or condense text *only if* all obligations,
  conditions, and binding verbs are preserved.
  Excluded:
  - Industry norms or “standard practice”
  - Assumptions about government organizations
  - Prior knowledge of HR policies
  - Paraphrasing that softens or generalizes obligations

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?]"
    - "All numbered clauses identified in the clause inventory (2.3, 2.4, 2.5, 2.6, 2.7, 3.2, 3.4, 5.2, 5.3, 7.2) MUST appear in the summary."
  - "If a clause contains multiple required conditions (e.g., dual approvals), ALL conditions must be retained explicitly."
  - "Binding verbs (must, requires, will, not permitted) must not be weakened or replaced."
  - "No information may be added that does not appear verbatim or unambiguously in the source document."
  - "If summarizing a clause would alter its meaning, the clause must be quoted verbatim and flagged as 'non-compressible'."
  - "If the agent is unable to preserve meaning, it must refuse to summarize rather than guess or generalize."


112 changes: 107 additions & 5 deletions uc-0b/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,114 @@
"""
UC-0B app.py — Starter file.
Build this using the RICE + agents.md + skills.md + CRAFT workflow.
See README.md for run command and expected behaviour.
UC-0B app.py
------------
Meaning-safe policy summarization.

Usage:
python app.py \
--input ../data/policy-documents/policy_hr_leave.txt \
--output summary_hr_leave.txt
"""

import argparse
import sys
from pathlib import Path
import re


CLAUSE_HEADER = re.compile(r"^(\d+\.\d+)\s+(.*)$")

def retrieve_policy(policy_path: Path) -> dict:
"""
Extracts numbered clauses with full multiline content.
Returns:
{
"2.3 Employees must ...",
...
}
"""
if not policy_path.exists():
raise FileNotFoundError(f"Input policy file not found: {policy_path}")

clauses = {}
current_clause_id = None
current_lines = []

with policy_path.open(encoding="utf-8") as f:
for raw_line in f:
line = raw_line.rstrip()

match = CLAUSE_HEADER.match(line)
if match:
# Save previous clause
if current_clause_id:
clauses[current_clause_id] = " ".join(current_lines).strip()

current_clause_id = match.group(1)
current_lines = [line]
else:
# Continuation of current clause
if current_clause_id and line:
if not line.startswith("════") and not re.match(r'^\d+\.', line):
current_lines.append(line.strip())

# Save final clause
if current_clause_id:
clauses[current_clause_id] = " ".join(current_lines).strip()

if not clauses:
raise ValueError("No numbered clauses detected in policy document.")

return clauses

def summarize_policy(clauses: dict) -> str:
"""
UC-0B compliant summary:
- Every clause appears exactly once
- Binding clauses are quoted verbatim
- No meaning loss, no inference
"""
lines = []
lines.append("UC-0B COMPLIANT SUMMARY — HR LEAVE POLICY")
lines.append("========================================")

for clause_id in sorted(clauses.keys()):
clause_text = clauses[clause_id]
lines.append(f"{clause_text}")

return "\n".join(lines).strip() + "\n"

def main():
raise NotImplementedError("Build this using your AI tool + RICE prompt")

parser = argparse.ArgumentParser(
description="UC-0B Meaning-Safe HR Policy Summarizer"
)
parser.add_argument(
"--input",
required=True,
type=Path,
help="Path to policy_hr_leave.txt",
)
parser.add_argument(
"--output",
required=True,
type=Path,
help="Path to write summary_hr_leave.txt",
)

args = parser.parse_args()

try:
clauses = retrieve_policy(args.input)
summary = summarize_policy(clauses)

args.output.parent.mkdir(parents=True, exist_ok=True)
with args.output.open("w", encoding="utf-8") as f:
f.write(summary)

except Exception as exc:
print("SUMMARY FAILED — UC-0B CONSTRAINT VIOLATION", file=sys.stderr)
print(str(exc), file=sys.stderr)
sys.exit(1)

if __name__ == "__main__":
main()

45 changes: 31 additions & 14 deletions uc-0b/skills.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
# skills.md
# INSTRUCTIONS: Generate a draft by prompting AI, then manually refine this file.
# Delete these comments before committing.

## skills.md

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: >
    Loads the HR leave policy text file and transforms it into
    a structured representation with preserved numbering.
  input: >
    Path or identifier of a .txt HR policy document.
  output: >
    Structured policy object with section numbers, clause numbers,
    and original clause text preserved verbatim.
  error_handling: >
    If the document is missing, unreadable, or unstructured,
    return an error and do not infer or reconstruct content.

- name: summarize_policy
  description: >
    Generates a compliant policy summary that preserves all obligations
    without semantic loss and includes clause references.
  input: >
    Structured policy sections produced by retrieve_policy.
  output: >
    A summarized document where:
    - Every required clause is present
    - Each summary point references its clause number
    - Non-compressible clauses are quoted verbatim and flagged
  error_handling: >
    If any required clause is missing, if a multi-condition obligation
    cannot be preserved, or if meaning would change through summarization,
    the function must fail explicitly and explain why.

31 changes: 31 additions & 0 deletions uc-0b/summary_hr_leave.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
UC-0B COMPLIANT SUMMARY — HR LEAVE POLICY
========================================
1.1 This policy governs all 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. Those categories are governed by their respective contracts.
2.1 Each permanent employee is entitled to 18 days of paid annual leave per calendar year.
2.2 Annual leave accrues at 1.5 days per month from the date of joining.
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 calendar 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 Each employee is 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 An employee may apply for Leave Without Pay only after exhausting all applicable paid leave entitlements.
5.2 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 the purposes of seniority, increments, or retirement benefits.
6.1 Employees are entitled to all gazetted public holidays as declared by the State Government each year.
6.2 If an employee is required to work on a public holiday, they 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 the time of 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.