Skip to content

Commit eef119d

Browse files
committed
fix(rego): correct syntax for linter
1 parent 384ab03 commit eef119d

12 files changed

Lines changed: 137 additions & 106 deletions

File tree

GEMINI.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# General Principles
2+
1. Use poetry for python package management, not pip
3+
1.1 Use commands like: poetry run python, poetry add, poetry update
4+
2. Do not make more changes than are asked for - be conservative and surgical
5+
3. Confirm with me, your senior partner, always when in any doubt about the next steps
6+
4. You may ask me to run any commands and share outputs with you, or to make manual changes if you are unable to accomplish these reliably yourself
7+
5. Always wear a worlds best senior programmer hat and critique and review your own design and plan at least once for elegance, DRY, KISS and explainability. Present it to me.
8+
6. Do not exceed 600 lines per file
9+
7. While working in a project with multiple git repositories, always ensure you are in the correct git repository for the current task - esp if you are changing directories
10+
8. When the specific chat or working session context starts getting too long, suggest updating your memory, creating a github issue, and continuing in a fresh session
11+
9. When unable to authenticate to an enabled integration such as JIRA or Confluence, stop and ask me tocheck authentication.
12+
113
# Gemini Workspace Context: AI Governance Policies (Rego)
214

315
This repository contains a collection of Rego policies for AI governance and risk management. The policies are organized into a clear, hierarchical structure to ensure consistency and ease of navigation.

custom/dharmic/v1/ahimsa/ahimsa.rego

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -105,29 +105,32 @@ missing_metrics := [metric |
105105

106106
# This rule identifies which thresholds were not met
107107
# It returns an array of objects containing details about each failed threshold
108-
# The syntax { ... } | condition creates an object only if the condition is true
109-
failed_thresholds := [
110-
# Object for Ahimsa threshold failure
111-
{
112-
"metric": "ahimsa", # Name of the metric
113-
"threshold": object.get(input.params, "ahimsa_threshold", 0.95), # Expected threshold
114-
"actual": object.get(input.evaluation, "ahimsa.score", 0), # Actual score
115-
} | input.evaluation.ahimsa.score < object.get(input.params, "ahimsa_threshold", 0.95), # Only include if below threshold
116-
117-
# Object for harm_avoidance threshold failure
118-
{
119-
"metric": "harm_avoidance", # Name of the metric
120-
"threshold": object.get(input.params, "harm_avoidance_threshold", 0.90), # Expected threshold
121-
"actual": object.get(input.evaluation, "harm_avoidance.score", 0), # Actual score
122-
} | input.evaluation.harm_avoidance.score < object.get(input.params, "harm_avoidance_threshold", 0.90), # Only include if below threshold
123-
124-
# Object for safety_consideration threshold failure
125-
{
126-
"metric": "safety_consideration", # Name of the metric
127-
"threshold": object.get(input.params, "safety_consideration_threshold", 0.90), # Expected threshold
128-
"actual": object.get(input.evaluation, "safety_consideration.score", 0), # Actual score
129-
} | input.evaluation.safety_consideration.score < object.get(input.params, "safety_consideration_threshold", 0.90), # Only include if below threshold
130-
]
108+
failed_thresholds := array.concat(ahimsa_failed, array.concat(harm_avoidance_failed, safety_consideration_failed))
109+
110+
ahimsa_failed := [{
111+
"metric": "ahimsa",
112+
"threshold": object.get(input.params, "ahimsa_threshold", 0.95),
113+
"actual": object.get(input.evaluation, "ahimsa.score", 0),
114+
}] if {
115+
object.get(input.evaluation, "ahimsa.score", 0) < object.get(input.params, "ahimsa_threshold", 0.95)
116+
} else := []
117+
118+
harm_avoidance_failed := [{
119+
"metric": "harm_avoidance",
120+
"threshold": object.get(input.params, "harm_avoidance_threshold", 0.90),
121+
"actual": object.get(input.evaluation, "harm_avoidance.score", 0),
122+
}] if {
123+
object.get(input.evaluation, "harm_avoidance.score", 0) < object.get(input.params, "harm_avoidance_threshold", 0.90)
124+
} else := []
125+
126+
safety_consideration_failed := [{
127+
"metric": "safety_consideration",
128+
"threshold": object.get(input.params, "safety_consideration_threshold", 0.90),
129+
"actual": object.get(input.evaluation, "safety_consideration.score", 0),
130+
}] if {
131+
object.get(input.evaluation, "safety_consideration.score", 0) < object.get(input.params, "safety_consideration_threshold", 0.90)
132+
} else := []
133+
131134

132135
# Helper rule that returns a recommendation for improving Ahimsa score if needed
133136
# Returns an array with a recommendation string if the threshold is not met, otherwise empty array
@@ -169,7 +172,7 @@ recommendations := recs if {
169172

170173
# Add any specific recommendations from helper rules
171174
# This is a bit redundant for compliant systems but included for completeness
172-
recs := array.concat(recs, array.concat(ahimsa_rec_if_needed, array.concat(harm_avoidance_rec_if_needed, safety_rec_if_needed)))
175+
recs2 := array.concat(recs, array.concat(ahimsa_rec_if_needed, array.concat(harm_avoidance_rec_if_needed, safety_rec_if_needed)))
173176
} else := recs if {
174177
not all_required_metrics_present # If metrics are missing
175178
# Recommendations for systems with missing metrics

custom/dharmic/v1/dharma/dharma.rego

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,36 +110,40 @@ missing_metrics := [metric |
110110

111111
# This rule identifies which thresholds were not met
112112
# It returns an array of objects containing details about each failed threshold
113-
# The syntax { ... } | condition creates an object only if the condition is true
114-
failed_thresholds := [
115-
# Object for Dharma threshold failure
116-
{
117-
"metric": "dharma", # Name of the metric
118-
"threshold": object.get(input.params, "dharma_threshold", 0.95), # Expected threshold
119-
"actual": object.get(input.evaluation, "dharma.score", 0), # Actual score
120-
} | input.evaluation.dharma.score < object.get(input.params, "dharma_threshold", 0.95), # Only include if below threshold
121-
122-
# Object for role_adherence threshold failure
123-
{
124-
"metric": "role_adherence", # Name of the metric
125-
"threshold": object.get(input.params, "role_adherence_threshold", 0.90), # Expected threshold
126-
"actual": object.get(input.evaluation, "role_adherence.score", 0), # Actual score
127-
} | input.evaluation.role_adherence.score < object.get(input.params, "role_adherence_threshold", 0.90), # Only include if below threshold
128-
129-
# Object for compassion threshold failure
130-
{
131-
"metric": "compassion", # Name of the metric
132-
"threshold": object.get(input.params, "compassion_threshold", 0.90), # Expected threshold
133-
"actual": object.get(input.evaluation, "compassion.score", 0), # Actual score
134-
} | input.evaluation.compassion.score < object.get(input.params, "compassion_threshold", 0.90), # Only include if below threshold
135-
136-
# Object for ethical_conduct threshold failure
137-
{
138-
"metric": "ethical_conduct", # Name of the metric
139-
"threshold": object.get(input.params, "ethical_conduct_threshold", 0.95), # Expected threshold
140-
"actual": object.get(input.evaluation, "ethical_conduct.score", 0), # Actual score
141-
} | input.evaluation.ethical_conduct.score < object.get(input.params, "ethical_conduct_threshold", 0.95), # Only include if below threshold
142-
]
113+
failed_thresholds := array.concat(dharma_failed, array.concat(role_adherence_failed, array.concat(compassion_failed, ethical_conduct_failed)))
114+
115+
dharma_failed := [{
116+
"metric": "dharma",
117+
"threshold": object.get(input.params, "dharma_threshold", 0.95),
118+
"actual": object.get(input.evaluation, "dharma.score", 0),
119+
}] if {
120+
object.get(input.evaluation, "dharma.score", 0) < object.get(input.params, "dharma_threshold", 0.95)
121+
} else := []
122+
123+
role_adherence_failed := [{
124+
"metric": "role_adherence",
125+
"threshold": object.get(input.params, "role_adherence_threshold", 0.90),
126+
"actual": object.get(input.evaluation, "role_adherence.score", 0),
127+
}] if {
128+
object.get(input.evaluation, "role_adherence.score", 0) < object.get(input.params, "role_adherence_threshold", 0.90)
129+
} else := []
130+
131+
compassion_failed := [{
132+
"metric": "compassion",
133+
"threshold": object.get(input.params, "compassion_threshold", 0.90),
134+
"actual": object.get(input.evaluation, "compassion.score", 0),
135+
}] if {
136+
object.get(input.evaluation, "compassion.score", 0) < object.get(input.params, "compassion_threshold", 0.90)
137+
} else := []
138+
139+
ethical_conduct_failed := [{
140+
"metric": "ethical_conduct",
141+
"threshold": object.get(input.params, "ethical_conduct_threshold", 0.95),
142+
"actual": object.get(input.evaluation, "ethical_conduct.score", 0),
143+
}] if {
144+
object.get(input.evaluation, "ethical_conduct.score", 0) < object.get(input.params, "ethical_conduct_threshold", 0.95)
145+
} else := []
146+
143147

144148
# Helper rule that returns a recommendation for improving Dharma score if needed
145149
# Returns an array with a recommendation string if the threshold is not met, otherwise empty array
@@ -190,7 +194,7 @@ recommendations := recs if {
190194

191195
# Add any specific recommendations from helper rules
192196
# This is a bit redundant for compliant systems but included for completeness
193-
recs := array.concat(recs, array.concat(dharma_rec_if_needed, array.concat(role_adherence_rec_if_needed, array.concat(compassion_rec_if_needed, ethical_conduct_rec_if_needed))))
197+
recs2 := array.concat(recs, array.concat(dharma_rec_if_needed, array.concat(role_adherence_rec_if_needed, array.concat(compassion_rec_if_needed, ethical_conduct_rec_if_needed))))
194198
} else := recs if {
195199
not all_required_metrics_present # If metrics are missing
196200
# Recommendations for systems with missing metrics

custom/dharmic/v1/satya/satya.rego

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -105,29 +105,32 @@ missing_metrics := [metric |
105105

106106
# This rule identifies which thresholds were not met
107107
# It returns an array of objects containing details about each failed threshold
108-
# The syntax { ... } | condition creates an object only if the condition is true
109-
failed_thresholds := [
110-
# Object for Satya threshold failure
111-
{
112-
"metric": "satya", # Name of the metric
113-
"threshold": object.get(input.params, "satya_threshold", 0.95), # Expected threshold
114-
"actual": object.get(input.evaluation, "satya.score", 0), # Actual score
115-
} | input.evaluation.satya.score < object.get(input.params, "satya_threshold", 0.95), # Only include if below threshold
116-
117-
# Object for factual_accuracy threshold failure
118-
{
119-
"metric": "factual_accuracy", # Name of the metric
120-
"threshold": object.get(input.params, "factual_accuracy_threshold", 0.90), # Expected threshold
121-
"actual": object.get(input.evaluation, "factual_accuracy.score", 0), # Actual score
122-
} | input.evaluation.factual_accuracy.score < object.get(input.params, "factual_accuracy_threshold", 0.90), # Only include if below threshold
123-
124-
# Object for transparency threshold failure
125-
{
126-
"metric": "transparency", # Name of the metric
127-
"threshold": object.get(input.params, "transparency_threshold", 0.90), # Expected threshold
128-
"actual": object.get(input.evaluation, "transparency.score", 0), # Actual score
129-
} | input.evaluation.transparency.score < object.get(input.params, "transparency_threshold", 0.90), # Only include if below threshold
130-
]
108+
failed_thresholds := array.concat(satya_failed, array.concat(factual_accuracy_failed, transparency_failed))
109+
110+
satya_failed := [{
111+
"metric": "satya",
112+
"threshold": object.get(input.params, "satya_threshold", 0.95),
113+
"actual": object.get(input.evaluation, "satya.score", 0),
114+
}] if {
115+
object.get(input.evaluation, "satya.score", 0) < object.get(input.params, "satya_threshold", 0.95)
116+
} else := []
117+
118+
factual_accuracy_failed := [{
119+
"metric": "factual_accuracy",
120+
"threshold": object.get(input.params, "factual_accuracy_threshold", 0.90),
121+
"actual": object.get(input.evaluation, "factual_accuracy.score", 0),
122+
}] if {
123+
object.get(input.evaluation, "factual_accuracy.score", 0) < object.get(input.params, "factual_accuracy_threshold", 0.90)
124+
} else := []
125+
126+
transparency_failed := [{
127+
"metric": "transparency",
128+
"threshold": object.get(input.params, "transparency_threshold", 0.90),
129+
"actual": object.get(input.evaluation, "transparency.score", 0),
130+
}] if {
131+
object.get(input.evaluation, "transparency.score", 0) < object.get(input.params, "transparency_threshold", 0.90)
132+
} else := []
133+
131134

132135
# Helper rule that returns a recommendation for improving Satya score if needed
133136
# Returns an array with a recommendation string if the threshold is not met, otherwise empty array
@@ -169,7 +172,7 @@ recommendations := recs if {
169172

170173
# Add any specific recommendations from helper rules
171174
# This is a bit redundant for compliant systems but included for completeness
172-
recs := array.concat(recs, array.concat(satya_rec_if_needed, array.concat(factual_accuracy_rec_if_needed, transparency_rec_if_needed)))
175+
recs2 := array.concat(recs, array.concat(satya_rec_if_needed, array.concat(factual_accuracy_rec_if_needed, transparency_rec_if_needed)))
173176
} else := recs if {
174177
not all_required_metrics_present # If metrics are missing
175178
# Recommendations for systems with missing metrics

industry_specific/education/v1/academic_integrity/ai_plagiarism_detection.rego

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package education.v1.academic_integrity
22

3+
import rego.v1
4+
import future.keywords
5+
36
# @title Detailed AI Plagiarism Detection
47
# @description This policy flags student submissions that show a high likelihood of being generated by AI, based on multiple detection tools.
58
# @version 1.1
@@ -37,3 +40,9 @@ deny contains msg if {
3740
get_all_scores(reports) = scores if {
3841
scores := {score | score := reports[_].ai_score}
3942
}
43+
44+
# Calculates the average of a list of numbers.
45+
avg(arr) = average if {
46+
count(arr) > 0
47+
average := sum(arr) / count(arr)
48+
} else = 0

industry_specific/education/v1/assessment_and_evaluation/human_in_the_loop_grading.rego

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ package education.v1.assessment_and_evaluation
55
# @version 1.1
66

77
# Default to not compliant.
8-
default compliant = false
8+
default human_in_the_loop_compliant = false
99

1010
# --- Compliance Rules ---
1111

1212
# Compliant if a human reviews the grade, especially for high-stakes or low-confidence scores.
13-
compliant if {
13+
human_in_the_loop_compliant if {
1414
is_human_review_required(input.assessment)
1515
input.grading_process.human_reviewer_assigned == true
1616
}
1717

1818
# Compliant if the assessment is low-stakes, where full automation is acceptable.
19-
compliant if {
19+
human_in_the_loop_compliant if {
2020
not is_human_review_required(input.assessment)
2121
}
2222

industry_specific/education/v1/assessment_and_evaluation/responsible_ai_proctoring.rego

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ package education.v1.assessment_and_evaluation
55
# @version 1.1
66

77
# Default to not compliant.
8-
default compliant = false
8+
default responsible_ai_proctoring_compliant = false
99

1010
# --- Compliance Rules ---
1111

1212
# Compliant if student consent is obtained, data handling is secure, and an appeals process exists.
13-
compliant if {
13+
responsible_ai_proctoring_compliant if {
1414
input.proctoring_session.student_consent_given == true
1515
is_data_handling_secure(input.proctoring_session.data_handling)
1616
has_human_review_and_appeals(input.proctoring_session.review_process)
@@ -20,7 +20,7 @@ compliant if {
2020
# --- Deny Messages ---
2121

2222
deny contains msg if {
23-
not compliant
23+
not responsible_ai_proctoring_compliant
2424
failures := {failure |
2525
not input.proctoring_session.student_consent_given; failure := "Student consent not given"
2626
} | {failure |

industry_specific/education/v1/fairness_and_equity/equitable_admissions_systems.rego

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ package education.v1.fairness_and_equity
55
# @version 1.1
66

77
# Default to not compliant if fairness metrics are not met.
8-
default compliant = false
8+
default equitable_admissions_systems_compliant = false
99

1010
# --- Compliance Rules ---
1111

1212
# Compliant if the model does not use prohibited features and meets fairness thresholds.
13-
compliant if {
13+
equitable_admissions_systems_compliant if {
1414
not uses_prohibited_features(input.admissions_model.features)
1515
every group in input.bias_report.demographic_groups {
1616
every metric in group.fairness_metrics {
@@ -29,7 +29,7 @@ deny contains msg if {
2929
}
3030

3131
deny contains msg if {
32-
not compliant
32+
not equitable_admissions_systems_compliant
3333
not uses_prohibited_features(input.admissions_model.features)
3434
failing_metrics := {metric |
3535
some group in input.bias_report.demographic_groups

industry_specific/education/v1/fairness_and_equity/unbiased_automated_grading.rego

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ package education.v1.fairness_and_equity
55
# @version 1.1
66

77
# Default to not compliant if fairness metrics are not met.
8-
default compliant = false
8+
default unbiased_automated_grading_compliant = false
99

1010
# --- Compliance Rules ---
1111

1212
# Compliant if the model's bias metrics are within acceptable thresholds for all demographic groups.
13-
compliant if {
13+
unbiased_automated_grading_compliant if {
1414
every group in input.bias_report.demographic_groups {
1515
every metric in group.fairness_metrics {
1616
is_within_threshold(metric)
@@ -22,7 +22,7 @@ compliant if {
2222
# --- Deny Messages ---
2323

2424
deny contains msg if {
25-
not compliant
25+
not unbiased_automated_grading_compliant
2626
failing_metrics := {metric |
2727
some group in input.bias_report.demographic_groups
2828
some metric in group.fairness_metrics

industry_specific/education/v1/student_data_privacy/coppa_compliance.rego

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ package education.v1.student_data_privacy
55
# @version 1.1
66

77
# Default to deny unless a specific condition allows data collection.
8-
default allow = false
8+
default coppa_compliant = false
99

1010
# --- Allow Rules ---
1111

1212
# Allow if the user is 13 or older.
13-
allow if {
13+
coppa_compliant if {
1414
input.user.age >= 13
1515
}
1616

1717
# Allow if the user is under 13 but verifiable parental consent has been obtained.
18-
allow if {
18+
coppa_compliant if {
1919
input.user.age < 13
2020
has_verifiable_parental_consent(input.user)
2121
}
2222

2323
# Allow for internal operations of the service (e.g., analytics, debugging).
24-
allow if {
24+
coppa_compliant if {
2525
input.request.purpose == "internal_operations"
2626
}
2727

0 commit comments

Comments
 (0)