Repository navigation
Description
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,
sanitisederror(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),annotationsfromctx.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_timeoutas 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) andpipelines(default/preset pipelines by
hash only; client pipelines stay inline in the task document). The
app owns the collections: it passesplugin_builds,pipelines
and, withrecord_failed, a collection it names for failed-pipeline
records, and declares them in itsdbconfig 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_failedboth 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,
thedbconfig 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
- Blocked by feat(plugins): add plugin engine #486 (stacked on feat(plugins): resolve per-request pipelines #487 for the resolved
pipeline). - Blocks: feat(plugins): write gateway tags #494 (P11).
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
fix(plugins): address review of provenance
test(plugins): check cleaned URLs by field