Skip to content

refactor(backup): remove pre-payload allocation retries - #175983

Merged
steipete merged 1 commit into
mainfrom
deslop/z20-94-backup-allocation-owner-20261015
Oct 18, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/z20-94-backup-allocation-owner-20261015

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Backup scratch allocation retries speculative maintenance interleavings before any backup payload exists, adding a second recovery policy around the existing lifetime owner.

User Impact

Normal backups, interrupted-backup cleanup and abandoned-payload reclamation remain unchanged. If allocation or lifetime admission fails, the original error surfaces and the operator can rerun the backup command; the CLI guide now states that best-effort policy.

Why This Change Was Made

Replace the three-attempt pre-payload loop and missing/native-open/path-mismatch retry classifier with straight-line allocation. Keep native busy/retired-owner refusal, non-owner failure cleanup, exact error identity, private directory/Root identity checks and the admitted lifetime unchanged. Payload copying begins only after this operation returns in the actual archive/offsite/download callers.

Fifteen net production lines removed (+21/-36),44net test lines removed, one net documentation line added. This is the backup area of the existing wide preservation family, not a new large-family or duplicate credit. Remove only synthetic retry-success variants; retain read-only pending-creator inspection, replacement/symlink preservation, native failure identity and cleanup, retired-token refusal/maintenance recovery, active transactions, real abandoned payload and failed-retirement cleanup contracts.

Best-effort tradeoffs accepted

Evidence

  • Complete current owner, old483-line suite, complete439-line candidate suite and affected CLI guide frame inspected; previous complete consumer/token/private-directory/published fs-safe0.26.7 Root/context/native admission/move/remove closure retained. Exactly eight tracked determining preimages remain unchanged from the previously qualified parent to fresh3260d7b; dependency pin remains0.26.7. The Root constructor holds plain facts/adapters, not a new handle requiring an invented disposal API.
  • All three authored blobs exactly match the completed final full independent review scoped-clean P0-P2/0.97 and signed7d07fbab candidate, including the narrowed cleanup policy. The earlier0.55 incomplete review and withdrawn25-line cut are NOT approval or source for this PR. No substantive source change; valid input-identical review is reused. Simplification/test-audit preserves every independent kept contract. Only imports/edges are removed, so no new cycle/component can arise.
  • Reused focused owner proof: original17/17 passed65.02s Vitest/114.75s wrapper; final14 retained cases passed62.36s Vitest/93.97s wrapper. These are prior unchanged-input runs, not fresh runtime or exact pinned-native proof. The broader consumer attempt stopped before assertions during cold preparation; no equivalent retry or passing consumer claim. Installed fs-safe0.26.5 differs from pin0.26.7; published dependency source was inspected, and hosted exact-head CI owns pinned runtime/broad proof.
  • Current three-file formatting passed91ms, whitespace and canonical two-file type-aware lint passed. Targeted types retain36 dependency diagnostics byte-identical to the recorded baseline, none in changed files; NOT local type PASS. Fresh mandatory suppression guard passed14/14 (110.89s Vitest/154.36s wrapper). Normal signed25ms hook and all three post-hook blobs match the qualified review. Prior focused runtime timings above are source-identical historical evidence, not a current-harness run or a performance claim; exact-head hosted CI remains the pinned runtime gate. No broad local suite/build/E2E, new timeout/retry/skip/suppression, baseline expansion or shared dependency change.
  • Phase E standalone session-memory backend/factory/registry/expiry/federation/tests untouched.

Release-note context: report initial backup scratch-allocation failures directly instead of retrying empty-directory admission; ordinary backup recovery stays intact.

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M labels Oct 18, 2026
@steipete
steipete marked this pull request as ready for review October 18, 2026 01:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T01:46:44.894639Z 0679b70 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR removes retries when allocating empty backup scratch and documents rerunning the backup command after allocation failure.

Example: Maintenance reclaims openclaw-backup-owned-Ab12Cd before lifetime admission during openclaw backup create.

  • Before: Creation could allocate another directory, making up to three attempts.
  • After: Creation surfaces the original failure so the operator can rerun the command.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A coherent, source-verified simplification with retained boundary tests; behavioral evidence is historical harness coverage rather than a demonstrated CLI run of this change.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the contributor proof gate; its body supplies historical focused owner-test results, explicitly distinguishes the local dependency mismatch, and claims no fresh shipped-entry-point run for this change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: An allocation failure may currently be retried internally even though no backup payload exists and rerunning the command provides recovery.
Reason: The maintainer-authored direction explicitly trades automatic recovery from an empty-allocation interleaving for simpler ownership, consistent with repository guidance to accept visible, recoverable edge cases.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: the maintainer-approved simplification preserves payload cleanup and ownership checks, and no actionable correctness defect was found.

Priority: P3
Reviewed head: 0679b70617cc3ab24259c4e02af33bca98792fe4

Before merge

None.

Findings

None.

Agent review details

How this fits together

Archive creation, offsite backup, and downloaded-backup verification or restore request private scratch from the shared allocation owner before writing payloads; the lifetime token protects admitted scratch until retirement and cleanup.

flowchart TD
  A[Backup CLI] --> B[Archive and remote callers]
  B --> C[Private scratch allocation]
  C --> D[Directory identity checks]
  D --> E[SQLite lifetime admission]
  E --> F[Backup payload operations]
  F --> G[Retirement and cleanup]
Loading

Technical review

Best possible solution:

Keep allocation straight-line under the existing scratch owner, with explicit rerun recovery and the retained lifetime, identity, and payload-cleanup contracts.

Do we have a high-confidence way to reproduce the issue?

This is an intentional recovery-policy refactor rather than a new bug report; source and earlier deterministic tests establish the creator-versus-maintenance path without executing target code.

Is this the best way to solve the issue?

The diff is the smallest coherent implementation of the accepted policy: it removes the retry owner, preserves admission and cleanup protections, and updates the documented recovery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5631247395c8.

Provenance checked

  • Pre-payload scratch allocation retries changes intended behavior with a stated reason (0e4f556: The scratch lifecycle owner retried when reclamation won before lifetime admission; later namespace coordination and path-mismatch handling expanded coverage, including a CI-observed failure.)
  • Retry-success tests and backup recovery documentation changes intended behavior with a stated reason (9c87f19: Deterministic reclamation tests and documentation established successful fresh-directory recovery while rejecting replacements; this PR explicitly replaces successful retry expectations with original-error propagation and rerun guidance.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced diff removes the allocation loop and retry classifier while retaining exact directory identity checks, busy and retired-token refusal, original error propagation, and ordinary failure cleanup. (src/infra/backup-scratch.ts:34, 0679b70617cc)
  • Accepted recovery tradeoff: The maintainer-authored body explicitly accepts returning the original pre-payload admission failure instead of allocating another directory; the backup guide gives rerunning the command as recovery. Public docs: docs/cli/backup.md. (docs/cli/backup.md:845, 0679b70617cc)
  • Caller and persistence boundary: Archive config capture starts after scratch allocation returns; remote archive creation and download writes also follow allocation. Token format, retirement, payload recognition, and persisted configuration remain unchanged, establishing a no-migration case. (src/infra/backup-create.ts:477, 0679b70617cc)
  • Retained independent contracts: The suite retains replacement and symlink preservation, native failure identity and cleanup, retired-token rejection followed by maintenance recovery, active-transaction protection, abandoned-payload reclamation, and failed-retirement recovery. (src/infra/backup-scratch.test.ts:254, 0679b70617cc)
  • Current main and feature history: Fetched main retains the three-attempt policy. History traces its introduction to the abandoned-scratch owner and its later path-mismatch repair; this PR deliberately changes that recovery policy rather than duplicating an existing main change. (src/infra/backup-scratch.ts:35, 5631247395c8)
  • Exact-head CI remains pending: Paginated check reads showed PostgreSQL conformance shards still running, with no failed check runs returned; the aggregate CI status remained pending. These are unfinished gates, not attributed patch failures. (0679b70617cc)

Likely related people:

  • Peter Steinberger: Raw commit 0e4f556 adds src/infra/backup-scratch.ts:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0e4f556d0527; files: src/infra/backup-scratch.ts)
  • Vincent Koc: Raw commit ae9bc63 adds src/infra/backup-scratch.ts:298 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ae9bc63bfe04; files: src/infra/backup-scratch.ts)

PR surface

Source -15, Tests -44, Docs +1. Total -58 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 21 36 -15
Tests 1 114 158 -44
Docs 1 3 2 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 138 196 -58

Review metrics

Metric Value Why it matters
Production versus test LOC Production +21/-36; tests +114/-158 Production shrinks by removing retry policy; test churn narrows parameterized cases while preserving distinct ownership and cleanup contracts.

Labels

Label changes:

  • add P3: This is a focused simplification with a deliberately accepted, recoverable pre-payload allocation failure.
  • add merge-risk: 🚨 compatibility: Concurrent maintenance can now cause a backup command to fail where an automatic retry previously succeeded; the maintainer explicitly accepts this behavior and documents rerunning the command.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a focused simplification with a deliberately accepted, recoverable pre-payload allocation failure.
  • merge-risk: 🚨 compatibility: Concurrent maintenance can now cause a backup command to fail where an automatic retry previously succeeded; the maintainer explicitly accepts this behavior and documents rerunning the command.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 17, 2026, 9:58 PM ET / October 18, 2026, 01:58 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

Exact reviewed head: 0679b70.

The final narrowed three-blob backup allocation change retains the completed full independent review scoped-clean P0-P2/0.97. Current formatting, type-aware lint and mandatory suppression guard passed; input-identical historical focused owner proof is identified as historical in the PR body. Local dependency/type and pinned-native gaps are not claimed as passes. Only imports/edges are removed, so no new cycle/component is introduced.

Exact-head CI39087588674 succeeded. All filter=all check runs enumerated individually: no failed, cancelled or unfinished check. The selected runtime, PostgreSQL conformance, UI browser, type, lint, source-contract and architecture suites succeeded. All three commit statuses succeeded. Reviews and inline findings are empty; live head is unchanged and MERGEABLE. No rerun, repush, rebase or inherited-red exception.

Using the coordinator-authorized Ending10 exact-SHA guarded squash fallback after twice-recorded native startup infrastructure failures. Native locks and shared dependencies remain untouched; this bypasses broken tooling, not CI/review gates.

15 net production lines and44 net test lines removed;1 documentation line added. Best-effort empty-allocation failures surface directly; payload durability and human-incident recovery stay intact. Phase E session-memory surfaces untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant