Repository navigation
refactor(arch): give adapters Farm's farm-code rule and image-size errors through its contract - #1121
Merged
Merged
Conversation
…rors through its contract Part of #1116 (the P3 design change). The sign-in validator and the provision-account and rename-account verbs named the Account aggregate for the slug rule, and the logo and banner endpoints named ImageSanitizer and its asset kinds for the over-size refusal. - FarmCode, in Farm's Domain contract, now holds the one farm-code rule: trimming, the pattern, the reserved set, the error code and text, and the 32-character limit. Account.TryValidateSlug and Account.SlugMaxLength delegate to it. - FarmImageErrors.LogoTooLarge and BannerTooLarge forward to ImageSanitizer.TooLarge, so codes, messages, the configured limit and the 413 mapping are unchanged and ImageAssetKind stays internal to the sanitizer. The CW1004 census falls by the 6 P3 rows.
mforce
force-pushed
the
refactor/1116-farm-code-image-errors
branch
from
October 6, 2026 19:30
968e1a1 to
08baa93
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1116 (cleanup PR C5, the P3 design change). It does not close the issue.
Adapters stop naming Farm internals for two rules they need:
FarmCode(Domain/Modules/Farm/Contracts/) now holds the one farm-code rule: trimming, the pattern, the reserved set, theAccount.SlugInvalidcode and text, and the 32-character limit.Account.TryValidateSlugandAccount.SlugMaxLengthdelegate to it. The sign-in validator and theprovision-accountandrename-accountverbs callFarmCode.FarmImageErrors.LogoTooLargeandBannerTooLargeforward toImageSanitizer.TooLarge. The logo and banner endpoints call those, andImageAssetKindstays inside the sanitizer.CW1004 census (
tools/architecture/cw1004-census.sh), on main without C4: 46 → 40, exactly the 6 P3 rows. With C4 (#1120) merged as well, it is 8 → 2, leaving the two P4 rows. Proofs and the design notes follow in an edit.Design notes (Astra's review, §4 of the design comparison)
Account.SlugInvalidcode and text, and the 32-character limit moved verbatim fromAccountintoFarmCode. Diffed against main'sAccount.TryValidateSlug, the body is identical apart from member names (SlugPattern→Pattern,ReservedSlugs→Reserved), and the reserved set and regex literals are byte-identical.Account.TryValidateSlugandAccount.SlugMaxLengthare now one-line delegates, used byAccountitself,AccountProvisioner,AccountRenameServiceand the EF mapping.Account.ReservedSlugswas used only by tests, so it was removed rather than delegated;AccountSlugTestsreadsFarmCode.Reserved.ImageAssetKindnot exposed.FarmImageErrors.LogoTooLargeandBannerTooLargeforward toImageSanitizer.TooLargewith the same arguments the endpoints passed before. That keeps the configured byte limit, theFarmLogo.TooLarge/FarmBanner.TooLargecodes, the "must be N KB or smaller" message and the 413 mapping (MapFailure) in one place. The sanitizer and its asset kinds stay outside the contract.Policy review: why these belong in Farm's public API
FarmCode. The farm code is a public identifier: people type it at sign-in, and theprovision-accountandrename-accountverbs take it as an argument. Adapters need its length limit and validation. Before this PR they could get them only by naming theAccountaggregate, which adapters may not reach. Publishing the rule, and not the aggregate, gives them exactly that. It names no entity.FarmImageErrors. The upload endpoints refuse an over-size body while streaming, before the bytes reach the sanitizer. They need the same refusal the sanitizer would raise. Two error factories expose that and nothing else; they returnError, a kernel type.Proofs (head
968e1a1e)ProvisionAccountCliCommand,RenameAccountCliCommandandLoginRequestValidator→Account;FarmBannerEndpoints→ImageSanitizerandImageAssetKind;FarmLogoEndpoints→ImageSanitizerAccountProvisioner. The merge has one conflict, ausingline inAccount.cs(keep this PR's side, withoutSystem.Text.RegularExpressions); it builds with 0 warnings and 0 errorsTenantBypassRealTreeTests4/4; no registry member changed (AccountProvisionerandAccountRenameServicestill callAccount.TryValidateSlug)Entity<Guid>? PurityProbetoFarmCodefailsModuleContractRealAssemblyTests; restoredTenantBypassRealTreeTests4,AdapterReachRealTreeTests2,PeerContractRealTreeTests1,ModuleContractRealAssemblyTests1,ContractDerivationTests1,ModuleLedgerRealTreeTests2,CouplingMatrixRealTreeTests3,ModuleEdgeAnalyzerTests14,NamespaceFolderAgreementTests10,AdapterTierRealTreeTests3,AccessOwnershipClaimTests2,InsightsReadOnlyTests25,SeamSurfaceRealAssemblyTests2,TableOwnerRealModelTests2,CompatibilityExceptionRealTreeTests2AccountSlugTests30,ImageSanitizerTests81FarmLogoTests38,FarmBannerTests15,FarmLogoRequestBodyCapTests4: 413 withFarmLogo.TooLarge/FarmBanner.TooLargeon both the streaming cap and the handler path.LoginRequestValidatorTests7,AccountLifecycleCommandTests24:Account.SlugInvalidand "'bad code' is not a valid farm code" fromrename-account.ProvisionAccountCommandTests11dotnet build Cluckwork.slnxwith repo defaults: 0 warnings, 0 errorsDeslop removed one test-only delegate (
Account.ReservedSlugs). A historical plan,docs/plans/732-rename-account-verb/02-implementation-runbook.md, still namesAccount.TryValidateSlugand is left as written.