-
Notifications
You must be signed in to change notification settings - Fork 27
fix(ssd-stream): prevent RAM explosion when --draft-model + --stream-experts combined (#72) #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1005d3e
chore(agents): add review-github-pr workflow skill
github-actions[bot] 975db48
chore(agents): document /opt/homebrew/bin/gh path in review-github-prβ¦
github-actions[bot] 95303a5
fix(ssd-stream): prevent RAM explosion when --draft-model + --stream-β¦
github-actions[bot] 8a04b2b
test(ssd-stream): add regression suite for Issue #72 SSD budget with β¦
github-actions[bot] 9b0a31c
fix(ssd-stream): address Copilot review on PR #76
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,216 @@ | ||
| --- | ||
| description: Review a GitHub Issue or PR for SharpAI/SwiftLM β fetch, analyze, implement fixes, address review comments, and push back to the correct branch | ||
| --- | ||
|
|
||
| # Review GitHub Issue / PR | ||
|
|
||
| This workflow guides end-to-end handling of a GitHub Issue or Pull Request for the | ||
| `SharpAI/SwiftLM` repository: from fetching context, through implementing or | ||
| reviewing code changes, to pushing a clean commit back to the correct fork branch. | ||
|
|
||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - `gh` CLI path on macOS: **`/opt/homebrew/bin/gh`** | ||
| ```bash | ||
| export PATH="/opt/homebrew/bin:$PATH" | ||
| which gh # β /opt/homebrew/bin/gh | ||
| ``` | ||
| - `gh` must be authenticated (`gh auth status`) | ||
| - Working directory: `/Users/simba/workspace/mlx-server` | ||
| - Remote `fork` may need to be added if pushing to a contributor's fork: | ||
| ```bash | ||
| git remote add fork https://github.com/<contributor>/SwiftLM.git | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Steps | ||
|
|
||
| ### 1. Fetch the Issue or PR | ||
|
|
||
| Determine whether the user supplied an **Issue number** or a **PR number**, then | ||
| pull the full context using `gh`: | ||
|
|
||
| ```bash | ||
| # For a PR | ||
| gh pr view <NUMBER> --repo SharpAI/SwiftLM \ | ||
| --json number,title,body,state,baseRefName,headRefName,headRepository,commits,files | ||
|
|
||
| # For an Issue | ||
| gh issue view <NUMBER> --repo SharpAI/SwiftLM \ | ||
| --json number,title,body,state,labels,comments | ||
| ``` | ||
|
|
||
| Note the **`headRepository`** field β if it is not `SharpAI/SwiftLM`, the PR comes | ||
| from a fork. You must push back to the fork's branch (see Step 6). | ||
|
|
||
| --- | ||
|
|
||
| ### 2. Understand the Scope | ||
|
|
||
| Read the PR/Issue body and associated comments carefully. Identify: | ||
|
|
||
| - **Category** β bug fix, feature, test improvement, CI/CD, documentation. | ||
| - **Files touched** β run `gh pr diff <NUMBER> --repo SharpAI/SwiftLM` or read | ||
| the `files` field. | ||
| - **CI status** β check the latest run: | ||
| ```bash | ||
| gh run list --repo SharpAI/SwiftLM --branch <headRefName> --limit 3 | ||
| ``` | ||
| - **Review comments** β if Copilot or a human left inline review comments, read | ||
| them all before writing a single line of code: | ||
| ```bash | ||
| gh pr view <NUMBER> --repo SharpAI/SwiftLM --comments | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 3. Check Out the Branch Locally | ||
|
|
||
| ```bash | ||
| # If the PR is from SharpAI directly | ||
| git fetch origin | ||
| git checkout <headRefName> | ||
|
|
||
| # If the PR is from a fork | ||
| git remote add fork https://github.com/<forkOwner>/SwiftLM.git # once only | ||
| git fetch fork <headRefName> | ||
| git checkout -b <headRefName> fork/<headRefName> | ||
| ``` | ||
|
|
||
| Verify you are on the correct branch: | ||
| ```bash | ||
| git status | ||
| git log --oneline -5 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 4. Triage Review Comments (for PRs) | ||
|
|
||
| For each Copilot or human review comment: | ||
|
|
||
| 1. **Classify** the severity: | ||
| - π΄ **Must fix** β correctness bugs, resource leaks, race conditions, broken CI. | ||
| - π‘ **Should fix** β test coverage gaps, false-pass logic, missing imports. | ||
| - π’ **Optional** β style, wording, architecture refactors beyond the PR scope. | ||
|
|
||
| 2. **Implement** all π΄ and π‘ items. For π’ items, document them as follow-up | ||
| work in a code comment or GitHub comment but do not expand the PR scope. | ||
|
|
||
| 3. **Key patterns learned from SwiftLM history**: | ||
| - Shell scripts use `set -euo pipefail` β every `grep`, `jq`, or pipeline that | ||
| may produce no output **must** be guarded with `|| true` or placed inside an | ||
| `if` condition to prevent silent script abort. | ||
| - Heartbeat / background `Task` objects in Swift **must** be cancelled via | ||
| `defer { task?.cancel() }` so all exit paths (including client disconnect) | ||
| are covered β not just the happy path. | ||
| - CORS-related shell tests must target the dedicated `--cors` server instance, | ||
| not the main server started without the flag. | ||
| - Concurrent-request tests must use `--parallel N` (N β₯ 2) to actually exercise | ||
| parallel code paths. | ||
| - When adding new Swift test files that use `Data` / `JSONSerialization`, | ||
| always add `import Foundation` β XCTest does not re-export it in all SPM environments. | ||
|
|
||
| --- | ||
|
|
||
| ### 5. Verify Locally | ||
|
|
||
| Build and run the relevant test suite before pushing: | ||
|
|
||
| ```bash | ||
| # Swift unit tests | ||
| swift test --filter SwiftLMTests | ||
|
|
||
| # Integration tests (server) | ||
| ./tests/test-server.sh .build/release/SwiftLM 15413 | ||
|
|
||
| # OpenCode / SDK compatibility test | ||
| ./tests/test-opencode.sh .build/release/SwiftLM 15414 | ||
| ``` | ||
|
|
||
| If CI previously failed with a specific test number, reproduce it locally first: | ||
| ```bash | ||
| gh run view <RUN_ID> --repo SharpAI/SwiftLM --log-failed 2>&1 | grep -E "FAIL|error|Test [0-9]+" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 6. Commit and Push to the Correct Remote | ||
|
|
||
| > [!IMPORTANT] | ||
| > Always push to the **fork's branch** when updating a fork-originated PR. | ||
| > Pushing to `origin` (SharpAI) creates a new branch and does NOT update the PR. | ||
|
|
||
| ```bash | ||
| git add <files> | ||
| git commit -m "<type>(<scope>): <summary> | ||
|
|
||
| <body: what changed and why>" | ||
|
|
||
| # PR from a fork β push to fork | ||
| git push fork <headRefName>:<headRefName> | ||
|
|
||
| # PR from SharpAI directly β push to origin | ||
| git push origin <headRefName> | ||
| ``` | ||
|
|
||
| Verify the PR was updated: | ||
| ```bash | ||
| gh pr view <NUMBER> --repo SharpAI/SwiftLM --json commits --jq '.commits[].messageHeadline' | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 7. Monitor CI | ||
|
|
||
| After pushing, monitor the triggered workflow: | ||
|
|
||
| ```bash | ||
| # List recent runs on the branch | ||
| gh run list --repo SharpAI/SwiftLM --branch <headRefName> --limit 5 | ||
|
|
||
| # Stream logs for the latest run | ||
| gh run view <RUN_ID> --repo SharpAI/SwiftLM --log | ||
|
|
||
| # Pull only failed steps | ||
| gh run view <RUN_ID> --repo SharpAI/SwiftLM --log-failed 2>&1 | grep -E "FAIL|error|exit code" | ||
| ``` | ||
|
|
||
| If tests fail, go back to Step 4. Iterate until CI is green. | ||
|
|
||
| --- | ||
|
|
||
| ### 8. Respond to Reviewers (Optional) | ||
|
|
||
| If a human or Copilot reviewer left inline comments that you have addressed, | ||
| leave a reply comment summarising what was changed and why each item was handled | ||
| (or deferred): | ||
|
|
||
| ```bash | ||
| gh pr comment <NUMBER> --repo SharpAI/SwiftLM \ | ||
| --body "Addressed all π΄/π‘ review comments in commit <SHA>: | ||
| - heartbeat leak: added defer cleanup in both streaming handlers | ||
| - import Foundation: added to ServerSSETests.swift | ||
| - CORS test: redirected to CORS_PORT server | ||
| - parallel test: dedicated --parallel 2 server on PORT+3 | ||
| - set -e trap: guarded grep/jq pipelines with || true" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Quick Reference | ||
|
|
||
| | Task | Command | | ||
| |------|---------| | ||
| | View PR | `gh pr view <N> --repo SharpAI/SwiftLM` | | ||
| | View PR diff | `gh pr diff <N> --repo SharpAI/SwiftLM` | | ||
| | View PR comments | `gh pr view <N> --repo SharpAI/SwiftLM --comments` | | ||
| | View Issue | `gh issue view <N> --repo SharpAI/SwiftLM` | | ||
| | List CI runs | `gh run list --repo SharpAI/SwiftLM --branch <branch>` | | ||
| | Failed CI logs | `gh run view <ID> --repo SharpAI/SwiftLM --log-failed` | | ||
| | Push to fork | `git push fork <branch>:<branch>` | | ||
| | Push to SharpAI | `git push origin <branch>` | | ||
| | Verify PR commits | `gh pr view <N> --repo SharpAI/SwiftLM --json commits --jq '.commits[].messageHeadline'` | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow hard-codes machine-specific paths (e.g.
/opt/homebrew/bin/gh,/Users/simba/workspace/mlx-server). That makes the workflow non-portable for other contributors and CI environments. Consider replacing these with placeholders and/or environment-variable based guidance (e.g. "ensureghis on PATH" and "run from your local repo checkout").ghmust be authenticated (gh auth status)SharpAI/SwiftLMrepository