Skip to content

feat(web+logs): sessions observability — model-switch column, version provenance, per-session log views - #1627

Merged
ranxianglei merged 5 commits into
masterfrom
2026-09-29_web-sessions-observability
Sep 29, 2026
Merged

ranxianglei merged 5 commits into
masterfrom
2026-09-29_web-sessions-observability

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Supersedes #1560

#1560's stacked base branch (2026-09-28_cache-attribution-combined) was squash-merged to master via #1558, leaving its head cf81056 permanently CONFLICTING. Commit 1 carries that PR's byte-identical 5-file web delta (+230/−8, verified against stacked head a30ee8d) onto current master. Please close #1560 when this lands.

Three logical commits

1. feat(web): model-switch cache drops column in web sessions view
Sessions table gains a 模型切换/Switches column between hit% and folds: count · missed-tokens from the ledger agg.switches/agg.switchMissed (shipped in #1558), dim 「无」when never switched, fields omitted rather than zeroed. Includes live-endpoint test suite (rendered-DOM row-count check via node:vm).

2. feat(version): make proxy version traceable on sessions and log lines

  • persist stamps metadata.biliVersion (provenance: which build persisted the session) — pre-stamp files simply lack it, no backfill/fabrication
  • session detail card shows 代理版本 / Proxy version (honest dash pre-stamp)
  • boot line reads acp-proxy v0.1.169 listening …
  • every log line carries [v=x.y.z] so a multi-instance shared bili.log self-identifies its writer per line
  • existing dsh-native / logger-epipe line-shape assertions updated for the token

3. feat(logs): per-session observability in the web log view
Fixes the diagnosis pain point where the per-session log filter hid ~96% of warn/error lines (old format had no session field; only call sites that manually embedded an id matched):

  • ALS funnel in startServer tags every line emitted while handling a model request with [sess=<id>] — zero changes across the 264 log() call sites; one prefix per PHYSICAL line so multi-line stack traces keep attribution
  • GET /__bili/logs gains ctx=N (merged ±line context windows), win=seconds (chronological window around first..last hit, interleaving kept) and raw&all=1 unfiltered full-log download (rotated .old included, 100k-line cap); responses carry shown/omitted/isMatch
  • UI: context/window toggles, highlighted hit rows + dimmed context rows, truncation notice, dedicated full-log download button
  • query logic extracted to pure module src/web/logs-query.ts (+10 unit cases); new ALS tagging suite + in-process e2e (real startServer, mock upstream)

Verification

  • typecheck + build clean at every commit point tested; full targeted batch green (web-sessions 7, web-logs-query 10, logger-session-tag 4, logger-epipe, web-logs-view e2e, issue903 cost-log)
  • every remaining full-suite failure signature reproduced identically on clean master baseline (attach-spawn timeout family etc.) ⇒ no regressions from this branch
  • live proof on real data (172 sessions, real shared bili.log):
    • ?q=<sid>&ctx=3: 115 hits → 776 rows incl. 661 previously-invisible context rows (other sessions' persist warns, 429 upstream lines, affinity hydrate)
    • ?q=<sid>&win=120: interleaved window view with hits highlighted
    • raw&all=1: 12.2 MB / 72,364 lines == disk total (delta = concurrent writes during transfer); caught & fixed a real cap bug here (full download silently honored the lines=500 default)

Notes / caveats

  • Lines written by older builds stay untagged (no backfill); production [sess=…] lines already observed once newer instances picked up the tag — mix is visible by design in the shared log
  • Call sites that manually embed [session.id] in the message show the id twice alongside the auto tag — harmless, cosmetic
  • Per-line [v=] costs 12 bytes/line (+1 MB per 10 MB rotation)
  • Merge policy: human merges this (per AGENTS.md)

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-29_web-sessions-observability (bb1cc52)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1578-pr.1627.8016608

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

Option B — Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,开始 review 这个 PR(supersedes #1560)。按规范走:① 原 issue/方向 → ② 回归审查 → ③ 代码审查 → ④ 测试有效性 → ⑤ diff 整洁度。先拉分支核对代码与 CI 状态,稍后给完整结论。

Supersedes PR #1560: its stacked base branch (2026-09-28_cache-attribution-combined) was squash-merged to master via #1558, leaving head cf81056 permanently CONFLICTING. This carries the byte-identical 5-file web delta (+230/-8, verified against stacked head a30ee8d) onto current master. The switch accounting it displays shipped in #1558.
- persist stamps metadata.biliVersion with the running build's version (provenance: which bili persisted this session); pre-stamp files simply lack the field
- session detail card gains a 代理版本 row (honest dash for pre-stamp sessions)
- boot line now reads 'acp-proxy vX.Y.Z listening ...'
- every log line carries [v=x.y.z], so a multi-instance shared log self-identifies its writer per line
- updates dsh-native / logger-epipe line-shape assertions for the new token
- AsyncLocalStorage funnel in startServer tags every line emitted while handling a model request with [sess=<id>] — zero changes across 264 log() call sites; one prefix per PHYSICAL line so multi-line stack traces keep attribution
- GET /__bili/logs gains ctx=N (merged ±line context windows) and win=seconds (chronological window around first..last hit, interleaved lines kept) modes plus raw&all=1 unfiltered full-log download (rotated .old included, 100k cap); responses carry shown/omitted/isMatch
- UI: context/window toggles (window wins), highlighted hit rows + dimmed context rows, truncation notice, dedicated full-log download button; filtered download keeps the active mode params
- query logic in pure module src/web/logs-query.ts; tests: 10 unit cases + ALS tagging suite + in-process e2e (real startServer, mock upstream, tag grammar on disk and all three view modes over live HTTP)
@ranxianglei
ranxianglei force-pushed the 2026-09-29_web-sessions-observability branch from a331232 to 8036f0d Compare September 29, 2026 00:58
@ranxianglei
ranxianglei merged commit 43e148c into master Sep 29, 2026
13 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-29_web-sessions-observability branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant