@gate-forge/cli 0.7.0 → 0.8.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 (254) hide show
  1. package/README.md +511 -51
  2. package/dist/adapter-audit.d.ts +154 -0
  3. package/dist/adapter-audit.d.ts.map +1 -0
  4. package/dist/adapter-audit.js +531 -0
  5. package/dist/adapter-audit.js.map +1 -0
  6. package/dist/adapter-scaffold.d.ts +66 -0
  7. package/dist/adapter-scaffold.d.ts.map +1 -0
  8. package/dist/adapter-scaffold.js +353 -0
  9. package/dist/adapter-scaffold.js.map +1 -0
  10. package/dist/adopted-baseline.d.ts +10 -0
  11. package/dist/adopted-baseline.d.ts.map +1 -1
  12. package/dist/adopted-baseline.js +18 -1
  13. package/dist/adopted-baseline.js.map +1 -1
  14. package/dist/args.d.ts +15 -0
  15. package/dist/args.d.ts.map +1 -1
  16. package/dist/args.js +59 -2
  17. package/dist/args.js.map +1 -1
  18. package/dist/behavior-setup.d.ts +239 -0
  19. package/dist/behavior-setup.d.ts.map +1 -0
  20. package/dist/behavior-setup.js +738 -0
  21. package/dist/behavior-setup.js.map +1 -0
  22. package/dist/broker.d.ts.map +1 -1
  23. package/dist/broker.js +28 -2
  24. package/dist/broker.js.map +1 -1
  25. package/dist/cache-exclusions.d.ts +45 -0
  26. package/dist/cache-exclusions.d.ts.map +1 -0
  27. package/dist/cache-exclusions.js +205 -0
  28. package/dist/cache-exclusions.js.map +1 -0
  29. package/dist/candidate-tree.d.ts +86 -14
  30. package/dist/candidate-tree.d.ts.map +1 -1
  31. package/dist/candidate-tree.js +236 -62
  32. package/dist/candidate-tree.js.map +1 -1
  33. package/dist/ci-witnessed-template.d.ts +43 -0
  34. package/dist/ci-witnessed-template.d.ts.map +1 -0
  35. package/dist/ci-witnessed-template.js +283 -0
  36. package/dist/ci-witnessed-template.js.map +1 -0
  37. package/dist/cli.d.ts +1 -1
  38. package/dist/cli.d.ts.map +1 -1
  39. package/dist/cli.js +31 -4
  40. package/dist/cli.js.map +1 -1
  41. package/dist/commands/adapters.d.ts +15 -0
  42. package/dist/commands/adapters.d.ts.map +1 -0
  43. package/dist/commands/adapters.js +284 -0
  44. package/dist/commands/adapters.js.map +1 -0
  45. package/dist/commands/adopt.d.ts.map +1 -1
  46. package/dist/commands/adopt.js +9 -1
  47. package/dist/commands/adopt.js.map +1 -1
  48. package/dist/commands/baseline.d.ts.map +1 -1
  49. package/dist/commands/baseline.js +42 -1
  50. package/dist/commands/baseline.js.map +1 -1
  51. package/dist/commands/blocking.d.ts +81 -2
  52. package/dist/commands/blocking.d.ts.map +1 -1
  53. package/dist/commands/blocking.js +336 -53
  54. package/dist/commands/blocking.js.map +1 -1
  55. package/dist/commands/check.d.ts +36 -0
  56. package/dist/commands/check.d.ts.map +1 -1
  57. package/dist/commands/check.js +1008 -62
  58. package/dist/commands/check.js.map +1 -1
  59. package/dist/commands/classify.d.ts +2 -1
  60. package/dist/commands/classify.d.ts.map +1 -1
  61. package/dist/commands/classify.js +143 -5
  62. package/dist/commands/classify.js.map +1 -1
  63. package/dist/commands/enforce.d.ts +4 -4
  64. package/dist/commands/enforce.d.ts.map +1 -1
  65. package/dist/commands/enforce.js +41 -9
  66. package/dist/commands/enforce.js.map +1 -1
  67. package/dist/commands/enforcement.d.ts +13 -1
  68. package/dist/commands/enforcement.d.ts.map +1 -1
  69. package/dist/commands/enforcement.js +800 -30
  70. package/dist/commands/enforcement.js.map +1 -1
  71. package/dist/commands/history.d.ts +12 -0
  72. package/dist/commands/history.d.ts.map +1 -0
  73. package/dist/commands/history.js +45 -0
  74. package/dist/commands/history.js.map +1 -0
  75. package/dist/commands/init-presets.d.ts +148 -0
  76. package/dist/commands/init-presets.d.ts.map +1 -0
  77. package/dist/commands/init-presets.js +194 -0
  78. package/dist/commands/init-presets.js.map +1 -0
  79. package/dist/commands/init.d.ts +7 -12
  80. package/dist/commands/init.d.ts.map +1 -1
  81. package/dist/commands/init.js +610 -69
  82. package/dist/commands/init.js.map +1 -1
  83. package/dist/commands/keys.d.ts.map +1 -1
  84. package/dist/commands/keys.js +29 -13
  85. package/dist/commands/keys.js.map +1 -1
  86. package/dist/commands/next.d.ts.map +1 -1
  87. package/dist/commands/next.js +744 -15
  88. package/dist/commands/next.js.map +1 -1
  89. package/dist/commands/pre-commit.d.ts +25 -0
  90. package/dist/commands/pre-commit.d.ts.map +1 -1
  91. package/dist/commands/pre-commit.js +91 -6
  92. package/dist/commands/pre-commit.js.map +1 -1
  93. package/dist/commands/quarantine.d.ts +16 -0
  94. package/dist/commands/quarantine.d.ts.map +1 -0
  95. package/dist/commands/quarantine.js +213 -0
  96. package/dist/commands/quarantine.js.map +1 -0
  97. package/dist/commands/run.d.ts +39 -0
  98. package/dist/commands/run.d.ts.map +1 -0
  99. package/dist/commands/run.js +196 -0
  100. package/dist/commands/run.js.map +1 -0
  101. package/dist/commands/test-gates.d.ts +284 -2
  102. package/dist/commands/test-gates.d.ts.map +1 -1
  103. package/dist/commands/test-gates.js +3619 -186
  104. package/dist/commands/test-gates.js.map +1 -1
  105. package/dist/commands/tests.d.ts +1 -1
  106. package/dist/commands/tests.d.ts.map +1 -1
  107. package/dist/commands/tests.js +225 -22
  108. package/dist/commands/tests.js.map +1 -1
  109. package/dist/endpoint-compiler.d.ts.map +1 -1
  110. package/dist/endpoint-compiler.js +29 -8
  111. package/dist/endpoint-compiler.js.map +1 -1
  112. package/dist/engine-browser.d.ts +183 -0
  113. package/dist/engine-browser.d.ts.map +1 -0
  114. package/dist/engine-browser.js +381 -0
  115. package/dist/engine-browser.js.map +1 -0
  116. package/dist/engine-identity.d.ts +100 -0
  117. package/dist/engine-identity.d.ts.map +1 -0
  118. package/dist/engine-identity.js +182 -0
  119. package/dist/engine-identity.js.map +1 -0
  120. package/dist/evaluate.d.ts +89 -0
  121. package/dist/evaluate.d.ts.map +1 -1
  122. package/dist/evaluate.js +137 -16
  123. package/dist/evaluate.js.map +1 -1
  124. package/dist/execution.d.ts +253 -9
  125. package/dist/execution.d.ts.map +1 -1
  126. package/dist/execution.js +309 -12
  127. package/dist/execution.js.map +1 -1
  128. package/dist/git-hooks.d.ts +17 -0
  129. package/dist/git-hooks.d.ts.map +1 -1
  130. package/dist/git-hooks.js +119 -0
  131. package/dist/git-hooks.js.map +1 -1
  132. package/dist/git-objects.d.ts +60 -0
  133. package/dist/git-objects.d.ts.map +1 -0
  134. package/dist/git-objects.js +152 -0
  135. package/dist/git-objects.js.map +1 -0
  136. package/dist/history.d.ts +52 -0
  137. package/dist/history.d.ts.map +1 -0
  138. package/dist/history.js +116 -0
  139. package/dist/history.js.map +1 -0
  140. package/dist/host-load.d.ts +49 -0
  141. package/dist/host-load.d.ts.map +1 -0
  142. package/dist/host-load.js +78 -0
  143. package/dist/host-load.js.map +1 -0
  144. package/dist/input-snapshot.d.ts +63 -9
  145. package/dist/input-snapshot.d.ts.map +1 -1
  146. package/dist/input-snapshot.js +195 -17
  147. package/dist/input-snapshot.js.map +1 -1
  148. package/dist/io.d.ts +36 -0
  149. package/dist/io.d.ts.map +1 -1
  150. package/dist/io.js +21 -0
  151. package/dist/io.js.map +1 -1
  152. package/dist/mapping.d.ts +84 -1
  153. package/dist/mapping.d.ts.map +1 -1
  154. package/dist/mapping.js +276 -5
  155. package/dist/mapping.js.map +1 -1
  156. package/dist/native-freeze.d.ts +217 -0
  157. package/dist/native-freeze.d.ts.map +1 -0
  158. package/dist/native-freeze.js +332 -0
  159. package/dist/native-freeze.js.map +1 -0
  160. package/dist/pipeline.d.ts +52 -1
  161. package/dist/pipeline.d.ts.map +1 -1
  162. package/dist/pipeline.js +141 -3
  163. package/dist/pipeline.js.map +1 -1
  164. package/dist/playwright-browsers.d.ts +210 -0
  165. package/dist/playwright-browsers.d.ts.map +1 -0
  166. package/dist/playwright-browsers.js +364 -0
  167. package/dist/playwright-browsers.js.map +1 -0
  168. package/dist/plugins.d.ts +15 -5
  169. package/dist/plugins.d.ts.map +1 -1
  170. package/dist/plugins.js +59 -9
  171. package/dist/plugins.js.map +1 -1
  172. package/dist/progress.d.ts +148 -0
  173. package/dist/progress.d.ts.map +1 -0
  174. package/dist/progress.js +263 -0
  175. package/dist/progress.js.map +1 -0
  176. package/dist/providers.d.ts +26 -1
  177. package/dist/providers.d.ts.map +1 -1
  178. package/dist/providers.js +39 -0
  179. package/dist/providers.js.map +1 -1
  180. package/dist/receipts.d.ts +1 -0
  181. package/dist/receipts.d.ts.map +1 -1
  182. package/dist/receipts.js +35 -7
  183. package/dist/receipts.js.map +1 -1
  184. package/dist/repo-scan.d.ts +8 -1
  185. package/dist/repo-scan.d.ts.map +1 -1
  186. package/dist/repo-scan.js +221 -27
  187. package/dist/repo-scan.js.map +1 -1
  188. package/dist/reseal-chain.d.ts +184 -0
  189. package/dist/reseal-chain.d.ts.map +1 -0
  190. package/dist/reseal-chain.js +735 -0
  191. package/dist/reseal-chain.js.map +1 -0
  192. package/dist/reseal-evidence.d.ts +241 -0
  193. package/dist/reseal-evidence.d.ts.map +1 -0
  194. package/dist/reseal-evidence.js +319 -0
  195. package/dist/reseal-evidence.js.map +1 -0
  196. package/dist/reseal.d.ts +181 -0
  197. package/dist/reseal.d.ts.map +1 -0
  198. package/dist/reseal.js +1620 -0
  199. package/dist/reseal.js.map +1 -0
  200. package/dist/response-field-guidance.d.ts +82 -0
  201. package/dist/response-field-guidance.d.ts.map +1 -0
  202. package/dist/response-field-guidance.js +184 -0
  203. package/dist/response-field-guidance.js.map +1 -0
  204. package/dist/run-cache.d.ts +260 -0
  205. package/dist/run-cache.d.ts.map +1 -0
  206. package/dist/run-cache.js +771 -0
  207. package/dist/run-cache.js.map +1 -0
  208. package/dist/run-preflight.d.ts +77 -0
  209. package/dist/run-preflight.d.ts.map +1 -0
  210. package/dist/run-preflight.js +774 -0
  211. package/dist/run-preflight.js.map +1 -0
  212. package/dist/run-recipe.d.ts +107 -0
  213. package/dist/run-recipe.d.ts.map +1 -0
  214. package/dist/run-recipe.js +295 -0
  215. package/dist/run-recipe.js.map +1 -0
  216. package/dist/run-reliability.d.ts +126 -0
  217. package/dist/run-reliability.d.ts.map +1 -0
  218. package/dist/run-reliability.js +221 -0
  219. package/dist/run-reliability.js.map +1 -0
  220. package/dist/runtime.d.ts +15 -0
  221. package/dist/runtime.d.ts.map +1 -1
  222. package/dist/runtime.js +11 -1
  223. package/dist/runtime.js.map +1 -1
  224. package/dist/secret-guard.d.ts +36 -0
  225. package/dist/secret-guard.d.ts.map +1 -0
  226. package/dist/secret-guard.js +63 -0
  227. package/dist/secret-guard.js.map +1 -0
  228. package/dist/singleton-guidance.d.ts +73 -0
  229. package/dist/singleton-guidance.d.ts.map +1 -0
  230. package/dist/singleton-guidance.js +118 -0
  231. package/dist/singleton-guidance.js.map +1 -0
  232. package/dist/staged-candidate.d.ts +17 -0
  233. package/dist/staged-candidate.d.ts.map +1 -1
  234. package/dist/staged-candidate.js +50 -0
  235. package/dist/staged-candidate.js.map +1 -1
  236. package/dist/state-artifacts.d.ts +70 -0
  237. package/dist/state-artifacts.d.ts.map +1 -0
  238. package/dist/state-artifacts.js +215 -0
  239. package/dist/state-artifacts.js.map +1 -0
  240. package/dist/state.d.ts +170 -2
  241. package/dist/state.d.ts.map +1 -1
  242. package/dist/state.js +248 -8
  243. package/dist/state.js.map +1 -1
  244. package/dist/verifier-keys.d.ts +33 -2
  245. package/dist/verifier-keys.d.ts.map +1 -1
  246. package/dist/verifier-keys.js +95 -9
  247. package/dist/verifier-keys.js.map +1 -1
  248. package/guides/CONNECT-YOUR-PROJECT.md +367 -0
  249. package/guides/QUICKSTART.md +404 -0
  250. package/guides/RUNNER-NEUTRAL-EVIDENCE.md +199 -0
  251. package/guides/TEST-ENVIRONMENT.md +1226 -0
  252. package/guides/UPGRADE-0.6-to-0.7.md +65 -0
  253. package/guides/UPGRADE-0.7-to-0.8.md +114 -0
  254. package/package.json +12 -10
@@ -0,0 +1,332 @@
1
+ import { lstatSync, readlinkSync, realpathSync } from 'node:fs';
2
+ import { relative, resolve, sep } from 'node:path';
3
+ import { FREEZE_CONTROLLER_PROJECT, resolveProjectStorageState, } from '@gate-forge/pack-playwright';
4
+ /**
5
+ * Splits the planned project scopes into prerequisites and bodies, or
6
+ * explains why the captured graph cannot be trusted to order this run.
7
+ *
8
+ * The closure is walked from every PLANNED project (not from the
9
+ * dependency roots the plan happens to reach): a body project with no
10
+ * edges of its own still has to be frozen, which is why the barrier also
11
+ * arms for an independent, empty-edge project.
12
+ *
13
+ * @param projectScopes: the planned per-project file selection.
14
+ * @param projectDependencies: the graph the RUNNER resolved, or undefined
15
+ * when the enumeration could not read it.
16
+ *
17
+ * @returns
18
+ * `{plan}` | `{problem}`: the split, or one plain refusal.
19
+ */
20
+ export function planNativeFreeze(input) {
21
+ const { projectScopes, projectDependencies } = input;
22
+ if (projectScopes.length === 0) {
23
+ return { problem: 'this run planned no project scope, so there is nothing to freeze before' };
24
+ }
25
+ if (projectDependencies === undefined) {
26
+ return {
27
+ problem: 'the runner\'s resolved project graph could not be read, so the prerequisite stage cannot be ' +
28
+ 'ordered against the bodies — a global freeze is only honest on a known graph',
29
+ };
30
+ }
31
+ const planned = [];
32
+ for (const scope of projectScopes) {
33
+ if (planned.includes(scope.name)) {
34
+ return { problem: `project '${scope.name}' was planned twice, so its execution order is ambiguous` };
35
+ }
36
+ if (scope.name === FREEZE_CONTROLLER_PROJECT) {
37
+ return {
38
+ problem: `a project is named '${FREEZE_CONTROLLER_PROJECT}', which the engine reserves for its own ` +
39
+ 'preparation-freeze controller',
40
+ };
41
+ }
42
+ if (!Object.prototype.hasOwnProperty.call(projectDependencies, scope.name)) {
43
+ return {
44
+ problem: `project '${scope.name}' was planned but the runner's own resolved graph never recorded it — the ` +
45
+ 'captured graph and the captured tests disagree, so no ordering may be derived from either',
46
+ };
47
+ }
48
+ planned.push(scope.name);
49
+ }
50
+ const prerequisites = new Set();
51
+ const queue = [...planned];
52
+ while (queue.length > 0) {
53
+ const current = queue.shift();
54
+ for (const dependency of projectDependencies[current] ?? []) {
55
+ if (prerequisites.has(dependency))
56
+ continue;
57
+ prerequisites.add(dependency);
58
+ queue.push(dependency);
59
+ }
60
+ }
61
+ return {
62
+ plan: {
63
+ controllerProject: FREEZE_CONTROLLER_PROJECT,
64
+ prerequisiteProjects: [...prerequisites].sort(),
65
+ bodyProjects: planned.filter((name) => !prerequisites.has(name)),
66
+ },
67
+ };
68
+ }
69
+ /**
70
+ * Decides, per captured `use.storageState` declaration, whether native
71
+ * preparation may CREATE or MODIFY that path.
72
+ *
73
+ * The declaration itself is only a READ path — it says where a project
74
+ * reads browser state, not which bytes preparation owns. A declaration
75
+ * therefore becomes a generated-output target only when all of these hold:
76
+ *
77
+ * - it resolves inside the candidate root (already enforced physically by
78
+ * {@link resolveProjectStorageState}, repeated here so the classification
79
+ * can never disagree with the containment rule);
80
+ * - it is NOT tracked by git — a tracked file is source, and no setup may
81
+ * redefine it as "generated";
82
+ * - it is NOT part of the input inventory — a file the run's digest binds
83
+ * is authority, not output;
84
+ * - it is not an owner-approved excluded documentation or cache path.
85
+ *
86
+ * Everything else stays a valid, immutable read declaration. This is what
87
+ * keeps a repository that ships a committed fixture session working: its
88
+ * state is read, unchanged, and any actual write to it is refused by name
89
+ * at the global diff.
90
+ *
91
+ * @param root: the absolute candidate root (containment boundary).
92
+ * @param nativeConfigDir: the directory relative declarations resolve from.
93
+ * @param storageStates: project → declared `use.storageState`, as captured.
94
+ * @param tracked: repo-relative paths git tracks.
95
+ * @param inputFiles: repo-relative paths the run's input snapshot binds.
96
+ * @param docsExclusions: approved documentation folders.
97
+ * @param cacheExclusions: approved bytecode files.
98
+ *
99
+ * @returns
100
+ * GeneratedTargetClass: the writable set and the named refusals.
101
+ */
102
+ export function classifyGeneratedTargets(input) {
103
+ const eligible = new Set();
104
+ const refused = new Map();
105
+ const root = resolve(input.root);
106
+ const excluded = (relativePath) => input.docsExclusions.some((folder) => relativePath === folder || relativePath.startsWith(`${folder}/`)) ||
107
+ input.cacheExclusions.includes(relativePath);
108
+ for (const [project, declared] of Object.entries(input.storageStates)) {
109
+ let absolute;
110
+ try {
111
+ absolute = resolveProjectStorageState(declared, root, project, input.nativeConfigDir);
112
+ }
113
+ catch (error) {
114
+ refused.set(declared, error.message);
115
+ continue;
116
+ }
117
+ const relativePath = relative(root, absolute).split(sep).join('/');
118
+ if (relativePath.length === 0 || relativePath.startsWith('..')) {
119
+ refused.set(relativePath, 'the declared state resolves outside the candidate root');
120
+ continue;
121
+ }
122
+ if (excluded(relativePath)) {
123
+ refused.set(relativePath, 'it is an owner-approved excluded path, which no run may write');
124
+ continue;
125
+ }
126
+ if (input.tracked.has(relativePath)) {
127
+ refused.set(relativePath, 'it is tracked by git, so it is source: a declared storage state is a READ path and never a ' +
128
+ 'write permission over tracked bytes');
129
+ continue;
130
+ }
131
+ if (input.inputFiles.has(relativePath)) {
132
+ refused.set(relativePath, 'it is bound by this run\'s input snapshot, so preparation may not redefine what the run tested');
133
+ continue;
134
+ }
135
+ eligible.add(relativePath);
136
+ }
137
+ return { eligible, refused };
138
+ }
139
+ /**
140
+ * The RAW symmetric difference between the frozen baseline candidate tree
141
+ * and the prepared one, reduced to the writes that must fail.
142
+ *
143
+ * An entry that exists in both trees with the same blob and mode is not a
144
+ * change at all. Anything else must be an admissible generated target
145
+ * ADDITION or MODIFICATION; a REMOVAL always fails, eligible target or
146
+ * not — deleting the artifact a body needs is never preparation.
147
+ *
148
+ * @param baseline: the frozen pre-run candidate tree entries.
149
+ * @param prepared: the candidate tree entries at the freeze.
150
+ * @param targets: the writable classification (see
151
+ * {@link classifyGeneratedTargets}).
152
+ *
153
+ * @returns
154
+ * string[]: one refusal per offending path, naming the path, sorted.
155
+ */
156
+ export function preparedCandidateViolations(input) {
157
+ const before = new Map(input.baseline.map((entry) => [entry.path, entry]));
158
+ const after = new Map(input.prepared.map((entry) => [entry.path, entry]));
159
+ const violations = [];
160
+ for (const path of [...after.keys()].sort()) {
161
+ const now = after.get(path);
162
+ const then = before.get(path);
163
+ const change = then === undefined ? 'created' : `${then.sha} → ${now.sha}`;
164
+ if (then !== undefined && then.sha === now.sha && then.mode === now.mode)
165
+ continue;
166
+ if (input.targets.eligible.has(path)) {
167
+ // An admissible target is admitted as an ORDINARY FILE INSIDE THE
168
+ // CANDIDATE, re-checked HERE and not at nomination time. The
169
+ // nomination happened before the prerequisites ran, so a setup test
170
+ // could replace its own state file with a symbolic link in between;
171
+ // the snapshot records links as `120000` entries rather than
172
+ // rejecting them. An admitted write that is a link, or whose real
173
+ // path leaves the candidate, is refused BY NAME here.
174
+ if (now.mode === SYMLINK_MODE) {
175
+ violations.push(`native preparation ${change} '${path}' into a symbolic link — a generated target must be an ` +
176
+ 'ordinary file inside the candidate, never a link');
177
+ continue;
178
+ }
179
+ const escape = physicalEscapeOf(input.root, path);
180
+ if (escape !== null) {
181
+ violations.push(`native preparation ${change} '${path}', which reaches outside the candidate ('${escape}') — ` +
182
+ 'a generated target is admitted only while it physically stays inside');
183
+ }
184
+ continue;
185
+ }
186
+ violations.push(`native preparation ${change} '${path}', which is not an admissible generated target` +
187
+ (input.targets.refused.has(path) ? ` (${input.targets.refused.get(path)})` : ''));
188
+ }
189
+ for (const path of [...before.keys()].sort()) {
190
+ if (after.has(path))
191
+ continue;
192
+ violations.push(`native preparation removed '${path}' — a removal is never admissible, whatever the path is`);
193
+ }
194
+ return violations;
195
+ }
196
+ /** The Git mode a recorded symbolic link carries in a candidate tree. */
197
+ const SYMLINK_MODE = '120000';
198
+ /**
199
+ * Whether a repo-relative path is not an ordinary file inside the
200
+ * candidate once links are followed. Null means it is (or no longer
201
+ * exists on disk, which the seal-time drift check settles separately).
202
+ *
203
+ * This answers the PHYSICAL question the lexical one cannot: a link, or a
204
+ * chain of links, that leaves the tree — exactly the shape a setup test
205
+ * could produce after its target was nominated.
206
+ *
207
+ * @param root: absolute candidate root.
208
+ * @param path: repo-relative posix path.
209
+ *
210
+ * @returns
211
+ * string | null: what escapes, or null.
212
+ */
213
+ function physicalEscapeOf(root, path) {
214
+ const base = resolve(root);
215
+ const absolute = resolve(base, path);
216
+ let stats;
217
+ try {
218
+ stats = lstatSync(absolute);
219
+ }
220
+ catch {
221
+ return null;
222
+ }
223
+ if (stats.isSymbolicLink())
224
+ return readlinkSync(absolute);
225
+ if (!stats.isFile())
226
+ return `${path} is not an ordinary file`;
227
+ let real;
228
+ let realBase;
229
+ try {
230
+ real = realpathSync(absolute);
231
+ realBase = realpathSync(base);
232
+ }
233
+ catch {
234
+ return `${path} cannot be resolved on this host`;
235
+ }
236
+ if (real === realBase || real.startsWith(realBase + sep))
237
+ return null;
238
+ return real;
239
+ }
240
+ /**
241
+ * Proves, from the AUTHENTICATED witness execution trace, that every
242
+ * prerequisite identity really passed before the candidate is frozen.
243
+ *
244
+ * The trace is the supervisor's own record, not the suite's: a
245
+ * prerequisite counts only when the witness minted EXACTLY ONE session
246
+ * for it, sealed that session, and recorded `passed` on it.
247
+ *
248
+ * The distinction that matters is PENDING versus TERMINAL. A
249
+ * prerequisite with no session YET is pending: the runner may still be
250
+ * executing it, so the trusted side waits. A prerequisite that already
251
+ * sealed as anything but `passed`, that opened more than one session
252
+ * (a retry or a confused lifecycle), or whose trace is unreadable, is
253
+ * TERMINAL — waiting cannot change it, so waiting would only turn a
254
+ * permanent refusal into a slow one.
255
+ *
256
+ * @param trace: the witness execution trace, or null when it is unreadable.
257
+ * @param prerequisites: every prerequisite identity the plan executed.
258
+ *
259
+ * @returns
260
+ * {pending, refused}: pending reasons worth waiting for (empty when
261
+ * everything passed), and terminal reasons that end the wait at once.
262
+ */
263
+ export function unfrozenPrerequisiteState(input) {
264
+ if (input.trace === null) {
265
+ return {
266
+ pending: [],
267
+ refused: [
268
+ 'the witness execution trace could not be read, so no prerequisite can be proven to have passed ' +
269
+ 'before the candidate is frozen',
270
+ ],
271
+ };
272
+ }
273
+ const pending = [];
274
+ const refused = [];
275
+ for (const prerequisite of input.prerequisites) {
276
+ const key = prerequisite.titlePath.join('>');
277
+ const matches = input.trace.filter((traced) => traced.file === prerequisite.file && traced.titlePath.join('>') === key);
278
+ if (matches.length === 0) {
279
+ pending.push(`prerequisite '${prerequisite.file}#${key}' has no witness session yet`);
280
+ continue;
281
+ }
282
+ const sessions = matches.flatMap((traced) => traced.sessions);
283
+ if (sessions.length === 0) {
284
+ pending.push(`prerequisite '${prerequisite.file}#${key}' recorded no session yet`);
285
+ continue;
286
+ }
287
+ if (sessions.length > 1) {
288
+ refused.push(`prerequisite '${prerequisite.file}#${key}' opened ${String(sessions.length)} sessions — a retry or a ` +
289
+ 'duplicated lifecycle is never a prerequisite this run may freeze over');
290
+ continue;
291
+ }
292
+ const session = sessions[0];
293
+ if (session === undefined || session.sealedTick === null) {
294
+ pending.push(`prerequisite '${prerequisite.file}#${key}' has not sealed its session yet`);
295
+ continue;
296
+ }
297
+ if (session.outcome !== 'passed') {
298
+ refused.push(`prerequisite '${prerequisite.file}#${key}' sealed as '${session.outcome ?? 'unknown'}' — only a ` +
299
+ 'genuine pass may precede a frozen candidate');
300
+ }
301
+ }
302
+ return { pending, refused };
303
+ }
304
+ /**
305
+ * Checks the controller's request against the identities THIS run armed.
306
+ * A request is data the controller wrote into a file the suite can also
307
+ * write, so it is only accepted when it names this run, this invocation
308
+ * and this exact per-invocation nonce.
309
+ *
310
+ * @param request: the parsed controller request (unknown shape allowed).
311
+ * @param armed: the identities the CLI minted for this invocation.
312
+ *
313
+ * @returns
314
+ * FreezeRequest | string: the accepted request, or the plain refusal.
315
+ */
316
+ export function acceptedFreezeRequest(request, armed) {
317
+ if (typeof request !== 'object' || request === null) {
318
+ return 'the controller request is not an object';
319
+ }
320
+ const row = request;
321
+ if (row['project'] !== armed.project) {
322
+ return `the controller request names project '${String(row['project'])}', not this run's controller`;
323
+ }
324
+ if (row['runId'] !== armed.runId || row['invocationId'] !== armed.invocationId) {
325
+ return 'the controller request belongs to another run or invocation';
326
+ }
327
+ if (row['nonce'] !== armed.nonce) {
328
+ return 'the controller request carries another nonce (a replayed or forged request)';
329
+ }
330
+ return row;
331
+ }
332
+ //# sourceMappingURL=native-freeze.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-freeze.js","sourceRoot":"","sources":["../src/native-freeze.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAG3B,MAAM,6BAA6B,CAAC;AA6BrC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAGhC;IACC,MAAM,EAAE,aAAa,EAAE,mBAAmB,EAAE,GAAG,KAAK,CAAC;IACrD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,OAAO,EAAE,yEAAyE,EAAE,CAAC;IAChG,CAAC;IACD,IAAI,mBAAmB,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO;YACL,OAAO,EACL,8FAA8F;gBAC9F,8EAA8E;SACjF,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;QAClC,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,EAAE,OAAO,EAAE,YAAY,KAAK,CAAC,IAAI,0DAA0D,EAAE,CAAC;QACvG,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,yBAAyB,EAAE,CAAC;YAC7C,OAAO;gBACL,OAAO,EAAE,uBAAuB,yBAAyB,2CAA2C;oBAClG,+BAA+B;aAClC,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3E,OAAO;gBAC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,IAAI,OAAO,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CACV,iBAAiB,YAAY,CAAC,IAAI,IAAI,GAAG,gBAAgB,OAAO,CAAC,OAAO,IAAI,SAAS,aAAa;gBAChG,6CAA6C,CAChD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAgB,EAChB,KAA8E;IAE9E,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACpD,OAAO,yCAAyC,CAAC;IACnD,CAAC;IACD,MAAM,GAAG,GAAG,OAAkC,CAAC;IAC/C,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;QACrC,OAAO,yCAAyC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,8BAA8B,CAAC;IACvG,CAAC;IACD,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,KAAK,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,KAAK,CAAC,YAAY,EAAE,CAAC;QAC/E,OAAO,6DAA6D,CAAC;IACvE,CAAC;IACD,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC;QACjC,OAAO,6EAA6E,CAAC;IACvF,CAAC;IACD,OAAO,GAA+B,CAAC;AACzC,CAAC"}
@@ -1,4 +1,5 @@
1
- import { type BehaviorCatalog, type ChangedProvider, type ClassificationFile, type ClassificationResult, type DetectorOutput, type GateforgeConfig, type PolicyEvaluationResult, type ResourceGraph, type RunManifest } from '@gate-forge/core';
1
+ import { type BehaviorCatalog, type ChangedProvider, type ClassificationFile, type ClassificationResult, type DetectorOutput, type GateforgeConfig, type PolicyEvaluationResult, type ResourceGraph, type RunManifest, type LifecycleDerivationReportEntry } from '@gate-forge/core';
2
+ import type { CacheControl, CacheCounts } from './run-cache.js';
2
3
  import { type EndpointInventory } from './endpoint-compiler.js';
3
4
  /** Everything one pipeline run needs. */
4
5
  export interface PipelineOptions {
@@ -21,6 +22,11 @@ export interface PipelineOptions {
21
22
  * pipeline executes in has no diff basis of its own.
22
23
  */
23
24
  changedFilesOverride?: readonly string[];
25
+ /**
26
+ * Plugin result cache control. Absent or
27
+ * disabled = full scan (the historical behavior).
28
+ */
29
+ pluginCache?: CacheControl;
24
30
  }
25
31
  /** The complete pipeline result. */
26
32
  export interface PipelineResult {
@@ -40,6 +46,13 @@ export interface PipelineResult {
40
46
  changedFiles: string[];
41
47
  /** The raw classifier result (decisions with traces, stale/invalid signals). */
42
48
  classification: ClassificationResult;
49
+ /**
50
+ * The effective `http.endpoint.requireObservation` option from the
51
+ * pinned policies document (plan Phase 4c, E60): which endpoint
52
+ * resources owe the observation contracts. Navigation surfaces read
53
+ * it to explain an obligation the option itself created.
54
+ */
55
+ observationScope: 'consumed' | 'all';
43
56
  /**
44
57
  * The effective-classification view (plan phase 5): every resolved
45
58
  * resource's classification keyed by plane-qualified id. Derived
@@ -47,8 +60,36 @@ export interface PipelineResult {
47
60
  * never reads it back as input.
48
61
  */
49
62
  classificationsView: ClassificationFile;
63
+ /** Lifecycle omissions and observability limits derived from complete detector facts. */
64
+ lifecycleDerivation: LifecycleDerivationReportEntry[];
50
65
  /** Compiled complete-behavior catalog, or null when the document is absent. */
51
66
  behaviorCatalog: BehaviorCatalog | null;
67
+ /**
68
+ * Coarse per-step wall-clock timings (`check --timing`): plugin/detector
69
+ * duration and the whole-pipeline
70
+ * duration in milliseconds. Observability only — never an input.
71
+ */
72
+ timings: PipelineTimings;
73
+ /** Plugin cache accounting for this run (0/0 when disabled). */
74
+ cache: CacheCounts;
75
+ /** Engine-issued Alembic records. Empty when the pack is not enabled. */
76
+ engineAlembicRecords: readonly {
77
+ obligationId: string;
78
+ kind: string;
79
+ trust?: string;
80
+ origin?: string;
81
+ payload?: unknown;
82
+ recordId?: string;
83
+ }[];
84
+ /** Owner-visible Alembic notes, including pinned irreversible revisions. */
85
+ alembicNotices: readonly string[];
86
+ }
87
+ /** Coarse pipeline step durations in milliseconds (`check --timing`). */
88
+ export interface PipelineTimings {
89
+ /** Total `runPlugins` duration (all detectors, config order). */
90
+ pluginsMs: number;
91
+ /** Total `runPipeline` duration including the detector step. */
92
+ totalMs: number;
52
93
  }
53
94
  /** Source-file map resourceId → repo-relative source (for diff scoping). */
54
95
  export declare function sourceByResourceId(graph: ResourceGraph): Map<string, string>;
@@ -98,4 +139,14 @@ export declare function runPipeline(options: PipelineOptions): Promise<PipelineR
98
139
  * reads this back as input — recomputed from signals on every run.
99
140
  */
100
141
  export declare function effectiveClassifications(graph: ResourceGraph, classification: ClassificationResult): ClassificationFile;
142
+ /**
143
+ * Projects classified lifecycle derivations into the stable report shape.
144
+ *
145
+ * Args:
146
+ * classification: the classifier result with trace metadata.
147
+ *
148
+ * Returns:
149
+ * LifecycleDerivationReportEntry[]: sorted resource-level report entries.
150
+ */
151
+ export declare function lifecycleDerivationForReport(classification: ClassificationResult): LifecycleDerivationReportEntry[];
101
152
  //# sourceMappingURL=pipeline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAkBA,OAAO,EAiBH,KAAK,eAAe,EACtB,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EAEvB,KAAK,oBAAoB,EAEzB,KAAK,cAAc,EACnB,KAAK,eAAe,EAEpB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAI7F,yCAAyC;AACzC,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,sDAA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
  import { join } from 'node:path';
16
16
  import { spawnSync } from 'node:child_process';
17
17
  import { randomUUID } from 'node:crypto';
18
+ import { performance } from 'node:perf_hooks';
18
19
  import { parse as parseYaml } from 'yaml';
19
20
  import { ClaimSchema, ClassificationPolicySchema, ClassificationSignalSchema, PolicyFileSchema, PolicyEvaluationError, RunManifestSchema, buildResourceGraph, compareStrings, compileBehaviorPolicy, evaluatePolicies, jsonPathFor, loadWaivers, normalizeChangedFiles, parseBehaviorPolicy, runClassification, sortLifecycleRules, } from '@gate-forge/core';
21
+ import { compileAlembic } from '@gate-forge/pack-alembic';
22
+ import { staticAdapterFieldsFromSource } from '@gate-forge/pack-playwright';
20
23
  import { UsageError } from './errors.js';
21
24
  import { assertBundledDetectors, validateCoverageTrust } from './detector-trust.js';
22
25
  import { clockFromConfig } from './clock.js';
@@ -132,6 +135,74 @@ export function resolveRepoPath(cwd, repoRelative) {
132
135
  }
133
136
  return join(cwd, ...normalized.split('/'));
134
137
  }
138
+ /**
139
+ * Finds known model update fields omitted from statically declared adapter
140
+ * projections without importing or evaluating adapter modules.
141
+ *
142
+ * Args:
143
+ * cwd: repository root.
144
+ * adaptersDir: repo-relative adapter directory.
145
+ * adapterNames: discovered adapter module basenames.
146
+ * decisions: effective classifier decisions for this pipeline run.
147
+ *
148
+ * Returns:
149
+ * BlockingEntry[]: one visible blocker for each affected resource.
150
+ */
151
+ function adapterProjectionBlockers(cwd, adaptersDir, adapterNames, decisions) {
152
+ const fieldsByAdapter = new Map();
153
+ const absoluteDir = resolveRepoPath(cwd, adaptersDir);
154
+ for (const adapterName of adapterNames) {
155
+ let source;
156
+ try {
157
+ source = readFileSync(join(absoluteDir, `${adapterName}.mjs`), 'utf8');
158
+ }
159
+ catch {
160
+ continue;
161
+ }
162
+ const fields = staticAdapterFieldsFromSource(source);
163
+ if (fields !== null) {
164
+ fields.sort(compareStrings);
165
+ fieldsByAdapter.set(adapterName, fields);
166
+ }
167
+ }
168
+ const blockers = [];
169
+ for (const decision of decisions) {
170
+ const classified = decision.classification;
171
+ const adapterName = classified?.evidenceAdapter;
172
+ const projectedFields = adapterName === undefined ? undefined : fieldsByAdapter.get(adapterName);
173
+ const updateableFields = classified?.lifecycle.updateableFields;
174
+ if (adapterName === undefined ||
175
+ projectedFields === undefined ||
176
+ updateableFields === undefined) {
177
+ continue;
178
+ }
179
+ let missing = null;
180
+ for (const field of updateableFields) {
181
+ if (!projectedFields.includes(field)) {
182
+ if (missing === null)
183
+ missing = [];
184
+ missing.push(field);
185
+ }
186
+ }
187
+ if (missing === null)
188
+ continue;
189
+ missing.sort(compareStrings);
190
+ const missingFields = missing.length === 1 ? `field ${missing[0]}` : `fields [${missing.join(', ')}]`;
191
+ const verb = missing.length === 1 ? 'is' : 'are';
192
+ blockers.push({
193
+ kind: 'classification',
194
+ resourceId: decision.resourceId,
195
+ name: decision.name,
196
+ detail: `${missingFields} ${verb} not exposed by adapter '${adapterName}' ` +
197
+ `(fields: ${projectedFields.length === 0 ? '<none>' : projectedFields.join(', ')})`,
198
+ location: decision.location,
199
+ cause: null,
200
+ nextAction: "Add the missing fields to the adapter's 'fields' projection or remove them from the model's " +
201
+ 'updateable fields.',
202
+ });
203
+ }
204
+ return blockers.sort((left, right) => compareStrings(left.resourceId ?? '', right.resourceId ?? ''));
205
+ }
135
206
  /** First zod issue as one actionable `path: message` line. */
136
207
  function firstIssueText(error, fallback) {
137
208
  const issue = error.issues?.[0];
@@ -161,7 +232,10 @@ export async function runPipeline(options) {
161
232
  // requested and scanned sets.
162
233
  const expandErrors = [];
163
234
  const paths = expandIncludePaths(config.project.paths.include, config.project.paths.exclude, cwd, expandErrors);
164
- const { contributions, registrations } = await runPlugins(config.plugins, paths, cwd);
235
+ const pipelineStartedAtMs = performance.now();
236
+ const pluginsStartedAtMs = performance.now();
237
+ const { contributions, registrations, cache: pluginCacheCounts } = await runPlugins(config.plugins, paths, cwd, options.pluginCache);
238
+ const pluginsMs = performance.now() - pluginsStartedAtMs;
165
239
  const policyDocRaw = loadYaml(resolveRepoPath(cwd, config.classificationPolicy), 'classification-policy');
166
240
  const policyDocParsed = ClassificationPolicySchema.safeParse(policyDocRaw);
167
241
  if (!policyDocParsed.success) {
@@ -244,6 +318,7 @@ export async function runPipeline(options) {
244
318
  authority,
245
319
  policy: policyDocParsed.data,
246
320
  adapters,
321
+ deriveLifecycleDefaults: true,
247
322
  scan: {
248
323
  // The proof request must describe the same repository scope that
249
324
  // detector discovery scans. Project exclusions remove files from the
@@ -260,7 +335,10 @@ export async function runPipeline(options) {
260
335
  graph,
261
336
  policies: policiesParsed.data,
262
337
  claims,
263
- extraBlocking: blocking,
338
+ extraBlocking: [
339
+ ...blocking,
340
+ ...adapterProjectionBlockers(cwd, config.adapters, adapters, classification.decisions),
341
+ ],
264
342
  });
265
343
  let behaviorCatalog = null;
266
344
  if (config.behaviorPolicy !== undefined) {
@@ -299,9 +377,36 @@ export async function runPipeline(options) {
299
377
  const changedFiles = options.changedFilesOverride !== undefined
300
378
  ? normalizeChangedFiles([...options.changedFilesOverride])
301
379
  : providerFor(provider, cwd, env).changedFiles();
380
+ const runId = options.runId ?? randomUUID();
381
+ let engineAlembicRecords = [];
382
+ let alembicNotices = [];
383
+ if (config.alembic !== undefined) {
384
+ const compiled = await compileAlembic({
385
+ cwd,
386
+ alembic: config.alembic,
387
+ changedFiles,
388
+ now,
389
+ runId,
390
+ });
391
+ const obligationIds = new Set(policy.obligations.map((item) => item.id));
392
+ const mergedObligations = [...policy.obligations];
393
+ for (const item of compiled.obligations) {
394
+ if (obligationIds.has(item.id))
395
+ continue;
396
+ obligationIds.add(item.id);
397
+ mergedObligations.push(item);
398
+ }
399
+ policy = {
400
+ ...policy,
401
+ obligations: mergedObligations.sort((a, b) => compareStrings(a.id, b.id)),
402
+ blocking: [...policy.blocking, ...compiled.blocking].sort((a, b) => compareStrings(a.kind, b.kind) || compareStrings(a.resourceId ?? '', b.resourceId ?? '')),
403
+ };
404
+ engineAlembicRecords = compiled.records;
405
+ alembicNotices = compiled.notices;
406
+ }
302
407
  const manifest = RunManifestSchema.parse({
303
408
  schemaVersion: 1,
304
- runId: options.runId ?? randomUUID(),
409
+ runId,
305
410
  startedAt: now,
306
411
  gitSha: headSha(cwd),
307
412
  provider,
@@ -313,12 +418,18 @@ export async function runPipeline(options) {
313
418
  endpointInventory,
314
419
  graph,
315
420
  policy,
421
+ observationScope: policiesParsed.data.options?.['http.endpoint.requireObservation'] ?? 'consumed',
316
422
  manifest,
317
423
  now,
318
424
  changedFiles,
319
425
  classification,
320
426
  classificationsView: effectiveClassifications(graph, classification),
427
+ lifecycleDerivation: lifecycleDerivationForReport(classification),
321
428
  behaviorCatalog,
429
+ timings: { pluginsMs, totalMs: performance.now() - pipelineStartedAtMs },
430
+ cache: pluginCacheCounts,
431
+ engineAlembicRecords,
432
+ alembicNotices,
322
433
  };
323
434
  }
324
435
  /**
@@ -356,6 +467,33 @@ export function effectiveClassifications(graph, classification) {
356
467
  }
357
468
  return { schemaVersion: 1, resources };
358
469
  }
470
+ /**
471
+ * Projects classified lifecycle derivations into the stable report shape.
472
+ *
473
+ * Args:
474
+ * classification: the classifier result with trace metadata.
475
+ *
476
+ * Returns:
477
+ * LifecycleDerivationReportEntry[]: sorted resource-level report entries.
478
+ */
479
+ export function lifecycleDerivationForReport(classification) {
480
+ const entries = [];
481
+ for (const decision of classification.decisions) {
482
+ const derivations = decision.classification?.lifecycleDerivation ?? [];
483
+ if (derivations.length === 0)
484
+ continue;
485
+ const resourceId = decision.classification === null
486
+ ? decision.resourceId
487
+ : `${decision.classification.plane}.${decision.name}`;
488
+ for (const derivation of derivations) {
489
+ entries.push({ ...derivation, resourceId, resourceName: decision.name });
490
+ }
491
+ }
492
+ const operationOrder = { read: 0, update: 1, delete: 2 };
493
+ return entries.sort((left, right) => compareStrings(left.resourceId ?? left.resourceName, right.resourceId ?? right.resourceName) ||
494
+ compareStrings(left.resourceName, right.resourceName) ||
495
+ operationOrder[left.operation] - operationOrder[right.operation]);
496
+ }
359
497
  /**
360
498
  * Host-issued authority minting (red-team V1/V2 remediation, ADR 0003 D2):
361
499
  * translates configured source-declaration markers into ENGINE-minted