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
+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 {