@ifc-lite/mcp 0.7.1 → 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/README.md +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/context.d.ts +13 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +21 -4
- package/dist/server.js.map +1 -1
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/layer-access.d.ts +18 -0
- package/dist/tools/layer-access.d.ts.map +1 -0
- package/dist/tools/layer-access.js +91 -0
- package/dist/tools/layer-access.js.map +1 -0
- package/dist/tools/layer-ops.d.ts +52 -0
- package/dist/tools/layer-ops.d.ts.map +1 -0
- package/dist/tools/layer-ops.js +130 -0
- package/dist/tools/layer-ops.js.map +1 -0
- package/dist/tools/layer-review.d.ts +3 -0
- package/dist/tools/layer-review.d.ts.map +1 -0
- package/dist/tools/layer-review.js +347 -0
- package/dist/tools/layer-review.js.map +1 -0
- package/dist/tools/layer-store.d.ts +96 -0
- package/dist/tools/layer-store.d.ts.map +1 -0
- package/dist/tools/layer-store.js +271 -0
- package/dist/tools/layer-store.js.map +1 -0
- package/dist/tools/layer.d.ts +19 -0
- package/dist/tools/layer.d.ts.map +1 -0
- package/dist/tools/layer.js +257 -0
- package/dist/tools/layer.js.map +1 -0
- package/dist/transport/http.d.ts +11 -1
- package/dist/transport/http.d.ts.map +1 -1
- package/dist/transport/http.js +38 -3
- package/dist/transport/http.js.map +1 -1
- package/package.json +19 -14
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* Capability derivation for draft ops — the shared vocabulary between
|
|
6
|
+
* write-time enforcement (each op matched against the draft's scope
|
|
7
|
+
* claims *before* it touches the Y.Doc) and publish-time verification
|
|
8
|
+
* (descriptors re-derived from the frozen layer's data nodes and checked
|
|
9
|
+
* against the manifest's `scope_claim`; mismatches are reported, never
|
|
10
|
+
* silently accepted).
|
|
11
|
+
*
|
|
12
|
+
* Spec: docs/architecture/layer-prs/06-agents.md §6.4, 07-security.md §7.1.
|
|
13
|
+
*/
|
|
14
|
+
import { findCoveringClaim, parseScopeClaims } from '@ifc-lite/extensions';
|
|
15
|
+
import { extractStackState } from '@ifc-lite/merge';
|
|
16
|
+
import { IFCLITE_ATTR } from '@ifc-lite/ifcx';
|
|
17
|
+
import { ToolErrorCode, ToolExecutionError } from '../errors.js';
|
|
18
|
+
import { ifcClassOfAttributes } from './layer-store.js';
|
|
19
|
+
/** `Pset_*` / `Qto_*` segment anywhere in a namespaced attribute key. */
|
|
20
|
+
const PSET_QTO_RE = /(?:^|::)((?:Pset|Qto)_[A-Za-z0-9_]+)(?:::|$)/;
|
|
21
|
+
/**
|
|
22
|
+
* Capability target for an attribute key: the Pset/Qto set name when the
|
|
23
|
+
* key carries one, else the last `::` segment (write-time and publish-time
|
|
24
|
+
* use the same normalization so they cannot drift).
|
|
25
|
+
*/
|
|
26
|
+
export function mutationTarget(attributeKey) {
|
|
27
|
+
const match = PSET_QTO_RE.exec(attributeKey);
|
|
28
|
+
if (match)
|
|
29
|
+
return match[1];
|
|
30
|
+
const segments = attributeKey.split('::');
|
|
31
|
+
return segments[segments.length - 1];
|
|
32
|
+
}
|
|
33
|
+
/** Write-time descriptor for one draft op. */
|
|
34
|
+
export function descriptorForDraftOp(op, ifcType) {
|
|
35
|
+
switch (op.op) {
|
|
36
|
+
case 'create_entity':
|
|
37
|
+
return { capability: 'model.create', ...(ifcType !== undefined ? { ifcType } : {}) };
|
|
38
|
+
case 'delete_entity':
|
|
39
|
+
return { capability: 'model.delete', ...(ifcType !== undefined ? { ifcType } : {}) };
|
|
40
|
+
case 'set_property':
|
|
41
|
+
return { capability: `model.mutate:${op.pset}`, ...(ifcType !== undefined ? { ifcType } : {}) };
|
|
42
|
+
case 'set_attribute':
|
|
43
|
+
return {
|
|
44
|
+
capability: `model.mutate:${mutationTarget(op.name ?? '')}`,
|
|
45
|
+
...(ifcType !== undefined ? { ifcType } : {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Write-time enforcement: drafts with claims only accept covered ops;
|
|
51
|
+
* drafts with empty claims are unrestricted. Throws the structured error
|
|
52
|
+
* the agent can reason about.
|
|
53
|
+
*/
|
|
54
|
+
export function assertOpWithinClaims(claims, rawClaims, descriptor, op) {
|
|
55
|
+
if (claims.length === 0)
|
|
56
|
+
return;
|
|
57
|
+
if (findCoveringClaim(claims, descriptor))
|
|
58
|
+
return;
|
|
59
|
+
throw new ToolExecutionError({
|
|
60
|
+
code: ToolErrorCode.PERMISSION_DENIED,
|
|
61
|
+
message: `scope does not permit ${descriptor.capability}; request elevation or narrow the task`,
|
|
62
|
+
details: {
|
|
63
|
+
op: { ...op },
|
|
64
|
+
capability: descriptor.capability,
|
|
65
|
+
ifcType: descriptor.ifcType,
|
|
66
|
+
claims: [...rawClaims],
|
|
67
|
+
},
|
|
68
|
+
hint: 'Create a new draft with a wider scope, or drop the offending op.',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Publish-time descriptors from a frozen layer's data nodes (same mapping
|
|
73
|
+
* as the CLI's `deriveScopeOps`):
|
|
74
|
+
* - tombstone opinion (`ifclite::deleted`) → model.delete
|
|
75
|
+
* - path absent from the base stack state → model.create
|
|
76
|
+
* - attribute keys on existing entities → model.mutate:<target>
|
|
77
|
+
* `ifclite::*` bookkeeping keys never produce ops.
|
|
78
|
+
*/
|
|
79
|
+
export function deriveLayerDescriptors(file, baseFiles) {
|
|
80
|
+
const baseState = extractStackState(baseFiles);
|
|
81
|
+
const out = [];
|
|
82
|
+
for (const node of file.data) {
|
|
83
|
+
const baseEntity = baseState.get(node.path);
|
|
84
|
+
const baseClassAttrs = baseEntity?.components.get('attr:class');
|
|
85
|
+
const ifcType = ifcClassOfAttributes(baseClassAttrs) ?? ifcClassOfAttributes(node.attributes);
|
|
86
|
+
const typed = ifcType !== undefined ? { ifcType } : {};
|
|
87
|
+
if (node.attributes?.[IFCLITE_ATTR.DELETED] === true) {
|
|
88
|
+
out.push({ capability: 'model.delete', path: node.path, ...typed });
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (baseEntity === undefined || baseEntity.deleted) {
|
|
92
|
+
out.push({ capability: 'model.create', path: node.path, ...typed });
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
for (const key of Object.keys(node.attributes ?? {})) {
|
|
96
|
+
if (key === IFCLITE_ATTR.DELETED || key.startsWith(IFCLITE_ATTR.DERIVED))
|
|
97
|
+
continue;
|
|
98
|
+
out.push({ capability: `model.mutate:${mutationTarget(key)}`, path: node.path, ...typed });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Verify a published layer's actual ops against its manifest scope claims.
|
|
105
|
+
* Empty claims mean an unrestricted draft — trivially verified.
|
|
106
|
+
*/
|
|
107
|
+
export function verifyLayerAgainstClaims(file, baseFiles, rawClaims) {
|
|
108
|
+
if (rawClaims.length === 0)
|
|
109
|
+
return { verified: true, mismatches: [] };
|
|
110
|
+
const parsed = parseScopeClaims(rawClaims);
|
|
111
|
+
if (!parsed.ok) {
|
|
112
|
+
throw new ToolExecutionError({
|
|
113
|
+
code: ToolErrorCode.INVALID_INPUT,
|
|
114
|
+
message: 'Manifest scope claims failed to parse during publish verification.',
|
|
115
|
+
details: { errors: parsed.errors },
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const mismatches = [];
|
|
119
|
+
for (const descriptor of deriveLayerDescriptors(file, baseFiles)) {
|
|
120
|
+
if (findCoveringClaim(parsed.value, descriptor))
|
|
121
|
+
continue;
|
|
122
|
+
mismatches.push({
|
|
123
|
+
path: descriptor.path,
|
|
124
|
+
capability: descriptor.capability,
|
|
125
|
+
...(descriptor.ifcType !== undefined ? { ifcType: descriptor.ifcType } : {}),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return { verified: mismatches.length === 0, mismatches };
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=layer-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-ops.js","sourceRoot":"","sources":["../../src/tools/layer-ops.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;GASG;AAEH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAcxD,yEAAyE;AACzE,MAAM,WAAW,GAAG,8CAA8C,CAAC;AAEnE;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,YAAoB;IACjD,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7C,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,QAAQ,CAAC,QAAQ,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;YACd,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,UAAU,EAAE,UAAU,CAAC,UAAU;YACjC,GAAG,CAAC,UAAU,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7E,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-review.d.ts","sourceRoot":"","sources":["../../src/tools/layer-review.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAmYvC,eAAO,MAAM,gBAAgB,EAAE,IAAI,EAQlC,CAAC"}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* Layer review tools (spec 06-agents.md §6.3): structured diff, dry-run
|
|
6
|
+
* merge previews, and the review loop (`request_review` →
|
|
7
|
+
* `add_review_feedback` → `get_review_feedback` → `respond_to_review`)
|
|
8
|
+
* that lets a reviewer reject per-entity decisions and the agent open a
|
|
9
|
+
* follow-up draft on the same base to address them.
|
|
10
|
+
*/
|
|
11
|
+
import { randomUUID } from 'node:crypto';
|
|
12
|
+
import { computeStackHash, getProvenance } from '@ifc-lite/ifcx';
|
|
13
|
+
import { parseScopeClaims } from '@ifc-lite/extensions';
|
|
14
|
+
import { diffStackStates, extractStackState, planThreeWayMerge } from '@ifc-lite/merge';
|
|
15
|
+
import { okResult, fmtCount } from './util.js';
|
|
16
|
+
import { ToolErrorCode, ToolExecutionError } from '../errors.js';
|
|
17
|
+
import { createDraft, getLayerWorkspace, refLayerFiles, resolveAncestorFiles, resolveAncestorFilesAnyRef, } from './layer-store.js';
|
|
18
|
+
import { requireOwnedReview, requireReview, visibleDraftIds } from './layer-access.js';
|
|
19
|
+
import { publishDraftFile } from './layer.js';
|
|
20
|
+
/** Resolve a draft id or layer id into state/base/delta files. */
|
|
21
|
+
function resolveCandidate(ws, id, ctx, into) {
|
|
22
|
+
const draft = ws.drafts.get(id);
|
|
23
|
+
if (draft) {
|
|
24
|
+
// Publish preview: `publishLayer` is pure w.r.t. the draft.
|
|
25
|
+
const preview = publishDraftFile(draft, ctx).file;
|
|
26
|
+
return {
|
|
27
|
+
stateFiles: [...draft.baseFiles, preview],
|
|
28
|
+
baseFiles: draft.baseFiles,
|
|
29
|
+
candidateFile: preview,
|
|
30
|
+
baseResolved: true,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const layer = ws.layers.get(id);
|
|
34
|
+
if (layer) {
|
|
35
|
+
const base = getProvenance(layer)?.base ?? null;
|
|
36
|
+
// With an explicit ref, resolve against it; otherwise search every
|
|
37
|
+
// ref — an empty ref list could never reconstruct a stack-hash base
|
|
38
|
+
// and the diff would misreport the whole layer as newly added.
|
|
39
|
+
const baseFiles = into !== undefined
|
|
40
|
+
? resolveAncestorFiles(ws, base, ws.refs.get(into) ?? [])
|
|
41
|
+
: resolveAncestorFilesAnyRef(ws, base);
|
|
42
|
+
const baseResolved = base === null ||
|
|
43
|
+
baseFiles.length > 0 ||
|
|
44
|
+
(base.kind === 'stack' && base.id === computeStackHash([]));
|
|
45
|
+
return { stateFiles: [...baseFiles, layer], baseFiles, candidateFile: layer, baseResolved };
|
|
46
|
+
}
|
|
47
|
+
// Published layers carry no owner (immutable, workspace-shared); drafts
|
|
48
|
+
// do, so only the caller's own / unowned draft ids may be enumerated.
|
|
49
|
+
throw new ToolExecutionError({
|
|
50
|
+
code: ToolErrorCode.ENTITY_NOT_FOUND,
|
|
51
|
+
message: `'${id}' is neither an open draft nor a published layer.`,
|
|
52
|
+
details: { drafts: visibleDraftIds(ws, ctx.session?.principal), layers: Array.from(ws.layers.keys()) },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** Resolve the `against` side of a diff: ref name, layer id, or draft id. */
|
|
56
|
+
function resolveStateFiles(ws, id, ctx) {
|
|
57
|
+
if (ws.refs.has(id))
|
|
58
|
+
return refLayerFiles(ws, id);
|
|
59
|
+
return resolveCandidate(ws, id, ctx).stateFiles;
|
|
60
|
+
}
|
|
61
|
+
function planMerge(ws, input, ctx) {
|
|
62
|
+
const into = input.into;
|
|
63
|
+
if (!ws.refs.has(into)) {
|
|
64
|
+
throw new ToolExecutionError({
|
|
65
|
+
code: ToolErrorCode.ENTITY_NOT_FOUND,
|
|
66
|
+
message: `Unknown ref '${into}'.`,
|
|
67
|
+
details: { refs: Array.from(ws.refs.keys()) },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const ours = refLayerFiles(ws, into);
|
|
71
|
+
const candidate = resolveCandidate(ws, input.layer_or_draft, ctx, into);
|
|
72
|
+
const plan = planThreeWayMerge({
|
|
73
|
+
ancestor: candidate.baseFiles,
|
|
74
|
+
ours,
|
|
75
|
+
theirs: [...candidate.baseFiles, candidate.candidateFile],
|
|
76
|
+
});
|
|
77
|
+
return { plan, baseResolved: candidate.baseResolved };
|
|
78
|
+
}
|
|
79
|
+
function conflictsJson(plan) {
|
|
80
|
+
return plan.conflicts.map((c) => ({
|
|
81
|
+
kind: c.kind,
|
|
82
|
+
path: c.path,
|
|
83
|
+
...(c.componentKey !== undefined ? { componentKey: c.componentKey } : {}),
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
const diffLayer = {
|
|
87
|
+
name: 'diff_layer',
|
|
88
|
+
description: 'Structured diff of a draft or published layer against a ref, layer, or draft ' +
|
|
89
|
+
'(defaults to the candidate\'s own base). Same JSON shape the review UI consumes.',
|
|
90
|
+
scope: 'read',
|
|
91
|
+
inputSchema: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
properties: {
|
|
94
|
+
layer_or_draft: { type: 'string', description: 'Draft id or published layer id.' },
|
|
95
|
+
against: { type: 'string', description: 'Ref name, layer id, or draft id to diff against. Defaults to the candidate\'s base.' },
|
|
96
|
+
},
|
|
97
|
+
required: ['layer_or_draft'],
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
},
|
|
100
|
+
handler(input, ctx) {
|
|
101
|
+
const ws = getLayerWorkspace(ctx.session?.id);
|
|
102
|
+
const candidate = resolveCandidate(ws, input.layer_or_draft, ctx);
|
|
103
|
+
const leftFiles = input.against !== undefined
|
|
104
|
+
? resolveStateFiles(ws, input.against, ctx)
|
|
105
|
+
: candidate.baseFiles;
|
|
106
|
+
// The shared contract from `@ifc-lite/merge` — CLI and review UI emit
|
|
107
|
+
// the identical JSON (deterministically ordered).
|
|
108
|
+
const diff = diffStackStates(extractStackState(leftFiles), extractStackState(candidate.stateFiles));
|
|
109
|
+
return okResult(`Diff: +${diff.added.length} / -${diff.deleted.length} / ~${diff.modified.length} entities.`, {
|
|
110
|
+
added: diff.added,
|
|
111
|
+
deleted: diff.deleted,
|
|
112
|
+
modified: diff.modified,
|
|
113
|
+
base_resolved: candidate.baseResolved,
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
const dryRunMerge = {
|
|
118
|
+
name: 'dry_run_merge',
|
|
119
|
+
description: 'Preview merging a draft or layer into a ref: MergePlan conflicts and auto-op count. No side effects.',
|
|
120
|
+
scope: 'read',
|
|
121
|
+
inputSchema: {
|
|
122
|
+
type: 'object',
|
|
123
|
+
properties: {
|
|
124
|
+
layer_or_draft: { type: 'string' },
|
|
125
|
+
into: { type: 'string', description: 'Target ref name.' },
|
|
126
|
+
},
|
|
127
|
+
required: ['layer_or_draft', 'into'],
|
|
128
|
+
additionalProperties: false,
|
|
129
|
+
},
|
|
130
|
+
handler(input, ctx) {
|
|
131
|
+
const { plan, baseResolved } = planMerge(getLayerWorkspace(ctx.session?.id), input, ctx);
|
|
132
|
+
return okResult(`Merge preview into '${input.into}': ${fmtCount(plan.conflicts.length, 'conflict')}, ${plan.autoOps.length} auto op(s).`, { conflicts: conflictsJson(plan), auto_op_count: plan.autoOps.length, base_resolved: baseResolved });
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
const listConflicts = {
|
|
136
|
+
name: 'list_conflicts',
|
|
137
|
+
description: 'Conflict records a merge of the candidate into the ref would produce. No side effects.',
|
|
138
|
+
scope: 'read',
|
|
139
|
+
inputSchema: {
|
|
140
|
+
type: 'object',
|
|
141
|
+
properties: {
|
|
142
|
+
layer_or_draft: { type: 'string' },
|
|
143
|
+
into: { type: 'string', description: 'Target ref name.' },
|
|
144
|
+
},
|
|
145
|
+
required: ['layer_or_draft', 'into'],
|
|
146
|
+
additionalProperties: false,
|
|
147
|
+
},
|
|
148
|
+
handler(input, ctx) {
|
|
149
|
+
const { plan, baseResolved } = planMerge(getLayerWorkspace(ctx.session?.id), input, ctx);
|
|
150
|
+
return okResult(`${fmtCount(plan.conflicts.length, 'conflict')}.`, {
|
|
151
|
+
conflicts: conflictsJson(plan),
|
|
152
|
+
base_resolved: baseResolved,
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
const requestReview = {
|
|
157
|
+
name: 'request_review',
|
|
158
|
+
description: 'Open a review (the PR object) proposing a published layer for merge into a ref.',
|
|
159
|
+
scope: 'mutate',
|
|
160
|
+
inputSchema: {
|
|
161
|
+
type: 'object',
|
|
162
|
+
properties: {
|
|
163
|
+
layer_id: { type: 'string' },
|
|
164
|
+
into: { type: 'string', description: 'Target ref name.' },
|
|
165
|
+
reviewers: { type: 'array', items: { type: 'string' } },
|
|
166
|
+
},
|
|
167
|
+
required: ['layer_id', 'into'],
|
|
168
|
+
additionalProperties: false,
|
|
169
|
+
},
|
|
170
|
+
handler(input, ctx) {
|
|
171
|
+
const ws = getLayerWorkspace(ctx.session?.id);
|
|
172
|
+
const layerId = input.layer_id;
|
|
173
|
+
if (!ws.layers.has(layerId)) {
|
|
174
|
+
throw new ToolExecutionError({
|
|
175
|
+
code: ToolErrorCode.ENTITY_NOT_FOUND,
|
|
176
|
+
message: `Unknown layer '${layerId}'. Publish the draft first.`,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const into = input.into;
|
|
180
|
+
if (!ws.refs.has(into)) {
|
|
181
|
+
throw new ToolExecutionError({
|
|
182
|
+
code: ToolErrorCode.ENTITY_NOT_FOUND,
|
|
183
|
+
message: `Unknown ref '${into}' — a review must target an existing ref.`,
|
|
184
|
+
details: { refs: Array.from(ws.refs.keys()) },
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const review = {
|
|
188
|
+
id: randomUUID(),
|
|
189
|
+
layerId,
|
|
190
|
+
into,
|
|
191
|
+
reviewers: input.reviewers ?? [],
|
|
192
|
+
status: 'open',
|
|
193
|
+
feedback: [],
|
|
194
|
+
responses: [],
|
|
195
|
+
owner: ctx.session?.principal,
|
|
196
|
+
};
|
|
197
|
+
ws.reviews.set(review.id, review);
|
|
198
|
+
return okResult(`Review ${review.id} opened: ${layerId} → '${review.into}'.`, { review_id: review.id });
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
const addReviewFeedback = {
|
|
202
|
+
name: 'add_review_feedback',
|
|
203
|
+
description: 'Record per-entity reviewer decisions (and optionally a status change) on an open review.',
|
|
204
|
+
scope: 'mutate',
|
|
205
|
+
inputSchema: {
|
|
206
|
+
type: 'object',
|
|
207
|
+
properties: {
|
|
208
|
+
review_id: { type: 'string' },
|
|
209
|
+
decisions: {
|
|
210
|
+
type: 'array',
|
|
211
|
+
minItems: 1,
|
|
212
|
+
items: {
|
|
213
|
+
type: 'object',
|
|
214
|
+
properties: {
|
|
215
|
+
entity: { type: 'string' },
|
|
216
|
+
component_key: { type: 'string' },
|
|
217
|
+
decision: { type: 'string', enum: ['accept', 'reject'] },
|
|
218
|
+
comment: { type: 'string' },
|
|
219
|
+
},
|
|
220
|
+
required: ['entity', 'decision'],
|
|
221
|
+
additionalProperties: false,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
status: { type: 'string', enum: ['changes-requested', 'approved'] },
|
|
225
|
+
},
|
|
226
|
+
required: ['review_id', 'decisions'],
|
|
227
|
+
additionalProperties: false,
|
|
228
|
+
},
|
|
229
|
+
handler(input, ctx) {
|
|
230
|
+
const ws = getLayerWorkspace(ctx.session?.id);
|
|
231
|
+
const review = requireOwnedReview(ws, input.review_id, ctx.session?.principal, {
|
|
232
|
+
allowReviewers: true,
|
|
233
|
+
});
|
|
234
|
+
const decisions = input.decisions;
|
|
235
|
+
for (const d of decisions) {
|
|
236
|
+
const entry = { entity: d.entity, decision: d.decision };
|
|
237
|
+
if (d.component_key !== undefined)
|
|
238
|
+
entry.componentKey = d.component_key;
|
|
239
|
+
if (d.comment !== undefined)
|
|
240
|
+
entry.comment = d.comment;
|
|
241
|
+
review.feedback.push(entry);
|
|
242
|
+
}
|
|
243
|
+
if (input.status === 'approved') {
|
|
244
|
+
// No self-approval — mirrors the registry route: the layer's
|
|
245
|
+
// manifest author cannot satisfy the approval their own merge needs.
|
|
246
|
+
const layer = ws.layers.get(review.layerId);
|
|
247
|
+
const author = layer ? getProvenance(layer)?.author.principal : undefined;
|
|
248
|
+
if (author !== undefined && ctx.session?.principal !== undefined && author === ctx.session.principal) {
|
|
249
|
+
throw new ToolExecutionError({
|
|
250
|
+
code: ToolErrorCode.INVALID_INPUT,
|
|
251
|
+
message: `Layer author '${author}' cannot approve their own review ${review.id}.`,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (input.status !== undefined)
|
|
256
|
+
review.status = input.status;
|
|
257
|
+
return okResult(`Recorded ${fmtCount(decisions.length, 'decision')} on review ${review.id}; status=${review.status}.`, { review_id: review.id, status: review.status, decision_count: review.feedback.length });
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
const getReviewFeedback = {
|
|
261
|
+
name: 'get_review_feedback',
|
|
262
|
+
description: 'Read a review\'s status and per-entity decisions, structured for the agent to act on.',
|
|
263
|
+
scope: 'read',
|
|
264
|
+
inputSchema: {
|
|
265
|
+
type: 'object',
|
|
266
|
+
properties: {
|
|
267
|
+
review_id: { type: 'string' },
|
|
268
|
+
},
|
|
269
|
+
required: ['review_id'],
|
|
270
|
+
additionalProperties: false,
|
|
271
|
+
},
|
|
272
|
+
handler(input, ctx) {
|
|
273
|
+
const review = requireReview(getLayerWorkspace(ctx.session?.id), input.review_id, ctx.session?.principal);
|
|
274
|
+
return okResult(`Review ${review.id}: status=${review.status}, ${fmtCount(review.feedback.length, 'decision')}.`, {
|
|
275
|
+
review_id: review.id,
|
|
276
|
+
layer_id: review.layerId,
|
|
277
|
+
into: review.into,
|
|
278
|
+
status: review.status,
|
|
279
|
+
decisions: review.feedback.map((d) => ({
|
|
280
|
+
entity: d.entity,
|
|
281
|
+
...(d.componentKey !== undefined ? { component_key: d.componentKey } : {}),
|
|
282
|
+
decision: d.decision,
|
|
283
|
+
...(d.comment !== undefined ? { comment: d.comment } : {}),
|
|
284
|
+
})),
|
|
285
|
+
responses: [...review.responses],
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
const respondToReview = {
|
|
290
|
+
name: 'respond_to_review',
|
|
291
|
+
description: 'Open a follow-up draft on the reviewed layer\'s base so the agent can address feedback; ' +
|
|
292
|
+
'the draft is recorded as a response on the review.',
|
|
293
|
+
scope: 'mutate',
|
|
294
|
+
inputSchema: {
|
|
295
|
+
type: 'object',
|
|
296
|
+
properties: {
|
|
297
|
+
review_id: { type: 'string' },
|
|
298
|
+
intent: { type: 'string', description: 'Intent for the follow-up draft. Defaults to a reference to the review.' },
|
|
299
|
+
},
|
|
300
|
+
required: ['review_id'],
|
|
301
|
+
additionalProperties: false,
|
|
302
|
+
},
|
|
303
|
+
handler(input, ctx) {
|
|
304
|
+
const ws = getLayerWorkspace(ctx.session?.id);
|
|
305
|
+
const review = requireOwnedReview(ws, input.review_id, ctx.session?.principal);
|
|
306
|
+
const layer = ws.layers.get(review.layerId);
|
|
307
|
+
if (!layer) {
|
|
308
|
+
throw new ToolExecutionError({
|
|
309
|
+
code: ToolErrorCode.INTERNAL_ERROR,
|
|
310
|
+
message: `Review ${review.id} references unknown layer ${review.layerId}.`,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
const manifest = getProvenance(layer);
|
|
314
|
+
const base = manifest?.base ?? null;
|
|
315
|
+
const baseFiles = resolveAncestorFiles(ws, base, ws.refs.get(review.into) ?? []);
|
|
316
|
+
const rawClaims = manifest?.scope_claim ?? [];
|
|
317
|
+
const parsed = parseScopeClaims(rawClaims);
|
|
318
|
+
if (!parsed.ok) {
|
|
319
|
+
throw new ToolExecutionError({
|
|
320
|
+
code: ToolErrorCode.INVALID_INPUT,
|
|
321
|
+
message: `Reviewed layer carries unparseable scope claims.`,
|
|
322
|
+
details: { errors: parsed.errors },
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
const draft = createDraft(ws, {
|
|
326
|
+
base,
|
|
327
|
+
baseFiles,
|
|
328
|
+
intent: input.intent ?? `Address review ${review.id} feedback on ${review.layerId}`,
|
|
329
|
+
claims: parsed.value,
|
|
330
|
+
rawClaims: [...rawClaims],
|
|
331
|
+
session: manifest?.author.session,
|
|
332
|
+
owner: ctx.session?.principal,
|
|
333
|
+
});
|
|
334
|
+
review.responses.push(draft.id);
|
|
335
|
+
return okResult(`Follow-up draft ${draft.id} opened for review ${review.id} (same base and scope as ${review.layerId}).`, { draft_id: draft.id, review_id: review.id, base, scope: [...rawClaims] });
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
export const layerReviewTools = [
|
|
339
|
+
diffLayer,
|
|
340
|
+
dryRunMerge,
|
|
341
|
+
listConflicts,
|
|
342
|
+
requestReview,
|
|
343
|
+
addReviewFeedback,
|
|
344
|
+
getReviewFeedback,
|
|
345
|
+
respondToReview,
|
|
346
|
+
];
|
|
347
|
+
//# sourceMappingURL=layer-review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-review.js","sourceRoot":"","sources":["../../src/tools/layer-review.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIxF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAkB9C,kEAAkE;AAClE,SAAS,gBAAgB,CAAC,EAAkB,EAAE,EAAU,EAAE,GAAgB,EAAE,IAAa;IACvF,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChC,IAAI,KAAK,EAAE,CAAC;QACV,4DAA4D;QAC5D,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC;QAClD,OAAO;YACL,UAAU,EAAE,CAAC,GAAG,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;YACzC,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,aAAa,EAAE,OAA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AAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAC1E,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAW;IACtC,SAAS;IACT,WAAW;IACX,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;CAChB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import type { ScopeClaim } from '@ifc-lite/extensions';
|
|
3
|
+
import type { IfcxFile, ProvenanceBase } from '@ifc-lite/ifcx';
|
|
4
|
+
export interface DraftLayer {
|
|
5
|
+
id: string;
|
|
6
|
+
doc: Y.Doc;
|
|
7
|
+
/** `Y.encodeStateAsUpdate(doc)` at creation — what `publishLayer` diffs against. */
|
|
8
|
+
baseline: Uint8Array;
|
|
9
|
+
base: ProvenanceBase | null;
|
|
10
|
+
/** Resolved base stack (weakest first) for merge previews; may be []. */
|
|
11
|
+
baseFiles: IfcxFile[];
|
|
12
|
+
intent: string;
|
|
13
|
+
claims: ScopeClaim[];
|
|
14
|
+
rawClaims: string[];
|
|
15
|
+
session: string;
|
|
16
|
+
/** Creating principal; undefined = unauthenticated/local → accessible to anyone in the workspace. */
|
|
17
|
+
owner?: string;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ReviewDecision {
|
|
21
|
+
entity: string;
|
|
22
|
+
componentKey?: string;
|
|
23
|
+
decision: 'accept' | 'reject';
|
|
24
|
+
comment?: string;
|
|
25
|
+
}
|
|
26
|
+
export type ReviewStatus = 'open' | 'changes-requested' | 'approved';
|
|
27
|
+
export interface LayerReview {
|
|
28
|
+
id: string;
|
|
29
|
+
layerId: string;
|
|
30
|
+
into: string;
|
|
31
|
+
reviewers: string[];
|
|
32
|
+
status: ReviewStatus;
|
|
33
|
+
feedback: ReviewDecision[];
|
|
34
|
+
/** Follow-up draft ids opened via `respond_to_review`. */
|
|
35
|
+
responses: string[];
|
|
36
|
+
/** Requesting principal; undefined = unauthenticated/local → accessible to anyone in the workspace. */
|
|
37
|
+
owner?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface LayerWorkspace {
|
|
40
|
+
drafts: Map<string, DraftLayer>;
|
|
41
|
+
layers: Map<string, IfcxFile>;
|
|
42
|
+
refs: Map<string, string[]>;
|
|
43
|
+
reviews: Map<string, LayerReview>;
|
|
44
|
+
}
|
|
45
|
+
export declare function createLayerWorkspace(): LayerWorkspace;
|
|
46
|
+
export declare function getLayerWorkspace(sessionId?: string): LayerWorkspace;
|
|
47
|
+
/**
|
|
48
|
+
* Drop a session's draft space when the transport session ends. Layers,
|
|
49
|
+
* refs, and reviews deliberately survive — they are the published shared
|
|
50
|
+
* record other sessions keep building on.
|
|
51
|
+
*/
|
|
52
|
+
export declare function disposeLayerWorkspace(sessionId: string): void;
|
|
53
|
+
/** Test hook: drop all draft spaces and shared state; return a fresh local workspace. */
|
|
54
|
+
export declare function resetLayerWorkspace(): LayerWorkspace;
|
|
55
|
+
/** Files for a ref, erroring on dangling layer ids (corrupt workspace). */
|
|
56
|
+
export declare function refLayerFiles(ws: LayerWorkspace, name: string): IfcxFile[];
|
|
57
|
+
export interface ResolvedBase {
|
|
58
|
+
base: ProvenanceBase | null;
|
|
59
|
+
files: IfcxFile[];
|
|
60
|
+
}
|
|
61
|
+
/** Resolve a base spec (ref name or layer id; absent → no base). */
|
|
62
|
+
export declare function resolveBase(ws: LayerWorkspace, ref?: string): ResolvedBase;
|
|
63
|
+
/**
|
|
64
|
+
* Resolve a manifest base against a ref's layer ids: a stack base matches
|
|
65
|
+
* a prefix stack hash, a layer base matches a prefix end (or a stored
|
|
66
|
+
* stray layer). Best effort — unknown bases resolve to [].
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveAncestorFiles(ws: LayerWorkspace, base: ProvenanceBase | null, refIds: readonly string[]): IfcxFile[];
|
|
69
|
+
/**
|
|
70
|
+
* Resolve a manifest base by searching every ref's layer list — used when
|
|
71
|
+
* a tool gets a published layer without an explicit `into` ref, where an
|
|
72
|
+
* empty ref list could never reconstruct a stack-hash base.
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveAncestorFilesAnyRef(ws: LayerWorkspace, base: ProvenanceBase | null): IfcxFile[];
|
|
75
|
+
/** Read the IfcClass code off the well-known class attribute, if present. */
|
|
76
|
+
export declare function ifcClassOfAttributes(attributes: Record<string, unknown> | undefined): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Fold an ordered layer stack (weakest first) into a draft Y.Doc.
|
|
79
|
+
*
|
|
80
|
+
* Unlike `seedFromIfcx` (whose `createEntity` is a no-op on existing
|
|
81
|
+
* paths), this applies later layers' opinions on top: nulls remove,
|
|
82
|
+
* tombstones delete, values overwrite.
|
|
83
|
+
*/
|
|
84
|
+
export declare function seedDraftDoc(doc: Y.Doc, files: readonly IfcxFile[]): void;
|
|
85
|
+
export interface CreateDraftInit {
|
|
86
|
+
base: ProvenanceBase | null;
|
|
87
|
+
baseFiles: IfcxFile[];
|
|
88
|
+
intent: string;
|
|
89
|
+
claims: ScopeClaim[];
|
|
90
|
+
rawClaims: string[];
|
|
91
|
+
session?: string;
|
|
92
|
+
owner?: string;
|
|
93
|
+
}
|
|
94
|
+
/** Build, seed, baseline, and register a new draft. */
|
|
95
|
+
export declare function createDraft(ws: LayerWorkspace, init: CreateDraftInit): DraftLayer;
|
|
96
|
+
//# sourceMappingURL=layer-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-store.d.ts","sourceRoot":"","sources":["../../src/tools/layer-store.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAazB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG/D,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,C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