Skip to content

fix(drive,docs): build request before the lease gate - #1713

Merged
newhoggy merged 1 commit into
mainfrom
issue-1688-build-request-audit-gate
Sep 17, 2026
Merged

newhoggy merged 1 commit into
mainfrom
issue-1688-build-request-audit-gate

Conversation

@newhoggy

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • cargo build
  • cargo test --lib drive::sheets:: (485 passed)
  • cargo clippy --all-targets -- -D warnings
  • Reviewed via /code-review high — no correctness bugs found; two minor cleanup findings noted but left as-is (comment duplication, and a documented-only ordering contract) since neither is a bug

gate_leased_write fsyncs a write-ahead pending audit record (ADR-0080
§11) and only the mutating call's own allowed/failed outcome concludes
it. format.rs and structure.rs built their batchUpdate request after
the gate, so a request that could never be issued (a malformed color,
a sheet that resolved by title but reported no sheetId) still opened
a pending record with nothing to close it — indistinguishable from a
process that died mid-write.

Move build_request above the gate in both engines, matching
protection.rs's existing ordering. One accepted side effect: a
malformed request under a bad or absent lease now reports the
request-build refusal rather than the lease refusal, consistent with
every other pre-lease refusal both engines already report ahead of
the gate.

Fixes #1688
@github-actions

Copy link
Copy Markdown

Coverage

Total: 97.27% ⚪ 0 pp vs main

Comparing e78ba2f..81037b6 (merge-base → PR head)

No per-file coverage changes vs main.

🔇 5 ignored region(s), 0 tolerated region(s)

ignore removes the lines from both reports; tolerate keeps them in the reported percentage but scores them against the baseline, so a cross-run flip cannot move a delta. Regions are read from each revision's own source.

File Kind Lines Rev Reason
src/cli/drive/lease.rs ignore 408-412 both a sheet restore's fresh backup is always a DriveCopy — restore.rs's own recheck refuses unless the target is still a spreadsheet, and acquire() only ever takes a Bytes backup of a non-native target; this arm exists solely for exhaustiveness over the shared LeaseBackup enum
src/cli/drive/lease.rs ignore 882-885 both guards this test helper against misuse; every call site below passes an acquire subcommand
src/cli/drive/lease.rs ignore 896-899 both guards this test helper against misuse; every call site below passes a prune subcommand
src/drive/lease/ledger.rs ignore 743-747 both mutate_locked refuses before ever calling the closure, so its body never runs — a hit here is a regression, not a coverage gap
src/drive/lease/restore.rs ignore 977-981 both every test using this double refuses before authenticating; a hit here is a regression, not a coverage gap

Patch coverage

Patch: 100% (50/50 new lines covered)

File Patch Uncovered new lines
src/drive/sheets/format.rs 100% (10/10)
src/drive/sheets/structure.rs 100% (40/40)

📦 Full per-file coverage summary · run summary

@newhoggy
newhoggy merged commit 0fdc3c0 into main Sep 17, 2026
17 checks passed
@newhoggy
newhoggy deleted the issue-1688-build-request-audit-gate branch September 17, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(drive): sheets format/structure orphan the pending audit record when build_request fails after the lease gate

1 participant