Commit Graph
2 Commits
Author SHA1 Message Date
JoeyWu-tech b8de6e5afd agent: TestCodexDriftReached and TestCodexBehindReverseProxy read Codex's log again after each request they log (#3398)
codexReached keeps its read of Codex's log while the database and its
-wal keep their size and modification time (84210ae7, #1665), for up to
reachedFor (15s). Both tests insert a request into logs_2.sqlite and ask
Drift at once, three or four times over. Two inserts inside one tick of
the file system's clock leave that stamp as it was, so Drift answers
from the read taken before the second insert. On this Linux box (ext4
under /tmp), 317 of 400 back-to-back inserts left a rollback-journal
database's size and time unchanged; in WAL mode 156 of 400 did, once
the -wal had wrapped and was written over in place. Codex's own
logs_2.sqlite here is WAL, with a -wal that stays at 4.4 MB.

On b437e4ad, -count=60 of the two tests:
  TestCodexDriftReached red 11 times
    applied_test.go:280: elsewhere: &{Kind:bypassed ... Detail:Codex couldn't reach magpie at 09:46 — magpie wasn't running then, ...} (5)
    applied_test.go:284: reached magpie: &{Kind:bypassed ... Detail:Codex's last request (09:46) went to chatgpt.com, not magpie — ...} (6)
  TestCodexBehindReverseProxy red 2 times
    proxy_kept_test.go:293: to chatgpt.com: <nil>
Both tests are older than the memo; before it, each ask opened the log.

These tests are about what Drift says of each kind of request. When the
log is read again is TestCodexReachedReadsLogOnlyWhenItChanged's to
test. So each request they log now drops the kept read
(forgetReached), and the next ask reads the log.

What was run (tree d5c248e9, on b437e4ad):
  the tick injected: after each insert, the database's time set back
  to what it was before the insert (os.Chtimes), so every insert keeps
  the stamp. -count=20 of both tests:
    without this change: both red 20 of 20, at the elsewhere check
    (applied_test.go:280) and the to chatgpt.com one
    (proxy_kept_test.go:293)
    with it: ok
  -count=200 of TestCodexDriftReached, TestCodexBehindReverseProxy and
  TestCodexReachedReadsLogOnlyWhenItChanged: ok
  broken by hand, with this change:
    codexReachedRead never records a refusal:
      applied_test.go:277: refused: <nil>
    applied.go's went-elsewhere case off:
      applied_test.go:281: elsewhere: <nil>
      proxy_kept_test.go:294: to chatgpt.com: <nil>
  gofmt -l internal/agent: nothing
  GOOS=linux, darwin, windows go vet -tags nogui ./internal/agent: exit 0
  full suite, go test -tags nogui -count=1 -timeout 45m ./... (481s):
  62 packages ok, the two tests above with them. 14 reds in 7
  packages, none in a file this change touches, each red on b437e4ad
  without it:
    internal/agent TestInstalledVersion, TestHowInstalled,
    TestOmpDetectedWithPiDir, TestCopilotFolderFromAnIDEPluginIsNotTheCLI
    and TestZedAppPath: proc.Look keeps "not found" for a tool written
    in the tick of its folder's last change (#3141). Alone on b437e4ad,
    -count=10: TestHowInstalled red 3 times, TestZedAppPath 7.
    internal/agent TestReasonixCLIRequiresSupportedNativeVersion and
    TestReasonixCLIRecoversAfterProbeTimeout: their fixture build under
    /tmp meets a /tmp/.git that isn't a repository of this user's
    ("error obtaining VCS status: exit status 128").
    internal/claudebridge TestCallbackGoesPastTheAgentsProxy,
    internal/gateway TestClaudeToolCallbackOnANonLoopbackAddress,
    internal/gui TestGatewayHeldByAContainer and
    TestGatewayFixQuitsOnlyAMagpie: the processes this run started had
    their outgoing connections sent through a proxy (graftcp).
    internal/edit TestWriteAtomicReadOnlyHardLink and internal/testenv
    TestProgram: umask 077 here; the fixtures' own modes go through it
    (0444 is written as 0400).
    internal/netproxy TestBunProxyLoginWithReservedCharacters: Bun
    1.3.11 on PATH names port 80 in the request line (#3397).

Not changed:
  - The memo. In the app, a request Codex logs inside the tick of
    magpie's last read (a connect and its refusal one after the other)
    can reach Drift up to reachedFor late, which the memo allows for
    already. A settle window like filememo's or codex_list_tag's would
    see it at once, at the cost of a read per ask just after each of
    Codex's writes, the reads #1665 took out.
  - The fixtures' journal mode. A WAL fixture would pass these tests
    only while its -wal grows, which stops once it wraps.

Landed by yetone in a batch of Coffemon's patches from the issues.
What was run, go1.26.8, on origin/main cc81ad4ea, then again at
70a0c387c (gofmt, the three vets, the changed tests, umask 077):
- mote (macOS 27): gofmt -l clean; go vet, GOOS=linux go vet -tags
  nogui and GOOS=windows go vet ./...: ok. edit and testenv at umask
  077; agent, provider, library and gateway with an empty .git above
  TMPDIR; davsync, imagemcp, plugin, library, edit, testenv whole; the
  changed tests in agent, provider, gateway and gui; the timing tests
  -count=10 (gateway, davsync, imagemcp) and -count=5 (agent): all ok.
  TestCoreScriptBudget ok: core 1,536,751 of 1,537,034, app.js
  1,312,975 of 1,315,316, no budget raised.
- Red on the old code: on origin/main, TestWriteAtomicReadOnlyHardLink
  at umask 077 and two Reasonix tests under an empty .git; on Linux
  (wsl-run) TestProgram at umask 077 with the old program.go. With
  each fix's code taken back to main's, the Gemini imageConfig tests,
  TestPluginToldWhereTheAgentWorks, TestSkillRepoTraced,
  TestTaggedHooksAlone, TestMainURL/TestMainView and update-auto,
  plugin-github-hooks, plugins-more-discover, plugin-namesake were
  red. Broken by hand: claudeKeyed always true (both
  OwnEndpointNeverAsked tests red), claudeAsk a no-op
  (TestClaudeFirstWriteAsksTheProxy red), GitAt taking any .git folder
  (the three TestGitOnDisk tests red).
- GUI: 123 files (plugins*, update-*, panel/tray/start/context, i18n,
  gui-zh-tw/ja/de and every file that evals app.js parts) in WebKit on
  Linux (wsl-run). 11 files had reds (click-scroll, panel-fold,
  plugin-card-update, plugin-github, plugin-move*, segs-glide,
  tray-totals, update-*), and run again side by side they fail the
  same on origin/main d80d75f30 (79 pass, 26 fail here; 78 and 27
  there). They are click-scroll guards ("the click must not scroll
  the page"), varying by language from run to run (#4385).
  copilot-ghe's route-after-close red is #1949, seen on main 244d80e23
  too. In Chromium on mote, Chromium segfaulted partway through files
  (#4125): context-map, context-scroll-end and context-tune fail the
  same on origin/main 0911a65e7, so the batch's own files
  (plugin-namesake, update-auto, plugins-more-discover,
  plugin-github-hooks) ran in Chromium on Linux: 62 of 62.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./..., mote)
  at 472a0608f (on 70a0c387c): every package ok but internal/gateway,
  whose five reds were #4362's (Antigravity turned-away and
  TestCodexSpentGrokFailingIsTold), fixed on main in d80d75f30. After
  the rebase on 244d80e23 the five pass, and gofmt, the three vets
  and the targeted runs above were run again: ok. In Linux the
  sign-in, copilot, plugin-github*, plugins-more-discover,
  plugin-namesake, plugin-gateway, update-auto, quota-refresh-order
  and i18n files ran in both engines: 475 pass, 4 fail (copilot-ghe
  #1949, plugin-github's click scroll, both red on main too).
- Rebased again on c7171a256, over its budget fix e94bf7a08: gofmt, vet of
  gui, gateway, provider and plugin, TestCoreScriptBudget (core
  1,536,265 of 1,536,586 with the batch's last commit, statusTErr and settingsErr), the Gemini,
  GitOnDisk and plugin tests, and in Linux both engines i18n-keys,
  update-mirror, plugin-namesake, plugins-more-discover,
  plugin-github-hooks and update-auto (138 of 138): ok.
Not tried: the whole GUI suite (mote's WebKit wouldn't launch and its
Chromium segfaulted, #4125); macOS WebKit; the real app's window.
2026-10-30 15:53:22 +08:00
yetone 84210ae7bd agent: Codex's log database is read again only when it or its -wal changed
#1665, owner's item 2: codexReached opened Codex's logs_*.sqlite on
every ask, and every Drift asks it. The report's trace shows ~2465 reads
of logs_2.sqlite in 25s of a Windows start. The read is now kept per
Codex folder. The key is the database path, the since day, and the size
and modification time of the database and its -wal. A kept read stands
for at most 15s, so a file system with coarse times can't hide a write
that kept the size. A hit older than 24h is never kept, since it falls
out of the window being read. In an interposed sandbox start, opens of
logs_2.sqlite went from 6-8 per run to 4.

TestCodexReachedReadsLogOnlyWhenItChanged asks 50 times and expects 1
read. It then writes to the log and expects a fresh read that sees the
write. With the cache check turned off by hand, it goes red:
  --- FAIL: TestCodexReachedReadsLogOnlyWhenItChanged (3.23s)
      codex_reached_test.go:50: 50 asks read the log 50 times, want 1

Owner's item 3: the PATH x PATHEXT lookup cache, 8bfe33f1f (#1771), is
an ancestor of this commit and shipped in v0.1.1214. The reporter's
trace was taken on v0.1.1212.

What was run (worktree at 9fd80b212 plus this change and the commits
before it):
  gofmt -l internal/: nothing
  go vet ./internal/agent: exit 0
  GOOS=linux go vet -tags nogui ./...: exit 0
  GOOS=windows go vet -tags nogui ./...: exit 0
  go test -timeout 45m -count=1 ./internal/agent: ok 2591.806s
2026-10-20 20:23:55 +08:00