Skip to content

PRD policy: templates, gate, and org defaults - #1

Draft
koushik-databrain wants to merge 1 commit into
databrainhq:mainfrom
koushik-databrain:chore/prd-policy
Draft

koushik-databrain wants to merge 1 commit into
databrainhq:mainfrom
koushik-databrain:chore/prd-policy

Conversation

@koushik-databrain

@koushik-databrain koushik-databrain commented Aug 25, 2026

Copy link
Copy Markdown

Makes the PRD policy Rahul and I agreed enforceable, instead of a reminder.

Why now

I checked the org before writing this:

  • 10 PRD-ish issues across frontend-mono and backend. None carry a label.
  • No issue template in .github, frontend-mono or backend.
  • No PR template either.
  • PRDs live in 4 places: issue bodies, repo .md files, Google Docs, Slack threads.

Two Slack reminders have not changed that, because a rule people have to remember is
not a gate. This makes it a status check.

What is here

File Does
.github/ISSUE_TEMPLATE/prd.yml Full PRD. Crosses a repo boundary, changes a contract, or needs a migration.
.github/ISSUE_TEMPLATE/prd-lite.yml One page. Fixes and hotfix RCAs. Rahul asked for this.
.github/workflows/prd-gate.yml Reusable gate. A PR merges only with an approved PRD linked.
.github/PULL_REQUEST_TEMPLATE.md Second section is "Deviations from the PRD".
docs/PRD-POLICY.md The rule, which template to pick, the escape hatch.
docs/PRD-TEMPLATE.md The skeleton both existing PRDs already use, written down for the first time.
setup/install-prd-gate.sh Creates labels, can open the caller PRs. Never deletes, never force-pushes.

Two calls worth arguing about

1. Two template sizes, not one. The Semantic Layer PRD is ~8000 words. If a border
colour fix needs that, people route around the rule. The gate checks that a PRD
exists, not which size.

2. There is an escape hatch. A maintainer can put prd-exempt on a PR to skip the
gate. It exists so this never blocks a real outage fix. Every use is visible in the PR
timeline.

This does not enforce anything yet

Three steps need an org admin, and I deliberately did not script them:

  1. databrainhq/.github -> Settings -> Actions -> General -> Access -> allow org repos.
  2. Add the org secret PRD_GATE_TOKEN (read access to Issues) for cross-repo links.
  3. Make PRD gate / prd a required status check on each repo's default branch.

Until step 3, the gate reports and does not block. Merging this changes nothing on its
own, which is the point: you two decide when it starts biting.

Tested

  • All 4 YAML files parse.
  • Gate script syntax-checked, and its reference extraction tested against 7 PR-body
    shapes including PRD: #3379, databrainhq/frontend-mono#7873, full issue URLs, and
    a dependabot body (correctly finds nothing).
  • install-prd-gate.sh passes bash -n. Not run — no labels created yet.

Companion, not in this PR

Edith gets /edith-prd <issue> (drafts a PRD into an issue, never approves it) and
/edith-build <issue> (hands an approved PRD to a Cursor cloud agent, which branches,
builds, and opens a PR). Written and tested, not deployed.

https://claude.ai/code/session_01E2afbz3AS1tATwMc5iaNCu

Greptile Summary

This PR introduces organization-wide PRD issue templates, policy documentation, a reusable approval gate, and an installer for rolling the gate out to selected repositories.

  • Adds full and lite PRD issue forms plus a pull-request template.
  • Implements same- and cross-repository PRD resolution with an exemption label.
  • Documents approval and rollout policy and provides caller/installation scaffolding.
  • The gate currently cannot refresh automatically when approval changes on the PRD issue.

Confidence Score: 4/5

The approval-refresh defect should be fixed before enabling the gate as a required check; the cross-repository metadata boundary and workflow dependency pinning also need hardening.

The gate evaluates issue approval only on pull-request activity, so subsequent approval or revocation leaves the required check stale, while unrestricted token-backed issue reads and mutable action resolution add non-blocking security concerns.

Files Needing Attention: setup/caller-workflow.yml, .github/workflows/prd-gate.yml, setup/install-prd-gate.sh

Security Review

The cross-repository lookup accepts unrestricted repositories and emits token-readable issue metadata into caller workflow output, which can cross repository visibility boundaries. The workflow also references its executable action through a mutable version tag rather than an immutable commit.

Important Files Changed

Filename Overview
.github/workflows/prd-gate.yml Adds the reusable PRD resolver and approval check, but unrestricted cross-repository reads expose metadata and the action dependency is mutable.
setup/caller-workflow.yml Installs the reusable gate for PR events, but cannot update its result when approval changes on the linked issue.
setup/install-prd-gate.sh Creates labels and workflow PRs across repositories, though the fixed branch and unconditional PR creation make retries fail partway through.
.github/ISSUE_TEMPLATE/prd.yml Adds a structured full-PRD issue form with required scope, contract, rollout, and acknowledgment fields.
.github/ISSUE_TEMPLATE/prd-lite.yml Adds a smaller required-field PRD form for fixes, RCAs, and self-contained work.
docs/PRD-POLICY.md Documents the PRD lifecycle, template selection, exemption policy, labels, and rollout prerequisites.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Pull request event] --> B[Run reusable PRD gate]
    B --> C[Read linked issue labels]
    C -->|Approved| D[Successful required check]
    C -->|Not approved| E[Failed required check]
    F[PRD issue label changes] -. no caller trigger .-> B
    F --> G[Existing check remains stale]
Loading

Fix all with Greploop Fix All in Claude Code Fix All in Cursor Fix All in Codex

Prompt To Fix All With AI
### Issue 1
setup/caller-workflow.yml:17-18
**PRD approval leaves stale checks**

When the linked PRD gains or loses `prd-approved` after this workflow runs, no configured event reruns the gate because these triggers only observe activity on the pull request. The required check therefore remains failed after approval or remains successful after approval is revoked until unrelated PR activity occurs.

### Issue 2
.github/workflows/prd-gate.yml:116-123
**Token-backed issue metadata oracle**

If the shared token can read an issue that is hidden from readers of the caller repository, a PR author can submit that unrestricted owner/repository reference and the gate publishes the issue title and URL in the caller's workflow output. Restrict lookups to repositories with a compatible visibility boundary or avoid emitting metadata obtained with the shared credential.

**How this was verified:** PR-controlled repository coordinates flow without an allowlist into the token-authenticated fetch, and the returned metadata is written to notices, summaries, and failure output.

### Issue 3
.github/workflows/prd-gate.yml:42
**Mutable workflow action reference**

`actions/github-script@v7` resolves through a mutable tag while this step receives repository permissions and the cross-repository issue token. Pinning the action to a reviewed full commit SHA prevents an upstream tag change from executing different code with those credentials.

**How this was verified:** The executable action uses the mutable `v7` tag and the same step receives `CROSS_REPO_TOKEN` through its environment.

### Issue 4
setup/install-prd-gate.sh:51-55
**Installer cannot resume safely**

When `--with-workflow` is rerun after an earlier invocation created `chore/prd-gate` or its pull request, the fixed branch push or unconditional duplicate PR creation fails. Because `set -e` aborts a sequential multi-repository installation, later repositories remain unconfigured while changes made to earlier repositories persist.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "feat: PRD policy — templates, gate, and ..." | Re-trigger Greptile

Greptile also left 4 inline comments on this PR.

Every feature and hotfix gets a PRD, approved before the PR is reviewed.
Agreed by Rahul and Koushik, August 2026.

Today nothing enforces this. I checked: 10 PRD-ish issues across frontend-mono
and backend, none labelled, no issue template in any repo, and PRDs scattered
across issue bodies, repo .md files, Google Docs and Slack threads. Two Slack
reminders have not fixed it, because a rule people must remember is not a gate.

What this adds:

- Two org-default issue forms. PRD (full) for anything crossing a repo
  boundary, changing a contract, or needing a migration. PRD (lite), one page,
  for fixes and hotfix RCAs. Rahul asked for a shorter template; a single long
  one would get routed around.
- A reusable PRD gate workflow. A PR merges only if it references an issue
  carrying both PRD and prd-approved, or if a maintainer applies prd-exempt.
  Reads the PR body, title and branch name for #123, owner/repo#123 and full
  issue URLs. Cross-repo lookups need the PRD_GATE_TOKEN secret.
- A PR template whose second section is "Deviations from the PRD".
- docs/PRD-POLICY.md and docs/PRD-TEMPLATE.md. The template is the skeleton
  both existing PRDs already use, written down for the first time.
- setup/install-prd-gate.sh creates the labels and can open the caller PRs.
  It never deletes and never force-pushes.

Nothing enforces until someone makes "PRD gate / prd" a required status check.
Until then the gate reports and does not block.

Claude-Session: https://claude.ai/code/session_01E2afbz3AS1tATwMc5iaNCu
Comment thread setup/caller-workflow.yml
Comment on lines +17 to +18
pull_request:
types: [opened, edited, reopened, synchronize, labeled, unlabeled]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 PRD approval leaves stale checks

When the linked PRD gains or loses prd-approved after this workflow runs, no configured event reruns the gate because these triggers only observe activity on the pull request. The required check therefore remains failed after approval or remains successful after approval is revoked until unrelated PR activity occurs.

Prompt To Fix With AI
This is a comment left during a code review.
Path: setup/caller-workflow.yml
Line: 17-18

Comment:
**PRD approval leaves stale checks**

When the linked PRD gains or loses `prd-approved` after this workflow runs, no configured event reruns the gate because these triggers only observe activity on the pull request. The required check therefore remains failed after approval or remains successful after approval is revoked until unrelated PR activity occurs.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Cursor Fix in Codex

Comment on lines +116 to +123
const res = await fetch(
`https://api.github.com/repos/${ref.owner}/${ref.repo}/issues/${ref.number}`,
{ headers: {
Authorization: `Bearer ${crossToken}`,
Accept: 'application/vnd.github+json',
'User-Agent': 'databrainhq-prd-gate',
} },
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 security Token-backed issue metadata oracle

If the shared token can read an issue that is hidden from readers of the caller repository, a PR author can submit that unrestricted owner/repository reference and the gate publishes the issue title and URL in the caller's workflow output. Restrict lookups to repositories with a compatible visibility boundary or avoid emitting metadata obtained with the shared credential.

How this was verified: PR-controlled repository coordinates flow without an allowlist into the token-authenticated fetch, and the returned metadata is written to notices, summaries, and failure output.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/prd-gate.yml
Line: 116-123

Comment:
**Token-backed issue metadata oracle**

If the shared token can read an issue that is hidden from readers of the caller repository, a PR author can submit that unrestricted owner/repository reference and the gate publishes the issue title and URL in the caller's workflow output. Restrict lookups to repositories with a compatible visibility boundary or avoid emitting metadata obtained with the shared credential.

**How this was verified:** PR-controlled repository coordinates flow without an allowlist into the token-authenticated fetch, and the returned metadata is written to notices, summaries, and failure output.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Cursor Fix in Codex

check:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 security Mutable workflow action reference

actions/github-script@v7 resolves through a mutable tag while this step receives repository permissions and the cross-repository issue token. Pinning the action to a reviewed full commit SHA prevents an upstream tag change from executing different code with those credentials.

How this was verified: The executable action uses the mutable v7 tag and the same step receives CROSS_REPO_TOKEN through its environment.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/prd-gate.yml
Line: 42

Comment:
**Mutable workflow action reference**

`actions/github-script@v7` resolves through a mutable tag while this step receives repository permissions and the cross-repository issue token. Pinning the action to a reviewed full commit SHA prevents an upstream tag change from executing different code with those credentials.

**How this was verified:** The executable action uses the mutable `v7` tag and the same step receives `CROSS_REPO_TOKEN` through its environment.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Cursor Fix in Codex

Comment thread setup/install-prd-gate.sh
Comment on lines +51 to +55
git -C "$tmp/$repo" checkout -b chore/prd-gate
git -C "$tmp/$repo" add .github/workflows/prd-gate.yml
git -C "$tmp/$repo" commit -m "ci: require an approved PRD before a PR can merge"
git -C "$tmp/$repo" push -u origin chore/prd-gate
gh pr create --repo "$ORG/$repo" --base main --head chore/prd-gate \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Installer cannot resume safely

When --with-workflow is rerun after an earlier invocation created chore/prd-gate or its pull request, the fixed branch push or unconditional duplicate PR creation fails. Because set -e aborts a sequential multi-repository installation, later repositories remain unconfigured while changes made to earlier repositories persist.

Prompt To Fix With AI
This is a comment left during a code review.
Path: setup/install-prd-gate.sh
Line: 51-55

Comment:
**Installer cannot resume safely**

When `--with-workflow` is rerun after an earlier invocation created `chore/prd-gate` or its pull request, the fixed branch push or unconditional duplicate PR creation fails. Because `set -e` aborts a sequential multi-repository installation, later repositories remain unconfigured while changes made to earlier repositories persist.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Cursor Fix in Codex

@koushik-databrain koushik-databrain self-assigned this Sep 15, 2026
@koushik-databrain
koushik-databrain marked this pull request as draft September 15, 2026 13:16
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