Fixes#6796. Preserve bili compression by disabling incompatible native thread deltas through Pi session-local model compatibility.
(cherry picked from commit 7d790d9970)
The first cut of this fix persisted the turn-final reply as non-tail rows
in the messages table. That breaks the table's contract: its seq space is
the ref-ledger substrate — on the first fold, persist.maybeRestampToLedger
aligns every live ref onto the store row's seq+1 (#4316), so a non-view row
interleaved in the table desyncs every post-fold ref (golden wire drift:
responses/google legs, body #10 onward).
C1: the stash lives only in sessions.metadata_json.handoffReply. That column
is persisted in both the legacy file and the unified DB, identical in both
views (digest-equal), so the reply still lands durably in the database for
#6947's 'anything reading the DB loses the turn's final reply' concern —
without touching the view, the ledger, or any wire. A client re-send then
persists the reply as a normal view row with the kernel-minted ref, exactly
as before #6947.
- handoff-response.ts: unchanged from the previous cut (metadata-only stash,
plan-ready rows with the codec-canonical ids, restampForJoin sidecars)
- ingest.ts: keep the planStoredMessageRow/HandoffReplyStashRow exports the
capture uses; no planner emission
- store.ts / mysql.ts: back to the pre-cut delta/full paths (the join
extension is gone with the table rows)
- tests: rewrite for C1 (stash never reaches the table; re-send is base
behavior; identity join-key parity; golden re-baseline = metadata section
only)
Local (node 22, clean env): issue6947 12/12, fork 4 files 91/91, lane/
storage/golden 6 files + storage-engine-proofs green at BASE expectations,
build OK.
Owner ruling 2026-11-13, after the dsh-live-compact record (#5984) shipped
as an ungated remote-feed broadcast and had to be retracted (#6508/#6509):
1. strict prohibition on announcements visible to every machine unconditionally
2. explicit owner confirmation before ANY announcement PR (add/change/retract)
3. announcement PRs must state the blast radius: audience, version coverage
(incl. which older versions ignore new gate fields), and display duration
4. plugin-targeted announcements disallowed in principle — plugin conflict
surfacing belongs to the read-only conflict scan (#1206); a plugin-targeted
notice must be trigger-based (scan surfaces, or a requiresScan-gated record)
AGENTS.md: new MANDATORY table row + 'Remote Announcements' section in §4;
reference/design-decisions.md: KDD #19 with the full ruling and precedent.
The dsh-live-compact-conflict entry in announcements/remote.json
broadcast to EVERY instance: NoticeRecord gates (versions/percent/time
window/dismiss) carry no client dimension, so the banner showed even on
machines where the plugin is not installed — contradicting the conflict
scan's 'flag only when found' semantics (#5984).
Add optional requiresScan: { client, knownId? } to the record schema
(validated by the shared validateRecord, counted in contentHash16):
when set, noticePassesGates keeps the record hidden unless that
client's read-only plugin-registry scan actually reports the plugin
(any finding, or a matching knownId). Empty registries scan empty, so
the gate fails closed and can never force user action. Scan results
are cached per client+cwd for 5 min, keeping hot poll paths cheap.
- remote.json: the #5984 entry now gates on dsh + dsh-live-compact
- docs: configuration (en/ja/zh) + KDD #16 record the field
- tests/remote-announcements.test.ts: gate behavior (hidden→shown→
knownId mismatch→any-finding), validation matrix, remote-lane
end-to-end, shipped-feed validation — hermetic DSH_HOME fixture,
scan cache cleared per case
The #4452 batch added a new src/server/ module but the file-by-file map in
reference/architecture.md was not regenerated, so the architecture-docs CI
guard failed with 'missing: src/server/rejection-diagnostics.ts'. Add the row
(alphabetically between relay.ts and request-cost.ts) so the map covers all
src files again.
[PR] Web Panel: Handoff Documentation and Collapsed Tree Diagram Rendering Upgrade (eWork-Level Rendering, Appendix Sectionin | Web 面板:交接文档与压缩树图渲染升级(eWork 级渲染、附录分节、冻结快照水合)
The sessions' handoff (交接文档) tab rendered every message body as
escaped plain text: markdown in assistant replies stayed literal, code
fences showed raw backticks, and tool input/output was one giant
unhighlighted pre with no copy button.
- new src/web/mdrender.ts: single escape-first Markdown + hand-rolled
syntax-highlight core (json/diff/js/ts/py/sh lexers, GitHub light+dark
palettes, unknown languages degrade to escaped text, zero runtime
deps). Inlined into the browser IIFE via .toString() exactly like the
JSONC helpers; tests/mdrender.test.ts pins behavior plus the
self-contained inlining contract (esbuild-minified .toString() must
run in a bare scope, mirroring the tsup pipeline).
- web/markdown.ts becomes a thin wrapper over the same core, so the
server-rendered handoff fallback and blog articles gain highlighting
too.
- client.ts renderHandoffMd: role cards (user/assistant/tool left border
+ badge), markdown-rendered bodies incl. thinking chains (collapsed by
default), structured tool cards (input/output label, language detection
json/diff, per-block copy button, JSON pretty-print, open when <= 20
lines), document meta (title/session id/token stats) rendered as a
key/value box instead of being skipped.
- styles.ts: card/token CSS vars in light + both dark palettes (#2559
verbatim-equality kept); i18n: det.io_in/det.io_out.
- tests/web-handoff-roles.test.ts adapted to the new markup; the #2065
invariant (in-body headings never become role dividers) is preserved.
CHANGELOG + docs/architecture/webui(.zh-CN).md + reference/architecture.md
file map updated (architecture-docs lane green).
Per owner review: the always-on compact record line (acp-nudge CustomEntry,
billion-context-pi #326 parity) is unnecessary — the transient verbatim
terminal notification (debug switch on) is the whole point of this feature.
- src/agent/pi.ts: no more registerEntryRenderer/appendEntry wiring; one
after_provider_response hook shows the verbatim wire text once per user
turn via ctx.ui.notify (consumes+clears the pending event, turnKey dedup)
- src/nudge-debug.ts: drop ACP_NUDGE_CUSTOM_TYPE + formatNudgeRecord
- tests: wiring test asserts the pi host carries exactly one extra
after_provider_response subscription vs omp (the #3248 ack channel
subscribes both lanes); formatNudgeRecord test removed
- docs en+zh, architecture.md: transient notify only, never persisted
- custom type acp-nudge (was bili-nudge); compact one-liner
[ACP nudge] <pct>% · T<tier>[ EMERGENCY][ · top range a–b]
- the compact record line is ALWAYS on (no debug config needed):
one per user turn, persistent in the session file, pi-visible /
model-invisible (type:custom never enters LLM context)
- the verbatim wire text becomes a transient terminal notification
(debug switch on: ACP_DEBUG / config debug), shown once per turn
after the model answered — never persisted
- dedup per (session, turn) via a stable key of the last text user
message (anthropic tool_result user messages skipped)
- bus events carry the record metadata (pct/tier/emergency/topRange/
turnKey); emitters compute it from the PRE-nudge array
The #5924 architecture-docs guard (landed on master via the branch sync)
requires every tracked src/ file in reference/architecture.md; the new block-ops
host executor module was added by this PR without its map row, so the guard
failed on the merged head. One-line registration next to the acp-* cluster;
guard passes locally (320 src files covered, no ghosts).
With the existing debug switch on (ACP_DEBUG=1 / config debug), every
compression nudge the proxy injects is mirrored into the pi transcript
as a transcript-only CustomEntry: [bili-nudge] <protocol>/<kind>
tier=… reason=… label + the final wire text the model actually read
that turn. Human-only: pi's session-context build ignores
type:"custom", so the view never enters LLM context or re-sent history.
Mechanism: the prepare stage (anthropic + openai lanes — the two pi
reaches) emits the post-wrapper text into a tiny in-process pub/sub
(src/nudge-debug.ts); in the default INLINE pi mode the extension is
the same bundle/process and mirrors each event via
pi.appendEntry("bili-nudge") + registerEntryRenderer. Emitters are
listener-less no-ops, so the prepare sites stay config-plumbing-free;
the consumer gate is a new debugEnabled() knob (src/knobs.ts) mirroring
Options.debug exactly (env ACP_DEBUG > file debug > false).
No new config fields / env vars / CLI flags — rides the existing debug
switch (owner decision; a draft nudgeDebug field from the first draft
was removed before the PR). kernel/ and pi-subagents/ untouched.
- src/server.ts / src/server/request-cost.ts: keep this PR's module
extraction; port master's #5907 once-per-session slow-warn dedup
(SLOW_SESSION_WARNED map + bound, est-tok field,
_resetSlowSessionWarnedForTest) into request-cost.ts. The warn line
composes both intents as pinned by the merged test suite in
tests/issue4528-event-loop-yield.test.ts: factual non-attributing core
(#5481) + size picture with the bili sessions rm cleanup command
(#5907); restart/enabling-compression advice stays out.
- src/server/relay.ts: master's #5998 strict-thinking-posture strip runs
BEFORE this PR's requestBody extraction, so onWireBody captures the
bytes actually handed to fetch.
- src/server.ts imports: drop queryLogLines (no longer used on master)
and noteRequest (moved with logRequestCost); keep configureLogRetention.
- CHANGELOG.md / reference/architecture.md: union of both sides' entries.
- Targeted local runs green: issue4528-event-loop-yield,
issue903-request-cost-log, issue5998-unsigned-thinking-egress (25/25);
typecheck clean.
The rebase onto master picked up the new architecture-docs guard
(#5930) which requires reference/architecture.md to list every tracked
src/ file. exit-deadline.ts (split out in the exit-flush hardening
commit of this PR) was missing.
The #1444 feature branch polished these five lines after this PR's tip
was cut: the wire-contracts ledger reference becomes a clickable
relative link (the file lives next to configuration.md), the docs
index row states the ledger's permanence rule, and the architecture
source map carries the longer comments with adapter-commandcode.ts
in position. Taking the #1444 versions verbatim makes this PR a
superset of the feature branch, so either merge path offered in the
PR body (merge tip into the feature branch, or replace its head)
lands identical docs.
The architecture-docs CI guard (#5930) requires every tracked src/ file to
appear in reference/architecture.md. Merging master exposed three modules the
PR adds without registering, so the guard fails on the merged head 0f502f4
with:
FAIL: reference/architecture.md missing: src/commandcode-wire.ts
FAIL: reference/architecture.md missing: src/loop/adapter-commandcode.ts
FAIL: reference/architecture.md missing: src/model-endpoints.ts
Ran the guard's own logic against this tree: 311 src files, 0 missing,
0 ghosts, ledger/page/SVG checks green.
restampRefsToLedger renumbers the live refs at cold load (the #5196 parked band
lands on fresh high numbers), but messages.ref_num stays frozen at index time.
The web block-detail path resolved each direct message's raw id through the live
byRaw map to a ref NUMBER and queried the store by that number, so every
renumbered row silently missed: ~37% of a long session's block-detail leaves
rendered "该消息已不在会话里". Folding, summaries and model volume were
unaffected; only the retrospective "what did this block fold" inspection broke,
and once refLedgerAligned=true set it never self-healed.
Switch both hydration callers (buildSessionDetail leaves + buildMessageContent)
to join on the stable msg_id — invariant across restamps — via a new
store.messageContentByMsgIds → shadow → persist.unifiedMessageContentByIds path
that mirrors the existing ref-number sibling (same fail-open posture, same
retired-row exclusion). The ref stays display-only. Export JSONL reads rows by
seq order and never joins live refs, so it is untouched. Registry row updated.
Closes#6029
- mark the nine internal-only symbols in src/context-analysis.ts
(InitMessageEntry/InitProfile/NudgeEvent/HarvestRecord/CommitSample/
TierReadiness/ContextAnalysis/NudgeObservationTurn/buildVerdict) as
consumed inside the module or through the view formatter, satisfying
the unused-exports gate
- add src/context-analysis.ts to the reference/architecture.md file map
A stream:false Anthropic response that calls a proxy tool (compress,
acp_status, search_context, decompress) was rewritten once: each
tool_use became its result text and stop_reason was forced to
end_turn, so a compress round ended the client turn with the fold
receipt and the model never saw the result. Port the streaming
decision (core.ts reRequest gate) to this lane: proxy-only rounds
execute through the same executors, append the original assistant turn
plus a tool_result user turn to the forwarded body, and re-request;
mixed or tool-free rounds fall through to the untouched one-shot
rewriter. Bounded by MAX_LOOP_ROUNDS with degradation to the pre-fix
shape at the limit.
Union of the two divergent edits in the compat-role rewrite path: keep #5478's object-graph/string split for the carrier binding, and retain master's Kiro judgeRoleRestore capture in BOTH success branches (graph and string) so Kiro turns carrying a separator manifest still get the invariant-judge role restore. CHANGELOG keeps both sides' entries.
Kiro CLI's agent calls its model gateway over the OpenAI Responses wire
(POST https://runtime.<region>.kiro.dev/v1/responses, SSE), replays the full
history every turn, authenticates with a bearer token (no body signature)
and honors HTTPS_PROXY — so the existing responses pipeline compresses it
once two gateway quirks are handled (src/kiro.ts):
- Roles: the gateway accepts only user/assistant items; the injected
developer compress prompt was rejected (400 "not supported", param
input[0]), system likewise. Built-in compat map developer/system -> user
for Kiro traffic, lowest precedence (compat.roles and learned roles win
per key). The invariant judge sees the injected prompt with its original
role (no false I1 mid-insertion).
- Identity: Kiro's first item is not byte-stable across processes, so every
'kiro-cli chat --resume' minted a new session. Promote
metadata["kiro:conversation_id"] (kiro-<id>) over a content fingerprint.
Launcher: 'bili kiro' cert-MITMs only the four runtime.*.kiro.dev gateways,
combined CA on SSL_CERT_FILE (Rust shell) + NODE_EXTRA_CA_CERTS (Node agent
server), loopback via NO_PROXY, resolves kiro-cli.
Tests: tests/kiro.test.ts (9), runLaunch kiro in tests/launcher.test.ts.
Docs: CLIENTS.md / CLIENTS.zh-CN.md, README tables + launcher lists,
CHANGELOG, reference/architecture.md.