open-code-review/internal/scan
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.go fix(scan): join background memory compression before session finalization (#1026) 2026-08-22 10:58:55 +08:00
agent_test.go fix(scan): join background memory compression before session finalization (#1026) 2026-08-22 10:58:55 +08:00
batch.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
batch_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
budget_exceeded_test.go feat(scan): report token budget stop in JSON summary.budget_exceeded (#791) 2026-08-16 19:21:18 +08:00
budget_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
coverage_test.go fix(scan): persist safe dedup checkpoints on resume (#1035) 2026-08-22 10:09:50 +08:00
dedup_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
estimate.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
estimate_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
getters_more_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
getters_test.go feat(scan): report token budget stop in JSON summary.budget_exceeded (#791) 2026-08-16 19:21:18 +08:00
init_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
preview.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
provider.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
provider_more_test.go feat(config): resolve api_key/auth_token from a command (#236) (#605) 2026-08-17 14:40:37 +08:00
provider_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
retry_identity_test.go Feat/llm retry report:SDK retry-attempt observability for review (#785) (#790) 2026-08-13 14:31:18 +08:00