|
Download tasks/data/reverse/abdelstark__guts.8876fcf/environment/docs/MILESTONE-8.md from Lego-X/ProgramGen: direct link, hf CLI and curl.
- Browser
- Download file 11.1 kB
-
https://huggingface.co/datasets/Lego-X/ProgramGen/resolve/main/tasks/data/reverse/abdelstark__guts.8876fcf/environment/docs/MILESTONE-8.md
- Command line
-
hf download hf://datasets/Lego-X/ProgramGen/tasks/data/reverse/abdelstark__guts.8876fcf/environment/docs/MILESTONE-8.md
-
curl -L -o MILESTONE-8.md https://huggingface.co/datasets/Lego-X/ProgramGen/resolve/main/tasks/data/reverse/abdelstark__guts.8876fcf/environment/docs/MILESTONE-8.md
11.1 kB
Milestone 8: Git & GitHub Compatibility
Status: In Progress Started: 2025-12-21
Overview
Milestone 8 focuses on making Guts fully compatible with existing Git and GitHub tooling. This includes user accounts with personal access tokens (PATs), GitHub-compatible API responses, repository contents API, releases/tags management, archive downloads, and SSH key management. These features enable seamless integration with existing CI/CD tools, IDE plugins, and developer workflows.
Goals
- User Accounts: Full user account management with profile, settings, and identity mapping
- Personal Access Tokens: Token-based authentication for API and Git operations
- GitHub API Compatibility: Standard headers, pagination, rate limits, and error formats
- Contents API: Browse and download files without cloning the repository
- Releases & Tags: Release management with assets and changelogs
- Archive Downloads: Tarball and zipball downloads for any ref
- SSH Key Management: User SSH key storage for future SSH protocol support
New Crate: guts-compat
Technology Choices
| Component | Technology | Rationale |
|---|---|---|
| Token Generation | CSPRNG + Base62 | Secure, URL-safe tokens |
| Token Hashing | Argon2id | Industry standard password hashing |
| SSH Keys | ed25519-dalek | Ed25519 key validation |
| Archives | flate2 + tar | Standard compression formats |
| Pagination | Link headers | GitHub API standard |
Core Types
User Account
Personal Access Token
SSH Key
Release
Repository Contents
Middleware Types
Data Flow
Token Authentication Flow
Contents API Flow
Phase 1: Core Types & Storage
- Create
guts-compatcrate structure - Define User and UserProfile types
- Define PersonalAccessToken types
- Define SshKey types
- Create compatibility data store
- Add user storage with username index
Phase 2: User Accounts
- POST
/api/users- Create user account - GET
/api/users- List users - GET
/api/users/{username}- Get user profile - PATCH
/api/users/{username}- Update user profile - GET
/api/user- Get authenticated user - PATCH
/api/user- Update authenticated user - GET
/api/users/{username}/repos- List user repos
Phase 3: Personal Access Tokens
- Implement token generation (CSPRNG)
- Implement Argon2id hashing
- POST
/api/user/tokens- Create token - GET
/api/user/tokens- List tokens (no secrets) - DELETE
/api/user/tokens/{id}- Revoke token - Create token authentication middleware
- Support Basic auth (username:token)
- Support Bearer token auth
Phase 4: SSH Key Management
- POST
/api/user/keys- Add SSH key - GET
/api/user/keys- List SSH keys - GET
/api/user/keys/{id}- Get SSH key - DELETE
/api/user/keys/{id}- Remove SSH key - Validate SSH key format
- Calculate SSH key fingerprint
Phase 5: GitHub API Compatibility Middleware
- Rate limiting middleware (X-RateLimit-* headers)
- Pagination middleware (Link header)
- Error response formatting
- ETag/If-None-Match support
- GitHub media type handling
- CORS headers for API
Phase 6: Repository Contents API
- GET
/api/repos/{owner}/{repo}/contents/{path}- Get contents - GET
/api/repos/{owner}/{repo}/readme- Get README - GET
/api/repos/{owner}/{repo}/license- Get license - Support
refquery parameter - Support directory listing
- Support symlink resolution
Phase 7: Archive Downloads
- GET
/api/repos/{owner}/{repo}/tarball/{ref}- Download tarball - GET
/api/repos/{owner}/{repo}/zipball/{ref}- Download zipball - Implement tar archive generation
- Implement zip archive generation
- Stream archives for large repos
Phase 8: Releases & Tags
- POST
/api/repos/{owner}/{repo}/releases- Create release - GET
/api/repos/{owner}/{repo}/releases- List releases - GET
/api/repos/{owner}/{repo}/releases/{id}- Get release - PATCH
/api/repos/{owner}/{repo}/releases/{id}- Update release - DELETE
/api/repos/{owner}/{repo}/releases/{id}- Delete release - GET
/api/repos/{owner}/{repo}/releases/latest- Get latest - GET
/api/repos/{owner}/{repo}/releases/tags/{tag}- Get by tag - POST
/api/repos/{owner}/{repo}/releases/{id}/assets- Upload asset - GET
/api/repos/{owner}/{repo}/releases/{id}/assets- List assets - DELETE
/api/repos/{owner}/{repo}/releases/{id}/assets/{asset_id}- Delete asset
Phase 9: CLI Commands
-
guts auth login- Interactive login -
guts auth token create- Create PAT -
guts auth token list- List tokens -
guts auth token revoke- Revoke token -
guts ssh-key add- Add SSH key -
guts ssh-key list- List SSH keys -
guts release create- Create release -
guts release list- List releases -
guts release download- Download release assets
Phase 10: Tests & Documentation
- Unit tests for token generation/verification
- Unit tests for SSH key parsing
- E2E tests for user account CRUD
- E2E tests for token authentication
- E2E tests for contents API
- E2E tests for releases API
- Update API documentation
- Add compatibility guide
API Reference
User Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /api/users |
Create user account |
| GET | /api/users |
List users |
| GET | /api/users/{username} |
Get user profile |
| PATCH | /api/users/{username} |
Update user profile |
| GET | /api/user |
Get authenticated user |
| PATCH | /api/user |
Update authenticated user |
| GET | /api/users/{username}/repos |
List user repos |
Token Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /api/user/tokens |
Create personal access token |
| GET | /api/user/tokens |
List tokens (no secrets) |
| GET | /api/user/tokens/{id} |
Get token metadata |
| DELETE | /api/user/tokens/{id} |
Revoke token |
SSH Key Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /api/user/keys |
Add SSH key |
| GET | /api/user/keys |
List SSH keys |
| GET | /api/user/keys/{id} |
Get SSH key |
| DELETE | /api/user/keys/{id} |
Remove SSH key |
Contents Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/repos/{owner}/{repo}/contents |
Get root contents |
| GET | /api/repos/{owner}/{repo}/contents/{path} |
Get file/directory |
| GET | /api/repos/{owner}/{repo}/readme |
Get README |
| GET | /api/repos/{owner}/{repo}/license |
Get license |
Archive Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/repos/{owner}/{repo}/tarball/{ref} |
Download tarball |
| GET | /api/repos/{owner}/{repo}/zipball/{ref} |
Download zipball |
Release Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /api/repos/{owner}/{repo}/releases |
Create release |
| GET | /api/repos/{owner}/{repo}/releases |
List releases |
| GET | /api/repos/{owner}/{repo}/releases/latest |
Get latest release |
| GET | /api/repos/{owner}/{repo}/releases/tags/{tag} |
Get by tag |
| GET | /api/repos/{owner}/{repo}/releases/{id} |
Get release |
| PATCH | /api/repos/{owner}/{repo}/releases/{id} |
Update release |
| DELETE | /api/repos/{owner}/{repo}/releases/{id} |
Delete release |
| POST | /api/repos/{owner}/{repo}/releases/{id}/assets |
Upload asset |
| GET | /api/repos/{owner}/{repo}/releases/{id}/assets |
List assets |
| DELETE | /api/repos/{owner}/{repo}/releases/{id}/assets/{asset_id} |
Delete asset |
Rate Limit Endpoint
| Method | Path | Description |
|---|---|---|
| GET | /api/rate_limit |
Get current rate limit status |
Response Headers
All API responses include GitHub-compatible headers:
Error Response Format
Errors follow GitHub's format:
For validation errors:
Token Format
Tokens follow a structured format for easy identification:
- Prefix: 8 characters (lowercase alphanumeric)
- Secret: 32 characters (mixed case alphanumeric)
- Only the first 8 characters are stored; the full token is hashed
Authentication Methods
Bearer Token (Recommended)
Basic Auth (Token as password)
Git Credential Helper
Success Criteria
- Users can create accounts with unique usernames
- Users can generate and manage personal access tokens
- Token authentication works for all API endpoints
- Git push/pull works with token authentication
- Contents API returns file/directory listings
- Archives can be downloaded for any ref
- Releases can be created and managed
- Rate limiting headers present on all responses
- Pagination works with Link headers
- Error responses match GitHub format
- SSH keys can be stored and validated
Security Considerations
- Token Storage: Tokens are hashed with Argon2id; plaintext never stored
- Token Rotation: Support for token expiration and revocation
- Scope Limitation: Fine-grained scopes limit token capabilities
- Rate Limiting: Prevent abuse with per-user rate limits
- Audit Logging: Log all authentication events
- Input Validation: Validate all user inputs strictly
- SSH Key Validation: Verify SSH key format and type
Performance Considerations
- Token Lookup: Index tokens by prefix for O(1) lookup
- Caching: Cache user profiles and rate limit state
- Streaming: Stream large archives to avoid memory issues
- Compression: Compress archive responses
- Pagination: Limit default page size to 30 items
Future Enhancements
These features are out of scope for Milestone 8 but planned:
- SSH Protocol: Full SSH Git protocol support
- OAuth 2.0: OAuth apps and authorization flow
- GitHub App Compatibility: App installation and authentication
- Two-Factor Authentication: TOTP/WebAuthn support
- GPG Key Management: Commit signing verification
- GraphQL API: GitHub GraphQL compatibility
- Starring/Watching: Repository stars and watch notifications
Dependencies
guts-storage: Object storage for contents APIguts-git: Git protocol for archive generationguts-auth: Permission checkingargon2: Password hashingbase64: Content encodingflate2: Gzip compressiontar: Tar archive creationzip: Zip archive creationrand: Secure random token generation