Add Organization aggregate (client-as-status), wired but inert
Deploy / deploy (push) Successful in 34s

Prospect -> Client -> PastClient (Prospect -> PastClient allowed
directly too - a prospect that never converted). "Client" is a status
on Organization, not a separate aggregate, per the event-sourcing
plan's design decision. Wired into the same dispatch points as the
other three aggregates (content.rs's bucket map, answers.rs's
create/transition dispatch) so it's ready the moment content
references an "organizations" bucket - nothing does yet, so this lands
compiled and tested but with zero production surface.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Bendik Aagaard Lynghaug
2026-08-06 12:01:17 +02:00
co-authored by Claude Sonnet 5
parent 755b796ad1
commit aa18c69be4
4 changed files with 54 additions and 2 deletions
+6 -2
View File
@@ -78,7 +78,7 @@ pub async fn store_answer(
// fail a submission the NATS notification event has already
// recorded" policy as the KV write above.
if let Some(agg_type) = crate::content::aggregate_type_for_bucket(bucket) {
use crate::aggregates::{applicant, create, project, subscriber};
use crate::aggregates::{applicant, create, organization, project, subscriber};
let seed = match agg_type {
"applicant" => create::<applicant::State>(js, &id, responses.clone(), submitted_ms)
.await
@@ -89,6 +89,9 @@ pub async fn store_answer(
"project" => create::<project::State>(js, &id, responses.clone(), submitted_ms)
.await
.map(|_| ()),
"organization" => create::<organization::State>(js, &id, responses.clone(), submitted_ms)
.await
.map(|_| ()),
_ => Ok(()),
};
if let Err(e) = seed {
@@ -242,7 +245,7 @@ async fn transition_by_aggregate(
payload: serde_json::Value,
occurred_at_ms: i64,
) -> Result<(), crate::aggregates::TransitionError> {
use crate::aggregates::{applicant, project, subscriber, transition, AggregateKind, TransitionError};
use crate::aggregates::{applicant, organization, project, subscriber, transition, AggregateKind, TransitionError};
macro_rules! dispatch {
($state:ty) => {{
@@ -260,6 +263,7 @@ async fn transition_by_aggregate(
"applicant" => dispatch!(applicant::State),
"subscriber" => dispatch!(subscriber::State),
"project" => dispatch!(project::State),
"organization" => dispatch!(organization::State),
_ => return Err(TransitionError::UnknownAggregate),
}
Ok(())