@davesheffer/hunch 1.31.1 → 1.32.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 (220) hide show
  1. package/README.md +1 -0
  2. package/dist/cli/automaticReviewMemory.d.ts +13 -0
  3. package/dist/cli/dna.d.ts +2 -0
  4. package/dist/cli/index.d.ts +16 -0
  5. package/dist/cli/index.js +602 -43
  6. package/dist/cli/integrations.d.ts +2 -0
  7. package/dist/cli/integrations.js +5 -2
  8. package/dist/cli/invocation.d.ts +35 -0
  9. package/dist/cli/preflight.d.ts +1 -0
  10. package/dist/cli/reviewMemory.d.ts +4 -0
  11. package/dist/cli/reviewMemoryProvider.d.ts +14 -0
  12. package/dist/cli/serve.d.ts +2 -0
  13. package/dist/cli/taskReport.d.ts +6 -0
  14. package/dist/cli/taskReport.js +124 -0
  15. package/dist/cli/update.d.ts +14 -0
  16. package/dist/client/state.d.ts +248 -0
  17. package/dist/constitution/adapters.d.ts +29 -0
  18. package/dist/constitution/behaviorAttestationBinding.d.ts +3 -0
  19. package/dist/constitution/behaviorEvaluator.d.ts +8 -0
  20. package/dist/constitution/behaviorProof.d.ts +9 -0
  21. package/dist/constitution/behaviorWorkspace.d.ts +25 -0
  22. package/dist/constitution/bootstrap.d.ts +30 -0
  23. package/dist/constitution/canonical.d.ts +15 -0
  24. package/dist/constitution/card.d.ts +58 -0
  25. package/dist/constitution/compiler.d.ts +52 -0
  26. package/dist/constitution/composition.d.ts +10 -0
  27. package/dist/constitution/corpus.d.ts +7 -0
  28. package/dist/constitution/correctionPolicyMaterializer.d.ts +57 -0
  29. package/dist/constitution/delta.d.ts +4 -0
  30. package/dist/constitution/disposition.d.ts +20 -0
  31. package/dist/constitution/evaluator.d.ts +47 -0
  32. package/dist/constitution/experiment.d.ts +466 -0
  33. package/dist/constitution/experimentRunner.d.ts +7 -0
  34. package/dist/constitution/g2.d.ts +209 -0
  35. package/dist/constitution/g2BehaviorAttestation.d.ts +45 -0
  36. package/dist/constitution/g2BehaviorCandidates.d.ts +123 -0
  37. package/dist/constitution/g2BehaviorDependencies.d.ts +83 -0
  38. package/dist/constitution/g2BehaviorMaterialization.d.ts +77 -0
  39. package/dist/constitution/g2BehaviorPolicyMaterializer.d.ts +48 -0
  40. package/dist/constitution/g2CandidateAttestation.d.ts +43 -0
  41. package/dist/constitution/g2Candidates.d.ts +80 -0
  42. package/dist/constitution/g2Drills.d.ts +33 -0
  43. package/dist/constitution/g3.d.ts +311 -0
  44. package/dist/constitution/g3Conformance.d.ts +33 -0
  45. package/dist/constitution/lifecycle.d.ts +25 -0
  46. package/dist/constitution/mutation.d.ts +15 -0
  47. package/dist/constitution/nodeTestEvidence.d.ts +13 -0
  48. package/dist/constitution/plan.d.ts +18 -0
  49. package/dist/constitution/policyRuntime.d.ts +5 -0
  50. package/dist/constitution/proof.d.ts +11 -0
  51. package/dist/constitution/repairPolicies.d.ts +34 -0
  52. package/dist/constitution/replacementFreeGit.d.ts +14 -0
  53. package/dist/constitution/replay.d.ts +40 -0
  54. package/dist/constitution/replayCache.d.ts +14 -0
  55. package/dist/constitution/replayWorker.d.ts +1 -0
  56. package/dist/constitution/repository.d.ts +129 -0
  57. package/dist/constitution/safeCheckout.d.ts +9 -0
  58. package/dist/constitution/schema.d.ts +1763 -0
  59. package/dist/constitution/scorecard.d.ts +219 -0
  60. package/dist/constitution/service.d.ts +398 -0
  61. package/dist/constitution/shadow.d.ts +54 -0
  62. package/dist/constitution/sourceMutation.d.ts +15 -0
  63. package/dist/constitution/staticGraphBaseline.d.ts +13 -0
  64. package/dist/constitution/structural.d.ts +64 -0
  65. package/dist/core/agenthook.d.ts +63 -0
  66. package/dist/core/agenthook.js +1 -0
  67. package/dist/core/automaticReviewMemory.d.ts +60 -0
  68. package/dist/core/autoreview.d.ts +66 -0
  69. package/dist/core/canonicalOrder.d.ts +3 -0
  70. package/dist/core/capturetoken.d.ts +19 -0
  71. package/dist/core/changeIdentity.d.ts +22 -0
  72. package/dist/core/changeProof.d.ts +14 -0
  73. package/dist/core/checkreport.d.ts +140 -0
  74. package/dist/core/commitrepair.d.ts +171 -0
  75. package/dist/core/commitrepair.js +238 -0
  76. package/dist/core/compare.d.ts +21 -0
  77. package/dist/core/config.d.ts +20 -0
  78. package/dist/core/conformance.d.ts +35 -0
  79. package/dist/core/constraintmatch.d.ts +54 -0
  80. package/dist/core/correction.d.ts +42 -0
  81. package/dist/core/correctionStage.d.ts +224 -0
  82. package/dist/core/declarationClusters.d.ts +149 -0
  83. package/dist/core/delivery.d.ts +110 -0
  84. package/dist/core/docanchors.d.ts +32 -0
  85. package/dist/core/docscan.d.ts +26 -0
  86. package/dist/core/drift.d.ts +13 -0
  87. package/dist/core/drift.js +31 -1
  88. package/dist/core/dupdetect.d.ts +43 -0
  89. package/dist/core/escalations.d.ts +129 -0
  90. package/dist/core/escalations.js +165 -0
  91. package/dist/core/events.d.ts +29 -0
  92. package/dist/core/evidenceMap.d.ts +164 -0
  93. package/dist/core/externalImports.d.ts +8 -0
  94. package/dist/core/format.d.ts +13 -0
  95. package/dist/core/glob.d.ts +9 -0
  96. package/dist/core/groundingLag.d.ts +84 -0
  97. package/dist/core/groundingLag.js +16 -2
  98. package/dist/core/groundingMerge.d.ts +15 -0
  99. package/dist/core/groundingMerge.js +95 -0
  100. package/dist/core/hookcache.d.ts +10 -0
  101. package/dist/core/hookpolicy.d.ts +47 -0
  102. package/dist/core/ids.d.ts +36 -0
  103. package/dist/core/importReview.d.ts +30 -0
  104. package/dist/core/io.d.ts +23 -0
  105. package/dist/core/jsonc.d.ts +4 -0
  106. package/dist/core/landscapeAdoption.d.ts +66 -0
  107. package/dist/core/landscapeDelivery.d.ts +76 -0
  108. package/dist/core/memorylog.d.ts +37 -0
  109. package/dist/core/migrate.d.ts +28 -0
  110. package/dist/core/outcomeExperience.d.ts +89 -0
  111. package/dist/core/overlaySafety.d.ts +24 -0
  112. package/dist/core/overlaySafety.js +7 -1
  113. package/dist/core/paths.d.ts +31 -0
  114. package/dist/core/pipeline.d.ts +289 -0
  115. package/dist/core/premises.d.ts +43 -0
  116. package/dist/core/provenance.d.ts +21 -0
  117. package/dist/core/publication.d.ts +54 -0
  118. package/dist/core/refrepair.d.ts +24 -0
  119. package/dist/core/refrepair.js +1 -1
  120. package/dist/core/relativeImports.d.ts +11 -0
  121. package/dist/core/repair.d.ts +44 -0
  122. package/dist/core/repairqueue.d.ts +40 -0
  123. package/dist/core/repairqueue.js +133 -0
  124. package/dist/core/reviewMemory.d.ts +40 -0
  125. package/dist/core/reviewqueue.d.ts +54 -0
  126. package/dist/core/safeRepoFile.d.ts +20 -0
  127. package/dist/core/served.d.ts +57 -0
  128. package/dist/core/served.js +14 -0
  129. package/dist/core/stateContract.d.ts +979 -0
  130. package/dist/core/stateDelivery.d.ts +78 -0
  131. package/dist/core/stateRecords.d.ts +383 -0
  132. package/dist/core/stats.d.ts +88 -0
  133. package/dist/core/strictgate.d.ts +33 -0
  134. package/dist/core/taskReport.d.ts +226 -0
  135. package/dist/core/taskReport.js +514 -0
  136. package/dist/core/taskReportCapture.d.ts +8 -0
  137. package/dist/core/taskReportCapture.js +36 -0
  138. package/dist/core/taskReportEvidence.d.ts +26 -0
  139. package/dist/core/taskReportEvidence.js +268 -0
  140. package/dist/core/taskReportHook.d.ts +20 -0
  141. package/dist/core/taskReportHook.js +76 -0
  142. package/dist/core/taskReportPaths.d.ts +3 -0
  143. package/dist/core/taskReportPaths.js +23 -0
  144. package/dist/core/taskReportPublic.d.ts +31 -0
  145. package/dist/core/taskReportPublic.js +45 -0
  146. package/dist/core/taskReportRender.d.ts +6 -0
  147. package/dist/core/taskReportRender.js +97 -0
  148. package/dist/core/topics.d.ts +73 -0
  149. package/dist/core/types.d.ts +1239 -0
  150. package/dist/core/version.d.ts +10 -0
  151. package/dist/eval/guards.d.ts +45 -0
  152. package/dist/eval/harness.d.ts +58 -0
  153. package/dist/extractors/adrImport.d.ts +59 -0
  154. package/dist/extractors/comments.d.ts +7 -0
  155. package/dist/extractors/correctionSources.d.ts +11 -0
  156. package/dist/extractors/diff.d.ts +40 -0
  157. package/dist/extractors/git.d.ts +304 -0
  158. package/dist/extractors/git.js +208 -20
  159. package/dist/extractors/helm.d.ts +31 -0
  160. package/dist/extractors/indexer.d.ts +55 -0
  161. package/dist/extractors/landscapeDiscovery.d.ts +41 -0
  162. package/dist/extractors/languages.d.ts +77 -0
  163. package/dist/extractors/nativeTreeSitter.d.ts +16 -0
  164. package/dist/extractors/parse.d.ts +54 -0
  165. package/dist/extractors/php.d.ts +26 -0
  166. package/dist/extractors/repoSource.d.ts +53 -0
  167. package/dist/extractors/testreport.d.ts +36 -0
  168. package/dist/integrations/ciAction.d.ts +8 -0
  169. package/dist/integrations/claudeConfig.d.ts +44 -0
  170. package/dist/integrations/claudemd.d.ts +13 -0
  171. package/dist/integrations/claudemd.js +11 -2
  172. package/dist/integrations/gitignore.d.ts +16 -0
  173. package/dist/integrations/gitignore.js +7 -0
  174. package/dist/integrations/health.d.ts +74 -0
  175. package/dist/integrations/hooks.d.ts +41 -0
  176. package/dist/integrations/hooks.js +92 -66
  177. package/dist/integrations/madrExport.d.ts +39 -0
  178. package/dist/integrations/madrManifest.d.ts +69 -0
  179. package/dist/integrations/mergeDriver.d.ts +3 -0
  180. package/dist/integrations/mergeDriver.js +25 -8
  181. package/dist/integrations/probe.d.ts +4 -0
  182. package/dist/integrations/providers.d.ts +103 -0
  183. package/dist/integrations/scaffold.d.ts +29 -0
  184. package/dist/integrations/sync.d.ts +30 -0
  185. package/dist/integrations/sync.js +3 -2
  186. package/dist/integrations/team.d.ts +70 -0
  187. package/dist/integrations/worktree.d.ts +8 -0
  188. package/dist/mcp/roots.d.ts +16 -0
  189. package/dist/mcp/server.d.ts +36 -0
  190. package/dist/mcp/server.js +74 -22
  191. package/dist/mcp/taskReportTools.d.ts +3 -0
  192. package/dist/mcp/taskReportTools.js +106 -0
  193. package/dist/serve/app.d.ts +36 -0
  194. package/dist/serve/config.d.ts +100 -0
  195. package/dist/serve/writelock.d.ts +22 -0
  196. package/dist/store/changeLedger.d.ts +132 -0
  197. package/dist/store/compact.d.ts +33 -0
  198. package/dist/store/db.d.ts +9 -0
  199. package/dist/store/embedder.d.ts +32 -0
  200. package/dist/store/hunchStore.d.ts +624 -0
  201. package/dist/store/hunchStore.js +6 -3
  202. package/dist/store/jsonStore.d.ts +125 -0
  203. package/dist/store/merge.d.ts +39 -0
  204. package/dist/store/privateMigrate.d.ts +24 -0
  205. package/dist/store/replay.d.ts +56 -0
  206. package/dist/store/schema.d.ts +17 -0
  207. package/dist/store/stateBinding.d.ts +145 -0
  208. package/dist/store/stateCapture.d.ts +15 -0
  209. package/dist/synthesis/cliAdapter.d.ts +22 -0
  210. package/dist/synthesis/initiator.d.ts +13 -0
  211. package/dist/synthesis/provider.d.ts +307 -0
  212. package/dist/synthesis/synthesize.d.ts +117 -0
  213. package/dist/synthesis/tripwires.d.ts +9 -0
  214. package/dist/taskReports.d.ts +76 -0
  215. package/dist/taskReports.js +67 -0
  216. package/dist/wiki/adopt.d.ts +22 -0
  217. package/dist/wiki/graph.d.ts +87 -0
  218. package/dist/wiki/wiki.d.ts +242 -0
  219. package/package.json +6 -5
  220. package/server.json +2 -2
@@ -0,0 +1,219 @@
1
+ import { z } from "zod";
2
+ export declare const CompilerCaseBankSchema: z.ZodObject<{
3
+ version: z.ZodLiteral<1>;
4
+ experiment: z.ZodLiteral<"EXP-03">;
5
+ threshold: z.ZodDefault<z.ZodNumber>;
6
+ preregistered_metric: z.ZodLiteral<"intended supported assertion or honest non-minting classification">;
7
+ cases: z.ZodArray<z.ZodObject<{
8
+ id: z.ZodString;
9
+ family: z.ZodString;
10
+ evidence: z.ZodString;
11
+ expected: z.ZodObject<{
12
+ outcome: z.ZodEnum<{
13
+ conflicted: "conflicted";
14
+ covered: "covered";
15
+ uncompilable: "uncompilable";
16
+ assertion: "assertion";
17
+ }>;
18
+ assertion: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
19
+ kind: z.ZodLiteral<"exists">;
20
+ subject: z.ZodObject<{
21
+ selector: z.ZodString;
22
+ }, z.core.$strip>;
23
+ }, z.core.$strip>, z.ZodObject<{
24
+ kind: z.ZodEnum<{
25
+ reaches: "reaches";
26
+ "not-reaches": "not-reaches";
27
+ }>;
28
+ subject: z.ZodObject<{
29
+ selector: z.ZodString;
30
+ }, z.core.$strip>;
31
+ relation: z.ZodObject<{
32
+ edges: z.ZodDefault<z.ZodArray<z.ZodEnum<{
33
+ depends_on: "depends_on";
34
+ calls: "calls";
35
+ imports: "imports";
36
+ contains: "contains";
37
+ }>>>;
38
+ transitive: z.ZodDefault<z.ZodBoolean>;
39
+ max_depth: z.ZodDefault<z.ZodNumber>;
40
+ }, z.core.$strip>;
41
+ object: z.ZodObject<{
42
+ selector: z.ZodString;
43
+ }, z.core.$strip>;
44
+ }, z.core.$strip>, z.ZodObject<{
45
+ kind: z.ZodLiteral<"must-pass-through">;
46
+ subject: z.ZodObject<{
47
+ selector: z.ZodString;
48
+ }, z.core.$strip>;
49
+ relation: z.ZodObject<{
50
+ edges: z.ZodDefault<z.ZodArray<z.ZodEnum<{
51
+ depends_on: "depends_on";
52
+ calls: "calls";
53
+ imports: "imports";
54
+ contains: "contains";
55
+ }>>>;
56
+ transitive: z.ZodDefault<z.ZodBoolean>;
57
+ max_depth: z.ZodDefault<z.ZodNumber>;
58
+ }, z.core.$strip>;
59
+ via: z.ZodObject<{
60
+ selector: z.ZodString;
61
+ }, z.core.$strip>;
62
+ object: z.ZodObject<{
63
+ selector: z.ZodString;
64
+ }, z.core.$strip>;
65
+ }, z.core.$strip>, z.ZodObject<{
66
+ kind: z.ZodLiteral<"executable-behavior">;
67
+ test: z.ZodObject<{
68
+ file: z.ZodString;
69
+ name: z.ZodString;
70
+ source_commit: z.ZodString;
71
+ source_hash: z.ZodString;
72
+ }, z.core.$strict>;
73
+ runner: z.ZodEnum<{
74
+ "node-test": "node-test";
75
+ "node-test-tsx": "node-test-tsx";
76
+ }>;
77
+ attestation: z.ZodObject<{
78
+ id: z.ZodString;
79
+ content_hash: z.ZodString;
80
+ candidate_id: z.ZodString;
81
+ candidate_hash: z.ZodString;
82
+ replay_id: z.ZodString;
83
+ replay_hash: z.ZodString;
84
+ }, z.core.$strict>;
85
+ dependency_snapshot_ids: z.ZodArray<z.ZodString>;
86
+ timeout_ms: z.ZodNumber;
87
+ }, z.core.$strict>], "kind">>;
88
+ scope: z.ZodOptional<z.ZodObject<{
89
+ repos: z.ZodDefault<z.ZodArray<z.ZodString>>;
90
+ paths: z.ZodDefault<z.ZodArray<z.ZodString>>;
91
+ components: z.ZodDefault<z.ZodArray<z.ZodString>>;
92
+ }, z.core.$strict>>;
93
+ uncertainty: z.ZodDefault<z.ZodArray<z.ZodString>>;
94
+ conflicts: z.ZodDefault<z.ZodArray<z.ZodString>>;
95
+ incumbent: z.ZodDefault<z.ZodNullable<z.ZodString>>;
96
+ reason: z.ZodDefault<z.ZodString>;
97
+ }, z.core.$strict>;
98
+ actual: z.ZodObject<{
99
+ outcome: z.ZodEnum<{
100
+ conflicted: "conflicted";
101
+ covered: "covered";
102
+ uncompilable: "uncompilable";
103
+ assertion: "assertion";
104
+ }>;
105
+ assertion: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
106
+ kind: z.ZodLiteral<"exists">;
107
+ subject: z.ZodObject<{
108
+ selector: z.ZodString;
109
+ }, z.core.$strip>;
110
+ }, z.core.$strip>, z.ZodObject<{
111
+ kind: z.ZodEnum<{
112
+ reaches: "reaches";
113
+ "not-reaches": "not-reaches";
114
+ }>;
115
+ subject: z.ZodObject<{
116
+ selector: z.ZodString;
117
+ }, z.core.$strip>;
118
+ relation: z.ZodObject<{
119
+ edges: z.ZodDefault<z.ZodArray<z.ZodEnum<{
120
+ depends_on: "depends_on";
121
+ calls: "calls";
122
+ imports: "imports";
123
+ contains: "contains";
124
+ }>>>;
125
+ transitive: z.ZodDefault<z.ZodBoolean>;
126
+ max_depth: z.ZodDefault<z.ZodNumber>;
127
+ }, z.core.$strip>;
128
+ object: z.ZodObject<{
129
+ selector: z.ZodString;
130
+ }, z.core.$strip>;
131
+ }, z.core.$strip>, z.ZodObject<{
132
+ kind: z.ZodLiteral<"must-pass-through">;
133
+ subject: z.ZodObject<{
134
+ selector: z.ZodString;
135
+ }, z.core.$strip>;
136
+ relation: z.ZodObject<{
137
+ edges: z.ZodDefault<z.ZodArray<z.ZodEnum<{
138
+ depends_on: "depends_on";
139
+ calls: "calls";
140
+ imports: "imports";
141
+ contains: "contains";
142
+ }>>>;
143
+ transitive: z.ZodDefault<z.ZodBoolean>;
144
+ max_depth: z.ZodDefault<z.ZodNumber>;
145
+ }, z.core.$strip>;
146
+ via: z.ZodObject<{
147
+ selector: z.ZodString;
148
+ }, z.core.$strip>;
149
+ object: z.ZodObject<{
150
+ selector: z.ZodString;
151
+ }, z.core.$strip>;
152
+ }, z.core.$strip>, z.ZodObject<{
153
+ kind: z.ZodLiteral<"executable-behavior">;
154
+ test: z.ZodObject<{
155
+ file: z.ZodString;
156
+ name: z.ZodString;
157
+ source_commit: z.ZodString;
158
+ source_hash: z.ZodString;
159
+ }, z.core.$strict>;
160
+ runner: z.ZodEnum<{
161
+ "node-test": "node-test";
162
+ "node-test-tsx": "node-test-tsx";
163
+ }>;
164
+ attestation: z.ZodObject<{
165
+ id: z.ZodString;
166
+ content_hash: z.ZodString;
167
+ candidate_id: z.ZodString;
168
+ candidate_hash: z.ZodString;
169
+ replay_id: z.ZodString;
170
+ replay_hash: z.ZodString;
171
+ }, z.core.$strict>;
172
+ dependency_snapshot_ids: z.ZodArray<z.ZodString>;
173
+ timeout_ms: z.ZodNumber;
174
+ }, z.core.$strict>], "kind">>;
175
+ scope: z.ZodOptional<z.ZodObject<{
176
+ repos: z.ZodDefault<z.ZodArray<z.ZodString>>;
177
+ paths: z.ZodDefault<z.ZodArray<z.ZodString>>;
178
+ components: z.ZodDefault<z.ZodArray<z.ZodString>>;
179
+ }, z.core.$strict>>;
180
+ uncertainty: z.ZodDefault<z.ZodArray<z.ZodString>>;
181
+ conflicts: z.ZodDefault<z.ZodArray<z.ZodString>>;
182
+ incumbent: z.ZodDefault<z.ZodNullable<z.ZodString>>;
183
+ reason: z.ZodDefault<z.ZodString>;
184
+ }, z.core.$strict>;
185
+ }, z.core.$strict>>;
186
+ }, z.core.$strict>;
187
+ export type CompilerCaseBank = z.infer<typeof CompilerCaseBankSchema>;
188
+ export interface CompilerScorecard {
189
+ experiment: "EXP-03";
190
+ denominator: number;
191
+ numerator: number;
192
+ incorrect: number;
193
+ silent_semantic_substitutions: number;
194
+ rate: number;
195
+ threshold: number;
196
+ risk_difference_vs_threshold: number;
197
+ wilson_95: {
198
+ low: number;
199
+ high: number;
200
+ };
201
+ passed: boolean;
202
+ by_outcome: Record<"assertion" | "uncompilable" | "conflicted" | "covered", {
203
+ total: number;
204
+ correct: number;
205
+ }>;
206
+ cases: Array<{
207
+ id: string;
208
+ family: string;
209
+ correct: boolean;
210
+ silent_substitution: boolean;
211
+ reason: string;
212
+ }>;
213
+ deterministic_hash: string;
214
+ }
215
+ /** Score only exact semantic outcomes. Wording/reason text is diagnostic and
216
+ * never rescues a wrong assertion. An expected refusal that becomes any
217
+ * assertion is counted separately as a silent semantic substitution. */
218
+ export declare function scoreCompilerCaseBank(raw: unknown): CompilerScorecard;
219
+ export declare function renderCompilerScorecard(card: CompilerScorecard): string;
@@ -0,0 +1,398 @@
1
+ import type { HunchStore } from "../store/hunchStore.js";
2
+ import { type CompilePolicyOptions } from "./compiler.js";
3
+ import { type GraphSnapshot } from "./evaluator.js";
4
+ import { PolicyRepository } from "./repository.js";
5
+ import type { PolicyEvaluation, PolicyProof, PolicySpec, ProofCorpus } from "./schema.js";
6
+ import type { ProofPlan } from "./schema.js";
7
+ import { type BootstrapOptions, type BootstrapReport } from "./bootstrap.js";
8
+ import { type StructuralInspection } from "./structural.js";
9
+ import { type ProofPlanOptions } from "./plan.js";
10
+ import { type LocalEvidenceOptions, type LocalEvidenceReport } from "./adapters.js";
11
+ import { type ProofCard } from "./card.js";
12
+ import { type ShadowPrecisionReport, type ShadowPrecisionThresholds } from "./shadow.js";
13
+ import type { HistoryDisposition, HistoryDispositionClassification, ShadowDisposition, ShadowEvaluationRecord } from "./schema.js";
14
+ import { G2_RUNBOOK_CATEGORIES, G2EvidenceRepository, type CompileG2PlanInput, type G2ReadinessReport, type G2ShadowQueue, type G2ShadowBackfillReport, type G2ShadowSweepReport, type RunbookRehearsal } from "./g2.js";
15
+ import { type G2CandidateReviewOptions, type G2CandidateReviewReport } from "./g2Candidates.js";
16
+ import { G2CandidateAttestationRepository, type G2CandidateAttestation } from "./g2CandidateAttestation.js";
17
+ import { type G2BehaviorCandidateReviewOptions, type G2BehaviorCandidateReview, type G2BehaviorReplayReceipt } from "./g2BehaviorCandidates.js";
18
+ import { type G2BehaviorDependencySnapshotReceipt } from "./g2BehaviorDependencies.js";
19
+ import { G2BehaviorAttestationRepository, type G2BehaviorAttestation } from "./g2BehaviorAttestation.js";
20
+ import { type G2BehaviorMaterializationAssessment } from "./g2BehaviorMaterialization.js";
21
+ import { type G2BehaviorPolicyMaterialization } from "./g2BehaviorPolicyMaterializer.js";
22
+ import { type BehaviorEvaluationOptions } from "./behaviorEvaluator.js";
23
+ import { type G2OperationalDrillReceipt } from "./g2Drills.js";
24
+ import { G3EvidenceRepository, type CompileExperimentPreregistrationInput, type CompileG3PlanInput, type G3ReadinessReport, type ProofReviewMeasurement, type ExperimentPreregistration, type AdapterConformanceReceipt } from "./g3.js";
25
+ import { ExperimentRepository, experimentReviewGuide, type CompileExperimentCaseBankInput, type Exp03ReviewResponse, type CompileExperimentRunInput, type ExperimentCaseBank, type ExperimentFollowup, type ExperimentOutcome, type ExperimentReport, type ExperimentReviewStart, type CompileExperimentReviewerQualificationInput, type ExperimentReviewerQualification, type ExperimentRun, type ExperimentStop } from "./experiment.js";
26
+ import { type CorrectionPolicySweep, type CorrectionPolicyUpgrade, type CorrectionUpgradeOptions } from "./correctionPolicyMaterializer.js";
27
+ export interface PolicyEvaluationSet {
28
+ policy: PolicySpec;
29
+ evaluation: PolicyEvaluation;
30
+ blocks: boolean;
31
+ strict_error: boolean;
32
+ gate_error?: string;
33
+ }
34
+ /** Client-neutral evaluator receipt plus the fail-closed enforcement decision.
35
+ * The canonical evaluation hash remains untouched; adapters expose the wrapper
36
+ * so a persisted active-state configuration error can never disappear behind a
37
+ * valid-looking satisfied/violated receipt. */
38
+ export type PolicyEvaluationEnvelope = PolicyEvaluation & {
39
+ enforcement: {
40
+ blocks: boolean;
41
+ strict_error: boolean;
42
+ gate_error: string | null;
43
+ };
44
+ };
45
+ export declare function policyEvaluationEnvelope(result: PolicyEvaluationSet): PolicyEvaluationEnvelope;
46
+ export interface PolicyRelationSummary {
47
+ id: string;
48
+ statement: string;
49
+ state: PolicySpec["state"];
50
+ severity: PolicySpec["severity"];
51
+ data_class: PolicySpec["data_class"];
52
+ scope: PolicySpec["scope"];
53
+ exception_of: string | null;
54
+ }
55
+ export interface PolicyExceptionRelations {
56
+ policy: PolicyRelationSummary;
57
+ exception_parent: PolicyRelationSummary | null;
58
+ missing_exception_parent: string | null;
59
+ exceptions: PolicyRelationSummary[];
60
+ }
61
+ export interface PolicyConsolidationCandidate {
62
+ anchor: PolicyRelationSummary;
63
+ suggested_scope: PolicySpec["scope"] | null;
64
+ status: "unavailable" | "reviewable" | "challenged";
65
+ members: PolicyRelationSummary[];
66
+ independent_decisions: string[];
67
+ counterexamples: string[];
68
+ conflicts: string[];
69
+ exception_linked_members: string[];
70
+ reasons: string[];
71
+ }
72
+ export interface PolicyHistoryDispositionView {
73
+ policy_id: string;
74
+ proof_id: string;
75
+ violations: Array<{
76
+ commit: string;
77
+ receipt_hash: string;
78
+ disposition: HistoryDisposition | null;
79
+ }>;
80
+ current: HistoryDisposition[];
81
+ audit: HistoryDisposition[];
82
+ }
83
+ export interface PolicyShadowView extends ShadowPrecisionReport {
84
+ evaluations: Array<{
85
+ record: ShadowEvaluationRecord;
86
+ disposition: ShadowDisposition | null;
87
+ }>;
88
+ disposition_audit: ShadowDisposition[];
89
+ }
90
+ export declare function shadowCommitEligible(root: string, policy: PolicySpec, commit: string): boolean;
91
+ /** The commit a shadow receipt's ancestry check must be anchored to.
92
+ *
93
+ * A WORKSPACE receipt retains a content-addressed PSEUDO-head for dedupe — it is not a
94
+ * real git rev. Handing it to `git merge-base --is-ancestor` makes git exit with
95
+ * neither 0 nor 1, which shadowCommitEligible turns into a THROW, so the surface
96
+ * hard-fails instead of reporting. Ancestry is always the real base commit.
97
+ *
98
+ * Shared because that rule was previously written out at one call site (with this
99
+ * explanation attached) and silently omitted at another — the same one-side-only drift
100
+ * as OVERLAY_IGNORE. One definition, both callers. */
101
+ export declare function shadowAncestryCommit(record: ShadowEvaluationRecord): string;
102
+ export declare class ConstitutionService {
103
+ private readonly store;
104
+ private readonly root;
105
+ readonly repository: PolicyRepository;
106
+ readonly g2Repository: G2EvidenceRepository;
107
+ readonly g3Repository: G3EvidenceRepository;
108
+ readonly experimentRepository: ExperimentRepository;
109
+ readonly g2CandidateRepository: G2CandidateAttestationRepository;
110
+ readonly g2BehaviorAttestationRepository: G2BehaviorAttestationRepository;
111
+ constructor(store: HunchStore, root: string);
112
+ createG2Plan(input: CompileG2PlanInput, opts?: {
113
+ now?: string;
114
+ }): {
115
+ id: string;
116
+ content_hash: string;
117
+ gate: "G2";
118
+ policy_ids: string[];
119
+ runbooks: {
120
+ evaluator_error: string;
121
+ false_positive: string;
122
+ private_leak: string;
123
+ stale_policy: string;
124
+ provider_outage: string;
125
+ corrupt_graph: string;
126
+ adapter_break: string;
127
+ };
128
+ min_shadow_applicable: number;
129
+ actor: string;
130
+ reason: string;
131
+ supersedes: string | null;
132
+ data_class: "private";
133
+ authority: "none";
134
+ created_at: string;
135
+ };
136
+ recordRunbookRehearsal(runbookId: string, result: "passed" | "failed", actor: string, evidenceHashes: string[], notes: string, opts?: {
137
+ now?: string;
138
+ supersedes?: string | null;
139
+ }): RunbookRehearsal;
140
+ g2Readiness(): G2ReadinessReport;
141
+ registerG3Experiment(input: CompileExperimentPreregistrationInput, opts?: {
142
+ now?: string;
143
+ }): ExperimentPreregistration;
144
+ createG3Plan(input: CompileG3PlanInput, opts?: {
145
+ now?: string;
146
+ }): {
147
+ id: string;
148
+ content_hash: string;
149
+ gate: "G3";
150
+ g2_readiness_hash: string;
151
+ policy_ids: string[];
152
+ clients: string[];
153
+ experiments: {
154
+ retrieval: string;
155
+ compiler: string;
156
+ };
157
+ actor: string;
158
+ reason: string;
159
+ supersedes: string | null;
160
+ data_class: "private";
161
+ authority: "none";
162
+ created_at: string;
163
+ };
164
+ recordG3ProofReview(input: {
165
+ policy_id: string;
166
+ reviewer: string;
167
+ duration_ms: number;
168
+ comprehension: {
169
+ requirement: "correct" | "incorrect";
170
+ limitations: "correct" | "incorrect";
171
+ authority: "correct" | "incorrect";
172
+ };
173
+ notes: string;
174
+ supersedes?: string | null;
175
+ }, opts?: {
176
+ now?: string;
177
+ }): ProofReviewMeasurement;
178
+ g3AdapterConformance(opts?: {
179
+ timeoutMs?: number;
180
+ now?: string;
181
+ }): AdapterConformanceReceipt;
182
+ g3Readiness(): G3ReadinessReport;
183
+ validateExperimentCaseBank(input: CompileExperimentCaseBankInput, opts?: {
184
+ now?: string;
185
+ }): ExperimentCaseBank;
186
+ lockExperimentCaseBank(input: CompileExperimentCaseBankInput, opts?: {
187
+ now?: string;
188
+ }): ExperimentCaseBank;
189
+ createExperimentRun(caseBankId: string, input: CompileExperimentRunInput, opts?: {
190
+ now?: string;
191
+ }): ExperimentRun;
192
+ experimentRun(runId: string): ExperimentRun;
193
+ executeExperimentRun(runId: string, opts?: {
194
+ limit?: number;
195
+ timeoutMs?: number;
196
+ now?: string;
197
+ }): {
198
+ outcomes: ExperimentOutcome[];
199
+ report: ExperimentReport;
200
+ };
201
+ nextExperimentReview(runId: string, reviewer: string, opts?: {
202
+ now?: string;
203
+ }): {
204
+ start: ExperimentReviewStart;
205
+ assignment: ExperimentRun["assignments"][number];
206
+ treatment: unknown;
207
+ review_guide: ReturnType<typeof experimentReviewGuide>;
208
+ };
209
+ qualifyExperimentReviewer(input: CompileExperimentReviewerQualificationInput, opts?: {
210
+ now?: string;
211
+ }): ExperimentReviewerQualification;
212
+ /** Resolve an EXP-03 run/assignment/case triple (the shared lookup for both
213
+ * review-submission dialects). */
214
+ private resolveExp03Assignment;
215
+ /** Raw metrics-vocabulary submission — the ORIGINAL revision-1 contract, kept
216
+ * byte-identical for the append-only pilot. Revision-2 cases are refused here:
217
+ * they must go through the standardized plain-language template (dec_0be4fd3717)
218
+ * so the presented question and the recorded outcome cannot drift apart. */
219
+ submitExperimentReview(runId: string, assignmentId: string, input: {
220
+ reviewer: string;
221
+ decision: "accepted_precise" | "accepted_edited" | "rejected" | "uncompilable" | "abandoned" | "timeout";
222
+ precise: boolean;
223
+ proof_inspected: boolean;
224
+ result: string | null;
225
+ silent_semantic_substitution: boolean;
226
+ rejection_reason: string | null;
227
+ confirmed_private_leak: boolean;
228
+ data_loss_or_corruption: boolean;
229
+ unsafe_evaluator_behavior: boolean;
230
+ reason: string;
231
+ }, opts?: {
232
+ now?: string;
233
+ }): ExperimentOutcome;
234
+ /** Revision-2 standardized submission: the reviewer answers in the SAME
235
+ * plain-language vocabulary the treatment presented (choice + rule + one
236
+ * sentence); the deterministic mapper translates it into canonical metrics.
237
+ * Revision-1 cases are refused (the mapper throws) — they keep the raw path. */
238
+ respondExperimentReview(runId: string, assignmentId: string, input: Exp03ReviewResponse & {
239
+ reviewer: string;
240
+ confirmed_private_leak?: boolean;
241
+ data_loss_or_corruption?: boolean;
242
+ unsafe_evaluator_behavior?: boolean;
243
+ }, opts?: {
244
+ now?: string;
245
+ }): ExperimentOutcome;
246
+ /** The shared review-completion core: machine-owned timing, append-only dedup,
247
+ * derived edit distance, and the outcome write. Both dialects land here. */
248
+ private completeExp03Review;
249
+ recordExperimentFollowup(runId: string, assignmentId: string, input: {
250
+ reviewer: string;
251
+ reversed: boolean | null;
252
+ missing_reason: string | null;
253
+ notes: string;
254
+ supersedes?: string | null;
255
+ }, opts?: {
256
+ now?: string;
257
+ }): ExperimentFollowup;
258
+ stopExperiment(runId: string, input: {
259
+ category: ExperimentStop["category"];
260
+ actor: string;
261
+ reason: string;
262
+ evidence_hashes: string[];
263
+ }, opts?: {
264
+ now?: string;
265
+ }): ExperimentStop;
266
+ experimentReport(runId: string): ExperimentReport;
267
+ g2ShadowSweep(opts?: {
268
+ now?: string;
269
+ }): G2ShadowSweepReport;
270
+ g2ShadowBackfill(maxCommits?: number, opts?: {
271
+ now?: string;
272
+ }): G2ShadowBackfillReport;
273
+ g2OperationalDrill(category: (typeof G2_RUNBOOK_CATEGORIES)[number]): G2OperationalDrillReceipt;
274
+ g2CandidateReview(opts?: G2CandidateReviewOptions): G2CandidateReviewReport;
275
+ attestG2Candidate(candidateId: string, reviewHash: string, disposition: "selected" | "rejected", actor: string, reason: string, opts?: G2CandidateReviewOptions & {
276
+ now?: string;
277
+ supersedes?: string | null;
278
+ }): G2CandidateAttestation;
279
+ g2BehaviorCandidateReview(opts?: G2BehaviorCandidateReviewOptions): G2BehaviorCandidateReview;
280
+ g2BehaviorCandidateReplay(candidateId: string, reviewHash: string, opts?: G2BehaviorCandidateReviewOptions & {
281
+ timeoutMs?: number;
282
+ }): G2BehaviorReplayReceipt;
283
+ g2BehaviorMaterializationAssessment(opts?: G2BehaviorCandidateReviewOptions): G2BehaviorMaterializationAssessment;
284
+ g2BehaviorPolicyMaterialize(opts?: G2BehaviorCandidateReviewOptions & {
285
+ allowInstallScripts?: string[];
286
+ dependencyTimeoutMs?: number;
287
+ now?: string;
288
+ }): G2BehaviorPolicyMaterialization;
289
+ g2BehaviorDependencySnapshots(candidateId: string, reviewHash: string, opts?: G2BehaviorCandidateReviewOptions & {
290
+ allowInstallScripts?: string[];
291
+ timeoutMs?: number;
292
+ }): G2BehaviorDependencySnapshotReceipt;
293
+ attestG2BehaviorCandidate(candidateId: string, reviewHash: string, disposition: "selected" | "rejected", actor: string, reason: string, opts?: G2BehaviorCandidateReviewOptions & {
294
+ timeoutMs?: number;
295
+ now?: string;
296
+ supersedes?: string | null;
297
+ }): G2BehaviorAttestation;
298
+ g2ShadowQueue(limit?: number): G2ShadowQueue;
299
+ list(opts?: {
300
+ publicOnly?: boolean;
301
+ privateOnly?: boolean;
302
+ state?: string;
303
+ }): PolicySpec[];
304
+ get(id: string, opts?: {
305
+ publicOnly?: boolean;
306
+ privateOnly?: boolean;
307
+ }): PolicySpec;
308
+ private composition;
309
+ proof(id: string, opts?: {
310
+ publicOnly?: boolean;
311
+ privateOnly?: boolean;
312
+ }): PolicyProof;
313
+ card(id: string, opts?: {
314
+ publicOnly?: boolean;
315
+ privateOnly?: boolean;
316
+ }): ProofCard;
317
+ corpus(id: string, opts?: {
318
+ publicOnly?: boolean;
319
+ privateOnly?: boolean;
320
+ }): ProofCorpus;
321
+ importCorpus(id: string, raw: unknown, opts?: {
322
+ now?: string;
323
+ }): ProofCorpus;
324
+ compile(decisionId: string, opts?: CompilePolicyOptions): PolicySpec;
325
+ bootstrap(opts?: BootstrapOptions): BootstrapReport;
326
+ inspectStructural(decisionId: string, opts?: {
327
+ publicOnly?: boolean;
328
+ privateOnly?: boolean;
329
+ }): StructuralInspection;
330
+ ingest(opts?: LocalEvidenceOptions): LocalEvidenceReport;
331
+ upgradeCorrection(id: string, opts?: CorrectionUpgradeOptions): CorrectionPolicyUpgrade;
332
+ upgradeCorrections(opts?: CorrectionUpgradeOptions): CorrectionPolicySweep;
333
+ plan(id: string, opts?: ProofPlanOptions): ProofPlan;
334
+ prove(id: string, opts?: {
335
+ now?: string;
336
+ repositoryName?: string;
337
+ }): {
338
+ policy: PolicySpec;
339
+ proof: PolicyProof;
340
+ };
341
+ approve(id: string, mode: "advisory" | "blocking", actor: string, opts?: {
342
+ now?: string;
343
+ }): PolicySpec;
344
+ historyDispositions(id: string, opts?: {
345
+ publicOnly?: boolean;
346
+ privateOnly?: boolean;
347
+ }): PolicyHistoryDispositionView;
348
+ classifyHistory(id: string, commit: string, classification: HistoryDispositionClassification, actor: string, reason: string, opts?: {
349
+ now?: string;
350
+ supersedes?: string | null;
351
+ }): HistoryDisposition;
352
+ private compileShadowRecord;
353
+ recordShadow(id: string, opts?: {
354
+ now?: string;
355
+ latencyMs?: number;
356
+ commit?: string;
357
+ snapshot?: GraphSnapshot;
358
+ behavior?: BehaviorEvaluationOptions;
359
+ }): ShadowEvaluationRecord;
360
+ classifyShadow(id: string, shadowId: string, classification: HistoryDispositionClassification, actor: string, reason: string, opts?: {
361
+ now?: string;
362
+ supersedes?: string | null;
363
+ }): ShadowDisposition;
364
+ shadowReport(id: string, thresholds?: Partial<ShadowPrecisionThresholds>, opts?: {
365
+ publicOnly?: boolean;
366
+ privateOnly?: boolean;
367
+ }): PolicyShadowView;
368
+ demote(id: string, actor: string, reason: string, opts?: {
369
+ now?: string;
370
+ }): PolicySpec;
371
+ /** Targeted advisory withdrawal (§57): active_advisory → proposed; authority
372
+ * returns to the human pool and the policy re-enters the escalation loop. */
373
+ withdraw(id: string, actor: string, reason: string, opts?: {
374
+ now?: string;
375
+ }): PolicySpec;
376
+ /** Permanent retirement: active/proposed → retired; window closed, history kept. */
377
+ retire(id: string, actor: string, reason: string, opts?: {
378
+ now?: string;
379
+ }): PolicySpec;
380
+ linkException(id: string, parentId: string, actor: string, reason: string, opts?: {
381
+ now?: string;
382
+ }): PolicySpec;
383
+ relations(id: string, opts?: {
384
+ publicOnly?: boolean;
385
+ privateOnly?: boolean;
386
+ }): PolicyExceptionRelations;
387
+ consolidation(id: string, opts?: {
388
+ publicOnly?: boolean;
389
+ privateOnly?: boolean;
390
+ }): PolicyConsolidationCandidate;
391
+ evaluate(opts?: {
392
+ id?: string;
393
+ activeOnly?: boolean;
394
+ publicOnly?: boolean;
395
+ behavior?: BehaviorEvaluationOptions;
396
+ snapshot?: GraphSnapshot;
397
+ }): PolicyEvaluationSet[];
398
+ }
@@ -0,0 +1,54 @@
1
+ import { type HistoryDisposition, type HistoryDispositionClassification, type PolicyEvaluation, type PolicyProof, type PolicySpec, type ShadowDisposition, type ShadowEvaluationRecord } from "./schema.js";
2
+ export declare function policyEvaluationContentHash(evaluation: PolicyEvaluation): string;
3
+ export declare function shadowEvaluationContentHash(record: ShadowEvaluationRecord): string;
4
+ export declare function shadowEvaluationIdentityHash(record: ShadowEvaluationRecord): string;
5
+ export declare function shadowDispositionContentHash(record: ShadowDisposition): string;
6
+ export declare function shadowDispositionJudgmentHash(record: ShadowDisposition): string;
7
+ export declare function compileShadowEvaluation(policy: PolicySpec, proof: PolicyProof, expectedPolicyHash: string, evaluation: PolicyEvaluation, alsoDetectedBy: string[], latencyMs: number, now?: string): ShadowEvaluationRecord;
8
+ export declare function compileShadowDisposition(evaluation: ShadowEvaluationRecord, classification: HistoryDispositionClassification, actor: string, reason: string, opts?: {
9
+ now?: string;
10
+ supersedes?: string | null;
11
+ }): ShadowDisposition;
12
+ /** Resolve append-only correction chains without trusting timestamps. */
13
+ export declare function currentShadowDispositions(records: ShadowDisposition[]): ShadowDisposition[];
14
+ export interface ShadowPrecisionThresholds {
15
+ minApplicable: number;
16
+ recentApplicable: number;
17
+ maxUnknownErrorRate: number;
18
+ minMutationSensitivity: number;
19
+ }
20
+ export declare const DEFAULT_SHADOW_THRESHOLDS: ShadowPrecisionThresholds;
21
+ export interface ShadowPrecisionReport {
22
+ policy_id: string;
23
+ proof_id: string;
24
+ policy_hash: string;
25
+ thresholds: ShadowPrecisionThresholds;
26
+ counts: {
27
+ total: number;
28
+ applicable: number;
29
+ satisfied: number;
30
+ violated: number;
31
+ not_applicable: number;
32
+ unknown: number;
33
+ error: number;
34
+ stale_excluded: number;
35
+ };
36
+ window: {
37
+ recent_limit: number;
38
+ applicable: number;
39
+ violated: number;
40
+ };
41
+ dispositions: Record<HistoryDispositionClassification | "unclassified", number>;
42
+ precision: {
43
+ true_positives: number;
44
+ false_positives: number;
45
+ confirmed_denominator: number;
46
+ confirmed: number | null;
47
+ lower_bound: number | null;
48
+ };
49
+ unknown_error_rate: number;
50
+ mutation_sensitivity: number;
51
+ recommendation: "not_ready" | "eligible_for_p4_review";
52
+ reasons: string[];
53
+ }
54
+ export declare function scoreShadowPrecision(policy: PolicySpec, proof: PolicyProof, evaluations: ShadowEvaluationRecord[], dispositions: ShadowDisposition[], historyDispositions: HistoryDisposition[], thresholdOverrides?: Partial<ShadowPrecisionThresholds>): ShadowPrecisionReport;
@@ -0,0 +1,15 @@
1
+ import { type GraphSnapshot } from "./evaluator.js";
2
+ import type { PolicyEvaluation, PolicySpec } from "./schema.js";
3
+ export interface SourceMutationOutcome {
4
+ snapshot?: GraphSnapshot;
5
+ evaluation?: PolicyEvaluation;
6
+ source_patch?: {
7
+ files: string[];
8
+ diff: string;
9
+ diff_hash: string;
10
+ };
11
+ error_code?: string;
12
+ }
13
+ /** Apply one primary mutation to an immutable disposable source checkout. No
14
+ * project script, build, test, provider, model, or repository hook executes. */
15
+ export declare function runSourceMutation(root: string, policy: PolicySpec, base: GraphSnapshot): SourceMutationOutcome;