@unbrained/pm-cli 2026.8.16 → 2026.8.18

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 (225) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/AGENTS.md +4 -3
  3. package/CHANGELOG.md +65 -6
  4. package/README.md +16 -16
  5. package/dist/cli/error-guidance.js +7 -4
  6. package/dist/cli/public.d.ts +2 -0
  7. package/dist/cli/public.js +21 -0
  8. package/dist/cli/register-list-query.js +132 -51
  9. package/dist/cli/register-mutation.js +4 -4
  10. package/dist/cli-bundle/bundle-manifest.json +148 -148
  11. package/dist/cli-bundle/chunks/chunk-5UZZAJKR.js +3 -0
  12. package/dist/cli-bundle/chunks/chunk-ALDJGKAK.js +2 -0
  13. package/dist/cli-bundle/chunks/chunk-BSK2IN3C.js +8 -0
  14. package/dist/cli-bundle/chunks/chunk-DY4DMUMC.js +197 -0
  15. package/dist/cli-bundle/chunks/{chunk-73UGEBRS.js → chunk-GNFAFIJI.js} +10 -10
  16. package/dist/cli-bundle/chunks/chunk-L5Q2CLPE.js +35 -0
  17. package/dist/cli-bundle/chunks/{chunk-RIS565OA.js → chunk-PVRUN5ZS.js} +5 -5
  18. package/dist/cli-bundle/chunks/chunk-RZQTVMRQ.js +2 -0
  19. package/dist/cli-bundle/chunks/chunk-SARFF5H5.js +3 -0
  20. package/dist/cli-bundle/chunks/chunk-UYCLQVL2.js +13 -0
  21. package/dist/cli-bundle/chunks/{chunk-URW4QRMI.js → chunk-YRGOLZA7.js} +59 -55
  22. package/dist/cli-bundle/chunks/register-list-query-I23LALEE.js +11 -0
  23. package/dist/cli-bundle/chunks/register-mutation-6YGU3GPH.js +20 -0
  24. package/dist/cli-bundle/chunks/{register-operations-KGDNRMCL.js → register-operations-4HTFC6J7.js} +2 -2
  25. package/dist/cli-bundle/chunks/{register-setup-NVXBOD5I.js → register-setup-PPPEF3SN.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-2PN4TJXH.js +2 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-C7JUBRFP.js → chunk-3TKWMNKF.js} +3 -3
  28. package/dist/cli-bundle/focused-chunks/chunk-5AF3ZBNB.js +155 -0
  29. package/dist/cli-bundle/focused-chunks/chunk-C5IW2NDA.js +2 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-CODV5LUT.js → chunk-EUEGXZ2A.js} +3 -3
  31. package/dist/cli-bundle/focused-chunks/{chunk-4JPEBFFC.js → chunk-EX6MKP2X.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/{chunk-SSNDYZTM.js → chunk-K43KKAFS.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/{chunk-6ROKKT4X.js → chunk-M62NO7EI.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-T46KLOIB.js → chunk-ODOVCP45.js} +47 -47
  35. package/dist/cli-bundle/focused-chunks/chunk-RNDNMARJ.js +16 -0
  36. package/dist/cli-bundle/focused-chunks/chunk-TN4AE665.js +26 -0
  37. package/dist/cli-bundle/focused-chunks/chunk-TVV2DONO.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-UI6AJ5TD.js +4 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-V5XTGLK7.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-WGHQVU6P.js +2 -0
  41. package/dist/cli-bundle/focused-chunks/chunk-XYNBXTDQ.js +2 -0
  42. package/dist/cli-bundle/focused-chunks/chunk-Z56ECT7I.js +2 -0
  43. package/dist/cli-bundle/main.js +7 -7
  44. package/dist/cli-bundle/sdk-authoring.js +1 -1
  45. package/dist/cli-bundle/sdk-contracts.js +1 -1
  46. package/dist/cli-bundle/sdk-core.js +31 -31
  47. package/dist/cli-bundle/sdk-governance.js +1 -1
  48. package/dist/cli-bundle/sdk-graph.js +1 -1
  49. package/dist/cli-bundle/sdk-merge.js +32 -32
  50. package/dist/cli-bundle/sdk-query.js +1 -1
  51. package/dist/cli-bundle/sdk-runtime.js +1 -1
  52. package/dist/cli-bundle/sdk-testing.js +1 -1
  53. package/dist/cli-bundle/sdk.js +4 -2
  54. package/dist/core/config/nested-settings.js +8 -2
  55. package/dist/core/extensions/exporter-output-contract.d.ts +12 -0
  56. package/dist/core/extensions/exporter-output-contract.js +67 -0
  57. package/dist/core/extensions/extension-types.d.ts +36 -1
  58. package/dist/core/extensions/extension-types.js +2 -2
  59. package/dist/core/extensions/loader.js +43 -48
  60. package/dist/core/extensions/manifest-schema.d.ts +20 -0
  61. package/dist/core/extensions/manifest-schema.js +52 -0
  62. package/dist/core/history/event-index.d.ts +5 -0
  63. package/dist/core/history/event-index.js +133 -27
  64. package/dist/core/history/replay.js +32 -14
  65. package/dist/core/schema/fields-file.d.ts +1 -1
  66. package/dist/core/schema/fields-file.js +2 -2
  67. package/dist/core/schema/runtime-field-values.js +115 -9
  68. package/dist/core/schema/runtime-schema.d.ts +3 -1
  69. package/dist/core/schema/runtime-schema.js +124 -3
  70. package/dist/core/sentry/helpers.js +3 -3
  71. package/dist/core/shared/constants.js +5 -2
  72. package/dist/core/shared/errors.d.ts +10 -0
  73. package/dist/core/shared/errors.js +2 -2
  74. package/dist/core/shared/time.d.ts +2 -0
  75. package/dist/core/shared/time.js +27 -2
  76. package/dist/core/store/settings-validator.d.ts +4 -0
  77. package/dist/core/store/settings-validator.js +3 -2
  78. package/dist/core/store/settings.js +8 -2
  79. package/dist/mcp/tool-definitions.js +12 -7
  80. package/dist/sdk/agent/refusal-reachability.d.ts +46 -6
  81. package/dist/sdk/agent/refusal-reachability.js +350 -8
  82. package/dist/sdk/authoring.d.ts +1 -1
  83. package/dist/sdk/authoring.js +2 -2
  84. package/dist/sdk/cli-bootstrap.d.ts +2 -2
  85. package/dist/sdk/cli-bootstrap.js +4 -4
  86. package/dist/sdk/cli-contracts/command-aliases.d.ts +34 -2
  87. package/dist/sdk/cli-contracts/command-aliases.js +64 -13
  88. package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -0
  89. package/dist/sdk/cli-contracts/enum-contracts.js +9 -2
  90. package/dist/sdk/cli-contracts/flag-contracts.js +11 -7
  91. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +70 -0
  92. package/dist/sdk/cli-contracts/grammar-contracts.js +345 -0
  93. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +19 -2
  94. package/dist/sdk/cli-contracts/runtime-contracts.js +61 -14
  95. package/dist/sdk/cli-contracts/tool-parameter-tables.js +10 -4
  96. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  97. package/dist/sdk/cli-contracts/tool-schema.js +20 -11
  98. package/dist/sdk/cli-contracts.d.ts +2 -2
  99. package/dist/sdk/cli-contracts.js +4 -4
  100. package/dist/sdk/completion.js +13 -15
  101. package/dist/sdk/compose.d.ts +9 -5
  102. package/dist/sdk/compose.js +33 -3
  103. package/dist/sdk/context-intent-contracts.d.ts +8 -4
  104. package/dist/sdk/context-intent-contracts.js +76 -31
  105. package/dist/sdk/contracts.d.ts +1 -0
  106. package/dist/sdk/contracts.js +3 -2
  107. package/dist/sdk/core.d.ts +1 -1
  108. package/dist/sdk/core.js +3 -3
  109. package/dist/sdk/dependency-flag-validation.d.ts +9 -2
  110. package/dist/sdk/dependency-flag-validation.js +101 -35
  111. package/dist/sdk/environment/host-environment-errors.js +25 -7
  112. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +78 -14
  113. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +62 -14
  114. package/dist/sdk/governance/assurance-action.d.ts +3 -7
  115. package/dist/sdk/governance/assurance-action.js +97 -2
  116. package/dist/sdk/governance/boundary-fixtures.d.ts +86 -0
  117. package/dist/sdk/governance/boundary-fixtures.js +201 -0
  118. package/dist/sdk/governance/defect-recurrence-signals.d.ts +10 -0
  119. package/dist/sdk/governance/defect-recurrence-signals.js +25 -0
  120. package/dist/sdk/governance/defect-recurrence.d.ts +242 -0
  121. package/dist/sdk/governance/defect-recurrence.js +523 -0
  122. package/dist/sdk/governance.d.ts +2 -0
  123. package/dist/sdk/governance.js +4 -2
  124. package/dist/sdk/graph/governance.js +3 -2
  125. package/dist/sdk/guide-topics.js +193 -4
  126. package/dist/sdk/index.d.ts +7 -3
  127. package/dist/sdk/index.js +8 -5
  128. package/dist/sdk/init-agent-guidance.js +3 -3
  129. package/dist/sdk/lifecycle/create.js +4 -2
  130. package/dist/sdk/lifecycle/update-many.js +15 -2
  131. package/dist/sdk/lifecycle/update.js +5 -2
  132. package/dist/sdk/linked-artifacts.js +63 -14
  133. package/dist/sdk/mutation-events.d.ts +18 -2
  134. package/dist/sdk/mutation-events.js +59 -16
  135. package/dist/sdk/output.d.ts +44 -0
  136. package/dist/sdk/output.js +28 -2
  137. package/dist/sdk/query/complete-list.d.ts +94 -0
  138. package/dist/sdk/query/complete-list.js +173 -0
  139. package/dist/sdk/query/get.d.ts +2 -0
  140. package/dist/sdk/query/get.js +32 -7
  141. package/dist/sdk/query/list.js +5 -2
  142. package/dist/sdk/query.d.ts +1 -0
  143. package/dist/sdk/query.js +3 -2
  144. package/dist/sdk/read-output-contracts.d.ts +2 -2
  145. package/dist/sdk/read-output-contracts.js +36 -9
  146. package/dist/sdk/relationship-analytics.js +90 -14
  147. package/dist/sdk/relationship-kinds/contract.d.ts +4 -0
  148. package/dist/sdk/relationship-kinds/contract.js +3 -2
  149. package/dist/sdk/relationships.d.ts +1 -1
  150. package/dist/sdk/relationships.js +11 -2
  151. package/dist/sdk/runtime-extended-actions.js +10 -2
  152. package/dist/sdk/runtime.d.ts +8 -2
  153. package/dist/sdk/runtime.js +11 -8
  154. package/dist/sdk/schema.d.ts +1 -0
  155. package/dist/sdk/schema.js +2 -2
  156. package/dist/sdk/test/execution.d.ts +6 -2
  157. package/dist/sdk/test/execution.js +39 -13
  158. package/dist/types.d.ts +34 -2
  159. package/dist/types.js +4 -2
  160. package/docs/AGENT_GUIDE.md +25 -9
  161. package/docs/CLI_GRAMMAR.md +106 -0
  162. package/docs/COMMANDS.md +23 -23
  163. package/docs/CONFIGURATION.md +58 -1
  164. package/docs/CONTEXT_INTEGRITY_CONTRACTS.md +58 -0
  165. package/docs/DEFECT_RECURRENCE.md +134 -0
  166. package/docs/DEPENDENCY_KIND_CONTRACT.md +12 -2
  167. package/docs/ONBOARDING.md +4 -4
  168. package/docs/QUICKSTART.md +1 -1
  169. package/docs/README.md +4 -0
  170. package/docs/RELATIONSHIP_GRAPH.md +16 -2
  171. package/docs/RELEASING.md +30 -6
  172. package/docs/SDK.md +74 -7
  173. package/docs/SDK_ARTIFACT_OUTPUT.md +72 -0
  174. package/docs/SDK_CONTEXT_COORDINATION.md +46 -12
  175. package/docs/SDK_RUNTIME_BOUNDARIES.md +9 -1
  176. package/docs/TESTING.md +18 -1
  177. package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +1 -1
  178. package/docs/agent-task-token-baseline.json +5 -5
  179. package/marketplace.json +2 -2
  180. package/package.json +8 -5
  181. package/packages/pm-beads/package.json +1 -1
  182. package/packages/pm-calendar/package.json +1 -1
  183. package/packages/pm-command-kit/package.json +1 -1
  184. package/packages/pm-digital-twin/package.json +1 -1
  185. package/packages/pm-governance-audit/package.json +1 -1
  186. package/packages/pm-guide-shell/package.json +1 -1
  187. package/packages/pm-kanban/package.json +1 -1
  188. package/packages/pm-lifecycle-hooks/package.json +1 -1
  189. package/packages/pm-linked-test-adapters/package.json +1 -1
  190. package/packages/pm-search-advanced/package.json +1 -1
  191. package/packages/pm-templates/package.json +1 -1
  192. package/packages/pm-todos/package.json +1 -1
  193. package/packages/pm-vcs/package.json +1 -1
  194. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  195. package/plugins/pm-claude/skills/pm-audit/SKILL.md +26 -0
  196. package/plugins/pm-claude/skills/pm-developer/SKILL.md +26 -0
  197. package/plugins/pm-claude/skills/pm-planner/SKILL.md +26 -0
  198. package/plugins/pm-claude/skills/pm-release/SKILL.md +26 -0
  199. package/plugins/pm-claude/skills/pm-workflow/SKILL.md +26 -0
  200. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  201. package/plugins/pm-codex/skills/pm-auditor/SKILL.md +26 -0
  202. package/plugins/pm-codex/skills/pm-native/SKILL.md +26 -0
  203. package/plugins/pm-codex/skills/pm-release/SKILL.md +26 -0
  204. package/sdk/public-surface.json +1243 -54
  205. package/dist/cli-bundle/chunks/chunk-47OQEOQB.js +0 -2
  206. package/dist/cli-bundle/chunks/chunk-HCIYWD6M.js +0 -35
  207. package/dist/cli-bundle/chunks/chunk-I2LUWWR5.js +0 -3
  208. package/dist/cli-bundle/chunks/chunk-IC5W2T34.js +0 -2
  209. package/dist/cli-bundle/chunks/chunk-OAC5NIV4.js +0 -3
  210. package/dist/cli-bundle/chunks/chunk-PANOOBIS.js +0 -13
  211. package/dist/cli-bundle/chunks/chunk-TK6N7HGM.js +0 -8
  212. package/dist/cli-bundle/chunks/chunk-TOFG2URD.js +0 -197
  213. package/dist/cli-bundle/chunks/register-list-query-EYCXHZAG.js +0 -10
  214. package/dist/cli-bundle/chunks/register-mutation-7YVIG54J.js +0 -20
  215. package/dist/cli-bundle/focused-chunks/chunk-5NMFSX26.js +0 -155
  216. package/dist/cli-bundle/focused-chunks/chunk-725JSCMP.js +0 -2
  217. package/dist/cli-bundle/focused-chunks/chunk-DQ6SMTBF.js +0 -2
  218. package/dist/cli-bundle/focused-chunks/chunk-HAACPSUW.js +0 -2
  219. package/dist/cli-bundle/focused-chunks/chunk-J4UFYHOD.js +0 -2
  220. package/dist/cli-bundle/focused-chunks/chunk-JX5Z344Q.js +0 -2
  221. package/dist/cli-bundle/focused-chunks/chunk-L4RDYBIQ.js +0 -2
  222. package/dist/cli-bundle/focused-chunks/chunk-NJ5RLEFD.js +0 -26
  223. package/dist/cli-bundle/focused-chunks/chunk-QYZERYR5.js +0 -4
  224. package/dist/cli-bundle/focused-chunks/chunk-TZATVC4G.js +0 -16
  225. package/dist/cli-bundle/focused-chunks/chunk-WY3WRPVN.js +0 -2
@@ -29,15 +29,19 @@ export interface PmContextIntentReceipt {
29
29
  included_field_groups: string[];
30
30
  /** Effective token ceiling after an explicit caller override is applied. */
31
31
  token_budget: number;
32
- /** Deterministic JSON-size estimate for the result including this receipt. */
32
+ /** Ceiling declared by the selected intent before caller overrides. */
33
+ declared_token_budget: number;
34
+ /** Signed difference between the effective and declared ceilings. */
35
+ token_budget_override: number;
36
+ /** Deterministic JSON-size estimate for the useful result before any receipt-only omission. */
33
37
  estimated_tokens: number;
34
- /** Whether the measured result fits the declared ceiling. */
38
+ /** Whether the measured result fits the effective ceiling after caller overrides. */
35
39
  within_budget: boolean;
36
40
  /** Projection strategy applied before the result was measured. */
37
41
  degradation: "bounded_fields_and_rows" | "bounded_ranked_rows" | "bounded_sections" | "budget_row_compaction" | "recursive_budget_compaction" | "budget_receipt_only" | "standard_item" | "none";
38
- /** Whether the declared ceiling can carry at least one useful result row. */
42
+ /** Whether the declared ceiling can carry the measured useful projection, independent of an override. */
39
43
  declaration_feasible: boolean;
40
- /** True only when no useful result survived the declared ceiling. */
44
+ /** True only when no useful result survived the effective ceiling. */
41
45
  result_omitted: boolean;
42
46
  /** Row ceiling calculated from the selected intent's effective token budget. */
43
47
  budget_derived_limit?: number;
@@ -5,7 +5,7 @@
5
5
  * workspace configuration, and packages.
6
6
  */
7
7
 
8
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fa03d543-ff0d-5556-8558-9bed82838a58")}catch(e){}}();
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d09393aa-0253-5ad6-a2fe-245f31b9eb87")}catch(e){}}();
9
9
  import { AsyncLocalStorage } from "node:async_hooks";
10
10
  import { attachOutputOmissionReceipt } from "./output-projection.js";
11
11
  import { encodeQueryCursor } from "./pagination.js";
@@ -25,7 +25,7 @@ export const PM_CONTEXT_INTENT_CONTRACTS = Object.freeze([
25
25
  "blockers",
26
26
  "activity",
27
27
  ],
28
- token_budget: 2400,
28
+ token_budget: 3000,
29
29
  source: "core",
30
30
  },
31
31
  {
@@ -211,10 +211,14 @@ const CONTEXT_INTENT_DEFAULT_APPLIERS = {
211
211
  : ["hierarchy", "blockers", "activity"];
212
212
  }
213
213
  const tokenBudget = resolveIntentTokenBudget(projected.tokenBudget, contract.token_budget);
214
- const calculatedLimit = Math.max(1, Math.floor((tokenBudget - 800) / 500));
215
- const derivedLimit = String(explicitTokenBudget ? calculatedLimit : Math.min(20, calculatedLimit));
216
- if (projected.limit === undefined)
214
+ const budgetDerivedLimit = resolveIntentRowBudget("context", contract.intent, tokenBudget, explicitTokenBudget);
215
+ const requestedLimit = parsePositiveIntentTokenBudget(projected.limit);
216
+ const derivedLimit = String(requestedLimit === undefined
217
+ ? budgetDerivedLimit
218
+ : Math.min(requestedLimit, budgetDerivedLimit));
219
+ if (projected.limit === undefined || requestedLimit !== undefined) {
217
220
  projected.limit = derivedLimit;
221
+ }
218
222
  if (projected.activityLimit === undefined) {
219
223
  projected.activityLimit = derivedLimit;
220
224
  }
@@ -232,10 +236,13 @@ const CONTEXT_INTENT_DEFAULT_APPLIERS = {
232
236
  projected.fields =
233
237
  "id,title,status,type,priority,parent,assignee,risk,blocked_by";
234
238
  }
235
- if (projected.limit === undefined) {
236
- const tokenBudget = resolveIntentTokenBudget(projected.tokenBudget, contract.token_budget);
237
- const calculatedLimit = Math.max(2, Math.floor((tokenBudget - 520) / 16));
238
- projected.limit = String(explicitTokenBudget ? calculatedLimit : Math.min(100, calculatedLimit));
239
+ const tokenBudget = resolveIntentTokenBudget(projected.tokenBudget, contract.token_budget);
240
+ const budgetDerivedLimit = resolveIntentRowBudget("list", contract.intent, tokenBudget, explicitTokenBudget);
241
+ const requestedLimit = parsePositiveIntentTokenBudget(projected.limit);
242
+ if (projected.limit === undefined || requestedLimit !== undefined) {
243
+ projected.limit = String(requestedLimit === undefined
244
+ ? budgetDerivedLimit
245
+ : Math.min(requestedLimit, budgetDerivedLimit));
239
246
  }
240
247
  },
241
248
  next: (projected) => {
@@ -248,10 +255,13 @@ const CONTEXT_INTENT_DEFAULT_APPLIERS = {
248
255
  projected.fields === undefined) {
249
256
  projected.compact = true;
250
257
  }
251
- if (projected.limit === undefined) {
252
- const tokenBudget = resolveIntentTokenBudget(projected.tokenBudget, contract.token_budget);
253
- const calculatedLimit = Math.max(2, Math.floor((tokenBudget - 480) / 16));
254
- projected.limit = String(explicitTokenBudget ? calculatedLimit : Math.min(100, calculatedLimit));
258
+ const tokenBudget = resolveIntentTokenBudget(projected.tokenBudget, contract.token_budget);
259
+ const budgetDerivedLimit = resolveIntentRowBudget("search", contract.intent, tokenBudget, explicitTokenBudget);
260
+ const requestedLimit = parsePositiveIntentTokenBudget(projected.limit);
261
+ if (projected.limit === undefined || requestedLimit !== undefined) {
262
+ projected.limit = String(requestedLimit === undefined
263
+ ? budgetDerivedLimit
264
+ : Math.min(requestedLimit, budgetDerivedLimit));
255
265
  }
256
266
  },
257
267
  };
@@ -341,6 +351,23 @@ function resolveIntentTokenBudget(value, declaredBudget) {
341
351
  }
342
352
  return parsed;
343
353
  }
354
+ function resolveIntentRowBudget(command, intent, tokenBudget, explicitTokenBudget) {
355
+ if (command === "get" || command === "next")
356
+ return undefined;
357
+ const contextOrient = command === "context" && intent === "orient";
358
+ const overhead = command === "context"
359
+ ? contextOrient
360
+ ? 1200
361
+ : 800
362
+ : command === "list"
363
+ ? 520
364
+ : 480;
365
+ const rowCost = command === "context" ? (contextOrient ? 600 : 500) : 16;
366
+ const calculatedLimit = Math.max(command === "context" ? 1 : 2, Math.floor((tokenBudget - overhead) / rowCost));
367
+ return explicitTokenBudget
368
+ ? calculatedLimit
369
+ : Math.min(command === "context" ? 20 : 100, calculatedLimit);
370
+ }
344
371
  /** Update a receipt until its estimate matches the serialized projection that contains it. */
345
372
  function updateContextIntentEstimate(projected, receipt) {
346
373
  let measuredTokens = receipt.estimated_tokens;
@@ -495,12 +522,15 @@ export function attachContextIntentReceipt(command, options, result) {
495
522
  return result;
496
523
  const builtInCommand = normalizedCommand;
497
524
  const contract = resolveContextIntentContract(builtInCommand, options.for);
525
+ const effectiveTokenBudget = resolveIntentTokenBudget(options.tokenBudget ?? options.token_budget, contract.token_budget);
498
526
  const receipt = {
499
527
  command: builtInCommand,
500
528
  intent: contract.intent,
501
529
  source: contract.source,
502
530
  included_field_groups: [...contract.included_field_groups],
503
- token_budget: resolveIntentTokenBudget(options.tokenBudget ?? options.token_budget, contract.token_budget),
531
+ token_budget: effectiveTokenBudget,
532
+ declared_token_budget: contract.token_budget,
533
+ token_budget_override: effectiveTokenBudget - contract.token_budget,
504
534
  estimated_tokens: 0,
505
535
  within_budget: true,
506
536
  degradation: CONTEXT_INTENT_DEGRADATIONS[builtInCommand],
@@ -508,21 +538,17 @@ export function attachContextIntentReceipt(command, options, result) {
508
538
  result_omitted: false,
509
539
  };
510
540
  const resultWithDiagnostics = { ...result };
511
- if (builtInCommand === "list" || builtInCommand === "search") {
512
- const overhead = builtInCommand === "list" ? 520 : 480;
513
- const calculatedLimit = Math.max(2, Math.floor((receipt.token_budget - overhead) / 16));
514
- const explicitTokenBudget = parsePositiveIntentTokenBudget(options.tokenBudget ?? options.token_budget) !== undefined;
515
- const budgetDerivedLimit = explicitTokenBudget
516
- ? calculatedLimit
517
- : Math.min(100, calculatedLimit);
518
- const hasExplicitLimit = options.limit !== undefined;
541
+ const budgetDerivedLimit = resolveIntentRowBudget(builtInCommand, contract.intent, receipt.token_budget, parsePositiveIntentTokenBudget(options.tokenBudget ?? options.token_budget) !== undefined);
542
+ if (budgetDerivedLimit !== undefined) {
543
+ const effectiveLimit = parsePositiveIntentTokenBudget(options.limit);
544
+ const explicitLimitBinds = effectiveLimit !== undefined && effectiveLimit < budgetDerivedLimit;
519
545
  receipt.budget_derived_limit = budgetDerivedLimit;
520
- receipt.binding_constraint = hasExplicitLimit
546
+ receipt.binding_constraint = explicitLimitBinds
521
547
  ? "explicit_limit"
522
548
  : "token_budget";
523
- receipt.limit_reason = hasExplicitLimit
524
- ? "The caller supplied an explicit row limit; the budget-derived limit remains diagnostic."
525
- : "The selected intent token budget determines the row ceiling.";
549
+ receipt.limit_reason = explicitLimitBinds
550
+ ? "The caller supplied a smaller row limit than the budget-derived ceiling."
551
+ : "The selected intent token budget constrains the effective row ceiling.";
526
552
  resultWithDiagnostics.budget_derived_limit = budgetDerivedLimit;
527
553
  }
528
554
  let projected = {
@@ -543,20 +569,22 @@ export function attachContextIntentReceipt(command, options, result) {
543
569
  receipt.degradation = "budget_row_compaction";
544
570
  updateContextIntentEstimate(projected, receipt);
545
571
  }
572
+ receipt.declaration_feasible =
573
+ receipt.estimated_tokens <= receipt.declared_token_budget;
546
574
  if (receipt.estimated_tokens > receipt.token_budget) {
547
575
  receipt.degradation = "budget_receipt_only";
548
- receipt.declaration_feasible = false;
549
576
  receipt.result_omitted = true;
550
577
  receipt.within_budget = false;
551
578
  projected = {
552
579
  budget_exceeded: {
553
580
  omitted_result: true,
554
- reason: "declared_budget_infeasible",
555
- restore_with: "Increase --token-budget or narrow the request; the unprojected command may be larger.",
581
+ reason: receipt.token_budget_override === 0
582
+ ? "declared_budget_infeasible"
583
+ : "effective_budget_infeasible",
584
+ restore_with: buildContextIntentRecoveryCommand(command, builtInCommand, contract.intent, receipt, resultWithDiagnostics),
556
585
  },
557
586
  context_intent: receipt,
558
587
  };
559
- updateContextIntentEstimate(projected, receipt);
560
588
  }
561
589
  return projected;
562
590
  }
@@ -594,6 +622,23 @@ function collapseContinuationMetadata(options, result) {
594
622
  function isOutputRecord(value) {
595
623
  return value !== null && typeof value === "object" && !Array.isArray(value);
596
624
  }
625
+ /** Build a shell-safe bounded retry while retaining required read positionals. */
626
+ function buildContextIntentRecoveryCommand(command, builtInCommand, intent, receipt, result) {
627
+ const recoveryTarget = builtInCommand === "get" &&
628
+ isOutputRecord(result.item) &&
629
+ typeof result.item.id === "string"
630
+ ? result.item.id
631
+ : builtInCommand === "search" && typeof result.query === "string"
632
+ ? result.query
633
+ : undefined;
634
+ const recoveryPositional = recoveryTarget === undefined
635
+ ? ""
636
+ : ` '${recoveryTarget.replaceAll("'", `'"'"'`)}'`;
637
+ const boundedRowLimit = builtInCommand === "get"
638
+ ? ""
639
+ : ` --limit ${receipt.budget_derived_limit ?? 1}`;
640
+ return `pm ${command}${recoveryPositional} --for ${intent} --token-budget ${Math.ceil(receipt.estimated_tokens / 100) * 100}${boundedRowLimit}`;
641
+ }
597
642
  /** Read one numeric fixed-point estimate from an optional receipt. */
598
643
  function receiptEstimate(value, field) {
599
644
  if (!isOutputRecord(value))
@@ -641,4 +686,4 @@ export function attachReadOutputContracts(command, options, result) {
641
686
  return stabilizeSuppressedRowContractReceipts(Object.fromEntries(Object.entries(projected).filter(([key]) => key !== "row_contract")), options);
642
687
  }
643
688
  //# sourceMappingURL=context-intent-contracts.js.map
644
- //# debugId=fa03d543-ff0d-5556-8558-9bed82838a58
689
+ //# debugId=d09393aa-0253-5ad6-a2fe-245f31b9eb87
@@ -4,6 +4,7 @@
4
4
  * Exposes command and action contract data without loading SDK runtime code.
5
5
  */
6
6
  export * from "./cli-contracts.js";
7
+ export * from "./cli-contracts/grammar-contracts.js";
7
8
  export * from "./cli-contracts/command-exit-contracts.js";
8
9
  export * from "./context-intent-contracts.js";
9
10
  export * from "./error-code-catalog.js";
@@ -4,8 +4,9 @@
4
4
  * Exposes command and action contract data without loading SDK runtime code.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="65e53d90-6fff-59df-bdfc-0d2387b5a28d")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="df504de1-de3b-55fe-baef-08c0d1dcf97f")}catch(e){}}();
8
8
  export * from "./cli-contracts.js";
9
+ export * from "./cli-contracts/grammar-contracts.js";
9
10
  export * from "./cli-contracts/command-exit-contracts.js";
10
11
  export * from "./context-intent-contracts.js";
11
12
  export * from "./error-code-catalog.js";
@@ -15,4 +16,4 @@ export * from "./output-token-accounting.js";
15
16
  export * from "./output-contracts.js";
16
17
  export * from "./read-output-contracts.js";
17
18
  //# sourceMappingURL=contracts.js.map
18
- //# debugId=65e53d90-6fff-59df-bdfc-0d2387b5a28d
19
+ //# debugId=df504de1-de3b-55fe-baef-08c0d1dcf97f
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Provides the stable item lifecycle client and universal project data types.
5
5
  */
6
- export { BASELINE_ITEM_FORMAT_VERSION, BUILTIN_ITEM_TYPE_VALUES, CONFIDENCE_TEXT_VALUES, CURRENT_ITEM_FORMAT_VERSION, DEPENDENCY_KIND_VALUES, EXIT_CODE, ISSUE_SEVERITY_VALUES, ITEM_TYPE_VALUES, PM_CLI_EXPECTED_ERROR_NAME, PmCliError, PmClient, RISK_VALUES, STATUS_VALUES, canonicalDocument, classifyItemFormatVersion, createPmCliExpectedError, effectiveItemFormatVersion, emptyImportedDocument, isPmCliExpectedError, normalizeItemFormatVersion, normalizeItemId, normalizeStatusInput, nowIso, runAction, serializeItemDocument, aggregate, append, claim, claimNext, close, comments, context, copy, create, deleteItem, deps, docs, files, filesDiscover, focus, get, graph, learnings, list, next, notes, release, restore, search, update, type AggregateOptions, type AggregateResult, type AggregateRow, type AssuranceActionInput, type AssuranceActionResult, type AppendCommandOptions, type AppendResult, type ClaimNextOptions, type ClaimResult, type CloseResult, type CommentsCommandOptions, type CommentsResult, type ContextOptions, type ContextResult, type CopyResult, type CreateResult, type Dependency, type DeleteResult, type DepsCommandOptions, type DepsResult, type DocsCommandOptions, type DocsResult, type FilesCommandOptions, type FilesDiscoverOptions, type FilesDiscoverResult, type FilesResult, type FocusResult, type GetOptions, type GetResult, type ItemFormatVersionScanEntry, type ItemFormatVersionScanResult, type ItemFormatVersionStatus, type LearningsCommandOptions, type LearningsResult, type ListOptions, type ListResult, type NextOptions, type NextResult, type NotesCommandOptions, type NotesResult, type PmActionInput, type PmActionName, type PmActionOptions, type PmClientOptions, type ReleaseResult, type RestoreResult, type SearchOptions, type SearchResult, type UpdateResult, } from "./runtime.js";
6
+ export { BASELINE_ITEM_FORMAT_VERSION, BUILTIN_ITEM_TYPE_VALUES, CONFIDENCE_TEXT_VALUES, CURRENT_ITEM_FORMAT_VERSION, DEPENDENCY_KIND_VALUES, EXIT_CODE, ISSUE_SEVERITY_VALUES, ITEM_TYPE_VALUES, PM_CLI_EXPECTED_ERROR_NAME, PmCliError, PmClient, RISK_VALUES, STATUS_VALUES, canonicalDocument, classifyItemFormatVersion, createPmCliExpectedError, effectiveItemFormatVersion, emptyImportedDocument, isPmCliExpectedError, normalizeItemFormatVersion, normalizeItemId, normalizeStatusInput, nowIso, runAction, serializeItemDocument, aggregate, append, claim, claimNext, close, comments, context, copy, create, deleteItem, deps, docs, files, filesDiscover, focus, get, graph, learnings, list, next, notes, release, restore, search, update, type AggregateOptions, type AggregateResult, type AggregateRow, type AssuranceActionInput, type AssuranceActionResult, type AppendCommandOptions, type AppendResult, type ClaimNextOptions, type ClaimResult, type CloseResult, type CommentsCommandOptions, type CommentsResult, type ContextOptions, type ContextResult, type CopyResult, type CreateResult, type Dependency, type DeleteResult, type DepsCommandOptions, type DepsResult, type DocsCommandOptions, type DocsResult, type FilesCommandOptions, type FilesDiscoverOptions, type FilesDiscoverResult, type FilesResult, type FocusResult, type GetOptions, type GetResult, type ItemFormatVersionScanEntry, type ItemFormatVersionScanResult, type ItemFormatVersionStatus, type LearningsCommandOptions, type LearningsResult, type ListOptions, type ListResult, listAllComplete, type PmCompleteListOptions, type PmCompleteListResult, type NextOptions, type NextResult, type NotesCommandOptions, type NotesResult, type PmActionInput, type PmActionName, type PmActionOptions, type PmClientOptions, type ReleaseResult, type RestoreResult, type SearchOptions, type SearchResult, type UpdateResult, } from "./runtime.js";
7
7
  export * from "./core-governance.js";
8
8
  export * from "./agent-session-context.js";
9
9
  export { isAlreadyClaimedError } from "./lifecycle/claim.js";
package/dist/sdk/core.js CHANGED
@@ -4,12 +4,12 @@
4
4
  * Provides the stable item lifecycle client and universal project data types.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="dfc95179-77dd-5762-9bcc-c6bb461ff553")}catch(e){}}();
8
- export { BASELINE_ITEM_FORMAT_VERSION, BUILTIN_ITEM_TYPE_VALUES, CONFIDENCE_TEXT_VALUES, CURRENT_ITEM_FORMAT_VERSION, DEPENDENCY_KIND_VALUES, EXIT_CODE, ISSUE_SEVERITY_VALUES, ITEM_TYPE_VALUES, PM_CLI_EXPECTED_ERROR_NAME, PmCliError, PmClient, RISK_VALUES, STATUS_VALUES, canonicalDocument, classifyItemFormatVersion, createPmCliExpectedError, effectiveItemFormatVersion, emptyImportedDocument, isPmCliExpectedError, normalizeItemFormatVersion, normalizeItemId, normalizeStatusInput, nowIso, runAction, serializeItemDocument, aggregate, append, claim, claimNext, close, comments, context, copy, create, deleteItem, deps, docs, files, filesDiscover, focus, get, graph, learnings, list, next, notes, release, restore, search, update, } from "./runtime.js";
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3b27abec-8da3-531a-9bbc-71e97b8b65c5")}catch(e){}}();
8
+ export { BASELINE_ITEM_FORMAT_VERSION, BUILTIN_ITEM_TYPE_VALUES, CONFIDENCE_TEXT_VALUES, CURRENT_ITEM_FORMAT_VERSION, DEPENDENCY_KIND_VALUES, EXIT_CODE, ISSUE_SEVERITY_VALUES, ITEM_TYPE_VALUES, PM_CLI_EXPECTED_ERROR_NAME, PmCliError, PmClient, RISK_VALUES, STATUS_VALUES, canonicalDocument, classifyItemFormatVersion, createPmCliExpectedError, effectiveItemFormatVersion, emptyImportedDocument, isPmCliExpectedError, normalizeItemFormatVersion, normalizeItemId, normalizeStatusInput, nowIso, runAction, serializeItemDocument, aggregate, append, claim, claimNext, close, comments, context, copy, create, deleteItem, deps, docs, files, filesDiscover, focus, get, graph, learnings, list, next, notes, release, restore, search, update, listAllComplete, } from "./runtime.js";
9
9
  export * from "./core-governance.js";
10
10
  export * from "./agent-session-context.js";
11
11
  export { isAlreadyClaimedError } from "./lifecycle/claim.js";
12
12
  export { PM_READ_OUTPUT_DIMENSIONS, PM_READ_OUTPUT_OPTION_FLAGS, PM_READ_OUTPUT_COMPOSITION_OPTION_FLAGS, PM_READ_OUTPUT_SURFACE_CONTRACTS, applyReadOutputDimensions, decodeReadOutputContinuationCursor, encodeReadOutputContinuationCursor, isReadOutputBudgetExceeded, resolveReadOutputDimensions, resolveReadOutputEncoding, resolveReadOutputSurface, validateReadOutputOptions, } from "./read-output-contracts.js";
13
13
  export { applyReadOutputSessionReferences, attachReadOutputSessionReceipt, parseReadOutputSession, readOutputSessionRemainingTokens, } from "./read-output-session.js";
14
14
  //# sourceMappingURL=core.js.map
15
- //# debugId=dfc95179-77dd-5762-9bcc-c6bb461ff553
15
+ //# debugId=3b27abec-8da3-531a-9bbc-71e97b8b65c5
@@ -1,4 +1,4 @@
1
- import type { Dependency, ItemFormat } from "../types/index.js";
1
+ import type { Dependency, ItemFormat, RuntimeSchemaSettings } from "../types/index.js";
2
2
  import { type RelationshipKindRegistry } from "./relationships.js";
3
3
  /** Reject malformed shorthand before item-id prefix normalization can create a dangling graph node. */
4
4
  export declare function assertValidBareDependencyFlagValue(value: string, structured: boolean): void;
@@ -8,7 +8,8 @@ export declare function assertValidBareDependencyFlagValue(value: string, struct
8
8
  */
9
9
  export declare function assertDependencyEdgesAllowed(holderId: string, dependencies: readonly Dependency[] | undefined, registry?: RelationshipKindRegistry): void;
10
10
  /**
11
- * Resolve every newly supplied local dependency before a mutation commits.
11
+ * Resolve every newly supplied local dependency and enforce declared endpoint
12
+ * chronology before a mutation commits.
12
13
  * Explicit external provenance bypasses workspace lookup, while the opt-in
13
14
  * unresolved mode returns durable warning tokens instead of pretending that
14
15
  * the graph edge resolved successfully.
@@ -20,4 +21,10 @@ export declare function assertDependencyTargetsResolvable(params: {
20
21
  itemFormat: ItemFormat;
21
22
  typeToFolder: Record<string, string>;
22
23
  allowUnresolved?: boolean;
24
+ holders?: readonly {
25
+ id: string;
26
+ createdAt?: string;
27
+ }[];
28
+ schema?: RuntimeSchemaSettings;
29
+ registry?: RelationshipKindRegistry;
23
30
  }): Promise<string[]>;
@@ -1,10 +1,10 @@
1
1
  /** @module cli/commands/dependency-flag-validation */
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e7cd6092-ed18-52ea-94a0-03bed42eb858")}catch(e){}}();
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f9c9b926-c912-548e-a9c7-64c2c69767cd")}catch(e){}}();
4
4
  import { EXIT_CODE } from "../core/shared/constants.js";
5
5
  import { PmCliError } from "../core/shared/errors.js";
6
6
  import { toErrorMessage } from "../core/shared/primitives.js";
7
- import { locateItem } from "../core/store/item-store.js";
7
+ import { locateItem, readLocatedItem, } from "../core/store/item-store.js";
8
8
  import { isExternalDependencySourceKind } from "./dependency-provenance.js";
9
9
  import { resolveWorkspaceRelationshipKindRegistry } from "./graph/assembly.js";
10
10
  import { assertRelationshipEdgeAllowed, } from "./relationships.js";
@@ -31,55 +31,121 @@ export function assertDependencyEdgesAllowed(holderId, dependencies, registry =
31
31
  }
32
32
  }
33
33
  }
34
+ async function readDependencyEndpointCreatedAt(located, schema) {
35
+ return (await readLocatedItem(located, { schema })).document.metadata
36
+ .created_at;
37
+ }
38
+ async function resolveDependencyHolderCreatedAt(holder, context) {
39
+ if (holder.createdAt !== undefined)
40
+ return holder.createdAt;
41
+ const located = await locateItem(context.pmRoot, holder.id, context.idPrefix, context.itemFormat, context.typeToFolder);
42
+ return located === null
43
+ ? undefined
44
+ : readDependencyEndpointCreatedAt(located, context.schema);
45
+ }
46
+ function dependencyTemporalOrderError(params) {
47
+ const definition = params.registry.require(params.dependency.kind);
48
+ return new PmCliError(`${definition.kind} requires source ${params.holder.id} to be created after target ${params.dependency.id}`, EXIT_CODE.USAGE, {
49
+ code: "dependency_temporal_order_invalid",
50
+ reason: "source_not_after_target",
51
+ required: `${params.holder.id}.created_at must be later than ${params.dependency.id}.created_at for ${definition.kind}.`,
52
+ why: "Chronological recurrence direction must be validated before the relationship is persisted.",
53
+ source_id: params.holder.id,
54
+ source_created_at: params.sourceCreatedAt,
55
+ target_id: params.dependency.id,
56
+ target_created_at: params.targetCreatedAt,
57
+ temporal_order: definition.temporalOrder,
58
+ });
59
+ }
60
+ async function assertTemporalDependencyChronology(params) {
61
+ const temporalDependencies = params.dependencies.filter((dependency) => params.registry.resolve(dependency.kind)?.temporalOrder ===
62
+ "source_after_target" &&
63
+ !params.missingTargets.includes(dependency.id));
64
+ if (temporalDependencies.length === 0 || params.holders.length === 0)
65
+ return;
66
+ const locatedTargets = new Map(params.resolutions.flatMap(({ target, located }) => located === null ? [] : [[target, located]]));
67
+ const targetCreatedAt = new Map(await Promise.all([...new Set(temporalDependencies.map(({ id }) => id))].map(async (target) => [
68
+ target,
69
+ await readDependencyEndpointCreatedAt(locatedTargets.get(target), params.context.schema),
70
+ ])));
71
+ for (const holder of params.holders) {
72
+ const sourceCreatedAt = await resolveDependencyHolderCreatedAt(holder, params.context);
73
+ if (sourceCreatedAt === undefined)
74
+ continue;
75
+ for (const dependency of temporalDependencies) {
76
+ const targetTimestamp = targetCreatedAt.get(dependency.id);
77
+ const sourceTime = Date.parse(sourceCreatedAt);
78
+ const targetTime = Date.parse(targetTimestamp);
79
+ if (Number.isFinite(sourceTime) &&
80
+ Number.isFinite(targetTime) &&
81
+ sourceTime > targetTime) {
82
+ continue;
83
+ }
84
+ throw dependencyTemporalOrderError({
85
+ holder,
86
+ dependency,
87
+ sourceCreatedAt,
88
+ targetCreatedAt: targetTimestamp,
89
+ registry: params.registry,
90
+ });
91
+ }
92
+ }
93
+ }
34
94
  /**
35
- * Resolve every newly supplied local dependency before a mutation commits.
95
+ * Resolve every newly supplied local dependency and enforce declared endpoint
96
+ * chronology before a mutation commits.
36
97
  * Explicit external provenance bypasses workspace lookup, while the opt-in
37
98
  * unresolved mode returns durable warning tokens instead of pretending that
38
99
  * the graph edge resolved successfully.
39
100
  */
40
101
  export async function assertDependencyTargetsResolvable(params) {
102
+ const registry = params.registry ?? resolveWorkspaceRelationshipKindRegistry();
103
+ const localDependencies = (params.dependencies ?? []).filter((dependency) => !isExternalDependencySourceKind(dependency.source_kind));
41
104
  const localTargets = [
42
- ...new Set((params.dependencies ?? [])
43
- .filter((dependency) => !isExternalDependencySourceKind(dependency.source_kind))
44
- .map((dependency) => dependency.id)),
105
+ ...new Set(localDependencies.map((dependency) => dependency.id)),
45
106
  ];
46
107
  const resolutions = await Promise.all(localTargets.map(async (target) => ({
47
108
  target,
48
109
  located: await locateItem(params.pmRoot, target, params.idPrefix, params.itemFormat, params.typeToFolder),
49
110
  })));
50
- const targets = resolutions
111
+ const missingTargets = resolutions
51
112
  .filter(({ located }) => located === null)
52
113
  .map(({ target }) => target)
53
114
  .sort((left, right) => (left < right ? -1 : 1));
54
- if (targets.length === 0) {
55
- return [];
56
- }
57
- if (params.allowUnresolved === true) {
58
- return targets.map((target) => `dependency_target_unresolved:${target}`);
115
+ if (missingTargets.length > 0 && params.allowUnresolved !== true) {
116
+ throw new PmCliError(`Dependency target${missingTargets.length === 1 ? "" : "s"} not found: ${missingTargets.join(", ")}`, EXIT_CODE.NOT_FOUND, {
117
+ code: "dependency_target_not_found",
118
+ reason: "unresolved_local_dependency",
119
+ required: "Every local dependency target must exist before the edge is committed.",
120
+ why: "Fail-fast target resolution prevents dangling graph nodes and preserves reliable traversal semantics.",
121
+ unresolved_targets: missingTargets,
122
+ examples: [
123
+ "--dep id=<existing-item-id>,kind=related",
124
+ "--dep id=<external-id>,kind=related,source_kind=external",
125
+ "--allow-unresolved-deps --dep id=<future-item-id>,kind=related",
126
+ ],
127
+ nextSteps: [
128
+ `Create or correct ${missingTargets.length === 1 ? "the target" : "the targets"}, then retry the mutation.`,
129
+ "Use source_kind=external for a cross-workspace reference.",
130
+ "Use --allow-unresolved-deps only when the dangling local edge is intentional.",
131
+ ],
132
+ recovery: {
133
+ recovery_mode: "compact",
134
+ missing: missingTargets,
135
+ suggested_flags: ["--allow-unresolved-deps"],
136
+ suggested_retry: `pm search "${missingTargets[0]}" --limit 10`,
137
+ },
138
+ });
59
139
  }
60
- throw new PmCliError(`Dependency target${targets.length === 1 ? "" : "s"} not found: ${targets.join(", ")}`, EXIT_CODE.NOT_FOUND, {
61
- code: "dependency_target_not_found",
62
- reason: "unresolved_local_dependency",
63
- required: "Every local dependency target must exist before the edge is committed.",
64
- why: "Fail-fast target resolution prevents dangling graph nodes and preserves reliable traversal semantics.",
65
- unresolved_targets: targets,
66
- examples: [
67
- "--dep id=<existing-item-id>,kind=related",
68
- "--dep id=<external-id>,kind=related,source_kind=external",
69
- "--allow-unresolved-deps --dep id=<future-item-id>,kind=related",
70
- ],
71
- nextSteps: [
72
- `Create or correct ${targets.length === 1 ? "the target" : "the targets"}, then retry the mutation.`,
73
- "Use source_kind=external for a cross-workspace reference.",
74
- "Use --allow-unresolved-deps only when the dangling local edge is intentional.",
75
- ],
76
- recovery: {
77
- recovery_mode: "compact",
78
- missing: targets,
79
- suggested_flags: ["--allow-unresolved-deps"],
80
- suggested_retry: `pm search "${targets[0]}" --limit 10`,
81
- },
140
+ await assertTemporalDependencyChronology({
141
+ dependencies: localDependencies,
142
+ missingTargets,
143
+ resolutions,
144
+ holders: params.holders ?? [],
145
+ registry,
146
+ context: params,
82
147
  });
148
+ return missingTargets.map((target) => `dependency_target_unresolved:${target}`);
83
149
  }
84
150
  //# sourceMappingURL=dependency-flag-validation.js.map
85
- //# debugId=e7cd6092-ed18-52ea-94a0-03bed42eb858
151
+ //# debugId=f9c9b926-c912-548e-a9c7-64c2c69767cd
@@ -5,7 +5,8 @@
5
5
  * leaking local paths or swallowing genuine implementation defects.
6
6
  */
7
7
 
8
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="41fec0f3-5cc8-5007-a896-f8d8b83ae4f5")}catch(e){}}();
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1c74b5a9-67b8-597c-98de-a4487691081f")}catch(e){}}();
9
+ import { constants as osConstants } from "node:os";
9
10
  import { EXIT_CODE } from "../../core/shared/constants.js";
10
11
  import { PmCliError } from "../../core/shared/errors.js";
11
12
  const HOST_ENVIRONMENT_FAULTS = new Map([
@@ -75,6 +76,16 @@ const HOST_ENVIRONMENT_FAULTS = new Map([
75
76
  ],
76
77
  ]);
77
78
  const OPERATION_PATTERN = /^[a-z][a-z0-9_]{0,63}$/u;
79
+ const HOST_ENVIRONMENT_ERRNO_NAMES = new Map([
80
+ [osConstants.errno.EACCES, "EACCES"],
81
+ [osConstants.errno.EDQUOT, "EDQUOT"],
82
+ [osConstants.errno.EMFILE, "EMFILE"],
83
+ [osConstants.errno.ENFILE, "ENFILE"],
84
+ [osConstants.errno.ENOMEM, "ENOMEM"],
85
+ [osConstants.errno.ENOSPC, "ENOSPC"],
86
+ [osConstants.errno.EPERM, "EPERM"],
87
+ [osConstants.errno.EROFS, "EROFS"],
88
+ ].filter(([errno]) => Number.isInteger(errno)));
78
89
  const HOST_ENVIRONMENT_FAULT_CODES = {
79
90
  capacity: { code: "host_environment_capacity_fault" },
80
91
  permission: { code: "host_environment_permission_fault" },
@@ -82,12 +93,19 @@ const HOST_ENVIRONMENT_FAULT_CODES = {
82
93
  };
83
94
  /** Return a declared host errno only when it represents recoverable environment state. */
84
95
  export function classifyHostEnvironmentFault(error) {
85
- if (typeof error !== "object" || error === null || !("code" in error))
96
+ if (typeof error !== "object" || error === null) {
86
97
  return null;
87
- const code = error.code;
88
- return typeof code === "string" && HOST_ENVIRONMENT_FAULTS.has(code)
89
- ? code
90
- : null;
98
+ }
99
+ const errorRecord = error;
100
+ if (typeof errorRecord.code === "string" &&
101
+ HOST_ENVIRONMENT_FAULTS.has(errorRecord.code)) {
102
+ return errorRecord.code;
103
+ }
104
+ if (typeof errorRecord.errno !== "number" ||
105
+ !Number.isInteger(errorRecord.errno)) {
106
+ return null;
107
+ }
108
+ return HOST_ENVIRONMENT_ERRNO_NAMES.get(Math.abs(errorRecord.errno)) ?? null;
91
109
  }
92
110
  /** Translate one known host fault into a stable path-redacted SDK refusal. */
93
111
  export function translateHostEnvironmentFault(error, operation, options = {}) {
@@ -121,4 +139,4 @@ export async function withHostEnvironmentBoundary(operation, run, options = {})
121
139
  }
122
140
  }
123
141
  //# sourceMappingURL=host-environment-errors.js.map
124
- //# debugId=41fec0f3-5cc8-5007-a896-f8d8b83ae4f5
142
+ //# debugId=1c74b5a9-67b8-597c-98de-a4487691081f