Skip to content

Commit 48d31a9

Browse files
FoundupFoundups Agent
andauthored
feat(reddog): summarize resident control loop receipts (#1279)
Co-authored-by: Foundups Agent <dev@foundups.com>
1 parent 8868764 commit 48d31a9

3 files changed

Lines changed: 141 additions & 2 deletions

File tree

main.py

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3854,6 +3854,30 @@ def _reddog_queue_stage_rejected(stage_callable: Any) -> bool:
38543854
return isinstance(raw, Mapping) and raw.get("accepted") is False
38553855

38563856

3857+
def _reddog_queue_stage_receipt_ids(stage_callable: Any) -> tuple[str, ...]:
3858+
"""Return receipt IDs recorded by a queue control stage."""
3859+
3860+
raw = getattr(stage_callable, "last_result", None)
3861+
if not isinstance(raw, Mapping):
3862+
return ()
3863+
values = raw.get("receipt_ids")
3864+
if not isinstance(values, (list, tuple)):
3865+
return ()
3866+
return tuple(str(value) for value in values if str(value or "").strip())
3867+
3868+
3869+
def _reddog_queue_stage_rejection_reasons(stage_callable: Any) -> tuple[str, ...]:
3870+
"""Return rejection reasons recorded by a queue control stage."""
3871+
3872+
raw = getattr(stage_callable, "last_result", None)
3873+
if not isinstance(raw, Mapping):
3874+
return ()
3875+
values = raw.get("rejection_reasons")
3876+
if not isinstance(values, (list, tuple)):
3877+
return ()
3878+
return tuple(str(value) for value in values if str(value or "").strip())
3879+
3880+
38573881
def run_reddog_resident_queue_control_loop_preflight(repo_root: Path) -> bool:
38583882
"""
38593883
Drive the resident queue through bounded serial/claim rounds.
@@ -3880,8 +3904,46 @@ def run_reddog_resident_queue_control_loop_preflight(repo_root: Path) -> bool:
38803904
)
38813905
if not requested:
38823906
if not run_reddog_resident_queue_serial_loop_preflight(repo_root):
3907+
run_reddog_resident_queue_control_loop_preflight.last_result = {
3908+
"accepted": False,
3909+
"status": "SERIAL_LOOP_REJECT",
3910+
"rounds": 0,
3911+
"serial_progress": _reddog_queue_stage_progress(
3912+
run_reddog_resident_queue_serial_loop_preflight,
3913+
default_progress=0,
3914+
),
3915+
"claim_progress": 0,
3916+
"receipt_ids": (),
3917+
"rejection_reasons": _reddog_queue_stage_rejection_reasons(
3918+
run_reddog_resident_queue_serial_loop_preflight
3919+
),
3920+
}
38833921
return False
3884-
return run_reddog_openclaw_signed_worker_claim_loop_preflight(repo_root)
3922+
claim_ok = run_reddog_openclaw_signed_worker_claim_loop_preflight(repo_root)
3923+
claim_receipts = _reddog_queue_stage_receipt_ids(
3924+
run_reddog_openclaw_signed_worker_claim_loop_preflight
3925+
)
3926+
run_reddog_resident_queue_control_loop_preflight.last_result = {
3927+
"accepted": bool(claim_ok)
3928+
and not _reddog_queue_stage_rejected(
3929+
run_reddog_openclaw_signed_worker_claim_loop_preflight
3930+
),
3931+
"status": "PASS" if claim_ok else "CLAIM_LOOP_REJECT",
3932+
"rounds": 1,
3933+
"serial_progress": _reddog_queue_stage_progress(
3934+
run_reddog_resident_queue_serial_loop_preflight,
3935+
default_progress=1,
3936+
),
3937+
"claim_progress": _reddog_queue_stage_progress(
3938+
run_reddog_openclaw_signed_worker_claim_loop_preflight,
3939+
default_progress=1 if claim_ok else 0,
3940+
),
3941+
"receipt_ids": claim_receipts,
3942+
"rejection_reasons": _reddog_queue_stage_rejection_reasons(
3943+
run_reddog_openclaw_signed_worker_claim_loop_preflight
3944+
),
3945+
}
3946+
return claim_ok
38853947

38863948
enforced = os.getenv("REDDOG_RESIDENT_QUEUE_CONTROL_LOOP_ENFORCED", "0") != "0"
38873949
raw_rounds = os.getenv("REDDOG_RESIDENT_QUEUE_CONTROL_LOOP_MAX_ROUNDS", "8").strip()
@@ -3891,11 +3953,21 @@ def run_reddog_resident_queue_control_loop_preflight(repo_root: Path) -> bool:
38913953
max_rounds = 0
38923954
if max_rounds < 1:
38933955
print("[REDDOG-QUEUE-CONTROL] preflight=FAIL error=invalid_max_rounds")
3956+
run_reddog_resident_queue_control_loop_preflight.last_result = {
3957+
"accepted": False,
3958+
"status": "INVALID_MAX_ROUNDS",
3959+
"rounds": 0,
3960+
"serial_progress": 0,
3961+
"claim_progress": 0,
3962+
"receipt_ids": (),
3963+
"rejection_reasons": ("invalid_max_rounds",),
3964+
}
38943965
return not enforced
38953966

38963967
completed_rounds = 0
38973968
serial_progress_total = 0
38983969
claim_progress_total = 0
3970+
receipt_ids: list[str] = []
38993971
stopped_reason = "max_rounds"
39003972
for round_index in range(1, max_rounds + 1):
39013973
serial_ok = run_reddog_resident_queue_serial_loop_preflight(repo_root)
@@ -3907,6 +3979,17 @@ def run_reddog_resident_queue_control_loop_preflight(repo_root: Path) -> bool:
39073979
if not serial_ok or _reddog_queue_stage_rejected(
39083980
run_reddog_resident_queue_serial_loop_preflight
39093981
):
3982+
run_reddog_resident_queue_control_loop_preflight.last_result = {
3983+
"accepted": False,
3984+
"status": "SERIAL_LOOP_REJECT",
3985+
"rounds": completed_rounds,
3986+
"serial_progress": serial_progress_total,
3987+
"claim_progress": claim_progress_total,
3988+
"receipt_ids": tuple(receipt_ids),
3989+
"rejection_reasons": _reddog_queue_stage_rejection_reasons(
3990+
run_reddog_resident_queue_serial_loop_preflight
3991+
),
3992+
}
39103993
print(
39113994
f"[REDDOG-QUEUE-CONTROL] preflight=FAIL round={round_index} "
39123995
"stage=serial_loop"
@@ -3918,9 +4001,25 @@ def run_reddog_resident_queue_control_loop_preflight(repo_root: Path) -> bool:
39184001
default_progress=1 if claim_ok else 0,
39194002
)
39204003
claim_progress_total += claim_progress
4004+
receipt_ids.extend(
4005+
_reddog_queue_stage_receipt_ids(
4006+
run_reddog_openclaw_signed_worker_claim_loop_preflight
4007+
)
4008+
)
39214009
if not claim_ok or _reddog_queue_stage_rejected(
39224010
run_reddog_openclaw_signed_worker_claim_loop_preflight
39234011
):
4012+
run_reddog_resident_queue_control_loop_preflight.last_result = {
4013+
"accepted": False,
4014+
"status": "CLAIM_LOOP_REJECT",
4015+
"rounds": completed_rounds,
4016+
"serial_progress": serial_progress_total,
4017+
"claim_progress": claim_progress_total,
4018+
"receipt_ids": tuple(dict.fromkeys(receipt_ids)),
4019+
"rejection_reasons": _reddog_queue_stage_rejection_reasons(
4020+
run_reddog_openclaw_signed_worker_claim_loop_preflight
4021+
),
4022+
}
39244023
print(
39254024
f"[REDDOG-QUEUE-CONTROL] preflight=FAIL round={round_index} "
39264025
"stage=openclaw_claim_loop"
@@ -3931,10 +4030,22 @@ def run_reddog_resident_queue_control_loop_preflight(repo_root: Path) -> bool:
39314030
stopped_reason = "idle"
39324031
break
39334032

4033+
receipt_ids_tuple = tuple(dict.fromkeys(receipt_ids))
4034+
run_reddog_resident_queue_control_loop_preflight.last_result = {
4035+
"accepted": True,
4036+
"status": "PASS",
4037+
"rounds": completed_rounds,
4038+
"serial_progress": serial_progress_total,
4039+
"claim_progress": claim_progress_total,
4040+
"receipt_ids": receipt_ids_tuple,
4041+
"rejection_reasons": (),
4042+
}
4043+
receipts = ",".join(receipt_ids_tuple) or "(none)"
39344044
print(
39354045
f"[REDDOG-QUEUE-CONTROL] preflight=PASS rounds={completed_rounds} "
39364046
f"max_rounds={max_rounds} stopped_reason={stopped_reason} "
3937-
f"serial_progress={serial_progress_total} claim_progress={claim_progress_total}"
4047+
f"serial_progress={serial_progress_total} claim_progress={claim_progress_total} "
4048+
f"receipts={receipts}"
39384049
)
39394050
return True
39404051

modules/communication/moltbot_bridge/ModLog.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# ModLog - moltbot_bridge
22

3+
## 2026-07-17: REDDOG_RESIDENT_CONTROL_LOOP_RECEIPT_SUMMARY_PHASE1
4+
5+
**Author**: 0102 (Codex) | Commander: 012 | WSP: 00, 15, 22, 97
6+
7+
- Surfaced signed-worker execution receipt IDs through the outer resident queue
8+
control-loop summary and `run_reddog_resident_queue_control_loop_preflight.last_result`.
9+
- Added fail-closed control-loop `last_result` summaries for invalid rounds and
10+
serial/claim-loop rejection paths.
11+
- Added regressions proving full resident control-loop runs expose durable
12+
signed-worker task receipt IDs without changing authority, queue, runner,
13+
shell, PR, PatternMemory, reward, or HoloIndex behavior.
14+
- HoloIndex query-only check did not surface the new resident control-loop
15+
receipt summary surface; recorded as
16+
HOLOINDEX_REDDOG_RESIDENT_CONTROL_LOOP_RECEIPT_SUMMARY_INDEX_GAP. No runtime
17+
reindex performed.
18+
319
## 2026-07-17: REDDOG_OPENCLAW_SIGNED_WORKER_CLAIM_RECEIPT_TELEMETRY_PHASE1
420

521
**Author**: 0102 (Codex) | Commander: 012 | WSP: 00, 15, 22, 97

modules/communication/moltbot_bridge/tests/test_reddog_main_openclaw_signed_worker_claim_loop_preflight.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,12 @@ def _serve_signer() -> None:
11391139
assert "[REDDOG-QUEUE-LOOP] preflight=PASS" in captured
11401140
assert "[REDDOG-OPENCLAW-CLAIM-LOOP] preflight=PASS" in captured
11411141
assert "claimed_count=7" in captured
1142+
assert "receipts=signed_worker_task_execution_" in captured
1143+
assert str(
1144+
main.run_reddog_resident_queue_control_loop_preflight.last_result[
1145+
"receipt_ids"
1146+
][0]
1147+
).startswith("signed_worker_task_execution_")
11421148
assert "REDDOG_WORK_ORDERS_PATH" not in os.environ
11431149

11441150
pending = [
@@ -1429,6 +1435,12 @@ def _serve_signer_cli() -> None:
14291435
assert "[REDDOG-QUEUE-CONTROL] preflight=PASS" in captured
14301436
assert "[REDDOG-QUEUE-LOOP] preflight=PASS" in captured
14311437
assert "[REDDOG-OPENCLAW-CLAIM-LOOP] preflight=PASS" in captured
1438+
assert "receipts=signed_worker_task_execution_" in captured
1439+
assert str(
1440+
main.run_reddog_resident_queue_control_loop_preflight.last_result[
1441+
"receipt_ids"
1442+
][0]
1443+
).startswith("signed_worker_task_execution_")
14321444
assert calls
14331445
stored = json.loads(chain.read_text(encoding="utf-8"))
14341446
assert stored["stage_results"]["worker_dispatch_runtime"]["accepted"] is True

0 commit comments

Comments
 (0)