From e879cdeab7fff179a41cbaa3e45f6b8566429ea8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 19:14:59 +0000 Subject: [PATCH 1/2] Initial plan From faa7b2513406530b2b61d1130b765aaafa323a44 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 19:20:18 +0000 Subject: [PATCH 2/2] feat: add Copilot cascade routing to multiple free agents at $0 cost Co-authored-by: blackboxprogramming <118287761+blackboxprogramming@users.noreply.github.com> --- .github/copilot-instructions.md | 44 +++++++++ .github/scripts/cascade_review.py | 136 +++++++++++++++++++++++++++ .github/workflows/cascade-review.yml | 39 ++++++++ 3 files changed, 219 insertions(+) create mode 100644 .github/copilot-instructions.md create mode 100644 .github/scripts/cascade_review.py create mode 100644 .github/workflows/cascade-review.yml diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..15a4929 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,44 @@ +# Copilot Instructions for simulation-hypothesis + +## Repository Overview + +This is a static research repository containing a paper and supporting code exploring the "Simulation Hypothesis" — the computational argument that reality is self-referential. It is authored by Alexa Louise Amundson at BlackRoad OS, Inc. + +## Repository Structure + +- `PAPER.md` — The main research paper (21 sections) +- `DECLARATION.md`, `ORIGIN.md` — Supporting declarations +- `README.md` — Overview, abstract, and evidence index +- `code/` — Python 3 demonstration scripts (no external dependencies except `matplotlib` for `lorenz.py`) +- `evidence/` — Evidence index with references +- `index.html`, `vr.html`, `qr.html` — Static web app pages +- `manifest.json`, `icon.svg` — PWA manifest assets +- `LICENSE` — BlackRoad OS proprietary license + +## Languages & Runtimes + +- **Python 3** for all scripts in `code/` +- **HTML/CSS/JS** for the web app (`index.html`, `vr.html`, `qr.html`) +- No build system, no package manager, no compilation step + +## Running the Code + +```bash +cd code +python3 hashchain.py # no external deps +python3 riemann_zeros.py # no external deps +python3 lorenz.py # requires: pip install matplotlib +python3 magic_square.py # no external deps +python3 dna_encoding.py # no external deps +python3 roadchain.py # no external deps +``` + +## Validation + +There are no automated tests. To validate changes to Python scripts, run them directly and confirm they produce expected output without errors. There are no linting configs or CI pipelines defined in this repository. + +## Pull Request Guidelines + +- Python code changes should be validated by running the affected script +- Documentation changes do not require code execution +- Keep changes minimal and focused on the stated task diff --git a/.github/scripts/cascade_review.py b/.github/scripts/cascade_review.py new file mode 100644 index 0000000..b20fc2c --- /dev/null +++ b/.github/scripts/cascade_review.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python3 +""" +Cascade PR review using multiple free GitHub Models agents. + +Routes each pull request through two independent free-tier AI models +and writes a combined Markdown review to /tmp/cascade_review.md. + +Cost: $0 — uses the GitHub Models free rate-limited tier. +Docs: https://docs.github.com/en/github-models/about-github-models +""" + +import json +import os +import subprocess +import urllib.request +import urllib.error + +# --------------------------------------------------------------------------- +# Configuration — free models only (no premium request multiplier cost) +# --------------------------------------------------------------------------- +MODELS = [ + { + "id": "openai/gpt-4o-mini", + "label": "Agent 1 · `openai/gpt-4o-mini`", + "system": ( + "You are a concise code reviewer. Provide clear, actionable feedback " + "focused on correctness, clarity, and potential issues." + ), + }, + { + "id": "meta/meta-llama-3.1-8b-instruct", + "label": "Agent 2 · `meta/meta-llama-3.1-8b-instruct`", + "system": ( + "You are a thoughtful code reviewer. Focus on logic, edge cases, " + "and documentation quality." + ), + }, +] + +MODELS_ENDPOINT = "https://models.inference.ai.azure.com/chat/completions" +MAX_DIFF_CHARS = 6000 # stay well within free-tier token limits +MAX_TOKENS = 512 +TEMPERATURE = 0.3 +OUTPUT_FILE = "/tmp/cascade_review.md" + + +def get_pr_diff(pr_number: str, repo: str) -> str: + """Fetch the PR diff using the GitHub CLI.""" + try: + result = subprocess.run( + ["gh", "pr", "diff", pr_number, "--repo", repo], + capture_output=True, + text=True, + timeout=30, + ) + diff = result.stdout or "" + return diff[:MAX_DIFF_CHARS] + except Exception as exc: + return f"(diff unavailable: {exc})" + + +def call_model(model_id: str, system_prompt: str, user_prompt: str, token: str) -> str: + """Call one GitHub Models endpoint and return the reply text.""" + payload = json.dumps( + { + "model": model_id, + "messages": [ + {"role": "system", "content": system_prompt}, + {"role": "user", "content": user_prompt}, + ], + "max_tokens": MAX_TOKENS, + "temperature": TEMPERATURE, + } + ).encode() + + req = urllib.request.Request( + MODELS_ENDPOINT, + data=payload, + headers={ + "Authorization": f"Bearer {token}", + "Content-Type": "application/json", + "Accept": "application/vnd.github+json", + }, + method="POST", + ) + try: + with urllib.request.urlopen(req, timeout=60) as resp: + data = json.loads(resp.read()) + return data["choices"][0]["message"]["content"].strip() + except urllib.error.HTTPError as exc: + body = exc.read().decode(errors="replace") + return f"*(model unavailable — HTTP {exc.code}: {body[:200]})*" + except Exception as exc: + return f"*(model unavailable — {exc})*" + + +def main() -> None: + token = os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN", "") + pr_number = os.environ.get("PR_NUMBER", "") + pr_title = os.environ.get("PR_TITLE", "(no title)") + pr_body = os.environ.get("PR_BODY", "")[:1000] + repo = os.environ.get("REPO", "") + + diff = get_pr_diff(pr_number, repo) + + user_prompt = ( + f"**PR title:** {pr_title}\n\n" + f"**PR description:**\n{pr_body}\n\n" + f"**Diff (may be truncated):**\n```diff\n{diff}\n```\n\n" + "Please provide 3–5 bullet points of review feedback." + ) + + sections: list[str] = [] + for model in MODELS: + reply = call_model(model["id"], model["system"], user_prompt, token) + sections.append(f"### {model['label']}\n\n{reply}") + + body = "\n\n---\n\n".join(sections) + comment = ( + "## 🤖 Cascade Review — Multiple Free Agents ($0)\n\n" + "Two independent AI agents reviewed this pull request using the " + "[GitHub Models free tier](https://docs.github.com/en/github-models/about-github-models).\n\n" + "---\n\n" + f"{body}\n\n" + "---\n\n" + "*Cost: $0 — both models used within the GitHub Models free rate-limited tier.*" + ) + + with open(OUTPUT_FILE, "w") as fh: + fh.write(comment) + + print(f"Review written to {OUTPUT_FILE}") + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/cascade-review.yml b/.github/workflows/cascade-review.yml new file mode 100644 index 0000000..a175cb7 --- /dev/null +++ b/.github/workflows/cascade-review.yml @@ -0,0 +1,39 @@ +name: Cascade PR Review — Multiple Free Agents + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: write + +jobs: + cascade-review: + name: Route PR to multiple free AI agents ($0) + runs-on: ubuntu-latest + if: github.event.pull_request.draft == false + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run cascade review via GitHub Models free tier + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_BODY: ${{ github.event.pull_request.body }} + REPO: ${{ github.repository }} + run: | + python3 .github/scripts/cascade_review.py + + - name: Post review comment + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + gh pr comment "$PR_NUMBER" --body-file /tmp/cascade_review.md