Repository navigation
Description
Problem or Motivation
The commit hooks are slow, and the pre-push hooks catch too little.
- The commit stage takes 4.4 s for 3 Python files at load 11, and 12-16 s at load 13-31.
ast-grep-scanscans all ofsrcandtestsat each commit (4.6-5.2 s).ast-grep-testruns at each commit. - Ruff has two pins: the
ruff-pre-commitrev anduv.lock. They were different from 2026-09-18 to 2026-09-28. pre-commit-hooksis at v5.0.0. v6.0.0 is out since 2025-08-09.language: systemis the old name ofunsupported(pre-commit 4.4.0). 17stages: [pre-commit]lines repeat the default.- The pre-push stage runs only
lintandformat. In 14 days, 6 agent Static Analysis failures failed only in the rowsconstructs,swallowed-failures,depsoruv-check. 3 of the 4constructsfailures came from rules that landed onmainthe same day, which only a check after the rebase catches.
Proposed Solution & Architectural Design
Commit stage
ast-grep-scantakes the staged Python files ofsrc/andtests/(files: ^(src|tests)/,types: [python]), not the whole tree.ast-grep-testruns only when.ast-grep/orsgconfig.ymlchanges (pass_filenames: false).ruff-checkandruff-formatbecome local hooks withuv run --no-sync ruff ..., souv.lockis the one pin. The ast-grep hooks also use--no-sync.openspec-gatekeeps plainuv runand runsdevops ci --only openspec --timeout 90. In a worktree with no synced venv,--no-syncruns thedevopsof the main venv.- Change
pre-commit-hooksto v6.0.0. - Use
language: unsupportedand addminimum_pre_commit_version: 4.4.0. - Delete the
stages: [pre-commit]lines that repeat the default.
Pre-push stage
devops-ci-pre-pushrunsuv run devops ci --check --only lint,format,constructs,swallowed-failures,deps,uv-check --timeout 60.- The workflows hook gets
--timeout 30. - The push gate hook of feat(git): refuse a push that does not hold origin/main #4670 stays the first pre-push hook.
Remove constructs from CONST_ROADMAP_IMPLEMENT_SCOPED_ROWS (src/devops_cli/config/constants.py), because the pre-push stage of the Job now runs it. #4635 changes the same constant.
The per-file ast-grep scan and the pre-push constructs row ship together, so the whole-tree scan still runs after each rebase.
Update CONTRIBUTING.md (the hook list), the local-runs line of ADR 0014 and tests/roadmap/test_roadmap_runner_tools.py.
Target Subsystem
SDLC, Git & PR Governance (.pre-commit-config.yaml, src/devops_cli/config/constants.py, CONTRIBUTING.md, ADR 0014).
Existing Tool Considered
pre-commit 4.6.2 keys (files, types, stages, minimum_pre_commit_version), ast-grep file arguments, uv run --no-sync and the devops ci rows. The change is configuration only. Rejected: prek (it saves 0.4-0.6 s for each commit after this change, and it is a 0.x tool in the commit gate of the Job). Cost (estimate): about 200,000 tokens and half a day to build, near 0 to keep.
Acceptance Criteria
- The commit stage on the same 3 Python files takes at most 2 s at a load under 12 (4.4 s today).
- The pre-push rows take at most 20 s warm on 16 CPUs and 25 s on 2 CPUs (11.6 s and 16.5 s measured).
- The structural test of feat(ci): devops ci ends each row at a time limit #4775 passes: the gate fetch (20 s) plus the rows (60 s) plus the workflows hook (30 s) plus the start time is under 120 s.
- The Job runs
constructsonce for each push. pre-commit run --all-filespasses onmainafter the change.
Dependencies
Source: #4771
Alternatives check of 2026-11-14: not-applicable.
Class: perf, no search.
Tool: none found.
Proposed design
Problem statement
The commit hooks are slow: ast-grep-scan scans all of src and tests, and ast-grep-test runs at each commit. Ruff has two pins, and the pre-push stage runs only lint and format. This change scans only staged files, runs ast-grep-test only on rule changes, makes Ruff local with uv run --no-sync, and adds the fast static rows to pre-push within the existing 94 s timeout budget.
Acceptance criteria
Requirement: Staged ast-grep scan
The ast-grep-scan hook SHALL pass only the staged Python files under src/ and tests/ to ast-grep.
Scenario: Three staged Python files
- WHEN
uv run pre-commit run ast-grep-scan --files src/devops_cli/config/constants.py tests/roadmap/implement/test_roadmap_implement_scoped_ci.py tests/gate/construct_gate.pyruns. - THEN The command exits 0 and its output names only the three given paths and no path outside them.
Requirement: Config-only ast-grep test
The ast-grep-test hook SHALL run only when .ast-grep/ or sgconfig.yml changes.
Scenario: Source-only commit
- WHEN
uv run pre-commit run ast-grep-test --files src/devops_cli/config/constants.pyruns. - THEN The command reports
(no files to check)Skippedforast-grep-testand exits 0.
Requirement: Single Ruff pin
The ruff-check and ruff-format hooks SHALL be local hooks that run uv run --no-sync ruff, so uv.lock is the only Ruff pin.
Scenario: Ruff hook command
- WHEN
uv run pre-commit run ruff-check --files src/devops_cli/config/constants.py --verboseanduv run pre-commit run ruff-format --files src/devops_cli/config/constants.py --verboserun. - THEN Both commands exit 0 and their output shows
uv run --no-sync ruffand noruff-pre-commitrev.
Requirement: No-sync ast-grep hooks
The ast-grep-scan and ast-grep-test hooks SHALL run ast-grep with uv run --no-sync.
Scenario: Ast-grep hook command
- WHEN
uv run pre-commit run ast-grep-scan --files src/devops_cli/config/constants.py --verboseanduv run pre-commit run ast-grep-test --files sgconfig.yml --verboserun. - THEN Both outputs show
uv run --no-sync ast-grepand nouv sync.
Requirement: OpenSpec gate timeout
The openspec-gate hook SHALL keep plain uv run and run timeout 90 uv run devops ci --only openspec.
Scenario: OpenSpec gate command
- WHEN
uv run pre-commit run openspec-gate --files src/devops_cli/config/constants.py --verboseruns. - THEN The output shows
timeout 90 uv run devops ci --only openspecand contains no--no-syncand no--timeout.
Requirement: Hook configuration validation
The configuration SHALL set minimum_pre_commit_version to 4.4.0, use language: unsupported for local hooks, and keep pre-commit-hooks at v6.0.0.
Scenario: Config validation
- WHEN
uv run pre-commit validate-configruns. - THEN The command exits 0 and reports the configuration as valid.
Requirement: Default stage cleanup
The configuration MUST remove the stages: [pre-commit] lines that repeat the default stage.
Scenario: Default stage run
- WHEN
uv run pre-commit run --all-filesruns. - THEN Every hook runs at its default stage and the command exits 0.
Requirement: Pre-push fast rows
The devops-ci-pre-push hook SHALL run timeout 40 uv run devops ci --check --only lint,format,constructs,swallowed-failures,deps,uv-check,domain and keep UV_MALWARE_CHECK=0.
Scenario: Pre-push row selection
- WHEN
uv run pre-commit run devops-ci-pre-push --hook-stage pre-push --files src/devops_cli/config/constants.py --verboseruns. - THEN The output shows the seven rows including
domain, thetimeout 40prefix, andUV_MALWARE_CHECK=0.
Requirement: Workflows timeout
The devops-ci-workflows-pre-push hook SHALL use timeout 30.
Scenario: Workflows hook timeout
- WHEN
uv run pre-commit run devops-ci-workflows-pre-push --hook-stage pre-push --files .github/workflows/ci.yml --verboseruns. - THEN The output shows
timeout 30and the command exits 0.
Requirement: Push gate first
The push gate hook of #4670 SHALL stay the first pre-push hook.
Scenario: Pre-push hook order
- WHEN
uv run pre-commit run --hook-stage pre-push --files src/devops_cli/config/constants.py --verboseruns. - THEN The output lists the push gate hook before
devops-ci-pre-push.
Requirement: Constructs once per push
The roadmap Job SHALL run constructs once for each push after constructs leaves CONST_ROADMAP_IMPLEMENT_SCOPED_ROWS.
Scenario: Scoped rows test
- WHEN
uv run pytest tests/roadmap/implement/test_roadmap_implement_scoped_ci.py -qruns. - THEN The test passes and asserts that
constructsis not inCONST_ROADMAP_IMPLEMENT_SCOPED_ROWS.
Requirement: Pre-push budget
The sum of the pre-push hook timeouts and the 25 s outside-hook time MUST stay under the 120 s agent shell limit.
Scenario: Workflow contracts test
- WHEN
uv run pytest tests/invariants/test_workflow_contracts.py -qruns. - THEN The test passes and the sum of the
branch-current,devops-ci-pre-pushanddevops-ci-workflows-pre-pushtimeouts plus 25 s is less than 120 s.
Requirement: Gate structural budget
The structural test of #4775 SHALL pass with the gate fetch, the rows, the workflows hook and the start time under 120 seconds.
Scenario: Gate structural test
- WHEN
uv run pytest tests/gate/construct_gate.py -qruns. - THEN The test passes and its measured total is under 120 seconds.
Requirement: All files pass
pre-commit run --all-files MUST pass on main after the change.
Scenario: All-files run
- WHEN
uv run pre-commit run --all-filesruns onmainafter the change. - THEN Every hook passes and the command exits 0.
Requirement: Pending a person after the merge
A person SHALL verify the hook documentation and the timing budgets after the merge.
Scenario: Post-merge hook review
- WHEN A person reviews
CONTRIBUTING.mdand ADR 0014 and runs the three-file commit and warm pre-push benchmarks after the merge. - THEN The documents name the new hooks, the commit stage takes at most 2 s at load under 12, and the pre-push rows take at most 30 s on 16 CPUs and 40 s on 2 CPUs.
Existing Tool Considered
The alternatives check of 2026-11-14 records not-applicable for this perf item and names no tool (see the alternatives block in the issue body). The change uses existing pre-commit, ast-grep-cli, uv and devops ci configuration. It builds no new code. The written build cost is zero tokens and zero elapsed time.
Key questions
- How does the proposal handle the newer merged work that already changed the hook configuration?: Keep
pre-commit-hooksat v6.0.0, keep thedomainrow andUV_MALWARE_CHECK=0, and updatetests/gate/construct_gate.pyfor the new command. (best practice) [sources: .pre-commit-config.yaml, tests/gate/construct_gate.py:372-403, src/devops_cli/config/constants.py:4083, tests/roadmap/implement/test_roadmap_implement_scoped_ci.py]- Chosen: Adapt to current configuration. The reply shows v6.0.0, domain and UV_MALWARE_CHECK=0 are already merged. The change keeps them and updates the construct gate test.
- Rejected: Use the older body state. It would downgrade v6.0.0 and drop the domain row and the malware-check setting.
- Which files should
ast-grep-scanreceive at commit time?: Pass only the staged Python files undersrc/andtests/. Setfilesto^(src|tests)/,typesto[python], and update the construct gate test. (best practice) [sources: .pre-commit-config.yaml, tests/gate/construct_gate.py:372-403, sgconfig.yml]- Chosen: Staged Python files under src/ and tests/. This cuts the whole-tree scan. ast-grep accepts file arguments, and the construct gate test changes with the hook.
- Rejected: Whole src/ and tests/ tree. This scans unchanged files and keeps the slow commit stage.
- When should
ast-grep-testrun?: Run it only when.ast-grep/orsgconfig.ymlchanges. Setpass_filenamesfalse and afilespattern for those paths. (best practice) [sources: .pre-commit-config.yaml, sgconfig.yml]- Chosen: Only on .ast-grep/ or sgconfig.yml changes. No rule changes on a source-only commit.
- Rejected: Every commit. It adds a full test run to commits that do not change rules.
- How should Ruff be pinned?: Use local hooks with
uv run --no-sync ruff checkanduv run --no-sync ruff format.uv.lockis the only pin. (best practice) [sources: .pre-commit-config.yaml, uv.lock]- Chosen: Local uv hooks with --no-sync. This removes the second pin and the drift.
- Rejected: Keep the ruff-pre-commit rev. Two pins can differ and do not update together.
- Should the ast-grep hooks use
uv run --no-sync?: Yes. Runuv run --no-sync ast-grepand keep the existingUV_MALWARE_CHECK=0setting. (best practice) [sources: .pre-commit-config.yaml]- Chosen: Use --no-sync. It removes the uv sync and its OSV malware query from the commit path.
- Rejected: Keep plain uv run. A network fault can stop a commit.
- Should
openspec-gatekeep plainuv run?: Yes. Keep plainuv runand prefix the command with coreutilstimeout 90:timeout 90 uv run devops ci --only openspec. Do not use--timeout. (best practice) [sources: .pre-commit-config.yaml, tests/invariants/test_workflow_contracts.py]- Chosen: Keep plain uv run with coreutils timeout 90. The gate must use the devops of the worktree or the main venv as it does today, and
devops cihas no--timeoutoption. - Rejected: Use --no-sync. It can run the wrong devops in a worktree with no synced venv.
- Rejected: Use --timeout 90.
devops cihas no--timeoutoption, and the invariant test rejects flags absent fromdevops ci.
- Chosen: Keep plain uv run with coreutils timeout 90. The gate must use the devops of the worktree or the main venv as it does today, and
- Should
constructsleaveCONST_ROADMAP_IMPLEMENT_SCOPED_ROWS?: Yes. Removeconstructsfrom the constant because the pre-push hook runs it once for each push. (best practice) [sources: src/devops_cli/config/constants.py:4083, tests/roadmap/implement/test_roadmap_implement_scoped_ci.py, .pre-commit-config.yaml]- Chosen: Remove constructs from scoped rows. The pre-push row runs constructs once. The Job must not run it again.
- Rejected: Keep constructs in scoped rows. The Job would run constructs twice for each push.
- Which rows should the pre-push stage run, and with what timeout?: Run
lint,format,constructs,swallowed-failures,deps,uv-check,domainwith coreutilstimeout 40andUV_MALWARE_CHECK=0. Keep the workflows hook attimeout 30and the push gate first. (best practice) [sources: .pre-commit-config.yaml, docs/adr/0014-required-checks-gate-the-merge-and-the-pre-push-hook-runs-the-fast-static-checks.md, tests/invariants/test_workflow_contracts.py:218-239]- Chosen: Seven fast rows including domain with timeout 40. The domain row is security-critical and already in the pre-push hook. The other rows caught six agent failures in 14 days. The sum of timeouts stays at 94 s, and 94 + 25 = 119 < 120.
- Rejected: Six rows without domain. It would drop the security-critical domain row.
- Rejected: Use --timeout 60.
devops cihas no--timeoutoption, and 60 + 24 + 30 + 25 = 139 >= 120 fails the pre-push budget test.
- Is
pre-commit-hooksv6.0.0 a change in this issue?: No. The repository already has v6.0.0. The change keeps it and does not downgrade. [sources: .pre-commit-config.yaml] - Which documents and tests must change with the hooks?: Update
CONTRIBUTING.md, the local-runs line of ADR 0014,tests/gate/construct_gate.py, andtests/roadmap/implement/test_roadmap_implement_scoped_ci.py. (best practice) [sources: CONTRIBUTING.md, docs/adr/0014-required-checks-gate-the-merge-and-the-pre-push-hook-runs-the-fast-static-checks.md, tests/gate/construct_gate.py:372-403, tests/roadmap/implement/test_roadmap_implement_scoped_ci.py]- Chosen: Update docs and both tests. The hook list, the construct gate command and the scoped rows must match the new config.
- Rejected: Change only .pre-commit-config.yaml. The docs and tests would state the old hooks.
- How does the proposal stay within the pre-push timeout budget?: Keep
devops-ci-pre-pushattimeout 40,branch-currentattimeout 24, anddevops-ci-workflows-pre-pushattimeout 30. The sum is 94 s, and 94 + 25 = 119 < 120. (best practice) [sources: tests/invariants/test_workflow_contracts.py:218-239, .pre-commit-config.yaml]- Chosen: Keep the current 94 s sum. The invariant test requires the sum plus 25 s to be under 120 s. The current hooks already use the full budget.
- Rejected: Raise devops-ci-pre-push to 60 s. 60 + 24 + 30 + 25 = 139 >= 120 fails the test, and lowering the threshold is forbidden.
- How does the proposal replace the invalid
--timeoutflag?: Prefix each command with coreutilstimeout <N>, such astimeout 40 uv run devops ci ...ortimeout 90 uv run devops ci .... Do not pass--timeouttodevops ci. (best practice) [sources: tests/invariants/test_workflow_contracts.py, .pre-commit-config.yaml]- Chosen: Use coreutils timeout prefix.
devops cihas no--timeoutoption, and the invariant test rejects flags absent fromdevops ci. - Rejected: Use --timeout 60.
devops cihas no--timeoutoption.
- Chosen: Use coreutils timeout prefix.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
perfprefix of the title gives the type.(ci)scope of the title gives the scope.Improves hook speed and adds pre-push checks, but the system is functional today and no user is blocked.Cuts commit-hook time from 4.4 s to under 2 s and catches constructs and deps failures before push.Configuration-only edits to .pre-commit-config.yaml, one constant, and docs; estimated half a day.Both make pre-commit and pre-push checks faster, but #256 adds a caching engine while this candidate scopes existing hooks to staged files and adds new pre-push rows.dan-petty commentedon Nov 11, 2026
More evidence for the
--no-syncitem of this issue.On 2026-11-11, a commit in a worktree failed in the
ast-grep-scanhook. The hook runsuv run ast-grep scan .... WithUV_MALWARE_CHECK=1, the sync ofuv runsends a query to OSV, and the DNS lookup failed:The same commit passed at the second try. So a fault of the network stops a commit.
uv run --no-syncin the ast-grep hooks, as this issue plans, removes the sync and its query. #1667 made the same change for thestructural-invariantshook.devops-cli-service commentedon Nov 14, 2026
Alternatives check: not-applicable
Class: perf. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 15, 2026
Status set to Ready at e5dfddb (see proposed design in issue body).
dan-petty commentedon Nov 28, 2026
Premise conflict: newer merged work (#4881, #5295, and v6.0.0) changed .pre-commit-config.yaml and tests/gate/construct_gate.py. Specifically: (1) tests/gate/construct_gate.py:372-403 asserts ast-grep-scan exact command ['uv', 'run', 'ast-grep', *CONST_AST_GREP_SCAN_ARGS] (which includes 'src tests'), rejecting --no-sync and staged-file-only args; (2) #5295 added the security-critical 'domain' row to devops-ci-pre-push, whereas the proposed row list omits 'domain'; (3) #4881 added 'env UV_MALWARE_CHECK=0'; and (4) pre-commit-hooks is already v6.0.0.
4 remaining items
devops-cli-service commentedon Nov 28, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
dan-petty commentedon Nov 29, 2026
Returning
#4776tostatus/newwith evidence (AGENTS.mdrule 2: cannot be built as specified):--timeoutCLI option: RequirementsOpenSpec gate sync,Pre-push fast rows, andWorkflows timeoutspecify runninguv run devops ci ... --timeout 60/--timeout 90/--timeout 30.uv run devops ci --helphas no--timeoutoption;#5031(1fa4e9cdb, closes#4775) deliberately rejected--timeoutin favor of coreutilstimeout <N>, andtests/invariants/test_workflow_contracts.py(test_every_devops_command_the_workflows_actions_and_hooks_run_resolves&test_the_pre_push_hooks_end_before_the_agent_shell_limit) rejects flags absent fromdevops ciand requirestimeout <N>.#4775/#6190pre-push timeout budget:tests/invariants/test_workflow_contracts.py:218-239requiressum(pre-push timeouts) + PUSH_OUTSIDE_HOOKS_SECONDS (25) < AGENT_SHELL_LIMIT_SECONDS (120)(cap94 s). Currentorigin/mainalready uses the full budget:branch-current(timeout 24,#6190) +devops-ci-pre-push(timeout 40) +devops-ci-workflows-pre-push(timeout 30) =94 s(119 s < 120 s). A60 sbudget fordevops-ci-pre-pushplus24 s+30 s+25 s=139 s >= 120 s, failingtest_the_pre_push_hooks_end_before_the_agent_shell_limitwithout lowering the threshold (forbidden byAGENTS.mdrule 5).Please re-refine
#4776around coreutilstimeoutlimits within the94 spre-push sum (for instance, keepingtimeout 40after checking 2-CPU runtime margin — measured24.38sreal /22sgate elapsed for all 7 rows on idle 16 CPUs — or splitting commit-stage hook speedups from pre-push row additions).devops-cli-service commentedon Nov 29, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 29, 2026
Released in v0.248.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.248.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:50 UTC