Repository navigation
fix: external summary credentials — readable failures, bounded retry, tri-state status (#3488) - #3541
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4213-pr.3541.8a57d94This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3541.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 收到,开始审阅本 PR(不重做,核对代码 + CI + 定向测试)。 查重: 不重复。 检索 open+closed 的 issue/PR 后确认:在途 PR 中只有本 PR 触碰 external-summary 凭证链路的失败可见性/重试/三态状态。相关但不重复的:
当前状态:mergeable=true,但分支 behind master(需 rebase);CI 状态与代码审查进行中,结论稍后按八问体例回复。 |
…gging and bounded retry (#3488)
…sk urls in logged snippets Review fixes on #3541 (two small defects in the new retry loop): - waitBeforeRetry pushed every scheduled delay into the module-level scheduledSummaryRetryDelaysMs array even in production (override null), so long-lived processes leaked entries on every transient retry. The recording now only happens when the test override is armed. - the HTTP failure body snippet was logged raw while the pre-response path masks its error text; maskUrlsInText now applies to the log line only (the transient verdict below still needs the raw body markers).
…ad of mislabeling The five-state badge expression left badgeState undefined when no detail entry existed AND the legacy boolean was false — reachable for recipes without credentialRef/apiKeyEnv (agent-registered #2336 providers) on NEW servers, rendering 'Invalid reference format' where the pre-PR UI showed 'Not configured'. Fallback now maps absent detail to configured/missing from the legacy record.
…inct from backoff retry-after: '1' computed to 1000 ms — identical to the attempt-1 backoff fallback — so the [1000] assertion could not tell a honored header from an ignored one. Now uses '7' (asserts [7000]) and adds a hostile '999' case pinning the 15 s cap.
…heir owning surfaces The startup audit expanded chains against FILE recipes only, but request time also sees agent-registered recipes (#2336, in-memory, registered after boot). A chain targeting an agent-layer provider therefore emitted a false 'unknown provider' warn at every start although it resolves fine at request time. Unresolvable references are already surfaced by web save (400) and the request-path one-shot warn, so the audit now reports only what only it can know: credential states of expandable chains.
23253a5 to
b012950
Compare
(ai: vllm-qwen/qwen3.8-27b) 审核结论:通过,可合并(合并由人来)分支已 rebase 到当前 master(v0.1.198,与 master 零文件重叠,rebase 干净),并补了 4 个 review 小修 commit(见下)。新 head 结构化八问
行为变更披露(旧 → 新 + 原因)
判定方向正确、实现闭环、CI 全绿、无回归、无越权配置面变更。可以合并——按规矩合并动作留给你:#3541 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.561-master.05aae74 # this exact build
npm install -g billion-context@master # always the newest merged build
|
(ai: vllm-qwen/qwen3.8-27b)
Closes #3488
Sub-item 1 of #3488 (PUT
/__bili/external-summary/credentialnever registered → 404) is already fixed by open PR #3445 (closes #3443) — this PR does not touch that registration and stands independently for sub-items 2–4.What was broken
erroroutcome: no HTTP status, no response body anywhere. A single 429/5xx killed the whole batch (reason=exhausted, 0 folds) with nothing actionable in the log.env:value could only be discovered at first dial.Changes
Per-attempt logging + bounded retry (
src/external-summary-http.ts)HTTP <status>from the masked host plus a whitespace-collapsed ≤1 KB response-body snippet (streaming-capped read — a hostile multi-MB error body is not buffered whole); pre-response network failures log the classified kind (connect-refused,upstream-timeout, …).isTransientUpstreamError(429 / ≥5xx / risk-control body markers) for HTTP responses andisFailFastUpstreamKindfor network errors. Up to 3 dispatches per candidate, exponential backoff 1 s → 2 s (cap 8 s),Retry-Afterhonored capped at 15 s. Non-transient statuses still fail fast on the first response. The whole loop stays inside the executor's existing per-attempt deadline (targetTimeoutMs), so the worst-case wall-clock bound is unchanged.Tri-state credential status (
src/external-summary-credentials.ts,src/web/api.ts,src/web/client.ts,src/web/i18n.ts)configured | missing | invalid_value | store_unreadable | invalid_reference, with human-readable descriptions per state.GET /__bili/configgains an ADDITIVE fieldexternalSummaryCredentialStatus(reference → state). The legacy booleanexternalSummaryCredentialsis byte-for-byte unchanged.[object Object](json() now extracts.messagefrom object error bodies).Boot-time audit (
src/server.ts) — at startup, every effective enabled external-summary chain (global → route → model cascade, deduped) is checked; missing/unusable credential references produce one warn line each, e.g.[config] external summary credential: target nexus--free: environment variable NEXUS_API_KEY holds an unusable value (…). No new behavior knobs.Behavior changes (old → new)
attempts=[t0:error]onlyexternalSummaryCredentials: {ref: boolean}externalSummaryCredentialStatus: {ref: five-state}No wire format change, no persistence change, no kernel change, no new dependencies.
Config surface
No new config fields, env vars, or CLI flags. One additive read-only field on an existing admin GET endpoint (legacy consumers unaffected). Nothing to migrate.
Tests
tests/external-summary-http.test.ts: split the old status loop into fail-fast (400/401/403 → primary+backup once, zero backoffs) vs transient (429/500/503 → 3 primary attempts with recorded 1000/2000 ms backoffs + backup, three logged rejection lines, result stays leak-free); new tests for Retry-After recovery, risk-control 403 marker retry, socket-death retry, exhausted-chain logging.tests/issue3488-credential-status.test.ts(new): five-state matrix for env refs, malformed refs, secret lifecycle incl. corrupt-file and 0o644-permission paths,auditExternalSummaryCredentialsagainst named recipes, boot-audit cascade over global/route/model, andhandleConfigGetasserting the additive field alongside the untouched legacy booleans.tests/external-summary-runtime.test.ts: two assertions updated to the new ≤3-attempts contract (commented), plus the retry-delay test seam.Local on rebased head: typecheck clean; 109/109 across the four external-summary suites + 67/67 adjacent (web-routing, lane-credentials, summary badge/batch/autofold/executor-parallel). Full suite = CI.
Note: hot-file coordination with open #3460 (fold storm) — both touch
src/server.ts; merged cleanly here.