feat(domain): add pure Dart domain model: Agent, Hire, Payment, Feedback, validated StellarAddress/UsdcAmount, ports and typed errors - #60
Merged
Conversation
…, ports and typed errors New puls3_domain package at the repo root (ADR-0001), added to the pub workspace. Entities Agent, Skill, Hire, Payment and Feedback; value objects StellarAddress (length, base32, version byte and CRC16 checksum), UsdcAmount (integer stroops, 0..2^53-1), AgentId (u32), HireId and TransactionHash; ports AgentRepository, LedgerPort and AgentRuntimePort; typed DomainError subclasses. docs/domain/model.md has the glossary, class diagram and invariants I1-I17. Written test-first: 40 tests, one group per invariant, and mutating each invariant check makes a test fail. No dependency on serverpod, flutter or any Stellar SDK.
Deploying puls3 with
|
| Latest commit: |
839da02
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ada875ca.puls3-4lw.pages.dev |
| Branch Preview URL: | https://feat-9-domain-model.puls3-4lw.pages.dev |
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.
Closes #9
Summary
Adds
puls3_domain/, the pure Dart domain package every other layer builds on, anddocs/domain/model.md.puls3_domain/at the repo root, next to the otherpuls3_*packages, as ADR-0001 decided (the issue's default waspackages/puls3_domain/). Added to the root pub workspace; no new dependencies, sopubspec.lockis unchanged.Agent(id, owner, wallet, name, description, 1–5 skills, price),Skill(A2A shape from ADR-0004),Hire(price and manifest version at hire time),Payment(withsettles(hire, agentWallet:), the ADR-0003 rule: same hire, paid to the agent wallet, exact amount),Feedback(score 1–5, comment ≤ 500).StellarAddress(56 chars, base32,G/Cprefix, version byte, CRC16-XModem checksum),UsdcAmount(integer stroops, 0..2^53−1 so it is exact on the web too),AgentId(u32, like the contract),HireId(1..2^53−1, the payment's muxed id),TransactionHash.AgentRepository,LedgerPort,AgentRuntimePort.DomainErrorwith one subclass per rule (InvalidStellarAddress,InvalidAgent, …), each carrying an enum that names the broken rule.docs/domain/model.md: glossary, Mermaid class diagram, and invariants I1–I17, each naming the error it raises.Acceptance criteria
pubspec.yamlof the domain package has no dependency onserverpod,flutter, orstellar_flutter_sdkdart analyzereports 0 issues (--fatal-infos)dart testpasses (40 tests)model.mdhas at least one test that fails when the invariant is broken (see mutation run below)StellarAddressrejects wrong prefix, wrong length, and bad checksum, with a test for each (plus invalid characters and a tampered payload)doubleanywhere in the packageVerification evidence
Written test-first: the tests were run before
lib/existed and failed to compile (Type 'Skill' not found).Mutation run: each of the 24 invariant checks was broken one at a time, the suite was run, and the code restored:
StellarAddresstests use real testnet addresses: an account and the Identity Registry contract deployed in #58.The current CI steps still pass with the new workspace member:
flutter pub getat the root, thendart analyze --fatal-infosanddart format --set-exit-if-changed .inpuls3_server.Notes for reviewers