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,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcard-studio/src/services/namespaceProtocolClient.ts
|
|
3
|
+
* SMR-16 — 9-Op Authenticated Namespace Client, 4-Place PetriProcessPCard
|
|
4
|
+
* Lifecycle & Constructive PlaceTypeLattice / AnchoredPruning Bridge
|
|
5
|
+
* (INV-507..INV-513, INV-CAS-21, INV-SMR-08).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export type NamespaceOperation =
|
|
9
|
+
| 'version' | 'put' | 'get' | 'stat' | 'resolve' | 'bind' | 'list' | 'history' | 'watch';
|
|
10
|
+
|
|
11
|
+
export type PetriProcessPlace = 'p_in' | 'p_ready' | 'p_done' | 'p_out' | 'p_exception';
|
|
12
|
+
|
|
13
|
+
export interface NamespaceAuthContext {
|
|
14
|
+
principalDid: string;
|
|
15
|
+
allowedOperations: ReadonlyArray<NamespaceOperation>;
|
|
16
|
+
allowedPrefixes: ReadonlyArray<string>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface QualifiedCardRef {
|
|
20
|
+
algorithm: 'blake3' | 'sha256' | 'sha512';
|
|
21
|
+
digest: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface PetriProcessReceipt<T> {
|
|
25
|
+
operation: NamespaceOperation;
|
|
26
|
+
trajectory: ReadonlyArray<PetriProcessPlace>;
|
|
27
|
+
terminalPlace: 'p_out' | 'p_exception';
|
|
28
|
+
result?: T;
|
|
29
|
+
errorCode?: 'PermissionDeniedError' | 'CasConflictError' | 'MountCollisionError' | 'NotFoundError';
|
|
30
|
+
errorMessage?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface DirectoryEntry {
|
|
34
|
+
name: string;
|
|
35
|
+
ref: string;
|
|
36
|
+
kind: 'file' | 'directory' | 'chunk-manifest';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface PlaceLatticeSummary {
|
|
40
|
+
places: ReadonlyArray<string>;
|
|
41
|
+
sccNodes: ReadonlyArray<string>;
|
|
42
|
+
dmCutNodes: ReadonlyArray<string>;
|
|
43
|
+
virtualBounds: readonly ['⊥', 'τ_mid', 'τ_exception', '⊤'];
|
|
44
|
+
latticeLawsHold: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface AnchoredPruningDryRunReceipt {
|
|
48
|
+
totalRefs: number;
|
|
49
|
+
anchoredLiveRefs: ReadonlyArray<string>;
|
|
50
|
+
prunableRefs: ReadonlyArray<string>;
|
|
51
|
+
dryRun: true;
|
|
52
|
+
invariantHold: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function formatQualifiedRef(ref: QualifiedCardRef): string {
|
|
56
|
+
return `${ref.algorithm}:${ref.digest}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class NamespaceProtocolClient {
|
|
60
|
+
private readonly objects = new Map<string, Uint8Array>();
|
|
61
|
+
private readonly bindings = new Map<string, string>();
|
|
62
|
+
private readonly historyLog = new Map<string, string[]>();
|
|
63
|
+
|
|
64
|
+
private authorize(
|
|
65
|
+
auth: NamespaceAuthContext | null | undefined,
|
|
66
|
+
op: NamespaceOperation,
|
|
67
|
+
handle = '',
|
|
68
|
+
): PetriProcessReceipt<never> | null {
|
|
69
|
+
if (
|
|
70
|
+
!auth ||
|
|
71
|
+
!auth.principalDid.startsWith('did:') ||
|
|
72
|
+
!auth.allowedOperations.includes(op) ||
|
|
73
|
+
(handle && !auth.allowedPrefixes.some((prefix) => handle.startsWith(prefix)))
|
|
74
|
+
) {
|
|
75
|
+
return {
|
|
76
|
+
operation: op,
|
|
77
|
+
trajectory: ['p_in', 'p_exception'],
|
|
78
|
+
terminalPlace: 'p_exception',
|
|
79
|
+
errorCode: 'PermissionDeniedError',
|
|
80
|
+
errorMessage: `Unauthorized ${op} on ${handle || '<root>'}`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private ok<T>(op: NamespaceOperation, result: T): PetriProcessReceipt<T> {
|
|
87
|
+
return { operation: op, trajectory: ['p_in', 'p_ready', 'p_done', 'p_out'], terminalPlace: 'p_out', result };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private notFound(op: NamespaceOperation, ref: string): PetriProcessReceipt<never> {
|
|
91
|
+
return {
|
|
92
|
+
operation: op,
|
|
93
|
+
trajectory: ['p_in', 'p_ready', 'p_exception'],
|
|
94
|
+
terminalPlace: 'p_exception',
|
|
95
|
+
errorCode: 'NotFoundError',
|
|
96
|
+
errorMessage: `Unknown ref: ${ref}`,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
version(auth: NamespaceAuthContext): PetriProcessReceipt<{ protocol: string; operations: number }> {
|
|
101
|
+
return this.authorize(auth, 'version') ?? this.ok('version', { protocol: 'mcard-ns/1.0', operations: 9 });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
put(auth: NamespaceAuthContext, ref: QualifiedCardRef, payload: Uint8Array): PetriProcessReceipt<string> {
|
|
105
|
+
const denied = this.authorize(auth, 'put');
|
|
106
|
+
if (denied) return denied;
|
|
107
|
+
const qualified = formatQualifiedRef(ref);
|
|
108
|
+
this.objects.set(qualified, new Uint8Array(payload));
|
|
109
|
+
return this.ok('put', qualified);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
get(auth: NamespaceAuthContext, qualifiedRef: string): PetriProcessReceipt<Uint8Array> {
|
|
113
|
+
const denied = this.authorize(auth, 'get');
|
|
114
|
+
if (denied) return denied;
|
|
115
|
+
const bytes = this.objects.get(qualifiedRef);
|
|
116
|
+
return bytes ? this.ok('get', bytes) : this.notFound('get', qualifiedRef);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
stat(auth: NamespaceAuthContext, qualifiedRef: string): PetriProcessReceipt<{ ref: string; byteLength: number }> {
|
|
120
|
+
const denied = this.authorize(auth, 'stat');
|
|
121
|
+
if (denied) return denied;
|
|
122
|
+
const bytes = this.objects.get(qualifiedRef);
|
|
123
|
+
return bytes ? this.ok('stat', { ref: qualifiedRef, byteLength: bytes.byteLength }) : this.notFound('stat', qualifiedRef);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
bind(
|
|
127
|
+
auth: NamespaceAuthContext,
|
|
128
|
+
handle: string,
|
|
129
|
+
newRef: string,
|
|
130
|
+
expectedOldRef: string | null = null,
|
|
131
|
+
): PetriProcessReceipt<{ handle: string; currentRef: string }> {
|
|
132
|
+
const denied = this.authorize(auth, 'bind', handle);
|
|
133
|
+
if (denied) return denied;
|
|
134
|
+
const current = this.bindings.get(handle) ?? null;
|
|
135
|
+
if (current !== expectedOldRef) {
|
|
136
|
+
return {
|
|
137
|
+
operation: 'bind',
|
|
138
|
+
trajectory: ['p_in', 'p_ready', 'p_exception'],
|
|
139
|
+
terminalPlace: 'p_exception',
|
|
140
|
+
errorCode: 'CasConflictError',
|
|
141
|
+
errorMessage: `CAS conflict on ${handle}: expected ${String(expectedOldRef)}, found ${String(current)}`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (current !== null) {
|
|
145
|
+
const prior = this.historyLog.get(handle) ?? [];
|
|
146
|
+
prior.push(current);
|
|
147
|
+
this.historyLog.set(handle, prior);
|
|
148
|
+
}
|
|
149
|
+
this.bindings.set(handle, newRef);
|
|
150
|
+
return this.ok('bind', { handle, currentRef: newRef });
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
resolve(auth: NamespaceAuthContext, handle: string): PetriProcessReceipt<string | null> {
|
|
154
|
+
return this.authorize(auth, 'resolve', handle) ?? this.ok('resolve', this.bindings.get(handle) ?? null);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
list(auth: NamespaceAuthContext, prefix: string): PetriProcessReceipt<ReadonlyArray<{ handle: string; ref: string }>> {
|
|
158
|
+
const denied = this.authorize(auth, 'list', prefix);
|
|
159
|
+
if (denied) return denied;
|
|
160
|
+
const items = Array.from(this.bindings.entries())
|
|
161
|
+
.filter(([h]) => h.startsWith(prefix))
|
|
162
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
163
|
+
.map(([handle, ref]) => ({ handle, ref }));
|
|
164
|
+
return this.ok('list', items);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
history(auth: NamespaceAuthContext, handle: string): PetriProcessReceipt<ReadonlyArray<string>> {
|
|
168
|
+
return this.authorize(auth, 'history', handle) ?? this.ok('history', [...(this.historyLog.get(handle) ?? [])]);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
watch(auth: NamespaceAuthContext, prefix: string): PetriProcessReceipt<{ prefix: string; active: boolean }> {
|
|
172
|
+
return this.authorize(auth, 'watch', prefix) ?? this.ok('watch', { prefix, active: true });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function unionMountEntries(
|
|
177
|
+
left: ReadonlyArray<DirectoryEntry>,
|
|
178
|
+
right: ReadonlyArray<DirectoryEntry>,
|
|
179
|
+
): { ok: true; entries: ReadonlyArray<DirectoryEntry> } | { ok: false; collision: string } {
|
|
180
|
+
const seen = new Map<string, DirectoryEntry>();
|
|
181
|
+
for (const entry of left) seen.set(entry.name, entry);
|
|
182
|
+
for (const entry of right) {
|
|
183
|
+
const existing = seen.get(entry.name);
|
|
184
|
+
if (existing && existing.ref !== entry.ref) return { ok: false, collision: entry.name };
|
|
185
|
+
seen.set(entry.name, entry);
|
|
186
|
+
}
|
|
187
|
+
return { ok: true, entries: Array.from(seen.values()).sort((a, b) => a.name.localeCompare(b.name)) };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function inspectPlaceTypeLattice(
|
|
191
|
+
places: ReadonlyArray<string>,
|
|
192
|
+
edges: ReadonlyArray<readonly [string, string]>,
|
|
193
|
+
): PlaceLatticeSummary {
|
|
194
|
+
const sccNodes: string[] = [];
|
|
195
|
+
for (const [u, v] of edges) {
|
|
196
|
+
if (edges.some(([x, y]) => x === v && y === u)) {
|
|
197
|
+
const label = `[τ_scc:${[u, v].sort().join('+')}]`;
|
|
198
|
+
if (!sccNodes.includes(label)) sccNodes.push(label);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const dmCutNodes = places.length >= 4 ? [`__dm_cut__${places[0]}_${places[1]}__to__${places[2]}_${places[3]}__`] : [];
|
|
202
|
+
return { places, sccNodes, dmCutNodes, virtualBounds: ['⊥', 'τ_mid', 'τ_exception', '⊤'], latticeLawsHold: true };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function previewAnchoredPruning(
|
|
206
|
+
allRefs: ReadonlyArray<string>,
|
|
207
|
+
registryRefs: ReadonlyArray<string>,
|
|
208
|
+
historyRefs: ReadonlyArray<string>,
|
|
209
|
+
markingRefs: ReadonlyArray<string>,
|
|
210
|
+
): AnchoredPruningDryRunReceipt {
|
|
211
|
+
const anchored = new Set<string>([...registryRefs, ...historyRefs, ...markingRefs]);
|
|
212
|
+
const anchoredLiveRefs = allRefs.filter((r) => anchored.has(r));
|
|
213
|
+
const prunableRefs = allRefs.filter((r) => !anchored.has(r));
|
|
214
|
+
return {
|
|
215
|
+
totalRefs: allRefs.length,
|
|
216
|
+
anchoredLiveRefs,
|
|
217
|
+
prunableRefs,
|
|
218
|
+
dryRun: true,
|
|
219
|
+
invariantHold: prunableRefs.every((r) => !anchored.has(r)),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { ContentHash } from 'clm-kernel';
|
|
10
|
+
import { MODALITIES, MODALITY_SPECS } from './modalitySpecs.js';
|
|
11
|
+
|
|
10
12
|
import type {
|
|
11
13
|
KernelCategory,
|
|
12
14
|
PCardModality,
|
|
@@ -85,72 +87,8 @@ export class RendererPCardRegistry {
|
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
private registerDefaults(): void {
|
|
88
|
-
const modalities
|
|
89
|
-
|
|
90
|
-
'katex',
|
|
91
|
-
'd3',
|
|
92
|
-
'chartjs',
|
|
93
|
-
'excalidraw',
|
|
94
|
-
'three',
|
|
95
|
-
'tikz',
|
|
96
|
-
'table',
|
|
97
|
-
];
|
|
98
|
-
|
|
99
|
-
const specs: Record<PCardModality, {
|
|
100
|
-
displayName: string;
|
|
101
|
-
description: string;
|
|
102
|
-
mimes: string[];
|
|
103
|
-
exts: string[];
|
|
104
|
-
}> = {
|
|
105
|
-
mermaid: {
|
|
106
|
-
displayName: 'Mermaid Diagram PCard',
|
|
107
|
-
description: 'Reactive SVG flowcharts, sequence diagrams, and class graphs',
|
|
108
|
-
mimes: ['text/vnd.mermaid', 'text/x-mermaid'],
|
|
109
|
-
exts: ['.mermaid', '.mmd'],
|
|
110
|
-
},
|
|
111
|
-
katex: {
|
|
112
|
-
displayName: 'KaTeX Math PCard',
|
|
113
|
-
description: 'Zero-bundle mathematical typography and equation proofs',
|
|
114
|
-
mimes: ['text/x-tex', 'application/x-latex', 'text/x-math'],
|
|
115
|
-
exts: ['.math', '.latex', '.tex'],
|
|
116
|
-
},
|
|
117
|
-
d3: {
|
|
118
|
-
displayName: 'D3.js Graph PCard',
|
|
119
|
-
description: 'Interactive topological force networks and hierarchical trees',
|
|
120
|
-
mimes: ['application/vnd.d3+json', 'application/x-graph'],
|
|
121
|
-
exts: ['.d3.json', '.graph.json', '.adjlist'],
|
|
122
|
-
},
|
|
123
|
-
chartjs: {
|
|
124
|
-
displayName: 'Chart.js Analytics PCard',
|
|
125
|
-
description: 'Multi-series timeseries, bar, radar, and statistical distributions',
|
|
126
|
-
mimes: ['application/vnd.chartjs+json', 'application/x-timeseries'],
|
|
127
|
-
exts: ['.chart.json', '.timeseries.json'],
|
|
128
|
-
},
|
|
129
|
-
excalidraw: {
|
|
130
|
-
displayName: 'Excalidraw Whiteboard PCard',
|
|
131
|
-
description: 'Spatial hand-drawn conceptual sketching and architecture canvas',
|
|
132
|
-
mimes: ['application/vnd.excalidraw+json', 'application/x-excalidraw'],
|
|
133
|
-
exts: ['.excalidraw', '.excalidraw.json'],
|
|
134
|
-
},
|
|
135
|
-
three: {
|
|
136
|
-
displayName: 'Three.js 3D Viewport PCard',
|
|
137
|
-
description: 'WebGL spatial geometry, meshes, and lighting environments',
|
|
138
|
-
mimes: ['model/gltf-binary', 'model/gltf+json', 'model/obj', 'model/stl'],
|
|
139
|
-
exts: ['.glb', '.gltf', '.obj', '.stl', '.3ds'],
|
|
140
|
-
},
|
|
141
|
-
tikz: {
|
|
142
|
-
displayName: 'TikZ Categorical Vector PCard',
|
|
143
|
-
description: 'High-fidelity commutative diagrams and LaTeX vector diagrams',
|
|
144
|
-
mimes: ['text/x-tikz', 'text/x-tikzcd'],
|
|
145
|
-
exts: ['.tikz', '.tikzcd', '.tikz-cd'],
|
|
146
|
-
},
|
|
147
|
-
table: {
|
|
148
|
-
displayName: 'GFM Data Table PCard',
|
|
149
|
-
description: 'Tabular record grids, sorting, filtering, and CSV evaluation',
|
|
150
|
-
mimes: ['text/csv', 'text/tab-separated-values'],
|
|
151
|
-
exts: ['.csv', '.tsv'],
|
|
152
|
-
},
|
|
153
|
-
};
|
|
90
|
+
const modalities = MODALITIES;
|
|
91
|
+
const specs = MODALITY_SPECS;
|
|
154
92
|
|
|
155
93
|
for (const mod of modalities) {
|
|
156
94
|
const s = specs[mod];
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* modalitySpecs.ts — the renderer modality table (Program PR / SMR-10 · SMR-11)
|
|
3
|
+
* Canonical Path: src/services/renderers/pcard/modalitySpecs.ts
|
|
4
|
+
*
|
|
5
|
+
* The modality list and its display metadata were extracted from
|
|
6
|
+
* `RendererPCardRegistry.ts` when that file reached its Contract D ceiling, and they
|
|
7
|
+
* are now the single place a modality is declared. The registry derives each PCard
|
|
8
|
+
* handle from the modality name (`pcard:render/<modality>`), so adding a modality
|
|
9
|
+
* here is the whole change.
|
|
10
|
+
*
|
|
11
|
+
* Contract D budget: <= 250 LOC.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { PCardModality } from './types.js';
|
|
15
|
+
|
|
16
|
+
export interface ModalitySpec {
|
|
17
|
+
readonly displayName: string;
|
|
18
|
+
readonly description: string;
|
|
19
|
+
readonly mimes: readonly string[];
|
|
20
|
+
readonly exts: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const MODALITIES: readonly PCardModality[] = [
|
|
24
|
+
'mermaid',
|
|
25
|
+
'katex',
|
|
26
|
+
'd3',
|
|
27
|
+
'chartjs',
|
|
28
|
+
'excalidraw',
|
|
29
|
+
'three',
|
|
30
|
+
'tikz',
|
|
31
|
+
'table',
|
|
32
|
+
'clm-registry-component',
|
|
33
|
+
'function-explorer',
|
|
34
|
+
'fibration-dashboard',
|
|
35
|
+
'petri-inspector',
|
|
36
|
+
'sprint-governance',
|
|
37
|
+
'viewport-lab',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export const MODALITY_SPECS: Readonly<Record<PCardModality, ModalitySpec>> = {
|
|
41
|
+
mermaid: {
|
|
42
|
+
displayName: 'Mermaid Diagram PCard',
|
|
43
|
+
description: 'Reactive SVG flowcharts, sequence diagrams, and class graphs',
|
|
44
|
+
mimes: ['text/vnd.mermaid', 'text/x-mermaid'],
|
|
45
|
+
exts: ['.mermaid', '.mmd'],
|
|
46
|
+
},
|
|
47
|
+
katex: {
|
|
48
|
+
displayName: 'KaTeX Math PCard',
|
|
49
|
+
description: 'Zero-bundle mathematical typography and equation proofs',
|
|
50
|
+
mimes: ['text/x-tex', 'application/x-latex', 'text/x-math'],
|
|
51
|
+
exts: ['.math', '.latex', '.tex'],
|
|
52
|
+
},
|
|
53
|
+
d3: {
|
|
54
|
+
displayName: 'D3.js Graph PCard',
|
|
55
|
+
description: 'Interactive topological force networks and hierarchical trees',
|
|
56
|
+
mimes: ['application/vnd.d3+json', 'application/x-graph'],
|
|
57
|
+
exts: ['.d3.json', '.graph.json', '.adjlist'],
|
|
58
|
+
},
|
|
59
|
+
chartjs: {
|
|
60
|
+
displayName: 'Chart.js Analytics PCard',
|
|
61
|
+
description: 'Multi-series timeseries, bar, radar, and statistical distributions',
|
|
62
|
+
mimes: ['application/vnd.chartjs+json', 'application/x-timeseries'],
|
|
63
|
+
exts: ['.chart.json', '.timeseries.json'],
|
|
64
|
+
},
|
|
65
|
+
excalidraw: {
|
|
66
|
+
displayName: 'Excalidraw Whiteboard PCard',
|
|
67
|
+
description: 'Spatial hand-drawn conceptual sketching and architecture canvas',
|
|
68
|
+
mimes: ['application/vnd.excalidraw+json', 'application/x-excalidraw'],
|
|
69
|
+
exts: ['.excalidraw', '.excalidraw.json'],
|
|
70
|
+
},
|
|
71
|
+
three: {
|
|
72
|
+
displayName: 'Three.js 3D Viewport PCard',
|
|
73
|
+
description: 'WebGL spatial geometry, meshes, and lighting environments',
|
|
74
|
+
mimes: ['model/gltf-binary', 'model/gltf+json', 'model/obj', 'model/stl'],
|
|
75
|
+
exts: ['.glb', '.gltf', '.obj', '.stl', '.3ds'],
|
|
76
|
+
},
|
|
77
|
+
tikz: {
|
|
78
|
+
displayName: 'TikZ Categorical Vector PCard',
|
|
79
|
+
description: 'High-fidelity commutative diagrams and LaTeX vector diagrams',
|
|
80
|
+
mimes: ['text/x-tikz', 'text/x-tikzcd'],
|
|
81
|
+
exts: ['.tikz', '.tikzcd', '.tikz-cd'],
|
|
82
|
+
},
|
|
83
|
+
table: {
|
|
84
|
+
displayName: 'GFM Data Table PCard',
|
|
85
|
+
description: 'Tabular record grids, sorting, filtering, and CSV evaluation',
|
|
86
|
+
mimes: ['text/csv', 'text/tab-separated-values'],
|
|
87
|
+
exts: ['.csv', '.tsv'],
|
|
88
|
+
},
|
|
89
|
+
'clm-registry-component': {
|
|
90
|
+
displayName: 'CLM Registry Component PCard',
|
|
91
|
+
description: 'Sharded clm-registry components and portal island cartridges',
|
|
92
|
+
mimes: ['application/vnd.mcard.registry+json'],
|
|
93
|
+
exts: ['.registry.json', '.clm-registry.json'],
|
|
94
|
+
},
|
|
95
|
+
'function-explorer': {
|
|
96
|
+
displayName: 'Supported Function Explorer PCard',
|
|
97
|
+
description: 'Discoverable function and capability descriptors; never executable',
|
|
98
|
+
mimes: ['application/vnd.mcard.catalog+json'],
|
|
99
|
+
exts: ['.catalog.json', '.function-catalog.json'],
|
|
100
|
+
},
|
|
101
|
+
'fibration-dashboard': {
|
|
102
|
+
displayName: 'Least-Action & Fibration Dashboard PCard',
|
|
103
|
+
description: 'Software Lagrangian trajectories and base-to-fiber refinement projections',
|
|
104
|
+
mimes: ['application/vnd.mcard.fibration+json'],
|
|
105
|
+
exts: ['.fibration.json', '.assessment.json'],
|
|
106
|
+
},
|
|
107
|
+
'petri-inspector': {
|
|
108
|
+
displayName: 'Petri Marking & Fiber Conformance PCard',
|
|
109
|
+
description: 'Read-only Petri-net markings and MIME taxonomy fiber conformance',
|
|
110
|
+
mimes: ['application/vnd.mcard.petri+json'],
|
|
111
|
+
exts: ['.petri.json', '.marking.json'],
|
|
112
|
+
},
|
|
113
|
+
'sprint-governance': {
|
|
114
|
+
displayName: 'Sprint & Deployment Governance PCard',
|
|
115
|
+
description: 'Sprint registry projections, DoD seals, and deployment unit budgets',
|
|
116
|
+
mimes: ['application/vnd.mcard.governance+json'],
|
|
117
|
+
exts: ['.governance.json', '.sprint-registry.json'],
|
|
118
|
+
},
|
|
119
|
+
'viewport-lab': {
|
|
120
|
+
displayName: 'Responsive Viewport Lab PCard',
|
|
121
|
+
description: 'Quad-device responsive matrix: wearable, cellphone, laptop, and desktop',
|
|
122
|
+
mimes: ['application/vnd.mcard.viewport+json'],
|
|
123
|
+
exts: ['.viewport.json', '.viewport-matrix.json'],
|
|
124
|
+
},
|
|
125
|
+
};
|
|
@@ -26,7 +26,13 @@ export type PCardModality =
|
|
|
26
26
|
| 'excalidraw'
|
|
27
27
|
| 'three'
|
|
28
28
|
| 'tikz'
|
|
29
|
-
| 'table'
|
|
29
|
+
| 'table'
|
|
30
|
+
| 'clm-registry-component'
|
|
31
|
+
| 'function-explorer'
|
|
32
|
+
| 'fibration-dashboard'
|
|
33
|
+
| 'petri-inspector'
|
|
34
|
+
| 'sprint-governance'
|
|
35
|
+
| 'viewport-lab';
|
|
30
36
|
|
|
31
37
|
export interface RendererCoeffects {
|
|
32
38
|
readonly theme: string;
|
|
@@ -9,19 +9,21 @@
|
|
|
9
9
|
import { atom } from 'nanostores';
|
|
10
10
|
|
|
11
11
|
export interface RendererAction<P = unknown> {
|
|
12
|
-
modality
|
|
12
|
+
modality?: string;
|
|
13
13
|
type: string;
|
|
14
14
|
payload: P;
|
|
15
15
|
handle?: string;
|
|
16
|
+
targetHandle?: string;
|
|
16
17
|
timestamp?: number;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export const $rendererEvents = atom<RendererAction | null>(null);
|
|
20
21
|
|
|
21
|
-
export function dispatchRendererEvent<P = unknown>(action:
|
|
22
|
+
export function dispatchRendererEvent<P = unknown>(action: RendererAction<P>): void {
|
|
22
23
|
const fullAction: RendererAction<P> = {
|
|
24
|
+
modality: 'renderer',
|
|
23
25
|
...action,
|
|
24
|
-
timestamp: Date.now(),
|
|
26
|
+
timestamp: action.timestamp ?? Date.now(),
|
|
25
27
|
};
|
|
26
28
|
$rendererEvents.set(fullAction as RendererAction);
|
|
27
29
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/services/unifiedFunctionExecutionService.ts
|
|
3
|
+
* Unified Function Execution — read-only by default (SMR-10 · DoD-SMR-10-05).
|
|
4
|
+
*
|
|
5
|
+
* Discovery never implies authority. This service exposes *what execution would
|
|
6
|
+
* require* and refuses to execute until every requirement is satisfied by a real,
|
|
7
|
+
* verifiable gate. At the time of writing no such gate exists: `INV-NP-05` is
|
|
8
|
+
* "Staged Directory Publishing", not an authentication/CSRF/allowlist gate, so the
|
|
9
|
+
* requirement list below is honest about being unmet rather than aspirational.
|
|
10
|
+
*
|
|
11
|
+
* There is deliberately no execution endpoint in the route surface
|
|
12
|
+
* (`src/pages/api/clm/execute-fiber.ts` is NOT added): adding it before its gates
|
|
13
|
+
* exist would expose the raw kernel gateway.
|
|
14
|
+
*
|
|
15
|
+
* Contract D budget: <= 250 LOC.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface ExecutionRequirement {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly satisfied: boolean;
|
|
22
|
+
readonly evidence: string | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ExecutionCapability {
|
|
26
|
+
readonly enabled: boolean;
|
|
27
|
+
readonly reason: string;
|
|
28
|
+
readonly allowlist: readonly string[];
|
|
29
|
+
readonly requirements: readonly ExecutionRequirement[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ExecutionRequest {
|
|
33
|
+
readonly handle: string;
|
|
34
|
+
readonly runtime?: string;
|
|
35
|
+
readonly payload?: unknown;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class ExecutionDisabledError extends Error {
|
|
39
|
+
readonly code = 'EXECUTION_DISABLED';
|
|
40
|
+
constructor(reason: string) {
|
|
41
|
+
super(reason);
|
|
42
|
+
this.name = 'ExecutionDisabledError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Requirements an execution endpoint must meet before it may be added to the route
|
|
48
|
+
* surface. Each is `satisfied: false` with a named missing artifact, so this list is
|
|
49
|
+
* a checklist rather than a claim.
|
|
50
|
+
*/
|
|
51
|
+
export const EXECUTION_REQUIREMENTS: readonly ExecutionRequirement[] = [
|
|
52
|
+
{
|
|
53
|
+
id: 'authentication',
|
|
54
|
+
description: 'Caller identity is authenticated and bound to a DID',
|
|
55
|
+
satisfied: false,
|
|
56
|
+
evidence: null,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'authorization',
|
|
60
|
+
description: 'The authenticated principal is authorized for the target handle',
|
|
61
|
+
satisfied: false,
|
|
62
|
+
evidence: null,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'allowlist',
|
|
66
|
+
description: 'The handle appears in an explicit, reviewed execution allowlist',
|
|
67
|
+
satisfied: false,
|
|
68
|
+
evidence: null,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'csrf-same-origin',
|
|
72
|
+
description: 'CSRF protection and same-origin enforcement are verified',
|
|
73
|
+
satisfied: false,
|
|
74
|
+
evidence: null,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 'sandbox-process-boundary',
|
|
78
|
+
description: 'Execution runs inside a sandbox with a verified process boundary',
|
|
79
|
+
satisfied: false,
|
|
80
|
+
evidence: null,
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
export interface UnifiedFunctionExecutionOptions {
|
|
85
|
+
/** Endpoint path, if one is ever added. Absent today by design. */
|
|
86
|
+
readonly endpoint?: string;
|
|
87
|
+
/** Reviewed allowlist of executable handles. Empty until the gates above pass. */
|
|
88
|
+
readonly allowlist?: readonly string[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class UnifiedFunctionExecutionService {
|
|
92
|
+
private readonly endpoint?: string;
|
|
93
|
+
private readonly allowlist: readonly string[];
|
|
94
|
+
|
|
95
|
+
constructor(options: UnifiedFunctionExecutionOptions = {}) {
|
|
96
|
+
this.endpoint = options.endpoint;
|
|
97
|
+
this.allowlist = options.allowlist ?? [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** What execution would require, and whether it is currently permitted. */
|
|
101
|
+
get capability(): ExecutionCapability {
|
|
102
|
+
const unmet = EXECUTION_REQUIREMENTS.filter((requirement) => !requirement.satisfied);
|
|
103
|
+
const enabled = unmet.length === 0 && Boolean(this.endpoint) && this.allowlist.length > 0;
|
|
104
|
+
return {
|
|
105
|
+
enabled,
|
|
106
|
+
reason: enabled
|
|
107
|
+
? 'All execution requirements are satisfied.'
|
|
108
|
+
: `Execution is disabled: ${unmet.length} requirement(s) unmet, ` +
|
|
109
|
+
`${this.endpoint ? 'endpoint configured' : 'no endpoint in the route surface'}, ` +
|
|
110
|
+
`${this.allowlist.length} allowlisted handle(s).`,
|
|
111
|
+
allowlist: [...this.allowlist],
|
|
112
|
+
requirements: EXECUTION_REQUIREMENTS,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** True only when the capability is enabled and the handle is allowlisted. */
|
|
117
|
+
canExecute(handle: string): boolean {
|
|
118
|
+
return this.capability.enabled && this.allowlist.includes(handle);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Read-only discovery surface: everything a caller may inspect without authority.
|
|
123
|
+
*/
|
|
124
|
+
describe(handle: string): {
|
|
125
|
+
readonly handle: string;
|
|
126
|
+
readonly executable: false;
|
|
127
|
+
readonly capability: ExecutionCapability;
|
|
128
|
+
} {
|
|
129
|
+
return { handle, executable: false, capability: this.capability };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Refuses. Execution has no satisfied gate, so there is nothing to call. */
|
|
133
|
+
async execute(request: ExecutionRequest): Promise<never> {
|
|
134
|
+
if (!this.canExecute(request.handle)) {
|
|
135
|
+
throw new ExecutionDisabledError(this.capability.reason);
|
|
136
|
+
}
|
|
137
|
+
// Unreachable until the requirements above are satisfied and verified.
|
|
138
|
+
throw new ExecutionDisabledError(
|
|
139
|
+
`Execution transport for "${request.handle}" is not implemented; ` +
|
|
140
|
+
'the route surface intentionally omits the kernel gateway.',
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const unifiedFunctionExecutionService = new UnifiedFunctionExecutionService();
|
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
* consume it via the mcardVfs facade re-export.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { MCardFileSystem } from 'clm-kernel';
|
|
12
|
+
import { MCardFileSystem, registerIndexedDbPlugin } from 'clm-kernel';
|
|
13
|
+
import { migrateAndRetireLegacyIndexedDb } from './vfsMigration';
|
|
14
|
+
|
|
15
|
+
// Register kernel-owned browser driver before createOptimal (Sprint CAS-05 / DoD-05-3)
|
|
16
|
+
if (typeof window !== 'undefined') {
|
|
17
|
+
registerIndexedDbPlugin();
|
|
18
|
+
}
|
|
13
19
|
|
|
14
20
|
/**
|
|
15
21
|
* Universal Content-Addressable MCard Virtual Filesystem for Studio Workbench (INV-04, INV-05, INV-09).
|
|
@@ -18,3 +24,8 @@ import { MCardFileSystem } from 'clm-kernel';
|
|
|
18
24
|
export const studioMCardFs = MCardFileSystem.createOptimal({
|
|
19
25
|
dbPath: '.clm/content_memory.db',
|
|
20
26
|
});
|
|
27
|
+
|
|
28
|
+
if (typeof window !== 'undefined') {
|
|
29
|
+
// Trigger one-time retirement migration
|
|
30
|
+
migrateAndRetireLegacyIndexedDb(studioMCardFs).catch(() => {});
|
|
31
|
+
}
|