Skip to content

fix: harden orchestration lifecycle messages - #8388

Draft
Dirtywater97 wants to merge 1 commit into
stablyai:mainfrom
Dirtywater97:fix/orchestration-lifecycle-payload-validation
Draft

Dirtywater97 wants to merge 1 commit into
stablyai:mainfrom
Dirtywater97:fix/orchestration-lifecycle-payload-validation

Conversation

@Dirtywater97

@Dirtywater97 Dirtywater97 commented Jul 12, 2026 •

Copy link
Copy Markdown

Summary

  • Reject malformed, unauthorized, and stale orchestration lifecycle messages before they mutate task state.
  • Make repeated worker_done delivery idempotent and prevent older dispatch completions from re-entering the coordinator inbox.
  • Add validated task-update --result-file support and teach agents to use PowerShell-safe structured lifecycle flags.

Root cause: the orchestration skill demonstrated a raw JSON payload command that PowerShell could quote-strip. The runtime accepted that lifecycle message too late in the flow, leaving the worker task unreconciled and allowing malformed or repeated completions into the audit stream.

User impact: Windows orchestration workers can now report lifecycle state with structured flags, malformed completions fail without state or inbox mutation, and safe retries do not duplicate coordinator mail.

Screenshots

No visual change.

Testing

  • pnpm lint (targeted oxlint and the max-lines ratchet passed)
  • pnpm typecheck (typecheck:node and typecheck:cli passed; web was not affected)
  • pnpm test (focused suite passed: 5 files, 167 tests)
  • pnpm build
  • Added or updated high-quality tests that would catch regressions

Additional validation:

  • Real Windows PowerShell subprocess coverage for structured completion, quote-stripped malformed JSON, result-file success, unreadable/malformed files, and inline/file conflicts.
  • Repository and installed orchestration skills passed quick_validate.py.
  • git diff --check and the repository pre-commit lint/format hook passed.

AI Review Report

Two independent read-only AI reviews were run. The first found no blocker and flagged stale/duplicate completion handling plus missing end-to-end --result-file coverage; both findings were fixed and retested. The follow-up review verified latest-dispatch enforcement, retry idempotency, PowerShell result paths, and the focused test evidence, with no blocker remaining.

Cross-platform review explicitly considered macOS, Linux, and Windows. The changed runtime validation uses platform-neutral TypeScript/Node behavior. Windows PowerShell shell quoting and file paths are exercised end to end. No keyboard shortcuts, UI labels, renderer behavior, or Electron-specific platform behavior changed.

Security Audit

Review covered lifecycle payload parsing, RPC/IPC input validation, sender/task/dispatch authority, stale-message rejection, duplicate delivery, explicit result-file path handling, and failure atomicity. Malformed input is rejected before message insertion or task mutation. No dependencies, credentials, secrets, authentication behavior, or command execution were added.

Follow-up: a direct RPC client can still address an otherwise valid lifecycle message to the wrong concrete coordinator handle because dispatch rows do not persist coordinator identity. Fully binding recipient authority requires a dispatch-schema migration and is intentionally deferred from this no-migration fix.

Notes

This PR adds no database migration. Existing dispatch storage remains compatible.

ELI5

Orchestration lifecycle messages could be malformed, unauthorized, or stale and still change task state, and PowerShell quoting could break structured flags. Messages are validated first, repeated worker_done is idempotent, and agents get safer PowerShell-friendly lifecycle flags.

This branch has not been deployed

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants