Address seed-packet review: 413 mapping, deadline, rollback, dedup
Build image / build-and-push (push) Successful in 6s

Gadfly findings on #94, the real ones:

- scanSeedPacket extends only the READ deadline; a slow upload + a live
  vision call runs past the server's absolute 30s WriteTimeout and the
  successful response is silently dropped (the #78 failure mode). Extend
  the write deadline too (scanWriteTimeout).
- An oversized upload tripping MaxBytesReader was mapped to 400; it's 413.
  Detect *http.MaxBytesError and report IMAGE_TOO_LARGE.
- Split imagenorm error mapping: ErrTooLarge->413, ErrUnsupported->400,
  genuine read/encode faults (and a failed file.Open)->500, not 400.
- CreateFromPacket discarded the plant it created when the lot then
  failed, contradicting its own doc. Roll the new plant back instead so
  the confirm is all-or-nothing (a fresh plant has no lots/plantings, so
  the delete is safe; log-and-continue on cleanup failure).
- Dedup: packetLotRequest and seedLotCreateRequest shared every lot
  field. Extract a seedLotFields base both use. validCategory now reuses
  plantCategories. EffectiveConfig resolves agent+vision from one
  settings-row read instead of two.
- capabilities swallowed an EffectiveVision error silently; log it.
- vision test hand-copied Extract's body (drift risk). Split generate()
  out of Extract so the hermetic test drives the real request builder.

Tests: rollback-on-lot-failure (service), oversized->413 (api).

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:13:42 -04:00
co-authored by Claude Opus 4.8
parent 156b3fd14c
commit 6a4fd40bc3
10 changed files with 178 additions and 78 deletions
+2 -14
View File
@@ -24,18 +24,6 @@ func tinyJPEG(t *testing.T) []byte {
return b.Bytes()
}
// extractVia is Extract with a caller-supplied registry, so the test can point it
// at a fake provider instead of resolving a live model. It mirrors Extract's body
// exactly apart from where the model comes from.
func extractVia(t *testing.T, m llm.Model, jpeg []byte) (SeedPacket, error) {
t.Helper()
return majordomo.Generate[SeedPacket](context.Background(), m, majordomo.Request{
Messages: []majordomo.Message{
majordomo.UserParts(majordomo.Text(extractPrompt), majordomo.Image("image/jpeg", jpeg)),
},
})
}
// TestExtractParsesModelJSON is the hermetic proof that the extraction path works
// end to end without a live model: a fake vision model returns canned packet JSON
// and Generate[SeedPacket] unmarshals it into the struct, image and schema
@@ -62,7 +50,7 @@ func TestExtractParsesModelJSON(t *testing.T) {
t.Fatalf("parse: %v", err)
}
got, err := extractVia(t, m, tinyJPEG(t))
got, err := generate(context.Background(), m, tinyJPEG(t))
if err != nil {
t.Fatalf("extract: %v", err)
}
@@ -102,7 +90,7 @@ func TestExtractLeavesMissingFieldsNil(t *testing.T) {
fp.Enqueue("vision", fake.Reply(`{"species":"basil","category":"herb"}`))
m, _ := reg.Parse("fp/vision")
got, err := extractVia(t, m, tinyJPEG(t))
got, err := generate(context.Background(), m, tinyJPEG(t))
if err != nil {
t.Fatalf("extract: %v", err)
}