@unson/brainbase-mcp 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/foundation/graph-history.sql +634 -0
- package/contracts/judgment-value-proof/schema.json +43 -1
- package/dist/canonical-task-contract.d.ts +9 -0
- package/dist/canonical-task-contract.js +39 -0
- package/dist/canonical-task-principal.d.ts +16 -0
- package/dist/canonical-task-principal.js +36 -0
- package/dist/canonical-task-service.d.ts +251 -0
- package/dist/canonical-task-service.js +820 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +107 -0
- package/dist/company-os-evaluation.d.ts +193 -0
- package/dist/company-os-evaluation.js +1150 -0
- package/dist/company-os-impact-review.d.ts +248 -0
- package/dist/company-os-impact-review.js +663 -0
- package/dist/company-os-learning-adoption.d.ts +288 -0
- package/dist/company-os-learning-adoption.js +944 -0
- package/dist/company-os-objectives.d.ts +63 -0
- package/dist/company-os-objectives.js +234 -0
- package/dist/company-os-receipt-adapter.d.ts +109 -0
- package/dist/company-os-receipt-adapter.js +636 -0
- package/dist/constraint-exception-store.d.ts +23 -0
- package/dist/constraint-exception-store.js +108 -0
- package/dist/constraint-resolution.d.ts +175 -0
- package/dist/constraint-resolution.js +922 -0
- package/dist/decision-adapter.d.ts +145 -0
- package/dist/decision-adapter.js +586 -0
- package/dist/durable-wait-http.d.ts +51 -0
- package/dist/durable-wait-http.js +497 -0
- package/dist/durable-waits.d.ts +234 -0
- package/dist/durable-waits.js +944 -0
- package/dist/execution-authority-http.d.ts +28 -0
- package/dist/execution-authority-http.js +359 -0
- package/dist/execution-authority.d.ts +201 -0
- package/dist/execution-authority.js +634 -0
- package/dist/foundation-authenticated-tools.d.ts +56 -0
- package/dist/foundation-authenticated-tools.js +347 -0
- package/dist/foundation-catalog.d.ts +26 -0
- package/dist/foundation-catalog.js +206 -0
- package/dist/foundation-constraint-store.d.ts +50 -0
- package/dist/foundation-constraint-store.js +215 -0
- package/dist/foundation-graph-http.d.ts +43 -0
- package/dist/foundation-graph-http.js +243 -0
- package/dist/foundation-graph-write.d.ts +90 -0
- package/dist/foundation-graph-write.js +447 -0
- package/dist/foundation-http.d.ts +90 -0
- package/dist/foundation-http.js +439 -0
- package/dist/foundation-public-provider.d.ts +140 -0
- package/dist/foundation-public-provider.js +192 -0
- package/dist/foundation-store.d.ts +132 -0
- package/dist/foundation-store.js +654 -0
- package/dist/graph-corrections.d.ts +157 -0
- package/dist/graph-corrections.js +620 -0
- package/dist/graph-foundation-reader.d.ts +60 -0
- package/dist/graph-foundation-reader.js +494 -0
- package/dist/graph-retrieval.d.ts +6 -1
- package/dist/graph-revision-reader.d.ts +80 -0
- package/dist/graph-revision-reader.js +246 -0
- package/dist/graph-web-http.d.ts +26 -0
- package/dist/graph-web-http.js +215 -0
- package/dist/graph-web.d.ts +364 -0
- package/dist/graph-web.js +639 -0
- package/dist/judgment-dag-composition.d.ts +224 -0
- package/dist/judgment-dag-composition.js +731 -0
- package/dist/judgment-dag.d.ts +2 -0
- package/dist/judgment-dag.js +1 -0
- package/dist/judgment-problem-snapshot.d.ts +213 -0
- package/dist/judgment-problem-snapshot.js +1073 -0
- package/dist/judgment-value-proof-review.d.ts +166 -0
- package/dist/judgment-value-proof-review.js +437 -0
- package/dist/judgment-value-proof.d.ts +28 -1
- package/dist/judgment-value-proof.js +53 -8
- package/dist/judgment-view-http.d.ts +22 -0
- package/dist/judgment-view-http.js +128 -0
- package/dist/judgment-view.d.ts +222 -0
- package/dist/judgment-view.js +627 -0
- package/dist/knowledge-adapter.d.ts +112 -0
- package/dist/knowledge-adapter.js +691 -0
- package/dist/knowledge-continuation.d.ts +127 -0
- package/dist/knowledge-continuation.js +446 -0
- package/dist/knowledge-lookup.d.ts +178 -0
- package/dist/knowledge-lookup.js +758 -0
- package/dist/local-web-fetch-bridge.d.ts +5 -0
- package/dist/local-web-fetch-bridge.js +37 -0
- package/dist/local-web-host.d.ts +109 -0
- package/dist/local-web-host.js +688 -0
- package/dist/local-web-security.d.ts +25 -0
- package/dist/local-web-security.js +95 -0
- package/dist/ontology-foundation.d.ts +209 -0
- package/dist/ontology-foundation.js +1000 -0
- package/dist/ontology.d.ts +13 -0
- package/dist/ontology.js +14 -0
- package/dist/organization-connection.d.ts +164 -0
- package/dist/organization-connection.js +428 -0
- package/dist/organization-graph.d.ts +15 -0
- package/dist/organization-graph.js +24 -4
- package/dist/personal-knowledge.d.ts +132 -0
- package/dist/personal-knowledge.js +779 -0
- package/dist/personal-memory-handover.d.ts +108 -0
- package/dist/personal-memory-handover.js +369 -0
- package/dist/philosophy-revision-reader.d.ts +85 -0
- package/dist/philosophy-revision-reader.js +241 -0
- package/dist/portable-graph.d.ts +24 -0
- package/dist/portable-graph.js +77 -0
- package/dist/problem-candidates.d.ts +149 -0
- package/dist/problem-candidates.js +898 -0
- package/dist/problem-selection.d.ts +238 -0
- package/dist/problem-selection.js +995 -0
- package/dist/resource-reservation-http.d.ts +31 -0
- package/dist/resource-reservation-http.js +371 -0
- package/dist/resource-reservations.d.ts +221 -0
- package/dist/resource-reservations.js +577 -0
- package/dist/server.d.ts +104 -2
- package/dist/server.js +186 -4
- package/dist/ssot.d.ts +6 -1
- package/dist/ssot.js +63 -5
- package/dist/streamable-http.d.ts +42 -0
- package/dist/streamable-http.js +288 -0
- package/dist/types.d.ts +20 -0
- package/dist/value-proof-review-http.d.ts +25 -0
- package/dist/value-proof-review-http.js +185 -0
- package/dist/world-model.d.ts +199 -0
- package/dist/world-model.js +955 -0
- package/package.json +230 -3
- package/ui/brainbase-tokens.css +56 -0
- package/ui/graph-own-share.js +367 -0
- package/ui/graph-projects-view.css +23 -0
- package/ui/graph-projects-view.js +730 -0
- package/ui/graph-registry-view.css +101 -0
- package/ui/graph-registry-view.js +804 -0
- package/ui/graph-view-shared.css +522 -0
- package/ui/graph-view-shared.js +1227 -0
- package/ui/judgment-view.css +312 -0
- package/ui/judgment-view.js +508 -0
- package/ui/local-web-shell.css +396 -0
- package/ui/local-web-shell.js +378 -0
- package/ui/objective-editor-http-port.js +154 -0
- package/ui/objective-editor.css +286 -0
- package/ui/objective-editor.js +1586 -0
- package/ui/outcome-knowledge.css +50 -14
- package/ui/outcome-knowledge.js +15 -1
- package/ui/outcome-mana.css +91 -14
- package/ui/outcome-mana.js +958 -61
- package/ui/value-proof-review.css +504 -0
- package/ui/value-proof-review.js +1104 -0
- package/ui/workspace-kit.css +485 -0
- package/ui/workspace-kit.js +229 -0
- package/ui/world-model-view.css +188 -0
- package/ui/world-model-view.js +486 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ObjectiveDefinition, VariableDefinition, FoundationRevision, FoundationTimeCondition } from './ontology-foundation.js';
|
|
2
|
+
import type { FoundationRef } from './foundation-catalog.js';
|
|
3
|
+
import type { FoundationCatalogRecord } from './types.js';
|
|
4
|
+
import type { FoundationRevisionStore, FoundationStoreContext } from './foundation-store.js';
|
|
5
|
+
export interface ObjectiveReadinessIssue {
|
|
6
|
+
code: string;
|
|
7
|
+
path: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ObjectiveReadiness {
|
|
11
|
+
/** Whether the definition can be used for a judgment or evaluation setup. */
|
|
12
|
+
ready: boolean;
|
|
13
|
+
/** Definition and referenced Variable issues; observations are not inferred. */
|
|
14
|
+
issues: readonly ObjectiveReadinessIssue[];
|
|
15
|
+
}
|
|
16
|
+
/** The canonical read surface needed to check an Objective and its criteria. */
|
|
17
|
+
export interface ObjectiveReadinessReader {
|
|
18
|
+
read(reference: FoundationRevision, context: FoundationStoreContext): Promise<FoundationCatalogRecord | null>;
|
|
19
|
+
readLatest?(type: 'objective' | 'variable', id: string, context: FoundationStoreContext): Promise<FoundationCatalogRecord | null>;
|
|
20
|
+
}
|
|
21
|
+
export type StoryObjectiveLinkKind = 'contribution' | 'execution_dependency' | 'time_condition';
|
|
22
|
+
export interface StoryObjectiveLinkInput {
|
|
23
|
+
storyId: string;
|
|
24
|
+
storyRevision?: string;
|
|
25
|
+
objective: FoundationRevision;
|
|
26
|
+
linkKind: StoryObjectiveLinkKind;
|
|
27
|
+
timeCondition?: FoundationTimeCondition;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Typed Story 02 operations over the shared foundation revision port.
|
|
31
|
+
*
|
|
32
|
+
* This class owns no storage. It prevents callers from accidentally using a
|
|
33
|
+
* Variable as an Objective, while the generic store remains the one canonical
|
|
34
|
+
* Graph SSOT writer and authorization boundary.
|
|
35
|
+
*/
|
|
36
|
+
export declare class CompanyOsObjectives {
|
|
37
|
+
private readonly store;
|
|
38
|
+
constructor(store: FoundationRevisionStore);
|
|
39
|
+
createObjective(definition: ObjectiveDefinition, context: FoundationStoreContext): Promise<FoundationRef>;
|
|
40
|
+
readObjective(id: string, context: FoundationStoreContext, revision?: string): Promise<FoundationCatalogRecord | null>;
|
|
41
|
+
updateObjective(id: string, expectedRevision: string, next: ObjectiveDefinition, context: FoundationStoreContext): Promise<FoundationRef>;
|
|
42
|
+
checkObjectiveReadiness(id: string, context: FoundationStoreContext, revision?: string): Promise<ObjectiveReadiness>;
|
|
43
|
+
createVariable(definition: VariableDefinition, context: FoundationStoreContext): Promise<FoundationRef>;
|
|
44
|
+
readVariable(id: string, context: FoundationStoreContext, revision?: string): Promise<FoundationCatalogRecord | null>;
|
|
45
|
+
updateVariable(id: string, expectedRevision: string, next: VariableDefinition, context: FoundationStoreContext): Promise<FoundationRef>;
|
|
46
|
+
/** Exposes typed relation persistence without creating a second relation store. */
|
|
47
|
+
addRelation(relation: Parameters<FoundationRevisionStore['addRelation']>[0], context: FoundationStoreContext): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Stores one explicitly typed Story/Objective reference. The relation kind
|
|
50
|
+
* is required by the caller and is never inferred from the Story text.
|
|
51
|
+
* Objective revisions are supplied explicitly so a later Objective update
|
|
52
|
+
* cannot silently rewrite the historical link.
|
|
53
|
+
*/
|
|
54
|
+
linkObjectiveStory(input: StoryObjectiveLinkInput, context: FoundationStoreContext): Promise<void>;
|
|
55
|
+
private readTyped;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Check an Objective and every Variable revision named by its criteria.
|
|
59
|
+
* Both the Objective service and judgment snapshot providers call this
|
|
60
|
+
* function so readiness cannot vary by caller.
|
|
61
|
+
*/
|
|
62
|
+
export declare function checkObjectiveReadiness(reader: ObjectiveReadinessReader, id: string, context: FoundationStoreContext, revision?: string): Promise<ObjectiveReadiness>;
|
|
63
|
+
export declare function createCompanyOsObjectives(store: FoundationRevisionStore): CompanyOsObjectives;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { validateFoundationDefinition } from './ontology-foundation.js';
|
|
2
|
+
/**
|
|
3
|
+
* Typed Story 02 operations over the shared foundation revision port.
|
|
4
|
+
*
|
|
5
|
+
* This class owns no storage. It prevents callers from accidentally using a
|
|
6
|
+
* Variable as an Objective, while the generic store remains the one canonical
|
|
7
|
+
* Graph SSOT writer and authorization boundary.
|
|
8
|
+
*/
|
|
9
|
+
export class CompanyOsObjectives {
|
|
10
|
+
store;
|
|
11
|
+
constructor(store) {
|
|
12
|
+
this.store = store;
|
|
13
|
+
}
|
|
14
|
+
createObjective(definition, context) {
|
|
15
|
+
assertType(definition, 'objective');
|
|
16
|
+
return this.store.create(definition, context);
|
|
17
|
+
}
|
|
18
|
+
readObjective(id, context, revision) {
|
|
19
|
+
return this.readTyped('objective', id, context, revision);
|
|
20
|
+
}
|
|
21
|
+
updateObjective(id, expectedRevision, next, context) {
|
|
22
|
+
assertType(next, 'objective');
|
|
23
|
+
return this.store.update({
|
|
24
|
+
reference: { id, type: 'objective', revision: expectedRevision },
|
|
25
|
+
next,
|
|
26
|
+
expectedRevision
|
|
27
|
+
}, context);
|
|
28
|
+
}
|
|
29
|
+
async checkObjectiveReadiness(id, context, revision) {
|
|
30
|
+
return checkObjectiveReadiness(this.store, id, context, revision);
|
|
31
|
+
}
|
|
32
|
+
createVariable(definition, context) {
|
|
33
|
+
assertType(definition, 'variable');
|
|
34
|
+
return this.store.create(definition, context);
|
|
35
|
+
}
|
|
36
|
+
readVariable(id, context, revision) {
|
|
37
|
+
return this.readTyped('variable', id, context, revision);
|
|
38
|
+
}
|
|
39
|
+
updateVariable(id, expectedRevision, next, context) {
|
|
40
|
+
assertType(next, 'variable');
|
|
41
|
+
return this.store.update({
|
|
42
|
+
reference: { id, type: 'variable', revision: expectedRevision },
|
|
43
|
+
next,
|
|
44
|
+
expectedRevision
|
|
45
|
+
}, context);
|
|
46
|
+
}
|
|
47
|
+
/** Exposes typed relation persistence without creating a second relation store. */
|
|
48
|
+
addRelation(relation, context) {
|
|
49
|
+
return this.store.addRelation(relation, context);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Stores one explicitly typed Story/Objective reference. The relation kind
|
|
53
|
+
* is required by the caller and is never inferred from the Story text.
|
|
54
|
+
* Objective revisions are supplied explicitly so a later Objective update
|
|
55
|
+
* cannot silently rewrite the historical link.
|
|
56
|
+
*/
|
|
57
|
+
linkObjectiveStory(input, context) {
|
|
58
|
+
if (!input || typeof input.storyId !== 'string' || input.storyId.length === 0) {
|
|
59
|
+
throw new TypeError('A Story id is required');
|
|
60
|
+
}
|
|
61
|
+
if (!input.objective || input.objective.type !== 'objective') {
|
|
62
|
+
throw new TypeError('A versioned Objective reference is required');
|
|
63
|
+
}
|
|
64
|
+
const relationByKind = {
|
|
65
|
+
contribution: 'contributes_to',
|
|
66
|
+
execution_dependency: 'execution_depends_on',
|
|
67
|
+
time_condition: 'time_condition'
|
|
68
|
+
};
|
|
69
|
+
return this.addRelation({
|
|
70
|
+
relation: relationByKind[input.linkKind],
|
|
71
|
+
source: {
|
|
72
|
+
id: input.storyId,
|
|
73
|
+
type: 'story',
|
|
74
|
+
...(input.storyRevision === undefined ? {} : { revision: input.storyRevision })
|
|
75
|
+
},
|
|
76
|
+
target: input.objective,
|
|
77
|
+
...(input.timeCondition === undefined ? {} : { timeCondition: input.timeCondition })
|
|
78
|
+
}, context);
|
|
79
|
+
}
|
|
80
|
+
readTyped(type, id, context, revision) {
|
|
81
|
+
if (revision !== undefined) {
|
|
82
|
+
return this.store.read({ id, type, revision }, context);
|
|
83
|
+
}
|
|
84
|
+
return this.store.readLatest(type, id, context);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check an Objective and every Variable revision named by its criteria.
|
|
89
|
+
* Both the Objective service and judgment snapshot providers call this
|
|
90
|
+
* function so readiness cannot vary by caller.
|
|
91
|
+
*/
|
|
92
|
+
export async function checkObjectiveReadiness(reader, id, context, revision) {
|
|
93
|
+
const record = revision === undefined
|
|
94
|
+
? reader.readLatest === undefined ? null : await reader.readLatest('objective', id, context)
|
|
95
|
+
: await reader.read({ id, type: 'objective', revision }, context);
|
|
96
|
+
if (!record) {
|
|
97
|
+
return {
|
|
98
|
+
ready: false,
|
|
99
|
+
issues: [{ code: 'NOT_FOUND', path: 'id', message: `Objective ${id} was not found.` }]
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (record.definition.type !== 'objective') {
|
|
103
|
+
return {
|
|
104
|
+
ready: false,
|
|
105
|
+
issues: [{ code: 'INVALID_OBJECTIVE_REFERENCE', path: 'type', message: `Foundation ${id} is not an Objective.` }]
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const objective = record.definition;
|
|
109
|
+
const issues = validationIssues(objective, 'judgment');
|
|
110
|
+
const criteria = Array.isArray(objective.criteria) ? objective.criteria : [];
|
|
111
|
+
for (const [index, criterion] of criteria.entries()) {
|
|
112
|
+
if (!criterion || typeof criterion !== 'object' || !criterion.variableRef)
|
|
113
|
+
continue;
|
|
114
|
+
if (!isVariableRevisionReference(criterion.variableRef)) {
|
|
115
|
+
issues.push({
|
|
116
|
+
code: 'INVALID_VARIABLE_REFERENCE',
|
|
117
|
+
path: `criteria[${index}].variableRef`,
|
|
118
|
+
message: 'Criterion must reference a Variable with a positive revision.'
|
|
119
|
+
});
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const variable = await reader.read(criterion.variableRef, context);
|
|
123
|
+
if (!variable) {
|
|
124
|
+
issues.push({
|
|
125
|
+
code: 'MISSING_VARIABLE_REVISION',
|
|
126
|
+
path: `criteria[${index}].variableRef`,
|
|
127
|
+
message: `Variable ${criterion.variableRef.id}@${criterion.variableRef.revision} was not found.`
|
|
128
|
+
});
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (variable.definition.type !== 'variable') {
|
|
132
|
+
issues.push({
|
|
133
|
+
code: 'INVALID_VARIABLE_REFERENCE',
|
|
134
|
+
path: `criteria[${index}].variableRef`,
|
|
135
|
+
message: `Criterion ${criterion.variableRef.id}@${criterion.variableRef.revision} is not a Variable.`
|
|
136
|
+
});
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
for (const issue of validationIssues(variable.definition, 'judgment')) {
|
|
140
|
+
issues.push({
|
|
141
|
+
...issue,
|
|
142
|
+
path: `criteria[${index}].variableRef.${issue.path}`
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
issues.push(...criterionCompatibilityIssues(criterion, variable.definition, index));
|
|
146
|
+
issues.push(...criterionPeriodIssues(objective, variable.definition, index));
|
|
147
|
+
}
|
|
148
|
+
return { ready: issues.length === 0, issues };
|
|
149
|
+
}
|
|
150
|
+
export function createCompanyOsObjectives(store) {
|
|
151
|
+
return new CompanyOsObjectives(store);
|
|
152
|
+
}
|
|
153
|
+
function assertType(definition, type) {
|
|
154
|
+
if (!definition || definition.type !== type) {
|
|
155
|
+
throw new TypeError(`Expected a ${type} definition`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function validationIssues(definition, use) {
|
|
159
|
+
try {
|
|
160
|
+
const result = validateFoundationDefinition(definition, { use });
|
|
161
|
+
return result.issues.map((issue) => ({
|
|
162
|
+
code: issue.code,
|
|
163
|
+
path: issue.path,
|
|
164
|
+
message: issue.message
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
return [{
|
|
169
|
+
code: 'INVALID_FIELD',
|
|
170
|
+
path: 'definition',
|
|
171
|
+
message: error instanceof Error ? error.message : String(error)
|
|
172
|
+
}];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function isVariableRevisionReference(value) {
|
|
176
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
177
|
+
return false;
|
|
178
|
+
const candidate = value;
|
|
179
|
+
return candidate.type === 'variable'
|
|
180
|
+
&& typeof candidate.id === 'string'
|
|
181
|
+
&& candidate.id.length > 0
|
|
182
|
+
&& typeof candidate.revision === 'string'
|
|
183
|
+
&& /^[1-9]\d*$/.test(candidate.revision);
|
|
184
|
+
}
|
|
185
|
+
function criterionCompatibilityIssues(criterion, variable, index) {
|
|
186
|
+
const path = `criteria[${index}]`;
|
|
187
|
+
if (criterion.target === undefined)
|
|
188
|
+
return [];
|
|
189
|
+
if (criterion.operator === 'at_least' || criterion.operator === 'at_most') {
|
|
190
|
+
if (variable.valueKind !== 'number' || typeof criterion.target !== 'number' || !Number.isFinite(criterion.target)) {
|
|
191
|
+
return [{
|
|
192
|
+
code: 'CRITERION_TYPE_MISMATCH',
|
|
193
|
+
path,
|
|
194
|
+
message: `${criterion.operator} requires a numeric Variable and a finite number target.`
|
|
195
|
+
}];
|
|
196
|
+
}
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
if (criterion.operator !== 'equals')
|
|
200
|
+
return [];
|
|
201
|
+
const targetMatches = variable.valueKind === 'number'
|
|
202
|
+
? typeof criterion.target === 'number' && Number.isFinite(criterion.target)
|
|
203
|
+
: variable.valueKind === 'boolean'
|
|
204
|
+
? typeof criterion.target === 'boolean'
|
|
205
|
+
: (variable.valueKind === 'string' || variable.valueKind === 'state') && typeof criterion.target === 'string';
|
|
206
|
+
if (!targetMatches) {
|
|
207
|
+
return [{
|
|
208
|
+
code: 'CRITERION_TYPE_MISMATCH',
|
|
209
|
+
path,
|
|
210
|
+
message: `equals target type does not match Variable valueKind ${variable.valueKind}.`
|
|
211
|
+
}];
|
|
212
|
+
}
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
function criterionPeriodIssues(objective, variable, index) {
|
|
216
|
+
const objectiveFrom = Date.parse(objective.evaluationPeriod?.from ?? '');
|
|
217
|
+
const objectiveUntil = Date.parse(objective.evaluationPeriod?.until ?? '');
|
|
218
|
+
const variableFrom = Date.parse(variable.scope?.validFrom ?? '');
|
|
219
|
+
const variableUntil = variable.scope?.validUntil === undefined
|
|
220
|
+
? Number.POSITIVE_INFINITY
|
|
221
|
+
: Date.parse(variable.scope.validUntil);
|
|
222
|
+
if (!Number.isFinite(objectiveFrom) || !Number.isFinite(objectiveUntil)
|
|
223
|
+
|| !Number.isFinite(variableFrom)
|
|
224
|
+
|| (variable.scope?.validUntil !== undefined && !Number.isFinite(variableUntil))) {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
if (variableFrom <= objectiveFrom && variableUntil >= objectiveUntil)
|
|
228
|
+
return [];
|
|
229
|
+
return [{
|
|
230
|
+
code: 'CRITERION_PERIOD_MISMATCH',
|
|
231
|
+
path: `criteria[${index}].variableRef`,
|
|
232
|
+
message: `Variable ${variable.id}@${variable.revision} does not cover the Objective evaluation period.`
|
|
233
|
+
}];
|
|
234
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { FoundationScope } from './ontology-foundation.js';
|
|
2
|
+
import type { OutcomeCasePort } from './company-os-evaluation.js';
|
|
3
|
+
export declare const COMPANY_OS_RECEIPT_ADAPTER_CONTRACT_VERSION: "0.1.1";
|
|
4
|
+
export declare const COMPANY_OS_RECEIPT_LINK_CATALOG_VERSION: 2;
|
|
5
|
+
export declare const COMPANY_OS_RECEIPT_LINK_SIDECAR: "evidence/company-os-receipt-links.json";
|
|
6
|
+
export type ReceiptSourceKind = 'run_receipt' | 'outcome_case' | 'meeting_context_receipt' | 'decision_event';
|
|
7
|
+
export type ReceiptUnknownOwnerReason = 'not_recorded' | 'legacy_untyped' | 'source_unavailable';
|
|
8
|
+
export interface ReceiptEntityReference {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly type: string;
|
|
11
|
+
readonly revision?: string;
|
|
12
|
+
readonly digest?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ReceiptTypedOwnerReference {
|
|
15
|
+
readonly status: 'typed';
|
|
16
|
+
readonly ref: ReceiptEntityReference;
|
|
17
|
+
}
|
|
18
|
+
export interface ReceiptUnknownOwnerReference {
|
|
19
|
+
readonly status: 'unknown';
|
|
20
|
+
readonly reason: ReceiptUnknownOwnerReason;
|
|
21
|
+
}
|
|
22
|
+
export type ReceiptOwnerReference = ReceiptTypedOwnerReference | ReceiptUnknownOwnerReference;
|
|
23
|
+
export type ReceiptSourceConditionValue = string | number | boolean | null | readonly ReceiptSourceConditionValue[] | {
|
|
24
|
+
readonly [key: string]: ReceiptSourceConditionValue;
|
|
25
|
+
};
|
|
26
|
+
export type ReceiptSourceConditions = Readonly<Record<string, ReceiptSourceConditionValue>>;
|
|
27
|
+
/**
|
|
28
|
+
* The source's original identity and state. `hash: null` means the source
|
|
29
|
+
* did not record a hash; the adapter never computes one as a replacement.
|
|
30
|
+
*/
|
|
31
|
+
export interface ReceiptSourceReference {
|
|
32
|
+
readonly kind: ReceiptSourceKind;
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly revision?: string;
|
|
35
|
+
readonly hash: string | null;
|
|
36
|
+
readonly state: string;
|
|
37
|
+
readonly owner_refs: readonly ReceiptOwnerReference[];
|
|
38
|
+
/** Optional source-owned conditions that are part of the stable identity. */
|
|
39
|
+
readonly conditions?: ReceiptSourceConditions;
|
|
40
|
+
}
|
|
41
|
+
export type ReceiptJudgmentReferenceKind = 'problem' | 'objective' | 'model' | 'constraint' | 'dag' | 'decision' | 'evaluation' | 'evidence';
|
|
42
|
+
export interface ReceiptJudgmentReference {
|
|
43
|
+
readonly kind: ReceiptJudgmentReferenceKind;
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly revision?: string;
|
|
46
|
+
readonly digest?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ReceiptAccessContext {
|
|
49
|
+
/** Identity resolved by a trusted caller boundary. */
|
|
50
|
+
readonly principal: string;
|
|
51
|
+
readonly scope?: FoundationScope;
|
|
52
|
+
}
|
|
53
|
+
/** A source-owner read port. It must enforce its current ACL before returning. */
|
|
54
|
+
export interface ReceiptSourcePort {
|
|
55
|
+
read(reference: ReceiptSourceReference, access: ReceiptAccessContext): Promise<ReceiptSourceProjection | null>;
|
|
56
|
+
}
|
|
57
|
+
export interface ReceiptSourceProjection {
|
|
58
|
+
/** Current source identity/state; the stored link remains immutable. */
|
|
59
|
+
readonly reference: ReceiptSourceReference;
|
|
60
|
+
}
|
|
61
|
+
export interface ReceiptLinkRequest {
|
|
62
|
+
readonly id: string;
|
|
63
|
+
readonly source: ReceiptSourceReference;
|
|
64
|
+
readonly judgment_refs: readonly ReceiptJudgmentReference[];
|
|
65
|
+
readonly recorded_at: string;
|
|
66
|
+
readonly access: ReceiptAccessContext;
|
|
67
|
+
}
|
|
68
|
+
export interface ReceiptLinkRecord {
|
|
69
|
+
readonly version: typeof COMPANY_OS_RECEIPT_LINK_CATALOG_VERSION;
|
|
70
|
+
readonly id: string;
|
|
71
|
+
/** The source reference captured at link time, not a mutable source copy. */
|
|
72
|
+
readonly source: ReceiptSourceReference;
|
|
73
|
+
/** Digest of the immutable source snapshot; source.hash remains source-owned metadata. */
|
|
74
|
+
readonly source_digest: string;
|
|
75
|
+
readonly judgment_refs: readonly ReceiptJudgmentReference[];
|
|
76
|
+
readonly recorded_at: string;
|
|
77
|
+
/** These statuses are intentionally not derived from source execution state. */
|
|
78
|
+
readonly objective_status: 'unrecorded';
|
|
79
|
+
readonly judgment_quality_status: 'unrecorded';
|
|
80
|
+
}
|
|
81
|
+
export interface ReceiptSourceRead {
|
|
82
|
+
readonly reference: ReceiptSourceReference;
|
|
83
|
+
readonly state_changed: boolean;
|
|
84
|
+
}
|
|
85
|
+
export interface ReceiptProjection {
|
|
86
|
+
readonly link: ReceiptLinkRecord;
|
|
87
|
+
readonly source_read: ReceiptSourceRead;
|
|
88
|
+
}
|
|
89
|
+
export interface ReceiptAdapterPort {
|
|
90
|
+
link(request: ReceiptLinkRequest): Promise<ReceiptProjection>;
|
|
91
|
+
read(id: string, access: ReceiptAccessContext): Promise<ReceiptProjection | null>;
|
|
92
|
+
list(access: ReceiptAccessContext): Promise<readonly ReceiptProjection[]>;
|
|
93
|
+
}
|
|
94
|
+
export interface CompanyOsReceiptAdapterOptions {
|
|
95
|
+
readonly dataDir: string;
|
|
96
|
+
readonly sourcePorts: Partial<Record<ReceiptSourceKind, ReceiptSourcePort>>;
|
|
97
|
+
}
|
|
98
|
+
export type ReceiptAdapterErrorCode = 'invalid_input' | 'not_found' | 'authorization_denied' | 'source_unavailable' | 'source_not_found' | 'integrity_mismatch' | 'revision_conflict' | 'corrupt_record' | 'readback_mismatch';
|
|
99
|
+
export declare class CompanyOsReceiptAdapterError extends Error {
|
|
100
|
+
readonly code: ReceiptAdapterErrorCode;
|
|
101
|
+
constructor(code: ReceiptAdapterErrorCode, message: string);
|
|
102
|
+
}
|
|
103
|
+
export declare function createCompanyOsReceiptAdapter(options: CompanyOsReceiptAdapterOptions): ReceiptAdapterPort;
|
|
104
|
+
/**
|
|
105
|
+
* Reuses the existing read-only OutcomeCasePort without importing any
|
|
106
|
+
* organization runtime. OutcomeCase closure and evaluation remain owned by
|
|
107
|
+
* that provider; this adapter only exposes a source projection.
|
|
108
|
+
*/
|
|
109
|
+
export declare function createOutcomeCaseReceiptSourcePort(port: OutcomeCasePort): ReceiptSourcePort;
|