Skip to content

feat(j5): report who started each turn - #515

Merged
Jacksondr5 merged 1 commit into
j5/mainfrom
j5/turn-started-analytics
Oct 10, 2026
Merged

Jacksondr5 merged 1 commit into
j5/mainfrom
j5/turn-started-analytics

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Problem

Product analytics could not see fleet activity. Upstream's client.turn.requested fires only for a message a person sends from a client, so a turn started by an agent's message, an Inbox reply, a spawn brief, a Crew notice, a playbook step or a scheduled task produced no "requested" event, and provider.turn.completed does not say who asked. Over the 14 days to 2026-10-10 the project recorded 4,066 completed turns against 1,219 requested ones. Part of #510 (the first of its events).

What changed

J5 records j5.turn.started for every run the orchestrator creates, with:

  • createdBy (user, agent, system) and creationSource (web, mobile, mcp, provider, server) of the message that asked for the turn;
  • scheduled, wake, firstTurn;
  • threadCreatedBy, threadCreationSource, crewSeat for the thread it runs in.

It reads the committed run.created event from the stored-event stream, the same way J5's other daemons do. That one hook covers every way a turn starts, including upstream's delegate_task and scheduled tasks, and a retried command counts once. Composer turns are included, so the share of turns a person did not start comes from one event.

Not counted: a message that steers a turn already running (no new run), and turns that start while the server is down (the tail starts at the current position on boot, so a restart never counts old turns again). Crew notices, playbook steps and handoff nudges all report as system/server and are not told apart.

The event carries enums and booleans only: no message text, no thread or run IDs, no names.

Verified against PostHog's dev project with a tagged dev server (#514): a composer turn, two follow-ups, an agent's spawn brief and an agent-to-agent message produced five events with the expected properties, no duplicates, and nothing reached the real project. In the same run client.turn.requested fired three times. A Crew seat, a scheduled task, a platform notice and a wake-up are covered by the unit test only.

UI changes

The privacy page's event list gains one item.

Before After
Usage data section before Usage data section after, with the turn-starting item

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior (backend changes ship with focused tests)
  • UI changes: before/after screenshots above, and a video for motion or interaction
  • Upstream-owned files: each one is recorded in FORK.md (case text and file-table row) in this PR. None edited: the recorder and its wiring are J5-owned files.
  • Upstream product: any change to what upstream's product does has a human decision linked above and a register entry in docs/j5/product/upstream.md. Upstream's events are unchanged; J5 sending its own events was decided in J5 analytics, later: UI-only moments and health measures #510.
  • Surfaces: entry points, clients, providers, contracts, reverse states, connection modes (see AGENTS.md). Server only. Every turn-start path goes through run.created, on every provider; no client or contract change.
  • Docs: definitions under docs/j5/product/ and user docs rewritten where this changes them. docs/user/telemetry.md and the privacy page.

Claude Opus 5.5 (1M context), Claude Code in J5 Code. Live check by GPT-6-Astra, Codex.

🤖 Generated with Claude Code

Upstream's client.turn.requested fires only for a message a person sends
from a client, so turns started by an agent's message, an Inbox reply, a
spawn brief, a Crew notice, a playbook step or a scheduled task were
invisible, and provider.turn.completed does not say who asked. J5 now
records j5.turn.started for every run the orchestrator creates, read
from the committed run.created event so a retried command counts once.

Part of #510

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@vercel

vercel Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
j5-code Ready Ready Preview Oct 10, 2026 4:36pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 9506d5fa-8255-45d5-8852-e9201e1f05fe


📥 Commits

Reviewing files that changed from the base of the PR and between b495cd2 and 9169dce.



📒 Files selected for processing (7)
  • apps/marketing/src/pages/privacy-policy.astro
  • apps/server/src/j5/a2a/mcp/orchestratorVerbs.live.test.ts
  • apps/server/src/j5/a2a/runtimeLayer.test.ts
  • apps/server/src/j5/a2a/runtimeLayer.ts
  • apps/server/src/j5/analytics/TurnAnalytics.test.ts
  • apps/server/src/j5/analytics/TurnAnalytics.ts
  • docs/user/telemetry.md


Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.




📝 Walkthrough
📝 Walkthrough

Walkthrough

The change adds turn-start analytics for created runs. It records creator and origin metadata, integrates event processing into the auxiliary runtime, adds tests, and updates telemetry descriptions in the privacy policy and user documentation.

Changes

Turn-start analytics

Layer / File(s) Summary
Record turn-start events
apps/server/src/j5/analytics/TurnAnalytics.ts, apps/server/src/j5/analytics/TurnAnalytics.test.ts
TurnAnalytics records metadata for run.created events and ignores other event types. The recorded properties include creator, source, scheduled-task status, thread origin, Crew-seat status, first-turn status, and wake status. Tests check these properties and verify that message text is not included.
Runtime wiring and telemetry disclosures
apps/server/src/j5/a2a/runtimeLayer.ts, apps/server/src/j5/a2a/runtimeLayer.test.ts, apps/server/src/j5/a2a/mcp/orchestratorVerbs.live.test.ts, apps/marketing/src/pages/privacy-policy.astro, docs/user/telemetry.md
The auxiliary runtime includes the turn analytics layer with its Crew-instance dependency. Runtime tests provide analytics test layers. The privacy policy and telemetry documentation describe turn-start fields.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant EventStore
  participant TurnAnalytics
  participant Projections
  participant AnalyticsService
  EventStore->>TurnAnalytics: Stream stored event
  TurnAnalytics->>Projections: Read run message and thread metadata
  Projections-->>TurnAnalytics: Return creator and origin markers
  TurnAnalytics->>AnalyticsService: Record j5.turn.started properties
Loading


Merge Risk: ⚪ Minimal · up to 9169d

This adds turn-start analytics events and updates the matching telemetry disclosures. No concrete defect was found, so the risk of merging is low.

Pre-merge checks | Passed 4
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the primary change: reporting who started each turn.
Description check Passed The description is detailed and covers the problem, implementation, tests, UI evidence, checklist, limitations, and documentation. It omits a dedicated Upstream impact section, although privacy-policy…

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@Jacksondr5
Jacksondr5 merged commit f75195f into j5/main Oct 10, 2026
37 checks passed
@Jacksondr5
Jacksondr5 deleted the j5/turn-started-analytics branch October 10, 2026 16:53
Jacksondr5 added a commit that referenced this pull request Nov 23, 2026

This branch was successfully deployed

1 active deployment
Preview — 9169dce2 Deployed Oct 10, 2026 by vercel[bot]
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