Skip to content

[Experiment] orchestrator-v2 hardening: telemetry, resilience, capability routing#42

Closed
matt-wright86 wants to merge 2 commits into
devzeebo:mainfrom
matt-wright86:refactor/orchestrator-v2-hardening
Closed

[Experiment] orchestrator-v2 hardening: telemetry, resilience, capability routing#42
matt-wright86 wants to merge 2 commits into
devzeebo:mainfrom
matt-wright86:refactor/orchestrator-v2-hardening

Conversation

@matt-wright86

Copy link
Copy Markdown
Collaborator

Summary

Experiment / exploratory (opened as a Draft): hardens the orchestrator-v2 rebuild —
telemetry propagation, failure resilience, and capability-aware routing — plus a runnable
real-engine example and a full write-up. Not intended to merge as-is; see
orchestrator-v2/docs/experiment/.

Motivation

A session that audited and dogfooded orchestrator-v2 found that its "thin" terminal boundary
dropped everything but taskId — execution telemetry, task-source callback errors, and runner
capability all had to be threaded deliberately. This branch does that threading, with regression
tests, and captures the findings.

  • Related issue/rune: # (none — exploratory)

Type of change

  • Bug fix (non-breaking) — I3 (task-source callback resilience), G1 (resumable failed runs)
  • New feature (non-breaking) — I1 (capability routing), Route A (telemetry propagation)
  • Breaking change
  • Documentation — gap report, retrospective, dogfood-run notes
  • Refactor / cleanup — two /simplify passes
  • Test coverage — orchestrator.spec (I3), peer-registry.spec (I1)
  • Chore / tooling

Checklist

  • Raw go/npx were not used
  • make lint passes — N/A: orchestrator-v2 uses its own vp/oxlint toolchain (not wired into make); vp check is clean
  • make test passes — N/A: vp run -r test is green (43/43)
  • make build passes — N/A: vp run -r build is clean
  • Tests added/updated for new behavior
  • Docs updated where relevant
  • Commit messages are short, lowercase, imperative
  • No force-push to main; branch is current with main
  • Self-reviewed the diff (two /simplify passes)

Notes for reviewers

  • This is an experiment, not merge-ready. It bundles several fixes for shared review; if
    pursued, it should split into focused PRs (Route A / I1 / I3).
  • Open follow-ups (not in this branch): E3 (a task's output/message isn't propagated — same
    shape as the telemetry gap, for the result), reconcile 3 correctness-level doc gaps, build
    agent-4-workflow + a TaskSource read-side.
  • The dogfood's code-review swarm repeatedly flagged canHandle's fail-open default (null
    capabilities → handles anything) as surprising. It's deliberate (backward-compat for
    non-advertising runners, load-bearing for the stub-runner tests) but deserves an explicit
    rationale comment or an opt-in.
  • A packaging fix to orchestrator/package.json (the test-helpers export) was deliberately left
    out of this branch.
  • CONTRIBUTING.md predates orchestrator-v2/ and doesn't document its vp toolchain — worth updating.

🤖 Generated with Claude Code

matt-wright86 and others added 2 commits July 3, 2026 16:43
- Route A: propagate execution telemetry from the engine through the runner
  RPC to the TaskSource as a terminal outcome; unify ExecutionStats in
  interfaces-task-source.
- G1: persist sessionId (and telemetry) on the failure path so a failed run
  stays resumable.
- I3: guard task-source callbacks so a throw can't leak a peer's in-flight
  slot, hang the runner's terminal RPC, or escape as an unhandled rejection
  (settle/recordBestEffort helpers + a route().catch net).
- I1: capability-aware routing -- runners advertise their registered agents
  in the heartbeat; the orchestrator only dispatches a task to a capable peer
  (backward compatible: a runner that advertises nothing = capable of anything).
- Adds regression tests (orchestrator.spec I3, peer-registry.spec I1).
  43/43 tests pass; build + lint clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- examples/claude-engine: a runnable real-engine deployment (runner.yaml
  onboarding + a claude-CLI Engine that maps CLI JSON to EngineResult, so real
  token/cost telemetry flows). Registers examples/* as a workspace member.
- docs/experiment: the session's gap report, retrospective (lessons), and
  dogfood-run notes with telemetry receipts (three escalating real-engine runs,
  incl. the G1 resume payoff).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 67848361-373e-4b21-98fa-3d23cfe0afef

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@matt-wright86 matt-wright86 closed this by deleting the head repository Jul 4, 2026
ScriptTaskDefinition,
} from "./types.js";
export { isScriptTaskDefinition } from "./types.js";
export type { ExecutionStats } from "@bifrost-ai/interfaces-task-source";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't think execution stats belong to the task source. They're a core part of the orchestrator and can exist for non task-source'd things

selected: ConnectedPeer | undefined;
};

const fakePeer = (peerId: string): ConnectedPeer => ({

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Context and helpers should be below describe blocks. 30 lines of non-tests to get to the real tests is a lot to skip

}
state.runnerId = payload.runnerId;
state.lastSeen = Date.now();
if (payload.capabilities !== undefined) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

So we send the capabilities every time, but only update them once? What if an agent updates their capabilities dynamically?

function canHandle(state: PeerState, requiredCapability: string | undefined): boolean {
// No requirement, or a runner that hasn't advertised its capabilities, is treated as
// able to handle the task (keeps non-advertising runners working as before).
if (requiredCapability === undefined || state.capabilities === null) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I like the capabilities. I think we should move forward with the expectation that all runners will advertise and treat null as no capabilities

return { method: record.method, args: record.args };
}

function errorMessage(error: unknown): string {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This should be part of send rpc error

): HeartbeatHandle {
const send = () => {
peer.send({ kind: "heartbeat", runnerId: identity.keyId });
peer.send({ kind: "heartbeat", runnerId: identity.keyId, capabilities: [...capabilities] });

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Don't need to clone the array. Pass it directly and ensure peer send doesn't modify parameters

@matt-wright86

Copy link
Copy Markdown
Collaborator Author

Superseded by #43 — this PR got auto-closed when I deleted the source fork (GitHub closes a cross-fork PR once its head repo is gone). #43 re-opens the same two commits on a branch in the main repo, so it won't be fragile like this one. Carrying your review feedback over to #43 — thanks for the thorough pass! 🙏

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.

2 participants