liferay/liferay-portal / .claude/skills/pr-check
pr-check
VerifiedCheck that a PR is ready to be sent for review.
validations/branch/transaction-usage.md
View on GitHub# Transaction Usage
Flags new transaction usage in hand written Java, such as `@Transactional`, `Propagation.REQUIRES_NEW`, or `TransactionInvokerUtil`. Improper transaction usage has heavy performance costs, so Shuyang Zhou and the Core Infrastructure team must approve every new case.
## Match
`\.java$`
## Command
This check is static and needs no build. It walks each changed Java file, skips generated files, and reports any newly added transaction usage in the rest. It uses `command grep` so the diff is filtered by the system grep rather than the shell's `grep` wrapper, which some environments route to another tool with its own defaults.
A generated file carries the `@generated` Javadoc marker that Service Builder and the other code generators stamp on every file they produce (for example every `*LocalService` interface). The scan matches it case-insensitively, so the `@Generated` annotation on REST Builder output is covered too. That annotation is machine-written boilerplate, not hand-written transaction code, so any file carrying it is excluded before the transaction scan.
Anchor that match to a Javadoc tag or an annotation rather than searching the whole file for the bare word, or a class that only mentions `@generated` in prose drops out of the scan entirely.
```bash
FINDINGS=$(
bash "${SKILL_DIR}/select_paths.sh" "${MERGE_BASE}" "${VALIDATION_FILE}" | while IFS= read -r FILE
do
[[ -f ${FILE} ]] || continue
if command grep \
--extended-regexp \
--ignore-case \
--regexp='^[[:space:]]*(\*[[:space:]]*@generated|@generated\()' \
"${FILE}" > /dev/null
then
continue
fi
git diff "${MERGE_BASE}...HEAD" -- "${FILE}" \
| command grep --extended-regexp '^\+' \
| command grep --extended-regexp --invert-match '^\+\+\+' \
| command grep \
--fixed-strings \
--regexp='@Transactional' \
--regexp='Propagation.REQUIRES_NEW' \
--regexp='REQUIRES_NEW_TRANSACTION' \
--regexp='TransactionCallbackUtil' \
--regexp='TransactionCommitCallbackUtil' \
--regexp='TransactionInvokerUtil'
done
)
printf '%s' "${FINDINGS}"
```
**Judge this from `${FINDINGS}` and never from the exit status**, which carries no verdict in either direction. The loop's status is whatever its last iteration happened to leave behind, so it reports on the diff's last Java file rather than on the diff. A clean branch ends on a `command grep` that matched nothing and exits 1. A branch that adds transaction usage in an early file and ends on a clean one also exits 1. `continue` returns 0, so a diff whose last Java file is generated exits 0 whatever preceded it. Both statuses occur on both verdicts.
Run the loop from `${REPO_ROOT}`. The changed paths are relative to the repository root, so from any directory below it, every file test fails and the check passes without scanning anything.
Use `while read` rather than a `for` over an unquoted substitution, so a path holding whitespace stays one file rather than splitting into several.
When `${FINDINGS}` is empty, the branch adds no new transaction usage, so the validation passes.
Otherwise, resolve the GitHub login of the person running pr-check with `gh api user --jq '.login'` and check it against the whitelist below. The validation passes only when that login is on the whitelist, and fails for everyone else. It also fails when the login cannot be resolved, for example when `gh` is not authenticated, so an unknown initiator never passes. Add one login per line as the roster changes.
```
shuyangzhou
```
When the validation fails, report the message below to the developer and return it as the failure note.
```markdown
**Transaction usage requires Core Infrastructure review.** New transaction code (`@Transactional`, `TransactionInvokerUtil`, etc.) has heavy performance implications and requires additional review. After team review is complete, please send this pull request to @liferay-core-infra and request review from @shuyangzhou. For additional questions, use #t-core-infrastructure on Slack.
```
## Time Estimate
~10-20 sec (static, no build).Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |