Skip to content

Commit

Permalink
[memory-bank] Update with more details (#20639)
Browse files Browse the repository at this point in the history
* [memory-bank] Tell cline how to build components

Tool: gitpod/catfood.gitpod.cloud

* [memory-bank] Document API components as well

Tool: gitpod/catfood.gitpod.cloud

* [memory-bank] Document content-service-api, ide-metrics-api, ide-service-api

Tool: gitpod/catfood.gitpod.cloud

* [memory-bank] Document image-builder-api, local-app-api, registry-facade-api

Tool: gitpod/catfood.gitpod.cloud

* [memory-bank] Document supervisor-api, usage-api, ws-daemon-api

Tool: gitpod/catfood.gitpod.cloud

* [memory-bank] Document ws-manager-api, ws-manager-bridge-api

Tool: gitpod/catfood.gitpod.cloud
  • Loading branch information
geropl authored Feb 27, 2025
1 parent 0cba458 commit 5510b8a
Showing 15 changed files with 1,721 additions and 23 deletions.
56 changes: 46 additions & 10 deletions memory-bank/.clinerules
Original file line number Diff line number Diff line change
@@ -26,19 +26,35 @@ This file captures important patterns, preferences, and project intelligence tha

## Development Workflow

- **Build System**: Use Leeway for building components
- `leeway build` to build specific components
- `leeway exec` to run commands across components
- **Build Approaches**:
- **In-tree builds** (primary for local development):
- TypeScript components: Use `yarn` commands defined in package.json
- `yarn build`: Compile the component
- `yarn test`: Run tests
- `yarn lint`: Check code style
- `yarn watch`: Watch for changes and rebuild
- Go components: Use standard Go tools
- `go build ./...`: Build all packages
- `go test ./...`: Test all packages
- `go run main.go`: Build and run

- **Out-of-tree builds** (Leeway, primary for CI):
- `leeway build components/component-name:app`: Build a specific component
- `leeway build -D components/component-name:app`: Build with dependencies
- `leeway exec --package components/component-name:app -- command`: Run a command for a package

- **Testing**:
- Unit tests alongside code
- Integration tests in separate directories
- End-to-end tests in the `test/` directory
- Component-specific test commands in package.json (for TypeScript)
- Go tests use standard `go test` command

- **Local Development**:
- Use Gitpod workspaces for development (dogfooding)
- Components can be run individually for testing
- Preview environments for testing changes
- Use in-tree builds for rapid iteration during development

## Critical Implementation Paths

@@ -76,9 +92,12 @@ This file captures important patterns, preferences, and project intelligence tha
- **Memory Bank Documentation**:
- Component-specific documentation is stored in `memory-bank/components/` directory
- Each component gets its own markdown file with detailed information about its purpose, architecture, and implementation
- API components (with "*-api" suffix) should NOT be documented separately as they are typically just interface definitions
- Component documentation should focus on the main service components that implement business logic
- Component documentation should focus on both service components that implement business logic and API components that define interfaces
- Documentation follows a consistent structure with sections for Overview, Purpose, Architecture, Key Features, etc.
- API component documentation should include a "Code Generation and Building" section that explains:
- How to regenerate code from protobuf definitions
- The implementation details of the generation process
- How to build components that depend on the API after regeneration

## Evolution of Project Decisions

@@ -92,16 +111,33 @@ This section will be updated as I learn about how and why certain architectural
3. Make it easier to find information about specific components
4. Enable incremental updates to component documentation without affecting other files

- **API Component Exclusion**: The decision to exclude "*-api" components from separate documentation was made because:
1. API components primarily contain interface definitions, not implementation logic
2. The interfaces are typically documented within the main service component that implements them
3. Documenting API components separately would create redundancy
4. The focus should be on documenting the service components that implement business logic
- **API Component Documentation**: The decision to include "*-api" components in separate documentation was made because:
1. API components define critical interfaces between services
2. Understanding these interfaces is essential for developers working across components
3. API documentation helps clarify system boundaries and communication patterns
4. Separate documentation makes it easier to track API changes and versioning

## User Preferences

This section will be updated as I learn about specific user preferences for working with the codebase.

## Build and Test Information

When working with components, I should always document:

- **Build Commands**: Document any new or component-specific build commands I encounter
- **Test Commands**: Document how to run tests for each component
- **Dependencies**: Note any special dependencies required for building or testing
- **Common Issues**: Document common build or test issues and their solutions
- **Performance Considerations**: Note any performance considerations for builds

Whenever I encounter new build patterns or commands, I should update:
1. The relevant component documentation in `memory-bank/components/`
2. The `.clinerules` file with general patterns
3. The `techContext.md` file if it represents a significant pattern

This information is critical for effective development work, as being able to build and test components is fundamental to making changes and verifying their correctness.

---

Note: This file will be continuously updated as I work with the Gitpod codebase and discover new patterns, preferences, and insights.
37 changes: 33 additions & 4 deletions memory-bank/activeContext.md
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ Key areas of focus include:
- Created detailed documentation for key components:
- blobserve: Service that provides static assets from OCI images
- content-service: Manages various types of content within the platform
- dashboard: Web-based user interface for Gitpod
- dashboard: Web-based user inSterface for Gitpod
- ws-manager-mk2: Kubernetes controller for managing workspace lifecycle
- supervisor: Init process that runs inside each workspace container
- ws-daemon: Node-level daemon for workspace operations
@@ -49,6 +49,23 @@ Key areas of focus include:
- openvsx-proxy: Caching proxy service for the OpenVSX registry
- scheduler-extender: Extends Kubernetes scheduling capabilities for workspaces
- ipfs: Provides distributed content-addressable storage for container images
- Created documentation for API components:
- content-service-api: Interfaces for managing workspace content, blobs, logs, and IDE plugins
- ide-metrics-api: Interfaces for collecting metrics and error reports from IDE components
- ide-service-api: Interfaces for managing IDE configurations and resolving workspace IDE requirements
- image-builder-api: Interfaces for building Docker images for workspaces
- local-app-api: Interfaces for communication between local machines and remote workspaces
- registry-facade-api: Interfaces for dynamically assembling workspace container images
- supervisor-api: Interfaces for workspace management, terminal handling, and port forwarding
- usage-api: Interfaces for tracking, calculating, and managing workspace usage and billing
- ws-daemon-api: Interfaces for workspace content management and container operations
- ws-manager-api: Interfaces for managing the lifecycle of workspaces in Kubernetes clusters
- ws-manager-bridge-api: Interfaces for dynamic management of workspace clusters
- Enhanced API component documentation with code generation information:
- Added details on how to regenerate code from protobuf definitions
- Documented the implementation details of the generation process
- Included instructions for building components after code regeneration
- Updated .clinerules to standardize API documentation with code generation sections

As work progresses, this section will continue to be updated to reflect:
- Additional component documentation
@@ -63,9 +80,11 @@ The immediate next steps are:

1. **Explore Component Interactions**: Understand how components interact with each other
2. **Set Up Development Environment**: Configure a local development environment for effective testing
3. **Identify Initial Tasks**: Determine specific tasks or improvements to focus on
4. **Establish Testing Approach**: Define how changes will be tested and validated
5. **Update Memory Bank**: Continue to refine and expand the memory bank as new information is discovered
3. **Explore Build System**: Gain hands-on experience with both in-tree and Leeway builds
4. **Test Component Builds**: Practice building and testing different component types
5. **Identify Initial Tasks**: Determine specific tasks or improvements to focus on
6. **Establish Testing Approach**: Define how changes will be tested and validated
7. **Update Memory Bank**: Continue to refine and expand the memory bank as new information is discovered

## Active Decisions and Considerations

@@ -115,5 +134,15 @@ Initial exploration of the Gitpod codebase has revealed:
- Go services typically have a cmd/ directory with command implementations
- TypeScript services use React and modern frontend practices
- Most components have a clear separation between API definitions and implementations
- **Build System Approaches**: Gitpod uses two primary approaches for building components:
- **In-tree builds**: Using language-specific tools (yarn, go) directly in the workspace
- Primary method for local development
- TypeScript components use commands defined in package.json (yarn build, yarn test, etc.)
- Go components use standard Go tools (go build, go test, etc.)
- **Out-of-tree builds**: Using Leeway, a custom build tool
- Primary method for CI to generate build artifacts
- Works by copying relevant sources into a separate file tree
- Can also be run from inside the workspace
- Manages complex dependencies between components

This section will be continuously updated as new insights are gained through working with the system.
127 changes: 127 additions & 0 deletions memory-bank/components/content-service-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Content Service API

## Overview
The Content Service API defines the gRPC interfaces for the Content Service, which is responsible for managing various types of content within the Gitpod platform, including workspace files, blobs, logs, and IDE plugins.

## Purpose
This API provides a standardized interface for other components to interact with the Content Service, enabling operations such as:
- Managing workspace content (downloading, deleting, checking snapshots)
- Handling blob storage (uploading, downloading, deleting)
- Accessing headless logs
- Managing IDE plugins
- Defining workspace initialization methods

## Architecture
The Content Service API is implemented as a set of gRPC services defined in Protocol Buffer files. These definitions are used to generate client and server code in various languages (Go, TypeScript) for use by other components in the system.

## Key Services

### ContentService
Provides core content management functionality:
- `DeleteUserContent`: Deletes all content associated with a user

### WorkspaceService
Manages workspace content:
- `WorkspaceDownloadURL`: Provides a URL from which workspace content can be downloaded
- `DeleteWorkspace`: Deletes the content of a single workspace
- `WorkspaceSnapshotExists`: Checks whether a workspace snapshot exists

### BlobService
Handles blob storage operations:
- `UploadUrl`: Provides a URL to which clients can upload content via HTTP PUT
- `DownloadUrl`: Provides a URL from which clients can download content via HTTP GET
- `Delete`: Deletes uploaded content

### HeadlessLogService
Manages access to headless logs:
- `LogDownloadURL`: Provides a URL from which logs can be downloaded
- `ListLogs`: Returns a list of task IDs for a specified workspace instance

### IDEPluginService
Manages IDE plugins:
- `UploadURL`: Provides a URL for uploading plugin content
- `DownloadURL`: Provides a URL for downloading plugin content
- `PluginHash`: Provides a hash of a plugin

## Key Data Structures

### WorkspaceInitializer
Defines how a workspace is initialized, with several initialization methods:
- `EmptyInitializer`: Creates an empty workspace
- `GitInitializer`: Initializes from a Git repository
- `SnapshotInitializer`: Initializes from a snapshot
- `PrebuildInitializer`: Combines snapshots with Git
- `CompositeInitializer`: Uses multiple initializers in sequence
- `FileDownloadInitializer`: Downloads files for workspace content
- `FromBackupInitializer`: Initializes from a backup

### GitStatus
Describes the current Git working copy status, similar to a combination of "git status" and "git branch".

## Communication Patterns
- The API uses gRPC for efficient, typed communication between services
- Many operations return URLs rather than content directly, allowing for efficient transfer of large files
- Authentication information is passed in request messages

## Dependencies
- Used by various components that need to interact with workspace content
- Depends on underlying storage systems (not specified in the API)

## Usage Examples
- Workspace Manager uses this API to initialize workspaces
- Dashboard uses this API to provide download links for workspace content
- IDE components use this API to access plugins

## Version Compatibility
The API uses Protocol Buffers version 3 (proto3) syntax, which provides forward and backward compatibility features.

## Code Generation and Building

### Regenerating Code from Protobuf Definitions
The Content Service API uses Protocol Buffers and gRPC for defining interfaces. When changes are made to the `.proto` files, the corresponding code in various languages needs to be regenerated.

To regenerate the code:

1. Navigate to the content-service-api directory:
```bash
cd components/content-service-api
```

2. Run the generate script:
```bash
./generate.sh
```

This script performs the following actions:
- Installs necessary dependencies (protoc plugins)
- Generates Go code using `protoc-gen-go` and `protoc-gen-go-grpc`
- Generates TypeScript code
- Updates license headers

### Implementation Details
The `generate.sh` script uses functions from the shared script at `scripts/protoc-generator.sh`, which provides common functionality for all API components:

- `install_dependencies`: Installs required protoc plugins
- `protoc_buf_generate`: Uses the `buf` tool to generate code based on the configuration in `buf.gen.yaml`
- `update_license`: Updates license headers in generated files

### Building After Code Generation
After regenerating the code, you may need to rebuild components that depend on the Content Service API. This typically involves:

1. For Go components:
```bash
cd <component-directory>
go build ./...
```

2. For TypeScript components:
```bash
cd <component-directory>
yarn install
yarn build
```

3. Using Leeway (for CI/CD):
```bash
leeway build -D components/<component-name>:app
```
Loading
Oops, something went wrong.

0 comments on commit 5510b8a

Please sign in to comment.