feat: enforce Guanghu-native HoloLake runtime laws
This commit is contained in:
parent
ccee303355
commit
67e6fcdd38
57 changed files with 1765 additions and 1504 deletions
|
|
@ -101,7 +101,7 @@ export function HoloLakeHome({
|
|||
}))
|
||||
))
|
||||
const [livingKernel, setLivingKernel] = useState<'server' | 'model' | 'fallback' | 'planning'>('fallback')
|
||||
const [livingReceiptId, setLivingReceiptId] = useState('local-execution:system-start')
|
||||
const [livingReceiptId, setLivingReceiptId] = useState('local-state:system-start')
|
||||
const [livingServerReceiptId, setLivingServerReceiptId] = useState<string>()
|
||||
const [architectureOpen, setArchitectureOpen] = useState(false)
|
||||
const [releaseNotesOpen, setReleaseNotesOpen] = useState(false)
|
||||
|
|
@ -117,25 +117,47 @@ export function HoloLakeHome({
|
|||
const worldOpen = login.state.phase === 'online'
|
||||
const fifthDomainOpen = worldOpen && route !== 'world'
|
||||
const worldRouterState = router.state
|
||||
const activeRouterReceipt = worldRouterState.status === 'online'
|
||||
&& worldRouterState.latestReceipt?.state === 'online'
|
||||
? worldRouterState.latestReceipt
|
||||
: null
|
||||
const t = (key: TranslationKey) => translate(locale, key)
|
||||
|
||||
const executeLivingPlan = useCallback((
|
||||
const applyLivingPlan = useCallback((
|
||||
plan: GuanghuLivingSystemPlan,
|
||||
source: 'server' | 'model' | 'fallback',
|
||||
serverReceiptId?: string,
|
||||
) => {
|
||||
const receipt = createLivingSystemExecutionReceipt({ plan, source })
|
||||
setLivingPlan(plan)
|
||||
setLivingKernel(source)
|
||||
setLivingReceiptId(receipt.receiptId)
|
||||
setLivingServerReceiptId(serverReceiptId)
|
||||
setRoute(plan.route)
|
||||
setRoute(plan.navigationAction.route)
|
||||
}, [])
|
||||
|
||||
const recordLivingExecution = useCallback((
|
||||
plan: GuanghuLivingSystemPlan,
|
||||
source: 'server' | 'model' | 'fallback',
|
||||
outcome: 'executed' | 'failed',
|
||||
evidence: string[],
|
||||
error?: string,
|
||||
serverReceiptId?: string,
|
||||
) => {
|
||||
const receipt = createLivingSystemExecutionReceipt({
|
||||
plan,
|
||||
source,
|
||||
outcome,
|
||||
evidence,
|
||||
error,
|
||||
})
|
||||
setLivingReceiptId(receipt.receiptId)
|
||||
trackEvent('guanghu_living_system_receipt', {
|
||||
eventId: receipt.eventId,
|
||||
outcome: receipt.outcome,
|
||||
planId: receipt.planId,
|
||||
receiptId: receipt.receiptId,
|
||||
route: receipt.route,
|
||||
source: receipt.source,
|
||||
evidence: receipt.evidence.join(','),
|
||||
...(serverReceiptId ? { serverReceiptId } : {}),
|
||||
})
|
||||
}, [])
|
||||
|
|
@ -160,29 +182,49 @@ export function HoloLakeHome({
|
|||
appearanceTheme,
|
||||
worldOpen,
|
||||
})
|
||||
const executeAcceptedPlan = (
|
||||
const executeAcceptedPlan = async (
|
||||
plan: GuanghuLivingSystemPlan,
|
||||
source: 'server' | 'model' | 'fallback',
|
||||
serverReceiptId?: string,
|
||||
) => {
|
||||
executeLivingPlan(plan, source, serverReceiptId)
|
||||
if (plan.intent === intent && plan.route === nextRoute) {
|
||||
void onAccepted?.()
|
||||
applyLivingPlan(plan, source, serverReceiptId)
|
||||
const routeAccepted = plan.intent === intent && plan.navigationAction.route === nextRoute
|
||||
try {
|
||||
if (routeAccepted && onAccepted) {
|
||||
await onAccepted()
|
||||
}
|
||||
const evidence = [
|
||||
`ui.route:${plan.navigationAction.route}`,
|
||||
...(routeAccepted && onAccepted && plan.capabilityCall
|
||||
? [`capability.${plan.capabilityCall.capabilityId}.result`]
|
||||
: []),
|
||||
]
|
||||
recordLivingExecution(plan, source, 'executed', evidence, undefined, serverReceiptId)
|
||||
} catch (error) {
|
||||
recordLivingExecution(
|
||||
plan,
|
||||
source,
|
||||
'failed',
|
||||
[`ui.route:${plan.navigationAction.route}`],
|
||||
error instanceof Error ? error.message : 'host_action_failed',
|
||||
serverReceiptId,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!isTauri() && !livingSystemTarget) {
|
||||
executeAcceptedPlan(createDeterministicLivingSystemPlan(event), 'fallback')
|
||||
void executeAcceptedPlan(createDeterministicLivingSystemPlan(event), 'fallback')
|
||||
return
|
||||
}
|
||||
setLivingKernel('planning')
|
||||
void planGuanghuLivingSystem({ event, target: livingSystemTarget }).then(result => {
|
||||
if (livingRequestSequence.current !== sequence) return
|
||||
executeAcceptedPlan(result.plan, result.source, result.serverReceiptId)
|
||||
void executeAcceptedPlan(result.plan, result.source, result.serverReceiptId)
|
||||
})
|
||||
}, [
|
||||
executeLivingPlan,
|
||||
applyLivingPlan,
|
||||
livingSystemTarget,
|
||||
login.state.workorderId,
|
||||
recordLivingExecution,
|
||||
route,
|
||||
worldOpen,
|
||||
worldRouterState.latestReceipt?.receipt_id,
|
||||
|
|
@ -259,7 +301,7 @@ export function HoloLakeHome({
|
|||
return (
|
||||
<GuanghuWorldMap
|
||||
enterprise={enterprise.state}
|
||||
livingScene={livingPlan.scene}
|
||||
livingScene={livingPlan.uiProjection.scene}
|
||||
onEnterFifthDomain={() => navigate(worldOpen ? 'fifth-domain' : 'world-login')}
|
||||
onOpenLibrary={openArchitecture}
|
||||
onOpenReceipt={() => navigate('servers')}
|
||||
|
|
@ -376,17 +418,21 @@ export function HoloLakeHome({
|
|||
</div>
|
||||
<div className="world-presence world-presence--large">
|
||||
<i />
|
||||
<span><strong>已进入光湖世界</strong><small>第五域 · JD-FD-PRIMARY</small></span>
|
||||
<span>
|
||||
<strong>{activeRouterReceipt ? '第五域连接已回执' : '光湖身份已授权'}</strong>
|
||||
<small>{activeRouterReceipt ? `第五域 · ${activeRouterReceipt.node_id}` : '等待真实节点回执'}</small>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="node-page__content">
|
||||
<article className="node-page__primary">
|
||||
<span>当前世界节点</span>
|
||||
<strong>JD-FD-PRIMARY</strong>
|
||||
<p>第五域国内主控节点</p>
|
||||
<span>{activeRouterReceipt ? '当前世界节点' : '登记目标节点'}</span>
|
||||
<strong>{activeRouterReceipt?.node_id ?? 'JD-FD-PRIMARY'}</strong>
|
||||
<p>{activeRouterReceipt ? '第五域连接已由节点回执证明' : '尚未把身份授权误报为节点连接'}</p>
|
||||
<dl>
|
||||
<div><dt>身份</dt><dd>冰朔</dd></div>
|
||||
<div><dt>世界状态</dt><dd>已打开</dd></div>
|
||||
<div><dt>身份会话</dt><dd>{worldOpen ? '已授权' : '未授权'}</dd></div>
|
||||
<div><dt>节点连接</dt><dd>{activeRouterReceipt ? '已回执' : '未回执'}</dd></div>
|
||||
<div><dt>公开发现入口</dt><dd>{fifthDomainConnection.status === 'connected' ? '可用' : fifthDomainConnection.status === 'error' ? '失败' : '检查中'}</dd></div>
|
||||
</dl>
|
||||
<Button variant="outline" onClick={() => {
|
||||
|
|
@ -425,13 +471,13 @@ export function HoloLakeHome({
|
|||
<main
|
||||
aria-label={t('hololake.home.ariaLabel')}
|
||||
className="hololake-home"
|
||||
data-living-connection={livingPlan.scene.connectionEmphasis}
|
||||
data-living-connection={livingPlan.uiProjection.scene.connectionEmphasis}
|
||||
data-living-kernel={livingKernel}
|
||||
data-living-motion={livingPlan.scene.motion}
|
||||
data-living-motion={livingPlan.uiProjection.scene.motion}
|
||||
data-living-receipt={livingReceiptId}
|
||||
data-living-server-receipt={livingServerReceiptId}
|
||||
data-living-scene={livingPlan.scene.depth}
|
||||
data-living-stars={livingPlan.scene.starDensity}
|
||||
data-living-scene={livingPlan.uiProjection.scene.depth}
|
||||
data-living-stars={livingPlan.uiProjection.scene.starDensity}
|
||||
data-route={route}
|
||||
data-world-open={worldOpen}
|
||||
>
|
||||
|
|
@ -439,7 +485,7 @@ export function HoloLakeHome({
|
|||
<div className="channel-rail__heading">
|
||||
<span>{fifthDomainOpen ? 'FIFTH DOMAIN' : 'HOLOLAKE OS'}</span>
|
||||
<strong>{fifthDomainOpen ? '第五域' : 'HoloLake'}</strong>
|
||||
<small>{worldOpen ? fifthDomainOpen ? '域内系统与语言路径' : '系统能力与光湖世界入口' : '本地系统可用 · 第五域需授权'}</small>
|
||||
<small>{worldOpen ? fifthDomainOpen ? '身份已授权 · 节点状态看回执' : '系统能力与光湖世界入口' : '本地系统可用 · 第五域需授权'}</small>
|
||||
</div>
|
||||
<nav>
|
||||
{!fifthDomainOpen && <>
|
||||
|
|
@ -486,7 +532,19 @@ export function HoloLakeHome({
|
|||
</div>
|
||||
{worldOpen && route !== 'world-login' ? <>
|
||||
<header className="world-session-bar">
|
||||
<div className="world-presence"><i /><span><strong>已进入光湖世界</strong><small>{fifthDomainOpen ? '第五域 · JD-FD-PRIMARY' : '世界入口 · 等待域跳转'}</small></span></div>
|
||||
<div className="world-presence">
|
||||
<i />
|
||||
<span>
|
||||
<strong>{activeRouterReceipt ? '第五域连接已回执' : '光湖身份已授权'}</strong>
|
||||
<small>
|
||||
{activeRouterReceipt
|
||||
? `第五域 · ${activeRouterReceipt.node_id}`
|
||||
: fifthDomainOpen
|
||||
? '域内界面已打开 · 节点未回执'
|
||||
: '世界入口 · 等待域跳转'}
|
||||
</small>
|
||||
</span>
|
||||
</div>
|
||||
<div className="world-session-bar__actions">
|
||||
{fifthDomainOpen && onOpenAiWorkspace
|
||||
? <Button className="world-session-bar__ai" variant="ghost" size="sm" onClick={openAiWorkspace}>人格体工作舱</Button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue