diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-04 15:42:00 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-04 15:42:00 +0000 |
| commit | 819866330c7e2f535a155d1d7efaf2e12dc15dc2 (patch) | |
| tree | d84c8361811544aad9cad089c0358b9028c8fb80 /docs/learnings/grasp-01-implementation.md | |
| parent | fd0c87c787d0626b3546fa571541c9c809711821 (diff) | |
refactor: split Nip34WritePolicy into focused sub-policies
Split the ~900 line Nip34WritePolicy into focused sub-policies for improved
testability and maintainability:
- AnnouncementPolicy - Repository announcement validation
- StatePolicy - State event validation + ref alignment
- PrEventPolicy - PR/PR Update validation
- RelatedEventPolicy - Forward/backward reference checking
The main Nip34WritePolicy now delegates to these sub-policies via a shared
PolicyContext that provides domain, database, and git_data_path.
Also updates:
- README.md: Accurate project structure reflecting actual implementation
- docs/learnings: Marks this technical debt item as complete
Diffstat (limited to 'docs/learnings/grasp-01-implementation.md')
| -rw-r--r-- | docs/learnings/grasp-01-implementation.md | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/docs/learnings/grasp-01-implementation.md b/docs/learnings/grasp-01-implementation.md index dea6389..719f751 100644 --- a/docs/learnings/grasp-01-implementation.md +++ b/docs/learnings/grasp-01-implementation.md | |||
| @@ -156,17 +156,17 @@ This enables parallel CI runs without interference. | |||
| 156 | 156 | ||
| 157 | **Better approach:** Treat architecture docs as living documents. When implementation diverges from the plan, update the doc immediately. The initial design document was valuable and should remain, but it should reflect what was built. | 157 | **Better approach:** Treat architecture docs as living documents. When implementation diverges from the plan, update the doc immediately. The initial design document was valuable and should remain, but it should reflect what was built. |
| 158 | 158 | ||
| 159 | ### 2. Smaller Nip34WritePolicy | 159 | ### 2. ~~Smaller Nip34WritePolicy~~ ✅ DONE |
| 160 | 160 | ||
| 161 | **What happened:** The [`Nip34WritePolicy`](src/nostr/builder.rs:51) grew to ~900 lines handling all event types. | 161 | **What happened:** The `Nip34WritePolicy` grew to ~900 lines handling all event types. |
| 162 | 162 | ||
| 163 | **Better approach:** Split into: | 163 | **Resolution:** Split into focused sub-policies in [`src/nostr/policy/`](src/nostr/policy/mod.rs:1): |
| 164 | - `AnnouncementPolicy` - Repository announcement validation | 164 | - [`AnnouncementPolicy`](src/nostr/policy/announcement.rs:1) - Repository announcement validation |
| 165 | - `StatePolicy` - State event validation + ref alignment | 165 | - [`StatePolicy`](src/nostr/policy/state.rs:1) - State event validation + ref alignment |
| 166 | - `RelatedEventPolicy` - Forward/backward reference checking | 166 | - [`RelatedEventPolicy`](src/nostr/policy/related.rs:1) - Forward/backward reference checking |
| 167 | - `PrEventPolicy` - PR/PR Update validation | 167 | - [`PrEventPolicy`](src/nostr/policy/pr_event.rs:1) - PR/PR Update validation |
| 168 | 168 | ||
| 169 | This would improve testability and readability. | 169 | The main [`Nip34WritePolicy`](src/nostr/builder.rs:51) now delegates to these sub-policies, improving testability and readability. |
| 170 | 170 | ||
| 171 | ### 3. Git Operations Module Organization | 171 | ### 3. Git Operations Module Organization |
| 172 | 172 | ||
| @@ -190,7 +190,7 @@ This would improve testability and readability. | |||
| 190 | 190 | ||
| 191 | ### High Priority | 191 | ### High Priority |
| 192 | 192 | ||
| 193 | 1. **Split `Nip34WritePolicy`** - Too large, hard to test/maintain | 193 | 1. ~~**Split `Nip34WritePolicy`**~~ ✅ DONE - Split into sub-policies in [`src/nostr/policy/`](src/nostr/policy/mod.rs:1) |
| 194 | 2. **Add unit tests for policy logic** - Currently relies on integration tests | 194 | 2. **Add unit tests for policy logic** - Currently relies on integration tests |
| 195 | 3. **Document actual architecture** - Docs describe plans, not implementation | 195 | 3. **Document actual architecture** - Docs describe plans, not implementation |
| 196 | 196 | ||