@openai/codex-security 0.1.30 → 0.2.0

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.
Files changed (320) hide show
  1. package/README.md +386 -37
  2. package/_bundled_plugin/.mcp.json +1 -0
  3. package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
  4. package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +4 -4
  5. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  6. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  7. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  8. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  9. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  10. package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
  11. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  12. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  13. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  14. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  15. package/_bundled_plugin/references/artifact-storage.md +4 -4
  16. package/_bundled_plugin/references/config-preflight.md +1 -1
  17. package/_bundled_plugin/references/core-scan.md +14 -2
  18. package/_bundled_plugin/references/final-report.md +4 -2
  19. package/_bundled_plugin/references/scan-artifacts.md +2 -2
  20. package/_bundled_plugin/references/scan-contract.md +2 -2
  21. package/_bundled_plugin/references/threat-model.md +2 -2
  22. package/_bundled_plugin/schemas/coverage.schema.json +22 -0
  23. package/_bundled_plugin/schemas/scan-manifest.schema.json +100 -85
  24. package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +19 -4
  25. package/_bundled_plugin/schemas/tools/scan-draft.schema.json +116 -102
  26. package/_bundled_plugin/scripts/config_preflight.py +4 -8
  27. package/_bundled_plugin/scripts/deep_scan_workbench.py +83 -217
  28. package/_bundled_plugin/scripts/filesystem_identity.py +1 -5
  29. package/_bundled_plugin/scripts/finalize_scan_contract.py +441 -166
  30. package/_bundled_plugin/scripts/finding_preview.py +42 -82
  31. package/_bundled_plugin/scripts/generate_in_scope_files.py +30 -34
  32. package/_bundled_plugin/scripts/generate_rank_input.py +58 -99
  33. package/_bundled_plugin/scripts/launch_codex_security_mcp +5 -1
  34. package/_bundled_plugin/scripts/rank_preview.py +86 -68
  35. package/_bundled_plugin/scripts/report_projection.py +37 -58
  36. package/_bundled_plugin/scripts/threat_model_projection.py +164 -0
  37. package/_bundled_plugin/scripts/windows_scan_local_files.py +11 -6
  38. package/_bundled_plugin/scripts/workbench/storage.py +11 -0
  39. package/_bundled_plugin/scripts/workbench_cli.py +11 -17
  40. package/_bundled_plugin/scripts/workbench_constants.py +6 -14
  41. package/_bundled_plugin/scripts/workbench_db.py +116 -228
  42. package/_bundled_plugin/scripts/workbench_finding_index.py +1 -6
  43. package/_bundled_plugin/scripts/workbench_native_indexes.py +1 -4
  44. package/_bundled_plugin/scripts/workbench_progress.py +12 -34
  45. package/_bundled_plugin/scripts/workbench_publication.py +47 -62
  46. package/_bundled_plugin/scripts/workbench_remediation.py +2 -20
  47. package/_bundled_plugin/scripts/workbench_saved_results.py +1246 -230
  48. package/_bundled_plugin/scripts/workbench_scan_start.py +4 -11
  49. package/_bundled_plugin/scripts/workbench_scan_usage.py +7 -15
  50. package/_bundled_plugin/scripts/workbench_schema.py +86 -271
  51. package/_bundled_plugin/scripts/workbench_severity.py +3 -0
  52. package/_bundled_plugin/scripts/workbench_source_excerpt.py +5 -6
  53. package/_bundled_plugin/scripts/workbench_target.py +98 -10
  54. package/_bundled_plugin/scripts/workbench_target_state.py +1 -5
  55. package/_bundled_plugin/scripts/workbench_validation.py +6 -20
  56. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +3 -3
  57. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +3 -3
  58. package/_bundled_plugin/skills/security-scan/SKILL.md +2 -2
  59. package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +2 -2
  60. package/_bundled_plugin/skills/threat-model/SKILL.md +2 -2
  61. package/dist/api.d.ts +3 -5
  62. package/dist/api.d.ts.map +1 -1
  63. package/dist/api.js +201 -207
  64. package/dist/api.js.map +1 -1
  65. package/dist/artifact-export.d.ts +70 -0
  66. package/dist/artifact-export.d.ts.map +1 -0
  67. package/dist/artifact-export.js +277 -0
  68. package/dist/artifact-export.js.map +1 -0
  69. package/dist/auth.d.ts.map +1 -1
  70. package/dist/auth.js +9 -4
  71. package/dist/auth.js.map +1 -1
  72. package/dist/bulk-scan-discovery.d.ts +1 -0
  73. package/dist/bulk-scan-discovery.d.ts.map +1 -1
  74. package/dist/bulk-scan-discovery.js +8 -9
  75. package/dist/bulk-scan-discovery.js.map +1 -1
  76. package/dist/classify-scan-severity.d.ts.map +1 -1
  77. package/dist/classify-scan-severity.js +2 -5
  78. package/dist/classify-scan-severity.js.map +1 -1
  79. package/dist/classify-severity.d.ts +2 -8
  80. package/dist/classify-severity.d.ts.map +1 -1
  81. package/dist/classify-severity.js +3 -5
  82. package/dist/classify-severity.js.map +1 -1
  83. package/dist/cli-help.d.ts +3 -0
  84. package/dist/cli-help.d.ts.map +1 -0
  85. package/dist/cli-help.js +281 -0
  86. package/dist/cli-help.js.map +1 -0
  87. package/dist/cli.d.ts +21 -22
  88. package/dist/cli.d.ts.map +1 -1
  89. package/dist/cli.js +673 -701
  90. package/dist/cli.js.map +1 -1
  91. package/dist/cloud-publish.d.ts.map +1 -1
  92. package/dist/cloud-publish.js +1 -8
  93. package/dist/cloud-publish.js.map +1 -1
  94. package/dist/codex-prompt.d.ts.map +1 -1
  95. package/dist/codex-prompt.js +1 -2
  96. package/dist/codex-prompt.js.map +1 -1
  97. package/dist/codex-sdk-environment.d.ts +2 -0
  98. package/dist/codex-sdk-environment.d.ts.map +1 -0
  99. package/dist/codex-sdk-environment.js +30 -0
  100. package/dist/codex-sdk-environment.js.map +1 -0
  101. package/dist/component-plan.d.ts.map +1 -1
  102. package/dist/component-plan.js +2 -6
  103. package/dist/component-plan.js.map +1 -1
  104. package/dist/component-scan.d.ts +1 -0
  105. package/dist/component-scan.d.ts.map +1 -1
  106. package/dist/component-scan.js +31 -9
  107. package/dist/component-scan.js.map +1 -1
  108. package/dist/config.d.ts.map +1 -1
  109. package/dist/config.js +32 -33
  110. package/dist/config.js.map +1 -1
  111. package/dist/contract.d.ts +2 -1
  112. package/dist/contract.d.ts.map +1 -1
  113. package/dist/contract.js +63 -122
  114. package/dist/contract.js.map +1 -1
  115. package/dist/cost-model.d.ts.map +1 -1
  116. package/dist/cost-model.js +65 -34
  117. package/dist/cost-model.js.map +1 -1
  118. package/dist/cost.d.ts.map +1 -1
  119. package/dist/cost.js +15 -31
  120. package/dist/cost.js.map +1 -1
  121. package/dist/custom-validation-prompt.js +4 -4
  122. package/dist/custom-validation-prompt.js.map +1 -1
  123. package/dist/custom-validation.d.ts.map +1 -1
  124. package/dist/custom-validation.js +17 -16
  125. package/dist/custom-validation.js.map +1 -1
  126. package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
  127. package/dist/deduplication/checkpointed-review.js +10 -11
  128. package/dist/deduplication/checkpointed-review.js.map +1 -1
  129. package/dist/deduplication/codex-review.d.ts +2 -0
  130. package/dist/deduplication/codex-review.d.ts.map +1 -1
  131. package/dist/deduplication/codex-review.js +3 -3
  132. package/dist/deduplication/codex-review.js.map +1 -1
  133. package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
  134. package/dist/deduplication/deduplication-reviewer.js +2 -0
  135. package/dist/deduplication/deduplication-reviewer.js.map +1 -1
  136. package/dist/deduplication/deduplication.js +40 -62
  137. package/dist/deduplication/deduplication.js.map +1 -1
  138. package/dist/deduplication/records-protocol.d.ts.map +1 -1
  139. package/dist/deduplication/records-protocol.js +1 -4
  140. package/dist/deduplication/records-protocol.js.map +1 -1
  141. package/dist/deduplication/records.d.ts +2 -1
  142. package/dist/deduplication/records.d.ts.map +1 -1
  143. package/dist/deduplication/records.js +24 -6
  144. package/dist/deduplication/records.js.map +1 -1
  145. package/dist/deduplication/review.d.ts +7 -0
  146. package/dist/deduplication/review.d.ts.map +1 -1
  147. package/dist/deduplication/review.js.map +1 -1
  148. package/dist/deduplication/scan.js +3 -7
  149. package/dist/deduplication/scan.js.map +1 -1
  150. package/dist/deep-config.d.ts.map +1 -1
  151. package/dist/deep-config.js +3 -19
  152. package/dist/deep-config.js.map +1 -1
  153. package/dist/deep-progress.d.ts +0 -1
  154. package/dist/deep-progress.d.ts.map +1 -1
  155. package/dist/deep-progress.js +22 -40
  156. package/dist/deep-progress.js.map +1 -1
  157. package/dist/errors.d.ts +3 -2
  158. package/dist/errors.d.ts.map +1 -1
  159. package/dist/errors.js +5 -7
  160. package/dist/errors.js.map +1 -1
  161. package/dist/finding-catalogue.d.ts.map +1 -1
  162. package/dist/finding-catalogue.js +22 -22
  163. package/dist/finding-catalogue.js.map +1 -1
  164. package/dist/finding-workflow.d.ts.map +1 -1
  165. package/dist/finding-workflow.js +4 -7
  166. package/dist/finding-workflow.js.map +1 -1
  167. package/dist/findings-import.d.ts.map +1 -1
  168. package/dist/findings-import.js +7 -17
  169. package/dist/findings-import.js.map +1 -1
  170. package/dist/github.d.ts.map +1 -1
  171. package/dist/github.js +2 -3
  172. package/dist/github.js.map +1 -1
  173. package/dist/import-scan.js +2 -2
  174. package/dist/import-scan.js.map +1 -1
  175. package/dist/index.d.ts +6 -2
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +3 -1
  178. package/dist/index.js.map +1 -1
  179. package/dist/knowledge-base.js +7 -3
  180. package/dist/knowledge-base.js.map +1 -1
  181. package/dist/linear.d.ts.map +1 -1
  182. package/dist/linear.js +2 -3
  183. package/dist/linear.js.map +1 -1
  184. package/dist/models.d.ts +24 -0
  185. package/dist/models.d.ts.map +1 -1
  186. package/dist/models.js.map +1 -1
  187. package/dist/multiscan.d.ts.map +1 -1
  188. package/dist/multiscan.js +36 -31
  189. package/dist/multiscan.js.map +1 -1
  190. package/dist/owner-evidence.d.ts +29 -0
  191. package/dist/owner-evidence.d.ts.map +1 -0
  192. package/dist/owner-evidence.js +192 -0
  193. package/dist/owner-evidence.js.map +1 -0
  194. package/dist/patch-tui.d.ts.map +1 -1
  195. package/dist/patch-tui.js +2 -4
  196. package/dist/patch-tui.js.map +1 -1
  197. package/dist/project-config-schema.d.ts +10 -0
  198. package/dist/project-config-schema.d.ts.map +1 -1
  199. package/dist/project-config-schema.js +1 -0
  200. package/dist/project-config-schema.js.map +1 -1
  201. package/dist/project-config.d.ts +1 -0
  202. package/dist/project-config.d.ts.map +1 -1
  203. package/dist/project-config.js +2 -0
  204. package/dist/project-config.js.map +1 -1
  205. package/dist/prompt-files.d.ts +0 -1
  206. package/dist/prompt-files.d.ts.map +1 -1
  207. package/dist/prompt-files.js +2 -4
  208. package/dist/prompt-files.js.map +1 -1
  209. package/dist/publication-events.d.ts.map +1 -1
  210. package/dist/publication-events.js +15 -29
  211. package/dist/publication-events.js.map +1 -1
  212. package/dist/publication-store.d.ts.map +1 -1
  213. package/dist/publication-store.js +9 -13
  214. package/dist/publication-store.js.map +1 -1
  215. package/dist/publication.d.ts.map +1 -1
  216. package/dist/publication.js +11 -14
  217. package/dist/publication.js.map +1 -1
  218. package/dist/publish.d.ts.map +1 -1
  219. package/dist/publish.js +31 -41
  220. package/dist/publish.js.map +1 -1
  221. package/dist/record.d.ts +2 -0
  222. package/dist/record.d.ts.map +1 -0
  223. package/dist/record.js +4 -0
  224. package/dist/record.js.map +1 -0
  225. package/dist/result.d.ts +4 -1
  226. package/dist/result.d.ts.map +1 -1
  227. package/dist/result.js +7 -0
  228. package/dist/result.js.map +1 -1
  229. package/dist/runtime.d.ts +10 -13
  230. package/dist/runtime.d.ts.map +1 -1
  231. package/dist/runtime.js +230 -145
  232. package/dist/runtime.js.map +1 -1
  233. package/dist/saved-scan.d.ts.map +1 -1
  234. package/dist/saved-scan.js +10 -20
  235. package/dist/saved-scan.js.map +1 -1
  236. package/dist/scan-activity.d.ts.map +1 -1
  237. package/dist/scan-activity.js +8 -22
  238. package/dist/scan-activity.js.map +1 -1
  239. package/dist/scan-comparison.d.ts +4 -4
  240. package/dist/scan-comparison.d.ts.map +1 -1
  241. package/dist/scan-comparison.js +38 -73
  242. package/dist/scan-comparison.js.map +1 -1
  243. package/dist/scan-dashboard.d.ts +0 -1
  244. package/dist/scan-dashboard.d.ts.map +1 -1
  245. package/dist/scan-dashboard.js +10 -19
  246. package/dist/scan-dashboard.js.map +1 -1
  247. package/dist/scan-history-renderer.d.ts.map +1 -1
  248. package/dist/scan-history-renderer.js +1 -2
  249. package/dist/scan-history-renderer.js.map +1 -1
  250. package/dist/scan-logs.d.ts.map +1 -1
  251. package/dist/scan-logs.js +2 -6
  252. package/dist/scan-logs.js.map +1 -1
  253. package/dist/scan-sessions.d.ts.map +1 -1
  254. package/dist/scan-sessions.js +1 -3
  255. package/dist/scan-sessions.js.map +1 -1
  256. package/dist/scan-settings.d.ts +5 -0
  257. package/dist/scan-settings.d.ts.map +1 -1
  258. package/dist/scan-settings.js +4 -0
  259. package/dist/scan-settings.js.map +1 -1
  260. package/dist/security-policy-cli.d.ts.map +1 -1
  261. package/dist/security-policy-cli.js +8 -6
  262. package/dist/security-policy-cli.js.map +1 -1
  263. package/dist/security-policy.d.ts +8 -4
  264. package/dist/security-policy.d.ts.map +1 -1
  265. package/dist/security-policy.js +98 -84
  266. package/dist/security-policy.js.map +1 -1
  267. package/dist/server/dashboard/app.js +5 -5
  268. package/dist/server/embeddings.d.ts.map +1 -1
  269. package/dist/server/embeddings.js +1 -0
  270. package/dist/server/embeddings.js.map +1 -1
  271. package/dist/server/routes.d.ts +3 -2
  272. package/dist/server/routes.d.ts.map +1 -1
  273. package/dist/server/routes.js +19 -7
  274. package/dist/server/routes.js.map +1 -1
  275. package/dist/server/server.d.ts.map +1 -1
  276. package/dist/server/server.js +2 -3
  277. package/dist/server/server.js.map +1 -1
  278. package/dist/server/sqlite-store.d.ts.map +1 -1
  279. package/dist/server/sqlite-store.js +4 -14
  280. package/dist/server/sqlite-store.js.map +1 -1
  281. package/dist/severity-store.js +8 -15
  282. package/dist/severity-store.js.map +1 -1
  283. package/dist/suggest-owners.d.ts +37 -0
  284. package/dist/suggest-owners.d.ts.map +1 -0
  285. package/dist/suggest-owners.js +111 -0
  286. package/dist/suggest-owners.js.map +1 -0
  287. package/dist/targets.d.ts +7 -2
  288. package/dist/targets.d.ts.map +1 -1
  289. package/dist/targets.js +29 -25
  290. package/dist/targets.js.map +1 -1
  291. package/dist/thread-source.d.ts +1 -0
  292. package/dist/thread-source.d.ts.map +1 -1
  293. package/dist/thread-source.js +1 -0
  294. package/dist/thread-source.js.map +1 -1
  295. package/dist/trusted-executable.d.ts +5 -0
  296. package/dist/trusted-executable.d.ts.map +1 -1
  297. package/dist/trusted-executable.js +22 -5
  298. package/dist/trusted-executable.js.map +1 -1
  299. package/dist/value.d.ts +2 -0
  300. package/dist/value.d.ts.map +1 -0
  301. package/dist/value.js +20 -0
  302. package/dist/value.js.map +1 -0
  303. package/dist/version.d.ts.map +1 -1
  304. package/dist/version.js +3 -6
  305. package/dist/version.js.map +1 -1
  306. package/dist/windows-path.d.ts.map +1 -1
  307. package/dist/windows-path.js +1 -2
  308. package/dist/windows-path.js.map +1 -1
  309. package/dist/worker-progress.d.ts +1 -0
  310. package/dist/worker-progress.d.ts.map +1 -1
  311. package/dist/worker-progress.js +13 -34
  312. package/dist/worker-progress.js.map +1 -1
  313. package/docs/dedupe-records.md +24 -0
  314. package/package.json +15 -13
  315. package/schemas/project-config.schema.json +5 -0
  316. package/_bundled_plugin/scripts/normalize_candidates.py +0 -338
  317. package/dist/server/findings-service.d.ts +0 -20
  318. package/dist/server/findings-service.d.ts.map +0 -1
  319. package/dist/server/findings-service.js +0 -31
  320. package/dist/server/findings-service.js.map +0 -1
@@ -11,22 +11,16 @@ import sqlite3
11
11
  import sys
12
12
  import tempfile
13
13
  import uuid
14
- from dataclasses import dataclass
15
14
  from datetime import datetime, timedelta
16
15
  from pathlib import Path
17
16
  from typing import Any, Callable
18
17
 
19
18
  sys.path.insert(0, str(Path(__file__).resolve().parent))
20
19
  from deep_scan_config import resolve_deep_scan_config
21
- from filesystem_identity import serialize_filesystem_identity
22
20
  from finalize_scan_contract import _read_scan_local_json
23
21
  from workbench.handoff import require_current_continuation
24
- from workbench_target import (
25
- directory_content_digest,
26
- directory_snapshot_regular_file_count,
27
- git_revision,
28
- worktree_content_digest,
29
- )
22
+ from workbench.storage import create_private_directory
23
+ from workbench_target import directory_snapshot_regular_file_count
30
24
  from workbench_validation import optional_text, require_uuid, user_context_argument
31
25
 
32
26
  DEEP_SCAN_WORKER_KINDS = ("setup", "discovery", "dedup")
@@ -136,42 +130,20 @@ def non_negative_int(value: str) -> int:
136
130
  return parsed
137
131
 
138
132
 
139
- @dataclass(frozen=True)
140
- class DeepScanDependencies:
141
- now: Callable[[], str]
142
- state_dir: Callable[[], Path]
143
- require_scan: Callable[[sqlite3.Connection, str], sqlite3.Row]
144
- require_workspace: Callable[[sqlite3.Connection, str], sqlite3.Row]
145
- require_target: Callable[[str], Path]
146
- require_remediation_target: Callable[[str], Path]
147
- require_scannable_target: Callable[[Path], None]
148
- require_scope: Callable[[str, str, Path], str]
149
- ensure_security_target: Callable[[sqlite3.Connection, str], str]
150
- require_canonical_scan_directory: Callable[[Path], Path]
151
- safe_segment: Callable[[str], str]
152
- compact_timestamp: Callable[[], str]
153
- scan_completion_lock: Callable[[str], Any]
154
- preserve_stopped_results: Callable[[sqlite3.Connection, str], None]
155
-
156
-
157
- _dependencies: DeepScanDependencies | None = None
133
+ _dependencies: Any = None
158
134
 
159
135
 
160
- def configure(dependencies: DeepScanDependencies) -> None:
136
+ def configure(dependencies: Any) -> None:
161
137
  global _dependencies
162
138
  _dependencies = dependencies
163
139
 
164
140
 
165
- def dependencies() -> DeepScanDependencies:
141
+ def dependencies() -> Any:
166
142
  if _dependencies is None:
167
143
  raise RuntimeError("Deep Scan workbench dependencies are not configured.")
168
144
  return _dependencies
169
145
 
170
146
 
171
- def now() -> str:
172
- return dependencies().now()
173
-
174
-
175
147
  def _bounded_error_text(message: str, maximum: int) -> str:
176
148
  if len(message) <= maximum:
177
149
  return message
@@ -206,54 +178,6 @@ def _parse_timestamp(value: str) -> datetime:
206
178
  return datetime.fromisoformat(value)
207
179
 
208
180
 
209
- def state_dir() -> Path:
210
- return dependencies().state_dir()
211
-
212
-
213
- def require_scan(connection: sqlite3.Connection, scan_id: str) -> sqlite3.Row:
214
- return dependencies().require_scan(connection, scan_id)
215
-
216
-
217
- def require_workspace(connection: sqlite3.Connection, workspace_id: str) -> sqlite3.Row:
218
- return dependencies().require_workspace(connection, workspace_id)
219
-
220
-
221
- def require_target(value: str) -> Path:
222
- return dependencies().require_target(value)
223
-
224
-
225
- def require_remediation_target(value: str) -> Path:
226
- return dependencies().require_remediation_target(value)
227
-
228
-
229
- def require_scannable_target(target: Path) -> None:
230
- dependencies().require_scannable_target(target)
231
-
232
-
233
- def require_scope(scope: str, mode: str, target: Path) -> str:
234
- return dependencies().require_scope(scope, mode, target)
235
-
236
-
237
- def ensure_security_target(connection: sqlite3.Connection, target_path: str) -> str:
238
- return dependencies().ensure_security_target(connection, target_path)
239
-
240
-
241
- def require_canonical_scan_directory(scan_dir: Path) -> Path:
242
- return dependencies().require_canonical_scan_directory(scan_dir)
243
-
244
-
245
- def safe_segment(value: str) -> str:
246
- return dependencies().safe_segment(value)
247
-
248
-
249
- def compact_timestamp() -> str:
250
- return dependencies().compact_timestamp()
251
-
252
-
253
- def scan_completion_lock(scan_id: str) -> Any:
254
- return dependencies().scan_completion_lock(scan_id)
255
-
256
-
257
181
  def require_deep_scan_run(connection: sqlite3.Connection, scan_id: str) -> sqlite3.Row:
258
182
  scan_id = require_uuid(scan_id, "scan-id")
259
183
  row = connection.execute(
@@ -265,7 +189,7 @@ def require_deep_scan_run(connection: sqlite3.Connection, scan_id: str) -> sqlit
265
189
 
266
190
 
267
191
  def deep_scan_deadline_reached(run: sqlite3.Row) -> bool:
268
- elapsed = _parse_timestamp(now()) - _parse_timestamp(str(run["created_at"]))
192
+ elapsed = _parse_timestamp(dependencies().now()) - _parse_timestamp(str(run["created_at"]))
269
193
  return elapsed.total_seconds() / 3600 >= run["max_time_hours"]
270
194
 
271
195
 
@@ -288,8 +212,8 @@ def require_deep_scan_ready_for_parent_completion(
288
212
  def require_owned_scan(
289
213
  connection: sqlite3.Connection, scan_id: str, thread_id: str
290
214
  ) -> tuple[sqlite3.Row, sqlite3.Row]:
291
- scan = require_scan(connection, scan_id)
292
- workspace = require_workspace(connection, scan["workspace_id"])
215
+ scan = dependencies().require_scan(connection, scan_id)
216
+ workspace = dependencies().require_workspace(connection, scan["workspace_id"])
293
217
  owner = optional_text(thread_id, maximum=512)
294
218
  if owner is None:
295
219
  raise SystemExit("thread-id is required.")
@@ -311,7 +235,7 @@ def deep_scan_path(
311
235
  raise SystemExit(f"{label} must be an absolute path inside the scan directory.")
312
236
  try:
313
237
  resolved = supplied.resolve(strict=True)
314
- scan_dir = require_canonical_scan_directory(Path(scan["scan_dir"]))
238
+ scan_dir = dependencies().require_canonical_scan_directory(Path(scan["scan_dir"]))
315
239
  resolved.relative_to(scan_dir)
316
240
  except (OSError, RuntimeError, ValueError) as exc:
317
241
  raise SystemExit(f"{label} must be an existing path inside the scan directory.") from exc
@@ -395,23 +319,18 @@ def publication_matches_snapshot(publication: Path, snapshot: Path) -> bool:
395
319
 
396
320
  def canonical_discovery_artifacts(scan: sqlite3.Row) -> dict[str, str]:
397
321
  discovery_dir = Path(scan["scan_dir"]) / "artifacts" / "02_discovery"
398
- artifacts = {
399
- "inScopeFilesPath": discovery_dir / "in_scope_files.txt",
400
- "candidateLedgerPath": discovery_dir / "candidate_ledger.jsonl",
401
- }
402
- labels = {
403
- "inScopeFilesPath": "Canonical in-scope inventory path",
404
- "candidateLedgerPath": "Canonical candidate ledger path",
405
- }
406
322
  return {
407
- name: deep_scan_path(scan, str(path), labels[name], kind="file")
408
- for name, path in artifacts.items()
323
+ name: deep_scan_path(scan, str(discovery_dir / filename), label, kind="file")
324
+ for name, filename, label in (
325
+ ("inScopeFilesPath", "in_scope_files.txt", "Canonical in-scope inventory path"),
326
+ ("candidateLedgerPath", "candidate_ledger.jsonl", "Canonical candidate ledger path"),
327
+ )
409
328
  }
410
329
 
411
330
 
412
331
  def deep_scan_state(connection: sqlite3.Connection, scan_id: str) -> dict[str, Any]:
413
332
  run = require_deep_scan_run(connection, scan_id)
414
- scan = require_scan(connection, run["scan_id"])
333
+ scan = dependencies().require_scan(connection, run["scan_id"])
415
334
  worker_rows = connection.execute(
416
335
  """
417
336
  SELECT *
@@ -686,8 +605,8 @@ def begin_deep_scan_for_scan(
686
605
  args: argparse.Namespace,
687
606
  ) -> dict[str, Any]:
688
607
  scan_id = require_uuid(scan_id, "scan-id")
689
- candidate = require_scan(connection, scan_id)
690
- workspace = require_workspace(connection, candidate["workspace_id"])
608
+ candidate = dependencies().require_scan(connection, scan_id)
609
+ workspace = dependencies().require_workspace(connection, candidate["workspace_id"])
691
610
  if (
692
611
  candidate["mode"] == "deep"
693
612
  and candidate["status"] == "running"
@@ -701,7 +620,7 @@ def begin_deep_scan_for_scan(
701
620
  args.claim_token,
702
621
  error_message="Deep Scan orchestration is owned by another continuation.",
703
622
  )
704
- timestamp = now()
623
+ timestamp = dependencies().now()
705
624
  with connection:
706
625
  claimed_workspace = connection.execute(
707
626
  "UPDATE workspaces SET thread_id = ?, updated_at = ? "
@@ -746,45 +665,35 @@ def begin_deep_scan_for_scan(
746
665
  if workflow_version is None:
747
666
  raise SystemExit("workflow-version is required.")
748
667
  connection.execute("BEGIN IMMEDIATE")
749
- try:
668
+ with connection:
750
669
  scan, _ = require_owned_scan(connection, scan_id, thread_id)
751
670
  require_current_continuation(
752
671
  scan,
753
672
  args.claim_token,
754
673
  error_message="Deep Scan orchestration is owned by another continuation.",
755
674
  )
756
- ensure_deep_scan_run(connection, scan, config, workflow_version, now())
757
- connection.commit()
758
- except BaseException:
759
- connection.rollback()
760
- raise
675
+ ensure_deep_scan_run(connection, scan, config, workflow_version, dependencies().now())
761
676
  return deep_scan_result(connection, scan_id, start_disposition="created")
762
677
 
763
678
 
764
679
  def begin_deep_scan_for_target(
765
680
  connection: sqlite3.Connection, args: argparse.Namespace, thread_id: str
766
681
  ) -> dict[str, Any]:
767
- target = require_target(args.target_path)
768
- require_scannable_target(target)
769
- scope = require_scope(args.scope, "deep", target)
682
+ target = dependencies().require_target(args.target_path)
683
+ dependencies().require_scannable_target(target)
684
+ scope = dependencies().require_scope(args.scope, "deep", target)
770
685
  target_path = str(target)
771
686
  existing = existing_deep_scan_for_target(connection, thread_id, target_path, scope)
772
687
  if existing is not None:
773
688
  return begin_deep_scan_for_scan(connection, existing["id"], thread_id, args)
774
689
  target_metadata = target.stat()
775
- revision = git_revision(target)
776
- target_snapshot_digest = (
777
- directory_content_digest(target)
778
- if revision == "unversioned"
779
- else worktree_content_digest(target)
780
- )
781
- target_device = serialize_filesystem_identity(target_metadata.st_dev)
782
- target_inode = serialize_filesystem_identity(target_metadata.st_ino)
690
+ target_identity = dependencies().scan_target_identity(target, None, metadata=target_metadata)
691
+ revision, target_snapshot_digest, target_device, target_inode = target_identity
783
692
  scope_file_count = directory_snapshot_regular_file_count(
784
693
  target if scope == "." else target / scope
785
694
  )
786
695
  connection.execute("BEGIN IMMEDIATE")
787
- try:
696
+ with connection:
788
697
  existing = existing_deep_scan_for_target(connection, thread_id, target_path, scope)
789
698
  if existing is not None:
790
699
  existing_run = connection.execute(
@@ -795,14 +704,16 @@ def begin_deep_scan_for_target(
795
704
  workflow_version = optional_text(args.workflow_version, maximum=256)
796
705
  if workflow_version is None:
797
706
  raise SystemExit("workflow-version is required.")
798
- ensure_deep_scan_run(connection, existing, config, workflow_version, now())
707
+ ensure_deep_scan_run(
708
+ connection, existing, config, workflow_version, dependencies().now()
709
+ )
799
710
  connection.commit()
800
711
  return deep_scan_result(
801
712
  connection,
802
713
  existing["id"],
803
714
  start_disposition="joined" if existing_run is not None else "created",
804
715
  )
805
- current_target = require_remediation_target(target_path)
716
+ current_target = dependencies().require_remediation_target(target_path)
806
717
  current_metadata = current_target.stat()
807
718
  if (current_metadata.st_dev, current_metadata.st_ino) != (
808
719
  target_metadata.st_dev,
@@ -832,23 +743,21 @@ def begin_deep_scan_for_target(
832
743
  workflow_version = optional_text(args.workflow_version, maximum=256)
833
744
  if workflow_version is None:
834
745
  raise SystemExit("workflow-version is required.")
835
- root = (
836
- Path(args.scan_root).expanduser().resolve() if args.scan_root else state_dir() / "scans"
837
- )
838
- target_root = (root / safe_segment(target.name)).resolve()
746
+ root = dependencies().resolve_scan_root(args.scan_root)
747
+ target_root = (root / dependencies().safe_segment(target.name)).resolve()
839
748
  if target_root == target or target in target_root.parents:
840
749
  raise SystemExit("The scan artifact directory must be outside the selected target.")
841
- target_root.mkdir(parents=True, exist_ok=True)
750
+ create_private_directory(target_root)
842
751
  user_context = user_context_argument(args)
843
752
  model = optional_text(args.model, maximum=200)
844
753
  reasoning_effort = optional_text(args.reasoning_effort, maximum=32)
845
754
  workspace_id = str(uuid.uuid4())
846
755
  scan_id = str(uuid.uuid4())
847
- timestamp = now()
848
- target_id = ensure_security_target(connection, target_path)
756
+ timestamp = dependencies().now()
757
+ target_id = dependencies().ensure_security_target(connection, target_path)
849
758
  scan_dir = Path(
850
759
  tempfile.mkdtemp(
851
- prefix=f"{safe_segment(revision)}_{compact_timestamp()}_",
760
+ prefix=f"{dependencies().safe_segment(revision)}_{dependencies().compact_timestamp()}_",
852
761
  dir=target_root,
853
762
  )
854
763
  ).resolve()
@@ -871,55 +780,28 @@ def begin_deep_scan_for_target(
871
780
  timestamp,
872
781
  ),
873
782
  )
874
- connection.execute(
875
- """
876
- INSERT INTO scans (
877
- id, workspace_id, target_id, target_path, target_revision, target_snapshot_digest,
878
- target_device, target_inode, scope, mode, user_context,
879
- deep_scan_owner_thread_id, scan_dir, model, reasoning_effort, status, phase,
880
- handoff_status, started_at, created_at, updated_at
881
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'deep', ?, ?, ?, ?, ?,
882
- 'running', 'preflight', 'delivered', ?, ?, ?)
883
- """,
884
- (
885
- scan_id,
886
- workspace_id,
887
- target_id,
888
- target_path,
889
- revision,
890
- target_snapshot_digest,
891
- target_device,
892
- target_inode,
893
- scope,
894
- user_context,
895
- thread_id,
896
- str(scan_dir),
897
- model,
898
- reasoning_effort,
899
- timestamp,
900
- timestamp,
901
- timestamp,
902
- ),
903
- )
904
- connection.execute(
905
- """
906
- INSERT INTO scan_progress (
907
- scan_id, scope_file_count, review_items_total, review_items_completed,
908
- reportable_findings_count, updated_at
909
- ) VALUES (?, ?, 0, 0, 0, ?)
910
- """,
911
- (scan_id, scope_file_count, timestamp),
912
- )
913
- connection.execute(
914
- "UPDATE workspaces SET active_scan_id = ?, updated_at = ? WHERE id = ?",
915
- (scan_id, timestamp, workspace_id),
783
+ workspace = connection.execute(
784
+ "SELECT * FROM workspaces WHERE id = ?", (workspace_id,)
785
+ ).fetchone()
786
+ dependencies().insert_running_scan(
787
+ connection,
788
+ scan_id=scan_id,
789
+ workspace=workspace,
790
+ target=target,
791
+ scope=scope,
792
+ diff_target=None,
793
+ target_identity=target_identity,
794
+ target_root=target_root,
795
+ target_summary=None,
796
+ scope_file_count=scope_file_count,
797
+ timestamp=timestamp,
798
+ handoff_status="delivered",
799
+ model=model,
800
+ reasoning_effort=reasoning_effort,
801
+ scan_dir=scan_dir,
916
802
  )
917
- scan = require_scan(connection, scan_id)
803
+ scan = dependencies().require_scan(connection, scan_id)
918
804
  ensure_deep_scan_run(connection, scan, config, workflow_version, timestamp)
919
- connection.commit()
920
- except BaseException:
921
- connection.rollback()
922
- raise
923
805
  return deep_scan_result(connection, scan_id, start_disposition="created")
924
806
 
925
807
 
@@ -994,7 +876,7 @@ def claim_deep_scan_coordinator(
994
876
  connection: sqlite3.Connection, args: argparse.Namespace
995
877
  ) -> dict[str, Any]:
996
878
  scan_id = require_uuid(args.scan_id, "scan-id")
997
- with scan_completion_lock(scan_id):
879
+ with dependencies().scan_completion_lock(scan_id):
998
880
  return claim_deep_scan_coordinator_locked(connection, args, scan_id)
999
881
 
1000
882
 
@@ -1002,7 +884,7 @@ def claim_deep_scan_coordinator_locked(
1002
884
  connection: sqlite3.Connection, args: argparse.Namespace, scan_id: str
1003
885
  ) -> dict[str, Any]:
1004
886
  connection.execute("BEGIN IMMEDIATE")
1005
- try:
887
+ with connection:
1006
888
  scan, _ = require_owned_scan(connection, scan_id, args.thread_id)
1007
889
  require_current_continuation(
1008
890
  scan,
@@ -1010,7 +892,7 @@ def claim_deep_scan_coordinator_locked(
1010
892
  error_message="Deep Scan orchestration is owned by another continuation.",
1011
893
  )
1012
894
  run, _ = require_running_deep_scan(connection, scan_id)
1013
- timestamp = now()
895
+ timestamp = dependencies().now()
1014
896
  if args.coordinator_generation is not None:
1015
897
  require_current_coordinator(run, args)
1016
898
  disposition = "claimed"
@@ -1034,10 +916,6 @@ def claim_deep_scan_coordinator_locked(
1034
916
  """,
1035
917
  (int(args.coordinator_generation != run["coordinator_generation"]), timestamp, scan_id),
1036
918
  )
1037
- connection.commit()
1038
- except BaseException:
1039
- connection.rollback()
1040
- raise
1041
919
  return {
1042
920
  **deep_scan_result(connection, scan_id),
1043
921
  "coordinatorDisposition": disposition,
@@ -1122,7 +1000,7 @@ def recover_expired_coordinator(
1122
1000
 
1123
1001
 
1124
1002
  def recover_candidate_ledger_publication(connection: sqlite3.Connection, scan_id: str) -> None:
1125
- scan = require_scan(connection, scan_id)
1003
+ scan = dependencies().require_scan(connection, scan_id)
1126
1004
  ledger = Path(scan["scan_dir"]) / "artifacts" / "02_discovery" / "candidate_ledger.jsonl"
1127
1005
  backups = sorted(
1128
1006
  ledger.parent.glob(f".{ledger.name}.*.backup"),
@@ -1173,7 +1051,7 @@ def require_running_deep_scan(
1173
1051
  connection: sqlite3.Connection, scan_id: str
1174
1052
  ) -> tuple[sqlite3.Row, sqlite3.Row]:
1175
1053
  run = require_deep_scan_run(connection, scan_id)
1176
- scan = require_scan(connection, run["scan_id"])
1054
+ scan = dependencies().require_scan(connection, run["scan_id"])
1177
1055
  if run["status"] != "running" or run["cancel_requested"]:
1178
1056
  raise SystemExit("Only a running Deep Scan can update orchestration state.")
1179
1057
  if scan["status"] != "running" or scan["canceled_at"] is not None:
@@ -1199,10 +1077,10 @@ def upsert_deep_scan_worker(
1199
1077
  scan_id = require_uuid(args.scan_id, "scan-id")
1200
1078
  worker_id = require_uuid(args.worker_id, "worker-id")
1201
1079
  connection.execute("BEGIN IMMEDIATE")
1202
- try:
1080
+ with connection:
1203
1081
  run = require_deep_scan_run(connection, scan_id)
1204
1082
  require_current_coordinator(run, args)
1205
- scan = require_scan(connection, scan_id)
1083
+ scan = dependencies().require_scan(connection, scan_id)
1206
1084
  existing = connection.execute(
1207
1085
  "SELECT * FROM deep_scan_workers WHERE id = ?", (worker_id,)
1208
1086
  ).fetchone()
@@ -1245,7 +1123,7 @@ def upsert_deep_scan_worker(
1245
1123
  if args.result_manifest_path
1246
1124
  else None
1247
1125
  )
1248
- timestamp = now()
1126
+ timestamp = dependencies().now()
1249
1127
  if existing is None:
1250
1128
  if args.kind == "dedup":
1251
1129
  raise SystemExit("Create dedup workers with claim-deep-scan-dedup.")
@@ -1420,10 +1298,6 @@ def upsert_deep_scan_worker(
1420
1298
  worker_id,
1421
1299
  ),
1422
1300
  )
1423
- connection.commit()
1424
- except BaseException:
1425
- connection.rollback()
1426
- raise
1427
1301
  return deep_scan_result(connection, scan_id)
1428
1302
 
1429
1303
 
@@ -1436,7 +1310,7 @@ def claim_deep_scan_dedup(
1436
1310
  if len(set(input_ids)) != len(input_ids):
1437
1311
  raise SystemExit("Dedup input worker IDs must be unique.")
1438
1312
  connection.execute("BEGIN IMMEDIATE")
1439
- try:
1313
+ with connection:
1440
1314
  run, scan = require_running_deep_scan(connection, scan_id)
1441
1315
  require_current_coordinator(run, args)
1442
1316
  prompt_path = deep_scan_path(scan, args.prompt_path, "Dedup prompt path", kind="file")
@@ -1526,7 +1400,7 @@ def claim_deep_scan_dedup(
1526
1400
  if minimum_inputs == 2
1527
1401
  else "A Deep Scan dedup requires at least one buffered discovery result."
1528
1402
  )
1529
- timestamp = now()
1403
+ timestamp = dependencies().now()
1530
1404
  connection.execute(
1531
1405
  """
1532
1406
  INSERT INTO deep_scan_workers (
@@ -1565,10 +1439,6 @@ def claim_deep_scan_dedup(
1565
1439
  """,
1566
1440
  (timestamp, scan_id),
1567
1441
  )
1568
- connection.commit()
1569
- except BaseException:
1570
- connection.rollback()
1571
- raise
1572
1442
  return deep_scan_result(connection, scan_id)
1573
1443
 
1574
1444
 
@@ -1576,7 +1446,7 @@ def commit_deep_scan_dedup(
1576
1446
  connection: sqlite3.Connection, args: argparse.Namespace
1577
1447
  ) -> dict[str, Any]:
1578
1448
  scan_id = require_uuid(args.scan_id, "scan-id")
1579
- with scan_completion_lock(scan_id):
1449
+ with dependencies().scan_completion_lock(scan_id):
1580
1450
  return commit_deep_scan_dedup_locked(connection, args, scan_id)
1581
1451
 
1582
1452
 
@@ -1590,7 +1460,7 @@ def commit_deep_scan_dedup_locked(
1590
1460
  try:
1591
1461
  run = require_deep_scan_run(connection, scan_id)
1592
1462
  require_current_coordinator(run, args)
1593
- scan = require_scan(connection, scan_id)
1463
+ scan = dependencies().require_scan(connection, scan_id)
1594
1464
  worker = require_deep_scan_worker(connection, worker_id)
1595
1465
  if worker["scan_id"] != scan_id or worker["kind"] != "dedup":
1596
1466
  raise SystemExit("Dedup worker does not belong to this Deep Scan.")
@@ -1652,7 +1522,7 @@ def commit_deep_scan_dedup_locked(
1652
1522
  str(publication_copy),
1653
1523
  canonical_candidate_ledger_path,
1654
1524
  )
1655
- timestamp = now()
1525
+ timestamp = dependencies().now()
1656
1526
  connection.execute(
1657
1527
  """
1658
1528
  UPDATE deep_scan_workers
@@ -1702,7 +1572,7 @@ def commit_deep_scan_dedup_locked(
1702
1572
 
1703
1573
  def finish_deep_scan(connection: sqlite3.Connection, args: argparse.Namespace) -> dict[str, Any]:
1704
1574
  scan_id = require_uuid(args.scan_id, "scan-id")
1705
- with scan_completion_lock(scan_id):
1575
+ with dependencies().scan_completion_lock(scan_id):
1706
1576
  return finish_deep_scan_locked(connection, args, scan_id)
1707
1577
 
1708
1578
 
@@ -1719,7 +1589,7 @@ def finish_deep_scan_locked(
1719
1589
  try:
1720
1590
  run = require_deep_scan_run(connection, scan_id)
1721
1591
  require_current_coordinator(run, args)
1722
- scan = require_scan(connection, scan_id)
1592
+ scan = dependencies().require_scan(connection, scan_id)
1723
1593
  manifest_path = (
1724
1594
  deep_scan_output_path(scan, args.manifest_path, "Deep Scan coordinator manifest path")
1725
1595
  if args.staged_manifest_path
@@ -1784,7 +1654,7 @@ def finish_deep_scan_locked(
1784
1654
  AND reducers.status IN ('failed', 'canceled')
1785
1655
  )
1786
1656
  """,
1787
- (now(), scan_id, scan_id),
1657
+ (dependencies().now(), scan_id, scan_id),
1788
1658
  )
1789
1659
  buffered_worker_ids = [
1790
1660
  row["id"]
@@ -1816,7 +1686,7 @@ def finish_deep_scan_locked(
1816
1686
  if run["manifest_path"] is None:
1817
1687
  connection.execute(
1818
1688
  "UPDATE deep_scan_runs SET manifest_path = ?, updated_at = ? WHERE scan_id = ?",
1819
- (manifest_path, now(), scan_id),
1689
+ (manifest_path, dependencies().now(), scan_id),
1820
1690
  )
1821
1691
  connection.commit()
1822
1692
  return deep_scan_result(connection, scan_id)
@@ -1910,7 +1780,7 @@ def finish_deep_scan_locked(
1910
1780
  if args.terminal_reason == "saturated":
1911
1781
  # Mark any remaining workers canceled, including those whose own
1912
1782
  # cancellation writes failed, so they cannot block completion.
1913
- cancel_active_workers(connection, scan_id, now())
1783
+ cancel_active_workers(connection, scan_id, dependencies().now())
1914
1784
  active_worker = connection.execute(
1915
1785
  """
1916
1786
  SELECT 1 FROM deep_scan_workers
@@ -1950,7 +1820,7 @@ def finish_deep_scan_locked(
1950
1820
  kind="file",
1951
1821
  )
1952
1822
  promotion = promote_staged_file(staged_manifest_path, manifest_path)
1953
- timestamp = now()
1823
+ timestamp = dependencies().now()
1954
1824
  connection.execute(
1955
1825
  """
1956
1826
  UPDATE deep_scan_runs
@@ -1974,7 +1844,7 @@ def finish_deep_scan_locked(
1974
1844
 
1975
1845
  def fail_deep_scan(connection: sqlite3.Connection, args: argparse.Namespace) -> dict[str, Any]:
1976
1846
  scan_id = require_uuid(args.scan_id, "scan-id")
1977
- with scan_completion_lock(scan_id):
1847
+ with dependencies().scan_completion_lock(scan_id):
1978
1848
  return fail_deep_scan_locked(connection, args, scan_id)
1979
1849
 
1980
1850
 
@@ -1989,7 +1859,7 @@ def fail_deep_scan_locked(
1989
1859
  try:
1990
1860
  run = require_deep_scan_run(connection, scan_id)
1991
1861
  require_current_coordinator(run, args)
1992
- scan = require_scan(connection, scan_id)
1862
+ scan = dependencies().require_scan(connection, scan_id)
1993
1863
  manifest_path = None
1994
1864
  if args.manifest_path:
1995
1865
  manifest_path = (
@@ -2036,7 +1906,7 @@ def fail_deep_scan_locked(
2036
1906
  kind="file",
2037
1907
  )
2038
1908
  promotion = promote_staged_file(staged_manifest_path, manifest_path)
2039
- timestamp = now()
1909
+ timestamp = dependencies().now()
2040
1910
  connection.execute(
2041
1911
  """
2042
1912
  UPDATE deep_scan_runs
@@ -2080,12 +1950,12 @@ def record_deep_scan_publication_failure(
2080
1950
  message = optional_text(args.message, maximum=2400)
2081
1951
  if message is None:
2082
1952
  raise SystemExit("message is required.")
2083
- with scan_completion_lock(scan_id):
1953
+ with dependencies().scan_completion_lock(scan_id):
2084
1954
  connection.execute("BEGIN IMMEDIATE")
2085
- try:
1955
+ with connection:
2086
1956
  run = require_deep_scan_run(connection, scan_id)
2087
1957
  require_current_coordinator(run, args)
2088
- scan = require_scan(connection, scan_id)
1958
+ scan = dependencies().require_scan(connection, scan_id)
2089
1959
  if (
2090
1960
  run["status"] not in {"failed", "canceled", "interrupted"}
2091
1961
  or scan["status"] != "failed"
@@ -2097,7 +1967,7 @@ def record_deep_scan_publication_failure(
2097
1967
  connection.commit()
2098
1968
  return deep_scan_result(connection, scan_id)
2099
1969
  if run["publication_error_message"] != message:
2100
- timestamp = now()
1970
+ timestamp = dependencies().now()
2101
1971
  connection.execute(
2102
1972
  """
2103
1973
  UPDATE deep_scan_runs
@@ -2106,10 +1976,6 @@ def record_deep_scan_publication_failure(
2106
1976
  """,
2107
1977
  (message, timestamp, scan_id),
2108
1978
  )
2109
- connection.commit()
2110
- except BaseException:
2111
- connection.rollback()
2112
- raise
2113
1979
  return deep_scan_result(connection, scan_id)
2114
1980
 
2115
1981
 
@@ -2118,7 +1984,7 @@ def clear_deep_scan_publication_failure(connection: sqlite3.Connection, scan_id:
2118
1984
  connection.execute(
2119
1985
  "UPDATE deep_scan_runs SET publication_error_message = NULL, updated_at = ? "
2120
1986
  "WHERE scan_id = ? AND publication_error_message IS NOT NULL",
2121
- (now(), scan_id),
1987
+ (dependencies().now(), scan_id),
2122
1988
  )
2123
1989
 
2124
1990
 
@@ -22,9 +22,5 @@ def stored_filesystem_identity_matches(stored: object, current: int) -> bool:
22
22
  return stored == serialize_filesystem_identity(current)
23
23
 
24
24
 
25
- def main() -> None:
26
- argparse.ArgumentParser(description=__doc__).parse_args()
27
-
28
-
29
25
  if __name__ == "__main__":
30
- main()
26
+ argparse.ArgumentParser(description=__doc__).parse_args()