system recover: a failed participation check is a barrier failure, never a plain refusal
Astra (round 4): in settleWithoutJournal, when ParticipationRequired itself failed (the store did not open, a retained census did not read) the original census refusal came back bare, so the legacy marker's settlement logged it and recover exited 0 without a barrier; once the transient failure cleared, Acquire could succeed. The check's failure now returns errAcquisitionBarrier with both errors kept, which settleMarker makes fatal in every mode. A box where participation is not required still falls back as before. Witness: TestRecoverFailsALegacyMarkerWhoseBarrierPrerequisiteFails (a store whose census stops reading once BeginUpdate has withdrawn its record). Mutation check: restoring the bare return fails it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2 files changed,
+48
−1
internal/host/guardtransaction.go+8 −1internal/host/recover_settlement_test.go+40 −0
diff --git a/internal/host/guardtransaction.go b/internal/host/guardtransaction.go| index da1caae37..5d3c91eb9 100644 |
| --- a/internal/host/guardtransaction.go |
| +++ b/internal/host/guardtransaction.go |
| @@ -327,7 +327,14 @@ func (a *systemApplier) settleWithoutJournal(ctx context.Context, barrier string |
| return err |
| } |
| required, checkErr := a.participationDisk().ParticipationRequired(ctx) |
| - if checkErr != nil || !required { |
| + if checkErr != nil { |
| + // Whether a barrier is needed could not be established (the store |
| + // did not open, a retained census did not read): that is a barrier |
| + // failure too, never a plain refusal a caller may log (Astra |
| + // round 4). Both errors are kept. |
| + return errors.Join(err, fmt.Errorf("%w: participation required: %w", errAcquisitionBarrier, checkErr)) |
| + } |
| + if !required { |
| return err |
| } |
| if holdErr := a.participationDisk().WithParticipation(ctx, func(ctx context.Context, l rootparticipation.Ledger) error { |
diff --git a/internal/host/recover_settlement_test.go b/internal/host/recover_settlement_test.go| index 16dbd5dce..632be5423 100644 |
| --- a/internal/host/recover_settlement_test.go |
| +++ b/internal/host/recover_settlement_test.go |
| @@ -755,3 +755,43 @@ func TestRecoverFailsALegacyMarkerWhoseBarrierCannotBeWritten(t *testing.T) { |
| t.Fatalf("the marker went without a settlement: %v", err) |
| } |
| } |
| + |
| +// prerequisiteFailingStore is the participation store whose census stops |
| +// reading once BeginUpdate has withdrawn the update record it wrote: the |
| +// barrier's prerequisite, ParticipationRequired, then fails. |
| +type prerequisiteFailingStore struct { |
| + rootstate.Store |
| + withdrawn bool |
| +} |
| + |
| +func (p *prerequisiteFailingStore) Remove(name string) error { |
| + if name == "update.json" { |
| + p.withdrawn = true |
| + } |
| + return p.Store.Remove(name) |
| +} |
| + |
| +func (p *prerequisiteFailingStore) Read(name string) ([]byte, error) { |
| + if name == "census.json" && p.withdrawn { |
| + return nil, errors.New("census read refused for the test") |
| + } |
| + return p.Store.Read(name) |
| +} |
| + |
| +func TestRecoverFailsALegacyMarkerWhoseBarrierPrerequisiteFails(t *testing.T) { |
| + // Astra round 4: after the census refused BeginUpdate and the record it |
| + // wrote was withdrawn, the check whether a barrier is needed fails. That |
| + // is a barrier failure: recover must not log it and exit 0. |
| + f := newApplyFixture(t, "stable", "old") |
| + a := f.a |
| + legacyMarker(t, f) |
| + refuseCensus(t, f) |
| + a.participation.State = &prerequisiteFailingStore{Store: a.participation.State} |
| + err := a.Run(t.Context(), true) |
| + if err == nil || !errors.Is(err, errAcquisitionBarrier) { |
| + t.Fatalf("recover with the barrier prerequisite failing = %v, want it fatal", err) |
| + } |
| + if _, err := os.Lstat(updateBegunPath(a.optDir)); err != nil { |
| + t.Fatalf("the marker went without a settlement: %v", err) |
| + } |
| +} |