@davoodmehraban89 / VELYQOR / commits / 1270673
Fork 0

Intelligence, Advanced Charting & Trading Platform

docs(risk): record revoked-consent sender gate, bounded queue scan and corrected CI errors

davoodmehraban89 committed Oct 22, 2026 at 23:54 UTC 12706735a478957783aa83db63878d4b6f07644d
1 file changed +16
docs/operations/chartnova-alert-runtime-staging-2026-10-22.md
+16
@@ -10,6 +10,22 @@
10 4. [Coordinator](../../packages/market-domain/src/alert-postgres-coordinator.mjs) accepts injected \`evaluateQuoteGate\` and \`stepAlert\` functions from PR #33, a verified server principal and a PostgreSQL \`query\` adapter. It blocks mismatched provider/instrument/quote-side and any missing **public display + derived alerts + historical storage licensing** BEFORE storing source prices. Its gate-to-rule-to-event bindings check price/time/source, rule identity and the explicit information-only label. It retries an optimistic version conflict at most three times and performs no network sending.
11 5. **Data minimization:** outbox persists only event key, user UUID, channel and opaque recipient reference; rule runtime stores quote information required for spike/trailing calculations, therefore historical-storage permission is mandatory. No bot token, chat ID, API key, broker credentials or order instructions are stored.
12
13 +## Revoked-consent delivery safety (new)
14 +
15 +- The proposed future sender must use SQL function \`alert_notification_claim_consented\`, **not** raw PR #34 \`notification_outbox_claim\`. The wrapper looks up each claimed row's actual **user ID, recipient reference and channel** and checks active consent from the database again before handing anything to an outbound transport.
16 +- If consent was revoked **after enqueue but before claim**, the wrapper marks the unsent row terminal \`UNKNOWN\` with explicit reason \`RECIPIENT_CONSENT_REVOKED_OR_MISSING\`; it does NOT call any messaging provider and does not retry. Under PR #34's existing status model, \`UNKNOWN\` is the only non-retry terminal available without changing the approved schema. The reason differentiates revocation from a real uncertain HTTP delivery.
17 +- To avoid starvation when old/revoked recipients are at the head of the queue, the wrapper scans at most **16** pending rows per claim, terminating revoked ones and returning the first entitled recipient if found. A larger backlog requires subsequent scheduled checks; no unbounded loop.
18 +- PostgreSQL invariant tests cover an active consent, revoked consent, revoke-after-enqueue, repeated claim of a revoked item, multiple queued recipients and a revoked oldest entry preceding an eligible recipient.
19 +- **Residual race**: consent can be revoked after a database claim transaction commits but before an external HTTP request. A future real sender MUST recheck consent immediately before egress, and document this unavoidable race in the operational contract. No such sender, connector or external network action exists in this PR.
20 +- SQL privilege policy must prohibit the approved runtime sender from bypassing this wrapper via direct raw claim or table mutation. **Least-privilege role grants are not implemented here**, so no proof of fully enforced sender isolation exists.
21 +
22 +### Test failures repaired
23 +
24 +- One first-pass run failed because an added PL/pgSQL wrapper was incorrectly dollar-quoted. Repaired with named \`$alert_claim$\` delimiters.
25 +- A follow-up test run found a missing declared local test variable \`current_status\`. The declaration was added; neither issue affected Neon or live users.
26 +- Subsequent green checks validate the repaired schema on disposable PostgreSQL; failures have not been erased from GitHub Actions history.
27 +
28 +
29 ## Test evidence (read only from source repository)
30
31 - SQL invariant tests run against a fresh PostgreSQL 18 service on GitHub Actions and **ROLLBACK test fixtures**. They assert no unconsented/revoked send, correct CAS revisions, exactly one terminal event, no duplicate enqueue, no public permissions and a quality gate that is not suspended.