diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..49fcb8c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,31 @@ +name: Bug report +description: Report a reproducible problem without private data +title: "Bug: " +body: + - type: markdown + attributes: + value: "Use synthetic examples. Remove credentials, customer information, private URLs, and captured content. Report security issues privately through the repository's Security tab." + - type: input + id: version + attributes: + label: Version or commit + placeholder: "Package version or commit SHA" + - type: textarea + id: reproduction + attributes: + label: Steps to reproduce + description: Include the smallest synthetic example and relevant configuration. + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected behavior + validations: + required: true + - type: textarea + id: actual + attributes: + label: Actual behavior + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3ba13e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..01f71b7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,23 @@ +name: Feature request +description: Suggest a change to the public project +title: "Feature: " +body: + - type: markdown + attributes: + value: "Describe a general use case. Do not include internal plans, tracker links, or customer-identifying details." + - type: textarea + id: problem + attributes: + label: Problem to solve + validations: + required: true + - type: textarea + id: proposal + attributes: + label: Proposed behavior + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Alternatives considered diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..8aed7f5 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,12 @@ +## What changed + + + +## Verification + + + +## Publication check + +- [ ] Branch name, commits, diff, fixtures, logs, screenshots, and this PR contain no secrets, private tracker references, or identifying customer data. +- [ ] Security-sensitive details are being reported privately. diff --git a/.github/workflows/publication-check.yml b/.github/workflows/publication-check.yml new file mode 100644 index 0000000..04034f4 --- /dev/null +++ b/.github/workflows/publication-check.yml @@ -0,0 +1,13 @@ +name: Public contribution check +on: pull_request +jobs: + metadata: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Check public references + run: python3 scripts/check_publication.py origin/${{ github.event.repository.default_branch }} diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..ba4e2f4 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,19 @@ +# Public contribution rules + +This repository is public. Before publishing a branch, commit, issue, pull +request, comment, release, screenshot, fixture, or log: + +- Use a self-contained public description. Keep private tracker IDs, links, + discussion, and customer context in the internal tracker. Do not put them in + public branch names, commit messages, issue or PR titles and bodies, or + release notes. +- Remove secrets, tokens, non-public customer or prospect names and domains, + tenant or workspace IDs, captured prompts or responses, private paths, and + cloud account or resource IDs. Use synthetic examples and `example.com`. +- Inspect the exact diff and all metadata before pushing or posting. A CI + failure after publication cannot undo disclosure. +- Report a suspected vulnerability privately to maintainers. Do not include + exploit details in a public issue. + +If unsure whether a detail is public, stop and ask before publishing. Existing +harmless issue IDs in history do not, by themselves, require rewriting history. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..43c994c --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..8af03ea --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,10 @@ +# Contributing + +Please use the issue forms for bugs and feature requests, and open a pull +request with a short explanation of the change and how you checked it. Provide +minimal, synthetic reproduction data. Before posting, review your branch name, +commits, diff, logs, screenshots, and PR text for private information. Keep +internal tracker references in the internal tracker. + +For a security issue, contact maintainers privately instead of opening a +public issue. diff --git a/README.md b/README.md index daf58a1..a08f319 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,11 @@ -# .github +# Metergraph community defaults + +This repository supplies the default issue forms, pull request template, and +contribution guidelines for repositories owned by the `metergraph` GitHub +organization. A repository's own template takes precedence. Repositories in +other organizations need their own copies. + +The public publishing rules are in [AGENTS.md](AGENTS.md). Agents working in +another repository need that repository's own `AGENTS.md`; GitHub community +defaults do not place agent instructions in checkouts. Shared contribution and issue templates for Metergraph repositories diff --git a/scripts/check_publication.py b/scripts/check_publication.py new file mode 100644 index 0000000..feb2470 --- /dev/null +++ b/scripts/check_publication.py @@ -0,0 +1,76 @@ +"""Check common internal references before a public push or PR. + +Usage: python3 scripts/check_publication.py origin/main +This cannot detect all private data. Review the full diff and metadata yourself. +""" + +import json +import os +import re +import subprocess +import sys + + +PATTERNS = { + "internal issue ID": re.compile(r"\b" + "MET" + r"-[0-9]+\b", re.I), + "internal tracker URL": re.compile("linear.app/" + "metergraph", re.I), + "private repository reference": re.compile("PioneerSquareLabs/" + "metergraph-internal", re.I), +} + + +def git(*args: str) -> str: + return subprocess.check_output(["git", *args], text=True) + + +def main() -> int: + base = sys.argv[1] if len(sys.argv) > 1 else "origin/main" + try: + metadata = [ + ("new commits", git("log", "--format=%B", f"{base}..HEAD")), + ] + diff = git("diff", "--no-ext-diff", "--unified=0", f"{base}...HEAD", "--") + except subprocess.CalledProcessError as error: + print(f"Could not compare against {base}: {error}", file=sys.stderr) + return 2 + + event_path = os.environ.get("GITHUB_EVENT_PATH") + if event_path: + with open(event_path, encoding="utf-8") as event_file: + pull_request = json.load(event_file).get("pull_request", {}) + metadata.extend( + [ + ("PR title", pull_request.get("title") or ""), + ("PR body", pull_request.get("body") or ""), + ] + ) + + added_lines = "\n".join( + line[1:] + for line in diff.splitlines() + if line.startswith("+") and not line.startswith("+++") + ) + metadata.append(("added lines", added_lines)) + + branch = git("branch", "--show-current").strip() + if event_path: + branch = pull_request.get("head", {}).get("ref") or branch + if PATTERNS["internal issue ID"].search(branch): + print("Review branch name: it appears to contain an internal issue ID.") + + findings = [ + f"{location}: {name}" + for location, content in metadata + for name, pattern in PATTERNS.items() + if pattern.search(content) + ] + if findings: + print("Check these public references before publishing:") + print("\n".join(f"- {finding}" for finding in findings)) + return 1 + + print("No known internal references found. Review for other private data before publishing.") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())