feat: add review runner command hook#147
Conversation
|
@kapi-agent review Head: 82af7bf What changed
Why this closes the prior feedback
Verification
|
There was a problem hiding this comment.
kapi-agent review
Verdict: REQUEST_CHANGES
Blocking issues
-
src/cli/kapi-review-cli.ts:--runner-commandis documented and modeled as an “isolated read-only runner”, but the implementation executes the command with the default cwd and full inheritedprocess.env. In practice, that means the runner can mutate the checked-out repository and read all ambient secrets/environment variables available to the kapi-review process. This violates the stated runner/workflow contract and is especially risky because the runner is intended to consume untrusted PR review context. Please either enforce the isolation boundary more concretely, e.g. run from the temp workspace, pass a minimal sanitized environment, and only expose explicitly intended paths/data, or change the contract/docs/types to stop claiming read-only isolation. -
src/cli/kapi-review-cli.ts: the runner input includesprompt: renderIsolatedRunnerPrompt(...), butrunner.prompt_sha256is computed bybuildIsolatedReviewRunner(...)over a different prompt string.renderIsolatedRunnerPromptaddsguidance-source, so the hash ininput.runner.prompt_sha256does not actually authenticate the prompt supplied to the command. This weakens the prompt provenance contract and could cause compliant runners to attest to the wrong prompt. Please make the rendered prompt and hashed prompt share one implementation/string.
Warnings / risks
- Runner failures are converted into structured
runner_erroroutput and then deterministically fail validation, which is reasonable, but the error string may include details from failed child process execution. Consider whether stderr/path leakage is acceptable in persisted artifacts or PR-visible output.
Suggestions
- Add a regression test that reads
KAPI_REVIEW_RUNNER_INPUT, recomputessha256(input.prompt), and asserts it equalsinput.runner.prompt_sha256. - Add a test runner command that attempts to observe cwd/env expectations so the isolation contract is pinned down.
Looks good
execFileis used instead of shell execution, which avoids command string shell injection.- Mutual exclusion between
--runner-output-fileand--runner-commandis clear. - The bad JSON runner path is covered and correctly turns into a failing deterministic runner-output gate instead of being silently accepted.
- Docs were updated alongside the CLI behavior.
Verification notes
- Verifier gate status: PASS — reported
npm ci && npm run verifyexited 0. - Size gate status: PASS — 67 changed lines, below the 200-line limit.
- Revision-explanation status: not required for this opened PR; found true.
- Additional inspection: reviewed the PR diff for
src/cli/kapi-review-cli.ts,test/kapi-review-cli.test.ts,README.md, anddocs/kapi-agent-approval-gate.md.
Engine: pi
82af7bf to
eeb118c
Compare
eeb118c to
3cf3ca0
Compare
There was a problem hiding this comment.
kapi-agent review
Verdict: REQUEST_CHANGES
Blocking issues
- Revision explanation gate failed. This PR was updated after a prior kapi-agent review requested changes, but there is no current-head author explanation of what changed and why. Please add a same-comment re-review request that includes:
@kapi-agent review- the current head SHA
What changedWhy this closes the prior feedbackVerification
Warnings / risks
- None beyond the failing workflow gate. The current code changes appear aimed at addressing the prior runner isolation and prompt provenance concerns.
Suggestions
- Consider adding/confirming explicit tests for
--runner-commandcovering:- minimal environment exposure,
- temp workspace cwd,
- invalid JSON runner output,
- mutual exclusion with
--runner-output-file, - prompt hash matching the supplied runner prompt.
Looks good
src/cli/kapi-review-cli.tsnow runs the runner from a temporary workspace with a constrained environment instead of inheriting the repo cwd and fullprocess.env.- The prompt material used for runner input now includes
guidance-source, matching the prompt provenance represented byrunner.prompt_sha256. - Documentation in
README.mdanddocs/kapi-agent-approval-gate.mdnow reflects the intended runner-command contract.
Verification notes
- Verifier gate status: PASS —
npm ci && npm run verifyexited 0. - Size gate status: PASS — 78 changed lines, under the 200-line limit.
- Revision-explanation status: FAIL — required for this synchronized revision after prior kapi-agent feedback, but not found.
- Prior kapi-agent review existed and requested changes, so approval is blocked until the author supplies the current-head revision explanation.
Engine: pi
|
@kapi-agent review Head: 3cf3ca0c2ca6e1ec60a7154a5d3f5b36a1001954 What changed
Why this closes the prior feedback
Verification
|
There was a problem hiding this comment.
kapi-agent review
Verdict: REQUEST_CHANGES
Blocking issues
- Revision explanation gate failed. This PR was updated after a prior kapi-agent review, but there is no current-head author explanation of what changed and why. Please add a same-comment re-review request with
@kapi-agent review, the current head SHA,What changed,Why this closes the prior feedback, andVerificationbefore requesting re-review again.
Warnings / risks
- None beyond the failed process gate. The current code appears to address the prior isolation/prompt-provenance concerns:
src/cli/kapi-review-cli.tsnow runs the command from a temporary workspace with a reduced environment, and the prompt hash now includesguidance-sourceconsistently.
Suggestions
- Consider adding/confirming targeted tests for
--runner-commandcwd/env behavior and prompt hash matching if they are not already present in the truncated verifier output.
Looks good
--runner-output-fileand--runner-commandare mutually exclusive.- Runner command execution uses
execFilewithout a shell, a temporary cwd, sanitizedHOME/TMPDIR, timeout, bounded output buffer, and deterministic JSON validation. - Documentation in
README.mdanddocs/kapi-agent-approval-gate.mdnow matches the intended runner-command contract.
Verification notes
- Verifier gate status: PASS —
npm ci && npm run verifyexited 0. - Size gate status: PASS — 78 changed lines, under the 200-line limit.
- Revision-explanation status: FAIL — required now, not found for the current head.
- Prior feedback closure: likely closed by the current implementation, but approval is blocked until the required revision explanation is provided.
Engine: pi
|
@kapi-agent review Head: 3cf3ca0 What changed
Why this closes the prior feedback
Verification
|
|
@kapi-agent review Revision explanation for current head
|
kapi-agent reviewVerdict: APPROVE Final approval summaryReview journey
What changed
Why this is correct
Evidence
Remaining risks and approval rationale
Blocking issues
Warnings / risks
Suggestions
Looks good
Verification notes
Engine: kapi-agent request lifecycle:
|
There was a problem hiding this comment.
kapi-agent review
Verdict: APPROVE
Final approval summary
Review journey
- Original goal: add a
--runner-commandhook tokapi-review github-prso an isolated review runner can contribute structured findings. - The semantic scope is bounded to the review harness CLI, runner contract docs, and targeted regression tests.
- Prior kapi-agent feedback requested changes for runner isolation and prompt hash/provenance mismatch, then required a current-head revision explanation. The current revision includes that explanation and addresses the technical blockers.
What changed
src/cli/kapi-review-cli.ts: adds--runner-command, mutually excludes it with--runner-output-file, runs the command from a temp workspace with sanitized env, validates JSON output through the existing runner-output gate, and hashes the same prompt material supplied to the runner.test/kapi-review-cli.test.ts: adds coverage for temp cwd/HOME, no ambientGITHUB_TOKEN, bundled guidance inclusion, prompt hash equality, invalid JSON, and malformed structured output.README.mdanddocs/kapi-agent-approval-gate.md: document the executable runner-command contract.
Why this is correct
- The previous prompt provenance issue is closed because
runner.prompt_sha256now includesguidance-sourceand matches the rendered prompt passed throughKAPI_REVIEW_RUNNER_INPUT. - The previous isolation-contract issue is materially improved: the runner no longer executes in the checkout, does not inherit full ambient env, receives only a temp input path plus minimal env, and its output remains deterministically validated before affecting findings.
- Runner failures and invalid JSON do not silently pass; they become validation failures and force
REQUEST_CHANGES.
Evidence
- Verifier gate: PASS —
npm ci && npm run verifyexited 0. - Size gate: PASS — 78 changed lines, below the 200-line rejection threshold.
- Revision-explanation status: PASS — current-head explanation was found.
- Inspected files:
src/cli/kapi-review-cli.ts,test/kapi-review-cli.test.ts,README.md, anddocs/kapi-agent-approval-gate.md.
Remaining risks and approval rationale
- Remaining risk: this is process-level isolation, not an OS sandbox; a malicious configured runner executable is still arbitrary local code. The docs now describe the actual temp-workspace/minimal-env contract rather than claiming repository mutation is impossible by sandboxing.
- Approval is justified because the blocking correctness and contract-integrity issues from prior reviews are fixed, covered by tests, documented, and verified.
Blocking issues
- none.
Warnings / risks
src/cli/kapi-review-cli.ts:--runner-commandstill executes a local executable, so operators must treat the configured runner as trusted code. The current implementation limits repo/env exposure but is not a full sandbox.
Suggestions
- Consider documenting explicitly that
--runner-commandaccepts an executable path only, not arbitrary shell syntax or arguments. - Consider future support for a runner timeout/configuration knob if different environments need more or less than 120 seconds.
Looks good
--runner-commandand--runner-output-fileare mutually exclusive.- Runner execution uses
execFilewithout a shell, a temporary cwd, sanitizedHOME/TMPDIR, bounded runtime/output, and deterministic JSON validation. - Prompt hashing now authenticates the actual guidance-bearing prompt supplied to the runner.
- Regression coverage targets the previously reported failure modes.
Verification notes
- Verifier gate: PASS —
npm ci && npm run verifyexited 0. - Size gate: PASS — 78 changed lines < 200.
- Revision-explanation status: PASS — required current-head author explanation found.
- Local inspection matched the PR intent and no blocking regression was found.
Engine: pi
There was a problem hiding this comment.
kapi-agent review
Verdict: APPROVE
Final approval summary
Review journey
- Original goal: add a
--runner-commandhook tokapi-review github-prso the Ilchul review harness can invoke an isolated structured review runner. - The semantic scope is limited to the review CLI harness, runner contract documentation, and targeted regression coverage.
- Earlier kapi-agent feedback requested fixes for runner isolation, prompt provenance/hash mismatch, and current-head revision explanation. Those issues have been addressed, and the current head already has a valid revision explanation.
What changed
src/cli/kapi-review-cli.tsadds--runner-command, mutually excludes it with--runner-output-file, runs it from a temporary workspace, passes a minimal environment, validates JSON output through the existing runner-output gate, and aligns the runner prompt hash with the supplied prompt.test/kapi-review-cli.test.tsadds regression coverage for isolated cwd/HOME, no ambientGITHUB_TOKEN, bundled guidance inclusion, prompt hash equality, invalid JSON runner output, and gate failure behavior.README.mdanddocs/kapi-agent-approval-gate.mddocument the runner command contract.
Why this is correct
- The prior isolation concern is closed because the runner executes outside the checkout with sanitized
HOME,TMPDIR, and environment exposure limited toKAPI_REVIEW_RUNNER_INPUT,PATH,HOME, andTMPDIR. - The prior prompt provenance concern is closed because the prompt material used for
runner.prompt_sha256now includes the sameguidance-sourceand guidance content supplied to the runner input. - Runner failures or malformed output do not silently pass; they are converted into invalid structured runner output and force the deterministic gate to fail.
Evidence
- Verifier gate: PASS —
npm ci && npm run verifyexited 0. - Size gate: PASS — 78 changed lines, under the 200-line limit.
- Revision-explanation status: not required now; found.
- Inspected files:
src/cli/kapi-review-cli.ts,test/kapi-review-cli.test.ts,README.md, anddocs/kapi-agent-approval-gate.md.
Remaining risks and approval rationale
- Remaining risk:
src/cli/kapi-review-cli.tshas executable mode in the diff, likely harmless because the file has a shebang, but it is worth confirming this was intentional. - Approval is justified because all gates pass, the PR is small, the previous blockers are addressed with tests, and no blocking correctness or safety issue remains.
Blocking issues
- None.
Warnings / risks
src/cli/kapi-review-cli.ts: file mode changed to executable. This appears non-blocking due to the shebang, but confirm it is intentional to avoid accidental mode churn.
Suggestions
- Consider documenting explicitly that
--runner-commandaccepts an executable path only, not a shell command with arguments, sinceexecFile(command, [])intentionally avoids shell parsing.
Looks good
- Runner command and runner output file are mutually exclusive.
- Runner execution uses
execFilewithout a shell, a temporary cwd, bounded timeout/output, and sanitized environment. - Prompt hash now authenticates the same guidance-backed prompt supplied to the runner.
- Invalid runner JSON and malformed structured output fail the runner-output gate rather than being ignored.
Verification notes
- Verifier gate status: PASS —
npm ci && npm run verifyexited 0. - Size gate status: PASS — 78 changed lines < 200.
- Revision-explanation status: not required now; found.
- Local/CI evidence includes the full verify suite passing, including targeted
kapi-review-clirunner-command coverage.
Engine: pi
Summary
--runner-commandto invoke an isolated read-only review runner fromkapi-review github-prKAPI_REVIEW_RUNNER_INPUTVerification
Refs #141