docs use cases backend use cases - AlexandreZanata/Abastevo GitHub Wiki
Backend use cases
Planned contracts; no implementation implied. Backend IDs avoid the existing Android UC-001âŠ015 namespace. Domain rules are in DOMAIN_MODEL; wire contracts in API_PLAN.
BUC-001 â Import official revision
Actor: scheduled worker/restricted operator. Preconditions: allowlisted source, parser fixtures validated, import lease available. Flow: discover â bounded download/checksum â parse/stage â resolve stations â quarantine/validate â atomically publish revision â record report. Alternatives: same bytes no-op; provider unavailable retries; layout/quality failure retains previous publication; corrected bytes create superseding revision. Rules: B-BR-001/002/013/014. Events: StationRegistered, OfficialRevisionPublished. Postcondition: no partially published official week. Acceptance: identical rerun stable, correction preserves prior prices, malformed import never clears current catalog. Tasks: P02-T01âŠT08.
BUC-002 â Establish and maintain anonymous identity
Actor: installation or synthetic client. Preconditions: generated supported key; no traditional account required. Flow: challenge bound to fingerprint â proof â unique contributor/key registration â signed action using fresh challenge â rotation with old/new proofs when requested. Alternatives: replay/expiry rejects; duplicate registration returns existing identity after proof; blocked key denied; lost key cannot recover anonymous identity. Rules: B-BR-004/005/015. Events: ContributorRegistered, ContributorKeyRotated. Postcondition: private key never leaves client; server identity derives from proof. Acceptance: race/replay/key ownership and rotation fixtures. Tasks: P03-T01âŠT06; Android only P10-T03.
BUC-003 â Submit and validate a price observation
Actor: anonymous contributor, then worker. Preconditions: signed identity, valid station/product/unit/condition, stable client submission ID, quota. Flow: validate request â persist immutable fact + idempotency + job â acknowledge RECEIVED â worker obtains station/evidence/trust signals â append VALIDATED or REJECTED decision â enqueue consensus if eligible. Alternatives: metadata-only accepted under lower confidence policy; photo pending waits; old capture historical-only; transient dependency fails/retries without fake approval; retry returns same resource; correction creates superseding observation. Rules: B-BR-001âŠ005/010/011/014/015. Events: PriceObserved, ObservationValidated/Rejected. Acceptance: atomicity, immutability, owner-only status and no client-controlled trust. Tasks: P04 and P06-T01.
BUC-004 â Provide private photographic evidence
Actor: contributor and evidence worker. Preconditions: identity, quota and allowed JPEG intent. Flow: reserve session â short presigned PUT â complete intent â bounded immutable snapshot validation â strip metadata/write sanitized final key â READY â bind to owner observation. Alternatives: duplicate completion idempotent; bad media rejected; overwrite after presign cannot change verified final bytes; DB/object failure reconciled; orphan/expiry cleanup. Rules: B-BR-010/011/015/016. Events: internal EvidenceVerified, EvidenceRejected, EvidenceDeleted. Postcondition: no public evidence and no unvalidated photo counted as proof. Acceptance: actual staging storage behavior plus security fixtures. Tasks: P05; camera/OCR only P10-T04.
BUC-005 â Confirm, dispute and publish current price
Actor: distinct contributor; consensus worker. Preconditions: public projection exposes a representative eligible observation ID, identity and quota; target validated and eligible. Flow: view amount/product/full condition â submit unique confirmation or structured dispute/replacement â append fact and recompute job â reduce independent votes â publish versioned projection with expiry. Alternatives: self-confirmation denied; repeated request deduplicated; supported conflict returns DISPUTED; no eligible anchor returns UNKNOWN; expiry applies even with worker down. Rules: B-BR-006âŠ009/012. Events: PriceConfirmed, ObservationDisputed, CommunityPriceChanged. Acceptance: golden results identical under permutation; payment immaterial. Tasks: P06-T02âŠT05.
BUC-006 â Moderate abuse with an audit trail
Actor: authorized operator via restricted CLI. Preconditions: strong operator access, open case or documented target/reason. Flow: inspect minimal signals and authorized private evidence â record reviewed decision â application command invalidates/block/reviews â append audit + recalculation jobs â verify projected result. Alternatives: no privilege/reason denies; appeal produces a new decision or reviewed replacement fact; deleted evidence explicitly unavailable. Rules: B-BR-003/004/009/011/012/016. Events: ModerationActionRecorded, ObservationRejected, ContributorTrustChanged as applicable. Acceptance: no public admin route, direct destructive edit or unaudited override. Tasks: P07-T01/T02.
BUC-007 â Export, erase and expire personal data
Actor: verified contributor; privacy worker; responsible operator for exceptional requests. Preconditions: current ownership proof or separately reviewed support procedure. Flow: register request â gather inventory â private expiring export OR revoke writes/purge/unlink per approved policy â recompute affected facts/projections â receipt â retain minimal deletion ledger through backup horizon. Periodic cleanup enforces inventory deadlines. Alternatives: lost-key request cannot disclose unverifiable data; retention hold requires lawful reviewed reason/deadline; restore must replay deletions before traffic. Rules: B-BR-011/016. Events: EvidenceDeleted and minimal PrivacyRequestCompleted. Acceptance: own data exported, erasure effective and no resurrection after restore. Tasks: P07-T03âŠT05, P08-T04.
BUC-008 â Release and recover the backend
Actor: operator. Preconditions: tested release, fresh backup, compatible migration, separate deployment privileges. Flow: stage â backup â migrate â deploy â smoke/health â monitor â record release evidence. Recovery: disable writes if needed â restore off-host backup into new isolated environment â verify rows/projections/jobs/object references â apply erasure ledger â smoke â switch traffic. Alternatives: failed migration/readiness stops rollout; failed restore blocks launch; provider outage uses documented source-specific degradation. Rules: B-BR-003/005/008/011/013/016 and infrastructure runbooks. Acceptance: actual measured RPO/RTO, no erased-data leak, no false write acceptance. Tasks: P08/P09.