Skip to content

feat(plugins): record provenance #488

Closed

Description

@uniqueg

Problem

The maintainer requires full provenance (R8): what was requested and
resolved (prospective) and what actually ran (retrospective), stored
with each task, normalised where useful, GDPR-aware.

Proposal

foca.plugins.provenance, used by the engine; run.provenance()
returns a plain dict for the app to store:

  • Prospective: source (default|preset|client), preset,
    requested (by reference to the tag), resolved, resolved_hash
    (sha256: of the RFC 8785 canonical JSON; own implementation, tested
    against the RFC's vectors).
  • Retrospective per executed alternative: step, phase, alternative,
    plugin (build reference), outcome, started_at, duration_ms,
    sanitised error (type + message without URL credentials, ≤ 500
    chars), changes (hashes before/after + changed JSON Pointers, no
    values: provenance.detail: paths, the only value now, extensible by
    config later; Q9), annotations from ctx.record() (≤ 2 KiB, JSON
    scalars/short lists), route candidates in/out, client backend
    selection (type, items, discarded), forward attempts (backend id,
    outcome, reason, remote task id, timings; forward_timeout as final
    reason when the budget ran out, Q20).
  • Engine info: FOCA version, app name/version, API_VERSION.
  • Normalisation helpers: plugin_builds (key = hash of id,
    distribution, version, entry point, RECORD digest; optional image
    digest from an env var) and pipelines (default/preset pipelines by
    hash only; client pipelines stay inline in the task document). The
    app owns the collections: it passes plugin_builds, pipelines
    and, with record_failed, a collection it names for failed-pipeline
    records, and declares them in its db config with the index specs
    FOCA documents (unique key indexes; a TTL index suggested for failure
    records). FOCA creates no collections of its own.
  • Config plugins.provenance: detail: paths, record_failed: false
    (Q8: store failed-pipeline records for audit only if configured; GDPR
    default off). run.failure_record() gives the record to store.
  • ctx.record() limits enforced; docs tell authors not to record
    personal data.

Acceptance criteria

  • Shape and hashing tested (RFC 8785 vectors, key order by UTF-16 code
    units, number formatting); changed paths for nested dicts/lists;
    sanitisation of errors; record() limits; record_failed both ways;
    helpers tested with mongomock (no MongoDB needed).
  • No IP addresses, tokens, header values or claims in any record.
  • Docs: provenance section (what is recorded, retention, GDPR notes,
    the db config snippet with collections and index specs for apps).
  • 100% coverage, mypy, ruff, mkdocs build --strict.

Surviving the Connexion 3 migration

Plain dicts and pymongo collections; no request or framework objects.
Unchanged in rc1.

Dependencies

Open questions

  • None.

Changed during pre-review: the detail option is removed; plugins.provenance.secret_headers lists headers (besides credential headers and auth) left out of change hashes; the image digest is part of the build key; changed paths are capped at 256 per execution (truncated: true), and arrays whose length changed are recorded as a whole; save()/save_failure() never raise (failures are logged, stored: false); a run whose data is not I-JSON gets resolved_hash: null and error: not_json; after an unknown outcome, final_reason is outcome_unknown.

Activity

  1. added this to the v0.18.0 milestone on Oct 24, 2026
  2. added
    priority: high
    status: blocked
    type: feature
    workload: days
    on Oct 24, 2026
  3. added
    status: in progress
    and removed
    status: blocked
    on Oct 25, 2026
  4. removed
    status: in progress
    on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: hightype: featureworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions