feat: enforce Guanghu-native HoloLake runtime laws

This commit is contained in:
冰朔 2026-08-04 23:11:25 +08:00
commit 67e6fcdd38
57 changed files with 1765 additions and 1504 deletions

View file

@ -3,8 +3,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import { FeedbackDialog } from './FeedbackDialog'
import {
CIRCLECI_HOME_URL,
CODACY_HOME_URL,
CODESCENE_HOME_URL,
REFACTORING_HOME_URL,
TOLARIA_GITHUB_CONTRIBUTING_URL,
TOLARIA_GITHUB_DISCUSSIONS_URL,
@ -48,8 +46,6 @@ describe('FeedbackDialog', () => {
expect(screen.getByText('Report a bug')).toBeInTheDocument()
expect(screen.getByText(/Refactoring is my newsletter and community/i)).toBeInTheDocument()
expect(screen.getByText(/HoloLake Era is supported by a panel of tools/i)).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Open Codacy' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Open CodeScene' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Open CircleCI' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Open Unblocked' })).toBeInTheDocument()
expect(screen.getByText('Search on the board first, upvote existing ideas, and create new posts when genuinely new!')).toBeInTheDocument()
@ -81,8 +77,6 @@ describe('FeedbackDialog', () => {
render(<FeedbackDialog open={true} onClose={onClose} buildNumber="b281" releaseChannel={null} />)
fireEvent.click(screen.getByRole('button', { name: 'Check out Refactoring' }))
fireEvent.click(screen.getByRole('button', { name: 'Open Codacy' }))
fireEvent.click(screen.getByRole('button', { name: 'Open CodeScene' }))
fireEvent.click(screen.getByRole('button', { name: 'Open CircleCI' }))
fireEvent.click(screen.getByRole('button', { name: 'Open Unblocked' }))
fireEvent.click(screen.getByRole('button', { name: 'Open Product Board' }))
@ -92,15 +86,13 @@ describe('FeedbackDialog', () => {
fireEvent.click(screen.getByRole('button', { name: 'Open GitHub Issues' }))
await waitFor(() => expect(openExternalUrl).toHaveBeenNthCalledWith(1, REFACTORING_HOME_URL))
expect(openExternalUrl).toHaveBeenNthCalledWith(2, CODACY_HOME_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(3, CODESCENE_HOME_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(4, CIRCLECI_HOME_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(5, UNBLOCKED_HOME_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(6, TOLARIA_PRODUCT_BOARD_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(7, TOLARIA_GITHUB_DISCUSSIONS_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(8, TOLARIA_GITHUB_PULL_REQUESTS_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(9, TOLARIA_GITHUB_CONTRIBUTING_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(10, TOLARIA_GITHUB_ISSUES_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(2, CIRCLECI_HOME_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(3, UNBLOCKED_HOME_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(4, TOLARIA_PRODUCT_BOARD_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(5, TOLARIA_GITHUB_DISCUSSIONS_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(6, TOLARIA_GITHUB_PULL_REQUESTS_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(7, TOLARIA_GITHUB_CONTRIBUTING_URL)
expect(openExternalUrl).toHaveBeenNthCalledWith(8, TOLARIA_GITHUB_ISSUES_URL)
expect(onClose).not.toHaveBeenCalled()
expect(screen.getByTestId('feedback-dialog')).toBeInTheDocument()
})

View file

@ -2,10 +2,6 @@ import { ArrowUpRight, Bug, Chats as MessagesSquare, Check, Copy, GitPullRequest
import { type ReactNode, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
import circleCiDarkLogo from '@/assets/sponsors/circleci-dark.svg'
import circleCiLightLogo from '@/assets/sponsors/circleci-light.svg'
import codacyDarkLogo from '@/assets/sponsors/codacy-dark.svg'
import codacyLightLogo from '@/assets/sponsors/codacy-light.svg'
import codeSceneDarkLogo from '@/assets/sponsors/codescene-dark.svg'
import codeSceneLightLogo from '@/assets/sponsors/codescene-light.svg'
import unblockedDarkLogo from '@/assets/sponsors/unblocked-dark.svg'
import unblockedLightLogo from '@/assets/sponsors/unblocked-light.svg'
import { Button } from '@/components/ui/button'
@ -26,8 +22,6 @@ import {
} from '@/components/ui/dialog'
import {
CIRCLECI_HOME_URL,
CODACY_HOME_URL,
CODESCENE_HOME_URL,
REFACTORING_HOME_URL,
TOLARIA_GITHUB_CONTRIBUTING_URL,
TOLARIA_GITHUB_DISCUSSIONS_URL,
@ -129,18 +123,6 @@ const NEWSLETTER_PATH = {
} satisfies ContributionPath
const SPONSOR_LOGOS: SponsorLogo[] = [
{
name: 'Codacy',
url: CODACY_HOME_URL,
darkLogo: codacyDarkLogo,
lightLogo: codacyLightLogo,
},
{
name: 'CodeScene',
url: CODESCENE_HOME_URL,
darkLogo: codeSceneDarkLogo,
lightLogo: codeSceneLightLogo,
},
{
name: 'CircleCI',
url: CIRCLECI_HOME_URL,

View file

@ -94,6 +94,51 @@ const worldLogin = (
...overrides,
})
const livingPlan = ({
eventId = 'model-event',
intent = 'navigate',
route = 'fifth-domain',
motion = 'active',
}: {
eventId?: string
intent?: 'navigate' | 'open-knowledge' | 'open-agent-workspace' | 'open-local-workspace' | 'apply-theme'
route?: 'world' | 'fifth-domain'
motion?: 'quiet' | 'responsive' | 'active'
} = {}) => ({
version: 1 as const,
eventId,
intent,
planId: 'model-plan',
requiredTruth: [],
uiProjection: {
route,
stateLabel: 'model-proposed' as const,
scene: {
depth: route === 'world' ? 'overview' as const : 'immersive' as const,
motion,
starDensity: 'rich' as const,
connectionEmphasis: 'network' as const,
},
},
navigationAction: { type: 'navigate' as const, route },
capabilityCall: intent === 'navigate'
? null
: {
type: 'capability' as const,
capabilityId: {
'open-knowledge': 'knowledge.open',
'open-agent-workspace': 'agent.workspace.open',
'open-local-workspace': 'local.workspace.open',
'apply-theme': 'appearance.apply',
}[intent],
input: {},
},
receiptSchema: {
outcome: 'pending-evidence' as const,
requiredEvidence: [],
},
})
describe('HoloLakeHome', () => {
beforeEach(() => {
vi.clearAllMocks()
@ -116,20 +161,7 @@ describe('HoloLakeHome', () => {
})
planGuanghuLivingSystemMock.mockResolvedValue({
source: 'model',
plan: {
version: 1,
eventId: 'model-event',
intent: 'navigate',
planId: 'model-plan',
route: 'fifth-domain',
requiredTruth: [],
scene: {
depth: 'immersive',
motion: 'active',
starDensity: 'rich',
connectionEmphasis: 'network',
},
},
plan: livingPlan(),
})
})
@ -243,18 +275,13 @@ describe('HoloLakeHome', () => {
source: 'server',
serverReceiptId: 'GMRP-HOST-ACTION-001',
plan: {
version: 1,
eventId: event.eventId,
intent: event.intent,
planId: 'host-action-plan',
route: event.requestedRoute,
requiredTruth: [],
scene: {
depth: 'overview',
...livingPlan({
eventId: event.eventId,
intent: event.intent,
route: event.requestedRoute,
motion: 'responsive',
starDensity: 'balanced',
connectionEmphasis: 'contextual',
},
}),
planId: 'host-action-plan',
},
}))
@ -292,18 +319,13 @@ describe('HoloLakeHome', () => {
source: 'server',
serverReceiptId: 'GMRP-THEME-001',
plan: {
version: 1,
eventId: event.eventId,
intent: event.intent,
planId: 'theme-plan',
route: event.requestedRoute,
requiredTruth: [],
scene: {
depth: 'overview',
...livingPlan({
eventId: event.eventId,
intent: event.intent,
route: event.requestedRoute,
motion: 'active',
starDensity: 'rich',
connectionEmphasis: 'network',
},
}),
planId: 'theme-plan',
},
}))

View file

@ -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>