{"messages":[{"content":"You are a constitutional council ranking individual git commits for ownership allocation.\n\nCompare these two commits. Decide which contributed more lasting value to the project.\n\nJudge substance, not spectacle:\n- Prefer correct, lasting design and real bugfixes over churn, formatting, renames, or generated noise.\n- Prefer clarity and necessity over sheer line count. A small precise change can beat a large diffuse one.\n- Do not favor a side merely because its patch is longer or noisier.\n- Weight what the change does for the project, not the contributor's name.\n\nReturn ONLY a JSON object: {\"winner\": \"A\" or \"B\", \"ratio\": \"N:M\", \"explanation\": \"...\"}\nThe explanation must cite concrete differences in the patches (1-3 sentences).\n\nSide A — contributor: tommy-mor\nSide A — commit message:\n[075d4d37] Fix OAuth test mocks so Clojure E2E auth flows work again.\n\nHttpServer handlers were crashing on query parsing and token POSTs, which broke Playwright login; also read alias/history via real CSS selectors.\n\nCo-authored-by: Cursor \n\nSide A — unified diff (full patch):\ndiff --git a/test/auth_login.clj b/test/auth_login.clj\nindex 6f2f00d7aa7340e63d1ac465b0a2234cec7a983f..aa63b66ccb2471b710ba3d168d0461252b39fc10 100644\n--- a/test/auth_login.clj\n+++ b/test/auth_login.clj\n@@ -14,27 +14,27 @@\n (defn- type-alias! [pg text]\n (page/evaluate pg\n (.replace\n- \"(() => { const i = document.getElementById('alias-input'); const f = document.getElementById('alias-check-form'); if (!i || !f) return;\n+ \"(() => { const i = document.getElementById('alias-input'); const f = document.getElementById('alias-check-form'); if (!i || !f) return Promise.resolve('missing-form');\n i.value = __TEXT__;\n const cf = document.getElementById('alias-claim-field'); if (cf) cf.value = i.value;\n return fetch(f.action, { method: 'POST', credentials: 'same-origin',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams(new FormData(f)).toString() })\n .then(function (r) { return r.text(); })\n- .then(function (t) { eval(t); }); })()\"\n+ .then(function (t) { eval(t); return document.getElementById('alias-status')?.textContent || ''; }); })()\"\n \"__TEXT__\"\n- (pr-str text)))\n- (Thread/sleep 400))\n+ (pr-str text))))\n \n-(defn- element-text [pg test-id]\n+(defn- element-text [pg selector]\n (let [raw (page/evaluate pg\n- (str \"document.querySelector('[data-testid=\\\"\" test-id \"\\\"]')?.textContent || ''\"))]\n+ (str \"document.querySelector(\" (pr-str selector) \")?.textContent || ''\"))]\n (when (string? raw) (str/trim raw))))\n \n (defn- wait-for-text [pg test-id text timeout-ms]\n- (let [deadline (+ (System/currentTimeMillis) timeout-ms)]\n+ (let [deadline (+ (System/currentTimeMillis) timeout-ms)\n+ selector (str \"[data-testid=\\\"\" test-id \"\\\"]\")]\n (loop []\n- (let [got (or (element-text pg test-id) \"\")]\n+ (let [got (or (element-text pg selector) \"\")]\n (cond\n (= got text) got\n (< (System/currentTimeMillis) deadline) (do (Thread/sleep 200) (recur))\ndiff --git a/test/support/mock_oauth.clj b/test/support/mock_oauth.clj\nindex 5ba7e9be3cf6d2226648e9609a09ed45f306930f..333fe08d56cb06bac2a338cad1c73894d54c4495 100644\n--- a/test/support/mock_oauth.clj\n+++ b/test/support/mock_oauth.clj\n@@ -7,7 +7,7 @@\n (defn- query-param [query key]\n (when query\n (some (fn [pair]\n- (let [[k v] (str/split pair \"=\" 2)]\n+ (let [[k v] (str/split pair #\"=\" 2)]\n (when (= k key)\n (URLDecoder/decode (or v \"\") \"UTF-8\"))))\n (str/split query #\"&\"))))\n@@ -31,11 +31,11 @@\n \n (defn- send-redirect [^HttpExchange ex location]\n (.set (.getResponseHeaders ex) \"Location\" location)\n- (.sendResponseHeaders ex 302 -1)\n+ (.sendResponseHeaders ex 302 0)\n (.close (.getResponseBody ex)))\n \n (defn- read-form [^HttpExchange ex]\n- (let [body (slurp (.getInputStream ex))]\n+ (let [body (slurp (.getRequestBody ex))]\n {:code (query-param body \"code\")\n :grant (query-param body \"grant_type\")}))\n \n@@ -45,7 +45,7 @@\n (str/replace #\"^[Bb]earer \" \"\")))\n \n (defn- parse-token-user [token]\n- (when (str/starts-with? token \"mock:\")\n+ (when (and token (str/starts-with? token \"mock:\"))\n (parse-mock-user (subs token 5))))\n \n (defn- authorize-redirect [exchange query]\n@@ -55,7 +55,7 @@\n user (parse-mock-user mock-user)\n code (str \"mock:\" (:id user) \":\" (:login user))\n loc (str redirect-uri \"?code=\" (java.net.URLEncoder/encode code \"UTF-8\")\n- \"&state=\" (java.net.URLEncoder/encode state \"UTF-8\"))]\n+ \"&state=\" (java.net.URLEncoder/encode (or state \"\") \"UTF-8\"))]\n (send-redirect exchange loc)))\n \n (defn start-mock-oauth\n@@ -65,49 +65,56 @@\n handler\n (proxy [HttpHandler] []\n (handle [^HttpExchange exchange]\n- (let [uri (.getRequestURI exchange)\n- path (.getPath uri)\n- query (.getQuery uri)\n- method (.getRequestMethod exchange)]\n- (cond\n- ;; GitHub authorize\n- (str/ends-with? path \"/login/oauth/authorize\")\n- (authorize-redirect exchange query)\n+ (try\n+ (let [uri (.getRequestURI exchange)\n+ path (.getPath uri)\n+ query (.getQuery uri)\n+ method (.getRequestMethod exchange)]\n+ (cond\n+ ;; GitHub authorize\n+ (str/ends-with? path \"/login/oauth/authorize\")\n+ (authorize-redirect exchange query)\n \n- ;; Reddit authorize\n- (str/ends-with? path \"/api/v1/authorize\")\n- (authorize-redirect exchange query)\n+ ;; Reddit authorize\n+ (str/ends-with? path \"/api/v1/authorize\")\n+ (authorize-redirect exchange query)\n \n- ;; GitHub token\n- (and (= method \"POST\") (str/ends-with? path \"/login/oauth/access_token\"))\n- (let [code (or (:code (read-form exchange)) \"mock:1002:newbie\")]\n- (send-json exchange 200 (str \"{\\\"access_token\\\":\\\"\" code \"\\\",\\\"token_type\\\":\\\"bearer\\\"}\")))\n+ ;; GitHub token\n+ (and (= method \"POST\") (str/ends-with? path \"/login/oauth/access_token\"))\n+ (let [code (or (:code (read-form exchange)) \"mock:1002:newbie\")]\n+ (send-json exchange 200 (str \"{\\\"access_token\\\":\\\"\" code \"\\\",\\\"token_type\\\":\\\"bearer\\\"}\")))\n \n- ;; Reddit token (client_credentials for import + authorization_code for login)\n- (and (= method \"POST\") (str/ends-with? path \"/api/v1/access_token\"))\n- (let [form (read-form exchange)\n- grant (or (:grant form) \"\")\n- code (or (:code form) \"mock:t2_test:redditor\")]\n- (if (= grant \"client_credentials\")\n- (send-json exchange 200 \"{\\\"access_token\\\":\\\"app-token\\\",\\\"token_type\\\":\\\"bearer\\\",\\\"expires_in\\\":3600}\")\n- (send-json exchange 200 (str \"{\\\"access_token\\\":\\\"\" code \"\\\",\\\"token_type\\\":\\\"bearer\\\",\\\"expires_in\\\":3600}\"))))\n+ ;; Reddit token (client_credentials for import + authorization_code for login)\n+ (and (= method \"POST\") (str/ends-with? path \"/api/v1/access_token\"))\n+ (let [form (read-form exchange)\n+ grant (or (:grant form) \"\")\n+ code (or (:code form) \"mock:t2_test:redditor\")]\n+ (if (= grant \"client_credentials\")\n+ (send-json exchange 200 \"{\\\"access_token\\\":\\\"app-token\\\",\\\"token_type\\\":\\\"bearer\\\",\\\"expires_in\\\":3600}\")\n+ (send-json exchange 200 (str \"{\\\"access_token\\\":\\\"\" code \"\\\",\\\"token_type\\\":\\\"bearer\\\",\\\"expires_in\\\":3600}\"))))\n \n- ;; GitHub user\n- (= path \"/user\")\n- (let [token (bearer-token exchange)\n- user (or (parse-token-user token) {:id \"1002\" :login \"newbie\" :numeric? true})]\n- (send-json exchange 200\n- (str \"{\\\"id\\\":\" (:id user) \",\\\"login\\\":\\\"\" (:login user) \"\\\"}\")))\n+ ;; GitHub user\n+ (= path \"/user\")\n+ (let [token (bearer-token exchange)\n+ user (or (parse-token-user token) {:id \"1002\" :login \"newbie\" :numeric? true})]\n+ (send-json exchange 200\n+ (str \"{\\\"id\\\":\" (:id user) \",\\\"login\\\":\\\"\" (:login user) \"\\\"}\")))\n \n- ;; Reddit /api/v1/me\n- (str/ends-with? path \"/api/v1/me\")\n- (let [token (bearer-token exchange)\n- user (or (parse-token-user token) {:id \"t2_test\" :login \"redditor\"})]\n- (send-json exchange 200\n- (str \"{\\\"id\\\":\\\"\" (:id user) \"\\\",\\\"name\\\":\\\"\" (:login user) \"\\\"}\")))\n+ ;; Reddit /api/v1/me\n+ (str/ends-with? path \"/api/v1/me\")\n+ (let [token (bearer-token exchange)\n+ user (or (parse-token-user token) {:id \"t2_test\" :login \"redditor\"})]\n+ (send-json exchange 200\n+ (str \"{\\\"id\\\":\\\"\" (:id user) \"\\\",\\\"name\\\":\\\"\" (:login user) \"\\\"}\")))\n \n- :else\n- (send-json exchange 404 \"{\\\"error\\\":\\\"not found\\\"}\")))))]\n+ :else\n+ (send-json exchange 404 \"{\\\"error\\\":\\\"not found\\\"}\")))\n+ (catch Throwable t\n+ (binding [*out* *err*]\n+ (println \"mock-oauth handler error:\" t))\n+ (try\n+ (send-json exchange 500 \"{\\\"error\\\":\\\"mock-oauth internal\\\"}\")\n+ (catch Throwable _))))))]\n (.createContext server \"/\" handler)\n (.setExecutor server nil)\n (.start server)\ndiff --git a/test/support/mock_reddit.clj b/test/support/mock_reddit.clj\nindex a630cf0938722193e9af88382d60e777ff371be4..faa27945b6394363914c853627a0bad1e819a5f9 100644\n--- a/test/support/mock_reddit.clj\n+++ b/test/support/mock_reddit.clj\n@@ -12,7 +12,7 @@\n (defn- query-param [query key]\n (when query\n (some (fn [pair]\n- (let [[k v] (str/split pair \"=\" 2)]\n+ (let [[k v] (str/split pair #\"=\" 2)]\n (when (= k key)\n (URLDecoder/decode (or v \"\") \"UTF-8\"))))\n (str/split query #\"&\"))))\n@@ -34,11 +34,11 @@\n \n (defn- send-redirect [^HttpExchange ex location]\n (.set (.getResponseHeaders ex) \"Location\" location)\n- (.sendResponseHeaders ex 302 -1)\n+ (.sendResponseHeaders ex 302 0)\n (.close (.getResponseBody ex)))\n \n (defn- read-form [^HttpExchange ex]\n- (let [body (slurp (.getInputStream ex))]\n+ (let [body (slurp (.getRequestBody ex))]\n {:code (query-param body \"code\")\n :grant (query-param body \"grant_type\")}))\n \n@@ -48,7 +48,7 @@\n (str/replace #\"^[Bb]earer \" \"\")))\n \n (defn- parse-token-user [token]\n- (when (str/starts-with? token \"mock:\")\n+ (when (and token (str/starts-with? token \"mock:\"))\n (parse-mock-user (subs token 5))))\n \n (defn start-mock-reddit\n@@ -72,7 +72,7 @@\n user (parse-mock-user (query-param query \"mock_user\"))\n code (str \"mock:\" (:id user) \":\" (:login user))\n loc (str redirect-uri \"?code=\" (java.net.URLEncoder/encode code \"UTF-8\")\n- \"&state=\" (java.net.URLEncoder/encode state \"UTF-8\"))]\n+ \"&state=\" (java.net.URLEncoder/encode (or state \"\") \"UTF-8\"))]\n (send-redirect exchange loc))\n \n (and (= method \"POST\") (str/ends-with? path \"/api/v1/access_token\"))\n\n\nSide B — contributor: tommy-mor\nSide B — commit message:\n[0d3270d1] Fix GitHub OAuth callback NameError on missing API base URL.\n\nCo-authored-by: Cursor \n\nSide B — unified diff (full patch):\ndiff --git a/constitution.py b/constitution.py\nindex f819007252f435680b8356fb4da83469b21e33af..4dd5b9dfbba231d46289c490f91b1dd5b1018bcf 100644\n--- a/constitution.py\n+++ b/constitution.py\n@@ -119,6 +119,9 @@ JSONL_PATH = pathlib.Path(os.environ.get(\"JSONL_PATH\", \"/data/ledger.jsonl\"))\n \n GITHUB_CLIENT_ID = os.environ.get(\"GITHUB_CLIENT_ID\", \"\")\n GITHUB_CLIENT_SECRET = os.environ.get(\"GITHUB_CLIENT_SECRET\", \"\")\n+GITHUB_API_BASE_URL = os.environ.get(\n+ \"GITHUB_API_BASE_URL\", \"https://api.github.com\"\n+).rstrip(\"/\")\n \n OPENROUTER_API_KEY = os.environ.get(\"OPENROUTER_API_KEY\", \"\")\n OPENROUTER_BASE_URL = os.environ.get(\"OPENROUTER_BASE_URL\", \"https://openrouter.ai\").rstrip(\"/\")\n","role":"user"}],"model":"~anthropic/claude-sonnet-latest"}