[verified] Handle delivery acknowledgements and read-only recovery
This commit is contained in:
+39
@@ -88,3 +88,42 @@ def deliver_implementation(adapter: Any, *, head: str, declaration: Any) -> dict
|
||||
readback = adapter.read_pr(pr_number)
|
||||
bounded_pr = _validate_readback(readback, pr_number, head)
|
||||
return {"remote_head": remote_head, "pr": bounded_pr}
|
||||
|
||||
|
||||
def reconcile_implementation(adapter: Any, *, head: str, number: int,
|
||||
declaration: Any) -> dict[str, Any]:
|
||||
"""Explicit read-only recovery after uncertain write acknowledgement.
|
||||
|
||||
The trusted main-owned adapter must freshly verify identity/scope, exact
|
||||
intended body, protected Issue snapshot, and complete files/commits via
|
||||
verify_reconciliation(head, number). Only literal True accepts that proof.
|
||||
These callbacks MUST be read-only. This is not a transport sandbox, an
|
||||
automatic exception handler, or permission to retry a write.
|
||||
"""
|
||||
_validate_head(head)
|
||||
_validate_pr_number(number)
|
||||
for name in ("read_remote_head", "read_pr", "verify_reconciliation"):
|
||||
callback = None
|
||||
try:
|
||||
callback = getattr(adapter, name)
|
||||
except Exception:
|
||||
_reject("trusted reconciliation adapter required")
|
||||
if not callable(callback):
|
||||
_reject("trusted reconciliation adapter required")
|
||||
|
||||
remote_head = _delivery_adoption.deliver(
|
||||
adapter.read_remote_head, head=head, declaration=declaration
|
||||
)
|
||||
if type(remote_head) is not str or remote_head != head:
|
||||
_reject("remote head mismatch")
|
||||
readback = _delivery_adoption.deliver(
|
||||
lambda: adapter.read_pr(number), head=head, declaration=declaration
|
||||
)
|
||||
bounded_pr = _validate_readback(readback, number, head)
|
||||
verified = _delivery_adoption.deliver(
|
||||
lambda: adapter.verify_reconciliation(head, number),
|
||||
head=head, declaration=declaration
|
||||
)
|
||||
if verified is not True:
|
||||
_reject("reconciliation intent or protected state mismatch")
|
||||
return {"remote_head": remote_head, "pr": bounded_pr}
|
||||
|
||||
Reference in New Issue
Block a user