Skip to content

🫗 fix: Drain Cancelled BYOM Settlements - #172

Merged
danny-avila merged 3 commits into
mainfrom
danny-avila/fix-byom-cancellation-settlement
Sep 9, 2026
Merged

🫗 fix: Drain Cancelled BYOM Settlements#172
danny-avila merged 3 commits into
mainfrom
danny-avila/fix-byom-cancellation-settlement

Conversation

@danny-avila

@danny-avila danny-avila commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

I fixed foreground Stop handling across Code API and the native BYOM worker so a cancelled command cannot keep writing or strand its workspace behind a durable mutation guard. This is the Code API/worker companion to LibreChat PR #15777.

  • Mark cancellation before closing an in-flight workspace mutation assignment and drain its clean worker rejection for a bounded five-second grace.
  • Use exponential settlement polling during the disconnected drain to limit Redis load.
  • Keep cancellation grace independent from the execution deadline so a Stop near timeout remains a cancellation rather than an ambiguous timeout.
  • Distinguish a command that may have partially modified files from a command whose process termination is still uncertain.
  • Clear the mutation guard only after POSIX process-group termination and accepted rejection settlement; retain quarantine on Windows, executor loss, transport ambiguity, and older workers that cannot provide the stronger proof.
  • Preserve rolling compatibility: deploy Code API before updating BYOM workers; either mixed-version order remains fail-closed.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • Built @librechat/code with TypeScript.
  • Passed 19 focused native executor, timeout/cancellation cleanup, proof-validation, and worker quarantine tests.
  • Passed all 13 workspace-store tests plus focused Redis cancellation/listener regressions.
  • Passed an isolated live LibreChat handler → HTTP → Code API bridge store → native SRT worker test: Stop returned in 2 ms, killed the process tree, prevented the delayed write, cleared quarantine, and allowed an immediate second command in the same workspace.

Test Configuration:

  • macOS native SRT worker
  • Ephemeral HTTP port
  • Ephemeral Redis Unix socket
  • Temporary writable workspace

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in complex areas of my code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current PR head ef49ad6. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-09T08:27:52.846344Z 09786a1 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current PR head 85ae145. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current PR head 09786a1. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 09786a1bab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila danny-avila changed the title 🧯 fix: Drain BYOM Cancellation Settlements 🫗 fix: Drain Cancelled BYOM Settlements Sep 9, 2026
@danny-avila
danny-avila merged commit 6abed11 into main Sep 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant