@unbrained/pm-cli 2026.8.15 → 2026.8.17

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 (176) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +56 -12
  3. package/README.md +13 -13
  4. package/dist/cli/error-guidance.d.ts +5 -0
  5. package/dist/cli/error-guidance.js +15 -2
  6. package/dist/cli/public.d.ts +2 -0
  7. package/dist/cli/public.js +21 -0
  8. package/dist/cli/register-history-author.js +16 -11
  9. package/dist/cli/register-mutation.js +4 -4
  10. package/dist/cli-bundle/bundle-manifest.json +143 -143
  11. package/dist/cli-bundle/chunks/{chunk-J42EGKDK.js → chunk-2QLOXC3V.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-LJHOAVGI.js → chunk-3UEGXBMR.js} +49 -43
  13. package/dist/cli-bundle/chunks/chunk-4JPYF536.js +35 -0
  14. package/dist/cli-bundle/chunks/chunk-6VDLG2FC.js +13 -0
  15. package/dist/cli-bundle/chunks/chunk-7IBRGCHX.js +2 -0
  16. package/dist/cli-bundle/chunks/chunk-HBJAS566.js +8 -0
  17. package/dist/cli-bundle/chunks/chunk-ION3E43Q.js +197 -0
  18. package/dist/cli-bundle/chunks/{chunk-WLPDLNEZ.js → chunk-JOKATURE.js} +4 -4
  19. package/dist/cli-bundle/chunks/{chunk-MEM2ZS3O.js → chunk-TPXZIBIV.js} +5 -5
  20. package/dist/cli-bundle/chunks/chunk-YM2YAMF7.js +2 -0
  21. package/dist/cli-bundle/chunks/{register-list-query-CT3LFDDN.js → register-list-query-Q7KII4G5.js} +2 -2
  22. package/dist/cli-bundle/chunks/{register-mutation-NWEVA5YS.js → register-mutation-4WBRPXLV.js} +3 -3
  23. package/dist/cli-bundle/chunks/{register-operations-AHIAG5KM.js → register-operations-SSENDH5B.js} +2 -2
  24. package/dist/cli-bundle/chunks/{register-setup-ZJZFVAKE.js → register-setup-DOSFBGKE.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-WTSER4WJ.js → chunk-267MUUS6.js} +11 -11
  26. package/dist/cli-bundle/focused-chunks/chunk-2NNFLLNG.js +2 -0
  27. package/dist/cli-bundle/focused-chunks/chunk-2QSAKMIH.js +2 -0
  28. package/dist/cli-bundle/focused-chunks/{chunk-ZMFXQ7VF.js → chunk-ATEY76SX.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/chunk-BUCG4ZI2.js +2 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-M67F5AIN.js → chunk-CYFK5UPB.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-EHXIKD6K.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-EXZA4257.js → chunk-KGEXTMPG.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-KP2VQQVQ.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-MHPIL773.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/chunk-POEEAD2V.js +4 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-ITAUHSO6.js → chunk-SALH6B6K.js} +47 -47
  37. package/dist/cli-bundle/focused-chunks/{chunk-KLVUMNXJ.js → chunk-SYZENPIT.js} +3 -3
  38. package/dist/cli-bundle/focused-chunks/{chunk-KTKH4IMG.js → chunk-XKAMP5OU.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-NSPYTG6G.js → chunk-XPIC53VA.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-6XKF3PGV.js → chunk-ZQPGZZWQ.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/chunk-ZT2DJS27.js +155 -0
  42. package/dist/cli-bundle/main.js +10 -10
  43. package/dist/cli-bundle/sdk-authoring.js +1 -1
  44. package/dist/cli-bundle/sdk-contracts.js +1 -1
  45. package/dist/cli-bundle/sdk-core.js +31 -31
  46. package/dist/cli-bundle/sdk-governance.js +1 -1
  47. package/dist/cli-bundle/sdk-graph.js +1 -1
  48. package/dist/cli-bundle/sdk-merge.js +32 -32
  49. package/dist/cli-bundle/sdk-query.js +1 -1
  50. package/dist/cli-bundle/sdk-runtime.js +1 -1
  51. package/dist/cli-bundle/sdk-testing.js +1 -1
  52. package/dist/cli-bundle/sdk.js +4 -2
  53. package/dist/core/extensions/loader.js +10 -6
  54. package/dist/core/extensions/manifest-schema.d.ts +20 -0
  55. package/dist/core/extensions/manifest-schema.js +52 -0
  56. package/dist/core/history/replay.js +32 -14
  57. package/dist/core/history/workspace-history.js +32 -10
  58. package/dist/core/output/output.js +6 -3
  59. package/dist/core/schema/fields-file.d.ts +1 -1
  60. package/dist/core/schema/fields-file.js +2 -2
  61. package/dist/core/schema/runtime-field-values.js +115 -9
  62. package/dist/core/schema/runtime-schema.d.ts +3 -1
  63. package/dist/core/schema/runtime-schema.js +124 -3
  64. package/dist/core/shared/errors.d.ts +12 -0
  65. package/dist/core/shared/errors.js +2 -2
  66. package/dist/core/shared/time.d.ts +2 -0
  67. package/dist/core/shared/time.js +27 -2
  68. package/dist/core/store/item-store.js +28 -2
  69. package/dist/sdk/agent/refusal-reachability.d.ts +56 -8
  70. package/dist/sdk/agent/refusal-reachability.js +414 -4
  71. package/dist/sdk/author-attribution.d.ts +56 -11
  72. package/dist/sdk/author-attribution.js +174 -50
  73. package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
  74. package/dist/sdk/cli-contracts/tool-parameter-tables.js +12 -4
  75. package/dist/sdk/cli-contracts/tool-schema.js +12 -4
  76. package/dist/sdk/completion.js +11 -4
  77. package/dist/sdk/compose.d.ts +6 -2
  78. package/dist/sdk/compose.js +33 -3
  79. package/dist/sdk/context-intent-contracts.d.ts +8 -4
  80. package/dist/sdk/context-intent-contracts.js +76 -31
  81. package/dist/sdk/dependency-flag-validation.d.ts +9 -2
  82. package/dist/sdk/dependency-flag-validation.js +101 -35
  83. package/dist/sdk/environment/host-environment-errors.js +25 -7
  84. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +62 -14
  85. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +50 -2
  86. package/dist/sdk/governance/assurance-action.d.ts +3 -7
  87. package/dist/sdk/governance/assurance-action.js +97 -2
  88. package/dist/sdk/governance/boundary-fixtures.d.ts +86 -0
  89. package/dist/sdk/governance/boundary-fixtures.js +201 -0
  90. package/dist/sdk/governance/coverage-assurance.d.ts +24 -0
  91. package/dist/sdk/governance/coverage-assurance.js +61 -0
  92. package/dist/sdk/governance/defect-recurrence-signals.d.ts +10 -0
  93. package/dist/sdk/governance/defect-recurrence-signals.js +25 -0
  94. package/dist/sdk/governance/defect-recurrence.d.ts +242 -0
  95. package/dist/sdk/governance/defect-recurrence.js +523 -0
  96. package/dist/sdk/governance/extension-host-version.js +20 -9
  97. package/dist/sdk/governance.d.ts +2 -0
  98. package/dist/sdk/governance.js +4 -2
  99. package/dist/sdk/graph/governance.js +3 -2
  100. package/dist/sdk/guide-topics.js +191 -2
  101. package/dist/sdk/index.d.ts +5 -1
  102. package/dist/sdk/index.js +6 -3
  103. package/dist/sdk/lifecycle/create.js +4 -2
  104. package/dist/sdk/lifecycle/update-many.js +15 -2
  105. package/dist/sdk/lifecycle/update.js +5 -2
  106. package/dist/sdk/linked-artifacts.js +63 -14
  107. package/dist/sdk/query/get.d.ts +2 -0
  108. package/dist/sdk/query/get.js +32 -7
  109. package/dist/sdk/read-output-contracts.js +5 -3
  110. package/dist/sdk/relationship-analytics.js +90 -14
  111. package/dist/sdk/relationship-kinds/contract.d.ts +4 -0
  112. package/dist/sdk/relationship-kinds/contract.js +3 -2
  113. package/dist/sdk/relationships.d.ts +1 -1
  114. package/dist/sdk/relationships.js +11 -2
  115. package/dist/sdk/runtime.d.ts +2 -5
  116. package/dist/sdk/runtime.js +3 -2
  117. package/dist/sdk/schema.d.ts +1 -0
  118. package/dist/sdk/schema.js +2 -2
  119. package/dist/sdk/test/execution.d.ts +6 -2
  120. package/dist/sdk/test/execution.js +39 -13
  121. package/dist/types.d.ts +29 -2
  122. package/dist/types.js +4 -2
  123. package/docs/CONFIGURATION.md +58 -1
  124. package/docs/CONTEXT_INTEGRITY_CONTRACTS.md +58 -0
  125. package/docs/DEFECT_RECURRENCE.md +134 -0
  126. package/docs/DEPENDENCY_KIND_CONTRACT.md +12 -2
  127. package/docs/README.md +2 -0
  128. package/docs/READ_OUTPUT_CONTRACTS.md +7 -1
  129. package/docs/RELATIONSHIP_GRAPH.md +16 -2
  130. package/docs/RELEASING.md +13 -7
  131. package/docs/SDK.md +38 -5
  132. package/docs/SDK_CONTEXT_INTEGRITY.md +33 -5
  133. package/docs/SDK_CONTEXT_TRUTH_CONTRACTS.md +13 -5
  134. package/docs/SDK_RUNTIME_BOUNDARIES.md +9 -1
  135. package/docs/TESTING.md +18 -1
  136. package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +1 -1
  137. package/marketplace.json +2 -2
  138. package/package.json +6 -4
  139. package/packages/pm-beads/package.json +1 -1
  140. package/packages/pm-calendar/package.json +1 -1
  141. package/packages/pm-command-kit/package.json +1 -1
  142. package/packages/pm-digital-twin/package.json +1 -1
  143. package/packages/pm-governance-audit/package.json +1 -1
  144. package/packages/pm-guide-shell/package.json +1 -1
  145. package/packages/pm-kanban/package.json +1 -1
  146. package/packages/pm-lifecycle-hooks/package.json +1 -1
  147. package/packages/pm-linked-test-adapters/package.json +1 -1
  148. package/packages/pm-search-advanced/package.json +1 -1
  149. package/packages/pm-templates/package.json +1 -1
  150. package/packages/pm-todos/package.json +1 -1
  151. package/packages/pm-vcs/package.json +1 -1
  152. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  153. package/plugins/pm-claude/skills/pm-audit/SKILL.md +26 -0
  154. package/plugins/pm-claude/skills/pm-developer/SKILL.md +26 -0
  155. package/plugins/pm-claude/skills/pm-planner/SKILL.md +26 -0
  156. package/plugins/pm-claude/skills/pm-release/SKILL.md +26 -0
  157. package/plugins/pm-claude/skills/pm-workflow/SKILL.md +26 -0
  158. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  159. package/plugins/pm-codex/skills/pm-auditor/SKILL.md +26 -0
  160. package/plugins/pm-codex/skills/pm-native/SKILL.md +26 -0
  161. package/plugins/pm-codex/skills/pm-release/SKILL.md +26 -0
  162. package/sdk/public-surface.json +716 -33
  163. package/dist/cli-bundle/chunks/chunk-24GAV7XL.js +0 -8
  164. package/dist/cli-bundle/chunks/chunk-AIM6VT2N.js +0 -13
  165. package/dist/cli-bundle/chunks/chunk-DSWDLTDR.js +0 -197
  166. package/dist/cli-bundle/chunks/chunk-KIEGUBYQ.js +0 -2
  167. package/dist/cli-bundle/chunks/chunk-KLKYLSDX.js +0 -2
  168. package/dist/cli-bundle/chunks/chunk-QHPCJWEJ.js +0 -35
  169. package/dist/cli-bundle/focused-chunks/chunk-4X57RE4U.js +0 -2
  170. package/dist/cli-bundle/focused-chunks/chunk-7NJ4QYQ2.js +0 -2
  171. package/dist/cli-bundle/focused-chunks/chunk-KT5XMYSX.js +0 -4
  172. package/dist/cli-bundle/focused-chunks/chunk-OKA6ELTL.js +0 -2
  173. package/dist/cli-bundle/focused-chunks/chunk-PUISBOPP.js +0 -2
  174. package/dist/cli-bundle/focused-chunks/chunk-QLNMCESQ.js +0 -155
  175. package/dist/cli-bundle/focused-chunks/chunk-SLKC6QLJ.js +0 -2
  176. package/dist/cli-bundle/focused-chunks/chunk-U65UC4G3.js +0 -2
@@ -1,12 +1,410 @@
1
- /** Recovery-reference kinds emitted by structured refusal envelopes. */
1
+ /**
2
+ * @module sdk/agent/refusal-reachability
3
+ *
4
+ * Verifies real-entrypoint observations against refusal states declared by the
5
+ * generated public error-code catalog.
6
+ */
2
7
 
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]="631031be-883f-5a1d-bcb6-498208cf7922")}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]="70af2366-a675-5631-8edb-4ebeef4bb786")}catch(e){}}();
9
+ import { stripTypeScriptTypes } from "node:module";
10
+ /** Recovery-reference kinds emitted by structured refusal envelopes. */
4
11
  export const PM_RECOVERY_REFERENCE_KINDS = [
5
12
  "suggested_retry",
6
13
  "candidate_command",
7
14
  "example",
8
15
  "next_step",
16
+ "migration_hint",
17
+ "restore_with",
9
18
  ];
19
+ const RECOVERY_REFERENCE_FIELD_CONTRACTS = {
20
+ suggested_retry: { kind: "suggested_retry", semantics: "recovery" },
21
+ retry_command: { kind: "suggested_retry", semantics: "recovery" },
22
+ candidate_command: { kind: "candidate_command", semantics: "recovery" },
23
+ candidate_commands: { kind: "candidate_command", semantics: "recovery" },
24
+ fallback_candidates: {
25
+ kind: "candidate_command",
26
+ semantics: "recovery",
27
+ nested_value_field: "command",
28
+ },
29
+ next_best_command: { kind: "candidate_command", semantics: "recovery" },
30
+ example: { kind: "example", semantics: "recovery" },
31
+ examples: { kind: "example", semantics: "recovery" },
32
+ next_step: { kind: "next_step", semantics: "recovery" },
33
+ next_steps: { kind: "next_step", semantics: "recovery" },
34
+ suggested_next_steps: { kind: "next_step", semantics: "recovery" },
35
+ migration_hint: { kind: "migration_hint", semantics: "replacement" },
36
+ migration_hints: { kind: "migration_hint", semantics: "replacement" },
37
+ restore_with: {
38
+ kind: "restore_with",
39
+ semantics: "behavior_preserving",
40
+ },
41
+ };
42
+ /** Literal envelope fields recognized as recovery-reference producers. */
43
+ export const PM_RECOVERY_REFERENCE_FIELDS = Object.freeze(Object.keys(RECOVERY_REFERENCE_FIELD_CONTRACTS));
44
+ /** Resolve an own recovery-field contract without trusting object prototypes. */
45
+ function recoveryReferenceContract(field) {
46
+ if (!Object.hasOwn(RECOVERY_REFERENCE_FIELD_CONTRACTS, field))
47
+ return undefined;
48
+ return RECOVERY_REFERENCE_FIELD_CONTRACTS[field];
49
+ }
50
+ const SOURCE_REGEXP_PREFIX_PUNCTUATORS = new Set([
51
+ ..."=([{,:;!?&|+-*%^~<>",
52
+ "=>",
53
+ ]);
54
+ function compareCodeUnits(left, right) {
55
+ return left < right ? -1 : left > right ? 1 : 0;
56
+ }
57
+ function skipQuotedSourceToken(source, index) {
58
+ const quote = source[index];
59
+ let next = index + 1;
60
+ let value = "";
61
+ while (next < source.length && source[next] !== quote) {
62
+ if (source[next] === "\\")
63
+ next += 2;
64
+ else {
65
+ value += source[next];
66
+ next += 1;
67
+ }
68
+ }
69
+ if (source[next] === quote)
70
+ next += 1;
71
+ return { next, value };
72
+ }
73
+ function canStartRegularExpression(previous) {
74
+ return (previous === undefined ||
75
+ (previous.kind === "punctuator" &&
76
+ SOURCE_REGEXP_PREFIX_PUNCTUATORS.has(previous.value)) ||
77
+ (previous.kind === "identifier" &&
78
+ ["return", "case", "throw", "else", "yield"].includes(previous.value)));
79
+ }
80
+ function sourceTriviaEnd(source, index) {
81
+ if (/\s/u.test(source[index]))
82
+ return index + 1;
83
+ if (source.startsWith("//", index)) {
84
+ const newline = source.indexOf("\n", index + 2);
85
+ return newline === -1 ? source.length : newline + 1;
86
+ }
87
+ if (!source.startsWith("/*", index))
88
+ return undefined;
89
+ // stripTypeScriptTypes validates block-comment termination before tokenization.
90
+ return source.indexOf("*/", index + 2) + 2;
91
+ }
92
+ function regularExpressionEnd(source, index, previous) {
93
+ if (source[index] !== "/" || !canStartRegularExpression(previous))
94
+ return undefined;
95
+ let next = index + 1;
96
+ let inClass = false;
97
+ while (next < source.length) {
98
+ if (source[next] === "\\")
99
+ next += 2;
100
+ else if (source[next] === "[") {
101
+ inClass = true;
102
+ next += 1;
103
+ }
104
+ else if (source[next] === "]") {
105
+ inClass = false;
106
+ next += 1;
107
+ }
108
+ else if (source[next] === "/" && !inClass) {
109
+ next += 1;
110
+ while (/[A-Za-z]/u.test(source.charAt(next)))
111
+ next += 1;
112
+ return next;
113
+ }
114
+ else
115
+ next += 1;
116
+ }
117
+ return next;
118
+ }
119
+ function readSourceSyntaxToken(source, index) {
120
+ const character = source[index];
121
+ if (character === "'" || character === '"' || character === "`") {
122
+ const quoted = skipQuotedSourceToken(source, index);
123
+ return character === "`"
124
+ ? { next: quoted.next }
125
+ : {
126
+ next: quoted.next,
127
+ token: { kind: "string", value: quoted.value, offset: index + 1 },
128
+ };
129
+ }
130
+ if (/[A-Za-z_$]/u.test(character)) {
131
+ let next = index + 1;
132
+ while (/[A-Za-z0-9_$]/u.test(source[next] ?? ""))
133
+ next += 1;
134
+ return {
135
+ next,
136
+ token: {
137
+ kind: "identifier",
138
+ value: source.slice(index, next),
139
+ offset: index,
140
+ },
141
+ };
142
+ }
143
+ const punctuator = source.startsWith("=>", index) ? "=>" : character;
144
+ return {
145
+ next: index + punctuator.length,
146
+ token: { kind: "punctuator", value: punctuator, offset: index },
147
+ };
148
+ }
149
+ /** Tokenize executable JavaScript while ignoring comments, templates, and regex bodies. */
150
+ function tokenizeExecutableSource(source) {
151
+ const tokens = [];
152
+ let index = 0;
153
+ while (index < source.length) {
154
+ const ignoredEnd = sourceTriviaEnd(source, index);
155
+ if (ignoredEnd !== undefined) {
156
+ index = ignoredEnd;
157
+ continue;
158
+ }
159
+ const regexEnd = regularExpressionEnd(source, index, tokens.at(-1));
160
+ if (regexEnd !== undefined) {
161
+ index = regexEnd;
162
+ continue;
163
+ }
164
+ const read = readSourceSyntaxToken(source, index);
165
+ if (read.token)
166
+ tokens.push(read.token);
167
+ index = read.next;
168
+ }
169
+ return tokens;
170
+ }
171
+ const SOURCE_BRACE_FRAME_KINDS = new Set([
172
+ "object",
173
+ "block",
174
+ "pattern",
175
+ ]);
176
+ const SOURCE_PATTERN_DECLARATIONS = new Set(["const", "let", "var"]);
177
+ const SOURCE_CLOSING_TOKENS = new Set(["}", ")", "]"]);
178
+ const SOURCE_OBJECT_PRECEDERS = new Set([
179
+ "=",
180
+ "(",
181
+ "[",
182
+ ",",
183
+ ":",
184
+ "?",
185
+ "return",
186
+ ]);
187
+ function objectFrameKind(tokens, index, stack) {
188
+ const enclosingBrace = [...stack]
189
+ .reverse()
190
+ .find((frame) => SOURCE_BRACE_FRAME_KINDS.has(frame.kind));
191
+ if (enclosingBrace?.kind === "pattern")
192
+ return "pattern";
193
+ if (stack.at(-1)?.kind === "paren" && stack.at(-1)?.parameter_list)
194
+ return "pattern";
195
+ const previous = tokens[index - 1];
196
+ if (previous?.kind === "identifier" &&
197
+ SOURCE_PATTERN_DECLARATIONS.has(previous.value)) {
198
+ return "pattern";
199
+ }
200
+ if (previous?.value === "=>" || previous?.value === ")")
201
+ return "block";
202
+ return previous && SOURCE_OBJECT_PRECEDERS.has(previous.value)
203
+ ? "object"
204
+ : "block";
205
+ }
206
+ function openingSourceFrame(tokens, index, stack) {
207
+ const token = tokens[index];
208
+ if (token.value === "{") {
209
+ const kind = objectFrameKind(tokens, index, stack);
210
+ return {
211
+ kind,
212
+ ...(kind === "object" ? { member_start: true, candidates: [] } : {}),
213
+ };
214
+ }
215
+ if (token.value === "[")
216
+ return { kind: "array" };
217
+ if (token.value !== "(")
218
+ return undefined;
219
+ const previous = tokens[index - 1];
220
+ const beforePrevious = tokens[index - 2];
221
+ const parameterList = previous?.value === "function" || beforePrevious?.value === "function";
222
+ return { kind: "paren", ...(parameterList ? { parameter_list: true } : {}) };
223
+ }
224
+ function staticObjectMember(frame, token, next) {
225
+ if (frame?.kind !== "object" ||
226
+ !frame.member_start ||
227
+ (token.kind !== "identifier" && token.kind !== "string") ||
228
+ next?.value !== ":" ||
229
+ !/^[A-Za-z][A-Za-z0-9_]*$/u.test(token.value)) {
230
+ return undefined;
231
+ }
232
+ return { field: token.value, offset: token.offset };
233
+ }
234
+ function isPatternLikeObjectClosure(tokens, index) {
235
+ return ((tokens[index + 1]?.value === ")" && tokens[index + 2]?.value === "=>") ||
236
+ tokens[index + 1]?.value === "=");
237
+ }
238
+ /** Parse static object-literal members without treating patterns or labels as producers. */
239
+ function scanSourcePropertyTokens(source) {
240
+ const tokens = tokenizeExecutableSource(stripTypeScriptTypes(source, { mode: "strip" }));
241
+ const properties = [];
242
+ const stack = [];
243
+ for (const [index, token] of tokens.entries()) {
244
+ const frame = stack.at(-1);
245
+ const property = staticObjectMember(frame, token, tokens[index + 1]);
246
+ if (property)
247
+ frame.candidates.push(property);
248
+ const opening = openingSourceFrame(tokens, index, stack);
249
+ if (opening) {
250
+ stack.push(opening);
251
+ }
252
+ else if (SOURCE_CLOSING_TOKENS.has(token.value)) {
253
+ const closed = stack.pop();
254
+ if (closed?.kind === "object" &&
255
+ !isPatternLikeObjectClosure(tokens, index)) {
256
+ properties.push(...closed.candidates);
257
+ }
258
+ }
259
+ else if (token.value === "," && frame?.kind === "object") {
260
+ frame.member_start = true;
261
+ }
262
+ else if (frame?.kind === "object" && token.value !== ":") {
263
+ frame.member_start = false;
264
+ }
265
+ }
266
+ return properties;
267
+ }
268
+ function sourceLineStarts(source) {
269
+ const starts = [0];
270
+ for (let index = 0; index < source.length; index += 1) {
271
+ if (source[index] === "\n")
272
+ starts.push(index + 1);
273
+ }
274
+ return starts;
275
+ }
276
+ function sourceLineAtOffset(starts, offset) {
277
+ let low = 0;
278
+ let high = starts.length;
279
+ while (low < high) {
280
+ const middle = Math.floor((low + high) / 2);
281
+ if (starts[middle] <= offset)
282
+ low = middle + 1;
283
+ else
284
+ high = middle;
285
+ }
286
+ return low;
287
+ }
288
+ /** Census syntax-parsed structured-envelope producers without executing source code. */
289
+ export function censusPmRecoveryReferenceProducers(sources) {
290
+ const producers = [];
291
+ const findings = [];
292
+ for (const source of [...sources].sort((left, right) => compareCodeUnits(left.path, right.path))) {
293
+ const lineStarts = sourceLineStarts(source.content);
294
+ let properties;
295
+ try {
296
+ properties = scanSourcePropertyTokens(source.content);
297
+ }
298
+ catch (error) {
299
+ findings.push({
300
+ kind: "invalid_source",
301
+ subject: source.path,
302
+ detail: `${source.path} could not be parsed for recovery producers: ${String(error)}.`,
303
+ });
304
+ continue;
305
+ }
306
+ for (const property of properties) {
307
+ const field = property.field;
308
+ const line = sourceLineAtOffset(lineStarts, property.offset);
309
+ const contract = recoveryReferenceContract(field);
310
+ if (contract) {
311
+ producers.push({
312
+ path: source.path,
313
+ line,
314
+ field: field,
315
+ kind: contract.kind,
316
+ });
317
+ }
318
+ else if (/(?:retry_command|candidate_command|fallback_candidate|next_best_command|example|next_step|migration_hint|restore_with)/u.test(field) &&
319
+ !/(?:_total|_truncated)$/u.test(field)) {
320
+ findings.push({
321
+ kind: "unknown_recovery_field",
322
+ subject: `${source.path}:${line}:${field}`,
323
+ detail: `${field} resembles a recovery reference but has no typed field contract.`,
324
+ });
325
+ }
326
+ }
327
+ }
328
+ const producerCountByKind = Object.fromEntries(PM_RECOVERY_REFERENCE_KINDS.map((kind) => [
329
+ kind,
330
+ producers.filter((producer) => producer.kind === kind).length,
331
+ ]));
332
+ for (const kind of PM_RECOVERY_REFERENCE_KINDS) {
333
+ if (producerCountByKind[kind] === 0) {
334
+ findings.push({
335
+ kind: "missing_kind_producer",
336
+ subject: kind,
337
+ detail: `No source producer emits the ${kind} recovery-reference kind.`,
338
+ });
339
+ }
340
+ }
341
+ producers.sort((left, right) => left.path !== right.path
342
+ ? compareCodeUnits(left.path, right.path)
343
+ : left.line !== right.line
344
+ ? left.line - right.line
345
+ : compareCodeUnits(left.field, right.field));
346
+ findings.sort((left, right) => left.subject !== right.subject
347
+ ? compareCodeUnits(left.subject, right.subject)
348
+ : compareCodeUnits(left.kind, right.kind));
349
+ return {
350
+ ok: findings.length === 0,
351
+ scanned_file_count: sources.length,
352
+ producer_count: producers.length,
353
+ producer_count_by_kind: producerCountByKind,
354
+ producers,
355
+ findings,
356
+ };
357
+ }
358
+ /** Derive typed obligations from every recognized recovery field in an emitted envelope. */
359
+ export function derivePmRecoveryReferenceObligations(probeId, envelope) {
360
+ const obligations = [];
361
+ const visit = (value, path) => {
362
+ if (Array.isArray(value)) {
363
+ value.forEach((entry, index) => visit(entry, [...path, String(index)]));
364
+ return;
365
+ }
366
+ if (typeof value !== "object" || value === null)
367
+ return;
368
+ for (const [key, entry] of Object.entries(value).sort(([left], [right]) => compareCodeUnits(left, right))) {
369
+ const baseContract = recoveryReferenceContract(key);
370
+ const contract = baseContract?.kind === "migration_hint" &&
371
+ value.semantics === "behavior_preserving"
372
+ ? { ...baseContract, semantics: "behavior_preserving" }
373
+ : baseContract;
374
+ const entries = [entry].flat();
375
+ if (contract !== undefined) {
376
+ entries.forEach((candidate, index) => {
377
+ const nestedValueField = "nested_value_field" in contract &&
378
+ typeof contract.nested_value_field === "string"
379
+ ? contract.nested_value_field
380
+ : undefined;
381
+ const resolvedCandidate = nestedValueField &&
382
+ typeof candidate === "object" &&
383
+ candidate !== null &&
384
+ !Array.isArray(candidate)
385
+ ? candidate[nestedValueField]
386
+ : candidate;
387
+ if (typeof resolvedCandidate !== "string" ||
388
+ resolvedCandidate.trim().length === 0)
389
+ return;
390
+ const coordinate = [...path, key, String(index)]
391
+ .map((segment) => encodeURIComponent(segment))
392
+ .join("/");
393
+ obligations.push({
394
+ id: `${probeId}:${contract.kind}:${coordinate}`,
395
+ probe_id: probeId,
396
+ kind: contract.kind,
397
+ semantics: contract.semantics,
398
+ value: resolvedCandidate,
399
+ });
400
+ });
401
+ }
402
+ visit(entry, [...path, key]);
403
+ }
404
+ };
405
+ visit(envelope, []);
406
+ return obligations;
407
+ }
10
408
  /** Compare declared refusal states with real-entrypoint observations. */
11
409
  export function verifyPmRefusalReachability(catalog, observations) {
12
410
  const declarations = catalog.flatMap((contract) => (contract.owned_states ?? []).map((state) => ({ contract, state })));
@@ -129,6 +527,13 @@ export function verifyPmRecoveryReferences(obligations, observations) {
129
527
  detail: `Recovery reference ${obligation.value} did not reach its promised target.`,
130
528
  });
131
529
  }
530
+ else if (observation.semantics !== obligation.semantics) {
531
+ findings.push({
532
+ kind: "wrong_semantics",
533
+ reference_id: obligation.id,
534
+ detail: `Recovery reference ${obligation.value} promised ${obligation.semantics}; proof demonstrated ${observation.semantics}.`,
535
+ });
536
+ }
132
537
  }
133
538
  const coverageByKind = PM_RECOVERY_REFERENCE_KINDS.map((kind) => {
134
539
  const kindObligations = obligations.filter((obligation) => obligation.kind === kind);
@@ -140,7 +545,12 @@ export function verifyPmRecoveryReferences(obligations, observations) {
140
545
  kind,
141
546
  declared: kindObligations.length,
142
547
  observed: kindObservations.length,
143
- passed: kindObservations.filter(({ reachable }) => reachable).length,
548
+ passed: kindObligations.filter((obligation) => {
549
+ const observation = observationsById.get(obligation.id);
550
+ return (!duplicateIds.has(obligation.id) &&
551
+ observation?.reachable === true &&
552
+ observation.semantics === obligation.semantics);
553
+ }).length,
144
554
  };
145
555
  });
146
556
  findings.sort((left, right) => left.reference_id !== right.reference_id
@@ -157,4 +567,4 @@ export function verifyPmRecoveryReferences(obligations, observations) {
157
567
  };
158
568
  }
159
569
  //# sourceMappingURL=refusal-reachability.js.map
160
- //# debugId=631031be-883f-5a1d-bcb6-498208cf7922
570
+ //# debugId=70af2366-a675-5631-8edb-4ebeef4bb786
@@ -46,12 +46,63 @@ export interface AcknowledgeUnknownAuthorEventsOptions {
46
46
  /** Select every currently actionable, undispositioned event in the tracker. */
47
47
  all_actionable?: boolean;
48
48
  /** Principal attributed by maintainer review. */
49
- attributed_author: string;
49
+ attributed_author?: string;
50
50
  /** Reviewer appending the disposition event. */
51
- reviewer: string;
51
+ reviewer?: string;
52
52
  /** Evidence-backed rationale for the attribution. */
53
- reason: string;
53
+ reason?: string;
54
+ /** Resolve and return the selected plan without appending history. */
55
+ dry_run?: boolean;
56
+ /** Fingerprint from the exact preview plan being applied. */
57
+ plan_fingerprint?: string;
58
+ /** Maximum coordinate rows included in the returned plan. */
59
+ coordinate_limit?: number;
54
60
  }
61
+ /** One source-bound coordinate in an author-acknowledgement plan. */
62
+ export interface UnknownAuthorAcknowledgmentPlanCoordinate extends UnknownAuthorHistoryEvent {
63
+ /** SHA-256 of the exact immutable JSONL source line. */
64
+ source_event_hash: string;
65
+ /** Whether the row is undispositioned or an explicit apply would supersede it. */
66
+ disposition: "actionable" | "already_acknowledged";
67
+ }
68
+ /** Deterministic preview shared by CLI, SDK, and MCP apply paths. */
69
+ export interface UnknownAuthorAcknowledgmentPlan {
70
+ /** Selector family resolved by the plan. */
71
+ selection: {
72
+ kind: "events" | "all_actionable";
73
+ };
74
+ /** Complete number of unique selected coordinates. */
75
+ selected_count: number;
76
+ /** Selected coordinates not covered by an earlier disposition. */
77
+ actionable_count: number;
78
+ /** Coordinates an explicit-events apply would supersede. */
79
+ already_acknowledged_count: number;
80
+ /** Coordinate rows omitted only from this bounded preview. */
81
+ omitted_count: number;
82
+ /** Stable ordered prefix of the complete selected set. */
83
+ coordinates: UnknownAuthorAcknowledgmentPlanCoordinate[];
84
+ /** SHA-256 over selection kind and every complete source-bound coordinate. */
85
+ plan_fingerprint: string;
86
+ }
87
+ /** Structured preview or apply result for immutable author acknowledgement. */
88
+ export interface UnknownAuthorAcknowledgmentResult {
89
+ /** Whether this invocation was a read-only preview. */
90
+ dry_run: boolean;
91
+ /** Whether an append-only workspace event was written. */
92
+ mutated: boolean;
93
+ /** Number of coordinates written to the appended disposition. */
94
+ acknowledged: number;
95
+ /** Effect-aware command outcome. */
96
+ outcome: "preview" | "effect" | "no_effect" | "partial_effect";
97
+ /** Stable shell and transport exit paired with the outcome. */
98
+ exit_code: 0 | 6 | 7;
99
+ /** Exact plan used for preview or apply. */
100
+ plan: UnknownAuthorAcknowledgmentPlan;
101
+ /** Appended workspace history path when mutation occurred. */
102
+ history_path?: string;
103
+ }
104
+ /** Resolve a deterministic, source-bound author-acknowledgement preview. */
105
+ export declare function planUnknownAuthorHistoryAcknowledgment(pmRoot: string, selector: Pick<AcknowledgeUnknownAuthorEventsOptions, "events" | "all_actionable">, coordinateLimit?: number): Promise<UnknownAuthorAcknowledgmentPlan>;
55
106
  /** Resolve the mutually exclusive CLI and SDK acknowledgment selectors. */
56
107
  export declare function resolveUnknownAuthorAcknowledgmentSelector(rawEvents: readonly string[], allActionable: boolean): {
57
108
  events: UnknownAuthorHistoryEvent[];
@@ -60,15 +111,9 @@ export declare function resolveUnknownAuthorAcknowledgmentSelector(rawEvents: re
60
111
  /** Parse user-facing item or workspace history coordinates into SDK events. */
61
112
  export declare function parseUnknownAuthorHistoryEventCoordinates(values: readonly string[]): UnknownAuthorHistoryEvent[];
62
113
  /** Normalize an untyped transport payload and execute author acknowledgment. */
63
- export declare function acknowledgeUnknownAuthorHistoryEventsFromTransport(pmRoot: string, input: Record<string, unknown>): Promise<{
64
- acknowledged: number;
65
- history_path: string;
66
- }>;
114
+ export declare function acknowledgeUnknownAuthorHistoryEventsFromTransport(pmRoot: string, input: Record<string, unknown>): Promise<UnknownAuthorAcknowledgmentResult>;
67
115
  /**
68
116
  * Append an audited disposition for immutable unknown-author events without
69
117
  * rewriting their original streams.
70
118
  */
71
- export declare function acknowledgeUnknownAuthorHistoryEvents(pmRoot: string, options: AcknowledgeUnknownAuthorEventsOptions): Promise<{
72
- acknowledged: number;
73
- history_path: string;
74
- }>;
119
+ export declare function acknowledgeUnknownAuthorHistoryEvents(pmRoot: string, options: AcknowledgeUnknownAuthorEventsOptions): Promise<UnknownAuthorAcknowledgmentResult>;