Skip to content

Commit de63b99

Browse files
committed
test(server): repoint the loopback-listener seam oracle at the serve-options leaf
tests/server/loopback-listener-integration.test.ts has a describe that reads src/server/index.ts as text for three properties with no runtime oracle on this Bun version. Two of them -- the explicit 127.0.0.1 binds for the loopback listener and the hub management ingress -- stayed in the composition root next to Bun.serve. The third, that the WebSocket upgrade uses the receiving server rather than the captured binding, moved with the fetch handler, so `requestServer.upgrade(req,` dropped to zero matches and `.toBe(3)` failed. The read now concatenates the facade and the serve-options leaf, which satisfies all three: 3 upgrade call sites, no `server.upgrade(req,`, and both binds. This is the third oracle this round that a literal path search did not find. It builds its path from `join(process.cwd(), "src", "server", "index.ts")`, so the candidate set my detector generated never reached src/server/index.ts. The three misses had three different shapes, which is the argument for not relying on a static detector: `bun run test:changed` found this one in 40 seconds against 2,249 tests, where the earlier two each cost a full CI round.
1 parent 523bfbf commit de63b99

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

‎devlog/_plan/260915_godfile_round5/061_server_index_outcome.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,27 @@ CI typecheck 가 잡았다. 이 워크트리에 node_modules 가 없는 한 이
4646
core.ts 쪽이 쓴 "모듈 목록 상수 + 목록과 import 그래프 일치 단언" 방식이 이 문제를 구조적으로 닫는다.
4747
다음 라운드는 그 방식을 먼저 쓴다.
4848

49+
50+
## 오라클 누락 세 번째, 그리고 방법을 바꾼 이유
51+
52+
`tests/server/loopback-listener-integration.test.ts` 의 "seams the runtime cannot defend" 가
53+
세 번째 누락이었다. `bun run test:changed` 가 40초에 잡았다.
54+
55+
이 오라클은 경로를 `join(process.cwd(), "src", "server", "index.ts")` 로 조립한다. 내가 만든 탐지기는
56+
문자열 리터럴을 뽑아 `src/` 를 붙여 해석해보는 방식이라 후보가 `index.ts`, `src/index.ts` 였고
57+
`src/server/index.ts` 에 닿지 못했다. bridge 때는 `repoPath("src", ...relative.split("/"))` 에,
58+
server/index 때는 같은 파일 안 다른 describe 에, 여기서는 다중 세그먼트 조립에 걸렸다.
59+
60+
세 번 다 형태가 다르다. 탐지기를 한 번 더 넓히는 것으로는 닫히지 않는다는 뜻이다. 실제로 닫는 방법은
61+
두 개뿐이었다.
62+
63+
하나는 `core.ts` 쪽이 쓴 방식이다. 모듈 목록을 상수로 두고, 그 목록이 실제 import 그래프와 같은지
64+
테스트가 단언한다. 목록에 없는 리프를 추가하면 그 테스트가 실패하므로 오라클이 조용해질 수 없다.
65+
66+
다른 하나는 `bun run test:changed` 다. 변경 파일의 import 그래프를 따라 테스트를 고르므로 어떤 형태로
67+
경로를 조립했든 그 테스트를 실행한다. 이번에 주 체크아웃의 `node_modules` 를 링크해서 처음 돌렸고,
68+
40초에 105파일 2,249개를 돌려 한 건을 찾았다. 앞선 두 번은 CI 한 바퀴(수십 분)를 태워서 알았다.
69+
70+
다음 라운드의 순서는 이렇게 고정한다. 링크를 먼저 걸고, 분해 직후 `test:changed` 를 돌리고,
71+
그 다음에 오라클 목록을 손으로 본다. 정적 탐지기는 보조 수단이지 1차 방어선이 아니다.
72+

‎tests/server/loopback-listener-integration.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,16 @@ describe("seams the runtime cannot defend", () => {
857857
// Two properties have no runtime oracle on this Bun version, and both would regress
858858
// silently. A source assertion is a weak instrument, but a weak instrument aimed at a known
859859
// blind spot beats none — the alternative is a comment nobody runs.
860-
const serverSource = readFileSync(join(process.cwd(), "src", "server", "index.ts"), "utf-8");
860+
// src/server/index.ts is a facade now. The three assertions below split across it and the
861+
// serve-options leaf: the upgrade call sites moved with the fetch handler, while both
862+
// explicit 127.0.0.1 binds stayed in the composition root next to Bun.serve. Read both.
863+
// Reading the facade alone would leave requestServer.upgrade at zero matches, and
864+
// `.toBe(3)` would fail on undefined rather than pass silently -- but the two bind
865+
// assertions would still hold, so only one of the three would have told us anything.
866+
const serverSource = [
867+
readFileSync(join(process.cwd(), "src", "server", "index.ts"), "utf-8"),
868+
readFileSync(join(process.cwd(), "src", "server", "index", "serve-options.ts"), "utf-8"),
869+
].join("\n");
861870

862871
test("the WebSocket upgrade uses the receiving server, never the captured binding", () => {
863872
// Swapping in `server.upgrade` stays green at runtime here: this Bun accepts an upgrade

0 commit comments

Comments
 (0)