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

@ -1,16 +0,0 @@
<svg width="139" height="40" viewBox="0 0 139 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.36764 16.0917C7.32203 12.5678 9.63126 9.56442 12.7881 7.74239L9.83149 2.63672C5.3198 5.23961 2.02281 9.53105 0.667969 14.5633L6.36764 16.0917Z" fill="#0f172a"/>
<path d="M16.1182 6.3604C17.2795 6.05339 18.4742 5.89322 19.6755 5.89989V0C17.9603 0 16.2517 0.220245 14.5898 0.660734L16.1182 6.3604Z" fill="#0f172a"/>
<path d="M23.2598 6.36666C26.777 7.32105 29.7803 9.63029 31.6024 12.7871L36.7147 9.83718C34.1052 5.3255 29.8137 2.02851 24.7881 0.666992L23.2598 6.36666Z" fill="#0f172a"/>
<path d="M0 19.6553C0 21.3705 0.220245 23.0791 0.667408 24.7409L6.36708 23.2126C6.05339 22.0513 5.89989 20.8566 5.89989 19.6553H0Z" fill="#0f172a"/>
<path d="M2.63672 29.4929C3.49768 30.9746 4.54551 32.3427 5.75352 33.5508L9.94484 29.3861C9.09723 28.5318 8.36308 27.5775 7.75574 26.543L2.63672 29.4929Z" fill="#0f172a"/>
<path d="M9.83984 36.6866C12.8232 38.4152 16.2136 39.3228 19.6574 39.3162V33.4163C17.2481 33.4163 14.8788 32.7822 12.7898 31.5742L9.83984 36.6866Z" fill="#0f172a"/>
<path d="M31.5942 26.5566C29.7655 29.7068 26.7622 32.0094 23.2383 32.9504L24.7666 38.6501C29.7989 37.2952 34.0903 34.0049 36.6999 29.4999L31.5942 26.5566Z" fill="#0f172a"/>
<path d="M38.9161 24.7341C39.8238 21.3971 39.8372 17.8798 38.9629 14.5361L33.2432 16.0645C33.8572 18.4071 33.8438 20.8698 33.2031 23.2058L38.9161 24.7341Z" fill="#0f172a"/>
<path d="M62.2624 17.5331C61.5683 15.7711 60.0466 14.73 58.3714 14.73C55.8086 14.73 54.0733 16.9258 54.0733 19.4219C54.0733 22.0248 55.8553 24.2005 58.3981 24.2005C60.0266 24.2005 61.4148 23.2862 62.2624 21.4842H66.5605C65.5594 25.3484 62.2424 27.8045 58.4382 27.8045C56.2023 27.8045 54.0933 27.0236 52.4448 25.3952C50.7096 23.7 49.9688 21.6577 49.9688 19.2283C49.9688 14.9702 53.6395 11.126 58.2446 11.126C60.4604 11.126 62.2424 11.7333 63.8508 13.1015C65.3725 14.403 66.2869 15.8846 66.5672 17.5331H62.2624Z" fill="#0f172a"/>
<path d="M74.4704 27.8709C70.7997 27.8709 67.9766 25.1545 67.9766 21.4638C67.9766 17.7263 70.8664 15.0566 74.4704 15.0566C78.0945 15.0566 80.9643 17.773 80.9643 21.4237C80.9643 25.1946 78.1012 27.8709 74.4704 27.8709ZM77.3603 21.4638C77.3603 19.8553 76.1456 18.4204 74.4504 18.4204C72.862 18.4204 71.5872 19.8086 71.5872 21.4638C71.5872 23.1123 72.8486 24.5071 74.4771 24.5071C76.1657 24.5005 77.3603 23.0655 77.3603 21.4638Z" fill="#0f172a"/>
<path d="M92.1294 27.497V26.1955H92.0894C91.4153 27.3034 90.2006 27.8907 88.4854 27.8907C84.8346 27.8907 82.4453 25.0876 82.4453 21.4369C82.4453 17.8329 84.9014 15.0298 88.4186 15.0298C89.8068 15.0298 90.9347 15.4436 91.9559 16.4647V11.4258H95.5599V27.497H92.1294ZM92.1494 21.4169C92.1494 19.7417 90.868 18.4002 89.086 18.4002C87.3908 18.4002 86.0426 19.6616 86.0426 21.4169C86.0426 23.2389 87.3241 24.5203 89.0593 24.5203C90.828 24.5203 92.1494 23.1989 92.1494 21.4169Z" fill="#0f172a"/>
<path d="M107.227 27.4975V26.196H107.187C106.666 27.2639 105.231 27.9113 103.649 27.9113C100.085 27.9113 97.6094 25.1081 97.6094 21.4574C97.6094 17.8935 100.192 15.0303 103.649 15.0303C105.124 15.0303 106.493 15.6176 107.187 16.7255H107.227V15.4441H110.831V27.4975H107.227ZM107.227 21.4641C107.227 19.7689 105.859 18.4007 104.163 18.4007C102.515 18.4007 101.207 19.7689 101.207 21.5041C101.207 23.1793 102.528 24.5475 104.203 24.5475C105.905 24.5475 107.227 23.1994 107.227 21.4641Z" fill="#0f172a"/>
<path d="M121.976 20.0959C121.456 18.968 120.522 18.4007 119.28 18.4007C117.632 18.4007 116.497 19.7689 116.497 21.4641C116.497 23.226 117.692 24.5275 119.367 24.5275C120.582 24.5275 121.429 23.9669 121.976 22.919H125.647C124.933 25.9357 122.344 27.8912 119.26 27.8912C115.696 27.8912 112.873 25.0014 112.873 21.4374C112.873 17.8334 115.723 15.0303 119.193 15.0303C122.364 15.0303 124.946 17.0258 125.621 20.0892H121.976V20.0959Z" fill="#0f172a"/>
<path d="M128.477 31.5146L130.386 26.8894L125.914 15.4434H129.758L132.168 22.4378H132.208L134.51 15.4434H138.335L132.294 31.5146H128.477Z" fill="#0f172a"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.9 KiB

View file

@ -1,16 +0,0 @@
<svg width="139" height="40" viewBox="0 0 139 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.36764 16.0917C7.32203 12.5678 9.63126 9.56442 12.7881 7.74239L9.83149 2.63672C5.3198 5.23961 2.02281 9.53105 0.667969 14.5633L6.36764 16.0917Z" fill="white"/>
<path d="M16.1182 6.3604C17.2795 6.05339 18.4742 5.89322 19.6755 5.89989V0C17.9603 0 16.2517 0.220245 14.5898 0.660734L16.1182 6.3604Z" fill="white"/>
<path d="M23.2598 6.36666C26.777 7.32105 29.7803 9.63029 31.6024 12.7871L36.7147 9.83718C34.1052 5.3255 29.8137 2.02851 24.7881 0.666992L23.2598 6.36666Z" fill="white"/>
<path d="M0 19.6553C0 21.3705 0.220245 23.0791 0.667408 24.7409L6.36708 23.2126C6.05339 22.0513 5.89989 20.8566 5.89989 19.6553H0Z" fill="white"/>
<path d="M2.63672 29.4929C3.49768 30.9746 4.54551 32.3427 5.75352 33.5508L9.94484 29.3861C9.09723 28.5318 8.36308 27.5775 7.75574 26.543L2.63672 29.4929Z" fill="white"/>
<path d="M9.83984 36.6866C12.8232 38.4152 16.2136 39.3228 19.6574 39.3162V33.4163C17.2481 33.4163 14.8788 32.7822 12.7898 31.5742L9.83984 36.6866Z" fill="white"/>
<path d="M31.5942 26.5566C29.7655 29.7068 26.7622 32.0094 23.2383 32.9504L24.7666 38.6501C29.7989 37.2952 34.0903 34.0049 36.6999 29.4999L31.5942 26.5566Z" fill="white"/>
<path d="M38.9161 24.7341C39.8238 21.3971 39.8372 17.8798 38.9629 14.5361L33.2432 16.0645C33.8572 18.4071 33.8438 20.8698 33.2031 23.2058L38.9161 24.7341Z" fill="white"/>
<path d="M62.2624 17.5331C61.5683 15.7711 60.0466 14.73 58.3714 14.73C55.8086 14.73 54.0733 16.9258 54.0733 19.4219C54.0733 22.0248 55.8553 24.2005 58.3981 24.2005C60.0266 24.2005 61.4148 23.2862 62.2624 21.4842H66.5605C65.5594 25.3484 62.2424 27.8045 58.4382 27.8045C56.2023 27.8045 54.0933 27.0236 52.4448 25.3952C50.7096 23.7 49.9688 21.6577 49.9688 19.2283C49.9688 14.9702 53.6395 11.126 58.2446 11.126C60.4604 11.126 62.2424 11.7333 63.8508 13.1015C65.3725 14.403 66.2869 15.8846 66.5672 17.5331H62.2624Z" fill="white"/>
<path d="M74.4704 27.8709C70.7997 27.8709 67.9766 25.1545 67.9766 21.4638C67.9766 17.7263 70.8664 15.0566 74.4704 15.0566C78.0945 15.0566 80.9643 17.773 80.9643 21.4237C80.9643 25.1946 78.1012 27.8709 74.4704 27.8709ZM77.3603 21.4638C77.3603 19.8553 76.1456 18.4204 74.4504 18.4204C72.862 18.4204 71.5872 19.8086 71.5872 21.4638C71.5872 23.1123 72.8486 24.5071 74.4771 24.5071C76.1657 24.5005 77.3603 23.0655 77.3603 21.4638Z" fill="white"/>
<path d="M92.1294 27.497V26.1955H92.0894C91.4153 27.3034 90.2006 27.8907 88.4854 27.8907C84.8346 27.8907 82.4453 25.0876 82.4453 21.4369C82.4453 17.8329 84.9014 15.0298 88.4186 15.0298C89.8068 15.0298 90.9347 15.4436 91.9559 16.4647V11.4258H95.5599V27.497H92.1294ZM92.1494 21.4169C92.1494 19.7417 90.868 18.4002 89.086 18.4002C87.3908 18.4002 86.0426 19.6616 86.0426 21.4169C86.0426 23.2389 87.3241 24.5203 89.0593 24.5203C90.828 24.5203 92.1494 23.1989 92.1494 21.4169Z" fill="white"/>
<path d="M107.227 27.4975V26.196H107.187C106.666 27.2639 105.231 27.9113 103.649 27.9113C100.085 27.9113 97.6094 25.1081 97.6094 21.4574C97.6094 17.8935 100.192 15.0303 103.649 15.0303C105.124 15.0303 106.493 15.6176 107.187 16.7255H107.227V15.4441H110.831V27.4975H107.227ZM107.227 21.4641C107.227 19.7689 105.859 18.4007 104.163 18.4007C102.515 18.4007 101.207 19.7689 101.207 21.5041C101.207 23.1793 102.528 24.5475 104.203 24.5475C105.905 24.5475 107.227 23.1994 107.227 21.4641Z" fill="white"/>
<path d="M121.976 20.0959C121.456 18.968 120.522 18.4007 119.28 18.4007C117.632 18.4007 116.497 19.7689 116.497 21.4641C116.497 23.226 117.692 24.5275 119.367 24.5275C120.582 24.5275 121.429 23.9669 121.976 22.919H125.647C124.933 25.9357 122.344 27.8912 119.26 27.8912C115.696 27.8912 112.873 25.0014 112.873 21.4374C112.873 17.8334 115.723 15.0303 119.193 15.0303C122.364 15.0303 124.946 17.0258 125.621 20.0892H121.976V20.0959Z" fill="white"/>
<path d="M128.477 31.5146L130.386 26.8894L125.914 15.4434H129.758L132.168 22.4378H132.208L134.51 15.4434H138.335L132.294 31.5146H128.477Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.9 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.6 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.6 KiB

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>

View file

@ -1,6 +1,4 @@
export const REFACTORING_HOME_URL = 'https://refactoring.fm/'
export const CODACY_HOME_URL = 'https://www.codacy.com/'
export const CODESCENE_HOME_URL = 'https://codescene.com/'
export const CIRCLECI_HOME_URL = 'https://circleci.com/'
export const UNBLOCKED_HOME_URL = 'https://getunblocked.com/'
export const HOLOLAKE_REPOSITORY_URL = 'https://guanghulab.com/code/bingshuo/hololake-system-architecture'

View file

@ -8,6 +8,61 @@ import {
} from './guanghuLivingSystem'
describe('Guanghu living system contract', () => {
it('binds every event to the persona system, knowledge state, boundaries, and capability registry', () => {
const event = createLivingSystemEvent({
currentRoute: 'world',
eventId: 'event-context',
intent: 'open-knowledge',
receiptIds: ['truth-001'],
requestedRoute: 'world',
worldOpen: true,
modelInstanceId: 'model-instance-current',
knowledgeState: {
selectedLakeId: 'lake-current',
mountedSources: ['REPO-012', 'REPO-014'],
},
})
expect(event.personaSystem).toEqual({
humanAnchorId: 'ICE-GL∞',
personaSystemId: 'ICE-P-ZY001',
memoryProtocolRoot: 'REPO-012',
modelInstanceId: 'model-instance-current',
})
expect(event.knowledgeState).toEqual({
selectedLakeId: 'lake-current',
mountedSources: ['REPO-012', 'REPO-014'],
})
expect(event.permissionBoundary.allowedCapabilities).toContain('knowledge.open')
expect(event.responsibilityBoundary.controllerPersonaSystemId).toBe('ICE-P-ZY001')
expect(event.capabilityRegistry).toContainEqual(expect.objectContaining({
id: 'knowledge.open',
outputType: 'CapabilityCall',
}))
})
it('drops a claimed runtime binding when its issuing receipt is absent', () => {
const event = createLivingSystemEvent({
currentRoute: 'world',
eventId: 'event-unverified-runtime',
intent: 'navigate',
receiptIds: [],
requestedRoute: 'world',
worldOpen: true,
runtimeBinding: {
bindingId: 'binding-unverified',
nodeId: 'JD-FD-PRIMARY',
personaSystemId: 'ICE-P-ZY001',
modelInstanceId: 'model-unverified',
issuedByReceiptId: 'missing-receipt',
status: 'verified',
},
})
expect(event.currentSystemState.runtimeBinding).toBeNull()
expect(event.personaSystem.modelInstanceId).toBeNull()
})
it('accepts a model-native navigation plan with a bounded visual scene', () => {
const event = createLivingSystemEvent({
currentRoute: 'world',
@ -23,14 +78,20 @@ describe('Guanghu living system contract', () => {
eventId: 'event-001',
intent: 'navigate',
planId: 'plan-001',
route: 'fifth-domain',
requiredTruth: ['receipt-001'],
scene: {
depth: 'immersive',
motion: 'responsive',
starDensity: 'rich',
connectionEmphasis: 'active-route',
uiProjection: {
route: 'fifth-domain',
stateLabel: 'model-proposed',
scene: {
depth: 'immersive',
motion: 'responsive',
starDensity: 'rich',
connectionEmphasis: 'active-route',
},
},
navigationAction: { type: 'navigate', route: 'fifth-domain' },
capabilityCall: null,
receiptSchema: { outcome: 'pending-evidence', requiredEvidence: ['ui.route.readback'] },
}))
expect(validateLivingSystemPlan(event, plan)).toEqual({
@ -54,11 +115,17 @@ describe('Guanghu living system contract', () => {
eventId: 'event-002',
intent: 'navigate',
planId: 'plan-002',
route: 'fifth-domain',
requiredTruth: ['invented-receipt'],
scene: {
depth: 'focused', motion: 'quiet', starDensity: 'balanced', connectionEmphasis: 'contextual',
uiProjection: {
route: 'fifth-domain',
stateLabel: 'model-proposed',
scene: {
depth: 'focused', motion: 'quiet', starDensity: 'balanced', connectionEmphasis: 'contextual',
},
},
navigationAction: { type: 'navigate', route: 'fifth-domain' },
capabilityCall: null,
receiptSchema: { outcome: 'pending-evidence', requiredEvidence: [] },
}))
expect(validateLivingSystemPlan(event, plan)).toEqual({
@ -79,8 +146,11 @@ describe('Guanghu living system contract', () => {
})
expect(createDeterministicLivingSystemPlan(event)).toMatchObject({
route: 'world-login',
scene: { depth: 'focused', motion: 'responsive' },
uiProjection: {
route: 'world-login',
scene: { depth: 'focused', motion: 'responsive' },
},
navigationAction: { route: 'world-login' },
})
})
@ -99,14 +169,24 @@ describe('Guanghu living system contract', () => {
eventId: event.eventId,
intent: 'open-agent-workspace',
planId: 'substituted-action',
route: 'world',
requiredTruth: [],
scene: {
depth: 'overview',
motion: 'responsive',
starDensity: 'balanced',
connectionEmphasis: 'contextual',
uiProjection: {
route: 'world',
stateLabel: 'model-proposed',
scene: {
depth: 'overview',
motion: 'responsive',
starDensity: 'balanced',
connectionEmphasis: 'contextual',
},
},
navigationAction: { type: 'navigate', route: 'world' },
capabilityCall: {
type: 'capability',
capabilityId: 'agent.workspace.open',
input: {},
},
receiptSchema: { outcome: 'pending-evidence', requiredEvidence: [] },
}))
expect(validateLivingSystemPlan(event, plan)).toEqual({
@ -115,9 +195,76 @@ describe('Guanghu living system contract', () => {
})
})
it('rejects route substitution, closed-world projection, and capability substitution', () => {
const openEvent = createLivingSystemEvent({
currentRoute: 'world',
eventId: 'event-route-boundary',
intent: 'navigate',
requestedRoute: 'fifth-domain',
worldOpen: true,
receiptIds: [],
now: 1,
})
const openPlan = createDeterministicLivingSystemPlan(openEvent)
expect(validateLivingSystemPlan(openEvent, {
...openPlan,
navigationAction: { type: 'navigate', route: 'world' },
})).toEqual({ accepted: false, reason: 'route_mismatch' })
const closedEvent = createLivingSystemEvent({
currentRoute: 'world',
eventId: 'event-world-boundary',
intent: 'navigate',
requestedRoute: 'fifth-domain',
worldOpen: false,
receiptIds: [],
now: 1,
})
const closedPlan = createDeterministicLivingSystemPlan(closedEvent)
const protectedPlan = {
...closedPlan,
uiProjection: { ...closedPlan.uiProjection, route: 'fifth-domain' as const },
navigationAction: { type: 'navigate' as const, route: 'fifth-domain' as const },
}
expect(validateLivingSystemPlan(closedEvent, protectedPlan)).toEqual({
accepted: false,
reason: 'world_closed',
})
const capabilityEvent = createLivingSystemEvent({
currentRoute: 'world',
eventId: 'event-capability-boundary',
intent: 'open-knowledge',
requestedRoute: 'world',
worldOpen: true,
receiptIds: [],
now: 1,
})
const capabilityPlan = createDeterministicLivingSystemPlan(capabilityEvent)
expect(validateLivingSystemPlan(capabilityEvent, {
...capabilityPlan,
capabilityCall: {
type: 'capability',
capabilityId: 'agent.workspace.open',
input: {},
},
})).toEqual({ accepted: false, reason: 'capability_mismatch' })
})
it('rejects chatty or structurally invalid model output', () => {
expect(parseLivingSystemPlan('我来帮你进入第五域')).toBeNull()
expect(parseLivingSystemPlan('{"route":"fifth-domain"}')).toBeNull()
expect(parseLivingSystemPlan(JSON.stringify({
version: 1,
eventId: 'event-001',
intent: 'navigate',
planId: 'legacy-theme-adapter',
route: 'fifth-domain',
requiredTruth: [],
scene: {
depth: 'immersive', motion: 'active', starDensity: 'rich', connectionEmphasis: 'network',
},
}))).toBeNull()
})
it('binds a local executor receipt to the accepted event and plan', () => {
@ -131,16 +278,43 @@ describe('Guanghu living system contract', () => {
now: 1,
}))
expect(createLivingSystemExecutionReceipt({ plan, source: 'fallback', now: 2 })).toEqual({
expect(createLivingSystemExecutionReceipt({
plan,
source: 'fallback',
outcome: 'executed',
evidence: ['ui.route:zero-core'],
now: 2,
})).toEqual({
version: 1,
receiptId: 'local-execution:fallback-event-004',
receiptId: 'local-execution:fallback-event-004:executed',
eventId: 'event-004',
intent: 'navigate',
planId: 'fallback-event-004',
route: 'zero-core',
source: 'fallback',
outcome: 'executed',
executedAt: 2,
evidence: ['ui.route:zero-core'],
completedAt: 2,
})
})
it('refuses to create a successful receipt before real evidence exists', () => {
const plan = createDeterministicLivingSystemPlan(createLivingSystemEvent({
currentRoute: 'world',
intent: 'navigate',
requestedRoute: 'zero-core',
worldOpen: true,
receiptIds: [],
eventId: 'event-no-evidence',
now: 1,
}))
expect(() => createLivingSystemExecutionReceipt({
plan,
source: 'fallback',
outcome: 'executed',
evidence: [],
now: 2,
})).toThrow('guanghu_living_system_success_evidence_required')
})
})

View file

@ -34,6 +34,61 @@ export type GuanghuLivingScene = {
connectionEmphasis: LivingSceneConnectionEmphasis
}
export type GuanghuPersonaSystemContext = {
humanAnchorId: 'ICE-GL∞'
personaSystemId: 'ICE-P-ZY001'
memoryProtocolRoot: 'REPO-012'
modelInstanceId: string | null
}
export type GuanghuRuntimeBinding = {
bindingId: string
nodeId: string
personaSystemId: 'ICE-P-ZY001'
modelInstanceId: string
issuedByReceiptId: string
status: 'verified'
}
export type GuanghuKnowledgeState = {
selectedLakeId: string | null
mountedSources: string[]
}
export type GuanghuCapabilityId =
| 'navigation.apply'
| 'knowledge.open'
| 'agent.workspace.open'
| 'local.workspace.open'
| 'appearance.apply'
export type GuanghuCapabilityRegistration = {
id: GuanghuCapabilityId
inputType: 'NavigationAction' | 'CapabilityCall'
outputType: 'ReceiptSchema' | 'CapabilityCall'
requiresWorldOpen: boolean
}
export type GuanghuPermissionBoundary = {
allowedCapabilities: GuanghuCapabilityId[]
deniedCapabilities: string[]
}
export type GuanghuResponsibilityBoundary = {
controllerPersonaSystemId: 'ICE-P-ZY001'
humanAnchorId: 'ICE-GL∞'
executorRule: 'deterministic-host-only'
successRule: 'evidence-required'
}
export type GuanghuCurrentSystemState = {
currentRoute: GuanghuChannelRoute
requestedRoute: GuanghuChannelRoute
worldOpen: boolean
receiptIds: string[]
runtimeBinding: GuanghuRuntimeBinding | null
}
export type GuanghuLivingSystemEvent = {
eventId: string
intent: GuanghuLivingIntent
@ -43,6 +98,34 @@ export type GuanghuLivingSystemEvent = {
worldOpen: boolean
receiptIds: string[]
occurredAt: number
personaSystem: GuanghuPersonaSystemContext
currentSystemState: GuanghuCurrentSystemState
knowledgeState: GuanghuKnowledgeState
permissionBoundary: GuanghuPermissionBoundary
responsibilityBoundary: GuanghuResponsibilityBoundary
capabilityRegistry: GuanghuCapabilityRegistration[]
}
export type GuanghuUIProjection = {
route: GuanghuChannelRoute
scene: GuanghuLivingScene
stateLabel: 'local-safe' | 'model-proposed' | 'server-bound'
}
export type GuanghuNavigationAction = {
type: 'navigate'
route: GuanghuChannelRoute
}
export type GuanghuCapabilityCall = {
type: 'capability'
capabilityId: GuanghuCapabilityId
input: Record<string, unknown>
}
export type GuanghuReceiptSchema = {
outcome: 'pending-evidence'
requiredEvidence: string[]
}
export type GuanghuLivingSystemPlan = {
@ -50,9 +133,11 @@ export type GuanghuLivingSystemPlan = {
eventId: string
intent: GuanghuLivingIntent
planId: string
route: GuanghuChannelRoute
requiredTruth: string[]
scene: GuanghuLivingScene
uiProjection: GuanghuUIProjection
navigationAction: GuanghuNavigationAction
capabilityCall: GuanghuCapabilityCall | null
receiptSchema: GuanghuReceiptSchema
}
export type GuanghuLivingSystemExecutionReceipt = {
@ -63,17 +148,40 @@ export type GuanghuLivingSystemExecutionReceipt = {
planId: string
route: GuanghuChannelRoute
source: 'server' | 'model' | 'fallback'
outcome: 'executed'
executedAt: number
outcome: 'executed' | 'failed'
evidence: string[]
completedAt: number
error?: string
}
type CreateLivingSystemEventInput = Omit<GuanghuLivingSystemEvent, 'occurredAt'> & {
type CreateLivingSystemEventInput = Omit<
GuanghuLivingSystemEvent,
| 'occurredAt'
| 'personaSystem'
| 'currentSystemState'
| 'knowledgeState'
| 'permissionBoundary'
| 'responsibilityBoundary'
| 'capabilityRegistry'
> & {
now?: number
modelInstanceId?: string | null
runtimeBinding?: GuanghuRuntimeBinding | null
knowledgeState?: GuanghuKnowledgeState
}
export type LivingSystemPlanValidation =
| { accepted: true; plan: GuanghuLivingSystemPlan }
| { accepted: false; reason: 'event_mismatch' | 'intent_mismatch' | 'route_mismatch' | 'unverified_truth' | 'world_closed' }
| {
accepted: false
reason:
| 'event_mismatch'
| 'intent_mismatch'
| 'route_mismatch'
| 'unverified_truth'
| 'world_closed'
| 'capability_mismatch'
}
const PROTECTED_ROUTES = new Set<GuanghuChannelRoute>([
'fifth-domain',
@ -90,6 +198,39 @@ const SCENE_MOTIONS = new Set<LivingSceneMotion>(['quiet', 'responsive', 'active
const STAR_DENSITIES = new Set<LivingSceneStarDensity>(['sparse', 'balanced', 'rich'])
const CONNECTION_EMPHASES = new Set<LivingSceneConnectionEmphasis>(['contextual', 'active-route', 'network'])
const LIVING_INTENTS = new Set<GuanghuLivingIntent>(GUANGHU_LIVING_INTENTS)
const CAPABILITY_FOR_INTENT: Record<GuanghuLivingIntent, GuanghuCapabilityId> = {
navigate: 'navigation.apply',
'open-knowledge': 'knowledge.open',
'open-agent-workspace': 'agent.workspace.open',
'open-local-workspace': 'local.workspace.open',
'apply-theme': 'appearance.apply',
}
const CAPABILITY_REGISTRY: GuanghuCapabilityRegistration[] = [
{ id: 'navigation.apply', inputType: 'NavigationAction', outputType: 'ReceiptSchema', requiresWorldOpen: false },
{ id: 'knowledge.open', inputType: 'CapabilityCall', outputType: 'CapabilityCall', requiresWorldOpen: false },
{ id: 'agent.workspace.open', inputType: 'CapabilityCall', outputType: 'CapabilityCall', requiresWorldOpen: false },
{ id: 'local.workspace.open', inputType: 'CapabilityCall', outputType: 'CapabilityCall', requiresWorldOpen: false },
{ id: 'appearance.apply', inputType: 'CapabilityCall', outputType: 'CapabilityCall', requiresWorldOpen: false },
]
function verifiedRuntimeBinding(
binding: GuanghuRuntimeBinding | null | undefined,
receiptIds: string[],
): GuanghuRuntimeBinding | null {
if (
!binding
|| binding.status !== 'verified'
|| binding.personaSystemId !== 'ICE-P-ZY001'
|| binding.bindingId.length === 0
|| binding.nodeId.length === 0
|| binding.modelInstanceId.length === 0
|| binding.issuedByReceiptId.length === 0
|| !receiptIds.includes(binding.issuedByReceiptId)
) {
return null
}
return { ...binding }
}
function isStringArray(value: unknown): value is string[] {
return Array.isArray(value) && value.every(item => typeof item === 'string')
@ -99,26 +240,58 @@ function isRoute(value: unknown): value is GuanghuChannelRoute {
return typeof value === 'string' && (GUANGHU_CHANNEL_ROUTES as readonly string[]).includes(value)
}
function isLivingScene(value: unknown): value is GuanghuLivingScene {
if (!value || typeof value !== 'object') return false
const scene = value as Partial<GuanghuLivingScene>
return SCENE_DEPTHS.has(scene.depth!)
&& SCENE_MOTIONS.has(scene.motion!)
&& STAR_DENSITIES.has(scene.starDensity!)
&& CONNECTION_EMPHASES.has(scene.connectionEmphasis!)
}
function isCapabilityCall(value: unknown): value is GuanghuCapabilityCall | null {
if (value === null) return true
if (!value || typeof value !== 'object') return false
const call = value as Partial<GuanghuCapabilityCall>
return call.type === 'capability'
&& Object.values(CAPABILITY_FOR_INTENT).includes(call.capabilityId!)
&& Boolean(call.input)
&& typeof call.input === 'object'
&& !Array.isArray(call.input)
}
function isLivingSystemPlan(value: unknown): value is GuanghuLivingSystemPlan {
if (!value || typeof value !== 'object') return false
const candidate = value as Partial<GuanghuLivingSystemPlan>
const scene = candidate.scene
const projection = candidate.uiProjection
const navigation = candidate.navigationAction
const receipt = candidate.receiptSchema
return candidate.version === GUANGHU_LIVING_SYSTEM_VERSION
&& typeof candidate.eventId === 'string'
&& candidate.eventId.length > 0
&& LIVING_INTENTS.has(candidate.intent!)
&& typeof candidate.planId === 'string'
&& candidate.planId.length > 0
&& isRoute(candidate.route)
&& isStringArray(candidate.requiredTruth)
&& Boolean(scene)
&& SCENE_DEPTHS.has(scene!.depth)
&& SCENE_MOTIONS.has(scene!.motion)
&& STAR_DENSITIES.has(scene!.starDensity)
&& CONNECTION_EMPHASES.has(scene!.connectionEmphasis)
&& Boolean(projection)
&& isRoute(projection!.route)
&& isLivingScene(projection!.scene)
&& ['local-safe', 'model-proposed', 'server-bound'].includes(projection!.stateLabel)
&& Boolean(navigation)
&& navigation!.type === 'navigate'
&& isRoute(navigation!.route)
&& isCapabilityCall(candidate.capabilityCall)
&& Boolean(receipt)
&& receipt!.outcome === 'pending-evidence'
&& isStringArray(receipt!.requiredEvidence)
}
export function createLivingSystemEvent(input: CreateLivingSystemEventInput): GuanghuLivingSystemEvent {
const runtimeBinding = verifiedRuntimeBinding(input.runtimeBinding, input.receiptIds)
const allowedCapabilities = CAPABILITY_REGISTRY
.filter(capability => !capability.requiresWorldOpen || input.worldOpen)
.map(capability => capability.id)
const receiptIds = [...input.receiptIds]
return {
eventId: input.eventId,
intent: input.intent,
@ -126,8 +299,36 @@ export function createLivingSystemEvent(input: CreateLivingSystemEventInput): Gu
requestedRoute: input.requestedRoute,
...(input.appearanceTheme ? { appearanceTheme: input.appearanceTheme } : {}),
worldOpen: input.worldOpen,
receiptIds: [...input.receiptIds],
receiptIds,
occurredAt: input.now ?? Date.now(),
personaSystem: {
humanAnchorId: 'ICE-GL∞',
personaSystemId: 'ICE-P-ZY001',
memoryProtocolRoot: 'REPO-012',
modelInstanceId: input.modelInstanceId ?? runtimeBinding?.modelInstanceId ?? null,
},
currentSystemState: {
currentRoute: input.currentRoute,
requestedRoute: input.requestedRoute,
worldOpen: input.worldOpen,
receiptIds,
runtimeBinding,
},
knowledgeState: input.knowledgeState ?? {
selectedLakeId: null,
mountedSources: [],
},
permissionBoundary: {
allowedCapabilities,
deniedCapabilities: [],
},
responsibilityBoundary: {
controllerPersonaSystemId: 'ICE-P-ZY001',
humanAnchorId: 'ICE-GL∞',
executorRule: 'deterministic-host-only',
successRule: 'evidence-required',
},
capabilityRegistry: CAPABILITY_REGISTRY.map(capability => ({ ...capability })),
}
}
@ -146,16 +347,33 @@ export function validateLivingSystemPlan(
): LivingSystemPlanValidation {
if (!plan || plan.eventId !== event.eventId) return { accepted: false, reason: 'event_mismatch' }
if (plan.intent !== event.intent) return { accepted: false, reason: 'intent_mismatch' }
if (plan.route !== event.requestedRoute && plan.route !== 'world-login') {
if (
plan.uiProjection.route !== plan.navigationAction.route
|| (
plan.uiProjection.route !== event.requestedRoute
&& plan.uiProjection.route !== 'world-login'
)
) {
return { accepted: false, reason: 'route_mismatch' }
}
const suppliedTruth = new Set(event.receiptIds)
if (plan.requiredTruth.some(receiptId => !suppliedTruth.has(receiptId))) {
return { accepted: false, reason: 'unverified_truth' }
}
if (!event.worldOpen && PROTECTED_ROUTES.has(plan.route)) {
if (!event.worldOpen && PROTECTED_ROUTES.has(plan.uiProjection.route)) {
return { accepted: false, reason: 'world_closed' }
}
const expectedCapability = CAPABILITY_FOR_INTENT[event.intent]
if (
!event.permissionBoundary.allowedCapabilities.includes(expectedCapability)
|| (
event.intent === 'navigate'
? plan.capabilityCall !== null
: plan.capabilityCall?.capabilityId !== expectedCapability
)
) {
return { accepted: false, reason: 'capability_mismatch' }
}
return { accepted: true, plan }
}
@ -166,18 +384,39 @@ export function createDeterministicLivingSystemPlan(
? 'world-login'
: event.requestedRoute
const immersive = event.worldOpen && route !== 'world' && route !== 'world-login'
const capabilityId = CAPABILITY_FOR_INTENT[event.intent]
return {
version: GUANGHU_LIVING_SYSTEM_VERSION,
eventId: event.eventId,
intent: event.intent,
planId: `fallback-${event.eventId}`,
route,
requiredTruth: [],
scene: {
depth: immersive ? 'immersive' : route === 'world' ? 'overview' : 'focused',
motion: route === 'world' ? 'quiet' : 'responsive',
starDensity: immersive ? 'rich' : 'balanced',
connectionEmphasis: immersive ? 'active-route' : 'contextual',
uiProjection: {
route,
stateLabel: 'local-safe',
scene: {
depth: immersive ? 'immersive' : route === 'world' ? 'overview' : 'focused',
motion: route === 'world' ? 'quiet' : 'responsive',
starDensity: immersive ? 'rich' : 'balanced',
connectionEmphasis: immersive ? 'active-route' : 'contextual',
},
},
navigationAction: { type: 'navigate', route },
capabilityCall: event.intent === 'navigate'
? null
: {
type: 'capability',
capabilityId,
input: {
...(event.appearanceTheme ? { appearanceTheme: event.appearanceTheme } : {}),
requestedRoute: route,
},
},
receiptSchema: {
outcome: 'pending-evidence',
requiredEvidence: event.intent === 'navigate'
? ['ui.route.readback']
: [`capability.${capabilityId}.result`],
},
}
}
@ -185,21 +424,32 @@ export function createDeterministicLivingSystemPlan(
export function createLivingSystemExecutionReceipt({
plan,
source,
outcome,
evidence,
error,
now = Date.now(),
}: {
plan: GuanghuLivingSystemPlan
source: GuanghuLivingSystemExecutionReceipt['source']
outcome: GuanghuLivingSystemExecutionReceipt['outcome']
evidence: string[]
error?: string
now?: number
}): GuanghuLivingSystemExecutionReceipt {
if (outcome === 'executed' && evidence.length === 0) {
throw new Error('guanghu_living_system_success_evidence_required')
}
return {
version: GUANGHU_LIVING_SYSTEM_VERSION,
receiptId: `local-execution:${plan.planId}`,
receiptId: `local-execution:${plan.planId}:${outcome}`,
eventId: plan.eventId,
intent: plan.intent,
planId: plan.planId,
route: plan.route,
route: plan.uiProjection.route,
source,
outcome: 'executed',
executedAt: now,
outcome,
evidence: [...evidence],
completedAt: now,
...(error ? { error } : {}),
}
}

View file

@ -30,26 +30,72 @@ const event = createLivingSystemEvent({
now: 1,
})
function typedPlan({
eventId = 'event-001',
intent = 'navigate' as const,
requiredTruth = ['truth-001'],
stateLabel = 'model-proposed' as const,
} = {}) {
return {
version: 1 as const,
eventId,
intent,
planId: 'model-plan-001',
requiredTruth,
uiProjection: {
route: 'fifth-domain' as const,
stateLabel,
scene: {
depth: 'immersive' as const,
motion: 'active' as const,
starDensity: 'rich' as const,
connectionEmphasis: 'network' as const,
},
},
navigationAction: { type: 'navigate' as const, route: 'fifth-domain' as const },
capabilityCall: null,
receiptSchema: {
outcome: 'pending-evidence' as const,
requiredEvidence: ['ui.route.readback'],
},
}
}
describe('planGuanghuLivingSystem', () => {
it('uses the receipt-backed Shanghai lighthouse as the primary system model', async () => {
it('does not call a server planner without a verified current runtime binding', async () => {
const server = vi.fn().mockRejectedValue(new Error('legacy server route must stay closed'))
await planGuanghuLivingSystem({ event, server })
expect(server).not.toHaveBeenCalled()
})
it('uses a server model only when the current runtime binding has a receipt', async () => {
const boundEvent = createLivingSystemEvent({
eventId: 'event-001',
intent: 'navigate',
currentRoute: 'world',
requestedRoute: 'fifth-domain',
worldOpen: true,
receiptIds: ['truth-001', 'runtime-binding-receipt'],
runtimeBinding: {
bindingId: 'binding-current',
nodeId: 'JD-FD-PRIMARY',
personaSystemId: 'ICE-P-ZY001',
modelInstanceId: 'model-current',
issuedByReceiptId: 'runtime-binding-receipt',
status: 'verified',
},
now: 1,
})
const server = vi.fn().mockResolvedValue({
source: 'server_lighthouse',
serverReceiptId: 'GMRP-HOLOLAKE-001',
model: 'deepseek-v4-flash',
plan: {
version: 1,
eventId: 'event-001',
intent: 'navigate',
planId: 'server-plan-001',
route: 'fifth-domain',
requiredTruth: ['truth-001'],
scene: {
depth: 'immersive', motion: 'responsive', starDensity: 'rich', connectionEmphasis: 'network',
},
},
plan: { ...typedPlan({ stateLabel: 'server-bound' }), planId: 'server-plan-001' },
})
await expect(planGuanghuLivingSystem({ event, server })).resolves.toMatchObject({
await expect(planGuanghuLivingSystem({ event: boundEvent, server })).resolves.toMatchObject({
source: 'server',
serverReceiptId: 'GMRP-HOLOLAKE-001',
plan: { planId: 'server-plan-001' },
@ -59,37 +105,76 @@ describe('planGuanghuLivingSystem', () => {
it('uses a valid model-native plan as the primary system path', async () => {
const server = vi.fn().mockRejectedValue(new Error('offline'))
const stream = vi.fn(async ({ callbacks }) => {
callbacks.onText(JSON.stringify({
version: 1,
eventId: 'event-001',
intent: 'navigate',
planId: 'model-plan-001',
route: 'fifth-domain',
requiredTruth: ['truth-001'],
scene: {
depth: 'immersive', motion: 'active', starDensity: 'rich', connectionEmphasis: 'network',
},
}))
callbacks.onText(JSON.stringify(typedPlan()))
callbacks.onDone()
})
await expect(planGuanghuLivingSystem({ event, target, stream, server })).resolves.toMatchObject({
source: 'model',
plan: { planId: 'model-plan-001', route: 'fifth-domain' },
plan: {
planId: 'model-plan-001',
navigationAction: { route: 'fifth-domain' },
},
})
})
it('returns an explicit fallback receipt when model output violates the boundary', async () => {
const server = vi.fn().mockRejectedValue(new Error('offline'))
const stream = vi.fn(async ({ callbacks }) => {
callbacks.onText('{"version":1,"eventId":"event-001","intent":"navigate","planId":"bad","route":"fifth-domain","requiredTruth":["invented"],"scene":{"depth":"immersive","motion":"active","starDensity":"rich","connectionEmphasis":"network"}}')
callbacks.onText(JSON.stringify({
...typedPlan({ requiredTruth: ['invented'] }),
planId: 'bad',
}))
callbacks.onDone()
})
await expect(planGuanghuLivingSystem({ event, target, stream, server })).resolves.toMatchObject({
source: 'fallback',
fallbackReason: 'unverified_truth',
plan: { route: 'fifth-domain' },
plan: { navigationAction: { route: 'fifth-domain' } },
})
})
it('fails closed for model callback errors, rejected streams, and timeouts', async () => {
const callbackErrorStream = vi.fn(async ({ callbacks }) => {
callbacks.onThinking('bounded')
callbacks.onToolStart('none')
callbacks.onToolDone('none')
callbacks.onError(new Error('model callback failed'))
callbacks.onDone()
})
await expect(planGuanghuLivingSystem({
event,
target,
stream: callbackErrorStream,
timeoutMs: 20,
})).resolves.toMatchObject({
source: 'fallback',
fallbackReason: 'model_error',
})
const rejectedStream = vi.fn(async () => {
throw new Error('stream rejected')
})
await expect(planGuanghuLivingSystem({
event,
target,
stream: rejectedStream,
timeoutMs: 20,
})).resolves.toMatchObject({
source: 'fallback',
fallbackReason: 'model_error',
})
const timedOutStream = vi.fn(async () => new Promise<void>(() => {}))
await expect(planGuanghuLivingSystem({
event,
target,
stream: timedOutStream,
timeoutMs: 1,
})).resolves.toMatchObject({
source: 'fallback',
fallbackReason: 'timeout',
})
})
})

View file

@ -18,14 +18,15 @@ const DEFAULT_TIMEOUT_MS = 1_400
const LIVING_SYSTEM_PROMPT = [
'You are the non-conversational HoloLake living-system planner.',
'Transform exactly one verified interaction event into one version-1 system plan.',
'Transform exactly one bounded interaction event into one version-1 typed system plan.',
'Return one compact JSON object only. Never return prose, markdown, explanations, or tool calls.',
'Keep eventId and intent unchanged. route must equal requestedRoute, except world-login may be used as a safe gate.',
'Keep eventId and intent unchanged.',
'uiProjection.route and navigationAction.route must equal requestedRoute, except world-login may be used as a safe gate.',
'requiredTruth may contain only receiptIds supplied by the event.',
'scene.depth: overview|focused|immersive.',
'scene.motion: quiet|responsive|active.',
'scene.starDensity: sparse|balanced|rich.',
'scene.connectionEmphasis: contextual|active-route|network.',
'uiProjection.scene is a visual projection of supplied state, not a theme score.',
'navigationAction is typed and cannot substitute another host action.',
'capabilityCall must use the exact registered capability for the event intent, or null for navigate.',
'receiptSchema must remain pending-evidence; never claim execution success.',
'Do not infer authorization, server state, identity, or execution success.',
].join(' ')
@ -39,6 +40,14 @@ type LivingSystemStreamRequest = {
type LivingSystemStream = (request: LivingSystemStreamRequest) => Promise<void>
const CAPABILITY_FOR_INTENT: Record<GuanghuLivingSystemEvent['intent'], string | null> = {
navigate: null,
'open-knowledge': 'knowledge.open',
'open-agent-workspace': 'agent.workspace.open',
'open-local-workspace': 'local.workspace.open',
'apply-theme': 'appearance.apply',
}
export type LivingSystemPlanResult = {
source: 'server' | 'model' | 'fallback'
plan: GuanghuLivingSystemPlan
@ -60,28 +69,34 @@ type PlanGuanghuLivingSystemOptions = {
function eventPrompt(event: GuanghuLivingSystemEvent): string {
return JSON.stringify({
version: 1,
event: {
eventId: event.eventId,
intent: event.intent,
currentRoute: event.currentRoute,
requestedRoute: event.requestedRoute,
appearanceTheme: event.appearanceTheme,
worldOpen: event.worldOpen,
receiptIds: event.receiptIds,
occurredAt: event.occurredAt,
},
event,
output: {
version: 1,
eventId: event.eventId,
intent: event.intent,
planId: 'unique string',
route: event.requestedRoute,
requiredTruth: [],
scene: {
depth: 'overview|focused|immersive',
motion: 'quiet|responsive|active',
starDensity: 'sparse|balanced|rich',
connectionEmphasis: 'contextual|active-route|network',
uiProjection: {
route: event.requestedRoute,
stateLabel: event.currentSystemState.runtimeBinding ? 'server-bound' : 'model-proposed',
scene: {
depth: 'overview|focused|immersive',
motion: 'quiet|responsive|active',
starDensity: 'sparse|balanced|rich',
connectionEmphasis: 'contextual|active-route|network',
},
},
navigationAction: { type: 'navigate', route: event.requestedRoute },
capabilityCall: event.intent === 'navigate'
? null
: {
type: 'capability',
capabilityId: CAPABILITY_FOR_INTENT[event.intent],
input: {},
},
receiptSchema: {
outcome: 'pending-evidence',
requiredEvidence: [],
},
},
})
@ -147,19 +162,21 @@ export async function planGuanghuLivingSystem({
stream = streamAiModel,
timeoutMs = DEFAULT_TIMEOUT_MS,
}: PlanGuanghuLivingSystemOptions): Promise<LivingSystemPlanResult> {
try {
const serverResult = await server(event)
const validation = validateLivingSystemPlan(event, serverResult.plan)
if (validation.accepted) {
return {
source: 'server',
plan: validation.plan,
serverReceiptId: serverResult.serverReceiptId,
if (event.currentSystemState.runtimeBinding?.status === 'verified') {
try {
const serverResult = await server(event)
const validation = validateLivingSystemPlan(event, serverResult.plan)
if (validation.accepted) {
return {
source: 'server',
plan: validation.plan,
serverReceiptId: serverResult.serverReceiptId,
}
}
} catch {
// A receipt-bound runtime is optional. A configured local model or the
// deterministic recovery plan keeps local navigation available.
}
} catch {
// The server route is the primary runtime. A configured direct model or
// the deterministic recovery plan keeps navigation available if it is absent.
}
if (!target) return fallback(event, 'model_error')
const model = await collectModelOutput(stream, target, event, timeoutMs)