Skip to content

Commit 3a3663f

Browse files
learn: retrospective learnings
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent 275c780 commit 3a3663f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎.claude/knowledge/learning-log.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,10 @@ until a human merges it. The engineer author phase reads this log (see
204204
- **Context:** PR #1019 made the kernel backend honor `use_cloud_fetch=False` by injecting `cloudfetch_enabled=false` into `session_conf`. The unit tests only checked that the key reached a fake `Session`. The reviewer noted that CI would stay green if the kernel or server stopped honoring the key. The fix added a credential-gated e2e test: it fetches a large result through a proxy that blocks non-workspace hosts, verifies every row with a digest, and runs an enabled-CloudFetch control to show the same query normally takes the cloud path.
205205
**Rule:** When a fix works by forwarding a config key that another component (kernel or server) must honor, unit tests that check forwarding are not enough. Add a live test that checks the actual behavior, and include a positive control showing the opposite setting changes the outcome, so the test can't pass vacuously.
206206

207+
### 2026-11-14: learnings since 2026-11-13T17:25:57Z
208+
- **Context:** PR #1055 replaced the layered telemetry no-op patches in the e2e retry tests (`tests/e2e/common/retry_test_mixins.py`). Patching `HTTPSConnectionPool._get_conn`/`_validate_conn` at class level also caught background telemetry and flush-thread requests, which inflated `call_count` and used up `side_effect` response lists. The fix makes the mock dispatch only on the calling test thread. Review then found a second leak: urllib3's `urlopen` hands the fake connection (and on 1.26 the result of `conn.close()`, which is a child mock) to the real `_put_conn`, so MagicMock connections landed in the shared pool queue. Real threads could pick them up later, including in later tests.
209+
**Rule:** When mocking urllib3 pool internals in tests, scope the mock to the test thread and patch both sides of the pool. Route `_get_conn` and `_put_conn` by thread so fake connections, their child mocks and `None` never reach the real `pool.pool` queue. Set the mocked `close()` to return `None` so urllib3 1.26's `conn = conn and conn.close()` path behaves like it does with a real connection. Prove the isolation with a shared-pool, concurrent-thread regression test, not separate pool instances.
210+
- **Context:** PR #1024 cached the result of `inspect.signature(_kernel.Session)` in a module-level global keyed on the `Session` class identity, filled under a double-checked lock. The reviewer pointed out that the tests only passed because each one installed a brand-new `Session` class. A test that reused a shared `Session` or patched only `inspect.signature` would quietly read a value cached by an earlier test, and `assert_called_once` checks would depend on test order.
211+
**Rule:** When adding a process-global cache (memoized introspection, singleton lookup), add an autouse fixture that resets it (`monkeypatch.setattr(module, "_CACHE", None)`) in the tests that exercise it. Each test should start cold instead of relying on cache-key changes to force a refresh.
212+
207213
--- *Add new entries above this line (oldest→newest); newest sections sort to the bottom.* ---

0 commit comments

Comments
 (0)