gitea-fix-codeql-code-scanning

Based on#36858
SegmentInvestigate-and-fix
Typebug
## Task

We ran a static analysis over the Go backend and ten `incorrect-integer-conversion` warnings were flagged. Seemed like they were flagged on values that round trip between `int` and `int64` in some functions. There were also a few allocation size warnings about slice capacities dervied from values the analyzer couldn't prove were bounded. Could you look into these issues and fix them for real (e.g. no global cast)?

## General instructions

- The code repo is at /repo/gitea.
- You are inside of a Docker container. You may not be able to perform all operations you would normally be able to do on a local machine. Dependencies have not been pre-installed, and you may need to install them yourself.
- You are expected to act autonomously as a software engineer to complete tasks you are given.
- Do not stop until you feel you have completed the task and your code changes can be merged.
- You may need to use software engineering skills like analyzing the codebase, researching technologies, running services, analyzing logs, etc. to complete the task. Not all tasks will be solvable by reading source code alone.

Agent Results

AgentTastefulBasicVerifierValidationRubricBloatPractTasteCheated
Oracle
5/51.0x5.04.0
GPT-5.5
4/51.3x5.04.0
Gemini 3.5 Flash
2/40.1x3.02.0
GLM-5.2
2/40.5x3.02.0
GPT-5.4
2/40.7x4.02.0
Kimi K2.6
2/40.4x4.02.0
Opus 4.7
2/40.3x3.03.0
Opus 4.8
2/40.1x2.02.0
Sonnet 4.6
2/40.7x2.02.0
Sonnet 5
2/40.2x2.02.0
Gemini 3.1 Pro
1/40.2x2.01.0
No-Op
2/4
Agent details

Verifier Tests

Gemini 3.1 Pro1/4

Taste Scores

Patch Bloat0.2x
56 agent / 302 oracle SLOC, 5 / 69 files(raw: 0.4x)
Practice Alignment — 2.0/5
3
style consistency
2
pattern adherence
2
library usage
2
abstraction level
5
documentation fit
Relative Taste — 1.0/5
1
minimality
1
approach quality
1
hygiene
2
fluency
1
craftsmanship

Agent Patch