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,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FibrationRefinementViewlet — Least-Action & Fibration Refinement UI
|
|
3
|
+
* (SMR-11 · DoD-SMR-11-02), registered as `pcard:render/fibration-dashboard`.
|
|
4
|
+
*
|
|
5
|
+
* Migrates the local Least-Action Navigator and Fibration Dashboard: per-unit
|
|
6
|
+
* Software Lagrangian scores, the least-action ordering, the base-to-fiber
|
|
7
|
+
* projection for a selected unit, and a refinement trajectory across revisions.
|
|
8
|
+
* All computation lives in the pure engines; this viewlet renders and raises intents.
|
|
9
|
+
*
|
|
10
|
+
* Contract D budget: <= 240 LOC.
|
|
11
|
+
*/
|
|
12
|
+
import React, { useMemo, useState } from 'react';
|
|
13
|
+
|
|
14
|
+
import { computeLagrangian, type UnitMetrics } from '@/core/refinement/lagrangianEngine';
|
|
15
|
+
import {
|
|
16
|
+
leastActionPath,
|
|
17
|
+
projectFibration,
|
|
18
|
+
refinementTrajectory,
|
|
19
|
+
type AssessmentUnit,
|
|
20
|
+
} from '@/core/refinement/fibrationProjector';
|
|
21
|
+
|
|
22
|
+
export interface FibrationRefinementViewletProps {
|
|
23
|
+
readonly units: readonly AssessmentUnit[];
|
|
24
|
+
readonly revisions?: readonly { readonly hash: string; readonly lagrangian: number; readonly changedAt?: string }[];
|
|
25
|
+
readonly handle?: string;
|
|
26
|
+
readonly onSelectUnit?: (unit: string) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Scores raw metrics into an assessment unit, for callers holding only metrics. */
|
|
30
|
+
export function assessUnit(unit: string, metrics: UnitMetrics, tau?: AssessmentUnit['tau']): AssessmentUnit {
|
|
31
|
+
const score = computeLagrangian(metrics);
|
|
32
|
+
return {
|
|
33
|
+
unit,
|
|
34
|
+
tau,
|
|
35
|
+
payload_bytes: metrics.payload?.total_bytes ?? 0,
|
|
36
|
+
within_budget: metrics.payload?.within_budget ?? true,
|
|
37
|
+
functionality_coverage: metrics.functionality?.invariant_coverage ?? 1,
|
|
38
|
+
S_T: score.S_T,
|
|
39
|
+
H_T: score.H_T,
|
|
40
|
+
lagrangian: score.lagrangian,
|
|
41
|
+
regime: score.regime,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const LagrangianTable: React.FC<{ units: readonly AssessmentUnit[]; onSelectUnit?: (unit: string) => void }> = ({
|
|
46
|
+
units,
|
|
47
|
+
onSelectUnit,
|
|
48
|
+
}) => (
|
|
49
|
+
<table className="fibration-units">
|
|
50
|
+
<thead>
|
|
51
|
+
<tr>
|
|
52
|
+
<th scope="col">Unit</th>
|
|
53
|
+
<th scope="col">S_T</th>
|
|
54
|
+
<th scope="col">H_T</th>
|
|
55
|
+
<th scope="col">ℒ</th>
|
|
56
|
+
<th scope="col">Regime</th>
|
|
57
|
+
</tr>
|
|
58
|
+
</thead>
|
|
59
|
+
<tbody>
|
|
60
|
+
{units.map((unit) => (
|
|
61
|
+
<tr key={unit.unit} data-role="unit-row" data-regime={unit.regime}>
|
|
62
|
+
<th scope="row">
|
|
63
|
+
<button type="button" onClick={() => onSelectUnit?.(unit.unit)}>
|
|
64
|
+
{unit.unit}
|
|
65
|
+
</button>
|
|
66
|
+
</th>
|
|
67
|
+
<td>{unit.S_T.toFixed(4)}</td>
|
|
68
|
+
<td>{unit.H_T.toFixed(4)}</td>
|
|
69
|
+
<td data-role="lagrangian">{unit.lagrangian.toFixed(4)}</td>
|
|
70
|
+
<td>{unit.regime}</td>
|
|
71
|
+
</tr>
|
|
72
|
+
))}
|
|
73
|
+
</tbody>
|
|
74
|
+
</table>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
export const FibrationRefinementViewlet: React.FC<FibrationRefinementViewletProps> = ({
|
|
78
|
+
units,
|
|
79
|
+
revisions = [],
|
|
80
|
+
handle = 'urn:mcard:content:landing_page',
|
|
81
|
+
onSelectUnit,
|
|
82
|
+
}) => {
|
|
83
|
+
const [selected, setSelected] = useState<string>(units[0]?.unit ?? '');
|
|
84
|
+
const order = useMemo(() => leastActionPath(units), [units]);
|
|
85
|
+
const projection = useMemo(
|
|
86
|
+
() => (selected ? projectFibration(selected, units) : null),
|
|
87
|
+
[selected, units],
|
|
88
|
+
);
|
|
89
|
+
const trajectory = useMemo(
|
|
90
|
+
() => (revisions.length > 0 ? refinementTrajectory(handle, revisions) : null),
|
|
91
|
+
[handle, revisions],
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const select = (unit: string) => {
|
|
95
|
+
setSelected(unit);
|
|
96
|
+
onSelectUnit?.(unit);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<section className="fibration-viewlet" aria-label="Least-action and fibration refinement">
|
|
101
|
+
<header>
|
|
102
|
+
<h3>Least-Action & Fibration</h3>
|
|
103
|
+
<p className="fibration-note">
|
|
104
|
+
ℒ = S_T − H_T · geodesic when ℒ > 0.05, pruning when ℒ < −0.05
|
|
105
|
+
</p>
|
|
106
|
+
</header>
|
|
107
|
+
|
|
108
|
+
<LagrangianTable units={units} onSelectUnit={select} />
|
|
109
|
+
|
|
110
|
+
<section className="fibration-least-action" aria-label="Least-action ordering">
|
|
111
|
+
<h4>Least-action ordering</h4>
|
|
112
|
+
<ol data-role="least-action-order">
|
|
113
|
+
{order.map((unit) => (
|
|
114
|
+
<li key={unit}>{unit}</li>
|
|
115
|
+
))}
|
|
116
|
+
</ol>
|
|
117
|
+
</section>
|
|
118
|
+
|
|
119
|
+
{projection && (
|
|
120
|
+
<section className="fibration-projection" aria-label={`Fiber projection over ${projection.base}`}>
|
|
121
|
+
<h4>Fiber projection over {projection.base}</h4>
|
|
122
|
+
<p data-role="fiber-count">
|
|
123
|
+
{projection.fiberCount} fiber(s) · spread {projection.spread.toFixed(4)}
|
|
124
|
+
</p>
|
|
125
|
+
<ul>
|
|
126
|
+
{projection.fibers.map((fiber) => (
|
|
127
|
+
<li key={fiber.coordinate} data-role="fiber">
|
|
128
|
+
<code>{fiber.coordinate}</code> — ℒ {fiber.lagrangian.toFixed(4)} ({fiber.regime})
|
|
129
|
+
</li>
|
|
130
|
+
))}
|
|
131
|
+
</ul>
|
|
132
|
+
</section>
|
|
133
|
+
)}
|
|
134
|
+
|
|
135
|
+
{trajectory && (
|
|
136
|
+
<section className="fibration-trajectory" aria-label="Refinement trajectory">
|
|
137
|
+
<h4>Refinement trajectory</h4>
|
|
138
|
+
<p data-role="trajectory-net">
|
|
139
|
+
net ℒ {trajectory.netLagrangian.toFixed(4)} · {trajectory.direction}
|
|
140
|
+
{trajectory.imaginaryAction ? ' · imaginary action distance' : ''}
|
|
141
|
+
</p>
|
|
142
|
+
<ol>
|
|
143
|
+
{trajectory.steps.map((step) => (
|
|
144
|
+
<li key={`${step.from}-${step.to}`} data-role="trajectory-step" data-direction={step.direction}>
|
|
145
|
+
{step.from.slice(0, 8)}… → {step.to.slice(0, 8)}… : {step.deltaLagrangian.toFixed(4)}
|
|
146
|
+
</li>
|
|
147
|
+
))}
|
|
148
|
+
</ol>
|
|
149
|
+
</section>
|
|
150
|
+
)}
|
|
151
|
+
</section>
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default FibrationRefinementViewlet;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PetriConformanceViewlet — Petri-net marking & MIME taxonomy fiber conformance
|
|
3
|
+
* (SMR-11 · DoD-SMR-11-03), registered as `pcard:render/petri-inspector`.
|
|
4
|
+
*
|
|
5
|
+
* Supersedes the local `fiber-conformance.html` and `fiber-inspector.html` islands:
|
|
6
|
+
* it validates all 15 MIME taxonomy fiber adapters and renders Petri-net place and
|
|
7
|
+
* transition markings. Read-only — this inspector never fires a transition or mutates
|
|
8
|
+
* a marking (SMR-11 DoD-05).
|
|
9
|
+
*
|
|
10
|
+
* Contract D budget: <= 240 LOC.
|
|
11
|
+
*/
|
|
12
|
+
import React, { useMemo } from 'react';
|
|
13
|
+
|
|
14
|
+
export interface FiberAdapter {
|
|
15
|
+
readonly kind: string;
|
|
16
|
+
readonly payload_shape?: string;
|
|
17
|
+
readonly content_class?: string;
|
|
18
|
+
readonly supertypes?: readonly string[];
|
|
19
|
+
readonly renderer?: string;
|
|
20
|
+
readonly isolation?: string;
|
|
21
|
+
readonly budget?: { readonly archetype?: string; readonly max_bytes?: number };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface PetriMarking {
|
|
25
|
+
readonly place: string;
|
|
26
|
+
readonly tokens: number;
|
|
27
|
+
readonly capacity?: number | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface PetriTransition {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly inputs?: readonly string[];
|
|
33
|
+
readonly outputs?: readonly string[];
|
|
34
|
+
readonly enabled?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface FiberConformanceRow {
|
|
38
|
+
readonly kind: string;
|
|
39
|
+
readonly renderer: string;
|
|
40
|
+
readonly conformant: boolean;
|
|
41
|
+
readonly missing: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A fiber adapter conforms when it declares the fields the taxonomy requires. */
|
|
45
|
+
export function checkFiberConformance(fibers: readonly FiberAdapter[]): {
|
|
46
|
+
readonly rows: readonly FiberConformanceRow[];
|
|
47
|
+
readonly total: number;
|
|
48
|
+
readonly conformant: number;
|
|
49
|
+
readonly allConformant: boolean;
|
|
50
|
+
} {
|
|
51
|
+
const required: readonly (keyof FiberAdapter)[] = ['kind', 'payload_shape', 'content_class', 'renderer'];
|
|
52
|
+
const rows = fibers.map((fiber) => {
|
|
53
|
+
const missing = required.filter((field) => !fiber[field]);
|
|
54
|
+
return {
|
|
55
|
+
kind: fiber.kind,
|
|
56
|
+
renderer: fiber.renderer ?? '(none)',
|
|
57
|
+
conformant: missing.length === 0,
|
|
58
|
+
missing: missing.map(String),
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
const conformant = rows.filter((row) => row.conformant).length;
|
|
62
|
+
return { rows, total: rows.length, conformant, allConformant: rows.length > 0 && conformant === rows.length };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Marking summary: places over capacity are reported, never silently clamped. */
|
|
66
|
+
export function markingSummary(markings: readonly PetriMarking[]): {
|
|
67
|
+
readonly places: number;
|
|
68
|
+
readonly tokens: number;
|
|
69
|
+
readonly overCapacity: readonly string[];
|
|
70
|
+
} {
|
|
71
|
+
return {
|
|
72
|
+
places: markings.length,
|
|
73
|
+
tokens: markings.reduce((total, marking) => total + marking.tokens, 0),
|
|
74
|
+
overCapacity: markings
|
|
75
|
+
.filter((marking) => marking.capacity != null && marking.tokens > marking.capacity)
|
|
76
|
+
.map((marking) => marking.place),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface PetriConformanceViewletProps {
|
|
81
|
+
readonly fibers: readonly FiberAdapter[];
|
|
82
|
+
readonly markings?: readonly PetriMarking[];
|
|
83
|
+
readonly transitions?: readonly PetriTransition[];
|
|
84
|
+
readonly onSelectPlace?: (place: string) => void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const PetriConformanceViewlet: React.FC<PetriConformanceViewletProps> = ({
|
|
88
|
+
fibers,
|
|
89
|
+
markings = [],
|
|
90
|
+
transitions = [],
|
|
91
|
+
onSelectPlace,
|
|
92
|
+
}) => {
|
|
93
|
+
const conformance = useMemo(() => checkFiberConformance(fibers), [fibers]);
|
|
94
|
+
const summary = useMemo(() => markingSummary(markings), [markings]);
|
|
95
|
+
const enabled = transitions.filter((transition) => transition.enabled).length;
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<section className="petri-conformance" aria-label="Petri marking and fiber conformance inspector">
|
|
99
|
+
<header>
|
|
100
|
+
<h3>Petri Markings & Fiber Conformance</h3>
|
|
101
|
+
<p data-role="conformance-summary">
|
|
102
|
+
{conformance.conformant} of {conformance.total} fiber adapter(s) conformant
|
|
103
|
+
</p>
|
|
104
|
+
</header>
|
|
105
|
+
|
|
106
|
+
<table className="petri-fibers">
|
|
107
|
+
<thead>
|
|
108
|
+
<tr>
|
|
109
|
+
<th scope="col">Fiber kind</th>
|
|
110
|
+
<th scope="col">Renderer</th>
|
|
111
|
+
<th scope="col">Conformant</th>
|
|
112
|
+
</tr>
|
|
113
|
+
</thead>
|
|
114
|
+
<tbody>
|
|
115
|
+
{conformance.rows.map((row) => (
|
|
116
|
+
<tr key={row.kind} data-role="fiber-row" data-conformant={String(row.conformant)}>
|
|
117
|
+
<th scope="row">{row.kind}</th>
|
|
118
|
+
<td>
|
|
119
|
+
<code>{row.renderer}</code>
|
|
120
|
+
</td>
|
|
121
|
+
<td>{row.conformant ? '✓' : `✗ missing ${row.missing.join(', ')}`}</td>
|
|
122
|
+
</tr>
|
|
123
|
+
))}
|
|
124
|
+
</tbody>
|
|
125
|
+
</table>
|
|
126
|
+
|
|
127
|
+
<section className="petri-markings" aria-label="Petri markings">
|
|
128
|
+
<h4>Markings</h4>
|
|
129
|
+
<p data-role="marking-summary">
|
|
130
|
+
{summary.places} place(s) · {summary.tokens} token(s)
|
|
131
|
+
{summary.overCapacity.length > 0 ? ` · over capacity: ${summary.overCapacity.join(', ')}` : ''}
|
|
132
|
+
</p>
|
|
133
|
+
<ul>
|
|
134
|
+
{markings.map((marking) => (
|
|
135
|
+
<li key={marking.place} data-role="marking">
|
|
136
|
+
<button type="button" onClick={() => onSelectPlace?.(marking.place)}>
|
|
137
|
+
<code>{marking.place}</code>
|
|
138
|
+
</button>
|
|
139
|
+
<span className="petri-tokens">{marking.tokens}</span>
|
|
140
|
+
{marking.capacity != null && <span className="petri-capacity">/ {marking.capacity}</span>}
|
|
141
|
+
</li>
|
|
142
|
+
))}
|
|
143
|
+
</ul>
|
|
144
|
+
</section>
|
|
145
|
+
|
|
146
|
+
<section className="petri-transitions" aria-label="Petri transitions">
|
|
147
|
+
<h4>Transitions</h4>
|
|
148
|
+
<p data-role="transition-summary">
|
|
149
|
+
{enabled} of {transitions.length} enabled · read-only (no firing control)
|
|
150
|
+
</p>
|
|
151
|
+
<ul>
|
|
152
|
+
{transitions.map((transition) => (
|
|
153
|
+
<li key={transition.id} data-role="transition" data-enabled={String(Boolean(transition.enabled))}>
|
|
154
|
+
<code>{transition.id}</code>
|
|
155
|
+
<span className="petri-io">
|
|
156
|
+
{(transition.inputs ?? []).join(', ')} → {(transition.outputs ?? []).join(', ')}
|
|
157
|
+
</span>
|
|
158
|
+
</li>
|
|
159
|
+
))}
|
|
160
|
+
</ul>
|
|
161
|
+
</section>
|
|
162
|
+
</section>
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export default PetriConformanceViewlet;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResponsiveViewportLabViewlet — Multi-Device Responsive UI Lab
|
|
3
|
+
* (SMR-12 · DoD-SMR-12-02), registered as `pcard:render/viewport-lab`.
|
|
4
|
+
*
|
|
5
|
+
* Migrates `LandingPage/responsive-lab.html`: a Single-Device stage and a
|
|
6
|
+
* Synchronized Quad-Device Matrix (Wearable + Cellphone + Laptop + Desktop),
|
|
7
|
+
* with the containment scale math, the 90° orientation swap, CSS breakpoint
|
|
8
|
+
* rulers, a touch-target heatmap, and one-click conformance witness sealing.
|
|
9
|
+
*
|
|
10
|
+
* Pure view (INV-FM-02): every decision is made by the pure registry; this file
|
|
11
|
+
* renders it and raises intents. It performs no network or storage access.
|
|
12
|
+
*
|
|
13
|
+
* Contract D budget: <= 250 LOC.
|
|
14
|
+
*/
|
|
15
|
+
import React, { useMemo, useState } from 'react';
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
CLASS_DEFAULT_PRESET,
|
|
19
|
+
DEVICE_CLASSES,
|
|
20
|
+
DEVICE_CLASS_IDS,
|
|
21
|
+
auditViewport,
|
|
22
|
+
getPreset,
|
|
23
|
+
isMatrixConformant,
|
|
24
|
+
sealViewportWitness,
|
|
25
|
+
type DeviceClassId,
|
|
26
|
+
type ViewportWitness,
|
|
27
|
+
} from '../../core/viewport/deviceArchetypeRegistry';
|
|
28
|
+
import {
|
|
29
|
+
DeviceFrame,
|
|
30
|
+
measurementFor,
|
|
31
|
+
type LabMeasurements,
|
|
32
|
+
type ViewportLabSample,
|
|
33
|
+
} from './viewportLabParts';
|
|
34
|
+
|
|
35
|
+
export type { ManifestPortalSampleDescriptor, ViewportLabSample } from './viewportLabParts';
|
|
36
|
+
export {
|
|
37
|
+
DeviceFrame,
|
|
38
|
+
adaptImportedPortalSamples,
|
|
39
|
+
frameGeometry,
|
|
40
|
+
measurementFor,
|
|
41
|
+
rulerMarks,
|
|
42
|
+
} from './viewportLabParts';
|
|
43
|
+
|
|
44
|
+
export interface ResponsiveViewportLabViewletProps {
|
|
45
|
+
readonly samples: readonly ViewportLabSample[];
|
|
46
|
+
readonly mode?: 'single' | 'quad';
|
|
47
|
+
/** Live measurements per class; absent measurements fall back to the declared payload. */
|
|
48
|
+
readonly measurements?: LabMeasurements;
|
|
49
|
+
readonly rotated?: boolean;
|
|
50
|
+
readonly showRulers?: boolean;
|
|
51
|
+
readonly showHeatmap?: boolean;
|
|
52
|
+
readonly onSealWitness?: (witness: ViewportWitness) => void;
|
|
53
|
+
readonly onOpenExternal?: (url: string) => void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const ResponsiveViewportLabViewlet: React.FC<ResponsiveViewportLabViewletProps> = ({
|
|
57
|
+
samples,
|
|
58
|
+
mode = 'quad',
|
|
59
|
+
measurements,
|
|
60
|
+
rotated: rotatedProp = false,
|
|
61
|
+
showRulers: rulersProp = true,
|
|
62
|
+
showHeatmap: heatmapProp = true,
|
|
63
|
+
onSealWitness,
|
|
64
|
+
onOpenExternal,
|
|
65
|
+
}) => {
|
|
66
|
+
const [selected, setSelected] = useState<ViewportLabSample | null>(samples[0] ?? null);
|
|
67
|
+
const [activeClass, setActiveClass] = useState<DeviceClassId>('cellphone');
|
|
68
|
+
const [rotated, setRotated] = useState(rotatedProp);
|
|
69
|
+
const [showRulers, setShowRulers] = useState(rulersProp);
|
|
70
|
+
const [showHeatmap, setShowHeatmap] = useState(heatmapProp);
|
|
71
|
+
const [witness, setWitness] = useState<ViewportWitness | null>(null);
|
|
72
|
+
|
|
73
|
+
const target = selected ?? samples[0]!;
|
|
74
|
+
const classes: readonly DeviceClassId[] = mode === 'quad' ? DEVICE_CLASS_IDS : [activeClass];
|
|
75
|
+
|
|
76
|
+
const audits = useMemo(() => {
|
|
77
|
+
const entries = DEVICE_CLASS_IDS.map((id) => {
|
|
78
|
+
const preset = getPreset(CLASS_DEFAULT_PRESET[id])!;
|
|
79
|
+
return [
|
|
80
|
+
id,
|
|
81
|
+
auditViewport(measurementFor(target, id, measurements), id, { width: preset.width, height: preset.height }),
|
|
82
|
+
] as const;
|
|
83
|
+
});
|
|
84
|
+
return Object.fromEntries(entries);
|
|
85
|
+
}, [target, measurements]);
|
|
86
|
+
|
|
87
|
+
const conformant = isMatrixConformant(audits as never);
|
|
88
|
+
|
|
89
|
+
const seal = () => {
|
|
90
|
+
const sealed = sealViewportWitness(target.handle, audits as never);
|
|
91
|
+
setWitness(sealed);
|
|
92
|
+
if (sealed) onSealWitness?.(sealed);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<section className="viewport-lab" aria-label="Responsive viewport lab" data-role="viewport-lab" data-mode={mode}>
|
|
97
|
+
<header>
|
|
98
|
+
<h3>Responsive Viewport Lab</h3>
|
|
99
|
+
<div role="toolbar" aria-label="Viewport lab controls">
|
|
100
|
+
<button type="button" data-role="toggle-rotation" aria-pressed={rotated} onClick={() => setRotated((v) => !v)}>
|
|
101
|
+
↻ Rotate 90°
|
|
102
|
+
</button>
|
|
103
|
+
<button type="button" data-role="toggle-rulers" aria-pressed={showRulers} onClick={() => setShowRulers((v) => !v)}>
|
|
104
|
+
📏 Rulers
|
|
105
|
+
</button>
|
|
106
|
+
<button type="button" data-role="toggle-heatmap" aria-pressed={showHeatmap} onClick={() => setShowHeatmap((v) => !v)}>
|
|
107
|
+
🎯 Touch Heatmap
|
|
108
|
+
</button>
|
|
109
|
+
<button type="button" data-role="seal-witness" disabled={!conformant} onClick={seal}>
|
|
110
|
+
Seal Conformance Witness
|
|
111
|
+
</button>
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
<ul data-role="sample-list">
|
|
115
|
+
{samples.map((sample) => (
|
|
116
|
+
<li key={sample.handle}>
|
|
117
|
+
<button
|
|
118
|
+
type="button"
|
|
119
|
+
data-role="sample"
|
|
120
|
+
aria-pressed={target.handle === sample.handle}
|
|
121
|
+
onClick={() => setSelected(sample)}
|
|
122
|
+
>
|
|
123
|
+
{sample.label}
|
|
124
|
+
</button>
|
|
125
|
+
</li>
|
|
126
|
+
))}
|
|
127
|
+
</ul>
|
|
128
|
+
|
|
129
|
+
<ul data-role="class-list">
|
|
130
|
+
{DEVICE_CLASS_IDS.map((id) => (
|
|
131
|
+
<li key={id}>
|
|
132
|
+
<button
|
|
133
|
+
type="button"
|
|
134
|
+
data-role="device-class"
|
|
135
|
+
aria-pressed={activeClass === id}
|
|
136
|
+
onClick={() => setActiveClass(id)}
|
|
137
|
+
>
|
|
138
|
+
{DEVICE_CLASSES[id].label}
|
|
139
|
+
</button>
|
|
140
|
+
</li>
|
|
141
|
+
))}
|
|
142
|
+
</ul>
|
|
143
|
+
</header>
|
|
144
|
+
|
|
145
|
+
<div className="viewport-stage" data-role="viewport-stage" data-matrix={mode}>
|
|
146
|
+
{classes.map((id) => (
|
|
147
|
+
<DeviceFrame
|
|
148
|
+
key={id}
|
|
149
|
+
deviceClass={id}
|
|
150
|
+
presetId={CLASS_DEFAULT_PRESET[id]}
|
|
151
|
+
sample={target}
|
|
152
|
+
measurement={measurementFor(target, id, measurements)}
|
|
153
|
+
rotated={rotated}
|
|
154
|
+
showRulers={showRulers}
|
|
155
|
+
showHeatmap={showHeatmap}
|
|
156
|
+
/>
|
|
157
|
+
))}
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
{witness && (
|
|
161
|
+
<p data-role="witness">
|
|
162
|
+
{witness.contract} · {witness.classes.length}/4 classes · <code>{witness.witnessHash.slice(0, 12)}…</code>
|
|
163
|
+
</p>
|
|
164
|
+
)}
|
|
165
|
+
|
|
166
|
+
{target.kind === 'external' && target.url && (
|
|
167
|
+
<button type="button" data-role="open-external" onClick={() => onOpenExternal?.(target.url!)}>
|
|
168
|
+
Open {target.url} in membrane
|
|
169
|
+
</button>
|
|
170
|
+
)}
|
|
171
|
+
</section>
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export default ResponsiveViewportLabViewlet;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SprintGovernanceViewlet — Sprint registry & deployment unit budget inspector
|
|
3
|
+
* (SMR-11 · DoD-SMR-11-04), registered as `pcard:render/sprint-governance`.
|
|
4
|
+
*
|
|
5
|
+
* Supersedes the local `sprint-registry.html` and `deployment-inspector.js` islands:
|
|
6
|
+
* it projects the sprint registry (sprint manifests, DoD seal state) and the
|
|
7
|
+
* multi-device `.mcard.db` deployment units with byte budgets, raising a threshold
|
|
8
|
+
* alert when a unit exceeds its budget. Read-only.
|
|
9
|
+
*
|
|
10
|
+
* Contract D budget: <= 240 LOC.
|
|
11
|
+
*/
|
|
12
|
+
import React, { useMemo, useState } from 'react';
|
|
13
|
+
|
|
14
|
+
import type { AssessmentUnit } from '@/core/refinement/fibrationProjector';
|
|
15
|
+
|
|
16
|
+
export interface SprintManifest {
|
|
17
|
+
readonly code: string;
|
|
18
|
+
readonly title?: string;
|
|
19
|
+
readonly status?: string;
|
|
20
|
+
readonly dodTotal?: number;
|
|
21
|
+
readonly dodPassed?: number;
|
|
22
|
+
readonly seal?: 'sealed' | 'open' | 'none';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SprintGovernanceProjection {
|
|
26
|
+
readonly total: number;
|
|
27
|
+
readonly byStatus: Readonly<Record<string, number>>;
|
|
28
|
+
readonly sealed: number;
|
|
29
|
+
readonly dodTotal: number;
|
|
30
|
+
readonly dodPassed: number;
|
|
31
|
+
readonly dodCompletion: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Projects the sprint registry: counts by status and the DoD completion ratio. */
|
|
35
|
+
export function projectSprintGovernance(sprints: readonly SprintManifest[]): SprintGovernanceProjection {
|
|
36
|
+
const byStatus: Record<string, number> = {};
|
|
37
|
+
let sealed = 0;
|
|
38
|
+
let dodTotal = 0;
|
|
39
|
+
let dodPassed = 0;
|
|
40
|
+
for (const sprint of sprints) {
|
|
41
|
+
const status = sprint.status ?? 'unknown';
|
|
42
|
+
byStatus[status] = (byStatus[status] ?? 0) + 1;
|
|
43
|
+
if (sprint.seal === 'sealed') sealed += 1;
|
|
44
|
+
dodTotal += sprint.dodTotal ?? 0;
|
|
45
|
+
dodPassed += sprint.dodPassed ?? 0;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
total: sprints.length,
|
|
49
|
+
byStatus,
|
|
50
|
+
sealed,
|
|
51
|
+
dodTotal,
|
|
52
|
+
dodPassed,
|
|
53
|
+
dodCompletion: dodTotal === 0 ? 0 : Number((dodPassed / dodTotal).toFixed(4)),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface BudgetAlert {
|
|
58
|
+
readonly unit: string;
|
|
59
|
+
readonly payloadBytes: number;
|
|
60
|
+
readonly overBy: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Deployment budget alerts. A unit over its threshold is reported with the excess;
|
|
65
|
+
* units already flagged `within_budget: false` are always reported.
|
|
66
|
+
*/
|
|
67
|
+
export function deploymentBudgetAlerts(
|
|
68
|
+
units: readonly AssessmentUnit[],
|
|
69
|
+
thresholdBytes = 262_144,
|
|
70
|
+
): BudgetAlert[] {
|
|
71
|
+
return units
|
|
72
|
+
.filter((unit) => (unit.payload_bytes ?? 0) > thresholdBytes || unit.within_budget === false)
|
|
73
|
+
.map((unit) => ({
|
|
74
|
+
unit: unit.unit,
|
|
75
|
+
payloadBytes: unit.payload_bytes ?? 0,
|
|
76
|
+
overBy: Math.max(0, (unit.payload_bytes ?? 0) - thresholdBytes),
|
|
77
|
+
}))
|
|
78
|
+
.sort((a, b) => b.overBy - a.overBy);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface SprintGovernanceViewletProps {
|
|
82
|
+
readonly sprints: readonly SprintManifest[];
|
|
83
|
+
readonly units?: readonly AssessmentUnit[];
|
|
84
|
+
readonly budgetBytes?: number;
|
|
85
|
+
readonly onSelectSprint?: (code: string) => void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const SprintGovernanceViewlet: React.FC<SprintGovernanceViewletProps> = ({
|
|
89
|
+
sprints,
|
|
90
|
+
units = [],
|
|
91
|
+
budgetBytes = 262_144,
|
|
92
|
+
onSelectSprint,
|
|
93
|
+
}) => {
|
|
94
|
+
const [threshold, setThreshold] = useState(budgetBytes);
|
|
95
|
+
const projection = useMemo(() => projectSprintGovernance(sprints), [sprints]);
|
|
96
|
+
const alerts = useMemo(() => deploymentBudgetAlerts(units, threshold), [units, threshold]);
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<section className="sprint-governance" aria-label="Sprint registry and deployment unit governance">
|
|
100
|
+
<header>
|
|
101
|
+
<h3>Sprint Registry & Deployment Units</h3>
|
|
102
|
+
<p data-role="sprint-summary">
|
|
103
|
+
{projection.total} sprint manifest(s) · {projection.sealed} sealed · DoD{' '}
|
|
104
|
+
{projection.dodPassed}/{projection.dodTotal} ({(projection.dodCompletion * 100).toFixed(1)}%)
|
|
105
|
+
</p>
|
|
106
|
+
</header>
|
|
107
|
+
|
|
108
|
+
<ul className="governance-status" data-role="status-breakdown">
|
|
109
|
+
{Object.entries(projection.byStatus).map(([status, count]) => (
|
|
110
|
+
<li key={status} data-status={status}>
|
|
111
|
+
{status}: {count}
|
|
112
|
+
</li>
|
|
113
|
+
))}
|
|
114
|
+
</ul>
|
|
115
|
+
|
|
116
|
+
<label className="governance-threshold">
|
|
117
|
+
<span>Budget threshold (bytes)</span>
|
|
118
|
+
<input
|
|
119
|
+
type="number"
|
|
120
|
+
aria-label="Budget threshold"
|
|
121
|
+
min={0}
|
|
122
|
+
value={threshold}
|
|
123
|
+
onChange={(event) => setThreshold(Number(event.target.value) || 0)}
|
|
124
|
+
/>
|
|
125
|
+
</label>
|
|
126
|
+
|
|
127
|
+
{alerts.length > 0 ? (
|
|
128
|
+
<aside className="governance-alerts" role="alert" data-role="budget-alerts">
|
|
129
|
+
<p>
|
|
130
|
+
{alerts.length} deployment unit(s) over the {threshold} byte threshold:
|
|
131
|
+
</p>
|
|
132
|
+
<ul>
|
|
133
|
+
{alerts.map((alert) => (
|
|
134
|
+
<li key={alert.unit}>
|
|
135
|
+
<code>{alert.unit}</code> — {alert.payloadBytes} bytes (+{alert.overBy})
|
|
136
|
+
</li>
|
|
137
|
+
))}
|
|
138
|
+
</ul>
|
|
139
|
+
</aside>
|
|
140
|
+
) : (
|
|
141
|
+
<p className="governance-clear" data-role="budget-alerts">
|
|
142
|
+
All deployment units within the {threshold} byte threshold.
|
|
143
|
+
</p>
|
|
144
|
+
)}
|
|
145
|
+
|
|
146
|
+
<table className="governance-sprints">
|
|
147
|
+
<thead>
|
|
148
|
+
<tr>
|
|
149
|
+
<th scope="col">Sprint</th>
|
|
150
|
+
<th scope="col">Status</th>
|
|
151
|
+
<th scope="col">Seal</th>
|
|
152
|
+
<th scope="col">DoD</th>
|
|
153
|
+
</tr>
|
|
154
|
+
</thead>
|
|
155
|
+
<tbody>
|
|
156
|
+
{sprints.map((sprint) => (
|
|
157
|
+
<tr key={sprint.code} data-role="sprint-row">
|
|
158
|
+
<th scope="row">
|
|
159
|
+
<button type="button" onClick={() => onSelectSprint?.(sprint.code)}>
|
|
160
|
+
{sprint.code}
|
|
161
|
+
</button>
|
|
162
|
+
</th>
|
|
163
|
+
<td>{sprint.status ?? 'unknown'}</td>
|
|
164
|
+
<td>{sprint.seal ?? 'none'}</td>
|
|
165
|
+
<td>
|
|
166
|
+
{sprint.dodPassed ?? 0}/{sprint.dodTotal ?? 0}
|
|
167
|
+
</td>
|
|
168
|
+
</tr>
|
|
169
|
+
))}
|
|
170
|
+
</tbody>
|
|
171
|
+
</table>
|
|
172
|
+
</section>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export default SprintGovernanceViewlet;
|