@unson/brainbase-mcp 0.10.11 → 0.10.13
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.
- package/dist/knowledge-lookup.js +57 -46
- package/dist/knowledge-promotion.d.ts +410 -0
- package/dist/knowledge-promotion.js +843 -0
- package/package.json +6 -2
- package/ui/value-proof-review.js +7 -2
package/dist/knowledge-lookup.js
CHANGED
|
@@ -640,6 +640,25 @@ function unsupported(input, action, error) {
|
|
|
640
640
|
error: { code: error.code, message: error.message },
|
|
641
641
|
};
|
|
642
642
|
}
|
|
643
|
+
function lookupActionVariant(kind, properties, required) {
|
|
644
|
+
return {
|
|
645
|
+
type: 'object',
|
|
646
|
+
properties: {
|
|
647
|
+
kind: { const: kind },
|
|
648
|
+
...properties,
|
|
649
|
+
required_fields: {
|
|
650
|
+
type: 'array',
|
|
651
|
+
minItems: 1,
|
|
652
|
+
maxItems: MAX_FIELDS,
|
|
653
|
+
description: 'Must contain the same public field paths as the top-level required_fields.',
|
|
654
|
+
items: { type: 'string', minLength: 1, maxLength: MAX_FIELD_LENGTH },
|
|
655
|
+
},
|
|
656
|
+
why_different: { type: 'string', minLength: 1, maxLength: MAX_HINT_LENGTH },
|
|
657
|
+
},
|
|
658
|
+
required: ['kind', ...required],
|
|
659
|
+
additionalProperties: false,
|
|
660
|
+
};
|
|
661
|
+
}
|
|
643
662
|
export const knowledgeLookupTools = [{
|
|
644
663
|
name: 'brainbase_knowledge_lookup',
|
|
645
664
|
description: 'Find and read authorized Graph knowledge by purpose. Each call performs one bounded search, read, relation follow, or finish proposal; project hints never change authorization scope.',
|
|
@@ -664,57 +683,49 @@ export const knowledgeLookupTools = [{
|
|
|
664
683
|
missing_information: { type: 'array', maxItems: MAX_FIELDS, items: { type: 'string', minLength: 1, maxLength: MAX_HINT_LENGTH } },
|
|
665
684
|
based_on_attempt_ids: { type: 'array', maxItems: MAX_IDS, items: { type: 'string', minLength: 1, maxLength: 300 } },
|
|
666
685
|
why_different: { type: 'string', minLength: 1, maxLength: MAX_HINT_LENGTH },
|
|
686
|
+
// Each variant lists its own properties. Codex renders only the oneOf
|
|
687
|
+
// variants into the model-facing declaration, so properties declared
|
|
688
|
+
// beside oneOf are invisible and read/finish calls cannot be written.
|
|
667
689
|
next_action: {
|
|
668
690
|
type: 'object',
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
type: '
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
691
|
+
oneOf: [
|
|
692
|
+
lookupActionVariant('search', {
|
|
693
|
+
query: { type: 'string', minLength: 1, maxLength: MAX_TEXT_LENGTH },
|
|
694
|
+
entity_types: { type: 'array', maxItems: 10, items: { type: 'string', minLength: 1, maxLength: 100 } },
|
|
695
|
+
seed_ids: { type: 'array', minItems: 1, maxItems: MAX_IDS, items: { type: 'string', minLength: 1, maxLength: 1_000 } },
|
|
696
|
+
}, []),
|
|
697
|
+
lookupActionVariant('read', {
|
|
698
|
+
entity_id: { type: 'string', minLength: 1, maxLength: 1_000 },
|
|
699
|
+
entity_type: { type: 'string', minLength: 1, maxLength: 100 },
|
|
700
|
+
}, ['entity_id', 'entity_type']),
|
|
701
|
+
lookupActionVariant('follow_relation', {
|
|
702
|
+
seed_ids: { type: 'array', minItems: 1, maxItems: MAX_IDS, items: { type: 'string', minLength: 1, maxLength: 1_000 } },
|
|
703
|
+
relation: { type: 'string', minLength: 1, maxLength: MAX_RELATION_LENGTH },
|
|
704
|
+
direction: { type: 'string', enum: ['incoming', 'outgoing'] },
|
|
705
|
+
target_types: { type: 'array', maxItems: 10, items: { type: 'string', minLength: 1, maxLength: 100 } },
|
|
706
|
+
}, ['seed_ids', 'relation', 'direction']),
|
|
707
|
+
lookupActionVariant('finish', {
|
|
708
|
+
assessment: { type: 'string', enum: ['sufficient', 'insufficient'] },
|
|
709
|
+
status: { type: 'string', enum: ['satisfied', 'unresolved', 'needs_user_input'] },
|
|
710
|
+
reference_ids: { type: 'array', maxItems: MAX_IDS, items: { type: 'string', minLength: 1, maxLength: 1_000 } },
|
|
711
|
+
field_evidence: {
|
|
712
|
+
type: 'array',
|
|
713
|
+
maxItems: MAX_FIELDS,
|
|
714
|
+
items: {
|
|
715
|
+
type: 'object',
|
|
716
|
+
properties: {
|
|
717
|
+
field: { type: 'string', minLength: 1, maxLength: MAX_FIELD_LENGTH },
|
|
718
|
+
reference_id: { type: 'string', minLength: 1, maxLength: 1_000 },
|
|
719
|
+
attempt_id: { type: 'string', minLength: 1, maxLength: 300 },
|
|
720
|
+
},
|
|
721
|
+
required: ['field', 'reference_id', 'attempt_id'],
|
|
722
|
+
additionalProperties: false,
|
|
699
723
|
},
|
|
700
|
-
required: ['field', 'reference_id', 'attempt_id'],
|
|
701
|
-
additionalProperties: false,
|
|
702
724
|
},
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
},
|
|
707
|
-
oneOf: [
|
|
708
|
-
{ properties: { kind: { const: 'search' } }, required: ['kind'] },
|
|
709
|
-
{ properties: { kind: { const: 'read' } }, required: ['kind', 'entity_id', 'entity_type'] },
|
|
710
|
-
{ properties: { kind: { const: 'follow_relation' } }, required: ['kind', 'seed_ids', 'relation', 'direction'] },
|
|
711
|
-
{
|
|
712
|
-
properties: { kind: { const: 'finish' } },
|
|
713
|
-
required: ['kind', 'assessment', 'status', 'reference_ids', 'field_evidence', 'unresolved_items', 'termination_reason'],
|
|
714
|
-
},
|
|
725
|
+
unresolved_items: { type: 'array', maxItems: MAX_FIELDS, items: { type: 'string', minLength: 1, maxLength: MAX_HINT_LENGTH } },
|
|
726
|
+
termination_reason: { type: 'string', minLength: 1, maxLength: MAX_HINT_LENGTH },
|
|
727
|
+
}, ['assessment', 'status', 'reference_ids', 'field_evidence', 'unresolved_items', 'termination_reason']),
|
|
715
728
|
],
|
|
716
|
-
required: ['kind'],
|
|
717
|
-
additionalProperties: false,
|
|
718
729
|
},
|
|
719
730
|
},
|
|
720
731
|
required: ['question', 'target_hint', 'required_fields'],
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
export declare const KNOWLEDGE_PROMOTION_CONTRACT_VERSION: "knowledge_promotion.v1";
|
|
2
|
+
/** Kept byte-compatible with brainbase-unson so stored hashes and receipts still verify. */
|
|
3
|
+
export declare const NORMALIZED_PROMOTION_SCHEMA_VERSION: "personal_knowledge_normalized.v1";
|
|
4
|
+
export type PromotionApprovalKind = 'personal_share' | 'organization_candidate';
|
|
5
|
+
export type PromotionSourceKind = 'personal_knowledge_v1' | 'organization_candidate';
|
|
6
|
+
export type PromotionStatus = 'pending_owner_approval' | 'pending_org_review' | 'owner_rejected' | 'org_rejected' | 'org_accepted' | 'source_stale';
|
|
7
|
+
export type PromotionDecision = 'approve' | 'reject';
|
|
8
|
+
export type PromotionReviewAction = 'request' | 'owner_consent' | 'organization_review';
|
|
9
|
+
export declare class KnowledgePromotionError extends Error {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
readonly status: number;
|
|
12
|
+
readonly details?: Record<string, unknown>;
|
|
13
|
+
constructor(code: string, status?: number, details?: Record<string, unknown>);
|
|
14
|
+
}
|
|
15
|
+
type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
16
|
+
[key: string]: JsonValue;
|
|
17
|
+
};
|
|
18
|
+
export interface NormalizedPromotionEntity {
|
|
19
|
+
id: string;
|
|
20
|
+
type: string;
|
|
21
|
+
payload: Record<string, JsonValue>;
|
|
22
|
+
}
|
|
23
|
+
export interface NormalizedPromotionEdge {
|
|
24
|
+
from_id: string;
|
|
25
|
+
to_id: string;
|
|
26
|
+
relation: string;
|
|
27
|
+
payload: Record<string, JsonValue>;
|
|
28
|
+
}
|
|
29
|
+
export interface NormalizedPromotionPayload {
|
|
30
|
+
schema_version: typeof NORMALIZED_PROMOTION_SCHEMA_VERSION;
|
|
31
|
+
kind: 'decision' | 'entity' | 'relation';
|
|
32
|
+
entity: NormalizedPromotionEntity;
|
|
33
|
+
edges: NormalizedPromotionEdge[];
|
|
34
|
+
context_entities: Array<{
|
|
35
|
+
id: string;
|
|
36
|
+
type: string;
|
|
37
|
+
}>;
|
|
38
|
+
decision_domain?: string;
|
|
39
|
+
sensitivity: string;
|
|
40
|
+
role_min: string;
|
|
41
|
+
}
|
|
42
|
+
export interface NormalizedPromotionResult {
|
|
43
|
+
normalized: NormalizedPromotionPayload;
|
|
44
|
+
normalized_payload_hash: string;
|
|
45
|
+
summary: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function promotionSha256(value: unknown): string;
|
|
48
|
+
/** Validate and canonicalize the structured content a person approves for the organization. */
|
|
49
|
+
export declare function normalizePromotionPayload(input: unknown): NormalizedPromotionResult;
|
|
50
|
+
/** Owner consent receipt, identical to brainbase-unson's `pkoc_` receipt. */
|
|
51
|
+
export declare function ownerConsentReceipt(request: {
|
|
52
|
+
request_id: string;
|
|
53
|
+
owner_person_id: string | null;
|
|
54
|
+
owner_decided_by: string | null;
|
|
55
|
+
owner_decided_at: string | Date | null;
|
|
56
|
+
normalized_payload_hash: string;
|
|
57
|
+
}): string;
|
|
58
|
+
/** Organization review receipt of a personal share, identical to brainbase-unson's `pkor_` receipt. */
|
|
59
|
+
export declare function organizationReviewReceipt(request: {
|
|
60
|
+
request_id: string;
|
|
61
|
+
}, normalizedPayloadHash: string, reviewerPersonId: string, reviewedAt: string): string;
|
|
62
|
+
/** Organization approval receipt of an organization candidate. */
|
|
63
|
+
export declare function candidateApprovalReceipt(request: {
|
|
64
|
+
request_id: string;
|
|
65
|
+
source: PromotionSourceRef;
|
|
66
|
+
normalized_payload_hash: string;
|
|
67
|
+
}, reviewerPersonId: string, reviewedAt: string): string;
|
|
68
|
+
export interface PromotionSourceRef {
|
|
69
|
+
kind: PromotionSourceKind;
|
|
70
|
+
id: string;
|
|
71
|
+
version: string;
|
|
72
|
+
evidence_hash: string;
|
|
73
|
+
}
|
|
74
|
+
export interface PromotionDecisionRecord {
|
|
75
|
+
action: 'owner_consent' | 'organization_review';
|
|
76
|
+
decision: PromotionDecision;
|
|
77
|
+
actor_person_id: string;
|
|
78
|
+
decided_at: string;
|
|
79
|
+
receipt_id: string | null;
|
|
80
|
+
reason: string | null;
|
|
81
|
+
}
|
|
82
|
+
export interface KnowledgePromotionRequest {
|
|
83
|
+
request_id: string;
|
|
84
|
+
contract_version: typeof KNOWLEDGE_PROMOTION_CONTRACT_VERSION;
|
|
85
|
+
approval_kind: PromotionApprovalKind;
|
|
86
|
+
source: PromotionSourceRef;
|
|
87
|
+
source_event_ids: string[];
|
|
88
|
+
organization_id: string;
|
|
89
|
+
project_code: string;
|
|
90
|
+
owner_person_id: string | null;
|
|
91
|
+
requested_by_person_id: string;
|
|
92
|
+
status: PromotionStatus;
|
|
93
|
+
revision: number;
|
|
94
|
+
subject: {
|
|
95
|
+
type: string;
|
|
96
|
+
id: string;
|
|
97
|
+
};
|
|
98
|
+
sanitized_preview: string | null;
|
|
99
|
+
preview_hash: string | null;
|
|
100
|
+
normalized_payload: NormalizedPromotionPayload;
|
|
101
|
+
normalized_payload_hash: string;
|
|
102
|
+
normalization_contract_version: typeof NORMALIZED_PROMOTION_SCHEMA_VERSION;
|
|
103
|
+
owner_decided_by: string | null;
|
|
104
|
+
owner_decided_at: string | null;
|
|
105
|
+
owner_consent_receipt_id: string | null;
|
|
106
|
+
organization_review_receipt_id: string | null;
|
|
107
|
+
organization_event_id: string | null;
|
|
108
|
+
graph_entity_id: string | null;
|
|
109
|
+
decisions: PromotionDecisionRecord[];
|
|
110
|
+
created_at: string;
|
|
111
|
+
updated_at: string;
|
|
112
|
+
}
|
|
113
|
+
export interface KnowledgePromotionPrincipal {
|
|
114
|
+
personId: string;
|
|
115
|
+
/** The person who acts, when a service acts for `personId`. Defaults to `personId`. */
|
|
116
|
+
actorPersonId?: string;
|
|
117
|
+
organizationId: string;
|
|
118
|
+
projectCodes: string[];
|
|
119
|
+
role?: string;
|
|
120
|
+
principalType: 'person' | 'service';
|
|
121
|
+
}
|
|
122
|
+
/** Opaque signed authority. When present, the store records its single use. */
|
|
123
|
+
export interface KnowledgePromotionAuthority {
|
|
124
|
+
operationId: string;
|
|
125
|
+
idempotencyKey: string;
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
}
|
|
128
|
+
export interface PromotionContext {
|
|
129
|
+
tx: unknown;
|
|
130
|
+
principal: KnowledgePromotionPrincipal;
|
|
131
|
+
}
|
|
132
|
+
export interface PersonalKnowledgeSourceRecord {
|
|
133
|
+
event_id: string;
|
|
134
|
+
owner_person_id: string;
|
|
135
|
+
organization_id: string;
|
|
136
|
+
body_hash: string;
|
|
137
|
+
version: string;
|
|
138
|
+
active: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface OrganizationCandidateSourceRecord {
|
|
141
|
+
candidate_id: string;
|
|
142
|
+
organization_id: string;
|
|
143
|
+
project_code: string;
|
|
144
|
+
version: string;
|
|
145
|
+
active: boolean;
|
|
146
|
+
evidence_hash: string;
|
|
147
|
+
source_event_ids?: string[];
|
|
148
|
+
}
|
|
149
|
+
export interface OrganizationCandidateOutcome {
|
|
150
|
+
candidate_id: string;
|
|
151
|
+
outcome: 'promoted' | 'rejected';
|
|
152
|
+
request_id: string;
|
|
153
|
+
actor_person_id: string;
|
|
154
|
+
receipt_id: string;
|
|
155
|
+
graph_entity_id: string | null;
|
|
156
|
+
organization_event_id: string | null;
|
|
157
|
+
decided_at: string;
|
|
158
|
+
}
|
|
159
|
+
export interface KnowledgePromotionLineage {
|
|
160
|
+
lineage_id: string;
|
|
161
|
+
contract_version: typeof KNOWLEDGE_PROMOTION_CONTRACT_VERSION;
|
|
162
|
+
approval_kind: PromotionApprovalKind;
|
|
163
|
+
promotion_request_id: string;
|
|
164
|
+
source: PromotionSourceRef;
|
|
165
|
+
source_event_ids: string[];
|
|
166
|
+
owner_person_id: string | null;
|
|
167
|
+
organization_id: string;
|
|
168
|
+
project_code: string;
|
|
169
|
+
organization_event_id: string;
|
|
170
|
+
graph_entity_id: string;
|
|
171
|
+
normalized_payload_hash: string;
|
|
172
|
+
receipts: {
|
|
173
|
+
owner_consent_receipt_id: string | null;
|
|
174
|
+
organization_review_receipt_id: string;
|
|
175
|
+
};
|
|
176
|
+
approved_by_person_id: string;
|
|
177
|
+
sanitization: {
|
|
178
|
+
raw_copied: false;
|
|
179
|
+
personal_body_copied: false;
|
|
180
|
+
sanitized_preview_copied: false;
|
|
181
|
+
};
|
|
182
|
+
created_at: string;
|
|
183
|
+
}
|
|
184
|
+
export interface KnowledgePromotionStore {
|
|
185
|
+
transaction<T>(work: (tx: unknown) => Promise<T>, options?: {
|
|
186
|
+
principal: KnowledgePromotionPrincipal;
|
|
187
|
+
}): Promise<T>;
|
|
188
|
+
/** Insert, or return the existing request with the same `request_id`. */
|
|
189
|
+
createRequest(request: KnowledgePromotionRequest, ctx: PromotionContext): Promise<KnowledgePromotionRequest>;
|
|
190
|
+
findRequest(requestId: string, ctx: PromotionContext): Promise<KnowledgePromotionRequest | null>;
|
|
191
|
+
/** Apply `patch` and increment `revision` only when the stored revision equals `expectedRevision`; otherwise `null`. */
|
|
192
|
+
updateRequest(requestId: string, patch: Partial<KnowledgePromotionRequest>, options: {
|
|
193
|
+
expectedRevision: number;
|
|
194
|
+
}, ctx: PromotionContext): Promise<KnowledgePromotionRequest | null>;
|
|
195
|
+
createLineage(lineage: KnowledgePromotionLineage, ctx: PromotionContext): Promise<void>;
|
|
196
|
+
claimAuthorityUse?(use: {
|
|
197
|
+
operation_id: string;
|
|
198
|
+
idempotency_key: string;
|
|
199
|
+
request_id: string;
|
|
200
|
+
action: PromotionReviewAction;
|
|
201
|
+
actor_person_id: string;
|
|
202
|
+
organization_id: string;
|
|
203
|
+
project_code: string;
|
|
204
|
+
}, ctx: PromotionContext): Promise<void>;
|
|
205
|
+
}
|
|
206
|
+
export interface KnowledgePromotionSources {
|
|
207
|
+
readPersonalKnowledgeEvent?(eventId: string, ctx: PromotionContext): Promise<PersonalKnowledgeSourceRecord | null>;
|
|
208
|
+
readOrganizationCandidate?(candidateId: string, ctx: PromotionContext): Promise<OrganizationCandidateSourceRecord | null>;
|
|
209
|
+
recordOrganizationCandidateOutcome?(outcome: OrganizationCandidateOutcome, ctx: PromotionContext): Promise<void>;
|
|
210
|
+
}
|
|
211
|
+
export type PromotionReviewDecisionResult = {
|
|
212
|
+
allowed: true;
|
|
213
|
+
decider_person_id?: string;
|
|
214
|
+
} | {
|
|
215
|
+
allowed: false;
|
|
216
|
+
code: string;
|
|
217
|
+
status?: number;
|
|
218
|
+
details?: Record<string, unknown>;
|
|
219
|
+
};
|
|
220
|
+
export interface PromotionReviewInput {
|
|
221
|
+
action: PromotionReviewAction;
|
|
222
|
+
approvalKind: PromotionApprovalKind;
|
|
223
|
+
request: KnowledgePromotionRequest;
|
|
224
|
+
normalized: NormalizedPromotionPayload;
|
|
225
|
+
principal: KnowledgePromotionPrincipal;
|
|
226
|
+
authority: KnowledgePromotionAuthority | null;
|
|
227
|
+
}
|
|
228
|
+
/** Organization-owned review rules (brainbase-organization). */
|
|
229
|
+
export interface PromotionReviewPolicy {
|
|
230
|
+
authorize(input: PromotionReviewInput, ctx: PromotionContext): Promise<PromotionReviewDecisionResult>;
|
|
231
|
+
}
|
|
232
|
+
export interface KnowledgeEventRecordResult {
|
|
233
|
+
event_id: string;
|
|
234
|
+
candidate_id?: string | null;
|
|
235
|
+
semantic_state?: string;
|
|
236
|
+
quarantine_reason?: string | null;
|
|
237
|
+
}
|
|
238
|
+
export interface KnowledgePromotionEventSink {
|
|
239
|
+
recordOrganizationEvent(event: OrganizationKnowledgeEvent, ctx: PromotionContext): Promise<KnowledgeEventRecordResult>;
|
|
240
|
+
reconcileGraphProjection?(input: {
|
|
241
|
+
candidate_id: string;
|
|
242
|
+
graph_entity_id: string;
|
|
243
|
+
event_id: string;
|
|
244
|
+
actor_person_id: string;
|
|
245
|
+
decision_owner_person_id: string;
|
|
246
|
+
}, ctx: PromotionContext): Promise<void>;
|
|
247
|
+
}
|
|
248
|
+
export interface KnowledgePromotionGraphWriter {
|
|
249
|
+
commitNormalizedPromotion(mutation: NormalizedGraphMutation, ctx: PromotionContext): Promise<{
|
|
250
|
+
id: string;
|
|
251
|
+
} | null>;
|
|
252
|
+
}
|
|
253
|
+
export interface KnowledgePromotionPorts {
|
|
254
|
+
store: KnowledgePromotionStore;
|
|
255
|
+
sources: KnowledgePromotionSources;
|
|
256
|
+
reviewPolicy: PromotionReviewPolicy | null;
|
|
257
|
+
knowledgeEvents: KnowledgePromotionEventSink;
|
|
258
|
+
graph: KnowledgePromotionGraphWriter;
|
|
259
|
+
now?: () => Date;
|
|
260
|
+
}
|
|
261
|
+
export interface PromotionEvidence {
|
|
262
|
+
contract_version: typeof NORMALIZED_PROMOTION_SCHEMA_VERSION;
|
|
263
|
+
approval_kind: PromotionApprovalKind;
|
|
264
|
+
promotion_request_id: string;
|
|
265
|
+
source_kind: PromotionSourceKind;
|
|
266
|
+
source_version: string;
|
|
267
|
+
source_evidence_hash: string;
|
|
268
|
+
normalized_payload_hash: string;
|
|
269
|
+
owner_consent_receipt_id: string | null;
|
|
270
|
+
organization_review_receipt_id: string;
|
|
271
|
+
source_pointer: {
|
|
272
|
+
uri: string;
|
|
273
|
+
digest: string;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
export interface OrganizationKnowledgeEvent {
|
|
277
|
+
schema_version: 'knowledge_event.v1';
|
|
278
|
+
event_id: string;
|
|
279
|
+
occurred_at: string;
|
|
280
|
+
captured_at: string;
|
|
281
|
+
source: {
|
|
282
|
+
type: string;
|
|
283
|
+
venue: string;
|
|
284
|
+
contract_version: string;
|
|
285
|
+
};
|
|
286
|
+
subject: {
|
|
287
|
+
type: string;
|
|
288
|
+
id: string;
|
|
289
|
+
};
|
|
290
|
+
decision?: {
|
|
291
|
+
statement: JsonValue;
|
|
292
|
+
};
|
|
293
|
+
decision_authority: {
|
|
294
|
+
authorized: true;
|
|
295
|
+
decider_id: string;
|
|
296
|
+
domain: string;
|
|
297
|
+
};
|
|
298
|
+
applicability_scope: {
|
|
299
|
+
scope: 'organization';
|
|
300
|
+
organization_id: string;
|
|
301
|
+
project_code: string;
|
|
302
|
+
};
|
|
303
|
+
permission_snapshot: Record<string, unknown>;
|
|
304
|
+
source_pointer: {
|
|
305
|
+
uri: string;
|
|
306
|
+
digest: string;
|
|
307
|
+
};
|
|
308
|
+
body_hash: string;
|
|
309
|
+
parent_episode_id: string;
|
|
310
|
+
payload: {
|
|
311
|
+
summary: string;
|
|
312
|
+
normalized_kind: string;
|
|
313
|
+
promotion_evidence: PromotionEvidence;
|
|
314
|
+
};
|
|
315
|
+
promotion_evidence: PromotionEvidence;
|
|
316
|
+
organization_id: string;
|
|
317
|
+
project_code: string;
|
|
318
|
+
sensitivity: string;
|
|
319
|
+
role_min: string;
|
|
320
|
+
venue: string;
|
|
321
|
+
}
|
|
322
|
+
export interface NormalizedGraphMutation {
|
|
323
|
+
project_code: string;
|
|
324
|
+
entity: {
|
|
325
|
+
id: string;
|
|
326
|
+
type: string;
|
|
327
|
+
payload: Record<string, unknown>;
|
|
328
|
+
};
|
|
329
|
+
edges: Array<NormalizedPromotionEdge & {
|
|
330
|
+
payload: Record<string, unknown>;
|
|
331
|
+
}>;
|
|
332
|
+
context_entities: Array<{
|
|
333
|
+
id: string;
|
|
334
|
+
type: string;
|
|
335
|
+
}>;
|
|
336
|
+
role_min: string;
|
|
337
|
+
sensitivity: string;
|
|
338
|
+
evidence: PromotionEvidence & {
|
|
339
|
+
organization_event_id: string;
|
|
340
|
+
candidate_id: string | null;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
export declare function buildPromotionEvidence(request: KnowledgePromotionRequest, organizationReviewReceiptId: string): PromotionEvidence;
|
|
344
|
+
/** The organization knowledge event that records the approval. The approval kind is never disguised. */
|
|
345
|
+
export declare function buildOrganizationKnowledgeEvent(request: KnowledgePromotionRequest, normalized: NormalizedPromotionPayload, summary: string, evidence: PromotionEvidence, approverPersonId: string, occurredAt: string): OrganizationKnowledgeEvent;
|
|
346
|
+
/** Graph mutation carrying only normalized content and provenance pointers. */
|
|
347
|
+
export declare function buildNormalizedGraphMutation(request: KnowledgePromotionRequest, normalized: NormalizedPromotionPayload, evidence: PromotionEvidence, eventResult: KnowledgeEventRecordResult, organizationEvent: OrganizationKnowledgeEvent): NormalizedGraphMutation;
|
|
348
|
+
export declare function promotionRequestId(input: {
|
|
349
|
+
approval_kind: PromotionApprovalKind;
|
|
350
|
+
source: PromotionSourceRef;
|
|
351
|
+
project_code: string;
|
|
352
|
+
normalized_payload_hash: string;
|
|
353
|
+
}): string;
|
|
354
|
+
export declare class KnowledgePromotionService {
|
|
355
|
+
readonly ports: KnowledgePromotionPorts;
|
|
356
|
+
private readonly now;
|
|
357
|
+
constructor(ports: KnowledgePromotionPorts);
|
|
358
|
+
/** D4: request sharing a Personal Knowledge v1 event owned by the authenticated person. */
|
|
359
|
+
requestPersonalShare(input: {
|
|
360
|
+
personal_event_id: string;
|
|
361
|
+
project_code: string;
|
|
362
|
+
summary: string;
|
|
363
|
+
subject?: {
|
|
364
|
+
type: string;
|
|
365
|
+
id: string;
|
|
366
|
+
};
|
|
367
|
+
normalized_payload: unknown;
|
|
368
|
+
}, context: {
|
|
369
|
+
principal: KnowledgePromotionPrincipal;
|
|
370
|
+
authority?: KnowledgePromotionAuthority | null;
|
|
371
|
+
}): Promise<KnowledgePromotionRequest>;
|
|
372
|
+
/** D12: request promoting an organization candidate waiting for the Graph promotion review. */
|
|
373
|
+
requestOrganizationCandidate(input: {
|
|
374
|
+
candidate_id: string;
|
|
375
|
+
project_code: string;
|
|
376
|
+
normalized_payload: unknown;
|
|
377
|
+
}, context: {
|
|
378
|
+
principal: KnowledgePromotionPrincipal;
|
|
379
|
+
authority?: KnowledgePromotionAuthority | null;
|
|
380
|
+
}): Promise<KnowledgePromotionRequest>;
|
|
381
|
+
/** D4: the owner approves or rejects sharing the exact normalized content. */
|
|
382
|
+
decideOwnerConsent(requestId: string, input: {
|
|
383
|
+
decision: PromotionDecision;
|
|
384
|
+
normalized_payload_hash?: string;
|
|
385
|
+
expected_revision: number;
|
|
386
|
+
}, context: {
|
|
387
|
+
principal: KnowledgePromotionPrincipal;
|
|
388
|
+
authority?: KnowledgePromotionAuthority | null;
|
|
389
|
+
}): Promise<KnowledgePromotionRequest>;
|
|
390
|
+
/**
|
|
391
|
+
* D4: organization review of an owner-approved personal share.
|
|
392
|
+
* D12: organization approval of an organization candidate.
|
|
393
|
+
* Only an approval commits the event, the Graph mutation, the lineage, and the request in one transaction.
|
|
394
|
+
*/
|
|
395
|
+
reviewOrganization(requestId: string, input: {
|
|
396
|
+
decision: PromotionDecision;
|
|
397
|
+
reason?: string;
|
|
398
|
+
expected_revision: number;
|
|
399
|
+
}, context: {
|
|
400
|
+
principal: KnowledgePromotionPrincipal;
|
|
401
|
+
authority?: KnowledgePromotionAuthority | null;
|
|
402
|
+
}): Promise<KnowledgePromotionRequest>;
|
|
403
|
+
private requirePolicy;
|
|
404
|
+
private draftRequest;
|
|
405
|
+
private authorize;
|
|
406
|
+
private claimAuthority;
|
|
407
|
+
private sourceIsCurrent;
|
|
408
|
+
private recordCandidateOutcome;
|
|
409
|
+
}
|
|
410
|
+
export {};
|