refactor: rename PR review state helpers#214
Conversation
|
@kapi-agent review Revision explanation for current head What changed:
Why this closes the prior feedback:
Verification:
|
There was a problem hiding this comment.
kapi-agent review
Verdict: APPROVE
Final approval summary
Review journey
This PR addresses issue #209 by removing a focused internal naming cluster that leaked KapiAgent* terminology into reusable PR-review state helpers. The semantic scope is narrow: it renames internal PR review types, helper names, and JSON field names while preserving external contract strings such as kapi-agent, kapi-agent/review, and kapi.pr.* event names. There was no prior kapi-agent review on this PR, so no feedback ping-pong was required.
What changed
The current revision updates:
src/cli/worker-events.tssrc/cli/runctl-cli.tssrc/presentation/runctl-formatters.tssrc/application/github-run-contract-adapter.ts- Related tests in
test/cli-args.test.ts,test/cli-worker-events.test.ts, andtest/github-run-contract-adapter.test.ts
The internal surface now uses PullRequestReviewState, PullRequestReviewView, formatPullRequestReview, latestAgentReview, and reviewCheckConclusion.
Why this is correct
The rename is internally consistent across state production, event payloads, report formatting, and GitHub workflow adapter mapping. External reviewer identity and workflow/event contract strings remain unchanged where they appear to be observable behavior, so the change avoids unnecessary compatibility risk while fixing the targeted implementation-name leakage.
Evidence
- Verifier gate: PASS.
- Size gate: PASS, 74 changed lines under the semantic review threshold.
- Revision-explanation status: not required; author explanation present in the PR body.
- Ilchul review harness gate: PASS, neutral/comment result with no blocking findings.
- Verified evidence includes
npm ci && npm run verifypassing, which ran tests, type/check gates, unused checks, and quality budgets. - I also inspected the PR diff and searched for the renamed legacy symbols across
srcandtest; no old targeted names remained.
Remaining risks and approval rationale
Remaining risk is low and limited to consumers of the internal JSON/report shape expecting the old field names. The PR body explicitly frames these as internal supervisor report/event internals, and the relevant tests were updated. Approval is justified because the scope is focused, verification passed, external strings/contracts were preserved, and I found no blocking correctness or safety issue.
Blocking issues
None.
Warnings / risks
pr_reviewpayload shape changes fromlatestKapiReview/kapiAgentReviewCheckConclusiontolatestAgentReview/reviewCheckConclusion. If any out-of-repo consumer parses these internal JSON fields, it will need to be updated. This appears intentional and covered by tests.
Suggestions
- Consider documenting the internal
pr_reviewJSON shape if it is consumed by tooling outside this repository.
Looks good
- The rename is consistent across producer, formatter, adapter, and tests.
- External contract identifiers such as
kapi-agent,kapi-agent/review, andkapi.pr.*were intentionally preserved. - The residual search for the targeted legacy names came back clean.
Verification notes
- Verifier gate status: PASS —
npm ci && npm run verifyexited 0. - Size gate status: PASS — 74 changed lines, below the 200-line semantic threshold.
- Revision-explanation status: not required; explanation found.
- Ilchul review harness: PASS with no blocking findings.
Engine: pi
There was a problem hiding this comment.
kapi-agent review
Verdict: APPROVE
Final approval summary
Review journey
This PR is a focused refactor for issue #209. The semantic scope is narrow: rename the internal PR review state/helper surface away from KapiAgent*-specific names while preserving external contract literals such as kapi-agent, kapi-agent/review, and kapi.pr.* event names. A prior kapi-agent approval already exists on this same current head, and the revision explanation is present.
What changed
The PR renames internal state/view/helper fields and types across:
src/cli/worker-events.tssrc/cli/runctl-cli.tssrc/presentation/runctl-formatters.tssrc/application/github-run-contract-adapter.ts- Related tests in
test/cli-args.test.ts,test/cli-worker-events.test.ts, andtest/github-run-contract-adapter.test.ts
Key internal names now use PullRequestReviewState, PullRequestReviewView, latestAgentReview, and reviewCheckConclusion.
Why this is correct
The change is mechanically consistent across production code and tests. The renamed fields flow from PR inspection, through event payloads and reports, into the GitHub workflow adapter without changing the external reviewer identity or event/check contracts. Residual scans show the targeted legacy internal names are gone from src and test.
Evidence
Verifier gate: PASS. npm ci && npm run verify exited 0.
Size gate: PASS, 74 changed lines under the 200-line semantic review threshold.
Revision-explanation status: not required now, but present.
Ilchul review harness gate: PASS with neutral/comment output and no blocking findings.
I inspected the relevant changed files and ran targeted searches for the renamed legacy symbols.
Remaining risks and approval rationale
Remaining risk is low and limited to consumers expecting the old internal JSON field names. The PR body explicitly frames these as supervisor report/event internals, and tests were updated to cover the new shape. Approval is justified because the scope is bounded, verification passes, no blocking correctness or contract issue remains, and external kapi-agent contracts are preserved.
Blocking issues
None.
Warnings / risks
pr_reviewpayload internals now uselatestAgentReview/reviewCheckConclusion; any out-of-tree consumer of the old internal JSON shape would need to update. This appears intentional and covered by tests.
Suggestions
- Consider documenting this internal event/report shape as non-stable if external consumers are not intended to rely on it.
Looks good
- External contract strings are preserved while internal reusable names are generalized.
- The rename is consistent across inspection, formatting, event emission, adapter mapping, and tests.
- The residual scan for the targeted old identifiers is clean.
Verification notes
Verifier gate: PASS — npm ci && npm run verify exited 0.
Size gate: PASS — 74 changed lines.
Revision-explanation status: not required now; found.
Ilchul harness: PASS — no blocking findings.
Local inspection included git show of changed files and rg checks for the retired internal names.
Engine: pi
Summary
KapiAgentPrReview*to genericPullRequestReview*names.latestKapiReview/kapiAgentReviewCheckConclusiontolatestAgentReview/reviewCheckConclusionwhile preserving literalkapi-agenttext where it names the external reviewer bot.Linked issue
Refs #209
Problem
Issue #209 is removing legacy
kapiproduct-name leakage from reusable internal implementation identifiers. The PR-review event/report surface still usedKapiAgentPrReviewState,KapiAgentPrReviewView,formatKapiAgentPrReview,latestKapiReview, andkapiAgentReviewCheckConclusionas internal names.That mixed an external integration name (
kapi-agent, which is still the real GitHub App/reviewer name) with reusable internal PR-review state concepts that should be generic.Options considered
KapiAgentPrReviewStateandKapiAgentPrReviewView.latestKapiReviewandkapiAgentReviewCheckConclusionas reusable internal field names.PullRequestReviewState,PullRequestReviewView,formatPullRequestReview,latestAgentReview, andreviewCheckConclusion.kapi-agentstrings intact.kapi.pr.*event names andkapi-agentreviewer labels outside this small slice.Selected approach
Selected option 2.
This keeps the slice small and semantic: internal state/helper names become generic, while external compatibility/event names and actual GitHub App labels remain untouched. It deliberately avoids changing
kapi.pr.*event type contracts or the visiblekapi-agent PR reviewreport label in this PR.Implementation
src/cli/worker-events.tsKapiAgentPrReviewStatetoPullRequestReviewState.latestAgentReviewandreviewCheckConclusion.kapi-agentevent names and reviewer literals as external integration contracts.src/cli/runctl-cli.tssrc/presentation/runctl-formatters.tsKapiAgentPrReviewViewtoPullRequestReviewViewandformatKapiAgentPrReviewtoformatPullRequestReview.kapi-agentreviewer.src/application/github-run-contract-adapter.tstest/cli-args.test.ts,test/cli-worker-events.test.ts,test/github-run-contract-adapter.test.tsWhy this fixes it
The old internal PR-review naming cluster no longer contains
KapiAgent*type/helper names orlatestKapiReview/kapiAgentReviewCheckConclusionfield names. Remainingkapi-agentreferences in this touched surface now denote the external reviewer bot, check name, or event contract rather than reusable implementation vocabulary.Residual scan for this slice:
Changed-line size: 74 total changed lines (
37 insertions + 37 deletions).QA / Verification
npm test -- test/cli-worker-events.test.ts test/github-run-contract-adapter.test.ts test/cli-args.test.ts— pass; package script ran the fulltest/*.test.tssuite plus repeated args: 521 tests, 510 pass, 11 skipped.npm run check— pass.npm run check:unused— pass.npm run quality:budgets— pass with existing non-failing warning:code_smells=52.git diff --check— pass.rg -n 'KapiAgentPrReviewState|KapiAgentPrReviewView|formatKapiAgentPrReview|latestKapiReview|kapiAgentReviewCheckConclusion|latestKapi\b' src test— no matches.Manual smoke, if applicable:
Anomalies observed
npm test -- test/cli-worker-events.test.ts test/github-run-contract-adapter.test.ts test/cli-args.test.tsinvokedtsx --test test/*.test.ts ...; 521 tests ran.src/cli/kapi-review-cli.tsexecutable bit locally.git diff -- src/cli/kapi-review-cli.tsshowed onlyold mode 100644/new mode 100755.100644before staging.quality:budgetsstill warns oncode_smells=52.npm run quality:budgetsoutput.Risks / Follow-up
KapiRegistryEntry,KapiService, orKapiStore; those remain follow-up slices under Remove remaining kapi identifiers from internal codebase #209.kapi-agentstrings andkapi.pr.*event names where they are external integration/contract identifiers.kapi-agent review
@kapi-agent review.REQUEST_CHANGES, orCOMMENT, request re-review with a same-comment current-head revision explanation:@kapi-agent reviewRevision explanation for current head <HEAD_SHA>What changedWhy this closes the prior feedbackVerification