@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,147 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ /**
4
+ * C1 declared deposit closure (#3601 / #3899).
5
+ *
6
+ * Required consumer-deposit paths are a closed typed declaration, not a
7
+ * regex over AGENTS.md RFC2119 prose. Existence checks reuse existsSync
8
+ * the same way validate-links.ts does, against a staged pack root (the
9
+ * prepack flatten), not the source checkout.
10
+ */
11
+ export const DEPOSIT_REQUIRED_SCHEMA = "deft.deposit-required-paths.v1";
12
+ export const DEPOSIT_REQUIRED_REL = "contracts/deposit-required-paths.json";
13
+ export const DEPOSIT_PREFIX = ".deft/core/";
14
+ /** Parser-visible field. Not a scan of ! / backtick paths. */
15
+ const DEPOSIT_REQUIRED_COMMENT = /<!--\s*deposit-required:\s+(\S+)\s*-->/g;
16
+ export function extractDepositRequiredComments(source) {
17
+ const out = [];
18
+ const re = new RegExp(DEPOSIT_REQUIRED_COMMENT.source, "g");
19
+ let match = re.exec(source);
20
+ while (match !== null) {
21
+ const path = match[1];
22
+ if (path !== undefined) {
23
+ out.push(path);
24
+ }
25
+ match = re.exec(source);
26
+ }
27
+ return out;
28
+ }
29
+ export function parseDepositRequiredDeclaration(jsonText) {
30
+ let _data;
31
+ let parsed;
32
+ try {
33
+ parsed = JSON.parse(jsonText);
34
+ }
35
+ catch (err) {
36
+ const reason = err instanceof Error ? err.message : String(err);
37
+ throw new Error(`deposit-required: invalid JSON (${reason})`);
38
+ }
39
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
40
+ throw new Error("deposit-required: expected an object");
41
+ }
42
+ const data = parsed;
43
+ if (data.schema !== DEPOSIT_REQUIRED_SCHEMA) {
44
+ throw new Error("deposit-required: expected schema " +
45
+ DEPOSIT_REQUIRED_SCHEMA +
46
+ ", got " +
47
+ String(data.schema));
48
+ }
49
+ if (!Array.isArray(data.paths) || data.paths.length === 0) {
50
+ throw new Error("deposit-required: paths must be a non-empty array of strings");
51
+ }
52
+ const paths = [];
53
+ for (const item of data.paths) {
54
+ if (typeof item !== "string" ||
55
+ !item.startsWith(DEPOSIT_PREFIX) ||
56
+ item.includes("\\") ||
57
+ item.includes("..")) {
58
+ throw new Error(`deposit-required: invalid path ${String(item)}`);
59
+ }
60
+ paths.push(item);
61
+ }
62
+ return { schema: DEPOSIT_REQUIRED_SCHEMA, paths };
63
+ }
64
+ export function packRelativeFromDepositPath(declared) {
65
+ if (!declared.startsWith(DEPOSIT_PREFIX)) {
66
+ throw new Error(`deposit-required: not a deposit path: ${declared}`);
67
+ }
68
+ return declared.slice(DEPOSIT_PREFIX.length);
69
+ }
70
+ /** Prepack mapping used by @deftai/directive-content. */
71
+ export function sourcePathForPackRelative(repoRoot, packRelative) {
72
+ const rel = packRelative.replace(/\\/g, "/");
73
+ if (rel === "main.md" ||
74
+ rel === "SKILL.md" ||
75
+ rel === "Taskfile.yml" ||
76
+ rel.startsWith("tasks/") ||
77
+ rel.startsWith(".githooks/")) {
78
+ return join(repoRoot, ...rel.split("/"));
79
+ }
80
+ return join(repoRoot, "content", ...rel.split("/"));
81
+ }
82
+ export function evaluateDepositClosure(options) {
83
+ const missing = [];
84
+ for (const declared of options.paths) {
85
+ const rel = packRelativeFromDepositPath(declared);
86
+ const target = join(options.packRoot, ...rel.split("/"));
87
+ if (!existsSync(target)) {
88
+ missing.push(declared);
89
+ }
90
+ }
91
+ return { ok: missing.length === 0, missing, checked: options.paths.length };
92
+ }
93
+ export function loadDepositRequiredDeclaration(filePath) {
94
+ return parseDepositRequiredDeclaration(readFileSync(filePath, "utf8"));
95
+ }
96
+ export function resolveDeclarationFile(root) {
97
+ const underContent = join(root, "content", DEPOSIT_REQUIRED_REL);
98
+ if (existsSync(underContent)) {
99
+ return underContent;
100
+ }
101
+ const underRoot = join(root, DEPOSIT_REQUIRED_REL);
102
+ if (existsSync(underRoot)) {
103
+ return underRoot;
104
+ }
105
+ return null;
106
+ }
107
+ export function evaluateInstalledDepositClosure(projectRoot) {
108
+ const deftDir = join(projectRoot, ".deft", "core");
109
+ const declarationPath = resolveDeclarationFile(deftDir) ?? resolveDeclarationFile(projectRoot);
110
+ if (declarationPath === null) {
111
+ return { skipped: true, missing: [], declarationPath: null, error: null };
112
+ }
113
+ if (!existsSync(deftDir)) {
114
+ return { skipped: true, missing: [], declarationPath, error: null };
115
+ }
116
+ try {
117
+ const declaration = loadDepositRequiredDeclaration(declarationPath);
118
+ const result = evaluateDepositClosure({ packRoot: deftDir, paths: declaration.paths });
119
+ return { skipped: false, missing: result.missing, declarationPath, error: null };
120
+ }
121
+ catch (err) {
122
+ const reason = err instanceof Error ? err.message : String(err);
123
+ return { skipped: false, missing: [], declarationPath, error: reason };
124
+ }
125
+ }
126
+ export function renderDeclaredDepositClosureLine(result) {
127
+ if (result.skipped) {
128
+ return "Deposit required-paths: skip -- no C1 declaration in this tree.";
129
+ }
130
+ if (result.error) {
131
+ return ("Deposit required-paths: fail -- could not read C1 declaration (" +
132
+ result.error +
133
+ "). Run directive update to refresh the deposit (#3601 C1).");
134
+ }
135
+ if (result.missing.length === 0) {
136
+ return "Deposit required-paths: ok -- declared C1 paths exist in .deft/core.";
137
+ }
138
+ const sample = result.missing.slice(0, 5).join(", ");
139
+ const extra = result.missing.length > 5 ? ` (+${String(result.missing.length - 5)} more)` : "";
140
+ return ("Deposit required-paths: fail -- " +
141
+ String(result.missing.length) +
142
+ " declared path(s) missing from .deft/core. Examples: " +
143
+ sample +
144
+ extra +
145
+ ". Run directive update to refresh the deposit (#3601 C1).");
146
+ }
147
+ //# sourceMappingURL=deposit-required.js.map
@@ -1,5 +1,6 @@
1
1
  export { resolveCapacityAllocation } from "./capacity-policy.js";
2
2
  export { computeReport, renderReport } from "./capacity-show.js";
3
+ export * as depositRequired from "./deposit-required.js";
3
4
  export { isDatePrefixedVbriefFilename } from "./filename.js";
4
5
  export { extractLinkTargets, shouldSkipLinkTarget } from "./link-parser.js";
5
6
  export * from "./types.js";
@@ -1,5 +1,6 @@
1
1
  export { resolveCapacityAllocation } from "./capacity-policy.js";
2
2
  export { computeReport, renderReport } from "./capacity-show.js";
3
+ export * as depositRequired from "./deposit-required.js";
3
4
  export { isDatePrefixedVbriefFilename } from "./filename.js";
4
5
  export { extractLinkTargets, shouldSkipLinkTarget } from "./link-parser.js";
5
6
  export * from "./types.js";
@@ -18,8 +18,7 @@ export interface ValidateLinksOptions {
18
18
  readonly linkCheckStrict?: boolean;
19
19
  readonly argv?: readonly string[];
20
20
  }
21
- /**
22
- * Validate internal markdown links. Faithful to `scripts/validate-links.py`.
23
- */
21
+ /** Collect broken internal markdown links under cwd. Used by packed-fixture tests (#3937). */
22
+ export declare function collectBrokenLinks(cwd: string): BrokenLink[];
24
23
  export declare function evaluate(options?: ValidateLinksOptions): EvaluateResult;
25
24
  //# sourceMappingURL=validate-links.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readdirSync, readFileSync } from "node:fs";
2
2
  import { join, relative, resolve, sep } from "node:path";
3
+ import { evaluateLiveProcedureTargets, formatLiveProcedureFailure, } from "../deposit/live-procedure-targets.js";
3
4
  import { NON_PRODUCT_DIRS } from "../fs/non-product-dirs.js";
4
5
  import { extractLinkTargets, shouldSkipLinkTarget } from "./link-parser.js";
5
6
  /**
@@ -43,7 +44,8 @@ function collectMarkdownFiles(root) {
43
44
  walk(root, []);
44
45
  return out.sort();
45
46
  }
46
- function findBrokenLinks(cwd) {
47
+ /** Collect broken internal markdown links under cwd. Used by packed-fixture tests (#3937). */
48
+ export function collectBrokenLinks(cwd) {
47
49
  const broken = [];
48
50
  const root = resolve(cwd);
49
51
  for (const md of collectMarkdownFiles(root)) {
@@ -82,13 +84,38 @@ function findBrokenLinks(cwd) {
82
84
  /**
83
85
  * Validate internal markdown links. Faithful to `scripts/validate-links.py`.
84
86
  */
87
+ function contentRootForC3(cwd) {
88
+ const underContent = join(cwd, "content");
89
+ return existsSync(underContent) ? underContent : cwd;
90
+ }
91
+ function extraMarkdownForC3(cwd) {
92
+ const extras = [];
93
+ for (const name of ["main.md", "SKILL.md"]) {
94
+ const absolutePath = join(cwd, name);
95
+ if (existsSync(absolutePath)) {
96
+ extras.push({ relativePath: name, absolutePath });
97
+ }
98
+ }
99
+ return extras;
100
+ }
85
101
  export function evaluate(options = {}) {
86
102
  const cwd = resolve(options.cwd ?? ".");
87
103
  const strict = options.strict === true ||
88
104
  options.linkCheckStrict === true ||
89
105
  (options.argv ?? []).includes("--strict") ||
90
106
  process.env.LINK_CHECK_STRICT === "1";
91
- const broken = findBrokenLinks(cwd);
107
+ const c3 = evaluateLiveProcedureTargets({
108
+ stagedRoot: contentRootForC3(cwd),
109
+ extraFiles: extraMarkdownForC3(cwd),
110
+ });
111
+ if (c3.uniqueTargets.length > 0) {
112
+ return {
113
+ code: 1,
114
+ message: formatLiveProcedureFailure(c3),
115
+ stream: "stdout",
116
+ };
117
+ }
118
+ const broken = collectBrokenLinks(cwd);
92
119
  if (broken.length === 0) {
93
120
  return {
94
121
  code: 0,
@@ -6,8 +6,13 @@ export interface ActivateOptions {
6
6
  readonly now?: Date;
7
7
  }
8
8
  /**
9
- * Pure activator returns ``{ exitCode, message }``. Faithful to
10
- * ``scripts/vbrief_activate.py::activate``.
9
+ * Pure activator -- returns ``{ exitCode, message }``. Ported from
10
+ * ``scripts/vbrief_activate.py::activate`` under the #1782 byte-identical
11
+ * parity contract, with one deliberate divergence: the Python oracle created a
12
+ * ``vBRIEFInfo`` when the artifact carried no envelope, and that behaviour is
13
+ * NOT preserved (#3933). Envelope handling now follows the shared lifecycle
14
+ * policy -- stamp whichever envelope exists, refuse an envelope-less artifact
15
+ * by name.
11
16
  */
12
17
  export declare function activate(vbriefPath: string, options?: ActivateOptions): ActivateResult;
13
18
  //# sourceMappingURL=activate.d.ts.map
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, unli
2
2
  import { basename, dirname, resolve } from "node:path";
3
3
  import { containedWrite } from "../fs/contained-write.js";
4
4
  import { assertProjectionContained, ProjectionContainmentError, } from "../fs/projection-containment.js";
5
+ import { BRIEF_ENVELOPE_KEYS, missingEnvelopeMessage, stampExistingEnvelopes, } from "../lifecycle/brief-envelope.js";
5
6
  import { evaluateEffortActivateGate } from "../scope/effort-activate-gate.js";
6
7
  import { utcNowIso } from "../scope/vbrief-json.js";
7
8
  import { pythonJsonPretty } from "../vbrief-build/json.js";
@@ -57,8 +58,13 @@ function loadVbrief(vbriefPath) {
57
58
  return { payload: payload, error: null };
58
59
  }
59
60
  /**
60
- * Pure activator returns ``{ exitCode, message }``. Faithful to
61
- * ``scripts/vbrief_activate.py::activate``.
61
+ * Pure activator -- returns ``{ exitCode, message }``. Ported from
62
+ * ``scripts/vbrief_activate.py::activate`` under the #1782 byte-identical
63
+ * parity contract, with one deliberate divergence: the Python oracle created a
64
+ * ``vBRIEFInfo`` when the artifact carried no envelope, and that behaviour is
65
+ * NOT preserved (#3933). Envelope handling now follows the shared lifecycle
66
+ * policy -- stamp whichever envelope exists, refuse an envelope-less artifact
67
+ * by name.
62
68
  */
63
69
  export function activate(vbriefPath, options = {}) {
64
70
  const now = options.now ?? new Date();
@@ -143,19 +149,26 @@ export function activate(vbriefPath, options = {}) {
143
149
  }
144
150
  throw err;
145
151
  }
146
- planObj.status = TARGET_STATUS;
147
- let info = payload.vBRIEFInfo;
148
- if (info === undefined) {
149
- info = {};
150
- payload.vBRIEFInfo = info;
152
+ for (const key of BRIEF_ENVELOPE_KEYS) {
153
+ if (!(key in payload)) {
154
+ continue;
155
+ }
156
+ const env = payload[key];
157
+ if (env === null || typeof env !== "object" || Array.isArray(env)) {
158
+ return {
159
+ exitCode: 1,
160
+ message: `vBRIEF at ${vbriefPath} has a non-object \`${key}\` -- malformed.`,
161
+ };
162
+ }
151
163
  }
152
- if (info === null || typeof info !== "object" || Array.isArray(info)) {
153
- return {
154
- exitCode: 1,
155
- message: `vBRIEF at ${vbriefPath} has a non-object \`vBRIEFInfo\` -- malformed.`,
156
- };
164
+ // #3933: stamp the envelope the brief already carries; never create one. A
165
+ // manufactured version-less `vBRIEFInfo` wins schema resolution over a valid
166
+ // `xBRIEFInfo`, so the brief this verb just moved would fail validation.
167
+ const stampedEnvelopes = stampExistingEnvelopes(payload, utcNowIso(now));
168
+ if (stampedEnvelopes.length === 0) {
169
+ return { exitCode: 1, message: missingEnvelopeMessage(`vBRIEF at ${vbriefPath}`) };
157
170
  }
158
- info.updated = utcNowIso(now);
171
+ planObj.status = TARGET_STATUS;
159
172
  try {
160
173
  mkdirSync(activeDir, { recursive: true });
161
174
  }
@@ -3,7 +3,8 @@ export { DEFAULT_STATUS_FOR_FOLDER, DEPRECATION_SENTINEL, EMITTED_VBRIEF_VERSION
3
3
  export { pythonJsonPretty } from "./json.js";
4
4
  export { cmdVbriefBuild, run, usage } from "./main.js";
5
5
  export { PARITY_SCENARIO_NAMES, renderScenarioOutput, runParityScenario, SAMPLE_PROJECT_MD, SAMPLE_ROADMAP_MD, SAMPLE_SPEC_MD, SAMPLE_SPEC_VBRIEF, } from "./parity-scenarios.js";
6
- export { atomicWriteProjectDefinition, loadProjectDefinitionForMutation, projectDefinitionMutationLock, projectDefinitionPath, } from "./project-definition-io.js";
6
+ export { atomicWriteProjectDefinition, CONFIGURED_PROJECT_DEFINITION_LABEL, loadProjectDefinitionForMutation, type MutationLockDeps, ProjectDefinitionLockError, parseProjectDefinitionAt, projectDefinitionArtifactLabel, projectDefinitionMutationLock, projectDefinitionPath, } from "./project-definition-io.js";
7
+ export { type ProjectDefinitionMutation, withProjectDefinitionMutation, } from "./project-definition-mutation.js";
7
8
  export { loadProjectInvariants, parseProjectInvariantsField } from "./project-invariants-io.js";
8
9
  export { buildScopeVbriefFromReconciled, defaultStatusForFolder, folderForStatus, migrationTimestamp, planStatusMatchesFolder, } from "./routing.js";
9
10
  export { deriveOverviewNarrative, extractTechStack, firstProseParagraph, parseRoadmapItems, resolveRepoUrl, } from "./sources.js";
@@ -3,7 +3,8 @@ export { DEFAULT_STATUS_FOR_FOLDER, DEPRECATION_SENTINEL, EMITTED_VBRIEF_VERSION
3
3
  export { pythonJsonPretty } from "./json.js";
4
4
  export { cmdVbriefBuild, run, usage } from "./main.js";
5
5
  export { PARITY_SCENARIO_NAMES, renderScenarioOutput, runParityScenario, SAMPLE_PROJECT_MD, SAMPLE_ROADMAP_MD, SAMPLE_SPEC_MD, SAMPLE_SPEC_VBRIEF, } from "./parity-scenarios.js";
6
- export { atomicWriteProjectDefinition, loadProjectDefinitionForMutation, projectDefinitionMutationLock, projectDefinitionPath, } from "./project-definition-io.js";
6
+ export { atomicWriteProjectDefinition, CONFIGURED_PROJECT_DEFINITION_LABEL, loadProjectDefinitionForMutation, ProjectDefinitionLockError, parseProjectDefinitionAt, projectDefinitionArtifactLabel, projectDefinitionMutationLock, projectDefinitionPath, } from "./project-definition-io.js";
7
+ export { withProjectDefinitionMutation, } from "./project-definition-mutation.js";
7
8
  export { loadProjectInvariants, parseProjectInvariantsField } from "./project-invariants-io.js";
8
9
  export { buildScopeVbriefFromReconciled, defaultStatusForFolder, folderForStatus, migrationTimestamp, planStatusMatchesFolder, } from "./routing.js";
9
10
  export { deriveOverviewNarrative, extractTechStack, firstProseParagraph, parseRoadmapItems, resolveRepoUrl, } from "./sources.js";
@@ -2,7 +2,7 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { createScopeVbrief, referenceWithDefaultTrust, slugify } from "./build.js";
4
4
  import { pythonJsonPretty } from "./json.js";
5
- import { atomicWriteProjectDefinition, loadProjectDefinitionForMutation, projectDefinitionMutationLock, } from "./project-definition-io.js";
5
+ import { withProjectDefinitionMutation } from "./project-definition-mutation.js";
6
6
  import { buildScopeVbriefFromReconciled, folderForStatus, planStatusMatchesFolder, } from "./routing.js";
7
7
  import { deriveOverviewNarrative, extractTechStack, firstProseParagraph, parseRoadmapItems, resolveRepoUrl, } from "./sources.js";
8
8
  import { createSpeckitScopeVbrief, dependenciesForItem, edgeNodes, migrateSpeckitPlan, speckitIpIndex, speckitIpSlug, } from "./speckit.js";
@@ -209,11 +209,11 @@ export function runParityScenario(name, ctx) {
209
209
  const pdPath = join(vbriefDir, "PROJECT-DEFINITION.xbrief.json");
210
210
  writeFileSync(pdPath, pythonJsonPretty(seed), "utf8");
211
211
  let roundtrip = {};
212
- projectDefinitionMutationLock(ctx.fixtureRoot, () => {
213
- const [data, path] = loadProjectDefinitionForMutation(ctx.fixtureRoot);
212
+ withProjectDefinitionMutation(ctx.fixtureRoot, (mutation) => {
213
+ const data = mutation.load();
214
214
  data.plan.policy = { wipCap: 12 };
215
- atomicWriteProjectDefinition(path, data);
216
- roundtrip = JSON.parse(readFileSync(path, "utf8"));
215
+ mutation.persist(data);
216
+ roundtrip = JSON.parse(readFileSync(mutation.artifactPath, "utf8"));
217
217
  });
218
218
  return { scenario: name, ok: true, payload: roundtrip };
219
219
  }
@@ -1,4 +1,15 @@
1
1
  import type { JsonObject } from "./types.js";
2
+ /** Setup override for a noncanonical PROJECT-DEFINITION path. */
3
+ export declare const ENV_PROJECT_PATH = "DEFT_PROJECT_PATH";
4
+ /**
5
+ * Constant display label for a PROJECT-DEFINITION reached through the
6
+ * `DEFT_PROJECT_PATH` override (#3796). A configured path is operator- or
7
+ * environment-supplied data, so lock and loader diagnostics name this label
8
+ * instead of interpolating the raw path. Matches the label already used by
9
+ * `verify:vbrief-conformance` so one artifact reads the same way on every
10
+ * diagnostic surface.
11
+ */
12
+ export declare const CONFIGURED_PROJECT_DEFINITION_LABEL = "<configured PROJECT-DEFINITION>";
2
13
  /**
3
14
  * Absolute path to the PROJECT-DEFINITION artifact. Layout-aware (#2302):
4
15
  * resolves `xbrief/PROJECT-DEFINITION.xbrief.json` on a migrated tree, else the
@@ -6,14 +17,63 @@ import type { JsonObject } from "./types.js";
6
17
  * name the path that actually applies to the project's layout.
7
18
  */
8
19
  export declare function projectDefinitionPath(projectRoot: string): string;
20
+ /**
21
+ * Control-safe label for an artifact path in a human diagnostic (#3796).
22
+ * A configured artifact collapses to {@link CONFIGURED_PROJECT_DEFINITION_LABEL};
23
+ * a layout-resolved canonical artifact keeps its path because the layout
24
+ * resolver derived it rather than reading it from configuration.
25
+ */
26
+ export declare function projectDefinitionArtifactLabel(artifactPath: string): string;
27
+ /** Result of probing whether a recorded lock owner PID is still running. */
28
+ export type ProcessLiveness = "dead" | "alive" | "unknown";
29
+ /**
30
+ * Why an acquisition attempt could not take the lock. Only `contended` is
31
+ * ordinary traffic; the rest fail closed to manual recovery (#3796).
32
+ */
33
+ export type LockBlockedReason = "contended" | "owner-alive" | "owner-liveness-unknown" | "malformed-lock-directory" | "legacy-file-sidecar";
9
34
  export interface MutationLockDeps {
10
35
  readonly sleepMs?: (ms: number) => void;
11
- readonly now?: () => number;
36
+ /**
37
+ * Monotonic millisecond clock. One budget is derived from a single reading of
38
+ * this clock and shared by every retry and recovery branch (#3796), so a
39
+ * wall-clock step or a recovery detour cannot extend the acquisition window.
40
+ */
41
+ readonly monotonicNowMs?: () => number;
42
+ /** Total acquisition budget in milliseconds. */
43
+ readonly acquisitionBudgetMs?: number;
44
+ /**
45
+ * Three-state liveness oracle. Only `dead` authorises an automatic reap;
46
+ * `alive` (including possible PID reuse) and `unknown` fail closed.
47
+ */
48
+ readonly probeProcess?: (pid: number) => ProcessLiveness;
49
+ readonly writeOwner?: (fd: number, payload: string) => number;
50
+ readonly renameLock?: (source: string, destination: string) => void;
51
+ /** Test seam: fires after the stale owner entry is unlinked, before `rmdir`. */
52
+ readonly beforeLockDirRemove?: (lockPath: string) => void;
12
53
  }
13
- /** Serialise PROJECT-DEFINITION read-modify-write critical sections. */
14
- export declare function projectDefinitionMutationLock<T>(projectRoot: string, fn: () => T, deps?: MutationLockDeps): T;
54
+ /** Acquisition failed within the shared budget. `reason` names the blocker. */
55
+ export declare class ProjectDefinitionLockError extends Error {
56
+ readonly reason: LockBlockedReason;
57
+ constructor(message: string, reason: LockBlockedReason);
58
+ }
59
+ /**
60
+ * Serialise PROJECT-DEFINITION read-modify-write critical sections.
61
+ *
62
+ * Acquisition publishes a fully-materialised, non-empty owner directory by
63
+ * renaming it onto the public lock pathname, so no contender can observe a
64
+ * partial lock. Prefer {@link withProjectDefinitionMutation} in
65
+ * `project-definition-mutation.ts`: it binds load/parse/persist to the captured
66
+ * artifact path so a caller cannot lock one identity and write another (#3796).
67
+ */
68
+ export declare function projectDefinitionMutationLock<T>(projectRoot: string, fn: (artifactPath: string) => T, deps?: MutationLockDeps): T;
15
69
  /** Read PROJECT-DEFINITION.vbrief.json and return ``(data, path)``. */
16
70
  export declare function loadProjectDefinitionForMutation(projectRoot: string): [JsonObject, string];
71
+ /**
72
+ * Load and parse the PROJECT-DEFINITION at an already-captured path (#3796).
73
+ * Diagnostics name the artifact through {@link projectDefinitionArtifactLabel}
74
+ * so a configured path is never interpolated raw.
75
+ */
76
+ export declare function parseProjectDefinitionAt(path: string): JsonObject;
17
77
  /** Atomically write ``data`` to ``path`` as pretty-printed JSON. */
18
78
  export declare function atomicWriteProjectDefinition(path: string, data: JsonObject): void;
19
79
  //# sourceMappingURL=project-definition-io.d.ts.map