Skip to content

Instantly share code, notes, and snippets.

@hieu-lee
Created November 1, 2026 06:44
Show Gist options
  • Select an option

  • Save hieu-lee/3afc0bf4395fafe51f4a3082bd897d9b to your computer and use it in GitHub Desktop.

Select an option

Save hieu-lee/3afc0bf4395fafe51f4a3082bd897d9b to your computer and use it in GitHub Desktop.
T3 Code linear plan-prefix verification at 5b030f2950

Reproduce plan-prefix verification

Base: pingdotgg/t3code main 7195b699547b.

Clone the linked evidence gist to /tmp/t3-complexity-audit (or copy its files there). From the PR checkout:

node /tmp/t3-complexity-audit/verify-plan.mjs "$PWD/packages/shared/src/proposedPlanText.ts"
vp test run packages/shared/src/threadFindText.test.ts apps/web/src/proposedPlan.test.ts
vp run check:changed

The verifier was written and run before changing the implementation. The failure matrix lists boundary cases. The saved baseline is the exact original helper. The verifier checks 11 literal cases and 5,000 deterministic generated inputs. The large-prefix cases count Array.shift calls and sum the lengths moved by the standard array shift cost model; these are algorithmic operation counts, not wall-clock measurements or live client latency claims. The new cursor visits each skipped line once; split, slice, and join remain linear. Auxiliary and result space remain O(n).

Shared users: web and desktop ProposedPlanCard and collapsed plan preview; mobile ProposedPlanCard; displayed plan search. No contracts, networking, provider adapters, permissions, or output text change. No live UI session was run.

The production patch was reviewed independently by three Codex subagents, all clean. Focused caller tests pass (12). check:changed passes. No new unit tests were added after the implementation.

note: You are running `vp test` as a Vite+ built-in command. If you meant to run the test npm script, use `vpr test` instead.
RUN v5.0.5 /Users/hieu.leduc/t3code
Test Files 2 passed (2)
Tests 12 passed (12)
Start at 07:21:41
Duration 4.37s (transform 78%, setup 12%, import 10%)
{
"exampleCases": 11,
"differentialCases": 5000,
"scaling": [
{
"blankLines": 200,
"baseline": {
"shifts": 201,
"movedSlots": 20301
},
"candidate": {
"shifts": 0,
"movedSlots": 0
}
},
{
"blankLines": 2000,
"baseline": {
"shifts": 2001,
"movedSlots": 2003001
},
"candidate": {
"shifts": 0,
"movedSlots": 0
}
},
{
"blankLines": 20000,
"baseline": {
"shifts": 20001,
"movedSlots": 200030001
},
"candidate": {
"shifts": 0,
"movedSlots": 0
}
}
],
"note": "Moved slots are a source-level cost model for repeated Array.shift, not a wall-clock speedup."
}
{
"exampleCases": 11,
"differentialCases": 5000,
"scaling": [
{
"blankLines": 200,
"baseline": {
"shifts": 201,
"movedSlots": 20301
},
"candidate": {
"shifts": 201,
"movedSlots": 20301
}
},
{
"blankLines": 2000,
"baseline": {
"shifts": 2001,
"movedSlots": 2003001
},
"candidate": {
"shifts": 2001,
"movedSlots": 2003001
}
},
{
"blankLines": 20000,
"baseline": {
"shifts": 20001,
"movedSlots": 200030001
},
"candidate": {
"shifts": 20001,
"movedSlots": 200030001
}
}
],
"note": "Moved slots are a source-level cost model for repeated Array.shift, not a wall-clock speedup."
}
$ node scripts/check-changed.ts ⊘ cache disabled
check:changed: 1 files since 7195b699547b (origin/main)
> vp format pass 0.2s
Checking formatting...
All matched files use the correct format.
Finished in 85ms on 1 files using 16 threads.
> vp lint pass 0.4s
> vp knip 1/2 pass 6.7s
> vp knip 2/2 pass 12.6s
> vp typecheck (33 packages) pass 5.0s
~/apps/desktop$ tsc --noEmit ◉ cache hit, replaying
~/packages/provider-opencode$ tsc --noEmit ◉ cache hit, replaying
~/packages/secret-provider-onepassword$ tsc --noEmit ◉ cache hit, replaying
~/packages/shared$ tsc --noEmit ◉ cache hit, replaying
~/packages/client-runtime$ tsc --noEmit ◉ cache hit, replaying
~/packages/provider-acp$ tsc --noEmit ◉ cache hit, replaying
~/packages/provider-core$ tsc --noEmit ◉ cache hit, replaying
~/scripts$ tsc --noEmit ○ cache miss: 'packages/contracts/src/settings.ts' modified, executing
~/packages/provider-pi$ tsc --noEmit ◉ cache hit, replaying
~/evals$ tsc --noEmit ◉ cache hit, replaying
~/packages/source-control-github$ tsc --noEmit ◉ cache hit, replaying
~/packages/provider-fx$ tsc --noEmit ◉ cache hit, replaying
~/apps/server$ tsc --noEmit ◉ cache hit, replaying
~/apps/web$ tsc --noEmit ◉ cache hit, replaying
~/packages/source-control-bitbucket$ tsc --noEmit ◉ cache hit, replaying
~/packages/source-control-gitcafe$ tsc --noEmit ◉ cache hit, replaying
~/packages/source-control-gitlab$ tsc --noEmit ◉ cache hit, replaying
~/packages/provider-cursor$ tsc --noEmit ◉ cache hit, replaying
src/server/adapter.test.ts:84:30 - suggestion TS377096: This generator applies `Effect.orDie` to every yielded effect. Hoist it once to the generator result: `Effect.gen(...).pipe(Effect.orDie)`, or `Effect.fn(function*(){ ... }, Effect.orDie)`. effect(redundantOrDie)
84 Effect.gen(function* () {
~~~~~~~~~
src/server/adapter.test.ts:116:31 - This repeated `Effect.orDie` site participates in the hoistable generator-wide `orDie`. effect(redundantOrDie)
116 }).pipe(Effect.orDie);
~~~~~~~~~~~~
src/server/adapter.test.ts:144:58 - This repeated `Effect.orDie` site participates in the hoistable generator-wide `orDie`. effect(redundantOrDie)
144 yield* input.onDelta!(update).pipe(Effect.orDie);
~~~~~~~~~~~~
~/packages/provider-grok$ tsc --noEmit ◉ cache hit, replaying
~/packages/secret-provider-definitions$ tsc --noEmit ◉ cache hit, replaying
~/packages/source-control-definitions$ tsc --noEmit ◉ cache hit, replaying
~/packages/ssh$ tsc --noEmit ◉ cache hit, replaying
~/packages/provider-testing$ tsc --noEmit ◉ cache hit, replaying
~/apps/marketing$ astro check ◉ cache hit, replaying
07:22:14 [types] Generated 134ms
07:22:14 [check] Getting diagnostics for Astro files in /Users/hieu.leduc/t3code/apps/marketing...
Result (22 files):
- 0 errors
- 0 warnings
- 0 hints
~/infra/relay$ tsc --noEmit ◉ cache hit, replaying
~/packages/source-control-core$ tsc --noEmit ◉ cache hit, replaying
~/packages/source-control-forgejo$ tsc --noEmit ◉ cache hit, replaying
~/packages/source-control-testing$ tsc --noEmit ◉ cache hit, replaying
~/packages/tailscale$ tsc --noEmit ◉ cache hit, replaying
~/packages/provider-muse$ tsc --noEmit ◉ cache hit, replaying
~/apps/mobile$ tsc --noEmit ◉ cache hit, replaying
~/packages/source-control-azure-devops$ tsc --noEmit ◉ cache hit, replaying
~/packages/provider-acp-registry$ tsc --noEmit ◉ cache hit, replaying
---
vp run: 32/33 cache hit (96%), 33/33 successful, 103.33s saved. (Run `vp run --last-details` for full details)
> vp test (1 files) pass 6.3s
RUN v5.0.5 /Users/hieu.leduc/t3code
Test Files 1 passed (1)
Tests 1 passed (1)
Start at 07:23:01
Duration 5.04s (transform 60%, import 22%, setup 17%, tests 1%)
check:changed summary
pass format 0.2s
pass lint 0.4s
pass knip 1/2 6.7s
pass knip 2/2 12.6s
pass typecheck (33 packages) 5.0s
pass test (1 files) 6.3s
CI also runs: full test suites, build, release smoke
unused patch check skipped: no dependency files changed

Failure cases before implementation

  • Empty or whitespace-only input must remain empty.
  • Only a heading on the first line is removed; an indented or later title follows existing rules.
  • The first nonblank Summary heading is removed, case-insensitively, but no later Summary.
  • Blank lines after either removed heading are skipped, including Unicode whitespace.
  • CRLF is normalized exactly as before; a lone CR keeps its old behavior.
  • Markdown/body text and internal blank lines are unchanged; trailing whitespace is trimmed.
  • Multiple calls share no cursor state.
  • Large leading blank prefixes must not move the entire remaining array per line.
export function proposedPlanTitle(planMarkdown: string): string | null {
const heading = planMarkdown.match(/^\s{0,3}#{1,6}\s+(.+)$/m)?.[1]?.trim();
return heading && heading.length > 0 ? heading : null;
}
export function stripDisplayedPlanMarkdown(planMarkdown: string): string {
const lines = planMarkdown.trimEnd().split(/\r?\n/);
const sourceLines = lines[0] && /^\s{0,3}#{1,6}\s+/.test(lines[0]) ? lines.slice(1) : [...lines];
while (sourceLines[0]?.trim().length === 0) {
sourceLines.shift();
}
const firstHeadingMatch = sourceLines[0]?.match(/^\s{0,3}#{1,6}\s+(.+)$/);
if (firstHeadingMatch?.[1]?.trim().toLowerCase() === "summary") {
sourceLines.shift();
while (sourceLines[0]?.trim().length === 0) {
sourceLines.shift();
}
}
return sourceLines.join("\n");
}
import assert from 'node:assert/strict';
import {pathToFileURL} from 'node:url';
const {stripDisplayedPlanMarkdown: actual} = await import(pathToFileURL(process.argv[2]));
const {stripDisplayedPlanMarkdown: baseline} = await import(pathToFileURL('/tmp/t3-complexity-audit/proposedPlanText.baseline.ts'));
const examples = [
['', ''], [' \t\n', ''], ['# Plan\n\n## Summary\n\nShip it\n', 'Ship it'],
['\n# Plan\n\nBody', '# Plan\n\nBody'], ['# Plan\r\n\t\r\n## sUmMaRy\r\n\r\nBody \r\n','Body'],
['####### Plan\nBody','####### Plan\nBody'], [' # Plan\nBody',' # Plan\nBody'],
['# Title\n## Other\n\n## Summary\nBody','## Other\n\n## Summary\nBody'],
['# Title\n\u00a0\n## Summary\n\u2028\nFirst\n\nSecond\t','First\n\nSecond'],
['# Title\n## Summary\n\n',''], ['# Title\n## Summary \n x\r\ny',' x\ny'],
];
for(const [input,expected]of examples) assert.equal(actual(input),expected);
let seed=12345678;const random=()=>((seed=(Math.imul(seed,1664525)+1013904223)>>>0)/2**32);
const lines=['','# Plan','## Summary','### SUMMARY ','## Other','Body','\t','\u00a0',' # Title','####### nope','\r',' Item ','\u2028','\ufeff'];
for(let i=0;i<5000;i++){
const input=Array.from({length:Math.floor(random()*20)},()=>lines[Math.floor(random()*lines.length)]).join(random()<.5?'\n':'\r\n');
assert.equal(actual(input),baseline(input),JSON.stringify(input));
}
const nativeShift=Array.prototype.shift;
function movement(fn,input){let movedSlots=0,shifts=0;Array.prototype.shift=function(){movedSlots+=Math.max(0,this.length-1);shifts++;return nativeShift.call(this)};try{assert.equal(fn(input),'Body');}finally{Array.prototype.shift=nativeShift}return {shifts,movedSlots};}
const scaling=[100,1000,10000].map(n=>{const input='# Plan\n'+'\n'.repeat(n)+'## Summary\n'+'\n'.repeat(n)+'Body';return {blankLines:2*n,baseline:movement(baseline,input),candidate:movement(actual,input)};});
console.log(JSON.stringify({exampleCases:examples.length,differentialCases:5000,scaling,note:'Moved slots are a source-level cost model for repeated Array.shift, not a wall-clock speedup.'},null,2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment