4. GRASP Git Hosting (fleetmesh_protocols.grasp)#

fleetmesh_protocols.grasp implements host-side Git repository hosting for web applications: bare repositories on disk, Git smart HTTP transport, the /api/grasp workbench API, and seeded repositories. Its browser counterpart is @fleetmesh/grasp.

4.1. Security and Resource Controls#

Because fleetmesh_protocols.grasp invokes git on inputs supplied by authenticated users, it enforces the following safeguards:

  • Rejects file paths referencing .git (case-insensitively) or traversing outside the working tree, as well as branch names that git could interpret as command-line options.

  • Performs working-tree checkouts with symbolic links disabled.

  • Configures receive.fsckObjects and receive.maxInputSize (64 MiB) on every served repository, and enforces execution timeouts on Git smart HTTP operations.

  • Following a Git push, reads branch contents up to MAX_SYNC_FILE_BYTES (1 MiB) per file, MAX_SYNC_FILES (5,000), and MAX_SYNC_BYTES (32 MiB), listing excluded paths in omitted_files. API-initiated pushes leave unmodified files byte-for-byte unchanged.

  • Publishes clone URLs exclusively under the host-configured public_base_url.

4.2. Git Store and Workbench#

Fleetmesh GRASP Git Smart HTTP & Source Code Repository Store (node.protocols.grasp.git_store).

Provides real Git bare repository storage, Git Smart HTTP (git clone, git fetch, git push via /git/<slug>.git/info/refs, git-upload-pack, git-receive-pack), and JSON workbench APIs (/api/grasp/repos, /push, /merge) with 1,024-byte RhioBaoTree Merkle root commitments and Kind 30617 (NIP-34 / GRASP) repository state announcements.

fleetmesh_protocols.grasp.git_store.branch_name(raw)[source]#

A branch name git takes as a name, never as an option (MeshAccessError 400 otherwise).

Parameters:

raw (Any)

Return type:

str

fleetmesh_protocols.grasp.git_store.repo_path(raw)[source]#

A file path inside the work tree, never into .git or above it (MeshAccessError 400 otherwise).

Parameters:

raw (Any)

Return type:

str

class fleetmesh_protocols.grasp.git_store.StandaloneGraspGitStore[source]#

Bases: object

Manages bare Git repositories on disk and JSON metadata for /git/* and /api/grasp/*.

MAX_SYNC_FILE_BYTES = 1048576#
MAX_SYNC_FILES = 5000#
MAX_SYNC_BYTES = 33554432#
__init__(base_dir=None, public_base_url='')[source]#

public_base_url is where this host serves /git/; without it no clone URL is published.

Parameters:
  • base_dir (str | None)

  • public_base_url (str)

Return type:

None

list_repos()[source]#
Return type:

List[MutableMapping[str, Any]]

get_repo(repo_id)[source]#
Parameters:

repo_id (str)

Return type:

MutableMapping[str, Any] | None

create_or_update_repo(payload, principal=None)[source]#
Parameters:
Return type:

MutableMapping[str, Any]

push_commit(repo_id, payload, principal=None)[source]#
Parameters:
Return type:

MutableMapping[str, Any]

merge_branch(repo_id, payload, principal=None)[source]#
Parameters:
Return type:

MutableMapping[str, Any]

fleetmesh_protocols.grasp.git_store.handle_grasp_api_http(store, method, route, body=None, principal=None)[source]#

Dispatch /api/grasp/* JSON requests; writes as principal (the server’s own session resolution).

Parameters:
Return type:

Tuple[int, MutableMapping[str, Any]] | None

4.3. Smart HTTP and the Portal#

Git Smart HTTP and the node portal for the GRASP git store (node.protocols.grasp.git_http).

/git/<repo>.git/…: fetching (git-upload-pack) is open; pushing (git-receive-pack and its advertisement) is the repo owner’s alone, as the request principal. A fetch never creates a repo.

fleetmesh_protocols.grasp.git_http.handle_git_smart_http(store, method, route, query, body=b'', principal=None)[source]#

Handle Git Smart HTTP requests (/git/<slug>.git/info/refs, git-upload-pack, git-receive-pack).

Parameters:
Return type:

Tuple[int, bytes, str, Dict[str, str]] | None

fleetmesh_protocols.grasp.git_http.render_node_portal_html(store)[source]#
Parameters:

store (StandaloneGraspGitStore)

Return type:

bytes

4.4. Seeded Repositories#

Seeded Fleetmesh GRASP Git repositories (node.protocols.grasp.seeds).

Contains the initial source files (src/*.rs, src/*.asm, src/*.ts, index.html, nsite.json, Makefile, README.md) for built-in Game Engines, DMG-01 ROMs, and NIP-5A nsite apps.

class fleetmesh_protocols.grasp.seeds.SeededGraspRepo[source]#

Bases: TypedDict

repo_id: str#
title: str#
description: str#
linked_target_id: str#
target_kind: str#
owner_handle: str#
owner_did: str#
files: Dict[str, str]#