Abaixo está uma formulação em Semantic-Typed Algebra usando uma standard-lib canônica para validate, propriedades, ações e fluxo entre Planes.
Assumi estes operadores da nossa standard-lib:
x ⊢ T // x satisfaz o tipo/semântica T
x ⊣ InvalidValue(R) // x é refutado por uma razão R
A ⇢ B // A reescreve/transiciona para B
A ⇔ B // equivalência semântica
A ⊕ B // composição obrigatória: A e B precisam valer
A + B // composição paralelizável/independente no fluxo BE2E
A ⇒_{Agent} B // entrega semântica entre agents
A ⟂ B // contradição/refutação
exists(E.id) // referência precisa existir
unique(E.p) // unicidade semântica/indexada
index(E.p) // propriedade indexável
readonly(E.p) // propriedade não mutável depois da criação
nullable(E.p) // aceita null ou valor válido
secret(E.p) // valor secreto, nunca exposto cru
sensitive(E.p) // dado sensível governado por capability/legal basis
immutable(E.p) // não pode mudar após vínculo causal
positive(x) // x > 0
non_negative(x) // x >= 0
ValidateProperty(E.p : T) ⇔
raw(E.p)
⇒_{EUITypeValidatorAgent}
normalized(E.p)
⇒_{ETypeValidatorAgent}
E.p ⊢ T
Erro padrão:
ValidateProperty(E.p : T).error ⇔
raw(E.p) ⊣ InvalidValue(TypeMismatch(E.p, T))
∨ normalized(E.p) ⊣ InvalidValue(SemanticViolation(E.p, T))
Validação total de uma entidade:
ValidateEntity(E) ⇔
ValidateIdentity(E)
⊕ ValidateProperties(E)
⊕ ValidateCapabilities(E)
⊕ ValidateContradictions(E)
Validação de ação:
ValidateAction(E.action) ⇔
ValidateEntity(E)
⊕ ValidateActionPreconditions(E.action)
⊕ ValidateActionEffects(E.action)
Fluxo genérico entre planes:
UIPlane.Intent(E.action)
⇒_{EUIAgent}
UITestPlane.ValidateIntent
⇒_{ETestAgent}
TypePlane.ValidatePayload
⇒_{ETypeAgent}
GatewayPlane.AntiCorruption
⇒_{EGatewayAgent}
DomainPlane.ApplyAction
⇒_{EDomainAgent}
DataPlane.Persist
⇒_{EDataAgent}
E.action.success
Erro genérico:
AnyPlane.error ⇢ PreviousAgent.error
PreviousAgent.error ⇢ SemanticExecutionStep.error
SemanticExecutionStep.error ⇢ SelfHealingGraph.enrich
ValidateIdentity(Order) ⇔
Order.id ⊢ OrderId
ValidateProperties(Order) ⇔
Validate(Order.status : OrderStatus)
⊕ Validate(Order.totalAmount : FinanceAmount)
⊕ Validate(Order.currency : FinanceCurrency)
⊕ Validate(Order.userId : uuid)
Detalhado:
Validate(Order.id) ⇔
Order.id ⊢ OrderId
Validate(Order.status) ⇔
Order.status ⊢ OrderStatus
⊕ Order.status ⊢ AllowedTransition(OrderStatus)
Validate(Order.totalAmount) ⇔
Order.totalAmount ⊢ FinanceAmount
⊕ positive(Order.totalAmount)
Validate(Order.currency) ⇔
Order.currency ⊢ FinanceCurrency
Validate(Order.userId) ⇔
Order.userId ⊢ uuid
⊕ exists(User.id = Order.userId)
Erros:
Order.status ⊣ InvalidValue(ForbiddenTransition)
⇔ ¬AllowedTransition(Order.status)
Order.totalAmount ⊣ InvalidValue(AmountMustBePositive)
⇔ ¬positive(Order.totalAmount)
Order.userId ⊣ InvalidValue(UserReferenceNotFound)
⇔ ¬exists(User.id = Order.userId)
Order.ValidateOrderTypes ⇔
Validate(Order.status)
⊕ Validate(Order.totalAmount)
Order.ValidateOrderTypes.success ⇔
Order.status ⊢ AllowedTransition(OrderStatus)
⊕ positive(Order.totalAmount)
⇢ OrderTypeAgent.success
Order.ValidateOrderTypes.error ⇔
Order.status ⊣ InvalidValue(ForbiddenTransition)
∨ Order.totalAmount ⊣ InvalidValue(AmountMustBePositive)
⇢ PreviousAgent.error
Order.PaymentAuthorizationFlow ⇔
OrderGatewayAgent
⇒_{TestPlane}
OrderTestAgent
⇒_{TypePlane}
OrderTypeAgent
⇒_{PaymentDomainPlane}
PaymentDomainAgent.authorize
⇒_{OrderDomainPlane}
OrderDomainAgent.process_authorization
⇒_{DataPlane}
OrderDataAgent.persist
⇢ OrderDataAgent.success
Sucesso:
Order.PaymentAuthorizationFlow.success ⇔
Validate(Order)
⊕ Payment.authorize(Order.totalAmount) ⊢ true
⊕ Order.status ⇢ OrderStatus.paid
⊕ Persist(Order)
⇢ OrderDomainAgent.success
Erro:
Order.PaymentAuthorizationFlow.error ⇔
Payment.authorize(Order.totalAmount) ⊢ false
∨ PaymentDomainAgent.error
⇢ OrderGatewayAgent.error
Order.AuthorizePayment.success ⇔
PaymentDomainAgent.authorize(Order.totalAmount) ⊢ true
⊕ Order.status ⇢ OrderStatus.paid
⊕ result("Payment Authorized and Order Updated")
⇢ OrderDomainAgent.success
Order.AuthorizePayment.error ⇔
PaymentDomainAgent.authorize(Order.totalAmount) ⊢ false
⊕ Order.status ⇢ OrderStatus.awaiting_payment
⊕ Order ⊣ InvalidValue(PaymentAuthorizationFailed)
⇢ OrderGatewayAgent.error
ValidateIdentity(Payment) ⇔
Payment.transactionId ⊢ UUID
ValidateProperties(Payment) ⇔
Validate(Payment.amount : FinanceAmount)
⊕ Validate(Payment.currency : FinanceCurrency)
⊕ Validate(Payment.status : FinanceStatus)
⊕ Validate(Payment.method : string)
⊕ Validate(Payment.payerId : string)
⊕ Validate(Payment.payeeId : string)
Detalhado:
Validate(Payment.transactionId) ⇔
Payment.transactionId ⊢ UUID
Validate(Payment.amount) ⇔
Payment.amount ⊢ FinanceAmount
⊕ positive(Payment.amount)
Validate(Payment.currency) ⇔
Payment.currency ⊢ FinanceCurrency
Validate(Payment.status) ⇔
Payment.status ⊢ FinanceStatus
Validate(Payment.method) ⇔
Payment.method ⊢ string
⊕ non_empty(Payment.method)
Validate(Payment.payerId) ⇔
Payment.payerId ⊢ string
⊕ non_empty(Payment.payerId)
Validate(Payment.payeeId) ⇔
Payment.payeeId ⊢ string
⊕ non_empty(Payment.payeeId)
Erros:
Payment.amount ⊣ InvalidValue(AmountMustBePositive)
⇔ ¬positive(Payment.amount)
Payment.method ⊣ InvalidValue(PaymentMethodEmpty)
⇔ empty(Payment.method)
Payment.payerId ⊣ InvalidValue(PayerIdEmpty)
⇔ empty(Payment.payerId)
Payment.payeeId ⊣ InvalidValue(PayeeIdEmpty)
⇔ empty(Payment.payeeId)
Payment.process ⇔
Payment.validate
+
Payment.authorize
⇢ Payment.capture
⇢ Payment.processed
Validação da ação:
ValidateAction(Payment.process) ⇔
Validate(Payment)
⊕ Payment.amount ⊢ FinanceAmount
⊕ positive(Payment.amount)
⊕ Payment.authorize(Payment.amount) ⊢ boolean
Sucesso:
Payment.process.success ⇔
Validate(Payment)
⊕ Payment.authorize(Payment.amount) ⊢ true
⊕ Payment.capture ⊢ immediate
⇢ Payment.processed
Erro:
Payment.process.error ⇔
Validate(Payment) ⊣ InvalidValue(_)
∨ Payment.authorize(Payment.amount) ⊢ false
∨ Payment.capture ⊣ InvalidValue(CaptureFailed)
Payment.refund ⇔
Payment.authorize
⇢ Payment.reversal
⇢ Payment.refunded
ValidateAction(Payment.refund) ⇔
Validate(Payment)
⊕ Payment.status ⊢ RefundableFinanceStatus
⊕ Payment.authorize(Payment.amount) ⊢ true
Payment.refund.success ⇔
Payment.authorize(Payment.amount) ⊢ true
⊕ Payment.reversal ⊢ immediate
⇢ Payment.refunded
Payment.refund.error ⇔
Payment.authorize(Payment.amount) ⊢ false
∨ Payment.status ⊣ InvalidValue(NotRefundable)
∨ Payment.reversal ⊣ InvalidValue(ReversalFailed)
Payment.authorize ⇔
input(Payment.amount) ⊢ FinanceAmount
⊕ output(Payment.authorize) ⊢ boolean
⊕ consistency(Payment.authorize) ⊢ immediate
Payment.capture ⇔
depends_on(Payment.capture, Payment.authorize)
⊕ Payment.authorize(Payment.amount) ⊢ true
⊕ consistency(Payment.capture) ⊢ immediate
⊕ effects(Payment.capture) ⊢ audit
ValidateIdentity(Product) ⇔
Product.id ⊢ ProductId
ValidateProperties(Product) ⇔
Validate(Product.sku : ProductSku)
⊕ Validate(Product.slug : ProductSlug)
⊕ Validate(Product.name : ProductName)
⊕ Validate(Product.description : ProductDescription)
⊕ Validate(Product.shortDescription : ProductShortDescription)
⊕ Validate(Product.price : ProductPrice)
⊕ Validate(Product.currency : ProductCurrency)
⊕ Validate(Product.stock : ProductStock)
⊕ Validate(Product.images : ProductImages)
⊕ Validate(Product.category : ProductCategory)
⊕ Validate(Product.brand : ProductBrand)
⊕ Validate(Product.tags : ProductTags)
⊕ Validate(Product.status : ProductStatus)
⊕ Validate(Product.metadata : ProductMetadata)
⊕ Validate(Product.weight : ProductWeight)
⊕ Validate(Product.dimensions : ProductDimensions)
⊕ Validate(Product.createdAt : ProductCreatedAt)
⊕ Validate(Product.updatedAt : ProductUpdatedAt)
⊕ Validate(Product.deletedAt : nullable ProductDeletedAt)
Detalhado:
Validate(Product.id) ⇔
Product.id ⊢ ProductId
Validate(Product.sku) ⇔
Product.sku ⊢ ProductSku
⊕ unique(Product.sku)
⊕ index(Product.sku)
Validate(Product.slug) ⇔
Product.slug ⊢ ProductSlug
⊕ unique(Product.slug)
⊕ index(Product.slug)
Validate(Product.name) ⇔
Product.name ⊢ ProductName
⊕ index(Product.name)
Validate(Product.description) ⇔
Product.description ⊢ ProductDescription
Validate(Product.shortDescription) ⇔
Product.shortDescription ⊢ ProductShortDescription
Validate(Product.price) ⇔
Product.price ⊢ ProductPrice
⊕ non_negative(Product.price)
Validate(Product.currency) ⇔
Product.currency ⊢ ProductCurrency
Validate(Product.stock) ⇔
Product.stock ⊢ ProductStock
⊕ non_negative(Product.stock)
Validate(Product.images) ⇔
Product.images ⊢ ProductImages
Validate(Product.category) ⇔
Product.category ⊢ ProductCategory
⊕ index(Product.category)
Validate(Product.brand) ⇔
Product.brand ⊢ ProductBrand
⊕ index(Product.brand)
Validate(Product.tags) ⇔
Product.tags ⊢ ProductTags
Validate(Product.status) ⇔
Product.status ⊢ ProductStatus
Validate(Product.metadata) ⇔
Product.metadata ⊢ ProductMetadata
Validate(Product.weight) ⇔
Product.weight ⊢ ProductWeight
⊕ non_negative(Product.weight)
Validate(Product.dimensions) ⇔
Product.dimensions ⊢ ProductDimensions
Validate(Product.createdAt) ⇔
Product.createdAt ⊢ ProductCreatedAt
⊕ readonly(Product.createdAt)
Validate(Product.updatedAt) ⇔
Product.updatedAt ⊢ ProductUpdatedAt
⊕ readonly(Product.updatedAt)
Validate(Product.deletedAt) ⇔
nullable(Product.deletedAt)
⊕ (
Product.deletedAt = null
∨ Product.deletedAt ⊢ ProductDeletedAt
)
⊕ readonly(Product.deletedAt)
Erros principais:
Product.sku ⊣ InvalidValue(SkuAlreadyExists)
⇔ ¬unique(Product.sku)
Product.slug ⊣ InvalidValue(SlugAlreadyExists)
⇔ ¬unique(Product.slug)
Product.price ⊣ InvalidValue(PriceCannotBeNegative)
⇔ Product.price < 0
Product.stock ⊣ InvalidValue(StockCannotBeNegative)
⇔ Product.stock < 0
Product.createdAt ⊣ InvalidValue(ReadOnlyViolation)
⇔ mutated_after_create(Product.createdAt)
Product.updatedAt ⊣ InvalidValue(ReadOnlyViolation)
⇔ externally_mutated(Product.updatedAt)
Product.deletedAt ⊣ InvalidValue(DeletedAtInvalid)
⇔ Product.deletedAt ≠ null ∧ Product.deletedAt ⊣ ProductDeletedAt
Product.create ⇔
Product.sku.normalize
+
Product.sku.verify_unique
+
Product.slug.generate
+
Product.slug.verify_unique
+
Product.name.normalize
+
Product.description.sanitize
+
Product.shortDescription.sanitize
+
Product.price.validate
+
Product.currency.validate
+
Product.stock.initialize
+
Product.images.validate
+
Product.category.validate
+
Product.brand.normalize
+
Product.status.draft
⇢ Product.created
ValidateAction(Product.create) ⇔
Validate(Product.sku)
⊕ Validate(Product.slug)
⊕ Validate(Product.name)
⊕ Validate(Product.description)
⊕ Validate(Product.shortDescription)
⊕ Validate(Product.price)
⊕ Validate(Product.currency)
⊕ Validate(Product.stock)
⊕ Validate(Product.images)
⊕ Validate(Product.category)
⊕ Validate(Product.brand)
⊕ Product.status ⇢ ProductStatus.draft
Product.publish ⇔
Product.sku.validate
+
Product.slug.validate
+
Product.name.validate
+
Product.price.validate
+
Product.stock.validate
+
Product.images.validate
+
Product.status.publish
⇢ Product.published
ValidateAction(Product.publish) ⇔
Validate(Product.sku)
⊕ Validate(Product.slug)
⊕ Validate(Product.name)
⊕ Validate(Product.price)
⊕ Validate(Product.stock)
⊕ Validate(Product.images)
⊕ Product.status ⊢ PublishableProductStatus
Product.publish.success ⇔
ValidateAction(Product.publish)
⊕ Product.status ⇢ ProductStatus.published
⇢ Product.published
Product.updateDetails ⇔
Product.name.normalize
+
Product.description.sanitize
+
Product.shortDescription.sanitize
+
Product.category.validate
+
Product.brand.normalize
+
Product.tags.validate
⇢ Product.details_updated
ValidateAction(Product.updateDetails) ⇔
Validate(Product.name)
⊕ Validate(Product.description)
⊕ Validate(Product.shortDescription)
⊕ Validate(Product.category)
⊕ Validate(Product.brand)
⊕ Validate(Product.tags)
Product.updatePrice ⇔
Product.price.validate
+
Product.currency.validate
⇢ Product.price_updated
ValidateAction(Product.updatePrice) ⇔
Validate(Product.price)
⊕ Validate(Product.currency)
Product.updateStock ⇔
Product.stock.adjust
⇢ Product.stock_updated
ValidateAction(Product.updateStock) ⇔
Validate(Product.stock)
⊕ Product.stock ⊢ AdjustableStockValue
Product.addImages ⇔
Product.images.validate
+
Product.images.optimize
⇢ Product.images_updated
ValidateAction(Product.addImages) ⇔
Validate(Product.images)
⊕ Product.images ⊢ OptimizableImageSet
Product.archive ⇔
Product.status.archive
⇢ Product.archived
ValidateAction(Product.archive) ⇔
Product.status ⊢ ArchivableProductStatus
Product.delete ⇔
Product.deletedAt.mark
+
Product.status.archive
⇢ Product.deleted
ValidateAction(Product.delete) ⇔
Product.deletedAt ⊢ ProductDeletedAt
⊕ Product.status ⊢ ArchivableProductStatus
ValidateCapabilities(Stock) ⇔
Stock ⊢ causal_ordering
⊕ Stock ⊢ temporal_consistency
ValidateIdentity(Stock) ⇔
Stock.id ⊢ StockId
ValidateProperties(Stock) ⇔
Validate(Stock.product : ProductId)
⊕ Validate(Stock.quantity : StockQuantity)
⊕ Validate(Stock.reserved : StockReserved)
⊕ Validate(Stock.available : StockAvailable)
⊕ Validate(Stock.warehouse : StockWarehouse)
⊕ Validate(Stock.location : StockLocation)
⊕ Validate(Stock.status : StockStatus)
⊕ Validate(Stock.deleted : boolean)
⊕ Validate(Stock.deletedAt : datetime)
Detalhado:
Validate(Stock.id) ⇔
Stock.id ⊢ StockId
Validate(Stock.product) ⇔
Stock.product ⊢ ProductId
⊕ exists(Product.id = Stock.product)
⊕ index(Stock.product)
⊕ immutable(Stock.product)
Validate(Stock.quantity) ⇔
Stock.quantity ⊢ StockQuantity
⊕ non_negative(Stock.quantity)
Validate(Stock.reserved) ⇔
Stock.reserved ⊢ StockReserved
⊕ non_negative(Stock.reserved)
⊕ Stock.reserved <= Stock.quantity
Validate(Stock.available) ⇔
Stock.available ⊢ StockAvailable
⊕ Stock.available == Stock.quantity - Stock.reserved
Validate(Stock.warehouse) ⇔
Stock.warehouse ⊢ StockWarehouse
⊕ index(Stock.warehouse)
Validate(Stock.location) ⇔
Stock.location ⊢ StockLocation
Validate(Stock.status) ⇔
Stock.status ⊢ StockStatus
Validate(Stock.deleted) ⇔
Stock.deleted ⊢ boolean
Validate(Stock.deletedAt) ⇔
Stock.deletedAt ⊢ datetime
StockRule.ReservedLTEQuantity ⇔
Stock.reserved <= Stock.quantity
StockRule.AvailableDerivation ⇔
Stock.available == Stock.quantity - Stock.reserved
StockRule.OutOfStockIffAvailableZero ⇔
Stock.status.out_of_stock ⇔ Stock.available == 0
StockContradiction.ReservedAndDiscontinued ⇔
Stock.reserved > 0
⟂
Stock.status.discontinued
Erros:
Stock.reserved ⊣ InvalidValue(ReservedGreaterThanQuantity)
⇔ Stock.reserved > Stock.quantity
Stock.available ⊣ InvalidValue(AvailableMustEqualQuantityMinusReserved)
⇔ Stock.available ≠ Stock.quantity - Stock.reserved
Stock.status ⊣ InvalidValue(OutOfStockStatusMismatch)
⇔ Stock.status.out_of_stock ∧ Stock.available ≠ 0
Stock ⊣ RefutedValue(ReservedDiscontinuedContradiction)
⇔ Stock.reserved > 0 ∧ Stock.status.discontinued
Stock.replenish ⇔
Stock.quantity.increment
+
Stock.available.calculate
⇢ Stock.replenished
ValidateAction(Stock.replenish) ⇔
Validate(Stock.quantity)
⊕ Validate(Stock.available)
⊕ Stock.quantity.increment ⊢ PositiveDelta
⊕ Stock.available' == Stock.quantity' - Stock.reserved
Stock.reserve ⇔
Stock.reserved.reserve
+
Stock.available.calculate
⇢ Stock.reserved
ValidateAction(Stock.reserve) ⇔
Validate(Stock.quantity)
⊕ Validate(Stock.reserved)
⊕ Validate(Stock.available)
⊕ Stock.reserved' <= Stock.quantity
⊕ Stock.available' == Stock.quantity - Stock.reserved'
Erro:
Stock.reserve.error ⇔
Stock.reserved' > Stock.quantity
⇢ Stock ⊣ InvalidValue(InsufficientAvailableStock)
Stock.release ⇔
Stock.reserved.release
+
Stock.available.calculate
⇢ Stock.released
ValidateAction(Stock.release) ⇔
Stock.reserved.release ⊢ NonNegativeDelta
⊕ Stock.reserved' >= 0
⊕ Stock.available' == Stock.quantity - Stock.reserved'
Stock.transfer ⇔
Stock.warehouse.update
⇢ Stock.transferred
ValidateAction(Stock.transfer) ⇔
Validate(Stock.warehouse)
⊕ Stock.warehouse' ⊢ StockWarehouse
⊕ Stock.warehouse' ≠ Stock.warehouse
Stock.reconcile ⇔
Stock.quantity.reconcile
+
Stock.available.calculate
⇢ Stock.reconciled
ValidateAction(Stock.reconcile) ⇔
Validate(Stock.quantity)
⊕ Stock.quantity' ⊢ StockQuantity
⊕ non_negative(Stock.quantity')
⊕ Stock.available' == Stock.quantity' - Stock.reserved
ValidateCapabilities(User) ⇔
User ⊢ legal_basis(contractual)
⊕ User ⊢ retention_limited
ValidateIdentity(User) ⇔
User.id ⊢ UserId
ValidateProperties(User) ⇔
Validate(User.username : UserUsername)
⊕ Validate(User.email : UserEmail)
⊕ Validate(User.passwordHash : UserPasswordHash)
⊕ Validate(User.isActive : UserIsActive)
⊕ Validate(User.createdAt : UserCreatedAt)
⊕ Validate(User.lastLoginAt : nullable UserLastLoginAt)
Detalhado:
Validate(User.id) ⇔
User.id ⊢ UserId
Validate(User.username) ⇔
User.username ⊢ UserUsername
⊕ index(User.username)
⊕ unique(User.username)
⊕ User.username ⊢ ValidLength
⊕ User.username ⊢ ValidCharacters
Validate(User.email) ⇔
User.email ⊢ UserEmail
⊕ index(User.email)
⊕ unique(User.email)
⊕ sensitive(User.email)
⊕ User.email ⊢ EmailFormat
Validate(User.passwordHash) ⇔
User.passwordHash ⊢ UserPasswordHash
⊕ secret(User.passwordHash)
⊕ sensitive(User.passwordHash)
⊕ User.passwordHash ⊢ HashFormat
⊕ User.passwordHash ⊢ PasswordComplexityDerived
Validate(User.isActive) ⇔
User.isActive ⊢ UserIsActive
Validate(User.createdAt) ⇔
User.createdAt ⊢ UserCreatedAt
⊕ readonly(User.createdAt)
Validate(User.lastLoginAt) ⇔
nullable(User.lastLoginAt)
⊕ (
User.lastLoginAt = null
∨ User.lastLoginAt ⊢ UserLastLoginAt
)
⊕ readonly(User.lastLoginAt)
Erros:
User.username ⊣ InvalidValue(UsernameAlreadyExists)
⇔ ¬unique(User.username)
User.username ⊣ InvalidValue(InvalidUsernameCharacters)
⇔ User.username ⊣ ValidCharacters
User.email ⊣ InvalidValue(InvalidEmailFormat)
⇔ User.email ⊣ EmailFormat
User.email ⊣ InvalidValue(EmailAlreadyExists)
⇔ ¬unique(User.email)
User.passwordHash ⊣ InvalidValue(PasswordHashInvalid)
⇔ User.passwordHash ⊣ HashFormat
User.createdAt ⊣ InvalidValue(ReadOnlyViolation)
⇔ mutated_after_create(User.createdAt)
User.lastLoginAt ⊣ InvalidValue(LastLoginAtInvalid)
⇔ User.lastLoginAt ≠ null ∧ User.lastLoginAt ⊣ UserLastLoginAt
User.ValidateUserTypes ⇔
Validate(User.username)
⊕ Validate(User.email)
⊕ Validate(User.passwordHash)
⊕ Validate(User.id)
User.ValidateUserTypes.success ⇔
User.username ⊢ ValidLength
⊕ User.username ⊢ ValidCharacters
⊕ User.email ⊢ EmailFormat
⊕ User.passwordHash ⊢ UserPasswordHash
⊕ User.id ⊢ UserId
⇢ UserTypeAgent.success
User.ValidateUserTypes.error ⇔
User.username ⊣ InvalidValue(_)
∨ User.email ⊣ InvalidValue(_)
∨ User.passwordHash ⊣ InvalidValue(_)
∨ User.id ⊣ InvalidValue(_)
⇢ PreviousAgent.error
O arquivo user.be2e já declara o fluxo mais completo. Em álgebra:
User.CreateUserFlow ⇔
UserUIAgent
⇒_{UIPlane}
UserTestAgent
⇒_{UITestPlane}
UserTypeAgent
⇒_{UITypePlane}
UserGatewayAgent
⇒_{GatewayPlane}
UserTestAgent
⇒_{GatewayTestPlane}
UserTypeAgent
⇒_{GatewayTypePlane}
UserDomainAgent
⇒_{DomainPlane}
UserTestAgent
⇒_{DomainTestPlane}
UserTypeAgent
⇒_{DomainTypePlane}
UserDataAgent.persist
⇒_{DataPlane}
UserDataAgent.success
Forma com validações explícitas:
UserUIAgent.receive(CreateUserIntent)
⇒_{UserTestAgent}
ValidateIntent(CreateUserIntent)
⇒_{UserTypeAgent}
ValidateUserTypes
⇒_{UserGatewayAgent}
AntiCorruption(UserPayload)
⇒_{UserTestAgent}
ValidateGatewayContract(UserPayload)
⇒_{UserTypeAgent}
ValidateUserTypes
⇒_{UserDomainAgent}
Apply(User.create)
⇒_{UserTestAgent}
ValidateDomainInvariants(User)
⇒_{UserTypeAgent}
ValidateUserTypes
⇒_{UserDataAgent}
Persist(User)
⇢ UserDataAgent.success
Propagação pós-persistência:
UserDataAgent.success
⇒_{UserEventsAgent}
Emit(User.created)
UserDataAgent.success
⇒_{UserGraphAgent}
Project(User.identity_graph)
UserDataAgent.success
⇒_{UserAnalyticsAgent}
Project(User.analytics)
UserDataAgent.success
⇒_{UserReadAgent}
Project(User.read_model)
UserDataAgent.success
⇒_{UserCacheAgent}
Cache(User)
UserDataAgent.success
⇒_{UserVectorAgent}
Vectorize(User.canonical_label)
UserDataAgent.success
⇒_{UserLogsAgent}
Log(User.created)
UserDataAgent.success
⇒_{UserTracesAgent}
Trace(User.CreateUserFlow)
UserDataAgent.success
⇒_{UserMetricsAgent}
Metric(User.created.count + 1)
Product.Create.flow ⇔
open(ProductCreatePage)
⇢ fill(Product.sku)
⇢ fill(Product.name)
⇢ fill(Product.description)
⇢ fill(Product.price)
⇢ fill(Product.stock)
⇢ upload(Product.images)
⇢ click(ProductCreatePage.submit)
⇢ expect(Product.created)
Por Planes:
ProductUIAgent.receive(Product.create)
⇒_{ProductUITestAgent}
ValidateUIIntent(Product.create)
⇒_{ProductUITypeAgent}
ValidateProperties(Product)
⇒_{ProductGatewayAgent}
AntiCorruption(ProductPayload)
⇒_{ProductDomainAgent}
Apply(Product.create)
⇒_{ProductDataAgent}
Persist(Product)
⇢ Product.created
Com ação expandida:
ProductUIAgent.submit(ProductCreatePage)
⇒_{ProductUITypeAgent}
(
Validate(Product.sku)
⊕ Validate(Product.name)
⊕ Validate(Product.description)
⊕ Validate(Product.price)
⊕ Validate(Product.stock)
⊕ Validate(Product.images)
)
⇒_{ProductDomainAgent}
Product.create
⇒_{ProductDataAgent}
Persist(Product)
⇢ Product.created
Product.Publish.flow ⇔
open(ProductEditPage)
⇢ click(ProductEditPage.publish)
⇢ expect(Product.published)
ProductUIAgent.receive(Product.publish)
⇒_{ProductTypeAgent}
ValidateAction(Product.publish)
⇒_{ProductDomainAgent}
Product.status.publish
⇒_{ProductDataAgent}
Persist(Product.status = ProductStatus.published)
⇢ Product.published
Search não vai obrigatoriamente até o Data Plane transacional; ele pode ir para Read/Search Plane. Mas, se você quiser manter a cadeia UI → Data, a fórmula fica:
Product.Search.flow ⇔
open(ProductSearchPage)
⇢ fill(Product.name)
⇢ click(ProductSearchPage.search)
⇢ expect(ProductSearchPage.results exists)
ProductUIAgent.receive(Product.search)
⇒_{ProductUITypeAgent}
Validate(Product.name)
⇒_{ProductGatewayAgent}
AntiCorruption(SearchQuery)
⇒_{ProductReadAgent}
Query(ProductReadModel ∨ ProductSearchIndex)
⇢ ProductSearchPage.results
Forma com Data Plane como fallback:
ProductReadAgent.miss
⇒_{ProductDataAgent}
Query(Product)
⇒_{ProductReadAgent}
Project(ProductSearchPage.results)
Stock.Audit.flow ⇔
open(StockAuditPage)
⇢ fill(Stock.warehouse)
⇢ click(StockAuditPage.reconcile)
⇢ expect(Stock.reconciled)
Por Planes:
StockUIAgent.receive(Stock.reconcile)
⇒_{StockUITypeAgent}
Validate(Stock.warehouse)
⇒_{StockGatewayAgent}
AntiCorruption(StockPayload)
⇒_{StockDomainAgent}
Apply(Stock.reconcile)
⇒_{StockDataAgent}
Persist(Stock)
⇢ Stock.reconciled
Com regras explícitas:
StockDomainAgent.Apply(Stock.reconcile) ⇔
Stock.quantity.reconcile
+
Stock.available.calculate
⊕ Stock.available' == Stock.quantity' - Stock.reserved
⊕ Stock.reserved' <= Stock.quantity'
⊕ ¬(Stock.reserved' > 0 ∧ Stock.status.discontinued)
PaymentUIAgent.receive(Payment.process)
⇒_{PaymentUITypeAgent}
ValidateProperties(Payment)
⇒_{PaymentGatewayAgent}
AntiCorruption(PaymentPayload)
⇒_{PaymentDomainAgent}
Payment.validate + Payment.authorize
⇒_{PaymentDomainAgent}
Payment.capture
⇒_{PaymentDataAgent}
Persist(Payment)
⇢ Payment.processed
Este é o fluxo mais importante porque atravessa duas entidades: Order e Payment.
OrderUIAgent.receive(Order.AuthorizePayment)
⇒_{OrderGatewayAgent}
OrderGatewayAgent
⇒_{OrderTestAgent}
ValidateIntent(Order.AuthorizePayment)
⇒_{OrderTypeAgent}
ValidateOrderTypes
⇒_{PaymentDomainAgent}
Payment.authorize(Order.totalAmount)
⇒_{OrderDomainAgent}
Order.process_authorization
⇒_{OrderDataAgent}
Persist(Order.status = OrderStatus.paid)
⇢ OrderDataAgent.success
Erro:
PaymentDomainAgent.error
⇒_{OrderGatewayAgent}
OrderGatewayAgent.error
⇒_{OrderUIAgent}
Render(PaymentAuthorizationFailed)
Sucesso:
PaymentDomainAgent.success
⇒_{OrderDomainAgent}
Order.status ⇢ OrderStatus.paid
⇒_{OrderDataAgent}
Persist(Order)
⇢ OrderDomainAgent.success
System.ValidateFromUIToData(E.action) ⇔
UIPlane(E.action)
⊕ TestPlane(E.action)
⊕ TypePlane(E)
⊕ GatewayPlane(E.action)
⊕ DomainPlane(E.action)
⊕ DataPlane(E.persist)
Expandida:
System.ValidateFromUIToData(E.action) ⇔
EUIAgent.receive(Intent(E.action))
⇒_{ETestAgent}
ValidateIntent(Intent(E.action))
⇒_{ETypeAgent}
ValidateProperties(E)
⇒_{EGatewayAgent}
AntiCorruption(E.payload)
⇒_{ETestAgent}
ValidateGatewayContract(E.payload)
⇒_{ETypeAgent}
ValidateProperties(E)
⇒_{EDomainAgent}
ValidateAction(E.action)
⇒_{ETestAgent}
ValidateDomainInvariants(E)
⇒_{ETypeAgent}
ValidateProperties(E)
⇒_{EDataAgent}
Persist(E)
⇢ EDataAgent.success
Erro global:
System.ValidateFromUIToData.error ⇔
ValidateIntent(Intent(E.action)) ⊣ InvalidValue(_)
∨ ValidateProperties(E) ⊣ InvalidValue(_)
∨ AntiCorruption(E.payload) ⊣ InvalidValue(_)
∨ ValidateAction(E.action) ⊣ InvalidValue(_)
∨ ValidateDomainInvariants(E) ⊣ RefutedValue(_)
∨ Persist(E) ⊣ PersistenceError(_)
Self-healing hook:
System.ValidateFromUIToData.error
⇢ SemanticExecutionStep.error
⇢ SemanticExecutionGraph.enrich
⇢ SimilarErrorSearch
⇢ RepairCandidate
⇢ RetryOrRefute
ValidateAllEntities ⇔
ValidateEntity(User)
⊕ ValidateEntity(Product)
⊕ ValidateEntity(Stock)
⊕ ValidateEntity(Payment)
⊕ ValidateEntity(Order)
ValidateAllActions ⇔
ValidateAction(User.CreateUserFlow)
⊕ ValidateAction(Product.create)
⊕ ValidateAction(Product.publish)
⊕ ValidateAction(Product.updateDetails)
⊕ ValidateAction(Product.updatePrice)
⊕ ValidateAction(Product.updateStock)
⊕ ValidateAction(Product.addImages)
⊕ ValidateAction(Product.archive)
⊕ ValidateAction(Product.delete)
⊕ ValidateAction(Stock.replenish)
⊕ ValidateAction(Stock.reserve)
⊕ ValidateAction(Stock.release)
⊕ ValidateAction(Stock.transfer)
⊕ ValidateAction(Stock.reconcile)
⊕ ValidateAction(Payment.process)
⊕ ValidateAction(Payment.refund)
⊕ ValidateAction(Order.AuthorizePayment)
⊕ ValidateAction(Order.PaymentAuthorizationFlow)
Fórmula sistêmica:
AllasCode.SemanticValidationPipeline ⇔
ValidateAllEntities
⊕ ValidateAllActions
⊕ ValidateAllPlaneFlows
⊕ RefuteAllContradictions
⊕ PersistOnlyValidSemanticState
E a regra constitucional principal:
Persist(E) ⇔
ValidateEntity(E)
⊕ ValidateAction(E.action)
⊕ ValidateDomainInvariants(E)
⊕ ¬Refuted(E)
Persist(E) ⊣ RefutedValue(InvalidSemanticState)
⇔
Refuted(E)
∨ ValidateEntity(E) ⊣ InvalidValue(_)
∨ ValidateAction(E.action) ⊣ InvalidValue(_)
Essa é a forma que deixa explícito que nenhum dado cru da UI chega ao Data Plane sem passar por validação de intenção, tipo, domínio, contradições e persistência semântica.