Fill mode: a "grid" layout that plants individual plants in rows (#77)
Build image / build-and-push (push) Successful in 6s
Gadfly review (reusable) / review (pull_request) Successful in 12m51s
Adversarial Review (Gadfly) / review (pull_request) Successful in 12m51s

Steve chose option 3: keep clumps as the default primitive, add a grid/rows
fill mode, so sketching and planning are different operations with different
outputs rather than one model forced to be both.

A plop is a CLUMP, not a plant — great for "a few plops of garlic in a corner",
useless for drawing a plantable 8-rows-of-garlic bed (that came out as ~15
blobs, #77). FillLayout selects what a fill packs:
- clump (default, unchanged): radius 1.5×spacing, ~7 plants per plop.
- grid: radius spacing/2, pitch = spacing, ONE plant per plop — rows you could
  actually plant from.

The geometry is the SAME hexCenters lattice and the SAME #75 half-spacing edge
rule; only the radius→spacing relationship differs (plopRadiusFor). Grid keeps
no 15cm floor — its whole point is true spacing — while clump keeps it so a
tiny-spacing plant doesn't make invisible clumps.

Threaded through FillRegion/FillNamedRegion (empty layout = clump, so existing
callers are unchanged; unknown layout = ErrInvalidInput), the REST /fill
endpoint (`layout`), and the agent's fill_region tool (`mode`, enum clump|grid),
so "plant the bed in rows" works.

Tests: grid produces many more, single-plant plops than clump on the same bed
(radius spacing/2, derived count 1); unknown layout is refused at both the
service and the API. maxFillPlops still caps a grid fill of a huge bed.

No frontend fill affordance exists yet (fill is agent-only in the UI; the fill
UI was deferred in #82), so the mode toggle rides along when that's built —
noted. Docs: DESIGN placement-model decision.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01H3zbym8Doka2d7D48maSgZ
This commit is contained in:
2026-07-22 00:01:27 -04:00
co-authored by Claude Opus 4.8
parent 1e2b763566
commit 7c1faa1515
9 changed files with 154 additions and 25 deletions
+1
View File
@@ -7,6 +7,7 @@ Work is tracked in Gitea issues; the tracking epic links every piece in dependen
## Decisions ## Decisions
- **Placement model:** freeform plops (not a square-foot grid), scaled by real plant spacing. Grid snapping may come later as a toggle. - **Placement model:** freeform plops (not a square-foot grid), scaled by real plant spacing. Grid snapping may come later as a toggle.
- **A fill is one of two operations (#77).** A plop is a *clump*, not a plant, which is the right primitive for SKETCHING ("a few plops of garlic in a corner") but can't draw a real planting — a filled bed comes out as ~15 blobs, not 8 rows of garlic. So `FillRegion`/`FillNamedRegion` take a `FillLayout`: `clump` (default; plop radius 1.5×spacing, ~7 plants each — quick coverage) or `grid` (radius spacing/2, pitch = spacing, ONE plant per plop — a layout you could plant from). Same `hexCenters` lattice and #75 edge rule for both; only the radius→spacing relationship differs. Surfaced on `POST /objects/:id/fill` (`layout`) and the agent's `fill_region` (`mode`). A grid-filled bed approaches the low-hundreds-of-plops the SVG budget was sized for, which the semantic-zoom tiers already anticipate.
- **Spacing is a plant-to-plant rule, so bed edges get half of it.** A bed edge is not a competitor for soil, light or water, so the outer row owes it half the spacing rather than a full one. `FillRegion` centres its lattice accordingly, and lets a plop — a *clump* three spacings across — cross the edge by up to half a spacing so its outermost plants land at that half-spacing. The rule, the square-foot-chart arithmetic behind it, and the failure mode it prevents are written out once in `hexCenters`; #75 is what getting it wrong looked like. - **Spacing is a plant-to-plant rule, so bed edges get half of it.** A bed edge is not a competitor for soil, light or water, so the outer row owes it half the spacing rather than a full one. `FillRegion` centres its lattice accordingly, and lets a plop — a *clump* three spacings across — cross the edge by up to half a spacing so its outermost plants land at that half-spacing. The rule, the square-foot-chart arithmetic behind it, and the failure mode it prevents are written out once in `hexCenters`; #75 is what getting it wrong looked like.
- **Stack:** Go 1.26.x backend, module `gitea.stevedudenhoeffer.com/steve/pansy`; React + TypeScript + Vite + Tailwind frontend, production build embedded via `embed.FS` → one static binary (`CGO_ENABLED=0`). - **Stack:** Go 1.26.x backend, module `gitea.stevedudenhoeffer.com/steve/pansy`; React + TypeScript + Vite + Tailwind frontend, production build embedded via `embed.FS` → one static binary (`CGO_ENABLED=0`).
- **Users:** multi-user with ownership. Users own gardens; a garden can be shared with other users as viewer (read) or editor (edit content). Owner additionally shares/deletes. The first registered user is `is_admin` (set race-free inside the INSERT); admin gates instance-wide Settings (`requireAdmin`), the only thing that reads that flag. - **Users:** multi-user with ownership. Users own gardens; a garden can be shared with other users as viewer (read) or editor (edit content). Owner additionally shares/deletes. The first registered user is `is_admin` (set race-free inside the INSERT); admin gates instance-wide Settings (`requireAdmin`), the only thing that reads that flag.
+1 -1
View File
@@ -60,7 +60,7 @@ func TestTurnIsOneChangeSet(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("bed: %v", err) t.Fatalf("bed: %v", err)
} }
if _, err := svc.FillNamedRegion(ctx, owner, bed.ID, "all", garlic.ID, nil); err != nil { if _, err := svc.FillNamedRegion(ctx, owner, bed.ID, "all", garlic.ID, nil, service.FillClump); err != nil {
t.Fatalf("seed garlic: %v", err) t.Fatalf("seed garlic: %v", err)
} }
+2 -1
View File
@@ -127,8 +127,9 @@ func (a *adapter) fillRegion(ctx context.Context, args struct {
Region string `json:"region" description:"nw|ne|sw|se corner, north|south|east|west (or top|bottom|left|right) half, or all"` Region string `json:"region" description:"nw|ne|sw|se corner, north|south|east|west (or top|bottom|left|right) half, or all"`
PlantID int64 `json:"plantId" description:"plant to fill with"` PlantID int64 `json:"plantId" description:"plant to fill with"`
SpacingOverride *float64 `json:"spacingOverrideCm" description:"optional in-row spacing override in cm; omit to use the plant's spacing"` SpacingOverride *float64 `json:"spacingOverrideCm" description:"optional in-row spacing override in cm; omit to use the plant's spacing"`
Mode string `json:"mode" enum:"clump,grid" description:"clump (default) drops a few fat clumps for a quick sketch; grid lays out individual plants in rows at true spacing, a layout you could plant from"`
}) (any, error) { }) (any, error) {
return a.svc.FillNamedRegion(ctx, a.actor, args.ObjectID, args.Region, args.PlantID, args.SpacingOverride) return a.svc.FillNamedRegion(ctx, a.actor, args.ObjectID, args.Region, args.PlantID, args.SpacingOverride, service.FillLayout(args.Mode))
} }
func (a *adapter) findPlant(ctx context.Context, args struct { func (a *adapter) findPlant(ctx context.Context, args struct {
+1 -1
View File
@@ -169,7 +169,7 @@ func TestGarlicBedToCucumbers(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("bed: %v", err) t.Fatalf("bed: %v", err)
} }
if _, err := svc.FillNamedRegion(ctx, owner, bed.ID, "all", garlic.ID, nil); err != nil { if _, err := svc.FillNamedRegion(ctx, owner, bed.ID, "all", garlic.ID, nil, service.FillClump); err != nil {
t.Fatalf("seed the garlic: %v", err) t.Fatalf("seed the garlic: %v", err)
} }
+6 -2
View File
@@ -51,6 +51,10 @@ type objectFillRequest struct {
// SpacingOverrideCM plants tighter or looser than the plant's mature spacing // SpacingOverrideCM plants tighter or looser than the plant's mature spacing
// without editing the catalog entry. // without editing the catalog entry.
SpacingOverrideCM *float64 `json:"spacingOverrideCm"` SpacingOverrideCM *float64 `json:"spacingOverrideCm"`
// Layout is "clump" (default; fat clumps for a quick sketch) or "grid"
// (individual plants in rows at true spacing). Empty = clump. An unknown value
// is refused by the service (#77).
Layout string `json:"layout"`
} }
func (h *handlers) fillObject(c *gin.Context) { func (h *handlers) fillObject(c *gin.Context) {
@@ -84,9 +88,9 @@ func (h *handlers) fillObject(c *gin.Context) {
return return
} }
region := service.Region{MinX: rect.MinX, MinY: rect.MinY, MaxX: rect.MaxX, MaxY: rect.MaxY} region := service.Region{MinX: rect.MinX, MinY: rect.MinY, MaxX: rect.MaxX, MaxY: rect.MaxY}
created, err = h.svc.FillRegion(c.Request.Context(), actor, id, region, req.PlantID, req.SpacingOverrideCM) created, err = h.svc.FillRegion(c.Request.Context(), actor, id, region, req.PlantID, req.SpacingOverrideCM, service.FillLayout(req.Layout))
} else { } else {
created, err = h.svc.FillNamedRegion(c.Request.Context(), actor, id, req.Region, req.PlantID, req.SpacingOverrideCM) created, err = h.svc.FillNamedRegion(c.Request.Context(), actor, id, req.Region, req.PlantID, req.SpacingOverrideCM, service.FillLayout(req.Layout))
} }
if err != nil { if err != nil {
writeServiceError(c, err) writeServiceError(c, err)
+21
View File
@@ -95,6 +95,27 @@ func TestFillAndClearAPI(t *testing.T) {
if n := int(decodeMap(t, w.Body.Bytes())["cleared"].(float64)); n != 0 { if n := int(decodeMap(t, w.Body.Bytes())["cleared"].(float64)); n != 0 {
t.Errorf("second clear removed %d, want 0", n) t.Errorf("second clear removed %d, want 0", n)
} }
// Grid layout (#77) packs individual plants at true spacing — many more, small
// plops than the clump default on the same bed.
w = doJSON(t, r, http.MethodPost, fillPath(objID), map[string]any{
"plantId": plantID, "region": "all", "layout": "grid",
}, cookie)
if w.Code != http.StatusOK {
t.Fatalf("grid fill: status %d, body %s", w.Code, w.Body.String())
}
if gridN := int(decodeMap(t, w.Body.Bytes())["created"].(float64)); gridN <= created {
t.Errorf("grid fill created %d, want more than the clump fill's %d", gridN, created)
}
// An unknown layout is a 400, not a silent clump fill.
if w := doJSON(t, r, http.MethodPost, clearPath(objID), nil, cookie); w.Code != http.StatusOK {
t.Fatalf("clear before bad-layout: %d", w.Code)
}
if w := doJSON(t, r, http.MethodPost, fillPath(objID), map[string]any{
"plantId": plantID, "region": "all", "layout": "spiral",
}, cookie); w.Code != http.StatusBadRequest {
t.Errorf("unknown layout = %d, want 400", w.Code)
}
} }
// TestFillRegionSelectionAPI: exactly one of region/rect, and a rect fills only // TestFillRegionSelectionAPI: exactly one of region/rect, and a rect fills only
+53 -6
View File
@@ -97,6 +97,49 @@ func defaultPlopRadius(spacingCM float64) float64 {
return math.Max(1.5*spacingCM, 15) return math.Max(1.5*spacingCM, 15)
} }
// FillLayout selects what a fill packs (#77).
//
// A plop is a CLUMP, not a plant, and that abstraction is the right primitive for
// SKETCHING — "a few plops of garlic in one corner" — but it can't draw a real
// planting: a filled 4×8ft bed comes out as ~15 blobs, not 8 rows of garlic. So
// filling is now two operations. FillClump (the default, unchanged) drops fat
// clumps for quick coverage; FillGrid lays out individual plants at true spacing,
// producing a layout you could actually plant from.
type FillLayout string
const (
// FillClump packs fat clumps (radius 1.5×spacing). Each plop is ~7 plants.
FillClump FillLayout = "clump"
// FillGrid packs one plant per plop at true spacing (radius spacing/2, pitch
// = spacing). A bed becomes rows of individual plants.
FillGrid FillLayout = "grid"
)
// plopRadiusFor is the plop radius a fill uses, given the plant's spacing and the
// layout. Grid mode is a plain spacing/2 (so the pitch is one spacing and each
// plop's derived count is 1); clump mode keeps the 15cm floor that stops a
// tiny-spacing plant from making invisibly small clumps — a floor grid mode
// doesn't want, since its whole point is true spacing.
func plopRadiusFor(spacingCM float64, layout FillLayout) float64 {
if layout == FillGrid {
return spacingCM / 2
}
return defaultPlopRadius(spacingCM)
}
// validFillLayout normalizes a layout: empty defaults to clump (so existing
// callers are unchanged), a known value passes, anything else is rejected.
func validFillLayout(l FillLayout) (FillLayout, bool) {
switch l {
case "", FillClump:
return FillClump, true
case FillGrid:
return FillGrid, true
default:
return "", false
}
}
// FillRegion lays a hex-packed field of plops of one plant across a region of a // FillRegion lays a hex-packed field of plops of one plant across a region of a
// plantable object the actor can edit. Plop radius comes from the plant's spacing // plantable object the actor can edit. Plop radius comes from the plant's spacing
// (or spacingOverride) via defaultPlopRadius; centers sit on a hex lattice at 2× // (or spacingOverride) via defaultPlopRadius; centers sit on a hex lattice at 2×
@@ -105,22 +148,26 @@ func defaultPlopRadius(spacingCM float64) float64 {
// the edge is owed. A candidate is skipped when its plop would sit entirely // the edge is owed. A candidate is skipped when its plop would sit entirely
// inside an existing active plop (so re-filling doesn't stack duplicates). // inside an existing active plop (so re-filling doesn't stack duplicates).
// Returns the plops it created. // Returns the plops it created.
func (s *Service) FillRegion(ctx context.Context, actorID, objectID int64, region Region, plantID int64, spacingOverride *float64) ([]domain.Planting, error) { func (s *Service) FillRegion(ctx context.Context, actorID, objectID int64, region Region, plantID int64, spacingOverride *float64, layout FillLayout) ([]domain.Planting, error) {
o, _, err := s.objectForRole(ctx, actorID, objectID, roleEditor) o, _, err := s.objectForRole(ctx, actorID, objectID, roleEditor)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return s.fillLoaded(ctx, actorID, o, region, plantID, spacingOverride) return s.fillLoaded(ctx, actorID, o, region, plantID, spacingOverride, layout)
} }
// fillLoaded is the shared body of FillRegion/FillNamedRegion given an object // fillLoaded is the shared body of FillRegion/FillNamedRegion given an object
// already loaded and authorized (roleEditor). It rejects a non-finite region, // already loaded and authorized (roleEditor). It rejects a non-finite region,
// clamps the region to the object's bounds, refuses fills over maxFillPlops, and // clamps the region to the object's bounds, refuses fills over maxFillPlops, and
// inserts the whole batch in one transaction rather than one round-trip per plop. // inserts the whole batch in one transaction rather than one round-trip per plop.
func (s *Service) fillLoaded(ctx context.Context, actorID int64, o *domain.GardenObject, region Region, plantID int64, spacingOverride *float64) ([]domain.Planting, error) { func (s *Service) fillLoaded(ctx context.Context, actorID int64, o *domain.GardenObject, region Region, plantID int64, spacingOverride *float64, layout FillLayout) ([]domain.Planting, error) {
if !o.Plantable { if !o.Plantable {
return nil, domain.ErrInvalidInput return nil, domain.ErrInvalidInput
} }
layout, ok := validFillLayout(layout)
if !ok {
return nil, domain.ErrInvalidInput
}
plant, err := s.visiblePlant(ctx, actorID, plantID) plant, err := s.visiblePlant(ctx, actorID, plantID)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -132,7 +179,7 @@ func (s *Service) fillLoaded(ctx context.Context, actorID int64, o *domain.Garde
} }
spacing = *spacingOverride spacing = *spacingOverride
} }
radius := defaultPlopRadius(spacing) radius := plopRadiusFor(spacing, layout)
if !isFinite(radius) || radius <= 0 { if !isFinite(radius) || radius <= 0 {
return nil, domain.ErrInvalidInput return nil, domain.ErrInvalidInput
} }
@@ -311,7 +358,7 @@ func coveredByExisting(x, y, radius float64, existing []domain.Planting) bool {
// FillNamedRegion is FillRegion addressed by a compass name ("ne", "south half") // FillNamedRegion is FillRegion addressed by a compass name ("ne", "south half")
// instead of a resolved Region — the ergonomic form for agent tools, which don't // instead of a resolved Region — the ergonomic form for agent tools, which don't
// hold the object's geometry. It resolves the name against the object, then fills. // hold the object's geometry. It resolves the name against the object, then fills.
func (s *Service) FillNamedRegion(ctx context.Context, actorID, objectID int64, regionName string, plantID int64, spacingOverride *float64) ([]domain.Planting, error) { func (s *Service) FillNamedRegion(ctx context.Context, actorID, objectID int64, regionName string, plantID int64, spacingOverride *float64, layout FillLayout) ([]domain.Planting, error) {
o, _, err := s.objectForRole(ctx, actorID, objectID, roleEditor) o, _, err := s.objectForRole(ctx, actorID, objectID, roleEditor)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -320,7 +367,7 @@ func (s *Service) FillNamedRegion(ctx context.Context, actorID, objectID int64,
if err != nil { if err != nil {
return nil, err return nil, err
} }
return s.fillLoaded(ctx, actorID, o, region, plantID, spacingOverride) return s.fillLoaded(ctx, actorID, o, region, plantID, spacingOverride, layout)
} }
// ClearObject soft-removes every active plop in an object the actor can edit (one // ClearObject soft-removes every active plop in an object the actor can edit (one
+64 -9
View File
@@ -59,7 +59,7 @@ func TestFillRegionCappedForHugeArea(t *testing.T) {
bed := seedFillBed(t, s, owner, g.ID, 6000, 6000) // ~46k lattice points at radius 15 → over the cap bed := seedFillBed(t, s, owner, g.ID, 6000, 6000) // ~46k lattice points at radius 15 → over the cap
plant := seedOwnPlant(t, s, owner, 10) plant := seedOwnPlant(t, s, owner, 10)
region, _ := NamedRegion(bed, "all") region, _ := NamedRegion(bed, "all")
if _, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil); !errors.Is(err, domain.ErrInvalidInput) { if _, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil, FillClump); !errors.Is(err, domain.ErrInvalidInput) {
t.Errorf("oversized fill err = %v, want ErrInvalidInput (over maxFillPlops)", err) t.Errorf("oversized fill err = %v, want ErrInvalidInput (over maxFillPlops)", err)
} }
} }
@@ -199,7 +199,7 @@ func TestFillRegionRejectsNonFiniteRegion(t *testing.T) {
{MinX: nan, MinY: -50, MaxX: 50, MaxY: 50}, {MinX: nan, MinY: -50, MaxX: 50, MaxY: 50},
{MinX: -50, MinY: -50, MaxX: 50, MaxY: math.Inf(1)}, {MinX: -50, MinY: -50, MaxX: 50, MaxY: math.Inf(1)},
} { } {
created, err := s.FillRegion(ctx, owner, bed.ID, r, plant.ID, nil) created, err := s.FillRegion(ctx, owner, bed.ID, r, plant.ID, nil, FillClump)
if !errors.Is(err, domain.ErrInvalidInput) { if !errors.Is(err, domain.ErrInvalidInput) {
t.Errorf("FillRegion(%+v) err = %v, want ErrInvalidInput", r, err) t.Errorf("FillRegion(%+v) err = %v, want ErrInvalidInput", r, err)
} }
@@ -223,7 +223,7 @@ func TestFillRegionOutsideObjectPlantsNothing(t *testing.T) {
plant := seedOwnPlant(t, s, owner, 10) plant := seedOwnPlant(t, s, owner, 10)
// Wholly east of the bed: clampTo gives MinX=500, MaxX=50. // Wholly east of the bed: clampTo gives MinX=500, MaxX=50.
created, err := s.FillRegion(ctx, owner, bed.ID, rect(500, -50, 600, 50), plant.ID, nil) created, err := s.FillRegion(ctx, owner, bed.ID, rect(500, -50, 600, 50), plant.ID, nil, FillClump)
if err != nil { if err != nil {
t.Fatalf("FillRegion: %v", err) t.Fatalf("FillRegion: %v", err)
} }
@@ -256,7 +256,7 @@ func TestFillRegionDeterministicPacking(t *testing.T) {
plant := seedOwnPlant(t, s, owner, 10) // radius = max(15,15) = 15 plant := seedOwnPlant(t, s, owner, 10) // radius = max(15,15) = 15
region, _ := NamedRegion(bed, "all") region, _ := NamedRegion(bed, "all")
created, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil) created, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil, FillClump)
if err != nil { if err != nil {
t.Fatalf("FillRegion: %v", err) t.Fatalf("FillRegion: %v", err)
} }
@@ -283,7 +283,7 @@ func TestFillRegionDeterministicPacking(t *testing.T) {
// Re-filling the same region skips everything (each candidate sits exactly on // Re-filling the same region skips everything (each candidate sits exactly on
// an existing plop → entirely inside it). // an existing plop → entirely inside it).
again, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil) again, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil, FillClump)
if err != nil { if err != nil {
t.Fatalf("second FillRegion: %v", err) t.Fatalf("second FillRegion: %v", err)
} }
@@ -292,6 +292,61 @@ func TestFillRegionDeterministicPacking(t *testing.T) {
} }
} }
// TestFillGridLaysOutIndividualPlants is the #77 grid mode: a grid fill packs one
// plant per plop at true spacing, so a bed becomes rows of plants rather than a
// few fat clumps. On the same bed it produces many more, smaller plops, each a
// single plant.
func TestFillGridLaysOutIndividualPlants(t *testing.T) {
ctx := context.Background()
s := newTestService(t, openConfig())
owner := seedUser(t, s, "[email protected]")
g, _ := s.CreateGarden(ctx, owner, GardenInput{Name: "Big", WidthCM: 2000, HeightCM: 2000})
bed := seedFillBed(t, s, owner, g.ID, 60, 60)
plant := seedOwnPlant(t, s, owner, 10) // spacing 10
region, _ := NamedRegion(bed, "all")
clump, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil, FillClump)
if err != nil {
t.Fatalf("clump: %v", err)
}
if _, err := s.ClearObject(ctx, owner, bed.ID); err != nil {
t.Fatalf("clear: %v", err)
}
grid, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil, FillGrid)
if err != nil {
t.Fatalf("grid: %v", err)
}
// Grid packs at spacing 10 (radius 5, pitch 10); clump at radius 15 (pitch 30).
// Grid must produce many more plops.
if len(grid) <= len(clump) {
t.Errorf("grid produced %d plops, clump %d — grid should be denser", len(grid), len(clump))
}
// Each grid plop is one plant at radius spacing/2 = 5.
for _, p := range grid {
if p.RadiusCM != 5 {
t.Errorf("grid plop radius = %v, want 5 (spacing/2)", p.RadiusCM)
}
if p.DerivedCount != 1 {
t.Errorf("grid plop derived count = %d, want 1 (one plant per plop)", p.DerivedCount)
}
}
}
// TestFillRejectsUnknownLayout: a layout that isn't clump/grid is ErrInvalidInput.
func TestFillRejectsUnknownLayout(t *testing.T) {
ctx := context.Background()
s := newTestService(t, openConfig())
owner := seedUser(t, s, "[email protected]")
g, _ := s.CreateGarden(ctx, owner, GardenInput{Name: "Big", WidthCM: 2000, HeightCM: 2000})
bed := seedFillBed(t, s, owner, g.ID, 60, 60)
plant := seedOwnPlant(t, s, owner, 10)
region, _ := NamedRegion(bed, "all")
if _, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil, FillLayout("spiral")); !errors.Is(err, domain.ErrInvalidInput) {
t.Errorf("unknown layout err = %v, want ErrInvalidInput", err)
}
}
func TestFillRegionRotatedBedUsesLocalFrame(t *testing.T) { func TestFillRegionRotatedBedUsesLocalFrame(t *testing.T) {
ctx := context.Background() ctx := context.Background()
s := newTestService(t, openConfig()) s := newTestService(t, openConfig())
@@ -304,7 +359,7 @@ func TestFillRegionRotatedBedUsesLocalFrame(t *testing.T) {
plant := seedOwnPlant(t, s, owner, 20) plant := seedOwnPlant(t, s, owner, 20)
region, _ := NamedRegion(bed, "ne") region, _ := NamedRegion(bed, "ne")
created, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil) created, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil, FillClump)
if err != nil { if err != nil {
t.Fatalf("FillRegion: %v", err) t.Fatalf("FillRegion: %v", err)
} }
@@ -327,7 +382,7 @@ func TestClearObject(t *testing.T) {
bed := seedBed(t, s, owner, g.ID) bed := seedBed(t, s, owner, g.ID)
plant := seedOwnPlant(t, s, owner, 10) plant := seedOwnPlant(t, s, owner, 10)
region, _ := NamedRegion(bed, "all") region, _ := NamedRegion(bed, "all")
if _, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil); err != nil { if _, err := s.FillRegion(ctx, owner, bed.ID, region, plant.ID, nil, FillClump); err != nil {
t.Fatalf("fill: %v", err) t.Fatalf("fill: %v", err)
} }
@@ -361,7 +416,7 @@ func TestOpsForbiddenForViewer(t *testing.T) {
} }
region, _ := NamedRegion(bed, "all") region, _ := NamedRegion(bed, "all")
if _, err := s.FillRegion(ctx, viewer, bed.ID, region, plant.ID, nil); !errors.Is(err, domain.ErrForbidden) { if _, err := s.FillRegion(ctx, viewer, bed.ID, region, plant.ID, nil, FillClump); !errors.Is(err, domain.ErrForbidden) {
t.Errorf("viewer fill = %v, want ErrForbidden", err) t.Errorf("viewer fill = %v, want ErrForbidden", err)
} }
if _, err := s.ClearObject(ctx, viewer, bed.ID); !errors.Is(err, domain.ErrForbidden) { if _, err := s.ClearObject(ctx, viewer, bed.ID); !errors.Is(err, domain.ErrForbidden) {
@@ -391,7 +446,7 @@ func TestFillScenario(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("region %q: %v", name, err) t.Fatalf("region %q: %v", name, err)
} }
if _, err := s.FillRegion(ctx, owner, bed.ID, region, plantID, nil); err != nil { if _, err := s.FillRegion(ctx, owner, bed.ID, region, plantID, nil, FillClump); err != nil {
t.Fatalf("fill %q: %v", name, err) t.Fatalf("fill %q: %v", name, err)
} }
} }
+5 -5
View File
@@ -73,7 +73,7 @@ func TestFillRegionIsOneChangeSet(t *testing.T) {
plant := seedOwnPlant(t, s, owner, 15) plant := seedOwnPlant(t, s, owner, 15)
ctx := context.Background() ctx := context.Background()
created, err := s.FillNamedRegion(ctx, owner, bed.ID, "all", plant.ID, nil) created, err := s.FillNamedRegion(ctx, owner, bed.ID, "all", plant.ID, nil, FillClump)
if err != nil { if err != nil {
t.Fatalf("FillNamedRegion: %v", err) t.Fatalf("FillNamedRegion: %v", err)
} }
@@ -320,7 +320,7 @@ func TestRevertClearObject(t *testing.T) {
plant := seedOwnPlant(t, s, owner, 15) plant := seedOwnPlant(t, s, owner, 15)
ctx := context.Background() ctx := context.Background()
if _, err := s.FillNamedRegion(ctx, owner, bed.ID, "all", plant.ID, nil); err != nil { if _, err := s.FillNamedRegion(ctx, owner, bed.ID, "all", plant.ID, nil, FillClump); err != nil {
t.Fatalf("fill: %v", err) t.Fatalf("fill: %v", err)
} }
before, _ := s.store.ListActivePlantingsForObject(ctx, bed.ID) before, _ := s.store.ListActivePlantingsForObject(ctx, bed.ID)
@@ -688,7 +688,7 @@ func TestClearObjectOnlyClearsWhatItSnapshotted(t *testing.T) {
plant := seedOwnPlant(t, s, owner, 15) plant := seedOwnPlant(t, s, owner, 15)
ctx := context.Background() ctx := context.Background()
if _, err := s.FillNamedRegion(ctx, owner, bed.ID, "all", plant.ID, nil); err != nil { if _, err := s.FillNamedRegion(ctx, owner, bed.ID, "all", plant.ID, nil, FillClump); err != nil {
t.Fatalf("fill: %v", err) t.Fatalf("fill: %v", err)
} }
before, _ := s.store.ListActivePlantingsForObject(ctx, bed.ID) before, _ := s.store.ListActivePlantingsForObject(ctx, bed.ID)
@@ -725,7 +725,7 @@ func TestRevertResultCarriesItsCounts(t *testing.T) {
plant := seedOwnPlant(t, s, owner, 15) plant := seedOwnPlant(t, s, owner, 15)
ctx := context.Background() ctx := context.Background()
if _, err := s.FillNamedRegion(ctx, owner, bed.ID, "all", plant.ID, nil); err != nil { if _, err := s.FillNamedRegion(ctx, owner, bed.ID, "all", plant.ID, nil, FillClump); err != nil {
t.Fatalf("fill: %v", err) t.Fatalf("fill: %v", err)
} }
// A second, different kind of change, so the breakdown has more than one row // A second, different kind of change, so the breakdown has more than one row
@@ -830,7 +830,7 @@ func TestSucceededTurnRecordsEvenIfTheCallerWentAway(t *testing.T) {
cs, err := s.WithChangeSet(ctx, owner, g.ID, ChangeSetOptions{ cs, err := s.WithChangeSet(ctx, owner, g.ID, ChangeSetOptions{
Source: domain.SourceAgent, Summary: "plant beans in the second bed", Source: domain.SourceAgent, Summary: "plant beans in the second bed",
}, func(ctx context.Context) error { }, func(ctx context.Context) error {
if _, err := s.FillNamedRegion(ctx, owner, bed.ID, "all", plant.ID, nil); err != nil { if _, err := s.FillNamedRegion(ctx, owner, bed.ID, "all", plant.ID, nil, FillClump); err != nil {
return err return err
} }
cancel() // the client disconnects, mid-turn, after the work landed cancel() // the client disconnects, mid-turn, after the work landed