Skip to content

test(service-automation): stub the host lookup in the http-nodes failed-call suite - #38147

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-38126-http-nodes-dns-stub
Nov 28, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-38126-http-nodes-dns-stub

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Fixes #38126
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户无感:只改了自动化服务里一个测试文件,产品代码与线上行为都不变。
  • 为什么做:消除一个偶发失败的测试,它依赖真实域名解析,CI 上解析慢时会超时变红。
  • 出错会怎样:最坏是这个测试本身再变红,不影响任何用户,可以直接撤回。
  • 要你做什么:无。

What changes

packages/services/service-automation/src/builtin/http-nodes.test.ts only (+25 / -3). In the describe http (canonical node) — a failed call names its host and cause, run() no longer falls back to defaultEgressGuard() (whose resolver is the real dns.promises.lookup). It hands the node the real egress guard, createEgressGuard({ policy: createEnvEgressPolicy({ allowedTargets: '127.0.0.1' }), resolve }), through the existing registerHttpNodes(..., { egress }) seam and the guard's own resolve option (documented "DNS override (tests)"; same pattern as http-node-egress-guard.test.ts). The stub resolver answers an ENOTFOUND-shaped error for no-such-host.invalid and throws on any other name; it records every name asked.

  • The refusal text assertion and the "nothing of the lookup" assertion (not.toContain('ENOTFOUND')) are unchanged.
  • The two cases that name no-such-host.invalid (unknown host; path/query/userinfo secrets) now also assert the stub answered the lookup (lookups equals ['no-such-host.invalid']).
  • ECONNREFUSED and timeout cases stay real undici against a real loopback socket: an IP literal never reaches the resolver.
  • No product change: http-nodes.ts and the egress guard are untouched.

Every other case in the file was checked for a host lookup: example.test / api.test cases use stubbedFetchEgress() or the durable outbox (no fetch); example.invalid in the missing-url case never sends. The DNS-off run below records zero lookups for the whole file.

Tests

  • http-nodes.test.ts: 19/19 passed, normally and with DNS disabled.
  • Control on origin/main's version with every name lookup made to hang (the CI shape): the two cases time out at 5000 ms, two lookups of no-such-host.invalid recorded.
  • Ablation: stub resolving no-such-host.invalid to a public address (93.184.215.14) turns both cases red; restored byte-identical.
  • Package: @objectstack/service-automation typecheck (incl. check:test-typecheck) green; full vitest 297/297 files, 4342/4342 tests.
DNS-off evidence (a preload hook records and then hangs or fails every non-IP lookup)
# origin/main version, DNS_HOOK=hang
× an unknown host reads the refusal ... 5003ms   Error: Test timed out in 5000ms.
× never names the path, query secret or userinfo of the url 5002ms
Tests  2 failed | 17 passed (19)
lookups: dns.promises.lookup no-such-host.invalid (x2)

# this branch, DNS_HOOK=hang and DNS_HOOK=fail
Test Files  1 passed (1)   Tests  19 passed (19)
lookups recorded: 0
Ablation (scripts/ablation-replace.mjs, anchor x1 -> x0, restored blob == HEAD blob)
× an unknown host reads the refusal ... 23ms
  AssertionError: expected 'Node \'http\' failed: HTTP 403' to match /http: EGRESS_REFUSED: /
× never names the path, query secret or userinfo of the url 14ms
  AssertionError: expected 'Node \'http\' failed: HTTP 403' to contain 'no-such-host.invalid'
Tests  2 failed | 17 passed (19)
restore: blob a5bbfa63edd6 == HEAD

Acceptance notes

  • skip-changeset: test-only diff. files[] is dist, README.md, CHANGELOG.md; after a build, the new test symbols have zero hits in dist/, and the positive control (defaultEgressGuard) has hits.

Verification

Read first: http-nodes.test.ts around the stubbedLookupEgress() helper (the only risky hunk: the default egress for run() changed).

Two-minute check: pnpm --filter @objectstack/service-automation exec vitest run --maxWorkers=2 src/builtin/http-nodes.test.ts with networking off; expect 19 passed.

Local gates at fc05d4e (derived list, dispatch-gates --ran: 53 derived, 52 run, 1 NOT MEASURED)
  • 52 derived families exit 0 (incl. check:nul-bytes, check:cross-package-test-inputs, check:test-source-alias, check:type-check-coverage, check:type-check-debt, check:issue-citations).
  • NOT MEASURED: check:dual-build-cjs-loads, exit 3 PREREQUISITE NOT MET (needs a whole-workspace dist/; this diff changes no built output). CI runs it.
  • overlap-check.mjs: VERDICT clean exit 0 (origin/main merges cleanly, 0 overlapping PR heads).
  • Everything else (repo-wide check:*, Test Core, Build Core, type-check lanes): CI's.

Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW

…ed-call suite

The unknown-host and url-secrets cases resolved no-such-host.invalid through
the real resolver; on a slow resolver the lookup outlasted the 5000 ms test
timeout. The suite now hands the real egress guard a resolver that answers
ENOTFOUND for that one host and fails on any other name, so the file makes
no DNS query. Refusal text and the nothing-of-the-lookup assertion unchanged.

Claude-Session: https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 581ae76a23c6b3ba8e2b69e7d8a920838bc51194 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4cxRDKprCtjpEdtiPFW

L1 verdict: ACCEPT (in-area self-review, area-lease.md 送审: ≤50 lines, test only, Clause-②: no) and landing · 2026-11-28T04:53Z · Head-sha fc05d4e861829a2b7a0749eb743bf4a63d03b91b (Fixes #38126)

  • Shape: one file, packages/services/service-automation/src/builtin/http-nodes.test.ts, +25/-3. check-governed-merges NOT governed. Checks: 37 succeeded, 21 expected skips, 0 failed. No product source.
  • Changeset (l1-face flag, judged): skip-changeset is right. @objectstack/service-automation ships files: ["dist", "README.md", "CHANGELOG.md"]; the diff is one *.test.ts, and the dev read the new test symbols at 0 hits in a built dist/ against a positive control of 2 (os-dev report, flake: service-automation http-nodes「unknown host」用例依赖真实 DNS 查询,CI 上 5000ms 超时 #38126 comment 7234032955).
  • Read: the suite's run() now hands the real egress guard (createEgressGuard + createEnvEgressPolicy) a resolve stub through the existing { egress } seam; the stub answers ENOTFOUND for no-such-host.invalid only and throws on any other name. The refusal-text assertion and not.toContain('ENOTFOUND') are unchanged; both unknown-host cases now also assert the stub answered. IP-literal cases (ECONNREFUSED, timeout) stay real undici.
  • Evidence (report): with DNS hung by a preload hook, origin/main's file reproduces the card's two 5000 ms timeouts; this head passes 19/19 with 0 real lookups. Ablation (stub resolving to a public address) reds both cases with HTTP 403; restored to the head blob.
  • Action: ready and auto-merge, by area o1-F.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 28, 2026 04:53
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 28, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4cxRDKprCtjpEdtiPFW

Queue ejection receipt and one re-enqueue · 2026-11-28T05:35Z · Head-sha fc05d4e861829a2b7a0749eb743bf4a63d03b91b (unchanged; Fixes #38126)

@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 46112924199 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Dogfood Regression Gate (2/3) — 失败步骤: Boot example apps and exercise real user flows

    @objectstack/dogfood:test:  FAIL   isolated  test/approval-decide-over-mcp.dogfood.test.ts > an approver's agent decides a pending approval request over MCP (#32442) > ⭐ a member on no slate is refuse
      ↳ 失败原因: @objectstack/dogfood:test: AssertionError: {
    @objectstack/dogfood:test:  FAIL   isolated  test/approval-decide-over-mcp.dogfood.test.ts > an approver's agent decides a pending approval request over MCP (#32442) > ⭐ [#33690] the approver's call d
      ↳ 失败原因: @objectstack/dogfood:test: AssertionError: {
    @objectstack/dogfood:test:  FAIL   isolated  test/approval-decide-over-mcp.dogfood.test.ts > an approver's agent decides a pending approval request over MCP (#32442) > ⭐ [#33690] the submitter's recal
      ↳ 失败原因: @objectstack/dogfood:test: AssertionError: {
    @objectstack/dogfood:test:  FAIL   isolated  test/mcp-system-object-action-exposure.dogfood.test.ts > [#27681, #27900] sys_user identity actions over MCP: what each bucket's declaration lets an agent 
      ↳ 失败原因: @objectstack/dogfood:test: AssertionError: {
    @objectstack/dogfood:test:  FAIL   isolated  test/mcp-system-object-action-exposure.dogfood.test.ts > [#27681, #27900] sys_user identity actions over MCP: what each bucket's declaration lets an agent 
      ↳ 失败原因: @objectstack/dogfood:test: AssertionError: {
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 38 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flake: service-automation http-nodes「unknown host」用例依赖真实 DNS 查询,CI 上 5000ms 超时

2 participants