feat: add formal PR reviews and Pi/OpenCode backends #29
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/issue-28-agent-cli"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reviews can now run headless coding agents to investigate callers and definitions beyond the diff, and optionally publish formal Forgejo review decisions. This repository is configured to use Pi with
strata/strataon the future Vega host runner and publish formalCOMMENTreviews after merge; approval and request-changes authority remain disabled. The tool's default behavior for other repositories remains advisory comments.Adds configurable Pi and bundled OpenCode backends alongside the existing HTTP providers. The OpenCode adapter extracts only a completed final response from its JSON event stream and explicitly rejects unknown or missing event types. Both CLI backends validate reports, enforce accepted-output limits, clean up temporary files, and terminate the process group on timeout. Publishing credentials are excluded from the child environment. Pi defaults to
strata/strata, selected from documented live synthetic samples; other installations can choose their own provider/model. OpenCode requires an explicit model and provides a dedicated agent with navigation permissions. CLI executables remain runner dependencies, and agent permissions are not an OS sandbox.Formal reviews are opt-in through trusted base-branch configuration. Approval and request-changes authority are separately configurable, with conservative approval checks and reviews attached to the exact reviewed head commit.
The repository configuration uses Vega's system Pi wrapper with navigation tools and optional integrations disabled. It retains second-pass validation and allows a 40-minute workflow budget for two 15-minute model passes plus checks. Vega must have a registered host runner with the
vegalabel and a service user able to access the Pi wrapper and Strata credentials. Pi starts on Vega, but an active Forgejo runner service was not found during verification; its deployment remains infrastructure work outside this PR. No Pi setup on Nova is needed.Validation:
nix flake check --no-update-lock-filepassed for the implementation and parser fix; aarch64-linux was skipped as incompatible with the validation host.This PR's model configuration still comes from the base branch, so its automatic review uses Ollama until merge. The workflow runner change may route this PR's checks to Vega before merge and queue them until that runner is registered.
Closes #27.
Closes #28.
Automated code review
Reviewed commit:
9dab3bffa307a35e5f41a53dc569c27fc5576ab1Verdict: Requires further work
Resolve the blocking or important findings and investigate failed deterministic checks before merging.
Overall assessment
The pull request introduces headless agent backends (Pi and OpenCode) for AI-driven code reviews, enabling the reviewer to navigate the codebase beyond the immediate diff. It also implements formal PR review decisions (COMMENT, REQUEST_CHANGES, APPROVED) via Forgejo's API, controlled by explicit configuration flags. The changes include a new
agent_cli_reviewfunction, event parsing for OpenCode, validation logic for formal reviews, and extensive unit tests covering these new paths. Documentation is updated to reflect the new capabilities and configuration options.Blocking findings
None.
Important findings
The
parse_opencode_eventsfunction iterates through lines and checks for specific event types. If an unknown type is encountered, it raises a ValueError. However, for known types like 'text', it checks for 'id' and 'text' keys but does not enforce that the entire structure matches a strict schema beyond these basic checks. While this prevents injection of arbitrary data, it relies on the assumption that future versions of OpenCode will not change the structure of known events in a way that breaks the parser without changing the event type.Impact: If OpenCode changes the structure of a known event type (e.g., adding required fields or changing types), the parser might accept malformed data or fail silently if not caught by subsequent validation. This could lead to incomplete or incorrect review reports being generated.
Suggested fix: Consider adding more robust schema validation for each known event type, perhaps using a library like
pydanticor explicit checks for all expected fields and their types. Additionally, log the raw event data (sanitized) when an error occurs to aid in debugging protocol changes.Suggestions
DEFAULT_PI_MODEL = "strata/strata" is defined as a constant. The
agent_cli_reviewfunction uses this as the default if no model is specified in the config for Pi providers.Impact: Users deploying this reviewer on systems without the 'strata/strata' model will encounter errors or unexpected behavior unless they explicitly configure the model. While the documentation mentions this, relying on a hardcoded default can lead to confusion.
Suggested fix: Consider making the default model configurable via an environment variable (e.g.,
DEFAULT_PI_MODEL_ENV) that can be set at build time or runtime, or require the model to be explicitly specified in the configuration for Pi providers, similar to OpenCode. Alternatively, provide a clear error message if the default model is not available.Tests and validation
Questions
agent_cli_reviewfunction designed to be extensible for future additions?Review limitations
Diff coverage
.forgejo/ai-review.yml: reviewed — included in a context-limited batch.forgejo/workflows/ai-review.yml: reviewed — included in a context-limited batchREADME.md: reviewed — included in a context-limited batchaction.yml: reviewed — included in a context-limited batchdocs/pi-live-sample.md: reviewed — included in a context-limited batchreviewer.py: reviewed — included in a context-limited batchtests/fixtures/agent_review.json: reviewed — included in a context-limited batchtests/fixtures/formal_review_events.json: reviewed — included in a context-limited batchtests/test_agent_cli.py: reviewed — included in a context-limited batchtests/test_opencode_smoke.py: reviewed — included in a context-limited batchtests/test_reviewer.py: reviewed — included in a context-limited batchReview metadata