Skip to main content

Module write

Module write 

Source
Expand description

drive docs replace/append engines — text mutation gated by the ADR-0071 write-permission rules and leased against a document revision (issue #1615, ADR-0076).

Single-target, so this follows sheets/write.rs’s linear shape — a public wrapper that logs, and an _inner that classifies then mutates — rather than file_move.rs’s Plan/Execute split. --dry-run and a real run therefore share the same gate classification by construction (same function, same early return), and Docs adds one strengthening: the preview values are computed from the snapshot before the branch and are the same values on both paths, so the two cannot disagree about what they saw.

Two refusals happen before the gate, because they are not policy decisions — the operation is simply nonsensical for that target: anything that is not a Google Doc, and a shortcut (even one pointing at a Doc, since we don’t follow shortcuts). This is the mirror image of content_edit.rs’s Google-native refusal.

The ordering of the rest is deliberate and is ADR-0076 §3 and §8:

  1. The gate runs before documents.get. The naive ordering — read first, so the preview is nicer — would hand the document body to a caller the gate is about to refuse.
  2. A missing revisionId is refused rather than written unleased. Google populates it only for callers with edit access, so its absence means the write would fail anyway; refusing keeps “there is no unleased path” true without exception.

Structs§

WriteOptions
Per-call options.
WriteOutcome
The full outcome of one attempt.

Enums§

WritePayload
What to mutate.
WriteResult
What happened (or, under --dry-run, would happen).
WriteVerb
Which text mutation to perform.

Functions§

count_occurrences
Counts non-overlapping occurrences of needle in haystack.
describe
Renders an outcome as a single human-readable line.
write
Runs one text mutation, logging every attempt that isn’t a dry run.