-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
185 lines (169 loc) · 7.96 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
185 lines (169 loc) · 7.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# Repo-wide pre-commit gate: lint (ruff) + types (pyright) + tests (pytest).
#
# Each Python package (ultan at the repo root, daemon, tools/search) has its
# own uv venv and its own pyproject.toml config. ruff is shared via the upstream
# pre-commit repo; pyright and pytest run as local hooks so they pick up each
# package's venv.
#
# Pyright runs on staged files only — existing baseline issues in
# untouched files don't block commits, but touching a file forces cleanup.
# ruff (check --fix and format) runs on the WHOLE package tree per commit
# so pre-existing format/lint drift on unrelated files can't slip past
# `ruff format --check .` in CI. pytest runs the full package suite at
# pre-push so a fast local edit/commit loop isn't blocked by the suite.
#
# Install once per clone: uv tool install pre-commit && pre-commit install
# (installs both pre-commit and pre-push git hooks, per the list below)
# Run on the whole repo: pre-commit run --all-files
default_install_hook_types: [pre-commit, pre-push]
repos:
- repo: local
hooks:
# Ruff per package — runs on the whole package tree (pass_filenames:
# false) so untouched files with pre-existing drift get auto-fixed,
# not just the staged set. Matches what CI does. If the hook
# modifies any files, pre-commit fails the commit so the user
# re-stages and commits again — standard auto-fix flow.
- id: ruff-check-daemon
name: ruff check (daemon)
language: system
entry: bash -c 'cd daemon && uv run --frozen ruff check --fix'
files: ^daemon/.*\.py$
pass_filenames: false
stages: [pre-commit]
- id: ruff-format-daemon
name: ruff format (daemon)
language: system
entry: bash -c 'cd daemon && uv run --frozen ruff format'
files: ^daemon/.*\.py$
pass_filenames: false
stages: [pre-commit]
- id: ruff-check-tools-search
name: ruff check (tools/search)
language: system
entry: bash -c 'cd tools/search && uv run --frozen ruff check --fix'
files: ^tools/search/.*\.py$
pass_filenames: false
stages: [pre-commit]
- id: ruff-format-tools-search
name: ruff format (tools/search)
language: system
entry: bash -c 'cd tools/search && uv run --frozen ruff format'
files: ^tools/search/.*\.py$
pass_filenames: false
stages: [pre-commit]
# ultan = the repo-root package. Run from the root (no cd); the root
# ruff config excludes the other members, so `.` is exactly ultan/ + tests/.
- id: ruff-check-ultan
name: ruff check (ultan)
language: system
entry: bash -c 'uv run --frozen ruff check --fix .'
files: ^(ultan/|tests/).*\.py$
pass_filenames: false
stages: [pre-commit]
- id: ruff-format-ultan
name: ruff format (ultan)
language: system
entry: bash -c 'uv run --frozen ruff format .'
files: ^(ultan/|tests/).*\.py$
pass_filenames: false
stages: [pre-commit]
# Pyright per package. Pre-commit passes repo-relative paths; we strip
# the leading "<pkg>/" so pyright (running with cwd=<pkg>) gets the
# package-relative paths it expects.
- id: pyright-daemon
name: pyright (daemon)
language: system
entry: bash -c 'cd daemon && uv run --frozen pyright "${@#daemon/}"' --
files: ^daemon/.*\.py$
pass_filenames: true
stages: [pre-commit]
- id: pyright-tools-search
name: pyright (tools/search)
language: system
entry: bash -c 'cd tools/search && uv run --frozen pyright "${@#tools/search/}"' --
files: ^tools/search/.*\.py$
pass_filenames: true
stages: [pre-commit]
# ultan runs from the repo root (the pyright config's include=["ultan"]
# IS the root package), so staged paths need no prefix strip.
- id: pyright-ultan
name: pyright (ultan)
language: system
entry: bash -c 'uv run --frozen pyright "${@}"' --
files: ^ultan/.*\.py$
pass_filenames: true
stages: [pre-commit]
# Duplicate-code (copy-paste) detection per package, via pylint's
# R0801 check — the only pylint rule we enable. Like ruff, it runs on
# the WHOLE package tree (pass_filenames: false) because the
# similarity checker only finds copies among the files in a single
# run; a staged-only subset would compare a file against itself.
# Threshold + ignore knobs live in each package's
# [tool.pylint.similarities]. --fail-on forces a non-zero exit on a
# finding (symilar would always exit 0).
- id: duplicate-code-daemon
name: duplicate-code (daemon)
language: system
entry: bash -c 'cd daemon && find . -name "*.py" -not -path "./.venv/*" -print0 | xargs -0 uv run --frozen pylint --disable=all --enable=duplicate-code --fail-on=duplicate-code'
files: ^daemon/.*\.py$
pass_filenames: false
stages: [pre-commit]
- id: duplicate-code-tools-search
name: duplicate-code (tools/search)
language: system
entry: bash -c 'cd tools/search && find . -name "*.py" -not -path "./.venv/*" -print0 | xargs -0 uv run --frozen pylint --disable=all --enable=duplicate-code --fail-on=duplicate-code'
files: ^tools/search/.*\.py$
pass_filenames: false
stages: [pre-commit]
- id: duplicate-code-ultan
name: duplicate-code (ultan)
language: system
entry: bash -c 'find ultan -name "*.py" -not -path "*/.venv/*" -print0 | xargs -0 uv run --frozen pylint --disable=all --enable=duplicate-code --fail-on=duplicate-code'
files: ^ultan/.*\.py$
pass_filenames: false
stages: [pre-commit]
# Pytest per package — runs at pre-push, not pre-commit. Full suite,
# only when something in that package changed since the last push.
- id: pytest-daemon
name: pytest (daemon)
language: system
entry: bash -c 'cd daemon && uv run --frozen pytest'
files: ^daemon/
pass_filenames: false
stages: [pre-push]
- id: pytest-tools-search
name: pytest (tools/search)
language: system
entry: bash -c 'cd tools/search && uv run --frozen pytest'
files: ^tools/search/
pass_filenames: false
stages: [pre-push]
- id: pytest-root
name: pytest (root ultan package)
language: system
entry: bash -c 'uv run --frozen pytest'
files: ^(ultan/|tests/|pyproject\.toml)
pass_filenames: false
stages: [pre-push]
# Behavioural evals for the curator agents (Librarian/Scholar). Plain
# pytest tests under daemon/evals/ (outside testpaths, so a normal pytest
# run never collects them), but they make REAL agent calls through the
# Claude Code subscription (claude_agent_sdk — never the metered API), so
# they're pre-push only and gated to the files that define curator
# behaviour: a doc/typo push never spins them up. --no-cov because the
# daemon's 90%-coverage gate would fail an eval-only run. Each case is a
# clear-cut situation (dedupe an existing rule; file an explicit /ultan
# memory) scored on the agent's typed output. See daemon/evals/README.md.
#
# Skip a one-off push: SKIP=ultan-agent-evals git push
# Skip always (env): ULTAN_SKIP_EVALS=1 git push
# A wrong answer (failed assert) blocks the push; an infra hiccup
# (timeout / transport / not authenticated) is a pytest skip, not a fail.
- id: ultan-agent-evals
name: ultan agent evals (subscription; dedupe + write)
language: system
entry: bash -c 'cd daemon && uv run --frozen pytest evals/ --no-cov -n auto'
files: ^daemon/(agent_mem_daemon/(librarian|scholar|librarian_prompt|scholar_prompt|_schemas|typed_agent|_agent_research)\.py|evals/(.*\.py|corpus/.*))$
pass_filenames: false
stages: [pre-push]