bmsdna-devtools 0.50.1__tar.gz → 0.52.0__tar.gz

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 (137) hide show
  1. bmsdna_devtools-0.50.1/README.md → bmsdna_devtools-0.52.0/PKG-INFO +46 -4
  2. bmsdna_devtools-0.50.1/PKG-INFO → bmsdna_devtools-0.52.0/README.md +28 -22
  3. bmsdna_devtools-0.52.0/bmsdna/devtools/ado_auth.py +177 -0
  4. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/azure_auth.py +6 -2
  5. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/ci_plan.py +30 -3
  6. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/cli.py +144 -43
  7. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/gh_pr.py +146 -10
  8. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/pr_build.py +258 -13
  9. bmsdna_devtools-0.52.0/bmsdna/devtools/pr_cancel.py +146 -0
  10. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/pr_info.py +45 -12
  11. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/pyproject.toml +1 -1
  12. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/skills/bmsdna-devtools/SKILL.md +3 -0
  13. bmsdna_devtools-0.52.0/tests/test_ado_auth.py +233 -0
  14. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_ci_plan.py +99 -0
  15. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_cli_commit.py +1 -1
  16. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_cli_issue.py +9 -9
  17. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_cli_pr_create.py +1 -1
  18. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_cli_pr_id.py +3 -3
  19. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_issue_for_me.py +4 -3
  20. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_build.py +3 -3
  21. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_build_flow.py +3 -3
  22. bmsdna_devtools-0.52.0/tests/test_pr_cancel_build.py +718 -0
  23. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_choice.py +7 -6
  24. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_description_not_truncated.py +1 -1
  25. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_info.py +10 -6
  26. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_wait_timeout.py +1 -1
  27. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/uv.lock +1 -1
  28. bmsdna_devtools-0.50.1/bmsdna/devtools/ado_auth.py +0 -28
  29. bmsdna_devtools-0.50.1/tests/test_ado_auth.py +0 -71
  30. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/.github/workflows/auto-release.yml +0 -0
  31. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/.github/workflows/python-publish.yml +0 -0
  32. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/.github/workflows/python-test.yml +0 -0
  33. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/.gitignore +0 -0
  34. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/.python-version +0 -0
  35. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/__init__.py +0 -0
  36. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/_api_dump.py +0 -0
  37. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/ado_issue.py +0 -0
  38. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/agent_mentions.py +0 -0
  39. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/api_usage.py +0 -0
  40. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/app_service_logs.py +0 -0
  41. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/azure_arm.py +0 -0
  42. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/bdt_config.py +0 -0
  43. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/business_user.py +0 -0
  44. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/ci_plan_env.py +0 -0
  45. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/cli_tools.py +0 -0
  46. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/commit.py +0 -0
  47. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/dead_code.py +0 -0
  48. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/env_config.py +0 -0
  49. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/env_files.py +0 -0
  50. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/find_injection.py +0 -0
  51. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/find_repo.py +0 -0
  52. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/gh_args.py +0 -0
  53. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/gh_issue.py +0 -0
  54. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/github_api.py +0 -0
  55. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/gitrepo.py +0 -0
  56. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/injection_frontend.py +0 -0
  57. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/injection_python.py +0 -0
  58. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/issue_do.py +0 -0
  59. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/issue_show.py +0 -0
  60. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/issue_watch.py +0 -0
  61. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/lint.py +0 -0
  62. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/lint_findings.py +0 -0
  63. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/lint_models.py +0 -0
  64. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/lint_sql.py +0 -0
  65. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/lint_sql_files.py +0 -0
  66. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/lint_tooling.py +0 -0
  67. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/lint_typescript.py +0 -0
  68. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/logs.py +0 -0
  69. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/pr_choice.py +0 -0
  70. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/pr_create_args.py +0 -0
  71. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/pr_issue_link.py +0 -0
  72. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/pr_labels.py +0 -0
  73. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/pr_markdown.py +0 -0
  74. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/pr_merge_defaults.py +0 -0
  75. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/pr_ref.py +0 -0
  76. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/pull.py +0 -0
  77. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/testdb.py +0 -0
  78. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/translate.py +0 -0
  79. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/__init__.py +0 -0
  80. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/cli.py +0 -0
  81. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/pipeline.py +0 -0
  82. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/pricing.py +0 -0
  83. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/report.py +0 -0
  84. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
  85. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
  86. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
  87. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
  88. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
  89. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
  90. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
  91. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/bmsdna/devtools/worktree.py +0 -0
  92. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/justfile +0 -0
  93. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/conftest.py +0 -0
  94. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/fake_github.py +0 -0
  95. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_ado_issue.py +0 -0
  96. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_ado_issue_flow.py +0 -0
  97. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_agent_mentions.py +0 -0
  98. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_api_usage.py +0 -0
  99. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_app_service_logs.py +0 -0
  100. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_azure_arm.py +0 -0
  101. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_bdt_config.py +0 -0
  102. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_business_user.py +0 -0
  103. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_ci_plan_env.py +0 -0
  104. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_cli_cleanup.py +0 -0
  105. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_cli_pull.py +0 -0
  106. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_cli_tools.py +0 -0
  107. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_cli_version.py +0 -0
  108. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_commit.py +0 -0
  109. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_env_config.py +0 -0
  110. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_env_files.py +0 -0
  111. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_find_injection.py +0 -0
  112. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_find_repo.py +0 -0
  113. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_gh_issue.py +0 -0
  114. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_gh_pr.py +0 -0
  115. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_github_api.py +0 -0
  116. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_gitrepo.py +0 -0
  117. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_issue_do.py +0 -0
  118. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_issue_show.py +0 -0
  119. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_issue_watch.py +0 -0
  120. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_lint.py +0 -0
  121. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_lint_models.py +0 -0
  122. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_lint_sql.py +0 -0
  123. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_lint_sql_files.py +0 -0
  124. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_lint_tooling.py +0 -0
  125. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_lint_typescript.py +0 -0
  126. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_logs.py +0 -0
  127. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_build_create_options.py +0 -0
  128. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_create_args.py +0 -0
  129. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_issue_link.py +0 -0
  130. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_labels.py +0 -0
  131. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_markdown.py +0 -0
  132. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pr_merge_defaults.py +0 -0
  133. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_pull.py +0 -0
  134. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_testdb.py +0 -0
  135. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_translate.py +0 -0
  136. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_usage.py +0 -0
  137. {bmsdna_devtools-0.50.1 → bmsdna_devtools-0.52.0}/tests/test_worktree_clean.py +0 -0
@@ -1,3 +1,21 @@
1
+ Metadata-Version: 2.5
2
+ Name: bmsdna-devtools
3
+ Version: 0.52.0
4
+ Summary: Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects
5
+ Requires-Python: >=3.14
6
+ Requires-Dist: azure-identity>=1.19.0
7
+ Requires-Dist: pgdevkit[db]>=0.7.1
8
+ Requires-Dist: requests>=2.32.0
9
+ Requires-Dist: rich>=13.0.0
10
+ Requires-Dist: tomli-w>=1.0.0
11
+ Requires-Dist: typer>=0.26.7
12
+ Provides-Extra: lint
13
+ Requires-Dist: sqlglot>=27.0.0; extra == 'lint'
14
+ Provides-Extra: usage
15
+ Requires-Dist: duckdb>=1.3.0; extra == 'usage'
16
+ Requires-Dist: plotly>=5.24.0; extra == 'usage'
17
+ Description-Content-Type: text/markdown
18
+
1
19
  # bmsdna-devtools
2
20
 
3
21
  Shared developer tooling for BMS projects: PR build/check status and a
@@ -108,7 +126,7 @@ bdt pr info [--json] [--pr-id PR]... [--target-branch BRANCH] [--all]
108
126
  ```
109
127
 
110
128
  One-shot summary of the current branch's PR: link, state (open/merged/closed, draft), aggregate
111
- build state (`passing`, `failing`, `pending`, `waiting` for a manual approval, `none`) and the
129
+ build state (`passing`, `failing`, `cancelled`, `pending`, `waiting` for a manual approval, `none`) and the
112
130
  issue(s)/work item(s) it closes, with links. Exits 1 when the branch has no PR. `--json` is what
113
131
  a status integration reads (e.g. the Claude Code mod planned in bmsuisse/skills#61). Build state is judged the way `bdt pr status` does: on GitHub from
114
132
  the check rollup (only a failed check fails it; skipped/cancelled ones don't count), on Azure DevOps
@@ -167,6 +185,17 @@ by a GitHub Actions run (e.g. a legacy commit status from an external CI)
167
185
  can't be retried this way and are skipped; if none of the failing checks are
168
186
  retryable, the command exits with an error.
169
187
 
188
+ ## `bdt pr cancel-build` / `requeue-build` / `abandon`
189
+
190
+ ```bash
191
+ bdt pr cancel-build --reason "..." [--session ID_OR_URL] [--pr-id N] # comment "CANCELLED BUILD: ..."
192
+ bdt pr requeue-build [--all] [--pr-id N] # new build; `retry` only reruns failed stages
193
+ bdt pr abandon --reason "..." [--session ID_OR_URL] [--pr-id N] # comment "ABANDONED PR: ..."
194
+ ```
195
+
196
+ `bdt pr info` / `bdt pr status` show the reason (and agent session) of a cancelled build or abandoned PR; run
197
+ `--help` for details.
198
+
170
199
  ## `bdt pr watch-deploy`
171
200
 
172
201
  Many pipelines have a second build/stage that only runs on the *target*
@@ -867,15 +896,28 @@ dir = "tests/unit" # areas = sub-folders with tests (test_*.py / *_
867
896
  [tool.bdt.ci.plan.tiers.e2e]
868
897
  dir = "tests/e2e" # flat folder: map the test_*.py files to areas instead
869
898
  areas = { chat = ["test_chat*.py"], review = ["test_review_*.py"] } # unmatched files form the area `shared`
899
+
900
+ [tool.bdt.ci.plan.paths] # non-test files an area owns: changing them infers that area instead of everything
901
+ infra = ["infra/**"] # built-in default when the repo has an infra/ folder; add e.g. frontend = ["frontend/**"]
870
902
  ```
871
903
 
872
904
  Labels on the PR: `test-<area>` (one per touched area, selects it in every tier), `test-shared` (just the area
873
- `shared`), `test-full` (everything), `test-none` (no tests; lint and build still run). Legacy `e2e-<area>` labels count
905
+ `shared`), `test-infra` (the area `infra`, see below), `test-full` (everything), `test-none` (no tests; lint and
906
+ build still run). Legacy `e2e-<area>` labels count
874
907
  as `test-<area>`. With the table present, `bdt pr create` requires one of them (group `test_area`, generated from the
875
908
  same folders; a hand-written `test_area` group in `[tool.bdt.pr.required_labels]` wins). Folders without tests (output
876
909
  folders like `test-results`, helper packages) are not areas; a changed file in one of them, or directly in the tier
877
910
  folder, selects everything because any test may use it.
878
911
 
912
+ `infra` is an ordinary area that owns `infra/**` (the Bicep folder) by default, whenever the repo has an `infra/`
913
+ folder. An area may have no tests: an infra-only PR (labelled `test-infra`, or inferred from the changed files)
914
+ plans `runTests=true` but none of the configured tiers runs (every `<tier>Run` is false), so lint, types and the infra
915
+ guards still run. A tier you did not split by area (e.g. flat unit tests, gated on `runTests` alone) still runs, which is
916
+ what you want when your infra tests live in it. A
917
+ repo that does test its infra files (Bicep settings checks and the like) puts those tests in a `tests/unit/infra/`
918
+ folder (or an `infra` glob area) and the same label selects exactly them. Do not list `infra/**` under `non_code`
919
+ in such a repo: that would skip those tests.
920
+
879
921
  Order of decision, always logged with its reason:
880
922
 
881
923
  1. Not a PR: the CI run after a push (merge) to `test`/`main` runs nothing (that code was tested on its way into
@@ -887,8 +929,8 @@ Order of decision, always logged with its reason:
887
929
  warning instead of guessing. Any other PR into `test` / `main` fails the build. Area folders must not be called
888
930
  `full` or `none` (they would collide with the labels).
889
931
  3. PR labels decide. No usable label (none, or only unknown `test-*` ones, which are warned about): the changed files
890
- (merge commit against its first parent) decide. Nothing changed or only `non_code` files -> nothing runs, only area
891
- tests -> those areas, any other file -> everything. `on_missing = "fail"` fails the build instead.
932
+ (merge commit against its first parent) decide. Nothing changed or only `non_code` files -> nothing runs, only files
933
+ an area owns (its tests, or its `paths`) -> those areas, any other file -> everything. `on_missing = "fail"` fails the build instead.
892
934
  4. Anything unreadable (label API, change list) runs everything: a missing decision never silently skips tests.
893
935
 
894
936
  Outputs (Azure Pipelines variables with `isOutput=true`; plain `name=value` lines elsewhere): `runTests`, and per tier
@@ -1,21 +1,3 @@
1
- Metadata-Version: 2.5
2
- Name: bmsdna-devtools
3
- Version: 0.50.1
4
- Summary: Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects
5
- Requires-Python: >=3.14
6
- Requires-Dist: azure-identity>=1.19.0
7
- Requires-Dist: pgdevkit[db]>=0.7.1
8
- Requires-Dist: requests>=2.32.0
9
- Requires-Dist: rich>=13.0.0
10
- Requires-Dist: tomli-w>=1.0.0
11
- Requires-Dist: typer>=0.26.7
12
- Provides-Extra: lint
13
- Requires-Dist: sqlglot>=27.0.0; extra == 'lint'
14
- Provides-Extra: usage
15
- Requires-Dist: duckdb>=1.3.0; extra == 'usage'
16
- Requires-Dist: plotly>=5.24.0; extra == 'usage'
17
- Description-Content-Type: text/markdown
18
-
19
1
  # bmsdna-devtools
20
2
 
21
3
  Shared developer tooling for BMS projects: PR build/check status and a
@@ -126,7 +108,7 @@ bdt pr info [--json] [--pr-id PR]... [--target-branch BRANCH] [--all]
126
108
  ```
127
109
 
128
110
  One-shot summary of the current branch's PR: link, state (open/merged/closed, draft), aggregate
129
- build state (`passing`, `failing`, `pending`, `waiting` for a manual approval, `none`) and the
111
+ build state (`passing`, `failing`, `cancelled`, `pending`, `waiting` for a manual approval, `none`) and the
130
112
  issue(s)/work item(s) it closes, with links. Exits 1 when the branch has no PR. `--json` is what
131
113
  a status integration reads (e.g. the Claude Code mod planned in bmsuisse/skills#61). Build state is judged the way `bdt pr status` does: on GitHub from
132
114
  the check rollup (only a failed check fails it; skipped/cancelled ones don't count), on Azure DevOps
@@ -185,6 +167,17 @@ by a GitHub Actions run (e.g. a legacy commit status from an external CI)
185
167
  can't be retried this way and are skipped; if none of the failing checks are
186
168
  retryable, the command exits with an error.
187
169
 
170
+ ## `bdt pr cancel-build` / `requeue-build` / `abandon`
171
+
172
+ ```bash
173
+ bdt pr cancel-build --reason "..." [--session ID_OR_URL] [--pr-id N] # comment "CANCELLED BUILD: ..."
174
+ bdt pr requeue-build [--all] [--pr-id N] # new build; `retry` only reruns failed stages
175
+ bdt pr abandon --reason "..." [--session ID_OR_URL] [--pr-id N] # comment "ABANDONED PR: ..."
176
+ ```
177
+
178
+ `bdt pr info` / `bdt pr status` show the reason (and agent session) of a cancelled build or abandoned PR; run
179
+ `--help` for details.
180
+
188
181
  ## `bdt pr watch-deploy`
189
182
 
190
183
  Many pipelines have a second build/stage that only runs on the *target*
@@ -885,15 +878,28 @@ dir = "tests/unit" # areas = sub-folders with tests (test_*.py / *_
885
878
  [tool.bdt.ci.plan.tiers.e2e]
886
879
  dir = "tests/e2e" # flat folder: map the test_*.py files to areas instead
887
880
  areas = { chat = ["test_chat*.py"], review = ["test_review_*.py"] } # unmatched files form the area `shared`
881
+
882
+ [tool.bdt.ci.plan.paths] # non-test files an area owns: changing them infers that area instead of everything
883
+ infra = ["infra/**"] # built-in default when the repo has an infra/ folder; add e.g. frontend = ["frontend/**"]
888
884
  ```
889
885
 
890
886
  Labels on the PR: `test-<area>` (one per touched area, selects it in every tier), `test-shared` (just the area
891
- `shared`), `test-full` (everything), `test-none` (no tests; lint and build still run). Legacy `e2e-<area>` labels count
887
+ `shared`), `test-infra` (the area `infra`, see below), `test-full` (everything), `test-none` (no tests; lint and
888
+ build still run). Legacy `e2e-<area>` labels count
892
889
  as `test-<area>`. With the table present, `bdt pr create` requires one of them (group `test_area`, generated from the
893
890
  same folders; a hand-written `test_area` group in `[tool.bdt.pr.required_labels]` wins). Folders without tests (output
894
891
  folders like `test-results`, helper packages) are not areas; a changed file in one of them, or directly in the tier
895
892
  folder, selects everything because any test may use it.
896
893
 
894
+ `infra` is an ordinary area that owns `infra/**` (the Bicep folder) by default, whenever the repo has an `infra/`
895
+ folder. An area may have no tests: an infra-only PR (labelled `test-infra`, or inferred from the changed files)
896
+ plans `runTests=true` but none of the configured tiers runs (every `<tier>Run` is false), so lint, types and the infra
897
+ guards still run. A tier you did not split by area (e.g. flat unit tests, gated on `runTests` alone) still runs, which is
898
+ what you want when your infra tests live in it. A
899
+ repo that does test its infra files (Bicep settings checks and the like) puts those tests in a `tests/unit/infra/`
900
+ folder (or an `infra` glob area) and the same label selects exactly them. Do not list `infra/**` under `non_code`
901
+ in such a repo: that would skip those tests.
902
+
897
903
  Order of decision, always logged with its reason:
898
904
 
899
905
  1. Not a PR: the CI run after a push (merge) to `test`/`main` runs nothing (that code was tested on its way into
@@ -905,8 +911,8 @@ Order of decision, always logged with its reason:
905
911
  warning instead of guessing. Any other PR into `test` / `main` fails the build. Area folders must not be called
906
912
  `full` or `none` (they would collide with the labels).
907
913
  3. PR labels decide. No usable label (none, or only unknown `test-*` ones, which are warned about): the changed files
908
- (merge commit against its first parent) decide. Nothing changed or only `non_code` files -> nothing runs, only area
909
- tests -> those areas, any other file -> everything. `on_missing = "fail"` fails the build instead.
914
+ (merge commit against its first parent) decide. Nothing changed or only `non_code` files -> nothing runs, only files
915
+ an area owns (its tests, or its `paths`) -> those areas, any other file -> everything. `on_missing = "fail"` fails the build instead.
910
916
  4. Anything unreadable (label API, change list) runs everything: a missing decision never silently skips tests.
911
917
 
912
918
  Outputs (Azure Pipelines variables with `isOutput=true`; plain `name=value` lines elsewhere): `runTests`, and per tier
@@ -0,0 +1,177 @@
1
+ """Azure DevOps auth: explicit PAT (`--pat` / AZURE_DEVOPS_EXT_PAT / AZURE_DEVOPS_PAT), or a token from
2
+ `DefaultAzureCredential` (see `azure_auth`)."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import base64
7
+ import re
8
+ from urllib.parse import parse_qs, urlparse
9
+
10
+ import requests
11
+
12
+ from .azure_auth import get_azure_token
13
+ from .pr_cancel import one_line
14
+ from .gitrepo import AdoRemote, current_remote
15
+
16
+ # Well-known Azure DevOps resource ID; `<id>/.default` is its AAD scope.
17
+ ADO_RESOURCE_ID = "499b84ac-1321-427f-aa17-267ca6975798"
18
+
19
+ PAT_SOURCES = "--pat / AZURE_DEVOPS_EXT_PAT / AZURE_DEVOPS_PAT"
20
+ # What a PAT needs for everything `bdt` does against Azure DevOps (PRs, builds, work items).
21
+ BDT_PAT_SCOPES = "Code (Read & write), Build (Read & execute), Work Items (Read & write)"
22
+
23
+ # REST API area -> the PAT scope a call into it needs at least
24
+ _SCOPE_BY_API = (
25
+ ("/_apis/build/", "Build (Read & execute)"),
26
+ ("/_apis/git/", "Code (Read & write)"),
27
+ ("/_apis/policy/", "Code (Read & write)"),
28
+ ("/_apis/wit/", "Work Items (Read & write)"),
29
+ ("/_apis/userentitlements/", "MemberEntitlement Management (Read)"),
30
+ ("/_apis/identities", "Identity (Read)"),
31
+ ("/_apis/graph/", "Graph (Read)"),
32
+ )
33
+ _ORG_RE = re.compile(r"^/([^/]+)")
34
+
35
+
36
+ class AdoAuthError(requests.HTTPError):
37
+ """Azure DevOps rejected the credentials (401), or accepted them but refuses the call (403): the message
38
+ already says which PAT scope / login to fix, so it is meant to be shown as is."""
39
+
40
+
41
+ def pat_settings_url(org: str | None) -> str:
42
+ if org:
43
+ return f"https://dev.azure.com/{org}/_usersSettings/tokens"
44
+ return "https://dev.azure.com/ (user settings > Personal access tokens)"
45
+
46
+
47
+ def _remote_org() -> str | None:
48
+ """The org of the current checkout's `origin`, if it is an Azure DevOps one (best effort: auth also fails
49
+ outside a checkout)."""
50
+ try:
51
+ remote = current_remote()
52
+ except Exception: # noqa: BLE001 -- not a git checkout / unknown remote: just no org to name
53
+ return None
54
+ return remote.org if isinstance(remote, AdoRemote) else None
55
+
56
+
57
+ def get_az_devops_token() -> str:
58
+ org = _remote_org()
59
+ hint = (
60
+ "No Azure DevOps credentials: no PAT was given (--pat, AZURE_DEVOPS_EXT_PAT and AZURE_DEVOPS_PAT are all unset) "
61
+ "and there is no usable `az login`.\n"
62
+ "Fix it with either:\n"
63
+ f" - a PAT: create one at {pat_settings_url(org)} (scopes: {BDT_PAT_SCOPES}), then "
64
+ "`export AZURE_DEVOPS_EXT_PAT=<token>` or pass --pat\n"
65
+ " - `az login` as a user with access to the organization"
66
+ )
67
+ return get_azure_token(f"{ADO_RESOURCE_ID}/.default", hint=hint)
68
+
69
+
70
+ def auth_header(pat: str | None) -> dict[str, str]:
71
+ """Basic-auth header for an explicit PAT, else Bearer via `DefaultAzureCredential`.
72
+
73
+ Never hardcode a PAT literal in a caller — pass it in from an env var
74
+ (e.g. AZURE_DEVOPS_EXT_PAT) or a CLI flag, or omit it and let azure-identity supply a
75
+ short-lived token from the operator's own login.
76
+ """
77
+ if pat:
78
+ token = base64.b64encode(f":{pat}".encode()).decode()
79
+ return {"Authorization": f"Basic {token}"}
80
+ return {"Authorization": f"Bearer {get_az_devops_token()}"}
81
+
82
+
83
+ def _ado_message(response: requests.Response) -> str | None:
84
+ try:
85
+ message = response.json().get("message")
86
+ except (ValueError, AttributeError):
87
+ return None
88
+ return one_line(message) if isinstance(message, str) and message.strip() else None
89
+
90
+
91
+ def _is_sign_in_url(url: str) -> bool:
92
+ return urlparse(url).path.rstrip("/").endswith("/_signin")
93
+
94
+
95
+ def _requested_url(response: requests.Response) -> str:
96
+ """The URL that was asked for. A rejected PAT is redirected to a sign-in page, which is what `response.url` is then
97
+ (and `response.history` is only filled in once the whole redirect chain is done, after the hook ran); the page
98
+ carries the original URL as `reply_to`."""
99
+ if response.history:
100
+ return response.history[0].url
101
+ if _is_sign_in_url(response.url):
102
+ reply_to = parse_qs(urlparse(response.url).query).get("reply_to")
103
+ if reply_to:
104
+ return reply_to[0]
105
+ return response.url
106
+
107
+
108
+ def auth_failure_message(response: requests.Response, pat_used: bool) -> str:
109
+ """Why `response` (a 401/403 from Azure DevOps) happened and how to fix it, for the credentials in use."""
110
+ parsed = urlparse(_requested_url(response))
111
+ org_match = _ORG_RE.match(parsed.path) if parsed.netloc == "dev.azure.com" else None
112
+ org = org_match.group(1) if org_match else _remote_org()
113
+ scope = next((s for api, s in _SCOPE_BY_API if api in parsed.path), None)
114
+ where = f"{parsed.scheme}://{parsed.netloc}{parsed.path}"
115
+ lines = []
116
+ if response.status_code == 403:
117
+ lines.append(f"Azure DevOps refused the call (HTTP 403) -- {where}")
118
+ else:
119
+ lines.append(f"Azure DevOps did not accept the credentials (HTTP 401) -- {where}")
120
+ says = _ado_message(response)
121
+ if says:
122
+ lines.append(f"Azure DevOps says: {says}")
123
+ if pat_used:
124
+ lines.append(f"Credentials: the PAT from {PAT_SOURCES}.")
125
+ causes: list[str] = ["it lacks the scope this call needs" + (f" ({scope})" if scope else "")]
126
+ if response.status_code != 403:
127
+ causes += ["it has expired or was revoked", "it was created for a different organization" + (f" than '{org}'" if org else "")]
128
+ else:
129
+ causes += ["your account itself lacks the permission"]
130
+ lines.append("Most likely " + ", or ".join(causes) + ".")
131
+ lines.append(f"Fix or recreate it at {pat_settings_url(org)} (scopes bdt needs: {BDT_PAT_SCOPES}).")
132
+ else:
133
+ lines.append("Credentials: your `az login` token (no PAT given).")
134
+ lines.append(
135
+ "Run `az login` as a user with access to " + (f"organization '{org}'" if org else "the organization")
136
+ + f", or use a PAT instead: create one at {pat_settings_url(org)} (scopes: {BDT_PAT_SCOPES}) and set AZURE_DEVOPS_EXT_PAT / pass --pat."
137
+ )
138
+ return "\n".join(lines)
139
+
140
+
141
+ def _is_sign_in_page(response: requests.Response) -> bool:
142
+ """Azure DevOps answers credentials it does not recognise by redirecting to a sign-in page (so 203, or 200 with
143
+ HTML) -- for its REST API, which otherwise only ever speaks JSON/text."""
144
+ if "/_apis/" not in _requested_url(response):
145
+ return False
146
+ if _is_sign_in_url(response.url):
147
+ return True
148
+ if response.status_code == 203:
149
+ return True
150
+ return response.status_code == 200 and "text/html" in response.headers.get("Content-Type", "")
151
+
152
+
153
+ def _check_auth_hook(pat_used: bool):
154
+ def hook(response: requests.Response, *args, **kwargs) -> requests.Response:
155
+ if _is_sign_in_page(response):
156
+ # one status for "not signed in", however Azure DevOps phrased it, so callers' `>= 400` checks agree
157
+ response.status_code = 401
158
+ if response.status_code in (401, 403):
159
+ error = AdoAuthError(auth_failure_message(response, pat_used), response=response)
160
+
161
+ def raise_for_status() -> None:
162
+ raise error
163
+
164
+ # replaces the generic "401 Client Error: Unauthorized for url" `raise_for_status` would raise
165
+ setattr(response, "raise_for_status", raise_for_status)
166
+ return response
167
+
168
+ return hook
169
+
170
+
171
+ def ado_session(pat: str | None) -> requests.Session:
172
+ """A `requests.Session` authenticated for Azure DevOps whose rejected calls fail with an `AdoAuthError`
173
+ (from `raise_for_status`) explaining which PAT / scope / login to fix, instead of a bare HTTP error."""
174
+ session = requests.Session()
175
+ session.headers.update(auth_header(pat))
176
+ session.hooks["response"].append(_check_auth_hook(bool(pat)))
177
+ return session
@@ -18,8 +18,9 @@ def _credential():
18
18
  return DefaultAzureCredential(process_timeout=CLI_TIMEOUT_SECS)
19
19
 
20
20
 
21
- def get_azure_token(scope: str) -> str:
22
- """A bearer token for `scope` (e.g. `https://management.azure.com/.default`)."""
21
+ def get_azure_token(scope: str, hint: str | None = None) -> str:
22
+ """A bearer token for `scope` (e.g. `https://management.azure.com/.default`). `hint` replaces the generic
23
+ "try `az login`" advice when the failing caller knows better (see `ado_auth`)."""
23
24
  try:
24
25
  from azure.core.exceptions import ClientAuthenticationError
25
26
  except ImportError: # pragma: no cover -- a declared dependency
@@ -27,4 +28,7 @@ def get_azure_token(scope: str) -> str:
27
28
  try:
28
29
  return _credential().get_token(scope).token
29
30
  except ClientAuthenticationError as e:
31
+ if hint:
32
+ # the credential chain's report lists every credential tried, one block each: the first line says it all
33
+ sys.exit(f"{hint}\n\n(azure-identity: {str(e).strip().splitlines()[0]})")
30
34
  sys.exit(f"Azure authentication failed (try `az login`, or set AZURE_DEVOPS_EXT_PAT for Azure DevOps):\n{e}")
@@ -13,6 +13,9 @@ Configured under `[tool.bdt.ci.plan]` in pyproject.toml (the table must exist, e
13
13
  dir = "tests/e2e" # flat folder: an area table maps test files to areas instead
14
14
  areas = { chat = ["test_chat*.py"], review = ["test_review_*.py"] } # unmatched files = area "shared"
15
15
 
16
+ [tool.bdt.ci.plan.paths] # non-test files an area owns: changing them infers that area, not everything
17
+ infra = ["infra/**"] # built-in default when the repo has an infra/ folder (areas may have no tests)
18
+
16
19
  Labels: `test-<area>`, `test-full` (everything), `test-none` (no tests; lint and build still run). The legacy
17
20
  `e2e-<area>` labels count as `test-<area>`. Order of decision (the reason is always reported):
18
21
 
@@ -21,7 +24,8 @@ Labels: `test-<area>`, `test-full` (everything), `test-none` (no tests; lint and
21
24
  2. Branch flow: promotions (dev -> test -> main -> dev) run nothing; `fix/*` and `hotfix/*` into `main` are tested
22
25
  and must be cut from `main`; any other PR into `test`/`main` is an error.
23
26
  3. PR labels decide. Without a usable label the changed files decide (`on_missing = "infer"`): nothing changed or
24
- only `non_code` files -> none, only area tests -> those areas, any other file -> everything.
27
+ only `non_code` files -> none, only files an area owns (its tests, or `paths`) -> those areas, any other file ->
28
+ everything. An area without tests (such as `infra`) selects nothing to run: `runTests` stays true, every tier is off.
25
29
  4. Anything unreadable (label API, change list) selects everything.
26
30
  """
27
31
 
@@ -49,6 +53,7 @@ FIX_PREFIXES = ("fix/", "hotfix/")
49
53
  PUSH_REASONS = frozenset(
50
54
  {"IndividualCI", "BatchedCI"}
51
55
  ) # a merge landed on the branch: deploy only
56
+ INFRA_AREA = "infra" # owns `infra/**` by default when the repo has an infra/ folder; usually has no tests
52
57
  RESERVED_AREAS = frozenset(
53
58
  {"full", "none"}
54
59
  ) # test-full / test-none are the control labels
@@ -157,9 +162,20 @@ class PlanConfig:
157
162
  tiers: tuple[Tier, ...]
158
163
  on_missing: OnMissing = "infer"
159
164
  non_code: tuple[str, ...] = ()
165
+ paths: Mapping[str, tuple[str, ...]] = field(default_factory=dict)
160
166
 
161
167
  def all_areas(self) -> set[str]:
162
- return {a for tier in self.tiers for a in tier.areas(self.root)}
168
+ """Areas with tests in a tier, plus areas that only own paths (such as `infra`, which may have no tests)."""
169
+ return {a for tier in self.tiers for a in tier.areas(self.root)} | set(
170
+ self.paths
171
+ )
172
+
173
+ def path_owners(self, path: str) -> frozenset[str]:
174
+ return frozenset(
175
+ area
176
+ for area, globs in self.paths.items()
177
+ if any(PurePosixPath(path).full_match(g) for g in globs)
178
+ )
163
179
 
164
180
  def is_non_code(self, path: str) -> bool:
165
181
  return any(PurePosixPath(path).full_match(g) for g in self.non_code)
@@ -203,11 +219,20 @@ def load_plan_config(start: Path | None = None) -> PlanConfig | None:
203
219
  tiers_raw = raw.get("tiers", {name: {} for name in DEFAULT_TIER_DIRS})
204
220
  if not isinstance(tiers_raw, dict):
205
221
  raise ValueError("[tool.bdt.ci.plan.tiers] must be a table")
222
+ paths_raw = raw.get("paths", {})
223
+ if not isinstance(paths_raw, dict):
224
+ raise ValueError("[tool.bdt.ci.plan.paths] must be a table of glob lists")
225
+ paths = {
226
+ str(area): _strings(globs, f"paths.{area}") for area, globs in paths_raw.items()
227
+ }
228
+ if (pyproject.parent / "infra").is_dir():
229
+ paths.setdefault(INFRA_AREA, ("infra/**",))
206
230
  config = PlanConfig(
207
231
  root=pyproject.parent,
208
232
  tiers=tuple(_tier(name, t) for name, t in tiers_raw.items()),
209
233
  on_missing=on_missing,
210
234
  non_code=_strings(raw.get("non_code", []), "non_code"),
235
+ paths=paths,
211
236
  )
212
237
  if clash := sorted(config.all_areas() & RESERVED_AREAS):
213
238
  raise ValueError(
@@ -337,6 +362,8 @@ def _from_files(files: list[str], config: PlanConfig, warnings: list[str]) -> Pl
337
362
  for tier in config.tiers
338
363
  if (owned := tier.area_of(config.root, path, known[tier.name]))
339
364
  ]
365
+ if owned_paths := config.path_owners(path):
366
+ owners.append(owned_paths)
340
367
  if not owners:
341
368
  return _full(
342
369
  config,
@@ -351,7 +378,7 @@ def _from_files(files: list[str], config: PlanConfig, warnings: list[str]) -> Pl
351
378
  warnings=tuple(warnings),
352
379
  )
353
380
  areas &= frozenset().union(
354
- *known.values()
381
+ *known.values(), config.paths
355
382
  ) # a removed area has nothing left to run
356
383
  if not areas:
357
384
  return Plan(