Skip to content

Document listing audiences and what rule-based ones accept - #17

Open
TeakBuilds wants to merge 4 commits into
mainfrom
feat/c-2818-audience-listing
Open

TeakBuilds wants to merge 4 commits into
mainfrom
feat/c-2818-audience-listing

Conversation

@TeakBuilds

@TeakBuilds TeakBuilds commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Part of C-2818

Audiences page and openapi/v2_audiences.yaml:

  • New Listing section for GET /v2/audiences: every audience except system ones, with limit, after, paging.
  • Reading and updating cover every audience except system ones, which stay a 404 on both; players is for list audiences only.
  • Says mParticle overwrites the name and description of its audiences on its next update.
  • Says upload_state, matched_count and unmatched_count describe list audiences only, and that a response doesn't mark which audiences those are.
  • Page retitled "Audience Management", in both navs and the index too.

The API change is GoCarrot/Carrot#2922; merge this once that is deployed.

Not rendered: I didn't build the page.

Checked at 869e751: a ruby -ryaml one-liner that runs YAML.load_file on openapi/v2_audiences.yaml and looks up every #/components/... ref → parsed; 9 distinct refs, unresolved: [].

🤖 Generated with Claude Code

Adds the GET /v2/audiences listing with its paging, widens reading and
updating to every audience, and says which fields and parameters are for
list audiences only.

<human-claude-interaction-log>
<human>/worker teak-md 2818 GoCarrot/Carrot feat/c-2818-audience-listing alex teak-md-carrot-worker-c-2818 #teak-md-carrot-issue-c-2818 https://linear.app/teakio/issue/C-2818</human>
<claude>Read C-2818, planned the Carrot change plus this docs change, and got the plan approved.</claude>
<teak-md-pm>lgtm, go. decided: no type marker. Adding a key later is additive and breaks no one, but removing one is a breaking change, so we leave it out until someone asks. The docs page says which fields describe list audiences only. Keep the split you named: one Carrot PR with two commits, plus the docs PR.</teak-md-pm>
<claude>Updated the audiences page, nav title and OpenAPI spec to match the Carrot change.</claude>
</human-claude-interaction-log>

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

Copy link
Copy Markdown
Contributor Author

[teak-md-server-api-docs-docs-c-2818] Docs cold read: findings

Cold-read takeaway: you can now list, read, rename and archive any of your Audiences, only list Audiences take players, and you page until paging is gone. All of that restates cleanly. What I couldn't work out from the page is which Audiences in a response are list Audiences.

1. A reader can't act on the list / non-list split (v2_audiences.adoc, The Audience Object, L272–280; also L5, L165, L199; same gap in openapi/v2_audiences.yaml, Audience schema)

  • Text: "upload_state, matched_count and unmatched_count describe list Audiences only." / "Ignore it on other Audiences."
  • What goes wrong: Listing returns both kinds together, and the documented keys include no kind. Per the facts, a new rule-based Audience shows upload_state "ready" with null counts, so it looks like a usable list state. null also means "not counted yet". Someone iterating the listing can't tell which entries to ignore upload_state on or which will accept players.
  • Required: the page either says how to tell the kind from a response (only if there is a reliable way) or says plainly that the response doesn't identify it, so the reader knows not to infer it from these three keys and what to rely on instead.

2. Note: players: null on a non-list Audience (Updating, L165)

  • Text: "Only a list Audience takes players. Sending it to any other Audience is a validation error, and nothing changes."
  • What gets missed: the facts show null and [] also get the 422. The archived row on the same page says "Sending null is the same as leaving the parameter out", so a client that serializes unset fields as null could expect the same here.
  • Required: it's clear that including the players key at all, even as null or empty, is the error.

3. Note: the old page name survives where readers navigate (files the PR didn't touch)

  • modules/ROOT/partials/nav-server-api.adoc L5 still says "Audience List Management". teak-usage/modules/ROOT/nav.adoc L31 includes that partial (grep of the local checkout).
  • modules/ROOT/pages/index.adoc says "Audience List Management + Create and update Audiences from a list of player IDs, to send Schedules to."
  • What gets missed: someone looking for listing or rule-based Audiences sees a list-only, create/update-only entry.
  • Required: both match the new title and scope. The rename is this PR's, so I'd take it here, but PM's call.

4. Note: Listing wording (L18, L40)

  • "in order of id" doesn't give the direction; the facts show ascending.
  • "The number of Audiences to return" is a maximum (limit=5000 over 1005 returned 1000; limit=2 over 5 ended with a page of 1).

For the reviewer, not findings: the facts don't cover the listing's lower clamp (limit=0), unknown game_id 404, or 429 / "5 requests per second".

Evidence: read v2_audiences.adoc, nav.adoc and the docs diff (incl. the openapi yaml) as source at 4a936b1 via git show / git diff, no render. No web searches: the new claims are about Teak's own API, with no vendor version or platform claim. No internal-doc claims to repro-match.

hold: the page says to treat list and other Audiences differently but never says how a reader tells them apart in a response

Also spells out that sending the players key at all is the error on other
audiences, that listing is ascending and limit is a maximum, and renames
the page in the nav partial and the index.

<human-claude-interaction-log>
<teak-md-server-api-docs-docs-c-2818>docs findings posted on server-api-docs#17 (read at 4a936b1): hold: the page says to treat list and other Audiences differently but never says how a reader tells them apart in a response</teak-md-server-api-docs-docs-c-2818>
<claude>Proposed taking all four findings.</claude>
<teak-md-pm>lgtm, go.</teak-md-pm>
<claude>Made the wording changes to the page and OpenAPI spec and renamed the leftover nav and index entries.</claude>
</human-claude-interaction-log>

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

Copy link
Copy Markdown
Contributor Author

[teak-md-server-api-docs-docs-c-2818] Docs re-check at f4ae2b5: hold cleared, two notes

Fixed: the page now says responses don't identify list Audiences and what to rely on; the players key with null / empty array is covered; the old title is gone from the nav partial and index (git grep -i 'audience list management' f4ae2b5 -- modules openapi: no hits); ascending order and "maximum" are in.

Notes:

  • v2_audiences.adoc, The Audience Object: "...carries Audience objects with these keys." The new "The response doesn't say whether..." paragraph now sits between that lead-in and the key list, so "these keys" points past it. Required: the lead-in runs straight into the list.
  • index.adoc: "List, read, create and update Audiences, including creating them from a list of player IDs, to send Schedules to." "including creating them from a list" suggests the API can also create Audiences some other way; the page says it creates list Audiences. Required: the blurb doesn't imply another kind of creation.

For the reviewer: "List Audiences are the ones you create through this API or upload as a CSV in the Dashboard" is an exhaustive claim. The worker's grep fact (two callers: API save, and dashboard uploaded-file or column-mapped upload) is consistent with it; I didn't check code.

Evidence: read the 4a936b1..f4ae2b5 diff and the changed sections at f4ae2b5 as source, no render. No web searches (no vendor version or platform claims).

yield

… blurb

<human-claude-interaction-log>
<teak-md-server-api-docs-docs-c-2818>docs re-check at f4ae2b5: hold cleared, two notes (no re-check needed for them) · yield</teak-md-server-api-docs-docs-c-2818>
<claude>Proposed taking both notes.</claude>
<teak-md-pm>lgtm, go.</teak-md-pm>
<claude>Moved the list-audience paragraph below the key list and reworded the index blurb.</claude>
</human-claude-interaction-log>

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

Copy link
Copy Markdown
Contributor Author

[teak-md-carrot-reviewer-c-2818] APPROVED at 7dd494b (with notes)

I checked the docs against Carrot#2922 at 710e84484f. Each claim below matches the code.

repro

  • Listing order: the request spec asserts listed_ids == ids in creation order, and the controller passes sort_options: [[:id, :asc, true]] → ascending id
  • System audiences excluded, archived included: the controller scope is @game.audiences.where(system_use: false) with no archived filter, and the spec lists an archived audience and leaves out a system_use one
  • limit: a runner call to PagedFetch with nil / "0" / "-5" / "2" → default / 1 / 1 / 2; the spec's limit=5000 case returns 1000 → "clamped to [1, 1000], defaults to 1,000" holds
  • paging on a full last page, followed by an empty page: the spec "when the last page is exactly full" → [ids, []]
  • paging.next with no game_id/secret_key: the spec asserts "/v2/audiences?limit=2&after=…"
  • 404 game_id / 403 / 429: read ApiControllerBase#find_game, its auth check, and render_rate_limit_exceeded! (status: rate_limit, 5 per second from requests_per_second)
  • players key with null or [] on a non-list Audience → 422: the spec "a refused player list" runs for [{id}], [] and nil, and the controller maps null to []
  • matched/unmatched null on other Audiences: upload_key is targeting_spec['file'], which is nil without an upload, so no summary is found
  • "List Audiences are the ones you create through this API or upload as a CSV in the Dashboard": the only callers of set_manual_list / set_mapped_upload are the API save and the dashboard upload
  • openapi parses with Ruby YAML, and every #/components/... ref resolves

Findings

  1. minor: the same note as on Carrot#2922. An mParticle Audience's name and description are rewritten on each mParticle sync (Mparticle::AudienceSubscription#update), so a rename through this API doesn't stick. If Carrot keeps accepting the rename, one sentence in Updating saying so would save a confused support ticket.

The page is unrendered (the worker's npx render was denied). Nothing in the diff uses unusual asciidoc.

<human-claude-interaction-log>
<teak-md-carrot-reviewer-c-2818>APPROVED at 7dd494b (with notes). minor: an mParticle Audience's name and description are rewritten on each mParticle sync, so a rename through this API doesn't stick. One sentence in Updating saying so would save a confused support ticket.</teak-md-carrot-reviewer-c-2818>
<claude>Proposed taking it as a docs sentence rather than refusing the rename.</claude>
<teak-md-pm>lgtm, go.</teak-md-pm>
<claude>Added the sentence to the Updating section and the OpenAPI patch description.</claude>
</human-claude-interaction-log>

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

Copy link
Copy Markdown
Contributor Author

[teak-md-carrot-reviewer-c-2818] delta: clear at 869e751

The delta is 7dd494b..869e751: one commit, and it carries the interaction log. It adds the mParticle sentence to the Updating section of the page and to the openapi patch description. Both match the code.

repro: read app/services/mparticle/audience_subscription.rb #update at Carrot 710e84484f → it sets audience.name = "mParticle: #{audience_name}" and audience.description = audience_description on mParticle's update action, so the sentence holds

@TeakBuilds
TeakBuilds marked this pull request as ready for review December 3, 2026 21:01
@TeakBuilds
TeakBuilds requested a review from AlexSc December 3, 2026 21:01
@TeakBuilds TeakBuilds added the review:medium Review within a couple of days. Normal priority. label Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:medium Review within a couple of days. Normal priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant