Skip to content

fix(#2601): absorb header-corroborated model-drift into the persona anchor - #2727

Merged
ranxianglei merged 2 commits into
2026-10-11_2601-model-switch-lineagefrom
2026-10-11_2601-model-drift-absorption
Oct 11, 2026
Merged

ranxianglei merged 2 commits into
2026-10-11_2601-model-switch-lineagefrom
2026-10-11_2601-model-drift-absorption

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Stacked on #2719 (base branch = its head). Proposal discussion: #2601 (comment)

What

#2719's churn-tolerant continuity makes a plain model switch MIGRATE. The residual fork shape is the conjunction: the model switch (fp changes) lands in the same window as an unannounced history rewrite (chain discontinuity — dsh local compaction / checkpoint) and the main lane still forks — exactly the XR1988 corpus shape (prompt-switch-heavy sessions + substrate destroyed events on the fork keys).

This PR absorbs the fp half when two independent host declarations corroborate the drift:

  1. the x-bili-plugin-model header actually changed (anchor-recorded model ≠ this request's model — src/agent/dsh-native.ts stamps it per request), and
  2. the system line-diff is confined to lines that name the old model (before) / the new model (after), folded to alphanumerics (display-name render vs header key both match).

→ migrate-model, raw key, compression state stays. No host-specific phrasing is hardcoded — only the header-declared names are matched. Anything less keeps the fork exactly as before: no header on either side, unchanged header model, an extra changed line (AGENTS.md edit), a line-count change, or a genuinely different (auto-review) system.

The recorded anchor model is only refreshed on a same-fp re-declaration when the new name actually renders in the system text — the invariant "anchored.model is a name the model line contains" is what makes the old-side containment test sound.

Tests

tests/issue2601-model-drift-absorption.test.ts (11 cases): absorbed switch migrates; missing header on either side forks; unchanged header forks; non-model line forks; line-count change forks; folded display-name variants corroborate; A→B→A stays on the raw key; continuing history still takes plain migrate (continuity runs first); auto-review system still forks; alias re-declaration refresh invariant; personaNamespace logs the absorbed migration. Adjacent: dsh-persona-continuity / issue2601-persona-fork-lineage / session-id / dsh-persona-fingerprint / fold-reconcile ×2 = 109/109; typecheck clean; build OK.

Config surface

None (no new config/env/CLI).

Kernel boundary

Host-side only (src/persona-anchor.ts, src/server/handle.ts plumbs the already-parsed header). No changes under kernel/.

Notes

  • Identity/session-binding logic → human review per §7.4.
  • The StarflowDream timestamp plugin (no header to corroborated) is deliberately NOT absorbed — out of scope, root fix is dsh-side (move time context out of system).

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review of #2727 complete. What I verified: pulled head 6583410d6 against base (#2719 head 988183a3), read the full diff hunk-by-hunk (3 files), traced the header plumbing end-to-end (src/agent/dsh-native.ts:1273 stamps per request → pluginReportedModel src/plugin.ts:197 → the four personaNamespace call sites in src/server/handle.ts), ran the new suite plus adjacent suites locally at the PR head (132/132 green, typecheck clean), checked CI, and did duplicate screening (no parallel B' implementation among open PRs; closest are the stacked base #2719 and older #2244, distinct mechanisms).

Structured conclusion (八问):

  1. 是什么问题: After fix(#2601): model-switch lineage — churn-tolerant chain continuity + persona-fork routing follow #2719 made plain model switches migrate, the residual fork shape is the conjunction — a model switch (fp change) landing in the same window as an unannounced history rewrite (dsh local compaction / checkpoint chain break) still forks the main lane onto a |sub:<fp> ghost (the XR1988 corpus shape). This PR absorbs the fp half of that conjunction when the drift is corroborated by two independent host declarations.

  2. 什么原因导致的: The fork decision keyed only on system-fingerprint equality and ignored two wire-declared facts: (a) the host's per-request x-bili-plugin-model header actually changed, and (b) the system diff is confined to the model-identity line(s). Here the fp change is the model switch rendered into the system text, not a persona change — forking on it mistakes the symptom (fp moved) for the mechanism (persona switched).

  3. 影响范围与严重程度: Only dsh pluginMode sessions where a model switch coincides with an unannounced rewrite inside the anchor window — previously permanently forked (compression state lost, substrate destroyed events on fork keys). All other traffic is a strict no-op: non-dsh lanes carry no x-bili-plugin marker so pluginReportedModel is undefined and absorption is disabled; missing/unchanged header, extra changed line, or line-count change keep the exact pre-PR fork. Severity: state-loss class under a specific conjunction, not an availability break.

  4. 怎么修复的: A dual-fact corroboration gate in resolvePersonaKey, placed AFTER continuity so plain migrate still wins: absorb iff the anchor-recorded model differs from this request's header model (raw or alphanumeric-folded) AND both systems have equal line counts AND every changed line contains the old model name (before) / new model name (after) folded. An absorbed switch takes the new migrate-model action on the RAW key — compression state stays. The recorded anchor model refreshes only on same-fp re-declaration when the new name actually renders in the system text, preserving the invariant "anchored.model is a name the model line contains" that makes the old-side containment test sound. No host-specific phrasing hardcoded — the implementation matches your B' proposal in the [Bug] dsh 会话反复 model/provider 切换时主对话迁移到 |sub:<fp> persona fork,宿主盖章的 compress/decompress/acp_status 仍解析在陈旧父 id —— ref 跨空间不可解析直至熔断 #2601 thread 1:1, including deliberately leaving the StarflowDream timestamp plugin out (no header channel; root fix is dsh-side).

  5. 是否有回归问题: Walked the touched paths' existing behaviors item by item:

    • fork-key format <rawId>|sub:<fp> — unchanged ✓
    • passthrough / claim / match / migrate / fork semantics — unchanged except the new migrate-model path (the intended change, disclosed below) ✓
    • match-path model refresh — internal record update only, returned key identical ✓
    • non-dsh lanes (codex/claude-over-Responses via the instructionsFingerprintApplies site) — pluginReportedModel undefined there, strict no-op ✓
    • BOTH compression modes reasoned (§6): routing-only change, zero wire/message-shape change; dsh is pluginMode by definition; proxy mode untouched ✓
    • high-risk patterns: no fail-fast→swallow, no threshold/timing/output-format drift; exactly ONE new additive info log line ✓
    • Intended behavior change (old→new): dual-corroborated model-switch+rewrite requests previously FORKED onto <id>|sub:<fp> → now stay on the raw key via migrate-model. That IS the fix.
    • Minor observation (flagged, not fixed, low severity): anchor map entries grew from a 16-hex fp string to {fp, full system text, model?}. The map was never evicted before either (pre-existing design), so long-lived processes now retain full system text per conversation id — MB-scale even at hundreds of conversations, negligible next to the proxy's session-state footprint. No action needed unless you want an eviction policy later.
  6. 是否破坏缓存: No. Staying on the raw key preserves compression state, ref ledgers, and incremental cursors (that's the point); persistence format/keys unchanged (anchor records are process-memory-only, as documented in the module header); upstream prefix-cache invalidation from the model switch itself predates this (existing MODEL-SWITCHES accounting, acp-cache同时统计切换模型掉缓存归因 #1535). Dedup keys and retry strategies unaffected.

  7. 是否改了设计方向: No pivot — extends the existing persona-anchor mechanism with one additional migration path, consistent with KDD release v0.1.2 #9 evidence-permitlist discipline (a generic rule keyed on host declarations, not a new host entry).

  8. 是否引入了新的配置: None — verified no new env/config/CLI surface in the diff (PR body's "Config surface: None" confirmed).

Test-quality gate: the 11 cases are deterministic hermetic unit tests pinning every boundary of the rule (absorb; missing header on either side forks; unchanged header forks; non-model line forks; line-count change forks; folded display-name variants corroborate; A→B→A stays on the raw key; continuity runs before absorption; auto-review system still forks; alias re-declaration refresh invariant; log surfacing). Each assertion has teeth — each catches a distinct regression. Diff cleanliness: single commit, 3 files, every line purposeful, no whitespace churn, no lockfile/generated noise.

CI status: all 8 workflow runs on the branch are green (e2e-codex-persona, e2e-dsh-plugin-lane, e2e-native-dsh, e2e-fake-codex, e2e-native-opencode, e2e-pi-codex-ws, e2e-native-pi, e2e-local-registry; check-runs 10/10 success). One note: the main ci.yml matrix (~30 jobs incl. typecheck/test/build) did NOT run on this PR — its triggers require base=master and this PR bases on #2719's branch, which is expected for a stacked PR; the full matrix will gate when the stack lands. Compensation: local typecheck clean + 132/132 targeted tests at the PR head.

判定:可合 — direction matches the approved B' proposal, implementation is faithful to it, tests pin the boundaries, branch CI green. Per §7.4 identity/session-binding logic requires human sign-off; auto-merge does not apply. Please merge yourself when ready: #2727

ranxianglei and others added 2 commits October 11, 2026 12:09
…nchor

A model switch landing in the same window as an unannounced history
rewrite (dsh local compaction) still satisfies the fork conjunction even
with #2719's churn-tolerant continuity: fp changed AND chain
discontinuous. dsh declares its model target on every request via
x-bili-plugin-model — consume both host declarations: the header model
changed AND the system line-diff is confined to lines naming the old/new
model (folded) => absorb the fp half (migrate-model, raw key). No
host-specific phrasing hardcoded; anything less keeps the fork.
@ranxianglei
ranxianglei force-pushed the 2026-10-11_2601-model-drift-absorption branch from b75e433 to e2da718 Compare October 11, 2026 04:09
@ranxianglei
ranxianglei merged commit ed86e5c into 2026-10-11_2601-model-switch-lineage Oct 11, 2026
10 checks passed
@ranxianglei
ranxianglei deleted the 2026-10-11_2601-model-drift-absorption branch October 15, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant