Reserve worker spend durably before governed dispatch
Some checks failed
Governed runtime contract / contract (push) Has been cancelled
Some checks failed
Governed runtime contract / contract (push) Has been cancelled
Assistant: codex Assistant-Model: gpt-5.6-luna Assistant-Session: 01a07ff8-19d0-7820-b4d0-1353833cb7fc
This commit is contained in:
parent
4ffb8acb19
commit
38b25fbc26
14 changed files with 1378 additions and 9 deletions
|
|
@ -190,6 +190,24 @@ def _cmd_close_outbox(args: argparse.Namespace) -> int:
|
|||
return 1 if payload["pending"] or payload["quarantined"] else 0
|
||||
|
||||
|
||||
def _cmd_spend(args: argparse.Namespace) -> int:
|
||||
from rein_aharness.spend_admission import SpendAdmissionError, SpendLedger, SpendPolicy
|
||||
|
||||
try:
|
||||
store = SpendLedger(args.ledger, SpendPolicy.load(args.policy))
|
||||
if args.action == "init":
|
||||
store.initialize()
|
||||
elif args.action == "reconcile":
|
||||
if not args.run_id or args.cost_usd is None or not args.receipt or not args.provider_stopped:
|
||||
raise SpendAdmissionError("reconcile requires run ID, final cost, receipt and --provider-stopped")
|
||||
store.reconcile(args.run_id, cost_usd=args.cost_usd, receipt=args.receipt)
|
||||
print(json.dumps(store.status(), indent=2, sort_keys=True))
|
||||
return 0
|
||||
except SpendAdmissionError as exc:
|
||||
print(f"spend admission refused: {exc}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
|
||||
def _cmd_preflight(args: argparse.Namespace) -> int:
|
||||
from rein_aharness.readiness import run_readiness_checks
|
||||
|
||||
|
|
@ -584,6 +602,15 @@ def main(argv: list[str] | None = None) -> int:
|
|||
help="Skip the read-only Activity Core queue probe",
|
||||
)
|
||||
|
||||
spend = sub.add_parser("spend", help="Inspect or reconcile private worker spend reservations")
|
||||
spend.add_argument("action", choices=("init", "status", "reconcile"))
|
||||
spend.add_argument("--policy", type=Path, required=True)
|
||||
spend.add_argument("--ledger", type=Path, required=True)
|
||||
spend.add_argument("--run-id")
|
||||
spend.add_argument("--cost-usd")
|
||||
spend.add_argument("--receipt", help="Reference to owner-verified termination and final accounting")
|
||||
spend.add_argument("--provider-stopped", action="store_true")
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
if args.command == "validate":
|
||||
|
|
@ -601,6 +628,9 @@ def main(argv: list[str] | None = None) -> int:
|
|||
if args.command == "close-outbox":
|
||||
return _cmd_close_outbox(args)
|
||||
|
||||
if args.command == "spend":
|
||||
return _cmd_spend(args)
|
||||
|
||||
if args.command == "preflight":
|
||||
return _cmd_preflight(args)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue