Created
November 6, 2026 23:43
-
-
Save Sidreyas/cea7362d4816f9f4e33d8f6007ece56b to your computer and use it in GitHub Desktop.
T3 #32167 model refresh RPC privacy: before/fixed reproduction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Diagnostics; | |
| using System.IO; | |
| using System.Net; | |
| using System.Web.Script.Serialization; | |
| public static class AcpFixture { | |
| static readonly JavaScriptSerializer Json = new JavaScriptSerializer(); | |
| static readonly string Instance = Environment.GetEnvironmentVariable("T3_25465_INSTANCE"); | |
| static readonly string Control = Environment.GetEnvironmentVariable("T3_25465_CONTROL_URL"); | |
| static string Model; | |
| static Dictionary<string, object> Event(string method) { | |
| var url = Control + "/event?instance=" + Uri.EscapeDataString(Instance) | |
| + "&method=" + Uri.EscapeDataString(method) | |
| + "&pid=" + Process.GetCurrentProcess().Id; | |
| var request = (HttpWebRequest)WebRequest.Create(url); | |
| request.Proxy = null; | |
| request.Timeout = 300000; | |
| using (var response = request.GetResponse()) | |
| using (var reader = new StreamReader(response.GetResponseStream())) | |
| return Json.Deserialize<Dictionary<string, object>>(reader.ReadToEnd()); | |
| } | |
| static object Initialize() { | |
| return new { | |
| protocolVersion = 1, | |
| agentCapabilities = new { loadSession = false }, | |
| agentInfo = new { name = "t3-25465-acp-fixture", version = "1.5.1" }, | |
| authMethods = new[] { new { id = "gemini-api-key", name = "Fixture API key" } } | |
| }; | |
| } | |
| public static int Main() { | |
| if (String.IsNullOrEmpty(Instance) || String.IsNullOrEmpty(Control)) return 2; | |
| string line; | |
| while ((line = Console.ReadLine()) != null) { | |
| var input = Json.Deserialize<Dictionary<string, object>>(line); | |
| if (!input.ContainsKey("id") || !input.ContainsKey("method")) continue; | |
| var method = (string)input["method"]; | |
| var directive = Event(method); | |
| object result; | |
| if (method == "initialize") { | |
| if (directive.ContainsKey("fail") && (bool)directive["fail"]) { | |
| Console.WriteLine(Json.Serialize(new { | |
| jsonrpc = "2.0", id = input["id"], | |
| error = new { code = -32603, message = "OAuth callback https://oauth.invalid/callback?code=private-runtime-model-refresh-code" } | |
| })); | |
| Console.Out.Flush(); | |
| continue; | |
| } | |
| Model = (string)directive["model"]; | |
| result = Initialize(); | |
| } else if (method == "authenticate") { | |
| result = new Dictionary<string, object>(); | |
| } else if (method == "session/new") { | |
| result = new { | |
| sessionId = "fixture-" + Instance, | |
| configOptions = new[] { new { | |
| id = "model", name = "Model", category = "model", type = "select", | |
| currentValue = Model, | |
| options = new[] { new { value = Model, name = Model } } | |
| } } | |
| }; | |
| } else { | |
| result = new Dictionary<string, object>(); | |
| } | |
| Console.WriteLine(Json.Serialize(new { jsonrpc = "2.0", id = input["id"], result = result })); | |
| Console.Out.Flush(); | |
| } | |
| return 0; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createServer } from 'node:http'; | |
| export async function startControl(onEvent = () => {}) { | |
| let phase = 'cached'; | |
| const events = []; | |
| const held = new Set(); | |
| const server = createServer((request, response) => { | |
| const url = new URL(request.url, 'http://127.0.0.1'); | |
| if (url.pathname !== '/event') { response.writeHead(404).end(); return; } | |
| const event = { phase, ...Object.fromEntries(url.searchParams), at: new Date().toISOString() }; | |
| events.push(event); | |
| onEvent(event); | |
| if (phase === 'timeout' && event.instance === 'antigravity_first' && event.method === 'initialize') { | |
| held.add(response); | |
| response.on('close', () => held.delete(response)); | |
| return; | |
| } | |
| response.writeHead(200, { 'content-type': 'application/json' }); | |
| response.end(JSON.stringify({ | |
| fail: phase === 'fail' && event.instance === 'antigravity_first', | |
| model: phase === 'cached' ? 'fixture-cached-model' : 'fixture-refreshed-model', | |
| })); | |
| }); | |
| await new Promise((resolve, reject) => { | |
| server.once('error', reject); | |
| server.listen(0, '127.0.0.1', resolve); | |
| }); | |
| return { | |
| url: `http://127.0.0.1:${server.address().port}`, | |
| events, | |
| setPhase(next) { phase = next; }, | |
| async close() { | |
| for (const response of held) response.destroy(); | |
| server.closeAllConnections(); | |
| await new Promise(resolve => server.close(resolve)); | |
| }, | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PR #32167: targeted model-refresh error privacy | |
| This fixture starts the production T3 CLI server with isolated settings and userdata, authenticates a WebSocket with exactly orchestration:read, and exercises the real Antigravity driver through two native ACP subprocess fixtures. No real credentials or paid model turns are used. | |
| Prerequisites: Windows, Node 26, checkout-local frozen-lockfile dependencies, and the .NET Framework C# compiler. Keep these fixture files together outside the checkout. Do not use live T3 state. | |
| From this fixture directory in PowerShell: | |
| & "$env:WINDIR\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /nologo /target:exe /r:System.Web.Extensions.dll /out:agy_acp_server.exe AcpFixture.cs | |
| Copy-Item -LiteralPath ./agy_acp_server.exe -Destination ./localharness_external.exe | |
| node runtime.mjs <baseline-checkout> before | |
| node runtime.mjs <fixed-checkout> fixed | |
| Baseline is PR commit 8322524ebbb3a984e58e7d7a3af5da6224b49ac9. Fixed is c9d556f03049a3cf595607969f44d4ce45a13e06. Each invocation creates its own state directory and captures the server PID; finally shuts down that server and the fixture control endpoint. | |
| Both runs populate two cached catalogs, refresh all accounts with one failing native peer, then request the failing account alone. The native peer's error contains the synthetic marker private-runtime-model-refresh-code in an OAuth callback URL. | |
| Expected baseline: bulk refresh succeeds with the failed account's cached catalog; targeted refresh fails and includes the synthetic callback marker in the serialized response to the read-only client. | |
| Expected fixed: bulk refresh still succeeds; targeted refresh still returns ProviderSetupError with its instance, operation and safe detail, and excludes the native cause and marker. Switching the fixture back to healthy makes a targeted retry succeed in both runs. | |
| Saved run evidence includes transcript.ndjson and source-hashes.json. Publish only the synthetic verification transcript and sources; server logs and isolated state may contain disposable authentication material. | |
| The focused regression uses the production JSON RPC codec rather than RpcServer.makeNoSerialization, checks the sentinel is absent on the wire, and separately checks the registry keeps its immediate driver cause internally. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PR #32167 RPC privacy correction | |
| Baseline: 8322524ebbb3a984e58e7d7a3af5da6224b49ac9 | |
| Fixed: c9d556f03049a3cf595607969f44d4ce45a13e06 | |
| Windows, Node 26.12.1; production T3 CLI/server and Antigravity driver; deterministic native ACP peers. | |
| No paid model turns or real provider credentials. Callback marker is synthetic. | |
| BEFORE | |
| {"at":"2026-11-06T23:31:06.842Z","kind":"authorized-scope","scope":"orchestration:read"} | |
| {"at":"2026-11-06T23:31:09.802Z","kind":"rpc","request":{"refreshModels":true},"elapsedMs":1415,"exit":"Success","providers":[{"instanceId":"antigravity_first","installed":true,"status":"ready","models":["fixture-cached-model"]},{"instanceId":"antigravity_second","installed":true,"status":"ready","models":["fixture-refreshed-model"]}]} | |
| {"at":"2026-11-06T23:31:10.715Z","kind":"targeted-privacy","variant":"before","exposesNativeCause":true,"safeFailurePreserved":true} | |
| {"at":"2026-11-06T23:31:11.493Z","kind":"e2e-passed","variant":"before"} | |
| {"at":"2026-11-06T23:31:11.616Z","kind":"server-stopped","pid":27644,"exitCode":130} | |
| Production source hashes: | |
| { | |
| "apps/server/src/ws.ts": "af0f35f66beedc6c1b1c4983b62626efde69cd1c6f71aa2bac75480dbd6fb5cd", | |
| "apps/server/src/provider/ProviderRegistry.ts": "0ed417b93d743b9f663e38ade043659411a555687f0cec48098c936a1d1066f9", | |
| "packages/contracts/src/providerSetup.ts": "2834c57d7fb662cea8d62bb488e79e60c1109cc2207f3cf051960475983f6df0" | |
| } | |
| FIXED | |
| {"at":"2026-11-06T23:32:32.039Z","kind":"authorized-scope","scope":"orchestration:read"} | |
| {"at":"2026-11-06T23:32:34.649Z","kind":"rpc","request":{"refreshModels":true},"elapsedMs":1213,"exit":"Success","providers":[{"instanceId":"antigravity_first","installed":true,"status":"ready","models":["fixture-cached-model"]},{"instanceId":"antigravity_second","installed":true,"status":"ready","models":["fixture-refreshed-model"]}]} | |
| {"at":"2026-11-06T23:32:35.248Z","kind":"targeted-privacy","variant":"fixed","exposesNativeCause":false,"safeFailurePreserved":true} | |
| {"at":"2026-11-06T23:32:35.912Z","kind":"e2e-passed","variant":"fixed"} | |
| {"at":"2026-11-06T23:32:35.985Z","kind":"server-stopped","pid":29756,"exitCode":130} | |
| Production source hashes: | |
| { | |
| "apps/server/src/ws.ts": "7597b9a6b8bda75a9f9f306c7f8a06fc7af3cc9c0c770895fca56046150fa889", | |
| "apps/server/src/provider/ProviderRegistry.ts": "0ed417b93d743b9f663e38ade043659411a555687f0cec48098c936a1d1066f9", | |
| "packages/contracts/src/providerSetup.ts": "2834c57d7fb662cea8d62bb488e79e60c1109cc2207f3cf051960475983f6df0" | |
| } | |
| Regression: baseline 1 failed / 1 passed, fixed 2 passed. Final selected suite: 111 passed in four files. | |
| All seven selected equivalents passed: format, lint, both Knip passes, GraphQL check, three affected typechecks, and tests. | |
| check:changed wrapper remained blocked before stages by PR #32023 Windows ignored-input junction traversal; no wrapper pass or cache entry is claimed. | |
| Knip used KNIP_DISABLE_RAW_TRANSFER=1; native checks used RAYON_NUM_THREADS=1. The duplicate parallel commit hook was skipped for this commit only after unchanged-source serial verification. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import assert from 'node:assert/strict'; | |
| import { spawn } from 'node:child_process'; | |
| import { createHash, randomBytes } from 'node:crypto'; | |
| import { once } from 'node:events'; | |
| import { appendFileSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs'; | |
| import { createServer } from 'node:net'; | |
| import path from 'node:path'; | |
| import { fileURLToPath } from 'node:url'; | |
| import { startControl } from './control.mjs'; | |
| const checkout = path.resolve(process.argv[2]); | |
| const variant = process.argv[3]; | |
| assert.ok(['before', 'fixed'].includes(variant), 'Usage: node run.mjs <checkout> <before|fixed>'); | |
| const scratch = fileURLToPath(new URL('.', import.meta.url)); | |
| const runDir = mkdtempSync(path.join(scratch, `${variant}-`)); | |
| const t3Home = path.join(runDir, 'state'); | |
| const workspace = path.join(runDir, 'workspace'); | |
| const providerHome = path.join(runDir, 'provider-home'); | |
| for (const dir of [workspace, providerHome, path.join(t3Home, 'userdata')]) mkdirSync(dir, { recursive: true }); | |
| const transcript = path.join(runDir, 'transcript.ndjson'); | |
| writeFileSync(path.join(runDir, 'source-hashes.json'), JSON.stringify(Object.fromEntries([ | |
| 'apps/server/src/ws.ts', 'apps/server/src/provider/ProviderRegistry.ts', | |
| 'packages/contracts/src/providerSetup.ts', | |
| ].map(name => [name, createHash('sha256').update(readFileSync(path.join(checkout,name))).digest('hex')])), null, 2)); | |
| const privateValues = new Set(); | |
| const redact = text => { | |
| for (const match of text.matchAll(/(?:^Token: |token%3D)([a-zA-Z0-9_-]+)/gm)) privateValues.add(match[1]); | |
| for (const value of privateValues) text = text.replaceAll(value, '[private]'); | |
| return text.replace(/((?:wsTicket|token)=)[^\s"&]+/gi, '$1[private]'); | |
| }; | |
| const record = (entry) => { | |
| const line = redact(JSON.stringify({ at: new Date().toISOString(), ...entry })); | |
| appendFileSync(transcript, line + '\n'); | |
| console.log(line); | |
| }; | |
| const control = await startControl(event => record({ kind: 'acp', ...event })); | |
| const ids = ['antigravity_first', 'antigravity_second']; | |
| const settings = { | |
| providerInstances: { | |
| codex: { driver: 'codex', enabled: false }, | |
| claudeAgent: { driver: 'claudeAgent', enabled: false }, | |
| ...Object.fromEntries(ids.map(instanceId => [instanceId, { | |
| driver: 'antigravity', enabled: true, displayName: instanceId, | |
| config: { | |
| binaryPath: path.join(scratch, 'agy_acp_server.exe'), | |
| authMethod: 'gemini-api-key', apiKey: 'fixture-only-not-a-real-key', | |
| }, | |
| environment: [ | |
| ['T3_25465_INSTANCE', instanceId], ['T3_25465_CONTROL_URL', control.url], | |
| ['USERPROFILE', providerHome], ['HOME', providerHome], | |
| ['ANTIGRAVITY_DATA_DIR', providerHome], | |
| ].map(([name, value]) => ({ name, value, sensitive: false })), | |
| }])), | |
| }, | |
| }; | |
| writeFileSync(path.join(t3Home, 'userdata', 'settings.json'), JSON.stringify(settings, null, 2)); | |
| const portProbe = createServer(); | |
| await new Promise(resolve => portProbe.listen(0, '127.0.0.1', resolve)); | |
| const port = portProbe.address().port; | |
| await new Promise(resolve => portProbe.close(resolve)); | |
| const bootstrapToken = randomBytes(32).toString('hex'); | |
| privateValues.add(bootstrapToken); | |
| const env = { ...process.env, T3CODE_LOG_LEVEL: 'Debug', T3CODE_DEV_SEED: '0' }; | |
| for (const key of ['VITE_HTTP_URL', 'VITE_WS_URL', 'VITE_DEV_SERVER_URL', 'T3CODE_DEV_AUTH_TOKEN', 'T3_SERVICE_LAUNCHER_CONTEXT', 'T3_BOOT_SERVICE_UNIT', 'T3CODE_BOOTSTRAP_FD']) delete env[key]; | |
| const server = spawn(process.execPath, [ | |
| '--import', new URL('./shutdown.mjs', import.meta.url).href, | |
| path.join(checkout, 'apps/server/src/bin.ts'), 'serve', | |
| '--base-dir', t3Home, '--host', '127.0.0.1', '--port', String(port), | |
| '--mode', 'desktop', '--no-browser', '--bootstrap-fd', '3', | |
| ], { cwd: workspace, env, windowsHide: true, stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'ipc'] }); | |
| record({ kind: 'server-start', pid: server.pid, variant, port, checkout, state: t3Home }); | |
| server.stdio[3].end(JSON.stringify({ | |
| mode: 'desktop', noBrowser: true, port, host: '127.0.0.1', t3Home, | |
| desktopBootstrapToken: bootstrapToken, shellEnvironmentPrepared: true, | |
| tailscaleServeEnabled: false, tailscaleServePort: 443, | |
| }) + '\n'); | |
| let ws; | |
| let pendingId = 0; | |
| const pending = new Map(); | |
| let output = ''; | |
| const ready = new Promise((resolve, reject) => { | |
| const timeout = setTimeout(() => reject(new Error('Server startup did not complete within five minutes.')), 300000); | |
| const consume = chunk => { | |
| const text = redact(chunk.toString()); | |
| appendFileSync(path.join(runDir, 'server.log'), text); | |
| output = (output + text).slice(-16000); | |
| if (output.includes('startup phase: complete')) { clearTimeout(timeout); resolve(); } | |
| }; | |
| server.stdout.on('data', consume); | |
| server.stderr.on('data', consume); | |
| server.once('error', error => { clearTimeout(timeout); reject(error); }); | |
| server.once('exit', code => { clearTimeout(timeout); reject(new Error(`Server exited ${code}; see ${path.join(runDir, 'server.log')}`)); }); | |
| }); | |
| const origin = `http://127.0.0.1:${port}`; | |
| async function jsonRequest(route, options) { | |
| const response = await fetch(origin + route, options); | |
| if (!response.ok) throw new Error(`${route} returned ${response.status}`); | |
| return response.json(); | |
| } | |
| async function rpc(payload) { | |
| const id = String(++pendingId); | |
| const start = performance.now(); | |
| const result = new Promise((resolve, reject) => { | |
| const timeout = setTimeout(() => { pending.delete(id); reject(new Error(`RPC ${id} exceeded three minutes.`)); }, 180000); | |
| pending.set(id, message => { clearTimeout(timeout); resolve(message.exit); }); | |
| }); | |
| ws.send(JSON.stringify({ _tag: 'Request', id, tag: 'server.refreshProviders', payload, headers: [] })); | |
| const exit = await result; | |
| record({ | |
| kind: 'rpc', request: payload, elapsedMs: Math.round(performance.now() - start), exit: exit._tag, | |
| providers: exit._tag === 'Success' ? exit.value.providers.filter(p => ids.includes(p.instanceId)).map(p => ({ | |
| instanceId: p.instanceId, installed: p.installed, status: p.status, models: p.models.map(m => m.slug), | |
| })) : undefined, | |
| cause: exit._tag === 'Failure' ? exit.cause : undefined, | |
| }); | |
| return exit; | |
| } | |
| function models(exit, id) { | |
| assert.equal(exit._tag, 'Success'); | |
| return exit.value.providers.find(p => p.instanceId === id).models.map(m => m.slug); | |
| } | |
| try { | |
| await ready; | |
| record({ kind: 'server-ready', pid: server.pid }); | |
| const token = await jsonRequest('/oauth/token', { | |
| method: 'POST', body: new URLSearchParams({ | |
| grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange', | |
| subject_token: bootstrapToken, | |
| subject_token_type: 'urn:t3:params:oauth:token-type:environment-bootstrap', | |
| requested_token_type: 'urn:ietf:params:oauth:token-type:access_token', | |
| client_label: 'Model refresh privacy isolated E2E', scope: 'orchestration:read', | |
| }), | |
| }); | |
| privateValues.add(token.access_token); | |
| assert.equal(token.scope, 'orchestration:read'); | |
| record({kind:'authorized-scope', scope:token.scope}); | |
| const ticket = await jsonRequest('/api/auth/websocket-ticket/rpc', { | |
| method: 'POST', headers: { authorization: `Bearer ${token.access_token}` }, | |
| }); | |
| privateValues.add(ticket.ticket); | |
| ws = new WebSocket(`ws://127.0.0.1:${port}/ws?orchestrationProtocol=2&wsTicket=${encodeURIComponent(ticket.ticket)}`); | |
| ws.addEventListener('message', event => { | |
| const data = JSON.parse(event.data); | |
| for (const message of Array.isArray(data) ? data : [data]) { | |
| if (message._tag === 'Exit') { | |
| const resolve = pending.get(String(message.requestId)); | |
| pending.delete(String(message.requestId)); | |
| resolve?.(message); | |
| } | |
| } | |
| }); | |
| await new Promise((resolve, reject) => { | |
| ws.addEventListener('open', resolve, { once: true }); | |
| ws.addEventListener('error', () => reject(new Error('WebSocket failed to open.')), { once: true }); | |
| }); | |
| record({ kind: 'authenticated-websocket' }); | |
| for (const id of ids) { | |
| const cached = await rpc({ refreshModels: true, instanceId: id }); | |
| assert.ok(models(cached, id).includes('fixture-cached-model')); | |
| } | |
| control.setPhase('fail'); | |
| const bulk = await rpc({refreshModels:true}); | |
| assert.ok(models(bulk,ids[0]).includes('fixture-cached-model')); | |
| assert.ok(models(bulk,ids[1]).includes('fixture-refreshed-model')); | |
| const targeted = await rpc({refreshModels:true, instanceId:ids[0]}); | |
| assert.equal(targeted._tag,'Failure'); | |
| const encoded = JSON.stringify(targeted); | |
| assert.match(encoded,/ProviderSetupError/); | |
| assert.match(encoded,/refresh-models/); | |
| const exposesNativeCause=encoded.includes('private-runtime-model-refresh-code'); | |
| assert.equal(exposesNativeCause,variant==='before'); | |
| if(variant==='fixed')assert.doesNotMatch(encoded,/ProviderDriverError|AcpRequestError/); | |
| record({kind:'targeted-privacy',variant,exposesNativeCause,safeFailurePreserved:true}); | |
| control.setPhase('healthy'); | |
| const recovered=await rpc({refreshModels:true,instanceId:ids[0]}); | |
| assert.ok(models(recovered,ids[0]).includes('fixture-refreshed-model')); | |
| record({kind:'e2e-passed',variant}); | |
| } finally { | |
| ws?.close(); | |
| for (const resolve of pending.values()) resolve({ exit: { _tag: 'Failure', cause: 'E2E cleanup' } }); | |
| pending.clear(); | |
| if (server.exitCode === null) { | |
| const exited = once(server, 'exit'); | |
| server.send({ type: 'stop-25465-fixture-server' }); | |
| const deadline = setTimeout(() => server.kill(), 45000); | |
| await exited; | |
| clearTimeout(deadline); | |
| } | |
| await control.close(); | |
| record({ kind: 'server-stopped', pid: server.pid, exitCode: server.exitCode }); | |
| console.log(`Evidence: ${runDir}`); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| process.on('message', message => { | |
| if (message?.type === 'stop-25465-fixture-server') process.emit('SIGINT'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment