Skip to content

feat(github): Generate the pull request Inbox rules from a decision table - #4395

Open
sentry-junior[bot] wants to merge 25 commits into
docs/inbox-kindsfrom
feat/inbox-kind-tables
Open

sentry-junior[bot] wants to merge 25 commits into
docs/inbox-kindsfrom
feat/inbox-kind-tables

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

design/inbox-kinds.md (#4390) now keeps only the contract for Inbox kinds. Its kind-table, table-checks, and table-links rules say that each kind's rules live in a decision table next to its owner's code, that the build checks each table, and that each table rule links to the design/ rules it serves and to a verification map claim. This PR builds that, so a kind's rules can be read and checked in one place instead of being spread across hand-written code. Stacked on #4390.

What changes

  • Each Inbox kind is a decision table in a *-kind.yaml file, next to the code of its owner:
    • packages/junior-github/src/webhooks/pull-request-kind.yaml (github:pull_request)
    • packages/junior-github/src/webhooks/merge-conflict-kind.yaml (github:merge_conflict)
    • packages/junior/src/chat/inbox-items/question-kind.yaml, notice-kind.yaml, and reply-kind.yaml
    • packages/junior/src/chat/todos/todo-kind.yaml
    • packages/junior/src/chat/automations/automation-kind.yaml
  • A table uses the FIRST hit policy and S-FEEL unary-test cells (-, v, v1, v2, not(v)). An input can have a description, which the generated code keeps as JSDoc.
  • scripts/inbox-kinds/ parses a table with YAML 1.2 and zod. For a table with code:, it generates TypeScript: Inputs, Command/Commands, an Outcome union that carries the rule ID, and decide(inputs). Only github:pull_request has code: (pull-request-kind.generated.ts). design/ gets no generated text.
  • Each rule names the design/ rule IDs that it serves. Each table names its verification map file (feature:), and each rule ID is a sub-feature there. The new sub-feature lines are in .agents/skills/verify-junior/features/github.md and inbox.md.
  • The inbox-kinds check runs in pnpm lint. It fails when:
    • the generated code drifts from its table, or a generated file has no table
    • a row is never the first match, over the product of the input domains
    • an input domain has unknown and no cell names it
    • the product is too big to enumerate (over 1,000,000)
    • a rule serves an ID that no design/*.md rule has
    • a rule ID is not a sub-feature in the table's verification map file
  • nextAction in pull-request-next-action.ts is a small adapter over decide(), with the requester as the viewer. The table also holds the reviewer rows for ref(inbox): Name each Inbox item by its subject kind and id #4164.
  • Gaps in design/inbox-kinds.md: the kind-table Gap now reads "Junior generates only the code of github:pull_request from its table. People write the code of the other kinds.", and the table-links Gap is gone.
  • The rules in design/github.md get IDs, from linked-account to github-truth, and the merged-or-closed rule splits into ended-silent and ready-to-merge. The pull request table rules serve them. The question and notice tables serve everyone-means-owner-audience from design/inbox.md.

Behavior changes

decide() gives what main's nextAction gives, for every value of mergeAccess, inMergeQueue, and baseOpen, including the requester's feedback, the draft review ask, and the mark-ready ask. That holds for every input that GitHub can produce: requestedReviewers is never set without reviewPending, and requesterFeedback is false on a draft.

The pr-review-again guards stay inside asked_again, as the code applies them today, and its description states them.

Nothing breaks for callers. The question and notice tables hold no code yet, so their new rows are the intent that people implement.

via @BYK.

--

View Session [Sentry]

…able

Add the Inbox kind generator and its check. Each design/inbox-kinds/*.yaml
table gives its kind's Inputs, Outcome, Commands, and decide() code, and
the rule list in its design file. inbox-kinds:check fails on drift, on a
row that can never be the first match, on an unknown input that no rule
names, and on a table too big to enumerate.

Pilot it on github:pull_request: nextAction in pull-request-action.ts now
calls the generated decide() with the requester as the viewer.

Co-Authored-By: BYK <[email protected]>
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 27, 2026 11:37pm UTC

Request Review

@sentry-junior
sentry-junior Bot added this pull request to stack #4391 November 25, 2026 23:39
The pull request table now has review_outcome (approved,
changes_requested, none) in place of a changes_requested flag, so a rule
can test for an approval. Behavior does not change.
sentry-junior Bot and others added 2 commits November 25, 2026 23:47
…n ask

Merge the new github:pull_request rules from docs/inbox-kinds into the
table: pr-merge-reviewer gives a still-requested reviewer "Ready to merge"
when it is approved, GitHub can merge it, and it is not a draft.
pr-review-again now tests that the requester has not approved and has not
commented or reviewed since Junior asked. The source already enforces
both, so the requester's next action does not change.

Record that github:pull_request is now a table in the kind-table Gap.

Co-Authored-By: BYK <[email protected]>
sentry-junior Bot and others added 3 commits November 25, 2026 23:58
The source already applies both pr-review-again guards when it computes
asked_again, so the table states them in that input's description
instead of in two extra inputs, and the merge state drops the
requesterApproved field. pr-merge-reviewer keeps the auto-merge-off
condition. Tables can now describe an input with { values, text }.

Co-Authored-By: BYK <[email protected]>
Each input value now has a phrase in its table, and the check renders each
rule's sentence from its rows, their outputs, and the phrases of the
commands, instead of a hand-written text field. It fails when a row names
a value or a command that has no phrase.

The tables now cover github:merge_conflict and the core kinds question,
notice, todo, reply, and automation. Their design files embed the
generated lists. Only github:pull_request names a code file, so code is
optional, and the check generates only the doc when it is missing. The
kind-table Gap now says that only that kind's code is generated.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 26, 2026 00:20
@sentry-junior
sentry-junior Bot requested a review from BYK November 26, 2026 00:20
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 26, 2026
Main moved nextAction into pull-request-next-action.ts and added the
requester's feedback, the draft review ask, and the mark-ready ask. The
github:pull_request table now covers them, and nextAction in
pull-request-next-action.ts is the adapter over decide().

Co-Authored-By: BYK <[email protected]>
sentry-junior Bot and others added 4 commits November 26, 2026 11:08
Each table now lives as a *-kind.yaml file next to the code of its owner
and generates only TypeScript. The design files keep intent only, so the
rule lists, their markers, and the phrases are gone. Each rule names the
design rules it serves and has a sub-feature in the verification map, and
the inbox-kinds check fails when either link is missing.

The github:pull_request table now matches nextAction, and pr-merge and
pr-merge-reviewer need a repository role that can merge. The question
and notice tables give an item with no assignee, or for Everyone, to
each viewer who can see it.

Co-Authored-By: BYK <[email protected]>
BYK added a commit that referenced this pull request Nov 26, 2026
The next-action sync gave the requester a "Ready to merge" item based
only on PR state: open, not a draft, auto-merge off, `mergeStateStatus`
`CLEAN`, no pending review, no change request. It never checked whether
the requester can merge on the repo. Two cases hit @BYK, whose role is
`read` on both repos. Neither repo requires a review, so GitHub reports
`CLEAN`:

- getsentry/shepherd#30: @BYK had approved it, so the item said that it
is approved and can merge.
- getsentry/herald#8: nobody had reviewed it, so the item said to review
it, then merge it.

Now `nextAction` takes a `mergeAccess` input for the requester, and a
requester without it gets no merge ask:

- Before an approval, the PR is in limbo, so Junior asks the requester
to review it on GitHub and they get "Review requested". After they
approve, the item closes. A person with write access merges it.
- An open merge item closes on the next sync with "Only a person with
write access can merge it." When the requester has not reviewed yet, as
on herald#8, the same sync asks for their review, and the item becomes
"Review requested".
- Junior knows a requester's access only through their linked GitHub
login. With no linked login, there is no merge ask.

The access comes from `GET
/repos/{owner}/{repo}/collaborators/{login}/permission`. It is read with
a metadata-only installation token and kept in the plugin cache for 10
minutes. This is the read that `loadRepositoryRole` already does. Both
now share one cache entry that holds GitHub's base `permission` (admin,
write, read, or none) and `role_name`. Write and admin can merge, and
maintain and custom roles map to one of them. I did not use the
requester's own token because the sync runs from webhooks and tasks that
have none. The endpoint answers for the login, so the App token is
enough. A sync reads the access only when the action would be merge or
the saved action is merge, so most recomputes read nothing. Nothing is
written to tables.

The Inbox label comes from the item title, so the dashboard needs no
change. `design/github.md` now states the write-access rule, in the text
that @BYK confirmed.

For #4395: the generated `github:pull_request` table
needs a new requester input, `mergeAccess`. It gates the merge rows in
the same way as `canMerge` in `pull-request-next-action.ts`. The sync
gets it from the cached permission read above.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3Aa0d5d9396e47d3c04ab85406 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/local%3Aweb%3Aa0d5d9396e47d3c04ab85406)
[[Sentry]](https://sentry.sentry.io/explore/conversations/local%3Aweb%3Aa0d5d9396e47d3c04ab85406/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

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

Stale Bugbot comment from a previous run.

@blacksmith-sh

This comment has been minimized.

…e cache, and match the To-do and Automation tables to their code
Co-Authored-By: BYK <[email protected]>

# Conflicts:
#	design/github.md
#	packages/junior-github/src/webhooks/installation-requests.ts
#	packages/junior-github/src/webhooks/pull-request-action.ts
#	packages/junior-github/src/webhooks/pull-request-next-action.ts
#	packages/junior-github/tests/pull-request-action-harness.ts
#	packages/junior/tests/integration/github-pull-request-ask.test.ts

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cb51a8c. Configure here.

Comment thread scripts/check-inbox-kinds.mjs Resolved
sentry-junior Bot and others added 2 commits November 27, 2026 13:31
Co-Authored-By: BYK <[email protected]>

# Conflicts:
#	design/github.md
#	packages/junior-github/src/webhooks/pull-request-next-action.ts

This branch was successfully deployed

1 active deployment
Preview – junior-docs — d04d40ce Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant