interplane.Get Omega
Read in your language

omega-projects

aien-dev/omega-projects

Brought by drakestapleton

GitHub aien-dev/omega-projects#5 (code only)

closed derived 3bb3fde3d0eed36a #5

Imported from GitHub aien-dev/omega-projects#5 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 4f405e1093b923d8252cead889c4669b7e0c3cdf · Head c86e529508399510567de16c009d10c9ce141cc9

Apply it

git checkout -b patch-3bb3fde3d0eed36a 4f405e1093b923d8252cead889c4669b7e0c3cdf
curl -fsSL https://interplane.io/drakestapleton/omega-projects/patches/3bb3fde3d0eed36a.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/omega-projects
5
c86e529508399510567de16c009d10c9ce141cc9
{"kind":"github-import","owner":"aien-dev","repo":"omega-projects","number":5,"url":"https://github.com/aien-dev/omega-projects/pull/5","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:53Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.github/check_projects.py b/.github/check_projects.py
new file mode 100755
index 0000000..250e202
--- /dev/null
+++ b/.github/check_projects.py
@@ -0,0 +1,163 @@
+#!/usr/bin/env python3
+"""Checks every pull request to main: the files Allen's visitors build must stay inside their
+home, be plain allowlisted text, load nothing from elsewhere and carry no secret or personal data.
+
+Run by .github/workflows/project-checks.yml from the main branch's copy of this file (the
+pull request's copy is used only while main has none), with no token and no secrets:
+
+  check_projects.py BASE_REV PR_REV HEAD_REF
+
+Rules (kept in step with allen_build.py / allen_spool.py in aien-dev/aienos.com, which apply
+them before anything is pushed; this check is the second, independent look):
+  - projects/<handle>/<project>/<file> only; handle and project are lowercase names;
+    files: index.html, README.md, meta.json, name.om|js|css|md|txt|patch; no folders below;
+  - UTF-8 text, no control characters, at most 64 KiB a file and 12 files a project;
+  - index.html, .js and .css load or send nothing from elsewhere (no remote script, link,
+    frame, fetch, WebSocket, beacon, import...);
+  - nothing shaped like a key, token or password; no email address anywhere and no phone
+    number in prose or the meta.json title and description (Allen removes them before filing; one here is a leak);
+  - meta.json is the pusher's: exactly its fields, matching the folder, no personal data;
+  - every touched project still has README.md, meta.json and index.html or an .om file;
+  - a branch named u/<handle> or p/<handle>/<project> (Allen's) changes nothing else.
+Exit 0 when every rule holds, 1 with one line per finding otherwise.
+"""
+
+import json
+import re
+import subprocess
+import sys
+
+HANDLE = r"(?:[a-z](?:[a-z0-9]|-(?=[a-z0-9])){1,23}-[0-9a-f]{8}|anon-[0-9a-f]{10})"
+NAME = r"[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?"
+PATH = re.compile(r"^projects/(%s)/(%s)/([^/]+)$" % (HANDLE, NAME))
+FILENAME = re.compile(r"^(?:index\.html|README\.md|meta\.json|[a-z0-9][a-z0-9_-]{0,39}\.(?:om|js|css|md|txt|patch))$")
+WEB = (".html", ".js", ".css")
+PROSE = (".md", ".txt")
+MAX_FILE = 64 * 1024
+MAX_FILES = 12
+META = {"v", "handle", "project", "title", "description", "saved", "item", "built_with", "files"}
+SECRET = [re.compile(p) for p in (
+    r"gh[pousr]_[A-Za-z0-9]{20,}", r"github_pat_[A-Za-z0-9_]{20,}", r"\bsk-[A-Za-z0-9_-]{20,}",
+    r"\bsk-ant-[A-Za-z0-9_-]{10,}", r"\bAKIA[0-9A-Z]{16}\b", r"\bAIza[0-9A-Za-z_-]{30,}",
+    r"xox[abprs]-[A-Za-z0-9-]{10,}", r"-----BEGIN [A-Z ]*PRIVATE KEY-----",
+    r"\beyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.",
+    r"(?i)\b(api[_-]?key|secret|passw(or)?d|access[_-]?token|auth[_-]?token)\b\s*[:=]\s*['\"]?[^\s'\"]{12,}")]
+EXTERNAL = [re.compile(p, re.I) for p in (
+    r"<script\b[^>]*\bsrc\s*=", r"<link\b", r"<iframe\b", r"<object\b", r"<embed\b", r"<base\b",
+    r"<meta\b[^>]*http-equiv", r"\b(src|href|action|formaction|poster|data)\s*=\s*['\"]?\s*(https?:)?//",
+    r"url\(\s*['\"]?\s*(https?:)?//", r"@import\b", r"\bfetch\s*\(", r"XMLHttpRequest", r"WebSocket",
+    r"EventSource", r"sendBeacon", r"\bimport\s*\(", r"\bimportScripts\b", r"\bwindow\.open\b")]
+EMAIL = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")
+PHONE = re.compile(r"(?<![\w.])\+?\d[\d ().-]{7,}\d(?!\w|\.\d)")
+
+
+def git(*args):
+    return subprocess.run(("git",) + args, check=True, capture_output=True).stdout
+
+
+def bad_text(text):
+    for ch in text:
+        o = ord(ch)
+        if ((o < 32 and ch not in "\n\t\r") or o == 127 or 0xD800 <= o <= 0xDFFF or 0xFDD0 <= o <= 0xFDEF
+                or (o & 0xFFFE) == 0xFFFE or o == 0xFFFD):
+            return "a control or binary character"
+    return None
+
+
+def check_file(path, name, handle, project, raw):
+    out = []
+    if not FILENAME.match(name):
+        out.append("file name not allowed (index.html, README.md, meta.json, name.om|js|css|md|txt|patch)")
+        return out
+    if len(raw) > MAX_FILE:
+        out.append("larger than %d KiB" % (MAX_FILE // 1024))
+    try:
+        text = raw.decode("utf-8")
+    except UnicodeDecodeError:
+        return out + ["not UTF-8 text"]
+    why = bad_text(text)
+    if why:
+        out.append("contains " + why)
+    for pat in SECRET:
+        if pat.search(text):
+            out.append("looks like it contains a secret (%s)" % pat.pattern[:30])
+            break
+    if name.endswith(WEB):
+        for pat in EXTERNAL:
+            if pat.search(text):
+                out.append("loads or sends something from elsewhere (%s)" % pat.pattern[:40])
+                break
+    if EMAIL.search(text):
+        out.append("contains an email address")
+    if name.endswith(PROSE) and PHONE.search(text):
+        out.append("contains a phone number")
+    if name == "meta.json":
+        try:
+            m = json.loads(text)
+        except ValueError:
+            return out + ["meta.json is not JSON"]
+        if not isinstance(m, dict) or set(m) != META:
+            out.append("meta.json fields must be exactly %s" % ", ".join(sorted(META)))
+        elif m.get("handle") != handle or m.get("project") != project:
+            out.append("meta.json names another home or project")
+        elif any(PHONE.search(str(m.get(k, ""))) for k in ("title", "description")):
+            out.append("meta.json contains a phone number")
+    return out
+
+
+def main(base, pr, head_ref):
+    findings = []
+    changed = git("diff", "--name-status", "--no-renames", "-z", base, pr).decode().split("\0")
+    entries = [(changed[i], changed[i + 1]) for i in range(0, len(changed) - 1, 2)]
+    allen = re.fullmatch(r"u/(%s)|p/(%s)/(%s)" % (HANDLE, HANDLE, NAME), head_ref)
+    touched = set()
+    for status, path in entries:
+        m = PATH.match(path)
+        if not path.startswith("projects/") or path == "projects/README.md":
+            if allen:
+                findings.append("%s: a branch from Allen may only change its own project folder" % path)
+            elif path.startswith(".github/"):
+                print("note: %s changes the repository's automation; review it by hand" % path)
+            continue
+        if not m:
+            findings.append("%s: outside projects/<handle>/<project>/<file>" % path)
+            continue
+        handle, project, name = m.groups()
+        if allen and allen.group(2) and (handle, project) != (allen.group(2), allen.group(3)):
+            findings.append("%s: branch %s may only change projects/%s/%s/" % (path, head_ref, allen.group(2),
+                                                                             allen.group(3)))
+        if allen and allen.group(1) and handle != allen.group(1):
+            findings.append("%s: branch %s may only change projects/%s/" % (path, head_ref, allen.group(1)))
+        touched.add((handle, project))
+        if status == "D":
+            continue
+        mode = git("ls-tree", pr, "--", path).decode().split(" ", 1)[0]
+        if mode != "100644":
+            findings.append("%s: must be a plain file (mode %s)" % (path, mode or "?"))
+            continue
+        for f in check_file(path, name, handle, project, git("show", "%s:%s" % (pr, path))):
+            findings.append("%s: %s" % (path, f))
+    for handle, project in sorted(touched):
+        d = "projects/%s/%s/" % (handle, project)
+        names = [p[len(d):] for p in git("ls-tree", "-r", "--name-only", pr, "--", d).decode().splitlines()]
+        if not names:
+            continue  # the project was removed
+        if any("/" in n for n in names):
+            findings.append("%s: no folders inside a project" % d)
+        if len(names) > MAX_FILES + 1:
+            findings.append("%s: more than %d files" % (d, MAX_FILES))
+        for need in ("README.md", "meta.json"):
+            if need not in names:
+                findings.append("%s: needs %s" % (d, need))
+        if not any(n == "index.html" or n.endswith(".om") for n in names):
+            findings.append("%s: needs index.html or an .om file" % d)
+    for f in findings:
+        print("FAIL " + f)
+    print("%d changed file(s), %d project(s), %d finding(s)" % (len(entries), len(touched), len(findings)))
+    return 1 if findings else 0
+
+
+if __name__ == "__main__":
+    if len(sys.argv) != 4:
+        sys.exit(__doc__)
+    sys.exit(main(*sys.argv[1:]))
diff --git a/.github/workflows/project-checks.yml b/.github/workflows/project-checks.yml
new file mode 100644
index 0000000..88af79e
--- /dev/null
+++ b/.github/workflows/project-checks.yml
@@ -0,0 +1,36 @@
+# Checks every pull request to main with .github/check_projects.py.
+# pull_request only (never pull_request_target): the run gets a read-only token and no
+# secrets, and no action is used at all: plain git and python3 from the runner image.
+# The checker comes from main, so a pull request cannot loosen the rules it is checked by.
+name: project checks
+on:
+  pull_request:
+    branches: [main]
+permissions:
+  contents: read
+concurrency:
+  group: project-checks-${{ github.event.pull_request.number }}
+  cancel-in-progress: true
+jobs:
+  check:
+    runs-on: ubuntu-24.04
+    timeout-minutes: 5
+    steps:
+      - name: Check the pull request's files
+        env:
+          PR: ${{ github.event.pull_request.number }}
+          REPO: ${{ github.repository }}
+          HEAD_REF: ${{ github.head_ref }}
+        run: |
+          set -eu
+          git init -q work && cd work
+          url="https://github.com/$REPO"
+          git fetch -q --no-tags --depth=2 "$url" "+refs/pull/$PR/merge:refs/check/pr"
+          git fetch -q --no-tags --depth=1 "$url" "+refs/heads/main:refs/check/main"
+          if git cat-file -e refs/check/main:.github/check_projects.py 2>/dev/null; then
+            git show refs/check/main:.github/check_projects.py > ../check.py
+          else
+            echo "main has no checker yet; using this pull request's copy"
+            git show refs/check/pr:.github/check_projects.py > ../check.py
+          fi
+          python3 ../check.py refs/check/pr^1 refs/check/pr "$HEAD_REF"
diff --git a/README.md b/README.md
index 8857d60..0f05e92 100644
--- a/README.md
+++ b/README.md
@@ -2,13 +2,21 @@
 
 Every project anyone builds with Allen at [aienos.com/allen/](https://www.aienos.com/allen/) goes here.
 
-- Each project lives in `projects/<slug>/`: an `index.html` that runs in the browser, the Omega
-  source (`<name>.om`), a `README.md` and a `meta.json` (slug, title, description, submission date,
-  item id; no personal data).
-- Allen never publishes anything. A project arrives as a pull request on a `submissions/<slug>-<id>`
-  branch. Drake reviews every project before it goes live; only Drake's merge to `main` publishes it.
+- Every builder has a home, `projects/<handle>/`, and each project lives in
+  `projects/<handle>/<project>/`: a `README.md` (what it is and who it helps), the source (`index.html`
+  that runs in the browser, Omega `<name>.om`, `.js`, `.css`, notes), and a `meta.json` written by
+  Allen's filing service (handle, project, title, description, date, item id, file list; no personal
+  data). A handle is a chosen name plus a tag tied to the visitor's Allen key (`ada-1a2b3c4d`), or a
+  one-time `anon-...` handle for anonymous builders; never an email address.
+- **Save** commits the project to the builder's branch `u/<handle>`, viewable here at once.
+- **Publish** opens a pull request from `p/<handle>/<project>` to `main`. Allen never merges and never
+  writes `main`; Drake reviews every project and only his merge publishes it ("Built with Allen").
+- Every pull request to `main` runs `project checks` (`.github/workflows/project-checks.yml`):
+  `pull_request` only, read-only token, no secrets, no third-party actions; the checker comes from
+  `main` and enforces the file allowlist, size caps, no external loads, and the secret and personal
+  data scan.
 - Live projects are served by GitHub Pages from `main` at
-  `https://aien-dev.github.io/omega-projects/projects/<slug>/`.
+  `https://aien-dev.github.io/omega-projects/projects/<handle>/<project>/`.
 - Issues filed from [aienos.com/allen/](https://www.aienos.com/allen/) arrive here labelled
   `from-allen`, with an `area:<repo>` label naming the repository they concern, and are transferred
   to the right repository.
diff --git a/index.html b/index.html
index e923a8e..2d412a6 100644
--- a/index.html
+++ b/index.html
@@ -18,7 +18,7 @@ Drake reviews every project before it goes live here.</p>
 <ul id="projects">
 <li>No projects are live yet.</li>
 </ul>
-<p>Each live project is served at <code>projects/&lt;slug&gt;/</code> under this address.</p>
+<p>Each live project is served at <code>projects/&lt;handle&gt;/&lt;project&gt;/</code> under this address.</p>
 <p><a href="https://github.com/aien-dev/omega-projects">Source on GitHub</a></p>
 </body>
 </html>
diff --git a/projects/README.md b/projects/README.md
index ad767be..17af45e 100644
--- a/projects/README.md
+++ b/projects/README.md
@@ -1,7 +1,8 @@
 # Projects
 
-One directory per project: `projects/<slug>/` with `index.html`, `<name>.om`, `README.md` and
-`meta.json`. Submissions arrive as pull requests from Allen at https://www.aienos.com/allen/ and go
-live only after Drake reviews and merges them.
+One home per builder, one directory per project: `projects/<handle>/<project>/` with `README.md`,
+`meta.json` and `index.html` or `<name>.om` (plus optional `.js`, `.css`, `.md`, `.txt`, `.patch`).
+Saves land on `u/<handle>`; published projects arrive as pull requests from `p/<handle>/<project>`
+via Allen at https://www.aienos.com/allen/ and go live only after Drake reviews and merges them.
 
 No projects are live yet.
diff --git a/projects/ci-control-0a1b2c3d/calculator/README.md b/projects/ci-control-0a1b2c3d/calculator/README.md
new file mode 100644
index 0000000..de875d0
--- /dev/null
+++ b/projects/ci-control-0a1b2c3d/calculator/README.md
@@ -0,0 +1,3 @@
+# Calculator (CI control)
+
+Positive control for project checks. Adds two numbers; helps check the CI passes clean projects.
diff --git a/projects/ci-control-0a1b2c3d/calculator/index.html b/projects/ci-control-0a1b2c3d/calculator/index.html
new file mode 100644
index 0000000..14ff088
--- /dev/null
+++ b/projects/ci-control-0a1b2c3d/calculator/index.html
@@ -0,0 +1 @@
+<!doctype html><meta charset="utf-8"><title>calc</title><p id=o></p><script>document.getElementById("o").textContent = 2 + 3;</script>
diff --git a/projects/ci-control-0a1b2c3d/calculator/meta.json b/projects/ci-control-0a1b2c3d/calculator/meta.json
new file mode 100644
index 0000000..f6ccb01
--- /dev/null
+++ b/projects/ci-control-0a1b2c3d/calculator/meta.json
@@ -0,0 +1 @@
+{"v":1,"handle":"ci-control-0a1b2c3d","project":"calculator","title":"Calculator (CI control)","description":"Positive control for project checks.","saved":"2026-10-26","item":"00000000000000000000","built_with":"Allen","files":["README.md","index.html"]}