Skip to content

Define snapshot state and stale retrieval semantics #8

Description

@pudo

Define how Pravda represents capture outcomes and returns a previous usable snapshot when a refresh fails.

Zavod should be able to request a fresh capture while remaining operational when a source is temporarily unavailable. If the refresh fails, Pravda may return the latest usable snapshot within a caller-specified maximum age. Zavod can parse that evidence and emit a warning instead of failing the crawler.

State model

Separate the page-facing state from the underlying failure cause.

Page states:

  • live: capture completed and passed validation.
  • blocked: access was denied or challenged.
  • gone: the source returned a permanent absence response.
  • down: the source could not be reached.
  • partial: some evidence was captured, but the result did not satisfy validation.

Failure causes should remain machine-readable, for example DNS failure, timeout, HTTP error, invalid content, browser error, or storage error.

Retrieval behavior

Support a capture operation with an optional maximum stale age:

  1. Attempt a fresh capture.
  2. Return it if it is usable.
  3. If it is unusable, find the latest usable snapshot within max_stale_age.
  4. Return the stale snapshot together with the failed fresh attempt and stale: true.
  5. Fail if no acceptable snapshot exists.

A stale snapshot must retain its original capture time and identity. The failed refresh attempt must also be stored.

Questions

  • Which HTTP statuses map to gone, blocked, and down?
  • Is usability determined by Pravda alone or by caller-supplied validation?
  • Should partial snapshots ever qualify for stale fallback?
  • Is stale retrieval part of POST /snapshots or a separate operation?
  • Should max_stale_age be required whenever fallback is enabled?

Acceptance criteria

  • Snapshot states and failure causes are defined.
  • Usable-snapshot criteria are explicit.
  • Fresh, stale-fallback, and no-fallback response shapes are specified.
  • Failed refresh attempts remain inspectable.
  • Stale responses expose snapshot age and the failed refresh outcome.
  • Tests cover fresh success, failed refresh with fallback, expired fallback, and no usable history.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions