Commit Graph
189 Commits
Author SHA1 Message Date
ework-agent 87e95b59e4 Merge remote-tracking branch 'origin/master' into 2026-11-15_msgid-snapshot-unified
# Conflicts:
#	src/persist.ts
#	src/storage/store.ts
2026-11-21 21:55:20 +08:00
ranxianglei 410d9fe615 Merge pull request #7423 from ranxianglei/2026-11-21_opencode-fork-lineage
[PR] fix: resolve opencode fork parent from its local DB to stop resume crosstalk (#7421)
2026-11-21 21:06:30 +08:00
ework-agent 1f4bd580be docs: seed the sessions/plugin/snapshot config surface + egress-lane-io file map
The PR's snapshot-plane commits added config fields (sessions.*, plugin.snapshotCapBytes, snapshot.shadow) and src/server/egress-lane-io.ts without doc seeds, so three CI gates went red on head 02fc8f4c2:

- config-surface-guard: 11 leaf fields lacked website/config-reference seed entries
- docs-coverage: 11 env vars + 2 top-level keys (sessions, plugin) undocumented (BILI_SESSION_CONTENT_STORE_PIN is env-only)
- architecture-docs: reference/architecture.md missing src/server/egress-lane-io.ts

Added the seeds (process.yaml: sessions block + 9 leaves; server.yaml: plugin.snapshotCapBytes + snapshot.shadow; env-only.yaml: BILI_SESSION_CONTENT_STORE_PIN), the file-map line, and the regenerated docs/configuration.{md,zh-CN.md,ja.md} + website artifacts.

Verified locally: all three gates green, generate idempotent, typecheck clean.

PR #6785 CI fix.
2026-11-21 17:20:04 +08:00
ranxianglei 02fc8f4c2c refactor(egress): one switch, one path — collapse egressOpLog/egressServeLog into egressPlane (#7439 ruling)
The egress plane gets a SINGLE rollout key: egressPlane (default 0).
ON = the complete new path in every lane — sparse-op recording,
serve-from-log (byte-identical swap), and server authority for pinned
plugin lanes (rulings 7439-3/5). OFF = legacy chain, zero rows,
byte-identical to pre-feature. Both predecessor keys never shipped
(default 0, born in rollback state) — no migration.

Owner ruling 2026-11-21: '删掉以前的开关 只留下一个开关'.

Verification: typecheck 0; 13-file storage/egress/fastpath battery
112/112; e2e codex 4-phase pass (rollout off = legacy path).
2026-11-21 16:12:38 +08:00
ework-agent d3ab5abb76 merge: resolve conflicts with master (#7381 pf-tail-ids-cap-and-stamp-decouple)
Conflicts resolved:
1. src/server/prepare-openai.ts: union of fastpath imports (PR's
   DeltaReanchorError/PF_TAIL_IDS_HEADER/evaluateDeltaResend/parseTailIdsForPin
   + master's stampOnlyWatermarkTurn).
2. tests/fastpath.test.ts: union of fastpath imports (PR's
   evaluateDeltaResend/PF_DELTA_HEADER + master's stampOnlyWatermarkTurn).
3. src/agent/pf-channel.ts: kept PR's TAIL_MAX_BYTES byte-budget (supersedes
   master's MAX_TAIL_IDS count-cap; the byte check is stricter and
   tailPayloadFor is the single source of truth for both header emit AND
   full-form suppression).
4. src/server/fastpath.ts: kept BOTH evaluateDeltaResend (PR #6785 delta arm)
   AND stampOnlyWatermarkTurn (master #7367 stamp-only turn).
5. src/storage/shadow.ts: kept master's fileJsonWriter parameter (new in
   master, not in PR branch).
6. tests/pf-channel.test.ts: updated #7367 tail-cap test to match PR branch's
   byte-budget behavior (full slice under 8 KB, not capped to 160).
2026-11-21 15:28:57 +08:00
ci-check 3329c2655f docs: list src/storage-backup-repair.ts in the reference architecture file map (#7156) 2026-11-21 12:32:35 +08:00
ci-check 83e28086c1 docs: register src/opencode-fork-lineage.ts in the architecture file map
The architecture-docs CI gate requires every tracked src/ file in
reference/architecture.md; the new module was missing, failing the lane.
2026-11-21 09:14:29 +08:00
ranxianglei a936b3f0ad feat(storage): egress serve-from-log reconstruction + shadow byte-identity comparison (discussions/7398 seg 4a)
The outbound element array can now be REBUILT from the op-log view alone:
view rows carry role + a unified-content-CAS reference (the message's final
core JSON, hashed at record time — no new content bytes anywhere), and
rebuildOutboundFromLog runs the exact legacy chain (systemToUser ->
coreToOpenai -> hardenOpenaiAssistantContent) over the CAS bodies.

- src/storage/egress-serve.ts (new): rebuild + the degrade ladder — missing
  CAS body / casRef-less legacy rows / tool rows / bad JSON -> null, the
  caller keeps the legacy bytes. v1 scope pinned: text + acp_summary rows.
- src/storage/egress-state.ts: role?/casRef? ride the I and U ops, the B
  base and both replay paths (JSON payload fields only — no schema change;
  absent on pre-seg-4 rows, which serve-from-log skips).
- src/storage/egress-record.ts: rows recorded with the CAS seam
  (store.egressPutContent); system row included with its own casRef.
- src/storage/store.ts: egressPutContent/egressGetContent public seam over
  the existing private content CAS (dedup by sha256, refcount).
- src/server/prepare-openai.ts: captures the legacy core elements + the
  recorded source; behind egressServeLog (default 0) it rebuilds from the
  log and logs IDENTICAL|DIVERGENT vs the legacy bytes. NO swap: the
  pipeline always sends the legacy path until the shadow gate proves it.
- rollout: egressServeLog {percent: 0} (env BILI_ROLLOUT_EGRESS_SERVE_LOG,
  requires egressOpLog on); config docs regenerated (348 entries, stable).
- tests/egress-serve.test.ts (new, 6 tests): byte identity vs the legacy
  chain (plain + summary re-voicing + table-replayed + post-compaction)
  and the three degrade directions (#3617).
- Battery: egress-state/record/serve 24/24, perf-suite set 53/53,
  typecheck + build clean.
2026-11-20 19:11:15 +08:00
ranxianglei 5b3b55cb61 feat(storage): egress op-log recording seam — shadow-record the outbound view as sparse ops (discussions/7398 seg 3)
The four upper-layer shapes now land in the op log behind rollout key
egressOpLog (default 0 = zero impact):

  1. new message            -> exactly one +I (tail append)
  2. nudge injection        -> structurally absent: the recording seam sits
                               BEFORE the nudge/scratch append, so the
                               ephemeral rows never reach the tables
  3. compress fold          -> one -D over the folded span + one +I for the
                               summary row; any -D batch triggers compaction
                               (replay into a base row, state table bounded)
  4. content edit           -> exactly one +U (msgid/ref stable, content-only)

recordEgressTurn (new src/storage/egress-record.ts) builds deterministic
view rows (system row first; msgid/ref/tokens/type/contentHash), diffs
against the previous turn's view, appends the sparse ops, and compacts on
folds. Wired in prepare-openai between recordNudgeInject and the single
return: feature-gated, try/catch with per-session disable on any error
(shadow lane — the pipeline never throws from it).

SessionStore.egressOpLogStore() -> UnifiedShadow.egressOpLogSync() exposes
the sqlite UnifiedStore (null on legacy mode / network backends -> the
turn is skipped exactly like every other sqlite-lane fast path).

Tests: tests/egress-record.test.ts 6/6 (build determinism, tail append =
one op, fold = -D + +I + compaction, edit = one +U, identical view = zero
ops, rollout-off default both directions). Battery 71/71.
Full battery + CI green.
2026-11-20 18:56:33 +08:00
ranxianglei b31e7e17e6 feat(storage): egress op-log outbound view — dual-table state+flow with replay, compaction, any-seq rollback (discussions/7398)
New egress_state + egress_flow tables (both PK (session_id, log_seq),
msgid secondary index): the outbound view becomes an op log instead of a
rebuilt blob. Row types: B=base, I=insert (after-anchor or tail, msgid +
render triple ref/tokens/type + content_hash), D=delete (inclusive
msgid endpoints), U=content update (msgid-stable).

Replay is deterministic: read the state table in log_seq order, apply
per row type; any anchor/endpoint/id violation throws
EgressStateCorruptError (whole-session legacy degrade, never fuzzy).
Compaction = one txn: write the replayed base as a B row, physically
delete the state rows below it (cancelled intermediates vanish); the
append-only flow table keeps every op, so any historical log_seq stays
reconstructible via egressStateViewAt.

No pipeline wiring yet — the tables are written/read through
UnifiedStore thin methods only; recording ops at the four upper-layer
sites (new message / nudge-ephemeral / compress fold / content update)
and serving from the log come next, behind a rollout key.
2026-11-20 18:38:13 +08:00
ranxianglei 950eb8d9b1 fix: 超长会话截断尾清单也能 pin——增量接受规则改为「尾部对齐 + 重叠段逐行对账」
ed71f127 之后 >2048 会话的 body 清单永远是被截断的尾段,其头在会话中部、
永远 ≠ 账本前沿 ⇒ 旧「锚点+宽度」规则每轮失配 ⇒ 服务端发「full」⇒ 客户端
永远只能再发同一份截断清单 ⇒ pin 死到会话结束(载体一旦超 8KB/戳陈旧
断一次即触发,2xx 救不回来——客户端已经没有全量可发了)。

新规则(只改服务端 tryIncrementalPin,客户端零改动):清单声明覆盖连续
尾段 [T-L, T-1];与账本的重叠段 [T-L, C-1] 逐行相等才接受,任一行漂移
降级发「full」(D1:永不 400);重叠之后的新增核逐槽筛查。稳态形态
(锚点+新增,L=N+1)= 单行重叠特例 = 原锚点检查,行为字节级不变;
2048 截断清单的重叠 ≈2047 行,证明更强。修完「退回全量」退化为
「发你有的」,任何结尾正确的形态都能 pin,死循环结构上消失。
空账本例外(B1:短数组打空账本 = 采集故障,R3 路径)不动。

测试:I2 用例 (a) 语义翻转(历史整段尾清单现在是合法 pin)重写为
重叠段漂移用例;新增 I7(C=3000 账本、2048 保留窗截断清单 pin 成功 +
一行漂移降级)、I8(稳态单行重叠特例双向)。定向 10 文件 171/171 绿,
tsc/build/architecture-docs 全绿。

KDD #21(AGENTS.md + design-decisions.md)接受规则文案同步。
2026-11-19 20:39:44 +08:00
ranxianglei c0df208e90 feat(msgid): 增量 pin 全客户端覆盖(#7064 §9 phase 2,owner 裁定 2026-11-18)
- 两形态上移申报通道:客户端每轮照旧全量算,但短数组(≤账本 frontier 锚定的
  尾部窗口)就是合法尾式——openai 走 pf-tail-ids、opencode V1/V2 走 x-bili-msg-ids
  短列表、responses/anthropic 走 body biliMsgIds 短列表,服务端按长度区分全量/尾部
- 空账本上的短数组 = 采集故障:沿用旧 R3 路径(400+熔断/conv-bound 降 content),
  B1/D2 行为不变;非空账本上的长度不符 = 漂移类,降级发全量、永不 400
- 尾部新 id 逐槽过校验(? 跳过,空/超长/保留前缀/控制字符/与账本前缀重复拒绝)
- x-bili-msgid-mode 信号头扩展到 responses/anthropic 车道
- opencode V1(anthropic header)与 V2(responses header)接 pfIdTailForm 尾式:
  稳态只发锚点+新增,压缩/分叉后的重写轮发全量重锚
- omp/claude/codex/google 无需接线(无全量申报或本就是增量车道),KDD #21 记录
- 默认开(pluginMsgIdIncremental 0→100,owner:新存储结构的核心部分);
  回滚 env BILI_ROLLOUT_PLUGIN_MSG_ID_INCREMENTAL=0
- KDD #21 更新 + AGENTS.md + #7064 本地 §9;新增 I4-I7/pfIdTailForm 测试
2026-11-19 00:44:52 +08:00
ranxianglei 2837c38282 (PR#6785 review) docs: drop the ghost checksums.ts entry that ced9644f0 orphaned — the architecture-docs CI guard greps reference/architecture.md for tracked src files and fails on the dead module 2026-11-19 00:11:39 +08:00
ranxianglei 8575e4e2fe Merge branch 'master' into 2026-11-15_msgid-snapshot-unified 2026-11-18 23:23:26 +08:00
ranxianglei 2cbbc1d350 feat(msgid): pin 通道增量化——稳态只发尾部、快照轮才发全量(#7064 §8,owner 裁定 2026-11-18)
背景:msgid pin 通道每轮发全量清单,opencode 的 16KiB header 预算在千条以上
长会话里让 pin 永久失效(有用户实测「发的是全量、最后超长度发不了」),pi/dsh
的 body 数组同样无界增长。裁定:不管哪个客户端都不发全量、只发增量。

- 稳态:客户端不再发 biliMsgIds body 字段 / x-bili-msg-ids header,复用既有
  有界通道 x-bili-pf-tail-ids(锚点+新增 cores,? 占位)携带增量(零新增
  发送代码,同一采集缝/chokepoint);服务端 tryIncrementalPin 按「锚点=账本
  尾部 live 行 + 宽度 C+N=视图长度」钉住增量,前缀 cores 无条件从账本 live
  行重盖(ingest 是 INSERT OR IGNORE,ref 空间稳定的前提)
- 全量形式不删且优先:启动(账本空)/压缩/fork/截断后的重锚轮照发全量;
  任何一条失配=降级为 full(不 pin、不 400、不 latch)——两轮收敛
- 信号头 x-bili-msgid-mode: incremental|full 与 x-bili-pf-seq 同一响应发出;
  4xx/宿主缩水/'full' 信号立即清 mode 回全量(回滚自愈)
- 客户端:pf-channel 单一状态机 + pfSuppressFullMsgIds 单一抑制点,pi/dsh
  各一行接线;opencode 留 phase 2(/responses 计头 run 的 off-by-one)
- 灰度:rollout flag pluginMsgIdIncremental 默认 0,off = 字节级同改前
- KDD #21;新测试 I1/I2/I3(增量 pin/失配降级矩阵/全量优先/? 槽位)+
  pf-channel 信号学习/抑制/缩水清除/4xx 清除
2026-11-18 19:24:13 +08:00
ranxianglei 001e16f12a msgid 生命周期梳理:存储瘦身(D1/D2/D3)+ fork 车道回归修复(discussion #7064)
一句话说清:把"每轮都存一份消息 id 清单"改成"只存头尾一小段",并修掉
fork 后子会话落到父会话代理车道上的回归。

存储瘦身(方案见 GitHub discussion #7064,owner 裁定 2026-11-17):
- l1_world 不再存全量 id 和校验和:改成 tail-512/head-32 id 窗口 + count +
  max_pos,只是记账游标,永不做身份判分叉(D1:尾锚比对不匹配时最强动作
  是 reanchor,绝不 400)
- D2:会话一旦有宿主身份(conversations 里有非 proxy 命名空间的声明),
  跳过 id 判定直接走 anchor,R3 熔断只在无宿主身份的裸会话上保留
- D3:tail 锚常活——hit turns(水印快路径命中轮)也刷新窗口,不再只在全量
  重发轮才动
- fold_journal 去掉 covered_ids:改 [start_seq, end_seq] 区间 + input_hash
  (对折叠时原始行逐字节取指纹,供服务摘要前按区间重推、防篡改)
- egress_snapshot 去掉 ids_json:改水印边界聚合(对 seq ≤ watermark 的存活行
  按 seq/msg_id/content_hash 取 sha256)

fork 车道回归修复:
- stage-0 游标前进(尾锚 reanchor/扩展)后 bump revisionEpoch,让快照刷新
  的 epoch 证明保持一致;否则 fork 出的子会话会落到父会话的代理车道
  (plugin-fork ×6 / plugin-fork-contract ×6 回归即此)
- identity.ts 窗口比对修正:prefix-contain 取代 tail-overlap(纯扩展场景
  原来永远判 0 重叠 → 误 reanchor),shrink 改真后缀判定,extend/append
  的 head 窗口跟随新消息走

配套:
- KDD #20(reference/design-decisions.md + AGENTS.md)
- 新增测试:D2 convBound→anchor、D3 hit-turn 刷新(issue5874-2x2-p3);
  egress/fold-journal 测试按新 API 重写
- tsc --noEmit 干净;定向 116/116 全绿
2026-11-18 10:40:12 +08:00
shreynshah 0b2ce30272 fix(pi): negotiate full Anthropic requests for bili
Fixes #6796. Preserve bili compression by disabling incompatible native thread deltas through Pi session-local model compatibility.

(cherry picked from commit 7d790d9970)
2026-11-18 10:16:19 +08:00
ranxianglei 5ea371460d Merge branch 'master' into 2026-11-15_msgid-snapshot-unified 2026-11-17 16:26:23 +08:00
ranxianglei 80daffc2f5 fix(storage): keep the reply stash out of the messages table (direction C1, #6947)
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.
2026-11-17 10:58:38 +08:00
ci-check 0283c812cd fix: dedupe responses-system-sections.ts module-map entry (ci-fixes merge left a second, less complete row) 2026-11-16 23:45:03 +08:00
ci-check 1a2e0c3bcb Merge remote-tracking branch 'origin/ci-fixes' into 2026-11-15_msgid-snapshot-unified 2026-11-16 23:35:29 +08:00
ranxianglei d08ce0dff9 #6785 review: register src/responses-system-sections.ts in the architecture map
The #6944 merge added the shared Responses developer-section joiner
(#6922) without its architecture.md entry, which the architecture-docs
guard requires. One-line module-map registration.
2026-11-16 22:30:01 +08:00
ci-check 1a4450bc85 Merge remote-tracking branch 'upstream/master' into HEAD 2026-11-16 20:44:19 +08:00
ci-check 8ed56be997 docs(architecture): add src/responses-system-sections.ts to the module map (#6922) 2026-11-16 20:42:39 +08:00
ranxianglei 301e1a5459 Merge pull request #6151 from ranxianglei/nudge-debug-pi
[PR] feat: pi lane — show the injected nudge text verbatim in the terminal when debug is on
2026-11-16 20:35:23 +08:00
ci-check 01b69f2975 fix: drop internal-only slim.ts exports and add slim.ts to the architecture file map (#6785 CI gates) 2026-11-16 12:38:17 +08:00
ranxianglei 57a5bcae91 docs: align architecture docs with the v2 plane (#6785)
reference/architecture.md: drop the three retired plane files from the
map (snap-egress, snapshot/assemble, snapshot/delta), re-point the
snapshot/ + snap.ts entries, note the egress splice/cut on
snapshot-render. storage-relations en/zh diagrams: the plane box now
shows l1_world / fold_journal / egress_snapshot / checkpoints (existing)
instead of the never-shipped snap_rows/snap_log/snap_ckpt; the fold and
GC flow boxes re-pointed. architecture/storage en/zh/ja: the kstate
convergence sentence no longer names a retired table (#6858 tracks the
follow-up). checksums/types headers: dropped the S4/snap_rows red-line
wording for the retired plane.
2026-11-16 00:10:09 +08:00
ranxianglei 3a68dcbbad integrate: #5901 (snapshot plane) + #6564 (msgid delivery) on master — pre-merge gate:local + full-CI validation
# Conflicts:
#	src/server/prepare-responses.ts
2026-11-14 16:43:44 +08:00
ranxianglei 5e38cf1792 fix(#5874 2x2): review round 1 — B0-B4 + M1-M6 (plane bypass, 400 funnel, frontier commit-on-accept, pure continuation, shared stage-0, codec-level pin)
Review of PR #6299 found four blockers and six majors; this is the
complete fix round.

B0 (root): a chained turn on the responses lane has no full-view
reconstruction (the D lane is skipped for pluginMode and #4804
augmentation is WS-only), so its kernel view is a delta, not the world.
Flushing that view to the plane deleted every row it did not contain.
Now a chained turn that is neither cohort (msgid-pinned stage-0) nor
WS-anchored sets session.skipPlaneFlush (one-shot, consumed by the
persist build — snapShadowSync returns before any plane work) and
passes bypass:true to applySnapEgress (the outbound is the legacy
bytes; the plane stays stale-but-intact until the next full/cohort
turn, which re-syncs it one-round).

B1: FoundationRejectError was swallowed by the lane 'kernel transform
failed, forwarding unchanged' catch -> 200. Both lane catches now
rethrow it first; the server funnel maps it to a 400 with
x-bili-snapshot: identity and {error:{type:'snapshot_identity_fault'}}
before the generic 503 path.

B3: a plugin chained round with EMPTY input (a pure provider-chain
continuation) is routed to the raw-body passthrough
(prepareResponsesCompact) at the dispatcher — no dev-message
injection, no chain-id strip, no kernel round. The injected dev
message + stripped id on a no-content round produced a blind provider
response that the host then chained from (permanent context loss).

B4: the delta frontier advanced at egress-build time with no rollback
on upstream failure. The selection now stashes pendingResponsesDelta
on the Prepared and commits session.responsesDelta only in the relay
when the upstream response status is < 400 (4xx -> null = reseed next
round; never advances on failure).

M1: stage-0 arming now requires the pluginLaneServerHistory rollout
(featureEnabled in runStage0), tying R3 to the rollout that makes it
reachable. M2: checkR3Identity is now the single R3 arbiter, called in
runStage0. M3: the R3 breaker latch persists (l1_world.r3_latched_at,
probe-first ALTER, upsert — the first fault precedes the session's
first l1 row) and survives a process restart; a latched session
degrades forever, never 400s again. M4: A1d pins the kernel-core
byte-identity at the CODEC level (the new element's core is
byte-identical between the M1 full-array parse and the M2 standalone
parse, wireIndex aside). M6: session.responsesDelta is cleared at
every stage-0 resync (s0.resynced). M5: PR body rewritten to match
the code.

Shared stage-0: the pin + R3 + stage-0 decision + assembly moved out
of the openai lane into src/snapshot/stage0.ts (runStage0), wired
into BOTH the openai and responses lanes (the responses lane reads
biliMsgIds/biliLedgerSeqs from its body; cohort = pluginMode +
declared).

Tests: tests/issue5874-2x2-p3.test.ts 40/40 (was 33): new A1d (M4
codec pin), B0a (skipPlaneFlush leaves the plane untouched), B0b
(egress bypass ref-identity), M3 (latch persistence across store
instances), and HTTP e2e B1 (400 + header + zero upstream forwards),
B3 (pure continuation raw passthrough), B4 (400 turn does not commit
the frontier; the next round re-seeds the full view). Regression:
snaplane-p2+snapshot-render+chain+shadow 41/41, storage-engine-proofs
+opencode-rolling 22/22, snapbase-p0+snaplane-p1+fastpath+
responses-previous-response-id 23/23, tsc clean.
2026-11-14 16:10:48 +08:00
ranxianglei 815d09527f feat(#5874 2×2): 2×2 snapshot egress modes — stage-0 world match, kernel-input assembly, delta outbound (#6181)
Implements the 2×2 brief (discussion 5874 comment 19544722) on top of the
P2 plane, kernel unchanged. The snapshot table (l1_world + row rows) stays
the single truth; the two selection points are independent:

- Inbound (stage 0, prepare-openai lane): the client's (sess_raw, msgid[])
  pair is matched against the stored world canon (matchWorld:
  echo/probe/scatter/issue/diverge/resync). Probe rounds assemble the kernel
  input from plane rows + only the NEW span, so M1 (full resend) and M2
  (incremental) reach byte-identical kernel cores. R3 identity faults
  (declared msgids vs element count) 400 with zero side effects, 3-strike
  window latch degrades to the legacy path.
- Outbound (egress stage, snap-egress + prepare-responses): the snapshot
  view carries a per-element side channel; the responses lane (provider
  retains context via previous_response_id) selects seed/delta/no-op via
  selectOutbound — first round full (incl. anchors), next rounds only new
  rows, isFullResend trips a reseed. Degrade to legacy resets the delta
  frontier (one-round convergence, #7).

Files: src/snapshot/{assemble,checksums,delta,identity,plane,types}.ts
(new), store.ts snapStage0/snapStage0Cores/snapStage0Reset facades,
snap.ts l1 envelope + clearSnapPlaneDead, msgid-pin.ts seqs channel,
session.ts responsesDelta persistence, architecture.md map.

Tests: tests/issue5874-2x2-p3.test.ts (33: verdicts ±, M1/M2 byte pin,
T5 scatter pin, #7 resync, #8 delta pin, R3 red gates, store round trip).
Regression: p1/p2/fastpath 23/23, snapshot-render 24/24,
storage-engine-proofs 12/12, opencode-rolling 10/10. tsc clean,
unused-export gate clean, architecture-docs guard green.
2026-11-14 16:10:48 +08:00
ranxianglei 1a81e59438 refactor(#5874 P2): mapEgress direct authority — no per-round diff, event-level plane writes
Owner ruling (2026-11-11): the snapshot plane is the DIRECT outbound
authority. No tripwire, no normalized diff, no sticky exclusion, no
seam-walk re-derivation. The plane stores the kernel's OWN tagged
processTurn output (invariant v); egress serves the plane rows and the
result is byte-identical to the legacy egress by construction.

Write side (store.ts snapViewEvents):
- Event-level increments (cast / update / delete / compact) derived from
  the kernel's tagged view, committed in one transaction with the legacy
  save (same tick). No per-round full diff.
- Plane-first row mapping (alias, then tag-stripped identity, then live
  ledger) — remint-stable: an identity-seed upgrade (#3752) re-keys the
  block to the client's re-minted ids, but the plane rows keep their
  positions and aliases, so the reminted save is a no-op.
- Covered rows compact LAST (after every cast/update/delete), protected
  set = mapped view positions plus the pin spans (view pin: first user
  row in the kernel view; transcript pin: first user row on the plane) —
  the kernel serves a pinned first user only when that row is in the
  kernel INPUT, so the plane must keep pin rows active even when covered.
- A/B oracle at fold time: view-vs-plane active-row identity multiset
  (remint-proof, tag-stripped); a mismatch latches the session
  plane-dead and legacy keeps serving. Replaces the legacy-table A/B.

Egress (snap-egress.ts):
- Reads the plane rows in pos order; serving = the active non-anchor
  rows (coverage by the plane's own active flag / cover_ref, never by
  id matching — alias matching mis-fired on a fresh reminted row whose
  core_ids carried a covered base id, the #4052 fresh-repeat case).
- Each active block's stored anchor summary (served verbatim from its
  plane row) is moved to its covered run's pair-safe position: the run
  is read from the rows' cover_ref MIN — immune to the #3752 re-key
  (resolving through the block's effectiveMessageIds first-sees the
  re-appended covered duplicates at fresh seqs and parks the anchor at
  the tail).
- Anchor clamp (#3642 pin run), #4311 visible-compress-call suppression,
  stale rendered-summary drop — kernel prune/rebuild parity.
- One-round legacy degrade on: flag off, cohort excluded, plane
  dead/missing, unparsable row, or any assembly exception (never
  throws). Reasons on /__bili/status under snaplane.egress.

Lanes: session.lastPlaneMessages carries a deep copy of the kernel
output to the in-request flush; forensics removed.

Tests: P2 suite rewritten to the direct-authority model (17 tests:
write-side W1-W5, egress E1-E7, gates G1-G5); snapshot-render 12/12;
opencode-rolling 10/10. Docs: config reference + proposal READMEs
updated to the final form (tripwire removed by owner ruling).
2026-11-14 16:10:48 +08:00
ranxianglei 3597fdc67e ci(#5874 P2): satisfy the guard jobs — config seeds, architecture doc, lock sync, internal types
- website/config-reference/process.yaml: seed storage.snapBase.egress /
  storage.snapBase.egressCohorts and regenerate docs/configuration*.md
  (config-surface-guard, docs-sync)
- reference/architecture.md: register src/server/snap-egress.ts
  (architecture-docs)
- package-lock.json: sync the kernel workspace to 0.0.189 (lock-sync)
- snap-egress: drop export on the file-local SnapEgressDeps /
  SnapEgressStatusWire interfaces (unused-exports)
2026-11-14 16:10:47 +08:00
ci-check f11f3fc402 docs: architecture map schema note v11 → v12 — this branch bumps STORAGE_SCHEMA_VERSION (#5874) 2026-11-14 16:10:47 +08:00
ci-check ce023c6d87 docs: list src/storage/snap.ts in the architecture file map (#5874) 2026-11-14 16:10:47 +08:00
ranxianglei 709596e033 msgid: pi+omp full-resend turns onto the biliMsgIds envelope (#6525/#6539) 2026-11-14 15:38:39 +08:00
ranxianglei ed0e84fcc0 fork: msgid identity track for the plugin fork protocol (#6262)
Principle 1 of the four-principles proposal (discussion #6262): identity,
not bytes, decides which prefix a fork inherits. The plugin-protocol
channel (dsh/omp/pi declared forks) gains an optional msgid track:

- a host-pinned parent exposes the host's stable message ids AS its
  snapshot rawIds, so the child may present the host id of each matched
  prefix message (prefixMsgIds) plus the hash-run length (driftFrom);
- the server accepts a byte-drifted prefix only when every presented id
  equals the parent's rawId at its slot; the receipt is marked
  status "drifted" (or "expanded+drifted") with the verified
  driftFrom echoed;
- a gate failure never fails the fork: the byte-verified strict fork
  proceeds exactly as before (no 409); malformed shapes are 400; parents
  without host-pinned ids make the track a no-op (byte path unchanged).

Client: lanes inject their existing parity-pinned collectors (dsh
hostMsgIdsOf; pi/omp laneMsgIdsForWire on the anthropic wire with the
same content-pinnable gate the incremental pin uses); fork-adopt
performs only the core-alignment length lock — no new validator copies,
msgid-rule-parity matrix untouched. opencode-v2 is not wired in this PR
(byte track, follow-up).

Tests: tests/issue6262-fork-msgid-track.test.ts (8) — client prefix
extension across a drift cell, the byte-fallback arms, a full-chain
proxy round trip, and the server gate (drifted receipt / strict
fallback / 400 arms). Docs: msgid-infrastructure.md consumer 6,
plugin-protocol.md section 8, architecture.md.
2026-11-14 15:38:39 +08:00
ranxianglei e484c0322f Merge remote-tracking branch 'origin/master' into fix-2817
# Conflicts:
#	tests/notice-registry.test.ts
2026-11-14 00:57:16 +08:00
ranxianglei 99c22d283f Merge pull request #6514 from ranxianglei/2026-11-13_announcement-policy
docs(governance): 公告政策——禁止全员广播、owner 确认、写明影响范围、插件公告必须触发式 (#6508)
2026-11-13 15:46:07 +08:00
ranxianglei baaeab5bae docs(governance): announcement policy — no broadcast-to-all, owner confirmation, blast-radius PRs, plugin notices trigger-only (#6508)
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.
2026-11-13 15:45:13 +08:00
ranxianglei e6e4ad90bc fix(notices): gate announcement records on the live conflict scan via requiresScan (#6508)
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
2026-11-13 13:59:07 +08:00
ci-check 8edc22ab6a docs(architecture): add src/server/rejection-diagnostics.ts to the module map
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.
2026-11-13 13:10:31 +08:00
ci-check a5996bb931 Merge remote-tracking branch 'origin/master' into pr6151-conflict
# Conflicts:
#	src/server/prepare-anthropic.ts
2026-11-12 22:37:56 +08:00
ranxianglei 873715d40a Merge pull request #6439 from ranxianglei/afloat-dry
[PR] chore(batch): land 50 open Afloat16 fixes in one history-preserving batch
2026-11-12 22:01:24 +08:00
Afloat baf19a1411 docs: register shared TOML integer reader in architecture map
(cherry picked from commit 46a95888c2)
2026-11-11 23:02:54 +08:00
ranxianglei c26c31ace4 Merge pull request #6260 from ranxianglei/handoff-render-ework
[PR] Web Panel: Handoff Documentation and Collapsed Tree Diagram Rendering Upgrade (eWork-Level Rendering, Appendix Sectionin | Web 面板:交接文档与压缩树图渲染升级(eWork 级渲染、附录分节、冻结快照水合)
2026-11-11 22:55:07 +08:00
ranxianglei bb8de86c3c web: eWork-grade handoff document rendering (markdown + syntax highlight + role cards)
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).
2026-11-11 10:24:37 +08:00
ranxianglei 1090cd8764 pi lane: drop the persistent nudge record line — transient verbatim notify only
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
2026-11-11 09:38:10 +08:00
ranxianglei 56bb58302e pi lane: align the nudge view with billion-context-pi #326
- 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
2026-11-11 09:05:48 +08:00
ci-check 24ff4e2d74 docs(architecture): register src/acp-block-ops.ts in the file map (#5765)
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).
2026-11-11 06:05:53 +08:00
ranxianglei 141cfbcf97 pi lane: show the injected nudge text verbatim in the transcript when debug is on
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.
2026-11-10 23:55:59 +08:00