Skip to content

serving: split llama-server lifecycle into bounded owner modules - #5233

Closed
joelteply wants to merge 3 commits into
canaryfrom
codex/llama-server-by-owner
Closed

joelteply wants to merge 3 commits into
canaryfrom
codex/llama-server-by-owner

Conversation

@joelteply

@joelteply joelteply commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Split the 9,823-line llama-server owner into lifecycle, launch preparation, readiness, paging and reconciliation modules. This advances the Serving module's build-loop work: each responsibility can be reviewed separately while public paths and serving decisions remain unchanged.

The root is 145 lines, production children at most 608, tests at most 969. All 2,862 original full comment lines and all 62 test annotations are retained. Logging targets and subprocess selectors follow their original contracts. No new test setup or duplicate implementation is introduced.

Rebased onto canary 8e26442 after #5239. Independent source review transferred APPROVE to e887947: serving source and probe macros are byte-identical to reviewed dbc6064 (304 function definitions, public paths, logging and test selectors). Source-hygiene passes at this head with the directly measured baseline of 36,308 excess lines across 10 files. Windows installer passes; full core tests and Windows compilation remain pending. No serving-node compilation or deployment and no measured latency or learning claim.

If another split lands first, remeasure the baseline on the merged tree before integration.

@joelteply

Copy link
Copy Markdown
Contributor Author

Validation at ef44115: Linux job118903846248 passes with 75 warnings, equal to baseline. Main suite8943 passed/47 ignored/42 filtered; explicit moved engine-install subprocess executes one test, retirement fixture and teacher custody fixture pass. Additional Postgres11 and doc guards2 pass. Binding check passes. Windows core artifact/custody and integration type-check steps pass; durable-stop regression still running. This is test evidence only, not deployment, latency improvement or learning proof. Hygiene remains blocked on the previously reported scanner floor; no baseline increases.

@joelteply
joelteply force-pushed the codex/llama-server-by-owner branch from ef44115 to cf388b1 Compare October 21, 2026 07:39
@joelteply

Copy link
Copy Markdown
Contributor Author

Independent source review — Continuum PR5233

Verdict: source APPROVE exact dbc6064 versus 437ee5f. CI remains the compilation/platform gate; no merge approval before exact-head checks are green.

Read AGENTS.md, CLAUDE.md plan, README and changed module facade/macro/ratchet. This serves persistent citizens by making serving lifecycle code independently reviewable and advances phase 1 / goal 4 (No monolith), under Codex serving/inference ownership. No builds or owner checkout edits performed; checkout was clean at the reviewed head.

Independent mechanical/source checks:

  • Compared old monolith against all resulting module/test files using normalized line multisets and a tokenized function-body comparison. 304 function definitions on each side. After only normalizing inserted tracing target arguments and relocation-qualified inference sibling paths, the only remaining function differences were two subprocess test-selector strings (correctly updated to tests::engine_install and tests::retirement) and indentation in an escaped-newline assertion string (same Rust string value). This is a source consistency check, not a compiler or full Rust parser claim.
  • 62 test annotations on both sides. No original full comment line missing. Longest resulting llama-server file is tests/retirement.rs at 969 lines; all resulting files are below 1,000.
  • Parent facade reexports public serving types/functions/constants at the original llama_server path. Child helper visibility is widened only to pub(super) where sibling impl/test responsibilities require it; existing crate-visible exports remain explicit. LlamaServerProcess inherent implementations remain on the same public type.
  • Inference sibling references formerly using super are qualified through crate::inference at the deeper module depth. No stale include_str/include_bytes source-contract paths referencing the split monolith found in the searched core/tests/scripts surfaces; module-relative subprocess test names were adjusted.
  • Every tracing/probe invocation in the moved module tree explicitly retains continuum_core::inference::llama_server as target. New probe! target arm retains INFO and probe_class assignment identically to the existing arm; old macro syntax is untouched. Macro compilation smoke invocation added.
  • The hygiene baseline change is a downward ratchet (54,053 to 45,230), not a waiver or increased allowance.

No concrete behavior regression found in this exact split. Does not establish live serving behavior or learning, and does not close the separate AIRC/Windows incidents. Exact-head hosted CI and the required live validation belong to integration/deployment owners.

@joelteply
joelteply force-pushed the codex/llama-server-by-owner branch from c48932b to e887947 Compare October 21, 2026 08:57
joelteply added a commit that referenced this pull request Oct 21, 2026
… measurement (#5229-#5233, #5240, #5244) (#5245)

* code/file_engine.rs split by owner: 3,935 lines -> 144 + seven files, each under 1,000

Split by the names already in the file: suggest (nearest paths), ops (read,
write, edit, delete, diff, undo, history), introspect (path resolution,
exists, list_dir, glob), edit_checks (parse checks, notices, repair hints),
apply (applying and reversing an edit), tests/{mod,filesystem}. Pure moves:
children `use super::*`, moved private items become pub(super), the parent
globs them back so every path holds; super::workspace_events becomes
crate::code::workspace_events (one level deeper); gutter_line_number keeps
its pub(crate) path through a re-export.

file_engine tests: 58 before, 58 after, all pass. Lines past 1000:
155,781 -> 152,846.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 18a6f6d)

* Split cognition/resource_admission.rs by owner (metrics, turns, lanes, gate, tests)

Pure move: no behaviour change. Every file is at most 1,000 lines; public paths unchanged via glob re-exports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 251e832)

* Split working_memory.rs by owner (pure move)

working_memory.rs 4138 -> 618 lines (types, snapshot, Drop; re-exports
WorkingMemoryFaculty). Moved verbatim into working_memory/:
  ledger.rs 451 (construction, action statements, fingerprints, receipts)
  continuity.rs 429 (pins, notices, facts, snapshot/restore, claim-gone)
  perception.rs 490 (readers, dispatch, collapse, settlement)
  faculty.rs 213 (WorkingMemoryFaculty + render_trail)
  tests/{mod,actions,custody,faculty,open_views,pins,provenance,rebuilt_marker,trail}.rs
    (all <=423 lines; the two test mods become one tests tree)
Widened to pub(super): push_receipt_head, collapse_results_over_cap,
publish_live_handles. Test files carry #![cfg(test)] so source-hygiene
keeps counting them as test code.

Tests: working_memory filter 49 passed before and after. Lib warnings
122 -> 122, lib-test warnings 74 -> 74. source-hygiene baselines lowered:
lines-over-1000 155781 -> 152643, excess test mods 19 -> 18.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 088a602)

* Split openai_adapter.rs by owner (near pure move)

openai_adapter.rs 3730 -> 267 lines (config/types; re-exports
extract_reasoning). Moved into ai/openai_adapter/:
  runtime.rs 423 (construction, endpoints, runtime models, slot pool)
  lora.rs 198, registry.rs 139, reasoning.rs 107, embedding.rs 72
  provider.rs 482 (AIProviderAdapter impl)
  stream.rs 789 (generate_stream_checked body)
  tests/{mod,lane_transport,request_shaping,lora_page_in,
         prefill_progress_is_liveness,unguaranteed_model_refusal_...}.rs
    (all <=593 lines)

Not a pure move in two places, both forced by the 1000-line cap:
- The AIProviderAdapter impl was a single 1250-line trait impl (one
  790-line method), which cannot span files. generate_stream_checked's
  body moved verbatim to the inherent `stream_checked` in stream.rs;
  the trait method is now a one-line forward.
- A doc link to crate::cognition::embedding in provider.rs became plain
  code formatting so the file-per-upward-import layer ratchet did not
  rise (cognition was named by two files after the split).
Widened to pub(super): endpoints, endpoints_for_model,
targets_local_serving_lane, refresh_runtime_models, resolve_dmr_model_name,
runtime_models_contain, ensure_slot_pool, lora_scale_vector,
match_lora_index, map_finish_reason, and the embedding helpers.

Tests: openai_adapter filter 41 passed before and after. Lib warnings
122 -> 122, lib-test 74 -> 74. source-hygiene lines-over-1000 baseline
152643 -> 149913.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 463d122)

* Split dream_consolidation.rs by owner (pure move + 9 justifications)

dream_consolidation.rs 2817 -> 200 lines (module header, BrainRegion impl,
engram builders, PersonaReflectionSource impl for the registry; re-exports
distiller::* and region::*). Moved into cognition/dream_consolidation/:
  distiller.rs 484 (DistilledFact, Lens, SemanticDistiller)
  region.rs 358 (reflection source, region state, boundaries, entry points)
  consolidate.rs 516 (consolidate_with, review-only, received passes)
  passes.rs 475 (dream/review/supersession passes)
  tests/mod.rs 307 (incl. pub(crate) helpers training_producer imports),
  tests/region.rs 505 (pub(crate) mod region, path kept)
Widened to pub(super): region consts/fields/ReviewBoundaries/DreamPermit/
CONSOLIDATE_EXECUTOR/consolidate_cooldown_elapsed, consolidate_with, the
pass fns, observations_block, union_recall_keys.

The original file's first code-level #[cfg(test)] (a field gate at line 694)
hid ~1,300 lines of production from the unwrap ratchet; split files expose 9
unjustified unwraps. Each now carries a same-line JUSTIFIED comment (comments
only) so the baseline does not rise.

Tests: dream_consolidation filter 18 passed before and after. Lib warnings
122 -> 122, lib-test 74 -> 74. source-hygiene baselines lowered:
lines-over-1000 149913 -> 148096, unwired 60 -> 59.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit afa6700)

* Move the faculty tests out of llm_deliberation_faculty.rs into tests/ by theme (pure move)

Each nested test module becomes its own file; the loose prompt-shaping and
verdict tests group by theme as on the owner split. include_str! paths gain
two ../ for the added directory depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 28e811b)

* Move the tool-surface selection out of llm_deliberation_faculty.rs (pure move)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 3b34e76)

* Move the request builder out of llm_deliberation_faculty.rs (pure move)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit cfcf416)

* Move verdict production out of llm_deliberation_faculty.rs (pure move)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit e3bda14)

* Move the prompt owner (types, view, messages, fit, system, segments) out of llm_deliberation_faculty.rs (pure move)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 5e3eced)

* Move the reply claim and the hands surface out of llm_deliberation_faculty.rs (pure move)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 9817768)

* Fix a super:: path the move rewrote one level short (pure move)

The depth rewrite skipped 'in super::' meant for pub(in super::..) but also
matched 'for fact in super::perception_facts'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 24e88f6)

* Widen the canary-only fit items the sibling modules use (visibility only)

ShedPreview, ContextComposition's framing fields and the GroundingPiece
notice helpers sit in prompt/ now; private -> pub(in super::super) like their
siblings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit c776905)

* act_observe: split mod.rs by responsibility (no behaviour change)

mod.rs was a 49-line coordinator plus a 2,460-line inline test module. The test
module moves to act_observe/tests/ (declared `#[cfg(test)] mod tests;`):

- tests/mod.rs           shared fixtures: RecordingExecutor, FailingExecutor,
                         ScriptedExecutor, ActThenSpeak, AlwaysAct, CountingSpeaker,
                         body/body_with_wm/admission/acts_of helpers (410 lines)
- tests/chain.rs         causal ActChain linking scenarios (125)
- tests/apply.rs         apply_act scoping, folded/running alias, no-hands/failure (440)
- tests/drive.rs         drive_to_settle / settle_step scenarios + nudge rearm (534)
- tests/credit.rs        directed credit and live room input scenarios (509)
- tests/investigation.rs multi-act investigation, re-awaken, promise/echo gates (507)

Test bodies are moved verbatim (dedented); two relative paths gain one `super::`
(settle::NARRATION_BUDGET, perception::batch_evidence). Uncompiled locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 946a8c0)

* act_observe tests: mark moved test files #![cfg(test)] so ratchets read them as test code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 13a29ca)

* act_observe tests: restore per-file imports (drive.rs lost them)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 13e77d7)

* refactor(serving): split llama server by lifecycle responsibility

(cherry picked from commit fc90c20)

* fix serving split imports and ratchet reduced file excess

(cherry picked from commit 08608e7)

* Ratchet measured llama split file excess

(cherry picked from commit e887947)

* refactor(serving): split daemon responsibilities preserving lifecycle ownership

(cherry picked from commit 26ff921)

* fix(serving): preserve trait and shared test helper visibility

(cherry picked from commit 039df9a)

* fix(serving): use retained facade types in owner signatures

(cherry picked from commit 597b0f1)

* refactor(serving): retain contract types in their original facade

git grep -n -E AdmissionHold|GateRefusal|PromptCacheGrant -- core apps found only serving_daemon definitions and implementation references, no external named caller. Retain original pub(crate) root definitions for the pure-split visibility contract; children consume those types directly. Removes redundant reexports and artificial super-qualified signature uses; preserves type comments and behavior.

(cherry picked from commit 3676ae9)

* source-hygiene: baselines measured once on the merged split train

The only Rust file past 1,000 lines is the vendored quantized_llama.rs.
Every changed count names its cause beside it; cargo test -p source-hygiene
passes 43/43 on a fresh build of this tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@joelteply

Copy link
Copy Markdown
Contributor Author

Landed via #5245 (merge-train, canary 741c118): this PR's own commits, cherry-picked unchanged. Its review stands at the head named in #5245's body.

@joelteply joelteply closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant