@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
|
@@ -17,6 +17,25 @@ function outcomeStatusLabel(status) {
|
|
|
17
17
|
return '結果未確認';
|
|
18
18
|
return '成果確認の対象外';
|
|
19
19
|
}
|
|
20
|
+
const BASIS_LAYER_LABELS = {
|
|
21
|
+
philosophy: '大切にすること',
|
|
22
|
+
objective: '目的',
|
|
23
|
+
world_model: '現状と見通し',
|
|
24
|
+
method: '判断方法',
|
|
25
|
+
constraint: '守る条件',
|
|
26
|
+
other: 'その他'
|
|
27
|
+
};
|
|
28
|
+
function basisLabel(entry) {
|
|
29
|
+
return entry.layer ? `[${BASIS_LAYER_LABELS[entry.layer]}] ${entry.application}` : entry.application;
|
|
30
|
+
}
|
|
31
|
+
function inheritanceLine(inheritance) {
|
|
32
|
+
if (!inheritance || inheritance.sources.length === 0)
|
|
33
|
+
return null;
|
|
34
|
+
const sources = inheritance.sources.map((source) => source.label.trim()).join(' / ');
|
|
35
|
+
const same = inheritance.same_conditions.length > 0 ? `。今回も同じ: ${inheritance.same_conditions.join('、')}` : '';
|
|
36
|
+
const rechecked = inheritance.rechecked_conditions.length > 0 ? `。今回だけ確認: ${inheritance.rechecked_conditions.join('、')}` : '';
|
|
37
|
+
return `引き継ぎ: ${sources}${same}${rechecked}`;
|
|
38
|
+
}
|
|
20
39
|
function evidenceLabel(evidence) {
|
|
21
40
|
const label = evidence.label?.trim() || evidence.kind;
|
|
22
41
|
return `${label} (${evidence.status === 'verified' ? '確認済み' : '未確認'})`;
|
|
@@ -57,6 +76,29 @@ export function validateJudgmentValueProof(proof) {
|
|
|
57
76
|
throw new TypeError('outcome_verified requires verified evidence');
|
|
58
77
|
}
|
|
59
78
|
}
|
|
79
|
+
const layers = ['philosophy', 'objective', 'world_model', 'method', 'constraint', 'other'];
|
|
80
|
+
for (const entry of proof.decision.basis) {
|
|
81
|
+
if (entry.layer !== undefined && !layers.includes(entry.layer)) {
|
|
82
|
+
throw new TypeError(`unsupported decision.basis[].layer: ${String(entry.layer)}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const kind = proof.decision.judgment_kind;
|
|
86
|
+
if (kind !== undefined && kind !== null) {
|
|
87
|
+
if (!/^[a-z0-9_]{1,64}$/u.test(kind.key ?? '')) {
|
|
88
|
+
throw new TypeError('decision.judgment_kind.key must be 1-64 lowercase letters, digits or underscores');
|
|
89
|
+
}
|
|
90
|
+
requiredText(kind.label, 'decision.judgment_kind.label');
|
|
91
|
+
}
|
|
92
|
+
const inheritance = proof.decision.inheritance;
|
|
93
|
+
if (inheritance !== undefined && inheritance !== null) {
|
|
94
|
+
for (const source of inheritance.sources) {
|
|
95
|
+
requiredText(source.ref, 'decision.inheritance.sources[].ref');
|
|
96
|
+
requiredText(source.label, 'decision.inheritance.sources[].label');
|
|
97
|
+
}
|
|
98
|
+
if (inheritance.sources.length > 0 && proof.decision.prior_learning_reused === false) {
|
|
99
|
+
throw new TypeError('decision.inheritance.sources contradicts prior_learning_reused=false');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
60
102
|
if (proof.feedback.status !== 'none' && proof.feedback.status !== 'pending'
|
|
61
103
|
&& !proof.feedback.evidence_ref) {
|
|
62
104
|
throw new TypeError('recorded feedback requires evidence_ref');
|
|
@@ -80,17 +122,18 @@ export function placeJudgmentValueProof(proof) {
|
|
|
80
122
|
}
|
|
81
123
|
const behaviorChanged = proof.interruption.resolution === 'continued_without_human';
|
|
82
124
|
const completed = proof.execution.status === 'completed';
|
|
125
|
+
const weeklyDigest = proof.interruption.resolution === 'not_applicable'
|
|
126
|
+
&& proof.feedback.status === 'none'
|
|
127
|
+
&& proof.state !== 'blocked'
|
|
128
|
+
&& proof.outcome.status === 'not_applicable'
|
|
129
|
+
? 'exclude'
|
|
130
|
+
: 'include';
|
|
83
131
|
return {
|
|
84
132
|
agent_progress: behaviorChanged && proof.execution.status === 'executing' ? 'show' : 'silent',
|
|
85
133
|
agent_completion: behaviorChanged && completed ? 'show' : 'silent',
|
|
86
134
|
companion_attention: companionAttention,
|
|
87
|
-
web_surface: 'none',
|
|
88
|
-
weekly_digest:
|
|
89
|
-
&& proof.feedback.status === 'none'
|
|
90
|
-
&& proof.state !== 'blocked'
|
|
91
|
-
&& proof.outcome.status === 'not_applicable'
|
|
92
|
-
? 'exclude'
|
|
93
|
-
: 'include'
|
|
135
|
+
web_surface: weeklyDigest === 'include' ? 'review' : 'none',
|
|
136
|
+
weekly_digest: weeklyDigest
|
|
94
137
|
};
|
|
95
138
|
}
|
|
96
139
|
export function renderJudgmentValueProofProgress(proof) {
|
|
@@ -111,8 +154,9 @@ export function renderJudgmentValueProofCompletion(proof) {
|
|
|
111
154
|
const decision = requiredText(proof.decision.summary ?? '', 'decision.summary');
|
|
112
155
|
const impact = optionalText(proof.decision.work_impact) ?? '確認による中断を避けて作業を継続';
|
|
113
156
|
const basis = proof.decision.basis.length > 0
|
|
114
|
-
? proof.decision.basis.map(
|
|
157
|
+
? proof.decision.basis.map(basisLabel).join(' / ')
|
|
115
158
|
: '適用根拠は未確認';
|
|
159
|
+
const inheritance = inheritanceLine(proof.decision.inheritance);
|
|
116
160
|
const evidence = proof.outcome.evidence_refs.length > 0
|
|
117
161
|
? proof.outcome.evidence_refs.map(evidenceLabel).join(' / ')
|
|
118
162
|
: '成果証跡なし';
|
|
@@ -122,6 +166,7 @@ export function renderJudgmentValueProofCompletion(proof) {
|
|
|
122
166
|
`判断: ${decision}`,
|
|
123
167
|
`仕事への影響: ${impact}`,
|
|
124
168
|
`根拠: ${basis}`,
|
|
169
|
+
...(inheritance ? [inheritance] : []),
|
|
125
170
|
`状態: ${outcomeStatusLabel(proof.outcome.status)}`,
|
|
126
171
|
`証拠: ${evidence}`,
|
|
127
172
|
'修正する場合: 「判断を修正: …」または「次回は確認」と返信'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { type JudgmentViewAccessContext, type JudgmentViewReadPort, type JudgmentViewService } from './judgment-view.js';
|
|
3
|
+
/** Identity supplied by the authenticated host, never by the request body. */
|
|
4
|
+
export interface TrustedJudgmentViewRequestContext extends JudgmentViewAccessContext {
|
|
5
|
+
}
|
|
6
|
+
export type JudgmentViewServiceFactory = (context: TrustedJudgmentViewRequestContext) => JudgmentViewService | Promise<JudgmentViewService>;
|
|
7
|
+
export interface JudgmentViewHttpOptions {
|
|
8
|
+
/** Bind the common read-only service to the host's trusted tenant/scope. */
|
|
9
|
+
readonly serviceFactory?: JudgmentViewServiceFactory;
|
|
10
|
+
/** Convenience for hosts that share one read port across contexts. */
|
|
11
|
+
readonly readPort?: JudgmentViewReadPort;
|
|
12
|
+
readonly basePath?: string;
|
|
13
|
+
}
|
|
14
|
+
export type JudgmentViewHttpHandler = (request: IncomingMessage, response: ServerResponse, context: TrustedJudgmentViewRequestContext | null) => Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Composable GET handler. It returns false outside `/judgment-views/:runId`
|
|
17
|
+
* so an organization host can compose it with reservation or other routes in
|
|
18
|
+
* one local server.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createJudgmentViewHttpHandler(options: JudgmentViewHttpOptions): JudgmentViewHttpHandler;
|
|
21
|
+
/** Alias matching hosts that name all composable adapters as routes. */
|
|
22
|
+
export declare const createJudgmentViewRoute: typeof createJudgmentViewHttpHandler;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createJudgmentViewService, } from './judgment-view.js';
|
|
2
|
+
const DEFAULT_BASE_PATH = '/judgment-views';
|
|
3
|
+
function requestPath(request) {
|
|
4
|
+
try {
|
|
5
|
+
return new URL(request.url ?? '/', 'http://localhost').pathname;
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return '/';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function writeJson(response, statusCode, body, headers = {}) {
|
|
12
|
+
if (response.headersSent)
|
|
13
|
+
return;
|
|
14
|
+
response.statusCode = statusCode;
|
|
15
|
+
response.setHeader('Content-Type', 'application/json');
|
|
16
|
+
for (const [name, value] of Object.entries(headers))
|
|
17
|
+
response.setHeader(name, value);
|
|
18
|
+
response.end(JSON.stringify(body));
|
|
19
|
+
}
|
|
20
|
+
function writeError(response, statusCode, code, message, headers = {}) {
|
|
21
|
+
writeJson(response, statusCode, { error: { code, message } }, headers);
|
|
22
|
+
}
|
|
23
|
+
function normalizeBasePath(basePath) {
|
|
24
|
+
const value = basePath ?? DEFAULT_BASE_PATH;
|
|
25
|
+
if (typeof value !== 'string' || !value.startsWith('/') || value === '/' || /[\u0000-\u001f\u007f]/u.test(value)) {
|
|
26
|
+
throw new TypeError('basePath must be an absolute URL path');
|
|
27
|
+
}
|
|
28
|
+
const normalized = value.replace(/\/+$/u, '');
|
|
29
|
+
if (normalized.length === 0)
|
|
30
|
+
throw new TypeError('basePath must not be root');
|
|
31
|
+
return normalized;
|
|
32
|
+
}
|
|
33
|
+
function matchRoute(pathname, basePath) {
|
|
34
|
+
const normalized = pathname.length > 1 ? pathname.replace(/\/+$/u, '') : pathname;
|
|
35
|
+
const prefix = `${basePath}/`;
|
|
36
|
+
if (!normalized.startsWith(prefix))
|
|
37
|
+
return null;
|
|
38
|
+
const encodedRunId = normalized.slice(prefix.length);
|
|
39
|
+
if (!encodedRunId || encodedRunId.includes('/'))
|
|
40
|
+
return null;
|
|
41
|
+
try {
|
|
42
|
+
const runId = decodeURIComponent(encodedRunId);
|
|
43
|
+
if (!runId.trim() || /[\u0000-\u001f\u007f]/u.test(runId))
|
|
44
|
+
return null;
|
|
45
|
+
return { runId };
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function validContext(context) {
|
|
52
|
+
return context !== null
|
|
53
|
+
&& typeof context === 'object'
|
|
54
|
+
&& typeof context.tenantId === 'string'
|
|
55
|
+
&& context.tenantId.trim().length > 0
|
|
56
|
+
&& typeof context.principal === 'string'
|
|
57
|
+
&& context.principal.trim().length > 0
|
|
58
|
+
&& typeof context.scopeId === 'string'
|
|
59
|
+
&& context.scopeId.trim().length > 0;
|
|
60
|
+
}
|
|
61
|
+
function queryEvaluationId(request) {
|
|
62
|
+
try {
|
|
63
|
+
const url = new URL(request.url ?? '/', 'http://localhost');
|
|
64
|
+
const value = url.searchParams.get('evaluationId');
|
|
65
|
+
if (value === null || value.trim().length === 0)
|
|
66
|
+
return undefined;
|
|
67
|
+
if (/[\u0000-\u001f\u007f]/u.test(value))
|
|
68
|
+
return undefined;
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function httpStatusForDocument(document) {
|
|
76
|
+
if (document.status === 'permission_denied')
|
|
77
|
+
return 403;
|
|
78
|
+
if (document.status === 'invalid')
|
|
79
|
+
return 400;
|
|
80
|
+
if (document.status === 'unavailable')
|
|
81
|
+
return 503;
|
|
82
|
+
return 200;
|
|
83
|
+
}
|
|
84
|
+
function serviceFromOptions(options, context) {
|
|
85
|
+
if (options.serviceFactory)
|
|
86
|
+
return Promise.resolve(options.serviceFactory(context));
|
|
87
|
+
if (options.readPort)
|
|
88
|
+
return Promise.resolve(createJudgmentViewService(options.readPort));
|
|
89
|
+
return Promise.reject(new TypeError('serviceFactory or readPort is required'));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Composable GET handler. It returns false outside `/judgment-views/:runId`
|
|
93
|
+
* so an organization host can compose it with reservation or other routes in
|
|
94
|
+
* one local server.
|
|
95
|
+
*/
|
|
96
|
+
export function createJudgmentViewHttpHandler(options) {
|
|
97
|
+
if (!options || typeof options !== 'object')
|
|
98
|
+
throw new TypeError('options are required');
|
|
99
|
+
if (typeof options.serviceFactory !== 'function' && !options.readPort) {
|
|
100
|
+
throw new TypeError('serviceFactory or readPort is required');
|
|
101
|
+
}
|
|
102
|
+
const basePath = normalizeBasePath(options.basePath);
|
|
103
|
+
return async (request, response, context) => {
|
|
104
|
+
const route = matchRoute(requestPath(request), basePath);
|
|
105
|
+
if (!route)
|
|
106
|
+
return false;
|
|
107
|
+
if ((request.method ?? 'GET').toUpperCase() !== 'GET') {
|
|
108
|
+
writeError(response, 405, 'method_not_allowed', 'Method is not allowed for this judgment view route', { Allow: 'GET' });
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
if (!validContext(context)) {
|
|
112
|
+
writeError(response, 401, 'unauthorized', 'Authenticated judgment view context is required');
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
const evaluationId = queryEvaluationId(request);
|
|
116
|
+
try {
|
|
117
|
+
const service = await serviceFromOptions(options, context);
|
|
118
|
+
const document = await service.read({ runId: route.runId, ...(evaluationId ? { evaluationId } : {}), access: context });
|
|
119
|
+
writeJson(response, httpStatusForDocument(document), document);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
writeError(response, 503, 'unavailable', 'Judgment view is temporarily unavailable');
|
|
123
|
+
}
|
|
124
|
+
return true;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** Alias matching hosts that name all composable adapters as routes. */
|
|
128
|
+
export const createJudgmentViewRoute = createJudgmentViewHttpHandler;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { CompanyOsEvaluationRecord, EvaluationJudgmentValidity, EvaluationResultStatus, PredictionComparison } from './company-os-evaluation.js';
|
|
2
|
+
import type { FoundationRef } from './foundation-catalog.js';
|
|
3
|
+
import type { FoundationOperator, ObjectiveDefinition, VariableDefinition } from './ontology-foundation.js';
|
|
4
|
+
import type { JudgmentDAGCompositionRunRecord, JudgmentDAGEvidenceReference, JudgmentDAGProblemSnapshotReference, JudgmentDAGSubDAGRunRecord, JudgmentDAGVersionReference } from './judgment-dag-composition.js';
|
|
5
|
+
import type { JudgmentDAGJSONValue, JudgmentDAGRunRecord } from './judgment-dag-runner.js';
|
|
6
|
+
import type { JudgmentProblemSnapshot } from './judgment-problem-snapshot.js';
|
|
7
|
+
import type { FoundationCatalogRecord } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Read-only projection contract for following one judgment from its
|
|
10
|
+
* conclusion back to the exact Problem, Objective, evidence, child runs, and
|
|
11
|
+
* evaluation that were used at the time.
|
|
12
|
+
*
|
|
13
|
+
* This module deliberately owns neither a store nor an authorization policy.
|
|
14
|
+
* A host supplies a port after authenticating the request and binding its
|
|
15
|
+
* tenant/scope. Every reference read is explicitly historical so the view
|
|
16
|
+
* cannot silently replace a past definition with its latest revision.
|
|
17
|
+
*/
|
|
18
|
+
export declare const JUDGMENT_VIEW_CONTRACT_VERSION: "judgment-view.v1";
|
|
19
|
+
export declare const JUDGMENT_VIEW_STATUSES: readonly ["resolved", "unknown", "permission_denied", "unavailable", "undecidable", "invalid"];
|
|
20
|
+
export type JudgmentViewStatus = (typeof JUDGMENT_VIEW_STATUSES)[number];
|
|
21
|
+
export type JudgmentViewFailureStatus = Exclude<JudgmentViewStatus, 'resolved'>;
|
|
22
|
+
export interface JudgmentViewAccessContext {
|
|
23
|
+
/** Identity and scope are resolved by the trusted host boundary. */
|
|
24
|
+
readonly tenantId: string;
|
|
25
|
+
readonly principal: string;
|
|
26
|
+
readonly scopeId: string;
|
|
27
|
+
}
|
|
28
|
+
export interface JudgmentViewReadResult<T> {
|
|
29
|
+
readonly status: 'resolved';
|
|
30
|
+
readonly value: T;
|
|
31
|
+
}
|
|
32
|
+
export interface JudgmentViewReadFailure {
|
|
33
|
+
readonly status: JudgmentViewFailureStatus;
|
|
34
|
+
readonly reason: string;
|
|
35
|
+
}
|
|
36
|
+
export type JudgmentViewPortResult<T> = JudgmentViewReadResult<T> | JudgmentViewReadFailure;
|
|
37
|
+
export interface JudgmentViewSection<T> {
|
|
38
|
+
readonly status: JudgmentViewStatus;
|
|
39
|
+
readonly value?: T;
|
|
40
|
+
readonly reason?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A collection carries an explicit absence marker. `items: []` means the
|
|
44
|
+
* source confirmed that there are no records; an unknown or unauthorized
|
|
45
|
+
* source must use `items: null` and `absence_confirmed: false`.
|
|
46
|
+
*/
|
|
47
|
+
export interface JudgmentViewCollection<T> {
|
|
48
|
+
readonly status: JudgmentViewStatus;
|
|
49
|
+
readonly items: readonly T[] | null;
|
|
50
|
+
readonly absence_confirmed: boolean;
|
|
51
|
+
readonly reason?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface JudgmentViewReadCompositionRunRequest {
|
|
54
|
+
readonly runId: string;
|
|
55
|
+
readonly access: JudgmentViewAccessContext;
|
|
56
|
+
}
|
|
57
|
+
export interface JudgmentViewReadProblemSnapshotRequest {
|
|
58
|
+
readonly reference: JudgmentDAGProblemSnapshotReference;
|
|
59
|
+
readonly access: JudgmentViewAccessContext;
|
|
60
|
+
readonly resolution: 'historical';
|
|
61
|
+
}
|
|
62
|
+
export interface JudgmentViewReadFoundationReferenceRequest {
|
|
63
|
+
readonly reference: FoundationRef;
|
|
64
|
+
readonly access: JudgmentViewAccessContext;
|
|
65
|
+
readonly resolution: 'historical';
|
|
66
|
+
}
|
|
67
|
+
export interface JudgmentViewReadRunArtifactRequest {
|
|
68
|
+
readonly runId: string;
|
|
69
|
+
readonly dag: JudgmentDAGVersionReference;
|
|
70
|
+
readonly artifactId?: string;
|
|
71
|
+
readonly access: JudgmentViewAccessContext;
|
|
72
|
+
readonly resolution: 'historical';
|
|
73
|
+
}
|
|
74
|
+
export interface JudgmentViewReadEvaluationRequest {
|
|
75
|
+
readonly runId: string;
|
|
76
|
+
readonly snapshot: JudgmentDAGProblemSnapshotReference;
|
|
77
|
+
readonly objective: FoundationRef;
|
|
78
|
+
readonly evaluationId?: string;
|
|
79
|
+
readonly access: JudgmentViewAccessContext;
|
|
80
|
+
readonly resolution: 'historical';
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Evidence is intentionally read through a host-owned port. The host must
|
|
84
|
+
* re-check the caller's current ACL and resolve the exact historical
|
|
85
|
+
* kind/id/revision requested here; the view never treats a reference string
|
|
86
|
+
* as proof that the evidence can still be read.
|
|
87
|
+
*/
|
|
88
|
+
export interface JudgmentViewReadEvidenceRequest {
|
|
89
|
+
readonly invocationId: string;
|
|
90
|
+
readonly runId?: string;
|
|
91
|
+
readonly reference: JudgmentDAGEvidenceReference;
|
|
92
|
+
readonly access: JudgmentViewAccessContext;
|
|
93
|
+
readonly resolution: 'historical';
|
|
94
|
+
}
|
|
95
|
+
export interface JudgmentViewEvidenceRecord {
|
|
96
|
+
readonly kind: string;
|
|
97
|
+
readonly id: string;
|
|
98
|
+
readonly revision: string;
|
|
99
|
+
readonly digest?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Adapters can be backed by the canonical Foundation store, Problem snapshot
|
|
103
|
+
* store, DAG artifact store, and Evaluation store. They return an explicit
|
|
104
|
+
* failure instead of turning a missing or unauthorized record into null.
|
|
105
|
+
*/
|
|
106
|
+
export interface JudgmentViewReadPort {
|
|
107
|
+
readonly readCompositionRun: (request: JudgmentViewReadCompositionRunRequest) => JudgmentViewPortResult<JudgmentDAGCompositionRunRecord> | Promise<JudgmentViewPortResult<JudgmentDAGCompositionRunRecord>>;
|
|
108
|
+
readonly readProblemSnapshot: (request: JudgmentViewReadProblemSnapshotRequest) => JudgmentViewPortResult<JudgmentProblemSnapshot> | Promise<JudgmentViewPortResult<JudgmentProblemSnapshot>>;
|
|
109
|
+
readonly readFoundationReference: (request: JudgmentViewReadFoundationReferenceRequest) => JudgmentViewPortResult<FoundationCatalogRecord> | Promise<JudgmentViewPortResult<FoundationCatalogRecord>>;
|
|
110
|
+
readonly readRunArtifact: (request: JudgmentViewReadRunArtifactRequest) => JudgmentViewPortResult<JudgmentDAGRunRecord> | Promise<JudgmentViewPortResult<JudgmentDAGRunRecord>>;
|
|
111
|
+
/** Current ACL plus exact historical evidence reference validation. */
|
|
112
|
+
readonly readEvidence: (request: JudgmentViewReadEvidenceRequest) => JudgmentViewPortResult<JudgmentViewEvidenceRecord> | Promise<JudgmentViewPortResult<JudgmentViewEvidenceRecord>>;
|
|
113
|
+
/** Optional until a host has an exact run-to-evaluation index. */
|
|
114
|
+
readonly readEvaluation?: (request: JudgmentViewReadEvaluationRequest) => JudgmentViewPortResult<CompanyOsEvaluationRecord> | Promise<JudgmentViewPortResult<CompanyOsEvaluationRecord>>;
|
|
115
|
+
}
|
|
116
|
+
export interface JudgmentViewReadRequest {
|
|
117
|
+
readonly runId: string;
|
|
118
|
+
readonly evaluationId?: string;
|
|
119
|
+
readonly access: JudgmentViewAccessContext;
|
|
120
|
+
}
|
|
121
|
+
export interface JudgmentViewRun {
|
|
122
|
+
readonly runId: string;
|
|
123
|
+
readonly status: JudgmentDAGCompositionRunRecord['status'];
|
|
124
|
+
readonly question: string;
|
|
125
|
+
readonly composition: JudgmentDAGVersionReference;
|
|
126
|
+
readonly parentDag: JudgmentDAGVersionReference;
|
|
127
|
+
readonly problemSnapshot: JudgmentDAGProblemSnapshotReference;
|
|
128
|
+
}
|
|
129
|
+
export interface JudgmentViewConclusion {
|
|
130
|
+
readonly source: 'parent-run-artifact';
|
|
131
|
+
readonly runId: string;
|
|
132
|
+
readonly dag: JudgmentDAGVersionReference;
|
|
133
|
+
/** The final node output; node internals are intentionally not exposed. */
|
|
134
|
+
readonly value: JudgmentDAGJSONValue;
|
|
135
|
+
}
|
|
136
|
+
export interface JudgmentViewProblem {
|
|
137
|
+
readonly snapshotId: string;
|
|
138
|
+
readonly problemId: string;
|
|
139
|
+
readonly revision: string;
|
|
140
|
+
readonly question: string;
|
|
141
|
+
readonly references: readonly JudgmentViewProblemReference[];
|
|
142
|
+
}
|
|
143
|
+
export interface JudgmentViewProblemReference {
|
|
144
|
+
readonly kind: string;
|
|
145
|
+
readonly id: string;
|
|
146
|
+
readonly revision: string;
|
|
147
|
+
readonly digest: string;
|
|
148
|
+
}
|
|
149
|
+
export interface JudgmentViewCriterion {
|
|
150
|
+
readonly variableRef: FoundationRef;
|
|
151
|
+
readonly operator: FoundationOperator;
|
|
152
|
+
readonly target?: string | number | boolean;
|
|
153
|
+
readonly variable: {
|
|
154
|
+
readonly meaning: string;
|
|
155
|
+
readonly subject: string;
|
|
156
|
+
readonly valueKind: VariableDefinition['valueKind'];
|
|
157
|
+
readonly unit?: string;
|
|
158
|
+
readonly aggregation: VariableDefinition['aggregation'];
|
|
159
|
+
readonly granularity: string;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
export interface JudgmentViewObjective {
|
|
163
|
+
readonly ref: FoundationRef;
|
|
164
|
+
readonly meaning: string;
|
|
165
|
+
readonly desiredState: string;
|
|
166
|
+
readonly adoptionState: ObjectiveDefinition['adoptionState'];
|
|
167
|
+
readonly epistemicState?: ObjectiveDefinition['epistemicState'];
|
|
168
|
+
readonly beneficiaryIds: readonly string[];
|
|
169
|
+
readonly criteria: JudgmentViewCollection<JudgmentViewCriterion>;
|
|
170
|
+
}
|
|
171
|
+
export interface JudgmentViewEvidence {
|
|
172
|
+
readonly source: 'subdag';
|
|
173
|
+
readonly invocationId: string;
|
|
174
|
+
readonly runId?: string;
|
|
175
|
+
readonly kind: string;
|
|
176
|
+
readonly id: string;
|
|
177
|
+
readonly revision: string;
|
|
178
|
+
readonly digest?: string;
|
|
179
|
+
}
|
|
180
|
+
export interface JudgmentViewChildRun {
|
|
181
|
+
readonly invocationId: string;
|
|
182
|
+
readonly dag: JudgmentDAGVersionReference;
|
|
183
|
+
readonly status: JudgmentDAGSubDAGRunRecord['result']['status'];
|
|
184
|
+
readonly question: string;
|
|
185
|
+
readonly runId?: string;
|
|
186
|
+
readonly conclusion: JudgmentDAGSubDAGRunRecord['result']['conclusion'];
|
|
187
|
+
readonly uncertainty: JudgmentDAGSubDAGRunRecord['result']['uncertainty'];
|
|
188
|
+
readonly applicability: JudgmentDAGSubDAGRunRecord['result']['applicability'];
|
|
189
|
+
readonly reason?: string;
|
|
190
|
+
}
|
|
191
|
+
export interface JudgmentViewResultEvaluation {
|
|
192
|
+
readonly evaluationId: string;
|
|
193
|
+
readonly achievement: EvaluationResultStatus;
|
|
194
|
+
readonly criteria: CompanyOsEvaluationRecord['criteria'];
|
|
195
|
+
readonly predictionComparisons: readonly PredictionComparison[];
|
|
196
|
+
readonly evaluatedAt: string;
|
|
197
|
+
readonly outcomeCaseRef: CompanyOsEvaluationRecord['outcomeCaseRef'];
|
|
198
|
+
}
|
|
199
|
+
export interface JudgmentViewJudgmentValidity {
|
|
200
|
+
readonly status: EvaluationJudgmentValidity;
|
|
201
|
+
readonly basis: string;
|
|
202
|
+
readonly evidenceRefs: readonly string[];
|
|
203
|
+
}
|
|
204
|
+
export interface JudgmentViewDocument {
|
|
205
|
+
readonly contract_version: typeof JUDGMENT_VIEW_CONTRACT_VERSION;
|
|
206
|
+
readonly mode: 'historical';
|
|
207
|
+
readonly status: JudgmentViewStatus;
|
|
208
|
+
readonly reason?: string;
|
|
209
|
+
readonly run: JudgmentViewSection<JudgmentViewRun>;
|
|
210
|
+
readonly conclusion: JudgmentViewSection<JudgmentViewConclusion>;
|
|
211
|
+
readonly problem: JudgmentViewSection<JudgmentViewProblem>;
|
|
212
|
+
readonly objective: JudgmentViewSection<JudgmentViewObjective>;
|
|
213
|
+
readonly evidence: JudgmentViewCollection<JudgmentViewEvidence>;
|
|
214
|
+
readonly childRuns: JudgmentViewCollection<JudgmentViewChildRun>;
|
|
215
|
+
readonly resultEvaluation: JudgmentViewSection<JudgmentViewResultEvaluation>;
|
|
216
|
+
readonly judgmentValidity: JudgmentViewSection<JudgmentViewJudgmentValidity>;
|
|
217
|
+
}
|
|
218
|
+
export interface JudgmentViewService {
|
|
219
|
+
readonly read: (request: JudgmentViewReadRequest) => Promise<JudgmentViewDocument>;
|
|
220
|
+
}
|
|
221
|
+
export declare function createJudgmentViewService(port: JudgmentViewReadPort): JudgmentViewService;
|
|
222
|
+
export declare function readJudgmentView(port: JudgmentViewReadPort, request: JudgmentViewReadRequest): Promise<JudgmentViewDocument>;
|