Skip to content
Draft
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
44 changes: 44 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +11 to +13
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This claims the code/ scripts have no external dependencies except matplotlib for lorenz.py, but code/hue_man.py imports numpy and scipy. Update the repo instructions so agents don’t assume a dependency-free runtime.

Copilot uses AI. Check for mistakes.
- `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.
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says there are “no linting configs or CI pipelines defined”, but this PR adds a GitHub Actions workflow under .github/workflows/. Update this section to avoid contradicting the repo’s actual CI setup.

Suggested change
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.
There are no automated tests or dedicated linting configuration files. To validate changes to Python scripts, run them directly and confirm they produce expected output without errors. A basic GitHub Actions workflow exists under `.github/workflows/`, but it does not replace manual validation.

Copilot uses AI. Check for mistakes.

## 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
136 changes: 136 additions & 0 deletions .github/scripts/cascade_review.py
Original file line number Diff line number Diff line change
@@ -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})"
Comment on lines +55 to +59
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_pr_diff ignores gh pr diff failures (non-zero returncode) and will silently return an empty/truncated diff, producing low-signal reviews. Check result.returncode (or run with check=True) and include stderr in the error so the workflow fails loudly when diff retrieval breaks.

Suggested change
)
diff = result.stdout or ""
return diff[:MAX_DIFF_CHARS]
except Exception as exc:
return f"(diff unavailable: {exc})"
check=True,
)
diff = result.stdout or ""
return diff[:MAX_DIFF_CHARS]
except subprocess.CalledProcessError as exc:
stderr = (exc.stderr or "").strip()
message = f"gh pr diff failed with exit code {exc.returncode}"
if stderr:
message += f": {stderr}"
raise RuntimeError(message) from exc
except Exception as exc:
raise RuntimeError(f"Unexpected error while fetching PR diff: {exc}") from exc

Copilot uses AI. Check for mistakes.


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)

Comment on lines +97 to +105
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main() proceeds even if PR_NUMBER, REPO, or the token are missing/empty, which will generate misleading “model unavailable” output and still post a comment. Validate these env vars up front and exit non-zero (so the workflow fails) when required inputs are not present.

Copilot uses AI. Check for mistakes.
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."
)
Comment on lines +106 to +111
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated Markdown wraps the PR diff in a fenced code block, but neither the PR body nor the diff are escaped for occurrences of triple backticks. If either contains ``` the resulting PR comment can render incorrectly. Consider escaping/backtick-neutralizing fence sequences before embedding.

Copilot uses AI. Check for mistakes.

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()
39 changes: 39 additions & 0 deletions .github/workflows/cascade-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Cascade PR Review — Multiple Free Agents

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read
pull-requests: write

Comment on lines +3 to +10
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow is triggered by pull_request, but for PRs from forks the GITHUB_TOKEN will be read-only regardless of pull-requests: write, so the gh pr comment step will fail. Consider either skipping the comment/posting steps for forked PRs, or switching to pull_request_target with a safe checkout strategy (use base repo code only) if you need to comment on fork PRs.

Copilot uses AI. Check for mistakes.
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
Comment on lines +38 to +39
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On synchronize this will create a new PR comment every push (gh pr comment always posts a new comment), which can quickly spam long-lived PRs. Prefer updating an existing “Cascade Review” comment (e.g., find by marker and edit) or using an action that supports create-or-update semantics.

Suggested change
run: |
gh pr comment "$PR_NUMBER" --body-file /tmp/cascade_review.md
REPO: ${{ github.repository }}
run: |
set -euo pipefail
MARKER="<!-- CASCADE_REVIEW_COMMENT -->"
BODY_FILE="/tmp/cascade_review_with_marker.md"
# Prepend a stable marker so we can find/update this comment later.
{
echo "$MARKER"
cat /tmp/cascade_review.md
} > "$BODY_FILE"
# Look for an existing Cascade Review comment on this PR.
EXISTING_COMMENT_ID="$(
gh api \
"repos/$REPO/issues/$PR_NUMBER/comments" \
--paginate \
--jq "[.[] | select(.body | contains(\"$MARKER\"))][0].id // empty"
)"
if [ -n "${EXISTING_COMMENT_ID:-}" ]; then
# Update the existing comment.
gh api \
"repos/$REPO/issues/comments/$EXISTING_COMMENT_ID" \
-X PATCH \
-f body=@"$BODY_FILE"
else
# Create a new comment (first run on this PR).
gh api \
"repos/$REPO/issues/$PR_NUMBER/comments" \
-f body=@"$BODY_FILE"
fi

Copilot uses AI. Check for mistakes.