Agent: what a day of live use asked for
Build image / build-and-push (push) Successful in 19s
Gadfly review (reusable) / review (pull_request) Successful in 10m2s
Adversarial Review (Gadfly) / review (pull_request) Successful in 10m2s

Twenty-one prompts against the live assistant found one fabricated success,
a model that believed it was 2025, and a describe_garden that was ~450 plop
entries per turn. This is the set of fixes, each traceable to a finding:

- The gardener's LOCAL day travels with the turn (`today` on POST /agent/chat,
  sent by the UI like plantedAt) into the system prompt and every dated tool
  default. Left to guess, the model dated journal entries a year back; left to
  the server, a 9 pm fill landed on UTC's tomorrow.
- describe_garden groups plops by plant — count, where, planted date, days to
  maturity — and lists ids only for groups of ≤ 8; list_plantings spells a big
  group out on demand and remove_plantings acts on one plant in a bed ("take
  the beets out, leave the garlic"), which used to mean 116 single removals.
- New tools: move_planting (keeps the planting date; across beds via the new
  MovePlanting, which is why the store's UPDATE now writes object_id),
  update_plant, read_history, copy_garden (the "<garden> — <year>" plan
  convention). fill_region takes an explicit local rectangle and a seedLotId;
  place_planting's radius defaults to one plant (spacing/2) instead of a guess.
- The system prompt states the date and the gardener's units, forbids claiming
  a change no tool made, says it cannot undo and points at the Undo button,
  asks before clearing beds on an ambiguous sentence, and stops narrating its
  own plantings into the journal.
- A mutation aimed at ANOTHER garden inside a turn is recorded under that
  garden as its own change set, not filed into the open scope.
- UI: the thread scrolls inside the Assistant panel so the composer stays
  put; every tool has a step label; wide tables stay inside the bubble.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
2026-08-23 00:14:41 -04:00
co-authored by Claude Fable 5
parent f0aefb5378
commit bc14bbed0d
18 changed files with 1702 additions and 186 deletions
+107 -3
View File
@@ -207,11 +207,22 @@ func TestPlantingBoundsCheck(t *testing.T) {
}); err != nil {
t.Errorf("edge-of-bounds center should be allowed: %v", err)
}
// Non-positive radius rejected.
// A negative radius is rejected; an unspecified (zero) one means ONE plant —
// half the plant's spacing, the editor's tap-to-place size — so a caller that
// just says "put a tomato here" gets a tomato-sized plop, not an error.
if _, err := s.CreatePlanting(context.Background(), owner, bed.ID, PlantingInput{
PlantID: plant.ID, XCM: 0, YCM: 0, RadiusCM: 0,
PlantID: plant.ID, XCM: 0, YCM: 0, RadiusCM: -1,
}); !errors.Is(err, domain.ErrInvalidInput) {
t.Errorf("zero radius err = %v, want ErrInvalidInput", err)
t.Errorf("negative radius err = %v, want ErrInvalidInput", err)
}
one, err := s.CreatePlanting(context.Background(), owner, bed.ID, PlantingInput{
PlantID: plant.ID, XCM: 0, YCM: 0, RadiusCM: 0,
})
if err != nil {
t.Fatalf("zero radius: %v, want the one-plant default", err)
}
if one.RadiusCM != plant.SpacingCM/2 || one.DerivedCount != 1 {
t.Errorf("zero radius → radius %v (count %d), want spacing/2 = %v (count 1)", one.RadiusCM, one.DerivedCount, plant.SpacingCM/2)
}
}
@@ -376,3 +387,96 @@ func TestDeletePlanting(t *testing.T) {
t.Errorf("planting still present after delete: %d", len(full.Plantings))
}
}
// TestMovePlantingAcrossBedsKeepsTheDate — "move the tomatoes to the other bed"
// is not "pull them up and plant new ones today". The assistant had only the
// latter for want of this, and the plants lost their planting date on the way.
func TestMovePlantingAcrossBedsKeepsTheDate(t *testing.T) {
ctx := context.Background()
s := newTestService(t, openConfig())
owner := seedUser(t, s, "[email protected]")
g := seedGarden(t, s, owner)
from, err := s.CreateObject(ctx, owner, g.ID, ObjectInput{Kind: domain.KindBed, Name: "A", XCM: 500, YCM: 500, WidthCM: 200, HeightCM: 200})
if err != nil {
t.Fatalf("bed A: %v", err)
}
to, err := s.CreateObject(ctx, owner, g.ID, ObjectInput{Kind: domain.KindBed, Name: "B", XCM: 900, YCM: 500, WidthCM: 200, HeightCM: 200})
if err != nil {
t.Fatalf("bed B: %v", err)
}
path, err := s.CreateObject(ctx, owner, g.ID, ObjectInput{Kind: domain.KindPath, Name: "Path", XCM: 700, YCM: 900, WidthCM: 400, HeightCM: 100})
if err != nil {
t.Fatalf("path: %v", err)
}
if path.Plantable {
no := false
if path, err = s.UpdateObject(ctx, owner, path.ID, ObjectPatch{Plantable: &no}, path.Version); err != nil {
t.Fatalf("make the path unplantable: %v", err)
}
}
plant := seedOwnPlant(t, s, owner, 30)
may := "2026-05-20"
pl, err := s.CreatePlanting(ctx, owner, from.ID, PlantingInput{PlantID: plant.ID, XCM: 10, YCM: 10, RadiusCM: 15, PlantedAt: &may})
if err != nil {
t.Fatalf("plant: %v", err)
}
moved, err := s.MovePlanting(ctx, owner, pl.ID, MoveInput{ToObjectID: &to.ID, XCM: -50, YCM: 20}, pl.Version)
if err != nil {
t.Fatalf("MovePlanting: %v", err)
}
if moved.ObjectID != to.ID || moved.XCM != -50 || moved.YCM != 20 {
t.Errorf("moved to object %d at (%v,%v), want B (%d) at (-50,20)", moved.ObjectID, moved.XCM, moved.YCM, to.ID)
}
if moved.PlantedAt == nil || *moved.PlantedAt != may {
t.Errorf("plantedAt after the move = %v, want %q kept", moved.PlantedAt, may)
}
if moved.Version != pl.Version+1 || moved.DerivedCount == 0 {
t.Errorf("moved row version %d (count %d), want %d and a derived count", moved.Version, moved.DerivedCount, pl.Version+1)
}
// It reads as a move in history, and undo puts it back in A.
sets, _, err := s.GardenHistory(ctx, owner, g.ID, 0, 0)
if err != nil {
t.Fatalf("history: %v", err)
}
if want := "Moved " + plant.Name + " from A to B"; sets[0].Summary != want {
t.Errorf("summary = %q, want %q", sets[0].Summary, want)
}
if _, conflicts, err := s.RevertChangeSet(ctx, owner, sets[0].ID, domain.SourceUI); err != nil || len(conflicts) != 0 {
t.Fatalf("undo: err=%v conflicts=%+v", err, conflicts)
}
back, err := s.store.GetPlanting(ctx, pl.ID)
if err != nil {
t.Fatalf("get: %v", err)
}
if back.ObjectID != from.ID || back.XCM != 10 {
t.Errorf("after undo the plop is in object %d at x=%v, want A (%d) at 10", back.ObjectID, back.XCM, from.ID)
}
// Refused: a position outside the target, a target that can't hold plants, a
// bed in another garden — and a stale version conflicts like any edit.
cur := back
if _, err := s.MovePlanting(ctx, owner, pl.ID, MoveInput{ToObjectID: &to.ID, XCM: 500, YCM: 0}, cur.Version); !errors.Is(err, domain.ErrInvalidInput) {
t.Errorf("out-of-bounds move err = %v, want ErrInvalidInput", err)
}
if _, err := s.MovePlanting(ctx, owner, pl.ID, MoveInput{ToObjectID: &path.ID, XCM: 0, YCM: 0}, cur.Version); !errors.Is(err, domain.ErrInvalidInput) {
t.Errorf("move into a path err = %v, want ErrInvalidInput", err)
}
other := seedGarden(t, s, owner)
far, err := s.CreateObject(ctx, owner, other.ID, ObjectInput{Kind: domain.KindBed, Name: "Far", XCM: 500, YCM: 500, WidthCM: 200, HeightCM: 200})
if err != nil {
t.Fatalf("far bed: %v", err)
}
if _, err := s.MovePlanting(ctx, owner, pl.ID, MoveInput{ToObjectID: &far.ID, XCM: 0, YCM: 0}, cur.Version); !errors.Is(err, domain.ErrInvalidInput) {
t.Errorf("move into another garden err = %v, want ErrInvalidInput", err)
}
if _, err := s.MovePlanting(ctx, owner, pl.ID, MoveInput{XCM: 5, YCM: 5}, cur.Version-1); !errors.Is(err, domain.ErrVersionConflict) {
t.Errorf("stale version err = %v, want ErrVersionConflict", err)
}
// A within-bed move is just a position change.
within, err := s.MovePlanting(ctx, owner, pl.ID, MoveInput{XCM: 5, YCM: 5}, cur.Version)
if err != nil || within.ObjectID != from.ID || within.XCM != 5 {
t.Errorf("within-bed move = %+v, %v; want the same bed at x=5", within, err)
}
}