refactor: deepen three shallow seams (TurnPump, config writes, branch queries) - #27
Open
perezdap wants to merge 3 commits into
Open
refactor: deepen three shallow seams (TurnPump, config writes, branch queries)#27perezdap wants to merge 3 commits into
perezdap wants to merge 3 commits into
Conversation
…nch walks One query module over the active branch (last-of-kind, count, usage totals, flatten-to-Conversation) loaded once via ISessionManager. Callers in Chat/ stop re-walking parentId links; semantics preserved.
…rConfigurator Widen the configurator (SetDefaultProviderAsync with repair, SetDefaultModelAsync, pure RepairDefaultModel shared with /provider) so every default-setting write crosses the validated seam. Delete ConfigFileUpdater, the unvalidated JSON splice path.
One module consumes the AgentEvent stream for all front-ends: it owns stream order, the terminal-event protocol (Failed, then Completed with "partial" or "completed"), artifact append on success and failure, usage extraction, and the steering-promotion policy. The REPL, JSON event stream, and RPC host plug in as presentation adapters; rendering behavior is unchanged and RPC keeps its steering semantics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Three deepening refactors from an architecture review of the hot spots (
Program.cs, Chat/REPL cluster, providers + config). One commit each, individually green.ActiveBranchquery module (ac34e46) — the nine hand-rolled parentId walks across the Chat cluster (last-of-kind ×3, count ×2, usage/char/token scans ×3, flatten ×2) now live behind one module loaded once fromISessionManager.GetActiveBranch().SessionManageruntouched. Also removes an accidental O(n²) walk inChatSessionBootstrap.d4bb530) —ProviderConfiguratorgainsSetDefaultProviderAsync(with default-model repair),SetDefaultModelAsync, and a pureRepairDefaultModelshared byproviders useand/provider.ConfigFileUpdater— the unvalidated JSON splice path — is deleted; every default-setting write now crosses the validator.TurnPump(a5aecde) — the Turn event-consumption loop was hand-written three times (REPL text, one-shot JSON, RPC) and had drifted. One module now owns stream order, the terminal-event protocol (Failed→Completed("partial"|"completed"), previously undocumented), artifact append on success and failure, usage extraction, and the steering-promotion policy. Front-ends plug in as presentation adapters; rendering behavior is byte-identical and RPC keeps its steering semantics.Behavior deltas (intentional, reviewed)
providers use/models usenow write canonical id casing and config.json is rewritten compact with defaults materialized — lossless for every key WinHarness owns, and now validated on save.Verification
dotnet build WinHarness.sln -c Release: 0 warnings, 0 errors (TreatWarningsAsErrors gate).dotnet test WinHarness.sln -c Release --no-build: 386 passed, 0 failed, 0 skipped (baseline 356; +30 new tests: ActiveBranch 11, configurator/repair 12, TurnPump 7).d4bb530built + tested standalone in a temp worktree (379 green) so every commit is bisect-safe.Follow-ups (not in this PR)
RpcHost.HandleSetModelmutates provider/model without appending aModelChangeSessionEntry— pre-existing drift outside the turn loop.