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,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/components/studio/views/pills/HashPill.tsx
|
|
3
|
+
*
|
|
4
|
+
* MCard Studio Hash Pill Component (Sprint CAS-08 / DoD-08-3, DoD-08-6).
|
|
5
|
+
* Renders head qualified hash, permalink copy button, true algorithm from g_time,
|
|
6
|
+
* row author DID, act author DID, and cryptographic signature status.
|
|
7
|
+
*
|
|
8
|
+
* Contract D budget: <= 250 LOC.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React, { FC, useState } from 'react';
|
|
12
|
+
import type { HashPillViewModel } from '../../../../core/projection/views';
|
|
13
|
+
|
|
14
|
+
export interface HashPillProps {
|
|
15
|
+
readonly model: HashPillViewModel;
|
|
16
|
+
readonly onCopyPermalink?: (permalink: string) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const HashPill: FC<HashPillProps> = ({ model, onCopyPermalink }) => {
|
|
20
|
+
const [copied, setCopied] = useState(false);
|
|
21
|
+
|
|
22
|
+
const handleCopy = () => {
|
|
23
|
+
if (onCopyPermalink) {
|
|
24
|
+
onCopyPermalink(model.permalink);
|
|
25
|
+
} else if (typeof navigator !== 'undefined' && navigator.clipboard) {
|
|
26
|
+
navigator.clipboard.writeText(model.permalink);
|
|
27
|
+
}
|
|
28
|
+
setCopied(true);
|
|
29
|
+
setTimeout(() => setCopied(false), 2000);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div data-testid="hash-pill" className="hash-pill inline-flex items-center gap-2 px-2.5 py-1 rounded-full border border-border bg-card/60 font-mono text-xs shadow-sm">
|
|
34
|
+
{/* 1. Algorithm Badge (read strictly from g_time or classification) */}
|
|
35
|
+
<span
|
|
36
|
+
data-testid="algorithm-badge"
|
|
37
|
+
className={`px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider ${
|
|
38
|
+
model.algorithm === 'legacy'
|
|
39
|
+
? 'bg-amber-500/20 text-amber-600'
|
|
40
|
+
: model.algorithm === 'malformed'
|
|
41
|
+
? 'bg-destructive/20 text-destructive'
|
|
42
|
+
: 'bg-primary/15 text-primary'
|
|
43
|
+
}`}
|
|
44
|
+
>
|
|
45
|
+
{model.algorithm}
|
|
46
|
+
</span>
|
|
47
|
+
|
|
48
|
+
{/* 2. Hash & Copyable permalink */}
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
data-testid="copy-permalink-btn"
|
|
52
|
+
title={`Click to copy ${model.permalink}`}
|
|
53
|
+
onClick={handleCopy}
|
|
54
|
+
className="text-foreground hover:text-primary transition-colors flex items-center gap-1 cursor-pointer bg-transparent border-0 p-0 font-mono text-xs"
|
|
55
|
+
>
|
|
56
|
+
<span data-testid="hash-text">{model.shortHash}</span>
|
|
57
|
+
<span className="text-[10px] text-muted-foreground">{copied ? '✓ copied' : '📋'}</span>
|
|
58
|
+
</button>
|
|
59
|
+
|
|
60
|
+
{/* 3. Row Author DID (from authorOf(g_time)) */}
|
|
61
|
+
{model.rowAuthor && (
|
|
62
|
+
<span
|
|
63
|
+
data-testid="row-author"
|
|
64
|
+
title={`Row author: ${model.rowAuthor}`}
|
|
65
|
+
className="text-muted-foreground text-[10px] max-w-[120px] truncate"
|
|
66
|
+
>
|
|
67
|
+
by: {model.rowAuthor}
|
|
68
|
+
</span>
|
|
69
|
+
)}
|
|
70
|
+
|
|
71
|
+
{/* 4. Act Author (transition author) */}
|
|
72
|
+
{model.actAuthor && model.actAuthor !== model.rowAuthor && (
|
|
73
|
+
<span
|
|
74
|
+
data-testid="act-author"
|
|
75
|
+
title={`Act author: ${model.actAuthor}`}
|
|
76
|
+
className="text-muted-foreground text-[10px] max-w-[120px] truncate"
|
|
77
|
+
>
|
|
78
|
+
act: {model.actAuthor}
|
|
79
|
+
</span>
|
|
80
|
+
)}
|
|
81
|
+
|
|
82
|
+
{/* 5. Signature Status */}
|
|
83
|
+
<span
|
|
84
|
+
data-testid="signature-status-badge"
|
|
85
|
+
className={`px-1.5 py-0.5 rounded text-[10px] font-semibold ${
|
|
86
|
+
model.signatureStatus === 'signed-ok'
|
|
87
|
+
? 'bg-emerald-500/20 text-emerald-600'
|
|
88
|
+
: model.signatureStatus === 'signed-bad'
|
|
89
|
+
? 'bg-destructive/20 text-destructive'
|
|
90
|
+
: model.signatureStatus === 'unresolved'
|
|
91
|
+
? 'bg-amber-500/20 text-amber-600'
|
|
92
|
+
: 'bg-muted text-muted-foreground'
|
|
93
|
+
}`}
|
|
94
|
+
>
|
|
95
|
+
{model.signatureStatus}
|
|
96
|
+
</span>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default HashPill;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/components/studio/views/residency/ResidencyIndicator.tsx
|
|
3
|
+
*
|
|
4
|
+
* MCard Studio Residency Indicator (Sprint CAS-08 / DoD-08-3, INV-CAS-14).
|
|
5
|
+
* Renders separate states:
|
|
6
|
+
* - browser replica: present or fetch-needed
|
|
7
|
+
* - authoritative server: committed or not
|
|
8
|
+
* - each remote replica: verified (with receipt verifiedAt), pending or none.
|
|
9
|
+
* Missing receipts render as none/pending, never verified.
|
|
10
|
+
*
|
|
11
|
+
* Contract D budget: <= 250 LOC.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import React, { FC } from 'react';
|
|
15
|
+
import type { ResidencyStateViewModel } from '../../../../core/projection/views';
|
|
16
|
+
|
|
17
|
+
export interface ResidencyIndicatorProps {
|
|
18
|
+
readonly state: ResidencyStateViewModel;
|
|
19
|
+
readonly hash?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const ResidencyIndicator: FC<ResidencyIndicatorProps> = ({ state, hash }) => {
|
|
23
|
+
const { browser, server, replicas } = state;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div data-testid="residency-indicator" className="residency-indicator flex flex-wrap items-center gap-2 font-mono text-xs">
|
|
27
|
+
{/* 1. Browser Replica State */}
|
|
28
|
+
<span
|
|
29
|
+
data-testid="residency-browser-badge"
|
|
30
|
+
className={`px-2 py-0.5 rounded text-[11px] font-semibold border ${
|
|
31
|
+
browser === 'present'
|
|
32
|
+
? 'bg-emerald-500/10 text-emerald-600 border-emerald-500/30'
|
|
33
|
+
: 'bg-amber-500/10 text-amber-600 border-amber-500/30'
|
|
34
|
+
}`}
|
|
35
|
+
>
|
|
36
|
+
browser: {browser}
|
|
37
|
+
</span>
|
|
38
|
+
|
|
39
|
+
{/* 2. Authoritative Server State */}
|
|
40
|
+
<span
|
|
41
|
+
data-testid="residency-server-badge"
|
|
42
|
+
className={`px-2 py-0.5 rounded text-[11px] font-semibold border ${
|
|
43
|
+
server === 'committed'
|
|
44
|
+
? 'bg-blue-500/10 text-blue-600 border-blue-500/30'
|
|
45
|
+
: 'bg-destructive/10 text-destructive border-destructive/30'
|
|
46
|
+
}`}
|
|
47
|
+
>
|
|
48
|
+
server: {server}
|
|
49
|
+
</span>
|
|
50
|
+
|
|
51
|
+
{/* 3. Remote Replicas (S3, MinIO, IPFS, etc.) */}
|
|
52
|
+
{Array.from(replicas.entries()).map(([driver, rep]) => {
|
|
53
|
+
const isVerified = rep.status === 'verified';
|
|
54
|
+
const isPending = rep.status === 'pending';
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<span
|
|
58
|
+
key={driver}
|
|
59
|
+
data-testid={`residency-replica-${driver}`}
|
|
60
|
+
title={rep.verifiedAt ? `Verified at ${rep.verifiedAt}` : undefined}
|
|
61
|
+
className={`px-2 py-0.5 rounded text-[11px] font-semibold border ${
|
|
62
|
+
isVerified
|
|
63
|
+
? 'bg-purple-500/10 text-purple-600 border-purple-500/30'
|
|
64
|
+
: isPending
|
|
65
|
+
? 'bg-amber-500/10 text-amber-600 border-amber-500/30'
|
|
66
|
+
: 'bg-muted/30 text-muted-foreground border-border'
|
|
67
|
+
}`}
|
|
68
|
+
>
|
|
69
|
+
{driver}: {rep.status}
|
|
70
|
+
{rep.verifiedAt && (
|
|
71
|
+
<span className="ml-1 text-[10px] opacity-75">
|
|
72
|
+
({new Date(rep.verifiedAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })})
|
|
73
|
+
</span>
|
|
74
|
+
)}
|
|
75
|
+
</span>
|
|
76
|
+
);
|
|
77
|
+
})}
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default ResidencyIndicator;
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"ignore": {
|
|
61
61
|
"dirs": ["__pycache__", "node_modules", ".git"],
|
|
62
62
|
"extensions": [".py", ".pyc", ".pyo", ".js", ".ts", ".mjs"],
|
|
63
|
-
"patterns": [".git", "__pycache__", "node_modules", ".DS_Store"],
|
|
63
|
+
"patterns": [".git", "__pycache__", "node_modules", ".DS_Store", "-wal", "-shm", "-journal", "servermemory.db", "server_log.db"],
|
|
64
64
|
"filenames": ["__init__.py"],
|
|
65
65
|
"skip_dotfiles": true
|
|
66
66
|
}
|
|
@@ -104,14 +104,14 @@
|
|
|
104
104
|
},
|
|
105
105
|
"vfs": {
|
|
106
106
|
"scan_roots": ["assets", "workspace"],
|
|
107
|
-
"extra_ignore_paths": ["dist", ".turbo", "dev-dist"],
|
|
107
|
+
"extra_ignore_paths": ["dist", ".turbo", "dev-dist", "servermemory.db", "servermemory.db-wal", "servermemory.db-shm", "server_log.db"],
|
|
108
108
|
"hash_max_bytes": 1048576,
|
|
109
109
|
"inline_max_bytes": 262144,
|
|
110
110
|
"handle_separator": ":",
|
|
111
111
|
"text_extensions": [
|
|
112
112
|
".txt", ".url", ".md", ".json", ".xml", ".csv", ".tsv", ".html", ".htm",
|
|
113
113
|
".ts", ".tsx", ".js", ".jsx", ".yaml", ".yml", ".css", ".svg",
|
|
114
|
-
".tikz", ".tikzcd", ".tikz-cd", ".tex"
|
|
114
|
+
".tikz", ".tikzcd", ".tikz-cd", ".tex", ".dxf"
|
|
115
115
|
],
|
|
116
116
|
"default_tabs": ["clm", "workspace"]
|
|
117
117
|
},
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/core/projection/catalog.ts
|
|
3
|
+
* Pure projection models for the Supported Function & Capability Explorer
|
|
4
|
+
* (SMR-10 · DoD-SMR-10-04).
|
|
5
|
+
*
|
|
6
|
+
* The catalog is built by `mcard-studio/scripts/build-supported-function-catalog.mjs`
|
|
7
|
+
* from declared sources only; this module only filters and summarises what that
|
|
8
|
+
* builder produced. No I/O, no ambient reads (INV-FM-02).
|
|
9
|
+
*
|
|
10
|
+
* Contract D budget: <= 250 LOC.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** One discoverable descriptor. `executable` is always false — discovery is not authority. */
|
|
14
|
+
export interface CatalogDescriptor {
|
|
15
|
+
readonly handle: string;
|
|
16
|
+
readonly kind: string;
|
|
17
|
+
readonly domain: string;
|
|
18
|
+
readonly operation: string | null;
|
|
19
|
+
readonly runtimes: readonly string[];
|
|
20
|
+
readonly correctness_grade: string | null;
|
|
21
|
+
readonly executable: boolean;
|
|
22
|
+
readonly source: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SupportedFunctionCatalog {
|
|
26
|
+
readonly catalog_version: string;
|
|
27
|
+
readonly generated_at: string;
|
|
28
|
+
readonly executable_descriptors: number;
|
|
29
|
+
readonly sources: readonly { readonly id: string; readonly path: string; readonly descriptors: number }[];
|
|
30
|
+
readonly counts: {
|
|
31
|
+
readonly total: number;
|
|
32
|
+
readonly by_kind: Readonly<Record<string, number>>;
|
|
33
|
+
readonly by_runtime: Readonly<Record<string, number>>;
|
|
34
|
+
readonly by_grade: Readonly<Record<string, number>>;
|
|
35
|
+
};
|
|
36
|
+
readonly descriptors: readonly CatalogDescriptor[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface CatalogFilter {
|
|
40
|
+
readonly query?: string;
|
|
41
|
+
readonly kind?: string | null;
|
|
42
|
+
readonly runtime?: string | null;
|
|
43
|
+
readonly grade?: string | null;
|
|
44
|
+
readonly source?: string | null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Facets the explorer offers as filters, derived from the catalog itself. */
|
|
48
|
+
export interface CatalogFacets {
|
|
49
|
+
readonly kinds: string[];
|
|
50
|
+
readonly runtimes: string[];
|
|
51
|
+
readonly grades: string[];
|
|
52
|
+
readonly sources: string[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function catalogFacets(catalog: SupportedFunctionCatalog): CatalogFacets {
|
|
56
|
+
const collect = (values: readonly (string | null)[]) =>
|
|
57
|
+
[...new Set(values.filter((value): value is string => Boolean(value)))].sort();
|
|
58
|
+
return {
|
|
59
|
+
kinds: collect(catalog.descriptors.map((d) => d.kind)),
|
|
60
|
+
runtimes: collect(catalog.descriptors.flatMap((d) => d.runtimes)),
|
|
61
|
+
grades: collect(catalog.descriptors.map((d) => d.correctness_grade)),
|
|
62
|
+
sources: collect(catalog.descriptors.map((d) => d.source)),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Free-text search over handle, operation, and domain. */
|
|
67
|
+
function matchesQuery(descriptor: CatalogDescriptor, query: string): boolean {
|
|
68
|
+
const needle = query.trim().toLowerCase();
|
|
69
|
+
if (!needle) return true;
|
|
70
|
+
return [descriptor.handle, descriptor.operation, descriptor.domain]
|
|
71
|
+
.filter((value): value is string => typeof value === 'string')
|
|
72
|
+
.some((value) => value.toLowerCase().includes(needle));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Filters descriptors by query, kind, runtime, correctness grade, and source. */
|
|
76
|
+
export function filterDescriptors(
|
|
77
|
+
descriptors: readonly CatalogDescriptor[],
|
|
78
|
+
filter: CatalogFilter = {},
|
|
79
|
+
): CatalogDescriptor[] {
|
|
80
|
+
const { query = '', kind = null, runtime = null, grade = null, source = null } = filter;
|
|
81
|
+
return descriptors.filter((descriptor) => {
|
|
82
|
+
if (!matchesQuery(descriptor, query)) return false;
|
|
83
|
+
if (kind && descriptor.kind !== kind) return false;
|
|
84
|
+
if (runtime && !descriptor.runtimes.includes(runtime)) return false;
|
|
85
|
+
if (grade && descriptor.correctness_grade !== grade) return false;
|
|
86
|
+
if (source && descriptor.source !== source) return false;
|
|
87
|
+
return true;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Descriptors a catalog claims are executable. It must always be empty: a catalog
|
|
93
|
+
* entry is discovery, never authority (DoD-SMR-10-05).
|
|
94
|
+
*/
|
|
95
|
+
export function executableDescriptors(catalog: SupportedFunctionCatalog): CatalogDescriptor[] {
|
|
96
|
+
return catalog.descriptors.filter((descriptor) => descriptor.executable);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Human-readable summary of what the catalog covers, for the viewlet header. */
|
|
100
|
+
export function catalogSummary(catalog: SupportedFunctionCatalog): string {
|
|
101
|
+
const kinds = Object.entries(catalog.counts.by_kind)
|
|
102
|
+
.map(([kind, count]) => `${count} ${kind}`)
|
|
103
|
+
.join(' · ');
|
|
104
|
+
return `${catalog.counts.total} descriptor(s) — ${kinds}`;
|
|
105
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/core/projection/collection.ts
|
|
3
|
+
* Pure projection models for the multi-card collection browser and the handle
|
|
4
|
+
* lineage drawer (SMR-10 · DoD-SMR-10-02).
|
|
5
|
+
*
|
|
6
|
+
* PURE by construction (INV-FM-02): no I/O, no timers, no ambient reads. Every
|
|
7
|
+
* function here is a total function of its arguments, so the components in
|
|
8
|
+
* `src/components/studio/views/navigation/` only render what these compute.
|
|
9
|
+
*
|
|
10
|
+
* Contract D budget: <= 250 LOC.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** The minimum a card must expose to be browsable. */
|
|
14
|
+
export interface CollectionCard {
|
|
15
|
+
readonly hash: string;
|
|
16
|
+
readonly handle?: string | null;
|
|
17
|
+
readonly mimeType?: string | null;
|
|
18
|
+
readonly sizeBytes?: number;
|
|
19
|
+
readonly gTime?: string | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CollectionFilter {
|
|
23
|
+
readonly query?: string;
|
|
24
|
+
readonly mime?: string | null;
|
|
25
|
+
readonly handlePrefix?: string | null;
|
|
26
|
+
readonly sort?: 'newest' | 'oldest' | 'handle';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** One handle bound to the same content hash more than once. */
|
|
30
|
+
export interface DuplicateGroup {
|
|
31
|
+
readonly handle: string;
|
|
32
|
+
readonly hashes: readonly string[];
|
|
33
|
+
readonly keepHash: string;
|
|
34
|
+
readonly releaseHashes: readonly string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A handle's revision chain, oldest first, with the current binding last. */
|
|
38
|
+
export interface HandleLineageViewModel {
|
|
39
|
+
readonly handle: string;
|
|
40
|
+
readonly currentHash: string;
|
|
41
|
+
readonly revisions: readonly { readonly previousHash: string; readonly changedAt: string }[];
|
|
42
|
+
readonly revisionCount: number;
|
|
43
|
+
/** True when the chain has at least one prior revision to restore. */
|
|
44
|
+
readonly restorable: boolean;
|
|
45
|
+
/** The hash a restore would reinstate, or null when there is nothing to restore. */
|
|
46
|
+
readonly restoreTarget: string | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Free-text search over handle, hash, and mime type. */
|
|
50
|
+
export function matchesQuery(card: CollectionCard, query: string): boolean {
|
|
51
|
+
const needle = query.trim().toLowerCase();
|
|
52
|
+
if (!needle) return true;
|
|
53
|
+
return [card.handle, card.hash, card.mimeType]
|
|
54
|
+
.filter((value): value is string => typeof value === 'string')
|
|
55
|
+
.some((value) => value.toLowerCase().includes(needle));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Filters and orders a collection. Stable for equal keys. */
|
|
59
|
+
export function filterCollectionCards(
|
|
60
|
+
cards: readonly CollectionCard[],
|
|
61
|
+
filter: CollectionFilter = {},
|
|
62
|
+
): CollectionCard[] {
|
|
63
|
+
const { query = '', mime = null, handlePrefix = null, sort = 'newest' } = filter;
|
|
64
|
+
const selected = cards.filter((card) => {
|
|
65
|
+
if (!matchesQuery(card, query)) return false;
|
|
66
|
+
if (mime && (card.mimeType ?? '') !== mime) return false;
|
|
67
|
+
if (handlePrefix && !(card.handle ?? '').startsWith(handlePrefix)) return false;
|
|
68
|
+
return true;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const ordered = [...selected];
|
|
72
|
+
if (sort === 'handle') {
|
|
73
|
+
ordered.sort((a, b) => (a.handle ?? '').localeCompare(b.handle ?? ''));
|
|
74
|
+
} else {
|
|
75
|
+
// `g_time` is `ALGORITHM|TIMESTAMP|LOCALE`; the timestamp is coordinate b.
|
|
76
|
+
const stamp = (card: CollectionCard) => String(card.gTime ?? '').split('|')[1] ?? '';
|
|
77
|
+
ordered.sort((a, b) =>
|
|
78
|
+
sort === 'oldest' ? stamp(a).localeCompare(stamp(b)) : stamp(b).localeCompare(stamp(a)),
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return ordered;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Distinct MIME types present, for the filter dropdown. */
|
|
85
|
+
export function collectionMimeTypes(cards: readonly CollectionCard[]): string[] {
|
|
86
|
+
return [...new Set(cards.map((card) => card.mimeType).filter((mime): mime is string => Boolean(mime)))].sort();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Finds handles bound to more than one distinct hash. Duplicate detection is by
|
|
91
|
+
* handle identity, never by content: two handles sharing a hash is normal, one
|
|
92
|
+
* handle reaching two hashes through a stale binding is the defect.
|
|
93
|
+
*/
|
|
94
|
+
export function findDuplicateHandles(
|
|
95
|
+
bindings: readonly { readonly handle: string; readonly currentHash: string }[],
|
|
96
|
+
): DuplicateGroup[] {
|
|
97
|
+
const byHandle = new Map<string, Set<string>>();
|
|
98
|
+
for (const { handle, currentHash } of bindings) {
|
|
99
|
+
if (!handle || !currentHash) continue;
|
|
100
|
+
if (!byHandle.has(handle)) byHandle.set(handle, new Set());
|
|
101
|
+
byHandle.get(handle)?.add(currentHash);
|
|
102
|
+
}
|
|
103
|
+
const groups: DuplicateGroup[] = [];
|
|
104
|
+
for (const [handle, hashes] of byHandle) {
|
|
105
|
+
if (hashes.size < 2) continue;
|
|
106
|
+
const ordered = [...hashes].sort();
|
|
107
|
+
groups.push({
|
|
108
|
+
handle,
|
|
109
|
+
hashes: ordered,
|
|
110
|
+
keepHash: ordered[ordered.length - 1],
|
|
111
|
+
releaseHashes: ordered.slice(0, -1),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return groups.sort((a, b) => a.handle.localeCompare(b.handle));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Counts the rows a cleanup would release, for the confirmation prompt. */
|
|
118
|
+
export function summarizeCleanup(groups: readonly DuplicateGroup[]): {
|
|
119
|
+
readonly handles: number;
|
|
120
|
+
readonly released: number;
|
|
121
|
+
} {
|
|
122
|
+
return {
|
|
123
|
+
handles: groups.length,
|
|
124
|
+
released: groups.reduce((total, group) => total + group.releaseHashes.length, 0),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Builds a handle's revision chain. `history` is `handle_history` (previous hashes,
|
|
130
|
+
* oldest first); the current binding is appended last, so restoring means re-binding
|
|
131
|
+
* the hash at `restoreTarget` — the immediately preceding revision.
|
|
132
|
+
*/
|
|
133
|
+
export function computeHandleLineage(
|
|
134
|
+
handle: string,
|
|
135
|
+
currentHash: string,
|
|
136
|
+
history: readonly { readonly previousHash: string; readonly changedAt: string }[] = [],
|
|
137
|
+
): HandleLineageViewModel {
|
|
138
|
+
const revisions = [...history].sort((a, b) => a.changedAt.localeCompare(b.changedAt));
|
|
139
|
+
const prior = revisions.filter((revision) => revision.previousHash !== currentHash);
|
|
140
|
+
return {
|
|
141
|
+
handle,
|
|
142
|
+
currentHash,
|
|
143
|
+
revisions,
|
|
144
|
+
revisionCount: revisions.length,
|
|
145
|
+
restorable: prior.length > 0,
|
|
146
|
+
restoreTarget: prior.length > 0 ? prior[prior.length - 1].previousHash : null,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/core/projection/handleSubscription.ts
|
|
3
|
+
*
|
|
4
|
+
* Per-handle reactive projection subscriptions (Sprint CAS-08 / DoD-08-1, INV-CAS-12).
|
|
5
|
+
* Exposes selectHandle(h) returning a Nanostores atom/computed keyed strictly to handle h.
|
|
6
|
+
* A transition for h updates ONLY selectHandle(h) and the manifest of h's parent directory.
|
|
7
|
+
* Unrelated viewlets experience zero re-renders.
|
|
8
|
+
*
|
|
9
|
+
* Strictly pure: zero imports from edge, membrane, ui, Node built-ins, or DOM.
|
|
10
|
+
* Contract D budget: <= 250 LOC.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { atom, type WritableAtom } from 'nanostores';
|
|
14
|
+
|
|
15
|
+
export interface HandleProjectionState {
|
|
16
|
+
readonly handle: string;
|
|
17
|
+
readonly hash?: string;
|
|
18
|
+
readonly content?: string;
|
|
19
|
+
readonly kind?: string;
|
|
20
|
+
readonly version: number;
|
|
21
|
+
readonly lastUpdated: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ParentManifestState {
|
|
25
|
+
readonly parent: string;
|
|
26
|
+
readonly children: readonly string[];
|
|
27
|
+
readonly version: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface TransitionNotificationPayload {
|
|
31
|
+
readonly handle: string;
|
|
32
|
+
readonly hash?: string;
|
|
33
|
+
readonly kind?: string;
|
|
34
|
+
readonly from?: string | null;
|
|
35
|
+
readonly to?: string | null;
|
|
36
|
+
readonly author?: string;
|
|
37
|
+
readonly clock?: unknown;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const handleStores = new Map<string, WritableAtom<HandleProjectionState>>();
|
|
41
|
+
const parentManifestStores = new Map<string, WritableAtom<ParentManifestState>>();
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Extracts the parent directory path/handle of a given handle.
|
|
45
|
+
* e.g., 'cards/text/05_document.md' -> 'cards/text'
|
|
46
|
+
*/
|
|
47
|
+
export function getParentHandle(handle: string): string | null {
|
|
48
|
+
if (!handle) return null;
|
|
49
|
+
const normalized = handle.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
50
|
+
const lastSlash = normalized.lastIndexOf('/');
|
|
51
|
+
if (lastSlash <= 0) return null;
|
|
52
|
+
return normalized.slice(0, lastSlash);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Returns a reactive Nanostores atom for a specific handle.
|
|
57
|
+
* Viewlets bind directly to this store instead of $mcardTree, guaranteeing
|
|
58
|
+
* render isolation across distinct handles.
|
|
59
|
+
*/
|
|
60
|
+
export function selectHandle(handle: string): WritableAtom<HandleProjectionState> {
|
|
61
|
+
let store = handleStores.get(handle);
|
|
62
|
+
if (!store) {
|
|
63
|
+
store = atom<HandleProjectionState>({
|
|
64
|
+
handle,
|
|
65
|
+
version: 0,
|
|
66
|
+
lastUpdated: 0,
|
|
67
|
+
});
|
|
68
|
+
handleStores.set(handle, store);
|
|
69
|
+
}
|
|
70
|
+
return store;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Returns a reactive Nanostores atom for a parent folder's child manifests.
|
|
75
|
+
*/
|
|
76
|
+
export function selectParentManifest(parentHandle: string): WritableAtom<ParentManifestState> {
|
|
77
|
+
let store = parentManifestStores.get(parentHandle);
|
|
78
|
+
if (!store) {
|
|
79
|
+
store = atom<ParentManifestState>({
|
|
80
|
+
parent: parentHandle,
|
|
81
|
+
children: [],
|
|
82
|
+
version: 0,
|
|
83
|
+
});
|
|
84
|
+
parentManifestStores.set(parentHandle, store);
|
|
85
|
+
}
|
|
86
|
+
return store;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Applies a clm.name.transition notification event.
|
|
91
|
+
* Per DoD-08-1: A clm.name.transition for h updates only selectHandle(h)
|
|
92
|
+
* and the manifest of h's parent.
|
|
93
|
+
*/
|
|
94
|
+
export function applyHandleTransition(transition: TransitionNotificationPayload): void {
|
|
95
|
+
const { handle, hash, to, kind } = transition;
|
|
96
|
+
if (!handle) return;
|
|
97
|
+
|
|
98
|
+
const store = selectHandle(handle);
|
|
99
|
+
const current = store.get();
|
|
100
|
+
const nextHash = to || hash || current.hash;
|
|
101
|
+
|
|
102
|
+
store.set({
|
|
103
|
+
handle,
|
|
104
|
+
hash: nextHash,
|
|
105
|
+
kind: kind || 'UPDATE',
|
|
106
|
+
version: current.version + 1,
|
|
107
|
+
lastUpdated: Date.now(),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Update manifest of h's parent
|
|
111
|
+
const parent = getParentHandle(handle);
|
|
112
|
+
if (parent) {
|
|
113
|
+
const parentStore = selectParentManifest(parent);
|
|
114
|
+
const parentCurrent = parentStore.get();
|
|
115
|
+
const children = parentCurrent.children.includes(handle)
|
|
116
|
+
? parentCurrent.children
|
|
117
|
+
: [...parentCurrent.children, handle];
|
|
118
|
+
parentStore.set({
|
|
119
|
+
parent,
|
|
120
|
+
children,
|
|
121
|
+
version: parentCurrent.version + 1,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Test helper to clear store caches.
|
|
128
|
+
*/
|
|
129
|
+
export function resetHandleSubscriptionsForTesting(): void {
|
|
130
|
+
handleStores.clear();
|
|
131
|
+
parentManifestStores.clear();
|
|
132
|
+
}
|
|
@@ -4,11 +4,15 @@
|
|
|
4
4
|
* Contract D budget: <= 250 LOC.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
export * from './collection';
|
|
7
8
|
export * from './files/reduce';
|
|
8
9
|
export * from './overlay';
|
|
9
10
|
export * from './processes/reduce';
|
|
11
|
+
export * from './handleSubscription';
|
|
10
12
|
export * from './reduce';
|
|
11
13
|
export * from './replay';
|
|
12
14
|
export * from './selectors';
|
|
13
15
|
export * from './shell/reduce';
|
|
14
16
|
export * from './state';
|
|
17
|
+
export * from './views';
|
|
18
|
+
|
|
@@ -77,3 +77,32 @@ export function selectOpenTabs(state: StudioState): readonly string[] {
|
|
|
77
77
|
export function selectIsTreeNodeExpanded(state: StudioState, path: string): boolean {
|
|
78
78
|
return state.shell.expandedTreeNodes.has(path);
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Filter visible history entries for presentation (CAS-02 / DoD-02-3).
|
|
83
|
+
* In the CAS model, history is immutable evidence; 'delete history' is replaced by a projection filter
|
|
84
|
+
* that hides entries from the list view without altering underlying storage.
|
|
85
|
+
*/
|
|
86
|
+
export function selectVisibleHistory<T extends { hash?: string; previousHash?: string }>(
|
|
87
|
+
history: readonly T[],
|
|
88
|
+
hiddenHashes: ReadonlySet<string> | readonly string[] = []
|
|
89
|
+
): readonly T[] {
|
|
90
|
+
const hiddenSet = hiddenHashes instanceof Set ? hiddenHashes : new Set(hiddenHashes);
|
|
91
|
+
if (hiddenSet.size === 0) return history;
|
|
92
|
+
return history.filter((entry) => {
|
|
93
|
+
const h = entry.hash || entry.previousHash;
|
|
94
|
+
return !h || !hiddenSet.has(h);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
selectHandle,
|
|
100
|
+
selectParentManifest,
|
|
101
|
+
applyHandleTransition,
|
|
102
|
+
getParentHandle,
|
|
103
|
+
resetHandleSubscriptionsForTesting,
|
|
104
|
+
type HandleProjectionState,
|
|
105
|
+
type ParentManifestState,
|
|
106
|
+
type TransitionNotificationPayload,
|
|
107
|
+
} from './handleSubscription';
|
|
108
|
+
|