feat: add continuous live contract verification - #7
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
📝 WalkthroughWalkthroughAdded the read-only ChangesDoctor command and verification
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Operator
participant doctorCommand
participant runDoctorProbes
participant GitHub
Operator->>doctorCommand: invoke gh2 doctor
doctorCommand->>runDoctorProbes: execute configured probes
runDoctorProbes->>GitHub: run read-only contract checks
GitHub-->>runDoctorProbes: return JSON responses or errors
runDoctorProbes-->>doctorCommand: aggregate probe statuses
doctorCommand-->>Operator: print table or JSON report and exit code
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| } | ||
|
|
||
| if (process.env.CI) process.exit(0); | ||
| if (process.env.CI || fs.existsSync(path.join(__dirname, "..", ".git"))) process.exit(0); |
There was a problem hiding this comment.
Suggestion: The installer exits whenever the package is installed from a Git checkout or while CI is set, even when bin/native/gh2 is missing. The launcher then imports this installer and immediately attempts to spawn that nonexistent binary, so gh2 fails to start for source-checkout installations and normal CI-installed packages. Only skip release downloads when a source-mode launcher is actually available, or make bin/gh2 fall back to the source entry point. [logic error]
Severity Level: Major ⚠️
- ⚠️ Normal non-CI registry installs remain unaffected.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** bin/install.js
**Line:** 35:35
**Comment:**
*Logic Error: The installer exits whenever the package is installed from a Git checkout or while `CI` is set, even when `bin/native/gh2` is missing. The launcher then imports this installer and immediately attempts to spawn that nonexistent binary, so `gh2` fails to start for source-checkout installations and normal CI-installed packages. Only skip release downloads when a source-mode launcher is actually available, or make `bin/gh2` fall back to the source entry point.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| if (!data || typeof data !== "object" || Reflect.get(data, "app") !== options.app) { | ||
| return "App permission output did not identify the requested App."; | ||
| } |
There was a problem hiding this comment.
Suggestion: The validator rejects an empty permission map as contract drift, but the permissions command intentionally omits permissions whose level is none, so an App with all permissions unset produces a valid current: {} response. This causes gh2 doctor to report healthy live data as parser drift. [incorrect condition logic]
Severity Level: Major ⚠️
- ❌ Doctor falsely reports valid App permissions as contract drift.
- ⚠️ Support diagnostics receive an incorrect failing probe.
- ⚠️ Exit code 1 can trigger false CI or scheduler alerts.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** src/commands/doctor.ts
**Line:** 133:135
**Comment:**
*Incorrect Condition Logic: The validator rejects an empty permission map as contract drift, but the permissions command intentionally omits permissions whose level is `none`, so an App with all permissions unset produces a valid `current: {}` response. This causes `gh2 doctor` to report healthy live data as parser drift.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
User description
Changes
gh2 doctorto run read-only live contract probes and distinguish parser drift from GitHub browser or sudo reauthentication.0.0.0for development builds and skip release-binary downloads from Git checkouts.Testing
bun install --frozen-lockfileactionlintbun run typecheckbun test— 122 tests passedbun run buildnpm pack --dry-rungh2 doctor --org circlesac --support --output json— 4/4 probes healthy--yessubmissionsNotes
2means reauthentication is needed, while exit code1means contract drift or another failure.CodeAnt-AI Description
Add read-only live contract checks with clear authentication and parser-drift results
What Changed
gh2 doctorto check GitHub App, repository, PAT policy, installation, Support, and fine-grained PAT surfaces without submitting changesImpact
✅ Detects GitHub parser drift before administrative operations fail✅ Separates expired sessions from contract changes✅ Verifies published npm, standalone, Debian, and Homebrew installations💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit
gh2 doctorcommand to verify GitHub integrations, authentication, and API responses.