Skip to content

Bound describe output and describe types by name - #309

Merged
tnkuehne merged 1 commit into
feat/generic-type-declarationsfrom
feat/describe-budget
Nov 22, 2026
Merged

tnkuehne merged 1 commit into
feat/generic-type-declarationsfrom
feat/describe-budget

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

describe follows every type a selected method reaches. In a GraphQL API, an issue type reaches most of the schema: one method returned close to 200 types and several hundred KB, more than a caller can use.

What changes

  • Budget: a description includes the types its methods name directly, then the types those lead to, breadth first, while the description stays within 16 KB. Types that do not fit are listed by name in omittedTypes.
  • Types by name: describe takes types, documented type names as signatures and omittedTypes write them. Named types are always included and follow the same budget. Available in the API, the MCP describe tool and the CLI (widefleet services describe <app> --type <name>). Names are the documented ones, as types, uses and omittedTypes list them, such as Page<T> for a signature returning Page<Item>.
  • Errors: an unknown entrypoint is reported as such; unknown methods and types are named.
  • API query: methods and types are repeated parameters (methods[]=read&types[]=Page<T>). Type names can contain commas, so the comma-separated methods list is replaced.

Measured on generated APIs (GraphQL and OpenAPI), typical methods describe in 8 to 27 KB. A method whose own types are larger than the budget, such as a repository type of about 31 KB, still returns them in full.

Verification

  • pnpm check
  • pnpm exec vitest run apps/control-plane packages
  • RUN_CLI_TESTS=1 app-services CLI, documentation extraction and app-services integration tests, with budget and type selection cases
  • RUN_SERVICE_TESTS=1 runtime service tests (workerd and celld), including MCP describe by type, unknown types and an empty selection
  • The OpenAPI handler parses methods[] and types[], including names with commas
  • bash tools/cargo.sh clippy --workspace --all-targets -D warnings, fmt --all --check

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with both previous findings fixed and no new actionable issues found.

Summary

Adds bounded type descriptions and lets callers request documented types by name.

  • Method descriptions stop following every type into a large API schema.
  • Callers can ask for a documented type by name.

Both previous findings are fixed. No new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Selected methods and named types] --> B[Include all directly named types]
  B --> C[Visit further type references breadth first]
  C --> D{Type fits remaining budget?}
  D -->|Yes| E[Include type and visit its references]
  E --> C
  D -->|No| F[Add name to omittedTypes]
Loading

Reviews (3) · Last reviewed commit: "Bound describe output and describe types..." · Reviewed by Greptile

@tnkuehne
tnkuehne added this pull request to stack #310 November 22, 2026 18:46
Comment thread packages/app-runtime/src/mcp.ts Resolved
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs b4a0d3a Nov 22 2026, 07:34 PM

@tnkuehne
tnkuehne force-pushed the feat/describe-budget branch 2 times, most recently from a89285f to b4a0d3a Compare November 22, 2026 19:33
Following every type a method reaches made describe return most of a large
API: a GraphQL issue type reaches hundreds of types. A description now
includes the types its methods name directly, adds the types they lead to
breadth first up to 16 KB and names the rest in omittedTypes. Callers
describe those by name with the new types selection in the API, MCP tool
and CLI (--type). The API takes repeated methods[] and types[] parameters,
since type names can contain commas.
@tnkuehne
tnkuehne merged commit 02e5a97 into main Nov 22, 2026
17 checks passed
@tnkuehne
tnkuehne deleted the feat/describe-budget branch November 22, 2026 20:51
tnkuehne added a commit that referenced this pull request Nov 22, 2026
Depends on #308 and #309 (stack). The generated API documents within
limits only with generic declarations documented once (#308).

## What changes

**New `templates/linear` on Linear's GraphQL API.**
- Connects each signed-in user's Linear account (`read`, `write`) and
offers every query and mutation of `https://api.linear.app/graphql` as a
typed method with the same name: 422 methods today.
- `pnpm generate` (`scripts/generate.ts`) downloads Linear's published
schema from Linear's SDK repository and writes `src/api.ts` (types and
methods, with Linear's descriptions as TSDoc) and `src/schema.ts` (field
types and argument types for writing requests).
- `connectionStatus` reports setup and linking, as in the other
templates.

**Typed selections.**
- Methods returning objects take the fields to return. The result has
exactly the selected fields with their schema types; unknown fields,
missing nested selections and wrong argument types are compile errors
(`tests/types.ts`).
- `$args` passes arguments of nested fields: `{ comments: { $args: {
first: 5 }, nodes: { body: true } } }`. Fields with arguments are
methods of their type, so declaration files keep them.
- `$on` selects fields per concrete type of unions and interfaces;
results carry `__typename`.
- At runtime every argument travels as a GraphQL variable with the type
the schema declares. Selections and inputs that do not match the schema
fail before anything is asked or sent.
- `Selection<T>` is a plain mapped type: a conditional type made the
documentation extractor expand each selection in full.

**Which operations are offered.**
- `scripts/operations.ts` lists every mutation as `create`, `update` or
`delete`, or as not offered with a reason. Generation stops on a
mutation it does not list and on names it lists that the schema no
longer has.
- Not offered (57): Linear's sign-in and session flows, agent-app
(`actor=app`) operations, OAuth application management (`oauth:create`
scope), completing other providers' OAuth authorizations, release
pipeline access keys, Linear website operations without a user, and one
operation Linear marks internal.
- The queries `initiativeUpdate` and `projectUpdate` share their names
with mutations; they are `initiativeUpdateById` and `projectUpdateById`.
Generation fails on any other name collision.
- Operations needing Linear's `admin` scope stay offered: Linear does
not document which they are, and it answers them with an error.

**Approval levels.**
- Queries never ask. Mutations ask as the user's level says:
`all_changes`, `updates_and_deletions` (default: only creating runs at
once) or `none`.
- A question returns `input_required` with the mutation and its input,
shortened to the 4,096-character limit; `declined` does not run. Users
without a connection get `connection_required` instead of a question.
- Each user's level is kept in the app's D1 database. `approvalLevel`
reads it; `setApprovalLevel` asks for confirmation before asking less,
and takes effect at once for asking more.
- Users also choose the level on the app's page. The choice saves
immediately and returns to the saved level with a notice if saving
fails.

**Results and errors.** `connected` with `data`, or `linear_error` with
Linear's errors (its `userPresentableMessage` where present). HTTP 401
and GraphQL authentication errors give `reconnect_required`; HTTP 429
and `ratelimited` errors give `rate_limited` with `Retry-After`.
Questions have no `status` and other results no `resultType`, so callers
can branch on either field.

**Login.**
- Managed OAuth uses a registered Linear OAuth application (`provider:
"linear"`) with `https://api.linear.app` as its host and revocation at
`https://api.linear.app/oauth/revoke`. The CIMD client for Linear's MCP
server is no longer used.
- Without managed OAuth, `LINEAR_CLIENT_ID` and `LINEAR_CLIENT_SECRET`
as before. Better Auth's Linear provider reads the profile from the
`viewer` query.
- `widefleet.jsonc` declares only `https://api.linear.app`.

## Screenshots

Connected account page, before and after (390 and 1280 px). The page has
no dark theme, like the other template pages.

| Before | After |
| --- | --- |
| <img
src="https://gist.githubusercontent.com/tnkuehne/b18582250038507a8a0fb9ae4addf385/raw/7ee665d928b076e78793775af2273587026a7907/before-1280.png"
width="420"> | <img
src="https://gist.githubusercontent.com/tnkuehne/b18582250038507a8a0fb9ae4addf385/raw/7ee665d928b076e78793775af2273587026a7907/after-1280.png"
width="420"> |
| <img
src="https://gist.githubusercontent.com/tnkuehne/b18582250038507a8a0fb9ae4addf385/raw/7ee665d928b076e78793775af2273587026a7907/before-390.png"
width="200"> | <img
src="https://gist.githubusercontent.com/tnkuehne/b18582250038507a8a0fb9ae4addf385/raw/7ee665d928b076e78793775af2273587026a7907/after-390.png"
width="200"> |

Saving failed: the previous level returns with a notice.

<img
src="https://gist.githubusercontent.com/tnkuehne/b18582250038507a8a0fb9ae4addf385/raw/7ee665d928b076e78793775af2273587026a7907/after-failed-1280.png"
width="420">

## Tests

- `templates/linear/src/graphql.test.ts`: request writing (variables
with schema types, nested `$args`, `$on`, scalar fields with arguments)
and rejected selections and inputs, including prototype keys.
- `templates/linear/tests/app.test.ts` against a synthetic Linear OAuth
application and GraphQL API: the GraphQL requests sent, all three
approval levels, confirming and declining, per-user levels, the page's
level form and its origin check, Linear errors, rate limits, revoked
tokens, refresh and outages, user and issuer isolation, replayed
callbacks.
- `tests/types.ts`: result types of selections and the compile errors
above.
- `packages/app-runtime/src/template-oauth.test.ts`: Linear runs the
managed OAuth suite through the real broker with a registered client,
including revocation on disconnect.
- Documentation of the template with the CLI from #309: 1.8 MB, 824
types, 425 methods, no warnings; describing a typical method returns 15
to 29 KB.
- `pnpm check` and `pnpm exec vitest run` pass.
`runtime-errors.integration.test.ts` needs a built control plane, which
my checkout lacked; it passes in a checkout with one.

## Not covered by tests

- Calls against Linear's production API: the managed Linear OAuth
application is not configured in any installation yet.
- The page in a real browser session; the screenshots render the page's
HTML with synthetic values.












<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><a
href="https://app.greptile.com/api/retrigger?id=115175738&amp;sig=6a855b2f18090b4cbd2213678bc2aa7c4d12f908132ba0f489f126dbd5bb616c"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/-/switch-tenant?tenant=mendra&amp;next=%2Fwidefleet%2Fwidefleet%2Fpull%2F265&amp;utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5 <sup><img alt="Tier:
plus" title="Review tier: plus"
src="https://greptile-static-assets.s3.amazonaws.com/badges/effort-plus.svg?v=3"
height="12"></sup></h2>

<!-- greptile-impact-verdict --> The PR appears safe to merge, with one
non-blocking part of the previous optional-value finding still open.

<h2>Findings</h2>

1. <img alt="P2"
src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9"
align="top">&nbsp;**Optional values stop valid requests** <a
href="https://github.com/widefleet/widefleet/pull/265#discussion_r4659668631">▶</a>

<details open><summary><h3>Summary</h3></summary>

Adds a Linear template with generated GraphQL methods, personal OAuth
connections, typed field selections, and per-user approval levels.

- Linear calls now use schema-checked methods with typed field
selections.
- Linear mutations ask users first according to their saved approval
level.
- Each user can connect a Linear account for app calls.
- Linear appears as a deployable template in the catalog.
</details>

<details open><summary><h3>Diagram</h3></summary>

```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Generated Linear method] --> B[Write GraphQL request]
  B --> C{Mutation?}
  C -- No --> G[Load user token]
  C -- Yes --> D[Check connection and approval level]
  D --> E{Ask first?}
  E -- No --> G
  E -- Yes --> F{User answer}
  F -- Missing --> Q[Return input_required]
  F -- Decline --> R[Return declined]
  F -- Accept --> G
  G --> H[Call Linear GraphQL API]
  H --> I[Return selected data or error]
```
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (10) · Last reviewed commit: ["Ask before creates that
change existing
..."](2ca211e)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
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