Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

Add Grok 4.6 vs 4.7 Build eval receipts

justrach036a1b89e4bb
diff --git a/evals/grok-46-vs-47/RESULTS.md b/evals/grok-46-vs-47/RESULTS.md
new file mode 100644
index 00000000..3d22b427
--- /dev/null
+++ b/evals/grok-46-vs-47/RESULTS.md
@@ -0,0 +1,59 @@
+# Grok 4.6 vs Grok 4.7 on three codegraff PRs
+
+Single-turn Grok Build calls, `reasoning_effort=high`, tools off. Both models saw the same closed-book prompt: the bug, the relevant pre-change excerpt, and a request for one unified diff. Gold diffs are in `gold/`. Raw CLI JSON is in `runs/`.
+
+Models resolved to `grok-4.6-build` and `grok-4.7-build`. This is the Build the CLI is logged into, not a separate public HTTPS call.
+
+## Same price means the published card
+
+Public list for both model names, under 200k prompt tokens: **$2 / 1M input, $0.50 / 1M cached input, $6 / 1M output**. Reasoning tokens are inside output. That is the card in the Grok 4.7 docs and the Grok 4.6 docs.
+
+`grok-4.7-build` receipts matched that card to the fraction of a cent on every run, and on a one-word probe before these runs (`$0.048194`).
+
+`grok-4.6-build` receipts were **exactly 0.34×** that card on all three runs. They do not match 1× list, 2× Fast, or `grok-build-0.1` ($1 / $2). The comparison below prices both models on the published card so a Build billing quirk is not treated as a model win. The receipt column is what the CLI actually printed.
+
+## Latency, tokens, cost
+
+| PR | Model | Wall | In | Cache | Out | Reasoning | Completion | Build receipt | List cost |
+| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
+| 1149 | 4.6 | 109s | 17,502 | 256 | 5,962 | 5,461 | 501 | $0.02411 | $0.07090 |
+| 1149 | 4.7 | 334s | 15,922 | 1,152 | 22,958 | 22,438 | 520 | $0.17017 | $0.17017 |
+| 1096 | 4.6 | 139s | 18,669 | 0 | 8,064 | 7,036 | 1,028 | $0.02915 | $0.08572 |
+| 1096 | 4.7 | 270s | 15,713 | 1,152 | 19,450 | 18,435 | 1,015 | $0.14870 | $0.14870 |
+| 1035 | 4.6 | 260s | 16,846 | 1,920 | 15,551 | 14,319 | 1,232 | $0.04351 | $0.12796 |
+| 1035 | 4.7 | 748s | 16,958 | 1,152 | 52,540 | 50,930 | 1,610 | $0.34973 | $0.34973 |
+| all | 4.6 | 507s | 53,017 | 2,176 | 29,577 | 26,816 | 2,761 | $0.09676 | $0.28458 |
+| all | 4.7 | 1,351s | 48,593 | 3,456 | 94,948 | 91,803 | 3,145 | $0.66860 | $0.66860 |
+
+Visible completions are about the same length. 4.7's extra time and list-price cost are almost entirely reasoning tokens (3.4×). Output throughput including reasoning was 58 tok/s for 4.6 and 70 tok/s for 4.7, so 4.7 is not a slower decoder. It just thinks longer.
+
+Pairs ran concurrently (same prompt, same window). PRs ran one pair after another. Wall time is each process's own clock.
+
+## What was asked
+
+- **#1149** tests only. A same-team `TEAM.*` keychain group must not authorize another bundle. `signBundle` must reject that profile before the signer runs.
+- **#1096** the `@` menu must not activate its default row on Enter/Tab until `engaged` is set by hover or arrow keys. Unengaged Enter still submits.
+- **#1035** drop `{pid}-{hex}.accord.sock` only when `proc_identity.stateOf` is `.reclaimable`. Unknown stays. Do not unlink the live listener's own sock. Sweep on listen.
+
+## Checklist (8 each)
+
+Scored against the merged diff's behavior, not against a byte-identical patch. These prompts did not include the full files, so none of the diffs are `patch -p1` clean. That miss is shared and is not in the checklist.
+
+**#1149.** Profile test, different application id, explicit `TEAM.*` groups, `authorize` throws, gold `/provisioning profile/` regex, `signBundle` test, signer not called, other-bundle profile injected.
+
+- 4.6 hit 6. It changed the application id (the fixture already has `TEAM.*`) and rejected before the signer. It did not set the groups explicitly, and the regex was `/application-identifier/` rather than `/provisioning profile/`.
+- 4.7 hit 7. Same shape, plus an explicit `TEAM.*` assignment. Same wrong regex.
+
+**#1096.** Helper predicate, PromptBar wired to it, unengaged Enter/Tab false, engaged Enter/Tab true, Shift does not activate, arrows are not activation, package.json gains the new test without dropping the others, tests use `node:test`.
+
+- Both hit 7. The predicate matches the merged helper (`engaged && !shiftKey && (Enter || Tab)`). Both rewrote the `test` script down to two files, which would drop the rest of the native suite. 4.7 used `node:test`'s `test()`; 4.6 used `describe`/`it`, which still runs.
+
+**#1035.** Parse `42-2a.accord.sock`, reject junk and non-positive pids, unlink only when reclaimable, unknown stays, skip own sock, do not dial an unlinked sock, sweep on listen, tests would compile against the real `listen` / `livePost` / `writeFile` signatures.
+
+- Both hit 7. The reclaim rule is right. Both tests call `listen` and `livePost` with the wrong arity and would not compile. 4.7's parser also rejects non-hex stems. 4.6 uses the first dash, not the last; for this name format that is the same split.
+
+## Reading
+
+On this sample, high-effort 4.7 is not a better patch author. It wins one checklist point on #1149 and ties the other two. At the shared list price it costs 2.3× as much and takes 2.7× as long, because it spends about 22k–51k reasoning tokens to emit a completion of similar length.
+
+n=3, one turn, no tools, no apply-and-test loop. A longer agent run could change the quality gap. It would not change the token shape seen here: 4.7's bill is reasoning.
diff --git a/evals/grok-46-vs-47/gold/1035.diff b/evals/grok-46-vs-47/gold/1035.diff
new file mode 100644
index 00000000..c41e1319
--- /dev/null
+++ b/evals/grok-46-vs-47/gold/1035.diff
@@ -0,0 +1,104 @@
+diff --git a/src/presence_accord.zig b/src/presence_accord.zig
+index 13fdec4f..2c306410 100644
+--- a/src/presence_accord.zig
++++ b/src/presence_accord.zig
+@@ -7,6 +7,7 @@ const builtin = @import("builtin");
+ const Io = std.Io;
+ const net = std.Io.net;
+ const accord = @import("accord");
++const proc_identity = @import("proc_identity.zig");
+
+ pub const env_var = "GRAFF_ACCORD";
+ pub const sock_env = "GRAFF_ACCORD_SOCK";
+@@ -134,18 +135,52 @@ pub fn livePost(io: Io, gpa: std.mem.Allocator, chan_name: []const u8, json_line
+ while (it.next(io) catch null) |entry| {
+ if (!std.mem.endsWith(u8, entry.name, ".accord.sock")) continue;
+ if (g_own_name) |own| if (std.mem.eql(u8, entry.name, own)) continue;
++ if (dropDeadSock(io, dir_path, entry.name)) continue;
+ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir_path, entry.name }) catch continue;
+ sendLine(io, gpa, path, json_line) catch {};
+ }
+ }
+
++fn parseSockName(name: []const u8) ?proc_identity.Record {
++ const suffix = ".accord.sock";
++ if (!std.mem.endsWith(u8, name, suffix)) return null;
++ const stem = name[0 .. name.len - suffix.len];
++ const dash = std.mem.lastIndexOfScalar(u8, stem, '-') orelse return null;
++ if (dash == 0 or dash + 1 >= stem.len) return null;
++ const pid = std.fmt.parseInt(i32, stem[0..dash], 10) catch return null;
++ const start_id = std.fmt.parseInt(u64, stem[dash + 1 ..], 16) catch return null;
++ if (pid <= 0) return null;
++ return .{ .pid = pid, .start_id = start_id };
++}
++
++/// Unlink only when the recorded owner is provably gone (#413). Unknown stays.
++fn dropDeadSock(io: Io, dir_path: []const u8, name: []const u8) bool {
++ const rec = parseSockName(name) orelse return false;
++ if (proc_identity.stateOf(io, rec) != .reclaimable) return false;
++ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
++ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir_path, name }) catch return false;
++ Io.Dir.cwd().deleteFile(io, path) catch return false;
++ return true;
++}
++
++fn sweepDead(io: Io, dir_path: []const u8) void {
++ var dir = Io.Dir.cwd().openDir(io, dir_path, .{ .iterate = true }) catch return;
++ defer dir.close(io);
++ var it = dir.iterate();
++ while (it.next(io) catch null) |entry| {
++ if (!std.mem.endsWith(u8, entry.name, ".accord.sock")) continue;
++ _ = dropDeadSock(io, dir_path, entry.name);
++ }
++}
++
+ /// Bind `{live_dir}/{pid}-{start}.accord.sock` and accept live posts.
+ pub fn listen(io: Io, gpa: std.mem.Allocator, dir_path: ?[]const u8) void {
+ if (!enabled()) return;
+ if (builtin.os.tag == .windows) return;
+ if (g_listener != null) return;
+ const dir = dir_path orelse return;
+- const self = @import("proc_identity.zig").selfRecord(io);
++ sweepDead(io, dir);
++ const self = proc_identity.selfRecord(io);
+ var name_buf: [64]u8 = undefined;
+ const name = std.fmt.bufPrint(&name_buf, "{d}-{x}.accord.sock", .{ self.pid, self.start_id }) catch return;
+ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
+@@ -414,6 +449,37 @@ test "Accord stats report session RSS when enabled" {
+ try std.testing.expectEqual(@as(usize, 0), s.outbound);
+ }
+
++test "parseSockName reads pid-start names and rejects junk" {
++ const rec = parseSockName("42-2a.accord.sock") orelse return error.ParseFailed;
++ try std.testing.expectEqual(@as(i32, 42), rec.pid);
++ try std.testing.expectEqual(@as(u64, 0x2a), rec.start_id);
++ try std.testing.expect(parseSockName("not-a-sock") == null);
++ try std.testing.expect(parseSockName("x-yy.accord.sock") == null);
++ try std.testing.expect(parseSockName("-1-1.accord.sock") == null);
++ try std.testing.expect(parseSockName("0-1.accord.sock") == null);
++}
++
++test "livePost unlinks a reclaimable peer sock" {
++ if (builtin.os.tag == .windows) return;
++ const io = std.testing.io;
++ const gpa = std.testing.allocator;
++ test_enabled = true;
++ defer {
++ stop(io);
++ test_enabled = false;
++ }
++ const dir = "graff-accord-dead";
++ try Io.Dir.cwd().createDirPath(io, dir);
++ defer Io.Dir.cwd().deleteTree(io, dir) catch {};
++ listen(io, gpa, dir);
++ const dead = "999999-1.accord.sock";
++ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
++ const path = try std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir, dead });
++ try Io.Dir.cwd().writeFile(io, .{ .sub_path = path, .data = "stale" });
++ livePost(io, gpa, "chan", "{\"text\":\"hi\"}\n");
++ try std.testing.expectError(error.FileNotFound, Io.Dir.cwd().statFile(io, path, .{}));
++}
++
+ test "listen binds a 0600 sock and stop unlinks it" {
+ if (builtin.os.tag == .windows) return;
+ const io = std.testing.io;
diff --git a/evals/grok-46-vs-47/gold/1096.diff b/evals/grok-46-vs-47/gold/1096.diff
new file mode 100644
index 00000000..906d1eca
--- /dev/null
+++ b/evals/grok-46-vs-47/gold/1096.diff
@@ -0,0 +1,153 @@
+diff --git a/apps/native/components/primitives/PromptBar.tsx b/apps/native/components/primitives/PromptBar.tsx
+index be7eaeb1..90862e59 100644
+--- a/apps/native/components/primitives/PromptBar.tsx
++++ b/apps/native/components/primitives/PromptBar.tsx
+@@ -7,6 +7,7 @@ import layout from "./PromptBar.module.css";
+ import ModelEffortButtons from "./ModelEffortButtons";
+ import type { ModelChoice } from "@/lib/acp-client";
+ import { resolveComposerModel } from "@/lib/composer-model";
++import { shouldPickComposerRow } from "@/lib/composer-keyboard";
+ import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
+ import ComposerMenu from "./ComposerMenu";
+ import ComposerAttachments from "./ComposerAttachments";
+@@ -488,7 +489,7 @@ export default function PromptBar({
+ setActive((activeIndex + (event.key === "ArrowDown" ? 1 : rows.length - 1)) % rows.length);
+ return;
+ }
+- if (!event.shiftKey && (event.key === "Enter" || event.key === "Tab")) {
++ if (shouldPickComposerRow(event.key, event.shiftKey, engaged)) {
+ event.preventDefault();
+ event.stopPropagation();
+ pick(rows[activeIndex]);
+diff --git a/apps/native/electron/composer-interaction-visual.cjs b/apps/native/electron/composer-interaction-visual.cjs
+index 5904be15..da8f1128 100644
+--- a/apps/native/electron/composer-interaction-visual.cjs
++++ b/apps/native/electron/composer-interaction-visual.cjs
+@@ -20,6 +20,18 @@ async function runComposerInteractions({ win, origin, output }) {
+ await pause();
+ };
+ const frames = () => js('new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(()=>resolve(true))))');
++ const nativeKey = async key => {
++ await testDesktop.testInput(wc, { type: 'keyDown', keyCode: key });
++ await testDesktop.testInput(wc, { type: 'keyUp', keyCode: key });
++ await frames();
++ };
++ const hover = async selector => {
++ await js(`document.querySelector(${JSON.stringify(selector)}).scrollIntoView({block:'nearest',behavior:'instant'})`);
++ await frames();
++ const point = await js(`(()=>{const r=document.querySelector(${JSON.stringify(selector)}).getBoundingClientRect();return {x:Math.round(r.x+r.width/2),y:Math.round(r.y+r.height/2)}})()`);
++ await testDesktop.testInput(wc, { type: 'mouseMove', ...point });
++ await frames();
++ };
+ const pointer = async selector => {
+ await js(`document.querySelector(${JSON.stringify(selector)}).scrollIntoView({block:'nearest',behavior:'instant'})`);
+ for (let attempt = 0; attempt < 30; attempt++) {
+@@ -45,6 +57,63 @@ async function runComposerInteractions({ win, origin, output }) {
+ try {
+ await wc.loadURL(origin); win.setSize(1440, 900); testDesktop.present(win);
+ await wait(`!!document.querySelector('textarea') && !document.querySelector('[aria-label="Choose model"]').textContent.includes('Loading')`);
++
++ // A completion row only owns Enter/Tab after its dark hover state makes
++ // that selection visible. Before engagement, Enter submits and Tab keeps
++ // normal focus traversal instead of silently choosing the attach row.
++ await js(`(()=>{
++ const original=window.fetch;window.composerKeyboardProbe={fileClicks:0,requests:0};
++ window.fetch=async(input,options)=>{
++ if(String(input).includes('/api/acp')&&options?.body){
++ const body=JSON.parse(options.body);
++ if(body.method==='session/prompt'){
++ window.composerKeyboardProbe.requests++;
++ return new Response(JSON.stringify({jsonrpc:'2.0',id:body.id??1,result:{stopReason:'end_turn'}})+'\\n',{headers:{'content-type':'application/x-ndjson'}});
++ }
++ }
++ return original(input,options);
++ };
++ document.querySelector('input[type="file"]').addEventListener('click',event=>{event.preventDefault();window.composerKeyboardProbe.fileClicks++;});
++ })()`);
++ await testDesktop.testInput(wc, { type: 'mouseMove', x: 1, y: 1 });
++ await input('@tab-without-selection');
++ await wait(`!!document.querySelector('[data-composer-menu] [role="option"][title^="Add photos"]')`);
++ assert.equal(await js(`document.querySelector('[data-composer-menu] [role="option"][title^="Add photos"]').classList.contains('bg-hover')`), false, 'An untouched @ menu has no visibly selected row');
++ await nativeKey('Tab');
++ assert.equal(await js('window.composerKeyboardProbe.fileClicks'), 0, 'Unengaged Tab must not open the file chooser');
++ assert.equal(await js('window.composerKeyboardProbe.requests'), 0, 'Unengaged Tab must not submit');
++ assert.notEqual(await js('document.activeElement.tagName'), 'TEXTAREA', 'Unengaged Tab keeps normal focus traversal');
++ await input('@enter-without-selection');
++ await wait(`!!document.querySelector('[data-composer-menu] [role="option"][title^="Add photos"]')`);
++ assert.equal(await js(`document.querySelector('[data-composer-menu] [role="option"][title^="Add photos"]').classList.contains('bg-hover')`), false, 'A changed @ query resets visible selection');
++ await nativeKey('Enter');
++ await wait(`window.composerKeyboardProbe.requests===1`);
++ assert.equal(await js('window.composerKeyboardProbe.fileClicks'), 0, 'Unengaged Enter submits instead of opening the file chooser');
++ assert.equal(await js('document.querySelector("textarea").value'), '', 'Unengaged Enter clears the submitted draft');
++
++ await wc.loadURL(origin);
++ await wait(`!!document.querySelector('textarea') && !document.querySelector('[aria-label="Choose model"]').textContent.includes('Loading')`);
++ await js(`(()=>{window.composerKeyboardProbe={fileClicks:0};document.querySelector('input[type="file"]').addEventListener('click',event=>{event.preventDefault();window.composerKeyboardProbe.fileClicks++;});})()`);
++ await testDesktop.testInput(wc, { type: 'mouseMove', x: 1, y: 1 });
++ await input('@hover-selection');
++ await wait(`!!document.querySelector('[data-composer-menu] [role="option"][title^="Add photos"]')`);
++ await hover('[data-composer-menu] [role="option"][title^="Add photos"]');
++ await wait(`document.querySelector('[data-composer-menu] [role="option"][title^="Add photos"]').classList.contains('bg-hover')`);
++ await nativeKey('Enter');
++ assert.equal(await js('window.composerKeyboardProbe.fileClicks'), 1, 'Hover-highlighted Enter opens the file chooser');
++ await testDesktop.testInput(wc, { type: 'mouseMove', x: 1, y: 1 });
++ await frames();
++ await input('@arrow-selection');
++ await wait(`!!document.querySelector('[data-composer-menu] [role="option"][title^="Add photos"]')`);
++ assert.equal(await js(`document.querySelector('[data-composer-menu] [role="option"][title^="Add photos"]').classList.contains('bg-hover')`), false, 'A fresh @ query starts without a visible selection');
++ await nativeKey('ArrowDown');
++ await wait(`document.querySelector('[data-composer-menu] [role="option"][title^="Add photos"]').classList.contains('bg-hover')`);
++ await nativeKey('Tab');
++ assert.equal(await js('window.composerKeyboardProbe.fileClicks'), 2, 'Arrow-highlighted Tab opens the file chooser');
++ assert.equal(await js('document.activeElement.tagName'), 'TEXTAREA', 'Engaged Tab is consumed and returns focus to the composer');
++
++ await wc.loadURL(origin);
++ await wait(`!!document.querySelector('textarea') && !document.querySelector('[aria-label="Choose model"]').textContent.includes('Loading')`);
+ await js(`(()=>{
+ const original=window.fetch;window.composerRequests=[];window.composerCancels=0;window.fileChooserClicks=0;
+ window.fetch=async(input,options)=>{
+diff --git a/apps/native/lib/composer-keyboard.test.ts b/apps/native/lib/composer-keyboard.test.ts
+new file mode 100644
+index 00000000..ad0fc14a
+--- /dev/null
++++ b/apps/native/lib/composer-keyboard.test.ts
+@@ -0,0 +1,15 @@
++import { test } from "node:test";
++import assert from "node:assert/strict";
++import { shouldPickComposerRow } from "./composer-keyboard.ts";
++
++test("an open composer menu does not capture Enter or Tab before a row is visibly selected", () => {
++ assert.equal(shouldPickComposerRow("Enter", false, false), false);
++ assert.equal(shouldPickComposerRow("Tab", false, false), false);
++});
++
++test("Enter and Tab activate an engaged composer row", () => {
++ assert.equal(shouldPickComposerRow("Enter", false, true), true);
++ assert.equal(shouldPickComposerRow("Tab", false, true), true);
++ assert.equal(shouldPickComposerRow("Enter", true, true), false);
++ assert.equal(shouldPickComposerRow("ArrowDown", false, true), false);
++});
+diff --git a/apps/native/lib/composer-keyboard.ts b/apps/native/lib/composer-keyboard.ts
+new file mode 100644
+index 00000000..a7efecab
+--- /dev/null
++++ b/apps/native/lib/composer-keyboard.ts
+@@ -0,0 +1,5 @@
++/** A composer menu row is keyboard-activatable only after the user has
++ * visibly selected it by hovering or using the arrow keys. */
++export function shouldPickComposerRow(key: string, shiftKey: boolean, engaged: boolean): boolean {
++ return engaged && !shiftKey && (key === "Enter" || key === "Tab");
++}
+diff --git a/apps/native/package.json b/apps/native/package.json
+index 42d06619..f1208b8b 100644
+--- a/apps/native/package.json
++++ b/apps/native/package.json
+@@ -10,7 +10,7 @@
+ "start": "NEXT_TELEMETRY_DISABLED=1 next start --port 3000",
+ "mock-serve": "node scripts/mock-serve.mjs",
+ "lint": "next lint",
+- "test": "node --experimental-strip-types --test lib/cite-markup.test.ts lib/graff-events.test.ts lib/acp.test.ts lib/sessions.test.ts lib/session-store.test.ts lib/follow-scroll.test.ts lib/motion-throttle.test.ts lib/prompt-queue.test.ts lib/prompt-queue-steer.test.ts lib/prompt-queue-resume.test.ts lib/streaming-code.test.ts lib/run-traces.test.ts lib/agents.test.ts lib/mermaid-plugin.test.ts lib/prompt-history.test.ts lib/attachments.test.ts lib/queued-attachments.test.ts lib/idle-http.test.ts lib/composer-model-pick.test.ts lib/workspaces.test.ts lib/fuzzy.test.ts lib/folder-picker.test.ts lib/browser/annotations.test.ts lib/browser/url.test.ts lib/extension-bridge.test.ts lib/close-confirm.test.ts components/site/harness-split.test.ts components/site/appearance-panel.test.ts",
++ "test": "node --experimental-strip-types --test lib/cite-markup.test.ts lib/graff-events.test.ts lib/acp.test.ts lib/sessions.test.ts lib/session-store.test.ts lib/follow-scroll.test.ts lib/motion-throttle.test.ts lib/prompt-queue.test.ts lib/prompt-queue-steer.test.ts lib/prompt-queue-resume.test.ts lib/streaming-code.test.ts lib/run-traces.test.ts lib/agents.test.ts lib/mermaid-plugin.test.ts lib/prompt-history.test.ts lib/attachments.test.ts lib/queued-attachments.test.ts lib/idle-http.test.ts lib/composer-model-pick.test.ts lib/composer-keyboard.test.ts lib/workspaces.test.ts lib/fuzzy.test.ts lib/folder-picker.test.ts lib/browser/annotations.test.ts lib/browser/url.test.ts lib/extension-bridge.test.ts lib/close-confirm.test.ts components/site/harness-split.test.ts components/site/appearance-panel.test.ts",
+ "electron:build": "bash electron/build.sh",
+ "test:electron": "bun test electron/policy.test.cjs",
+ "test:webauthn": "node scripts/test-webauthn.mjs",
diff --git a/evals/grok-46-vs-47/gold/1149.diff b/evals/grok-46-vs-47/gold/1149.diff
new file mode 100644
index 00000000..fdd01616
--- /dev/null
+++ b/evals/grok-46-vs-47/gold/1149.diff
@@ -0,0 +1,42 @@
+diff --git a/apps/native/electron/webauthn-profile.test.cjs b/apps/native/electron/webauthn-profile.test.cjs
+index 64bc46b7..5d003336 100644
+--- a/apps/native/electron/webauthn-profile.test.cjs
++++ b/apps/native/electron/webauthn-profile.test.cjs
+@@ -66,6 +66,13 @@ for (const [name, change] of [
+ });
+ }
+
++test('rejects a same-team profile for a different bundle even when TEAM.* keychain groups match', () => {
++ const profile = fixture();
++ profile.Entitlements['com.apple.application-identifier'] = 'ABCDE12345.com.unrelated.app';
++ profile.Entitlements['keychain-access-groups'] = ['ABCDE12345.*'];
++ assert.throws(() => authorize(profile), /provisioning profile/);
++});
++
+ test('accepts a profile until its expiration boundary', () => {
+ const profile = fixture();
+ profile.ExpirationDate = new Date(now + 1);
+diff --git a/apps/native/electron/webauthn-signing.test.cjs b/apps/native/electron/webauthn-signing.test.cjs
+index f0d0805b..688dccd9 100644
+--- a/apps/native/electron/webauthn-signing.test.cjs
++++ b/apps/native/electron/webauthn-signing.test.cjs
+@@ -94,6 +94,19 @@ test('invalid metadata fails before writing config or invoking signer', async ()
+ assert.equal(called, false);
+ });
+
++test('signBundle rejects a same-team profile for a different bundle before invoking the signer', async () => {
++ let called = false;
++ await assert.rejects(signBundle({
++ app: 'Fixture.app',
++ identity,
++ profilePath: 'fixture.provisionprofile',
++ readProvisioningProfile: () => profile('com.unrelated.app'),
++ readBundleId: () => bundleId,
++ sign: () => { called = true; },
++ }), /provisioning profile/);
++ assert.equal(called, false);
++});
++
+ test('default reader obtains actual bundle identifier through PlistBuddy', { skip: process.platform !== 'darwin' }, async () => {
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauthn-plist-test-'));
+ const app = path.join(root, 'Fixture.app');
diff --git a/evals/grok-46-vs-47/patches/grok-4.6-1035.diff b/evals/grok-46-vs-47/patches/grok-4.6-1035.diff
new file mode 100644
index 00000000..a68ff9eb
--- /dev/null
+++ b/evals/grok-46-vs-47/patches/grok-4.6-1035.diff
@@ -0,0 +1,77 @@
+--- a/src/presence_accord.zig
++++ b/src/presence_accord.zig
+@@ -1,6 +1,7 @@
+ const std = @import("std");
+ const Io = std.Io;
++const proc_identity = @import("proc_identity.zig");
+
+@@
+- const dir = dir_path orelse return;
+- const self = @import("proc_identity.zig").selfRecord(io);
++ const dir = dir_path orelse return;
++ const self = proc_identity.selfRecord(io);
+@@
+ const name = std.fmt.bufPrint(&name_buf, "{d}-{x}.accord.sock", .{ self.pid, self.start_id }) catch return;
++ sweepReclaimableSocks(io, dir, name);
+@@
+ if (g_own_name) |own| if (std.mem.eql(u8, entry.name, own)) continue;
+ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir_path, entry.name }) catch continue;
++ if (unlinkReclaimableSock(io, path, entry.name)) continue;
+ sendLine(io, gpa, path, json_line) catch {};
+@@
++fn parseSockName(name: []const u8) ?proc_identity.Record {
++ const suffix = ".accord.sock";
++ if (!std.mem.endsWith(u8, name, suffix)) return null;
++ const stem = name[0 .. name.len - suffix.len];
++ const dash = std.mem.indexOfScalar(u8, stem, '-') orelse return null;
++ if (dash == 0 or dash + 1 >= stem.len) return null;
++ const pid = std.fmt.parseInt(i32, stem[0..dash], 10) catch return null;
++ if (pid <= 0) return null;
++ const start_id = std.fmt.parseInt(proc_identity.StartId, stem[dash + 1 ..], 16) catch return null;
++ return .{ .pid = pid, .start_id = start_id };
++}
++
++fn unlinkReclaimableSock(io: Io, path: []const u8, name: []const u8) bool {
++ const rec = parseSockName(name) orelse return false;
++ if (proc_identity.stateOf(io, rec) != .reclaimable) return false;
++ Io.Dir.cwd().deleteFile(io, path) catch return false;
++ return true;
++}
++
++fn sweepReclaimableSocks(io: Io, dir_path: []const u8, own_name: []const u8) void {
++ var live_dir = Io.Dir.cwd().openDir(io, dir_path, .{ .iterate = true }) catch return;
++ defer live_dir.close(io);
++ var it = live_dir.iterate(io);
++ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
++ while (it.next(io) catch null) |entry| {
++ if (!std.mem.endsWith(u8, entry.name, ".accord.sock")) continue;
++ if (std.mem.eql(u8, entry.name, own_name)) continue;
++ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir_path, entry.name }) catch continue;
++ _ = unlinkReclaimableSock(io, path, entry.name);
++ }
++}
++
++test "parseSockName accepts pid-hex sock names and rejects junk" {
++ const rec = parseSockName("42-2a.accord.sock") orelse return error.TestUnexpectedResult;
++ try std.testing.expectEqual(@as(i32, 42), rec.pid);
++ try std.testing.expectEqual(@as(proc_identity.StartId, 0x2a), rec.start_id);
++ try std.testing.expect(parseSockName("junk") == null);
++ try std.testing.expect(parseSockName("42.accord.sock") == null);
++ try std.testing.expect(parseSockName("0-2a.accord.sock") == null);
++ try std.testing.expect(parseSockName("-1-2a.accord.sock") == null);
++ try std.testing.expect(parseSockName("42-.accord.sock") == null);
++ try std.testing.expect(parseSockName("42-2a") == null);
++}
++
++test "livePost unlinks reclaimable peer sock" {
++ const io = std.testing.io;
++ if (!test_enabled) return error.SkipZigTest;
++ listen(io);
++ defer stop(io);
++ const dir_path = dir_path orelse return error.SkipZigTest;
++ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
++ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir_path, "999999-1.accord.sock" }) catch return error.TestUnexpectedResult;
++ try Io.Dir.cwd().writeFile(io, path, "stale");
++ livePost(io, std.testing.allocator, "{}");
++ try std.testing.expectError(error.FileNotFound, Io.Dir.cwd().statFile(io, path));
++}
diff --git a/evals/grok-46-vs-47/patches/grok-4.6-1096.diff b/evals/grok-46-vs-47/patches/grok-4.6-1096.diff
new file mode 100644
index 00000000..c92c4168
--- /dev/null
+++ b/evals/grok-46-vs-47/patches/grok-4.6-1096.diff
@@ -0,0 +1,90 @@
+diff --git a/apps/native/components/primitives/PromptBar.tsx b/apps/native/components/primitives/PromptBar.tsx
+--- a/apps/native/components/primitives/PromptBar.tsx
++++ b/apps/native/components/primitives/PromptBar.tsx
+@@
+ } from "react";
++import { shouldPickComposerRow } from "../../lib/composer-keyboard";
+@@
+ if (menu && rows.length > 0) {
+ if (!event.shiftKey && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
+ event.preventDefault();
+ event.stopPropagation();
+ setEngaged(true);
+ setActive((activeIndex + (event.key === "ArrowDown" ? 1 : rows.length - 1)) % rows.length);
+ return;
+ }
+- if (!event.shiftKey && (event.key === "Enter" || event.key === "Tab")) {
++ if (shouldPickComposerRow(event.key, event.shiftKey, engaged)) {
+ event.preventDefault();
+ event.stopPropagation();
+ pick(rows[activeIndex]);
+ return;
+ }
+ }
+diff --git a/apps/native/lib/composer-keyboard.test.ts b/apps/native/lib/composer-keyboard.test.ts
+new file mode 100644
+--- /dev/null
++++ b/apps/native/lib/composer-keyboard.test.ts
+@@ -0,0 +1,42 @@
++import assert from "node:assert/strict";
++import { describe, it } from "node:test";
++import { shouldPickComposerRow } from "./composer-keyboard.ts";
++
++describe("shouldPickComposerRow", () => {
++ it("picks on Enter when the row is visibly engaged", () => {
++ assert.equal(shouldPickComposerRow("Enter", false, true), true);
++ });
++
++ it("picks on Tab when the row is visibly engaged", () => {
++ assert.equal(shouldPickComposerRow("Tab", false, true), true);
++ });
++
++ it("does not pick on Enter when the menu is not engaged", () => {
++ assert.equal(shouldPickComposerRow("Enter", false, false), false);
++ });
++
++ it("does not pick on Tab when the menu is not engaged", () => {
++ assert.equal(shouldPickComposerRow("Tab", false, false), false);
++ });
++
++ it("does not pick on Shift+Enter even when engaged", () => {
++ assert.equal(shouldPickComposerRow("Enter", true, true), false);
++ });
++
++ it("does not pick on Shift+Tab even when engaged", () => {
++ assert.equal(shouldPickComposerRow("Tab", true, true), false);
++ });
++
++ it("does not treat arrow keys as activation", () => {
++ assert.equal(shouldPickComposerRow("ArrowDown", false, true), false);
++ assert.equal(shouldPickComposerRow("ArrowUp", false, true), false);
++ assert.equal(shouldPickComposerRow("ArrowDown", false, false), false);
++ assert.equal(shouldPickComposerRow("ArrowUp", false, false), false);
++ });
++
++ it("does not pick on unrelated keys", () => {
++ assert.equal(shouldPickComposerRow("Escape", false, true), false);
++ assert.equal(shouldPickComposerRow(" ", false, true), false);
++ });
++});
+diff --git a/apps/native/lib/composer-keyboard.ts b/apps/native/lib/composer-keyboard.ts
+new file mode 100644
+--- /dev/null
++++ b/apps/native/lib/composer-keyboard.ts
+@@ -0,0 +1,10 @@
++export function shouldPickComposerRow(
++ key: string,
++ shiftKey: boolean,
++ engaged: boolean,
++): boolean {
++ if (!engaged || shiftKey) {
++ return false;
++ }
++ return key === "Enter" || key === "Tab";
++}
+diff --git a/apps/native/package.json b/apps/native/package.json
+--- a/apps/native/package.json
++++ b/apps/native/package.json
+@@
+- "test": "node --experimental-strip-types --test lib/composer-model-pick.test.ts
++ "test": "node --experimental-strip-types --test lib/composer-keyboard.test.ts lib/composer-model-pick.test.ts
\ No newline at end of file
diff --git a/evals/grok-46-vs-47/patches/grok-4.6-1149.diff b/evals/grok-46-vs-47/patches/grok-4.6-1149.diff
new file mode 100644
index 00000000..e21ce36e
--- /dev/null
+++ b/evals/grok-46-vs-47/patches/grok-4.6-1149.diff
@@ -0,0 +1,32 @@
+```diff
+diff --git a/apps/native/electron/webauthn-profile.test.cjs b/apps/native/electron/webauthn-profile.test.cjs
+--- a/apps/native/electron/webauthn-profile.test.cjs
++++ b/apps/native/electron/webauthn-profile.test.cjs
+@@ -1,5 +1,12 @@
+ test('accepts a profile until its expiration boundary', () => {
+ const profile = fixture();
+ profile.ExpirationDate = new Date(now + 1);
+ assert.deepEqual(authorize(profile), { 'com.apple.application-identifier': appId });
+ });
++
++test('rejects TEAM.* keychain groups when application-identifier is another bundle', () => {
++ const profile = fixture();
++ profile.Entitlements['com.apple.application-identifier'] = 'ABCDE12345.org.example.other';
++ assert.throws(() => authorize(profile), /application-identifier/);
++});
+diff --git a/apps/native/electron/webauthn-signing.test.cjs b/apps/native/electron/webauthn-signing.test.cjs
+--- a/apps/native/electron/webauthn-signing.test.cjs
++++ b/apps/native/electron/webauthn-signing.test.cjs
+@@ -1,5 +1,12 @@
+ test('invalid metadata fails before writing config or invoking signer', async () => {
+ let called = false;
+ await assert.rejects(signBundle({ app: 'Fixture.app', identity, teamId: '', readBundleId: () => bundleId, sign: () => { called = true; } }), /valid signing team/);
+ assert.equal(called, false);
+ });
++
++test('rejects a same-team profile for a different bundle before the signer runs', async () => {
++ let called = false;
++ await assert.rejects(signBundle({ app: 'Fixture.app', identity, teamId: 'ABCDE12345', readBundleId: () => bundleId, readProvisioningProfile: () => profile('org.example.other'), sign: () => { called = true; } }), /application-identifier/);
++ assert.equal(called, false);
++});
+```
\ No newline at end of file
diff --git a/evals/grok-46-vs-47/patches/grok-4.7-1035.diff b/evals/grok-46-vs-47/patches/grok-4.7-1035.diff
new file mode 100644
index 00000000..0915f47a
--- /dev/null
+++ b/evals/grok-46-vs-47/patches/grok-4.7-1035.diff
@@ -0,0 +1,102 @@
+diff --git a/src/presence_accord.zig b/src/presence_accord.zig
+--- a/src/presence_accord.zig
++++ b/src/presence_accord.zig
+@@ -0,0 +1,83 @@
++fn parseSockName(name: []const u8) ?@import("proc_identity.zig").Record {
++ const suffix = ".accord.sock";
++ if (!std.mem.endsWith(u8, name, suffix)) return null;
++ const stem = name[0 .. name.len - suffix.len];
++ const sep = std.mem.indexOfScalar(u8, stem, '-') orelse return null;
++ if (sep == 0) return null;
++ const pid_text = stem[0..sep];
++ const hex_text = stem[sep + 1 ..];
++ if (pid_text.len == 0 or hex_text.len == 0) return null;
++ for (pid_text) |c| {
++ if (c < '0' or c > '9') return null;
++ }
++ for (hex_text) |c| {
++ switch (c) {
++ '0'...'9', 'a'...'f', 'A'...'F' => {},
++ else => return null,
++ }
++ }
++ const pid = std.fmt.parseInt(i32, pid_text, 10) catch return null;
++ if (pid <= 0) return null;
++ const sample: @import("proc_identity.zig").Record = .{};
++ const start_id = std.fmt.parseInt(@TypeOf(sample.start_id), hex_text, 16) catch return null;
++ return .{ .pid = pid, .start_id = start_id };
++}
++
++fn unlinkIfReclaimable(io: Io, live_dir: []const u8, name: []const u8) bool {
++ if (g_own_name) |own| if (std.mem.eql(u8, name, own)) return false;
++ const self = @import("proc_identity.zig").selfRecord(io);
++ var own_buf: [160]u8 = undefined;
++ if (std.fmt.bufPrint(&own_buf, "{d}-{x}.accord.sock", .{ self.pid, self.start_id })) |own| {
++ if (std.mem.eql(u8, name, own)) return false;
++ } else |_| {}
++ const rec = parseSockName(name) orelse return false;
++ if (@import("proc_identity.zig").stateOf(io, rec) != .reclaimable) return false;
++ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
++ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ live_dir, name }) catch return false;
++ Io.Dir.cwd().deleteFile(io, path) catch return false;
++ return true;
++}
++
++fn sweepReclaimableSocks(io: Io, live_dir: []const u8) void {
++ var opened = Io.Dir.cwd().openDir(io, live_dir, .{ .iterate = true }) catch return;
++ defer opened.close(io);
++ var it = opened.iterate();
++ while (it.next(io) catch null) |entry| {
++ if (!std.mem.endsWith(u8, entry.name, ".accord.sock")) continue;
++ _ = unlinkIfReclaimable(io, live_dir, entry.name);
++ }
++}
++
++var noted_live_dir_buf: [std.fs.max_path_bytes]u8 = undefined;
++var noted_live_dir: ?[]const u8 = null;
++
++fn noteLiveDir(dir: []const u8) void {
++ if (dir.len > noted_live_dir_buf.len) return;
++ @memcpy(noted_live_dir_buf[0..dir.len], dir);
++ noted_live_dir = noted_live_dir_buf[0..dir.len];
++}
++
++test "parseSockName accepts 42-2a.accord.sock and rejects junk" {
++ const rec = parseSockName("42-2a.accord.sock") orelse return error.TestExpectedEqual;
++ try std.testing.expectEqual(@as(i32, 42), rec.pid);
++ try std.testing.expectEqual(@as(@TypeOf(rec.start_id), 0x2a), rec.start_id);
++ try std.testing.expect(parseSockName("junk") == null);
++ try std.testing.expect(parseSockName("0-1.accord.sock") == null);
++ try std.testing.expect(parseSockName("-9-1.accord.sock") == null);
++ try std.testing.expect(parseSockName("12-.accord.sock") == null);
++ try std.testing.expect(parseSockName("12.accord.sock") == null);
++}
++
++test "livePost unlinks reclaimable peer sock" {
++ if (!test_enabled) return;
++ const io = std.testing.io;
++ listen(io);
++ defer stop(io);
++ const dir = noted_live_dir orelse return error.TestExpectedEqual;
++ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
++ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir, "999999-1.accord.sock" }) catch unreachable;
++ try Io.Dir.cwd().writeFile(io, path, "");
++ livePost(io, std.testing.allocator, "{}");
++ try std.testing.expectError(error.FileNotFound, Io.Dir.cwd().statFile(io, path));
++}
++
+@@ -100,2 +183,4 @@
+ const dir = dir_path orelse return;
+ const self = @import("proc_identity.zig").selfRecord(io);
++noteLiveDir(dir);
++sweepReclaimableSocks(io, dir);
+@@ -250,6 +335,7 @@
+ while (it.next(io) catch null) |entry| {
+ if (!std.mem.endsWith(u8, entry.name, ".accord.sock")) continue;
+ if (g_own_name) |own| if (std.mem.eql(u8, entry.name, own)) continue;
+- const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir_path, entry.name }) catch continue;
+- sendLine(io, gpa, path, json_line) catch {};
++ if (unlinkIfReclaimable(io, dir_path, entry.name)) continue;
++ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir_path, entry.name }) catch continue;
++ sendLine(io, gpa, path, json_line) catch {};
+ }
diff --git a/evals/grok-46-vs-47/patches/grok-4.7-1096.diff b/evals/grok-46-vs-47/patches/grok-4.7-1096.diff
new file mode 100644
index 00000000..d131996e
--- /dev/null
+++ b/evals/grok-46-vs-47/patches/grok-4.7-1096.diff
@@ -0,0 +1,80 @@
+diff --git a/apps/native/lib/composer-keyboard.ts b/apps/native/lib/composer-keyboard.ts
+new file mode 100644
+--- /dev/null
++++ b/apps/native/lib/composer-keyboard.ts
+@@ -0,0 +1,10 @@
++// Keyboard activation follows the visible highlight. Hover and arrow keys set
++// `engaged`; until then Enter submits and Tab keeps normal focus traversal.
++export function shouldPickComposerRow(
++ key: string,
++ shiftKey: boolean,
++ engaged: boolean,
++): boolean {
++ if (shiftKey || !engaged) return false;
++ return key === "Enter" || key === "Tab";
++}
+diff --git a/apps/native/lib/composer-keyboard.test.ts b/apps/native/lib/composer-keyboard.test.ts
+new file mode 100644
+--- /dev/null
++++ b/apps/native/lib/composer-keyboard.test.ts
+@@ -0,0 +1,32 @@
++import assert from "node:assert/strict";
++import { test } from "node:test";
++import { shouldPickComposerRow } from "./composer-keyboard.ts";
++
++test("picks an engaged row on Enter or Tab without Shift", () => {
++ assert.equal(shouldPickComposerRow("Enter", false, true), true);
++ assert.equal(shouldPickComposerRow("Tab", false, true), true);
++});
++
++test("does not pick when the row is not engaged", () => {
++ assert.equal(shouldPickComposerRow("Enter", false, false), false);
++ assert.equal(shouldPickComposerRow("Tab", false, false), false);
++});
++
++test("does not pick on Shift+Enter or Shift+Tab", () => {
++ assert.equal(shouldPickComposerRow("Enter", true, true), false);
++ assert.equal(shouldPickComposerRow("Tab", true, true), false);
++ assert.equal(shouldPickComposerRow("Enter", true, false), false);
++});
++
++test("arrow keys are not activation keys", () => {
++ assert.equal(shouldPickComposerRow("ArrowDown", false, true), false);
++ assert.equal(shouldPickComposerRow("ArrowUp", false, true), false);
++ assert.equal(shouldPickComposerRow("ArrowDown", true, true), false);
++ assert.equal(shouldPickComposerRow("ArrowUp", false, false), false);
++});
++
++test("other keys do not pick a row", () => {
++ assert.equal(shouldPickComposerRow("Escape", false, true), false);
++ assert.equal(shouldPickComposerRow(" ", false, true), false);
++ assert.equal(shouldPickComposerRow("a", false, true), false);
++});
+diff --git a/apps/native/components/primitives/PromptBar.tsx b/apps/native/components/primitives/PromptBar.tsx
+--- a/apps/native/components/primitives/PromptBar.tsx
++++ b/apps/native/components/primitives/PromptBar.tsx
+@@ -1,0 +1,1 @@
++import { shouldPickComposerRow } from "../../lib/composer-keyboard";
+@@ -1,12 +2,12 @@
+ if (menu && rows.length > 0) {
+ if (!event.shiftKey && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
+ event.preventDefault();
+ event.stopPropagation();
+ setEngaged(true);
+ setActive((activeIndex + (event.key === "ArrowDown" ? 1 : rows.length - 1)) % rows.length);
+ return;
+ }
+- if (!event.shiftKey && (event.key === "Enter" || event.key === "Tab")) {
++ if (shouldPickComposerRow(event.key, event.shiftKey, engaged)) {
+ event.preventDefault();
+ event.stopPropagation();
+ pick(rows[activeIndex]);
+ return;
+ }
+ }
+diff --git a/apps/native/package.json b/apps/native/package.json
+--- a/apps/native/package.json
++++ b/apps/native/package.json
+@@ -1,1 +1,1 @@
+- "test": "node --experimental-strip-types --test lib/composer-model-pick.test.ts",
++ "test": "node --experimental-strip-types --test lib/composer-keyboard.test.ts lib/composer-model-pick.test.ts",
diff --git a/evals/grok-46-vs-47/patches/grok-4.7-1149.diff b/evals/grok-46-vs-47/patches/grok-4.7-1149.diff
new file mode 100644
index 00000000..d2b35c93
--- /dev/null
+++ b/evals/grok-46-vs-47/patches/grok-4.7-1149.diff
@@ -0,0 +1,31 @@
+diff --git a/apps/native/electron/webauthn-profile.test.cjs b/apps/native/electron/webauthn-profile.test.cjs
+--- a/apps/native/electron/webauthn-profile.test.cjs
++++ b/apps/native/electron/webauthn-profile.test.cjs
+@@ -120,5 +120,12 @@
+ test('accepts a profile until its expiration boundary', () => {
+ const profile = fixture();
+ profile.ExpirationDate = new Date(now + 1);
+ assert.deepEqual(authorize(profile), { 'com.apple.application-identifier': appId });
+ });
++
++test('rejects TEAM.* keychain groups when application-identifier is another bundle', () => {
++ const profile = fixture();
++ profile.Entitlements['keychain-access-groups'] = ['ABCDE12345.*'];
++ profile.Entitlements['com.apple.application-identifier'] = 'ABCDE12345.org.example.other';
++ assert.throws(() => authorize(profile), /application-identifier/);
++});
+diff --git a/apps/native/electron/webauthn-signing.test.cjs b/apps/native/electron/webauthn-signing.test.cjs
+--- a/apps/native/electron/webauthn-signing.test.cjs
++++ b/apps/native/electron/webauthn-signing.test.cjs
+@@ -70,5 +70,11 @@
+ test('invalid metadata fails before writing config or invoking signer', async () => {
+ let called = false;
+ await assert.rejects(signBundle({ app: 'Fixture.app', identity, teamId: '', readBundleId: () => bundleId, sign: () => { called = true; } }), /valid signing team/);
+ assert.equal(called, false);
+ });
++
++test('same-team profile for a different bundle fails before invoking the signer', async () => {
++ let called = false;
++ await assert.rejects(signBundle({ app: 'Fixture.app', identity, teamId: 'ABCDE12345', readBundleId: () => bundleId, readProvisioningProfile: () => profile('org.example.other'), sign: () => { called = true; } }), /application-identifier/);
++ assert.equal(called, false);
++});
diff --git a/evals/grok-46-vs-47/prompts/1035.txt b/evals/grok-46-vs-47/prompts/1035.txt
new file mode 100644
index 00000000..60ed22aa
--- /dev/null
+++ b/evals/grok-46-vs-47/prompts/1035.txt
@@ -0,0 +1,40 @@
+You are patching justrach/codegraff. Do not use tools. Reply with one unified diff and nothing else.
+
+PR 1035 — Unlink reclaimable Accord peer socks.
+
+Bug: a crashed session leaves `{pid}-{start}.accord.sock` in the live dir. Fan-out keeps dialing those names. Drop a sock only when process identity says the owner is gone. Unknown stays. Do not unlink the live listener's own sock.
+
+Relevant API in src/proc_identity.zig:
+```
+pub const Record = struct { pid: i32 = 0, start_id: StartId = 0 };
+pub const OwnerState = enum { held, reclaimable };
+pub fn stateOf(io: Io, rec: Record) OwnerState;
+```
+Sock names are `{pid}-{hex start_id}.accord.sock`, matching listen():
+```
+const name = std.fmt.bufPrint(&name_buf, "{d}-{x}.accord.sock", .{ self.pid, self.start_id }) catch return;
+```
+
+Current livePost fan-out in src/presence_accord.zig dials every other *.accord.sock and never unlinks:
+```
+while (it.next(io) catch null) |entry| {
+ if (!std.mem.endsWith(u8, entry.name, ".accord.sock")) continue;
+ if (g_own_name) |own| if (std.mem.eql(u8, entry.name, own)) continue;
+ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir_path, entry.name }) catch continue;
+ sendLine(io, gpa, path, json_line) catch {};
+}
+```
+listen() currently does:
+```
+const dir = dir_path orelse return;
+const self = @import("proc_identity.zig").selfRecord(io);
+```
+Delete with `Io.Dir.cwd().deleteFile(io, path)`. Tests in this file use `std.testing.io`, `test_enabled`, `listen`, `livePost`, `stop`, and `Io.Dir.cwd().writeFile` / `statFile`.
+
+Implement:
+- parse `{pid}-{hex}.accord.sock` into a proc_identity.Record; reject junk, non-positive pids, and missing hex.
+- before dialing a peer, unlink it when stateOf is .reclaimable; if it was unlinked, do not dial it.
+- on listen, sweep the live dir for reclaimable socks before binding.
+- tests: parseSockName accepts `42-2a.accord.sock` (pid 42, start_id 0x2a) and rejects junk; livePost unlinks a reclaimable peer sock named `999999-1.accord.sock` (pid 999999 is gone) and statFile then returns FileNotFound.
+
+Write a unified diff for src/presence_accord.zig only.
diff --git a/evals/grok-46-vs-47/prompts/1096.txt b/evals/grok-46-vs-47/prompts/1096.txt
new file mode 100644
index 00000000..8a02da3f
--- /dev/null
+++ b/evals/grok-46-vs-47/prompts/1096.txt
@@ -0,0 +1,36 @@
+You are patching justrach/codegraff. Do not use tools. Reply with one unified diff and nothing else.
+
+PR 1096 — fix(native): require visible composer selection on Enter.
+
+Bug: the @ menu defaults its active index to the attachment action. The keyboard handler activates that row on Enter or Tab immediately, even though `engaged` intentionally withholds the visual highlight until the user hovers or navigates with the arrow keys. Pressing Enter after typing an @ query can open the system file picker with no visible selection.
+
+Required behavior:
+- An autocomplete row is keyboard-activatable only after it is visibly engaged (hover or arrow keys).
+- If the @ menu is open but no row is engaged, Enter still submits the prompt and Tab keeps normal focus traversal.
+- Reuse the existing `engaged` state. Do not add a second selection model.
+- Shift+Enter must not activate a row.
+- Arrow keys are not activation keys.
+
+Current handler in apps/native/components/primitives/PromptBar.tsx (engaged already exists; arrow keys already call setEngaged(true); ComposerMenu receives setEngaged for hover):
+```
+if (menu && rows.length > 0) {
+ if (!event.shiftKey && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
+ event.preventDefault();
+ event.stopPropagation();
+ setEngaged(true);
+ setActive((activeIndex + (event.key === "ArrowDown" ? 1 : rows.length - 1)) % rows.length);
+ return;
+ }
+ if (!event.shiftKey && (event.key === "Enter" || event.key === "Tab")) {
+ event.preventDefault();
+ event.stopPropagation();
+ pick(rows[activeIndex]);
+ return;
+ }
+}
+```
+Later, unengaged Enter falls through to send().
+
+Add a pure helper `shouldPickComposerRow(key, shiftKey, engaged)` in apps/native/lib/composer-keyboard.ts, unit tests in apps/native/lib/composer-keyboard.test.ts, wire PromptBar to it, and append the new test file to the `test` script in apps/native/package.json (node --experimental-strip-types --test ...). The test script already lists lib/composer-model-pick.test.ts; insert the new file beside it.
+
+Write the unified diff.
diff --git a/evals/grok-46-vs-47/prompts/1149.txt b/evals/grok-46-vs-47/prompts/1149.txt
new file mode 100644
index 00000000..7f085595
--- /dev/null
+++ b/evals/grok-46-vs-47/prompts/1149.txt
@@ -0,0 +1,67 @@
+You are patching justrach/codegraff. Do not use tools. Reply with one unified diff and nothing else.
+
+PR 1149 — test: reject same-team profiles for a different bundle.
+
+Why: a matching team wildcard is not enough to authorize another product's profile.
+
+Add tests only:
+
+- profileEntitlements rejects TEAM.* keychain groups when application-identifier is another bundle.
+- signBundle rejects that profile before the signer runs.
+
+Match the existing helpers and assertion style in these two files. Do not rewrite unrelated tests.
+
+FILE apps/native/electron/webauthn-profile.test.cjs
+```
+const assert = require('node:assert/strict');
+const { test } = require('node:test');
+const { readProfile, profileEntitlements } = require('./webauthn-profile.cjs');
+
+const config = { keychainAccessGroup: 'ABCDE12345.org.example.fixture.webauthn' };
+const appId = 'ABCDE12345.org.example.fixture';
+const now = Date.parse('2030-01-01T00:00:00Z');
+
+function fixture() {
+ return {
+ Platform: ['OSX'],
+ TeamIdentifier: ['ABCDE12345'],
+ ExpirationDate: new Date('2099-01-01'),
+ Entitlements: {
+ 'com.apple.application-identifier': appId,
+ 'keychain-access-groups': ['ABCDE12345.*'],
+ },
+ };
+}
+
+function authorize(profile) {
+ return profileEntitlements(profile, config, now);
+}
+```
+The file already has a table of authorize() accept cases and a table of reject cases (wrong team, wrong application, wrong keychain group, expired, and so on), plus:
+```
+test('accepts a profile until its expiration boundary', () => {
+ const profile = fixture();
+ profile.ExpirationDate = new Date(now + 1);
+ assert.deepEqual(authorize(profile), { 'com.apple.application-identifier': appId });
+});
+```
+
+FILE apps/native/electron/webauthn-signing.test.cjs
+```
+const { signBundle } = require('./webauthn-signing.cjs');
+const identity = 'Developer ID Application: Test Fixture (ABCDE12345)';
+const bundleId = 'org.example.fixture';
+const profile = appId => ({ Platform: ['OSX'], TeamIdentifier: ['ABCDE12345'], ExpirationDate: new Date('2099-01-01'),
+ Entitlements: { 'com.apple.application-identifier': `ABCDE12345.${appId}`, 'keychain-access-groups': ['ABCDE12345.*'] } });
+```
+An existing test already proves invalid metadata fails before the signer:
+```
+test('invalid metadata fails before writing config or invoking signer', async () => {
+ let called = false;
+ await assert.rejects(signBundle({ app: 'Fixture.app', identity, teamId: '', readBundleId: () => bundleId, sign: () => { called = true; } }), /valid signing team/);
+ assert.equal(called, false);
+});
+```
+signBundle accepts readProvisioningProfile and readBundleId overrides.
+
+Write the two missing tests as a unified diff against those paths.
diff --git a/evals/grok-46-vs-47/results.json b/evals/grok-46-vs-47/results.json
new file mode 100644
index 00000000..6c94dc4e
--- /dev/null
+++ b/evals/grok-46-vs-47/results.json
@@ -0,0 +1,120 @@
+{
+ "protocol": {
+ "runner": "grok CLI (Grok Build)",
+ "models": ["grok-4.6", "grok-4.7"],
+ "resolved_models": ["grok-4.6-build", "grok-4.7-build"],
+ "reasoning_effort": "high",
+ "turns": 1,
+ "tools": "disabled",
+ "pricing_card": {
+ "input_per_mtok": 2.0,
+ "cached_input_per_mtok": 0.5,
+ "output_per_mtok": 6.0,
+ "note": "Public xAI list for grok-4.6 and grok-4.7 under 200k prompt tokens. Reasoning tokens are inside output."
+ },
+ "build_receipt_note": "grok-4.7-build receipts matched the list card exactly. grok-4.6-build receipts were 0.34x that card on every run."
+ },
+ "prs": [
+ {
+ "number": 1149,
+ "title": "test: reject same-team profiles for a different bundle",
+ "url": "https://github.com/justrach/codegraff/pull/1149"
+ },
+ {
+ "number": 1096,
+ "title": "fix(native): require visible composer selection on Enter",
+ "url": "https://github.com/justrach/codegraff/pull/1096"
+ },
+ {
+ "number": 1035,
+ "title": "Unlink reclaimable Accord peer socks",
+ "url": "https://github.com/justrach/codegraff/pull/1035"
+ }
+ ],
+ "runs": [
+ {
+ "model": "grok-4.6",
+ "resolved": "grok-4.6-build",
+ "pr": 1149,
+ "wall_s": 108.547,
+ "input_tokens": 17502,
+ "cached_input_tokens": 256,
+ "output_tokens": 5962,
+ "reasoning_tokens": 5461,
+ "build_receipt_usd": 0.02410736,
+ "list_cost_usd": 0.070904,
+ "checks_hit": 6,
+ "checks_total": 8
+ },
+ {
+ "model": "grok-4.7",
+ "resolved": "grok-4.7-build",
+ "pr": 1149,
+ "wall_s": 333.837,
+ "input_tokens": 15922,
+ "cached_input_tokens": 1152,
+ "output_tokens": 22958,
+ "reasoning_tokens": 22438,
+ "build_receipt_usd": 0.170168,
+ "list_cost_usd": 0.170168,
+ "checks_hit": 7,
+ "checks_total": 8
+ },
+ {
+ "model": "grok-4.6",
+ "resolved": "grok-4.6-build",
+ "pr": 1096,
+ "wall_s": 138.814,
+ "input_tokens": 18669,
+ "cached_input_tokens": 0,
+ "output_tokens": 8064,
+ "reasoning_tokens": 7036,
+ "build_receipt_usd": 0.02914548,
+ "list_cost_usd": 0.085722,
+ "checks_hit": 7,
+ "checks_total": 8
+ },
+ {
+ "model": "grok-4.7",
+ "resolved": "grok-4.7-build",
+ "pr": 1096,
+ "wall_s": 269.817,
+ "input_tokens": 15713,
+ "cached_input_tokens": 1152,
+ "output_tokens": 19450,
+ "reasoning_tokens": 18435,
+ "build_receipt_usd": 0.148702,
+ "list_cost_usd": 0.148702,
+ "checks_hit": 7,
+ "checks_total": 8
+ },
+ {
+ "model": "grok-4.6",
+ "resolved": "grok-4.6-build",
+ "pr": 1035,
+ "wall_s": 260.076,
+ "input_tokens": 16846,
+ "cached_input_tokens": 1920,
+ "output_tokens": 15551,
+ "reasoning_tokens": 14319,
+ "build_receipt_usd": 0.04350572,
+ "list_cost_usd": 0.127958,
+ "checks_hit": 7,
+ "checks_total": 8
+ },
+ {
+ "model": "grok-4.7",
+ "resolved": "grok-4.7-build",
+ "pr": 1035,
+ "wall_s": 747.711,
+ "input_tokens": 16958,
+ "cached_input_tokens": 1152,
+ "output_tokens": 52540,
+ "reasoning_tokens": 50930,
+ "build_receipt_usd": 0.349732,
+ "list_cost_usd": 0.349732,
+ "checks_hit": 7,
+ "checks_total": 8
+ }
+ ]
+}
diff --git a/evals/grok-46-vs-47/run_build.py b/evals/grok-46-vs-47/run_build.py
new file mode 100644
index 00000000..da94ffff
--- /dev/null
+++ b/evals/grok-46-vs-47/run_build.py
@@ -0,0 +1,119 @@
+#!/usr/bin/env python3
+"""Single-turn Grok Build runs of three codegraff PRs at high effort.
+
+Uses the local `grok` CLI (Grok Build), not the public HTTPS API.
+Token cost in the CLI receipt is the public list rate: $2 / 1M input,
+$0.50 / 1M cached input, $6 / 1M output. Reasoning tokens are inside output.
+"""
+
+import json
+import subprocess
+import time
+import uuid
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent
+PROMPTS = ROOT / "prompts"
+OUT = ROOT / "runs"
+OUT.mkdir(exist_ok=True)
+
+MODELS = ("grok-4.6", "grok-4.7")
+PRS = ("1149", "1096", "1035")
+SYSTEM = (
+ "You write unified diffs. Do not use tools. Do not search. "
+ "Output one unified diff and nothing else."
+)
+
+
+def run_one(model: str, pr: str) -> None:
+ session = str(uuid.uuid4())
+ dest = OUT / f"{model}-{pr}.json"
+ meta_path = OUT / f"{model}-{pr}.meta.json"
+ prompt = PROMPTS / f"{pr}.txt"
+ cmd = [
+ "grok",
+ "--prompt-file",
+ str(prompt),
+ "-m",
+ model,
+ "--reasoning-effort",
+ "high",
+ "--output-format",
+ "json",
+ "--max-turns",
+ "1",
+ "--no-plan",
+ "--no-subagents",
+ "--disable-web-search",
+ "--permission-mode",
+ "plan",
+ "--verbatim",
+ "--session-id",
+ session,
+ "--system-prompt-override",
+ SYSTEM,
+ "--disallowed-tools",
+ "bash,edit,write,read,grep,webfetch",
+ ]
+ started = time.perf_counter()
+ wall_start = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
+ proc = subprocess.run(
+ cmd,
+ cwd="/tmp",
+ capture_output=True,
+ text=True,
+ timeout=900,
+ )
+ elapsed = time.perf_counter() - started
+ payload = {
+ "model_flag": model,
+ "pr": pr,
+ "session_id": session,
+ "wall_s": round(elapsed, 3),
+ "started_at": wall_start,
+ "exit_code": proc.returncode,
+ "stderr": proc.stderr[-4000:],
+ }
+ try:
+ payload["response"] = json.loads(proc.stdout)
+ except json.JSONDecodeError:
+ payload["stdout_raw"] = proc.stdout[-20000:]
+ dest.write_text(json.dumps(payload, indent=2) + "\n")
+ usage = (payload.get("response") or {}).get("usage") or {}
+ meta_path.write_text(
+ json.dumps(
+ {
+ "model_flag": model,
+ "pr": pr,
+ "session_id": session,
+ "wall_s": payload["wall_s"],
+ "exit_code": proc.returncode,
+ "usage": usage,
+ "modelUsage": (payload.get("response") or {}).get("modelUsage"),
+ "total_cost_usd": (payload.get("response") or {}).get("total_cost_usd"),
+ "stopReason": (payload.get("response") or {}).get("stopReason"),
+ },
+ indent=2,
+ )
+ + "\n"
+ )
+ print(
+ f"{model} pr={pr} exit={proc.returncode} wall={payload['wall_s']}s "
+ f"in={usage.get('input_tokens')} out={usage.get('output_tokens')} "
+ f"reason={usage.get('reasoning_tokens')} cost={payload.get('response', {}).get('total_cost_usd') if isinstance(payload.get('response'), dict) else None}",
+ flush=True,
+ )
+
+
+def main() -> None:
+ # Head-to-head: both models see the same prompt in the same window.
+ from concurrent.futures import ThreadPoolExecutor
+
+ for pr in PRS:
+ print(f"== pair {pr} ==", flush=True)
+ with ThreadPoolExecutor(max_workers=2) as pool:
+ list(pool.map(lambda model: run_one(model, pr), MODELS))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/evals/grok-46-vs-47/runs/grok-4.6-1035.json b/evals/grok-46-vs-47/runs/grok-4.6-1035.json
new file mode 100644
index 00000000..31e33230
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.6-1035.json
@@ -0,0 +1,37 @@
+{
+ "model_flag": "grok-4.6",
+ "pr": "1035",
+ "session_id": "35c00000-6e64-4831-a1c7-92c012fd0460",
+ "wall_s": 260.076,
+ "started_at": "2026-09-21T17:34:40Z",
+ "exit_code": 0,
+ "stderr": "",
+ "response": {
+ "text": "--- a/src/presence_accord.zig\n+++ b/src/presence_accord.zig\n@@ -1,6 +1,7 @@\n const std = @import(\"std\");\n const Io = std.Io;\n+const proc_identity = @import(\"proc_identity.zig\");\n \n@@\n- const dir = dir_path orelse return;\n- const self = @import(\"proc_identity.zig\").selfRecord(io);\n+ const dir = dir_path orelse return;\n+ const self = proc_identity.selfRecord(io);\n@@\n const name = std.fmt.bufPrint(&name_buf, \"{d}-{x}.accord.sock\", .{ self.pid, self.start_id }) catch return;\n+ sweepReclaimableSocks(io, dir, name);\n@@\n if (g_own_name) |own| if (std.mem.eql(u8, entry.name, own)) continue;\n const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir_path, entry.name }) catch continue;\n+ if (unlinkReclaimableSock(io, path, entry.name)) continue;\n sendLine(io, gpa, path, json_line) catch {};\n@@\n+fn parseSockName(name: []const u8) ?proc_identity.Record {\n+ const suffix = \".accord.sock\";\n+ if (!std.mem.endsWith(u8, name, suffix)) return null;\n+ const stem = name[0 .. name.len - suffix.len];\n+ const dash = std.mem.indexOfScalar(u8, stem, '-') orelse return null;\n+ if (dash == 0 or dash + 1 >= stem.len) return null;\n+ const pid = std.fmt.parseInt(i32, stem[0..dash], 10) catch return null;\n+ if (pid <= 0) return null;\n+ const start_id = std.fmt.parseInt(proc_identity.StartId, stem[dash + 1 ..], 16) catch return null;\n+ return .{ .pid = pid, .start_id = start_id };\n+}\n+\n+fn unlinkReclaimableSock(io: Io, path: []const u8, name: []const u8) bool {\n+ const rec = parseSockName(name) orelse return false;\n+ if (proc_identity.stateOf(io, rec) != .reclaimable) return false;\n+ Io.Dir.cwd().deleteFile(io, path) catch return false;\n+ return true;\n+}\n+\n+fn sweepReclaimableSocks(io: Io, dir_path: []const u8, own_name: []const u8) void {\n+ var live_dir = Io.Dir.cwd().openDir(io, dir_path, .{ .iterate = true }) catch return;\n+ defer live_dir.close(io);\n+ var it = live_dir.iterate(io);\n+ var path_buf: [std.fs.max_path_bytes]u8 = undefined;\n+ while (it.next(io) catch null) |entry| {\n+ if (!std.mem.endsWith(u8, entry.name, \".accord.sock\")) continue;\n+ if (std.mem.eql(u8, entry.name, own_name)) continue;\n+ const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir_path, entry.name }) catch continue;\n+ _ = unlinkReclaimableSock(io, path, entry.name);\n+ }\n+}\n+\n+test \"parseSockName accepts pid-hex sock names and rejects junk\" {\n+ const rec = parseSockName(\"42-2a.accord.sock\") orelse return error.TestUnexpectedResult;\n+ try std.testing.expectEqual(@as(i32, 42), rec.pid);\n+ try std.testing.expectEqual(@as(proc_identity.StartId, 0x2a), rec.start_id);\n+ try std.testing.expect(parseSockName(\"junk\") == null);\n+ try std.testing.expect(parseSockName(\"42.accord.sock\") == null);\n+ try std.testing.expect(parseSockName(\"0-2a.accord.sock\") == null);\n+ try std.testing.expect(parseSockName(\"-1-2a.accord.sock\") == null);\n+ try std.testing.expect(parseSockName(\"42-.accord.sock\") == null);\n+ try std.testing.expect(parseSockName(\"42-2a\") == null);\n+}\n+\n+test \"livePost unlinks reclaimable peer sock\" {\n+ const io = std.testing.io;\n+ if (!test_enabled) return error.SkipZigTest;\n+ listen(io);\n+ defer stop(io);\n+ const dir_path = dir_path orelse return error.SkipZigTest;\n+ var path_buf: [std.fs.max_path_bytes]u8 = undefined;\n+ const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir_path, \"999999-1.accord.sock\" }) catch return error.TestUnexpectedResult;\n+ try Io.Dir.cwd().writeFile(io, path, \"stale\");\n+ livePost(io, std.testing.allocator, \"{}\");\n+ try std.testing.expectError(error.FileNotFound, Io.Dir.cwd().statFile(io, path));\n+}\n",
+ "stopReason": "end_turn",
+ "sessionId": "35c00000-6e64-4831-a1c7-92c012fd0460",
+ "requestId": "b437f71f-60c1-421a-9062-46a91ec9be3e",
+ "thought": "The user wants me to patch justrach/codegraff for PR 1035. They explicitly said:\n```diff\ndiff --git a/src/presence_accord.zig b/src/presence_accord.zig\nindex 8f3e2c5..a1b9d7f 100644\n--- a/src/presence_accord.zig\n+++ b/src/presence_accord.zig\n const std = @import(\"std\");\n const io = @import(\"io.zig\");\n const proc_identity = @import(\"proc_identity.zig\");\n const json = @import(\"json.zig\");\n \n pub const Record = struct {\n pid: i32 = 0,\n start_id: StartId = 0,\n };\n \n pub const OwnerState = enum { held, reclaimable };\n \n pub fn stateOf(io: Io, rec: Record) OwnerState {\n const path = sockPath(rec);\n const stat = io.Dir.cwd().statFile(io, path) catch return . held;\n return if (stat.size == 0) .reclaimable else .held;\n }\n \n fn sockPath(rec: Record) []const u8 {\n return std.fmt.bufPrint(&path_buf, \"{d}-{x}.accord.sock\", .{ rec.pid, rec.start_id }) catch unreachable;\n }\n \n fn parseSockName(name: []const u8) ?proc_identity.Record {\n if (!std.mem.endsWith(u8, name, \".accord.sock\")) return null;\n const stem = name[0 .. name.len - \".accord.sock\".len];\n const dash = std.mem lastIndexOfScalar(u8, stem, '-') orelse return null;\n if (dash == 0 or dash + 1 == stem.len) return null;\n const pid_s = stem[0..dash];\n const hex_s = stem[dash + 1 ..];\n const pid = std.f fmt.parseInt(i32, pid_s, 10) catch return null;\n if (pid <= 0) return null;\n const start_id = std.fmt.parseInt(proc_identity.StartId, hex_s, 16) catch return null;\n return .{ .pid = pid, .start_id = start_id };\n }\n \n fn reclaimPeerSock(io: Io, path: []const u8, name: []const u8) bool {\n const rec = parseSockName(name) orelse return false;\n if (proc_identity.stateOf(io, rec) != .reclaimable) return false ;\n io.Dir.cwd().deleteFile(io, path) catch return false;\n return true;\n }\n \n pub fn listen(io: Io) void {\n const dir_path = liveDirPath() orelse return;\n const self = proc_identity.selfRecord(io);\n const own_name = std.fmt bufPrint(&name_buf, \"{d}-{x}.accord.sock\", .{ self.pid, self.start_id }) catch return;\n sweepReclaimableSocks(io, dir_path, own_name);\n const name = own_name;\n const listener = io.Dir.cwd().openDir(io, dir_path, .{ . iterate = true }) catch return;\n defer listener.close(io);\n g_listener = listener;\n g_own_name = name;\n }\n \n fn sweepReclaimableSocks(io: Io, dir_path: []const u8, own_name: []const u8) void {\n var dir = io.Dir.cwd().openDir(io, dir_path, .{ .iterate = true }) catch return;\n defer dir.close(io);\n var it = dir.iterate(io);\n var path_buf: [std.fs.max_path_bytes]u8 = undefined;\n while (it.next(io) catch null) |entry | {\n if (!std.mem.endsWith(u8, entry.name, \".accord.sock\")) continue;\n if (std.mem.eql(u8, entry.name, own_name)) continue;\n const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir_path, entry.name }) catch continue;\n _ = reclaimPeerSock(io, path, entry.name);\n }\n }\n \n pub fn livePost(io: Io, gpa: Allocator, json_line: []const u8) void {\n const dir_path = liveDirPath() orelse return;\n var dir = io.Dir.cwd openDir(io, dir_path, .{ .iterate = true }) catch return;\n defer dir.close(io);\n var it = dir.iterate(io);\n var path_buf: [std.fs.max_path_bytes]u8 = undefined;\n while (it.next(io) catch null) |entry| {\n if (!std.mem.endsWith(u8, entry.name, \".accord.sock\")) continue;\n if (g_own_name) |own| if (std.mem.eql(u8, entry.name, own)) continue;\n const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir_path , entry.name }) catch continue;\n if (reclaimPeerSock(io, path, entry.name)) continue;\n sendLine(io, gpa, path, json_line) catch {};\n }\n }\n \n pub fn stop(io: Io) void {\n if (g_listener) |listener| {\n listener.close(io);\n g_listener = null;\n }\n g_own_name = null;\n }\n \n test \"parseSockName accepts pid-hex and rejects junk\" {\n const rec = parseSockName(\"42-2a.accord.sock\") orelse return error.TestUnexpectedResult;\n try std testing.expectEqual(@as(i32, 42), rec.pid);\n try std.testing.expectEqual(@as(proc_identity.StartId, 0x2a), rec.start_id);\n try std.testing.expect(parseSockName(\"junk\") == null);\n try std.testing.expect(parseSockName(\"0-2a .accord.sock\") == null);\n try std.testing.expect(parseSockName(\"42-.accord.sock\") == null);\n try std.testing.expect(parseSockName(\"42-zz.accord.sock\") == null);\n }\n \n test \"livePost unlinks a reclaimable peer sock\" {\n const io = std.testing.io;\n if (!test_enabled) return error.SkipZigTest;\n listen(io);\n defer stop(io);\n const dir_path = liveDirPath() orelse return error.SkipZigTest;\n var path_buf: [std.fs.max_path_bytes]u8 = undefined;\n const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir_path, \"999999-1.accord.sock\" }) catch unreachable;\n try io.Dir.cwd().writeFile(io, path, \"x\");\n livePost(io, std.testing.allocator, \"{}\");\n try std.testing.expect Error(FileNotFound, io.Dir.cwd().statFile(io, path));\n }\n``` <file_sep>src/presence_accord.zig</file> <file>proc_identity.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> < file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file> <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.zig</file> <file <file>stop.zig</file> <file>send_line.zig</file> <file>json.zig</file> <file>io.zig</file> <file>live_dir.zig</file> <file>test_enabled.",
+ "usage": {
+ "input_tokens": 16846,
+ "cache_read_input_tokens": 1920,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 15551,
+ "reasoning_tokens": 14319,
+ "total_tokens": 34317
+ },
+ "num_turns": 1,
+ "total_cost_usd": 0.04350572,
+ "total_cost_usd_ticks": 435057200,
+ "modelUsage": {
+ "grok-4.6-build": {
+ "inputTokens": 16846,
+ "outputTokens": 15551,
+ "cacheReadInputTokens": 1920,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.04350572
+ }
+ }
+ }
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.6-1035.meta.json b/evals/grok-46-vs-47/runs/grok-4.6-1035.meta.json
new file mode 100644
index 00000000..52eac756
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.6-1035.meta.json
@@ -0,0 +1,27 @@
+{
+ "model_flag": "grok-4.6",
+ "pr": "1035",
+ "session_id": "35c00000-6e64-4831-a1c7-92c012fd0460",
+ "wall_s": 260.076,
+ "exit_code": 0,
+ "usage": {
+ "input_tokens": 16846,
+ "cache_read_input_tokens": 1920,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 15551,
+ "reasoning_tokens": 14319,
+ "total_tokens": 34317
+ },
+ "modelUsage": {
+ "grok-4.6-build": {
+ "inputTokens": 16846,
+ "outputTokens": 15551,
+ "cacheReadInputTokens": 1920,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.04350572
+ }
+ },
+ "total_cost_usd": 0.04350572,
+ "stopReason": "end_turn"
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.6-1096.json b/evals/grok-46-vs-47/runs/grok-4.6-1096.json
new file mode 100644
index 00000000..9d853888
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.6-1096.json
@@ -0,0 +1,37 @@
+{
+ "model_flag": "grok-4.6",
+ "pr": "1096",
+ "session_id": "c52359d6-ffcf-4476-bc97-7c53feaa6488",
+ "wall_s": 138.814,
+ "started_at": "2026-09-21T17:30:11Z",
+ "exit_code": 0,
+ "stderr": "",
+ "response": {
+ "text": "diff --git a/apps/native/components/primitives/PromptBar.tsx b/apps/native/components/primitives/PromptBar.tsx\n--- a/apps/native/components/primitives/PromptBar.tsx\n+++ b/apps/native/components/primitives/PromptBar.tsx\n@@\n } from \"react\";\n+import { shouldPickComposerRow } from \"../../lib/composer-keyboard\";\n@@\n if (menu && rows.length > 0) {\n if (!event.shiftKey && (event.key === \"ArrowDown\" || event.key === \"ArrowUp\")) {\n event.preventDefault();\n event.stopPropagation();\n setEngaged(true);\n setActive((activeIndex + (event.key === \"ArrowDown\" ? 1 : rows.length - 1)) % rows.length);\n return;\n }\n- if (!event.shiftKey && (event.key === \"Enter\" || event.key === \"Tab\")) {\n+ if (shouldPickComposerRow(event.key, event.shiftKey, engaged)) {\n event.preventDefault();\n event.stopPropagation();\n pick(rows[activeIndex]);\n return;\n }\n }\ndiff --git a/apps/native/lib/composer-keyboard.test.ts b/apps/native/lib/composer-keyboard.test.ts\nnew file mode 100644\n--- /dev/null\n+++ b/apps/native/lib/composer-keyboard.test.ts\n@@ -0,0 +1,42 @@\n+import assert from \"node:assert/strict\";\n+import { describe, it } from \"node:test\";\n+import { shouldPickComposerRow } from \"./composer-keyboard.ts\";\n+\n+describe(\"shouldPickComposerRow\", () => {\n+ it(\"picks on Enter when the row is visibly engaged\", () => {\n+ assert.equal(shouldPickComposerRow(\"Enter\", false, true), true);\n+ });\n+\n+ it(\"picks on Tab when the row is visibly engaged\", () => {\n+ assert.equal(shouldPickComposerRow(\"Tab\", false, true), true);\n+ });\n+\n+ it(\"does not pick on Enter when the menu is not engaged\", () => {\n+ assert.equal(shouldPickComposerRow(\"Enter\", false, false), false);\n+ });\n+\n+ it(\"does not pick on Tab when the menu is not engaged\", () => {\n+ assert.equal(shouldPickComposerRow(\"Tab\", false, false), false);\n+ });\n+\n+ it(\"does not pick on Shift+Enter even when engaged\", () => {\n+ assert.equal(shouldPickComposerRow(\"Enter\", true, true), false);\n+ });\n+\n+ it(\"does not pick on Shift+Tab even when engaged\", () => {\n+ assert.equal(shouldPickComposerRow(\"Tab\", true, true), false);\n+ });\n+\n+ it(\"does not treat arrow keys as activation\", () => {\n+ assert.equal(shouldPickComposerRow(\"ArrowDown\", false, true), false);\n+ assert.equal(shouldPickComposerRow(\"ArrowUp\", false, true), false);\n+ assert.equal(shouldPickComposerRow(\"ArrowDown\", false, false), false);\n+ assert.equal(shouldPickComposerRow(\"ArrowUp\", false, false), false);\n+ });\n+\n+ it(\"does not pick on unrelated keys\", () => {\n+ assert.equal(shouldPickComposerRow(\"Escape\", false, true), false);\n+ assert.equal(shouldPickComposerRow(\" \", false, true), false);\n+ });\n+});\ndiff --git a/apps/native/lib/composer-keyboard.ts b/apps/native/lib/composer-keyboard.ts\nnew file mode 100644\n--- /dev/null\n+++ b/apps/native/lib/composer-keyboard.ts\n@@ -0,0 +1,10 @@\n+export function shouldPickComposerRow(\n+ key: string,\n+ shiftKey: boolean,\n+ engaged: boolean,\n+): boolean {\n+ if (!engaged || shiftKey) {\n+ return false;\n+ }\n+ return key === \"Enter\" || key === \"Tab\";\n+}\ndiff --git a/apps/native/package.json b/apps/native/package.json\n--- a/apps/native/package.json\n+++ b/apps/native/package.json\n@@\n- \"test\": \"node --experimental-strip-types --test lib/composer-model-pick.test.ts\n+ \"test\": \"node --experimental-strip-types --test lib/composer-keyboard.test.ts lib/composer-model-pick.test.ts",
+ "stopReason": "end_turn",
+ "sessionId": "c52359d6-ffcf-4476-bc97-7c53feaa6488",
+ "requestId": "039d134f-8e5e-416d-9cfa-6fdd012ef919",
+ "thought": "The user wants me to patch justrach/codegraff with a unified diff and nothing else. They explicitly said \"Do not use tools. Reply with one unified diff and nothing else.\"\n```diff\ndiff --git a/apps/native/lib/composer-keyboard.ts b/apps/native/lib/composer-keyboard.ts\nindex 8e9f0c5..3f7a2b1 100644\n--- a/apps/native/lib/composer-keyboard.ts\n+++ b/apps/native/lib/composer 100644\n@@ -1,3 +1,4 @@\n+import { shouldPickComposerRow } from './composer-keyboard';\n \n export function handleComposerKeyboard(\n event: KeyboardEvent,\n@@ -18,7 +19,7 @@ export function handleComposerKeyboard(\n return;\n }\n \n- if (!event.shiftKey && (event.key === \"Enter\" || event.key === \"Tab\")) {\n+ if (shouldPickComposerRow(event.key, event.shiftKey, engaged)) {\n event.preventDefault();\n event.stopPropagation();\n pick(rows[activeIndex]);\n@@ -28,6 +29, 7 @@ export function handleComposerKeyboard(\n }\n }\n \n+export function shouldPickComposerRow(key: string, shiftKey: boolean, engaged: boolean): boolean {\n+ if (!engaged) return false;\n+ if (shiftKey) return false;\n+ return key === \"Enter\" || key === \"Tab\";\n+}\n+\n```\n\n```diff\ndiff --git a/apps/native/lib/composer-keyboard.test.ts b/apps/native/lib/composer-keyboard.test.ts\nnew file mode 100644\nindex 0000000..8e9f0c5\n--- /dev/null\n+++ b/apps/native 100644\n@@ -0,0 +1,28 @@\n+import { describe, it } from \"node:test\";\n+import assert from \"node:assert/strict\";\n+import { shouldPickComposerRow } from \"./composer-keyboard\";\n+\n+describe(\"shouldPickComposerRow\", () => {\n+ it(\"returns true for Enter when engaged and no shift\", () => {\n+ assert.strictEqual(shouldPickComposerRow(\"Enter\", false, true), true);\n+ });\n+\n+ it(\"returns true for Tab when engaged and no shift\", () => {\n+ assert.strictEqual(shouldPickComposer Row(\"Tab\", false, true), true);\n+ });\n+\n+ it(\"returns false for Enter when not engaged\", () => {\n+ assert.strictEqual(shouldPickComposerRow(\"Enter\", false, false), false);\n+ });\n+\n+ it(\"returns false for Tab when not engaged\", () => {\n+ assert.strictEqual(shouldPickComposerRow(\"Tab\", false, false), false);\n+ });\n+\n+ it(\"returns false for Shift+Enter when engaged\", () => {\n+ assert.strictEqual(shouldPickComposerRow(\"Enter\", true, true), false);\n+ });\n });\n```\n\n```diff\ndiff --git a/apps/native/package.json b/apps/native/package.json\nindex 7c8e9f0..8e9f0c5 100644\n--- a/apps/native/package.json\n+++ b/apps/native/package.json\n@@ -1,5 +1,5 @@\n \"scripts\": {\n- \"test\": \"node --experimental-strip-types --test lib/composer-model-pick.test.ts\",\n+ \"test\": \"node --experimental-strip-types --test lib/composer-keyboard.test.ts lib/composer-model-pick.test.ts\",\n },\n```\n\n```diff\ndiff --git a/apps native/components/primitives/PromptBar.tsx b/apps/native/components/primitives/PromptBar.tsx\nindex 9f0c5e8..7c8e9f0 100644\n--- a/apps/native/components/primitives/PromptBar.tsx\n+++ b/apps/native/components/primitives/PromptBar.tsx\n import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n+ import { shouldPickComposerRow } from \"../../lib/composer-keyboard\";\n \n const handleKeyDown = useCallback((event: KeyboardEvent) => {\n if (menu && rows.length > 0 ) {\n if (!event.shiftKey && (event.key === \"ArrowDown\" || event.key === \"ArrowUp\")) {\n event.preventDefault();\n event.stopPropagation();\n setEngaged(true);\n setActive((activeIndex + (event.key === \"ArrowDown\" ? 1 : rows.length - 1)) % rows.length);\n return;\n }\n- if (!event.shiftKey && (event.key === \"Enter\" || event.key === \"Tab\")) {\n+ if (shouldPickComposerRow(event.key, event.shiftKey, engaged)) {\n event.preventDefault();\n event.stopPropagation();\n pick (rows[activeIndex]);\n return;\n }\n }\n }, [menu, rows, engaged, activeIndex, pick]);\n```\n\n```diff\ndiff --git a/apps/native/lib/composer-keyboard.ts b/apps/native/lib/composer-keyboard.ts\nindex 8e9f0c5..3 100644\n--- a/apps/native/lib/composer-keyboard.ts\n+++ b/apps/native/lib/composer-keyboard.ts\n@@ -1,3 +1,4 @@\n+import { shouldPickComposerRow } from './composer-keyboard';\n \n export function handleComposerKeyboard(\n event: KeyboardEvent,\n@@ - 18,7 +19,7 @@ export function handleComposerKeyboard(\n return;\n }\n \n- if (!event.shiftKey && (event.key === \"Enter\" || event.key === \"Tab\")) {\n+ if (shouldPickComposerRow(event.key, event.shiftKey, engaged)) {\n event.prevent Default();\n event.stopPropagation();\n pick(rows[activeIndex]);\n@@ -28,6 +29, 7 @@ export function handleComposerKeyboard(\n }\n }\n \n+export function shouldPickComposerRow(key: string, shiftKey: boolean, engaged: boolean): boolean {\n+ if (!engaged) return false;\n+ if (shiftKey) return false;\n+ return key === \"Enter\" || key === \"Tab\";\n+}\n+\n```\n\n```diff\ndiff --git a/apps/native/lib/composer-keyboard.test.ts b/apps/native/lib/composer-keyboard.test.ts\nnew file mode 100644\n index 0000000..8e9f0c5\n--- /dev/null\n+++ b/apps/native/lib/composer-keyboard.test.ts\n@@ -0,0 +1,28 @@\n+import { describe, it } from \"node:test\";\n+import assert from \"node:assert/strict\";\n import { shouldPickComposerRow } from \"./composer-keyboard\";\n \n describe(\"shouldPickComposerRow\", () => {\n it(\"returns true for Enter when engaged and no shift\", () => {\n assert.strictEqual(shouldPickComposerRow(\"Enter\", false, true), true);\n });\n \n it(\" returns true for Tab when engaged and no shift\", () => {\n assert.",
+ "usage": {
+ "input_tokens": 18669,
+ "cache_read_input_tokens": 0,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 8064,
+ "reasoning_tokens": 7036,
+ "total_tokens": 26733
+ },
+ "num_turns": 1,
+ "total_cost_usd": 0.02914548,
+ "total_cost_usd_ticks": 291454800,
+ "modelUsage": {
+ "grok-4.6-build": {
+ "inputTokens": 18669,
+ "outputTokens": 8064,
+ "cacheReadInputTokens": 0,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.02914548
+ }
+ }
+ }
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.6-1096.meta.json b/evals/grok-46-vs-47/runs/grok-4.6-1096.meta.json
new file mode 100644
index 00000000..03c9a450
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.6-1096.meta.json
@@ -0,0 +1,27 @@
+{
+ "model_flag": "grok-4.6",
+ "pr": "1096",
+ "session_id": "c52359d6-ffcf-4476-bc97-7c53feaa6488",
+ "wall_s": 138.814,
+ "exit_code": 0,
+ "usage": {
+ "input_tokens": 18669,
+ "cache_read_input_tokens": 0,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 8064,
+ "reasoning_tokens": 7036,
+ "total_tokens": 26733
+ },
+ "modelUsage": {
+ "grok-4.6-build": {
+ "inputTokens": 18669,
+ "outputTokens": 8064,
+ "cacheReadInputTokens": 0,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.02914548
+ }
+ },
+ "total_cost_usd": 0.02914548,
+ "stopReason": "end_turn"
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.6-1149.json b/evals/grok-46-vs-47/runs/grok-4.6-1149.json
new file mode 100644
index 00000000..20acb368
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.6-1149.json
@@ -0,0 +1,37 @@
+{
+ "model_flag": "grok-4.6",
+ "pr": "1149",
+ "session_id": "f6b5daf6-844b-4b19-89ff-0185387c2f48",
+ "wall_s": 108.547,
+ "started_at": "2026-09-21T17:24:37Z",
+ "exit_code": 0,
+ "stderr": "",
+ "response": {
+ "text": "```diff\ndiff --git a/apps/native/electron/webauthn-profile.test.cjs b/apps/native/electron/webauthn-profile.test.cjs\n--- a/apps/native/electron/webauthn-profile.test.cjs\n+++ b/apps/native/electron/webauthn-profile.test.cjs\n@@ -1,5 +1,12 @@\n test('accepts a profile until its expiration boundary', () => {\n const profile = fixture();\n profile.ExpirationDate = new Date(now + 1);\n assert.deepEqual(authorize(profile), { 'com.apple.application-identifier': appId });\n });\n+\n+test('rejects TEAM.* keychain groups when application-identifier is another bundle', () => {\n+ const profile = fixture();\n+ profile.Entitlements['com.apple.application-identifier'] = 'ABCDE12345.org.example.other';\n+ assert.throws(() => authorize(profile), /application-identifier/);\n+});\ndiff --git a/apps/native/electron/webauthn-signing.test.cjs b/apps/native/electron/webauthn-signing.test.cjs\n--- a/apps/native/electron/webauthn-signing.test.cjs\n+++ b/apps/native/electron/webauthn-signing.test.cjs\n@@ -1,5 +1,12 @@\n test('invalid metadata fails before writing config or invoking signer', async () => {\n let called = false;\n await assert.rejects(signBundle({ app: 'Fixture.app', identity, teamId: '', readBundleId: () => bundleId, sign: () => { called = true; } }), /valid signing team/);\n assert.equal(called, false);\n });\n+\n+test('rejects a same-team profile for a different bundle before the signer runs', async () => {\n+ let called = false;\n+ await assert.rejects(signBundle({ app: 'Fixture.app', identity, teamId: 'ABCDE12345', readBundleId: () => bundleId, readProvisioningProfile: () => profile('org.example.other'), sign: () => { called = true; } }), /application-identifier/);\n+ assert.equal(called, false);\n+});\n```",
+ "stopReason": "end_turn",
+ "sessionId": "f6b5daf6-844b-4b19-89ff-0185387c2f48",
+ "requestId": "4f8606e5-c9a8-4606-8c82-4ebf3c15d583",
+ "thought": "The user wants me to patch justrach/codegraff with a unified diff only - no tools. Let me understand the request:\n```diff\ndiff --git a/packages/test-utils/src/webauthn-profile.test.cjs b/packages/test-utils/src/webauthn-profile.test.cjs\nindex 5e8f0c3..a1b2c4d 100644\n--- a/packages/test-utils/src/webauthn profile.test.cjs\n+++ b/packages/test-utils/src/webauthn-profile.test.cjs\n@@ -142,6 +142,18 @@ test('rejects profiles with mismatched application-identifier', () => {\n assert.throws(() => authorize(profile), /application-identifier/);\n });\n \n+test('rejects TEAM.* keychain groups when application-identifier is another bundle', () => {\n+ const profile = fixture();\n+ profile.Entitlements['com.apple.application-identifier'] = 'ABCDE12345.org.example.other';\n+ profile.Entitlements['keychain-access-groups'] = ['ABCDE12345 . *'];\n+ assert.throws(() => authorize(profile), /application-identifier|keychain-access-groups/);\n+});\n+\n test('rejects profiles with mismatched keychain-access-groups', () => {\n const profile = fixture();\n profile.Entitlements['keychain-access-groups'] = ['ABCDE123 45.org.example.fixture.other'];\n@@ -189,6 +201,18 @@ test('accepts a profile until its expiration boundary', () => {\n assert.throws(() => authorize(profile), /expired/);\n });\n \n+test('rejects a same-team profile for a different bundle before the signer runs', async () => {\n+ let called = false;\n+ await assert.rejects(signBundle({\n+ app: 'Fixture.app',\n+ identity,\n+ teamId: 'ABCDE12345',\n+ readBundleId: () => bundleId,\n+ readProvisioningProfile: () => profile('org.example other'),\n+ sign: () => { called = true; },\n+ }), /application-identifier|bundle|profile/);\n+ assert.equal(called, false);\n+});\n+\n test('invalid metadata fails before writing config or invoking signer', async () => {\n let called = false;\n await assert.reject s(signBundle({ app: 'Fixture.app', identity, teamId: '', readBundleId: () => bundleId, sign: () => { called = true; } }), /valid signing team/);\n assert.equal(called, false);\n```\n\n**Note:** I adjusted the regexes to be more specific to the entitlement mismatch and bundle mismatch cases. The profile test adds a dedicated test for the TEAM.* keychain group case with a different bundle ID. The signing test ensures the profile is rejected early before the signer runs. These match the existing assertion style (assert.throws for sync profile validation, assert.rejects + called flag for async signing).",
+ "usage": {
+ "input_tokens": 17502,
+ "cache_read_input_tokens": 256,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 5962,
+ "reasoning_tokens": 5461,
+ "total_tokens": 23720
+ },
+ "num_turns": 1,
+ "total_cost_usd": 0.02410736,
+ "total_cost_usd_ticks": 241073600,
+ "modelUsage": {
+ "grok-4.6-build": {
+ "inputTokens": 17502,
+ "outputTokens": 5962,
+ "cacheReadInputTokens": 256,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.02410736
+ }
+ }
+ }
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.6-1149.meta.json b/evals/grok-46-vs-47/runs/grok-4.6-1149.meta.json
new file mode 100644
index 00000000..21ac01c6
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.6-1149.meta.json
@@ -0,0 +1,27 @@
+{
+ "model_flag": "grok-4.6",
+ "pr": "1149",
+ "session_id": "f6b5daf6-844b-4b19-89ff-0185387c2f48",
+ "wall_s": 108.547,
+ "exit_code": 0,
+ "usage": {
+ "input_tokens": 17502,
+ "cache_read_input_tokens": 256,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 5962,
+ "reasoning_tokens": 5461,
+ "total_tokens": 23720
+ },
+ "modelUsage": {
+ "grok-4.6-build": {
+ "inputTokens": 17502,
+ "outputTokens": 5962,
+ "cacheReadInputTokens": 256,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.02410736
+ }
+ },
+ "total_cost_usd": 0.02410736,
+ "stopReason": "end_turn"
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.7-1035.json b/evals/grok-46-vs-47/runs/grok-4.7-1035.json
new file mode 100644
index 00000000..48c22e98
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.7-1035.json
@@ -0,0 +1,37 @@
+{
+ "model_flag": "grok-4.7",
+ "pr": "1035",
+ "session_id": "8a5b8fb8-02ab-456e-b588-0eaa64481ef3",
+ "wall_s": 747.711,
+ "started_at": "2026-09-21T17:34:40Z",
+ "exit_code": 0,
+ "stderr": "",
+ "response": {
+ "text": "diff --git a/src/presence_accord.zig b/src/presence_accord.zig\n--- a/src/presence_accord.zig\n+++ b/src/presence_accord.zig\n@@ -0,0 +1,83 @@\n+fn parseSockName(name: []const u8) ?@import(\"proc_identity.zig\").Record {\n+ const suffix = \".accord.sock\";\n+ if (!std.mem.endsWith(u8, name, suffix)) return null;\n+ const stem = name[0 .. name.len - suffix.len];\n+ const sep = std.mem.indexOfScalar(u8, stem, '-') orelse return null;\n+ if (sep == 0) return null;\n+ const pid_text = stem[0..sep];\n+ const hex_text = stem[sep + 1 ..];\n+ if (pid_text.len == 0 or hex_text.len == 0) return null;\n+ for (pid_text) |c| {\n+ if (c < '0' or c > '9') return null;\n+ }\n+ for (hex_text) |c| {\n+ switch (c) {\n+ '0'...'9', 'a'...'f', 'A'...'F' => {},\n+ else => return null,\n+ }\n+ }\n+ const pid = std.fmt.parseInt(i32, pid_text, 10) catch return null;\n+ if (pid <= 0) return null;\n+ const sample: @import(\"proc_identity.zig\").Record = .{};\n+ const start_id = std.fmt.parseInt(@TypeOf(sample.start_id), hex_text, 16) catch return null;\n+ return .{ .pid = pid, .start_id = start_id };\n+}\n+\n+fn unlinkIfReclaimable(io: Io, live_dir: []const u8, name: []const u8) bool {\n+ if (g_own_name) |own| if (std.mem.eql(u8, name, own)) return false;\n+ const self = @import(\"proc_identity.zig\").selfRecord(io);\n+ var own_buf: [160]u8 = undefined;\n+ if (std.fmt.bufPrint(&own_buf, \"{d}-{x}.accord.sock\", .{ self.pid, self.start_id })) |own| {\n+ if (std.mem.eql(u8, name, own)) return false;\n+ } else |_| {}\n+ const rec = parseSockName(name) orelse return false;\n+ if (@import(\"proc_identity.zig\").stateOf(io, rec) != .reclaimable) return false;\n+ var path_buf: [std.fs.max_path_bytes]u8 = undefined;\n+ const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ live_dir, name }) catch return false;\n+ Io.Dir.cwd().deleteFile(io, path) catch return false;\n+ return true;\n+}\n+\n+fn sweepReclaimableSocks(io: Io, live_dir: []const u8) void {\n+ var opened = Io.Dir.cwd().openDir(io, live_dir, .{ .iterate = true }) catch return;\n+ defer opened.close(io);\n+ var it = opened.iterate();\n+ while (it.next(io) catch null) |entry| {\n+ if (!std.mem.endsWith(u8, entry.name, \".accord.sock\")) continue;\n+ _ = unlinkIfReclaimable(io, live_dir, entry.name);\n+ }\n+}\n+\n+var noted_live_dir_buf: [std.fs.max_path_bytes]u8 = undefined;\n+var noted_live_dir: ?[]const u8 = null;\n+\n+fn noteLiveDir(dir: []const u8) void {\n+ if (dir.len > noted_live_dir_buf.len) return;\n+ @memcpy(noted_live_dir_buf[0..dir.len], dir);\n+ noted_live_dir = noted_live_dir_buf[0..dir.len];\n+}\n+\n+test \"parseSockName accepts 42-2a.accord.sock and rejects junk\" {\n+ const rec = parseSockName(\"42-2a.accord.sock\") orelse return error.TestExpectedEqual;\n+ try std.testing.expectEqual(@as(i32, 42), rec.pid);\n+ try std.testing.expectEqual(@as(@TypeOf(rec.start_id), 0x2a), rec.start_id);\n+ try std.testing.expect(parseSockName(\"junk\") == null);\n+ try std.testing.expect(parseSockName(\"0-1.accord.sock\") == null);\n+ try std.testing.expect(parseSockName(\"-9-1.accord.sock\") == null);\n+ try std.testing.expect(parseSockName(\"12-.accord.sock\") == null);\n+ try std.testing.expect(parseSockName(\"12.accord.sock\") == null);\n+}\n+\n+test \"livePost unlinks reclaimable peer sock\" {\n+ if (!test_enabled) return;\n+ const io = std.testing.io;\n+ listen(io);\n+ defer stop(io);\n+ const dir = noted_live_dir orelse return error.TestExpectedEqual;\n+ var path_buf: [std.fs.max_path_bytes]u8 = undefined;\n+ const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir, \"999999-1.accord.sock\" }) catch unreachable;\n+ try Io.Dir.cwd().writeFile(io, path, \"\");\n+ livePost(io, std.testing.allocator, \"{}\");\n+ try std.testing.expectError(error.FileNotFound, Io.Dir.cwd().statFile(io, path));\n+}\n+\n@@ -100,2 +183,4 @@\n const dir = dir_path orelse return;\n const self = @import(\"proc_identity.zig\").selfRecord(io);\n+noteLiveDir(dir);\n+sweepReclaimableSocks(io, dir);\n@@ -250,6 +335,7 @@\n while (it.next(io) catch null) |entry| {\n if (!std.mem.endsWith(u8, entry.name, \".accord.sock\")) continue;\n if (g_own_name) |own| if (std.mem.eql(u8, entry.name, own)) continue;\n- const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir_path, entry.name }) catch continue;\n- sendLine(io, gpa, path, json_line) catch {};\n+ if (unlinkIfReclaimable(io, dir_path, entry.name)) continue;\n+ const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir_path, entry.name }) catch continue;\n+ sendLine(io, gpa, path, json_line) catch {};\n }\n",
+ "stopReason": "end_turn",
+ "sessionId": "8a5b8fb8-02ab-456e-b588-0eaa64481ef3",
+ "requestId": "198b8603-c8f3-4572-9f86-09a913e99ddd",
+ "thought": "The user wants me to write a unified diff for src/presence_accord.zig only. They explicitly said \"Do not use tools. Reply with one unified diff and nothing else.\"\n```diff\ndiff --git a/src/presence_accord.zig b/src/presence_accord.zig\nindex 8f3e2c1..9a7b4d2 100644\n--- a/src/presence_accord.zig\n+++ b/src/presence_accord.zig\n const std = @import(\"std\");\n const io = @import(\"io.zig\");\n const proc_identity = @import(\"proc_identity.zig\");\n \n pub const Record = struct {\n pid: i32 = 0,\n start_id: StartId = 0,\n };\n \n pub const OwnerState = enum { held, reclaimable };\n \n pub fn stateOf(io: Io, rec: Record) OwnerState {\n const path = sockPath(rec);\n const stat = io.dir.statFile(io, path) catch return .reclaimable;\n return if (stat.kind == .file and stat.size > 0) .held else .reclaimable;\n }\n \n fn sockPath(rec: Record) []const u8 {\n return std.fmt.allocPrint(null, \"{d}-{x}.accord.sock\", .{ rec.pid, rec.start_id }) catch unreachable;\n }\n \n fn parseSockName(name: []const u8) ?proc_identity.Record {\n const suffix = \".accord.sock\";\n if (!std.mem.endsWith(u8, name, suffix)) return null;\n const stem = name[0 .. name.len - suffix.len];\n const dash = std.mem.indexOfScalar(u 8, stem, '-') orelse return null;\n if (dash == 0) return null;\n const pid_slice = stem[0..dash];\n const hex_slice = stem[dash + 1 ..];\n if (hex_slice.len == 0) return null;\n const pid = std.f mt.parseInt(i32, pid_slice, 10) catch return null;\n if (pid <= 0) return null;\n const start_id = std.fmt.parseInt(proc_identity.StartId, hex_slice, 16) catch return null;\n return .{ .pid = pid, .start_id = start_id };\n }\n \n fn reclaimIfDead(io: Io, dir_path: []const u8, name: []const u8) bool {\n const rec = parseSockName(name) orelse return false;\n if (proc_identity.stateOf(io, rec) != .reclaimable) return false;\n var path_buf: [std.fs.max_path_bytes]u8 = undefined;\n const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir_path, name }) catch return false;\n io.dir.deleteFile(io, path) catch return false;\n return true;\n }\n \n pub fn livePost(io: Io, gpa: std.mem.Allocator, dir_path: []const u8, json_line: []const u8) void {\n var path_buf: [std.fs.max_path_bytes]u8 = undefined;\n var it = io.dir.iterate(io) catch return;\n while (it.next(io) catch null) |entry| {\n if (!std.mem.endsWith(u8, entry.name, \".accord.sock\")) continue;\n if (g_own_name) |own| if (std.mem.eql(u8, entry.name, own)) continue;\n if (reclaimIfDead(io, dir_path, entry.name)) continue;\n const path = std.fmt.bufPrint(&path_buf, \"{s}/{s}\", .{ dir_path, entry.name }) catch continue;\n sendLine(io, gpa, path, json_line) catch {};\n }\n }\n \n pub fn listen(io: Io, gpa: std.mem.Allocator, dir_path: []const u8) void {\n const dir = dir_path orelse return;\n const self = proc_identity.selfRecord(io);\n sweepReclaimable(io, dir);\n // bind own sock here (omitted for brevity)\n }\n \n fn sweepReclaimable(io: Io, dir_path: []const u8) void {\n var it = io.dir.iterate(io) catch return;\n while (it.next(io) catch null) |entry| {\n if (!std.mem.endsWith(u8, entry.name , \".accord.sock\")) continue;\n if (reclaimIfDead(io, dir_path, entry.name)) {}\n }\n }\n \n test \"parseSockName accepts pid-hex and rejects junk\" {\n if (!test_enabled) return;\n try std.testing.expectEqual(@as(i32, 42), parseSockName(\"42-2a.accord.sock\").?.pid);\n try std.testing.expectEqual(@as(proc_identity.StartId, 0x2a), parseSockName(\"42-2a.accord.sock\").?.start_id);\n try std.testing.expect(parseSockName(\"junk\") == null);\n }\n \n test \"livePost unlinks reclaimable peer sock\" {\n if (!test_enabled) return;\n const io = std.testing.io;\n const dir_path = \".\";\n try listen(io, std.testing.allocator, dir_path);\n try io.dir.writeFile(io, \"999999-1 .accord.sock\", \"\");\n livePost(io, std.testing.allocator, dir_path, \"test\");\n const stat = io.dir.statFile(io, \"999999-1.accord.sock\");\n try std.testing.expectError(error.FileNotFound, stat);\n stop();\n }\n``` <file_sep>tmp/presence_accord.zig.diff> <file_sep>tmp/presence_accord.zig.diff> <file_sep>tmp/presence_accord.zig.diff> <file_sep>tmp/presence_accord.zig.diff> <file_sep>tmp/presence_accord.zig.diff> <file_sep>tmp/presence_acc ord.zig.diff> <file_sep>tmp/presence_accord.zig.diff> <file_sep>tmp/presence_accord.zig.diff> <file_sep>tmp/presence_accord.zig.diff> <file_sep>tmp/presence_accord.zig.",
+ "usage": {
+ "input_tokens": 16958,
+ "cache_read_input_tokens": 1152,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 52540,
+ "reasoning_tokens": 50930,
+ "total_tokens": 70650
+ },
+ "num_turns": 1,
+ "total_cost_usd": 0.349732,
+ "total_cost_usd_ticks": 3497320000,
+ "modelUsage": {
+ "grok-4.7-build": {
+ "inputTokens": 16958,
+ "outputTokens": 52540,
+ "cacheReadInputTokens": 1152,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.349732
+ }
+ }
+ }
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.7-1035.meta.json b/evals/grok-46-vs-47/runs/grok-4.7-1035.meta.json
new file mode 100644
index 00000000..0d5f183d
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.7-1035.meta.json
@@ -0,0 +1,27 @@
+{
+ "model_flag": "grok-4.7",
+ "pr": "1035",
+ "session_id": "8a5b8fb8-02ab-456e-b588-0eaa64481ef3",
+ "wall_s": 747.711,
+ "exit_code": 0,
+ "usage": {
+ "input_tokens": 16958,
+ "cache_read_input_tokens": 1152,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 52540,
+ "reasoning_tokens": 50930,
+ "total_tokens": 70650
+ },
+ "modelUsage": {
+ "grok-4.7-build": {
+ "inputTokens": 16958,
+ "outputTokens": 52540,
+ "cacheReadInputTokens": 1152,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.349732
+ }
+ },
+ "total_cost_usd": 0.349732,
+ "stopReason": "end_turn"
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.7-1096.json b/evals/grok-46-vs-47/runs/grok-4.7-1096.json
new file mode 100644
index 00000000..fd2f2936
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.7-1096.json
@@ -0,0 +1,37 @@
+{
+ "model_flag": "grok-4.7",
+ "pr": "1096",
+ "session_id": "bebeba28-95f9-4160-ae43-0552af1f3d8f",
+ "wall_s": 269.817,
+ "started_at": "2026-09-21T17:30:11Z",
+ "exit_code": 0,
+ "stderr": "",
+ "response": {
+ "text": "diff --git a/apps/native/lib/composer-keyboard.ts b/apps/native/lib/composer-keyboard.ts\nnew file mode 100644\n--- /dev/null\n+++ b/apps/native/lib/composer-keyboard.ts\n@@ -0,0 +1,10 @@\n+// Keyboard activation follows the visible highlight. Hover and arrow keys set\n+// `engaged`; until then Enter submits and Tab keeps normal focus traversal.\n+export function shouldPickComposerRow(\n+ key: string,\n+ shiftKey: boolean,\n+ engaged: boolean,\n+): boolean {\n+ if (shiftKey || !engaged) return false;\n+ return key === \"Enter\" || key === \"Tab\";\n+}\ndiff --git a/apps/native/lib/composer-keyboard.test.ts b/apps/native/lib/composer-keyboard.test.ts\nnew file mode 100644\n--- /dev/null\n+++ b/apps/native/lib/composer-keyboard.test.ts\n@@ -0,0 +1,32 @@\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { shouldPickComposerRow } from \"./composer-keyboard.ts\";\n+\n+test(\"picks an engaged row on Enter or Tab without Shift\", () => {\n+ assert.equal(shouldPickComposerRow(\"Enter\", false, true), true);\n+ assert.equal(shouldPickComposerRow(\"Tab\", false, true), true);\n+});\n+\n+test(\"does not pick when the row is not engaged\", () => {\n+ assert.equal(shouldPickComposerRow(\"Enter\", false, false), false);\n+ assert.equal(shouldPickComposerRow(\"Tab\", false, false), false);\n+});\n+\n+test(\"does not pick on Shift+Enter or Shift+Tab\", () => {\n+ assert.equal(shouldPickComposerRow(\"Enter\", true, true), false);\n+ assert.equal(shouldPickComposerRow(\"Tab\", true, true), false);\n+ assert.equal(shouldPickComposerRow(\"Enter\", true, false), false);\n+});\n+\n+test(\"arrow keys are not activation keys\", () => {\n+ assert.equal(shouldPickComposerRow(\"ArrowDown\", false, true), false);\n+ assert.equal(shouldPickComposerRow(\"ArrowUp\", false, true), false);\n+ assert.equal(shouldPickComposerRow(\"ArrowDown\", true, true), false);\n+ assert.equal(shouldPickComposerRow(\"ArrowUp\", false, false), false);\n+});\n+\n+test(\"other keys do not pick a row\", () => {\n+ assert.equal(shouldPickComposerRow(\"Escape\", false, true), false);\n+ assert.equal(shouldPickComposerRow(\" \", false, true), false);\n+ assert.equal(shouldPickComposerRow(\"a\", false, true), false);\n+});\ndiff --git a/apps/native/components/primitives/PromptBar.tsx b/apps/native/components/primitives/PromptBar.tsx\n--- a/apps/native/components/primitives/PromptBar.tsx\n+++ b/apps/native/components/primitives/PromptBar.tsx\n@@ -1,0 +1,1 @@\n+import { shouldPickComposerRow } from \"../../lib/composer-keyboard\";\n@@ -1,12 +2,12 @@\n if (menu && rows.length > 0) {\n if (!event.shiftKey && (event.key === \"ArrowDown\" || event.key === \"ArrowUp\")) {\n event.preventDefault();\n event.stopPropagation();\n setEngaged(true);\n setActive((activeIndex + (event.key === \"ArrowDown\" ? 1 : rows.length - 1)) % rows.length);\n return;\n }\n- if (!event.shiftKey && (event.key === \"Enter\" || event.key === \"Tab\")) {\n+ if (shouldPickComposerRow(event.key, event.shiftKey, engaged)) {\n event.preventDefault();\n event.stopPropagation();\n pick(rows[activeIndex]);\n return;\n }\n }\ndiff --git a/apps/native/package.json b/apps/native/package.json\n--- a/apps/native/package.json\n+++ b/apps/native/package.json\n@@ -1,1 +1,1 @@\n- \"test\": \"node --experimental-strip-types --test lib/composer-model-pick.test.ts\",\n+ \"test\": \"node --experimental-strip-types --test lib/composer-keyboard.test.ts lib/composer-model-pick.test.ts\",\n",
+ "stopReason": "end_turn",
+ "sessionId": "bebeba28-95f9-4160-ae43-0552af1f3d8f",
+ "requestId": "b0505c4d-1f23-4437-acbb-146eaa1b1d18",
+ "thought": "The user wants me to write a unified diff for a specific bug fix. They explicitly said \"Do not use tools. Reply with one unified diff and nothing else.\"\n```diff\ndiff --git a/apps/native/lib/composer-keyboard.ts b/apps/native/lib/composer-keyboard.ts\nindex 8f3e2c5..9a7b1d4 100644\n--- a/apps/native/lib/composer-keyboard.ts\n+++ b/apps/native/lib/composer keyboard.ts\n@@ -45,6 +45,15 @@ export function useComposerKeyboard(\n }\n }\n \n+function shouldPickComposerRow(key: string, shiftKey: boolean, engaged: boolean): boolean {\n+ if (shiftKey) return false;\n+ if (key === \"Enter\" || key === \"Tab\") {\n+ return engaged;\n+ }\n+ return false;\n+}\n+\n export function useComposerKeyboard(\n menu: boolean,\n rows: string[],\n@@ -60,7 +69,7 @@ export function useComposerKeyboard(\n if (menu && rows.length > 0 ) {\n if (!event.shiftKey && (event.key === \"ArrowDown\" || event.key === \"ArrowUp\")) {\n event.preventDefault();\n- event.stopPropagation();\n+ event.stopPropagation();\n setEngaged(true);\n setActive((activeIndex + (event.key === \"ArrowDown\" ? 1 : rows.length - 1)) % rows.length);\n return;\n@@ -68,7 +77,7 @@ export function useComposerKeyboard(\n if (!event.shiftKey && (event.key === \"Enter\" || event.key === \"Tab\")) {\n event.preventDefault();\n event.stopPropagation ();\n- pick(rows[activeIndex]);\n+ pick(rows[activeIndex]);\n return;\n }\n }\ndiff --git a/apps/native/lib/composer-keyboard.test.ts b/apps/native/lib/composer-keyboard.test.ts\nnew file mode 100644\nindex 0000000..8f3 4c5\n--- /dev/null\n+++ b/apps/native/lib/composer-keyboard.test.ts\n@@ -0,0 +1,45 @@\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { shouldPickComposerRow } from \"./composer-key board.ts\";\n+\n+test(\"shouldPickComposerRow\", () => {\n+ assert.strictEqual(shouldPickComposerRow(\"Enter\", false, true), true);\n+ assert.strictEqual(shouldPickComposerRow(\"Tab\", false, true), true);\n+ assert.strictEqual(shouldPickComposerRow(\" Enter\", false, true), false);\n+ assert.strictEqual(shouldPickComposerRow(\"Enter\", true, true), false);\n+ assert.strictEqual(shouldPickComposerRow(\"Enter\", false, false), false);\n+ assert.strictEqual(shouldPickComposerRow(\"Tab\", false, false), false );\n+ assert.strictEqual(shouldPickComposerRow(\"ArrowDown\", false, true), false);\n+ assert.strictEqual(shouldPickComposerRow(\"ArrowUp\", false, true), false);\n+ assert.strictEqual(shouldPickComposerRow(\"Enter\", false, true), true);\n+});\n+\ndiff --git a/apps/native/components/primitives/PromptBar.tsx b/apps/native/components/primitives/PromptBar.tsx\nindex 2c8f3e2..9a7b1d4 100644\n--- a/apps/native/components/primitives/PromptBar.tsx\n+++ b/apps/native/components/primitives/P romptBar.tsx\n@@ -1,3 +1,4 @@\n+import { shouldPickComposerRow } from \"../../lib/composer-keyboard\";\n \n export function PromptBar() {\n const [engaged, setEngaged] = useState(false);\n@@ -85,7 +86,7 @@ export function Prompt Bar() {\n if (menu && rows.length > 0) {\n if (!event.shiftKey && (event.key === \"ArrowDown\" || event.key === \"ArrowUp\")) {\n event.preventDefault();\n- event.stopPropagation();\n+ event.stopPropagation();\n setEngaged(true);\n set Active((activeIndex + (event.key === \"ArrowDown\" ? 1 : rows.length - 1)) % rows.length);\n return;\n@@ -93,7 +94,7 @@ export function Prompt Bar() {\n if (!event.shiftKey && (event.key === \"Enter\" || event.key === \"Tab\")) {\n event.preventDefault();\n event.stopPropagation();\n- pick(rows[activeIndex]);\n+ pick(rows[activeIndex]);\n return;\n }\n }\ndiff --git a/apps/native/package.json b/apps/native/package.json\nindex 8f3e2c5..9a7 b1d4 100644\n--- a/apps/native/package.json\n+++ b/apps/native/package.json\n@@ -1,1 +1,1 @@\n- \"test\": \"node --experimental-strip-types --test lib/composer-model-pick.test.ts\"\n+ \"test\": \"node --experimental-strip-types --test lib/composer-keyboard.test.ts lib/composer-model-pick.test.ts\"\n``` <file_sep>apps/native/lib/composer-keyboard.ts</file>\n<file_sep>apps/native/lib/composer-keyboard.test.ts</file>\n<file_sep>apps/native/components/primitives/PromptBar.tsx</file>\n<file_sep>apps/native/package.json</file> <file_sep>apps/native/lib/composer-keyboard.ts</file>\n<file_sep>apps/native/lib/composer-keyboard.test.ts</file>\n<file_sep>apps/native/components/primitives/PromptBar.tsx</file>\n<file_sep>apps/native/package.json</file> <file_sep>apps/native/lib/com poser-keyboard.ts</file>\n<file_sep>apps/native/lib/composer-keyboard.test.ts</file>\n<file_sep>apps/native/components/primitives/PromptBar.tsx</file>\n<file_sep>apps/native/package.json</file> <file_sep>apps/native/lib/composer-keyboard.",
+ "usage": {
+ "input_tokens": 15713,
+ "cache_read_input_tokens": 1152,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 19450,
+ "reasoning_tokens": 18435,
+ "total_tokens": 36315
+ },
+ "num_turns": 1,
+ "total_cost_usd": 0.148702,
+ "total_cost_usd_ticks": 1487020000,
+ "modelUsage": {
+ "grok-4.7-build": {
+ "inputTokens": 15713,
+ "outputTokens": 19450,
+ "cacheReadInputTokens": 1152,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.148702
+ }
+ }
+ }
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.7-1096.meta.json b/evals/grok-46-vs-47/runs/grok-4.7-1096.meta.json
new file mode 100644
index 00000000..2a653f25
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.7-1096.meta.json
@@ -0,0 +1,27 @@
+{
+ "model_flag": "grok-4.7",
+ "pr": "1096",
+ "session_id": "bebeba28-95f9-4160-ae43-0552af1f3d8f",
+ "wall_s": 269.817,
+ "exit_code": 0,
+ "usage": {
+ "input_tokens": 15713,
+ "cache_read_input_tokens": 1152,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 19450,
+ "reasoning_tokens": 18435,
+ "total_tokens": 36315
+ },
+ "modelUsage": {
+ "grok-4.7-build": {
+ "inputTokens": 15713,
+ "outputTokens": 19450,
+ "cacheReadInputTokens": 1152,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.148702
+ }
+ },
+ "total_cost_usd": 0.148702,
+ "stopReason": "end_turn"
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.7-1149.json b/evals/grok-46-vs-47/runs/grok-4.7-1149.json
new file mode 100644
index 00000000..07d0844b
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.7-1149.json
@@ -0,0 +1,37 @@
+{
+ "model_flag": "grok-4.7",
+ "pr": "1149",
+ "session_id": "2e85912e-52f5-4a3f-a18d-ebc43d4dac31",
+ "wall_s": 333.837,
+ "started_at": "2026-09-21T17:24:37Z",
+ "exit_code": 0,
+ "stderr": "",
+ "response": {
+ "text": "diff --git a/apps/native/electron/webauthn-profile.test.cjs b/apps/native/electron/webauthn-profile.test.cjs\n--- a/apps/native/electron/webauthn-profile.test.cjs\n+++ b/apps/native/electron/webauthn-profile.test.cjs\n@@ -120,5 +120,12 @@\n test('accepts a profile until its expiration boundary', () => {\n const profile = fixture();\n profile.ExpirationDate = new Date(now + 1);\n assert.deepEqual(authorize(profile), { 'com.apple.application-identifier': appId });\n });\n+\n+test('rejects TEAM.* keychain groups when application-identifier is another bundle', () => {\n+ const profile = fixture();\n+ profile.Entitlements['keychain-access-groups'] = ['ABCDE12345.*'];\n+ profile.Entitlements['com.apple.application-identifier'] = 'ABCDE12345.org.example.other';\n+ assert.throws(() => authorize(profile), /application-identifier/);\n+});\ndiff --git a/apps/native/electron/webauthn-signing.test.cjs b/apps/native/electron/webauthn-signing.test.cjs\n--- a/apps/native/electron/webauthn-signing.test.cjs\n+++ b/apps/native/electron/webauthn-signing.test.cjs\n@@ -70,5 +70,11 @@\n test('invalid metadata fails before writing config or invoking signer', async () => {\n let called = false;\n await assert.rejects(signBundle({ app: 'Fixture.app', identity, teamId: '', readBundleId: () => bundleId, sign: () => { called = true; } }), /valid signing team/);\n assert.equal(called, false);\n });\n+\n+test('same-team profile for a different bundle fails before invoking the signer', async () => {\n+ let called = false;\n+ await assert.rejects(signBundle({ app: 'Fixture.app', identity, teamId: 'ABCDE12345', readBundleId: () => bundleId, readProvisioningProfile: () => profile('org.example.other'), sign: () => { called = true; } }), /application-identifier/);\n+ assert.equal(called, false);\n+});\n",
+ "stopReason": "end_turn",
+ "sessionId": "2e85912e-52f5-4a3f-a18d-ebc43d4dac31",
+ "requestId": "73576d4d-dd4b-481f-943a-8248621f4569",
+ "thought": "The user wants me to write a unified diff for adding tests to two files. They explicitly said \"Do not use tools. Reply with one unified diff and nothing else.\"\n```diff\ndiff --git a/apps/native/electron/webauthn-profile.test.cjs b/apps/native/electron/webauthn-profile.test.cjs\nindex 8f0e5c5..9b2c1d4 100644\n--- a/apps/native/electron/webauthn profile.test.cjs\n+++ b/apps/native/electron/webauthn-profile.test.cjs\n@@ -45,6 +45,15 @@ test('accepts a profile until its expiration boundary', () => {\n expect(profileEntitlements(profile)).toEqual(entitlements);\n });\n \n+test('rejects TEAM.* keychain groups when application-identifier is another bundle', () => {\n+ const profile = fixture();\n+ profile['keychain-access-groups'] = ['ABCDE12345.*'];\n+ profile['com.apple.application-identifier'] = 'ABCDE12345.org.example.other';\n+ expect(() => profile Entitlements(profile)).toThrow('Invalid profile entitlements');\n+});\n+\n+test('rejects TEAM.* keychain groups when application-identifier is another bundle', () => {\n+ const profile = fixture();\n+ profile['keychain-access-groups'] = ['ABCDE12345.*'];\n+ profile['com apple.application-identifier'] = 'ABCDE12345.org.example.other';\n+ expect(() => profileEntitlements(profile)).toThrow('Invalid profile entitlements');\n+});\n \n // ... existing reject tests ...\ndiff --git a/apps/native/electron/webauthn-signing.test.cjs b/apps/native/electron/we bauthn-signing.test.cjs\nindex 3a2b7c1..7d9e8f2 100644\n--- a/apps/native/electron/webauthn-signing.test.cjs\n+++ b/apps/native/electron/webauthn-signing.test.cjs\n@@ - 78,6 +78,15 @@ test('invalid metadata fails before writing config or invoking signer', async () =>\n assert.equal(called, false);\n });\n \n+test('rejects profile with TEAM.* keychain group for another bundle before signer runs', async () => {\n+ let called = false;\n+ await assert.rejects(signBundle({\n+ app: 'Fixture.app',\n+ identity,\n+ teamId: '',\n+ readProvisioningProfile: () => fixtureWithTeamWildcardOtherBundle(),\n+ readBundleId: () => bundleId,\n+ sign: () => { called = true; }\n+ }), /valid signing team/);\n+ assert.equal(called, false);\n+});\n \n // ... existing tests ...\n``` (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file. The exact error message and fixture helper may vary slightly from the actual implementation, but this follows the pattern shown in the accept/ reject cases.) (Note: I adjusted the test names and assertions to match the style of existing tests in the file.",
+ "usage": {
+ "input_tokens": 15922,
+ "cache_read_input_tokens": 1152,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 22958,
+ "reasoning_tokens": 22438,
+ "total_tokens": 40032
+ },
+ "num_turns": 1,
+ "total_cost_usd": 0.170168,
+ "total_cost_usd_ticks": 1701680000,
+ "modelUsage": {
+ "grok-4.7-build": {
+ "inputTokens": 15922,
+ "outputTokens": 22958,
+ "cacheReadInputTokens": 1152,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.170168
+ }
+ }
+ }
+}
diff --git a/evals/grok-46-vs-47/runs/grok-4.7-1149.meta.json b/evals/grok-46-vs-47/runs/grok-4.7-1149.meta.json
new file mode 100644
index 00000000..7b07d9b3
--- /dev/null
+++ b/evals/grok-46-vs-47/runs/grok-4.7-1149.meta.json
@@ -0,0 +1,27 @@
+{
+ "model_flag": "grok-4.7",
+ "pr": "1149",
+ "session_id": "2e85912e-52f5-4a3f-a18d-ebc43d4dac31",
+ "wall_s": 333.837,
+ "exit_code": 0,
+ "usage": {
+ "input_tokens": 15922,
+ "cache_read_input_tokens": 1152,
+ "cache_creation_input_tokens": 0,
+ "output_tokens": 22958,
+ "reasoning_tokens": 22438,
+ "total_tokens": 40032
+ },
+ "modelUsage": {
+ "grok-4.7-build": {
+ "inputTokens": 15922,
+ "outputTokens": 22958,
+ "cacheReadInputTokens": 1152,
+ "cacheCreationInputTokens": 0,
+ "modelCalls": 1,
+ "costUSD": 0.170168
+ }
+ },
+ "total_cost_usd": 0.170168,
+ "stopReason": "end_turn"
+}
diff --git a/evals/grok-46-vs-47/src-before/PromptBar.tsx b/evals/grok-46-vs-47/src-before/PromptBar.tsx
new file mode 100644
index 00000000..be7eaeb1
--- /dev/null
+++ b/evals/grok-46-vs-47/src-before/PromptBar.tsx
@@ -0,0 +1,573 @@
+"use client";
+
+import { parseComposerToken as parseToken, guiSkillRows } from "@/lib/gui-skills";
+import { Icon, GLYPHS, SOURCES, DEMO_COMMANDS, MODELS, FILES, DICTATION, AUTO_STEPS } from "./prompt-demo";
+import ModelPicker from "./ModelPicker";
+import layout from "./PromptBar.module.css";
+import ModelEffortButtons from "./ModelEffortButtons";
+import type { ModelChoice } from "@/lib/acp-client";
+import { resolveComposerModel } from "@/lib/composer-model";
+import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
+import ComposerMenu from "./ComposerMenu";
+import ComposerAttachments from "./ComposerAttachments";
+import { useComposerSweep } from "./useComposerSweep";
+import { useComposerSize } from "./useComposerSize";
+import { useComposerDraft } from "./useComposerDraft";
+import { useSteerArm } from "./useSteerArm";
+import type { AcpCommand } from "@/lib/acp";
+import {
+ filesFrom,
+ releaseAttachments,
+ discardAttachments,
+ uploadAttachment,
+ withAttachmentMarkers,
+} from "@/lib/attachments";
+import { entryAt, historyKeyIntent, stepHistory } from "@/lib/prompt-history";
+
+/* ─────────────────────────────────────────────────────────
+ * PROMPT BAR
+ * A composer with real controls: attach, @ data sources,
+ * / commands, a model picker, dictation, and send.
+ * Type @ or / to open the menus; ↑↓ + Enter to pick.
+ * Variants: Rounded (composer radius) · Pill (full radius). Send is circular.
+ * Radii: docs/design.md.
+ * ───────────────────────────────────────────────────────── */
+
+export type PromptModel = ModelChoice;
+
+export default function PromptBar({
+ variant = "Rounded",
+ demo = true,
+ tall = false,
+ placeholder,
+ onSend, onSetting, onSteerQueued,
+ models,
+ commands,
+ modelKey,
+ onModelChange,
+ disabled,
+ busy = false,
+ onStop,
+ history,
+ root,
+ contextMeter,
+ inject,
+}: {
+ variant?: string;
+ /** the self-running walkthrough; turn off when embedding in a real surface */
+ demo?: boolean;
+ /** hero sizing: a multi-line input with controls on their own row */
+ tall?: boolean;
+ placeholder?: string;
+ onSend?: (text: string) => void; onSetting?: (text: string) => Promise<void>;
+ /** Steer the next queued message without consuming the current draft. */
+ onSteerQueued?: () => void;
+ models?: PromptModel[];
+ /** The slash commands the agent advertised. Empty until it answers —
+ * an empty menu beats inventing commands this build may not service. */
+ commands?: AcpCommand[];
+ modelKey?: string;
+ onModelChange?: (key: string) => void;
+ disabled?: boolean;
+ /** A turn is running: the send arrow morphs into a stop square. */
+ busy?: boolean;
+ onStop?: () => void;
+ /** Earlier prompts, oldest first. ArrowUp on the first line of the draft
+ * walks back through them like a shell; ArrowDown walks forward again. */
+ history?: readonly string[];
+ /** The workspace this composer sends into. The @ picker searches it, and a
+ * picked file is mentioned by its path relative to it. */
+ root?: string;
+ contextMeter?: import("@/lib/context-meter").ContextMeter;
+ /** Load this text into the draft when `key` changes (edit-prompt). */
+ inject?: { key: number; text: string } | null;
+}) {
+ const pill = variant === "Pill";
+ const catalog = models && models.length > 0 ? models : MODELS;
+ const { draft, setDraft, attachments, setAttachments, uploads, setUploads, attachError, setAttachError } = useComposerDraft();
+ useEffect(() => {
+ if (!inject) return;
+ setDraft(inject.text);
+ setHistoryIndex(-1);
+ }, [inject?.key]);
+ /* Recall cursor: -1 is the live draft. Whatever was being typed is kept
+ * aside so ArrowDown past the newest entry hands it back untouched. */
+ const [historyIndex, setHistoryIndex] = useState(-1);
+ const stashRef = useRef("");
+ const caretToEndRef = useRef(false);
+ const [dismissed, setDismissed] = useState(false);
+ const [plusOpen, setPlusOpen] = useState(false);
+ const [modelOpen, setModelOpen] = useState(false);
+ const [model, setModel] = useState<PromptModel>(() => resolveComposerModel(catalog, modelKey));
+ /* Live surfaces load their catalog async (graff/models); once it lands, or
+ * the owner re-points modelKey, the picked entry must follow — the initial
+ * useState snapshot is stale by then. Unknown keys keep their own name. */
+ useEffect(() => {
+ const next = resolveComposerModel(catalog, modelKey);
+ setModel((cur) => (cur.key === next.key && cur.name === next.name ? cur : next));
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [modelKey, models]);
+ const [dragging, setDragging] = useState(false);
+ /* Workspace files matching the current @ query — live surfaces only. */
+ const [fileRows, setFileRows] = useState<{ key: string; name: string; desc: string }[]>([]);
+ const [connected, setConnected] = useState(false);
+ const [active, setActive] = useState(0);
+ const [listening, setListening] = useState(false);
+ const [auto, setAuto] = useState(demo);
+ const [autoStep, setAutoStep] = useState(0);
+ const [expanded, setExpanded] = useState(false);
+ const wide = expanded || tall;
+ const [engaged, setEngaged] = useState(false);
+ const controlsRef = useRef<HTMLDivElement>(null);
+ const inputRef = useRef<HTMLTextAreaElement>(null);
+ const fileInputRef = useRef<HTMLInputElement>(null);
+ const measureRef = useRef<HTMLSpanElement>(null);
+ const modelRef = useRef<HTMLButtonElement>(null);
+ const menuAnchor = useRef<HTMLDivElement>(null);
+ const menuPanel = useRef<HTMLDivElement>(null);
+ const menuId = useId();
+ const { sweepRef, celebrate } = useComposerSweep();
+
+ /* hand control to the user: stop the demo loop, and when they aim at
+ * the input itself, clear the demo's leftover draft for a clean start */
+ const takeOver = (event: { target: EventTarget | null }) => {
+ setAuto(false);
+ if (auto && event.target === inputRef.current) setDraft("");
+ };
+
+ /* ACP names commands bare; the menu shows and inserts the typed form. */
+ const slashRows = useMemo(() => {
+ const live = commands ?? (demo ? DEMO_COMMANDS : []);
+ return live.map((c) => ({ key: c.name, name: `/${c.name}`, desc: c.description }));
+ }, [commands, demo]);
+
+ const token = dismissed ? null : parseToken(draft);
+ const menu: "at" | "slash" | "skill" | null = plusOpen ? "at" : token?.kind ?? null;
+ const query = plusOpen ? "" : token?.query ?? "";
+
+ /* The @ picker searches the workspace. Debounced, and every in-flight
+ * search is abandoned when the query moves on, so a slow walk over a large
+ * tree can never land on top of results for what is now typed. */
+ useEffect(() => {
+ if (demo || menu !== "at") return;
+ if (!query) {
+ setFileRows([]);
+ return;
+ }
+ const abort = new AbortController();
+ const timer = setTimeout(() => {
+ const params = new URLSearchParams({ q: query });
+ if (root) params.set("root", root);
+ fetch(`/api/fs?${params}`, { signal: abort.signal })
+ .then((res) => res.json())
+ .then((json: { matches?: string[] }) => {
+ setFileRows(
+ (json.matches ?? []).map((rel) => ({
+ key: `file:${rel}`,
+ name: rel.slice(rel.lastIndexOf("/") + 1),
+ desc: rel,
+ })),
+ );
+ })
+ .catch(() => {
+ /* aborted, or the workspace went away — keep the rows we have */
+ });
+ }, 90);
+ return () => {
+ abort.abort();
+ clearTimeout(timer);
+ };
+ }, [demo, menu, query, root]);
+
+ /* The walkthrough glides through a fixed cast of sources. A live composer
+ * offers the real attach action and whatever the workspace search found —
+ * an invented data source is worse than an empty menu. */
+ const atRows = demo
+ ? SOURCES.filter((s) => s.name.toLowerCase().includes(query))
+ : [...guiSkillRows(query), SOURCES[0], ...fileRows];
+
+ const rows: { key: string; name: string; desc: string }[] =
+ menu === "skill" ? guiSkillRows(query) : menu === "at"
+ ? atRows
+ : menu === "slash"
+ ? slashRows.filter((c) => c.name.slice(1).startsWith(query))
+ : [];
+ const activeIndex = Math.min(active, Math.max(0, rows.length - 1));
+
+ useEffect(() => {
+ setActive(0);
+ setEngaged(false);
+ }, [menu, query]);
+
+ const selectModel = (next: PromptModel) => {
+ setModel(next);
+ setModelOpen(false);
+ if (next.key !== model.key) onModelChange?.(next.key);
+ if (next.key === "sprinkles-5") celebrate();
+ };
+
+ /* autoplay: apply the current step, then advance after its hold */
+ useEffect(() => {
+ if (!auto) return;
+ const step = AUTO_STEPS[autoStep % AUTO_STEPS.length];
+ setDraft(step.draft);
+ if (step.active !== undefined) setActive(step.active);
+ if (step.connect !== undefined) setConnected(step.connect);
+ if (step.modelOpen !== undefined) setModelOpen(step.modelOpen);
+ if (step.model) {
+ const next = MODELS.find((m) => m.key === step.model);
+ if (next) selectModel(next);
+ }
+ const t = setTimeout(() => setAutoStep((s) => s + 1), step.hold);
+ return () => clearTimeout(t);
+ }, [auto, autoStep]);
+
+ /* The simulated transcript is confined to the component demo. */
+ useEffect(() => {
+ if (!demo || !listening) return;
+ const t = setTimeout(() => {
+ setDraft((current) => (current ? `${current.trimEnd()} ${DICTATION}` : DICTATION));
+ setListening(false);
+ inputRef.current?.focus();
+ }, 2200);
+ return () => clearTimeout(t);
+ }, [demo, listening]);
+
+ useComposerSize({ inputRef, controlsRef, measureRef, modelRef, draft, expanded, setExpanded });
+
+ /* A recalled prompt lands with the caret at its end, ready to edit or send. */
+ useLayoutEffect(() => {
+ if (!caretToEndRef.current) return;
+ caretToEndRef.current = false;
+ inputRef.current?.setSelectionRange(draft.length, draft.length);
+ }, [draft]);
+
+ /* The menu is portaled: its own pointer events are still inside this
+ * composer. A different split's composer is outside. */
+ useEffect(() => {
+ if (!menu) return;
+ const close = (event: PointerEvent) => {
+ const target = event.target as Node;
+ if (menuAnchor.current?.contains(target) || menuPanel.current?.contains(target)) return;
+ setPlusOpen(false);
+ setDismissed(true);
+ };
+ document.addEventListener("pointerdown", close);
+ return () => document.removeEventListener("pointerdown", close);
+ }, [menu]);
+
+ const closeMenus = () => {
+ setPlusOpen(false);
+ setModelOpen(false);
+ };
+
+ const pick = (row: { key: string; name: string; desc: string }) => {
+ const before = token ? draft.slice(0, token.start) : draft;
+ if (row.key === "attach") {
+ if (demo) {
+ const name = FILES[attachments.length % FILES.length];
+ setAttachments((current) => [...current, { id: `${name}-${current.length}`, name, path: name }]);
+ } else {
+ fileInputRef.current?.click();
+ }
+ setDraft(before);
+ } else if (row.key.startsWith("gui-skill:")) {
+ setDraft(`${before}$${row.key.slice(10)} `);
+ } else if (row.key.startsWith("file:")) {
+ /* The harness reads `@[path]` out of the prompt text: an image becomes
+ * a native vision block, anything else stays a path it opens itself. */
+ setDraft(`${before}@[${row.desc}] `);
+ } else if (menu === "at") {
+ setDraft(`${before}@${row.name} `);
+ } else {
+ setDraft(`${before}${row.name} `);
+ }
+ setPlusOpen(false);
+ setDismissed(false);
+ inputRef.current?.focus();
+ };
+
+ const attachFiles = async (files: File[]) => {
+ if (demo || files.length === 0) return;
+ setAttachError(null); setUploads(count => count + files.length);
+ for (const file of files) {
+ try {
+ const attachment = await uploadAttachment(file);
+ setAttachments((current) => [...current, attachment]);
+ } catch (err) {
+ setAttachError(err instanceof Error ? err.message : String(err));
+ } finally { setUploads(count => count - 1); }
+ }
+ if (inputRef.current?.closest("[data-promptbar]")?.contains(document.activeElement)) inputRef.current.focus();
+ };
+
+ const removeAttachment = (id: string) => {
+ setAttachments((current) => {
+ discardAttachments(current.filter((a) => a.id === id));
+ return current.filter((a) => a.id !== id);
+ });
+ };
+
+ const canSend = !disabled && uploads === 0 && (draft.trim().length > 0 || attachments.length > 0);
+ const showStop = busy;
+ const steerArm = useSteerArm(busy && !disabled, onSteerQueued);
+ const send = () => {
+ if (!canSend) return;
+ if (/^\/(effort|reasoning)$/.test(draft.trim()) && model.effortLevels?.length) { modelRef.current?.dispatchEvent(new Event("graff-effort-open")); setDraft(""); return; }
+ onSend?.(withAttachmentMarkers(draft.trim(), attachments));
+ releaseAttachments(attachments);
+ setDraft("");
+ setAttachments([]);
+ setAttachError(null);
+ setHistoryIndex(-1);
+ stashRef.current = "";
+ closeMenus();
+ };
+
+ /* Shell-style recall. Only from the draft's first line (up) or last line
+ * (down) — in the middle of a multi-line draft the arrows keep moving the
+ * caret — and never while the @ / model menus own the arrow keys. */
+ const recall = (event: React.KeyboardEvent<HTMLTextAreaElement>): boolean => {
+ if (menu || modelOpen || !history || history.length === 0) return false;
+ const caret = event.currentTarget.selectionStart ?? draft.length;
+ const intent = historyKeyIntent(draft, caret, event.key);
+ if (!intent || (intent === "down" && historyIndex < 0)) return false;
+ event.preventDefault();
+ const next = stepHistory(history.length, historyIndex, intent);
+ if (next === historyIndex) return true;
+ if (historyIndex < 0) stashRef.current = draft;
+ setHistoryIndex(next);
+ setDraft(next < 0 ? stashRef.current : (entryAt(history, next) ?? ""));
+ caretToEndRef.current = true;
+ return true;
+ };
+
+ return (
+ <div
+ data-promptbar
+ className={`${layout.composer} ${demo ? "flex min-h-[384px] w-full max-w-105 flex-col justify-end pb-8" : "w-full"}`}
+ onPointerDownCapture={takeOver}
+ onKeyDownCapture={takeOver}
+ >
+ {/* composer is the anchor — menus grow up from its top edge */}
+ <div ref={menuAnchor} className="relative">
+ {/* ── @ / slash menu ─────────────────────────────── */}
+ {menu && <ComposerMenu anchor={menuAnchor} panel={menuPanel} id={menuId} menu={menu} rows={rows} query={query}
+ active={activeIndex} engaged={engaged} setActive={setActive} setEngaged={setEngaged}
+ connected={connected} setConnected={setConnected} demo={demo} onPick={pick} />}
+
+
+ {modelOpen && <ModelPicker models={catalog} selected={model} anchor={modelRef} onClose={() => setModelOpen(false)}
+ onSelect={next => { selectModel(next); inputRef.current?.focus({ preventScroll: true }); }} />}
+
+ {(steerArm.left > 0 || steerArm.steering) && (
+ <p role="status" className="mb-1.5 px-1 text-[12px] font-medium text-ink-2">
+ {steerArm.steering ? "Steering…" : `Enter again in ${steerArm.left} to steer`}
+ </p>
+ )}
+ {/* ── composer ───────────────────────────────────── */}
+ <div
+ onDragOver={(event) => {
+ /* Claim the drop only for files. Without preventDefault here the
+ * browser navigates away to the dropped file instead. */
+ if (demo || !event.dataTransfer.types.includes("Files")) return;
+ event.preventDefault();
+ setDragging(true);
+ }}
+ onDragLeave={(event) => {
+ if (event.currentTarget.contains(event.relatedTarget as Node | null)) return;
+ setDragging(false);
+ }}
+ onDrop={(event) => {
+ const files = filesFrom(event.dataTransfer);
+ if (demo || files.length === 0) return;
+ event.preventDefault();
+ setDragging(false);
+ void attachFiles(files);
+ }}
+ className={`relative isolate flex flex-col overflow-hidden border ${layout.glass} transition-[border-color,border-radius] duration-150 focus-within:border-line-strong ${
+ dragging ? "border-accent-ink" : "border-line"
+ } ${
+ tall ? "gap-2.5 p-3.5" : "gap-1.5 p-1.5"
+ } ${
+ pill ? (attachments.length > 0 || wide ? "rounded-composer" : "rounded-full") : "rounded-composer"
+ }`}
+ >
+ <input
+ ref={fileInputRef}
+ type="file"
+ multiple
+ hidden
+ onChange={(event) => {
+ void attachFiles(Array.from(event.target.files ?? []));
+ // Same file twice in a row is a real thing to want; without this
+ // the second pick fires no change event at all.
+ event.target.value = "";
+ }}
+ />
+ {/* A brief accent sweep, released as soon as the model feedback ends. */}
+ <span
+ ref={sweepRef}
+ aria-hidden="true"
+ data-composer-sweep
+ className="pointer-events-none absolute inset-0 -z-10 opacity-0"
+ style={{ background: "linear-gradient(110deg, transparent 15%, color-mix(in srgb, var(--accent) 18%, transparent) 48%, transparent 80%)" }}
+ />
+ <span
+ ref={measureRef}
+ aria-hidden="true"
+ className="pointer-events-none absolute invisible whitespace-pre text-[13px] leading-[18px]"
+ >
+ {draft}
+ </span>
+
+ <ComposerAttachments attachments={attachments} pill={pill} onRemove={removeAttachment} />
+
+ {uploads > 0 && <p role="status" className="px-2 text-xs text-ink-3">Adding {uploads} {uploads === 1 ? "file" : "files"}…</p>}
+ {attachError && (
+ <div className={`text-[11.5px] text-red ${pill ? "px-2" : "px-1"}`} role="status">
+ {attachError}
+ </div>
+ )}
+
+ <div
+ ref={controlsRef}
+ className={`${layout.controls} grid items-end gap-x-1 gap-y-1.5 ${
+ wide
+ ? "grid-cols-[28px_minmax(0,1fr)_0px_28px_28px]"
+ : "grid-cols-[28px_minmax(0,1fr)_auto_28px_28px]"
+ }`}
+ >
+ <button
+ type="button"
+ aria-label="Add attachments and sources"
+ aria-expanded={plusOpen}
+ onClick={() => {
+ setModelOpen(false);
+ setPlusOpen((current) => !current);
+ inputRef.current?.focus();
+ }}
+ className={`flex size-7 shrink-0 items-center justify-center justify-self-start rounded-full text-ink-3 transition-[background-color,color,transform] duration-150 hover:bg-hover hover:text-ink active:scale-[0.94] ${plusOpen ? "bg-hover text-ink" : ""} ${wide ? "col-start-1 row-start-2" : "col-start-1 row-start-1"}`}
+ >
+ <Icon size={16} strokeWidth={2}><path d="M12 5v14M5 12h14" /></Icon>
+ </button>
+
+ <textarea
+ ref={inputRef}
+ rows={1}
+ value={draft}
+ onChange={(event) => {
+ setDraft(event.target.value);
+ setDismissed(false);
+ setPlusOpen(false);
+ }}
+ onPaste={(event) => {
+ /* Claim the paste only when it carries files. A text paste has
+ * to fall through untouched — that is Cmd-V doing its job. */
+ const files = filesFrom(event.clipboardData);
+ if (demo || files.length === 0) return;
+ event.preventDefault();
+ void attachFiles(files);
+ }}
+ onKeyDown={(event) => {
+ // IME candidate keys always belong to the input method.
+ if (event.nativeEvent.isComposing || event.keyCode === 229) return;
+ if (event.key === "Enter" && (event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey && busy && !disabled && onSteerQueued) {
+ event.preventDefault();
+ event.stopPropagation();
+ if (!event.repeat) steerArm.fire();
+ return;
+ }
+ // Other modified keys belong to desktop shortcuts.
+ if (event.metaKey || event.ctrlKey || event.altKey) return;
+ if (menu && rows.length > 0) {
+ if (!event.shiftKey && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
+ event.preventDefault();
+ event.stopPropagation();
+ setEngaged(true);
+ setActive((activeIndex + (event.key === "ArrowDown" ? 1 : rows.length - 1)) % rows.length);
+ return;
+ }
+ if (!event.shiftKey && (event.key === "Enter" || event.key === "Tab")) {
+ event.preventDefault();
+ event.stopPropagation();
+ pick(rows[activeIndex]);
+ return;
+ }
+ }
+ if (!event.shiftKey && recall(event)) return;
+ if (event.key === "Escape") {
+ setDismissed(true);
+ closeMenus();
+ return;
+ }
+ if (event.key === "Enter" && !event.shiftKey) {
+ event.preventDefault();
+ event.stopPropagation();
+ if (!canSend && steerArm.consumeEnter()) return;
+ send();
+ }
+ }}
+ placeholder={listening ? "Listening…" : placeholder ?? "Write a message…"}
+ aria-label="Prompt"
+ aria-autocomplete="list" aria-controls={menu ? menuId : undefined}
+ aria-activedescendant={menu && rows.length ? `${menuId}-${activeIndex}` : undefined}
+ className={`${tall ? "min-h-[68px] px-2 py-2 text-[14px] leading-5" : "min-h-7 px-1 py-[5px] text-[13px] leading-[18px]"} min-w-0 w-full resize-none bg-transparent text-ink outline-none [overflow-wrap:anywhere] placeholder:text-ink-3 ${
+ wide ? "col-span-full col-start-1 row-start-1" : "col-start-2 row-start-1"
+ }`}
+ />
+
+ <ModelEffortButtons model={model} buttonRef={modelRef} modelOpen={modelOpen} wide={wide} pill={pill} busy={busy}
+ contextMeter={contextMeter} showContextMeter={!demo}
+ onCommand={onSetting} openModel={() => { setPlusOpen(false); setModelOpen(current => !current); }} />
+
+ {/* Keep cancellation available while a follow-up is being drafted. */}
+ <button
+ type="button"
+ aria-label={busy ? "Queue follow-up" : listening ? "Stop dictation" : "Start dictation"}
+ aria-pressed={busy ? undefined : listening} disabled={busy ? !canSend : !demo}
+ title={busy ? "Queue this follow-up" : demo ? "Demo dictation" : "Dictation is not available yet"}
+ onClick={busy ? send : () => setListening((current) => !current)}
+ className={`flex size-7 shrink-0 items-center justify-center rounded-full disabled:opacity-30 disabled:cursor-not-allowed transition-[background-color,color,transform] duration-150 active:scale-[0.94] ${listening ? "bg-accent-tint text-accent-ink" : "text-ink-3 hover:bg-hover hover:text-ink"} ${wide ? "col-start-4 row-start-2" : "col-start-4 row-start-1"}`}
+ >
+ {busy ? <Icon size={16} strokeWidth={2.4}><path d="M12 19V5M5 12l7-7 7 7" /></Icon> : listening ? (
+ <span className="flex h-3.5 items-center gap-[2.5px]">
+ {[0, 1, 2].map((i) => (
+ <span
+ key={i}
+ className="w-[2.5px] rounded-full bg-current"
+ style={{ height: "100%", animation: `eq-bounce 900ms steps(6, end) ${i * 150}ms infinite` }}
+ />
+ ))}
+ </span>
+ ) : (
+ <Icon size={15} strokeWidth={2}><g><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z" /><path d="M19 10v2a7 7 0 0 1-14 0v-2M12 19v3" /></g></Icon>
+ )}
+ </button>
+
+ {/* send — circular; while a turn runs it morphs into stop */}
+ <button
+ type="button"
+ aria-label={showStop ? "Stop" : "Send"}
+ disabled={showStop ? !onStop : !canSend}
+ onClick={showStop ? onStop : send}
+ className={`flex size-7 shrink-0 items-center justify-center rounded-full disabled:opacity-30 disabled:cursor-not-allowed transition-[background-color,color,transform] duration-200 enabled:active:scale-[0.94] ${wide ? "col-start-5 row-start-2" : "col-start-5 row-start-1"}`}
+ style={{
+ background: showStop || canSend ? "var(--ink)" : "var(--line-strong)",
+ color: showStop || canSend ? "var(--surface)" : "var(--ink-2)",
+ }}
+ >
+ {showStop ? (
+ <svg width="11" height="11" viewBox="0 0 24 24" fill="currentColor" aria-hidden>
+ <rect x="5" y="5" width="14" height="14" rx="2.5" />
+ </svg>
+ ) : (
+ <Icon size={16} strokeWidth={2.4}><path d="M12 19V5M5 12l7-7 7 7" /></Icon>
+ )}
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/evals/grok-46-vs-47/src-before/presence_accord.zig b/evals/grok-46-vs-47/src-before/presence_accord.zig
new file mode 100644
index 00000000..13fdec4f
--- /dev/null
+++ b/evals/grok-46-vs-47/src-before/presence_accord.zig
@@ -0,0 +1,492 @@
+//! Accord Unix 0600 live path behind presence_chan.postMessage.
+//! JSONL stays the durable room (ADR 0134). On by default except Windows;
+//! GRAFF_ACCORD=0 opts out. Lost live frames are never errors — the log remains.
+
+const std = @import("std");
+const builtin = @import("builtin");
+const Io = std.Io;
+const net = std.Io.net;
+const accord = @import("accord");
+
+pub const env_var = "GRAFF_ACCORD";
+pub const sock_env = "GRAFF_ACCORD_SOCK";
+
+/// Tests flip this instead of mutating process env.
+pub var test_enabled: bool = false;
+pub var test_sock: ?[]const u8 = null;
+
+pub fn enabled() bool {
+ if (builtin.os.tag == .windows) return false;
+ if (builtin.is_test) return test_enabled;
+ const v = std.c.getenv(env_var) orelse return true;
+ const s = std.mem.span(v);
+ if (s.len == 0) return true;
+ return !std.mem.eql(u8, s, "0") and !std.mem.eql(u8, s, "off") and !std.mem.eql(u8, s, "false");
+}
+
+var g_ping = std.atomic.Value(bool).init(false);
+var g_io: ?Io = null;
+var g_gpa: ?std.mem.Allocator = null;
+var g_dir_path: ?[]u8 = null;
+var g_own_name: ?[]u8 = null;
+var g_listener: ?net.Server = null;
+var g_future: ?Io.Future(void) = null;
+var g_mu: Io.Mutex = .init;
+var g_outs: std.ArrayList(OutLink) = .empty;
+var g_ins: std.ArrayList(*accord.Session) = .empty;
+var g_connects: std.atomic.Value(u32) = .init(0);
+
+const OutLink = struct {
+ path: []u8,
+ sess: *accord.Session,
+};
+
+pub fn takePing() bool {
+ return g_ping.swap(false, .acq_rel);
+}
+
+pub const Stats = struct {
+ on: bool,
+ inbound: usize = 0,
+ outbound: usize = 0,
+ connects: u32 = 0,
+ session_bytes: usize = 0,
+ proc_rss_bytes: usize = 0,
+};
+
+/// Accord-held Sessions plus process RSS (for /debug). Session bytes are the
+/// standing duplex cost; proc RSS is the whole process, just in case.
+pub fn stats() Stats {
+ if (!enabled()) return .{ .on = false, .proc_rss_bytes = processRssBytes() };
+ var inbound: usize = 0;
+ var outbound: usize = 0;
+ if (g_io) |io| {
+ g_mu.lockUncancelable(io);
+ inbound = g_ins.items.len;
+ outbound = g_outs.items.len;
+ g_mu.unlock(io);
+ }
+ const n = inbound + outbound;
+ return .{
+ .on = true,
+ .inbound = inbound,
+ .outbound = outbound,
+ .connects = g_connects.load(.monotonic),
+ .session_bytes = n * @sizeOf(accord.Session),
+ .proc_rss_bytes = processRssBytes(),
+ };
+}
+
+pub fn renderLine(w: *Io.Writer) !void {
+ const s = stats();
+ if (!s.on) {
+ try w.writeAll(" accord off\n");
+ return;
+ }
+ try w.print(
+ " accord {d} in · {d} out · {d} connects · ~{d} KB sessions · rss {d} KB\n",
+ .{
+ s.inbound,
+ s.outbound,
+ s.connects,
+ s.session_bytes / 1024,
+ s.proc_rss_bytes / 1024,
+ },
+ );
+}
+
+fn processRssBytes() usize {
+ if (builtin.os.tag == .windows) return 0;
+ var ru: std.c.rusage = std.mem.zeroes(std.c.rusage);
+ if (std.c.getrusage(std.c.rusage.SELF, &ru) != 0) return 0;
+ const rss: usize = @intCast(@max(ru.maxrss, 0));
+ return if (builtin.os.tag == .linux) rss * 1024 else rss;
+}
+
+fn sockPath(buf: []u8, chan_name: []const u8) ?[]const u8 {
+ _ = chan_name;
+ if (builtin.is_test) return test_sock;
+ if (std.c.getenv(sock_env)) |p| {
+ const s = std.mem.span(p);
+ if (s.len > 0) {
+ const n = @min(s.len, buf.len);
+ @memcpy(buf[0..n], s[0..n]);
+ return buf[0..n];
+ }
+ }
+ return null;
+}
+
+/// Best-effort live send of the same JSONL line already appended to the room.
+/// Never fails the durable write. Fans out to every peer sock in the live dir.
+pub fn livePost(io: Io, gpa: std.mem.Allocator, chan_name: []const u8, json_line: []const u8) void {
+ if (!enabled()) return;
+ if (builtin.os.tag == .windows) return;
+ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
+ if (sockPath(&path_buf, chan_name)) |path| {
+ sendLine(io, gpa, path, json_line) catch {};
+ return;
+ }
+ const dir_path = g_dir_path orelse return;
+ var dir = Io.Dir.cwd().openDir(io, dir_path, .{ .iterate = true }) catch return;
+ defer dir.close(io);
+ var it = dir.iterate();
+ while (it.next(io) catch null) |entry| {
+ if (!std.mem.endsWith(u8, entry.name, ".accord.sock")) continue;
+ if (g_own_name) |own| if (std.mem.eql(u8, entry.name, own)) continue;
+ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir_path, entry.name }) catch continue;
+ sendLine(io, gpa, path, json_line) catch {};
+ }
+}
+
+/// Bind `{live_dir}/{pid}-{start}.accord.sock` and accept live posts.
+pub fn listen(io: Io, gpa: std.mem.Allocator, dir_path: ?[]const u8) void {
+ if (!enabled()) return;
+ if (builtin.os.tag == .windows) return;
+ if (g_listener != null) return;
+ const dir = dir_path orelse return;
+ const self = @import("proc_identity.zig").selfRecord(io);
+ var name_buf: [64]u8 = undefined;
+ const name = std.fmt.bufPrint(&name_buf, "{d}-{x}.accord.sock", .{ self.pid, self.start_id }) catch return;
+ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
+ const path = std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir, name }) catch return;
+ const owned_dir = gpa.dupe(u8, dir) catch return;
+ const owned_name = gpa.dupe(u8, name) catch {
+ gpa.free(owned_dir);
+ return;
+ };
+ const listener = accord.listenUnix(io, path) catch {
+ gpa.free(owned_dir);
+ gpa.free(owned_name);
+ return;
+ };
+ g_dir_path = owned_dir;
+ g_own_name = owned_name;
+ g_listener = listener;
+ g_io = io;
+ g_gpa = gpa;
+ g_future = io.concurrent(acceptLoop, .{}) catch {
+ stop(io);
+ return;
+ };
+}
+
+pub fn stop(io: Io) void {
+ if (g_future) |*f| {
+ f.cancel(io);
+ g_future = null;
+ }
+ if (g_listener) |*l| {
+ l.deinit(io);
+ g_listener = null;
+ }
+ if (g_gpa) |gpa| {
+ g_mu.lockUncancelable(io);
+ for (g_outs.items) |link| {
+ link.sess.shutdown();
+ gpa.destroy(link.sess);
+ gpa.free(link.path);
+ }
+ g_outs.clearRetainingCapacity();
+ for (g_ins.items) |sess| sess.shutdown();
+ g_ins.clearRetainingCapacity();
+ g_mu.unlock(io);
+ g_outs.deinit(gpa);
+ g_ins.deinit(gpa);
+ g_outs = .empty;
+ g_ins = .empty;
+ }
+ if (g_dir_path) |dir| if (g_own_name) |name| {
+ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
+ if (std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir, name })) |path| {
+ Io.Dir.cwd().deleteFile(io, path) catch {};
+ } else |_| {}
+ if (g_gpa) |gpa| gpa.free(name);
+ g_own_name = null;
+ };
+ if (g_dir_path) |dir| if (g_gpa) |gpa| gpa.free(dir);
+ g_dir_path = null;
+ g_gpa = null;
+ g_io = null;
+ g_ping.store(false, .release);
+ g_connects.store(0, .release);
+}
+
+fn acceptLoop() void {
+ const io = g_io orelse return;
+ const gpa = g_gpa orelse return;
+ const listener = &(g_listener orelse return);
+ while (true) {
+ const stream = listener.accept(io) catch break;
+ const sess = gpa.create(accord.Session) catch {
+ stream.close(io);
+ continue;
+ };
+ sess.* = .{ .io = io, .gpa = gpa, .role = .server, .stream = stream };
+ _ = io.concurrent(holdInbound, .{sess}) catch {
+ sess.shutdown();
+ gpa.destroy(sess);
+ continue;
+ };
+ }
+}
+
+fn holdInbound(sess: *accord.Session) void {
+ const io = sess.io;
+ const gpa = sess.gpa;
+ sess.start() catch {
+ sess.shutdown();
+ gpa.destroy(sess);
+ return;
+ };
+ g_mu.lockUncancelable(io);
+ g_ins.append(gpa, sess) catch {
+ g_mu.unlock(io);
+ sess.shutdown();
+ gpa.destroy(sess);
+ return;
+ };
+ g_mu.unlock(io);
+ while (true) {
+ const got = sess.recv(1) catch break;
+ defer got.deinit(gpa);
+ switch (got.kind) {
+ .msg, .progress, .stop => g_ping.store(true, .release),
+ else => {},
+ }
+ }
+ dropInbound(sess);
+}
+
+fn dropInbound(sess: *accord.Session) void {
+ const io = sess.io;
+ const gpa = sess.gpa;
+ g_mu.lockUncancelable(io);
+ for (g_ins.items, 0..) |item, i| {
+ if (item == sess) {
+ _ = g_ins.orderedRemove(i);
+ break;
+ }
+ }
+ g_mu.unlock(io);
+ sess.shutdown();
+ gpa.destroy(sess);
+}
+
+fn sendLine(io: Io, gpa: std.mem.Allocator, path: []const u8, json_line: []const u8) !void {
+ const sess = ensureOut(io, gpa, path) orelse return;
+ sess.send(1, .msg, .none, json_line) catch {
+ dropOut(io, gpa, path);
+ const retry = ensureOut(io, gpa, path) orelse return;
+ retry.send(1, .msg, .none, json_line) catch {};
+ };
+}
+
+fn ensureOut(io: Io, gpa: std.mem.Allocator, path: []const u8) ?*accord.Session {
+ g_mu.lockUncancelable(io);
+ for (g_outs.items) |link| {
+ if (std.mem.eql(u8, link.path, path)) {
+ g_mu.unlock(io);
+ return link.sess;
+ }
+ }
+ g_mu.unlock(io);
+ const addr = net.UnixAddress.init(path) catch return null;
+ const stream = addr.connect(io) catch return null;
+ const sess = gpa.create(accord.Session) catch {
+ stream.close(io);
+ return null;
+ };
+ sess.* = .{ .io = io, .gpa = gpa, .role = .client, .stream = stream };
+ sess.start() catch {
+ sess.shutdown();
+ gpa.destroy(sess);
+ return null;
+ };
+ const owned = gpa.dupe(u8, path) catch {
+ sess.shutdown();
+ gpa.destroy(sess);
+ return null;
+ };
+ g_mu.lockUncancelable(io);
+ defer g_mu.unlock(io);
+ for (g_outs.items) |link| {
+ if (std.mem.eql(u8, link.path, path)) {
+ sess.shutdown();
+ gpa.destroy(sess);
+ gpa.free(owned);
+ return link.sess;
+ }
+ }
+ g_outs.append(gpa, .{ .path = owned, .sess = sess }) catch {
+ gpa.free(owned);
+ sess.shutdown();
+ gpa.destroy(sess);
+ return null;
+ };
+ _ = g_connects.fetchAdd(1, .monotonic);
+ return sess;
+}
+
+fn dropOut(io: Io, gpa: std.mem.Allocator, path: []const u8) void {
+ g_mu.lockUncancelable(io);
+ defer g_mu.unlock(io);
+ for (g_outs.items, 0..) |link, i| {
+ if (!std.mem.eql(u8, link.path, path)) continue;
+ link.sess.shutdown();
+ gpa.destroy(link.sess);
+ gpa.free(link.path);
+ _ = g_outs.orderedRemove(i);
+ return;
+ }
+}
+
+fn connectPath(io: Io, path: []const u8) !net.Stream {
+ const addr = try net.UnixAddress.init(path);
+ return addr.connect(io);
+}
+
+fn startSess(s: *accord.Session) !void {
+ try s.start();
+}
+
+const Pair = struct {
+ io: Io,
+ gpa: std.mem.Allocator,
+ listener: net.Server,
+ server: *accord.Session,
+ client: *accord.Session,
+ path: []const u8,
+
+ fn init(p: *Pair, io: Io, gpa: std.mem.Allocator, path: []const u8) !void {
+ Io.Dir.cwd().deleteFile(io, path) catch |err| switch (err) {
+ error.FileNotFound => {},
+ else => return err,
+ };
+ var listener = try accord.listenUnix(io, path);
+ errdefer listener.deinit(io);
+ var cfut = try Io.concurrent(io, connectPath, .{ io, path });
+ const server_sock = try listener.accept(io);
+ const client_sock = try cfut.await(io);
+ const server = try gpa.create(accord.Session);
+ errdefer gpa.destroy(server);
+ const client = try gpa.create(accord.Session);
+ errdefer gpa.destroy(client);
+ server.* = .{ .io = io, .gpa = gpa, .role = .server, .stream = server_sock };
+ client.* = .{ .io = io, .gpa = gpa, .role = .client, .stream = client_sock };
+ p.* = .{
+ .io = io,
+ .gpa = gpa,
+ .listener = listener,
+ .server = server,
+ .client = client,
+ .path = path,
+ };
+ var cstart = try Io.concurrent(io, startSess, .{p.client});
+ try p.server.start();
+ try cstart.await(io);
+ }
+
+ fn deinit(p: *Pair) void {
+ p.client.shutdown();
+ p.server.shutdown();
+ p.gpa.destroy(p.client);
+ p.gpa.destroy(p.server);
+ p.listener.deinit(p.io);
+ Io.Dir.cwd().deleteFile(p.io, p.path) catch {};
+ }
+};
+
+test "Accord live path is off in tests unless enabled" {
+ try std.testing.expect(!test_enabled);
+ try std.testing.expect(!enabled());
+ const s = stats();
+ try std.testing.expect(!s.on);
+}
+
+test "Accord stats report session RSS when enabled" {
+ if (builtin.os.tag == .windows) return; // enabled() is hard-false there
+ test_enabled = true;
+ defer test_enabled = false;
+ const s = stats();
+ try std.testing.expect(s.on);
+ try std.testing.expectEqual(@as(usize, 0), s.inbound);
+ try std.testing.expectEqual(@as(usize, 0), s.outbound);
+}
+
+test "listen binds a 0600 sock and stop unlinks it" {
+ if (builtin.os.tag == .windows) return;
+ const io = std.testing.io;
+ const gpa = std.testing.allocator;
+ test_enabled = true;
+ defer {
+ stop(io);
+ test_enabled = false;
+ }
+ const dir = "graff-accord-listen";
+ try Io.Dir.cwd().createDirPath(io, dir);
+ defer Io.Dir.cwd().deleteTree(io, dir) catch {};
+ listen(io, gpa, dir);
+ const name = g_own_name orelse return error.NoSock;
+ var path_buf: [std.fs.max_path_bytes]u8 = undefined;
+ const path = try std.fmt.bufPrint(&path_buf, "{s}/{s}", .{ dir, name });
+ const st = try Io.Dir.cwd().statFile(io, path, .{});
+ try std.testing.expectEqual(@as(std.posix.mode_t, 0o600), st.permissions.toMode() & 0o777);
+ stop(io);
+ try std.testing.expectError(error.FileNotFound, Io.Dir.cwd().statFile(io, path, .{}));
+}
+
+test "listenUnix socket is 0600" {
+ if (builtin.os.tag != .macos) return;
+ const io = std.testing.io;
+ const path = "graff-accord-mode.sock";
+ Io.Dir.cwd().deleteFile(io, path) catch {};
+ var listener = try accord.listenUnix(io, path);
+ defer {
+ listener.deinit(io);
+ Io.Dir.cwd().deleteFile(io, path) catch {};
+ }
+ const st = try Io.Dir.cwd().statFile(io, path, .{});
+ try std.testing.expectEqual(@as(std.posix.mode_t, 0o600), st.permissions.toMode() & 0o777);
+}
+
+test "Unix 0600 round-trips the JSONL line" {
+ if (builtin.os.tag == .windows) return;
+ const io = std.testing.io;
+ const gpa = std.testing.allocator;
+ const path = "graff-accord-roundtrip.sock";
+ var pair: Pair = undefined;
+ try pair.init(io, gpa, path);
+ defer pair.deinit();
+ const line = "{\"from_pid\":1,\"text\":\"hold gui/src\"}\n";
+ try pair.client.send(1, .msg, .none, line);
+ const got = try pair.server.recv(1);
+ defer got.deinit(gpa);
+ try std.testing.expectEqualStrings(line, got.payload);
+}
+
+test "standing link carries msg, progress, and a reply on one session" {
+ if (builtin.os.tag == .windows) return;
+ const io = std.testing.io;
+ const gpa = std.testing.allocator;
+ const path = "graff-accord-standing.sock";
+ var pair: Pair = undefined;
+ try pair.init(io, gpa, path);
+ defer pair.deinit();
+ try pair.client.send(1, .msg, .none, "hold gui/src");
+ const first = try pair.server.recv(1);
+ defer first.deinit(gpa);
+ try std.testing.expectEqual(accord.Kind.msg, first.kind);
+ try pair.client.send(1, .progress, .none, "working");
+ const mid = try pair.server.recv(1);
+ defer mid.deinit(gpa);
+ try std.testing.expectEqual(accord.Kind.progress, mid.kind);
+ try pair.server.send(1, .msg, .none, "acked");
+ const back = try pair.client.recv(1);
+ defer back.deinit(gpa);
+ try std.testing.expectEqualStrings("acked", back.payload);
+ try pair.client.send(1, .stop, .none, &.{});
+ const halt = try pair.server.recv(1);
+ defer halt.deinit(gpa);
+ try std.testing.expectEqual(accord.Kind.stop, halt.kind);
+}
diff --git a/evals/grok-46-vs-47/src-before/proc_identity.zig b/evals/grok-46-vs-47/src-before/proc_identity.zig
new file mode 100644
index 00000000..aca24d5b
--- /dev/null
+++ b/evals/grok-46-vs-47/src-before/proc_identity.zig
@@ -0,0 +1,466 @@
+//! Process START identity: the half of a lock owner record that a recycled pid
+//! cannot forge (#413).
+//!
+//! A bare pid is not an owner. Pids are a small recycled namespace, so after a
+//! crash the OS hands the dead holder's number to something unrelated, and a
+//! lock keyed on the pid alone then reads as "still held" forever — or, if the
+//! lock is time-based instead, gets stolen from a holder that is very much
+//! alive. Recording the process's START time alongside the pid removes both:
+//! the pair is unique for as long as the machine is up, so liveness becomes
+//! "the pid is alive AND it is still the same process", and a provable
+//! mismatch is what makes a stale lock reclaimable.
+//!
+//! Where the number comes from, one source per platform:
+//!
+//! * Linux `/proc/<pid>/stat` field 22 (`starttime`, clock ticks since
+//! boot). Field 2 is `(comm)` and comm may contain BOTH spaces and
+//! ')' — `(my )weird( proc)` is a legal name — so the fields are
+//! counted from the LAST ')' in the line, never by splitting it.
+//! * macOS `proc_pidinfo(PROC_PIDTBSDINFO)` -> `pbi_start_tvsec/tvusec`,
+//! the same instant `ps -o lstart= -p <pid>` prints. libproc is a
+//! plain libSystem call, so it beats the `ps` subprocess: no fork
+//! in a lock path, no locale-dependent date parsing, and
+//! microsecond instead of one-second resolution (two graffs
+//! started in the same second must not share an identity).
+//! * Windows `GetProcessTimes` -> `ftCreationTime` (100 ns ticks).
+//! * anything else: no identity is available, so `probe` answers with
+//! pid-only liveness and `selfStartId` returns 0. Records stamped there
+//! carry `start_id = 0` and are read under the legacy rule below, which is
+//! exactly the pre-#413 behaviour. Nothing degrades further than that.
+//!
+//! Two rules make the upgrade safe, and both live in `ownerState`:
+//!
+//! * A record with `start_id == 0` — written by a graff older than #413, or
+//! on a platform with no identity source — keeps the old pid-only
+//! contract. An in-flight lock from an older binary is never bricked, and
+//! never stolen just because the new binary cannot verify it.
+//! * A probe that FAILS (permissions, no /proc, an unexpected errno) is
+//! `.unknown`, and unknown means held. Wrongly reclaiming a live lock
+//! corrupts; wrongly honouring a dead one only waits.
+//!
+//! `claimOwnerFile`/`releaseOwnerFile` package the whole protocol for locks
+//! that cannot lean on `flock` — session_lock.zig's degraded path today, the
+//! credential store and any daemon lease next — so a future lock inherits the
+//! identity rules instead of reinventing a timeout.
+
+const std = @import("std");
+const builtin = @import("builtin");
+const Io = std.Io;
+
+/// Opaque per-process value that changes every time the OS starts a process.
+/// The units differ per platform, so it is only ever compared against another
+/// reading of the SAME pid on the SAME boot — never across machines, never
+/// interpreted as a wall clock. 0 means "no identity recorded".
+pub const StartId = u64;
+
+/// What the OS says about one pid right now.
+pub const Probe = union(enum) {
+ /// The pid is alive and this is the start identity of what holds it.
+ id: StartId,
+ /// Nothing holds the pid: the recorded owner is provably gone.
+ gone,
+ /// The pid could not be resolved to an identity — it may be alive and
+ /// simply opaque to us (another user's process), or the identity source
+ /// may be missing. Callers must treat this as live.
+ unknown,
+};
+
+pub const OwnerState = enum {
+ /// Someone still owns this record. Wait, do not take the lock.
+ held,
+ /// The recorded owner is gone or the pid now belongs to a different
+ /// process. The lock is stale and may be taken.
+ reclaimable,
+};
+
+/// The identity half of an owner record: what every graff lock writes down so
+/// the next process can decide whether the holder is real.
+pub const Record = struct {
+ pid: i32 = 0,
+ start_id: StartId = 0,
+};
+
+/// The whole #413 decision, pure so it can be tested without a process to kill.
+pub fn ownerState(rec_start_id: StartId, live: Probe) OwnerState {
+ return switch (live) {
+ .gone => .reclaimable,
+ // Fail SAFE: an unreadable identity is never evidence of death.
+ .unknown => .held,
+ // rec_start_id == 0 is a legacy (or identity-less platform) record:
+ // pid alive == held, exactly as before #413.
+ .id => |v| if (rec_start_id == 0 or v == rec_start_id) .held else .reclaimable,
+ };
+}
+
+pub fn selfPid() i32 {
+ // Mirrors trace.currentPid deliberately: this module is a leaf with no
+ // graff imports so that any lock can use it without pulling in telemetry.
+ return if (builtin.os.tag == .windows)
+ @intCast(std.os.windows.GetCurrentProcessId())
+ else
+ @intCast(std.posix.system.getpid());
+}
+
+/// This process's start identity, or 0 where the platform has no source.
+pub fn selfStartId(io: Io) StartId {
+ return switch (probe(io, selfPid())) {
+ .id => |v| v,
+ else => 0,
+ };
+}
+
+/// The owner record to write when taking a lock.
+pub fn selfRecord(io: Io) Record {
+ return .{ .pid = selfPid(), .start_id = selfStartId(io) };
+}
+
+/// `ownerState` for a record read off disk, probing the OS for the answer.
+pub fn stateOf(io: Io, rec: Record) OwnerState {
+ return ownerState(rec.start_id, probe(io, rec.pid));
+}
+
+pub fn probe(io: Io, pid: i32) Probe {
+ if (pid <= 0) return .gone;
+ return switch (builtin.os.tag) {
+ .linux => probeLinux(io, pid),
+ .macos, .ios, .tvos, .watchos, .visionos, .driverkit, .maccatalyst => probeDarwin(io, pid),
+ .windows => probeWindows(io, pid),
+ else => probePidOnly(io, pid),
+ };
+}
+
+/// Liveness with no identity: alive answers `.unknown` (held, never stolen),
+/// only a definitively free pid answers `.gone`. This is the pre-#413 contract
+/// and the floor every platform degrades to.
+fn probePidOnly(io: Io, pid: i32) Probe {
+ _ = io;
+ if (builtin.os.tag == .windows) return .unknown;
+ std.posix.kill(@intCast(pid), @enumFromInt(0)) catch |err| switch (err) {
+ error.ProcessNotFound => return .gone,
+ // PermissionDenied means alive and owned by someone else.
+ else => return .unknown,
+ };
+ return .unknown;
+}
+
+fn probeLinux(io: Io, pid: i32) Probe {
+ _ = io;
+ var path_buf: [64]u8 = undefined;
+ const path = std.fmt.bufPrint(&path_buf, "/proc/{d}/stat", .{pid}) catch return .unknown;
+ // Direct openat(FDCWD), not an Io.Dir read: under the io_uring test
+ // backend a /proc read can fail with EBADF, which the Io layer panics on
+ // as a "programmer bug" instead of surfacing a catchable error (that
+ // crashed CI on Linux). procfs reports size 0, so read to EOF.
+ const fd = std.posix.openat(std.posix.AT.FDCWD, path, .{}, 0) catch |err| switch (err) {
+ error.FileNotFound => return .gone,
+ else => return .unknown,
+ };
+ defer _ = std.posix.system.close(fd); // raw syscall wrapper (no std.posix.close in this std); returns usize, not an error
+ var buf: [4096]u8 = undefined;
+ const n = std.posix.read(fd, &buf) catch return .unknown;
+ return if (parseLinuxStat(buf[0..n])) |v| .{ .id = v } else .unknown;
+}
+
+/// Field 22 of a `/proc/<pid>/stat` line. Field 2 is `(comm)`, which may hold
+/// spaces and ')' alike, so the only safe anchor is the LAST ')': everything
+/// after it is space separated and positional, starting at field 3.
+pub fn parseLinuxStat(text: []const u8) ?StartId {
+ const close = std.mem.lastIndexOfScalar(u8, text, ')') orelse return null;
+ var it = std.mem.tokenizeAny(u8, text[close + 1 ..], " \t\r\n");
+ var n: usize = 0;
+ while (it.next()) |tok| {
+ n += 1; // token 1 is field 3 (state), so field 22 is token 20.
+ if (n == 20) return std.fmt.parseInt(StartId, tok, 10) catch null;
+ }
+ return null;
+}
+
+const darwin = struct {
+ const PROC_PIDTBSDINFO: c_int = 3;
+
+ /// `struct proc_bsdinfo` from <sys/proc_info.h>. Only the tail is read,
+ /// but the whole layout has to be spelled out for the offsets to land; the
+ /// comptime assert below is what keeps that honest.
+ const ProcBsdInfo = extern struct {
+ flags: u32,
+ status: u32,
+ xstatus: u32,
+ pid: u32,
+ ppid: u32,
+ uid: u32,
+ gid: u32,
+ ruid: u32,
+ rgid: u32,
+ svuid: u32,
+ svgid: u32,
+ rfu_1: u32,
+ comm: [16]u8,
+ name: [32]u8,
+ nfiles: u32,
+ pgid: u32,
+ pjobc: u32,
+ e_tdev: u32,
+ e_tpgid: u32,
+ nice: i32,
+ start_tvsec: u64,
+ start_tvusec: u64,
+ };
+
+ extern "c" fn proc_pidinfo(pid: c_int, flavor: c_int, arg: u64, buffer: ?*anyopaque, buffersize: c_int) c_int;
+};
+
+fn probeDarwin(io: Io, pid: i32) Probe {
+ comptime std.debug.assert(@sizeOf(darwin.ProcBsdInfo) == 136);
+ comptime std.debug.assert(@offsetOf(darwin.ProcBsdInfo, "start_tvsec") == 120);
+ var info: darwin.ProcBsdInfo = undefined;
+ const size: c_int = @sizeOf(darwin.ProcBsdInfo);
+ const n = darwin.proc_pidinfo(@intCast(pid), darwin.PROC_PIDTBSDINFO, 0, &info, size);
+ // A short answer means ESRCH (dead) or EPERM (alive, another user's).
+ // kill(pid, 0) tells those apart without reading errno by hand.
+ if (n != size) return probePidOnly(io, pid);
+ const usec = info.start_tvsec *% std.time.us_per_s +% info.start_tvusec;
+ return if (usec == 0) .unknown else .{ .id = usec };
+}
+
+const win = struct {
+ const w = std.os.windows;
+ const PROCESS_QUERY_LIMITED_INFORMATION: w.DWORD = 0x1000;
+
+ extern "kernel32" fn OpenProcess(dwDesiredAccess: w.DWORD, bInheritHandle: w.BOOL, dwProcessId: w.DWORD) callconv(.winapi) ?w.HANDLE;
+ extern "kernel32" fn GetProcessTimes(
+ hProcess: w.HANDLE,
+ lpCreationTime: *w.FILETIME,
+ lpExitTime: *w.FILETIME,
+ lpKernelTime: *w.FILETIME,
+ lpUserTime: *w.FILETIME,
+ ) callconv(.winapi) w.BOOL;
+};
+
+fn probeWindows(io: Io, pid: i32) Probe {
+ _ = io;
+ const w = std.os.windows;
+ // QUERY_LIMITED_INFORMATION is the least privilege that still answers
+ // GetProcessTimes, and it works across integrity levels.
+ const handle = win.OpenProcess(win.PROCESS_QUERY_LIMITED_INFORMATION, .FALSE, @intCast(pid)) orelse {
+ // INVALID_PARAMETER is Windows for "no process has that id"; a denial
+ // means it exists and is simply out of reach.
+ return switch (w.GetLastError()) {
+ .INVALID_PARAMETER => .gone,
+ else => .unknown,
+ };
+ };
+ defer w.CloseHandle(handle);
+ var created: w.FILETIME = undefined;
+ var exited: w.FILETIME = undefined;
+ var kernel: w.FILETIME = undefined;
+ var user: w.FILETIME = undefined;
+ if (!win.GetProcessTimes(handle, &created, &exited, &kernel, &user).toBool()) return .unknown;
+ const ticks = (@as(u64, created.dwHighDateTime) << 32) | @as(u64, created.dwLowDateTime);
+ return if (ticks == 0) .unknown else .{ .id = ticks };
+}
+
+/// One line, ASCII, no allocator: a lock file must be writable from a path
+/// that is already failing. `formatRecord` needs at least `record_max` bytes.
+pub const record_max = 80;
+
+pub fn formatRecord(buf: *[record_max]u8, rec: Record) []const u8 {
+ return std.fmt.bufPrint(buf, "graff-owner 1 pid={d} start={d}\n", .{ rec.pid, rec.start_id }) catch unreachable;
+}
+
+/// Tolerant on purpose. `start=` missing (a pre-#413 writer) yields
+/// `start_id = 0`, which `ownerState` honours under the legacy rule, and a
+/// bare number is read as the classic one-line pidfile. Anything else is null:
+/// an unparsable record is no record, never a spurious owner.
+pub fn parseRecord(text: []const u8) ?Record {
+ const line = std.mem.trim(u8, text[0 .. std.mem.indexOfScalar(u8, text, '\n') orelse text.len], " \t\r");
+ if (line.len == 0) return null;
+ if (!std.mem.startsWith(u8, line, "graff-owner")) {
+ // The classic one-line pidfile: a number and nothing else.
+ const pid = std.fmt.parseInt(i32, line, 10) catch return null;
+ return if (pid > 0) .{ .pid = pid } else null;
+ }
+ var rec: Record = .{};
+ var have_pid = false;
+ var it = std.mem.tokenizeAny(u8, line, " \t");
+ while (it.next()) |tok| {
+ if (std.mem.startsWith(u8, tok, "pid=")) {
+ rec.pid = std.fmt.parseInt(i32, tok[4..], 10) catch return null;
+ have_pid = true;
+ } else if (std.mem.startsWith(u8, tok, "start=")) {
+ rec.start_id = std.fmt.parseInt(StartId, tok[6..], 10) catch return null;
+ }
+ }
+ if (!have_pid or rec.pid <= 0) return null;
+ return rec;
+}
+
+/// A record is worth waiting for only when it names someone ELSE and is still
+/// held. Our own record is never contention.
+pub fn heldByOther(rec: Record, my_pid: i32, state: OwnerState) bool {
+ return rec.pid != my_pid and state == .held;
+}
+
+pub fn readOwnerFile(io: Io, dir: Io.Dir, path: []const u8) ?Record {
+ var buf: [record_max]u8 = undefined;
+ const text = dir.readFile(io, path, &buf) catch return null;
+ return parseRecord(text);
+}
+
+/// Take an owner file, or report that a live owner still has it. This is the
+/// whole cross-process lock protocol for a lock that cannot use `flock` —
+/// a filesystem with no working locks, or a lock that must outlive an open
+/// file descriptor — and it is what makes the identity worth recording: a
+/// crashed owner's record is RECLAIMED because its identity provably no longer
+/// matches, with no timeout to tune and no live owner ever robbed.
+///
+/// Failing to read or write the file itself is deliberately not an error. An
+/// owner file is a best-effort stand-in for a lock, and it must never become
+/// the reason the operation it guards cannot happen at all.
+pub fn claimOwnerFile(io: Io, dir: Io.Dir, path: []const u8) error{LockHeld}!void {
+ if (readOwnerFile(io, dir, path)) |rec| {
+ if (heldByOther(rec, selfPid(), stateOf(io, rec))) return error.LockHeld;
+ }
+ var stamp: [record_max]u8 = undefined;
+ dir.writeFile(io, .{ .sub_path = path, .data = formatRecord(&stamp, selfRecord(io)) }) catch {};
+}
+
+pub fn releaseOwnerFile(io: Io, dir: Io.Dir, path: []const u8) void {
+ dir.deleteFile(io, path) catch {};
+}
+
+test "ownerState: the same pid holds only while it is the same process (#413)" {
+ // Live and unchanged: the lock is genuinely held.
+ try std.testing.expectEqual(OwnerState.held, ownerState(4242, .{ .id = 4242 }));
+ // Same pid, different process: a recycled pid may never keep the lock.
+ try std.testing.expectEqual(OwnerState.reclaimable, ownerState(4242, .{ .id = 4243 }));
+ // Nothing holds the pid at all.
+ try std.testing.expectEqual(OwnerState.reclaimable, ownerState(4242, .gone));
+}
+
+test "ownerState: a record with no start identity keeps the pre-#413 contract" {
+ // An older graff's in-flight lock: pid alive means held, and it is never
+ // stolen merely because the new binary cannot verify it.
+ try std.testing.expectEqual(OwnerState.held, ownerState(0, .{ .id = 999 }));
+ try std.testing.expectEqual(OwnerState.held, ownerState(0, .unknown));
+ // Only a provably free pid retires it — the old rule, unchanged.
+ try std.testing.expectEqual(OwnerState.reclaimable, ownerState(0, .gone));
+}
+
+test "ownerState: a failed identity read fails safe and never steals a lock" {
+ try std.testing.expectEqual(OwnerState.held, ownerState(4242, .unknown));
+ try std.testing.expectEqual(OwnerState.held, ownerState(0, .unknown));
+}
+
+test "parseLinuxStat: field 22 survives a comm holding spaces and ')'" {
+ // comm is `graff (test) x`: a naive whitespace split answers 1 here, and
+ // any anchor but the LAST ')' lands inside the name.
+ const weird = "4242 (graff (test) x) S 4241 4242 4242 0 -1 4194304 512 0 0 0 7 3 0 0 20 0 1 0 987654321 12345678 900 18446744073709551615";
+ try std.testing.expectEqual(@as(?StartId, 987654321), parseLinuxStat(weird));
+
+ // The ordinary shape, captured from a real /proc/<pid>/stat.
+ const plain = "1 (systemd) S 0 1 1 0 -1 4194560 24512 366 89 0 61 213 0 0 20 0 1 0 12 170201088 3221 18446744073709551615 1 1 0 0 0 0 671173123 4096 1260 0 0 0 17 2 0 0 0 0 0\n";
+ try std.testing.expectEqual(@as(?StartId, 12), parseLinuxStat(plain));
+
+ // Truncated or nonsense input is no identity rather than a wrong one.
+ try std.testing.expectEqual(@as(?StartId, null), parseLinuxStat("4242 (graff) S 1 2 3"));
+ try std.testing.expectEqual(@as(?StartId, null), parseLinuxStat("no parens here"));
+}
+
+test "parseRecord: round trips, tolerates a legacy pidfile, rejects garbage" {
+ var buf: [record_max]u8 = undefined;
+ const line = formatRecord(&buf, .{ .pid = 4242, .start_id = 1785994345056160 });
+ const back = parseRecord(line) orelse return error.ExpectedRecord;
+ try std.testing.expectEqual(@as(i32, 4242), back.pid);
+ try std.testing.expectEqual(@as(StartId, 1785994345056160), back.start_id);
+
+ // A record from a graff older than #413: pid, no identity.
+ const legacy = parseRecord("graff-owner 1 pid=77\n") orelse return error.ExpectedRecord;
+ try std.testing.expectEqual(@as(i32, 77), legacy.pid);
+ try std.testing.expectEqual(@as(StartId, 0), legacy.start_id);
+ // The classic one-line pidfile, same treatment.
+ const bare = parseRecord("77\n") orelse return error.ExpectedRecord;
+ try std.testing.expectEqual(@as(i32, 77), bare.pid);
+ try std.testing.expectEqual(@as(StartId, 0), bare.start_id);
+
+ try std.testing.expect(parseRecord("") == null);
+ try std.testing.expect(parseRecord("graff-owner 1\n") == null);
+ try std.testing.expect(parseRecord("graff-owner 1 pid=0 start=5") == null);
+ try std.testing.expect(parseRecord("graff-owner 1 pid=nonsense") == null);
+ try std.testing.expect(parseRecord("half a written line") == null);
+}
+
+test "heldByOther: only a live record belonging to someone else is a holder" {
+ const me = selfPid();
+ try std.testing.expect(heldByOther(.{ .pid = me + 1, .start_id = 7 }, me, .held));
+ // Our own record is not contention, whatever it says.
+ try std.testing.expect(!heldByOther(.{ .pid = me, .start_id = 7 }, me, .held));
+ // A crashed owner, or one whose pid now belongs to something else.
+ try std.testing.expect(!heldByOther(.{ .pid = me + 1, .start_id = 7 }, me, .reclaimable));
+}
+
+test "claimOwnerFile: a crashed owner is reclaimed, a live one is waited for" {
+ if (builtin.os.tag == .windows) return error.SkipZigTest; // no pid 1
+ const io = std.testing.io;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ const lock = "engine.owner";
+ var buf: [record_max]u8 = undefined;
+
+ // Nobody has it: taking it stamps our own record.
+ try claimOwnerFile(io, tmp.dir, lock);
+ const mine = readOwnerFile(io, tmp.dir, lock) orelse return error.ExpectedRecord;
+ try std.testing.expectEqual(selfPid(), mine.pid);
+ // Re-entrant: our own record never locks us out of our own lock.
+ try claimOwnerFile(io, tmp.dir, lock);
+
+ // pid 1 (init/launchd) is alive on every unix and is never us. A record
+ // with NO start identity is what a graff older than #413 wrote, and it
+ // must still be honoured or the upgrade would brick an in-flight lock.
+ try tmp.dir.writeFile(io, .{ .sub_path = lock, .data = "graff-owner 1 pid=1\n" });
+ try std.testing.expectError(error.LockHeld, claimOwnerFile(io, tmp.dir, lock));
+
+ switch (probe(io, 1)) {
+ .id => |live| {
+ // Same pid, provably a different process: the record is reclaimed.
+ try tmp.dir.writeFile(io, .{ .sub_path = lock, .data = formatRecord(&buf, .{ .pid = 1, .start_id = live +% 1 }) });
+ try claimOwnerFile(io, tmp.dir, lock);
+ // Same pid AND the same identity: never stolen from.
+ try tmp.dir.writeFile(io, .{ .sub_path = lock, .data = formatRecord(&buf, .{ .pid = 1, .start_id = live }) });
+ try std.testing.expectError(error.LockHeld, claimOwnerFile(io, tmp.dir, lock));
+ },
+ // pid 1 is opaque to an unprivileged user on macOS; unreadable is
+ // held, which the legacy assertion above already proved here.
+ .unknown => {},
+ .gone => return error.InitProcessReportedGone,
+ }
+
+ // An unreadable or truncated record is no record: it must not lock the
+ // world out, and it must not survive the next claim either.
+ try tmp.dir.writeFile(io, .{ .sub_path = lock, .data = "half a written l" });
+ try claimOwnerFile(io, tmp.dir, lock);
+ releaseOwnerFile(io, tmp.dir, lock);
+ try std.testing.expect(readOwnerFile(io, tmp.dir, lock) == null);
+}
+
+test "probe: this process is alive and stably identified; a free pid is gone" {
+ const io = std.testing.io;
+ const me = selfPid();
+ try std.testing.expect(me > 0);
+ switch (probe(io, me)) {
+ // Every supported platform must identify the process it is running in.
+ .id => |v| {
+ try std.testing.expect(v != 0);
+ // Stable: a second reading of the same live pid must agree, or
+ // every lock would look reclaimable the moment it was checked.
+ try std.testing.expectEqual(OwnerState.held, stateOf(io, selfRecord(io)));
+ // And a neighbouring identity must not.
+ try std.testing.expectEqual(OwnerState.reclaimable, stateOf(io, .{ .pid = me, .start_id = v + 1 }));
+ },
+ // A platform with no identity source degrades to pid-only liveness.
+ .unknown => try std.testing.expectEqual(OwnerState.held, stateOf(io, .{ .pid = me })),
+ .gone => return error.LiveProcessReportedGone,
+ }
+ // pid 0 and negatives are not processes, so nothing can be held by them.
+ try std.testing.expectEqual(Probe.gone, probe(io, 0));
+ try std.testing.expectEqual(Probe.gone, probe(io, -1));
+}
diff --git a/evals/grok-46-vs-47/src-before/webauthn-profile.test.cjs b/evals/grok-46-vs-47/src-before/webauthn-profile.test.cjs
new file mode 100644
index 00000000..64bc46b7
--- /dev/null
+++ b/evals/grok-46-vs-47/src-before/webauthn-profile.test.cjs
@@ -0,0 +1,85 @@
+const assert = require('node:assert/strict');
+const { test } = require('node:test');
+const { readProfile, profileEntitlements } = require('./webauthn-profile.cjs');
+
+const config = { keychainAccessGroup: 'ABCDE12345.org.example.fixture.webauthn' };
+const appId = 'ABCDE12345.org.example.fixture';
+const now = Date.parse('2030-01-01T00:00:00Z');
+
+function fixture() {
+ return {
+ Platform: ['OSX'],
+ TeamIdentifier: ['ABCDE12345'],
+ ExpirationDate: new Date('2099-01-01'),
+ Entitlements: {
+ 'com.apple.application-identifier': appId,
+ 'keychain-access-groups': ['ABCDE12345.*'],
+ },
+ };
+}
+
+function authorize(profile) {
+ return profileEntitlements(profile, config, now);
+}
+
+for (const [name, application, groups] of [
+ ['fixture team wildcard group', appId, ['ABCDE12345.*']],
+ ['exact permissions', appId, [config.keychainAccessGroup]],
+ ['trailing wildcard permissions', 'ABCDE12345.org.example.*', ['ABCDE12345.org.example.fixture.*']],
+ ['matching group among unrelated groups', appId, ['ABCDE12345.org.example.other', config.keychainAccessGroup]],
+]) {
+ test(`authorizes ${name} and returns the concrete application identifier`, () => {
+ const profile = fixture();
+ profile.Entitlements['com.apple.application-identifier'] = application;
+ profile.Entitlements['keychain-access-groups'] = groups;
+ assert.deepEqual(authorize(profile), { 'com.apple.application-identifier': appId });
+ });
+}
+
+for (const [name, change] of [
+ ['wrong team', p => { p.TeamIdentifier = ['ZZZZZ99999']; }],
+ ['missing team', p => { delete p.TeamIdentifier; }],
+ ['wrong application', p => { p.Entitlements['com.apple.application-identifier'] = 'ABCDE12345.org.example.other'; }],
+ ['application wildcard with wrong prefix', p => { p.Entitlements['com.apple.application-identifier'] = 'ABCDE12345.org.example.other.*'; }],
+ ['missing application', p => { delete p.Entitlements['com.apple.application-identifier']; }],
+ ['wrong keychain group', p => { p.Entitlements['keychain-access-groups'] = ['ABCDE12345.org.example.other.webauthn']; }],
+ ['keychain wildcard with wrong team prefix', p => { p.Entitlements['keychain-access-groups'] = ['ZZZZZ99999.*']; }],
+ ['missing keychain groups', p => { delete p.Entitlements['keychain-access-groups']; }],
+ ['empty keychain groups', p => { p.Entitlements['keychain-access-groups'] = []; }],
+ ['missing entitlements', p => { delete p.Entitlements; }],
+ ['non-mac platform', p => { p.Platform = ['iOS']; }],
+ ['missing platform', p => { delete p.Platform; }],
+ ['expired profile', p => { p.ExpirationDate = new Date(now - 1); }],
+ ['expiration exactly now', p => { p.ExpirationDate = new Date(now); }],
+ ['invalid expiration string', p => { p.ExpirationDate = 'not-a-date'; }],
+ ['invalid Date object', p => { p.ExpirationDate = new Date(NaN); }],
+ ['missing expiration', p => { delete p.ExpirationDate; }],
+ ['interior application wildcard', p => { p.Entitlements['com.apple.application-identifier'] = 'ABCDE12345.org.*.fixture'; }],
+ ['interior and trailing application wildcards', p => { p.Entitlements['com.apple.application-identifier'] = 'ABCDE12345.*.fixture*'; }],
+ ['interior keychain wildcard', p => { p.Entitlements['keychain-access-groups'] = ['ABCDE12345.org.*.webauthn']; }],
+ ['interior and trailing keychain wildcards', p => { p.Entitlements['keychain-access-groups'] = ['ABCDE12345.*.fixture.*']; }],
+]) {
+ test(`rejects ${name}`, () => {
+ const profile = fixture();
+ change(profile);
+ assert.throws(() => authorize(profile));
+ });
+}
+
+test('accepts a profile until its expiration boundary', () => {
+ const profile = fixture();
+ profile.ExpirationDate = new Date(now + 1);
+ assert.deepEqual(authorize(profile), { 'com.apple.application-identifier': appId });
+});
+
+test('rejects missing profiles', () => {
+ for (const profile of [undefined, null, {}]) {
+ assert.throws(() => authorize(profile));
+ }
+});
+
+test('readProfile rejects a missing path without invoking security', () => {
+ for (const file of [undefined, null, '']) {
+ assert.throws(() => readProfile(file), /GRAFF_WEBAUTHN_PROFILE/);
+ }
+});
diff --git a/evals/grok-46-vs-47/src-before/webauthn-signing.test.cjs b/evals/grok-46-vs-47/src-before/webauthn-signing.test.cjs
new file mode 100644
index 00000000..f0d0805b
--- /dev/null
+++ b/evals/grok-46-vs-47/src-before/webauthn-signing.test.cjs
@@ -0,0 +1,112 @@
+const { test } = require('node:test');
+const assert = require('node:assert/strict');
+const fs = require('node:fs/promises');
+const os = require('node:os');
+const path = require('node:path');
+const { createRequire } = require('node:module');
+const { execFileSync } = require('node:child_process');
+const { signingConfig, optionsForFile, signBundle } = require('./webauthn-signing.cjs');
+const requireSigner = createRequire(require.resolve('@electron/osx-sign'));
+const plist = requireSigner('plist');
+const identity = 'Developer ID Application: Test Fixture (ABCDE12345)';
+const bundleId = 'org.example.fixture';
+const profile = appId => ({ Platform: ['OSX'], TeamIdentifier: ['ABCDE12345'], ExpirationDate: new Date('2099-01-01'),
+ Entitlements: { 'com.apple.application-identifier': `ABCDE12345.${appId}`, 'keychain-access-groups': ['ABCDE12345.*'] } });
+
+test('team derives only from an anchored Developer ID Application identity or explicit valid team', () => {
+ assert.deepEqual(signingConfig(identity, undefined, bundleId), { keychainAccessGroup: 'ABCDE12345.org.example.fixture.webauthn' });
+ assert.equal(signingConfig('a'.repeat(40), 'ZYXWV98765', bundleId).keychainAccessGroup, 'ZYXWV98765.org.example.fixture.webauthn');
+ for (const value of [undefined, '', 'a'.repeat(40), 'Other: Fixture (ABCDE12345)', `${identity} trailing`, `${identity}\n`, 'prefix ' + identity]) {
+ assert.throws(() => signingConfig(value, undefined, bundleId), /valid signing team/);
+ }
+ for (const team of ['', 'short', 'abcde12345', 'ABCDE12345\n', 'ABCDE1234*']) {
+ assert.throws(() => signingConfig(identity, team, bundleId), /valid signing team/);
+ }
+ for (const bundle of ['', undefined, 'org..fixture', '.fixture', 'org.fixture.', 'org_fixture', 'org.fixture\n', 'org.*', 'org/fixture']) {
+ assert.throws(() => signingConfig(identity, undefined, bundle), /CFBundleIdentifier/);
+ }
+});
+
+test('only main app gets keychain access; existing JIT and Bun policies stay exact', () => {
+ const app = path.resolve('Fixture.app');
+ const config = signingConfig(identity, undefined, bundleId);
+ const options = optionsForFile(app, config);
+ const jit = { 'com.apple.security.cs.allow-jit': true };
+ const cases = [
+ [app, { ...jit, 'keychain-access-groups': [config.keychainAccessGroup] }],
+ [app + '/', { ...jit, 'keychain-access-groups': [config.keychainAccessGroup] }],
+ [`${app}/Contents/Resources/bun`, { ...jit, 'com.apple.security.cs.allow-unsigned-executable-memory': true }],
+ [`${app}/Contents/Frameworks/Helper.app`, jit],
+ [`${app}/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework`, jit],
+ [`${app}/Contents/Resources/tool`, {}],
+ [`${app}/Contents/Frameworks/library.dylib`, {}],
+ ];
+ for (const [file, entitlements] of cases) assert.deepEqual(options(file), { hardenedRuntime: true, entitlements });
+});
+
+for (const fails of [false, true]) test(`sign dispatch writes matching config and plist entitlements, cleans temporary files (failure=${fails})`, async () => {
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauthn-sign-test-'));
+ const app = path.join(root, 'Fixture.app');
+ const resources = path.join(app, 'Contents', 'Resources');
+ const entitlementPaths = [];
+ let calls = 0;
+ try {
+ await fs.mkdir(resources, { recursive: true });
+ await fs.writeFile(path.join(resources, 'webauthn.json'), '{"stale":true}');
+ const profilePath = path.join(root, 'fixture.provisionprofile');
+ await fs.writeFile(profilePath, 'fixture CMS bytes');
+ await fs.writeFile(path.join(app, 'Contents', 'embedded.provisionprofile'), 'stale profile');
+ const applicationEntitlements = { 'com.apple.application-identifier': `ABCDE12345.${bundleId}` };
+ const work = signBundle({ app, identity, profilePath, readProvisioningProfile: () => profile(bundleId), readBundleId: (actual) => {
+ assert.equal(actual, app);
+ return bundleId;
+ }, sign: async (options) => {
+ calls++;
+ assert.equal(options.preAutoEntitlements, false);
+ assert.equal(options.preEmbedProvisioningProfile, false);
+ assert.equal(options.provisioningProfile, profilePath);
+ assert.equal(await fs.readFile(path.join(app, 'Contents', 'embedded.provisionprofile'), 'utf8'), 'fixture CMS bytes');
+ assert.equal(options.platform, 'darwin');
+ assert.equal(options.type, 'distribution');
+ const config = JSON.parse(await fs.readFile(path.join(resources, 'webauthn.json'), 'utf8'));
+ assert.deepEqual(config, signingConfig(identity, undefined, bundleId));
+ for (const file of [app, `${resources}/bun`, `${app}/Contents/Frameworks/Helper.app`, `${resources}/tool`]) {
+ const result = options.optionsForFile(file);
+ assert.equal(result.hardenedRuntime, true);
+ assert.equal(typeof result.entitlements, 'string');
+ entitlementPaths.push(result.entitlements);
+ assert.deepEqual(plist.parse(await fs.readFile(result.entitlements, 'utf8')), optionsForFile(app, config, applicationEntitlements)(file).entitlements);
+ }
+ if (fails) throw new Error('fixture failure');
+ } });
+ if (fails) await assert.rejects(work, /fixture failure/);
+ else await work;
+ assert.equal(calls, 1);
+ for (const file of entitlementPaths) await assert.rejects(fs.access(file), { code: 'ENOENT' });
+ } finally { await fs.rm(root, { recursive: true, force: true }); }
+});
+
+test('invalid metadata fails before writing config or invoking signer', async () => {
+ let called = false;
+ await assert.rejects(signBundle({ app: 'Fixture.app', identity, teamId: '', readBundleId: () => bundleId, sign: () => { called = true; } }), /valid signing team/);
+ await assert.rejects(signBundle({ app: 'Fixture.app', identity, readBundleId: () => 'bad/bundle', sign: () => { called = true; } }), /CFBundleIdentifier/);
+ await assert.rejects(signBundle({ app: 'Fixture.app', identity, readBundleId: () => bundleId, sign: () => { called = true; } }), /GRAFF_WEBAUTHN_PROFILE/);
+ assert.equal(called, false);
+});
+
+test('default reader obtains actual bundle identifier through PlistBuddy', { skip: process.platform !== 'darwin' }, async () => {
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), 'webauthn-plist-test-'));
+ const app = path.join(root, 'Fixture.app');
+ try {
+ await fs.mkdir(path.join(app, 'Contents', 'Resources'), { recursive: true });
+ await fs.writeFile(path.join(app, 'Contents', 'Info.plist'), plist.build({ CFBundleIdentifier: 'org.example.actual' }));
+ const profilePath = path.join(root, 'fixture.provisionprofile');
+ await fs.writeFile(profilePath, 'fixture CMS bytes');
+ await signBundle({ app, identity, profilePath, readProvisioningProfile: () => profile('org.example.actual'), sign: async (options) => {
+ const config = JSON.parse(await fs.readFile(path.join(app, 'Contents', 'Resources', 'webauthn.json'), 'utf8'));
+ assert.equal(config.keychainAccessGroup, 'ABCDE12345.org.example.actual.webauthn');
+ const group = execFileSync('/usr/libexec/PlistBuddy', ['-c', 'Print :keychain-access-groups:0', options.optionsForFile(app).entitlements], { encoding: 'utf8' }).trim();
+ assert.equal(group, config.keychainAccessGroup);
+ } });
+ } finally { await fs.rm(root, { recursive: true, force: true }); }
+});