Skip to content

[Bug]: Windows composed settlement exits 1 with ok=false after the spend commits #9398

Backlog

Description

@BigDataDZ

Reproduced behavior

On native Windows, the settlement command that the Turn plan itself publishes commits the spend and then reports failure.

tests/control_plane/test_execution_loss_closeout_cli.py::test_combined_writeback_keeps_the_admitted_lease_generation drives the real public CLI. The replaced=False variants follow the plan's semantic_closeout_command_template through to a successful settlement and require exit 0.

Variant Result on native Windows
[False-file] exit 1, ok=false
[False-sqlite] exit 1, ok=false
[True-file], [True-sqlite] pass (they never reach a settled composed writeback)

The failing packet shows that the settlement itself succeeded:

ok                     => false
appended               => true
settlement_progress    => {"schema_version": "quota_settlement_progress_v0", "state": "settled", "next_step": null, ...}
error => "The quota operation was already evaluated, but bounded result delivery failed. Recover the original operation/receipt; do not repeat admission or assume it did not commit. private capture validation is unsupported on this platform; use the same Turn command without --max-page-output-bytes"

Root cause

  1. loopx/control_plane/quota/settlement_plan.ts:51 and loopx/control_plane/quota/turn_envelope_references.ts:820 compose every plan writeback with --settle-turn --settlement-receipt, with no platform condition.
  2. loopx/cli_commands/refresh_settlement.py:44-50 runs present_settled_refresh whenever both flags are present, and turns QuotaDecisionTransportError into payload.update(ok=False, error=str(exc)).
  3. present_settled_refresh always calls budgeted_settlement_result for a non-dry-run settled result (supporting_fields is a tuple, so the early fits(payload) return is not taken), and budgeted_settlement_result calls private_capture_uid() first (loopx/cli_commands/quota_capture.py:577).
  4. private_capture_uid() deliberately fails closed off POSIX (loopx/control_plane/turn_driver/decision_capture.py:29-43: "Fail closed until this IO boundary has a qualified non-POSIX ACL reader").
  5. loopx/cli_commands/project_lifecycle_refresh_state.py:906-909 then returns 0 if payload.get("ok") else 1.

So the fail-closed check is intended, but it is reached on every composed settlement on Windows rather than only in an exceptional capture failure. The advice in the error is also not actionable for a caller following the plan: the composed command carries no --max-page-output-bytes; the budget is the implicit NATIVE_CONTEXT_PAGE_OUTPUT_BYTES passed at refresh_settlement.py:267 and :349.

Blast radius

  • Directly reproduced: the two variants above, on both File and SQLite providers.
  • By code reading, not separately executed: every plan-composed settlement on native Windows takes this path, since the composed flags are unconditional and private_capture_supported() is false for os.name != "posix".
  • tests/ references --settlement-receipt in 15 files (28 lines). I did not run those on Windows, so I am not claiming a count of further failures.
  • Not visible in CI: the windows-powershell job runs only the CLI output budget/differential files, not this test file.

Expected boundary

Decide what a composed settlement should return on a host that cannot validate private captures. Two candidate directions, both of which leave POSIX behavior unchanged:

  • Do not compose the receipt flag where it cannot be delivered. Publish the writeback with --settle-turn only (the pre-Return recoverable receipts for settled refreshes #8090 shape) when the host cannot validate a private capture. This is the more principled fix, but it makes the plan shape platform-dependent and touches the composed-plan contract.
  • Keep the evaluated result authoritative. In settle_requested_refresh, when the capture is unsupported on this platform, retain ok as evaluated and attach the delivery problem as a visible warning, the way the failed_with_spend branch at refresh_settlement.py:262-270 already retains the payload with result_delivery_error. This is the smaller change, and it alters the exit code of a committed settlement from 1 to 0 on Windows.

Either way, the returned packet should carry recovery guidance that matches the command the caller was actually given.

Scope and qualification

  • Reproduced on main d33af49aa, native Windows 10, Python 3.12, File and SQLite canonical providers, real public CLI.
  • loopx.control_plane.turn_driver.decision_capture.private_capture_supported() returns False on this host.
  • Not verified: no POSIX run, no real Host reaction to the exit code, and no measurement of how a native Host with a bounded stdout handles the returned packet.
  • Public-safe summary only; no local paths, prompts, logs or credentials.

Introduced by the combination of #8090 (present_settled_refresh) and 257b45585 (private_capture_uid). Related: #8604 covers other native Windows boundaries.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions