From 819866330c7e2f535a155d1d7efaf2e12dc15dc2 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 4 Dec 2025 15:42:00 +0000 Subject: 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 --- README.md | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index b63c5b1..ec1584c 100644 --- a/README.md +++ b/README.md @@ -326,23 +326,35 @@ nix develop -c cargo tarpaulin --out Html ngit-grasp/ ├── src/ │ ├── main.rs # Entry point, server setup +│ ├── lib.rs # Library exports +│ ├── config.rs # Configuration │ ├── git/ -│ │ ├── mod.rs # Git module -│ │ ├── handler.rs # Git HTTP handlers -│ │ └── authorization.rs # Push validation logic +│ │ ├── mod.rs # Git module + repository operations +│ │ ├── handlers.rs # Git HTTP handlers +│ │ ├── authorization.rs # Push validation logic +│ │ ├── protocol.rs # Git protocol encoding +│ │ └── subprocess.rs # Git subprocess management │ ├── nostr/ │ │ ├── mod.rs # Nostr module -│ │ ├── relay.rs # Relay setup and policies -│ │ └── events.rs # Event handlers -│ ├── storage/ -│ │ ├── mod.rs # Storage abstraction -│ │ └── repository.rs # Repository management -│ └── config.rs # Configuration -├── docs/ -│ └── ARCHITECTURE.md # Detailed architecture -├── tests/ -│ ├── integration/ # Integration tests -│ └── fixtures/ # Test data +│ │ ├── builder.rs # Relay builder + Nip34WritePolicy +│ │ ├── events.rs # Event parsing and validation +│ │ └── policy/ # Sub-policies (split for maintainability) +│ │ ├── mod.rs # Policy module exports +│ │ ├── announcement.rs # Repository announcement validation +│ │ ├── state.rs # State event validation + ref alignment +│ │ ├── pr_event.rs # PR/PR Update validation +│ │ └── related.rs # Forward/backward reference checking +│ ├── http/ +│ │ ├── mod.rs # HTTP module +│ │ ├── landing.rs # Landing page handler +│ │ └── nip11.rs # NIP-11 relay info document +│ └── metrics/ +│ ├── mod.rs # Prometheus metrics +│ ├── bandwidth.rs # Bandwidth tracking +│ └── connection.rs # Connection tracking +├── docs/ # Documentation (Diátaxis framework) +├── tests/ # Integration tests +├── grasp-audit/ # Compliance audit subproject └── README.md ``` -- cgit v1.2.3