judgment
judgment
¶
Judgment client for Recursive Light integration.
Provides JudgmentQuery/JudgmentResponse protocol for consulting Recursive Light on execution decisions, plus LocalJudgmentClient fallback for offline operation.
Phase 4 of AGI Evolution: Judgment Integration
Attributes¶
Classes¶
JudgmentQuery
dataclass
¶
JudgmentQuery(job_id, sheet_num, validation_results, execution_history, error_patterns, retry_count, confidence)
Query sent to Recursive Light for execution judgment.
Contains all relevant context about the current sheet execution state needed for RL to provide informed judgment.
JudgmentResponse
dataclass
¶
JudgmentResponse(recommended_action, confidence, reasoning, prompt_modifications=None, escalation_urgency=None, human_question=None, patterns_learned=list())
Response from Recursive Light with execution judgment.
Provides recommended action, reasoning, and optional modifications for how to proceed with sheet execution.
Attributes¶
recommended_action
instance-attribute
¶
Recommended action: - proceed: Continue to next sheet (current succeeded) - retry: Retry the current sheet - completion: Run completion prompt for partial success - escalate: Escalate to human for decision - abort: Stop the entire job
prompt_modifications
class-attribute
instance-attribute
¶
Optional modifications to apply to prompt on retry.
escalation_urgency
class-attribute
instance-attribute
¶
Urgency level if action is 'escalate'.
human_question
class-attribute
instance-attribute
¶
Specific question to ask human if escalating.
patterns_learned
class-attribute
instance-attribute
¶
New patterns identified by RL from this execution.
JudgmentClient
¶
HTTP client for Recursive Light judgment API.
Connects to Recursive Light's /api/marianne/judgment endpoint to get TDF-aligned execution decisions with accumulated wisdom.
Falls back to default "retry" action on connection errors for graceful degradation.
Attributes:
| Name | Type | Description |
|---|---|---|
endpoint |
Base URL for the Recursive Light API. |
|
timeout |
Request timeout in seconds. |
Initialize the judgment client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
Base URL for the Recursive Light API server. |
required |
timeout
|
float
|
Request timeout in seconds. Defaults to 30.0. |
30.0
|
Source code in src/marianne/learning/judgment.py
Functions¶
get_judgment
async
¶
Get execution judgment from Recursive Light.
Posts the query to RL's /api/marianne/judgment endpoint and parses the response. On errors, returns a default "retry" action for graceful degradation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
JudgmentQuery
|
Full context about the sheet execution state. |
required |
Returns:
| Type | Description |
|---|---|
JudgmentResponse
|
JudgmentResponse with recommended action. On connection |
JudgmentResponse
|
errors, returns default retry action with low confidence. |
Source code in src/marianne/learning/judgment.py
close
async
¶
Close the HTTP client connection.
Should be called when done using the client to clean up resources.
Source code in src/marianne/learning/judgment.py
__aenter__
async
¶
__aexit__
async
¶
Async context manager exit - closes client.
LocalJudgmentClient
¶
Local fallback judgment client using simple heuristics.
Provides judgment without network calls for offline operation or when Recursive Light is unavailable. Uses confidence thresholds and pass rate heuristics to determine actions.
This is a simpler, always-available alternative that makes reasonable decisions based on local metrics alone.
Attributes:
| Name | Type | Description |
|---|---|---|
proceed_threshold |
Confidence above which to proceed (default 0.7). |
|
retry_threshold |
Confidence above which to retry (default 0.4). |
|
max_retries |
Maximum retries before escalating (default 3). |
Initialize the local judgment client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proceed_threshold
|
float
|
Confidence >= this proceeds to next sheet. |
0.7
|
retry_threshold
|
float
|
Confidence >= this (but < proceed) retries. Below this, escalates or aborts. |
0.4
|
max_retries
|
int
|
Maximum retry count before escalating. |
3
|
Source code in src/marianne/learning/judgment.py
Functions¶
get_judgment
async
¶
Get execution judgment using local heuristics.
Decision logic: 1. High confidence (>= proceed_threshold) -> proceed 2. Medium confidence (>= retry_threshold) -> retry (unless max retries) 3. Low confidence (< retry_threshold) -> escalate 4. Max retries exceeded -> completion or escalate based on pass rate
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
JudgmentQuery
|
Full context about the sheet execution state. |
required |
Returns:
| Type | Description |
|---|---|
JudgmentResponse
|
JudgmentResponse with recommended action based on heuristics. |
Source code in src/marianne/learning/judgment.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | |