@oscharko-dev/keiko-contracts 0.2.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 (227) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/bff-wire.d.ts +661 -0
  3. package/dist/bff-wire.d.ts.map +1 -0
  4. package/dist/bff-wire.js +102 -0
  5. package/dist/bug-investigation-events.d.ts +92 -0
  6. package/dist/bug-investigation-events.d.ts.map +1 -0
  7. package/dist/bug-investigation-events.js +18 -0
  8. package/dist/coding-context.d.ts +76 -0
  9. package/dist/coding-context.d.ts.map +1 -0
  10. package/dist/coding-context.js +158 -0
  11. package/dist/connected-context.d.ts +174 -0
  12. package/dist/connected-context.d.ts.map +1 -0
  13. package/dist/connected-context.js +636 -0
  14. package/dist/conversation-budget.d.ts +37 -0
  15. package/dist/conversation-budget.d.ts.map +1 -0
  16. package/dist/conversation-budget.js +97 -0
  17. package/dist/editor-agent.d.ts +131 -0
  18. package/dist/editor-agent.d.ts.map +1 -0
  19. package/dist/editor-agent.js +197 -0
  20. package/dist/editor-completion.d.ts +62 -0
  21. package/dist/editor-completion.d.ts.map +1 -0
  22. package/dist/editor-completion.js +147 -0
  23. package/dist/editor-dirty-close.d.ts +17 -0
  24. package/dist/editor-dirty-close.d.ts.map +1 -0
  25. package/dist/editor-dirty-close.js +8 -0
  26. package/dist/editor-hot-exit.d.ts +18 -0
  27. package/dist/editor-hot-exit.d.ts.map +1 -0
  28. package/dist/editor-hot-exit.js +42 -0
  29. package/dist/editor-inline-completion.d.ts +70 -0
  30. package/dist/editor-inline-completion.d.ts.map +1 -0
  31. package/dist/editor-inline-completion.js +215 -0
  32. package/dist/editor-layout.d.ts +105 -0
  33. package/dist/editor-layout.d.ts.map +1 -0
  34. package/dist/editor-layout.js +479 -0
  35. package/dist/editor-patch-apply.d.ts +77 -0
  36. package/dist/editor-patch-apply.d.ts.map +1 -0
  37. package/dist/editor-patch-apply.js +122 -0
  38. package/dist/editor-session.d.ts +31 -0
  39. package/dist/editor-session.d.ts.map +1 -0
  40. package/dist/editor-session.js +75 -0
  41. package/dist/editor-test-generation.d.ts +104 -0
  42. package/dist/editor-test-generation.d.ts.map +1 -0
  43. package/dist/editor-test-generation.js +211 -0
  44. package/dist/evaluations.d.ts +75 -0
  45. package/dist/evaluations.d.ts.map +1 -0
  46. package/dist/evaluations.js +16 -0
  47. package/dist/evidence.d.ts +297 -0
  48. package/dist/evidence.d.ts.map +1 -0
  49. package/dist/evidence.js +9 -0
  50. package/dist/gateway.d.ts +129 -0
  51. package/dist/gateway.d.ts.map +1 -0
  52. package/dist/gateway.js +66 -0
  53. package/dist/harness.d.ts +274 -0
  54. package/dist/harness.d.ts.map +1 -0
  55. package/dist/harness.js +38 -0
  56. package/dist/index.d.ts +101 -0
  57. package/dist/index.d.ts.map +1 -0
  58. package/dist/index.js +83 -0
  59. package/dist/language-service.d.ts +145 -0
  60. package/dist/language-service.d.ts.map +1 -0
  61. package/dist/language-service.js +161 -0
  62. package/dist/local-knowledge-large-document-validation.d.ts +7 -0
  63. package/dist/local-knowledge-large-document-validation.d.ts.map +1 -0
  64. package/dist/local-knowledge-large-document-validation.js +161 -0
  65. package/dist/local-knowledge-large-document.d.ts +113 -0
  66. package/dist/local-knowledge-large-document.d.ts.map +1 -0
  67. package/dist/local-knowledge-large-document.js +142 -0
  68. package/dist/local-knowledge-paths.d.ts +3 -0
  69. package/dist/local-knowledge-paths.d.ts.map +1 -0
  70. package/dist/local-knowledge-paths.js +65 -0
  71. package/dist/local-knowledge-records.d.ts +190 -0
  72. package/dist/local-knowledge-records.d.ts.map +1 -0
  73. package/dist/local-knowledge-records.js +36 -0
  74. package/dist/local-knowledge-schema-validation.d.ts +19 -0
  75. package/dist/local-knowledge-schema-validation.d.ts.map +1 -0
  76. package/dist/local-knowledge-schema-validation.js +115 -0
  77. package/dist/local-knowledge-schema.d.ts +14 -0
  78. package/dist/local-knowledge-schema.d.ts.map +1 -0
  79. package/dist/local-knowledge-schema.js +715 -0
  80. package/dist/local-knowledge-validation.d.ts +20 -0
  81. package/dist/local-knowledge-validation.d.ts.map +1 -0
  82. package/dist/local-knowledge-validation.js +487 -0
  83. package/dist/local-knowledge.d.ts +158 -0
  84. package/dist/local-knowledge.d.ts.map +1 -0
  85. package/dist/local-knowledge.js +63 -0
  86. package/dist/memory-audit-events.d.ts +73 -0
  87. package/dist/memory-audit-events.d.ts.map +1 -0
  88. package/dist/memory-audit-events.js +44 -0
  89. package/dist/memory-audit-validation.d.ts +4 -0
  90. package/dist/memory-audit-validation.d.ts.map +1 -0
  91. package/dist/memory-audit-validation.js +151 -0
  92. package/dist/memory-barrel.d.ts +15 -0
  93. package/dist/memory-barrel.d.ts.map +1 -0
  94. package/dist/memory-barrel.js +20 -0
  95. package/dist/memory-internal.d.ts +26 -0
  96. package/dist/memory-internal.d.ts.map +1 -0
  97. package/dist/memory-internal.js +104 -0
  98. package/dist/memory-operations-validation.d.ts +12 -0
  99. package/dist/memory-operations-validation.d.ts.map +1 -0
  100. package/dist/memory-operations-validation.js +267 -0
  101. package/dist/memory-operations.d.ts +156 -0
  102. package/dist/memory-operations.d.ts.map +1 -0
  103. package/dist/memory-operations.js +29 -0
  104. package/dist/memory-record-validation.d.ts +10 -0
  105. package/dist/memory-record-validation.d.ts.map +1 -0
  106. package/dist/memory-record-validation.js +101 -0
  107. package/dist/memory-records.d.ts +66 -0
  108. package/dist/memory-records.d.ts.map +1 -0
  109. package/dist/memory-records.js +22 -0
  110. package/dist/memory-retrieval-validation.d.ts +6 -0
  111. package/dist/memory-retrieval-validation.d.ts.map +1 -0
  112. package/dist/memory-retrieval-validation.js +108 -0
  113. package/dist/memory-validation.d.ts +31 -0
  114. package/dist/memory-validation.d.ts.map +1 -0
  115. package/dist/memory-validation.js +318 -0
  116. package/dist/memory-workflow-port.d.ts +26 -0
  117. package/dist/memory-workflow-port.d.ts.map +1 -0
  118. package/dist/memory-workflow-port.js +13 -0
  119. package/dist/memory.d.ts +81 -0
  120. package/dist/memory.d.ts.map +1 -0
  121. package/dist/memory.js +104 -0
  122. package/dist/prompt-enhancer-analyzer.d.ts +7 -0
  123. package/dist/prompt-enhancer-analyzer.d.ts.map +1 -0
  124. package/dist/prompt-enhancer-analyzer.js +745 -0
  125. package/dist/prompt-enhancer-bff.d.ts +67 -0
  126. package/dist/prompt-enhancer-bff.d.ts.map +1 -0
  127. package/dist/prompt-enhancer-bff.js +156 -0
  128. package/dist/prompt-enhancer-critic.d.ts +46 -0
  129. package/dist/prompt-enhancer-critic.d.ts.map +1 -0
  130. package/dist/prompt-enhancer-critic.js +35 -0
  131. package/dist/prompt-enhancer-grounding.d.ts +19 -0
  132. package/dist/prompt-enhancer-grounding.d.ts.map +1 -0
  133. package/dist/prompt-enhancer-grounding.js +235 -0
  134. package/dist/prompt-enhancer-safety.d.ts +66 -0
  135. package/dist/prompt-enhancer-safety.d.ts.map +1 -0
  136. package/dist/prompt-enhancer-safety.js +446 -0
  137. package/dist/prompt-enhancer-validation.d.ts +28 -0
  138. package/dist/prompt-enhancer-validation.d.ts.map +1 -0
  139. package/dist/prompt-enhancer-validation.js +931 -0
  140. package/dist/prompt-enhancer.d.ts +184 -0
  141. package/dist/prompt-enhancer.d.ts.map +1 -0
  142. package/dist/prompt-enhancer.js +350 -0
  143. package/dist/qualityIntelligence/assertNever.d.ts +2 -0
  144. package/dist/qualityIntelligence/assertNever.d.ts.map +1 -0
  145. package/dist/qualityIntelligence/assertNever.js +7 -0
  146. package/dist/qualityIntelligence/auditSummary.d.ts +25 -0
  147. package/dist/qualityIntelligence/auditSummary.d.ts.map +1 -0
  148. package/dist/qualityIntelligence/auditSummary.js +7 -0
  149. package/dist/qualityIntelligence/bffWire.d.ts +356 -0
  150. package/dist/qualityIntelligence/bffWire.d.ts.map +1 -0
  151. package/dist/qualityIntelligence/bffWire.js +22 -0
  152. package/dist/qualityIntelligence/coverageMap.d.ts +21 -0
  153. package/dist/qualityIntelligence/coverageMap.d.ts.map +1 -0
  154. package/dist/qualityIntelligence/coverageMap.js +29 -0
  155. package/dist/qualityIntelligence/editableRevision.d.ts +21 -0
  156. package/dist/qualityIntelligence/editableRevision.d.ts.map +1 -0
  157. package/dist/qualityIntelligence/editableRevision.js +8 -0
  158. package/dist/qualityIntelligence/evidenceAtom.d.ts +35 -0
  159. package/dist/qualityIntelligence/evidenceAtom.d.ts.map +1 -0
  160. package/dist/qualityIntelligence/evidenceAtom.js +29 -0
  161. package/dist/qualityIntelligence/exportBundle.d.ts +28 -0
  162. package/dist/qualityIntelligence/exportBundle.d.ts.map +1 -0
  163. package/dist/qualityIntelligence/exportBundle.js +46 -0
  164. package/dist/qualityIntelligence/handoffEnvelope.d.ts +23 -0
  165. package/dist/qualityIntelligence/handoffEnvelope.d.ts.map +1 -0
  166. package/dist/qualityIntelligence/handoffEnvelope.js +8 -0
  167. package/dist/qualityIntelligence/ids.d.ts +58 -0
  168. package/dist/qualityIntelligence/ids.d.ts.map +1 -0
  169. package/dist/qualityIntelligence/ids.js +93 -0
  170. package/dist/qualityIntelligence/index.d.ts +29 -0
  171. package/dist/qualityIntelligence/index.d.ts.map +1 -0
  172. package/dist/qualityIntelligence/index.js +20 -0
  173. package/dist/qualityIntelligence/reviewRecord.d.ts +19 -0
  174. package/dist/qualityIntelligence/reviewRecord.d.ts.map +1 -0
  175. package/dist/qualityIntelligence/reviewRecord.js +20 -0
  176. package/dist/qualityIntelligence/runPlanAndEvents.d.ts +84 -0
  177. package/dist/qualityIntelligence/runPlanAndEvents.d.ts.map +1 -0
  178. package/dist/qualityIntelligence/runPlanAndEvents.js +51 -0
  179. package/dist/qualityIntelligence/sourceEnvelope.d.ts +77 -0
  180. package/dist/qualityIntelligence/sourceEnvelope.d.ts.map +1 -0
  181. package/dist/qualityIntelligence/sourceEnvelope.js +118 -0
  182. package/dist/qualityIntelligence/testCaseCandidate.d.ts +21 -0
  183. package/dist/qualityIntelligence/testCaseCandidate.d.ts.map +1 -0
  184. package/dist/qualityIntelligence/testCaseCandidate.js +21 -0
  185. package/dist/qualityIntelligence/testQualityRubric.d.ts +17 -0
  186. package/dist/qualityIntelligence/testQualityRubric.d.ts.map +1 -0
  187. package/dist/qualityIntelligence/testQualityRubric.js +32 -0
  188. package/dist/qualityIntelligence/validationFinding.d.ts +48 -0
  189. package/dist/qualityIntelligence/validationFinding.d.ts.map +1 -0
  190. package/dist/qualityIntelligence/validationFinding.js +36 -0
  191. package/dist/relationships-validation.d.ts +13 -0
  192. package/dist/relationships-validation.d.ts.map +1 -0
  193. package/dist/relationships-validation.js +422 -0
  194. package/dist/relationships.d.ts +79 -0
  195. package/dist/relationships.d.ts.map +1 -0
  196. package/dist/relationships.js +307 -0
  197. package/dist/text-safety.d.ts +7 -0
  198. package/dist/text-safety.d.ts.map +1 -0
  199. package/dist/text-safety.js +58 -0
  200. package/dist/tools.d.ts +153 -0
  201. package/dist/tools.d.ts.map +1 -0
  202. package/dist/tools.js +118 -0
  203. package/dist/unit-test-events.d.ts +87 -0
  204. package/dist/unit-test-events.d.ts.map +1 -0
  205. package/dist/unit-test-events.js +14 -0
  206. package/dist/verification-summary.d.ts +38 -0
  207. package/dist/verification-summary.d.ts.map +1 -0
  208. package/dist/verification-summary.js +5 -0
  209. package/dist/verification.d.ts +64 -0
  210. package/dist/verification.d.ts.map +1 -0
  211. package/dist/verification.js +13 -0
  212. package/dist/workflow-descriptor.d.ts +21 -0
  213. package/dist/workflow-descriptor.d.ts.map +1 -0
  214. package/dist/workflow-descriptor.js +8 -0
  215. package/dist/workflow-handoff.d.ts +69 -0
  216. package/dist/workflow-handoff.d.ts.map +1 -0
  217. package/dist/workflow-handoff.js +381 -0
  218. package/dist/workspace-descriptors.d.ts +21 -0
  219. package/dist/workspace-descriptors.d.ts.map +1 -0
  220. package/dist/workspace-descriptors.js +180 -0
  221. package/dist/workspace-ui.d.ts +119 -0
  222. package/dist/workspace-ui.d.ts.map +1 -0
  223. package/dist/workspace-ui.js +105 -0
  224. package/dist/workspace.d.ts +104 -0
  225. package/dist/workspace.d.ts.map +1 -0
  226. package/dist/workspace.js +27 -0
  227. package/package.json +71 -0
@@ -0,0 +1,184 @@
1
+ export declare const PROMPT_ENHANCER_SCHEMA_VERSION: "1";
2
+ export declare const PROMPT_ANALYSIS_MAX_SCAN_CHARS: 100000;
3
+ export declare const PROMPT_MISSING_CONTEXT_MAX_CHARS: 240;
4
+ declare const PromptEnhancementRequestIdBrand: unique symbol;
5
+ declare const EnhancedPromptIdBrand: unique symbol;
6
+ export type PromptEnhancementRequestId = string & {
7
+ readonly [PromptEnhancementRequestIdBrand]: true;
8
+ };
9
+ export type EnhancedPromptId = string & {
10
+ readonly [EnhancedPromptIdBrand]: true;
11
+ };
12
+ /**
13
+ * Validate a candidate string is acceptable as a Prompt Enhancer branded id. Pure; returns a typed
14
+ * reason on rejection. Rules mirror the QI / audit-ledger id discipline: non-empty after trim, no
15
+ * surrounding whitespace, max length 256, NFKC-normalised, no control characters, no path-traversal
16
+ * fragment. Exported for tests; production callers use the `asX` constructors.
17
+ */
18
+ export declare const validatePromptEnhancerIdString: (value: unknown, kind: string) => {
19
+ ok: true;
20
+ } | {
21
+ ok: false;
22
+ reason: string;
23
+ };
24
+ export declare const asPromptEnhancementRequestId: (value: string) => PromptEnhancementRequestId;
25
+ export declare const asEnhancedPromptId: (value: string) => EnhancedPromptId;
26
+ export type PromptTaskClass = "factual-qa" | "research" | "rag-question-answering" | "summarization" | "structured-extraction" | "data-analysis" | "code-generation" | "code-debugging" | "code-architecture" | "writing-editing" | "creative-writing" | "decision-support" | "agentic-tool-use" | "prompt-optimization" | "safety-critical";
27
+ export declare const PROMPT_TASK_CLASSES: readonly PromptTaskClass[];
28
+ export type PromptDomain = "software" | "legal" | "medical" | "finance" | "security" | "data-science" | "science" | "business" | "education" | "creative" | "general";
29
+ export declare const PROMPT_DOMAINS: readonly PromptDomain[];
30
+ export declare const SAFETY_CRITICAL_DOMAINS: readonly PromptDomain[];
31
+ export declare const isSafetyCriticalDomain: (domain: PromptDomain) => boolean;
32
+ export type PromptCriticality = "low" | "standard" | "elevated" | "critical";
33
+ export declare const PROMPT_CRITICALITIES: readonly PromptCriticality[];
34
+ export type PromptRiskClass = "instruction-override-suspected" | "tool-authority-requested" | "egress-requested" | "safety-critical-advice";
35
+ export declare const PROMPT_RISK_CLASSES: readonly PromptRiskClass[];
36
+ export type GroundingNeedKind = "none" | "supplied-context" | "external-knowledge" | "external-current";
37
+ export declare const GROUNDING_NEED_KINDS: readonly GroundingNeedKind[];
38
+ export type GroundingSignal = "temporal-recency-term" | "named-current-event" | "market-or-price" | "url-reference" | "supplied-context-reference" | "retrieval-cue" | "self-contained-task" | "no-external-signal";
39
+ export declare const GROUNDING_SIGNALS: readonly GroundingSignal[];
40
+ export interface GroundingNeed {
41
+ readonly kind: GroundingNeedKind;
42
+ readonly volatile: boolean;
43
+ readonly signals: readonly GroundingSignal[];
44
+ }
45
+ export type GroundingStrategy = "no-grounding" | "supplied-context-only" | "local-knowledge" | "repository-context" | "hybrid" | "external-research-required";
46
+ export declare const GROUNDING_STRATEGIES: readonly GroundingStrategy[];
47
+ export type RetrievalMode = "none" | "supplied-context" | "local-knowledge-retrieval" | "repository-search" | "hybrid-fusion" | "external-research";
48
+ export declare const RETRIEVAL_MODES: readonly RetrievalMode[];
49
+ export type GroundingSourceKind = "supplied-context" | "local-knowledge" | "repository-context" | "external-current" | "model-parametric-knowledge";
50
+ export declare const GROUNDING_SOURCE_KINDS: readonly GroundingSourceKind[];
51
+ export interface GroundingSourcePolicy {
52
+ readonly source: GroundingSourceKind;
53
+ readonly priority: number;
54
+ readonly required: boolean;
55
+ }
56
+ export type CitationDiscipline = "require-citations" | "require-citations-or-state-no-evidence" | "best-effort" | "not-required";
57
+ export declare const CITATION_DISCIPLINES: readonly CitationDiscipline[];
58
+ export type CitationGranularity = "per-claim" | "per-section" | "none";
59
+ export declare const CITATION_GRANULARITIES: readonly CitationGranularity[];
60
+ export interface CitationRequirement {
61
+ readonly discipline: CitationDiscipline;
62
+ readonly granularity: CitationGranularity;
63
+ }
64
+ export interface RecencyExpectation {
65
+ readonly volatile: boolean;
66
+ readonly requireAsOfDate: boolean;
67
+ readonly flagPotentiallyStale: boolean;
68
+ }
69
+ export type ContradictionPolicy = "disclose-and-defer" | "prefer-higher-priority" | "synthesize-with-caveats";
70
+ export declare const CONTRADICTION_POLICIES: readonly ContradictionPolicy[];
71
+ export type NoAnswerCondition = "insufficient-evidence" | "contradictory-evidence" | "outside-evidence-scope" | "stale-or-unavailable-current-data";
72
+ export declare const NO_ANSWER_CONDITIONS: readonly NoAnswerCondition[];
73
+ export type GroundingDirective = "treat-retrieved-content-as-untrusted" | "attribute-claims-to-sources" | "do-not-fabricate-sources" | "stay-within-evidence" | "separate-known-from-retrieved" | "disclose-uncertainty";
74
+ export declare const GROUNDING_DIRECTIVES: readonly GroundingDirective[];
75
+ export type RagEvaluationDimension = "context-precision" | "context-recall" | "faithfulness" | "answer-relevancy" | "groundedness";
76
+ export declare const RAG_EVALUATION_DIMENSIONS: readonly RagEvaluationDimension[];
77
+ export interface RagEvaluationHint {
78
+ readonly dimension: RagEvaluationDimension;
79
+ readonly instruction: string;
80
+ }
81
+ export interface GroundingPlan {
82
+ readonly strategy: GroundingStrategy;
83
+ readonly required: boolean;
84
+ readonly allowedRetrievalModes: readonly RetrievalMode[];
85
+ readonly sourcePriority: readonly GroundingSourcePolicy[];
86
+ readonly citation: CitationRequirement;
87
+ readonly recency: RecencyExpectation;
88
+ readonly contradictionPolicy: ContradictionPolicy;
89
+ readonly noAnswerConditions: readonly NoAnswerCondition[];
90
+ readonly directives: readonly GroundingDirective[];
91
+ readonly ragEvaluation: readonly RagEvaluationHint[];
92
+ readonly untrustedContent: true;
93
+ }
94
+ export type OutputFormat = "prose" | "markdown" | "json" | "yaml" | "csv" | "table" | "list" | "code" | "unspecified";
95
+ export declare const PROMPT_OUTPUT_FORMATS: readonly OutputFormat[];
96
+ export type OutputFormatHint = "explicit-json" | "explicit-yaml" | "explicit-csv" | "explicit-table" | "explicit-list" | "explicit-code" | "explicit-markdown" | "schema-keyword" | "no-format-signal";
97
+ export declare const OUTPUT_FORMAT_HINTS: readonly OutputFormatHint[];
98
+ export interface OutputSchemaDescriptor {
99
+ readonly format: OutputFormat;
100
+ readonly structured: boolean;
101
+ readonly hints: readonly OutputFormatHint[];
102
+ }
103
+ export type MissingContextTopic = "subject" | "scope" | "audience" | "output-format" | "constraints" | "data-source" | "success-criteria";
104
+ export declare const MISSING_CONTEXT_TOPICS: readonly MissingContextTopic[];
105
+ export interface PromptClarification {
106
+ readonly kind: "clarification";
107
+ readonly topic: MissingContextTopic;
108
+ readonly question: string;
109
+ }
110
+ export interface PromptAssumption {
111
+ readonly kind: "assumption";
112
+ readonly topic: MissingContextTopic;
113
+ readonly statement: string;
114
+ }
115
+ export type ClarificationOrAssumption = PromptClarification | PromptAssumption;
116
+ export type MissingInformationStrategy = "clarify" | "assume";
117
+ export declare const MISSING_INFORMATION_STRATEGIES: readonly MissingInformationStrategy[];
118
+ export type PromptSignalStrength = "strong" | "moderate" | "weak";
119
+ export declare const PROMPT_SIGNAL_STRENGTHS: readonly PromptSignalStrength[];
120
+ export type PromptSignalDimension = "task-class" | "domain" | "grounding" | "output" | "risk" | "missing-context";
121
+ export declare const PROMPT_SIGNAL_DIMENSIONS: readonly PromptSignalDimension[];
122
+ export interface PromptClassificationSignal {
123
+ readonly dimension: PromptSignalDimension;
124
+ readonly code: string;
125
+ }
126
+ export type PromptEnhancementProfileId = "fast" | "precise" | "research" | "creative" | "technical" | "safety-critical" | "agentic";
127
+ export declare const PROMPT_ENHANCEMENT_PROFILE_IDS: readonly PromptEnhancementProfileId[];
128
+ export interface PromptEnhancementProfile {
129
+ readonly id: PromptEnhancementProfileId;
130
+ readonly description: string;
131
+ readonly groundingMandatory: boolean;
132
+ readonly deterministicAnalysisOnly: boolean;
133
+ readonly preferredOutputModes: readonly OutputFormat[];
134
+ readonly maxClarifications: number;
135
+ }
136
+ export declare const PROMPT_ENHANCEMENT_PROFILES: Readonly<Record<PromptEnhancementProfileId, PromptEnhancementProfile>>;
137
+ export interface RawPromptInput {
138
+ readonly text: string;
139
+ readonly hasConnectedContext?: boolean | undefined;
140
+ readonly attachmentCount?: number | undefined;
141
+ }
142
+ export interface PromptEnhancementRequest {
143
+ readonly schemaVersion: typeof PROMPT_ENHANCER_SCHEMA_VERSION;
144
+ readonly requestId: PromptEnhancementRequestId;
145
+ readonly input: RawPromptInput;
146
+ readonly missingInformationStrategy: MissingInformationStrategy;
147
+ readonly profilePreference?: PromptEnhancementProfileId | undefined;
148
+ readonly locale?: string | undefined;
149
+ }
150
+ export interface PromptTaskAnalysis {
151
+ readonly schemaVersion: typeof PROMPT_ENHANCER_SCHEMA_VERSION;
152
+ readonly requestId: PromptEnhancementRequestId;
153
+ readonly taskClass: PromptTaskClass;
154
+ readonly taskClassConfidence: PromptSignalStrength;
155
+ readonly domain: PromptDomain;
156
+ readonly criticality: PromptCriticality;
157
+ readonly groundingNeed: GroundingNeed;
158
+ readonly outputSchema: OutputSchemaDescriptor;
159
+ readonly missingContext: readonly ClarificationOrAssumption[];
160
+ readonly riskFlags: readonly PromptRiskClass[];
161
+ readonly recommendedProfile: PromptEnhancementProfileId;
162
+ readonly normalizedInputLength: number;
163
+ readonly signals: readonly PromptClassificationSignal[];
164
+ }
165
+ export interface EnhancedPrompt {
166
+ readonly schemaVersion: typeof PROMPT_ENHANCER_SCHEMA_VERSION;
167
+ readonly promptId: EnhancedPromptId;
168
+ readonly role: string;
169
+ readonly goal: string;
170
+ readonly context: readonly string[];
171
+ readonly input: string;
172
+ readonly taskDecomposition: readonly string[];
173
+ readonly constraints: readonly string[];
174
+ readonly groundingRules: readonly string[];
175
+ readonly groundingPlan: GroundingPlan;
176
+ readonly outputSchema: OutputSchemaDescriptor;
177
+ readonly qualityCriteria: readonly string[];
178
+ readonly uncertaintyHandling: readonly string[];
179
+ readonly safetyRules: readonly string[];
180
+ }
181
+ export declare function assertNeverTaskClass(value: never): never;
182
+ export declare function normalizePromptDraft(text: string): string;
183
+ export {};
184
+ //# sourceMappingURL=prompt-enhancer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-enhancer.d.ts","sourceRoot":"","sources":["../src/prompt-enhancer.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,8BAA8B,EAAG,GAAY,CAAC;AAK3D,eAAO,MAAM,8BAA8B,EAAG,MAAgB,CAAC;AAG/D,eAAO,MAAM,gCAAgC,EAAG,GAAY,CAAC;AAM7D,OAAO,CAAC,MAAM,+BAA+B,EAAE,OAAO,MAAM,CAAC;AAC7D,OAAO,CAAC,MAAM,qBAAqB,EAAE,OAAO,MAAM,CAAC;AAEnD,MAAM,MAAM,0BAA0B,GAAG,MAAM,GAAG;IAChD,QAAQ,CAAC,CAAC,+BAA+B,CAAC,EAAE,IAAI,CAAC;CAClD,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG;IACtC,QAAQ,CAAC,CAAC,qBAAqB,CAAC,EAAE,IAAI,CAAC;CACxC,CAAC;AAgBF;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,GACzC,OAAO,OAAO,EACd,MAAM,MAAM,KACX;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CA6B5C,CAAC;AAUF,eAAO,MAAM,4BAA4B,GAAI,OAAO,MAAM,KAAG,0BACiC,CAAC;AAE/F,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,gBACuB,CAAC;AAS3E,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,UAAU,GACV,wBAAwB,GACxB,eAAe,GACf,uBAAuB,GACvB,eAAe,GACf,iBAAiB,GACjB,gBAAgB,GAChB,mBAAmB,GACnB,iBAAiB,GACjB,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,qBAAqB,GACrB,iBAAiB,CAAC;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AA8B,CAAC;IAC9D,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAG3C,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,sBAAsB,CAAC;IAC9C,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAC;IAChD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAKD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAExD;AAKD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzD"}
@@ -0,0 +1,350 @@
1
+ // Prompt Enhancer wire contracts, task taxonomy, and analyzer-result shapes
2
+ // (Epic #1307, Issue #1309; governed by ADR-0044 and the prompt-enhancer architecture blueprint).
3
+ //
4
+ // This module is the single conceptual map for the Prompt Enhancer domain in the contracts leaf.
5
+ // It carries ONLY wire-safe, provider-neutral data and pure value tables. There is no IO, no clock
6
+ // read, no hashing, and no randomness here. The leaf-package rule (ADR-0019 direction 1) forbids any
7
+ // `@oscharko-dev/keiko-*` import; same-package relative imports (e.g. `./text-safety.js`) are allowed.
8
+ //
9
+ // Schema evolution follows the EVIDENCE_SCHEMA_VERSION / CONNECTED_CONTEXT_SCHEMA_VERSION rule
10
+ // (ADR-0010 D2): a breaking structural change introduces a NEW literal member rather than mutating
11
+ // "1", so persisted/streamed artefacts remain discriminable across versions.
12
+ //
13
+ // Trust boundary (ADR-0044 §5, AC5 of #1309): none of these shapes may encode a provider credential,
14
+ // a hidden system prompt, or a tool/secret/egress/patch authority grant. The Enhanced Prompt is data,
15
+ // never a capability grant. The `boundary.test.ts` style key-shape assertions in
16
+ // `prompt-enhancer-contracts.test.ts` pin this property.
17
+ //
18
+ // Scope discipline. This module owns the contracts + taxonomy, the deterministic analyzer-result
19
+ // shape (Issue #1309), and the grounding-plan / source-policy shape (Issue #1311). Adjacent concerns
20
+ // are deliberately deferred to their owning issues and are NOT modelled here: machine-readable safety
21
+ // annotations and the validate-stage rule set (#1313), candidate generation and scorecards (#1312),
22
+ // and the evidence manifest (#1313). The risk flags below are explainable, lexical analyzer signals
23
+ // only; the authoritative prompt-injection redaction patterns and secret/PII detectors live in
24
+ // `keiko-security` (#1313) and are not duplicated here. The grounding plan is a source POLICY only:
25
+ // actual retrieval stays in the existing Keiko grounding paths, bound to the plan by the server
26
+ // (#1314); this module never imports a retrieval engine (leaf-package rule).
27
+ import { stripUnsafeFormatChars } from "./text-safety.js";
28
+ // ─── Schema version ─────────────────────────────────────────────────────────────
29
+ export const PROMPT_ENHANCER_SCHEMA_VERSION = "1";
30
+ // Upper bound on the number of characters the deterministic analyzer scans from a raw draft. Inputs
31
+ // longer than this are truncated before signal detection so analysis cost and output are bounded and
32
+ // deterministic regardless of draft size. Exported so callers and tests can reason about the bound.
33
+ export const PROMPT_ANALYSIS_MAX_SCAN_CHARS = 100_000;
34
+ // Maximum length of a single clarification question or assumption statement the analyzer emits.
35
+ export const PROMPT_MISSING_CONTEXT_MAX_CHARS = 240;
36
+ const PROMPT_ENHANCER_ID_MAX_LENGTH = 256;
37
+ const PROMPT_ENHANCER_ID_FORBIDDEN_FRAGMENTS = ["..", "/", "\\"];
38
+ const hasControlCharacter = (value) => {
39
+ for (let index = 0; index < value.length; index += 1) {
40
+ const code = value.charCodeAt(index);
41
+ // C0 controls 0x00–0x1F, DEL 0x7F, C1 controls 0x80–0x9F.
42
+ if (code <= 0x1f || code === 0x7f || (code >= 0x80 && code <= 0x9f)) {
43
+ return true;
44
+ }
45
+ }
46
+ return false;
47
+ };
48
+ /**
49
+ * Validate a candidate string is acceptable as a Prompt Enhancer branded id. Pure; returns a typed
50
+ * reason on rejection. Rules mirror the QI / audit-ledger id discipline: non-empty after trim, no
51
+ * surrounding whitespace, max length 256, NFKC-normalised, no control characters, no path-traversal
52
+ * fragment. Exported for tests; production callers use the `asX` constructors.
53
+ */
54
+ export const validatePromptEnhancerIdString = (value, kind) => {
55
+ if (typeof value !== "string") {
56
+ return { ok: false, reason: `${kind} must be a string` };
57
+ }
58
+ if (value.length === 0 || value.trim().length === 0) {
59
+ return { ok: false, reason: `${kind} must not be empty or whitespace-only` };
60
+ }
61
+ if (value !== value.trim()) {
62
+ return { ok: false, reason: `${kind} must not have leading or trailing whitespace` };
63
+ }
64
+ if (value.length > PROMPT_ENHANCER_ID_MAX_LENGTH) {
65
+ return {
66
+ ok: false,
67
+ reason: `${kind} exceeds max length ${String(PROMPT_ENHANCER_ID_MAX_LENGTH)}`,
68
+ };
69
+ }
70
+ if (value.normalize("NFKC") !== value) {
71
+ return { ok: false, reason: `${kind} must be NFKC-normalised` };
72
+ }
73
+ if (hasControlCharacter(value)) {
74
+ return { ok: false, reason: `${kind} contains control characters` };
75
+ }
76
+ if (stripUnsafeFormatChars(value) !== value) {
77
+ return { ok: false, reason: `${kind} contains unsafe format characters` };
78
+ }
79
+ if (PROMPT_ENHANCER_ID_FORBIDDEN_FRAGMENTS.some((fragment) => value.includes(fragment))) {
80
+ return { ok: false, reason: `${kind} contains a forbidden path fragment` };
81
+ }
82
+ return { ok: true };
83
+ };
84
+ const constructPromptEnhancerId = (value, kind) => {
85
+ const result = validatePromptEnhancerIdString(value, kind);
86
+ if (!result.ok) {
87
+ throw new TypeError(`Invalid ${kind}: ${result.reason}`);
88
+ }
89
+ return value;
90
+ };
91
+ export const asPromptEnhancementRequestId = (value) => constructPromptEnhancerId(value, "PromptEnhancementRequestId");
92
+ export const asEnhancedPromptId = (value) => constructPromptEnhancerId(value, "EnhancedPromptId");
93
+ export const PROMPT_TASK_CLASSES = [
94
+ "factual-qa",
95
+ "research",
96
+ "rag-question-answering",
97
+ "summarization",
98
+ "structured-extraction",
99
+ "data-analysis",
100
+ "code-generation",
101
+ "code-debugging",
102
+ "code-architecture",
103
+ "writing-editing",
104
+ "creative-writing",
105
+ "decision-support",
106
+ "agentic-tool-use",
107
+ "prompt-optimization",
108
+ "safety-critical",
109
+ ];
110
+ export const PROMPT_DOMAINS = [
111
+ "software",
112
+ "legal",
113
+ "medical",
114
+ "finance",
115
+ "security",
116
+ "data-science",
117
+ "science",
118
+ "business",
119
+ "education",
120
+ "creative",
121
+ "general",
122
+ ];
123
+ // The domains whose advice carries real-world legal, clinical, financial, or security consequence.
124
+ // Detecting any of these drives `criticality` to "critical" and raises the `safety-critical` task
125
+ // class and the `safety-critical-advice` risk flag.
126
+ export const SAFETY_CRITICAL_DOMAINS = [
127
+ "legal",
128
+ "medical",
129
+ "finance",
130
+ "security",
131
+ ];
132
+ export const isSafetyCriticalDomain = (domain) => SAFETY_CRITICAL_DOMAINS.includes(domain);
133
+ export const PROMPT_CRITICALITIES = [
134
+ "low",
135
+ "standard",
136
+ "elevated",
137
+ "critical",
138
+ ];
139
+ export const PROMPT_RISK_CLASSES = [
140
+ "instruction-override-suspected",
141
+ "tool-authority-requested",
142
+ "egress-requested",
143
+ "safety-critical-advice",
144
+ ];
145
+ export const GROUNDING_NEED_KINDS = [
146
+ "none",
147
+ "supplied-context",
148
+ "external-knowledge",
149
+ "external-current",
150
+ ];
151
+ export const GROUNDING_SIGNALS = [
152
+ "temporal-recency-term",
153
+ "named-current-event",
154
+ "market-or-price",
155
+ "url-reference",
156
+ "supplied-context-reference",
157
+ "retrieval-cue",
158
+ "self-contained-task",
159
+ "no-external-signal",
160
+ ];
161
+ export const GROUNDING_STRATEGIES = [
162
+ "no-grounding",
163
+ "supplied-context-only",
164
+ "local-knowledge",
165
+ "repository-context",
166
+ "hybrid",
167
+ "external-research-required",
168
+ ];
169
+ export const RETRIEVAL_MODES = [
170
+ "none",
171
+ "supplied-context",
172
+ "local-knowledge-retrieval",
173
+ "repository-search",
174
+ "hybrid-fusion",
175
+ "external-research",
176
+ ];
177
+ export const GROUNDING_SOURCE_KINDS = [
178
+ "supplied-context",
179
+ "local-knowledge",
180
+ "repository-context",
181
+ "external-current",
182
+ "model-parametric-knowledge",
183
+ ];
184
+ export const CITATION_DISCIPLINES = [
185
+ "require-citations",
186
+ "require-citations-or-state-no-evidence",
187
+ "best-effort",
188
+ "not-required",
189
+ ];
190
+ export const CITATION_GRANULARITIES = [
191
+ "per-claim",
192
+ "per-section",
193
+ "none",
194
+ ];
195
+ export const CONTRADICTION_POLICIES = [
196
+ "disclose-and-defer",
197
+ "prefer-higher-priority",
198
+ "synthesize-with-caveats",
199
+ ];
200
+ export const NO_ANSWER_CONDITIONS = [
201
+ "insufficient-evidence",
202
+ "contradictory-evidence",
203
+ "outside-evidence-scope",
204
+ "stale-or-unavailable-current-data",
205
+ ];
206
+ export const GROUNDING_DIRECTIVES = [
207
+ "treat-retrieved-content-as-untrusted",
208
+ "attribute-claims-to-sources",
209
+ "do-not-fabricate-sources",
210
+ "stay-within-evidence",
211
+ "separate-known-from-retrieved",
212
+ "disclose-uncertainty",
213
+ ];
214
+ export const RAG_EVALUATION_DIMENSIONS = [
215
+ "context-precision",
216
+ "context-recall",
217
+ "faithfulness",
218
+ "answer-relevancy",
219
+ "groundedness",
220
+ ];
221
+ export const PROMPT_OUTPUT_FORMATS = [
222
+ "prose",
223
+ "markdown",
224
+ "json",
225
+ "yaml",
226
+ "csv",
227
+ "table",
228
+ "list",
229
+ "code",
230
+ "unspecified",
231
+ ];
232
+ export const OUTPUT_FORMAT_HINTS = [
233
+ "explicit-json",
234
+ "explicit-yaml",
235
+ "explicit-csv",
236
+ "explicit-table",
237
+ "explicit-list",
238
+ "explicit-code",
239
+ "explicit-markdown",
240
+ "schema-keyword",
241
+ "no-format-signal",
242
+ ];
243
+ export const MISSING_CONTEXT_TOPICS = [
244
+ "subject",
245
+ "scope",
246
+ "audience",
247
+ "output-format",
248
+ "constraints",
249
+ "data-source",
250
+ "success-criteria",
251
+ ];
252
+ export const MISSING_INFORMATION_STRATEGIES = [
253
+ "clarify",
254
+ "assume",
255
+ ];
256
+ export const PROMPT_SIGNAL_STRENGTHS = [
257
+ "strong",
258
+ "moderate",
259
+ "weak",
260
+ ];
261
+ export const PROMPT_SIGNAL_DIMENSIONS = [
262
+ "task-class",
263
+ "domain",
264
+ "grounding",
265
+ "output",
266
+ "risk",
267
+ "missing-context",
268
+ ];
269
+ export const PROMPT_ENHANCEMENT_PROFILE_IDS = [
270
+ "fast",
271
+ "precise",
272
+ "research",
273
+ "creative",
274
+ "technical",
275
+ "safety-critical",
276
+ "agentic",
277
+ ];
278
+ export const PROMPT_ENHANCEMENT_PROFILES = {
279
+ fast: {
280
+ id: "fast",
281
+ description: "Low-latency enhancement for simple, self-contained tasks.",
282
+ groundingMandatory: false,
283
+ deterministicAnalysisOnly: true,
284
+ preferredOutputModes: ["prose", "markdown"],
285
+ maxClarifications: 1,
286
+ },
287
+ precise: {
288
+ id: "precise",
289
+ description: "Accuracy-first enhancement for factual and decision-support tasks.",
290
+ groundingMandatory: false,
291
+ deterministicAnalysisOnly: false,
292
+ preferredOutputModes: ["markdown", "list"],
293
+ maxClarifications: 3,
294
+ },
295
+ research: {
296
+ id: "research",
297
+ description: "Grounded, citation-oriented enhancement for research and deep-research tasks.",
298
+ groundingMandatory: true,
299
+ deterministicAnalysisOnly: false,
300
+ preferredOutputModes: ["markdown", "list"],
301
+ maxClarifications: 3,
302
+ },
303
+ creative: {
304
+ id: "creative",
305
+ description: "Expressive enhancement for creative writing and ideation tasks.",
306
+ groundingMandatory: false,
307
+ deterministicAnalysisOnly: false,
308
+ preferredOutputModes: ["prose", "markdown"],
309
+ maxClarifications: 2,
310
+ },
311
+ technical: {
312
+ id: "technical",
313
+ description: "Structure-first enhancement for coding, data, and extraction tasks.",
314
+ groundingMandatory: false,
315
+ deterministicAnalysisOnly: false,
316
+ preferredOutputModes: ["code", "json", "markdown"],
317
+ maxClarifications: 3,
318
+ },
319
+ "safety-critical": {
320
+ id: "safety-critical",
321
+ description: "Cautious, grounded enhancement for legal, medical, financial, or security-sensitive tasks.",
322
+ groundingMandatory: true,
323
+ deterministicAnalysisOnly: false,
324
+ preferredOutputModes: ["markdown", "list"],
325
+ maxClarifications: 4,
326
+ },
327
+ agentic: {
328
+ id: "agentic",
329
+ description: "Tool-aware enhancement for agentic tasks; authority stays behind governed handoff.",
330
+ groundingMandatory: false,
331
+ deterministicAnalysisOnly: false,
332
+ preferredOutputModes: ["markdown", "json"],
333
+ maxClarifications: 3,
334
+ },
335
+ };
336
+ // ─── Exhaustiveness helper ───────────────────────────────────────────────────────
337
+ // Compile-time guard: a future PromptTaskClass member with no switch arm forces a type error at the
338
+ // call site (the value is `never` only when every member is handled). Throws if reached at runtime.
339
+ export function assertNeverTaskClass(value) {
340
+ throw new TypeError(`Unhandled PromptTaskClass: ${String(value)}`);
341
+ }
342
+ // Normalize a raw draft for deterministic analysis: strip Trojan-source/control code points, NFKC
343
+ // normalize, and truncate to the scan bound. Shared by the analyzer and exposed for callers that
344
+ // need the same bounded view. Pure.
345
+ export function normalizePromptDraft(text) {
346
+ const stripped = stripUnsafeFormatChars(text).normalize("NFKC");
347
+ return stripped.length > PROMPT_ANALYSIS_MAX_SCAN_CHARS
348
+ ? stripped.slice(0, PROMPT_ANALYSIS_MAX_SCAN_CHARS)
349
+ : stripped;
350
+ }
@@ -0,0 +1,2 @@
1
+ export declare const assertQualityIntelligenceNever: (value: never) => never;
2
+ //# sourceMappingURL=assertNever.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertNever.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/assertNever.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,8BAA8B,GAAI,OAAO,KAAK,KAAG,KAE7D,CAAC"}
@@ -0,0 +1,7 @@
1
+ // Exhaustiveness helper for discriminated unions across the Quality Intelligence
2
+ // contract surface (Epic #270, Issue #277). Pure; throws at runtime if the type
3
+ // system has been bypassed (e.g. via `as`). Mirrors the convention used in
4
+ // `memory-internal.ts` (`assertNeverMemoryType`) but is shared by every QI union.
5
+ export const assertQualityIntelligenceNever = (value) => {
6
+ throw new TypeError(`Unexpected Quality Intelligence discriminant: ${JSON.stringify(value)}`);
7
+ };
@@ -0,0 +1,25 @@
1
+ import type { QualityIntelligenceAuditSummaryId, QualityIntelligenceRunId } from "./ids.js";
2
+ export declare const QUALITY_INTELLIGENCE_AUDIT_MANIFEST_SCHEMA_VERSION: 1;
3
+ export interface QualityIntelligenceAuditTotals {
4
+ readonly candidates: number;
5
+ readonly findings: number;
6
+ readonly exports: number;
7
+ readonly reviews: number;
8
+ }
9
+ export interface QualityIntelligenceEvidenceRetentionSummary {
10
+ readonly retainedDays: number;
11
+ readonly totalAtoms: number;
12
+ }
13
+ export interface QualityIntelligenceAuditSummary {
14
+ readonly id: QualityIntelligenceAuditSummaryId;
15
+ readonly runId: QualityIntelligenceRunId;
16
+ readonly manifestSchemaVersion: typeof QUALITY_INTELLIGENCE_AUDIT_MANIFEST_SCHEMA_VERSION;
17
+ readonly totals: QualityIntelligenceAuditTotals;
18
+ /** Display-only policy profile names applied to this run. */
19
+ readonly policyProfiles: readonly string[];
20
+ readonly modelGatewayCallCount: number;
21
+ readonly evidenceRetentionSummary: QualityIntelligenceEvidenceRetentionSummary;
22
+ /** ISO 8601 timestamp. */
23
+ readonly createdAt: string;
24
+ }
25
+ //# sourceMappingURL=auditSummary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auditSummary.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/auditSummary.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iCAAiC,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAE5F,eAAO,MAAM,kDAAkD,EAAG,CAAU,CAAC;AAE7E,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,2CAA2C;IAC1D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,EAAE,EAAE,iCAAiC,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC;IACzC,QAAQ,CAAC,qBAAqB,EAAE,OAAO,kDAAkD,CAAC;IAC1F,QAAQ,CAAC,MAAM,EAAE,8BAA8B,CAAC;IAChD,6DAA6D;IAC7D,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,wBAAwB,EAAE,2CAA2C,CAAC;IAC/E,0BAA0B;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
@@ -0,0 +1,7 @@
1
+ // Quality Intelligence audit summary (Epic #270, Issue #277).
2
+ //
3
+ // The audit summary is the persistable, versioned manifest the audit ledger (#274)
4
+ // records per QI run. The `manifestSchemaVersion` literal `1` follows the same
5
+ // evolution rule as EVIDENCE_SCHEMA_VERSION: a breaking change introduces a new
6
+ // literal member rather than mutating the existing one.
7
+ export const QUALITY_INTELLIGENCE_AUDIT_MANIFEST_SCHEMA_VERSION = 1;