Skip to content

fix(triage): keep the policy's group order when the hub stores a pull request's mail (CL-12197) - #856

Merged
TheGreatAxios merged 2 commits into
mainfrom
cl-12197-keep-the-policys-group-order-when-the-hub-stores-a-pull
Nov 5, 2026
Merged

TheGreatAxios merged 2 commits into
mainfrom
cl-12197-keep-the-policys-group-order-when-the-hub-stores-a-pull

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An author belongs to the first policy group they match, in the file's order. The pack held groups as a mapping, and the hub stores each pull request's mail in a jsonb column, which re-sorts keys. A listed maintainer who is a GitHub contributor could then land in outside: code review was skipped and outsider steps applied.

  • The pack now lists its groups in the file's order ({ name, ...group }[]); the policy file format is unchanged.
  • The policy file is read into that list in the file's order. A stored pack with groups as a mapping is read only when it holds one group; with two or more, storage may have re-sorted them, so reading it fails closed.
  • Code review, action steps, the policy read route, team lookups and the policy export all read the list; the export writes the mapping back in list order.

Verification

  • New PostgreSQL test in apps/hub/src/manager-state.postgres.test.ts: a policy with approved (users) then outside (CONTRIBUTOR) goes through the hub's mail storage; a CONTRIBUTOR listed in approved is in approved and an outside step does not hold. It failed on main (outside) and passes now.
  • bun run check, bun run lint
  • bun --conditions=intx-src test ./packages/triage-contracts ./packages/triage-workflows ./packages/triage-manager ./tests/model ./tests/policy-corpus: 483 pass
  • apps/hub src/manager-state.postgres.test.ts and src/github on local Postgres: 106 pass

During a deploy, managers still on the old code fail closed on repositories whose policy defines groups: they report that the policy cannot be read and never assign a wrong group. Mail stored before this change whose policy has two or more groups also fails closed, until Triage runs on the pull request again.

No docs change: what people write and see is unchanged.

Closes CL-12197

@linear-code

linear-code Bot commented Nov 5, 2026

Copy link
Copy Markdown

CL-12197

@corbits-triage

corbits-triage Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

Notes:

  • added code matches a code pattern: apps/hub/src/github/policy-read.ts:40 empty-list-fallback: Invented fallback `?? []`; handle the missing value instead., packages/triage-contracts/src/check-pack.ts:1402 empty-list-fallback: Invented fallback `?? []`; handle the missing value instead., packages/triage-manager/src/actions/review.ts:62 empty-list-fallback: Invented fallback `?? []`; handle the missing value instead., packages/triage-workflows/src/logic/actions.ts:207 empty-list-fallback: Invented fallback `?? []`; handle the missing value instead.
  • Risk: medium (5 recently fixed files)

@corbits-triage corbits-triage Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No defects reported.

@TheGreatAxios
TheGreatAxios merged commit 853bc07 into main Nov 5, 2026
19 checks passed
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