Skip to content

refactor: delegate session-handoff rendering to acp-kernel - #435

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-09-01_kernel-handoff-export
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-09-01_kernel-handoff-export

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Removes the duplicated session-handoff markdown logic from the proxy by delegating to the kernel's shared renderer (acp-kernel PR #183), so the proxy and billion-context-pi no longer each carry a copy of renderHandoff / renderMessage / matchSession (requested in ranxianglei/billion-context-pi#271).

Changes (src/export.ts)

  • The v3-snapshot path (s.lastMessages) now delegates the whole doc — metadata header + folded (prune) / full conversation — to kernel renderHandoff({coreMessages, state, full, meta}), with protocol / upstream / requests injected via meta.extraBullets.
  • The v2 fallback (per-block summaries + blockContents originals) is unchanged and stays byte-identical.
  • matchSession now comes from the kernel (label accessor = s.meta.label).
  • Bumps acp-kernel 0.0.47 → 0.0.49 (the release that ships the handoff exports). package-lock.json is refreshed once 0.0.49 is on npm.

Verification (local pre-validation against acp-kernel#183's build, 0.0.48-pr.183.36)

  • npm run typecheck — clean
  • npm test — 892 pass, 0 fail (incl. tests/cli-export.test.ts, which asserts the v2-fallback output is byte-identical, and tests/export-uncompressed.test.ts for the v3 path)
  • npm run build — success
  • Byte-identity check: rendered the same representative session (all four content types, empty message, role grouping, one active compression block) through the old master code and the new delegated code — outputs are byte-identical for both full=false and full=true.

Dependency / merge order

Blocked on acp-kernel#183 merging + acp-kernel 0.0.49 publishing. Until then CI is red at npm ci (cannot resolve 0.0.49). After 0.0.49 is live, run npm install to refresh the lockfile and the PR goes green.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 ework agent · qwen3.8-27b

[bot] 🏷 Investigated PR #435. Status: blocked on an upstream dependency — not a code problem.

Dependency state (verified just now):

  • acp-kernel PR release v0.1.45 #183 (adds renderHandoff / renderMessage / matchSession) is still open, not merged.
  • acp-kernel 0.0.49 is not on npm. Latest stable is 0.0.48, which does not export the handoff functions — only the release v0.1.45 #183 pre-release 0.0.48-pr.183.37 ships them.
  • So this PR's acp-kernel: 0.0.49 pin can't resolve → CI red at npm ci, exactly as noted in the issue.

Code review (against the #183 pre-release): the delegation is correct and byte-identical:

  • renderHandoff metadata order (title → label → session id → protocol → upstream → requests → last-context-tokens → compression-blocks) is reproduced via meta.extraBullets; the folded/full conversation section and per-message rendering match the old proxy code exactly.
  • matchSession(all, selector, (s) => s.meta.label) is semantically identical to the removed local helper (exact id → exact label → prefix on id-or-label).
  • The v2 fallback path is untouched.

Next: I'm running the PR branch against 0.0.48-pr.183.37 (typecheck + export tests + build) to confirm it goes green the moment 0.0.49 lands. Will follow up with results.

Unblocking needs (human/CI): merge acp-kernel#183 → publish acp-kernel 0.0.49 → then npm install here to refresh the lockfile.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 ework agent · qwen3.8-27b

[bot] 🏷 Validation results — ran the PR branch locally against the #183 pre-release 0.0.48-pr.183.37 (the only build that ships the handoff exports):

  • npm run typecheck — clean (exit 0)
  • npm test — 892 pass, 0 fail (includes tests/cli-export.test.ts v2-fallback byte-identity and tests/export-uncompressed.test.ts v3 path)
  • npm run build — success, dist/index.js 2.58 MB (kernel inlined, zero runtime deps)

So the code is merge-ready: it will go green the moment 0.0.49 is resolvable.

One thing to note for the unblock step: the pushed branch changed only package.json (0.0.47→0.0.49) and src/export.ts — package-lock.json was not refreshed. So npm ci is currently failing twice over: (a) lockfile out of sync with the 0.0.49 pin, and (b) 0.0.49 not on npm. Once 0.0.49 is live, a single npm install fixes both (refreshes the lockfile), and the PR goes green — matching the issue's plan.

Remaining (human/CI only, I can't do these):

  1. Merge acp-kernel#183 (still open).
  2. Publish acp-kernel 0.0.49 (release flow).
  3. Here: npm install to refresh the lockfile → PR green → merge.

Nothing to fix in the PR itself. Standing by for the dependency to land.

@ranxianglei

Copy link
Copy Markdown
Owner Author

Closing as duplicate of #434 — same session-handoff delegation to acp-kernel; keeping #434 (newer, includes the kernel lockfile refresh). The surviving PR needs a rework against the #587 export rewrite but keeps the intent tracked.

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