decision_agent 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +1060 -0
- data/bin/decision_agent +104 -0
- data/lib/decision_agent/agent.rb +147 -0
- data/lib/decision_agent/audit/adapter.rb +9 -0
- data/lib/decision_agent/audit/logger_adapter.rb +27 -0
- data/lib/decision_agent/audit/null_adapter.rb +8 -0
- data/lib/decision_agent/context.rb +42 -0
- data/lib/decision_agent/decision.rb +51 -0
- data/lib/decision_agent/dsl/condition_evaluator.rb +133 -0
- data/lib/decision_agent/dsl/rule_parser.rb +36 -0
- data/lib/decision_agent/dsl/schema_validator.rb +275 -0
- data/lib/decision_agent/errors.rb +62 -0
- data/lib/decision_agent/evaluation.rb +52 -0
- data/lib/decision_agent/evaluators/base.rb +15 -0
- data/lib/decision_agent/evaluators/json_rule_evaluator.rb +51 -0
- data/lib/decision_agent/evaluators/static_evaluator.rb +31 -0
- data/lib/decision_agent/replay/replay.rb +147 -0
- data/lib/decision_agent/scoring/base.rb +19 -0
- data/lib/decision_agent/scoring/consensus.rb +40 -0
- data/lib/decision_agent/scoring/max_weight.rb +16 -0
- data/lib/decision_agent/scoring/threshold.rb +40 -0
- data/lib/decision_agent/scoring/weighted_average.rb +26 -0
- data/lib/decision_agent/version.rb +3 -0
- data/lib/decision_agent/web/public/app.js +580 -0
- data/lib/decision_agent/web/public/index.html +190 -0
- data/lib/decision_agent/web/public/styles.css +558 -0
- data/lib/decision_agent/web/server.rb +255 -0
- data/lib/decision_agent.rb +29 -0
- data/spec/agent_spec.rb +249 -0
- data/spec/api_contract_spec.rb +430 -0
- data/spec/audit_adapters_spec.rb +74 -0
- data/spec/comprehensive_edge_cases_spec.rb +1777 -0
- data/spec/context_spec.rb +84 -0
- data/spec/dsl_validation_spec.rb +648 -0
- data/spec/edge_cases_spec.rb +353 -0
- data/spec/examples/feedback_aware_evaluator_spec.rb +460 -0
- data/spec/json_rule_evaluator_spec.rb +587 -0
- data/spec/replay_edge_cases_spec.rb +699 -0
- data/spec/replay_spec.rb +210 -0
- data/spec/scoring_spec.rb +225 -0
- data/spec/spec_helper.rb +28 -0
- metadata +133 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>DecisionAgent Rule Builder</title>
|
|
7
|
+
<link rel="stylesheet" href="styles.css">
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div class="container">
|
|
11
|
+
<header>
|
|
12
|
+
<h1>🎯 DecisionAgent Rule Builder</h1>
|
|
13
|
+
<p class="subtitle">Visual rule editor for non-technical users</p>
|
|
14
|
+
</header>
|
|
15
|
+
|
|
16
|
+
<div class="main-layout">
|
|
17
|
+
<!-- Left Panel: Rule Builder -->
|
|
18
|
+
<div class="panel builder-panel">
|
|
19
|
+
<div class="panel-header">
|
|
20
|
+
<h2>Rule Configuration</h2>
|
|
21
|
+
<button class="btn btn-secondary" id="loadExampleBtn">Load Example</button>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<!-- Ruleset Metadata -->
|
|
25
|
+
<div class="section">
|
|
26
|
+
<h3>Ruleset Information</h3>
|
|
27
|
+
<div class="form-group">
|
|
28
|
+
<label for="rulesetVersion">Version:</label>
|
|
29
|
+
<input type="text" id="rulesetVersion" value="1.0" class="input">
|
|
30
|
+
</div>
|
|
31
|
+
<div class="form-group">
|
|
32
|
+
<label for="rulesetName">Ruleset Name:</label>
|
|
33
|
+
<input type="text" id="rulesetName" placeholder="my_ruleset" class="input">
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<!-- Rules List -->
|
|
38
|
+
<div class="section">
|
|
39
|
+
<div class="section-header">
|
|
40
|
+
<h3>Rules</h3>
|
|
41
|
+
<button class="btn btn-primary" id="addRuleBtn">+ Add Rule</button>
|
|
42
|
+
</div>
|
|
43
|
+
<div id="rulesContainer" class="rules-container">
|
|
44
|
+
<!-- Rules will be added here dynamically -->
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<!-- Action Buttons -->
|
|
49
|
+
<div class="actions">
|
|
50
|
+
<button class="btn btn-success" id="validateBtn">✓ Validate Rules</button>
|
|
51
|
+
<button class="btn btn-secondary" id="clearBtn">Clear All</button>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<!-- Right Panel: JSON Preview & Validation -->
|
|
56
|
+
<div class="panel preview-panel">
|
|
57
|
+
<div class="panel-header">
|
|
58
|
+
<h2>JSON Output</h2>
|
|
59
|
+
<div class="header-actions">
|
|
60
|
+
<button class="btn btn-secondary" id="copyBtn">📋 Copy</button>
|
|
61
|
+
<button class="btn btn-secondary" id="downloadBtn">⬇ Download</button>
|
|
62
|
+
<label for="importFile" class="btn btn-secondary">📁 Import
|
|
63
|
+
<input type="file" id="importFile" accept=".json" style="display: none;">
|
|
64
|
+
</label>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<!-- JSON Preview -->
|
|
69
|
+
<div class="json-preview">
|
|
70
|
+
<pre id="jsonOutput" class="json-code">{}</pre>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<!-- Validation Status -->
|
|
74
|
+
<div id="validationStatus" class="validation-status hidden">
|
|
75
|
+
<div class="status-icon"></div>
|
|
76
|
+
<div class="status-message"></div>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<!-- Validation Errors -->
|
|
80
|
+
<div id="validationErrors" class="validation-errors hidden">
|
|
81
|
+
<h4>Validation Errors:</h4>
|
|
82
|
+
<ul id="errorList"></ul>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<!-- Rule Editor Modal -->
|
|
88
|
+
<div id="ruleModal" class="modal hidden">
|
|
89
|
+
<div class="modal-content">
|
|
90
|
+
<div class="modal-header">
|
|
91
|
+
<h2 id="modalTitle">Edit Rule</h2>
|
|
92
|
+
<button class="close-btn" id="closeModalBtn">×</button>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="modal-body">
|
|
95
|
+
<!-- Rule ID -->
|
|
96
|
+
<div class="form-group">
|
|
97
|
+
<label for="ruleId">Rule ID: <span class="required">*</span></label>
|
|
98
|
+
<input type="text" id="ruleId" class="input" placeholder="unique_rule_id" required>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<!-- Condition Builder -->
|
|
102
|
+
<div class="form-group">
|
|
103
|
+
<label>Condition (IF): <span class="required">*</span></label>
|
|
104
|
+
<div id="conditionBuilder" class="condition-builder">
|
|
105
|
+
<!-- Condition will be built here -->
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<!-- Then Clause -->
|
|
110
|
+
<div class="form-group">
|
|
111
|
+
<label>Then (Action): <span class="required">*</span></label>
|
|
112
|
+
<div class="then-clause">
|
|
113
|
+
<div class="form-row">
|
|
114
|
+
<div class="form-col">
|
|
115
|
+
<label for="thenDecision">Decision: <span class="required">*</span></label>
|
|
116
|
+
<input type="text" id="thenDecision" class="input" placeholder="approve" required>
|
|
117
|
+
</div>
|
|
118
|
+
<div class="form-col">
|
|
119
|
+
<label for="thenWeight">Weight (0.0-1.0):</label>
|
|
120
|
+
<input type="number" id="thenWeight" class="input" min="0" max="1" step="0.1" value="0.8">
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
<div class="form-row">
|
|
124
|
+
<div class="form-col full-width">
|
|
125
|
+
<label for="thenReason">Reason:</label>
|
|
126
|
+
<textarea id="thenReason" class="input" rows="2" placeholder="Explanation for this decision"></textarea>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
<div class="modal-footer">
|
|
133
|
+
<button class="btn btn-secondary" id="cancelModalBtn">Cancel</button>
|
|
134
|
+
<button class="btn btn-primary" id="saveRuleBtn">Save Rule</button>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<!-- Condition Builder Template -->
|
|
140
|
+
<template id="fieldConditionTemplate">
|
|
141
|
+
<div class="condition-item field-condition">
|
|
142
|
+
<select class="condition-type-select">
|
|
143
|
+
<option value="field">Field Condition</option>
|
|
144
|
+
<option value="all">All (AND)</option>
|
|
145
|
+
<option value="any">Any (OR)</option>
|
|
146
|
+
</select>
|
|
147
|
+
<div class="field-condition-inputs">
|
|
148
|
+
<input type="text" class="field-path input-sm" placeholder="field.path">
|
|
149
|
+
<select class="operator-select input-sm">
|
|
150
|
+
<option value="eq">equals (==)</option>
|
|
151
|
+
<option value="neq">not equals (!=)</option>
|
|
152
|
+
<option value="gt">greater than (>)</option>
|
|
153
|
+
<option value="gte">greater or equal (>=)</option>
|
|
154
|
+
<option value="lt">less than (<)</option>
|
|
155
|
+
<option value="lte">less or equal (<=)</option>
|
|
156
|
+
<option value="in">in array</option>
|
|
157
|
+
<option value="present">is present</option>
|
|
158
|
+
<option value="blank">is blank</option>
|
|
159
|
+
</select>
|
|
160
|
+
<input type="text" class="field-value input-sm" placeholder="value">
|
|
161
|
+
</div>
|
|
162
|
+
<button class="btn-remove" title="Remove condition">×</button>
|
|
163
|
+
</div>
|
|
164
|
+
</template>
|
|
165
|
+
|
|
166
|
+
<template id="compositeConditionTemplate">
|
|
167
|
+
<div class="condition-item composite-condition">
|
|
168
|
+
<div class="composite-header">
|
|
169
|
+
<select class="condition-type-select">
|
|
170
|
+
<option value="field">Field Condition</option>
|
|
171
|
+
<option value="all">All (AND)</option>
|
|
172
|
+
<option value="any">Any (OR)</option>
|
|
173
|
+
</select>
|
|
174
|
+
<button class="btn-add-subcondition btn-sm">+ Add Condition</button>
|
|
175
|
+
<button class="btn-remove" title="Remove">×</button>
|
|
176
|
+
</div>
|
|
177
|
+
<div class="subconditions-container">
|
|
178
|
+
<!-- Subconditions will be added here -->
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
</template>
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
<footer class="footer">
|
|
185
|
+
<p>DecisionAgent Rule Builder | <a href="https://github.com/yourusername/decision_agent" target="_blank">Documentation</a></p>
|
|
186
|
+
</footer>
|
|
187
|
+
|
|
188
|
+
<script src="app.js"></script>
|
|
189
|
+
</body>
|
|
190
|
+
</html>
|