Skip to content

chore(ci): stop new files in ee/ without human approval - #124071

Merged
trunk-io[bot] merged 4 commits into
masterfrom
reece/add-ee-new-file-semgrep-rule
Oct 28, 2026
Merged

trunk-io[bot] merged 4 commits into
masterfrom
reece/add-ee-new-file-semgrep-rule

Conversation

@ReeceJones

@ReeceJones ReeceJones commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

ee is deprecated but we dont have any guards to prevent new files from being added.

Changes

A path check, .github/scripts/check-no-new-ee-files.py, fails a pull request that adds a file under ee/. It runs in CI (Repo checks in Backend CI) and in hogli ci:preflight, and it compares paths, so an empty __init__.py counts too. This replaces the semgrep rule the first commit tried, which could not see an empty file.

A developer exempts one file by adding its exact path to EXEMPT in that script, so the exception is a line a human approves in review. ee/AGENTS.md tells an agent not to add a file there without explicit human approval.

How did you test this code?

This PR

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Release status

  • No feature flag controls this change
  • This change is behind a feature flag and is not available to users
  • This change makes a previously flagged feature available to everyone

Docs update

🤖 Agent context

Autonomy: Human-driven (agent-assisted) - or - Fully autonomous

Agent: tool, model

@ReeceJones
ReeceJones requested a review from a team October 27, 2026 13:40
@trunk-io

trunk-io Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

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

PostHog Review · Standard · reviewed 3f5d4f9: 2 Should fix.

This is the only automatic review while this pull request is a draft. Comment @posthog review to review new changes sooner. Otherwise, a review of the new changes runs when you mark it ready for review.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

Comment thread .github/workflows/ci-security.yaml Resolved
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

🚨 Trunk lane — universal lane

This PR is assigned to the universal lane. It cannot merge in parallel with other PRs, so it can take longer to merge. Ask dev-ex if you think this is wrong.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Duplication (TypeScript) — clean

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

@ReeceJones ReeceJones changed the title chore: add semgrep rule to stop new files in ee chore(ci): stop new files in ee/ without human approval Oct 27, 2026
@ReeceJones
ReeceJones marked this pull request as ready for review October 27, 2026 14:35
@parameterai

parameterai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Risk: No findings

Follow-up increment adds the guard's tests at .github/scripts/test_check_no_new_ee_files.py, deletes the old copy under posthog/test/repo_invariants/, marks the guard script as a sensitive devex-owned path in owners.yaml, and trims a doc paragraph. No security-relevant behavior changed: the guard script, its CI wiring, and preflight registration are untouched, and the owners.yaml edit only strengthens review routing for edits to the script and its EXEMPT list.

Sentinel reviewed 01fdf9f · Review settings

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

PostHog Review · Standard · reviewed 469b819: 1 Must fix, 1 Should fix.

# file that a content scan cannot. Exemptions live in the script.
- name: Check for new files under ee/
if: github.event_name == 'pull_request'
run: python .github/scripts/check-no-new-ee-files.py --against HEAD^1 --committed

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.

P1 · Gate the script invocation for branches that predate it

When this workflow reaches an unrebased PR whose checkout lacks the new script, python exits with a missing-file error. repo-checks then marks that failure deterministic and cancels Backend CI for unrelated changes. AGENTS.md:139 explicitly requires compatibility with these branches; gate the invocation on script availability.

Comment on lines +1616 to +1618
- name: Check for new files under ee/
if: github.event_name == 'pull_request'
run: python .github/scripts/check-no-new-ee-files.py --against HEAD^1 --committed

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.

P2 · Run the guard for every added path under ee/

A PR adding only ee/new.md or ee/frontend/new.ts skips repo-checks: its backend filter excludes Markdown and ee/frontend/**, and neither path triggers the other job conditions. The new guard never runs, bypassing the all-file approval requirement in ee/AGENTS.md:3–5; add an independent filter covering every ee/** path.

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

🤖 Agent review · steered by a person

Requesting changes. The human-approval step is not enforced yet. Where this check should live is still open.

Make the exemption list need a human

The EXEMPT set sits in .github/scripts/check-no-new-ee-files.py, and owners.yaml does not mark that file sensitive. An agent can add a path there, and stamphog can approve the PR. Add the script to the sensitive team-devex block in owners.yaml, or move the list to a data file that is routed there.

Drop the semgrep README edit

It belongs to the semgrep attempt that the PR replaced. It also pulls the "To flip a rule" paragraph into the bullet list above it.

Move the test next to the script

posthog/test/repo_invariants/ is for tests that scan the whole repository. This test checks one script against a temporary git repo. Tests for .github/scripts live next to them as test_*.py and run in ci-scripts.yml.

Open question: where the check lives

A path comparison is the right approach. Semgrep cannot see an empty file, and a repo invariant would need a baseline of every file in ee/. But this adds a standalone script, its own CI step and its own preflight entry. #124050 does the same for a different guard. A shared home for diff-based guards that need a human sign-off may fit better. That is not decided yet, so no change is needed here for now.

@trunk-io

trunk-io Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

- owners.yaml: the script that holds EXEMPT is sensitive team-devex, so a human reviews an exemption.
- Move the guard's test to .github/scripts, where ci-scripts.yml runs it.
- Drop the .semgrep/rules/devex/README.md edit, which belonged to the replaced semgrep attempt.
@ReeceJones
ReeceJones requested a review from webjunkie October 28, 2026 13:20

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

🤖 Agent review · steered by a person

Approving.

@trunk-io
trunk-io Bot merged commit 0633aa2 into master Oct 28, 2026
280 checks passed
@trunk-io
trunk-io Bot deleted the reece/add-ee-new-file-semgrep-rule branch October 28, 2026 21:13
@deployment-status-posthog

deployment-status-posthog Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-10-28 21:47 UTC Run
prod-us ✅ Deployed 2026-10-28 22:02 UTC Run
prod-eu ✅ Deployed 2026-10-28 22:01 UTC Run

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.

2 participants