open-code-review/internal
Nefelibata 6612029127
Some checks failed
CI / cross-compile (arm64, linux) (push) Has been cancelled
CI / cross-compile (arm64, windows) (push) Has been cancelled
CI / test (push) Has been cancelled
CI / windows (push) Has been cancelled
CI / cross-compile (amd64, darwin) (push) Has been cancelled
CI / cross-compile (amd64, windows) (push) Has been cancelled
CI / cross-compile (arm64, darwin) (push) Has been cancelled
CodeQL Advanced / Analyze (go) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
fix(scan): join background memory compression before session finalization (#1026)
* fix(scan): join background memory compression before session finalization

* test(scan): exercise background compression join barrier in ScanAgent.Run

- Rewrite TestScanAgent_WaitBackground_NoLeakOnRun using a blocking compression client pattern
- Verify that ScanAgent.Run waits for in-flight memory compression before session finalization
- Assert that memory_compression_task is recorded and session_end is the final record in session JSONL
- Update Runner.WaitBackground doc comment in llmloop/loop.go to reflect scan mode usage

* style: format internal/scan/agent_test.go with gofmt -s

* test(scan): avoid premature cancel exit in blocking compression mock

* fix(test): eliminate race in WaitBackground regression test

The original test had two timing bugs that made it pass even when
WaitBackground() was removed:

1. The mock's round-2 response (task_done) could return before the
   background compression goroutine reached the mock, allowing Run to
   finish before 'started' was ever closed. Fix: round 2 now waits on
   <-c.started so the main loop cannot complete until compression is
   in-flight.

2. The 'select { default: }' check fires instantly — if Run hadn't
   returned YET (still in cleanup, not because WaitBackground held it),
   the test passed spuriously. Fix: use time.After(200ms) which is
   vastly longer than the sub-millisecond cleanup path, so Run will
   have returned if WaitBackground is missing.

Verified: test now correctly FAILs when WaitBackground is commented out
and PASSes when it is present.

---------

Co-authored-by: kite <lizhengfeng.lzf@alibaba-inc.com>
2026-08-22 10:58:55 +08:00
..
agent fix(agent): name the main-loop stop trigger in item failure reasons (#855) 2026-08-20 18:46:56 +08:00
config feat(language): add support for .ipynb files (#980) 2026-08-18 20:24:20 +08:00
delegate chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
diff fix(diff): re-file comments whose code lives in another file (#921) 2026-08-15 19:20:41 +08:00
gitcmd chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
llm test(llm): cover tool_choice mapping for all three provider protocols (#1011) 2026-08-20 11:04:22 +08:00
llmloop fix(scan): join background memory compression before session finalization (#1026) 2026-08-22 10:58:55 +08:00
mcp test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
model chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
pathutil test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
release chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
scan fix(scan): join background memory compression before session finalization (#1026) 2026-08-22 10:58:55 +08:00
session feat(config): resolve api_key/auth_token from a command (#236) (#605) 2026-08-17 14:40:37 +08:00
stdout fix(cmd): stream review progress to stderr for json and sarif (#929) 2026-08-19 19:05:53 +08:00
suggestdiff chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
telemetry refactor(telemetry): replace PrintTraceSummary positional params with TraceSummary struct (#909) 2026-08-15 12:19:28 +08:00
tool chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
viewer feat(config): resolve api_key/auth_token from a command (#236) (#605) 2026-08-17 14:40:37 +08:00