upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/grasp-audit/src
AgeCommit message (Collapse)Author
2026-02-26chore: apply cargo fmt and fix clippy warningsDanConwayDev
Fix pre-existing clippy lints: - &PathBuf -> &Path in audit_cleanup.rs - too_many_arguments on process_newly_available_git_data, process_purgatory_announcements, and HttpService::new - clone_on_copy for PublicKey (Copy type) in purgatory cleanup loop
2026-02-25show probe help when invoked with no argumentsDanConwayDev
2026-02-25make read-only the default probe mode; add --create-repo to opt into write pathDanConwayDev
2026-02-25show software and version in nip11_fetch detailDanConwayDev
2026-02-25diagnose overall timeout: name culprit check if it consumed >50% of budget, ↵DanConwayDev
else report cumulative slowness
2026-02-25report partial results on overall timeout: completed checks pass/fail, ↵DanConwayDev
timed-out step marked, remaining skipped
2026-02-25add overall probe timeout of min(20s, watch_interval) to prevent overlapping ↵DanConwayDev
runs
2026-02-25silence all library logs for probe subcommand in both human and JSON modesDanConwayDev
2026-02-25suppress [Run N] header and redirect logs to stderr in JSON mode for clean ↵DanConwayDev
pipe-friendly output
2026-02-25use compact single-line JSON output for machine consumption and --watch log ↵DanConwayDev
piping
2026-02-25rename find_announcement to serves_latest_announcement and drop redundant ↵DanConwayDev
detail from git_fetch_refs
2026-02-25hide read-only mode skips from human and JSON probe outputDanConwayDev
2026-02-25fix git_refs_match_state in read-only mode to fetch state events from relayDanConwayDev
In read-only mode, fetch all served kind:30618 state events for the repo by #d tag. The relay already validates authorization (including recursive maintainer chains), so any served state event is authoritative. Derive expected refs by taking the latest-timestamp state event per ref across all served events, then compare against git info/refs output.
2026-02-25add probe subcommand for end-to-end relay health checksDanConwayDev
Implements grasp-audit probe with full write path (publish events, poll for repo init, push, verify refs match state) and read-only fallback (find existing announcement, fetch refs). Supports --nsec for whitelisted relays, --json output, and --watch for continuous monitoring.
2026-02-24fix grasp-audit test isolation to prevent cross-spec relay state corruptionDanConwayDev
Add Purgatory-prefixed fixture variants (PurgatoryValidRepoSent, PurgatoryOwnerStateDataPushed) that create independent repos never shared with the main fixture chain. Purgatory tests that mutate relay state (replacement announcements, new state events, deletions) now use these isolated fixtures so they cannot corrupt the repo that push-authorization tests depend on. Run purgatory tests before push-auth in the full suite, since push-auth sends new replaceable state events (kind 30618) for the shared repo_id that would displace the original served state event.
2026-02-24wire PurgatoryTests into CLI runner so purgatory tests are actually runDanConwayDev
2026-02-23fix: rewrite deletion integration tests to avoid shared-state side effectsDanConwayDev
The previous tests deleted purgatory announcements (kind 30617) and checked for bare-repo absence via git ls-remote, which would corrupt shared-mode test state by destroying repos other tests depend on. New approach tests deletion of purgatory state events (kind 30618) instead: - e-tag test: promotes a repo, creates a unique commit locally, submits a state event pointing to it (enters purgatory), deletes the state event by event ID, then verifies git push of that commit is rejected. - a-tag coordinate test: promotes a repo, generates a fresh maintainer keypair, sends a replacement announcement adding that maintainer, submits a state event signed by the new maintainer (enters purgatory), deletes by coordinate 30618:<new_maintainer_pubkey>:<identifier>, then verifies git push is rejected. Also extends DeletionPolicy to handle kind 30618 state events in purgatory for both e-tag (event ID) and a-tag (coordinate) deletion paths.
2026-02-23feat: remove purgatory announcements on NIP-09 deletion eventsDanConwayDev
Kind 5 deletion events signed by the announcement author now evict the corresponding purgatory entry and delete the bare repository from disk. Both NIP-09 reference styles are supported: - e tag (event ID): matches the purgatory entry whose event ID equals the tag value - a tag (coordinate 30617:<pubkey>:<identifier>): matches by coordinate, only removes entries with created_at <= deletion event created_at per NIP-09 spec Author-only enforcement: coordinate pubkey and e-tag owner must match the deletion event pubkey; third-party deletion attempts are silently ignored. Includes 6 unit tests and 2 integration tests (event ID and coordinate paths).
2026-02-18fix: use unique commit instead of deterministic Owner variant for ↵DanConwayDev
wrong-commit PR tests PRWrongCommitPushedBeforeEvent and test_push_to_nostr_ref_with_wrong_commit_after_event_received_rejected were calling create_deterministic_commit_with_variant(CommitVariant::Owner) on a clone that already had test.txt with 'Initial commit\n' content from OwnerStateDataPushed. Writing identical content staged nothing so git commit failed silently. Now that ValidRepoServed always depends on OwnerStateDataPushed (git data pushed), the clone is never empty - use create_commit (unique file) instead since the wrong commit only needs to differ from PR_TEST_COMMIT_HASH, not be deterministic.
2026-02-18extract OwnerRepoState fixture to make dependency chain explicitDanConwayDev
OwnerStateDataPushed was secretly building and sending the state event internally, with no corresponding fixture in the chain. Add OwnerRepoState as the explicit 'state event sent, sitting in purgatory' step so the dependency chain reads: ValidRepoSent -> OwnerRepoState -> OwnerStateDataPushed -> ValidRepoServed. OwnerStateDataPushed now reads the state event from the OwnerRepoState cache rather than rebuilding it, and only owns the git push + purgatory release.
2026-02-13fix: use ValidRepoServed for events that tag repo eventsDanConwayDev
PR events, issues, and comments need a queryable repo announcement to reference. Changed PREvent and PREventGenerated fixtures and related tests to depend on ValidRepoServed instead of ValidRepoSent. This ensures tests will fail correctly when announcement purgatory is implemented - events tagging a repo should require that repo to be served (not in purgatory).
2026-02-13refactor(grasp-audit): clarify PR purgatory test names and intentDanConwayDev
- Remove redundant test_pr_event_remains_in_purgatory_until_git_data - Rename test_pr_event_git_push_accepted -> test_pr_event_in_purgatory_git_push_accepted - Add PASS/FAIL meaning to each test's documentation - Note black-box testing limitation for purgatory detection
2026-02-13test: add PR purgatory tests with PREvent2 fixturesDanConwayDev
Add new fixtures for testing PR purgatory mechanism: - PREvent2Generated: PR event with different commit hash - PREvent2Sent: PR event sent to relay (enters purgatory) - PREvent2GitDataPushed: Git data pushed after event sent - PREvent2Served: Full fixture with event served Add PRTestCommit2 variant for second PR test commit. Update purgatory tests to use new fixtures for proper PR purgatory testing.
2026-02-13fix: add trailing newlines to deterministic commit contentDanConwayDev
The CommitVariant::file_content() methods were returning strings without trailing newlines, but the expected hash constants were calculated with trailing newlines. This caused hash mismatches in tests. Updated all hash constants to match the actual commit hashes produced with trailing newlines in the file content.
2026-02-12feat(grasp-audit): add explicit purgatory testsDanConwayDev
Add PurgatoryTests module with tests for GRASP-01 purgatory behavior: - Announcement purgatory tests (tolerant of unimplemented feature) - State event purgatory tests (already implemented) - PR purgatory tests (tolerant of unimplemented feature) Tests pass regardless of purgatory implementation status, enabling development without breaking the test suite. When features are implemented, tests will verify correct purgatory behavior.
2026-02-12refactor(grasp-audit): split ValidRepo into Sent/Served, add tolerant purgatoryDanConwayDev
- Rename ValidRepo to ValidRepoSent (announcement sent, may be in purgatory) - Add ValidRepoServed (announcement queryable after git data pushed) - Add send_event_and_note_purgatory() for tolerant purgatory detection - Update fixtures to use tolerant method instead of strict assertion - Update event_acceptance_policy tests to use ValidRepoServed This enables tests to pass regardless of purgatory implementation status while still having explicit purgatory tests that verify the behavior.
2026-02-12refactor(grasp-audit): introduce SpecRef enum for type-safe spec referencesDanConwayDev
Replace string-based spec references with typed SpecRef enum for compile-time validation and better IDE support. TestResult::new() now accepts SpecRef enum plus a requirement description string for test-specific context.
2026-02-12fix: update doctest to use valid FixtureKind::RepoState variantDanConwayDev
2026-02-12fix: use consistent git identity for PR test commit hashDanConwayDev
The PR_TEST_COMMIT_HASH constant was incorrect because the discovery test used a different git identity (pr-test@example.com) than the actual create_pr_test_commit function (test@grasp-audit.local from fixtures.rs). This caused the same commit content to produce different hashes due to different author/committer info being embedded in the commit object. Fixed by updating the discovery test to use the same git identity as clone_repo() in fixtures.rs, ensuring consistent commit hashes.
2026-01-19fix(grasp-audit): improve color readability with bold bright colorsDanConwayDev
Changes RED from standard red (\x1b[31m) to bold bright red (\x1b[1;91m) and GREEN from standard green (\x1b[32m) to bold bright green (\x1b[1;92m). This follows ANSI/ISO standards (ECMA-48) and matches industry best practices used by Rust/Cargo and other modern CLI tools. Bold bright colors provide significantly better readability on dark terminal backgrounds while maintaining maximum compatibility with all terminals. Addresses user feedback that red color was too hard to read.
2026-01-12feat(grasp-audit): add filter capability compliance testsDanConwayDev
Add comprehensive GRASP-01 compliance tests for uploadpack.allowFilter capability to the grasp-audit test suite. These tests can be run against ANY GRASP implementation (ngit-relay, ngit-grasp, or others) to verify filter support. New test module: grasp-audit/src/specs/grasp01/git_filter.rs Tests added: - test_filter_capability_advertised: Verifies filter appears in info/refs - test_filtered_clone_succeeds: Tests git clone --filter=blob:none - test_filtered_fetch_succeeds: Tests git fetch --filter=tree:0 Usage: cd grasp-audit && nix develop -c bash test-ngit-relay.sh --mode test cd grasp-audit && nix develop -c cargo run -- audit -r ws://localhost:8080 -s git-filter
2026-01-09test: fix deterministic commit hashDanConwayDev
i suspect this broke when we ensured commits weren't pgp signed
2026-01-08refactor: replace hardcoded Kind constants with rust-nostr variantsDanConwayDev
- Replace KIND_REPOSITORY_ANNOUNCEMENT with Kind::GitRepoAnnouncement - Replace KIND_REPOSITORY_STATE with Kind::RepoState - Replace KIND_PR with Kind::GitPullRequest - Replace KIND_PR_UPDATE with Kind::GitPullRequestUpdate - Replace KIND_USER_GRASP_LIST with Kind::GitUserGraspList - Replace KIND_PATCH with Kind::GitPatch - Replace KIND_ISSUE with Kind::GitIssue - Replace KIND_COMMENT with Kind::Comment - Replace all Kind::Custom(30617|30618|1617|1618|1619|1621|1111|10317) patterns - Remove all hardcoded KIND_* constants from events.rs - Update all match statements to use Kind enum directly - Update all filter builders to use Kind variants - Update all test helpers and assertions Benefits: - Type safety: compiler prevents wrong kind numbers - Readability: Kind::GitRepoAnnouncement is self-documenting - Maintainability: single source of truth (rust-nostr) - IDE support: full autocompletion and refactoring - Standards: aligns with rust-nostr best practices Files modified: 21 Constants removed: 9 Patterns replaced: 100+ Tests passing: 222/222
2026-01-08chore: upgrade nostr-* packages to rev 4767ad13DanConwayDev
- Update nostr-relay-builder, nostr-sdk, nostr-lmdb to latest revision - Update grasp-audit nostr-sdk dependency - Fix clippy warnings: - Replace .clone() with std::slice::from_ref() in src/git/sync.rs - Change &PathBuf to &Path in tests/common/git_server.rs - Replace vec![] with array literal in src/purgatory/sync/functions.rs - Update PR_TEST_COMMIT_HASH in grasp-audit due to event generation changes All 249 tests passing, no breaking changes required.
2025-12-31test: remove local sync on state git data received testDanConwayDev
because the current fixtures don't actually having mutliple owner_repos. they would need 2 announcements that both listed the service and a maintainer relationship. We could do this in grasp-audit but it would require an extra announcement from a different maintainer sent eariler on in the dependancy chain.
2025-12-31purgatory: when state data recieved sync across repositoiesDanConwayDev
2025-12-31test: fix ↵DanConwayDev
test_push_to_nostr_ref_with_correct_commit_after_event_received_accepted_and_event_served
2025-12-31test: fix test_head_set_after_git_push_with_required_oidsDanConwayDev
2025-12-31test: fix purgatory not-served check outcomeDanConwayDev
2025-12-24feat(purgatory): add broken purgatory implementationDanConwayDev
2025-12-23test: add purgatory to PR push testDanConwayDev
commented out so it currently passes
2025-12-23test: add stub for purgatory maintainer repo sync testDanConwayDev
2025-12-23test: prepare other state tests for purgatory featureDanConwayDev
2025-12-23test: prepare OwnerStateDataPushed fixture for purgatoryDanConwayDev
This is the model for how to prepare all push tests for purgatory
2025-12-23test: remove test covered elsewhereDanConwayDev
as new feature purgatory is going to complicate having this test here. it will be better to have this covered in push authorisation
2025-12-23audit: updated grasp01 line refs to reflect purgatory insertionDanConwayDev
2025-12-22chore: bump rust-nostr to latest masterDanConwayDev
so we can more easily support grasp purgatory feature
2025-12-11fix: resolve all fmt and clippy warningsDanConwayDev
Main lib (src/): - Add #[allow(dead_code)] for build_info field (stored to prevent Prometheus unregistration) - Add #[allow(dead_code)] for first_seen field (reserved for future rate limiting) - Replace .or_insert_with(RelaySyncNeeds::default) with .or_default() - Replace manual div_ceil implementations with .div_ceil(100) Test code (tests/): - Replace .expect(&format!(...)) with .unwrap_or_else(|_| panic!(...)) - Remove needless borrows in fetch_metrics() calls - Add #[allow(dead_code)] and #[allow(unused_imports)] to test helpers module grasp-audit: - Apply cargo fmt to fix formatting
2025-12-03feat: accept maintainer announcements without service listingDanConwayDev
2025-12-03remove depricated audit mode label ci / production ~> isolated / sharedDanConwayDev
2025-12-02audit: fix shared test_reject_repo_announcement_missing_relays_tag testDanConwayDev
2025-12-02fix: tests using gpg signerDanConwayDev
2025-12-02refactor: rename AuditMode variants and change CLI default to sharedDanConwayDev
Breaking change: Renamed AuditMode enum variants for clarity: - AuditMode::CI -> AuditMode::Isolated (fresh fixtures per test) - AuditMode::Production -> AuditMode::Shared (reuse fixtures across tests) Config constructors renamed (with deprecated aliases): - AuditConfig::ci() -> AuditConfig::isolated() - AuditConfig::production() -> AuditConfig::shared() CLI default changed from 'ci' to 'shared' mode, which enables fixture caching across tests. This fixes the issue where fixtures were being re-created for every test in CLI mode. Fixture caching behavior: - Shared mode (CLI default): Uses client's cache, fixtures reused - Isolated mode (for cargo test): Local cache per TestContext
2025-12-02grasp-audit: show tests under GRASP-01 lineDanConwayDev
2025-12-02refactor: fix fmt and clippyDanConwayDev
2025-12-01add repo land page and 404 page per GRASP-01DanConwayDev
2025-12-01better fixtures: clean upDanConwayDev
2025-12-01test: test_head_set_after_git_push_with_required_oidsDanConwayDev
2025-12-01better fixtures: test_head_set_after_state_event_with_existing_commitDanConwayDev
2025-12-01better fixtures: refs/nostr testsDanConwayDev
2025-12-01better fixtures: RecursiveMaintainerStateDataPushed and ↵DanConwayDev
test_non_maintainer_state_rejected
2025-12-01better fixtures: MaintainerStateDataPushedDanConwayDev
2025-12-01fixtures dependancy overhaulDanConwayDev
2025-12-01better fixtures: MaintainerStateDataPushedDanConwayDev
2025-12-01begin implementing better fixturesDanConwayDev
2025-12-01test placeholder: test_head_set_after_git_push_with_required_oidsDanConwayDev
2025-12-01test: test_head_set_after_state_event_with_existing_commitDanConwayDev
currently failing as branch isn't pushed (we should auto create this branch as we have the ref)
2025-12-01fix cargo clippy and fmt warningsDanConwayDev
2025-12-01reject push when refs/nostr/<event-id> doesnt match known event and delete ↵DanConwayDev
incorrect ref on event receive
2025-11-28test: added checks that refs/nostr/<event-id> match commit in PR / updateDanConwayDev
2025-11-28allow push to ref/nostr/<event-id>DanConwayDev
2025-11-28audit: fix push from maintainer tests when in production modeDanConwayDev
2025-11-28audit: fix rejected push wrong commit testDanConwayDev
2025-11-28audit: fix push test when not isolatedDanConwayDev
2025-11-28audit: future test shared / isolation fixesDanConwayDev
2025-11-28fix: respect Isolated mode in TestContext fixture helpersDanConwayDev
Previously get_or_create_repo() and get_or_create_issue() always checked the client cache first, bypassing the mode-based caching logic. This caused fixture leaking across test suites when using the same AuditClient. With this fix: - In Isolated mode: helpers skip the cache, creating fresh fixtures - In Shared mode: helpers use the cache for fixture reuse (unchanged) This restores proper test isolation for push authorization tests that were failing because they shared the same ValidRepo fixture.
2025-11-28audit: fix shared test context to minimise events sent to production relaysDanConwayDev
2025-11-28test: rationalise repository creation testsDanConwayDev
2025-11-28audit: stop checking git_data_directoryDanConwayDev
2025-11-28add git http advertisment allow-reachable-sha1-in-want and ↵DanConwayDev
allow-tip-sha1-in-want
2025-11-28fix grasp-audit importsDanConwayDev
2025-11-28fix running audit with production flagDanConwayDev
no events were allowed to be published which broke most tests
2025-11-28grasp-audit improve cli output eg. add colors and condenseDanConwayDev
2025-11-28grasp-audit run all tests in audit modeDanConwayDev
2025-11-27remove depricated codeDanConwayDev
2025-11-27Task 7: Export verification helpers in public APIDanConwayDev
- Added send_and_verify_accepted to lib.rs exports - Added send_and_verify_rejected to lib.rs exports - Organized exports into logical groups with comments: * Git operation helpers * Verification helpers * Repo setup helpers * Types and constants - Build succeeds: cargo build
2025-11-27Task 6: Clean up verification helper imports and remove duplicatesDanConwayDev
- All uses of send_and_verify_accepted/rejected import from crate::fixtures - Removed duplicate implementations from event_acceptance_policy.rs (lines 519-597) - Updated 15 call sites from Self::send_and_verify_* to send_and_verify_* - Build succeeds: cargo build
2025-11-27Task 5: Standardize nip01_smoke.rs tests to fixture-first patternDanConwayDev
- test_send_receive_event uses TestContext + FixtureKind::ValidRepo - test_create_subscription uses TestContext + FixtureKind::ValidRepo - Tests remain functionally equivalent (same verification logic) - Pure connectivity tests like test_websocket_connection unchanged - Tests pass: cargo test --lib nip01_smoke - Added fixture-first pattern documentation to test docstrings
2025-11-27Task 4: Refactor recursive maintainer push test to fixture-first patternDanConwayDev
- Deprecated setup_repo_for_recursive_maintainer helper in fixtures.rs - test_push_authorized_by_recursive_maintainer_state now creates own TestContext - Uses FixtureKind chain: RepoState, MaintainerAnnouncement, MaintainerState, RecursiveMaintainerRepoAndState - Uses git helpers from fixtures.rs (clone_repo, create_deterministic_commit_with_variant, try_push) - Updated imports to include RECURSIVE_MAINTAINER_DETERMINISTIC_COMMIT_HASH - All unit tests pass: cargo test --lib
2025-11-27Task 3: Refactor maintainer push authorization test to fixture-first patternDanConwayDev
- Deprecated setup_repo_for_maintainer helper - test_push_authorized_by_maintainer_state_only now creates own TestContext - Uses FixtureKind::RepoState and FixtureKind::MaintainerState - Uses git helpers from fixtures.rs (clone_repo, create_deterministic_commit_with_variant, try_push) - Uses CommitVariant::Maintainer and MAINTAINER_DETERMINISTIC_COMMIT_HASH - Test compiles and passes: cargo test --lib (25 passed, 0 failed)
2025-11-27Task 2: Refactor owner push authorization test to fixture-first patternDanConwayDev
- Refactored test_push_authorized_by_owner_state to use fixture-first pattern - Test now creates its own TestContext and uses FixtureKind::RepoState - Uses git helper functions from fixtures.rs (clone_repo, create_deterministic_commit, try_push) - Follows the 3-step pattern: Generate fixtures → Send to relay → Verify behavior - Deprecated setup_repo_with_deterministic_commit with migration guide - Test passes: cargo test --test push_authorization test_push_authorized_by_owner_state - No API changes required for main project tests
2025-11-27fix(auth): accept state announcements from maintainersDanConwayDev
Updated get_maintainers_recursive() to properly handle maintainers listed in accepted repository announcements: 1. Separated 'visited' set (cycle prevention) from 'maintainers' set (result) 2. Maintainers listed in an announcement's 'maintainers' tag are now added to the maintainer set immediately, even without their own announcement 3. Recursively traverse maintainer chains to handle multi-level delegation Also fixed RecursiveMaintainerRepoAndState fixture to publish the maintainer's announcement (which lists the recursive maintainer) before publishing the recursive maintainer's announcement, establishing the proper trust chain: Owner -> Maintainer -> RecursiveMaintainer Test results: 7/7 push authorization tests passing
2025-11-27fix(tests): update main project tests for grasp-audit API changesDanConwayDev
2025-11-26test: use fixtures in push testsDanConwayDev
2025-11-26feat(fixtures): reuse prerequisite fixtures in production modeDanConwayDev
Fixtures now reuse their prerequisites in Shared (production) mode, significantly reducing events published to production relays: Before: Each fixture created its own prerequisite events - ValidRepo: 1 event - RepoWithIssue: 2 events (repo + issue) - RepoWithComment: 3 events (repo + issue + comment) - RepoState: 2 events (repo + state) After: Fixtures share prerequisites via caching - ValidRepo: 1 event - RepoWithIssue: 1 new event (issue), reuses cached repo - RepoWithComment: 1 new event (comment), reuses cached repo+issue - RepoState: 1 new event (state), reuses cached repo Total for all 4 fixtures: 8 events → 4 events (50% reduction) In CI/Isolated mode, each test still gets fresh fixtures for test isolation - behavior unchanged. Implemented via get_or_create_repo() and get_or_create_issue() helpers that handle mode-aware caching without async recursion.
2025-11-26fix: parsing maintainers from announcement eventDanConwayDev
2025-11-26feat: push authorization from state eventDanConwayDev
2025-11-26test: remove bad testDanConwayDev
we dont need to check the git files exist locally
2025-11-26add cors supportDanConwayDev
2025-11-21add http clone testsDanConwayDev