Skip to content

feat: close the executor side-channel gaps (#590, #591, #593) - #604

Merged
kartikeya-27 merged 5 commits into
masterfrom
feat/executor-side-channel-gaps
Aug 2, 2026
Merged

feat: close the executor side-channel gaps (#590, #591, #593)#604
kartikeya-27 merged 5 commits into
masterfrom
feat/executor-side-channel-gaps

Conversation

@pratyush618

@pratyush618 pratyush618 commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Three gaps left by the side-channel work (#589 and its children). #592 and #594 were already complete.

#591 — an unknown frame tore the attach down

The scheduler's reader used the strict FrameReader::read, so a frame type it had no variant for surfaced as a parse error, and the only thing a reader loop can do with one is breakabandon(&executor): a live peer deregistered and its in-flight jobs left to the reaper.

Structural rather than an oversight — the payload length sits inside the header, so a header that will not deserialize gives no skip length. FrameReader::read_or_skip parses in two stages: the typed parse first (a known frame pays nothing for the tolerance), and only on failure a FramePreamble carrying type plus a payload_len that aliases the two legacy names. It skips the declared bytes and returns Incoming::Unknown, so the stream stays aligned on the next frame.

Frame::is_known_type keeps that narrow: a tag this build does know whose header will not parse is still an error, because skipping a malformed job would silently lose a dispatch. Both readers use the tolerant form — scheduler and executor — each warning once per type per connection so a newer peer cannot flood the log.

BINDING_CONTRACT.md's frame table had gone stale (no progress/task_log, no capability list). Updated, along with the forward rule this depends on: a frame type added from now on must declare its payload length as payload_len.

The issue also called for progress to be clamped 0–100. Left as a drop: the in-process storage path rejects out-of-range, so dropping matches it, and clamping 5000 → 100 would show a job as complete.

#590 — the shed counter was never asserted

dropped_logs existed but only surfaced in a warning at session end, so nothing proved a flood sheds rather than blocks or grows. ExecutorSideChannel::dropped_task_logs() exposes it.

The test fills the queue deterministically instead of racing the drain: a test-local transport whose write half parks on a gate. With the writer held shut the result loop can hold at most one line outside the queue, so every push past the capacity must shed and every progress report must land on the same map entry. It asserts the flood never parks the task, that at least FLOOD - CAPACITY - 1 lines were shed, that the newest line still arrives (drop-oldest), and that 500 progress reports coalesce to at most two frames ending on the newest value.

#593 — Node's queue-level shim still dropped

detached.ts warned and dropped updateProgress/writeTaskLog; only the task-callback seam had been wired, so a task reaching the queue directly reported nothing while the same call through the job context worked. It now installs a sink on attach and clears it on teardown, matching the Python shell.

The task-callback overrides stay. deps.queue is only the detached stand-in when the process is a taskito executor; one started from a process that does have storage would otherwise write progress into its own database, naming a job that lives in the scheduler's.

Also adds currentJob().log(message, level?, extra?)publish was the only route to a task log, so a plain log line had nowhere to go at all. TaskLogWriteLevel excludes result, which is publish's. Both share one encoder that falls back to the value's string form rather than failing a task over a circular reference.

Verification

  • cargo test --workspace green; cargo fmt --check and clippy --all-targets --all-features -- -D warnings clean; default, postgres and redis all check
  • Node: 653 tests, typecheck, biome
  • Python: 1379 passed / 14 skipped against a rebuilt wheel
  • The backpressure test ran 12 consecutive times without a flake

Closes #590
Closes #591
Closes #593

Summary by CodeRabbit

  • New Features

    • Added structured task logging with optional levels and metadata in the Node SDK.
    • Executor progress updates and task logs now reach the scheduler through a dedicated reporting channel.
    • Added safe handling for circular and non-serializable metadata.
  • Bug Fixes

    • Unknown protocol messages are skipped safely, keeping sessions active across version differences.
    • Detached reporting warns instead of failing when scheduler support is unavailable.
  • Documentation

    • Documented protocol compatibility behavior and updated executor examples with task logging.

A frame type only the far side knows was a parse error, and a reader loop can only drop the connection over one — abandoning every in-flight job to the reaper. Headers declare their own payload length, so an unrecognised type is now skipped and logged instead. A known type that will not parse stays fatal.
The counter existed but only surfaced in a warning at session end, so nothing asserted that a flood sheds rather than blocks or grows. The test gates the writer instead of racing the drain, which makes both halves of the contract deterministic: progress coalesces, the oldest logs are shed.
The detached stand-in warned and dropped progress and task logs, so a task reaching the queue directly reported nothing while the same call through the job context worked. Both now reach the scheduler.
publish was the only route to a task log, so a plain log line had nowhere to go — on an executor or in a worker. Extra blobs now share one encoder that falls back to the value's string form rather than failing the task on a circular reference.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds length-delimited unknown-frame skipping to the worker protocol. Rust readers preserve sessions across version skew. Node executors route progress and task logs through scheduler sinks, with safe metadata encoding and backpressure tests.

Changes

Executor side-channel reporting

Layer / File(s) Summary
Protocol contracts and tolerant frame reading
crates/taskito-core/BINDING_CONTRACT.md, crates/taskito-core/src/worker/protocol.rs, crates/taskito-core/src/worker/mod.rs
The protocol recognizes known frame types, skips unknown frames using payload_len, accepts legacy length aliases, and documents capability negotiation.
Rust reader integration and side-channel metrics
crates/taskito-core/src/worker/executor.rs, crates/taskito-core/src/worker/remote.rs
Executor and remote readers continue after unknown frames, warn once per frame type, preserve liveness, and expose dropped task-log counts.
Node task-log and progress routing
sdks/node/src/context.ts, sdks/node/src/detached.ts, sdks/node/src/executor.ts, sdks/node/src/index.ts, sdks/node/src/task-callback.ts
The Node SDK adds typed logging, safe metadata encoding, detached sinks, executor lifecycle wiring, and public type exports.
Compatibility and backpressure validation
crates/taskito-core/Cargo.toml, crates/taskito-core/tests/rust/executor_tests.rs, sdks/node/test/worker/executorAttach.test.ts, sdks/node/test/worker/detachedSink.test.ts, docs/content/docs/shared/guides/operations/executor.mdx
Tests and documentation cover synthetic future frames, stalled transports, sink lifecycle, unknown-frame continuation, progress coalescing, and oldest-log shedding.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

Possibly related PRs

Suggested labels: node, enhancement

Suggested reviewers: stromanni

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR covers tolerant frames and Node sink routing, but it does not show scheduler storage handling, capability advertisement, job enrichment, or middleware settings from [#590], [#591], and [#593]. Implement and test scheduler Progress and TaskLog storage, capability-gated emission, enriched job frames, and Node middleware-disable handling before merging.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed All listed code, documentation, dependency, and test changes support the executor side-channel objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the PR's main change: closing executor side-channel gaps across protocol, Rust, and Node components.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/taskito-core/tests/rust/executor_tests.rs (1)

281-293: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the Default derive on Gate.

Default produces open: false, which is a shut gate. opened() is the only constructor in use. A later Gate::default() would park every writer and hang the test with no obvious cause.

♻️ Proposed change
-#[derive(Default)]
 struct Gate {
     open: Mutex<bool>,
     changed: Condvar,
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/taskito-core/tests/rust/executor_tests.rs` around lines 281 - 293,
Remove the #[derive(Default)] attribute from the Gate struct, keeping opened()
as its sole constructor. Do not alter the open mutex initialization or Condvar
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sdks/node/src/detached.ts`:
- Around line 37-48: Replace the process-wide sink in
sdks/node/src/detached.ts#L37-L48 with executor- or detached-queue-scoped
registration and disposal; update detached queue write routing in
sdks/node/src/detached.ts#L92-L110 to use that queue’s sink, register only the
current executor’s sink in sdks/node/src/executor.ts#L155-L159, and dispose only
that executor’s registration in sdks/node/src/executor.ts#L229-L231 so multiple
executors remain isolated.

---

Nitpick comments:
In `@crates/taskito-core/tests/rust/executor_tests.rs`:
- Around line 281-293: Remove the #[derive(Default)] attribute from the Gate
struct, keeping opened() as its sole constructor. Do not alter the open mutex
initialization or Condvar behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9146b171-c9dc-448d-a250-a1778b56efee

📥 Commits

Reviewing files that changed from the base of the PR and between a91ebde and c200f72.

📒 Files selected for processing (14)
  • crates/taskito-core/BINDING_CONTRACT.md
  • crates/taskito-core/Cargo.toml
  • crates/taskito-core/src/worker/executor.rs
  • crates/taskito-core/src/worker/mod.rs
  • crates/taskito-core/src/worker/protocol.rs
  • crates/taskito-core/src/worker/remote.rs
  • crates/taskito-core/tests/rust/executor_tests.rs
  • docs/content/docs/shared/guides/operations/executor.mdx
  • sdks/node/src/context.ts
  • sdks/node/src/detached.ts
  • sdks/node/src/executor.ts
  • sdks/node/src/index.ts
  • sdks/node/src/task-callback.ts
  • sdks/node/test/worker/executorAttach.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • ByteVeda/taskito (manual)

Comment thread sdks/node/src/detached.ts Outdated
A module-level sink let a second attach take the first executor's writes, and either one stopping silenced the other.
@pratyush618 pratyush618 changed the title Close the executor side-channel gaps (#590, #591, #593) feat: close the executor side-channel gaps (#590, #591, #593) Aug 2, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
sdks/node/src/executor.ts (1)

164-185: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Clear the sink when executor startup fails.

If resources.acquireWorker() or worker.started throws after Line 164, this path shuts down native but leaves sink installed. No Executor is returned, so teardown() cannot clear it.

Clear this sink after shutdown. clearSink(queue, sink) preserves a replacement sink if another attach installed one while shutdown was pending.

Proposed fix
     } catch (error) {
       // The session is live by now and no caller holds an `Executor` to stop
       // it, so a throwing resource factory or `worker.started` listener would
       // leak the attach until the process exits.
       await native.shutdown().catch((failure) => {
         log.debug(() => "releasing the attach after a failed start failed", failure);
       });
+      clearSink(queue, sink);
       throw error;
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdks/node/src/executor.ts` around lines 164 - 185, Update the startup-failure
catch block after resources.acquireWorker() and the worker.started emission to
call clearSink(queue, sink) after native.shutdown() completes. Preserve
clearSink’s replacement-sink behavior and keep the existing shutdown failure
logging and original error propagation unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@sdks/node/src/executor.ts`:
- Around line 164-185: Update the startup-failure catch block after
resources.acquireWorker() and the worker.started emission to call
clearSink(queue, sink) after native.shutdown() completes. Preserve clearSink’s
replacement-sink behavior and keep the existing shutdown failure logging and
original error propagation unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 615fa6a3-24cd-41e0-a396-ab49f2c8e67d

📥 Commits

Reviewing files that changed from the base of the PR and between c200f72 and c546b14.

📒 Files selected for processing (3)
  • sdks/node/src/detached.ts
  • sdks/node/src/executor.ts
  • sdks/node/test/worker/detachedSink.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • ByteVeda/taskito (manual)

@kartikeya-27
kartikeya-27 merged commit 5134fcf into master Aug 2, 2026
34 of 35 checks passed
@kartikeya-27
kartikeya-27 deleted the feat/executor-side-channel-gaps branch August 2, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants