Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .agents/rules/git/oss-isolation.md
Original file line number Diff line number Diff line change
@@ -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)
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved

## 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`
Comment thread
ThePlenkov marked this conversation as resolved.
Resolved

run:

```sh
scripts/oss-github-guard.sh # scans outgoing commits + branch name
scripts/oss-github-guard.sh --pr <N> # 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.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,4 @@ gascity/AGENTS.md
.beads-credential-key
.beads/proxieddb/
*.gate.lock*
scripts/.oss-guard-local.patterns
20 changes: 20 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- Legacy Windsurf paths under **`.windsurf/`** are redirect stubs; extend `.agents/` instead.

<!-- BEGIN BEADS INTEGRATION v:1 profile:minimal hash:46cd31e7 -->

## Beads Issue Tracker

This project uses **bd (beads)** for issue tracking. Run `bd prime` to see full workflow context and commands.
Expand Down Expand Up @@ -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.

<!-- END BEADS INTEGRATION -->

<!-- BEGIN BEADS CODEX SETUP: generated by bd setup codex -->

## 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.
Expand All @@ -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.
<!-- END BEADS CODEX SETUP -->

## 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:
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Comment thread
ThePlenkov marked this conversation as resolved.
Resolved
`.agents/rules/git/oss-isolation.md`.
84 changes: 84 additions & 0 deletions scripts/oss-github-guard.sh
Original file line number Diff line number Diff line change
@@ -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 <N> # scan a live PR's title/body/comments via gh
# scripts/oss-github-guard.sh --file <f> # 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'
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
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"
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
fi
Comment thread
ThePlenkov marked this conversation as resolved.
Resolved
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 <label> — text arrives on stdin, kept in $TMP
cat >"$TMP"
if grep -Ein "$PATTERNS" "$TMP" >/dev/null 2>&1; then
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
die "$1"

Check warning on line 38 in scripts/oss-github-guard.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=abapify_adt-cli&issues=AaH5ED_EzBex6dE2tLDm&open=AaH5ED_EzBex6dE2tLDm&pullRequest=369
fi
}

case "${1:-}" in
--pr)
[ -n "${2:-}" ] || { echo "usage: $0 --pr <N>" >&2; exit 2; }
gh pr view "$2" --json title,body --jq '.title, .body' 2>/dev/null | scan "PR $2 title/body" || exit 1
gh pr view "$2" --json comments --jq '.comments[] | .body' 2>/dev/null | scan "PR $2 comments" || exit 1
Comment thread
ThePlenkov marked this conversation as resolved.
Resolved
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Comment thread
ThePlenkov marked this conversation as resolved.
Resolved
echo "OSS-GUARD: PR $2 clean."
;;
--file)
[ -n "${2:-}" ] || { echo "usage: $0 --file <path>" >&2; exit 2; }
scan "file $2" <"$2"
echo "OSS-GUARD: $2 clean."
;;
*)
if [ $# -ge 2 ]; then
# pre-push hook mode: args "<remote> <url>", stdin lines "<local_ref> <local_sha> <remote_ref> <remote_sha>"
remote_name="$1"; remote_url="$2"
case "$remote_url" in
*github.com*) : ;;
*) exit 0 ;; # internal remotes (GitLab) are out of scope for this guard
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
esac
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
while read -r local_ref local_sha remote_ref remote_sha; do

Check warning on line 62 in scripts/oss-github-guard.sh

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/oss-github-guard.sh#L62

remote_ref appears unused. Verify use (or export if used externally).
[ "$local_sha" = "0000000000000000000000000000000000000000" ] && continue
branch=${local_ref#refs/heads/}
printf '%s\n' "$branch" | scan "branch name ($branch)" || exit 1
if [ "$remote_sha" = "0000000000000000000000000000000000000000" ]; then
range="$local_sha"
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
else
Comment thread
ThePlenkov marked this conversation as resolved.
Resolved
range="$remote_sha..$local_sha"
fi
git log --format='%H%n%B%n%an <%ae>%n%cn <%ce>' "$range" 2>/dev/null | scan "commits $range -> $remote_name (github.com)" || exit 1
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
done
echo "OSS-GUARD: push to $remote_name (github.com) clean."
exit 0
fi
# standalone mode: scan branch name + commits between upstream and HEAD.
branch=$(git rev-parse --abbrev-ref HEAD)
printf '%s\n' "$branch" | scan "branch name" || exit 1
base=$(git rev-parse --abbrev-ref --symbolic-full-name '@{push}' 2>/dev/null | sed 's|/[^/]*$||') || base=origin
git log --format='%H%n%B%n%an <%ae>%n%cn <%ce>' "${base}/HEAD..HEAD" 2>/dev/null | scan "commit metadata (${base}/HEAD..HEAD)" || exit 1
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Comment thread
ThePlenkov marked this conversation as resolved.
Resolved
echo "OSS-GUARD: outgoing commits and branch name clean."
;;
esac
exit 0
Loading