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
|
|
@ -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')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue