Skip to content

feat(engine,sdk-rust): rename telemetry harness → origin_actor#184

Merged
willwashburn merged 9 commits into
mainfrom
feat/origin-actor
Jun 10, 2026
Merged

feat(engine,sdk-rust): rename telemetry harness → origin_actor#184
willwashburn merged 9 commits into
mainfrom
feat/origin-actor

Conversation

@willwashburn

Copy link
Copy Markdown
Member

PR 1 of the origin_actor rollout — plan: cloud/plans/origin-actor.md (cloud#2062).

Replaces the CLI-centric telemetry harness with origin_actor — a UA-style path {app}/{type}[/{name}]:

agent-relay-cli/cli                # the agent-relay CLI itself
agent-relay-cli/agent/claude-code  # a Claude Code agent under the CLI
pear/user/send-message-box         # a human, via Pear's send-message-box UI

Changes

  • engine: X-Relaycast-Harness / ?harness=X-Relaycast-Origin-Actor / ?origin_actor=; extractHarnessextractOriginActor; the request-context var, the emitted harness telemetry property, and the realtime UpgradeRequest field → origin_actor / originActor. Max length 120→128 for the longer path; the validation regex already permits /.
  • sdk-rust: harness.rsorigin_actor.rs; with_harnesswith_origin_actor; header + WS query renamed; field/getter renamed.

Guardrail: only the telemetry harness renames

harness was overloaded. The domain harness — harness-emitted session events (harness.${type}, POST /v1/agents/:name/events, the session_events table, migration 0010_actions_and_harness.sql) — is untouched. Only the telemetry/origin-attribution harness is renamed.

Breaking

No back-compat aliases — telemetry data intentionally breaks (per plan).

Verification

  • engine: tsc clean; origin.test.ts (15) + lib tests (20) pass.
  • sdk-rust: cargo test 77 pass; clippy + fmt --check clean.

Follow-ups (separate PRs)

  1. The UpgradeRequest.originActor port rename → the cloud adapter that implements it (lands with cloud#… when it bumps the engine).
  2. Remove origin_surface (types + sdk-rust/sdk-js/sdk-python + mcp).
  3. cloud: parse origin_actor → PostHog origin_app/origin_actor_type/origin_actor_name.
  4. relay: broker/CLI set the path (extends #1078) + JS SDK rename; bump the SDK pin.

🤖 Generated with Claude Code

Replaces the CLI-centric telemetry `harness` with `origin_actor`, a UA-style
path `{app}/{type}[/{name}]` (e.g. agent-relay-cli/agent/claude-code,
pear/user/send-message-box). Per cloud/plans/origin-actor.md.

- engine: `X-Relaycast-Harness`/`?harness=` -> `X-Relaycast-Origin-Actor`/
  `?origin_actor=`; `extractHarness`->`extractOriginActor`; the `harness`
  request-context var + emitted `harness` telemetry property + the realtime
  `UpgradeRequest` field -> `origin_actor`/`originActor`. Max length 120->128
  for the longer path form. The regex already permits `/`.
- sdk-rust: `harness.rs`->`origin_actor.rs`; `with_harness`->`with_origin_actor`;
  header + WS query renamed; field/getter renamed.

The DOMAIN harness (harness-emitted session events: `harness.${type}`,
`POST /v1/agents/:name/events`, the session_events table) is untouched — only
the telemetry/origin-attribution harness is renamed.

No back-compat aliases (telemetry data intentionally breaks). origin_surface
removal + the JS/python SDK + cloud/relay producer-consumer wiring follow in
separate PRs.

Engine: tsc clean, origin (15) + lib (20) tests pass.
sdk-rust: 77 tests pass, clippy + fmt clean.

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

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@willwashburn, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 37 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 42e145d8-ee6a-4637-bd1d-1be05eaf09e7

📥 Commits

Reviewing files that changed from the base of the PR and between c0427c7 and b74a354.

📒 Files selected for processing (1)
  • memory/workspace/.relay/state.json
📝 Walkthrough

Walkthrough

Replace the "harness" request origin identifier with "origin actor" across engine and Rust SDK: new extraction/validation, propagate originActor through middleware/context/telemetry and WS upgrade, update Rust HTTP/WS clients and RelayCast options, refresh parity tests, and convert persisted workspace state keys to camelCase.

Changes

Origin Actor Identifier Refactoring

Layer / File(s) Summary
Origin actor extraction & tests
packages/engine/src/lib/origin.ts, packages/engine/src/lib/__tests__/origin.test.ts
Introduce extractOriginActor with header/query reading, validation (allowed chars), trimming, lowercasing, truncation to 128 chars, and UNKNOWN_ORIGIN_ACTOR fallback; update tests for precedence, invalid inputs, CRLF rejection, and truncation.
Engine context, telemetry, and WS integration
packages/engine/src/middleware/logger.ts, packages/engine/src/lib/serverTelemetry.ts, packages/engine/src/env.ts, packages/engine/src/engine.ts, packages/engine/src/ports/realtime.ts
Logger middleware extracts and stores originActor in Hono context and request logger metadata; server telemetry emits origin_actor; AppVariables swaps harness for originActor; /v1/ws upgrade and UpgradeArgs use originActor.
Rust origin_actor module & tests
packages/sdk-rust/src/origin_actor.rs
New origin_actor module defines ORIGIN_ACTOR_HEADER and sanitize_origin_actor (trim, lowercase, validate, 128-char cap) and replaces harness sanitizer tests with origin_actor tests.
Rust SDK public module and re-exports
packages/sdk-rust/src/lib.rs
Replace harness public module with origin_actor; re-export sanitize_origin_actor and ORIGIN_ACTOR_HEADER, retain agent-relay distinct-id exports from origin_actor.
Rust HTTP client origin_actor configuration
packages/sdk-rust/src/client.rs
Add origin_actor: Option<String> to ClientOptions with with_origin_actor(...); HttpClient stores sanitized origin_actor, exposes getter, preserves it across with_api_key, and conditionally sets X-Relaycast-Origin-Actor header.
Rust WebSocket client origin_actor configuration
packages/sdk-rust/src/ws.rs
Add origin_actor: Option<String> to WsClientOptions with with_origin_actor(...); WsClient sanitizes/stores origin_actor and conditionally appends origin_actor query parameter on handshake and reconnect.
RelayCast options and AgentClient wiring
packages/sdk-rust/src/relay.rs, packages/sdk-rust/src/agent.rs
RelayCastOptions gains origin_actor field and builder; RelayCast::new applies it to client options; AgentClient::connect forwards origin_actor to WsClientOptions.
Parity verification tests for origin actor forwarding
packages/sdk-rust/tests/parity.rs
Update channel header, API-key-rotation, and WS forwarding parity tests to assert x-relaycast-origin-actor header/query propagation and lowercasing.
Persisted workspace state schema update
memory/workspace/.relay/state.json
Convert stored JSON keys from snake_case to camelCase (e.g., workspace_idworkspaceId, last_reconcile_atlastReconcileAt); refresh reconciliation timestamps and change counters.snapshotDeleteBlocked from 42 to 53.

🎯 3 (Moderate) | ⏱️ ~25 minutes


"I nibble code like crunchy greens,
headers trimmed and lowercased clean.
From harness name to origin's light,
telemetry hops through day and night.
JSON keys now stand up straight — hooray!" 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main change: renaming the telemetry field from 'harness' to 'origin_actor' across both the engine and sdk-rust packages.
Description check ✅ Passed The PR description is comprehensive and directly related to the changeset, explaining the rationale, scope, changes across packages, guardrails, breaking changes, verification steps, and follow-ups.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/origin-actor

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 and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 293dd0ba3c

ℹ️ 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".

Comment on lines 50 to +52
const raw =
request.headers.get(HARNESS_HEADER) ??
new URL(request.url).searchParams.get("harness");
if (!raw) return UNKNOWN_HARNESS;
request.headers.get(ORIGIN_ACTOR_HEADER) ??
new URL(request.url).searchParams.get(ORIGIN_ACTOR_QUERY);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Accept the current SDK header until clients migrate

When this engine change is released before the TypeScript SDK/docs follow-up, requests created by the in-repo SDK still send X-Relaycast-Harness and WS harness (checked packages/sdk-typescript/src/origin.ts and client.ts), and openapi.yaml still tells clients to use those names. Because extraction now only reads X-Relaycast-Origin-Actor/origin_actor, those clients’ attribution is silently recorded as unknown; either update the SDK/schema in the same release or keep a temporary alias for the still-published contract.

Useful? React with 👍 / 👎.

@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.

🧹 Nitpick comments (1)
packages/engine/src/lib/origin.ts (1)

22-23: ⚡ Quick win

Use a zod schema for origin-actor validation instead of ad-hoc checks.

This logic currently duplicates trim/empty/regex/max/lowercase manually; using a single schema keeps the contract centralized and aligned with repo standards.

As per coding guidelines, "Prefer zod schemas for validation instead of ad-hoc manual checks."

♻️ Suggested refactor
+import { z } from "zod";
+
 const ORIGIN_ACTOR_MAX_LENGTH = 128;
 const ORIGIN_ACTOR_ALLOWED = /^[a-z0-9 ._\-/():=;,+]+$/i;
+
+const originActorSchema = z
+  .string()
+  .trim()
+  .min(1)
+  .max(ORIGIN_ACTOR_MAX_LENGTH)
+  .regex(ORIGIN_ACTOR_ALLOWED)
+  .transform((value) => value.toLowerCase());

 export function extractOriginActor(request: Request): string {
   const raw =
     request.headers.get(ORIGIN_ACTOR_HEADER) ??
     new URL(request.url).searchParams.get(ORIGIN_ACTOR_QUERY);
-  if (!raw) return UNKNOWN_ORIGIN_ACTOR;
-
-  const trimmed = raw.trim();
-  if (!trimmed) return UNKNOWN_ORIGIN_ACTOR;
-  if (!ORIGIN_ACTOR_ALLOWED.test(trimmed)) return UNKNOWN_ORIGIN_ACTOR;
-
-  return trimmed.slice(0, ORIGIN_ACTOR_MAX_LENGTH).toLowerCase();
+  if (!raw) return UNKNOWN_ORIGIN_ACTOR;
+  const parsed = originActorSchema.safeParse(raw);
+  return parsed.success ? parsed.data : UNKNOWN_ORIGIN_ACTOR;
 }

Also applies to: 32-33, 49-59

🤖 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 `@packages/engine/src/lib/origin.ts` around lines 22 - 23, Replace the ad-hoc
origin-actor validation logic with a single zod schema (e.g., export const
originActorSchema =
z.string().trim().min(1).max(ORIGIN_ACTOR_MAX_LENGTH).regex(/.../).transform(s
=> s.toLowerCase())) in this module and use originActorSchema.safeParse/parse
wherever the current manual checks occur (the blocks around
ORIGIN_ACTOR_MAX_LENGTH and the checks at the ranges you noted). Ensure the
schema preserves the existing rules (trim, non-empty, regex, max length,
lowercase) and update the functions that perform validation to call
originActorSchema.safeParse and return/throw the same error shape as before.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@packages/engine/src/lib/origin.ts`:
- Around line 22-23: Replace the ad-hoc origin-actor validation logic with a
single zod schema (e.g., export const originActorSchema =
z.string().trim().min(1).max(ORIGIN_ACTOR_MAX_LENGTH).regex(/.../).transform(s
=> s.toLowerCase())) in this module and use originActorSchema.safeParse/parse
wherever the current manual checks occur (the blocks around
ORIGIN_ACTOR_MAX_LENGTH and the checks at the ranges you noted). Ensure the
schema preserves the existing rules (trim, non-empty, regex, max length,
lowercase) and update the functions that perform validation to call
originActorSchema.safeParse and return/throw the same error shape as before.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fd4046fa-7169-4508-aa84-af4d9613bda5

📥 Commits

Reviewing files that changed from the base of the PR and between 77f049c and e574d0d.

📒 Files selected for processing (15)
  • memory/workspace/.relay/state.json
  • packages/engine/src/engine.ts
  • packages/engine/src/env.ts
  • packages/engine/src/lib/__tests__/origin.test.ts
  • packages/engine/src/lib/origin.ts
  • packages/engine/src/lib/serverTelemetry.ts
  • packages/engine/src/middleware/logger.ts
  • packages/engine/src/ports/realtime.ts
  • packages/sdk-rust/src/agent.rs
  • packages/sdk-rust/src/client.rs
  • packages/sdk-rust/src/lib.rs
  • packages/sdk-rust/src/origin_actor.rs
  • packages/sdk-rust/src/relay.rs
  • packages/sdk-rust/src/ws.rs
  • packages/sdk-rust/tests/parity.rs

agent-relay-code Bot and others added 5 commits June 10, 2026 15:28
The name segment optionally carries harness version + model as
{harness}@{version}-{model} (e.g. claude-code@2.3.1-opus4.8) so cloud can
derive origin_actor_name/_version/_model. Add '@' to the allowed charset
(engine regex + sdk-rust is_allowed) and update the test fixtures from the
stale pre-path UA values (claude-code/2.3 …) to real path examples.

See cloud/plans/origin-actor.md (name sub-format).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@willwashburn willwashburn merged commit 68dc2f3 into main Jun 10, 2026
5 checks passed
@willwashburn willwashburn deleted the feat/origin-actor branch June 10, 2026 17:21
willwashburn added a commit that referenced this pull request Jun 26, 2026
The broker writes memory/workspace/.relay/state.json on every run, which
churned on PR branches (e.g. the "pr-reviewer fixes for #184" noise commits).
Ignore **/.relay/ and untrack the committed state file.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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