Skip to content

feat(server): move document extraction and context handoffs to Rust (step 18b) - #318

Merged
opficdev merged 1 commit into
mainfrom
feat/server-18b-documents-handoffs
Dec 6, 2026
Merged

opficdev merged 1 commit into
mainfrom
feat/server-18b-documents-handoffs

Conversation

@opficdev

@opficdev opficdev commented Dec 6, 2026

Copy link
Copy Markdown
Member

Summary

Moves step 18b of docs/bridge-to-rust.md (documents and context handoffs) out of the Node provider bridge into Rust and bumps the bridge protocol to version 15.

  • Documents (tern-server-assets::document):
    • Ported upstream's DocumentText.ts and documentTextWorker.ts (docx, xlsx, pptx, odt, ods, odp, rtf, epub, ipynb) onto zip, quick-xml (with escape-html), and encoding_rs, preserving its 16 MB input limit, 15 s timeout, two-slot concurrency semaphore, failure cache, in-flight deduplication, and atomic .txt sidecar publish.
    • Dropped tern-server-assets's dependency on tern-server-bridge.
    • Added crates/server/tests/own_documents.rs generating all nine formats (+ invalid RTF), recording upstream's worker output via TERN_RECORD=1 into crates/server/tests/fixtures/own-documents.json, and comparing in every test run and CI harness run.
  • Context handoffs (tern-server-threads::turns::handoff_budget):
    • Ported handoffBudget.ts, ContextHandoffService.ts (prepareProviderHandoff, prepareLegacyImport, makeLegacyImportSummary without upstream's product name), and ContextHandoffDelivery.ts (deliverContextHandoffs over SessionRuntime::context_window and Operation::InjectHistory).
    • Wired handoff.rs, switch.rs, fork.rs, imported.rs, and start.rs directly to Rust.
  • Bridge cleanup & protocol bump (14 -> 15):
    • Removed bridge/src/handoffs.ts, document.ensureText, handoffs.*, DocumentText.layer in bridge/src/host.ts, and __document-text in bridge/src/bin.ts.
    • Bumped PROTOCOL_VERSION from 14 to 15 in bridge/src/protocol.ts and crates/server-bridge/src/lib.rs.
  • Docs:
    • Marked 18b done in docs/bridge-to-rust.md, updated docs/server-orchestration.md, docs/crates.md, and regenerated docs/crates.svg.

Verification

  • cargo fmt --all -- --check
  • ./scripts/check-layers.py (53 crates, 0 allowed edges)
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo test --workspace --locked (scratch HOME, TERN_KEYCHAIN=off)
  • ./scripts/check-bridge.sh & ./scripts/bundle-bridge.sh & scripts/smoke-server.mjs
  • Differential harnesses (Node 26.13.1, scratch HOME, TERN_KEYCHAIN=off): own_documents, own_switch, own_fresh, own_imports, own_attachments, own_forks — all 6 passed with 0 differences.
  • Real run: uploaded a .docx to a scratch tern-server and dispatched a Replay message with it attached; verified both pending and claimed .docx.txt sidecars matched extracted text.

@opficdev
opficdev enabled auto-merge (squash) December 6, 2026 09:58
@opficdev
opficdev merged commit fe9b179 into main Dec 6, 2026
20 checks passed
@opficdev
opficdev deleted the feat/server-18b-documents-handoffs branch December 6, 2026 10:13
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