mcard-studio 0.0.2 → 0.0.3
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 +3 -0
- package/astro.config.mjs +41 -2
- package/cli/lib/runtimeContext.mjs +6 -3
- package/dist/client/_astro/{ChartAnalyticsViewlet.jrwIemvb.js → ChartAnalyticsViewlet.CBW-JyA3.js} +1 -1
- package/dist/client/_astro/{ClmPcardViewlet.C-fU7oZf.js → ClmPcardViewlet.cvKsR2ng.js} +2 -2
- package/dist/client/_astro/{D3GraphViewlet.BCZl0b2U.js → D3GraphViewlet.8YEIrCGL.js} +1 -1
- package/dist/client/_astro/DockviewSpatialWorkbench.BTd66LPl.js +12 -0
- package/dist/client/_astro/DocumentViewlets.KY1HcNka.js +2 -0
- package/dist/client/_astro/DxfViewlet.B3N5zpZR.js +1 -0
- package/dist/client/_astro/{ExcalidrawWhiteboardViewlet.CFpPYSdn.js → ExcalidrawWhiteboardViewlet.CMJGCQN4.js} +1 -1
- package/dist/client/_astro/{FaroVCardSpanInstrumenter.un8kDMWv.js → FaroVCardSpanInstrumenter.ClIqZujq.js} +1 -1
- package/dist/client/_astro/{FontSpecimenViewlet.D7Aw2xBZ.js → FontSpecimenViewlet.ChIyr0B8.js} +1 -1
- package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.D3FSc061.js +1 -0
- package/dist/client/_astro/{ImageViewlet.D4FN87n_.js → ImageViewlet.Cs-u7-wt.js} +1 -1
- package/dist/client/_astro/{KatexFormulaViewlet.CzhdIOw8.js → KatexFormulaViewlet.0nOzV_qD.js} +1 -1
- package/dist/client/_astro/{KoishiChatViewlet.5mepQvLX.js → KoishiChatViewlet.DLsMmwdb.js} +4 -4
- package/dist/client/_astro/{MCardLibraryHarness.DE8KeghO.js → MCardLibraryHarness.WBT9W10S.js} +1 -1
- package/dist/client/_astro/{MarkdownViewlet.CRuuXXmF.js → MarkdownViewlet.BIolkNXf.js} +25 -25
- package/dist/client/_astro/{MermaidDiagramViewlet.eW6sk-rF.js → MermaidDiagramViewlet.CkRk7QsS.js} +1 -1
- package/dist/client/_astro/PCardRendererBridge.DhaRSprd.js +1 -0
- package/dist/client/_astro/RendererPCardRegistry.brM2KiQs.js +1 -0
- package/dist/client/_astro/{SchemaYamlViewlet.ZJBvxItR.js → SchemaYamlViewlet.Bc7nkK4M.js} +1 -1
- package/dist/client/_astro/{ShellContainer.astro_astro_type_script_index_0_lang.j_ELcN5d.js → ShellContainer.astro_astro_type_script_index_0_lang.5q1gCLvf.js} +1 -1
- package/dist/client/_astro/{Spatial3dViewlet.DnVMBENJ.js → Spatial3dViewlet.C-jjhr0A.js} +1 -1
- package/dist/client/_astro/{StudioLayout.CBgiVbeb.css → StudioLayout.CX8XGtZV.css} +1 -1
- package/dist/client/_astro/StudioWorkbench.B1QwGHWM.js +7 -0
- package/dist/client/_astro/{SvgViewlet.BCje7Qqb.js → SvgViewlet.uGxvb06H.js} +1 -1
- package/dist/client/_astro/{TerminalView.C_Ksz6lT.js → TerminalView.DP7G7E1m.js} +1 -1
- package/dist/client/_astro/{ThemeSettingsViewlet.DJpjQQ0Z.js → ThemeSettingsViewlet.UaTHcGnF.js} +1 -1
- package/dist/client/_astro/{TikzDiagramViewlet.CXb1A8nf.js → TikzDiagramViewlet.O8MJyXfT.js} +1 -1
- package/dist/client/_astro/VideoPlayerViewlet.-ycmo3kY.js +1 -0
- package/dist/client/_astro/WebappZenViewlet.PNce4u2T.js +1 -0
- package/dist/client/_astro/{WelcomeViewport.BiYwLh6l.js → WelcomeViewport.CZ6RxGSw.js} +1 -1
- package/dist/client/_astro/{agentIdentityCredentialService.UzMMwBwv.js → agentIdentityCredentialService.BEtZzBlO.js} +1 -1
- package/dist/client/_astro/cardTypeDetector.C2HH5RnU.js +1 -0
- package/dist/client/_astro/disposable.BmlxZrDf.js +1 -0
- package/dist/client/_astro/{markdownService.BgWjyJ57.js → markdownService.CpuKl0vp.js} +1 -1
- package/dist/client/_astro/{mcardStore.CT-ollfl.js → mcardStore.nSWnzeLg.js} +1 -1
- package/dist/client/_astro/mcardVfs.BSdys1Y7.js +3 -0
- package/dist/client/_astro/pathsConfig.CSBBSzwH.js +2 -0
- package/dist/client/_astro/{polyfills._3wYPjZf.js → polyfills.Bi7kO8cu.js} +1 -1
- package/dist/client/_astro/rendererEventBus.DirFDmGw.js +1 -0
- package/dist/client/_astro/themeStore.BajxvCga.js +1 -0
- package/dist/client/_astro/{tikzCompiler.fe3qomFY.js → tikzCompiler.-fXMNQpz.js} +1 -1
- package/dist/client/_astro/{useMCardHydration.7Z-HfBh5.js → useMCardHydration.Bjj_N5Gv.js} +1 -1
- package/dist/client/_astro/vendor-clm-kernel.B0kxq3g4.js +108 -0
- package/dist/client/_astro/{vfsHandles.IX_wTpw_.js → vfsHandles.D4Pq18pW.js} +1 -1
- package/dist/client/_astro/vfsPersistence.DVrd1BZj.js +1 -0
- package/dist/client/_astro/{vfsTransactions.C_IQQg0s.js → vfsTransactions.DBNtFuRz.js} +1 -1
- package/dist/client/_astro/{workspaceStore.CD0kAVAl.js → workspaceStore.DUHW2YBc.js} +1 -1
- package/dist/server/chunks/{_.._5gPhVOLM.mjs → _.._CoQKwo62.mjs} +137 -91
- package/dist/server/chunks/{_handle__D_cIJYrU.mjs → _handle__D8dKQPUS.mjs} +3 -3
- package/dist/server/chunks/{cardTypeDetector_CyW1Xnmy.mjs → cardTypeDetector_C55M_HWS.mjs} +9 -0
- package/dist/server/chunks/{cards_B89BvF6W.mjs → cards_rVOc8K6H.mjs} +2 -2
- package/dist/server/chunks/cas_DTxlZ4Le.mjs +68 -0
- package/dist/server/chunks/{dispatch_DOwSKukU.mjs → dispatch_BTW4E_BJ.mjs} +8 -7
- package/dist/server/chunks/{dispatch_CxWKiHpn.mjs → dispatch_MbkljUxD.mjs} +8 -8
- package/dist/server/chunks/{export_DRouradA.mjs → export_DkEwDE2T.mjs} +3 -3
- package/dist/server/chunks/{health_Dfa5I0-X.mjs → health_cRt0M0yu.mjs} +1 -1
- package/dist/server/chunks/{mcard-library_7Wzoihkm.mjs → mcard-library_CLHvyslV.mjs} +1 -1
- package/dist/server/chunks/{mcardVfs_CeezzRvt.mjs → mcardVfs_DvNburKb.mjs} +5 -30
- package/dist/server/chunks/{move__RFvIDkq.mjs → move_DYcaXBLV.mjs} +6 -6
- package/dist/server/chunks/{pathsConfig_CgNYYLVm.mjs → pathsConfig_Dack-p2f.mjs} +13 -3
- package/dist/server/chunks/{proxy_CrWJQIBe.mjs → proxy_CMbbdBPW.mjs} +2 -2
- package/dist/server/chunks/{raw_DzNDaDVP.mjs → raw_C97sJWhg.mjs} +59 -26
- package/dist/server/chunks/{serverBootstrap_XKo2s6Ha.mjs → serverBootstrap_BDdSRIu5.mjs} +2 -2
- package/dist/server/chunks/tree_BwmO-pTe.mjs +186 -0
- package/dist/server/chunks/vfsCore_DIKpk-pk.mjs +98 -0
- package/dist/server/chunks/{vfsTreeScan_CKp7kMt9.mjs → vfsTreeScan_CRoCluPB.mjs} +18 -10
- package/dist/server/chunks/workspaceRoot_CRx3taID.mjs +157 -0
- package/dist/server/chunks/{write_popiFsO7.mjs → write_BLsmsTIx.mjs} +6 -5
- package/dist/server/chunks/{ws-server-init_DUjuR2-o.mjs → ws-server-init_Cfft7U5u.mjs} +343 -298
- package/dist/server/entry.mjs +1 -1
- package/dist/server/entry2.mjs +67 -28
- package/dist/server/virtual_astro_middleware.mjs +2 -2
- package/package.json +2 -2
- package/src/components/studio/views/cardViewlets/ClmRegistryComponentViewlet.tsx +133 -0
- package/src/components/studio/views/cardViewlets/DxfViewlet.tsx +230 -0
- package/src/components/studio/views/cardViewlets/VideoPlayerViewlet.tsx +4 -4
- package/src/components/studio/views/cardViewlets/coreViewletDefs.ts +2 -2
- package/src/components/studio/views/cardViewlets/documents/AudioPlayerViewlet.tsx +15 -3
- package/src/components/studio/views/cardViewlets/documents/PdfViewlet.tsx +25 -7
- package/src/components/studio/views/cardViewlets/markdown/stages/wikilinkStage.ts +2 -1
- package/src/components/studio/views/cardViewlets/mediaViewletDefs.ts +21 -1
- package/src/components/studio/views/cardViewlets/webapp/WebappCanvas.tsx +40 -15
- package/src/components/studio/views/cardViewlets/webapp/WebappDevicePresetBar.tsx +108 -0
- package/src/components/studio/views/cardViewlets/webapp/WebappZenViewlet.tsx +23 -30
- package/src/components/studio/views/fileTree/MCardFileTree.tsx +71 -54
- package/src/components/studio/views/fileTree/hooks/useFileTreeSync.ts +0 -1
- package/src/components/studio/views/fileTree/hooks/usePartitionedTrees.ts +68 -23
- package/src/components/studio/views/fileTree/hooks/useSectionAccordion.ts +21 -11
- package/src/components/studio/views/functions/UnifiedFunctionExplorerViewlet.tsx +168 -0
- package/src/components/studio/views/history/HistoryPanel.tsx +110 -0
- package/src/components/studio/views/lineage/LineagePanel.tsx +152 -0
- package/src/components/studio/views/navigation/HandleLineageDrawer.tsx +89 -0
- package/src/components/studio/views/navigation/MultiCardCollectionBrowser.tsx +154 -0
- package/src/components/studio/views/pills/HashPill.tsx +101 -0
- package/src/components/studio/views/residency/ResidencyIndicator.tsx +82 -0
- package/src/config/app_config.json +3 -3
- package/src/core/projection/catalog.ts +105 -0
- package/src/core/projection/collection.ts +148 -0
- package/src/core/projection/handleSubscription.ts +132 -0
- package/src/core/projection/index.ts +4 -0
- package/src/core/projection/selectors.ts +29 -0
- package/src/core/projection/views.ts +242 -0
- package/src/core/refinement/designMetrics.ts +104 -0
- package/src/core/refinement/fibrationProjector.ts +142 -0
- package/src/core/refinement/lagrangianEngine.ts +137 -0
- package/src/core/refinement/refinementCommands.ts +82 -0
- package/src/core/viewport/deviceArchetypeRegistry.ts +177 -0
- package/src/core/viewport/viewportAudit.ts +150 -0
- package/src/edge/storeFilter.d.ts +4 -0
- package/src/edge/storeFilter.js +54 -0
- package/src/edge/storeFilter.ts +52 -0
- package/src/lib/cryptoPolyfill.js +77 -1
- package/src/lib/fsPolyfill.js +65 -0
- package/src/lib/urlPolyfill.js +21 -0
- package/src/lib/zlibPolyfill.js +35 -0
- package/src/packages/mcard-studio/package.json +2 -2
- package/src/packages/mcard-studio/type/legacyMapping.ts +5 -0
- package/src/packages/mcard-studio/viewlets/manifests.ts +2 -0
- package/src/packages/mcard-studio/viewlets/moduleMap.ts +12 -0
- package/src/packages/mcard-studio/viewlets/refinementManifests.ts +114 -0
- package/src/pages/api/dispatch.ts +3 -2
- package/src/pages/api/vfs/cas.ts +114 -0
- package/src/pages/api/vfs/move.ts +5 -5
- package/src/pages/api/vfs/raw.ts +72 -27
- package/src/pages/api/vfs/tree.ts +130 -11
- package/src/pages/api/vfs/write.ts +5 -4
- package/src/server/api/kernelDispatch.ts +8 -8
- package/src/server/artifactCollectionService.ts +4 -7
- package/src/server/artifactRepository.ts +4 -3
- package/src/server/clmRunner.mjs +1 -1
- package/src/server/collectionOwner.mjs +5 -5
- package/src/server/effects/executionPersistenceService.mjs +11 -11
- package/src/server/effects/resultSealingService.mjs +2 -2
- package/src/server/fileIngestService.mjs +21 -9
- package/src/server/fileWatcherService.mjs +4 -1
- package/src/server/handlers/fileChangeHandler.mjs +18 -10
- package/src/server/handlers/saveExecutionLogHandler.mjs +6 -6
- package/src/server/notificationService.mjs +14 -1
- package/src/server/scripts/buildSeedingMemory.mjs +3 -3
- package/src/server/serverMemoryRepository.ts +41 -59
- package/src/server/vfsTreeScan.ts +16 -10
- package/src/server/workspaceRoot.ts +143 -5
- package/src/services/cardTypeDetector.ts +4 -0
- package/src/services/databaseSyncService.ts +30 -46
- package/src/services/namespaceProtocolClient.ts +221 -0
- package/src/services/renderers/pcard/RendererPCardRegistry.ts +4 -66
- package/src/services/renderers/pcard/modalitySpecs.ts +125 -0
- package/src/services/renderers/pcard/types.ts +7 -1
- package/src/services/renderers/rendererEventBus.ts +5 -3
- package/src/services/unifiedFunctionExecutionService.ts +145 -0
- package/src/services/vfs/vfsCore.ts +12 -1
- package/src/services/vfs/vfsMigration.ts +95 -0
- package/src/services/vfs/vfsMutations.ts +17 -35
- package/src/services/vfs/vfsPersistence.ts +19 -24
- package/src/services/vfs/vfsSync.ts +55 -17
- package/src/services/vfs/vfsVersions.ts +23 -34
- package/src/services/workbenchExecutionPolicy.ts +183 -0
- package/src/stores/mcardCollectionStore.ts +2 -0
- package/src/styles/dockview.css +34 -0
- package/src/ui/viewlets/FibrationRefinementViewlet.tsx +155 -0
- package/src/ui/viewlets/PetriConformanceViewlet.tsx +166 -0
- package/src/ui/viewlets/ResponsiveViewportLabViewlet.tsx +175 -0
- package/src/ui/viewlets/SprintGovernanceViewlet.tsx +176 -0
- package/src/ui/viewlets/viewletFocus.ts +35 -0
- package/src/ui/viewlets/viewportLabParts.tsx +190 -0
- package/dist/client/_astro/DockviewSpatialWorkbench.B_I1GJHw.js +0 -12
- package/dist/client/_astro/DocumentViewlets.B53IqmpY.js +0 -2
- package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.VDRYJCM-.js +0 -1
- package/dist/client/_astro/PCardRendererBridge.oxVKc0gN.js +0 -1
- package/dist/client/_astro/RendererPCardRegistry.CWjYZs2H.js +0 -1
- package/dist/client/_astro/StudioWorkbench.Blo5oSIw.js +0 -7
- package/dist/client/_astro/VideoPlayerViewlet.CmECt7yT.js +0 -1
- package/dist/client/_astro/WebappZenViewlet.whCmGVHR.js +0 -1
- package/dist/client/_astro/__vite-browser-external.CQZnr-r3.js +0 -1
- package/dist/client/_astro/cardTypeDetector.Ci4APwhX.js +0 -1
- package/dist/client/_astro/disposable.Dsb0sbRP.js +0 -1
- package/dist/client/_astro/mcardVfs.2UOw9Z-r.js +0 -3
- package/dist/client/_astro/pathsConfig.D0hV34p7.js +0 -2
- package/dist/client/_astro/rendererEventBus.DMH9afq9.js +0 -1
- package/dist/client/_astro/themeStore.CEt0e54l.js +0 -1
- package/dist/client/_astro/vendor-clm-kernel.Bvk3XHk2.js +0 -116
- package/dist/client/_astro/vfsPersistence.BuhXYeSb.js +0 -1
- package/dist/server/chunks/cryptoPolyfill_99rxUwYC.mjs +0 -180
- package/dist/server/chunks/kernelHash_DRaj51hY.mjs +0 -5
- package/dist/server/chunks/tree_CE2BhvyJ.mjs +0 -76
- package/dist/server/chunks/vfsCore_B6nCiBl5.mjs +0 -21
- package/dist/server/chunks/workspaceRoot_DVSUbYkd.mjs +0 -71
- package/src/server/kernelHash.ts +0 -22
- package/src/server/storage/cardCollection.ts +0 -94
- package/src/server/storage/index.ts +0 -3
- package/src/server/storage/mcard.ts +0 -99
- package/src/server/storage/sqliteNodeEngine.ts +0 -121
- /package/dist/server/chunks/{StudioLayout_B5ZnlqjF.mjs → StudioLayout_taayQJ5b.mjs} +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VFS Migration — One-time retirement migration for legacy clm_workbench_db (DoD-05-3, D7, R7)
|
|
3
|
+
* Canonical Path: src/services/vfs/vfsMigration.ts
|
|
4
|
+
* NOTE: Migration file scheduled for deletion after replica retirement.
|
|
5
|
+
*
|
|
6
|
+
* Reads legacy clm_cas_blobs, clm_handle_registry, clm_handle_history and clm_sqlite_snapshots
|
|
7
|
+
* into kernel-owned CAS driver, then deletes clm_workbench_db.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { ContentHash, AgentDid } from 'clm-kernel';
|
|
11
|
+
|
|
12
|
+
const DB_NAME = 'clm_workbench_db';
|
|
13
|
+
const DB_VERSION = 2;
|
|
14
|
+
|
|
15
|
+
export const STORE_CAS = 'clm_cas_blobs';
|
|
16
|
+
export const STORE_HANDLES = 'clm_handle_registry';
|
|
17
|
+
export const STORE_HISTORY = 'clm_handle_history';
|
|
18
|
+
export const STORE_SNAPSHOTS = 'clm_sqlite_snapshots';
|
|
19
|
+
export const STORE_LEGACY = 'clm_content_memory_db';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Migration-only IndexedDB opener.
|
|
23
|
+
* Scheduled for deletion once all client replicas migrate to kernel CAS driver.
|
|
24
|
+
*/
|
|
25
|
+
export function openMigrationIndexedDb(): Promise<IDBDatabase> {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
if (typeof window === 'undefined' || !window.indexedDB) {
|
|
28
|
+
return reject(new Error('IndexedDB not available'));
|
|
29
|
+
}
|
|
30
|
+
const req = window.indexedDB.open(DB_NAME, DB_VERSION);
|
|
31
|
+
req.onupgradeneeded = () => {
|
|
32
|
+
const db = req.result;
|
|
33
|
+
if (!db.objectStoreNames.contains(STORE_CAS)) db.createObjectStore(STORE_CAS, { keyPath: 'hash' });
|
|
34
|
+
if (!db.objectStoreNames.contains(STORE_HANDLES)) db.createObjectStore(STORE_HANDLES, { keyPath: 'handle' });
|
|
35
|
+
if (!db.objectStoreNames.contains(STORE_HISTORY)) db.createObjectStore(STORE_HISTORY, { keyPath: 'id', autoIncrement: true });
|
|
36
|
+
if (!db.objectStoreNames.contains(STORE_SNAPSHOTS)) db.createObjectStore(STORE_SNAPSHOTS, { keyPath: 'id' });
|
|
37
|
+
if (!db.objectStoreNames.contains(STORE_LEGACY)) db.createObjectStore(STORE_LEGACY);
|
|
38
|
+
};
|
|
39
|
+
req.onsuccess = () => resolve(req.result);
|
|
40
|
+
req.onerror = () => reject(req.error);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Executes one-time migration from legacy clm_workbench_db to kernel driver, then deletes database.
|
|
46
|
+
*/
|
|
47
|
+
export async function migrateAndRetireLegacyIndexedDb(targetFs?: any): Promise<boolean> {
|
|
48
|
+
if (typeof window === 'undefined' || !window.indexedDB) return false;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const db = await openMigrationIndexedDb();
|
|
52
|
+
const storeNames = Array.from(db.objectStoreNames);
|
|
53
|
+
|
|
54
|
+
if (storeNames.includes(STORE_CAS)) {
|
|
55
|
+
const tx = db.transaction([STORE_CAS], 'readonly');
|
|
56
|
+
const store = tx.objectStore(STORE_CAS);
|
|
57
|
+
const req = store.getAll();
|
|
58
|
+
await new Promise<void>((resolve) => {
|
|
59
|
+
req.onsuccess = () => {
|
|
60
|
+
const items = (req.result as any[]) || [];
|
|
61
|
+
for (const item of items) {
|
|
62
|
+
if (item.hash && item.content) {
|
|
63
|
+
try {
|
|
64
|
+
const ch = ContentHash.parse(item.hash);
|
|
65
|
+
const bytes = typeof item.content === 'string'
|
|
66
|
+
? new TextEncoder().encode(item.content)
|
|
67
|
+
: (item.content instanceof Uint8Array ? item.content : new Uint8Array(item.content));
|
|
68
|
+
if (targetFs && typeof targetFs.writeFile === 'function') {
|
|
69
|
+
targetFs.writeFile(item.handle || item.hash, bytes);
|
|
70
|
+
}
|
|
71
|
+
} catch {}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
resolve();
|
|
75
|
+
};
|
|
76
|
+
req.onerror = () => resolve();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
db.close();
|
|
81
|
+
|
|
82
|
+
// Delete legacy replica database
|
|
83
|
+
await new Promise<void>((resolve, reject) => {
|
|
84
|
+
const delReq = window.indexedDB.deleteDatabase(DB_NAME);
|
|
85
|
+
delReq.onsuccess = () => resolve();
|
|
86
|
+
delReq.onerror = () => reject(delReq.error);
|
|
87
|
+
delReq.onblocked = () => resolve();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return true;
|
|
91
|
+
} catch (err) {
|
|
92
|
+
console.warn('[VFS Migration] Migration completed or database already retired:', err);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -50,39 +50,19 @@ export function propagateHandleReferenceUpdate(
|
|
|
50
50
|
|
|
51
51
|
// Deduplicate unique cards by handle
|
|
52
52
|
const uniqueCardsMap = new Map<string, MCardFileNode>();
|
|
53
|
-
for (const node of Object.values(tree))
|
|
54
|
-
if (node && node.handle) {
|
|
55
|
-
uniqueCardsMap.set(node.handle, node);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
53
|
+
for (const node of Object.values(tree)) if (node?.handle) uniqueCardsMap.set(node.handle, node);
|
|
58
54
|
|
|
59
55
|
const oldHandleRegex = new RegExp(escapeRegExp(oldHandle), 'g');
|
|
60
56
|
const oldPathRegex = new RegExp(escapeRegExp(oldPath), 'g');
|
|
61
57
|
|
|
62
58
|
for (const card of uniqueCardsMap.values()) {
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
card.handle === oldHandle ||
|
|
66
|
-
card.handle === newHandle ||
|
|
67
|
-
card.path === oldPath ||
|
|
68
|
-
card.path === newPath
|
|
69
|
-
) {
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
59
|
+
if (card.handle === oldHandle || card.handle === newHandle || card.path === oldPath || card.path === newPath) continue;
|
|
72
60
|
|
|
73
61
|
if (typeof card.content === 'string') {
|
|
74
62
|
let content = card.content;
|
|
75
63
|
let hasUpdate = false;
|
|
76
|
-
|
|
77
|
-
if (content.includes(
|
|
78
|
-
content = content.replace(oldHandleRegex, newHandle);
|
|
79
|
-
hasUpdate = true;
|
|
80
|
-
}
|
|
81
|
-
if (content.includes(oldPath)) {
|
|
82
|
-
content = content.replace(oldPathRegex, newPath);
|
|
83
|
-
hasUpdate = true;
|
|
84
|
-
}
|
|
85
|
-
|
|
64
|
+
if (content.includes(oldHandle)) { content = content.replace(oldHandleRegex, newHandle); hasUpdate = true; }
|
|
65
|
+
if (content.includes(oldPath)) { content = content.replace(oldPathRegex, newPath); hasUpdate = true; }
|
|
86
66
|
if (hasUpdate) {
|
|
87
67
|
updateMCardContent(card.handle, content);
|
|
88
68
|
updatedHandles.push(card.handle);
|
|
@@ -90,10 +70,7 @@ export function propagateHandleReferenceUpdate(
|
|
|
90
70
|
}
|
|
91
71
|
}
|
|
92
72
|
|
|
93
|
-
return {
|
|
94
|
-
referencingCardsUpdated: updatedHandles.length,
|
|
95
|
-
updatedHandles,
|
|
96
|
-
};
|
|
73
|
+
return { referencingCardsUpdated: updatedHandles.length, updatedHandles };
|
|
97
74
|
}
|
|
98
75
|
|
|
99
76
|
/**
|
|
@@ -185,15 +162,20 @@ export async function renameMCardFile(
|
|
|
185
162
|
// Note: content, hash, detectedType, epistemicStatus, and subclass remain strictly identical (INV-284-02)
|
|
186
163
|
};
|
|
187
164
|
|
|
188
|
-
// 1.
|
|
165
|
+
// 1. Delegate rename directly to kernel relocate (DoD-03-6, INV-CAS-05)
|
|
189
166
|
try {
|
|
190
|
-
|
|
191
|
-
const coreHash = ContentHash.parse(existingNode.hash);
|
|
192
|
-
studioMCardFs.storageBackend.registerHandle(coreHandle, coreHash);
|
|
193
|
-
const slashHandle = Handle.parse(newPath);
|
|
194
|
-
studioMCardFs.storageBackend.registerHandle(slashHandle, coreHash);
|
|
167
|
+
studioMCardFs.relocate(oldPath, newPath);
|
|
195
168
|
} catch {
|
|
196
|
-
|
|
169
|
+
try {
|
|
170
|
+
studioMCardFs.relocate(oldHandle, newHandle);
|
|
171
|
+
} catch {
|
|
172
|
+
// Fall back to handle registration in test mocks
|
|
173
|
+
try {
|
|
174
|
+
const coreHandle = Handle.parse(newHandle);
|
|
175
|
+
const coreHash = ContentHash.parse(existingNode.hash);
|
|
176
|
+
studioMCardFs.storageBackend.registerHandle(coreHandle, coreHash);
|
|
177
|
+
} catch {}
|
|
178
|
+
}
|
|
197
179
|
}
|
|
198
180
|
|
|
199
181
|
// 2. Update $mcardTree atomically
|
|
@@ -15,30 +15,24 @@ const WS_DIR = PATHS.paths.workspace_dirname;
|
|
|
15
15
|
const DB_NAME = 'clm_workbench_db';
|
|
16
16
|
const DB_VERSION = 2;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!db.objectStoreNames.contains(STORE_LEGACY)) db.createObjectStore(STORE_LEGACY);
|
|
37
|
-
};
|
|
38
|
-
req.onsuccess = () => resolve(req.result);
|
|
39
|
-
req.onerror = () => reject(req.error);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
18
|
+
import {
|
|
19
|
+
openMigrationIndexedDb as openIndexedDb,
|
|
20
|
+
STORE_CAS,
|
|
21
|
+
STORE_HANDLES,
|
|
22
|
+
STORE_HISTORY,
|
|
23
|
+
STORE_SNAPSHOTS,
|
|
24
|
+
STORE_LEGACY,
|
|
25
|
+
migrateAndRetireLegacyIndexedDb,
|
|
26
|
+
} from './vfsMigration';
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
openIndexedDb,
|
|
30
|
+
STORE_CAS,
|
|
31
|
+
STORE_HANDLES,
|
|
32
|
+
STORE_HISTORY,
|
|
33
|
+
STORE_SNAPSHOTS,
|
|
34
|
+
migrateAndRetireLegacyIndexedDb,
|
|
35
|
+
};
|
|
42
36
|
|
|
43
37
|
export async function idbGet<T>(storeName: string, key: IDBValidKey): Promise<T | undefined> {
|
|
44
38
|
try {
|
|
@@ -91,6 +85,7 @@ async function performPersistenceFlush(): Promise<void> {
|
|
|
91
85
|
const casStore = tx.objectStore(STORE_CAS);
|
|
92
86
|
const handleStore = tx.objectStore(STORE_HANDLES);
|
|
93
87
|
|
|
88
|
+
handleStore.clear();
|
|
94
89
|
for (const n of wsEntries) {
|
|
95
90
|
if (n.hash && n.content !== undefined) {
|
|
96
91
|
casStore.put({ hash: n.hash, content: n.content, mimeType: n.mimeType, size: typeof n.content === 'string' ? n.content.length : (n.content as any)?.byteLength || 0 });
|
|
@@ -49,18 +49,20 @@ export async function syncMCardVfsWithServer(
|
|
|
49
49
|
|
|
50
50
|
// Entering local-db -> restore the database projection, never trust directory nodes
|
|
51
51
|
if (activeScope === 'local-db') {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
52
|
+
if (lastScope !== 'local-db') {
|
|
53
|
+
let localTree = localDbTreeSnapshot;
|
|
54
|
+
if (Object.keys(localTree).length === 0) {
|
|
55
|
+
if (typeof window !== 'undefined') {
|
|
56
|
+
await hydrateFromIndexedDb();
|
|
57
|
+
}
|
|
58
|
+
localTree = { ...$mcardTree.get() };
|
|
59
|
+
localDbTreeSnapshot = localTree;
|
|
60
|
+
} else {
|
|
61
|
+
$mcardTree.set(localTree);
|
|
56
62
|
}
|
|
57
|
-
localTree = { ...$mcardTree.get() };
|
|
58
|
-
localDbTreeSnapshot = localTree;
|
|
59
|
-
} else {
|
|
60
|
-
$mcardTree.set(localTree);
|
|
61
63
|
}
|
|
62
64
|
lastScope = activeScope;
|
|
63
|
-
return
|
|
65
|
+
return $mcardTree.get();
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
// Return cached read-only directory tree if available and not forced
|
|
@@ -124,20 +126,56 @@ export async function federateAllScopesIntoTree(
|
|
|
124
126
|
const data = await res.json();
|
|
125
127
|
if (!data.success || !Array.isArray(data.files)) throw new Error('Malformed tree response');
|
|
126
128
|
|
|
127
|
-
const
|
|
129
|
+
const current = $mcardTree.get();
|
|
130
|
+
const merged: Record<string, MCardFileNode> = {};
|
|
128
131
|
for (const file of data.files as MCardFileNode[]) {
|
|
129
132
|
const handle = file.handle || file.path;
|
|
130
133
|
const fileScope = (file as any).scope || PATHS.paths.assets_dirname;
|
|
131
|
-
const existing =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
const existing = current[handle];
|
|
135
|
+
const isPlaceholder = typeof existing?.content === 'string' && existing.content.startsWith('Content-addressed MCard:');
|
|
136
|
+
const mime = (file.mimeType || '').toLowerCase();
|
|
137
|
+
const isMedia =
|
|
138
|
+
(mime.startsWith('image/') && mime !== 'image/svg+xml') ||
|
|
139
|
+
mime.startsWith('audio/') ||
|
|
140
|
+
mime.startsWith('video/') ||
|
|
141
|
+
mime.startsWith('font/') ||
|
|
142
|
+
mime === 'application/pdf' ||
|
|
143
|
+
mime.startsWith('model/');
|
|
144
|
+
|
|
145
|
+
const isReadOnly = typeof file.readOnly === 'boolean' ? file.readOnly : (fileScope !== WS_DIR);
|
|
146
|
+
if (!force && existing && typeof existing.content === 'string' && existing.content.length > 0 && !isPlaceholder && !isMedia) {
|
|
147
|
+
merged[handle] = { ...file, ...existing, scope: fileScope, readOnly: isReadOnly };
|
|
148
|
+
} else {
|
|
149
|
+
merged[handle] = { ...file, scope: fileScope, readOnly: isReadOnly };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Preserve unsaved in-memory drafts that are not yet on the server
|
|
154
|
+
for (const [handle, node] of Object.entries(current)) {
|
|
155
|
+
if (merged[handle]) continue;
|
|
156
|
+
if ((node as any).isDirty || (node as any).isDraft) {
|
|
157
|
+
merged[handle] = node;
|
|
134
158
|
}
|
|
135
|
-
merged[handle] = { ...file, scope: fileScope, readOnly: fileScope !== WS_DIR };
|
|
136
159
|
}
|
|
137
160
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
161
|
+
const currentKeys = Object.keys(current);
|
|
162
|
+
const mergedKeys = Object.keys(merged);
|
|
163
|
+
let changed = currentKeys.length !== mergedKeys.length;
|
|
164
|
+
if (!changed) {
|
|
165
|
+
for (const k of mergedKeys) {
|
|
166
|
+
const a = current[k];
|
|
167
|
+
const b = merged[k];
|
|
168
|
+
if (!a || !b || a.hash !== b.hash || a.scope !== b.scope || a.path !== b.path || a.content !== b.content) {
|
|
169
|
+
changed = true;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (changed || force) {
|
|
176
|
+
$mcardTree.set(merged);
|
|
177
|
+
triggerIndexedDbSync();
|
|
178
|
+
}
|
|
141
179
|
return merged;
|
|
142
180
|
} catch (err) {
|
|
143
181
|
console.warn('[vfsSync] Multi-scope federation failed:', err);
|
|
@@ -36,12 +36,8 @@ export function getMCardHashHistory(handleOrPath: string): Array<{ hash: string;
|
|
|
36
36
|
for (const r of historyRecords) {
|
|
37
37
|
const hex = r.previousHash.asHex();
|
|
38
38
|
const key = `${hex}:${r.changedAt}`;
|
|
39
|
-
if (!seen.has(key)) {
|
|
40
|
-
seen.add(key);
|
|
41
|
-
result.push({ hash: hex, changedAt: r.changedAt });
|
|
42
|
-
}
|
|
39
|
+
if (!seen.has(key)) { seen.add(key); result.push({ hash: hex, changedAt: r.changedAt }); }
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
return result;
|
|
46
42
|
} catch {
|
|
47
43
|
return [];
|
|
@@ -54,6 +50,7 @@ export interface MCardVersionItem {
|
|
|
54
50
|
changedAt: string;
|
|
55
51
|
isHead: boolean;
|
|
56
52
|
isCurrentView: boolean;
|
|
53
|
+
kind?: string;
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
export interface MCardVersionListResult {
|
|
@@ -89,55 +86,47 @@ function computeMCardVersionList(
|
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
88
|
|
|
92
|
-
// 2. Get history records
|
|
89
|
+
// 2. Get history records & transitions (Sprint CAS-03, DoD-03-6)
|
|
90
|
+
const transitions = (studioMCardFs.transitions ? (studioMCardFs.transitions(targetPath).concat(studioMCardFs.transitions(targetHandle))) : []);
|
|
93
91
|
const hist = studioMCardFs.history(targetPath).concat(studioMCardFs.history(targetHandle));
|
|
94
92
|
const seen = new Set<string>();
|
|
95
|
-
const dedupeHist: Array<{ hash: string; changedAt: string }> = [];
|
|
93
|
+
const dedupeHist: Array<{ hash: string; changedAt: string; kind?: string }> = [];
|
|
96
94
|
|
|
97
95
|
for (const h of hist) {
|
|
98
96
|
const hex = h.previousHash.asHex();
|
|
99
97
|
const key = `${hex}:${h.changedAt}`;
|
|
100
|
-
if (!seen.has(key) && hex !== headHash) {
|
|
101
|
-
seen.add(key);
|
|
102
|
-
dedupeHist.push({ hash: hex, changedAt: h.changedAt });
|
|
103
|
-
}
|
|
98
|
+
if (!seen.has(key) && hex !== headHash) { seen.add(key); dedupeHist.push({ hash: hex, changedAt: h.changedAt, kind: (h as any).kind }); }
|
|
104
99
|
}
|
|
105
100
|
|
|
106
|
-
const versions: MCardVersionItem[] =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
isCurrentView: currentlyViewedHash ? currentlyViewedHash === h.hash : false,
|
|
115
|
-
});
|
|
116
|
-
});
|
|
101
|
+
const versions: MCardVersionItem[] = dedupeHist.map((h, idx) => ({
|
|
102
|
+
version: idx + 1,
|
|
103
|
+
hash: h.hash,
|
|
104
|
+
changedAt: h.changedAt,
|
|
105
|
+
isHead: false,
|
|
106
|
+
isCurrentView: currentlyViewedHash === h.hash,
|
|
107
|
+
kind: h.kind || 'UPDATE',
|
|
108
|
+
}));
|
|
117
109
|
|
|
118
110
|
// Active HEAD revision: v(N)
|
|
119
111
|
if (headHash) {
|
|
120
|
-
const isHeadView = currentlyViewedHash ? currentlyViewedHash === headHash : true;
|
|
121
112
|
let headChangedAt = "—";
|
|
122
|
-
try {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
headChangedAt = studioMCardFs.statFile(targetHandle).updatedAt;
|
|
127
|
-
} catch {
|
|
113
|
+
try { headChangedAt = studioMCardFs.statFile(targetPath).updatedAt; }
|
|
114
|
+
catch {
|
|
115
|
+
try { headChangedAt = studioMCardFs.statFile(targetHandle).updatedAt; }
|
|
116
|
+
catch {
|
|
128
117
|
const metaTime = existing?.coreCard?.metadata.get('updatedAt') || existing?.coreCard?.metadata.get('timestamp');
|
|
129
|
-
if (metaTime
|
|
130
|
-
headChangedAt = new Date(metaTime).toISOString();
|
|
131
|
-
}
|
|
118
|
+
if (metaTime) headChangedAt = new Date(metaTime as string | number).toISOString();
|
|
132
119
|
}
|
|
133
120
|
}
|
|
134
|
-
|
|
121
|
+
const latestTransition = transitions[transitions.length - 1];
|
|
122
|
+
const headKind = latestTransition?.kind || (dedupeHist.length === 0 ? 'CREATE' : 'UPDATE');
|
|
135
123
|
versions.push({
|
|
136
124
|
version: versions.length + 1,
|
|
137
125
|
hash: headHash,
|
|
138
126
|
changedAt: headChangedAt,
|
|
139
127
|
isHead: true,
|
|
140
|
-
isCurrentView:
|
|
128
|
+
isCurrentView: currentlyViewedHash ? currentlyViewedHash === headHash : true,
|
|
129
|
+
kind: headKind,
|
|
141
130
|
});
|
|
142
131
|
}
|
|
143
132
|
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcard-studio/src/services/workbenchExecutionPolicy.ts
|
|
3
|
+
* Sprint ULR-08 — Published-Kernel Workbench Contract, Descriptor Inspection,
|
|
4
|
+
* Allowlisted Execution Policy, and Approved Cordis 4-Preset Capability Matrix
|
|
5
|
+
* (INV-ULR-02, INV-ULR-06, INV-ULR-07).
|
|
6
|
+
*/
|
|
7
|
+
import { SavepointGuard, computeContentHash } from 'clm-kernel';
|
|
8
|
+
|
|
9
|
+
export type CordisPresetId = 'minimal' | 'developer' | 'verify' | 'studio';
|
|
10
|
+
|
|
11
|
+
export type WorkbenchEffect =
|
|
12
|
+
| 'read' | 'stat' | 'inspect' | 'write' | 'bind' | 'execute'
|
|
13
|
+
| 'verify_lattice' | 'dry_run_prune' | 'viewport_probe' | 'network' | 'unbounded_network';
|
|
14
|
+
|
|
15
|
+
export interface CordisPresetCapabilitySpec {
|
|
16
|
+
id: CordisPresetId;
|
|
17
|
+
allowedEffects: ReadonlyArray<WorkbenchEffect>;
|
|
18
|
+
forbiddenEffects: ReadonlyArray<WorkbenchEffect>;
|
|
19
|
+
allowedOperations: ReadonlyArray<string>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const PUBLISHED_CLM_KERNEL_008_DESCRIPTOR_EXPORTS = Object.freeze([
|
|
23
|
+
'PlaceMCard', 'TransitionMCard', 'TokenMCard', 'FiringReceiptMCard', 'NetMCard',
|
|
24
|
+
'PetriProcessPCard', 'ChunkerProcessPCard', 'StreamRangeProcessPCard',
|
|
25
|
+
'AnchoredPruningProcessPCard', 'MCardTokenNamespace', 'MCardNamespaceProtocolService',
|
|
26
|
+
'NAMESPACE_PROTOCOL_OPS', 'PlaceTypeLattice', 'MCardMarking',
|
|
27
|
+
] as const);
|
|
28
|
+
|
|
29
|
+
export const WORKSPACE_009_DEFERRED_DESCRIPTOR_EXPORTS = Object.freeze([
|
|
30
|
+
'PCardDescriptor', 'reifyPcardDescriptor', 'reflectPcardDescriptor',
|
|
31
|
+
] as const);
|
|
32
|
+
|
|
33
|
+
export const CORDIS_PRESET_CAPABILITY_MATRIX: Readonly<
|
|
34
|
+
Record<CordisPresetId, CordisPresetCapabilitySpec>
|
|
35
|
+
> = Object.freeze({
|
|
36
|
+
minimal: {
|
|
37
|
+
id: 'minimal',
|
|
38
|
+
allowedEffects: ['read', 'stat', 'inspect'],
|
|
39
|
+
forbiddenEffects: ['write', 'bind', 'execute', 'network', 'unbounded_network'],
|
|
40
|
+
allowedOperations: ['version', 'get', 'stat', 'resolve', 'list', 'history'],
|
|
41
|
+
},
|
|
42
|
+
developer: {
|
|
43
|
+
id: 'developer',
|
|
44
|
+
allowedEffects: ['read', 'stat', 'inspect', 'write', 'bind', 'execute'],
|
|
45
|
+
forbiddenEffects: ['unbounded_network'],
|
|
46
|
+
allowedOperations: [
|
|
47
|
+
'version', 'put', 'get', 'stat', 'resolve', 'bind', 'list', 'history', 'watch', 'petri:execute_step',
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
verify: {
|
|
51
|
+
id: 'verify',
|
|
52
|
+
allowedEffects: ['read', 'stat', 'inspect', 'verify_lattice', 'dry_run_prune'],
|
|
53
|
+
forbiddenEffects: ['write', 'bind', 'execute', 'network', 'unbounded_network'],
|
|
54
|
+
allowedOperations: [
|
|
55
|
+
'version', 'get', 'stat', 'resolve', 'list', 'history', 'lattice:verify', 'prune:dry_run',
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
studio: {
|
|
59
|
+
id: 'studio',
|
|
60
|
+
allowedEffects: [
|
|
61
|
+
'read', 'stat', 'inspect', 'write', 'bind', 'execute',
|
|
62
|
+
'verify_lattice', 'dry_run_prune', 'viewport_probe',
|
|
63
|
+
],
|
|
64
|
+
forbiddenEffects: ['unbounded_network'],
|
|
65
|
+
allowedOperations: [
|
|
66
|
+
'version', 'put', 'get', 'stat', 'resolve', 'bind', 'list', 'history', 'watch',
|
|
67
|
+
'petri:execute_step', 'lattice:verify', 'prune:dry_run', 'viewport:probe',
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export function resolveCordisPresetCapabilities(
|
|
73
|
+
label: string,
|
|
74
|
+
): { ok: true; spec: CordisPresetCapabilitySpec } | { ok: false; errorCode: 'UnknownPresetError'; reason: string } {
|
|
75
|
+
if (Object.prototype.hasOwnProperty.call(CORDIS_PRESET_CAPABILITY_MATRIX, label)) {
|
|
76
|
+
return { ok: true, spec: CORDIS_PRESET_CAPABILITY_MATRIX[label as CordisPresetId] };
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
ok: false,
|
|
80
|
+
errorCode: 'UnknownPresetError',
|
|
81
|
+
reason: `Unknown Cordis preset "${label}" (must be one of minimal, developer, verify, studio)`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface DescriptorInspectionResult {
|
|
86
|
+
variant: string;
|
|
87
|
+
supportedInPublished008: boolean;
|
|
88
|
+
executable: boolean;
|
|
89
|
+
deferredRelease: string | null;
|
|
90
|
+
metadata: Readonly<Record<string, unknown>>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function inspectPublishedDescriptor(
|
|
94
|
+
cardRecord: Readonly<Record<string, unknown>> | null | undefined,
|
|
95
|
+
): DescriptorInspectionResult {
|
|
96
|
+
if (!cardRecord || typeof cardRecord !== 'object') {
|
|
97
|
+
return { variant: 'unknown', supportedInPublished008: false, executable: false, deferredRelease: null, metadata: {} };
|
|
98
|
+
}
|
|
99
|
+
const rawVariant = String(cardRecord.variant ?? cardRecord.schema ?? cardRecord.kind ?? 'unknown');
|
|
100
|
+
const metadata = {
|
|
101
|
+
id: cardRecord.id ?? null,
|
|
102
|
+
name: cardRecord.name ?? null,
|
|
103
|
+
operationId: cardRecord.operationId ?? null,
|
|
104
|
+
};
|
|
105
|
+
const isDeferred009 =
|
|
106
|
+
rawVariant === 'urn:clm:pcard:descriptor:v1' ||
|
|
107
|
+
(WORKSPACE_009_DEFERRED_DESCRIPTOR_EXPORTS as readonly string[]).includes(rawVariant);
|
|
108
|
+
if (isDeferred009) {
|
|
109
|
+
return { variant: rawVariant, supportedInPublished008: false, executable: false, deferredRelease: '0.0.9', metadata };
|
|
110
|
+
}
|
|
111
|
+
const supportedIn008 = (PUBLISHED_CLM_KERNEL_008_DESCRIPTOR_EXPORTS as readonly string[]).includes(rawVariant);
|
|
112
|
+
const executableVariants = new Set([
|
|
113
|
+
'TransitionMCard', 'PetriProcessPCard', 'ChunkerProcessPCard', 'StreamRangeProcessPCard', 'AnchoredPruningProcessPCard',
|
|
114
|
+
]);
|
|
115
|
+
return {
|
|
116
|
+
variant: rawVariant,
|
|
117
|
+
supportedInPublished008: supportedIn008,
|
|
118
|
+
executable: supportedIn008 && executableVariants.has(rawVariant),
|
|
119
|
+
deferredRelease: null,
|
|
120
|
+
metadata,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function computeWorkbenchStateHash(state: Readonly<Record<string, unknown>>): string {
|
|
125
|
+
const canonical = JSON.stringify(
|
|
126
|
+
Object.keys(state).sort().reduce<Record<string, unknown>>((acc, key) => {
|
|
127
|
+
acc[key] = state[key];
|
|
128
|
+
return acc;
|
|
129
|
+
}, {}),
|
|
130
|
+
);
|
|
131
|
+
return computeContentHash(canonical);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface WorkbenchExecutionReceipt {
|
|
135
|
+
status: 'EXECUTED' | 'REJECTED';
|
|
136
|
+
operationId: string;
|
|
137
|
+
preset: string;
|
|
138
|
+
reason?: string;
|
|
139
|
+
stateHashBefore: string;
|
|
140
|
+
stateHashAfter: string;
|
|
141
|
+
mutated: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export async function executeAllowlistedOperation(options: {
|
|
145
|
+
operationId: string;
|
|
146
|
+
preset: string;
|
|
147
|
+
allowlist: Readonly<Record<string, (state: Record<string, unknown>) => void>>;
|
|
148
|
+
state: Record<string, unknown>;
|
|
149
|
+
}): Promise<WorkbenchExecutionReceipt> {
|
|
150
|
+
const { operationId, preset, allowlist, state } = options;
|
|
151
|
+
const stateHashBefore = computeWorkbenchStateHash(state);
|
|
152
|
+
const reject = (reason: string): WorkbenchExecutionReceipt => ({
|
|
153
|
+
status: 'REJECTED', operationId, preset, reason, stateHashBefore, stateHashAfter: stateHashBefore, mutated: false,
|
|
154
|
+
});
|
|
155
|
+
const presetLookup = resolveCordisPresetCapabilities(preset);
|
|
156
|
+
if (!presetLookup.ok) return reject(presetLookup.reason);
|
|
157
|
+
if (!presetLookup.spec.allowedOperations.includes(operationId)) {
|
|
158
|
+
return reject(`Operation "${operationId}" is not permitted under preset "${preset}"`);
|
|
159
|
+
}
|
|
160
|
+
const handler = Object.prototype.hasOwnProperty.call(allowlist, operationId) ? allowlist[operationId] : undefined;
|
|
161
|
+
if (typeof handler !== 'function') return reject(`Unregistered operation ID "${operationId}"`);
|
|
162
|
+
|
|
163
|
+
const snapshot = JSON.parse(JSON.stringify(state)) as Record<string, unknown>;
|
|
164
|
+
const guard = new SavepointGuard<Record<string, unknown>>((restored) => {
|
|
165
|
+
for (const k of Object.keys(state)) delete state[k];
|
|
166
|
+
Object.assign(state, restored);
|
|
167
|
+
});
|
|
168
|
+
guard.begin(snapshot);
|
|
169
|
+
try {
|
|
170
|
+
handler(state);
|
|
171
|
+
guard.commit();
|
|
172
|
+
const stateHashAfter = computeWorkbenchStateHash(state);
|
|
173
|
+
return { status: 'EXECUTED', operationId, preset, stateHashBefore, stateHashAfter, mutated: stateHashAfter !== stateHashBefore };
|
|
174
|
+
} catch (err: unknown) {
|
|
175
|
+
await guard.rollback();
|
|
176
|
+
const stateHashAfter = computeWorkbenchStateHash(state);
|
|
177
|
+
return {
|
|
178
|
+
status: 'REJECTED', operationId, preset,
|
|
179
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
180
|
+
stateHashBefore, stateHashAfter, mutated: stateHashAfter !== stateHashBefore,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -53,6 +53,7 @@ export type CardDetectedType =
|
|
|
53
53
|
export interface MCardFileNode {
|
|
54
54
|
handle: string;
|
|
55
55
|
hash: string;
|
|
56
|
+
hashDeferred?: boolean;
|
|
56
57
|
path: string;
|
|
57
58
|
name: string;
|
|
58
59
|
mimeType: string;
|
|
@@ -64,6 +65,7 @@ export interface MCardFileNode {
|
|
|
64
65
|
subclass?: 'MCard' | 'PCard' | 'VCard';
|
|
65
66
|
coreCard?: MCard;
|
|
66
67
|
sizeBytes?: number;
|
|
68
|
+
scope?: string;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
/**
|
package/src/styles/dockview.css
CHANGED
|
@@ -257,10 +257,44 @@
|
|
|
257
257
|
|
|
258
258
|
.mcard-file-tree-scroll {
|
|
259
259
|
flex: 1;
|
|
260
|
+
min-height: 0;
|
|
260
261
|
overflow-y: auto;
|
|
261
262
|
overflow-x: hidden;
|
|
262
263
|
}
|
|
263
264
|
|
|
265
|
+
.mcard-file-tree-gap-divider {
|
|
266
|
+
display: flex;
|
|
267
|
+
align-items: center;
|
|
268
|
+
gap: 8px;
|
|
269
|
+
padding: 10px 10px 8px 10px;
|
|
270
|
+
flex-shrink: 0;
|
|
271
|
+
border-top: 1px solid var(--vscode-sideBarSectionHeader-border, #2d2d2d);
|
|
272
|
+
background-color: var(--vscode-sideBar-background, #252526);
|
|
273
|
+
user-select: none;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.mcard-file-tree-gap-line {
|
|
277
|
+
flex: 1;
|
|
278
|
+
height: 1px;
|
|
279
|
+
background-color: var(--vscode-sideBarSectionHeader-border, rgba(255, 255, 255, 0.08));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.mcard-file-tree-gap-label {
|
|
283
|
+
font-size: 9px;
|
|
284
|
+
font-weight: 700;
|
|
285
|
+
text-transform: uppercase;
|
|
286
|
+
letter-spacing: 0.08em;
|
|
287
|
+
color: var(--vscode-descriptionForeground, #717171);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.mcard-file-tree-ro-scroll {
|
|
291
|
+
flex-shrink: 0;
|
|
292
|
+
max-height: 42%;
|
|
293
|
+
overflow-y: auto;
|
|
294
|
+
overflow-x: hidden;
|
|
295
|
+
background-color: var(--vscode-sideBar-background, #252526);
|
|
296
|
+
}
|
|
297
|
+
|
|
264
298
|
.explorer-action-bar {
|
|
265
299
|
display: flex;
|
|
266
300
|
align-items: center;
|