Skip to content

Commit 4e57b08

Browse files
committed
feat: name the operations a job may send directly to BReg
The connector implements every BReg operation family, but the direct destination admits only an item that maps to one BReg operation with no lookup: an immediate Action, or a Proposal start and submit (CONCEPT sections 17.1 and 17.3). Keeping the other families implemented made it easy to wire record create, batch, or ingestion into a job later for convenience, and with it the broader grants those need. `breg::job_direct_admits` names the admitted operations, the module documentation states the rule, and a test pins the split, so the job's destination wiring has one check to apply when it lands. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
1 parent 40e402a commit 4e57b08

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

‎crates/registry-adapter-connectors/src/breg.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@
2929
//! [`ConnectorFault::AuthorityAbsent`], and restored bytes that belong to
3030
//! another operation or an earlier envelope version are
3131
//! [`ConnectorFault::NotPrepared`].
32+
//!
33+
//! # The direct destination
34+
//!
35+
//! The connector implements more operations than an ingestion job may
36+
//! send. A job sends an item directly to BReg only when the item maps to
37+
//! exactly one BReg operation with no lookup: an immediate Action, or a
38+
//! Proposal start and submit (`products/adapter/CONCEPT.md` sections 17.1
39+
//! and 17.3). Record create, patch, and tombstone, batch, and the
40+
//! ingestion run family stay out of a job's direct path: an item that
41+
//! needs a lookup or a choice goes to Coordinator, and bulk ends in a
42+
//! file for `bregctl data import`. The job's destination wiring admits a
43+
//! configured operation only when [`job_direct_admits`] does, so the
44+
//! credential it holds needs only the narrow grants those operations
45+
//! use.
3246
3347
use std::sync::Arc;
3448

@@ -568,6 +582,19 @@ pub(crate) fn refused_state(state: &str) -> SendOutcome {
568582
}
569583
}
570584

585+
/// Whether an ingestion job may send this operation directly to BReg:
586+
/// only an immediate Action or a Proposal start and submit, the one-
587+
/// operation shapes the direct destination admits (see the module
588+
/// documentation).
589+
pub fn job_direct_admits(descriptor: &OperationDescriptor) -> bool {
590+
[
591+
action::INVOKE.name,
592+
proposal::START.name,
593+
proposal::SUBMIT.name,
594+
]
595+
.contains(&descriptor.name)
596+
}
597+
571598
/// Recovery's reading of a keyed exchange's answer.
572599
///
573600
/// Recovery repeats an attempt whose first answer was lost, so a

‎crates/registry-adapter-connectors/src/lib.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
//! an exact persistable prepared form with no bearer token, one send with
1717
//! a shared outcome vocabulary over the product's native detail, and a
1818
//! per-operation recovery rule.
19+
//!
20+
//! The connector implements every BReg operation family, but an
21+
//! ingestion job may send only some of them directly; the `breg`
22+
//! module's `job_direct_admits` names which.
1923
2024
pub mod operation;
2125

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
#![cfg(feature = "breg")]
3+
//! The direct destination's admission rule: an ingestion job sends an
4+
//! item straight to BReg only through an immediate Action or a Proposal
5+
//! start and submit (`products/adapter/CONCEPT.md` sections 17.1 and
6+
//! 17.3). Every other operation the connector implements stays out of a
7+
//! job's direct path.
8+
9+
use registry_adapter_connectors::breg::{
10+
action, batch, ingestion, job_direct_admits, mutation, proposal,
11+
};
12+
13+
#[test]
14+
fn the_direct_destination_admits_action_and_proposal_only() {
15+
for admitted in [&*action::INVOKE, &*proposal::START, &*proposal::SUBMIT] {
16+
assert!(job_direct_admits(admitted), "{}", admitted.name);
17+
}
18+
for refused in [
19+
&*mutation::CREATE,
20+
&*mutation::PATCH,
21+
&*mutation::TOMBSTONE,
22+
&*batch::RECORDS,
23+
&*ingestion::CREATE_RUN,
24+
&*ingestion::SUBMIT_CHUNK,
25+
] {
26+
assert!(!job_direct_admits(refused), "{}", refused.name);
27+
}
28+
}

0 commit comments

Comments
 (0)