oficina / equipo Public

Merge main into turn-batching

Brings in browser-timing (eaed1a1). budgets.txt: thintest test lines
to 13678, measured with both.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 32703b78927022032efcf1b6df7e089696d2b53b parent 72bf190parent eaed1a1
2 files changed, +76 −29
  • .rastrillo/budgets.txt +1 −1
  • internal/thintest/thinking_browser_test.go +75 −28

CI passed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 8bd63a33..735d6625 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -62,5 +62,5 @@ perf GET /conversation/attachments/{id}/preview skip Composer attachments: an im
perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section.
time cmd/equipo-runner 60s Mac runners slice B: TestReleaseRunnerHasNoFakeWorker builds the release runner exactly as make release-runner does and the thin package under the testbuild tag (measured 11.9s locally with a warm cache).
size internal/headless - 8523 Turn batching merged onto the browser lane: measured 8523. Turn batching adds TestHeadlessTurnBatching (three messages behind a slow turn through the real runner and fake CLI: the one next turn, its input, the bubbles and note, the usage rows and the spend lines) and TestHeadlessBatchAfterRefusedReply (the real runner reconnects after a refused reply), about 190 lines; measured 8518. Merge authority extends 4c_checks_card to end in Equipo's own merge, measured by the real runner, with its receipt (about 30 lines); measured 8330. Claude's sign-in by a link adds its end-to-end, contained-launch and real runner kill tests (signin_test.go, signin_contained_test.go, about 400 lines); measured 8090.
-size internal/thintest - 13631 Turn batching merged onto the browser lane: measured 13631. Turn batching adds its contracts (the crash between turns, the stranded recovery, failed, cancelled, interrupted and retried turns, the cancelled batch, the note clearing, batches split to fit one frame and the failed batch's note; about 430 lines); measured 13630 with the ship buttons merged. The ship buttons add their contract and browser tests (ships_buttons_test.go, ships_buttons_browser_test.go, about 190 lines); measured 13196. Merge authority merged onto Machines in Settings, with the re-run ruling's cases and stale thinking lines: measured 12998. Merge authority thin v1 adds its contracts (mergeauth_contract_test.go, about 650 lines) the protocol-aware rigs and the Mac re-run contract (macrecheck_mergeauth_contract_test.go) and the review fixes' contracts; measured 12535 with main merged. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Stale thinking lines merged onto Machines in Settings: measured 11967. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Stale thinking lines add their browser drive (stale_thinking_browser_test.go, about 200 lines) and the queued test now checks the note; measured 11795. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Spend 1 merged onto the four UI branches: measured 11325. Spend 1 marks overcounting Claude rows (about 120 lines); it adds the task page's spend contract and the 0059 upgrade (spend_pages_test.go, about 100 lines) and the fix round feedback by protocol (about 40); measured 10224. The team panel merged onto Projects UX and the Settings UX pass: measured 11064 with all three. The team panel adds its page contract and the drawer's browser drive at 1280 and 390 (team_panel_test.go, team_panel_browser_test.go, about 300 lines); measured 10235. Projects UX merged onto the Settings UX pass: measured 10768 with both. Projects UX adds the Projects page contracts (order, quiet fold, filter, stars and Undo, the coordinator's star, repository counts, whole words), the decision cards' Mac and Ask about this contracts and their browser drive (projects_pages_test.go, projects_browser_test.go, about 330 lines); measured 10321. The Settings UX pass adds the Settings pattern's page contracts and the savebar, Housekeeping groups and Teams browser drives (settings_ux_pages_test.go, settings_ux_browser_test.go, about 430 lines); measured 10390. Claude's sign-in by a link adds the code contract (signin_contract_test.go: the card, the code route's refusals, the wrong-code card, the kind it becomes and the canary sweep, about 220 lines); measured 9896. The Connections Add page and the Settings rail add their page contracts and the rail's browser drive (connections_add_pages_test.go, settings_rail_pages_test.go, about 230 lines); measured 9676. Claude setup tokens add the token and Check again contracts; measured 9444 with the composer and Mac lines merged. The instant thinking line adds its browser drive (instant_browser_test.go, about 230 lines); measured 9064 with the composer and Mac lines merged. Mac runners add the role, scoping, migration, placement, withdrawal, transfer and publication contracts (about 900 test lines) beside the thin v1 contracts; one package keeps one instance harness.
+size internal/thintest - 13678 Turn batching merged onto the ThinkingCycles clock fix (the drive takes a still clock and the page's record of each phrase, about 50 lines): measured 13678. Turn batching merged onto the browser lane: measured 13631. Turn batching adds its contracts (the crash between turns, the stranded recovery, failed, cancelled, interrupted and retried turns, the cancelled batch, the note clearing, batches split to fit one frame and the failed batch's note; about 430 lines); measured 13630 with the ship buttons merged. The ship buttons add their contract and browser tests (ships_buttons_test.go, ships_buttons_browser_test.go, about 190 lines); measured 13196. Merge authority merged onto Machines in Settings, with the re-run ruling's cases and stale thinking lines: measured 12998. Merge authority thin v1 adds its contracts (mergeauth_contract_test.go, about 650 lines) the protocol-aware rigs and the Mac re-run contract (macrecheck_mergeauth_contract_test.go) and the review fixes' contracts; measured 12535 with main merged. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Stale thinking lines merged onto Machines in Settings: measured 11967. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Stale thinking lines add their browser drive (stale_thinking_browser_test.go, about 200 lines) and the queued test now checks the note; measured 11795. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Spend 1 merged onto the four UI branches: measured 11325. Spend 1 marks overcounting Claude rows (about 120 lines); it adds the task page's spend contract and the 0059 upgrade (spend_pages_test.go, about 100 lines) and the fix round feedback by protocol (about 40); measured 10224. The team panel merged onto Projects UX and the Settings UX pass: measured 11064 with all three. The team panel adds its page contract and the drawer's browser drive at 1280 and 390 (team_panel_test.go, team_panel_browser_test.go, about 300 lines); measured 10235. Projects UX merged onto the Settings UX pass: measured 10768 with both. Projects UX adds the Projects page contracts (order, quiet fold, filter, stars and Undo, the coordinator's star, repository counts, whole words), the decision cards' Mac and Ask about this contracts and their browser drive (projects_pages_test.go, projects_browser_test.go, about 330 lines); measured 10321. The Settings UX pass adds the Settings pattern's page contracts and the savebar, Housekeeping groups and Teams browser drives (settings_ux_pages_test.go, settings_ux_browser_test.go, about 430 lines); measured 10390. Claude's sign-in by a link adds the code contract (signin_contract_test.go: the card, the code route's refusals, the wrong-code card, the kind it becomes and the canary sweep, about 220 lines); measured 9896. The Connections Add page and the Settings rail add their page contracts and the rail's browser drive (connections_add_pages_test.go, settings_rail_pages_test.go, about 230 lines); measured 9676. Claude setup tokens add the token and Check again contracts; measured 9444 with the composer and Mac lines merged. The instant thinking line adds its browser drive (instant_browser_test.go, about 230 lines); measured 9064 with the composer and Mac lines merged. Mac runners add the role, scoping, migration, placement, withdrawal, transfer and publication contracts (about 900 test lines) beside the thin v1 contracts; one package keeps one instance harness.
perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}.
diff --git a/internal/thintest/thinking_browser_test.go b/internal/thintest/thinking_browser_test.go
index 800935b3..10b389b5 100644
--- a/internal/thintest/thinking_browser_test.go
+++ b/internal/thintest/thinking_browser_test.go
@@ -7,7 +7,6 @@ import (
"encoding/json"
"fmt"
"testing"
- "time"
"amadan.net/oficina/equipo/internal/wire"
"github.com/chromedp/cdproto/cdp"
@@ -100,13 +99,18 @@ func TestBrowserThinkingWords(t *testing.T) {
// TestBrowserThinkingCycles: Paul, 2026-11-09: "They could swap a touch
// less frequently, they're a bit frantic. There needs to be many more per
-// category so it takes a while before I see the same ones again." With a
-// fake clock: a situation's first phrase holds about 5 s, then a new one
-// every 6 to 8 s; the phrases come from a shuffled deck, none again until
-// all have shown, across two turns (a reload keeps only localStorage);
-// after the deck runs out the next is none of the last three; a new
-// activity switches to its own phrases at once; under reduced motion the
-// words still change.
+// category so it takes a while before I see the same ones again." A
+// situation's first phrase holds 5 s, then a new one every 6 to 8 s; the
+// phrases come from a shuffled deck, none again until all have shown,
+// across two turns (a reload keeps only localStorage); after the deck runs
+// out the next is none of the last three; a new activity switches to its
+// own phrases at once; under reduced motion the words still change.
+//
+// The page's clock stands still but for the test (clock below): each
+// phrase is held to just under its minimum while the phrase timer looks,
+// then to its maximum. The page records each phrase it draws with its
+// clock, and the dwell rule is judged from that record, never from how
+// long the test waited, so a slow machine cannot make a phrase go early.
func TestBrowserThinkingCycles(t *testing.T) {
r := newToolRig(t)
words, _ := r.client.Thinking(r.ctx)
@@ -117,50 +121,92 @@ func TestBrowserThinkingCycles(t *testing.T) {
}
}
js := func(v any) string { raw, _ := json.Marshal(v); return string(raw) }
+ // The runner keeps reading, so it answers the instance's pings (a
+ // websocket answers only while it reads) and its stream outlives the
+ // ping deadline however slow the machine is; nothing it is sent
+ // matters here.
+ go func() {
+ for {
+ if _, _, err := r.runner.Conn.Read(r.ctx); err != nil {
+ return
+ }
+ }
+ }()
+ // clock: Date.now is base + skew, both kept in sessionStorage so a
+ // reload goes on from the same time; it moves only when the test
+ // moves it. The phrase timer (chat-stream.js turns phrases from a
+ // 250 ms interval) looks every 50 ms here, which changes no dwell (the
+ // dwell is read from the clock), and __ticks counts its runs, so the
+ // test knows the timer has looked at the clock it set. __drawn is each
+ // phrase drawn: its turn, its text and the clock when it came in.
+ const clock = `(()=>{const real=Date.now.bind(Date);window.__base=Number(sessionStorage.getItem('base'))||real();sessionStorage.setItem('base',window.__base);window.__skew=Number(sessionStorage.getItem('skew')||0);Date.now=()=>window.__base+window.__skew;` +
+ `window.__ticks=0;const every=window.setInterval;window.setInterval=function(fn,ms,...rest){if(ms===250&&typeof fn==='function'){const f=fn;fn=function(){try{return f.apply(this,arguments)}finally{window.__ticks++}};ms=50}return every.call(window,fn,ms,...rest)};` +
+ `window.__drawn=[];const once=new WeakSet();new MutationObserver(ms=>{for(const m of ms)for(const e of m.target.querySelectorAll('[equipo-phrase] > [data-in]'))if(!once.has(e)&&once.add(e))window.__drawn.push({turn:e.closest('[equipo-thinking]')?.dataset.turn,text:e.textContent,at:Date.now()})}).observe(document,{childList:true,subtree:true});})()`
for _, motion := range []string{"no-preference", "reduce"} {
p := openInner(t, r.inst.URL, r.inst.Cookie(), 390, 844, true, "dark", motion)
p.do(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
- _, err := cdp.Call(ctx, target, page.AddScriptToEvaluateOnNewDocument, page.AddScriptToEvaluateOnNewDocumentParams{Source: `(()=>{const real=Date.now.bind(Date);window.__skew=Number(sessionStorage.getItem('skew')||0);Date.now=()=>real()+window.__skew;})()`})
+ _, err := cdp.Call(ctx, target, page.AddScriptToEvaluateOnNewDocument, page.AddScriptToEvaluateOnNewDocumentParams{Source: clock})
return err
}))
p.open("/conversation")
line := `document.querySelector('[equipo-thinking][data-turn="` + r.turn + `"]')`
phrase := line + `?.querySelector('[equipo-phrase] [data-in]')?.textContent`
- advance := func(ms int) {
+ drawn := `window.__drawn.filter(d=>d.turn===` + js(r.turn) + `)`
+ // age: the page's clock to ms after the shown phrase came in, by
+ // the page's record.
+ age := func(ms int) {
t.Helper()
- p.check(fmt.Sprintf(`(()=>{window.__skew+=%d;sessionStorage.setItem('skew',window.__skew);return true})()`, ms), "advance the clock")
+ p.check(fmt.Sprintf(`(()=>{const d=%s;window.__skew=d[d.length-1].at-window.__base+%d;sessionStorage.setItem('skew',window.__skew);window.__looked=window.__ticks;return true})()`, drawn, ms), "set the clock")
+ }
+ var seen []string
+ first := func(what string) {
+ t.Helper()
+ p.wait(js(think)+`.includes(`+phrase+`) && `+drawn+`.length>0`, what)
+ seen = append(seen, eval[string](p, phrase))
}
- p.wait(js(think)+`.includes(`+phrase+`)`, "the first thinking phrase")
- seen := []string{eval[string](p, phrase)}
- // The pace: the first holds past 4.5 s and goes by 5.5 s; then each
- // holds past 5.8 s and goes by 8.2 s.
+ // holds: at ms, once the phrase timer has looked, the same phrase.
holds := func(ms int, what string) {
t.Helper()
- advance(ms)
- time.Sleep(600 * time.Millisecond)
+ age(ms)
+ p.wait(`window.__ticks>window.__looked`, "the phrase timer looked")
p.check(phrase+`===`+js(seen[len(seen)-1]), what)
}
next := func(ms int) {
t.Helper()
- advance(ms)
+ age(ms)
p.wait(phrase+`!==`+js(seen[len(seen)-1])+` && `+js(think)+`.includes(`+phrase+`)`, fmt.Sprintf("phrase %d", len(seen)+1))
seen = append(seen, eval[string](p, phrase))
}
- holds(4500, motion+": the first phrase went before 5 s")
- next(1000)
- for i := 0; i < 3; i++ {
- holds(5800, motion+": a phrase went before 6 s")
- next(2400)
+ // cycle: the next phrase, held past just under 6 s, gone by 8 s.
+ cycle := func() {
+ t.Helper()
+ holds(5999, motion+": a phrase went before 6 s")
+ next(8000)
+ }
+ // dwelt: the page's record of this page's phrases is seen[from:],
+ // in order; the first came in 5 s after the one before it, each
+ // later one 6 to 8 s after.
+ dwelt := func(from int) {
+ t.Helper()
+ if bad := eval[string](p, `(()=>{const d=`+drawn+`,want=`+js(seen[from:])+`;if(JSON.stringify(d.map(x=>x.text))!==JSON.stringify(want))return 'drawn '+JSON.stringify(d.map(x=>x.text));for(let i=1;i<d.length;i++){const g=d[i].at-d[i-1].at,min=i===1?5000:6000,max=i===1?5000:8000;if(g<min||g>max)return 'phrase '+(i+1)+' came '+g+' ms after the one before'}return ''})()`); bad != "" {
+ t.Fatalf("%s: %s", motion, bad)
+ }
}
+ first("the first thinking phrase")
+ holds(4999, motion+": the first phrase went before 5 s")
+ next(5000)
for len(seen) < 20 {
- next(8100)
+ cycle()
}
+ dwelt(0)
// A new turn: the page again, nothing kept but localStorage.
p.do(chromedp.Reload())
- p.wait(js(think)+`.includes(`+phrase+`)`, "the thinking phrase after the reload")
- seen = append(seen, eval[string](p, phrase))
+ from := len(seen)
+ first("the thinking phrase after the reload")
+ holds(4999, motion+": the first phrase after the reload went before 5 s")
+ next(5000)
for len(seen) < len(think) {
- next(8100)
+ cycle()
}
distinct := map[string]bool{}
for _, s := range seen {
@@ -171,12 +217,13 @@ func TestBrowserThinkingCycles(t *testing.T) {
}
// The deck ran out: the next is none of the last three.
last := seen[len(seen)-3:]
- next(8100)
+ cycle()
for _, l := range last {
if seen[len(seen)-1] == l {
t.Fatalf("%s: %q again straight after the deck ran out", motion, l)
}
}
+ dwelt(from)
// A new activity: its own phrases at once.
if err := r.runner.Send(r.ctx, "cyc-read-"+motion, wire.FrameActivity, wire.ActivityReport{TurnID: r.turn, Attempt: 1, Kind: wire.ActivityTool, Tool: wire.ToolReadFile}); err != nil {
t.Fatal(err)