Skip to content

Commit 1464549

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

12 files changed

Lines changed: 200 additions & 221 deletions

industry_specific/education/v1/academic_integrity/acceptable_ai_use.rego

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

77
# Default to not allowed unless explicitly permitted by the course policy.
8-
default allow = false
8+
default allow := false
99

1010
# --- Allow Rules ---
1111

1212
# Allow if the specific AI use case is permitted in the course's AI policy.
1313
allow if {
14-
is_permitted_use(input.ai_use_case, input.course.ai_policy)
14+
is_permitted_use(input.ai_use_case, input.course.ai_policy, permitted_uses)
1515
}
1616

1717
# Allow if the student is using a generally accepted tool for a common task (e.g., spell check).
1818
allow if {
19-
is_common_assistive_tool(input.ai_tool)
19+
is_common_assistive_tool(input.ai_tool)
2020
}
2121

22-
2322
# --- Deny Messages ---
2423

2524
deny contains msg if {
26-
not allow
27-
msg := sprintf("The use of AI tool '%v' for '%v' is not permitted for this assignment according to the course policy.", [input.ai_tool, input.ai_use_case])
25+
not allow
26+
msg := sprintf("The use of AI tool '%v' for '%v' is not permitted for this assignment according to the course policy.", [input.ai_tool, input.ai_use_case])
2827
}
2928

30-
3129
# --- Helper Functions ---
3230

3331
# Defines permitted uses based on different policy levels (e.g., "strict", "moderate", "open").
3432
permitted_uses := {
35-
"strict": {"spell_check", "grammar_check"},
36-
"moderate": {"spell_check", "grammar_check", "research_assistance", "code_completion"},
37-
"open": {"spell_check", "grammar_check", "research_assistance", "code_completion", "content_generation_with_attribution"}
33+
"strict": {"spell_check", "grammar_check"},
34+
"moderate": {"spell_check", "grammar_check", "research_assistance", "code_completion"},
35+
"open": {"spell_check", "grammar_check", "research_assistance", "code_completion", "content_generation_with_attribution"},
3836
}
3937

4038
# Checks if a use case is permitted under the given policy level.
41-
is_permitted_use(use_case, policy) if {
42-
use_case in permitted_uses[policy.level]
39+
is_permitted_use(use_case, policy, uses) if {
40+
use_case in uses[policy.level]
4341
}
4442

4543
# Checks if the tool is a common, generally accepted assistive tool.
4644
is_common_assistive_tool(tool) if {
47-
common_tools := {"grammarly", "spell_check_pro"}
48-
tool in common_tools
45+
common_tools := {"grammarly", "spell_check_pro"}
46+
tool in common_tools
4947
}
Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,46 @@
11
package education.v1.academic_integrity
22

33
import rego.v1
4-
import future.keywords
54

65
# @title Detailed AI Plagiarism Detection
76
# @description This policy flags student submissions that show a high likelihood of being generated by AI, based on multiple detection tools.
87
# @version 1.1
98

109
# By default, no plagiarism is flagged.
11-
default flag_for_review = false
10+
default flag_for_review := false
1211

1312
# --- Flagging Rules ---
1413

1514
# Flag if the average score from multiple AI detection tools exceeds a threshold.
1615
flag_for_review if {
17-
avg(get_all_scores(input.submission.ai_detection_reports)) > 0.90
16+
avg(all_scores(input.submission.ai_detection_reports)) > 0.90
1817
}
1918

2019
# Flag if any single high-confidence detector flags the content.
2120
flag_for_review if {
22-
some report in input.submission.ai_detection_reports
23-
report.detector_confidence == "high"
24-
report.ai_score > 0.95
21+
some report in input.submission.ai_detection_reports
22+
report.detector_confidence == "high"
23+
report.ai_score > 0.95
2524
}
2625

27-
2826
# --- Deny Messages ---
2927

3028
deny contains msg if {
31-
flag_for_review
32-
scores := get_all_scores(input.submission.ai_detection_reports)
33-
msg := sprintf("Submission flagged for potential AI plagiarism. Detection scores: %v", [scores])
29+
flag_for_review
30+
scores := all_scores(input.submission.ai_detection_reports)
31+
msg := sprintf("Submission flagged for potential AI plagiarism. Detection scores: %v", [scores])
3432
}
3533

36-
3734
# --- Helper Functions ---
3835

3936
# Extracts all AI detection scores from the reports.
40-
get_all_scores(reports) = scores if {
41-
scores := {score | score := reports[_].ai_score}
37+
all_scores(reports) := scores if {
38+
count(reports) > 0
39+
scores := {score | score := reports[_].ai_score}
4240
}
4341

4442
# 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
43+
avg(arr) := average if {
44+
count(arr) > 0
45+
average := sum(arr) / count(arr)
46+
} else := 0

industry_specific/education/v1/assessment_and_evaluation/human_in_the_loop_grading.rego

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

77
# Default to not compliant.
8-
default human_in_the_loop_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.
1313
human_in_the_loop_compliant if {
14-
is_human_review_required(input.assessment)
15-
input.grading_process.human_reviewer_assigned == true
14+
is_human_review_required(input.assessment)
15+
input.grading_process.human_reviewer_assigned == true
1616
}
1717

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

23-
2423
# --- Deny Messages ---
2524

2625
deny contains msg if {
27-
is_human_review_required(input.assessment)
28-
not input.grading_process.human_reviewer_assigned
29-
msg := sprintf("Human review is required for this %v assessment (final grade impact: %v%%), but no reviewer was assigned.", [input.assessment.type, input.assessment.final_grade_impact_percent])
26+
is_human_review_required(input.assessment)
27+
not input.grading_process.human_reviewer_assigned
28+
msg := sprintf("Human review is required for this %v assessment (final grade impact: %v%%), but no reviewer was assigned.", [input.assessment.type, input.assessment.final_grade_impact_percent])
3029
}
3130

32-
3331
# --- Helper Functions ---
3432

3533
# Determines if human review is required based on the assessment's weight or the AI's confidence.
3634
is_human_review_required(assessment) if {
37-
assessment.type == "final_exam"
35+
assessment.type == "final_exam"
3836
}
3937

4038
is_human_review_required(assessment) if {
41-
assessment.final_grade_impact_percent > 20
39+
assessment.final_grade_impact_percent > 20
4240
}
4341

4442
is_human_review_required(assessment) if {
45-
assessment.ai_confidence_score < 0.85
43+
assessment.ai_confidence_score < 0.85
4644
}

industry_specific/education/v1/assessment_and_evaluation/responsible_ai_proctoring.rego

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

77
# Default to not compliant.
8-
default responsible_ai_proctoring_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.
1313
responsible_ai_proctoring_compliant if {
14-
input.proctoring_session.student_consent_given == true
15-
is_data_handling_secure(input.proctoring_session.data_handling)
16-
has_human_review_and_appeals(input.proctoring_session.review_process)
14+
input.proctoring_session.student_consent_given == true
15+
is_data_handling_secure(input.proctoring_session.data_handling)
16+
has_human_review_and_appeals(input.proctoring_session.review_process)
1717
}
1818

19-
2019
# --- Deny Messages ---
2120

2221
deny contains msg if {
23-
not responsible_ai_proctoring_compliant
24-
failures := {failure |
25-
not input.proctoring_session.student_consent_given; failure := "Student consent not given"
26-
} | {failure |
27-
not is_data_handling_secure(input.proctoring_session.data_handling); failure := "Insecure data handling"
28-
} | {failure |
29-
not has_human_review_and_appeals(input.proctoring_session.review_process); failure := "Lack of human review or appeals process"
30-
}
31-
msg := sprintf("AI proctoring session is not compliant. Failures: %v", [failures])
22+
not responsible_ai_proctoring_compliant
23+
failures := ({failure |
24+
not input.proctoring_session.student_consent_given
25+
failure := "Student consent not given"
26+
} | {failure |
27+
not is_data_handling_secure(input.proctoring_session.data_handling)
28+
failure := "Insecure data handling"
29+
}) | {failure |
30+
not has_human_review_and_appeals(input.proctoring_session.review_process)
31+
failure := "Lack of human review or appeals process"
32+
}
33+
msg := sprintf("AI proctoring session is not compliant. Failures: %v", [failures])
3234
}
3335

34-
3536
# --- Helper Functions ---
3637

3738
# Checks for secure data handling practices.
3839
is_data_handling_secure(handling) if {
39-
handling.encryption_enabled == true
40-
handling.data_retention_period_days <= 30
40+
handling.encryption_enabled == true
41+
handling.data_retention_period_days <= 30
4142
}
4243

4344
# Checks for a robust human review and appeals process.
4445
has_human_review_and_appeals(process) if {
45-
process.human_review_required_for_all_flags == true
46-
process.student_appeal_possible == true
46+
process.human_review_required_for_all_flags == true
47+
process.student_appeal_possible == true
4748
}

industry_specific/education/v1/fairness_and_equity/digital_divide_mitigation.rego

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

77
# Default to not equitable unless mitigation strategies are in place.
8-
default equitable = false
8+
default equitable := false
99

1010
# --- Equity Rules ---
1111

1212
# Equitable if a comparable offline alternative is available.
1313
equitable if {
14-
input.assignment.has_offline_alternative == true
14+
input.assignment.has_offline_alternative == true
1515
}
1616

1717
# Equitable if the school provides all necessary resources (device and internet).
1818
equitable if {
19-
input.student.resources.has_school_provided_device == true
20-
input.student.resources.has_school_provided_internet == true
19+
input.student.resources.has_school_provided_device == true
20+
input.student.resources.has_school_provided_internet == true
2121
}
2222

2323
# Equitable if the assignment can be completed with low-bandwidth or basic devices.
2424
equitable if {
25-
input.assignment.requirements.bandwidth == "low"
26-
input.assignment.requirements.device_spec == "basic"
25+
input.assignment.requirements.bandwidth == "low"
26+
input.assignment.requirements.device_spec == "basic"
2727
}
2828

29-
3029
# --- Deny Messages ---
3130

3231
deny contains msg if {
33-
not equitable
34-
msg := "Assignment is not equitable. No sufficient alternative or resources provided for students impacted by the digital divide."
32+
not equitable
33+
msg := "Assignment is not equitable. No sufficient alternative or resources provided for students impacted by the digital divide."
3534
}

industry_specific/education/v1/fairness_and_equity/equitable_admissions_systems.rego

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

77
# Default to not compliant if fairness metrics are not met.
8-
default equitable_admissions_systems_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.
1313
equitable_admissions_systems_compliant if {
14-
not uses_prohibited_features(input.admissions_model.features)
15-
every group in input.bias_report.demographic_groups {
16-
every metric in group.fairness_metrics {
17-
is_within_threshold(metric)
18-
}
19-
}
14+
not uses_prohibited_features(input.admissions_model.features, prohibited_features)
15+
every group in input.bias_report.demographic_groups {
16+
every metric in group.fairness_metrics {
17+
is_within_threshold(metric, thresholds)
18+
}
19+
}
2020
}
2121

22-
2322
# --- Deny Messages ---
2423

2524
deny contains msg if {
26-
uses_prohibited_features(input.admissions_model.features)
27-
prohibited := {feature | feature := input.admissions_model.features[_]; is_prohibited(feature)}
28-
msg := sprintf("Admissions model is not compliant. It uses prohibited features: %v", [prohibited])
25+
uses_prohibited_features(input.admissions_model.features, prohibited_features)
26+
prohibited := {feature | some feature in input.admissions_model.features; is_prohibited(feature, prohibited_features)}
27+
msg := sprintf("Admissions model is not compliant. It uses prohibited features: %v", [prohibited])
2928
}
3029

3130
deny contains msg if {
32-
not equitable_admissions_systems_compliant
33-
not uses_prohibited_features(input.admissions_model.features)
34-
failing_metrics := {metric |
35-
some group in input.bias_report.demographic_groups
36-
some metric in group.fairness_metrics
37-
not is_within_threshold(metric)
38-
}
39-
msg := sprintf("Admissions model is not compliant. Fairness metrics are not met: %v", [failing_metrics])
31+
not equitable_admissions_systems_compliant
32+
not uses_prohibited_features(input.admissions_model.features, prohibited_features)
33+
failing_metrics := {metric |
34+
some group in input.bias_report.demographic_groups
35+
some metric in group.fairness_metrics
36+
not is_within_threshold(metric, thresholds)
37+
}
38+
msg := sprintf("Admissions model is not compliant. Fairness metrics are not met: %v", [failing_metrics])
4039
}
4140

42-
4341
# --- Helper Functions ---
4442

4543
# Defines prohibited features for admissions models.
4644
prohibited_features := {"race", "gender", "zip_code_proxy"}
4745

48-
is_prohibited(feature) if {
49-
feature in prohibited_features
46+
is_prohibited(feature, prohibited) if {
47+
feature in prohibited
5048
}
5149

52-
uses_prohibited_features(features) if {
53-
some feature in features
54-
is_prohibited(feature)
50+
uses_prohibited_features(features, prohibited) if {
51+
some feature in features
52+
is_prohibited(feature, prohibited)
5553
}
5654

5755
# Defines acceptable thresholds for different fairness metrics.
5856
thresholds := {
59-
"demographic_parity": 0.1,
60-
"equalized_odds": 0.1
57+
"demographic_parity": 0.1,
58+
"equalized_odds": 0.1,
6159
}
6260

63-
is_within_threshold(metric) if {
64-
abs(metric.value) < thresholds[metric.name]
61+
is_within_threshold(metric, thresholds) if {
62+
abs(metric.value) < thresholds[metric.name]
6563
}

0 commit comments

Comments
 (0)