Files
ngit-grasp/Cargo.toml
T
DanConwayDev 32217fe288 feat(grasp06): /prs/ endpoint reachable with empty-repo fetch
Adds the `/prs/<npub>/<identifier>.git/*` URL space behind the existing
`NGIT_GRASP06_ENABLE` flag. Fetches synthesise an empty bare repo per
request (via `git init --bare` in a tempdir) when no real repo exists
on disk; if a real repo exists at `<git_data_path>/prs/<hex>/<id>.git`
it delegates to the standard `handle_info_refs` / `handle_upload_pack`.

The receive-pack endpoint is a deliberate stub that returns HTTP 200
with an ERR pkt-line ("GRASP-06 receive-pack not yet implemented"),
matching `build_git_protocol_error_response`'s shape so git clients
print the message and exit non-zero rather than seeing a 404. The real
receive-pack handler is not yet implemented.

Module layout under `src/grasp06/`:
  paths.rs    — PRS_URL_PREFIX, PRS_DISK_PREFIX, prs_repo_path,
                prs_base_path, is_prs_repo_path (hex on disk).
  endpoint.rs — PrsUrl + parse_prs_url (npub-only, percent-decoded id).
  fetch.rs    — handle_prs_info_refs, handle_prs_upload_pack, and the
                receive-pack stub.

Routing is wired into HttpService::call ahead of `parse_git_url` so
`/prs/...` paths can't be misclassified as standard owner repos. When
the flag is off the branch is skipped and `/prs/*` falls through to
the existing 404 path (preserving the discovery-gate contract).

Tests flipped green:
  - prs_fetch_unknown_path_serves_empty_repo_with_grasp_06
  - prs_push_other_refs_rejected_with_grasp_06       (ERR pkt-line)
  - standard_push_does_not_mirror_to_prs_with_grasp_06

Tests still green (no regression):
  - prs_namespace_404_when_grasp06_not_advertised_no_grasp_06
  - nip11_advertises_grasp_06_when_enabled
  - pr_event_rejected_when_clone_tag_does_not_name_prs_endpoint_with_grasp_06

Tests still red (deferred):
  - prs_push_refs_nostr_event_id_accepted_with_grasp_06
  - pr_event_accepted_when_clone_tag_names_prs_endpoint_with_grasp_06
  - prs_push_mirrors_to_announced_repo_with_grasp_06

`tempfile` is promoted from a dev-dependency to a runtime dependency
because the empty-repo synthesis path needs it. No new config options,
so the four-place config-sync contract is unaffected.
2026-05-15 15:48:34 +00:00

82 lines
1.7 KiB
TOML

[package]
name = "ngit-grasp"
version = "1.0.2"
edition = "2021"
authors = ["ngit-grasp contributors"]
license = "MIT"
description = "A GRASP (Git Relays Authorized via Signed-Nostr Proofs) implementation in Rust"
repository = "https://gitworkshop.dev/ngit-grasp"
[dependencies]
# Async runtime
tokio = { version = "1.35", features = ["full"] }
# HTTP server (hyper for relay integration)
hyper = { version = "1.4", features = ["full"] }
hyper-util = { version = "0.1", features = ["tokio", "server", "http1", "http2"] }
http-body-util = "0.1"
# Nostr relay
nostr-relay-builder = { git = "https://github.com/rust-nostr/nostr", rev = "4767ad13" }
# Nostr
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "4767ad13" }
nostr-lmdb = { git = "https://github.com/rust-nostr/nostr", rev = "4767ad13" }
# Utilities
futures-util = "0.3"
base64 = "0.22"
flate2 = "1.0"
# Metrics
prometheus = "0.13"
dashmap = "5"
lazy_static = "1.4"
# Data structures
indexmap = "2"
# Random (for startup jitter)
rand = "0.8"
# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# Logging
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
# Configuration
dotenvy = "0.15"
clap = { version = "4.5", features = ["derive", "env"] }
# Error handling
anyhow = "1.0"
# Async traits
async-trait = "0.1"
# Temporary directories (used for GRASP-06 empty-repo synthesis)
tempfile = "3"
# Git (for future use)
# git-http-backend = "0.3"
[dev-dependencies]
# Testing
grasp-audit = { path = "grasp-audit" }
tempfile = "3"
reqwest = "0.12"
[lib]
name = "ngit_grasp"
path = "src/lib.rs"
[[bin]]
name = "ngit-grasp"
path = "src/main.rs"
[workspace]
members = [".", "grasp-audit"]