From 8837db3c196d3c09e67dc37a4408a1983c1b20bc Mon Sep 17 00:00:00 2001 From: ThePlenkov <6381507+ThePlenkov@users.noreply.github.com> Date: Fri, 13 Nov 2026 18:48:45 +0100 Subject: [PATCH] chore(agents): enforce OSS isolation with a mechanical pre-push guard Add an always-on agent rule (.agents/rules/git/oss-isolation.md) and scripts/oss-github-guard.sh: a mechanical gate that scans outgoing commit metadata, branch names and PR/issue text before anything reaches a public remote. Organization-specific forbidden patterns live in scripts/.oss-guard-local.patterns (local, untracked) so the published script ships only the mechanism; the pre-push hook OR-joins them into the scan. AGENTS.md gains a mandatory pointer section. --- .agents/rules/git/oss-isolation.md | 71 +++++++++++++++++++++++++ .gitignore | 1 + AGENTS.md | 20 +++++++ scripts/oss-github-guard.sh | 84 ++++++++++++++++++++++++++++++ 4 files changed, 176 insertions(+) create mode 100644 .agents/rules/git/oss-isolation.md create mode 100755 scripts/oss-github-guard.sh diff --git a/.agents/rules/git/oss-isolation.md b/.agents/rules/git/oss-isolation.md new file mode 100644 index 000000000..4d89f648d --- /dev/null +++ b/.agents/rules/git/oss-isolation.md @@ -0,0 +1,71 @@ +--- +trigger: always_on +description: Zero internal context in any public GitHub contribution. Mandatory preflight before publishing to github.com. +--- + +# OSS Isolation Rule (public GitHub) + +## The rule + +**Public GitHub remotes (`origin`, `github.com`) and internal development +remotes are two separate worlds.** No internal context may ever appear in any +public GitHub artifact — not even as "evidence" or "provenance". + +This applies to **every** contribution channel, for **every** agent runtime +(Cursor, Claude Code, Codex, and any CLI agent): + +- PR titles, bodies, comments, and code-review replies +- Issues and issue comments +- Branch names and commit messages +- Author / committer emails (use the personal public identity, never a + corporate address) +- Code comments, test fixtures, documentation, changelogs + +## Forbidden patterns + +Never write or paste into anything destined for GitHub: + +| Pattern class | Example of the leak | +| --------------------------------------------------------- | -------------------------------------- | +| Corporate host names and internal group paths | shadow-MR / pipeline / work-item links | +| Corporate email domains in author metadata | commit author `@corp.example` | +| Internal system codenames | release train / environment names | +| Internal MR/pipeline/job numbers tied to internal systems | "!105", "builder 3029698363" | + +The concrete patterns for this organization live in +`scripts/.oss-guard-local.patterns` (local, untracked — never commit it). The +mechanical guard reads that file and adds its patterns to the generic scan. + +Generic engineering words (`canary`, `draft`, `shadow review`) are fine. +Internal _system names_ and _links_ are not. When unsure, drop the sentence — +the public PR must stand on its own without internal evidence. + +## Mandatory preflight (mechanical gate) + +Before **any** of these actions targeting a public remote: + +- `git push` to a `github.com` remote +- `gh pr create` / `gh pr edit` / `gh pr comment` / `gh issue create` + +run: + +```sh +scripts/oss-github-guard.sh # scans outgoing commits + branch name +scripts/oss-github-guard.sh --pr # scans live PR text via gh +``` + +The guard exits non-zero on any forbidden pattern. **A non-zero exit is a hard +stop** — fix the text, do not bypass, do not `--no-verify`. + +## Summarizing internal work for a public PR + +Rewrite from scratch in public terms: what the bug was, what changed, which +local tests pass. Internal MR numbers, pipelines, jobs, and system names are +never part of that story. If a commit message or prior PR body already +contains internal references, do not copy it — sanitize first. + +## Why this exists + +Prose alone failed: public contributions kept picking up internal links, +system codenames and corporate emails. The guard script plus this always-on +rule are the enforced baseline. diff --git a/.gitignore b/.gitignore index 10a001f5f..a7c7b6fd4 100644 --- a/.gitignore +++ b/.gitignore @@ -190,3 +190,4 @@ gascity/AGENTS.md .beads-credential-key .beads/proxieddb/ *.gate.lock* +scripts/.oss-guard-local.patterns diff --git a/AGENTS.md b/AGENTS.md index 9ee87f127..5dffe9d5c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,6 +32,7 @@ - Legacy Windsurf paths under **`.windsurf/`** are redirect stubs; extend `.agents/` instead. + ## Beads Issue Tracker This project uses **bd (beads)** for issue tracking. Run `bd prime` to see full workflow context and commands. @@ -82,12 +83,15 @@ This protocol applies when ending a Beads implementation workflow. It is subordi 5. **Hand off** - Summarize changes, validation, issue status, and any blocked sync/commit/push step **Critical rules:** + - Explicit user or orchestrator instructions override this Beads block. - Do not commit or push without clear authority from the active profile or the current user request. - If a required sync or push is blocked, stop and report the exact command and error. + + ## Beads Issue Tracker Use Beads (`bd`) for durable task tracking in repositories that include it. Use the `beads` skill at `.agents/skills/beads/SKILL.md` (project install) or `~/.agents/skills/beads/SKILL.md` (global install) for Beads workflow guidance, then use the `bd` CLI for issue operations. @@ -110,3 +114,19 @@ bd prime # Refresh Beads context **Architecture in one line:** issues live in a local Dolt DB; sync uses `refs/dolt/data` on your git remote; `.beads/issues.jsonl` is a passive export. See https://github.com/gastownhall/beads/blob/main/docs/core-concepts/sync-concepts.md for details and anti-patterns. + +## OSS isolation (mandatory) + +Public GitHub remotes and internal development remotes are separate worlds. +**Zero internal context in any public contribution** — titles, bodies, +comments, reviews, issues, branch names, commit messages, author/committer +emails, code comments and docs. + +The concrete forbidden patterns are organization-specific and live in +`scripts/.oss-guard-local.patterns` (local, untracked; see +`.agents/rules/git/oss-isolation.md`). + +Before any `git push` to a public remote or `gh pr create/edit/comment`: +run `scripts/oss-github-guard.sh` (the pre-push hook enforces this; a +non-zero exit is a hard stop). Full rule: +`.agents/rules/git/oss-isolation.md`. diff --git a/scripts/oss-github-guard.sh b/scripts/oss-github-guard.sh new file mode 100755 index 000000000..0af09fe53 --- /dev/null +++ b/scripts/oss-github-guard.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env sh +# oss-github-guard.sh — block non-public internal context from reaching public GitHub. +# +# Usage: +# scripts/oss-github-guard.sh # scan outgoing commits + branch name (pre-push mode or HEAD) +# scripts/oss-github-guard.sh --pr # scan a live PR's title/body/comments via gh +# scripts/oss-github-guard.sh --file # scan an arbitrary text file (e.g. a draft PR body) +# +# Exit 0 = clean, exit 1 = forbidden context found, exit 2 = usage/infra error. +# Installed as a pre-push hook it only fires for github.com remotes. + +set -u + +# Generic fallback patterns safe to publish. Organization-specific patterns +# live in scripts/.oss-guard-local.patterns (local, untracked): one regex +# fragment per line, OR-joined into the scan. Without that file only the +# generic patterns apply. +PATTERNS='@(corp|internal)\.example' +LABEL='internal / non-public context' +PATTERN_FILE="$(dirname "$0")/.oss-guard-local.patterns" +if [ -f "$PATTERN_FILE" ]; then + LOCAL=$(grep -vE '^\s*(#|$)' "$PATTERN_FILE" | paste -sd '|' -) + [ -n "$LOCAL" ] && PATTERNS="$PATTERNS|$LOCAL" +fi +TMP=$(mktemp) || exit 2 +trap 'rm -f "$TMP"' EXIT + +die() { + echo "OSS-GUARD: forbidden $LABEL detected in [$1]:" >&2 + grep -Ein "$PATTERNS" "$TMP" | sed 's/^/ /' >&2 + echo "OSS-GUARD: sanitize the text before publishing to github.com (see .agents/rules/git/oss-isolation.md)." >&2 + exit 1 +} + +scan() { # scan