/ documentation

maleta watch and prune

Continuously apply a bound Maleta and safely remove only files that the CLI can prove it managed.

#Usage and options

Follow the bound Maleta
bash
maleta watch [--interval seconds] [--once]
Review or perform pending removals
bash
maleta prune [--dry-run] [--yes]
Watch and prune options
OptionCommandEffect
--interval secondswatchSets the interval in whole seconds. The value must be at least 1, but the server enforces a 10-second floor.
--oncewatchRuns one pass and exits. If the only failure is throttling, waits for Retry-After and tries once more.
--dry-runpruneOnly reports what would be removed. It does not write or need to acquire the lock.
--yespruneAuthorizes removal. Without this option, prune defaults to a dry run.

Without --interval, the first interval is 30 seconds; after the first response, the cadence provided by the server takes over. On startup, the CLI prints [ok] watch iniciado; aplicando a Maleta "<nome>" a cada <segundos>s.

#What happens on each pass

  1. Read the binding

    The CLI reads the device session and the revision of the bound Maleta. If the locally applied revision and the revision reported by the account already match, it does not download the document again.

  2. Fetch and plan

    When the revision changed or the previous pass ended in a conflict, it downloads the document, validates the Maleta, and creates the plan for the host. Plugins are deliberately excluded: a server-provided list must not become a remote-execution channel. The CLI prints [skip] <n> plugin(s) desta Maleta não são aplicados pelo watch; rode 'maleta sync' para aplicá-los.

  3. Apply without removing

    The plan adds or updates safe files and preserves local conflicts. watch always plans with removal disabled: it never deletes files.

  4. Record and report

    The CLI writes the local state, including the revision and result, then reports the result to the account. A reporting failure does not undo a completed write.

#Cadence, retries, and locking

The server accepts at least 10 seconds between polls. A lower --interval is raised to that floor and prints [warn] o servidor aceita no mínimo 10s entre polls; usando esse intervalo.

  • After an error, the delay grows as min(intervalo × 2^tentativa, 5 min) with ±20% jitter. A valid Retry-After replaces this delay.
  • There is one watch.lock per CLI home directory. A second process exits with [error] já existe um 'maleta watch' em execução neste computador (pid <pid>).
  • maleta status shows the process as watch: rodando (pid <pid>). Locks left by processes that have exited are reclaimed on the next run.
  • --once exits after one successful or conflicting pass; an error on that pass returns failure, except for the single throttling retry.

#What remains pending

  • Resources that the current Maleta revision no longer uses move to pendingRemoval.
  • When you run maleta detach or maleta logout, resources from the previous Maleta move to orphaned.
  • If the binding is replaced by another document, previously recorded resources also become orphaned for a later prune run.

#Prune and proof of ownership

Before deleting, prune reports each resource. Running without --yes is a simulation and prompts with <n> recurso(s): rode 'maleta prune --yes' para remover. Actual removal refuses to proceed while watch holds the lock: [error] há um 'maleta watch' em execução neste computador (pid <pid>); pare o watch antes de remover.

  • Only files with origin: "written" whose hash still matches the record can be deleted. Adopted or modified files, symlinks, unsafe paths, and unknown entries are preserved.
  • A directory is removed only after it becomes empty. A user-added file keeps the directory and blocks removal of the resource.
  • Without account access, prune evaluates only pendingRemoval and orphaned from the local record; it does not guess other candidates.

#Exit codes

CodeCondition
0A normal watch pass or shutdown; a completed prune report or removal. Untrusted state also exits without removing and returns 0.
1Single-pass failure, revoked credential, or another operational error.
2Invalid command, option, or value, including an --interval that is not a positive integer.
3Another watch already holds watch.lock or an actual removal was refused because the lock is held.