Implementation Plan: Fix Pre-Existing Clippy Errors Blocking PR #2971
Status: Draft
Research Doc: docs/research/pr-2971-merge-block-research.md
Author: OpenCode (Terraphim AI agent)
Date: 2026-06-25
Estimated Effort: 1–2 hours (implementation + verification + merge coordination)
Overview
Summary
Fix four pre-existing Clippy lint errors in three workspace crates so that cargo clippy --workspace --all-targets -- -D warnings passes. Once the fixes land on main, rebase PR #2971 so its required native-ci / build (push) status turns green and the PR can merge.
Approach
Apply minimal, semantically equivalent fixes for each lint error:
- Convert runtime
assert!s on constants into compile-timeconst { assert!(...) }blocks interraphim_merge_coordinator. - Move
build_router_for_testsinterraphim_serverto appear before themod testsblock. - Remove the vacuous
assert!(true)interraphim_validationwhile keeping the test that exercisesValidationSystem::new().
Scope
In Scope:
- Fix
clippy::assertions_on_constantsincrates/terraphim_merge_coordinator/src/gitea.rs. - Fix
clippy::items_after_test_moduleinterraphim_server/src/lib.rs. - Fix
clippy::assertions_on_constantsincrates/terraphim_validation/src/lib.rs. - Local verification with
cargo fmt,cargo clippy, andcargo build. - Rebase PR #2971 onto the fixed
main. - Confirm PR #2971's native CI run succeeds.
Out of Scope:
- Changes to the
native-ci.ymlworkflow. - Fixing the
rch::hookpath-normalisation warning. - Broader lint or refactor work across the workspace.
- Changes to ADF review agents or their status checks.
Avoid At All Cost (from 5/25 analysis):
- Forcing a merge through admin override while the required check is red.
- Silencing Clippy globally with
#![allow(...)]instead of fixing the root cause. - Expanding the PR into unrelated refactoring.
Architecture
Component Diagram
+----------------------------+
| terraphim_merge_coordinator |
| (const assertions) |
+----------------------------+
|
+----------------------------+
| terraphim_server |
| (test helper reordering) |
+----------------------------+
|
+----------------------------+
| terraphim_validation |
| (remove vacuous assert) |
+----------------------------+
|
+----------------------------+
| native CI (Gitea Actions) |
| native-ci / build (push) |
+----------------------------+
|
+----------------------------+
| PR #2971 merge gate |
+----------------------------+Data Flow
- Developer creates fix branch from
main. - Apply the three code changes.
- Run local format/lint/build verification.
- Push fix branch, open PR, merge to
main. - Rebase PR #2971 branch onto updated
main. - Native CI runs automatically on the rebased push.
- PR #2971 becomes mergeable.
Key Design Decisions
| Decision | Rationale | Alternatives Rejected |
|----------|-----------|----------------------|
| Use const { assert!(...) } for const invariants | Preserves the intent (compile-time failure if the constant violates the rule) and satisfies Clippy. | static_assertions::const_assert! — adds a dependency when std syntax is sufficient. |
| Move build_router_for_tests above mod tests | Directly addresses clippy::items_after_test_module without adding #[allow(...)]. | #[allow(clippy::items_after_test_module)] — hides the lint rather than fixing structure. |
| Remove assert!(true) but keep the test body | The test still exercises ValidationSystem::new().unwrap(); the assertion added no value. | assert!(!system.orchestrator.is_none()) — no such method exists and would be speculative. |
Eliminated Options (Essentialism)
| Option Rejected | Why Rejected | Risk of Including |
|-----------------|--------------|-------------------|
| Admin override merge of PR #2971 | Violates branch protection and sets a bad precedent. | Erodes CI authority; future PRs may expect the same override. |
| #![allow(clippy::assertions_on_constants)] at crate level | Masks real issues and contradicts the -D warnings policy. | Technical debt accumulates; other const-assert mistakes go undetected. |
| #[allow(clippy::items_after_test_module)] on build_router_for_tests | Hides structural issue; test helpers should live outside the test module. | Makes the file harder to navigate and maintain. |
| Broad cargo clippy --fix across workspace | Could introduce unrelated changes and extend scope. | Risk of hidden regressions and a larger review surface. |
Simplicity Check
"Minimum code that solves the problem. Nothing speculative."
What if this could be easy?
The easiest fix is four small edits: two const { assert!(...) } blocks, one function move, and one deleted line. No new dependencies, no workflow changes, no admin overrides.
Senior Engineer Test: A senior engineer would recognise these as straightforward lint fixes, not over-engineering.
Nothing Speculative Checklist:
- [x] No features the user didn't request
- [x] No abstractions "in case we need them later"
- [x] No flexibility "just in case"
- [x] No error handling for scenarios that cannot occur
- [x] No premature optimization
File Changes
Modified Files
| File | Changes |
|------|---------|
| crates/terraphim_merge_coordinator/src/gitea.rs | Replace two runtime assert!s on OPEN_PRS_LIMIT with const { assert!(...) } blocks. |
| terraphim_server/src/lib.rs | Move build_router_for_tests to before mod tests. |
| crates/terraphim_validation/src/lib.rs | Remove assert!(true); while retaining ValidationSystem::new().unwrap(). |
No New or Deleted Files
No new modules or deleted files are required.
API Design
No public API changes. All edits are internal to test code or const validation.
Test Strategy
Verification Commands
| Test | Command | Purpose |
|------|---------|---------|
| Format check | cargo fmt --all -- --check | Ensures no formatting regressions. |
| Lint check | cargo clippy --workspace --all-targets -- -D warnings | Confirms the four errors are gone and no new ones appear. |
| Build check | cargo build --workspace | Confirms the workspace still compiles. |
| Unit tests (workspace lib) | cargo test --workspace --lib --no-fail-fast | Confirms the changed tests still pass. |
| Gitea-runner tests | cargo test -p terraphim_gitea_runner --no-fail-fast | Matches the native CI test step. |
Expected Outcomes
- All five commands above exit 0.
- The two
terraphim_merge_coordinatorconst assertions still fail at compile time ifOPEN_PRS_LIMITis changed to an invalid value. terraphim_serverintegration tests that usebuild_router_for_testscontinue to compile and pass.terraphim_validation::tests::test_validation_system_creationcontinues to exerciseValidationSystem::new().
Implementation Steps
Step 1: Create Fix Branch
Files: N/A
Description: Create a branch from latest main for the lint fixes.
Command: git checkout -b task/fix-clippy-errors-blocking-ci
Tests: N/A
Estimated: 2 minutes
Step 2: Fix Const Assertions in terraphim_merge_coordinator
Files: crates/terraphim_merge_coordinator/src/gitea.rs
Description: Replace the two runtime assert!s with compile-time const { assert!(...) } blocks.
Tests: cargo clippy -p terraphim_merge_coordinator --all-targets -- -D warnings
Estimated: 10 minutes
// Before
// After
Step 3: Reorder Test Helper in terraphim_server
Files: terraphim_server/src/lib.rs
Description: Move build_router_for_tests and its doc comment from after mod tests to before it.
Tests: cargo clippy -p terraphim_server --all-targets -- -D warnings
Estimated: 15 minutes
Key move:
/// Constructs a minimal Axum router suitable for integration tests.
pub async
Step 4: Remove Vacuous Assertion in terraphim_validation
Files: crates/terraphim_validation/src/lib.rs
Description: Remove assert!(true); while keeping the call to ValidationSystem::new().unwrap().
Tests: cargo clippy -p terraphim_validation --all-targets -- -D warnings
Estimated: 5 minutes
// Before
async
// After
async Step 5: Local Verification
Files: All touched crates Description: Run the exact commands used by native CI to confirm the workspace is clean. Commands:
Estimated: 20–40 minutes (build/test time dominates)
Step 6: Commit and Push Fix Branch
Files: N/A
Description: Commit the changes with a clear message referencing the CI unblock.
Command: git commit -am "fix(ci): resolve clippy errors blocking native-ci build Refs #2492"
Estimated: 5 minutes
Step 7: Open and Merge Fix PR
Files: N/A
Description: Create a PR on Gitea, wait for native CI to pass, then merge to main.
Command: gtr create-pull --owner terraphim --repo terraphim-ai --title "fix(ci): resolve clippy errors blocking native-ci build" --base main --head task/fix-clippy-errors-blocking-ci
Estimated: 15 minutes (mostly CI wait)
Step 8: Rebase PR #2971
Files: N/A
Description: Update PR #2971's branch so it includes the fixed main.
Commands:
Estimated: 5 minutes
Step 9: Confirm PR #2971 CI Passes and Merge
Files: N/A
Description: Wait for the new native CI run on PR #2971, confirm native-ci / build (push) is green, then merge.
Command: gtr merge-pull --owner terraphim --repo terraphim-ai --index 2971
Estimated: 10 minutes (CI wait)
Rollback Plan
If any step causes unexpected failures:
- Revert the fix PR on
mainusinggit revert <merge-commit>. - Push the revert to both remotes (
originthengitea). - Re-open PR #2971 if it was merged prematurely.
There are no feature flags involved.
Dependencies
New Dependencies
None.
Dependency Updates
None.
Performance Considerations
No runtime performance impact. The changes are in test code and const validation.
Open Items
| Item | Status | Owner | |------|--------|-------| | Human approval of this plan | Pending | Alex / reviewer | | Local verification on fix branch | Pending | Implementer | | Native CI pass on fix PR | Pending | CI system | | Rebase PR #2971 | Pending | Implementer | | Merge PR #2971 | Pending | Implementer / maintainer |
Approval
- [ ] Technical review complete
- [ ] Test strategy approved
- [ ] Human approval received