@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
package/dist/cli.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ interface CliIo {
|
|
|
7
7
|
stderr?: {
|
|
8
8
|
write(chunk: string): unknown;
|
|
9
9
|
};
|
|
10
|
+
/** Stops a long-running command such as web:serve (besides SIGINT/SIGTERM). */
|
|
11
|
+
signal?: AbortSignal;
|
|
10
12
|
}
|
|
11
13
|
export declare function runCli(argv?: string[], io?: CliIo): Promise<number>;
|
|
12
14
|
export declare function isCliEntrypoint(moduleUrl: string, invokedPath: string | undefined): boolean;
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createPortableGraph, portableGraphDigest } from './portable-graph.js';
|
|
3
3
|
import { createOrganizationGraphConfig, createOrganizationGraphClient } from './organization-graph.js';
|
|
4
|
+
import { listLocalMemories, memoryListJson, registerSelectedMemories, registrationPreviewJson, renderMemoryList, renderRegistrationPreview, renderRegistrationResult, selectLocalMemories } from './personal-memory-handover.js';
|
|
4
5
|
import { constants, realpathSync } from 'node:fs';
|
|
5
6
|
import { access, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
6
7
|
import { delimiter, dirname, isAbsolute, join } from 'node:path';
|
|
@@ -19,6 +20,8 @@ import { buildProjectRegistrationPlan, parseProjectSource, parseProjectStakehold
|
|
|
19
20
|
import { renderGuidedFirstRun } from './guided-onboarding.js';
|
|
20
21
|
import { blockedJudgmentOutput, processJudgmentHook } from './judgment-host.js';
|
|
21
22
|
import { applyCanonicalWrites, buildCanonicalEdge } from './canonical-edge-builder.js';
|
|
23
|
+
import { defaultJudgmentJournalRoot } from './judgment-value-proof-review.js';
|
|
24
|
+
import { createLocalWebHost, LOCAL_WEB_DEFAULT_PORT } from './local-web-host.js';
|
|
22
25
|
export async function runCli(argv = process.argv.slice(2), io = process) {
|
|
23
26
|
const parsed = parseArgs(argv);
|
|
24
27
|
try {
|
|
@@ -41,6 +44,27 @@ export async function runCli(argv = process.argv.slice(2), io = process) {
|
|
|
41
44
|
sourceFilesUnchanged: true, graphId: config.graphId }) + '\n');
|
|
42
45
|
return 0;
|
|
43
46
|
}
|
|
47
|
+
case 'graph:bundles': {
|
|
48
|
+
const config = createOrganizationGraphConfig();
|
|
49
|
+
if (!config)
|
|
50
|
+
throw new Error('graph:bundles requires all BRAINBASE_ORGANIZATION_* settings');
|
|
51
|
+
const format = first(parsed, 'format') ?? 'text';
|
|
52
|
+
if (format !== 'text' && format !== 'json')
|
|
53
|
+
throw new Error('graph:bundles --format must be text or json');
|
|
54
|
+
const list = await createOrganizationGraphClient(config).listPortableGraphs();
|
|
55
|
+
if (format === 'json')
|
|
56
|
+
write(io, `${JSON.stringify(list, null, 2)}\n`);
|
|
57
|
+
else if (list.bundles.length === 0)
|
|
58
|
+
write(io, 'No Graph bundles have been uploaded to this organization yet.\n');
|
|
59
|
+
else
|
|
60
|
+
write(io, list.bundles.map((entry) => `${entry.createdAt} ${entry.projectCode} ${entry.graphId} ${entry.digest}\n`).join('')
|
|
61
|
+
+ (list.truncated ? `Only the newest ${list.bundles.length} bundle(s) are shown.\n` : ''));
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
case 'memory:list':
|
|
65
|
+
return await memoryList(parsed, io);
|
|
66
|
+
case 'memory:register':
|
|
67
|
+
return await memoryRegister(parsed, io);
|
|
44
68
|
case 'onboard:init':
|
|
45
69
|
return await onboardInit(parsed, io);
|
|
46
70
|
case 'onboard:seed':
|
|
@@ -86,6 +110,10 @@ export async function runCli(argv = process.argv.slice(2), io = process) {
|
|
|
86
110
|
return await judgmentInstall(parsed, io);
|
|
87
111
|
case 'doctor':
|
|
88
112
|
return await doctor(parsed, io);
|
|
113
|
+
case 'web:serve':
|
|
114
|
+
case 'review:serve':
|
|
115
|
+
// review:serve is kept as an alias of the same local Web host.
|
|
116
|
+
return await webServe(parsed, io, parsed.command);
|
|
89
117
|
case 'mcp':
|
|
90
118
|
await import('./index.js');
|
|
91
119
|
return 0;
|
|
@@ -175,6 +203,36 @@ async function readHookStdin(input) {
|
|
|
175
203
|
text += typeof chunk === 'string' ? chunk : Buffer.from(chunk).toString('utf8');
|
|
176
204
|
return text;
|
|
177
205
|
}
|
|
206
|
+
function textOrJsonFormat(parsed, command) {
|
|
207
|
+
const format = first(parsed, 'format') ?? 'text';
|
|
208
|
+
if (format !== 'text' && format !== 'json')
|
|
209
|
+
throw new Error(`${command} --format must be text or json`);
|
|
210
|
+
return format;
|
|
211
|
+
}
|
|
212
|
+
async function memoryList(parsed, io) {
|
|
213
|
+
const format = textOrJsonFormat(parsed, 'memory:list');
|
|
214
|
+
const memories = await listLocalMemories(first(parsed, 'dir'));
|
|
215
|
+
write(io, format === 'json' ? `${JSON.stringify(memoryListJson(memories), null, 2)}\n` : renderMemoryList(memories));
|
|
216
|
+
return 0;
|
|
217
|
+
}
|
|
218
|
+
async function memoryRegister(parsed, io) {
|
|
219
|
+
const format = textOrJsonFormat(parsed, 'memory:register');
|
|
220
|
+
const ids = parsed.values.get('id') ?? [];
|
|
221
|
+
if (ids.length === 0)
|
|
222
|
+
throw new Error('memory:register requires at least one --id <id> (see brainbase memory:list)');
|
|
223
|
+
const dataDir = first(parsed, 'dir');
|
|
224
|
+
if (!parsed.flags.has('write')) {
|
|
225
|
+
const selected = selectLocalMemories(await listLocalMemories(dataDir), ids);
|
|
226
|
+
write(io, format === 'json' ? `${JSON.stringify(registrationPreviewJson(selected), null, 2)}\n` : renderRegistrationPreview(selected));
|
|
227
|
+
return 0;
|
|
228
|
+
}
|
|
229
|
+
const config = createOrganizationGraphConfig();
|
|
230
|
+
if (!config)
|
|
231
|
+
throw new Error('memory:register --write requires all BRAINBASE_ORGANIZATION_* settings; nothing was sent');
|
|
232
|
+
const result = await registerSelectedMemories({ dataDir, ids, organization: { url: config.url, token: config.token } });
|
|
233
|
+
write(io, format === 'json' ? `${JSON.stringify({ status: 'registered', ...result }, null, 2)}\n` : renderRegistrationResult(result));
|
|
234
|
+
return 0;
|
|
235
|
+
}
|
|
178
236
|
async function onboardInit(parsed, io) {
|
|
179
237
|
const dataDir = resolveDataDir(first(parsed, 'dir'));
|
|
180
238
|
await initializePersonalOs(dataDir);
|
|
@@ -976,6 +1034,50 @@ async function doctor(parsed, io) {
|
|
|
976
1034
|
function graphDiagnosisExitCode(status) {
|
|
977
1035
|
return status === 'invalid' || status === 'unavailable' || status === 'migration_required' ? 1 : 0;
|
|
978
1036
|
}
|
|
1037
|
+
async function webServe(parsed, io, command) {
|
|
1038
|
+
const dataDir = resolveDataDir(first(parsed, 'dir'));
|
|
1039
|
+
const journalRoot = first(parsed, 'journal')
|
|
1040
|
+
?? process.env.BRAINBASE_JUDGMENT_JOURNAL_DIR
|
|
1041
|
+
?? defaultJudgmentJournalRoot(dataDir);
|
|
1042
|
+
const port = Number(first(parsed, 'port') ?? String(LOCAL_WEB_DEFAULT_PORT));
|
|
1043
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535) {
|
|
1044
|
+
throw new Error(`${command} requires --port to be an integer between 0 and 65535`);
|
|
1045
|
+
}
|
|
1046
|
+
const { server } = createLocalWebHost({ dataDir, journalRoot });
|
|
1047
|
+
await new Promise((resolveListen, rejectListen) => {
|
|
1048
|
+
server.once('error', rejectListen);
|
|
1049
|
+
server.listen(port, '127.0.0.1', () => resolveListen());
|
|
1050
|
+
});
|
|
1051
|
+
const address = server.address();
|
|
1052
|
+
const actualPort = typeof address === 'object' && address ? address.port : port;
|
|
1053
|
+
const origin = `http://127.0.0.1:${actualPort}`;
|
|
1054
|
+
write(io, [
|
|
1055
|
+
`Brainbase: ${origin}/`,
|
|
1056
|
+
`- 今日(判断の見返し): ${origin}/#today`,
|
|
1057
|
+
`- 目的と現状: ${origin}/#objectives`,
|
|
1058
|
+
`- プロジェクトと関係者: ${origin}/#projects`,
|
|
1059
|
+
`- 情報と関係: ${origin}/#graph`,
|
|
1060
|
+
`データ: ${dataDir}`,
|
|
1061
|
+
`判断journal: ${journalRoot}`,
|
|
1062
|
+
'終了: Ctrl+C',
|
|
1063
|
+
''
|
|
1064
|
+
].join('\n'));
|
|
1065
|
+
await new Promise((resolveClose) => {
|
|
1066
|
+
const stop = () => {
|
|
1067
|
+
process.off('SIGINT', stop);
|
|
1068
|
+
process.off('SIGTERM', stop);
|
|
1069
|
+
io.signal?.removeEventListener('abort', stop);
|
|
1070
|
+
server.close(() => resolveClose());
|
|
1071
|
+
};
|
|
1072
|
+
process.once('SIGINT', stop);
|
|
1073
|
+
process.once('SIGTERM', stop);
|
|
1074
|
+
if (io.signal?.aborted)
|
|
1075
|
+
stop();
|
|
1076
|
+
else
|
|
1077
|
+
io.signal?.addEventListener('abort', stop, { once: true });
|
|
1078
|
+
});
|
|
1079
|
+
return 0;
|
|
1080
|
+
}
|
|
979
1081
|
function parseArgs(argv) {
|
|
980
1082
|
const [firstToken, ...remaining] = argv;
|
|
981
1083
|
const command = firstToken?.startsWith('--') ? undefined : firstToken;
|
|
@@ -1104,10 +1206,15 @@ function usage() {
|
|
|
1104
1206
|
brainbase ontology:show
|
|
1105
1207
|
brainbase ontology:audit [--dir path] [--ontology-version 0.0.0|1.0.0|2.0.0]
|
|
1106
1208
|
brainbase graph:upgrade [--dir path]
|
|
1209
|
+
brainbase graph:bundles [--format text|json]
|
|
1210
|
+
brainbase memory:list [--dir path] [--format text|json]
|
|
1211
|
+
brainbase memory:register --id id [--id id...] [--dir path] [--write] [--format text|json]
|
|
1107
1212
|
brainbase ontology:migrate [--dir path] [--write --expected-input-digest digest]
|
|
1108
1213
|
brainbase judgment:install --target codex [--autonomy-mode off|canary|on] [--autonomy-project code] [--dry-run] [--output path]
|
|
1109
1214
|
brainbase judgment:hook [--autonomy-mode off|canary|on] [--autonomy-project code]
|
|
1110
1215
|
brainbase doctor [--dir path] [--judgment-hooks path]
|
|
1216
|
+
brainbase web:serve [--dir path] [--journal path] [--port n]
|
|
1217
|
+
brainbase review:serve [--dir path] [--journal path] [--port n] (web:serveの別名)
|
|
1111
1218
|
`;
|
|
1112
1219
|
}
|
|
1113
1220
|
function shellArg(value) {
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { FoundationAcl, FoundationEvaluationDescriptor, FoundationScope, ObjectiveCriterion } from './ontology-foundation.js';
|
|
2
|
+
import { type FoundationRef } from './foundation-catalog.js';
|
|
3
|
+
import type { FoundationRevisionStore, FoundationStoreContext } from './foundation-store.js';
|
|
4
|
+
import type { FoundationCatalogRecord } from './types.js';
|
|
5
|
+
import { type JudgmentProblemReferenceProvider, type JudgmentProblemSnapshotAccessContext, type JudgmentProblemSnapshotAccessProvider } from './judgment-problem-snapshot.js';
|
|
6
|
+
/**
|
|
7
|
+
* Evaluation is an evidence record over a pinned Problem. It does not own
|
|
8
|
+
* Objective or Variable definitions and it does not close an OutcomeCase.
|
|
9
|
+
*/
|
|
10
|
+
export declare const COMPANY_OS_EVALUATION_CONTRACT_VERSION: "0.1.0";
|
|
11
|
+
export declare const COMPANY_OS_EVALUATION_RECORD_CATALOG_VERSION: 1;
|
|
12
|
+
export declare const COMPANY_OS_EVALUATION_SIDECAR: "evidence/company-os-evaluation.json";
|
|
13
|
+
export type EvaluationMeasurementStatus = 'observed' | 'missing' | 'not_arrived';
|
|
14
|
+
export type EvaluationJudgmentValidity = 'valid' | 'invalid' | 'indeterminate';
|
|
15
|
+
export type EvaluationResultStatus = 'achieved' | 'not_achieved' | 'indeterminate';
|
|
16
|
+
export type PredictionComparisonStatus = 'matched' | 'missed' | 'indeterminate';
|
|
17
|
+
export type EvaluationScalar = string | number | boolean;
|
|
18
|
+
export interface EvaluationMeasurementDescriptor extends Omit<FoundationEvaluationDescriptor, 'variableRef'> {
|
|
19
|
+
}
|
|
20
|
+
export interface EvaluationConversionProvenance {
|
|
21
|
+
/** Stable evidence or transformation identifier, not a free-form assertion. */
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly description: string;
|
|
24
|
+
}
|
|
25
|
+
export interface EvaluationMeasurementConversion {
|
|
26
|
+
/** The input measurement's exact source definition. */
|
|
27
|
+
readonly sourceRef: FoundationRef;
|
|
28
|
+
/** The exact criterion definition used after the conversion. */
|
|
29
|
+
readonly targetRef: FoundationRef;
|
|
30
|
+
readonly provenance: EvaluationConversionProvenance;
|
|
31
|
+
}
|
|
32
|
+
export interface EvaluationMeasurementInput {
|
|
33
|
+
readonly variableRef: FoundationRef;
|
|
34
|
+
/** The descriptor describes the effective (possibly converted) definition. */
|
|
35
|
+
readonly descriptor: EvaluationMeasurementDescriptor;
|
|
36
|
+
readonly status: EvaluationMeasurementStatus;
|
|
37
|
+
readonly value?: EvaluationScalar;
|
|
38
|
+
readonly recordedAt: string;
|
|
39
|
+
readonly evidenceRef?: string;
|
|
40
|
+
readonly conversion?: EvaluationMeasurementConversion;
|
|
41
|
+
}
|
|
42
|
+
export interface EvaluationMeasurement extends EvaluationMeasurementInput {
|
|
43
|
+
readonly effectiveVariableRef: FoundationRef;
|
|
44
|
+
}
|
|
45
|
+
export interface JudgmentValidityInput {
|
|
46
|
+
readonly status: EvaluationJudgmentValidity;
|
|
47
|
+
readonly basis: string;
|
|
48
|
+
readonly evidenceRefs?: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
export interface JudgmentValidity extends JudgmentValidityInput {
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A port owned by OSS and implemented by an OutcomeCase provider. The port
|
|
54
|
+
* deliberately has a read operation only: closure, approval, and case
|
|
55
|
+
* mutation remain outside this repository.
|
|
56
|
+
*/
|
|
57
|
+
export interface OutcomeCaseReference {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly revision?: string;
|
|
60
|
+
readonly digest?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface OutcomeCaseCanonicalReference {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly revision: string;
|
|
65
|
+
readonly digest: string;
|
|
66
|
+
}
|
|
67
|
+
export type OutcomeCaseOwnerUnknownReason = 'not_recorded' | 'legacy_untyped' | 'source_unavailable';
|
|
68
|
+
export interface OutcomeCaseEntityReference {
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly type: string;
|
|
71
|
+
readonly revision?: string;
|
|
72
|
+
readonly digest?: string;
|
|
73
|
+
}
|
|
74
|
+
export type OutcomeCaseOwnerReference = {
|
|
75
|
+
readonly status: 'typed';
|
|
76
|
+
readonly ref: OutcomeCaseEntityReference;
|
|
77
|
+
} | {
|
|
78
|
+
readonly status: 'unknown';
|
|
79
|
+
readonly reason: OutcomeCaseOwnerUnknownReason;
|
|
80
|
+
};
|
|
81
|
+
export type OutcomeCaseConditionValue = string | number | boolean | null | readonly OutcomeCaseConditionValue[] | {
|
|
82
|
+
readonly [key: string]: OutcomeCaseConditionValue;
|
|
83
|
+
};
|
|
84
|
+
export type OutcomeCaseConditions = Readonly<Record<string, OutcomeCaseConditionValue>>;
|
|
85
|
+
/**
|
|
86
|
+
* Trusted source-owned metadata returned with an OutcomeCase read. The
|
|
87
|
+
* adapter must use this projection when creating a receipt link; caller
|
|
88
|
+
* supplied receipt state, owners, or conditions are lookup input only.
|
|
89
|
+
*/
|
|
90
|
+
export interface OutcomeCaseCanonicalSource {
|
|
91
|
+
readonly state: string;
|
|
92
|
+
readonly owner_refs: readonly OutcomeCaseOwnerReference[];
|
|
93
|
+
readonly conditions?: OutcomeCaseConditions;
|
|
94
|
+
}
|
|
95
|
+
export interface OutcomeCaseRead {
|
|
96
|
+
readonly reference: OutcomeCaseCanonicalReference;
|
|
97
|
+
/** Current source-owned identity/state projection, checked at read time. */
|
|
98
|
+
readonly source: OutcomeCaseCanonicalSource;
|
|
99
|
+
/** Current ACL, evaluated at read time. */
|
|
100
|
+
readonly acl: FoundationAcl;
|
|
101
|
+
readonly scope: FoundationScope;
|
|
102
|
+
}
|
|
103
|
+
export interface EvaluationAccessContext extends JudgmentProblemSnapshotAccessContext {
|
|
104
|
+
readonly scope?: FoundationScope;
|
|
105
|
+
}
|
|
106
|
+
export interface OutcomeCasePort {
|
|
107
|
+
read(reference: OutcomeCaseReference, actor: EvaluationAccessContext): Promise<OutcomeCaseRead>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Exact definition read used by evaluation. A caller cannot supply an
|
|
111
|
+
* Objective or criterion body as an evaluation input; this port resolves the
|
|
112
|
+
* requested revision and verifies its digest from the canonical store.
|
|
113
|
+
*/
|
|
114
|
+
export interface FoundationDefinitionLoadPort {
|
|
115
|
+
readExact(reference: FoundationRef, context: FoundationStoreContext): Promise<FoundationCatalogRecord | null>;
|
|
116
|
+
}
|
|
117
|
+
export declare function createFoundationDefinitionLoadPort(store: Pick<FoundationRevisionStore, 'read'>): FoundationDefinitionLoadPort;
|
|
118
|
+
export interface CriterionEvaluation {
|
|
119
|
+
readonly criterionIndex: number;
|
|
120
|
+
readonly variableRef: FoundationRef;
|
|
121
|
+
readonly operator: ObjectiveCriterion['operator'];
|
|
122
|
+
readonly target?: string | number | boolean;
|
|
123
|
+
readonly status: EvaluationResultStatus;
|
|
124
|
+
readonly reason: string;
|
|
125
|
+
}
|
|
126
|
+
export interface PredictionComparison {
|
|
127
|
+
readonly criterionIndex: number;
|
|
128
|
+
readonly variableRef: FoundationRef;
|
|
129
|
+
readonly status: PredictionComparisonStatus;
|
|
130
|
+
readonly reason: string;
|
|
131
|
+
readonly predictionStatus?: EvaluationMeasurementStatus;
|
|
132
|
+
readonly actualStatus?: EvaluationMeasurementStatus;
|
|
133
|
+
readonly predictionValue?: EvaluationScalar;
|
|
134
|
+
readonly actualValue?: EvaluationScalar;
|
|
135
|
+
}
|
|
136
|
+
export interface CompanyOsEvaluationRecord {
|
|
137
|
+
readonly version: typeof COMPANY_OS_EVALUATION_RECORD_CATALOG_VERSION;
|
|
138
|
+
readonly id: string;
|
|
139
|
+
readonly snapshot: {
|
|
140
|
+
readonly snapshotId: string;
|
|
141
|
+
readonly problemId: string;
|
|
142
|
+
readonly revision: string;
|
|
143
|
+
readonly digest: string;
|
|
144
|
+
};
|
|
145
|
+
readonly objectiveRef: FoundationRef;
|
|
146
|
+
readonly outcomeCaseRef: OutcomeCaseCanonicalReference;
|
|
147
|
+
readonly predictions: readonly EvaluationMeasurement[];
|
|
148
|
+
readonly actuals: readonly EvaluationMeasurement[];
|
|
149
|
+
readonly criteria: readonly CriterionEvaluation[];
|
|
150
|
+
readonly predictionComparisons: readonly PredictionComparison[];
|
|
151
|
+
readonly achievement: EvaluationResultStatus;
|
|
152
|
+
readonly judgmentAtTimeValidity: JudgmentValidity;
|
|
153
|
+
readonly evaluatedAt: string;
|
|
154
|
+
}
|
|
155
|
+
export interface EvaluateCompanyOsProblemRequest {
|
|
156
|
+
readonly id: string;
|
|
157
|
+
readonly snapshot: {
|
|
158
|
+
readonly root: string;
|
|
159
|
+
readonly snapshotId?: string;
|
|
160
|
+
readonly problemId?: string;
|
|
161
|
+
readonly revision?: string;
|
|
162
|
+
readonly accessProvider?: JudgmentProblemSnapshotAccessProvider;
|
|
163
|
+
readonly referenceProvider: JudgmentProblemReferenceProvider;
|
|
164
|
+
};
|
|
165
|
+
readonly access: EvaluationAccessContext;
|
|
166
|
+
readonly outcomeCase: OutcomeCaseReference;
|
|
167
|
+
readonly predictions: readonly EvaluationMeasurementInput[];
|
|
168
|
+
readonly actuals: readonly EvaluationMeasurementInput[];
|
|
169
|
+
readonly judgmentAtTimeValidity: JudgmentValidityInput;
|
|
170
|
+
readonly evaluatedAt: string;
|
|
171
|
+
}
|
|
172
|
+
export interface CompanyOsEvaluationStore {
|
|
173
|
+
evaluate(request: EvaluateCompanyOsProblemRequest): Promise<CompanyOsEvaluationRecord>;
|
|
174
|
+
read(id: string, access: EvaluationAccessContext): Promise<CompanyOsEvaluationRecord | null>;
|
|
175
|
+
list(access: EvaluationAccessContext): Promise<readonly CompanyOsEvaluationRecord[]>;
|
|
176
|
+
}
|
|
177
|
+
export interface CompanyOsEvaluationStoreOptions {
|
|
178
|
+
readonly dataDir: string;
|
|
179
|
+
readonly foundation: FoundationDefinitionLoadPort;
|
|
180
|
+
readonly outcomeCase: OutcomeCasePort;
|
|
181
|
+
/**
|
|
182
|
+
* Resolver used when a stored evaluation is read back. The evaluation
|
|
183
|
+
* record only stores a snapshot reference, so reads must resolve that exact
|
|
184
|
+
* snapshot again under the provider's current ACL/digest checks.
|
|
185
|
+
*/
|
|
186
|
+
readonly snapshotReferenceProvider: JudgmentProblemReferenceProvider;
|
|
187
|
+
}
|
|
188
|
+
export type CompanyOsEvaluationErrorCode = 'invalid_input' | 'not_found' | 'authorization_denied' | 'scope_violation' | 'integrity_mismatch' | 'incompatible_measurement' | 'revision_conflict' | 'unsupported_graph' | 'corrupt_record' | 'readback_mismatch';
|
|
189
|
+
export declare class CompanyOsEvaluationError extends Error {
|
|
190
|
+
readonly code: CompanyOsEvaluationErrorCode;
|
|
191
|
+
constructor(code: CompanyOsEvaluationErrorCode, message: string);
|
|
192
|
+
}
|
|
193
|
+
export declare function createCompanyOsEvaluationStore(options: CompanyOsEvaluationStoreOptions): CompanyOsEvaluationStore;
|