bs-engineering-suite 2.9.0-rc.11 → 2.9.0-rc.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +1 -1
- package/README.md +40 -38
- package/cordis.patch.yml +8 -0
- package/docs/content-packs/ONLINE_LIBRARY.md +15 -0
- package/docs/content-packs/TEMPLATE_PACKAGE_GUIDE.md +31 -0
- package/docs/rag-packs/library.md +57 -0
- package/docs/windows-install.md +29 -0
- package/docs/windows-usage.md +30 -0
- package/lib/ui-policy.cjs +11 -5
- package/node_modules/@buildseek/content-packs/lib/bundle.d.ts +3 -1
- package/node_modules/@buildseek/content-packs/lib/bundle.js +28 -6
- package/node_modules/@buildseek/content-packs/lib/bundle.js.map +1 -1
- package/node_modules/@buildseek/content-packs/lib/office-xml.d.ts +2 -0
- package/node_modules/@buildseek/content-packs/lib/office-xml.js +9 -0
- package/node_modules/@buildseek/content-packs/lib/office-xml.js.map +1 -0
- package/node_modules/@buildseek/content-packs/lib/repository.d.ts +10 -3
- package/node_modules/@buildseek/content-packs/lib/repository.js +395 -129
- package/node_modules/@buildseek/content-packs/lib/repository.js.map +1 -1
- package/node_modules/@buildseek/content-packs/lib/types.d.ts +1 -0
- package/node_modules/@buildseek/content-packs/lib/xlsx.d.ts +3 -0
- package/node_modules/@buildseek/content-packs/lib/xlsx.js +13 -6
- package/node_modules/@buildseek/content-packs/lib/xlsx.js.map +1 -1
- package/node_modules/@buildseek/diagnostics/lib/client.js +6 -6
- package/node_modules/@buildseek/diagnostics/lib/sanitize.js +1 -1
- package/node_modules/@buildseek/diagnostics/lib/store.js +18 -7
- package/node_modules/@buildseek/diagnostics/lib/updates.js +23 -11
- package/node_modules/@buildseek/diagnostics/lib/version.js +1 -1
- package/node_modules/@buildseek/diagnostics/package.json +7 -7
- package/node_modules/@buildseek/harness-engineering-document-plugin/dist/client/document-library.d.ts +1 -1
- package/node_modules/@buildseek/harness-engineering-document-plugin/dist/client/suite-settings.d.ts +1 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/dist/client/workbench-fact-editor.d.ts +1 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/dist/client.js +28 -8
- package/node_modules/@buildseek/harness-engineering-document-plugin/integration/licenses/deepseek-ai-0.2.2-rc.4-MIT-LICENSE +21 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/content-pack-rules.js +2 -1
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/content-pack-validation.js +6 -2
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/content-packs.js +116 -38
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/files/evidence.js +3 -1
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/files/materials.js +116 -39
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/files/renderers.js +2 -1
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/files/xlsx-preview-layout.js +1 -1
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/identity.js +7 -7
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/online-pack-worker.js +17 -18
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/online-packs.js +6 -5
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/orchestrator.js +25 -5
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-content-flow.js +149 -23
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/application.js +140 -81
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/artifact-mirror.js +10 -6
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/bridges.js +6 -4
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/contract.js +1 -1
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/evidence.js +34 -9
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/filesystem.js +6 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/full-before.js +91 -34
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/generation.js +54 -18
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/plan.js +1 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/preview-leases.js +10 -3
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/project-basic-reader.js +245 -47
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/project-setup.js +27 -18
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/project-data/store.js +4 -4
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/schemas.js +8 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/service.js +4 -1
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/typert.host.js +5 -5
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/typert.remote-client.js +2 -2
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/content-packs.d.ts +87 -18
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/files/materials.d.ts +2 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/identity.d.ts +7 -7
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/model.d.ts +1 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/project-content-flow.d.ts +75 -18
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/project-data/application.d.ts +1 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/project-data/artifact-mirror.d.ts +1 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/project-data/bridges.d.ts +5 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/project-data/evidence.d.ts +3 -2
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/project-data/filesystem.d.ts +2 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/project-data/plan.d.ts +1 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/project-data/preview-leases.d.ts +1 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/project-data/project-basic-reader.d.ts +14 -9
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/schemas.d.ts +10 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/service.d.ts +1 -1
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/types/workbench/application.d.ts +3 -0
- package/node_modules/@buildseek/harness-engineering-document-plugin/lib/workbench/application.js +45 -4
- package/node_modules/@buildseek/harness-engineering-document-plugin/package.json +66 -65
- package/node_modules/@buildseek/harness-engineering-document-plugin/policy/plugin-policy.json +3 -3
- package/node_modules/@buildseek/harness-engineering-document-plugin/scripts/package-contract.mjs +6 -6
- package/node_modules/@buildseek/harness-oag-plugin/dist/client/content-packs.d.ts +4 -0
- package/node_modules/@buildseek/harness-oag-plugin/dist/client/index.d.ts +2 -1
- package/node_modules/@buildseek/harness-oag-plugin/dist/client/suite-settings.d.ts +1 -0
- package/node_modules/@buildseek/harness-oag-plugin/dist/client.js +84 -19
- package/node_modules/@buildseek/harness-oag-plugin/dist/content-packs.js +22 -5
- package/node_modules/@buildseek/harness-oag-plugin/dist/native/buildseek_oag_node.darwin-arm64.node +0 -0
- package/node_modules/@buildseek/harness-oag-plugin/dist/native/buildseek_oag_node.win32-x64-msvc.node +0 -0
- package/node_modules/@buildseek/harness-oag-plugin/dist/native/buildseek_oag_node.win32-x64-msvc.node.json +3 -3
- package/node_modules/@buildseek/harness-oag-plugin/lib/config.js +7 -0
- package/node_modules/@buildseek/harness-oag-plugin/lib/remote-gateway.js +13 -11
- package/node_modules/@buildseek/harness-oag-plugin/lib/semantic-registry.js +67 -17
- package/node_modules/@buildseek/harness-oag-plugin/lib/service.js +11 -8
- package/node_modules/@buildseek/harness-oag-plugin/lib/tool-adapter.js +26 -10
- package/node_modules/@buildseek/harness-oag-plugin/lib/typert.host.js +91 -21
- package/node_modules/@buildseek/harness-oag-plugin/lib/typert.remote-client.d.ts +4 -1
- package/node_modules/@buildseek/harness-oag-plugin/lib/typert.remote-client.d.ts.map +1 -1
- package/node_modules/@buildseek/harness-oag-plugin/lib/typert.remote-client.js +58 -11
- package/node_modules/@buildseek/harness-oag-plugin/lib/types/api.d.ts +1 -1
- package/node_modules/@buildseek/harness-oag-plugin/lib/types/authorization.d.ts +1 -0
- package/node_modules/@buildseek/harness-oag-plugin/lib/types/config.d.ts +1 -1
- package/node_modules/@buildseek/harness-oag-plugin/lib/types/remote-gateway.d.ts +2 -1
- package/node_modules/@buildseek/harness-oag-plugin/lib/types/semantic-registry.d.ts +18 -7
- package/node_modules/@buildseek/harness-oag-plugin/lib/types/service.d.ts +6 -5
- package/node_modules/@buildseek/harness-oag-plugin/lib/types/tool-adapter.d.ts +1 -0
- package/node_modules/@buildseek/harness-oag-plugin/package.json +35 -35
- package/node_modules/@buildseek/harness-rag-plugin/data/library/bs-rag-national-building-2026.11-r1.zip +0 -0
- package/node_modules/@buildseek/harness-rag-plugin/dist/client/suite-settings.d.ts +1 -0
- package/node_modules/@buildseek/harness-rag-plugin/dist/client.js +309 -40
- package/node_modules/@buildseek/harness-rag-plugin/lib/core.js +201 -37
- package/node_modules/@buildseek/harness-rag-plugin/lib/local-folder.js +58 -14
- package/node_modules/@buildseek/harness-rag-plugin/lib/project-setup-read.js +5 -0
- package/node_modules/@buildseek/harness-rag-plugin/lib/rag-pack-library.js +283 -59
- package/node_modules/@buildseek/harness-rag-plugin/lib/retrieval-gateway.js +44 -30
- package/node_modules/@buildseek/harness-rag-plugin/lib/retrieval-lifecycle.js +112 -38
- package/node_modules/@buildseek/harness-rag-plugin/lib/retrieval-scope.js +1 -1
- package/node_modules/@buildseek/harness-rag-plugin/lib/retrieval-service.js +297 -139
- package/node_modules/@buildseek/harness-rag-plugin/lib/service.js +21 -9
- package/node_modules/@buildseek/harness-rag-plugin/lib/tool-adapter.js +15 -13
- package/node_modules/@buildseek/harness-rag-plugin/lib/typert.host.js +460 -25
- package/node_modules/@buildseek/harness-rag-plugin/lib/typert.remote-client.d.ts.map +1 -1
- package/node_modules/@buildseek/harness-rag-plugin/lib/typert.remote-client.js +255 -6
- package/node_modules/@buildseek/harness-rag-plugin/lib/types/api.d.ts +1 -1
- package/node_modules/@buildseek/harness-rag-plugin/lib/types/core.d.ts +43 -1
- package/node_modules/@buildseek/harness-rag-plugin/lib/types/index.d.ts +1 -1
- package/node_modules/@buildseek/harness-rag-plugin/lib/types/local-folder.d.ts +2 -0
- package/node_modules/@buildseek/harness-rag-plugin/lib/types/project-setup-read.d.ts +12 -0
- package/node_modules/@buildseek/harness-rag-plugin/lib/types/rag-pack-library.d.ts +14 -0
- package/node_modules/@buildseek/harness-rag-plugin/lib/types/retrieval-lifecycle.d.ts +15 -3
- package/node_modules/@buildseek/harness-rag-plugin/lib/types/retrieval-service.d.ts +27 -6
- package/node_modules/@buildseek/harness-rag-plugin/lib/types/service.d.ts +18 -0
- package/node_modules/@buildseek/harness-rag-plugin/package.json +37 -37
- package/node_modules/@buildseek/platform/project-setup.d.ts +10 -6
- package/node_modules/@buildseek/platform/project-setup.js +684 -31
- package/node_modules/@dsh-engineering/workbench/client/bundle.js +345 -140
- package/node_modules/@dsh-engineering/workbench/client/entry-connection.d.ts +1 -1
- package/node_modules/@dsh-engineering/workbench/client/entry.d.ts +2 -0
- package/node_modules/@dsh-engineering/workbench/client/native-session-observer.d.ts +2 -0
- package/node_modules/@dsh-engineering/workbench/client/project-controller.d.ts +8 -0
- package/node_modules/@dsh-engineering/workbench/client/project-workspace.d.ts +3 -2
- package/node_modules/@dsh-engineering/workbench/client/styles.d.ts +1 -1
- package/node_modules/@dsh-engineering/workbench/client/suite-updates.d.ts +2 -0
- package/node_modules/@dsh-engineering/workbench/package.json +15 -15
- package/node_modules/bs-engineering-docs/client/bundle.js +18 -13
- package/node_modules/bs-engineering-docs/lib/agent.js +53 -16
- package/node_modules/bs-engineering-docs/lib/api.js +54 -80
- package/node_modules/bs-engineering-docs/lib/extract/scan.js +30 -4
- package/node_modules/bs-engineering-docs/lib/generate/candidate.js +17 -0
- package/node_modules/bs-engineering-docs/lib/generate/run.js +12 -8
- package/node_modules/bs-engineering-docs/lib/index.js +30 -2
- package/node_modules/bs-engineering-docs/lib/project-tools.js +32 -5
- package/node_modules/bs-engineering-docs/lib/store.js +298 -243
- package/node_modules/bs-engineering-docs/lib/util/errors.js +2 -0
- package/node_modules/dsh-sidebar-office-preview/client/bundle.js +33 -33
- package/node_modules/dsh-sidebar-office-preview/client/src/parse.js +8 -1
- package/node_modules/dsh-sidebar-office-preview/cordis.patch.yml +1 -1
- package/node_modules/dsh-sidebar-office-preview/package.json +1 -1
- package/package.json +9 -4
- package/ui-compat/darwin-arm64/receipt.json +32 -27
- package/ui-compat/darwin-arm64/vendor/desktop/@deepseek-ai/dsh-client-ui-plugin-manager/lib/client.js +10 -2
- package/ui-compat/darwin-arm64/vendor/npm/@deepseek-ai/dsh-client-ui-chat/lib/bs-ui-guard.js +2 -2
- package/ui-compat/darwin-arm64/vendor/npm/@deepseek-ai/dsh-client-ui-chat/package.json +40 -40
- package/ui-compat/darwin-arm64/vendor/npm/@deepseek-ai/dsh-client-ui-plugin-manager/lib/bs-ui-guard.js +2 -2
- package/ui-compat/darwin-arm64/vendor/npm/@deepseek-ai/dsh-client-ui-plugin-manager/lib/client.js +10 -2
- package/ui-compat/darwin-arm64/vendor/npm/@deepseek-ai/dsh-client-ui-plugin-manager/package.json +19 -19
- package/ui-compat/darwin-arm64/vendor/npm/@deepseek-ai/dsh-client-ui-sidebar/lib/bs-ui-guard.js +2 -2
- package/ui-compat/darwin-arm64/vendor/npm/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/ui-compat/darwin-arm64/vendor/npm/@deepseek-ai/dsh-client-ui-sidebar/package.json +13 -13
- package/ui-compat/win32-x64/receipt.json +32 -27
- package/ui-compat/win32-x64/vendor/desktop/@deepseek-ai/dsh-client-ui-plugin-manager/lib/client.js +10 -2
- package/ui-compat/win32-x64/vendor/npm/@deepseek-ai/dsh-client-ui-chat/lib/bs-ui-guard.js +2 -2
- package/ui-compat/win32-x64/vendor/npm/@deepseek-ai/dsh-client-ui-chat/package.json +40 -40
- package/ui-compat/win32-x64/vendor/npm/@deepseek-ai/dsh-client-ui-plugin-manager/lib/bs-ui-guard.js +2 -2
- package/ui-compat/win32-x64/vendor/npm/@deepseek-ai/dsh-client-ui-plugin-manager/lib/client.js +10 -2
- package/ui-compat/win32-x64/vendor/npm/@deepseek-ai/dsh-client-ui-plugin-manager/package.json +19 -19
- package/ui-compat/win32-x64/vendor/npm/@deepseek-ai/dsh-client-ui-sidebar/lib/bs-ui-guard.js +2 -2
- package/ui-compat/win32-x64/vendor/npm/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/ui-compat/win32-x64/vendor/npm/@deepseek-ai/dsh-client-ui-sidebar/package.json +13 -13
|
@@ -84,6 +84,12 @@ export function csvFragments(text) {
|
|
|
84
84
|
emit();
|
|
85
85
|
return fragments;
|
|
86
86
|
}
|
|
87
|
+
function relationshipTarget(target, directory) {
|
|
88
|
+
// A leading slash identifies a package part, not a path on the host.
|
|
89
|
+
requireFile(target && /^[A-Za-z0-9_. /-]+$/.test(target) &&
|
|
90
|
+
!target.replace(/^\//, '').split('/').some(part => !part || part === '.' || part === '..'), 'OFFICE_RELATIONSHIP_TARGET');
|
|
91
|
+
return target.startsWith('/') ? target.slice(1) : directory + target;
|
|
92
|
+
}
|
|
87
93
|
function officeParts(bytes, format) {
|
|
88
94
|
const files = readOfficeZip(bytes);
|
|
89
95
|
const parts = new Map();
|
|
@@ -109,9 +115,9 @@ function officeParts(bytes, format) {
|
|
|
109
115
|
ids.add(Id);
|
|
110
116
|
requireFile(TargetMode === undefined || TargetMode === 'Internal', 'OFFICE_EXTERNAL_RELATIONSHIP');
|
|
111
117
|
requireFile(Type?.startsWith(OFFICE_REL) && /^(?:officeDocument|worksheet|styles|sharedStrings)$/.test(Type.slice(OFFICE_REL.length)), 'OFFICE_RELATIONSHIP_UNSUPPORTED');
|
|
112
|
-
requireFile(
|
|
118
|
+
requireFile(format === 'xlsx' || !Target?.startsWith('/'), 'OFFICE_RELATIONSHIP_TARGET');
|
|
113
119
|
const base = path === '_rels/.rels' ? '' : path.slice(0, path.indexOf('_rels/'));
|
|
114
|
-
requireFile(files.has(base
|
|
120
|
+
requireFile(files.has(relationshipTarget(Target, base)), 'OFFICE_RELATIONSHIP_MISSING');
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
123
|
parts.set(path, root);
|
|
@@ -128,7 +134,8 @@ function officeParts(bytes, format) {
|
|
|
128
134
|
requireFile(node.attrs.ContentType && !/(?:macro|vba|activex|oleobject|javascript)/i.test(node.attrs.ContentType), 'OFFICE_ACTIVE_CONTENT');
|
|
129
135
|
}
|
|
130
136
|
const rootRels = parts.get('_rels/.rels');
|
|
131
|
-
requireFile(rootRels?.children.length === 1 && rootRels.children[0]?.attrs.Type === `${OFFICE_REL}officeDocument` &&
|
|
137
|
+
requireFile(rootRels?.children.length === 1 && rootRels.children[0]?.attrs.Type === `${OFFICE_REL}officeDocument` &&
|
|
138
|
+
relationshipTarget(rootRels.children[0].attrs.Target, '') === mainPath, 'OFFICE_MAIN_RELATIONSHIP');
|
|
132
139
|
requireFile(parts.has(mainPath) && !parts.has(format === 'docx' ? 'xl/workbook.xml' : 'word/document.xml'), 'OFFICE_FORMAT_MISMATCH');
|
|
133
140
|
return parts;
|
|
134
141
|
}
|
|
@@ -152,15 +159,103 @@ function docxFragments(parts) {
|
|
|
152
159
|
return { location: `word/document.xml/paragraph:${index + 1}`, text: read(paragraph) };
|
|
153
160
|
});
|
|
154
161
|
}
|
|
162
|
+
function qualifiedName(root, namespace) {
|
|
163
|
+
const prefix = root.name.includes(':') ? root.name.split(':')[0] : '';
|
|
164
|
+
assertNamespace(root, prefix, namespace);
|
|
165
|
+
return (name) => prefix ? `${prefix}:${name}` : name;
|
|
166
|
+
}
|
|
167
|
+
function workbookRelationships(rels, directory, paths) {
|
|
168
|
+
requireFile(rels && rels.name.split(':').at(-1) === 'Relationships' && !rels.text.trim(), 'XLSX_RELATIONSHIPS_MISSING');
|
|
169
|
+
const qualify = qualifiedName(rels, REL);
|
|
170
|
+
const relations = new Map();
|
|
171
|
+
const targets = new Set();
|
|
172
|
+
for (const relation of rels.children) {
|
|
173
|
+
const { Id, Type, Target, TargetMode } = relation.attrs;
|
|
174
|
+
requireFile(relation.name === qualify('Relationship') && Id && Type && !relations.has(Id) &&
|
|
175
|
+
!relation.children.length && !relation.text.trim(), 'OFFICE_RELATIONSHIP_INVALID');
|
|
176
|
+
requireFile(TargetMode === undefined || TargetMode === 'Internal', 'OFFICE_EXTERNAL_RELATIONSHIP');
|
|
177
|
+
const path = relationshipTarget(Target, directory);
|
|
178
|
+
requireFile(paths.has(path), 'OFFICE_RELATIONSHIP_MISSING');
|
|
179
|
+
requireFile(!targets.has(path), 'XLSX_DUPLICATE_RELATIONSHIP_TARGET');
|
|
180
|
+
targets.add(path);
|
|
181
|
+
relations.set(Id, { path, type: Type });
|
|
182
|
+
}
|
|
183
|
+
return relations;
|
|
184
|
+
}
|
|
185
|
+
function workbookSheets(readPart, paths) {
|
|
186
|
+
const workbook = readPart('xl/workbook.xml');
|
|
187
|
+
requireFile(workbook && workbook.name.split(':').at(-1) === 'workbook', 'XLSX_ROOT');
|
|
188
|
+
const worksheetName = qualifiedName(workbook, SHEET);
|
|
189
|
+
const idPrefixes = Object.entries(workbook.attrs)
|
|
190
|
+
.filter(([key, value]) => key.startsWith('xmlns:') && value === OFFICE_REL.slice(0, -1))
|
|
191
|
+
.map(([key]) => key.slice('xmlns:'.length));
|
|
192
|
+
requireFile(idPrefixes.length > 0, 'XLSX_SHEET_RELATIONSHIP');
|
|
193
|
+
for (const prefix of idPrefixes)
|
|
194
|
+
assertNamespace(workbook, prefix, OFFICE_REL.slice(0, -1));
|
|
195
|
+
const relations = workbookRelationships(readPart('xl/_rels/workbook.xml.rels'), 'xl/', paths);
|
|
196
|
+
const sheetGroups = workbook.children.filter(node => node.name === worksheetName('sheets'));
|
|
197
|
+
requireFile(sheetGroups.length === 1 && !sheetGroups[0].text.trim() && sheetGroups[0].children.every(node => node.name === worksheetName('sheet') && !node.children.length && !node.text.trim()), 'XLSX_WORKBOOK_SUBSET');
|
|
198
|
+
const sheets = sheetGroups[0].children;
|
|
199
|
+
requireFile(sheets.length > 0 && sheets.length <= 64, 'XLSX_SHEET_LIMIT');
|
|
200
|
+
const names = new Set(), ids = new Set(), used = new Set();
|
|
201
|
+
const worksheetParts = sheets.map(sheet => {
|
|
202
|
+
const { name, sheetId, state } = sheet.attrs;
|
|
203
|
+
const foldedName = name?.toLowerCase();
|
|
204
|
+
requireFile(name && foldedName && !names.has(foldedName) &&
|
|
205
|
+
(state === undefined || ['visible', 'hidden', 'veryHidden'].includes(state)), 'XLSX_DUPLICATE_OR_INVALID_SHEET');
|
|
206
|
+
requireFile(sheetId && /^\d+$/.test(sheetId) && Number(sheetId) > 0 &&
|
|
207
|
+
Number(sheetId) <= 0xffffffff && !ids.has(Number(sheetId)), 'XLSX_DUPLICATE_OR_INVALID_SHEET_ID');
|
|
208
|
+
names.add(foldedName);
|
|
209
|
+
ids.add(Number(sheetId));
|
|
210
|
+
const references = idPrefixes.flatMap(prefix => sheet.attrs[`${prefix}:id`] === undefined ? [] : [sheet.attrs[`${prefix}:id`]]);
|
|
211
|
+
const relation = references.length === 1 ? relations.get(references[0]) : undefined;
|
|
212
|
+
requireFile(relation?.type === `${OFFICE_REL}worksheet`, 'XLSX_SHEET_RELATIONSHIP');
|
|
213
|
+
requireFile(!used.has(relation.path), 'XLSX_SHEET_MISSING_OR_DUPLICATE');
|
|
214
|
+
used.add(relation.path);
|
|
215
|
+
const xml = readPart(relation.path);
|
|
216
|
+
requireFile(xml && xml.name.split(':').at(-1) === 'worksheet', 'XLSX_SHEET_ROOT');
|
|
217
|
+
const cells = descendants(xml, qualifiedName(xml, SHEET)('c'));
|
|
218
|
+
const seen = new Set();
|
|
219
|
+
for (const cell of cells) {
|
|
220
|
+
const ref = cell.attrs.r;
|
|
221
|
+
// Explicit coordinates are structural, even when styles or cell values
|
|
222
|
+
// exceed the text extractor's supported subset.
|
|
223
|
+
if (ref === undefined)
|
|
224
|
+
continue;
|
|
225
|
+
const coordinate = /^([A-Z]{1,3})([1-9][0-9]{0,6})$/.exec(ref);
|
|
226
|
+
requireFile(coordinate && !seen.has(ref), 'XLSX_CELL_REFERENCE');
|
|
227
|
+
const column = [...coordinate[1]].reduce((value, char) => value * 26 + char.charCodeAt(0) - 64, 0);
|
|
228
|
+
requireFile(column <= 16384 && Number(coordinate[2]) <= 1048576, 'XLSX_CELL_REFERENCE');
|
|
229
|
+
seen.add(ref);
|
|
230
|
+
}
|
|
231
|
+
return { name, state, xml, cells };
|
|
232
|
+
});
|
|
233
|
+
requireFile([...paths].filter(path => /^xl\/worksheets\/[^/]+\.xml$/.test(path)).every(path => used.has(path)), 'XLSX_UNREFERENCED_SHEET');
|
|
234
|
+
return { workbook, sheets: worksheetParts };
|
|
235
|
+
}
|
|
236
|
+
/** Required for registration and preview, including workbooks whose cells cannot be extracted. */
|
|
237
|
+
export function validateXlsxStructure(parts) {
|
|
238
|
+
const readPart = (path) => {
|
|
239
|
+
const bytes = parts.get(path);
|
|
240
|
+
return bytes === undefined ? undefined : readXml(bytes);
|
|
241
|
+
};
|
|
242
|
+
const paths = new Set(parts.keys());
|
|
243
|
+
const rootRels = workbookRelationships(readPart('_rels/.rels'), '', paths);
|
|
244
|
+
const main = [...rootRels.values()].filter(relation => relation.type === `${OFFICE_REL}officeDocument`);
|
|
245
|
+
requireFile(main.length === 1 && main[0]?.path === 'xl/workbook.xml', 'OFFICE_MAIN_RELATIONSHIP');
|
|
246
|
+
const types = readPart('[Content_Types].xml');
|
|
247
|
+
requireFile(types && types.name.split(':').at(-1) === 'Types', 'OFFICE_CONTENT_TYPES');
|
|
248
|
+
const typeName = qualifiedName(types, CONTENT);
|
|
249
|
+
const overrides = types.children.filter(node => node.name === typeName('Override') && node.attrs.PartName === '/xl/workbook.xml');
|
|
250
|
+
requireFile(overrides.length === 1 && overrides[0]?.attrs.ContentType ===
|
|
251
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml', 'OFFICE_FORMAT_MISMATCH');
|
|
252
|
+
workbookSheets(readPart, paths);
|
|
253
|
+
}
|
|
155
254
|
function xlsxFragments(parts) {
|
|
156
|
-
const workbook = parts.get(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
assertNamespace(workbook, 'r', OFFICE_REL.slice(0, -1));
|
|
160
|
-
requireFile(workbook.children.length === 1 && workbook.children[0]?.name === 'sheets' && workbook.children[0].children.every(node => node.name === 'sheet' && !node.children.length), 'XLSX_WORKBOOK_SUBSET');
|
|
255
|
+
const { workbook, sheets } = workbookSheets(path => parts.get(path), new Set(parts.keys()));
|
|
256
|
+
const reviewWorkbook = workbook.children.some(node => node.name.split(':').at(-1) !== 'sheets');
|
|
257
|
+
const reviewHidden = sheets.some(sheet => sheet.state === 'hidden' || sheet.state === 'veryHidden');
|
|
161
258
|
requireFile([...parts.keys()].every(path => ['[Content_Types].xml', '_rels/.rels', 'xl/workbook.xml', 'xl/styles.xml', 'xl/sharedStrings.xml', 'xl/_rels/workbook.xml.rels'].includes(path) || /^xl\/worksheets\/sheet[1-9][0-9]*\.xml$/.test(path)), 'XLSX_PART_UNSUPPORTED');
|
|
162
|
-
const rels = parts.get('xl/_rels/workbook.xml.rels');
|
|
163
|
-
requireFile(rels, 'XLSX_RELATIONSHIPS_MISSING');
|
|
164
259
|
const strings = parts.get('xl/sharedStrings.xml');
|
|
165
260
|
const styles = parts.get('xl/styles.xml');
|
|
166
261
|
if (styles) {
|
|
@@ -173,38 +268,19 @@ function xlsxFragments(parts) {
|
|
|
173
268
|
requireFile(strings.name === 'sst' && strings.children.every(node => node.name === 'si' && node.children.every(child => child.name === 't' && !child.children.length)), 'XLSX_SHARED_STRINGS_UNSUPPORTED');
|
|
174
269
|
shared = strings.children.map(node => node.children.map(child => child.text).join(''));
|
|
175
270
|
}
|
|
271
|
+
const allowed = new Set('worksheet sheetData row c is t v cols col sheetViews sheetView pane selection dimension sheetFormatPr pageMargins'.split(' '));
|
|
272
|
+
const check = (node) => {
|
|
273
|
+
requireFile(allowed.has(node.name) && (['v', 't'].includes(node.name) || !node.text.trim()), 'XLSX_ELEMENT_UNSUPPORTED');
|
|
274
|
+
for (const child of node.children)
|
|
275
|
+
check(child);
|
|
276
|
+
};
|
|
176
277
|
const fragments = [];
|
|
177
|
-
const
|
|
178
|
-
const sheets = descendants(workbook, 'sheet');
|
|
179
|
-
requireFile(sheets.length > 0 && sheets.length <= 64, 'XLSX_SHEET_LIMIT');
|
|
180
|
-
for (const sheet of sheets) {
|
|
181
|
-
const name = sheet.attrs.name;
|
|
182
|
-
requireFile(name && !sheetNames.has(name) && (!sheet.attrs.state || sheet.attrs.state === 'visible'), 'XLSX_HIDDEN_OR_DUPLICATE_SHEET');
|
|
183
|
-
sheetNames.add(name);
|
|
184
|
-
const relation = rels.children.find(node => node.attrs.Id === sheet.attrs['r:id']);
|
|
185
|
-
requireFile(relation?.attrs.Type === `${OFFICE_REL}worksheet`, 'XLSX_SHEET_RELATIONSHIP');
|
|
186
|
-
const path = `xl/${relation.attrs.Target}`;
|
|
187
|
-
const xml = parts.get(path);
|
|
188
|
-
requireFile(xml && !visited.has(path), 'XLSX_SHEET_MISSING_OR_DUPLICATE');
|
|
189
|
-
visited.add(path);
|
|
190
|
-
assertNamespace(xml, '', SHEET);
|
|
191
|
-
requireFile(xml.name === 'worksheet', 'XLSX_SHEET_ROOT');
|
|
192
|
-
const allowed = new Set('worksheet sheetData row c is t v cols col sheetViews sheetView pane selection dimension sheetFormatPr pageMargins'.split(' '));
|
|
193
|
-
const check = (node) => {
|
|
194
|
-
requireFile(allowed.has(node.name) && (['v', 't'].includes(node.name) || !node.text.trim()), 'XLSX_ELEMENT_UNSUPPORTED');
|
|
195
|
-
for (const child of node.children)
|
|
196
|
-
check(child);
|
|
197
|
-
};
|
|
278
|
+
for (const { name, xml, cells } of sheets) {
|
|
198
279
|
check(xml);
|
|
199
|
-
const
|
|
200
|
-
for (const cell of descendants(xml, 'c')) {
|
|
280
|
+
for (const cell of cells) {
|
|
201
281
|
const ref = cell.attrs.r;
|
|
202
|
-
requireFile(ref
|
|
203
|
-
const letters = ref.match(/^[A-Z]+/)[0];
|
|
204
|
-
const column = [...letters].reduce((value, char) => value * 26 + char.charCodeAt(0) - 64, 0);
|
|
205
|
-
requireFile(column <= 16384 && Number(ref.slice(letters.length)) <= 1048576, 'XLSX_CELL_REFERENCE');
|
|
282
|
+
requireFile(ref, 'XLSX_CELL_REFERENCE');
|
|
206
283
|
requireFile(!cell.attrs.s || cell.attrs.s === '0', 'XLSX_FORMATTED_VALUE_UNSUPPORTED');
|
|
207
|
-
seen.add(ref);
|
|
208
284
|
const values = cell.children;
|
|
209
285
|
let text = '';
|
|
210
286
|
if (cell.attrs.t === 'inlineStr') {
|
|
@@ -231,7 +307,8 @@ function xlsxFragments(parts) {
|
|
|
231
307
|
fragments.push({ location: `sheet:${name}/cell:${ref}`, text });
|
|
232
308
|
}
|
|
233
309
|
}
|
|
234
|
-
requireFile(
|
|
310
|
+
requireFile(!reviewWorkbook, 'XLSX_WORKBOOK_FEATURE_UNSUPPORTED');
|
|
311
|
+
requireFile(!reviewHidden, 'XLSX_HIDDEN_SHEET_UNSUPPORTED');
|
|
235
312
|
return fragments;
|
|
236
313
|
}
|
|
237
314
|
function validatePng(bytes) {
|
|
@@ -30,7 +30,8 @@ function rowsFor(model) {
|
|
|
30
30
|
factIds.add(fact.factRef);
|
|
31
31
|
requireFile(['string', 'number', 'boolean'].includes(typeof fact.value) && (typeof fact.value !== 'number' || Number.isFinite(fact.value)), 'RENDER_FACT_VALUE');
|
|
32
32
|
requireFile(Array.isArray(fact.citationIds) && fact.citationIds.every(value => typeof value === 'string'), 'RENDER_FACT_CITATIONS');
|
|
33
|
-
|
|
33
|
+
const value = fact.unit === undefined ? fact.value : `${fact.value} ${fact.unit}`;
|
|
34
|
+
rows.push([section.sectionId, fact.factRef, fact.field, value, fact.valueType, fact.ontologyConcept, canonicalJson(fact.citationIds)]);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
for (const row of rows)
|
package/node_modules/@buildseek/harness-engineering-document-plugin/lib/files/xlsx-preview-layout.js
CHANGED
|
@@ -152,7 +152,7 @@ export function xlsxPreviewRepresentation(original) {
|
|
|
152
152
|
checkTime();
|
|
153
153
|
if (!changedParts.length)
|
|
154
154
|
return { bytes: original, kind: 'identity', transformVersion: 'identity-v1', changedParts };
|
|
155
|
-
const bytes = zipSync(output, { level: 6, mtime: new Date(
|
|
155
|
+
const bytes = zipSync(output, { level: 6, mtime: new Date(2000, 0, 1) });
|
|
156
156
|
checkTime();
|
|
157
157
|
requireFile(bytes.length <= MAX_BYTES, 'EDP_PREVIEW_TOO_LARGE');
|
|
158
158
|
validateEvidenceContainer({ name: 'preview.xlsx', mime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', bytes });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EDP release identity and the DSH host contract it targets.
|
|
3
3
|
*
|
|
4
|
-
* DSH 0.2.2-rc.
|
|
5
|
-
* `
|
|
4
|
+
* DSH 0.2.2-rc.4 has a public source identity (`dsh-v0.2.2-rc.4` /
|
|
5
|
+
* `3f321d32…`) used for review and static evidence. The shipped Desktop
|
|
6
6
|
* application build commit is not published for rc.3, so the runtime identity
|
|
7
7
|
* is recorded as NOT_OBSERVED instead of inheriting rc.1's unreachable build
|
|
8
8
|
* commit.
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
// Frozen legacy Remote identity. The M2 component/package version is recorded
|
|
13
13
|
// separately by its manifest; changing this literal changes the frozen wire.
|
|
14
14
|
export const EDP_PLUGIN_VERSION = '0.4.8-local.1';
|
|
15
|
-
export const EDP_HOST_CONTRACT = 'dsh-v0.2.2-rc.
|
|
16
|
-
export const EDP_HOST_PACKAGE = '@deepseek-ai/dsh@0.2.2-rc.
|
|
17
|
-
export const EDP_HOST_GIT_TAG = 'dsh-v0.2.2-rc.
|
|
18
|
-
export const EDP_HOST_SOURCE_COMMIT = '
|
|
15
|
+
export const EDP_HOST_CONTRACT = 'dsh-v0.2.2-rc.4';
|
|
16
|
+
export const EDP_HOST_PACKAGE = '@deepseek-ai/dsh@0.2.2-rc.4';
|
|
17
|
+
export const EDP_HOST_GIT_TAG = 'dsh-v0.2.2-rc.4';
|
|
18
|
+
export const EDP_HOST_SOURCE_COMMIT = '3f321d32bfe382212a8ed8785c1d47a5a300aa23';
|
|
19
19
|
export const EDP_HOST_APP_BUILD_COMMIT = 'NOT_OBSERVED';
|
|
20
20
|
export const EDP_CORDIS_RANGE = '~4.1.0';
|
|
21
21
|
export const EDP_SCHEMASTERY_RANGE = '~3.19.0';
|
|
22
|
-
export const EDP_DSH_RANGE = '>=0.2.2-rc.
|
|
22
|
+
export const EDP_DSH_RANGE = '>=0.2.2-rc.4 <0.3.0';
|
|
23
23
|
export const EDP_NODE_ENGINE = '>=24.9.0';
|
|
24
24
|
export const EDP_PACKAGE_MANAGER = 'pnpm@11.28.5';
|
|
25
25
|
//# sourceMappingURL=identity.js.map
|
package/node_modules/@buildseek/harness-engineering-document-plugin/lib/online-pack-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parentPort, workerData } from 'node:worker_threads';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
|
-
import { ContentPackRepository,
|
|
4
|
+
import { ContentPackRepository, packFailure } from '@buildseek/content-packs';
|
|
5
5
|
import { validateBundleContent } from './content-pack-validation.js';
|
|
6
6
|
import { nativePackValidator } from './content-pack-native.js';
|
|
7
7
|
const p = workerData;
|
|
@@ -10,25 +10,24 @@ const check = (condition, code) => { if (!condition)
|
|
|
10
10
|
try {
|
|
11
11
|
const bytes = await readFile(p.path);
|
|
12
12
|
check(bytes.length === p.pack.archive.bytes && createHash('sha256').update(bytes).digest('hex') === p.pack.archive.sha256, 'SHA_MISMATCH');
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const hooks = {
|
|
14
|
+
inspect(bundle) {
|
|
15
|
+
check(bundle.manifest.packId === p.pack.id && bundle.manifest.version === p.pack.version && bundle.manifest.schema === p.pack.archive.schema, 'BUNDLE_IDENTITY_MISMATCH');
|
|
16
|
+
const templates = bundle.manifest.templates;
|
|
17
|
+
check(templates.length === p.pack.counts.templates && templates.filter(t => t.kind === 'form').length === p.pack.counts.forms && templates.filter(t => t.kind === 'reference').length === p.pack.counts.references, 'BUNDLE_COUNTS_MISMATCH');
|
|
18
|
+
},
|
|
19
|
+
async beforeCommit() {
|
|
20
|
+
parentPort.postMessage({ phase: 'READY_TO_COMMIT' });
|
|
21
|
+
await new Promise(resolve => parentPort.once('message', value => { if (value === 'commit')
|
|
22
|
+
resolve(); }));
|
|
23
|
+
},
|
|
24
|
+
};
|
|
18
25
|
parentPort.postMessage({ phase: 'VALIDATING' });
|
|
19
|
-
const
|
|
20
|
-
const result = await validateBundle(bundle, b => validateBundleContent(b, oag));
|
|
21
|
-
if (!result.valid) {
|
|
22
|
-
const diagnostics = normalizePackDiagnostics(result.diagnostics);
|
|
23
|
-
throw new ContentPackError('VALIDATION_FAILED', formatPackDiagnostics(diagnostics), diagnostics);
|
|
24
|
-
}
|
|
25
|
-
parentPort.postMessage({ phase: 'READY_TO_COMMIT' });
|
|
26
|
-
await new Promise(resolve => parentPort.once('message', value => { if (value === 'commit')
|
|
27
|
-
resolve(); }));
|
|
28
|
-
// The same repository owns VERSION_DRIFT, immutable objects and the atomic index commit.
|
|
29
|
-
// Reparse/checks inside install protect the handoff from mutations. No second interpreter.
|
|
26
|
+
const validate = async (bundle) => validateBundleContent(bundle, await nativePackValidator(p.nativeEngineModuleUrl, p.limits));
|
|
30
27
|
const repository = new ContentPackRepository(p.root);
|
|
31
|
-
const installed = p.updateFrom
|
|
28
|
+
const installed = p.updateFrom
|
|
29
|
+
? await repository.update(p.updateFrom, bytes, validate, p.installationRevision ?? 0, hooks)
|
|
30
|
+
: await repository.install(bytes, validate, p.installationRevision ?? 0, hooks);
|
|
32
31
|
parentPort.postMessage({ phase: 'INSTALLED', ref: installed.ref });
|
|
33
32
|
}
|
|
34
33
|
catch (error) {
|
|
@@ -268,14 +268,15 @@ export class OnlinePacks {
|
|
|
268
268
|
this.preparing = new Promise(resolve => { release = resolve; });
|
|
269
269
|
let created = false;
|
|
270
270
|
try {
|
|
271
|
-
|
|
271
|
+
const snapshot = this.snapshot;
|
|
272
|
+
if (!snapshot || input.snapshotId !== snapshot.id)
|
|
272
273
|
fail('CATALOG_STALE');
|
|
273
|
-
const pack =
|
|
274
|
+
const pack = snapshot.packages.find(p => p.id === input.packId && p.version === input.version);
|
|
274
275
|
if (!pack)
|
|
275
276
|
fail('PACKAGE_NOT_IN_CATALOG');
|
|
277
|
+
if (!isPackageCompatible(pack.compatibility, this.versions()))
|
|
278
|
+
fail('INCOMPATIBLE');
|
|
276
279
|
if (input.from) {
|
|
277
|
-
if (!isPackageCompatible(pack.compatibility, this.versions()))
|
|
278
|
-
fail('INCOMPATIBLE');
|
|
279
280
|
const current = (await new ContentPackRepository(this.root).listCurrent()).find(p => p.ref.packId === pack.id);
|
|
280
281
|
if (!current || current.uninstalled || current.deletionPending || current.ref.packId !== input.from.packId || current.ref.version !== input.from.version || current.ref.contentSha256 !== input.from.contentSha256 || (compareReleaseVersions(pack.version, current.ref.version) ?? -1) <= 0)
|
|
281
282
|
fail('UPDATE_CONFLICT');
|
|
@@ -287,7 +288,7 @@ export class OnlinePacks {
|
|
|
287
288
|
if (!oag.validationEngineModuleUrl?.startsWith('file:'))
|
|
288
289
|
fail('OAG_UNAVAILABLE');
|
|
289
290
|
const now = new Date().toISOString();
|
|
290
|
-
this.job = { id: randomUUID(), snapshotId:
|
|
291
|
+
this.job = { id: randomUUID(), snapshotId: snapshot.id, packId: pack.id, version: pack.version, sha256: pack.archive.sha256, phase: 'PREPARING', receivedBytes: 0, totalBytes: pack.archive.bytes, startedAt: now, updatedAt: now, installationRevision, ...(input.from ? { updateFrom: structuredClone(input.from) } : {}) };
|
|
291
292
|
this.controller = new AbortController();
|
|
292
293
|
created = true;
|
|
293
294
|
await this.persist();
|
|
@@ -76,11 +76,15 @@ function fragmentIdentitySha256(fragment) {
|
|
|
76
76
|
excerptDigest: fragment.excerptDigest,
|
|
77
77
|
contentSha256: fragment.contentSha256,
|
|
78
78
|
orderKey: fragment.orderKey,
|
|
79
|
+
...(fragment.contentStatus === undefined ? {} : { contentStatus: fragment.contentStatus }),
|
|
79
80
|
}));
|
|
80
81
|
}
|
|
81
82
|
function factIri(factId) {
|
|
82
83
|
return `urn:buildseek:engineering-document:fact:${encodeURIComponent(factId)}`;
|
|
83
84
|
}
|
|
85
|
+
function factValueSha256(fact) {
|
|
86
|
+
return canonicalSha256(asJson({ value: fact.value, valueType: fact.valueType, unit: fact.unit }));
|
|
87
|
+
}
|
|
84
88
|
function turtleLiteral(value) {
|
|
85
89
|
return JSON.stringify(value);
|
|
86
90
|
}
|
|
@@ -89,13 +93,13 @@ function compileFactGraph(request) {
|
|
|
89
93
|
.slice()
|
|
90
94
|
.sort((left, right) => utf8Compare(left.factId, right.factId))
|
|
91
95
|
.map((fact) => {
|
|
92
|
-
const valueSha256 =
|
|
96
|
+
const valueSha256 = factValueSha256(fact);
|
|
93
97
|
return `<${factIri(fact.factId)}> a <${fact.ontologyConcept}> ; <urn:buildseek:engineering-document:fact-id> ${turtleLiteral(fact.factId)} ; <urn:buildseek:engineering-document:field> ${turtleLiteral(fact.field)} ; <urn:buildseek:engineering-document:value-type> ${turtleLiteral(fact.valueType)} ; <urn:buildseek:engineering-document:value-sha256> ${turtleLiteral(valueSha256)} .`;
|
|
94
98
|
})
|
|
95
99
|
.join('\n')}\n`;
|
|
96
100
|
}
|
|
97
101
|
function factBindingAsk(fact) {
|
|
98
|
-
const valueSha256 =
|
|
102
|
+
const valueSha256 = factValueSha256(fact);
|
|
99
103
|
return `ASK { <${factIri(fact.factId)}> a <${fact.ontologyConcept}> ; <urn:buildseek:engineering-document:fact-id> ${turtleLiteral(fact.factId)} ; <urn:buildseek:engineering-document:field> ${turtleLiteral(fact.field)} ; <urn:buildseek:engineering-document:value-type> ${turtleLiteral(fact.valueType)} ; <urn:buildseek:engineering-document:value-sha256> ${turtleLiteral(valueSha256)} . }`;
|
|
100
104
|
}
|
|
101
105
|
function assertQueryResult(value, request, queryRequest, expectedSnapshot) {
|
|
@@ -157,7 +161,8 @@ function assertQueryResult(value, request, queryRequest, expectedSnapshot) {
|
|
|
157
161
|
hit.citation.clauseId !== hit.fragment.clauseId ||
|
|
158
162
|
!sameLocation(hit.citation.location, hit.fragment) ||
|
|
159
163
|
hit.citation.excerptDigest !== hit.fragment.excerptDigest ||
|
|
160
|
-
|
|
164
|
+
(hit.fragment.contentSha256 !== hit.fragment.excerptDigest &&
|
|
165
|
+
textSha256(hit.fragment.normalizedText) !== hit.fragment.excerptDigest) ||
|
|
161
166
|
hit.citation.sourceDocumentId !== hit.source.sourceDocumentId ||
|
|
162
167
|
hit.citation.sourceVersion !== hit.source.sourceVersion ||
|
|
163
168
|
hit.citation.byteSha256 !== hit.source.byteSha256)) {
|
|
@@ -170,6 +175,19 @@ function assertResolution(value, hit, snapshotId, projectRef) {
|
|
|
170
175
|
if (!parsed.success)
|
|
171
176
|
fail('RAG_CITATION_INVALID', 'RAG');
|
|
172
177
|
const resolution = parsed.data;
|
|
178
|
+
const { excerpt } = resolution;
|
|
179
|
+
const { originalText: original, legacyTextNormalization } = resolution.fragment;
|
|
180
|
+
const fullText = original ?? excerpt;
|
|
181
|
+
let indexedText = fullText;
|
|
182
|
+
if (legacyTextNormalization === 'lf-trim')
|
|
183
|
+
indexedText = fullText.replace(/\r\n?/gu, '\n').trim();
|
|
184
|
+
if (legacyTextNormalization === 'nfc-trim')
|
|
185
|
+
indexedText = fullText.normalize('NFC').trim();
|
|
186
|
+
const matchesSearchDigest = textSha256(hit.fragment.normalizedText) === hit.fragment.excerptDigest;
|
|
187
|
+
const validExcerpt = fullText.startsWith(excerpt) && textSha256(indexedText) === hit.fragment.contentSha256 &&
|
|
188
|
+
(legacyTextNormalization === undefined || matchesSearchDigest) ||
|
|
189
|
+
legacyTextNormalization === undefined && original === undefined && matchesSearchDigest &&
|
|
190
|
+
hit.fragment.normalizedText.startsWith(excerpt);
|
|
173
191
|
if (resolution.indexSnapshotId !== snapshotId ||
|
|
174
192
|
resolution.citation.indexSnapshotId !== snapshotId ||
|
|
175
193
|
resolution.citation.projectRef !== projectRef ||
|
|
@@ -183,10 +201,11 @@ function assertResolution(value, hit, snapshotId, projectRef) {
|
|
|
183
201
|
!sameLocation(resolution.citation.location, hit.citation.location) ||
|
|
184
202
|
resolution.fragment.fragmentId !== hit.fragment.fragmentId ||
|
|
185
203
|
resolution.fragment.excerptDigest !== hit.fragment.excerptDigest ||
|
|
204
|
+
resolution.fragment.contentStatus !== hit.fragment.contentStatus ||
|
|
186
205
|
resolution.citation.excerptDigest !== hit.fragment.excerptDigest ||
|
|
187
206
|
resolution.excerpt.length < 1 ||
|
|
188
207
|
resolution.excerpt.length > 4096 ||
|
|
189
|
-
|
|
208
|
+
!validExcerpt ||
|
|
190
209
|
resolution.citation.sourceDocumentId !== resolution.source.sourceDocumentId ||
|
|
191
210
|
resolution.citation.sourceVersion !== resolution.source.sourceVersion ||
|
|
192
211
|
resolution.citation.byteSha256 !== resolution.source.byteSha256 ||
|
|
@@ -259,7 +278,7 @@ function compileDocument(request, evidence, requestSha256) {
|
|
|
259
278
|
(['string', 'date', 'identifier', 'name'].includes(fact.valueType) &&
|
|
260
279
|
typeof fact.value === 'string' &&
|
|
261
280
|
fact.value.length > 0);
|
|
262
|
-
if (!valueMatches)
|
|
281
|
+
if (!valueMatches || (fact.unit !== undefined && fact.valueType !== 'number'))
|
|
263
282
|
fail('EDP_FACT_BINDING_INVALID', 'COMPILATION');
|
|
264
283
|
const citationIds = [
|
|
265
284
|
...new Set(fact.citationQueryIds.flatMap((queryId) => citationIdsByQuery.get(queryId) ?? [])),
|
|
@@ -273,6 +292,7 @@ function compileDocument(request, evidence, requestSha256) {
|
|
|
273
292
|
field: fact.field,
|
|
274
293
|
value: fact.value,
|
|
275
294
|
valueType: fact.valueType,
|
|
295
|
+
...(fact.unit !== undefined ? { unit: fact.unit } : {}),
|
|
276
296
|
ontologyConcept: fact.ontologyConcept,
|
|
277
297
|
citationIds,
|
|
278
298
|
};
|