Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6a9d403
fold anchoring doctrine: order over hash (#3641, fixes #3588, fixes #…
Oct 18, 2026
a9fe72f
kernel: bump acp-kernel 0.0.130 -> 0.0.131 for the prune.ts placement…
Oct 18, 2026
0825bde
ci: sync package-lock.json to acp-kernel 0.0.131 (lock-sync after the…
Oct 18, 2026
1a3949a
docs: correct epochConfirmPending consumer note to match implementati…
Oct 18, 2026
be8709a
test: regenerate storage-render goldens for the new fold-drift metada…
Oct 18, 2026
5b2f672
fix: pin BILI_IMAGE_RESCALE=0 in the storage-render golden regen scri…
Oct 18, 2026
682173e
docs: snapshot-as-session doctrine section in MESSAGE-IDENTITY (#3641…
ranxianglei Oct 18, 2026
4165380
feat(wire): protocol-stable canonical core identity (#3642)
ranxianglei Oct 18, 2026
6663f89
kernel: pin the opening wire message's whole core run + fix stale goo…
Oct 18, 2026
3c940c5
kernel: keep trailing opaque parts when flushing leading ones (#3658 …
Oct 18, 2026
acc2aea
chore: sync root package-lock.json to acp-kernel 0.0.132 (lock-sync a…
Oct 18, 2026
93d2406
probe: master + #3658 (protocol-stable core identity) for full-CI run
Oct 18, 2026
5a35de5
ci: retrigger — PR body now carries the kernel-change declaration (re…
Oct 18, 2026
aa23b34
kernel: openai non-array content tolerance + golden regen + inverted …
Oct 18, 2026
c0f7873
probe: carry the shard-3 fixes (aa23b34c)
Oct 18, 2026
5fd814c
image-restore: conversion failures stay fail-open but WARN once per s…
Oct 18, 2026
e4ce98d
probe: carry the visibility warn (5fd814c6)
ranxianglei Oct 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag

- **Automatic upgrades now stagger across a window instead of landing within minutes; a public policy file controls the window fleet-wide (#3619).** Every bili instance that discovers a new version draws ONE random moment inside a delay window (built-in default **15 min – 48 h**), persists it, and upgrades when it arrives — restarts never re-roll. Before this, a release hit every auto-updating install within ~15–30 minutes, leaving no time to stop a bad one mid-rollout (#3401/#3600/#3394 were all shipped-too-fast incidents). The window and the emergency controls live in `auto-update-policy.json` in this repo, fetched anonymously (plain GET + ETag, zero telemetry, fail-open — an unreachable or malformed file falls back to local defaults): `hold` freezes automatic upgrades fleet-wide, `blocked` skips listed versions, `pinned` sets an upgrade ceiling, and per-version `overrides` tune the window (`{ "range": ">=0.1.200", "maxDelay": "1h" }`). Delay fields take human-readable durations — `"15m"`, `"2d"`, `"1d12h"` (units s/m/h/d/w, combinable; plain numbers still mean raw ms); malformed values are ignored with a warning, never guessed. The file steers timing/skip/pin only — it can never control what gets installed (no URLs, no commands; target versions must exist in the npm packument). Exits: manual `bili update` bypasses `hold`/stagger (still respects `blocked`/`pinned`), `update.staggerMinDelayMs: 0` + `update.staggerMaxDelayMs: 0` (or the `BILI_UPDATE_STAGGER_*_MS` twins) restore legacy immediate upgrades on one machine, `ACP_AUTO_UPDATE=0` disables auto-updates entirely. The update-driven e2e suites pin stagger 0/0 + an unroutable policy URL — they test periodic-update mechanics, not rollout timing.

- **openai wire: non-array content tolerance (kernel 0.0.133, #3658 follow-up)** — the #3642 per-part rewrite iterated `messages[].content` and threw `TypeError: m.content is not iterable` on clients that emit a lone content-part object instead of an array (#2824 corpus caught it). Non-array non-string content now degrades to the legacy empty-text core (byte-compatible ids and bytes with the pre-#3642 codec) instead of throwing. Also regenerates the storage-render chat goldens for the documented one-time canonical re-key (tool-pair ids), and inverts the retired reconcile-off id-churn control into an absorption canary: with reconcile OFF, tool_call id rewrites + argument re-serialization must not disturb fold coverage (canonical ids absorb them by construction).

- **protocol-stable core identity: the same logical conversation now yields byte-identical core message ids in all four dialects (#3642).** Wire codecs previously baked dialect accidents into message identity: anthropic used `"[image]"` as image text while openai deliberately kept `""` ("switching the seed would move every pre-existing shape"), tool-call ids embedded the provider's `toolCallId` bytes, raw JSON tool arguments hashed verbatim (key order = new id), and responses' empty-text reasoning cells seeded from the provider's volatile `item.id`. Switch protocols mid-session (opencode #3640: `/chat/completions` → `/v1/messages`) and ~20-68% of ids churned, tripping the fold-destroyed misdiagnosis #3641 just class-fixed. Identity now derives from a canonical form shared by all four codecs: a new `kernel/src/wire/identity.ts` (canonicalToolArgs: JSON args parsed → recursive key sort → compact stringify, verbatim for non-JSON; canonicalOpaqueSeed: provider `item.id`/`status` stripped; image marker `[image]` everywhere), the `toolCallId` slot retired from the seed (cluster suffixes disambiguate same-shape calls, deleting one sibling is local damage), and granularity normalized to one core per content part (anthropic's existing shape — its lanes take zero granularity re-keying, though tool-call/tool-result cores still re-seed since the `toolCallId` slot is retired; openai/responses/google split runs, with accumulators re-merging on rebuild so the wire stays byte-stable). The kernel first-user pin now spans the opening message's whole core run, so a multimodal opening message keeps its image bytes through folds (#781/#2607). Cross-protocol golden: text/tool/bash conversation → identical id arrays in all four dialects; canonical key-sort makes `{"file","line"}` == `{"line","file"}`. Image cells are now stamped `imagePart: true` at parse time (never text-compared — tag injection rewrites markers mid-render, which previously made image cores render as text and lose the real bytes, #767 billing fallout). Upgrade cost is one re-key of stored ids for openai/responses/google lanes; the #3641 reconcile tiers (word-bag claims, k-th image family pairing, toolCallId channel, epoch gate) absorb it without re-folding.

- **fold anchoring doctrine: order over hash — protocol switches, image offload, and host-side truncation stop being read as destruction (#3641, fixes #3588, fixes #3640).** Three real-world defect classes all shared one root: the fold's identity model keyed coverage to content hashes, so any transformation that re-mints ids without removing content (dsh's image-offload component rewriting image cells into placeholder text, opencode switching a mid-session request from `/chat/completions` to `/v1/messages`, or a host that compacts/truncates history itself) made every covered id look *destroyed*. Consequences: 7× false "compression substrate appears destroyed" escalations on healthy sessions (#3588), 298-id churn with unanchored summary blocks landing AFTER the user's newest question — the model answered five rounds of stale summaries instead of the question (#3640) — and the #2193 collapse streak on sanctioned host compaction. The reconcile pass now carries a shape tier (loose word-evidence pairing for prose cells, a flanked k-th discipline for evidence-less image cells), a residual census classifying unmatched ids as *transformed* (near-duplicate evidence exists), *absent* (content truly off the wire with the surviving wire a suffix-continuation of the episode baseline), or *drift* (nothing matches anywhere); only the third accrues the collapse streak, and a wire-frozen episode witness guarantees a foreign conversation can never quietly become the baseline mid-episode. Unresolved summary anchors clamp ahead of the newest user turn instead of at the array tail (the #3640 "stale summary after the question" shape), and a genuine total collapse now latches `foldEpochConfirmPending` and PAUSES folding (verbatim passthrough — nothing is deleted, the snapshot is kept) until the histories realign or the user confirms a new epoch, instead of escalating on a misdiagnosis. Single genuine edits below the mass bar still report drift honestly; the #1729/#2193 escalation itself stays (its error text now names the epoch gate).

- **dsh PTC sessions get compression back: a `run_code` omnibus on the wire reads as reachable, not unreachable (#3600).** dsh PTC presets collapse EVERY tool into a single `run_code` omnibus (the SDK bindings nest inside it), so the top-level tools array carries no `compress` entry. The #3427 reachability gate read exactly that shape as "tool not host-scoped → suppress the compress surface", and released 0.1.198 suppressed every dsh PTC session: 89× `ARMED-SUPPRESSED` nudges while the window ran to 100%, then the output got clamped and the session was effectively dead — silently, while standard-mode sessions on the same install kept compressing (v0.1.197 had no tools factor in its nudge gate, so this is a release regression, not "never worked"). The gate now treats a `run_code` omnibus declaration as reachable: top-level absence is not evidence of unreachability when the omnibus swallows everything. The #3177 true negative keeps its suppression (a bare single tool that is neither `compress` nor the omnibus still drops the surface), and the #3401 positive case is unchanged.

- **dsh desktop settings pane: the embed probe is admitted for the Electron scheme origin (#3513, desktop variant).** The dsh DESKTOP app renders its settings pane from the custom scheme origin `dsh-app://app` (not an http origin like dsh web). The #3514 fix echoed the requesting Origin — but the request never reached the echo: `isTrustedAdminOrigin` only accepts http/https origins, so the probe's `GET /__bili/?embed=1` died in the trust gate with a bare 403 and no `access-control-allow-origin` — the pane stayed on "正在连接 bili 代理…" forever (real-world console: "blocked by CORS policy … from origin 'dsh-app://app'"). The gate now admits exactly that one origin (scheme `dsh-app`, hostname `app`): browsers set the Origin header themselves and the `dsh-app` scheme only exists inside the dsh Electron app, so a website can never produce that Origin — while rebinding attacks still arrive with http/https attacker hostnames and stay rejected. Foreign hostnames under the same scheme (`dsh-app://evil`) and every other custom scheme stay 403; the existing #3514 echo then covers the response.
Expand Down
65 changes: 63 additions & 2 deletions MESSAGE-IDENTITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ question at session granularity). Implementation anchors:
**kernel ledger** below stays content-hash, while the **fold-coverage
re-anchoring layer** (`src/fold-reconcile.ts`) became positional-with-a-
self-stored-canonical-copy — see “The fold-coverage layer goes positional”
below; nothing in this document's ledger contract changed.
below; nothing in this document's ledger contract changed. #3641 later added
the verdict layer on top — what happens when **no** channel verifies — see
“The snapshot-as-session doctrine” below; the ledger contract still stands.

## The question is the join key, not the id

Expand Down Expand Up @@ -178,6 +180,64 @@ server-side compress may re-fold a failed replay — the healed round-2 must
never stand in for the retention proof), plus its own reconcile-off control
proving this churn class re-bills without the layer.

## The snapshot-as-session doctrine: verdict classes over the id (#3641)

#2480 made fold coverage positional-with-verification. #3641 settles what
happens when **no** channel verifies. The inversion: the **(session id +
fold snapshot) is the conversation body** — the wire is only an alignment
observation of it. Ids, hashes and shapes are hints; “which messages do my
blocks cover, in what order” is the fact. Three production classes forced
this: a protocol re-serialization re-minting every id with the words intact
(#3640), image-offload rewriting a textless family into placeholders
(#3588), and stateless clients truncating the covered slice (#2695) — all
three used to be diagnosed as "substrate destroyed".

The mechanism (all in `src/fold-reconcile.ts` plus one kernel placement
rule; proof tests in `tests/fold-anchor-doctrine.test.ts`):

- **Shape tier** (order-preserving): when a *mass* of covered ids goes
missing at once (≥ `SHAPE_MASS_MIN`), residual prose anchors pair with
inbound candidates in conversation order under the edit-honesty gate —
word-bag equality + simhash ≤ 8 + role + length guard (the same gate the
sim tier applies to gaps, applied to claims). Textless anchors (image
families: no sh/wh by construction) pair k-th-to-k-th when bracketed by
verified flanks on both sides and per-bucket counts match exactly — the
byImage discipline generalized past bili's own placeholder variant.
- **Residual census and verdict classes**: what the ladder cannot claim is
*classified*, not assumed destroyed. `shapeExplained` (transform: claims
or near-dup evidence carry the mass) — one info latch, streak reset.
`truncationExplained` (benign deletion: residuals absent everywhere, zero
near-dups, and a **wire-continuity witness** — the frozen old-order suffix
still heads the inbound) — blocks snooze instead of reaping (#2695).
Everything else is drift and escalates as before.
- **Episode witness**: at the first drift pass the old order's tail is
frozen (`foldEpisodeOrder`); a foreign conversation under the same session
id has no continuity with it, so wholesale replacement cannot masquerade
as truncation.
- **Epoch-confirm gate**: total collapse latches `foldEpochConfirmPending`,
emits one error, and preflight passes requests through verbatim — folding
*pauses*; nothing is deleted, nothing is silently reset. Alignment
recovery (the host resends the true history) auto-clears the latch.
- **Unresolved-anchor placement** (kernel `prune.ts`): a block whose anchors
all failed to resolve now inserts at the last user message instead of the
tail — a summary block can no longer ride *after* the user's newest
question (#3640's six tail-riding blocks).

The honesty boundary is deliberate: the shape tier requires **strict**
word-bag equality, so a systematic content mutation — a host re-stamping
history with a trailing `<system-reminder>` suffix, say — is *not* claimed
as the same message (fuzzy content joins misattribute on decompress; see
the rejected alternatives below). Such events classify as truncation or
collapse and land on the snooze/pause paths — never a silent re-key.
Whether a bulk identical-suffix re-stamp (N order-stable pairs sharing the
exact same delta) deserves its own *verified* class is an open follow-up,
to be sized against production logs (#3640/#3588).

Compatibility: the doctrine is a matching/verdict-layer change — zero
migration, applies to old and new sessions alike, storage-independent
(legacy JSON, shadow and full modes behave identically; bookkeeping rides
session metadata). The kernel ledger's content-hash contract is untouched.

## Known cost of the hash axiom — and how it was fixed

Same bytes ⇒ same identity has a cost face: #1476 — a user re-sends a short
Expand Down Expand Up @@ -254,4 +314,5 @@ Related: #1496 (this document's prompt), `SESSION-IDENTITY.md` (session
granularity), #1476 + kernel #459/#463 (echo discrimination), #242/#1475
(Responses id constraints), #206/#673 (tag echo), #1479/#1482 (strict-echo
repair), #1039 (tool-call byte-exactness invariant), #2396 (host-rewritten tool-call ids across a provider switch), #2480 (positional fold coverage;
`tests/identity-proof.test.ts` is its proof matrix).
`tests/identity-proof.test.ts` is its proof matrix), #2695/#3588/#3640/#3641
(snapshot-as-session doctrine; `tests/fold-anchor-doctrine.test.ts`).
Loading
Loading