@deftai/directive-core 0.107.0 → 0.109.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 (271) hide show
  1. package/dist/architecture/sor-preflight.js +2 -0
  2. package/dist/cache/operations.js +1 -1
  3. package/dist/check/cached-orchestrator.js +28 -3
  4. package/dist/check/gate-lists.d.ts +14 -0
  5. package/dist/check/gate-lists.js +26 -3
  6. package/dist/check/named-cause.js +18 -3
  7. package/dist/check/session-completed-ac.d.ts +1 -1
  8. package/dist/check/session-completed-ac.js +1 -1
  9. package/dist/codebase/provider.js +7 -1
  10. package/dist/consumer-check-contract/evaluate.d.ts +47 -0
  11. package/dist/consumer-check-contract/evaluate.js +181 -15
  12. package/dist/delivery-attempt/evaluate.d.ts +9 -1
  13. package/dist/delivery-attempt/evaluate.js +69 -0
  14. package/dist/delivery-attempt/handoff.js +1 -1
  15. package/dist/delivery-attempt/index.d.ts +1 -1
  16. package/dist/delivery-attempt/index.js +1 -1
  17. package/dist/deposit/live-procedure-exclusions.d.ts +18 -0
  18. package/dist/deposit/live-procedure-exclusions.js +110 -0
  19. package/dist/deposit/live-procedure-targets.d.ts +45 -0
  20. package/dist/deposit/live-procedure-targets.js +274 -0
  21. package/dist/deposit/python-free.d.ts +6 -0
  22. package/dist/deposit/python-free.js +15 -0
  23. package/dist/deposit/rewrite-deposit-links.d.ts +42 -0
  24. package/dist/deposit/rewrite-deposit-links.js +148 -0
  25. package/dist/deposit/run-stage-content-pack.d.ts +2 -0
  26. package/dist/deposit/run-stage-content-pack.js +3 -0
  27. package/dist/deposit/stage-content-pack.d.ts +17 -0
  28. package/dist/deposit/stage-content-pack.js +91 -0
  29. package/dist/design-critique/citation-grammar.d.ts +60 -0
  30. package/dist/design-critique/citation-grammar.js +303 -0
  31. package/dist/design-critique/completed-arc-record.d.ts +62 -0
  32. package/dist/design-critique/completed-arc-record.js +277 -0
  33. package/dist/freshness/bind.d.ts +32 -3
  34. package/dist/freshness/bind.js +58 -12
  35. package/dist/hooks/classify/host-session-identity.d.ts +89 -0
  36. package/dist/hooks/classify/host-session-identity.js +467 -0
  37. package/dist/hooks/classify/index.d.ts +3 -2
  38. package/dist/hooks/classify/index.js +3 -2
  39. package/dist/hooks/classify/paths.d.ts +9 -0
  40. package/dist/hooks/classify/paths.js +39 -0
  41. package/dist/hooks/classify/stdin.d.ts +5 -0
  42. package/dist/hooks/classify/stdin.js +94 -1
  43. package/dist/hooks/dest-form.d.ts +20 -1
  44. package/dist/hooks/dest-form.js +158 -21
  45. package/dist/hooks/dispatcher.d.ts +58 -3
  46. package/dist/hooks/dispatcher.js +762 -73
  47. package/dist/hooks/fixtures/cases.d.ts +22 -2
  48. package/dist/hooks/fixtures/cases.js +228 -0
  49. package/dist/hooks/git-destructive-log.d.ts +32 -0
  50. package/dist/hooks/git-destructive-log.js +46 -0
  51. package/dist/hooks/index.d.ts +2 -0
  52. package/dist/hooks/index.js +2 -0
  53. package/dist/hooks/scope.js +3 -1
  54. package/dist/hooks/shell-write-targets.d.ts +10 -0
  55. package/dist/hooks/shell-write-targets.js +274 -0
  56. package/dist/hooks/tools.d.ts +20 -2
  57. package/dist/hooks/tools.js +30 -1
  58. package/dist/init-deposit/agent-hooks.d.ts +2 -1
  59. package/dist/init-deposit/agent-hooks.js +8 -1
  60. package/dist/init-deposit/gitignore.d.ts +7 -0
  61. package/dist/init-deposit/gitignore.js +24 -0
  62. package/dist/init-deposit/hook-runtime-travel.d.ts +77 -0
  63. package/dist/init-deposit/hook-runtime-travel.js +269 -0
  64. package/dist/init-deposit/init-deposit.js +3 -0
  65. package/dist/init-deposit/refresh.js +7 -0
  66. package/dist/init-deposit/runtime-writers.d.ts +14 -0
  67. package/dist/init-deposit/runtime-writers.js +33 -0
  68. package/dist/intake/clause-derivation.js +9 -3
  69. package/dist/intake/issue-ingest.d.ts +6 -1
  70. package/dist/intake/issue-ingest.js +83 -4
  71. package/dist/intake/platform-capabilities.d.ts +9 -2
  72. package/dist/intake/platform-capabilities.js +38 -9
  73. package/dist/intake/reconcile-issues.js +13 -13
  74. package/dist/lifecycle/brief-envelope.d.ts +25 -0
  75. package/dist/lifecycle/brief-envelope.js +42 -0
  76. package/dist/lifecycle/index.d.ts +1 -0
  77. package/dist/lifecycle/index.js +1 -0
  78. package/dist/literal-acceptance/evaluate.js +14 -5
  79. package/dist/literal-acceptance/index.d.ts +1 -1
  80. package/dist/literal-acceptance/index.js +1 -1
  81. package/dist/literal-acceptance/run.d.ts +2 -0
  82. package/dist/literal-acceptance/run.js +19 -1
  83. package/dist/orphan-active/candidate-scope.d.ts +53 -0
  84. package/dist/orphan-active/candidate-scope.js +157 -0
  85. package/dist/orphan-active/evaluate.d.ts +52 -0
  86. package/dist/orphan-active/evaluate.js +250 -128
  87. package/dist/orphan-active/index.d.ts +2 -0
  88. package/dist/orphan-active/index.js +2 -0
  89. package/dist/orphan-active/issue-state.d.ts +121 -0
  90. package/dist/orphan-active/issue-state.js +278 -0
  91. package/dist/platform/cursor-managed-runtime.d.ts +95 -0
  92. package/dist/platform/cursor-managed-runtime.js +241 -0
  93. package/dist/platform/index.d.ts +1 -0
  94. package/dist/platform/index.js +1 -0
  95. package/dist/platform/platform-capabilities.d.ts +23 -1
  96. package/dist/platform/platform-capabilities.js +55 -15
  97. package/dist/policy/ceremony-dial.js +5 -9
  98. package/dist/policy/host-hooks.js +4 -9
  99. package/dist/policy/merge-approval-head.js +7 -6
  100. package/dist/policy/org-force-on-migration.js +5 -10
  101. package/dist/policy/plan-extensions.d.ts +14 -2
  102. package/dist/policy/plan-extensions.js +24 -3
  103. package/dist/policy/product-signal.js +5 -10
  104. package/dist/policy/require-human-merge.js +5 -9
  105. package/dist/policy/resolve.js +77 -16
  106. package/dist/policy/value-feedback.js +9 -18
  107. package/dist/pr-closeout-attestable/evaluate.d.ts +80 -0
  108. package/dist/pr-closeout-attestable/evaluate.js +306 -0
  109. package/dist/pr-closeout-attestable/index.d.ts +2 -0
  110. package/dist/pr-closeout-attestable/index.js +2 -0
  111. package/dist/pr-closing-keywords/gh.js +32 -9
  112. package/dist/pr-closing-keywords/main.d.ts +1 -0
  113. package/dist/pr-closing-keywords/main.js +68 -3
  114. package/dist/pr-closing-keywords/types.d.ts +2 -0
  115. package/dist/pr-merge-readiness/gh.js +32 -9
  116. package/dist/pr-protected-issues/gh.d.ts +6 -2
  117. package/dist/pr-protected-issues/gh.js +42 -11
  118. package/dist/pr-wait-mergeable/cascade.d.ts +9 -1
  119. package/dist/pr-wait-mergeable/cascade.js +21 -1
  120. package/dist/pr-wait-mergeable/types.d.ts +2 -0
  121. package/dist/pr-wait-mergeable/wrappers.d.ts +6 -0
  122. package/dist/pr-wait-mergeable/wrappers.js +14 -3
  123. package/dist/preflight/evaluate.d.ts +15 -0
  124. package/dist/preflight/evaluate.js +29 -3
  125. package/dist/product-first-done-gate/acceptance-resolver.d.ts +14 -2
  126. package/dist/product-first-done-gate/acceptance-resolver.js +13 -2
  127. package/dist/product-first-done-gate/evaluate.js +23 -9
  128. package/dist/product-first-done-gate/types.js +2 -0
  129. package/dist/release/cli-drift-report.d.ts +68 -0
  130. package/dist/release/cli-drift-report.js +189 -0
  131. package/dist/release/consumer-hard-stops.d.ts +48 -0
  132. package/dist/release/consumer-hard-stops.js +140 -0
  133. package/dist/release/consumer-readiness-disclosure.d.ts +18 -0
  134. package/dist/release/consumer-readiness-disclosure.js +51 -0
  135. package/dist/release/index.d.ts +3 -0
  136. package/dist/release/index.js +3 -0
  137. package/dist/release/issue-state-fetch.d.ts +5 -3
  138. package/dist/release/issue-state-fetch.js +86 -21
  139. package/dist/release/native-steps.js +1 -0
  140. package/dist/release/pipeline.js +74 -0
  141. package/dist/release/run-consumer-readiness.d.ts +15 -0
  142. package/dist/release/run-consumer-readiness.js +24 -0
  143. package/dist/release/types.d.ts +20 -0
  144. package/dist/render/constants.d.ts +4 -0
  145. package/dist/render/constants.js +11 -8
  146. package/dist/render/export-spec.js +31 -5
  147. package/dist/render/index.d.ts +1 -1
  148. package/dist/render/index.js +1 -1
  149. package/dist/render/prd-render.d.ts +4 -1
  150. package/dist/render/prd-render.js +82 -23
  151. package/dist/render/project-render.js +14 -7
  152. package/dist/render/scope-outlook.d.ts +2 -0
  153. package/dist/render/scope-outlook.js +3 -0
  154. package/dist/render/spec-render.js +2 -2
  155. package/dist/resolution/package-manager.d.ts +33 -4
  156. package/dist/resolution/package-manager.js +210 -9
  157. package/dist/review-monitor/constants.d.ts +7 -0
  158. package/dist/review-monitor/constants.js +7 -0
  159. package/dist/review-monitor/github-lease.d.ts +98 -1
  160. package/dist/review-monitor/github-lease.js +186 -4
  161. package/dist/review-monitor/lease-comment.d.ts +36 -0
  162. package/dist/review-monitor/lease-comment.js +103 -2
  163. package/dist/run-summary/types.d.ts +2 -2
  164. package/dist/scm/build-command.d.ts +2 -2
  165. package/dist/scm/build-command.js +2 -2
  166. package/dist/scm/call-shape.d.ts +25 -0
  167. package/dist/scm/call-shape.js +59 -0
  168. package/dist/scm/call.d.ts +7 -4
  169. package/dist/scm/call.js +48 -9
  170. package/dist/scm/design-critique-chip.d.ts +1 -0
  171. package/dist/scm/design-critique-chip.js +22 -6
  172. package/dist/scm/gh-rest.d.ts +34 -13
  173. package/dist/scm/gh-rest.js +168 -15
  174. package/dist/scm/index.d.ts +2 -0
  175. package/dist/scm/index.js +2 -0
  176. package/dist/scm/readiness.d.ts +2 -0
  177. package/dist/scm/readiness.js +28 -4
  178. package/dist/scm/spawn-status.d.ts +33 -0
  179. package/dist/scm/spawn-status.js +53 -0
  180. package/dist/scope/acceptance-evidence.d.ts +1 -1
  181. package/dist/scope/project-definition-sync.js +14 -7
  182. package/dist/scope/transition.js +4 -14
  183. package/dist/session/ac-pass-banking.d.ts +2 -2
  184. package/dist/session/ac-pass-banking.js +2 -2
  185. package/dist/session/git.d.ts +24 -0
  186. package/dist/session/git.js +138 -2
  187. package/dist/session/host-session-owner.d.ts +53 -0
  188. package/dist/session/host-session-owner.js +89 -0
  189. package/dist/session/index.d.ts +1 -0
  190. package/dist/session/index.js +1 -0
  191. package/dist/session/occupancy.d.ts +259 -13
  192. package/dist/session/occupancy.js +877 -33
  193. package/dist/session/ritual-sentinel.d.ts +5 -0
  194. package/dist/session/ritual-sentinel.js +5 -0
  195. package/dist/session/session-ready.d.ts +5 -1
  196. package/dist/session/session-ready.js +98 -8
  197. package/dist/session/session-start.d.ts +5 -1
  198. package/dist/session/session-start.js +32 -17
  199. package/dist/session/toolchain-preflight.d.ts +13 -3
  200. package/dist/session/toolchain-preflight.js +93 -18
  201. package/dist/session/verify-ac-session-cache.d.ts +2 -2
  202. package/dist/session/verify-ac-session-cache.js +2 -2
  203. package/dist/session/verify-session-ritual.d.ts +11 -0
  204. package/dist/session/verify-session-ritual.js +60 -15
  205. package/dist/slice/constants.d.ts +1 -1
  206. package/dist/spec-authority/constants.d.ts +10 -2
  207. package/dist/spec-authority/constants.js +53 -8
  208. package/dist/spec-authority/resolver.d.ts +3 -0
  209. package/dist/spec-authority/resolver.js +55 -7
  210. package/dist/subprocess/max-buffer.d.ts +14 -0
  211. package/dist/subprocess/max-buffer.js +15 -0
  212. package/dist/swarm/complete-cohort.d.ts +2 -0
  213. package/dist/swarm/complete-cohort.js +21 -13
  214. package/dist/swarm/index.d.ts +1 -0
  215. package/dist/swarm/index.js +1 -0
  216. package/dist/swarm/launch-cli.js +53 -33
  217. package/dist/swarm/launch.d.ts +8 -0
  218. package/dist/swarm/launch.js +63 -43
  219. package/dist/swarm/pre-dispatch-cli.js +2 -1
  220. package/dist/swarm/pre-dispatch.js +10 -1
  221. package/dist/swarm/subagent-status-dir.d.ts +27 -0
  222. package/dist/swarm/subagent-status-dir.js +42 -0
  223. package/dist/swarm/worktrees.d.ts +17 -3
  224. package/dist/swarm/worktrees.js +48 -4
  225. package/dist/triage/evaluate/worktrees.js +153 -6
  226. package/dist/triage/scope/mutations-core.d.ts +2 -6
  227. package/dist/triage/scope/mutations-core.js +23 -55
  228. package/dist/triage/scope-drift/add-ignore.js +5 -39
  229. package/dist/triage/subscribe/index.d.ts +2 -6
  230. package/dist/triage/subscribe/index.js +15 -65
  231. package/dist/triage/welcome/writers.js +15 -74
  232. package/dist/umbrella-current-shape/index.d.ts +51 -3
  233. package/dist/umbrella-current-shape/index.js +106 -18
  234. package/dist/validate-content/deposit-required.d.ts +39 -0
  235. package/dist/validate-content/deposit-required.js +147 -0
  236. package/dist/validate-content/index.d.ts +1 -0
  237. package/dist/validate-content/index.js +1 -0
  238. package/dist/validate-content/validate-links.d.ts +2 -3
  239. package/dist/validate-content/validate-links.js +29 -2
  240. package/dist/vbrief-activate/activate.d.ts +7 -2
  241. package/dist/vbrief-activate/activate.js +26 -13
  242. package/dist/vbrief-build/index.d.ts +2 -1
  243. package/dist/vbrief-build/index.js +2 -1
  244. package/dist/vbrief-build/parity-scenarios.js +5 -5
  245. package/dist/vbrief-build/project-definition-io.d.ts +63 -3
  246. package/dist/vbrief-build/project-definition-io.js +357 -31
  247. package/dist/vbrief-build/project-definition-mutation.d.ts +32 -0
  248. package/dist/vbrief-build/project-definition-mutation.js +43 -0
  249. package/dist/vbrief-validate/conformance.d.ts +1 -0
  250. package/dist/vbrief-validate/conformance.js +85 -8
  251. package/dist/vbrief-validate/main.js +2 -0
  252. package/dist/vbrief-validate/precutover.js +5 -10
  253. package/dist/verify-ac/clauses.d.ts +62 -2
  254. package/dist/verify-ac/clauses.js +183 -111
  255. package/dist/verify-ac/evaluate.d.ts +9 -0
  256. package/dist/verify-ac/evaluate.js +32 -9
  257. package/dist/verify-ac/index.d.ts +1 -1
  258. package/dist/verify-ac/index.js +1 -1
  259. package/dist/verify-env/node-runtime.d.ts +8 -4
  260. package/dist/verify-env/node-runtime.js +9 -6
  261. package/dist/verify-env/toolchain-check.d.ts +35 -3
  262. package/dist/verify-env/toolchain-check.js +155 -36
  263. package/dist/verify-source/deposit-closure.d.ts +23 -0
  264. package/dist/verify-source/deposit-closure.js +162 -0
  265. package/dist/verify-source/index.d.ts +2 -0
  266. package/dist/verify-source/index.js +2 -0
  267. package/dist/verify-source/project-definition-mutation-boundary.d.ts +104 -0
  268. package/dist/verify-source/project-definition-mutation-boundary.js +326 -0
  269. package/dist/verify-source/semantic-single-source.d.ts +36 -0
  270. package/dist/verify-source/semantic-single-source.js +349 -0
  271. package/package.json +7 -3
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Candidate diff ownership for the merge-chokepoint orphan run (#3893).
3
+ *
4
+ * The unscoped sweep enumerates every running brief under `active/`. Composed
5
+ * on `check:merge` that gives one stranded brief merge authority over every
6
+ * open PR, and N stranded briefs make N single-brief lifecycle PRs mutually
7
+ * unmergeable — each leaves the other orphan. The pre-merge run cannot see the
8
+ * residue its own candidate is about to create either: that candidate's linked
9
+ * PR still reads `merged_at: null` while the gate runs.
10
+ *
11
+ * Scoping the merge run to the candidate's own diff removes the coupling
12
+ * without touching the detector. Repo-wide truth stays enforced at the
13
+ * delivery tip (HEAD on the delivery line falls back to the full sweep) and
14
+ * after merge (`--issue N`, #3429).
15
+ */
16
+ import { realpathSync } from "node:fs";
17
+ import { basename, dirname, join, relative, resolve } from "node:path";
18
+ import { resolveDeliveryBranch } from "../policy/delivery-branch.js";
19
+ import { defaultGitRunner } from "../session/git.js";
20
+ /** Symlink-resolved path, or the input when it cannot be resolved. */
21
+ function realpathOrSelf(path) {
22
+ try {
23
+ return realpathSync.native(path);
24
+ }
25
+ catch {
26
+ try {
27
+ return realpathSync(path);
28
+ }
29
+ catch {
30
+ return path;
31
+ }
32
+ }
33
+ }
34
+ /**
35
+ * Canonical directory: symlinks resolved, then precomposed. Git reports the
36
+ * canonical worktree root while the lifecycle root keeps the caller's
37
+ * spelling, and git precomposes Unicode (`core.precomposeunicode`) while some
38
+ * filesystems hand `readdir` the decomposed form.
39
+ */
40
+ function canonicalDir(path) {
41
+ return realpathOrSelf(resolve(path)).normalize("NFC");
42
+ }
43
+ /**
44
+ * One comparable form for a git path and a readdir path.
45
+ *
46
+ * Only the directory is canonicalized: the file itself may be a deletion in
47
+ * the candidate diff and no longer exist on disk.
48
+ */
49
+ export function normalizeScopePath(path) {
50
+ const abs = resolve(path);
51
+ const full = join(canonicalDir(dirname(abs)), basename(abs)).normalize("NFC");
52
+ return process.platform === "win32" ? full.toLowerCase() : full;
53
+ }
54
+ function sweep(reason) {
55
+ return { kind: "sweep", reason };
56
+ }
57
+ /**
58
+ * Split `-z` git output. NUL-delimited paths are never C-quoted, so a brief
59
+ * whose name git would quote (non-ASCII, quotes, backslashes) still compares
60
+ * equal to the readdir path instead of silently falling outside the candidate
61
+ * scope. `GitRunner` returns `-z` output as latin1 bytes, so decode to UTF-8.
62
+ */
63
+ function splitNulPaths(stdout) {
64
+ return stdout
65
+ .split("\0")
66
+ .map((entry) => Buffer.from(entry, "latin1").toString("utf8"))
67
+ .filter((entry) => entry.length > 0);
68
+ }
69
+ function refExists(cwd, ref, runGit) {
70
+ return runGit(cwd, ["rev-parse", "--verify", "-q", `${ref}^{commit}`]).code === 0;
71
+ }
72
+ /**
73
+ * Base ref for the candidate diff: explicit override, else `origin/<branch>`,
74
+ * else the local delivery branch. Null when none resolves.
75
+ */
76
+ export function resolveCandidateBaseRef(projectRoot, override, runGit) {
77
+ const explicit = override?.trim() ?? "";
78
+ if (explicit.length > 0) {
79
+ return refExists(projectRoot, explicit, runGit) ? explicit : null;
80
+ }
81
+ const branch = resolveDeliveryBranch(projectRoot, runGit).branch;
82
+ for (const candidate of [`origin/${branch}`, branch]) {
83
+ if (refExists(projectRoot, candidate, runGit)) {
84
+ return candidate;
85
+ }
86
+ }
87
+ return null;
88
+ }
89
+ /**
90
+ * Brief paths under `activeDir` that the candidate's own diff touches.
91
+ *
92
+ * Falls back to the repo-wide sweep — never to a narrower scan — when git,
93
+ * the base ref, or the diff is unavailable, so the flag cannot silently
94
+ * shrink what a merge gate looks at.
95
+ */
96
+ export function resolveCandidateScope(projectRoot, activeDir, options = {}) {
97
+ const runGit = options.runGit ?? defaultGitRunner;
98
+ const root = resolve(projectRoot);
99
+ const topLevel = runGit(root, ["rev-parse", "--show-toplevel"]);
100
+ if (topLevel.code !== 0) {
101
+ return sweep("not a git worktree, so no candidate diff exists");
102
+ }
103
+ const gitRoot = topLevel.stdout.trim();
104
+ if (gitRoot.length === 0) {
105
+ return sweep("git worktree root could not be resolved");
106
+ }
107
+ const baseRef = resolveCandidateBaseRef(root, options.baseRef, runGit);
108
+ if (baseRef === null) {
109
+ const requested = options.baseRef?.trim() ?? "";
110
+ return sweep(requested.length > 0
111
+ ? `base ref '${requested}' not found; fetch it or pass a resolvable --base-ref`
112
+ : "no delivery base ref found (no origin/<deliveryBranch> or local branch); fetch it or pass --base-ref");
113
+ }
114
+ // HEAD at or behind the delivery line is the delivery tip itself, not a
115
+ // candidate: keep repo-wide truth there.
116
+ if (runGit(root, ["merge-base", "--is-ancestor", "HEAD", baseRef]).code === 0) {
117
+ return sweep(`HEAD is on the ${baseRef} delivery line, so this run is the delivery-tip check`);
118
+ }
119
+ const mergeBase = runGit(root, ["merge-base", "HEAD", baseRef]);
120
+ if (mergeBase.code !== 0) {
121
+ return sweep(`could not compute the merge base with ${baseRef}`);
122
+ }
123
+ const base = mergeBase.stdout.trim();
124
+ if (base.length === 0) {
125
+ return sweep(`merge base with ${baseRef} is empty`);
126
+ }
127
+ // Canonicalize both sides before the relative: a symlinked checkout or an
128
+ // unequal Unicode spelling of the same root would otherwise read as `..`
129
+ // and restore the repo-wide sweep.
130
+ const activeRel = relative(canonicalDir(gitRoot), canonicalDir(activeDir)).replace(/\\/g, "/");
131
+ if (activeRel.length === 0 || activeRel.startsWith("..")) {
132
+ return sweep("active/ is outside the git worktree");
133
+ }
134
+ // Diff against the working tree, not HEAD: a locally activated brief is a
135
+ // pre-commit `task check` candidate too.
136
+ const changed = runGit(gitRoot, ["diff", "--name-only", "-z", base, "--", activeRel]);
137
+ if (changed.code !== 0) {
138
+ return sweep(`could not diff active/ against ${baseRef}`);
139
+ }
140
+ const untracked = runGit(gitRoot, [
141
+ "ls-files",
142
+ "--others",
143
+ "--exclude-standard",
144
+ "-z",
145
+ "--",
146
+ activeRel,
147
+ ]);
148
+ if (untracked.code !== 0) {
149
+ return sweep("could not list untracked briefs under active/");
150
+ }
151
+ const paths = new Set();
152
+ for (const rel of [...splitNulPaths(changed.stdout), ...splitNulPaths(untracked.stdout)]) {
153
+ paths.add(normalizeScopePath(resolve(gitRoot, rel)));
154
+ }
155
+ return { kind: "diff", baseRef, paths };
156
+ }
157
+ //# sourceMappingURL=candidate-scope.js.map
@@ -1,4 +1,5 @@
1
1
  import type { RunGhFn } from "../pr-protected-issues/types.js";
2
+ import type { GitRunner } from "../session/git.js";
2
3
  export type OutputStream = "stdout" | "stderr" | "none";
3
4
  export type OrphanKind = "shipped" | "unresolved";
4
5
  export interface OrphanActiveBrief {
@@ -6,11 +7,40 @@ export interface OrphanActiveBrief {
6
7
  readonly reason: string;
7
8
  readonly kind: OrphanKind;
8
9
  }
10
+ /**
11
+ * How the run's issue-state verdicts were reached (#3767). A pass with
12
+ * `unverified > 0` is not evidence that the tree is clean.
13
+ */
14
+ export interface OrphanActiveBasis {
15
+ readonly inventory: number;
16
+ readonly live: number;
17
+ readonly cache: number;
18
+ readonly unverified: number;
19
+ /** Oldest cache entry that produced a verdict, in ms. */
20
+ readonly maxCacheAgeMs: number | null;
21
+ /** True when reads resolved through `ghx`, a cached GET proxy. */
22
+ readonly proxied: boolean;
23
+ readonly elapsedMs: number;
24
+ readonly budgetMs: number;
25
+ }
26
+ /** What merge-chokepoint scoping decided for this run (#3893). */
27
+ export interface OrphanActiveScopeSummary {
28
+ readonly kind: "diff" | "sweep";
29
+ /** Ref the candidate diff was taken against; null on a sweep. */
30
+ readonly baseRef: string | null;
31
+ /** Why the run stayed repo-wide; null on a candidate diff. */
32
+ readonly reason: string | null;
33
+ /** Running briefs left unevaluated because this candidate does not own them. */
34
+ readonly skipped: number;
35
+ }
9
36
  export interface EvaluateResult {
10
37
  readonly code: 0 | 1 | 2;
11
38
  readonly message: string;
12
39
  readonly stream: OutputStream;
13
40
  readonly orphans: readonly OrphanActiveBrief[];
41
+ readonly basis: OrphanActiveBasis;
42
+ /** Null unless `changedOnly` was requested. */
43
+ readonly scope: OrphanActiveScopeSummary | null;
14
44
  }
15
45
  export interface EvaluateOptions {
16
46
  readonly quiet?: boolean;
@@ -19,6 +49,17 @@ export interface EvaluateOptions {
19
49
  readonly skipGh?: boolean;
20
50
  /** When set, scan only active/running briefs that reference this issue (#3429). */
21
51
  readonly issue?: number | null;
52
+ /** Monotonic clock seam so basis ages and budget checks are testable. */
53
+ readonly nowMs?: () => number;
54
+ /**
55
+ * Merge-chokepoint scoping (#3893): evaluate only active/running briefs the
56
+ * candidate's own diff touches. Ignored with `issue`, which is already one
57
+ * origin. Falls back to the repo-wide sweep when the base ref is unresolvable.
58
+ */
59
+ readonly changedOnly?: boolean;
60
+ /** Base ref for `changedOnly`; defaults to `origin/<deliveryBranch>`. */
61
+ readonly baseRef?: string | null;
62
+ readonly runGit?: GitRunner;
22
63
  }
23
64
  /**
24
65
  * Pure evaluator for orphaned active/running xBRIEF detection (#2321 / #3429).
@@ -26,6 +67,17 @@ export interface EvaluateOptions {
26
67
  * issues and/or a merged PR — the stop-at:pr-open orphan signature.
27
68
  * Pass `issue` to scan one origin after merge. Confirmed shipped prints
28
69
  * scope:complete; unresolved lookup still exits 1 with a retry remediation.
70
+ *
71
+ * Issue state resolves by query shape (#3767): scoped `--issue N` takes an
72
+ * authoritative read and stays fail-closed on unknown; the unscoped sweep uses
73
+ * one complete, fail-closed open-issue inventory and stays fail-open on
74
+ * unknown so offline work is not network-authorized. A cache hit is honoured
75
+ * only inside `ISSUE_CACHE_MAX_AGE_MS`, and every verdict reports its basis.
76
+ *
77
+ * `changedOnly` is the merge-chokepoint form (#3893): only briefs the
78
+ * candidate's own diff touches are evaluated, so a brief stranded by another
79
+ * merge cannot fail this candidate. It falls back to the repo-wide sweep at
80
+ * the delivery tip and whenever the base ref is unresolvable.
29
81
  */
30
82
  export declare function evaluate(projectRoot: string, options?: EvaluateOptions): EvaluateResult;
31
83
  //# sourceMappingURL=evaluate.d.ts.map