A software development agent uses Claude to autonomously write, test, and commit code changes. During a session, the agent writes a new authentication module, runs tests (all passing), and commits to the main branch. A security researcher later discovers the module contains a subtle timing attack vulnerability that passed all tests. The agent's action log shows it made 23 tool calls across 45 minutes before committing. What architectural safeguard should have prevented the autonomous commit to main?
Select an answer to reveal the explanation.
Short Explanation
Here's the deal — you restrict the commit tool to feature branches only. That makes direct commits to main architecturally impossible, forcing every change through a pull request, CI/CD, code review, and security scanning before it reaches main.
Full Explanation
The correct architectural safeguard is restricting the commit tool to a feature branch only, with commits to main requiring a separate pull request tool that triggers CI/CD, code review, and security scanning before merging. This makes direct main commits architecturally impossible and creates a mandatory process gate: every code change must go through pull request, CI/CD, code review, and security scanning before reaching main. This is not about the agent's capability to detect vulnerabilities; it's about enforcing the same process gates that human developers use. A timing attack vulnerability that evades automated testing is exactly the type of issue that needs human code review or specialized security tooling in a pull request gate. The pre-commit hooks approach, which runs static analysis and security scanning tools before any commit tool call executes, is a good defense layer, but the claim that the scanner would have detected a subtle timing attack is not reliable because timing attack detection in static analysis is notoriously difficult. Pre-commit hooks are also bypassable in some git configurations. The security review agent approach, which analyzes all code changes for vulnerabilities before the commit tool is called and requires approval to unlock the commit tool, adds an AI security reviewer, but an AI reviewer of AI-generated code has the same blind spots; Claude reviewing Claude's timing attack vulnerability may miss it. The human-in-the-loop confirmation approach, where the agent proposes a commit with a diff summary and a human approves before the commit tool executes, is overly restrictive for an autonomous development agent; it defeats the autonomy purpose for low-risk changes and creates a bottleneck. Branch restriction with a proper pull request process is the industry-standard balance.