Skip to content

[AI-4104] Activity: a phone settings read counts as a dashboard read - #2571

Merged
kanat merged 8 commits into
mainfrom
kanat/ai-4104-phone-read-area
Nov 26, 2026
Merged

kanat merged 8 commits into
mainfrom
kanat/ai-4104-phone-read-area

Conversation

@kanat

@kanat kanat commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

What

A GET of any route in an area that is a funnel step (activity.Steps) is now counted under dashboard_reads. Writes and calls keep their area. A search of the sessions (POST /v1/agents/sessions/query) is a read too, so it is counted under dashboard_reads as well. One rule in areaOf replaces the special case that already did this for /v1/agents/configs, which is now an ordinary table entry.

dashboard_reads now holds every client's reads of a step area. The client field tells the dashboard from the SDK, the CLI and the API (see the updated description in ops_activity.go and openapi.yaml).

Why

/v1/phone was mapped to phone_sms whatever the method. One GET /v1/phone/sandbox from a dashboard moved an organization's furthest_step from conversations to phone_sms. Any organization that only opened the phone page in Volt looked as if it had reached the last step. The other step areas had the same defect (GET /v1/agents/skills moved an organization to agent_setup, GET /v1/agents/sessions/{id} to conversations).

Route to area

Request Before After
GET /v1/phone/sandbox, /numbers, /numbers/available, /vendors, /trunks, /use-cases, /opt-outs, /business-profile phone_sms dashboard_reads
PUT /v1/phone/sandbox/recipients, POST /v1/phone/numbers, POST /v1/phone/calls, trunk writes phone_sms phone_sms
GET /v1/agents/channels, /campaigns phone_sms dashboard_reads
POST /v1/agents/channels, POST /v1/agents/campaigns/{id}/launch phone_sms phone_sms
GET /v1/agents/skills, /knowledge/*, /models, /voices, /provider-keys, /router/configs, /{modality}/routes agent_setup dashboard_reads
GET /v1/agents/sessions/{id}, /conversations/{cid}/messages conversations dashboard_reads
POST /v1/agents/sessions/query conversations dashboard_reads
GET /v1/agents/calls, /calls/{id}/transcript voice_video dashboard_reads
GET /v1/agents/socket, /v1/agents/sessions/{id}/events, /v1/dispatch (they open a socket) unchanged unchanged
/v1/phone/hooks/*, /answer, /status, /machine hooks_in hooks_in
GETs of areas that are no step (model_api, connectors, scheduling, evals, data) unchanged unchanged

Not in this PR

POST /v1/agents/calls/reviews/analysis stays in its area, voice_video. It runs an analysis, so it is a call, not a read.

Tests

  • Unit (AreaSuite): phone GETs vs writes and calls, other step areas, socket GETs, hooks control, non-step areas control, and the sessions search (TestASearchOfTheSessionsIsADashboardReadAndAnyOtherSessionPostIsAConversation).
  • Integration (ActivitySuite): TestASessionSearchIsADashboardReadNotAConversation: a dashboard's sessions search is counted as dashboard_reads, and conversations stays at 0.
  • Integration: the app's counts after real GET /v1/phone/sandbox and /numbers (dashboard_reads) and a sandbox-recipients write and a number buy (phone_sms); an organization that set an agent up and then only read phone settings stays at agent_setup with no phone_sms area.
  • Existing tests that counted a GET under its old area (/v1/agents/skills, a forwarded GET of a session, the router start-up check) now expect dashboard_reads.
  • Only GET counts as a read: a HEAD is not counted, because the router answers HEAD with 405.
  • Mutation checks: 15 mutants of activity.go killed by AreaSuite; the read rule also by the integration tests.

🤖 Generated with Claude Code

kanat and others added 2 commits November 26, 2026 14:28
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: GO

[security R1] Security review of the activity area mapping (areaOf), at bcb0eb6.

No findings.

What I checked:

  • Who picks the area. The area comes from the route pattern that was matched and the method that was served. The router has no method-override middleware. A trailing slash, a double slash, an encoded segment, HEAD and OPTIONS are all refused with 404 or 405 and counted as other, the same as on base. A query string matches the same pattern. A caller cannot have a write run while it is counted as a read. I checked this with a scratch test on the real mux.
  • Another organization. The app and organization come only from the auth context. X-Stream-Client changes only the client column. This PR does not change that.
  • Requests with no app. Recorder.Record still drops them. Hooks keep the area their handler noted. hooks_in is not a step, so a GET of a hook stays hooks_in.
  • Who reads the area. Only staff analytics read it: the daily digest, /v1/ops/activity and /v1/ops/orgs/{org_id}/activity. Billing meters, the quota (it has its own rule on the method), spend limits and telephony suspension do not read it. A wrong area cannot change money or access.
  • GETs in step areas. Walking the spec, all of them are reads except the three sockets the PR lists. No other route in a step area opens a socket.
  • Error text in the diff. None, and no ids or secrets.
  • Mutations. I removed each new guard in turn (the socket exception, the step check, the read rule, one socket route) and a test failed each time (4 of 4). The activity integration suites pass on a separate test DB.

Not a security issue, noted for correctness: the router answers HEAD with 405 on every route, so the HEAD branch of isRead never runs in production.

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: NO-GO

Reviewed bcb0eb65b merged onto main e4e11b69b (main has not moved). CI on the head: CodeQL, Analyze, labeler and GitGuardian pass. go and integration are skipped because the PR is a draft; they run at gh pr ready.

[Should fix] R1.3 acceleration/internal/api/ops_activity.go:222-225 (not in the diff). The published definitions say "dashboard_reads alone is opening the dashboard's Agents tab", and say API calls leave out dashboard_reads because "Those are the dashboard's own reads". With this PR, dashboard_reads holds every client's read of a step area: 54 GET operations move there from any client (for example an SDK's GET /v1/agents/sessions/{id}, and the SDK/API GETs that TestAnSDKNamingItsReleaseIsCountedAsTheSDK now counts there). The text is now false, and "API calls" stops counting SDK, CLI and API reads without saying so. Fix: say what the area now holds (reads of a step area from any client; with client dashboard, the dashboard's own reads). Then run go run ./cmd/openapi and regenerate the clients.

[Question] R1.4 Same lines. Should "API calls" keep counting reads by clients other than the dashboard (readers would filter dashboard_reads by client != dashboard), or leave them out as it does now? The owner of the activity dashboard decides. This goes to a ticket, not this PR.

Checked and sound:

  • I dumped every operation's area on base and on head (306 operations each). 54 change, and all of them are GETs moving to dashboard_reads. I read each one's operation doc. None streams, starts work or is a vendor callback (the library voice preview fetches the vendor's published sample and synthesises nothing). After the PR, the only GETs left in a step area are the three socket routes. The hand-routed GETs are in areas that are no step, or in hooks_in (/v1/phone/answer).
  • The hooks_in operations are the same on base and head (14 of them). internal/activity (area and step names) is untouched. The configs special case became a table entry, and every configs operation keeps its area.
  • The 3 existing tests changed for the right reason. GET skills now counts under dashboard_reads with the same counts. The forwarded-session test still counts the POST once in conversations, and still fails if the forwarded GET is counted twice.
  • Mutations: 19 checked, 17 killed. That includes both call-site mutants (areaOf(POST|GET, ...) in recordActivity), which the integration suites kill. The 2 that survive are equivalent: OPTIONS counted as a read (the router answers OPTIONS with 405), and a socket check by prefix instead of exact match (no route sits below a socket route).
  • Tests on the merged tree: unit ./internal/api/... ./internal/activity/...; integration Activity, OrganizationActivity, OpsActivity(+Funded), ActivityKey, Posture committed-spec and RouterStart activity. All pass. vet and gofmt are clean.

{"/v1/prices", activity.AreaDashboardReads},
{"/v1/teams", activity.AreaDashboardReads},

{"/v1/agents/configs", activity.AreaAgentSetup},

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[Should fix] R1.1 POST /v1/agents/sessions/query (querySessions, session_query.go:662-664) only lists and searches sessions, but it is still counted under conversations. A search from the dashboard or an SDK moves furthest_step to conversations and adds a conversations day. The decision for this task is that it is a dashboard read (the PR body's "Not in this PR" leaves it out; POST /v1/agents/calls/reviews/analysis stays voice_video). Fix: add {"/v1/agents/sessions/query", activity.AreaDashboardReads}, in the dashboard block, before /v1/agents/sessions. Add these rows to AreaSuite. I checked them: they fail on this head (actual conversations) and pass with the entry.

s.Equal(activity.AreaDashboardReads, areaOf(http.MethodPost, "/v1/agents/sessions/query"))
s.Equal(activity.AreaConversations, areaOf(http.MethodPost, "/v1/agents/sessions"))
s.Equal(activity.AreaConversations, areaOf(http.MethodPost, "/v1/agents/sessions/{id}/say"))

Also add one integration row (a dashboard POST /v1/agents/sessions/query counts under dashboard_reads and adds nothing to conversations), and update the README note and the PR body.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 6fa7c4a: AreaSuite.TestASearchOfTheSessionsIsADashboardReadAndAnyOtherSessionPostIsAConversation (unit) and ActivitySuite.TestASessionSearchIsADashboardReadNotAConversation (integration). Without the table entry both fail (unit: expected dashboard_reads, actual conversations).

Comment thread acceleration/README.md Outdated
(refused when it errored). A signed MCP event counts under `hooks_in`, and a signed 10DLC report
on an app's campaign under `phone_sms`.

A GET of a route in one of those steps counts under `dashboard_reads`: it shows what was set up or

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[Should fix] R1.2 "one of those steps" points back to nothing: the steps are listed only in the next paragraph. "does not move furthest_step" is false: an organization with only these reads goes from none to dashboard_reads, which is Steps[0] (activity/steps.go:13). Fix: move the note below the furthest_step paragraph, and say a read "moves furthest_step no further than dashboard_reads". Add POST /v1/agents/sessions/query (R1.1).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 5b6cafa: the note now sits after the furthest_step paragraph, says it moves furthest_step no further than dashboard_reads, and names POST /v1/agents/sessions/query. Text-only; no test.

Comment thread acceleration/internal/api/activity.go Outdated

// isRead reports whether the method only reads state.
func isRead(method string) bool {
return method == http.MethodGet || method == http.MethodHead

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[Nit] R1.5 The HEAD branch never runs in production. Routes are registered as GET ..., and no GetHead middleware exists (grep for GetHead/MethodHead in internal/api and cmd finds none). So a HEAD gets a 405, and routeLabel gives the unmatched route, which counts as other. The security review's mux probe shows the same. The HEAD cases in AreaSuite test a path the router never takes. Ticket.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 17acfd7: isRead is GET only and the HEAD unit cases are gone (TestAReadOfThePhoneIsADashboardReadAndAWriteOrACallIsPhoneUse now runs GET). Dead-code removal; AreaSuite passes.

kanat and others added 5 commits November 26, 2026 15:00
…tion

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…thest_step no further than itself

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kanat

kanat commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

R1.3 fixed in 8ddda05: the two ops-activity definitions now say dashboard_reads holds a step area read from any client and a session search, and that client=dashboard picks the dashboard own. openapi.yaml regenerated; TestPostureSuite/TestTheCommittedSpecIsRenderedFromTheOperations fails when the description alone is reverted. Go, plugin and Ruby generators produce no diff (only the spec carries the text).

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: NO-GO

Delta review of e3a268c (old head bcb0eb6), merged onto main c351776 (the head already contains that merge; git show --remerge-diff e3a268cd6 is empty, no conflicts).

Prior findings

  • R1.1 fixed. {"/v1/agents/sessions/query", dashboard_reads} is in the dashboard block, before /v1/agents/sessions (activity.go:42). Mutation 1: entry removed -> TestAreaSuite fails (expected dashboard_reads, actual conversations) and ActivitySuite.TestASessionSearchIsADashboardReadNotAConversation fails. Mutation 2: entry moved below /v1/agents/sessions -> TestAreaSuite fails the same way. Both restored.
  • R1.2 fixed. README note now follows the furthest_step paragraph (README.md:2311-2315), says "no further than dashboard_reads", names sessions/query; matches areaOf.
  • R1.3 / R1.4 fixed in intent, one new gap in the new text (see N1). Spec regenerated: TestPostureSuite/TestTheCommittedSpecIsRenderedFromTheOperations passes; mutation 3 (one word changed in the description, no regeneration) fails it. Restored.
  • R1.5 fixed. isRead is GET only (activity.go:120), HEAD unit rows gone. No mutation possible: the HEAD branch was unreachable (no GetHead middleware, no HEAD route).

Areas for all 306 operations on the new head (delta-1-areas-head.txt) vs reviewer-1-areas-head.txt: exactly one line moved, POST /v1/agents/sessions/query conversations -> dashboard_reads.

Client regeneration: not needed. The only changed text is the description of listActivity (GET /v1/ops/activity, a staff operation, not x-client-accessible). The old text appears in no file but openapi.yaml. listActivity appears only in sdks/rust/src/operations.rs (summary and query struct, no description) and sdks/ruby/.../spec.rb (method, path, no text); it is absent from the Go, plugins/stream, Swift, Kotlin, Dart, JS, .NET and PHP outputs. uv run sdks/swift/generate.py --check on the head: "client up to date". Kotlin and Swift generate only client-accessible operations, so a staff description cannot move them. (Dart/.NET/PHP generators not run; they hold no listActivity.)

New finding
N1 [Should fix] acceleration/internal/api/ops_activity.go:223-224 — the new text says "dashboard_reads alone is only reading: a GET of a route in a step area, or a search of the sessions". That is not what the area holds. areaPrefixes puts whole resources in dashboard_reads for every method, so 12 writes land there too (dump delta-1-areas-head.txt): PUT /v1/policies/app, /organization, /users/{user_id}; DELETE /v1/policies/users/{user_id}; PATCH /v1/settings/app; POST/PATCH/DELETE on /v1/spend/limits and its grants and usage/reset; and POST /v1/audit/query. A reader who counts by this definition is told a policy or spend-limit edit is not in the area. The "API calls" bullet has the same gap ("Those are reads of a step area from any client"). Fix: say what the area holds, for example "dashboard_reads alone is the dashboard's own pages: a GET of a route in a step area, a search of the sessions or the audit log, and an edit of the policies, settings or spend limits, from any client." Keep the client sentence. Then go run ./cmd/openapi; no client file holds this text, so nothing else regenerates. (This sentence is in a hunk the delta wrote; the omission itself dates from base, where the text was just as loose.)

Suites (head, own DB, -p 1): go vet clean; unit ./internal/api/... ./internal/activity/... pass; integration TestActivitySuite, TestAreaSuite, TestActivityKeySuite, TestOpsActivitySuite, TestOpsActivityFundedSuite, TestOrganizationActivitySuite, TestPostureSuite pass.
CI: PR is a draft; every check "skipping" (gh pr checks). Not a failure.
Mutations: 3 checked, 0 survived. The earlier equivalent survivors (OPTIONS, socket check by prefix) are unchanged.
Unverified: Dart, .NET, PHP generators not run (reasoned from grep: no listActivity in their outputs).

"These definitions are the router's; count a dashboard by them:\n\n" +
"- Tried: at least one request answered in agent_setup or a later step, a step in steps other than " +
"dashboard_reads. dashboard_reads alone is opening the dashboard's Agents tab.\n" +
"dashboard_reads. dashboard_reads alone is only reading: a GET of a route in a step area, or a " +

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Should fix (N1): this says dashboard_reads is only reading, but the area also holds 12 writes (PUT/DELETE /v1/policies/*, PATCH /v1/settings/app, POST/PATCH/DELETE under /v1/spend/limits, POST /v1/audit/query). Say what the area holds: the dashboard's own pages, a GET of a route in a step area, a search of the sessions, and edits of policies, settings and spend limits, from any client. Then go run ./cmd/openapi; no client file carries this text.

@kanat kanat Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 854e453: TestPostureSuite/TestTheCommittedSpecIsRenderedFromTheOperations fails when the Go text is reverted to the old wording (mutation, both bullets checked), and passes on the regenerated api/openapi.yaml. Both bullets now name the dashboard's own pages, reads and edits of policies, settings and spend limits, from any client; the client field still tells the dashboard apart. Thread left open for the delta reviewer.

R2.1: the text said dashboard_reads alone is only reads. The area also holds
the dashboard's pages and edits of policies, settings and spend limits, from
any client. Regenerated api/openapi.yaml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: GO

Delta review of 854e453 (old head e3a268c), merged onto main c351776 (the head contains it: git merge-base --is-ancestor origin/main HEAD).

Prior findings

  • R2.1 fixed. git diff e3a268cd6 854e4535f --stat: only acceleration/internal/api/ops_activity.go (11 lines) and acceleration/api/openapi.yaml (4 lines). The new text for dashboard_reads: "the dashboard's own pages, a GET of a route in a step area, a search of the sessions or the audit log, and edits of policies, settings and spend limits, from any client". Checked against the code: areaPrefixes (activity.go:37-50) puts /v1/stats, /v1/{modality}/stats, providers, turns/stats, agents/logs, account, usage, prices, teams (the pages), /v1/agents/sessions/query and /v1/audit (searches), /v1/policies, /v1/settings and /v1/spend (edits) in dashboard_reads for every method; areaOf (activity.go:101-113) sends a GET of a step-area route there too. delta-1-areas-head.txt lists the 12 writes in the area (policies PUT/DELETE, settings PATCH, spend limits POST/PATCH/DELETE, POST /v1/audit/query), all covered by the three nouns; no other non-GET operation is in the area except sessions/query (covered by "a search of the sessions"). The API calls bullet now says dashboard_reads is left out and what it holds, hooks_in/webhooks_out are named as vendors' hooks and the router's deliveries, and the client sentence is kept. Reads plainly.
  • Committed spec: TestPostureSuite/TestTheCommittedSpecIsRenderedFromTheOperations passes on head. Mutations (Go text changed, openapi.yaml kept): M1 whole file reverted to e3a268c fails it; M2 "or the audit log" dropped fails it; M3 "reads and edits above, from any client" in the API calls bullet shortened fails it. Restored; passes again.
  • "from from to to" (ops_activity.go:222): the parameter names from and to ("on each UTC day from from to to"). Correct, pre-existing in base, unchanged by this delta; nothing needed.

New findings: none.
Suites on head (own DB delta2571b, -p 1): go vet ./... clean; integration TestPostureSuite|TestOpsActivity*|TestAreaSuite|TestActivitySuite pass; unit ./internal/api/... ./internal/activity/... pass.
CI: draft, gh pr checks: CodeQL/changes/dart/go/kotlin skipping; GitGuardian and labeler pass. Not a failure.
Mutations: 3 checked, 0 survived.
Unverified: client regeneration not rerun (delta-1 found no client file carries the text; this delta changes the same description only).
Cleanup: worktree removed, test DB and redis dropped.

@kanat
kanat marked this pull request as ready for review November 26, 2026 20:31
@kanat
kanat merged commit a02d0c7 into main Nov 26, 2026
33 of 34 checks passed
@kanat
kanat deleted the kanat/ai-4104-phone-read-area branch November 26, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant