Skip to content

refactor(server): establish owned generation lifecycle - #692

Open
Graffioh wants to merge 3 commits into
Luce-Org:mainfrom
Graffioh:codex/luce-engine-implementation
Open

refactor(server): establish owned generation lifecycle#692
Graffioh wants to merge 3 commits into
Luce-Org:mainfrom
Graffioh:codex/luce-engine-implementation

Conversation

@Graffioh

@Graffioh Graffioh commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Second PR in the server-refactor stack, directly following #691.

  • move generation request/result types out of the broad backend header
  • make retained GenerateRequest token sequences owned values
  • add move-only Generation and GenerationSource channel endpoints
  • bound request and token buffering and publish typed terminal results
  • make LuceEngine own ModelBackend, the serving thread, mode selection, and orderly join
  • make HttpServer borrow the engine while preserving the established serial worker and concurrent scheduler
  • document the engine components and runtime flow as they exist today

Stack

This is PR 2 of 2:

  1. refactor(server): seal backend construction behind a plan #691 — backend planning, owned configs, and grouped effective values, head a567baef9
  2. refactor(server): establish owned generation lifecycle #692 — owned generation lifecycle and runtime owner, head 2e6309477

The #692 commit is directly parented by the current #691 head. Because the branches live in a fork, this PR targets main and temporarily displays #691's commits.

Review only this PR's 15-file delta: Graffioh/lucebox-hub@codex/backend-plan-boundary...codex/luce-engine-implementation

Current boundary

server_main
  -> LuceEngine owns ModelBackend
       -> owns one serving thread
       -> selects serial worker or concurrent scheduler once
  -> HttpServer borrows LuceEngine
       -> owns HTTP, sockets, response formatting, and the current job queue

The server no longer owns backend lifetime and worker-thread lifetime as separate facts. Shutdown asks LuceEngine to stop and join its selected loop before transport and cache teardown continues.

The generation channel is implemented and tested, but is not presented as a live HTTP entry point yet. HttpServer still supplies the established serving loops and retains the ServerJob queue. The remaining request-channel and LuceEngine::generate() cutover stays in this PR rather than creating another stacked PR.

The current components, ownership, request flows, and shutdown order are documented in server/docs/ENGINE_COMPONENTS.md. It intentionally documents the current system without proposals or open questions.

Verification

A broad all-target build reaches and builds dflash_common, but stops in the unrelated existing HIP test test_rms_norm_hip because cudaErrorNoDevice is not defined by the compatibility shim.

@Graffioh

Graffioh commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@Graffioh I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 23 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/src/common/feature_gate.cpp
Comment thread server/CMakeLists.txt Outdated
Comment thread server/src/common/backend_plan.cpp
Comment thread docs/specs/engine-components.md Outdated
@Graffioh
Graffioh marked this pull request as ready for review September 3, 2026 07:37
@Graffioh
Graffioh force-pushed the codex/luce-engine-implementation branch from f20d5a0 to 4af1d71 Compare September 3, 2026 07:42

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/src/common/backend_plan.cpp
Comment thread docs/handoffs/luce-engine-implementation.tsv Outdated
@Graffioh
Graffioh force-pushed the codex/luce-engine-implementation branch from 4af1d71 to 239bb70 Compare September 3, 2026 07:52
@Graffioh
Graffioh force-pushed the codex/luce-engine-implementation branch 2 times, most recently from e657b94 to 66b9295 Compare September 3, 2026 10:22
@Graffioh
Graffioh marked this pull request as draft September 3, 2026 10:34
@Graffioh
Graffioh force-pushed the codex/luce-engine-implementation branch 2 times, most recently from 78d2990 to 9c541b6 Compare September 3, 2026 10:48
@Graffioh
Graffioh marked this pull request as ready for review September 3, 2026 10:55

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 53 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/src/engine/luce_engine.h
Comment thread server/src/engine/luce_engine.cpp Outdated
Comment thread server/src/common/backend_plan.cpp
Comment thread server/CMakeLists.txt Outdated
Comment thread server/test/test_luce_engine.cpp Outdated
Comment thread server/src/engine/luce_engine.cpp
Comment thread server/src/bailingmoe3/bailingmoe3_backend.h
Comment thread server/docs/ENGINE_COMPONENTS.md Outdated
@Graffioh
Graffioh force-pushed the codex/luce-engine-implementation branch 2 times, most recently from 8d1961c to 4814c5a Compare September 3, 2026 11:55
@Graffioh

Graffioh commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@Graffioh I have started the AI code review. It will take a few minutes to complete.

@Graffioh
Graffioh force-pushed the codex/luce-engine-implementation branch from 4814c5a to 2e63094 Compare September 3, 2026 12:04

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/src/engine/luce_engine.cpp Outdated
@Graffioh
Graffioh force-pushed the codex/luce-engine-implementation branch from 2e63094 to bd484ae Compare September 3, 2026 13:22
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