Skip to main content

qualia_core_db/bundle/stream/policy/remote/
mod.rs

1//! Purpose-scoped remote controller recognition, whole-source disclosure policy,
2//! RecipientRecord reuse, decision-ticket codec, and R2 issuance/current grant.
3//! B2 wrap_for / private M decode / PacketProtection delivery remain separate.
4mod codec;
5mod decision;
6mod policy;
7mod recognition;
8mod issuer;
9mod grant;
10mod current;
11
12pub use codec::{
13    decode_decision_ticket, encode_decision_ticket_into, ticket_package_len, DecisionTicketFields,
14    DisclosureAction, DECISION_TICKET_BYTES, MAX_TICKET_PACKAGE_BYTES,
15};
16pub use decision::{check_recipient_against_independent, DisclosureDecision, IndependentAdmission};
17pub use policy::{
18    bind_policy_to_closure, decode_disclosure_policy, encode_disclosure_policy_into, ClosureBudget,
19    DisclosurePolicyFields, DisclosurePolicyView, SourceCoverage, MAX_CLOSURE_LABELS,
20    MAX_DISCLOSURE_POLICY_BYTES,
21};
22pub use recognition::{
23    AllowedOps, ControllerRecognition, RecognitionAdmin, RecognitionEnrollment, RecognitionHandle,
24    RecognizedController, MAX_RECOGNIZED,
25};
26pub use issuer::fresh_challenge;
27#[cfg(not(target_arch = "wasm32"))]
28pub use issuer::{issue_disclosure, IssueBuffers, IssueRequest, IssuedLengths, ManagedSigners};
29pub use grant::{
30    install_remote_disclosure, InstallRequest, RemoteDisclosureGrant, VerifierChallengeSlot,
31};
32
33#[cfg(test)]
34mod lifecycle_tests;
35
36use super::PolicyError;
37use crate::crypto::network::errors::CryptoError;
38use crate::governance::consent_contract::ConsentLedger;
39use crate::net::qdnf::authority::PolicyOutcome;
40use crate::net::qdnf::policy_labels::VerifiedLabel;
41use crate::sensing::signed_scope::SignedSensingScope;
42
43/// Existing 1856-byte RecipientRecord is the remote authorization payload.
44/// Do not extend Delivery/RecordHeader or smuggle a ticket into A.
45pub use crate::crypto::network::object_stream::{
46    RecipientRecord, RECIPIENT_BYTES, RECIPIENT_PURPOSE,
47};
48
49/// Paired control-message purpose. Defined here; object_stream/types.rs stays frozen.
50pub const DISCLOSURE_DECISION_PURPOSE: &[u8] = b"qbdl-stream-protected-v1/disclosure-decision";
51pub const MAX_DECISION_LEASE_SECS: u64 = 30;
52pub const REMOTE_AUTHORIZATION_BYTES: usize = RECIPIENT_BYTES;
53
54/// Wire role flags never install recognition. Local admin is instance-bound.
55pub fn refuse_wire_role_install(_role: u8) -> PolicyError {
56    PolicyError::Crypto(CryptoError::Unauthorized)
57}
58
59/// SignedControllerChain-style delegation is unsupported in this profile.
60pub fn refuse_delegation_chain(_chain: &[u8]) -> PolicyError {
61    PolicyError::Crypto(CryptoError::Unsupported)
62}
63
64/// Do not accept an all-subjects-consented boolean as co-consent evidence.
65pub fn refuse_all_subjects_consented_flag(_flag: bool) -> PolicyError {
66    PolicyError::Reference
67}
68
69/// VerifiedLabel checks encoding/digest, not recognized issuer authority.
70pub fn refuse_verified_label_as_issuer(_label: &VerifiedLabel) -> PolicyError {
71    PolicyError::Reference
72}
73
74/// ConsentLedger is classical health-category consent, not PQ source authority.
75pub fn refuse_consent_ledger_as_pq_source_auth(_ledger: &ConsentLedger) -> PolicyError {
76    PolicyError::Crypto(CryptoError::Unsupported)
77}
78
79/// SignedSensingScope is a source-specific Ed25519 profile, not whole-source disclosure.
80pub fn refuse_signed_sensing_scope_as_whole_source(_scope: &SignedSensingScope) -> PolicyError {
81    PolicyError::Crypto(CryptoError::Unsupported)
82}
83
84/// PolicyOutcome::Allow is not a remote disclosure decision.
85pub fn refuse_policy_outcome(outcome: PolicyOutcome) -> PolicyError {
86    let _ = outcome;
87    PolicyError::Reference
88}
89
90/// A bool trait is not remote authority.
91pub fn refuse_bool_authority(_allow: bool) -> PolicyError {
92    PolicyError::Reference
93}
94
95#[cfg(test)]
96mod tests;