Merge branch 'main' into feat/poweruse-list-handler
Kollision mit #264 (Handoff-Budget im Brief sichtbar machen): beide Seiten haben HandoffRoundTracker, HandoffMcpTools und InteractiveLaunchSpecService angefasst. Der Konflikt war inhaltlich, nicht nur textuell. #264 liest den Cap an zwei Stellen aus der Konstante (GetStatus und das roundInfo-Rendering), waehrend dieser Branch ihn zum Parameter aus app_settings gemacht hat. Ein reiner Text-Merge haette kompiliert und trotzdem gelogen: Register haette den konfigurierten Cap durchgesetzt, waehrend der Brief dem Modell weiter "2 Runden uebrig" gemeldet haette, obwohl es 39 hat. Aufgeloest so, dass der Cap eine einzige Quelle hat: - GetStatus(taskId, maxHandoffs) nimmt den Cap als Parameter, mit demselben Clamp wie Register. Die Rechnerei liegt damit an einer Stelle. - GetHandoffStatus liest das Setting und gibt es weiter. - Das roundInfo-Rendering benutzt GetStatus statt eigener Arithmetik. Zwei Tests nageln genau diesen Drift fest, damit er beim naechsten Merge nicht unbemerkt zurueckkommt: einer auf GetHandoffStatus, einer auf den Brief. MaxHandoffs -> DefaultMaxHandoffs in #264s vier Test-Referenzen; die laufen alle mit Default-Settings, die Semantik bleibt.
This commit is contained in:
@@ -3,6 +3,7 @@ using ClaudeDo.Data.Git;
|
||||
using ClaudeDo.Data.Models;
|
||||
using ClaudeDo.Data.Repositories;
|
||||
using ClaudeDo.Worker.Config;
|
||||
using ClaudeDo.Worker.External;
|
||||
using ClaudeDo.Worker.Planning;
|
||||
using ClaudeDo.Worker.Runner;
|
||||
using ClaudeDo.Worker.Skills;
|
||||
@@ -72,11 +73,12 @@ public sealed class InteractiveLaunchSpecServiceTests : IDisposable
|
||||
=> Task.FromResult<IReadOnlyList<SessionSkillEntity>>(Installed);
|
||||
}
|
||||
|
||||
private InteractiveLaunchSpecService BuildService() =>
|
||||
private InteractiveLaunchSpecService BuildService(HandoffRoundTracker? handoffRounds = null) =>
|
||||
new(_db.CreateFactory(), _seeder, _registry,
|
||||
new WorktreeManager(new GitService(), _db.CreateFactory(), new WorkerConfig(), NullLogger<WorktreeManager>.Instance),
|
||||
new GitService(),
|
||||
new WorkerConfig { ClaudeBin = _claudeStubPath });
|
||||
new WorkerConfig { ClaudeBin = _claudeStubPath },
|
||||
handoffRounds ?? new HandoffRoundTracker());
|
||||
|
||||
private async Task<string> SeedListAsync(string? workingDir = null, string name = "L")
|
||||
{
|
||||
@@ -636,6 +638,43 @@ public sealed class InteractiveLaunchSpecServiceTests : IDisposable
|
||||
await ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private async Task SetMaxHandoffsAsync(int value)
|
||||
{
|
||||
using var ctx = _db.CreateContext();
|
||||
await new AppSettingsRepository(ctx).GetAsync();
|
||||
var row = await ctx.AppSettings.FirstAsync(s => s.Id == AppSettingsEntity.SingletonId);
|
||||
row.ListHandlerMaxHandoffs = value;
|
||||
await ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
/// The handoff brief reports the budget the chain is ACTUALLY bounded by. Recomputing it from
|
||||
/// HandoffRoundTracker.DefaultMaxHandoffs would compile, look fine, and quietly tell the model
|
||||
/// it has 2 rounds left when the configured cap gives it 39 — so pin the configured value.
|
||||
[Fact]
|
||||
public async Task BuildForMergeHelperHandoffAsync_RaisedCap_BriefReportsConfiguredBudget()
|
||||
{
|
||||
var repo = Path.Combine(_tempDir, "capBrief");
|
||||
Directory.CreateDirectory(repo);
|
||||
var listId = await SeedListAsync(workingDir: repo, name: "Alpha");
|
||||
var handler = Guid.NewGuid().ToString();
|
||||
var survivor = Guid.NewGuid().ToString();
|
||||
await SeedTaskAsync(handler, listId, TaskStatus.Idle, title: "List handler: Alpha");
|
||||
await SeedTaskAsync(survivor, listId, TaskStatus.WaitingForReview, title: "Survivor task");
|
||||
|
||||
await SetMaxHandoffsAsync(40);
|
||||
|
||||
var tracker = new HandoffRoundTracker();
|
||||
tracker.Register(handler, "wait", 40);
|
||||
|
||||
var svc = BuildService(tracker);
|
||||
var spec = await svc.BuildForMergeHelperHandoffAsync(handler, new[] { survivor }, "wait", CancellationToken.None);
|
||||
var sessionDir = TrackSessionDir(spec);
|
||||
var brief = await File.ReadAllTextAsync(Path.Combine(sessionDir, "handoff.md"));
|
||||
|
||||
Assert.Contains("round 1 of 40", brief);
|
||||
Assert.Contains("39 more possible", brief);
|
||||
}
|
||||
|
||||
private async Task SetPowerUseAllowedAsync(string listId, bool value)
|
||||
{
|
||||
using var ctx = _db.CreateContext();
|
||||
@@ -1134,7 +1173,13 @@ public sealed class InteractiveLaunchSpecServiceTests : IDisposable
|
||||
|
||||
var beforeCount = await CountTasksAsync();
|
||||
|
||||
var svc = BuildService();
|
||||
// In production, HandoffMcpTools.HandoffListHandler calls Register BEFORE the hub asks
|
||||
// this service to build the spec -- simulate that here so the brief's round info is
|
||||
// demonstrably read from HandoffRoundTracker, not recomputed.
|
||||
var tracker = new HandoffRoundTracker();
|
||||
tracker.Register(handlerTaskId, nextPhase);
|
||||
|
||||
var svc = BuildService(tracker);
|
||||
var spec = await svc.BuildForMergeHelperHandoffAsync(handlerTaskId, new[] { survivor }, nextPhase, CancellationToken.None);
|
||||
var sessionDir = TrackSessionDir(spec);
|
||||
|
||||
@@ -1181,6 +1226,11 @@ public sealed class InteractiveLaunchSpecServiceTests : IDisposable
|
||||
Assert.Contains(survivor, handoffBrief);
|
||||
Assert.Contains("phase 3", handoffBrief, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// Round info always names the current round and the total cap -- this is the ONE
|
||||
// Register call above, and this test leaves ListHandlerMaxHandoffs at its default,
|
||||
// so round 1 of DefaultMaxHandoffs.
|
||||
Assert.Contains($"round 1 of {HandoffRoundTracker.DefaultMaxHandoffs}", handoffBrief);
|
||||
|
||||
if (expectFinalNote)
|
||||
{
|
||||
Assert.Contains("FINAL round", handoffBrief);
|
||||
|
||||
Reference in New Issue
Block a user