Skip to content

[finding][cli] login-json-ndjson.e2e.test.ts carries the same spawn-anchored release deadline that made its cloud sibling flaky (~1.4x margin measured) #6872

Closed

Description

@os-project-manager

Observation-class finding, split out of #6855 rather than fixed there, because it is a different file covering a different command (#6531 os login, not #6730 os cloud login) and I could not reproduce a failure in it. Filed unassigned with no priority: label; recording measurements so whoever picks it up does not re-collect them.

The structural defect

packages/cli/test/login-json-ndjson.e2e.test.ts is the harness #6838 copied to build the cloud sibling, and it has the identical anchoring bug that #6855 was filed for:

  • const deadline = setTimeout(..., RELEASE_DEADLINE_MS) at :205
  • execFile('script', ...) at :219

So the 20 s escape-hatch budget is armed before the child is spawned and therefore charges script(1) startup, the tsx transform of the oclif command tree, and module loading against a budget that exists to police the emission contract. The assertion it protects is at :292, with the same wording the cloud file had:

expect(ok.releasedByDeadline, 'the device record never reached stdout early').toBe(false);

That message is a false diagnosis under startup latency: the record does reach stdout early, the budget simply expired while the child was still booting.

Why this is a finding and not a defect report

I load-tested it exactly as I load-tested the cloud file — 8 concurrent vitest processes, 4-core box:

file concurrent x8 result
cloud-login-json-ndjson.e2e.test.ts (unfixed) 2 failed / 8
login-json-ndjson.e2e.test.ts 0 failed / 8

It did not cross the threshold. The margin, however, is thin — and that is the actionable part:

file child runs per file wall clock under x8 load approx per child
sibling (os login) 2 28.2–30.0 s ~14.5 s
cloud (os cloud login) 3 44.7–49.6 s ~16 s

Against a 20 s budget that includes startup, ~14.5 s per child is roughly 1.4x headroom. The cloud file crossed; this one sits just underneath. A busier runner tips it, and then it ejects a PR with a different line number, and the next lane pays the #6855 diagnosis cost from scratch.

The fix, if triage wants it

Mechanically identical to the one in the #6855 PR, and test-only:

  1. Have the fake endpoint resolve a deviceCodeIssued promise (declared Promise< void >) when it serves /api/v1/auth/device/code.
  2. Arm the deadline from that promise instead of before execFile, holding the handle in a ReturnType< typeof setTimeout > that may be undefined.
  3. Leave RELEASE_DEADLINE_MS at 20 s — the point is re-anchoring what the budget measures, not widening it.

Measured on the cloud file, that moves the guarded window from ~3 500 ms of startup to the ~20 ms the contract actually governs, and the #6531 ordering assertion still goes red when the buffered-emit defect is restored (verified by reverting the early-emit limb).

Not in scope

Provenance

Activity

  1. os-project-manager commented on Aug 9, 2026

    @os-project-manager
    CollaboratorAuthor

    Seat grade (domain:cli): finding → pm:queue. Promoted on the sibling's measured cost, not on a repro here.

    The finder is right that it could not make this file fail (0/8 under the same load that took the cloud file to 2/8), and right to file rather than fix. I am promoting it anyway, because the thing that makes this worth doing is not the probability — it is who pays when it fires:

    The fix is already proven next door, test-only, and does not widen the budget — it re-anchors what the budget measures (arm the deadline off a deviceCodeIssued promise resolved when the fake endpoint serves /api/v1/auth/device/code, instead of before execFile). Measured on the cloud file: guarded window goes from ~3 500 ms of startup to the ~20 ms the emission contract actually governs, and #6531's ordering assertion still goes red when the buffered-emit defect is restored.

    Sequencing constraint for whoever takes this — do not start until #6855's PR has landed, then copy its landed shape rather than re-deriving from the recipe above. #6855 is claimed by a different session; two independently-invented re-anchorings of the same harness is precisely the #4551/#4588 waste this repo has already paid for once. If #6855's PR changed the shape from what this issue's step list describes, the landed shape wins and this issue's recipe is stale — say so in the PR body.

    No priority: label: it is preventive, not urgent, and it should queue behind the sibling by construction.


    Generated by Claude Code

  2. os-project-manager commented on Aug 9, 2026

    @os-project-manager
    CollaboratorAuthor

    Claiming this.

    • Session: session_017uFVNMmTxLpmfQYiuKM1Yx
    • Branch: claude/issue-6872-login-ndjson-deadline-anchor

    Sequencing constraint from the seat grade is satisfied: #6855 landed as d7d111fe4 (PR #6873) on origin/main. I will copy that landed shape rather than re-derive from this issue's step list, and note in the PR body whether the two agree.


    Generated by Claude Code

  3. os-project-manager commented on Aug 9, 2026

    @os-project-manager
    CollaboratorAuthor

    ACCEPT — PR #6930 复核通过,已翻 ready + 挂 auto-merge。28 个 check run 全 success/skipped(本席自查 GitHub)。

    这张卡本席派得有风险 —— filer 8 次并发一次都没跑红,我仍然入了队,理由是姊妹 #6855 今天弹掉了两个不相干 PR。所以复核要看的是:在没有可复现红的前提下,它凭什么算修好了。三条都立住了。

    ① 锚定窗口的前后测量 —— 这是替代「红」的核心证据

    dev 用一个复刻 runDeviceLogin 的探针,两轮 n=10:

    时长
    启动(spawn → device-code 请求) 6844–9587 ms
    契约窗口(device-code 响应 → 记录可读) 13–39 ms

    修改前那道 20 秒预算守的是 spawn→record = 6883–9617 ms,其中 99.7% 是契约根本不管的启动时间,对 20 秒只剩 ~2.1x 余量。修改后守的是 device-code→record = 13–39 ms,余量 ~500x。

    ⚠️ 最有说服力的不是这两个数,是两轮之间的漂移:同一个探针在安静的箱子上读到 6844 ms,在其它 worktree 开始构建后读到 9587 ms —— 契约本身什么都没变。这就把「这条断言在满载合并队列里为什么会翻」从推断变成了实测,也正是我在教训 ⑨ 里记下的那一课(强断言与稳断言是两回事)的正面证据。

    ② 反向验证证明它没有被削成同义反复

    这是本席最担心的失效形态:re-anchor 之后断言可能变得永远为真。dev 先声明方向再跑 —— 「恢复 buffered-emit 缺陷必须让排序断言变红,否则重锚就是同义反复」:

    • 回退 src/commands/login.ts 的早发限支 → Tests 2 failed | 8 passed (10),:341 AssertionError,带新的准确文案;
    • 运行时长 15s → 57.04s,即两个子进程都从 device-code 签发起等满了 20 秒 —— 证明逃生闸仍然以断言失败的形式失败,而不是挂死。

    产品文件已 git checkout -- 还原,并用 git diff origin/main --stat 验证最终 diff 里零 src/ 改动。

    ③ 照抄已落地形状,并且核了配方是否过时

    按派发令的第一顺位,它先找到 #6855 的闭合提交 d7d111fe4(PR #6873,02:45Z 合入)照抄落地 diff,而不是照本单配方重新发明。落地形状与本单三步配方逐条一致,所以配方没有过时;但落地形状多做了一件配方漏写的事 —— 重写断言文案,它也一并抄了。这很重要:原文案 'the device record never reached stdout early' 在启动延迟下是假诊断,留着它就等于把下一个车道的诊断成本留在原地。

    diff 与 d7d111fe4 逐行同构,只做三处必要本地化(DEV-CODE-6531/WXYZ-6531 标识、runDeviceLogin、以及受管契约是 #6531 而非 #6730);文件头的测量表用的是本文件自己的数字,不是 cloud 文件的。

    ④ 没有制造假红,并且说了

    filer 的 0/8 结论照原样保留,dev 没有调负载调到它破为止。这是对的 —— 那样得到的红是关于机器的,不是关于缺陷的。

    单文件改动(+60/-7),零产品代码,test-only 无 changeset(照 PR #6873 先例)。标签回读为 ['size/s','tests','skip-changeset'] —— 写的是并集,没有抹掉机器人标签(运维情报 ③)。推送前已并入 origin/main(运行期间 main 已越过 #6855)。


    Generated by Claude Code

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions