diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-05 10:19:56 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-05 10:19:56 +0000 |
| commit | 86077d24e7cc8ff9d474a5947f0151d005f9f747 (patch) | |
| tree | 47b7cd4c52e8f784e1b8f13ab6f88a1c4eef31e4 | |
| parent | 53b926427fa6b65abcf680dd1c19eebfd3e85f65 (diff) | |
fix: hardcoded port
| -rw-r--r-- | AGENTS.md | 25 | ||||
| -rw-r--r-- | grasp-audit/README.md | 15 | ||||
| -rw-r--r-- | grasp-audit/src/specs/grasp01_nostr_relay.rs | 6 | ||||
| -rwxr-xr-x | grasp-audit/test-ngit-relay.sh | 2 |
4 files changed, 32 insertions, 16 deletions
| @@ -5,6 +5,7 @@ This file provides guidance to agents when working with code in this repository. | |||
| 5 | ## Project Structure | 5 | ## Project Structure |
| 6 | 6 | ||
| 7 | **Workspace with Two Rust Projects:** | 7 | **Workspace with Two Rust Projects:** |
| 8 | |||
| 8 | - Root: `ngit-grasp` (main GRASP relay implementation) | 9 | - Root: `ngit-grasp` (main GRASP relay implementation) |
| 9 | - `grasp-audit/`: Separate subproject with own `Cargo.toml` and `flake.nix` | 10 | - `grasp-audit/`: Separate subproject with own `Cargo.toml` and `flake.nix` |
| 10 | 11 | ||
| @@ -32,11 +33,11 @@ nix-shell --run "cargo build" | |||
| 32 | **Integration tests require relay running:** | 33 | **Integration tests require relay running:** |
| 33 | 34 | ||
| 34 | ```bash | 35 | ```bash |
| 35 | # Start ngit-relay first (tests run on port 18081) | 36 | # Start ngit-relay first (choose any available port, example uses 18081) |
| 36 | docker run --rm -p 18081:8081 -e NGIT_BIND_ADDRESS=0.0.0.0:8081 ghcr.io/decentralizedclimate/ngit-relay:latest | 37 | docker run --rm -p 18081:8081 -e NGIT_BIND_ADDRESS=0.0.0.0:8081 ghcr.io/danconwaydev/ngit-relay:latest |
| 37 | 38 | ||
| 38 | # From grasp-audit directory | 39 | # From grasp-audit directory, set RELAY_URL to match your port |
| 39 | nix develop -c cargo test --lib test_grasp01_nostr_relay_against_relay -- --ignored --nocapture | 40 | RELAY_URL="ws://localhost:18081" nix develop -c cargo test --lib test_grasp01_nostr_relay_against_relay -- --ignored --nocapture |
| 40 | ``` | 41 | ``` |
| 41 | 42 | ||
| 42 | Tests marked `#[ignore]` need relay - unit tests don't. | 43 | Tests marked `#[ignore]` need relay - unit tests don't. |
| @@ -60,13 +61,14 @@ event.id() | |||
| 60 | event.tags() | 61 | event.tags() |
| 61 | for tag in &event.tags { } | 62 | for tag in &event.tags { } |
| 62 | 63 | ||
| 63 | // ✅ CORRECT (0.43 API) | 64 | // ✅ CORRECT (0.43 API) |
| 64 | event.id // Direct field access | 65 | event.id // Direct field access |
| 65 | event.tags // Direct field access | 66 | event.tags // Direct field access |
| 66 | event.tags.iter() // Iterator method | 67 | event.tags.iter() // Iterator method |
| 67 | ``` | 68 | ``` |
| 68 | 69 | ||
| 69 | **Tag API changed:** | 70 | **Tag API changed:** |
| 71 | |||
| 70 | ```rust | 72 | ```rust |
| 71 | // ❌ WRONG (0.35) | 73 | // ❌ WRONG (0.35) |
| 72 | Tag::Generic(TagKind::Custom("clone".into()), vec![...]) | 74 | Tag::Generic(TagKind::Custom("clone".into()), vec![...]) |
| @@ -76,6 +78,7 @@ Tag::custom(TagKind::custom("clone"), vec![...]) | |||
| 76 | ``` | 78 | ``` |
| 77 | 79 | ||
| 78 | **EventBuilder signature changed:** | 80 | **EventBuilder signature changed:** |
| 81 | |||
| 79 | ```rust | 82 | ```rust |
| 80 | // ❌ WRONG (0.35) | 83 | // ❌ WRONG (0.35) |
| 81 | EventBuilder::new(kind, content, &[tags]) | 84 | EventBuilder::new(kind, content, &[tags]) |
| @@ -89,12 +92,14 @@ See `docs/archive/2025-11-04-nostr-sdk-upgrade.md` for full migration. | |||
| 89 | ## Documentation | 92 | ## Documentation |
| 90 | 93 | ||
| 91 | **Diátaxis Framework Used:** | 94 | **Diátaxis Framework Used:** |
| 95 | |||
| 92 | - `docs/tutorials/` - Learning-oriented | 96 | - `docs/tutorials/` - Learning-oriented |
| 93 | - `docs/how-to/` - Task-oriented | 97 | - `docs/how-to/` - Task-oriented |
| 94 | - `docs/reference/` - Information-oriented | 98 | - `docs/reference/` - Information-oriented |
| 95 | - `docs/explanation/` - Understanding-oriented | 99 | - `docs/explanation/` - Understanding-oriented |
| 96 | 100 | ||
| 97 | **Session files go in `work/` (gitignored except README.md)** | 101 | **Session files go in `work/` (gitignored except README.md)** |
| 102 | |||
| 98 | - Archive valuable content to `docs/archive/YYYY-MM-DD-*.md` at session end | 103 | - Archive valuable content to `docs/archive/YYYY-MM-DD-*.md` at session end |
| 99 | - Delete temporary files | 104 | - Delete temporary files |
| 100 | - Keep root clean (only README.md, AGENTS.md) | 105 | - Keep root clean (only README.md, AGENTS.md) |
| @@ -111,6 +116,7 @@ See `docs/archive/2025-11-04-nostr-sdk-upgrade.md` for full migration. | |||
| 111 | ## File Restrictions by Mode | 116 | ## File Restrictions by Mode |
| 112 | 117 | ||
| 113 | Code mode can only edit files matching specific patterns (enforced by system): | 118 | Code mode can only edit files matching specific patterns (enforced by system): |
| 119 | |||
| 114 | - Example: Architect mode restricted to `\.md$` files only | 120 | - Example: Architect mode restricted to `\.md$` files only |
| 115 | - Attempting to edit restricted files causes FileRestrictionError | 121 | - Attempting to edit restricted files causes FileRestrictionError |
| 116 | - Check mode configuration if edit attempts fail unexpectedly | 122 | - Check mode configuration if edit attempts fail unexpectedly |
| @@ -121,11 +127,12 @@ Code mode can only edit files matching specific patterns (enforced by system): | |||
| 121 | # Build grasp-audit | 127 | # Build grasp-audit |
| 122 | cd grasp-audit && nix develop -c cargo build | 128 | cd grasp-audit && nix develop -c cargo build |
| 123 | 129 | ||
| 124 | # Run all tests (requires relay on 18081) | 130 | # Run all tests (requires relay running, set RELAY_URL to match your port) |
| 125 | cd grasp-audit && nix develop -c cargo test --ignored | 131 | cd grasp-audit && RELAY_URL="ws://localhost:18081" nix develop -c cargo test --ignored |
| 126 | 132 | ||
| 127 | # Run single test | 133 | # Run single test |
| 128 | cd grasp-audit && nix develop -c cargo test --lib test_name -- --nocapture | 134 | cd grasp-audit && nix develop -c cargo test --lib test_name -- --nocapture |
| 129 | 135 | ||
| 130 | # Check session files | 136 | # Check session files |
| 131 | ls work/ # Should only have README.md when clean \ No newline at end of file | 137 | ls work/ # Should only have README.md when clean |
| 138 | ``` | ||
diff --git a/grasp-audit/README.md b/grasp-audit/README.md index b8b452e..b73d72b 100644 --- a/grasp-audit/README.md +++ b/grasp-audit/README.md | |||
| @@ -22,15 +22,15 @@ async fn main() -> Result<()> { | |||
| 22 | // Create audit client for CI testing | 22 | // Create audit client for CI testing |
| 23 | let config = AuditConfig::ci(); | 23 | let config = AuditConfig::ci(); |
| 24 | let client = AuditClient::new("ws://localhost:7000", config).await?; | 24 | let client = AuditClient::new("ws://localhost:7000", config).await?; |
| 25 | 25 | ||
| 26 | // Run NIP-01 smoke tests | 26 | // Run NIP-01 smoke tests |
| 27 | let results = specs::Nip01SmokeTests::run_all(&client).await; | 27 | let results = specs::Nip01SmokeTests::run_all(&client).await; |
| 28 | results.print_report(); | 28 | results.print_report(); |
| 29 | 29 | ||
| 30 | if !results.all_passed() { | 30 | if !results.all_passed() { |
| 31 | std::process::exit(1); | 31 | std::process::exit(1); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | Ok(()) | 34 | Ok(()) |
| 35 | } | 35 | } |
| 36 | ``` | 36 | ``` |
| @@ -85,6 +85,7 @@ All audit events include special tags: | |||
| 85 | ``` | 85 | ``` |
| 86 | 86 | ||
| 87 | This allows: | 87 | This allows: |
| 88 | |||
| 88 | - **Isolation**: Each test run has unique ID | 89 | - **Isolation**: Each test run has unique ID |
| 89 | - **Cleanup**: Events marked for cleanup after timestamp | 90 | - **Cleanup**: Events marked for cleanup after timestamp |
| 90 | - **No deletion trails**: Direct database cleanup (no NIP-09 deletion events) | 91 | - **No deletion trails**: Direct database cleanup (no NIP-09 deletion events) |
| @@ -146,10 +147,14 @@ Test against the reference GRASP implementation to ensure compatibility. | |||
| 146 | 147 | ||
| 147 | See `test-ngit-relay.sh` for full setup/cleanup details. | 148 | See `test-ngit-relay.sh` for full setup/cleanup details. |
| 148 | 149 | ||
| 149 | **Manual One-Liner:** | 150 | **Manual Testing:** |
| 150 | 151 | ||
| 151 | ```bash | 152 | ```bash |
| 152 | # Start relay, then run: RELAY_URL="ws://localhost:$PORT" cargo test --lib -- --ignored --nocapture | 153 | # Start relay on a specific port (example uses 18081) |
| 154 | docker run --rm -p 18081:8081 -e NGIT_BIND_ADDRESS=0.0.0.0:8081 ghcr.io/danconwaydev/ngit-relay:latest | ||
| 155 | |||
| 156 | # In another terminal, run tests with RELAY_URL | ||
| 157 | RELAY_URL="ws://localhost:18081" cargo test --lib test_grasp01_nostr_relay_against_relay -- --ignored --nocapture | ||
| 153 | ``` | 158 | ``` |
| 154 | 159 | ||
| 155 | **Note:** ngit-relay only accepts Git-related events (NIP-34). Some NIP-01 smoke tests will fail (expected). Validation tests should pass. | 160 | **Note:** ngit-relay only accepts Git-related events (NIP-34). Some NIP-01 smoke tests will fail (expected). Validation tests should pass. |
diff --git a/grasp-audit/src/specs/grasp01_nostr_relay.rs b/grasp-audit/src/specs/grasp01_nostr_relay.rs index a18927c..ca84a4b 100644 --- a/grasp-audit/src/specs/grasp01_nostr_relay.rs +++ b/grasp-audit/src/specs/grasp01_nostr_relay.rs | |||
| @@ -653,8 +653,12 @@ mod tests { | |||
| 653 | #[tokio::test] | 653 | #[tokio::test] |
| 654 | #[ignore] // Requires running relay | 654 | #[ignore] // Requires running relay |
| 655 | async fn test_grasp01_nostr_relay_against_relay() { | 655 | async fn test_grasp01_nostr_relay_against_relay() { |
| 656 | // Read relay URL from environment variable, default to localhost:8081 | ||
| 657 | let relay_url = std::env::var("RELAY_URL") | ||
| 658 | .unwrap_or_else(|_| "ws://localhost:8081".to_string()); | ||
| 659 | |||
| 656 | let config = AuditConfig::ci(); | 660 | let config = AuditConfig::ci(); |
| 657 | let client = AuditClient::new("ws://localhost:18081", config) | 661 | let client = AuditClient::new(&relay_url, config) |
| 658 | .await | 662 | .await |
| 659 | .expect("Failed to connect to relay"); | 663 | .expect("Failed to connect to relay"); |
| 660 | 664 | ||
diff --git a/grasp-audit/test-ngit-relay.sh b/grasp-audit/test-ngit-relay.sh index 2d1d7f2..356eed1 100755 --- a/grasp-audit/test-ngit-relay.sh +++ b/grasp-audit/test-ngit-relay.sh | |||
| @@ -59,7 +59,7 @@ echo "Validation tests should pass." | |||
| 59 | echo "" | 59 | echo "" |
| 60 | 60 | ||
| 61 | # Run the CLI tool (cleanup happens via trap even on failure) | 61 | # Run the CLI tool (cleanup happens via trap even on failure) |
| 62 | cargo run -- audit --relay "ws://localhost:$PORT" --mode ci --spec nip01-smoke || { | 62 | RELAY_URL="ws://localhost:$PORT" cargo run -- audit --relay "ws://localhost:$PORT" --mode ci --spec nip01-smoke || { |
| 63 | echo "⚠️ Some tests failed (expected for ngit-relay)" | 63 | echo "⚠️ Some tests failed (expected for ngit-relay)" |
| 64 | echo " Validation tests should have passed" | 64 | echo " Validation tests should have passed" |
| 65 | } | 65 | } |