KazaiMazai/SwiftletModel
53.6
Adequate · 21 September 2026
6k
lines of production code
Swift
primary language
4
measurements over time
What this system is
SwiftletModel is a Swift library that provides an in-memory object-relational mapping (ORM) framework for managing entity data. It enables developers to define data models using macros, which automatically generate code for persistence, indexing, and relationship management. The system supports complex queries, soft deletes, merge strategies, and various indexing types, all managed through a context-based API.
How it got here
2024 — SwiftletModel macro and feature expansion
12 changes.
The project was renamed to SwiftletModel and expanded with Swift macros for automatic model generation, alongside new features like soft deletes, merge strategies, and in-memory context management. This period also involved comprehensive test coverage for queries, relations, and entity lifecycle operations.
2025 — Query and Indexing Features
8 changes.
This period focused on expanding the SwiftletModel framework with advanced indexing capabilities, including unique, hashable, and full-text search constraints. A new query API was introduced to support complex filtering, sorting, and relation handling, while the underlying macro architecture was refactored for better modularity.
Features
Introduce Context and EntitiesRepository for in-memory entity management
Added the Context struct and EntitiesRepository to provide an in-memory storage layer for SwiftletModel entities. The Context exposes methods to query, insert, remove, and mutate entities, while the EntitiesRepository manages the underlying storage using a generic dictionary-based approach. This change enables efficient in-memory operations on entities, supporting features like lazy evaluation and merge strategies during insertions.
Sources/SwiftletModel/Context · high confidence
Introduce Swift macros for model generation
Added the \EntityModel\ and \EntityRefModel\ macros to the SwiftletModel package. These macros, implemented in the new \SwiftletModelMacros\ module, enable automatic conformance to \EntityModelProtocol\ for Swift types, streamlining the creation of model classes with generated code.
Sources/SwiftletModel, Sources/SwiftletModelMacros · high confidence
New array, encoding, and concurrency utilities
Added array extensions for distincting elements by a key and for applying limit/offset pagination. Added Encodable and JSONEncoder extensions to produce pretty-printed, sorted-key JSON strings. Added a KeyPath extension to retrieve indexed key-path names. Marked BTree's Map as @unchecked Sendable to allow safe cross-thread transfer.
Sources/SwiftletModel/Extensions · medium confidence
New index types and collision resolution for unique, hashable, and comparable fields
The framework now supports unique, hashable, and comparable indexes, allowing entities to enforce uniqueness constraints on single or multiple fields. A new CollisionResolver mechanism lets users define how to handle duplicate values (e.g., throwing an error or performing an upsert). Additionally, full-text search capabilities have been introduced, enabling fuzzy matching and token-based search on string fields. These changes introduce new methods on the EntityModelProtocol to update and remove from these indexes, as well as new property wrappers like HashIndex, Index, and FullTextIndex to declare indexable fields.
Sources/SwiftletModel/Index · high confidence
New query building and filtering API for entities
The library introduces a new query system centered on \ContextQuery\ and \QueryList\ types, enabling users to construct, filter, sort, and resolve entity queries. Key additions include \Predicate\ and \RegexPredicate\ for filtering entities by comparable or regex-based conditions, \StringPredicate\ for text-based searches (contains, prefix, suffix, regex), and \MetadataPredicate\ for filtering by metadata like update timestamps. The API supports chaining filters, sorting by multiple key paths, handling nested relations (ToOne/ToMany) with \with\ and \fragment\ modifiers, and managing collections of queries with \QueryGroup\. This replaces or supplements previous query mechanisms, providing a more structured and composable way to interact with the data model.
Sources/SwiftletModel/Query · high confidence
New relationship management and serialization strategies
The library introduces a comprehensive set of new files to handle relationship persistence, serialization, and state management. A new \Link\ struct manages the storage of parent-child associations with configurable merge strategies (append, replace, remove). The \Relation\ struct and its \Relationship\ property wrapper are expanded with explicit encoding/decoding strategies (\plain\, \keyedContainer\, \explicitKeyedContainer\) to control JSON serialization formats. Additionally, convenience extensions are added for saving and deleting related entities, including a \DeleteRule\ enum to specify cascade or nullify behaviors for mutual and one-way relations.
Sources/SwiftletModel/Relationship · high confidence
Soft delete and merge strategy support for entities
The framework now supports soft deletion of entities via a new \Deleted\ wrapper struct and an \asDeleted\ method on \EntityModelProtocol\, allowing users to track deleted items without permanent removal. Additionally, a \MergeStrategy\ struct is introduced to handle entity updates, supporting strategies like 'replace', 'patch', and 'lastWriteWins' for resolving conflicts during save operations.
Sources/SwiftletModel/Model · high confidence
Architecture
Added Xcode scheme for SwiftletModel
A new Xcode scheme file (SwiftletModel.xcscheme) was added to the project, configuring build, test, launch, and archive actions for the SwiftletModel target and its associated tests. This change improves the developer experience by allowing direct building and testing of the model within Xcode.
.swiftpm · high confidence
Refactor entity model macro into modular attribute and diagnostic components
The EntityModelMacro implementation has been restructured into distinct, reusable components: AccessAttributes, IndexAttributes, PropertyAttributes, PropertyWrapperAttributes, RelationshipAttributes, SearchIndexAttributes, and UniqueAttributes, each handling specific metadata extraction and validation logic. A new IndexDiagnostic type introduces a static index warning to guide users toward instance property declarations. The main macro file now delegates attribute parsing to these specialized structs, improving code organization and maintainability without changing the macro's external behavior.
Sources/SwiftletModelMacros/EntityModelMacro · high confidence
Behavioural changes
Removed SwiftyModel struct
The SwiftyModel struct, which previously provided a default 'Hello, World!' text property, has been removed from the SwiftyModel module. This eliminates the public API and initialization for this specific model class.
Sources/SwiftyModel · medium confidence
Test coverage
Added test coverage for merge strategies and entity metadata accessors; Added test fixtures and tags for Swift Testing migration; Added test models for SwiftletModel schema entities; Added tests for ArrayExtensions; Added tests for entity deletion and detachment; Added tests for index behavior and performance; Added tests for query filtering, sorting, and encoding/decoding; Added tests for to-one and many-to-many relation behaviors; Removed obsolete placeholder test file.
Dependencies
SwiftletModel 2.0: Platform support, macros, and new dependencies
The package has been renamed from SwiftyModel to SwiftletModel and now targets iOS 12+, macOS 13+, tvOS 12+, and watchOS 7+. It introduces a new SwiftletModelMacros macro target that depends on swift-syntax, and adds runtime dependencies on swift-collections, BTree, and swift-snapshot-testing for testing.
(dependencies) · medium confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 69 → 54 (-15.0)
- Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 96 (new)
- Architecture 100 → 87 (-13.0)
- Maturity 58 → 70 (+11.6)
- Readiness 57 → 74 (+17.6)
- Security 100 → 97 (-2.5)
- Domain Modelling 100 → 100 (+0.0)
- Accessibility 26 (new)
Resolved (6)
- Coverage not included — suite not readable by the collector
- Dependency hygiene not measured — dependency manifest found but not parsed for hygiene
- No exposed public API
- Small-team knowledge concentration
- Test reliability not included
- complexity unreadable for .swift — churn × complexity hotspots could not be measured
New (103)
- Coverage not measured — Swift suite
- Dependency hygiene PARTLY measured — SwiftPM pinning read, dependency currency NOT established
- Documentation: no installation or build instructions (README.md)
- Duplicated block (10 lines × 2) (Sources/SwiftletModel/Index/Entity+IndexHashable.swift)
- Duplicated block (10 lines × 2) (Sources/SwiftletModel/Index/UniqueIndex+Comparable.swift)
- Duplicated block (10–11 lines × 3) (Sources/SwiftletModel/Index/Entity+IndexComparable.swift)
- Duplicated block (13 lines × 2) (Sources/SwiftletModel/Relationship/Relation+Codable.swift)
- Duplicated block (13 lines × 4) (Sources/SwiftletModelMacros/EntityModelMacro/EntityModelMacro.swift)
- Duplicated block (13 lines × 5) (Sources/SwiftletModelMacros/EntityModelMacro/EntityModelMacro.swift)
- Duplicated block (14–15 lines × 2) (Sources/SwiftletModelMacros/EntityModelMacro/EntityModelMacro.swift)
- Duplicated block (15 lines × 2) (Sources/SwiftletModelMacros/EntityModelMacro/EntityModelMacro.swift)
- Duplicated block (16 lines × 2) (Sources/SwiftletModelMacros/EntityModelMacro/EntityModelMacro.swift)
- Duplicated block (16 lines × 2) (Sources/SwiftletModelMacros/EntityModelMacro/EntityModelMacro.swift)
- Duplicated block (18 lines × 2) (Sources/SwiftletModel/Index/UniqueIndex+Comparable.swift)
- Duplicated block (23 lines × 2) (Sources/SwiftletModelMacros/EntityModelMacro/EntityModelMacro.swift)
- Duplicated block (25–26 lines × 2) (Sources/SwiftletModelMacros/EntityModelMacro/EntityModelMacro.swift)
- Duplicated block (32 lines × 2) (Sources/SwiftletModelMacros/EntityModelMacro/EntityModelMacro.swift)
- Duplicated block (5 lines × 2) (Sources/SwiftletModel/Index/HashIndex.swift)
- Duplicated block (5 lines × 2) (Sources/SwiftletModel/Query/QueryListNested.swift)
- Duplicated block (5 lines × 2) (Sources/SwiftletModel/Query/QueryListNested.swift)
- …and 83 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
KazaiMazai/SwiftletModel was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 21 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit c75efc3b07fadd42d5bdf816ef8836fe3e6537c4 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-cb02f2da8b24.