Skip to content

[PR] batch-6: 4 low-risk community fixes (verbatim --no-ff merges, authorship preserved) - #7412

Merged
ranxianglei merged 8 commits into
masterfrom
batch/afloat16-b6-2026-11-20
Nov 20, 2026
Merged

ranxianglei merged 8 commits into
masterfrom
batch/afloat16-b6-2026-11-20

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

batch-6: 4 low-risk community fixes (verbatim --no-ff merges, authorship preserved)

One batch PR carrying 4 independently-reviewed, self-contained fixes by Afloat. Each is a scoped bugfix with a regression test — no design-level change, no hot-path/core file touched (URL masking, diagnostics, one report exporter).

This is batch-6 of the layered split that began with batch-5 (#7392, merged): the small, isolated fixes come here in one reviewable unit; the remaining load-bearing ones (loop adapters / billing / storage / session-gc / persistence / keepalive, plus relay.ts/stream-io.ts/plugin.ts hot paths) stay separate so each gets its own focused review.

How the merges preserve authorship (and auto-close the source PRs)

Each PR is brought in with git merge --no-ff <its head> — the original commit SHAs, author (Afloat), dates, messages, and content are preserved verbatim in this branch's history (not squashed, not cherry-picked). Because each source PR's head commit becomes an ancestor of master once this lands, GitHub flips all 4 source PRs to "merged" automatically — no manual closing, no duplicate landings.

What's in it (4)

PR Issue What it fixes (plain language)
#7393 #7391 The shared URL maskers restarted their scheme scan at every letter of a long unbroken non-URL run, so masking a 40,000-char run took ~384 ms synchronously (blocking logging/diagnostics and the anonymous-session provenance preview). The scan now starts once per contiguous scheme-character run; all masking output is byte-identical (verified across 120,720 comparisons).
#7397 #7396 The loopback display exemption matched any 127.-prefixed string, so private DNS names like 127.customer.internal leaked through diagnostic URLs, host-event files, and 502 upstream-failure responses even with host masking on. Only a real 127/8 IPv4 loopback literal is now exempt. ⚠️ model-facing text change: the visible failure host now shows the masked form (acp-proxy failure: dns ENOTFOUND <private-host>:8443), not the private name.
#7400 #7399 Incident-dump files (main-path + preflight-summary) were named only by timestamp + session + status, and a plain writeFileSync overwrote an earlier incident when those values collided — silently losing evidence that is explicitly protected from retention GC. Both writers now create the file exclusively; only on EEXIST do they fall back to a UUID-suffixed name.
#7404 #7403 The SVG cache-ledger report fed every trajectory sample into Math.max.apply, so a legitimate 200,000-sample history threw RangeError: Maximum call stack size exceeded before the report could be downloaded (three more extrema calls in the recovery chart had the same ceiling). Those maxima/extrema are now computed with reductions; every sample still renders.

著作权 (authorship)

All 4 source PRs are by Afloat (ShuffleMonkey@163.com); their original commits are preserved verbatim via git merge --no-ff (author, date, message, content intact). 8 files changed, +388 / −26, 4 merge commits. No conflicts at assembly time (the single intra-batch overlap — src/log-mask.ts from #7393 + #7397 — merged cleanly).

Verification

  • tsc --noEmit + npm run build: clean (dist import / external / thin checks OK).
  • All 5 test files these 4 PRs touch (log-mask-linear, issue5795-early-hold-fastpath, loopback-diagnostic-hosts, error-dump-collision, session-report): 54 pass / 0 fail.
  • [PR] fix: validate diagnostic loopback host exemptions #7397 is the only model-facing change (visible failure host is now masked) — flagging for review attention; status/kind/code and retry behavior are unchanged.
  • Authoritative full-suite judgment + real-model release gate is delegated to GitHub CI on this head.

After this merges

The 4 source PRs — #7393 #7397 #7400 #7404 — land with content identical to theirs and will auto-flip to "merged" (their head commits are ancestors of master). Nothing needs manual closing.

Fixes #7391, fixes #7396, fixes #7399, fixes #7403.

Afloat16 and others added 8 commits November 20, 2026 17:58
⚠️ MODEL-FACING TEXT CHANGE
Failure-response host fields now mask 127-prefixed DNS names and keep a
portless IPv6 loopback intact. Status, failure kind, code and retry policy
are unchanged; the exact visible 502 error is covered by a regression.

Require actual IPv4 loopback addresses instead of accepting any 127.
prefix. Retain Node's numeric IPv4 aliases after syntax validation and
canonicalization. Split bracketed display targets after their closing
bracket so an address colon is never mistaken for a port separator.

The unchanged base fails six behavior regressions with two controls passing.
The fix passes 52 focused tests, typecheck, build and both static gates.
Create incident files exclusively so repeated same-millisecond failures,
sanitized session-name collisions, and existing files cannot lose earlier
evidence. Keep the historical filename when available; on EEXIST use a
bounded session hint and a UUID suffix, again with exclusive creation.

Use the same writer for main and preflight-summary failures. Other I/O
errors retain the existing fail-soft warning/null behavior. The plaintext
banner, byte limits and protected GC prefixes are unchanged.

Seven regression failures on the unchanged base become passing, alongside
the write-error control and existing dump/GC coverage (30 tests total).
Typecheck, build, unused-export and import-graph gates pass.
Reduce trajectory and recovery-window extrema without expanding retained
ledger samples into individual function arguments. Preserve every plot
point, reference axis, recovery floor and outlier threshold.

The unchanged base fails both 200,000-sample regressions; the fixed branch
passes all 15 report and large-ledger tests, typecheck, build and static
gates. This follows the separate cache-bucket fix in #6689; the SVG
exporter's extrema were not covered there.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: batch/afloat16-b6-2026-11-20 (bc48307)

Latest build — install this exact version

npm install -g billion-context@0.0.11103-pr.7412.c71c221

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
bc48307 billion-context@0.0.11103-pr.7412.c71c221 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr7412.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title batch-6: 4 low-risk community fixes (verbatim --no-ff merges, authorship preserved) [PR] batch-6: 4 low-risk community fixes (verbatim --no-ff merges, authorship preserved) Nov 20, 2026
@ranxianglei
ranxianglei merged commit b10c1a0 into master Nov 20, 2026
84 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1241-master.b10c1a0 (rolling master tag).

npm install -g billion-context@0.0.1241-master.b10c1a0  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: qwen/qwen3.8-27b)

查重: 不重复。这是 batch-6 批次 PR(GitHub #7412),把 4 个已独立 review 的社区 fix(#7393/#7397/#7400/#7404)用 git merge --no-ff 原样并入。4 个源 PR 均为 Afloat 的独立 PR,合入后其 head commit 成为 master 祖先,会自动翻转为 merged,不重复落地。与已合入的 batch-5(#7392)同结构,无并列重复 PR。

Review 结论:可合(待 CI 测试分片跑绿)。 4 个 fix 逐一审过——逻辑正确、测试有牙、diff 干净、作者署名保留、唯一的 model-facing 文本变更已披露。

What I verified (independent of the PR's own claims):

  • Code (all 4):
    • [PR] fix: avoid repeated scheme scans in URL masking #7393 URL-mask: the new regex (?<![a-z0-9+.-])([0-9+.-]*)([a-z][a-z0-9+.-]*:\/\/[^\s"'<>]+) adds a negative lookbehind so the engine attempts a match only at the START of each scheme-char run (not every letter) → O(N²)→O(N). The ([0-9+.-]*) prefix group keeps the non-letter prefix outside the masked URL, so output stays byte-identical. I traced xhttps://, 123abc://, 99ABChttps://, 123://not-a-scheme — same match as the old regex.
    • [PR] fix: validate diagnostic loopback host exemptions #7397 loopback: isLoopbackIp no longer exempts any 127.-prefixed string — only a real IPv4 loopback literal (isIpv4Literal) or a Node-normalized numeric alias resolving to 127/8. maskHostPortForDisplay now splits bracketed IPv6 at indexOf(']')+1 (old lastIndexOf(':') landed inside [::1]). The 502 failure host now renders masked — the disclosed model-facing change.
    • [PR] fix(diagnostics): preserve colliding incident dumps #7400 dump: writeIncident uses {flag:"wx"} (exclusive create); only on EEXIST does it fall back to a UUID-suffixed name; non-EEXIST errors propagate to the caller's fail-soft catch (returns null, no retry).
    • [PR] fix(web): keep long-session reports within the argument limit #7404 report: Math.max.apply/Math.max(...) → reduce-based max/min; I confirmed the edge cases (empty array, 0/negative win, 0 systemPromptTokens) are behavior-equivalent.
  • Tests have teeth: the perf test uses runInNewContext with a 2s timeout on a 40K-char run (catches the O(N²) regression); the report tests use 200K-line trajectories (throw RangeError on the old code); the loopback test covers the leak, the 502 body, host-event files, bracketed IPv6, numeric-alias preservation, and invalid-numeric rejection; the dump test covers same-ms, cross-process EEXIST, sanitization collisions, a 32-dump burst, and fail-soft non-retry.
  • Ran locally: built kernel + pi-subagents dist, then the 5 touched test files → 54/54 pass; npm run typecheck → clean (exit 0). (My first local run showed 3 file-level failures — that was the unbuilt acp-kernel dist, an env-setup artifact, not a PR defect; it clears once the dist is built.)
  • Regression surface: no core/hot-path file touched (no server.ts / loop adapters / storage / session-gc / persistence / keepalive / relay.ts / stream-io.ts / plugin.ts). The 3 source files are log-mask.ts (logger choke point — perf gain + masking-scope tightening), error-dump.ts (4xx/5xx path only), web/report.ts (report generation only). The only behavior change is the masking-scope tightening (127-prefixed DNS names now masked) — that IS the security fix, and real loopback (localhost / 127.0.0.1 / ::1 / 0.0.0.0 / numeric aliases) still renders verbatim.
  • CI (live): gates green (kernel-guard, config-surface-guard, lane-guard, test-import-graph, static-gates, mysql-contract, gate, pi-subagents-guard); 9 test shards in progress; 11 e2e lanes skipped (gated, not triggered by this diff). Branch is 0 commits behind master (fresh base).

八问(结构化结论):

  1. 是什么问题:4 个独立社区 bug——URL 掩码对长非 URL 串 O(N²) 同步卡死(阻塞日志/诊断/匿名会话来源预览)、127. 前缀私有 DNS 名被误判为 loopback 而泄漏、incident dump 同名覆盖丢证据、SVG 报告大样本 Math.max 栈溢出。
  2. 什么原因导致的:①正则逐字母重启 scheme 扫描→回溯 O(N²);②isLoopbackIp 用 startsWith("127.") 一刀切,把 127.customer.internal 这类私有 DNS 名当 loopback 豁免;③writeFileSync 默认 w flag 覆盖已存在文件;④Math.max.apply/Math.max(...) 对 20 万样本超调用栈/参数上限。
  3. 影响范围与严重程度:①长非 URL 日志行同步卡数百 ms~分钟级(诊断/日志延迟,非不可用);②私有 DNS 名经诊断 URL/host-event 文件/502 上游失败响应泄漏(安全,可用但信息泄漏);③同毫秒+同会话+同状态 incident 静默覆盖,丢失受 GC 保护的证据(边缘数据丢失);④>约 10 万样本的会话报告下载直接 RangeError,该报告不可用。整体:均为「可用但有明显问题」或「边缘数据丢失」,非核心不可用。
  4. 怎么修复的:①负向 lookbehind 让扫描只在 scheme 串起点尝试一次 + 前缀组保字节一致;②只豁免真实 IPv4 loopback 字面量或 Node 归一化后落在 127/8 的数字别名,[::1] 按 ] 后分界;③wx 独占创建,EEXIST 才回退 UUID 后缀名,非 EEXIST 走 fail-soft 不重试;④极值改 reduce 累加,样本全保留。
  5. 是否有回归问题:无。逐路径清点——URL 掩码输出字节级不变(测试逐前缀/Unicode 边界钉死);loopback 收紧只影响泄漏类(真 loopback 仍原样);dump 非碰撞路径行为不变;report 极值语义等价(空数组/0/negative win/0 systemPromptTokens 均核对)。高危模式(语义漂移/fail-fast 变吞错/阈值时序/输出格式)逐项过:仅 [PR] fix: validate diagnostic loopback host exemptions #7397 的 502 host 显示从私有名变掩码形,即本次安全修复本身,已在 PR 披露。
  6. 是否破坏缓存:不涉及。四者均不触碰缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及。无架构/边界/数据流转向,纯 bugfix。
  8. 是否引入了新的配置:不涉及。无新 env/config/默认值。

合并判定:可合。 代码、测试、diff、署名、披露全部过关;唯一待办是 CI 的 9 个 test 分片跑绿(全量判定以 CI 为准,本地不代跑全量)。建议 owner 在 CI 测试分片绿后合并;4 个源 PR 会随之自动翻转为 merged,无需手动关闭。

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

Projects

None yet

2 participants