Files
ngit-grasp/docs/how-to
DanConwayDev 2b7e71d4cb feat(grasp06): startup scan to recover zero-ref /prs/ repos from a previous run
The inline cleanup paths (receive handler, PR-event policy, purgatory
expiry) only fire while the process is running. They do not handle
directories left zero-ref by a previous run:

  * A crash between writing a ref and the end-of-push cleanup.
  * A crash between `delete_ref` and `remove_dir_all` in one of the
    off-push cleanup paths.
  * A clean shutdown with a scoped placeholder still in memory whose
    matching event then never arrives in the next run, after the
    purgatory state has been dropped or aged out.

Without recovery the bare directory and any dangling refs persist
indefinitely — the standalone `cleanup-empty-repos` CLI tool
explicitly skips `/prs/` because its event-driven model does not
apply, so there is no operational lifeline either.

Add `src/grasp06/cleanup.rs::scan_on_startup` that walks
`<git_data_path>/prs/<hex>/<id>.git` once and removes any bare repo
with zero refs. Empty submitter directories left behind are removed
too via `remove_dir` (which fails non-empty, so no explicit check is
needed). Wired into `run_relay` in `src/main.rs` immediately after the
shared `repo_init_locks` is constructed and before
`nostr::builder::create_relay` is called — at that point no request
handler has run, no `repo_init_locks` entries exist, and nothing else
is touching `/prs/`, so the scan needs no locking.

Gated on `config.grasp06_enable` so an operator who has turned the
feature off does not have their existing `/prs/` data scanned and
potentially trimmed on the next restart.

Entries whose first-level name is not valid 64-char hex, or whose
second-level name does not end in `.git`, are left alone — these
shouldn't exist under `/prs/`, but the scan should never delete
something it doesn't recognise.

Docs:

  * docs/explanation/grasp-06-contributor-pr-submission.md — add a
    fourth bullet to the Zero-ref `/prs/` cleanup section covering
    startup recovery.
  * docs/explanation/architecture.md — add the new `cleanup.rs` to
    the module layout.
  * docs/how-to/enable-grasp-06.md — mention the startup scan in the
    storage-cost section's bullet list.
  * CHANGELOG.md — extend the GRASP-06 feature entry to call out the
    startup scan alongside the three runtime cleanup sites.
2026-05-15 19:19:40 +00:00
..
2025-11-04 10:25:53 +00:00

How-To Guides

Task-oriented documentation - Practical solutions to common problems.


What Are How-To Guides?

How-to guides are recipes that show you how to solve specific problems or accomplish particular tasks.

Characteristics:

  • ✅ Task-oriented (solve a problem)
  • ✅ Practical (actionable steps)
  • ✅ Assume basic knowledge
  • ✅ Focus on results
  • ✅ Can be followed in any order

Not how-to guides:

  • ❌ Complete lessons for beginners (those are Tutorials)
  • ❌ Technical specifications (those are Reference)
  • ❌ Conceptual discussions (those are Explanation)

Available How-To Guides

Configure Nix Flakes

Problem: Set up reproducible development environment
Difficulty: Intermediate

You'll learn:

  • Enable Nix flakes
  • Enter development environment
  • Work with subprojects
  • Troubleshoot common issues

Test Sync Against Production Data

Problem: Debug and improve sync using real-world data
Difficulty: Intermediate

You'll learn:

  • Run sync against production relays
  • Sanitize logs for LLM analysis
  • Identify common issues and patterns
  • Iteratively improve sync behavior

Planned How-To Guides

Deploy ngit-grasp

Status: 🔜 Planned (waiting for main server)

Problem: Deploy to production
You'll learn:

  • Server requirements
  • Reverse proxy setup (nginx/Caddy)
  • SSL/TLS configuration
  • Monitoring and logging

Run Compliance Tests

Status: 🔜 Planned

Problem: Test GRASP compliance
You'll learn:

  • Set up test relay
  • Run integration tests
  • Interpret results
  • Add custom tests

Upgrade nostr-sdk

Status: 🔜 Planned

Problem: Handle breaking changes in nostr-sdk
You'll learn:

  • Check for breaking changes
  • Update dependencies
  • Fix compilation errors
  • Test after upgrade

Configure Authentication

Status: 🔜 Planned (feature not yet implemented)

Problem: Secure your relay
You'll learn:

  • Enable authentication
  • Configure allowed users
  • Set up rate limiting
  • Monitor access

Backup and Restore

Status: 🔜 Planned

Problem: Protect your data
You'll learn:

  • Backup Git repositories
  • Backup Nostr events
  • Restore from backup
  • Automate backups

How to Use How-To Guides

  1. Find your problem - Browse or search for what you need
  2. Check prerequisites - Make sure you have required knowledge
  3. Follow the steps - Adapt to your specific situation
  4. Solve and move on - No need to read everything

Not sure if this is what you need?


Contributing How-To Guides

When writing a how-to guide:

DO:

  • ✅ Start with the problem/goal
  • ✅ List prerequisites clearly
  • ✅ Provide concrete steps
  • ✅ Include troubleshooting
  • ✅ Show examples
  • ✅ Link to related docs

DON'T:

  • ❌ Teach basics (link to Tutorials)
  • ❌ Explain every concept (link to Explanation)
  • ❌ List all options (link to Reference)
  • ❌ Make it a tutorial (stay focused on the task)

Template:

# How-To: [Task/Problem]

**Problem:** [What you're trying to accomplish]  
**Difficulty:** [Beginner/Intermediate/Advanced]  
**Time:** [Estimated time]

## Prerequisites
- [Required knowledge/tools]

## Solution

### Step 1: [Action]
[Instructions]

### Step 2: [Action]
[Instructions]

## Troubleshooting

### [Common problem]
**Solution:** [How to fix]

## Related Documentation
- [Links to relevant docs]

See Diátaxis: How-To Guides for detailed guidance.


Part of the ngit-grasp documentation using the Diátaxis framework.