Skip to content

Commit c52044e

Browse files
authored
Merge pull request #492 from s-and-p-team/feat/aiac-github-issue-agent-poc
Feat: Add AI-assisted GitHub issue agent POC
2 parents 564f862 + bdce3b3 commit c52044e

29 files changed

Lines changed: 4799 additions & 40 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Runtime credentials — copy aiac.env.TEMPLATE to aiac.env and fill in your values.
2+
aiac.env
3+
4+
# LLM config with real endpoints/keys — copy llm_conf.yaml.TEMPLATE and fill in values.
5+
aiac_agent/config/llm_conf.yaml
6+
7+
# Generated policy files — created at runtime by aiac_cli.py.
8+
generated_configs/
9+
10+
# Python virtual environment
11+
venv/
12+
__pycache__/
13+
*.pyc
14+
.pytest_cache/
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# AIAC demo Makefile — AI-generated access control policy workflow.
2+
#
3+
# End-to-end:
4+
#
5+
# make setup # provision Keycloak realm (clients, roles, users)
6+
# make apply-policy # generate + apply regular_policy.txt (full pipeline)
7+
# make show-result # render active composite-role mappings in Keycloak
8+
# make reset # wipe generated configs + re-provision realm
9+
#
10+
# Prerequisites:
11+
# - uv (https://docs.astral.sh/uv/)
12+
# - Keycloak running and accessible
13+
# - aiac.env configured (copy from aiac.env.TEMPLATE)
14+
# - aiac_agent/config/llm_conf.yaml configured (copy from llm_conf.yaml.TEMPLATE)
15+
16+
.PHONY: help preflight setup apply-policy apply-permissive show-result reset
17+
18+
# `make` with no target prints help.
19+
.DEFAULT_GOAL := help
20+
21+
help: ## Show this menu (default)
22+
@printf "\nAIAC demo — AI-generated access control policies for the GitHub issue agent.\n\n"
23+
@printf "Typical run:\n"
24+
@printf " \033[1mmake setup\033[0m # provision Keycloak realm\n"
25+
@printf " \033[1mmake apply-policy\033[0m # generate + apply regular policy\n"
26+
@printf " \033[1mmake show-result\033[0m # verify composite roles in Keycloak\n"
27+
@printf " \033[1mmake reset\033[0m # wipe generated configs + re-provision realm\n\n"
28+
@printf "Targets:\n"
29+
@awk 'BEGIN { FS = ":.*## " } \
30+
/^[a-zA-Z_-]+:.*## / { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }' \
31+
$(MAKEFILE_LIST)
32+
@printf "\nVariables:\n"
33+
@printf " \033[36m%-20s\033[0m %s\n" "POLICY" "policy file to apply (default: policies/regular_policy.txt)"
34+
@printf " \033[36m%-20s\033[0m %s\n" "PYTHON" "Python interpreter (default: kagenti-extensions/.venv/bin/python)"
35+
@printf "\nPrerequisites: uv, Keycloak running, aiac.env and llm_conf.yaml configured.\n\n"
36+
37+
POLICY ?= policies/regular_policy.txt
38+
39+
# Resolve the venv relative to this Makefile, regardless of where make is invoked.
40+
MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
41+
VENV := $(MAKEFILE_DIR)../../../../.venv
42+
PYTHON ?= $(VENV)/bin/python
43+
44+
# ---------- Pre-flight ----------
45+
46+
preflight: ## Verify prerequisites (uv, venv, aiac.env, llm_conf.yaml, Keycloak)
47+
@command -v uv >/dev/null 2>&1 || { \
48+
echo "ERROR: uv not found."; \
49+
echo " Install: curl -LsSf https://astral.sh/uv/install.sh | sh"; \
50+
exit 1; \
51+
}
52+
@test -x "$(VENV)/bin/python" || { \
53+
echo "ERROR: venv not found at $(VENV)"; \
54+
echo " Run: uv venv $(VENV)"; \
55+
exit 1; \
56+
}
57+
@test -f aiac.env || { \
58+
echo "ERROR: aiac.env not found."; \
59+
echo " Copy aiac.env.TEMPLATE to aiac.env and fill in your Keycloak credentials."; \
60+
exit 1; \
61+
}
62+
@test -f aiac_agent/config/llm_conf.yaml || { \
63+
echo "ERROR: aiac_agent/config/llm_conf.yaml not found."; \
64+
echo " Copy aiac_agent/config/llm_conf.yaml.TEMPLATE and configure your LLM."; \
65+
exit 1; \
66+
}
67+
@$(PYTHON) -c 'import dotenv, yaml, keycloak, langgraph, langchain_core, langchain_openai, pydantic' 2>/dev/null || { \
68+
echo "ERROR: Python dependencies missing."; \
69+
echo " Run: uv pip install --python $(VENV)/bin/python -r ../../../requirements.txt"; \
70+
exit 1; \
71+
}
72+
@KEYCLOAK_URL=$$(grep -E '^KEYCLOAK_URL=' aiac.env | cut -d= -f2-); \
73+
curl -sf "$$KEYCLOAK_URL/realms/master" -o /dev/null || { \
74+
echo "ERROR: Keycloak not reachable at $$KEYCLOAK_URL"; \
75+
echo " Ensure Keycloak is running and KEYCLOAK_URL in aiac.env is correct."; \
76+
exit 1; \
77+
}
78+
@echo "[✓] All prerequisites met."
79+
80+
# ---------- Setup ----------
81+
82+
setup: preflight ## Provision Keycloak realm with clients, roles, and users
83+
@echo "[*] Provisioning Keycloak realm ..."
84+
$(PYTHON) ../setup_keycloak.py -rbac config.yaml
85+
@echo "[✓] Keycloak realm provisioned."
86+
87+
# ---------- Apply policy ----------
88+
89+
apply-policy: preflight ## Generate + apply POLICY (default: policies/regular_policy.txt) to Keycloak
90+
@echo "[*] Running AIAC full pipeline: $(POLICY)"
91+
$(PYTHON) aiac_cli.py --yes $(POLICY)
92+
93+
apply-permissive: POLICY = policies/permissive_policy.txt
94+
apply-permissive: apply-policy ## Generate + apply the permissive policy (grants Sales access)
95+
96+
# ---------- Show result ----------
97+
98+
show-result: preflight ## Show active composite-role mappings in Keycloak (verify applied policy)
99+
$(PYTHON) scripts/show-result.py
100+
101+
# ---------- Reset ----------
102+
103+
reset: preflight ## Wipe generated configs and re-provision the realm from scratch
104+
@echo "[*] Removing generated configs ..."
105+
@rm -f generated_configs/*.yaml
106+
@echo "[*] Re-provisioning Keycloak realm ..."
107+
$(PYTHON) ../setup_keycloak.py -rbac config.yaml
108+
@echo "[✓] Reset complete."
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Keycloak connection settings
2+
# Copy this file to aiac.env and fill in your values.
3+
KEYCLOAK_URL=http://keycloak.localtest.me:8080
4+
KEYCLOAK_ADMIN_USERNAME=<YOUR ADMIN USERNAME HERE>
5+
KEYCLOAK_ADMIN_PASSWORD=<YOUR ADMIN PASSWORD HERE>
6+
REALM_NAME=kagenti
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
Access Control Policy Builder Package
3+
4+
AI-powered access control policy builder using LangGraph.
5+
Converts natural language descriptions into structured YAML policies.
6+
"""
7+
8+
from aiac_agent.agent.graph import PolicyBuilder
9+
10+
__version__ = "1.0.0"
11+
12+
__all__ = ["PolicyBuilder"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
Agent Module
3+
4+
Contains the LangGraph-based policy builder agent implementation.
5+
6+
This module implements the core policy generation workflow using LangGraph's
7+
state machine architecture. It provides a multi-stage pipeline that processes
8+
natural language policy descriptions through parsing, building, generation,
9+
and validation stages.
10+
11+
"""
12+
13+
from .graph import PolicyBuilder, PolicyBuilderConfig, create_policy_builder_graph
14+
from .state import PolicyState
15+
16+
__all__ = [
17+
"PolicyBuilder",
18+
"PolicyBuilderConfig",
19+
"create_policy_builder_graph",
20+
"PolicyState",
21+
]

0 commit comments

Comments
 (0)