fix(stage): align session export render cap with artifact bound
Six computed Flutter runs stopped at the export handoff gate because the rendered session.html cap was 2 MiB while their complete sessions (well inside the 8 MiB source read bound) rendered between 2.25 and 4.28 MiB once html escaping and the readable projection duplicated native text. Raise SessionExportFileLimit to 8 MiB, the server's existing per-artifact file bound, so a complete export is still listed and served. Normal export verification, versioned repair and the handoff gate keep using the single shared constant. The source read bound is unchanged, and an over-cap render is still visibly truncated and recorded partial. Add focused regressions for a complete export above the old cap, an over-new-cap file rejected as partial, repair above the old cap leaving original evidence untouched, the gate accepting the larger repair, and the constant staying inside the artifact file bound. Update the artifact, handoff-gate and operations docs and record the diagnosis in docs/notes/session-export-render-cap.md.
This commit is contained in:
@@ -136,6 +136,56 @@ func TestSessionExportGateRetryOnlyAndExactlyOnce(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestSessionExportGateAcceptsRepairAboveOldRenderCap keeps the handoff gate's
|
||||
// versioned-repair verification on the same larger bound as normal export.
|
||||
func TestSessionExportGateAcceptsRepairAboveOldRenderCap(t *testing.T) {
|
||||
h, s, id, first, second := gateRunner(t, func(context.Context, stage.SessionExportRequest) (stage.SessionExportResult, error) {
|
||||
return stage.SessionExportResult{}, errors.New("export offline")
|
||||
}, false)
|
||||
h.runner.wg.Wait()
|
||||
ctx := context.Background()
|
||||
if err := s.ConfirmRecoveredSession(ctx, pipeline.SessionOwner{RunID: id, ID: "ses_exact"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
size := int64(2<<20) + 4096
|
||||
h.runner.exportSession = func(_ context.Context, req stage.SessionExportRequest) (stage.SessionExportResult, error) {
|
||||
if err := os.MkdirAll(req.ArtifactsDir, 0700); err != nil {
|
||||
return stage.SessionExportResult{}, err
|
||||
}
|
||||
f, err := os.Create(filepath.Join(req.ArtifactsDir, req.FileName))
|
||||
if err != nil {
|
||||
return stage.SessionExportResult{}, err
|
||||
}
|
||||
if err := f.Truncate(size); err != nil {
|
||||
f.Close()
|
||||
return stage.SessionExportResult{}, err
|
||||
}
|
||||
if err := f.Close(); err != nil {
|
||||
return stage.SessionExportResult{}, err
|
||||
}
|
||||
return stage.SessionExportResult{Source: "native_export", HTML: req.FileName, HTMLBytes: size, Messages: 2}, nil
|
||||
}
|
||||
if _, err := h.runner.repairSessionExport(ctx, id, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The worker promotes a persisted complete repair before claiming a lease.
|
||||
job, err := s.ClaimSessionExportJob(ctx, time.Now().Add(time.Second), time.Minute)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if job != nil {
|
||||
t.Fatalf("complete repair still claimed as a recovery job: %+v", job)
|
||||
}
|
||||
if err := h.runner.resumeExportGates(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h.runner.wg.Wait()
|
||||
d, _ := s.GetRun(ctx, id)
|
||||
if first.Load() != 1 || second.Load() != 1 || d.Status != "succeeded" || len(d.Steps) != 2 {
|
||||
t.Fatalf("large repair did not advance the gate: %+v (%d/%d)", d, first.Load(), second.Load())
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionExportGateCleanupUnconfirmedDoesNotExportOrAdvance(t *testing.T) {
|
||||
var exports atomic.Int32
|
||||
h, s, id, _, second := gateRunner(t, func(ctx context.Context, req stage.SessionExportRequest) (stage.SessionExportResult, error) {
|
||||
|
||||
Reference in New Issue
Block a user