Skip to content

Implementation Log: US-02 Domain Model Core Objects

Feature: US-02 Core Domain Objects

Summary

US-02 delivered the core Asset domain model and the contracts needed to support upload orchestration without leaking persistence or storage details into higher layers. The accepted delivery finished slightly wider than the original story so the repository and storage boundaries were explicit and the uploaded state could not exist without proof.

Implementation Details

  • Added the Asset aggregate with AssetId, UploadId, AccountId, AssetStatus, creation, lifecycle transitions, and reconstitution paths.
  • Extended AssetRepositoryInterface with findByUploadId(...) so the domain contract supports upload-identifier lookup in addition to asset-identifier lookup.
  • Added StorageAdapterInterface and a typed upload-target model made of UploadTarget, UploadParameter, UploadCompletionProof, UploadCompletionProofValue, UploadHttpMethod, and UploadCompletionProofSource.
  • Enforced a completion-proof invariant so uploaded assets require proof both when markUploaded(...) is called and when uploaded state is reconstituted from persistence.

Added to complete US-02

  • Repository lookup by uploadId was added to close a contract gap in the upload flow.
  • The domain storage contract and typed upload-target model were added so upload instructions are explicit, validated domain data.
  • The completion-proof requirement for uploaded state was added as a security-driven invariant instead of leaving uploaded-state reconstruction permissive.

Files Changed

  • src/Domain/Asset/Asset.php — defines the aggregate, lifecycle transitions, and uploaded-state reconstitution rules.
  • src/Domain/Asset/AssetRepositoryInterface.php — adds repository lookup by upload identifier.
  • src/Domain/Asset/StorageAdapterInterface.php — defines the domain storage contract that returns a typed upload target.
  • src/Domain/Asset/ValueObject/UploadTarget.php — models upload instructions as validated domain data.
  • src/Domain/Asset/ValueObject/UploadCompletionProof.php — defines the completion-proof descriptor returned with the upload target.
  • src/Domain/Asset/ValueObject/UploadCompletionProofValue.php — models the proof value captured when an upload completes.
  • tests/Unit/Domain/Asset/AssetTest.php — covers asset creation, lifecycle transitions, equality, and the uploaded-state invariant.
  • tests/Unit/Domain/Asset/ValueObject/UploadTargetTest.php — covers upload-target validation rules.
  • tests/Unit/Domain/Asset/ValueObject/UploadCompletionProofTest.php — covers completion-proof descriptor validation.
  • tests/Unit/Domain/Asset/ValueObject/UploadCompletionProofValueTest.php — covers completion-proof value validation.

Validation

  • composer fix:check — passed.
  • composer analyse — passed.
  • composer test — passed.

Delivery Chunks

  • Asset domain model — introduced the aggregate, identifiers, and asset status lifecycle.
  • Repository and storage contracts — added uploadId lookup and the typed upload-target boundary.
  • Invariant hardening and tests — required completion proof for uploaded state and updated unit coverage.

Follow-up

  • Later application and infrastructure work should consume these contracts directly instead of introducing parallel repository or storage shapes.