Skip to content

code/file_engine.rs split by owner: 3,935 lines -> 144 + seven files (pure moves) - #5229

Closed
joelteply wants to merge 2 commits into
canaryfrom
fable/split-file-engine
Closed

joelteply wants to merge 2 commits into
canaryfrom
fable/split-file-engine

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Part of the file-split blocker (rule and gate in #5221). file_engine.rs 3,935 → 144, plus suggest, ops, introspect, edit_checks, apply, tests/{mod,filesystem}, each under 1,000. Pure moves plus visibility widening for sibling access.

Verified

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 2 commits October 21, 2026 03:52
… 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)
Rebuilt as canary plus this PR's own commits (cherry-picked with -x). The
old branch carried #5227/#5228's pre-squash history. Each changed count is
traced to its cause in the comment beside it. cargo test -p source-hygiene
passes 43/43 on a fresh per-worktree build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fable/split-file-engine branch from bbcceae to 1403e9a Compare October 21, 2026 08:54
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