Skip to content

fix(affinity): append-continuation rung + hv2 ladder preference (#2807 regressions) - #2812

Merged
ranxianglei merged 1 commit into
masterfrom
fix/2807-append-continuation
Oct 11, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
fix/2807-append-continuation

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

Fixes the three test regressions introduced by #2807 (surfaced on the v0.1.193 release PR #2767 CI):

failing test root cause fix
fork-adoption-wires disabled-adoption assert follow-up appends an assistant message after an assistant tail → neutral merge rewrites the stored tail turn's hash → extra fork-of-fork mint leaks into the scan rung 1.4 append-continuation: per-source-message tail fragments (tailFrags) persisted on the chain; stored frags strict-prefix of incoming turn-at-K-1 frags + byte-equal first K-1 items ⇒ same conversation extended in place, match instead of mint
issue2033-anonymous-anchor 58701 !== 5000 same mint cascade orphaned the usage anchor onto a phantom session same rung 1.4 + hv2 ladder preference (below)
issue2601 placeholder filter branch placeholder text blocks joined with "" defeat the USER_IMAGE_PLACEHOLDER line filter placeholder blocks/parts dropped during neutral-text collection

hv2 ladder preference (upgrade seam, affects real users)

The v1 (pre-#2791 raw-wire) fallback rung could out-vote a matching hv2 chain by raw depth — but raw counts messages while neutral counts turns (16 vs 13 for the same history), so a stale pre-upgrade duplicate chain stole the request away from the live neutral session holding the fold ledger and usage anchor. Any 0.1.192 → 0.1.193 user hits this on their first post-upgrade request. Now hv2 candidates take precedence; hv1 still resolves untouched when no neutral chain matches (legacy bridge unchanged).

Verified locally

  • failing trio: issue2033-anonymous-anchor ✓ issue2601-persona-fork-lineage ✓ fork-adoption-wires ✓
  • targeted affinity sweep, 27 suites / ~190 tests all green (incl. prefix-affinity, prefix-affinity-simhash, prefix-affinity-orphan, e2e-session-identity, affinity-crosswire-fold, conflict-remediation)
  • tsc --noEmit clean

Full local suite running in parallel; CI is authoritative.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: fix/2807-append-continuation (1b7e380)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3113-pr.2812.72cae7c

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-pr2812.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei
ranxianglei force-pushed the fix/2807-append-continuation branch from 5a942e8 to 2853ae5 Compare October 11, 2026 15:25
…regressions)

#2807 made the anonymous/identified identity chains hash the wire-NEUTRAL
projection. That exposed three regressions (all three failing legs on the
v0.1.193 release PR #2767):

1. The neutral projection MERGES a run of consecutive same-role messages
   into one turn (required for cross-wire equality — the anthropic render
   joins the run). A client that APPENDS another assistant message after
   an assistant tail (agent harnesses replaying model replies, fork
   follow-ups) re-renders the stored tail turn, so its item hash changes
   and the exact ladder fails by ONE item → fresh pfa-* mint → the fold
   ledger and the usage anchor are orphaned (spurious fork-of-fork
   children in fork-adoption-wires, 58701-vs-5000 sizing in
   issue2033-anonymous-anchor).

   Fix: per-source-message tail FRAGMENTS (fragmentHash) are now carried
   on every NeutralTurn, persisted on the chain (ChainEntry.tailFrags,
   snapshot round-trip included) and forwarded through note() from all
   resolve() paths. New rung 1.4 (append-continuation): a stored hv2
   chain whose first K-1 items are byte-equal AND whose stored tail
   fragments are a strict PREFIX of the incoming turn-at-K-1 fragments
   is the same conversation extended in place → match instead of mint.

2. The v1 (pre-#2791 raw-wire) fallback rung could OUT-VOTE a matching
   hv2 chain by raw depth (raw counts MESSAGES, neutral counts TURNS —
   16 vs 13 for the same history) and steal the request to a stale
   pre-upgrade duplicate session. Any user upgrading 0.1.192 → 0.1.193
   hits this seam on their first post-upgrade request. Fix: within the
   ladder, hv2 candidates now take precedence over hv1; hv1 still
   resolves untouched when no neutral chain matches (legacy bridge).

3. Image placeholder text blocks were joined with "" into the neutral
   text, so the USER_IMAGE_PLACEHOLDER line filter could not strip them
   (issue2601 filter-branch replay). Placeholder blocks/parts are now
   dropped during neutral-text collection.

Local: full targeted affinity sweep (27 suites) green; failing trio green.
@ranxianglei
ranxianglei force-pushed the fix/2807-append-continuation branch from 2853ae5 to 1b7e380 Compare October 11, 2026 15:26
@ranxianglei
ranxianglei merged commit 9fb9164 into master Oct 11, 2026
28 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.288-master.9fb9164 (rolling master tag).

npm install -g billion-context@0.0.288-master.9fb9164  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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