claude-dev-env 2.27.0 → 2.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/hitl/SKILL.md +45 -0
- package/.agents/skills-archived/pr-loop-cloud-transport/reference/identity-and-hooks.md +1 -1
- package/audit-rubrics/category_rubrics/category-o-docstring-vs-impl-drift.md +16 -29
- package/audit-rubrics/prompts/category-o-docstring-vs-impl-drift.md +2 -2
- package/bin/ever-shipped-skills.mjs +1 -0
- package/docs/CODE_RULES.md +3 -3
- package/docs/agent-spawn-protocol.md +1 -1
- package/docs/references/prose-style-enforcement.md +5 -9
- package/hooks/blocking/AGENTS.md +3 -13
- package/hooks/blocking/code_rules_docstrings.py +10 -2138
- package/hooks/blocking/code_rules_enforcer.py +0 -121
- package/hooks/blocking/code_rules_imports_logging.py +1 -236
- package/hooks/blocking/code_rules_shared.py +23 -0
- package/hooks/blocking/code_rules_test_layout.py +8 -8
- package/hooks/blocking/config/prose_style_enforcement_constants.py +4 -2
- package/hooks/blocking/config/test_prose_style_enforcement_constants.py +5 -1
- package/hooks/blocking/precommit_code_rules_gate.py +8 -43
- package/hooks/blocking/state_description_blocker.py +1 -7
- package/hooks/blocking/test_code_rules_enforcer_cap_meta.py +0 -1
- package/hooks/blocking/test_code_rules_enforcer_dispatch_wiring.py +0 -8
- package/hooks/blocking/test_code_rules_enforcer_module_docstring_roster.py +11 -112
- package/hooks/blocking/test_code_rules_enforcer_narrow_edit.py +0 -1
- package/hooks/blocking/test_code_rules_enforcer_split_entry_1.py +1 -18
- package/hooks/blocking/test_code_rules_shared.py +12 -0
- package/hooks/blocking/test_precommit_code_rules_gate.py +32 -179
- package/hooks/blocking/test_precommit_code_rules_gate_native_owner.py +0 -1
- package/hooks/blocking/test_state_description_blocker.py +6 -4
- package/hooks/blocking/test_stop_dispatcher.py +5 -29
- package/hooks/hooks_constants/AGENTS.md +1 -6
- package/hooks/hooks_constants/bash_pre_tool_use_dispatcher_constants.py +0 -1
- package/hooks/hooks_constants/code_rules_enforcer_constants.py +3 -0
- package/hooks/hooks_constants/messages.py +0 -2
- package/hooks/hooks_constants/precommit_code_rules_gate_constants.py +3 -17
- package/hooks/hooks_constants/stop_dispatcher_constants.py +0 -2
- package/hooks/hooks_constants/test_bash_pre_tool_use_dispatcher_constants.py +0 -1
- package/hooks/hooks_constants/test_code_rules_enforcer_constants.py +7 -0
- package/hooks/hooks_constants/test_messages.py +5 -3
- package/hooks/hooks_constants/test_stop_dispatcher_constants.py +0 -2
- package/package.json +1 -1
- package/rules/AGENTS.md +3 -6
- package/rules/claims-as-quotes.md +0 -10
- package/rules/code-standards.md +6 -6
- package/rules/explore-thoroughly.md +0 -1
- package/rules/failure-blast-radius.md +0 -8
- package/rules/falsify-before-green.md +0 -8
- package/rules/file-global-constants.md +2 -2
- package/rules/filesystem-search.md +1 -1
- package/rules/git-workflow.md +1 -9
- package/rules/hedging-claims.md +2 -6
- package/rules/long-horizon-autonomy.md +1 -1
- package/rules/measurement-denominators.md +0 -9
- package/rules/research-mode.md +0 -6
- package/rules/verify-before-asking.md +0 -5
- package/rules/verify-runtime-state.md +0 -5
- package/scripts/codex_compat_materializer.py +99 -24
- package/scripts/sync_to_cursor/rules.py +0 -10
- package/scripts/tests/test_codex_compat_materializer.py +70 -19
- package/scripts/tests/test_engine.py +0 -1
- package/scripts/tests/test_rules.py +0 -1
- package/scripts/tests/test_sync_to_cursor.py +0 -1
- package/system-prompts/software-engineer.xml +3 -3
- package/hooks/blocking/code_rules_dead_argparse_argument.py +0 -554
- package/hooks/blocking/code_rules_dead_config_field.py +0 -568
- package/hooks/blocking/code_rules_dead_dataclass_field.py +0 -348
- package/hooks/blocking/code_rules_dead_module_constant.py +0 -757
- package/hooks/blocking/code_rules_dead_split_branch.py +0 -225
- package/hooks/blocking/code_rules_mock_completeness.py +0 -295
- package/hooks/blocking/code_rules_scope_binding.py +0 -151
- package/hooks/blocking/code_rules_unused_imports.py +0 -197
- package/hooks/blocking/hedging_language_blocker.py +0 -221
- package/hooks/blocking/intent_only_ending_blocker.py +0 -148
- package/hooks/blocking/test_code_rules_enforcer_dead_argparse_argument.py +0 -534
- package/hooks/blocking/test_code_rules_enforcer_dead_config_field.py +0 -846
- package/hooks/blocking/test_code_rules_enforcer_dead_dataclass_field.py +0 -507
- package/hooks/blocking/test_code_rules_enforcer_dead_module_constant.py +0 -679
- package/hooks/blocking/test_code_rules_enforcer_dead_module_constant_alias.py +0 -133
- package/hooks/blocking/test_code_rules_enforcer_dead_module_constant_read_cap.py +0 -103
- package/hooks/blocking/test_code_rules_enforcer_dead_split_branch.py +0 -105
- package/hooks/blocking/test_code_rules_enforcer_docstring_args_span_scope.py +0 -425
- package/hooks/blocking/test_code_rules_enforcer_docstring_cardinal_family.py +0 -176
- package/hooks/blocking/test_code_rules_enforcer_docstring_delegation_summary.py +0 -385
- package/hooks/blocking/test_code_rules_enforcer_docstring_fallback_branch.py +0 -398
- package/hooks/blocking/test_code_rules_enforcer_docstring_field_runmode_outcome.py +0 -129
- package/hooks/blocking/test_code_rules_enforcer_docstring_inline_literal_claim.py +0 -93
- package/hooks/blocking/test_code_rules_enforcer_docstring_length_constant_superlative.py +0 -198
- package/hooks/blocking/test_code_rules_enforcer_docstring_mark_glyph_enumeration.py +0 -262
- package/hooks/blocking/test_code_rules_enforcer_docstring_no_consumer.py +0 -93
- package/hooks/blocking/test_code_rules_enforcer_docstring_no_network.py +0 -115
- package/hooks/blocking/test_code_rules_enforcer_docstring_raises_largezipfile.py +0 -226
- package/hooks/blocking/test_code_rules_enforcer_docstring_returns_plural_cardinality.py +0 -207
- package/hooks/blocking/test_code_rules_enforcer_docstring_step_dispatch.py +0 -262
- package/hooks/blocking/test_code_rules_enforcer_docstring_type_checking_gate.py +0 -164
- package/hooks/blocking/test_code_rules_enforcer_docstring_unguarded_payload.py +0 -188
- package/hooks/blocking/test_code_rules_enforcer_import_block_sort.py +0 -157
- package/hooks/blocking/test_code_rules_enforcer_split_mocks_1.py +0 -303
- package/hooks/blocking/test_code_rules_enforcer_split_mocks_2.py +0 -111
- package/hooks/blocking/test_code_rules_enforcer_unused_imports.py +0 -656
- package/hooks/blocking/test_hedging_language_blocker.py +0 -261
- package/hooks/blocking/test_intent_only_ending_blocker.py +0 -209
- package/hooks/hooks_constants/dead_argparse_argument_constants.py +0 -28
- package/hooks/hooks_constants/dead_config_field_constants.py +0 -39
- package/hooks/hooks_constants/dead_dataclass_field_constants.py +0 -25
- package/hooks/hooks_constants/dead_module_constant_constants.py +0 -30
- package/hooks/hooks_constants/hedging_uncertainty_constants.py +0 -42
- package/hooks/hooks_constants/test_dispatcher_constants_docstrings.py +0 -44
- package/rules/conservative-action.md +0 -17
- package/rules/context7.md +0 -8
- package/rules/few-words.md +0 -3
- package/rules/parallel-tools.md +0 -23
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
"""Tests for check_docstring_delegation_summary_enumeration_drift (O6).
|
|
2
|
-
|
|
3
|
-
A thin wrapper docstring that enumerates its actions and points at the home
|
|
4
|
-
of the real body drifts when the same-named function in that named neighbor
|
|
5
|
-
carries a summary enumeration omitting one of those actions. The gate fires
|
|
6
|
-
from both sides: saving the wrapper compares it against the named neighbor on
|
|
7
|
-
disk, and saving the delegated body compares it against every neighboring
|
|
8
|
-
wrapper docstring pointing at it.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
from __future__ import annotations
|
|
12
|
-
|
|
13
|
-
import importlib.util
|
|
14
|
-
import sys
|
|
15
|
-
from pathlib import Path
|
|
16
|
-
from types import ModuleType
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def _load_enforcer_module() -> ModuleType:
|
|
20
|
-
module_path = Path(__file__).parent / "code_rules_enforcer.py"
|
|
21
|
-
spec = importlib.util.spec_from_file_location("code_rules_enforcer", module_path)
|
|
22
|
-
assert spec is not None
|
|
23
|
-
assert spec.loader is not None
|
|
24
|
-
module = importlib.util.module_from_spec(spec)
|
|
25
|
-
spec.loader.exec_module(module)
|
|
26
|
-
return module
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
code_rules_enforcer = _load_enforcer_module()
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def check_docstring_delegation_summary_enumeration_drift(
|
|
33
|
-
content: str, file_path: str
|
|
34
|
-
) -> list[str]:
|
|
35
|
-
return code_rules_enforcer.check_docstring_delegation_summary_enumeration_drift(
|
|
36
|
-
content, file_path
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def validate_content(content: str, file_path: str, old_content: str) -> list[str]:
|
|
41
|
-
return code_rules_enforcer.validate_content(content, file_path, old_content)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
HOOK_INFRASTRUCTURE_PATH = "/home/user/.claude/hooks/blocking/example.py"
|
|
45
|
-
TARGET_FLOW_STEM = "listing_edit_flow"
|
|
46
|
-
PROCESSOR_FILE_NAME = "portal_processor.py"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def _drifted_processor_source() -> str:
|
|
50
|
-
return (
|
|
51
|
-
"class PortalProcessor:\n"
|
|
52
|
-
" async def _refresh_store_sections(self, page: object) -> bool:\n"
|
|
53
|
-
' """Apply App Info, Russia, review note, publication edits;'
|
|
54
|
-
" full doc on ``listing_edit_flow``.\"\"\"\n"
|
|
55
|
-
" return await _refresh_store_sections(self, page)\n"
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def _matching_processor_source() -> str:
|
|
60
|
-
return (
|
|
61
|
-
"class PortalProcessor:\n"
|
|
62
|
-
" async def _refresh_store_sections(self, page: object) -> bool:\n"
|
|
63
|
-
' """Apply Russia, review note, publication edits;'
|
|
64
|
-
" full doc on ``listing_edit_flow``.\"\"\"\n"
|
|
65
|
-
" return await _refresh_store_sections(self, page)\n"
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def _target_flow_source() -> str:
|
|
70
|
-
return (
|
|
71
|
-
"async def _refresh_store_sections(processor: object, page: object) -> bool:\n"
|
|
72
|
-
' """Apply Russia uncheck, review note, and Publication edits.\n'
|
|
73
|
-
"\n"
|
|
74
|
-
" The App Info edit runs earlier in the binary phase and never\n"
|
|
75
|
-
" repeats here.\n"
|
|
76
|
-
' """\n'
|
|
77
|
-
" return True\n"
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def _target_flow_plain_summary() -> str:
|
|
82
|
-
return (
|
|
83
|
-
"async def _refresh_store_sections(processor: object, page: object) -> bool:\n"
|
|
84
|
-
' """Drive one theme end to end."""\n'
|
|
85
|
-
" return True\n"
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def _create_target_flow(directory: Path, source: str) -> Path:
|
|
90
|
-
created_path = directory / (TARGET_FLOW_STEM + ".py")
|
|
91
|
-
created_path.write_text(source, encoding="utf-8")
|
|
92
|
-
return created_path
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def test_should_flag_listed_action_absent_from_the_named_neighbor(tmp_path: Path) -> None:
|
|
96
|
-
_create_target_flow(tmp_path, _target_flow_source())
|
|
97
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
98
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
99
|
-
_drifted_processor_source(), checked_path
|
|
100
|
-
)
|
|
101
|
-
assert any("App Info" in each for each in issues), (
|
|
102
|
-
f"Expected 'App Info' to be flagged, got: {issues!r}"
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def test_should_pass_matching_summaries(tmp_path: Path) -> None:
|
|
107
|
-
_create_target_flow(tmp_path, _target_flow_source())
|
|
108
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
109
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
110
|
-
_matching_processor_source(), checked_path
|
|
111
|
-
)
|
|
112
|
-
assert issues == [], f"Aligned summaries pass, got: {issues!r}"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
def test_should_flag_saved_body_that_strands_a_pointing_neighbor(tmp_path: Path) -> None:
|
|
116
|
-
checked_path = tmp_path / PROCESSOR_FILE_NAME
|
|
117
|
-
checked_path.write_text(_drifted_processor_source(), encoding="utf-8")
|
|
118
|
-
created_path = str(tmp_path / (TARGET_FLOW_STEM + ".py"))
|
|
119
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
120
|
-
_target_flow_source(), created_path
|
|
121
|
-
)
|
|
122
|
-
assert any(
|
|
123
|
-
"App Info" in each and PROCESSOR_FILE_NAME in each for each in issues
|
|
124
|
-
), f"Expected the stranded caller to be flagged, got: {issues!r}"
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def test_should_pass_plain_one_purpose_summary(tmp_path: Path) -> None:
|
|
128
|
-
_create_target_flow(tmp_path, _target_flow_plain_summary())
|
|
129
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
130
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
131
|
-
_drifted_processor_source(), checked_path
|
|
132
|
-
)
|
|
133
|
-
assert issues == [], (
|
|
134
|
-
f"A comma-free summary compares against nothing, got: {issues!r}"
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
def test_should_pass_when_the_named_neighbor_does_not_exist(tmp_path: Path) -> None:
|
|
139
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
140
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
141
|
-
_drifted_processor_source(), checked_path
|
|
142
|
-
)
|
|
143
|
-
assert issues == [], f"Nothing on disk to compare against, got: {issues!r}"
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def test_should_pass_single_listed_action(tmp_path: Path) -> None:
|
|
147
|
-
_create_target_flow(tmp_path, _target_flow_source())
|
|
148
|
-
solo_source = (
|
|
149
|
-
"class PortalProcessor:\n"
|
|
150
|
-
" async def _refresh_store_sections(self, page: object) -> bool:\n"
|
|
151
|
-
' """Apply the App Info edit;'
|
|
152
|
-
" full doc on ``listing_edit_flow``.\"\"\"\n"
|
|
153
|
-
" return await _refresh_store_sections(self, page)\n"
|
|
154
|
-
)
|
|
155
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
156
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
157
|
-
solo_source, checked_path
|
|
158
|
-
)
|
|
159
|
-
assert issues == [], f"A lone named action never fires, got: {issues!r}"
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
def test_should_skip_strict_test_paths(tmp_path: Path) -> None:
|
|
163
|
-
_create_target_flow(tmp_path, _target_flow_source())
|
|
164
|
-
skipped_path = str(tmp_path / "test_portal_processor.py")
|
|
165
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
166
|
-
_drifted_processor_source(), skipped_path
|
|
167
|
-
)
|
|
168
|
-
assert issues == [], f"Exempt, got: {issues!r}"
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
def test_should_skip_hook_infrastructure() -> None:
|
|
172
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
173
|
-
_drifted_processor_source(), HOOK_INFRASTRUCTURE_PATH
|
|
174
|
-
)
|
|
175
|
-
assert issues == [], f"Exempt, got: {issues!r}"
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
def test_should_handle_syntax_error_gracefully(tmp_path: Path) -> None:
|
|
179
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
180
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
181
|
-
"def fetch(\n", checked_path
|
|
182
|
-
)
|
|
183
|
-
assert issues == [], f"A syntax error yields no issues, got: {issues!r}"
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
def test_should_handle_unparseable_neighbor(tmp_path: Path) -> None:
|
|
187
|
-
_create_target_flow(tmp_path, "def broken(\n")
|
|
188
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
189
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
190
|
-
_drifted_processor_source(), checked_path
|
|
191
|
-
)
|
|
192
|
-
assert issues == [], f"Unparseable neighbors yield no issues, got: {issues!r}"
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
def test_validate_content_surfaces_the_drift(tmp_path: Path) -> None:
|
|
196
|
-
_create_target_flow(tmp_path, _target_flow_source())
|
|
197
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
198
|
-
issues = validate_content(_drifted_processor_source(), checked_path, old_content="")
|
|
199
|
-
matching_issues = [each for each in issues if "App Info" in each and "O6" in each]
|
|
200
|
-
assert matching_issues, (
|
|
201
|
-
f"Expected validate_content to surface the O6 finding, got: {issues!r}"
|
|
202
|
-
)
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
def _drifted_processor_source_with_wrapped_summary() -> str:
|
|
206
|
-
return (
|
|
207
|
-
"class PortalProcessor:\n"
|
|
208
|
-
" async def _refresh_store_sections(self, page: object) -> bool:\n"
|
|
209
|
-
' """Apply App Info, Russia, review note, publication\n'
|
|
210
|
-
" edits; full doc on ``listing_edit_flow``.\"\"\"\n"
|
|
211
|
-
" return await _refresh_store_sections(self, page)\n"
|
|
212
|
-
)
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
def test_should_flag_listed_action_when_the_summary_wraps_a_physical_line(
|
|
216
|
-
tmp_path: Path,
|
|
217
|
-
) -> None:
|
|
218
|
-
_create_target_flow(tmp_path, _target_flow_source())
|
|
219
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
220
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
221
|
-
_drifted_processor_source_with_wrapped_summary(), checked_path
|
|
222
|
-
)
|
|
223
|
-
assert any("App Info" in each for each in issues), (
|
|
224
|
-
f"A summary wrapped onto a second physical line still names 'App Info', "
|
|
225
|
-
f"got: {issues!r}"
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
def _drifted_processor_source_with_capitalized_and_uneven_whitespace() -> str:
|
|
230
|
-
return (
|
|
231
|
-
"class PortalProcessor:\n"
|
|
232
|
-
" async def _refresh_store_sections(self, page: object) -> bool:\n"
|
|
233
|
-
' """Apply App Info, Russia, review note, And publication'
|
|
234
|
-
" edits; full doc on ``listing_edit_flow``.\"\"\"\n"
|
|
235
|
-
" return await _refresh_store_sections(self, page)\n"
|
|
236
|
-
)
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
def test_should_flag_listed_action_when_the_conjunction_is_capitalized_with_uneven_whitespace(
|
|
240
|
-
tmp_path: Path,
|
|
241
|
-
) -> None:
|
|
242
|
-
_create_target_flow(tmp_path, _target_flow_source())
|
|
243
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
244
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
245
|
-
_drifted_processor_source_with_capitalized_and_uneven_whitespace(), checked_path
|
|
246
|
-
)
|
|
247
|
-
assert any("App Info" in each for each in issues), (
|
|
248
|
-
f"A capitalized 'And' with uneven whitespace still splits into its own "
|
|
249
|
-
f"listed entry, got: {issues!r}"
|
|
250
|
-
)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
def _write_filler_neighbor_modules(directory: Path, filler_count: int) -> None:
|
|
254
|
-
for each_index in range(filler_count):
|
|
255
|
-
filler_path = directory / f"filler_module_{each_index:03d}.py"
|
|
256
|
-
filler_path.write_text("PLACEHOLDER_VALUE = 1\n", encoding="utf-8")
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
def test_should_stop_scanning_neighbors_past_the_configured_limit(
|
|
260
|
-
tmp_path: Path,
|
|
261
|
-
) -> None:
|
|
262
|
-
neighbor_scan_limit = sys.modules["code_rules_docstrings"].NEIGHBOR_SCAN_FILE_LIMIT
|
|
263
|
-
_write_filler_neighbor_modules(tmp_path, filler_count=neighbor_scan_limit + 5)
|
|
264
|
-
stranded_wrapper_path = tmp_path / "zzz_stranded_processor.py"
|
|
265
|
-
stranded_wrapper_path.write_text(_drifted_processor_source(), encoding="utf-8")
|
|
266
|
-
created_path = str(tmp_path / (TARGET_FLOW_STEM + ".py"))
|
|
267
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
268
|
-
_target_flow_source(), created_path
|
|
269
|
-
)
|
|
270
|
-
assert issues == [], (
|
|
271
|
-
"The alphabetically-last wrapper sits past the neighbor scan limit, so "
|
|
272
|
-
f"the scan must stop before reaching it, got: {issues!r}"
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
def test_should_still_flag_a_stranded_wrapper_within_the_scan_limit(
|
|
277
|
-
tmp_path: Path,
|
|
278
|
-
) -> None:
|
|
279
|
-
neighbor_scan_limit = sys.modules["code_rules_docstrings"].NEIGHBOR_SCAN_FILE_LIMIT
|
|
280
|
-
stranded_wrapper_path = tmp_path / "aaa_stranded_processor.py"
|
|
281
|
-
stranded_wrapper_path.write_text(_drifted_processor_source(), encoding="utf-8")
|
|
282
|
-
_write_filler_neighbor_modules(tmp_path, filler_count=neighbor_scan_limit + 5)
|
|
283
|
-
created_path = str(tmp_path / (TARGET_FLOW_STEM + ".py"))
|
|
284
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
285
|
-
_target_flow_source(), created_path
|
|
286
|
-
)
|
|
287
|
-
assert any(
|
|
288
|
-
"App Info" in each and "aaa_stranded_processor.py" in each for each in issues
|
|
289
|
-
), (
|
|
290
|
-
"The alphabetically-first wrapper sits within the neighbor scan limit "
|
|
291
|
-
f"and stays flagged even with extra filler neighbors, got: {issues!r}"
|
|
292
|
-
)
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
def _target_flow_source_with_nested_duplicate_name() -> str:
|
|
296
|
-
return (
|
|
297
|
-
"async def _refresh_store_sections(processor: object, page: object) -> bool:\n"
|
|
298
|
-
' """Apply Russia uncheck, review note, and Publication edits.\n'
|
|
299
|
-
"\n"
|
|
300
|
-
" The App Info edit runs earlier in the binary phase and never\n"
|
|
301
|
-
" repeats here.\n"
|
|
302
|
-
' """\n'
|
|
303
|
-
" return True\n"
|
|
304
|
-
"\n"
|
|
305
|
-
"\n"
|
|
306
|
-
"def _outer_helper() -> bool:\n"
|
|
307
|
-
" def _refresh_store_sections() -> bool:\n"
|
|
308
|
-
' """A same-named nested helper that must not shadow the'
|
|
309
|
-
' top-level entry."""\n'
|
|
310
|
-
" return True\n"
|
|
311
|
-
"\n"
|
|
312
|
-
" return _refresh_store_sections()\n"
|
|
313
|
-
)
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
def test_should_not_let_a_nested_duplicate_name_hide_the_top_level_entry(
|
|
317
|
-
tmp_path: Path,
|
|
318
|
-
) -> None:
|
|
319
|
-
_create_target_flow(tmp_path, _target_flow_source_with_nested_duplicate_name())
|
|
320
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
321
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
322
|
-
_drifted_processor_source(), checked_path
|
|
323
|
-
)
|
|
324
|
-
assert any("App Info" in each for each in issues), (
|
|
325
|
-
"A nested helper sharing the top-level function's name must not "
|
|
326
|
-
f"delete the top-level entry from comparison, got: {issues!r}"
|
|
327
|
-
)
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
def _processor_source_with_nested_pointer_wrapper() -> str:
|
|
331
|
-
return (
|
|
332
|
-
"class PortalProcessor:\n"
|
|
333
|
-
" async def _refresh_store_sections(self, page: object) -> bool:\n"
|
|
334
|
-
' """Drive one theme end to end."""\n'
|
|
335
|
-
" return True\n"
|
|
336
|
-
"\n"
|
|
337
|
-
" def _run_nested_helper(self) -> bool:\n"
|
|
338
|
-
" async def _refresh_store_sections() -> bool:\n"
|
|
339
|
-
' """Apply App Info, Russia, review note, publication'
|
|
340
|
-
' edits; full doc on ``listing_edit_flow``.\"\"\"\n'
|
|
341
|
-
" return True\n"
|
|
342
|
-
" return True\n"
|
|
343
|
-
)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
def test_should_not_flag_a_nested_wrapper_pointing_at_a_delegate(
|
|
347
|
-
tmp_path: Path,
|
|
348
|
-
) -> None:
|
|
349
|
-
_create_target_flow(tmp_path, _target_flow_source())
|
|
350
|
-
checked_path = str(tmp_path / PROCESSOR_FILE_NAME)
|
|
351
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
352
|
-
_processor_source_with_nested_pointer_wrapper(), checked_path
|
|
353
|
-
)
|
|
354
|
-
assert issues == [], (
|
|
355
|
-
"A function-local wrapper is not a top-level function or class "
|
|
356
|
-
f"method, so it must never be compared, got: {issues!r}"
|
|
357
|
-
)
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
def _neighbor_source_with_nested_pointer_wrapper() -> str:
|
|
361
|
-
return (
|
|
362
|
-
"def _run_nested_helper() -> bool:\n"
|
|
363
|
-
" async def _refresh_store_sections() -> bool:\n"
|
|
364
|
-
' """Apply App Info, Russia, review note, publication edits;'
|
|
365
|
-
' full doc on ``listing_edit_flow``.\"\"\"\n'
|
|
366
|
-
" return True\n"
|
|
367
|
-
" return True\n"
|
|
368
|
-
)
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
def test_should_not_flag_a_nested_neighbor_wrapper_as_a_stranded_caller(
|
|
372
|
-
tmp_path: Path,
|
|
373
|
-
) -> None:
|
|
374
|
-
neighbor_path = tmp_path / "portal_helpers.py"
|
|
375
|
-
neighbor_path.write_text(
|
|
376
|
-
_neighbor_source_with_nested_pointer_wrapper(), encoding="utf-8"
|
|
377
|
-
)
|
|
378
|
-
created_path = str(tmp_path / (TARGET_FLOW_STEM + ".py"))
|
|
379
|
-
issues = check_docstring_delegation_summary_enumeration_drift(
|
|
380
|
-
_target_flow_source(), created_path
|
|
381
|
-
)
|
|
382
|
-
assert issues == [], (
|
|
383
|
-
"A function-local wrapper in a neighbor module is not a pointing "
|
|
384
|
-
f"caller, so it must never be treated as stranded, got: {issues!r}"
|
|
385
|
-
)
|