fix(audit): reserve bounded repair capacity outside user file quota

This commit is contained in:
2026-10-20 22:00:43 +01:00
parent 128e134f98
commit e29be1181f
3 changed files with 15 additions and 9 deletions
@@ -73,6 +73,9 @@ retry and refresh of an already-open Session tab. Large (>256 KiB) API fixtures,
wrong identity, partial/empty exports, restart, cancellation, workspace reservation,
and exactly-once successor admission have focused regressions. A full ordinary
artifact inventory no longer blocks versioned audit repair.
Repairs have a separate bounded allowance (twenty attempts, each at most 2 MiB),
so neither the ordinary inventory's file count nor its byte budget consumes the
mandatory audit-recovery capacity. The ordinary scan limits remain unchanged.
No shared service was restarted or redeployed. Production run #19's original
evidence remains unchanged. A new real multi-stage run against the installed
+3 -7
View File
@@ -157,13 +157,9 @@ func (r *runner) repairSessionExportOwned(ctx context.Context, id int64, sequenc
if !info.Mode().IsRegular() || info.Size() <= 0 || info.Size() > stage.SessionExportFileLimit || result.Messages <= 0 || info.Size() != result.HTMLBytes {
return recordFailure("repair export missing, empty, non-normal or oversized")
}
var used int64
for _, file := range step.Artifacts {
used += file.SizeBytes
}
if used+info.Size() > maxArtifactTotalBytes {
return recordFailure("repaired export exceeds artifact inventory byte bounds")
}
// Mandatory audit repair has its own bounded allowance: at most twenty
// attempts, each capped by SessionExportFileLimit. A full ordinary file
// inventory (count OR bytes) must not prevent recovery of the handoff.
evidence.HTML = name
evidence.HTMLBytes = info.Size()
if err := r.store.RecordDeliverable(persistCtx, id, sequence, protocol.StageArtifact{Name: evidence.HTML, SizeBytes: info.Size(), ContentType: "text/html; charset=utf-8", URL: artifactURL(id, sequence, evidence.HTML)}); err != nil {
@@ -61,8 +61,15 @@ func TestRuntimeSessionExportRepairPreservesOriginalAndUsesRecordedOwner(t *test
// Restore readback availability; this is a fake native export CLI, not a
// model stage, no generation/resumption/definition mutation is performed.
// A full user-artifact inventory must not consume mandatory audit capacity.
for i := 0; i < maxArtifactFiles; i++ {
if err := s.RecordDeliverable(context.Background(), id, 1, protocol.StageArtifact{Name: fmt.Sprintf("private/capture-%03d.png", i), SizeBytes: 100}); err != nil {
remaining := int64(maxArtifactTotalBytes)
for _, file := range original.Steps[0].Artifacts {
remaining -= file.SizeBytes
}
slots := maxArtifactFiles - len(original.Steps[0].Artifacts)
for i := 0; i < slots; i++ {
size := remaining / int64(slots-i)
remaining -= size
if err := s.RecordDeliverable(context.Background(), id, 1, protocol.StageArtifact{Name: fmt.Sprintf("private/capture-%03d.png", i), SizeBytes: size}); err != nil {
t.Fatal(err)
}
}