feat: add language-first operating contract

This commit is contained in:
冰朔 2026-08-10 11:59:43 +08:00
commit 79dd5f3920
5 changed files with 257 additions and 2 deletions

View file

@ -0,0 +1,42 @@
{
"schema": "hololake.source-publication-receipt/v1",
"record_id": "HLP-LANGUAGE-SHELL-STAGE-011-001",
"development_id": "DEV-20260809-007",
"source_remote_head": "d35b46a5b574d02511a60803dbd4db1096935a69",
"target_branch": "main",
"current_architecture": "HLP-CURRENT-ARCH-001@2026-08-10.2",
"files": [
{
"path": "product-source/hololake-platform/src/lib/languageOperatingModel.ts",
"sha256": "1cf6aa2c057231c7c30ee67a4600481ff3f08c0ddd422813e8dae0f413e23148"
},
{
"path": "product-source/hololake-platform/src/lib/languageOperatingModel.test.ts",
"sha256": "1c63a1bcc5161997c1dd7c2652ba714c98a46282e1b9d16c1c86818ef58f03c6"
},
{
"path": "product-source/hololake-platform/architecture/HOLOLAKE-LANGUAGE-SHELL-STAGE-011-IMPLEMENTATION-20260810.md",
"sha256": "c7fd9346f0e439b841ced096b756aca503747e8244a049885c0995ddc738f387"
},
{
"path": "routing/hololake-current-architecture.json",
"sha256": "1fd7409785becb454e14a970e8dc8a60c00b3f10513eaf7e16dbb2904f99f771"
}
],
"checks": {
"focused_vitest": "PASS_100_5_OF_5",
"eslint": "PASS_100",
"typescript_no_emit": "PASS_100",
"clean_worktree_source_hash_matches_tested_source": "PASS_100",
"architecture_json_parse": "PASS_100",
"git_diff_check": "PASS_100"
},
"truth_boundary": {
"source_contract_published": true,
"ui_integrated": false,
"artifact_built": false,
"runtime_deployed": false,
"online_service_healthy": false
},
"recorded_at": "2026-08-10T11:58:30+08:00"
}

View file

@ -0,0 +1,45 @@
# HoloLake 语言壳 Stage 011 实现登记 · 2026-08-10
> 记录编号:`HLP-LANGUAGE-SHELL-STAGE-011-001`
>
> 对应模型:`HLP-LANGUAGE-PERSONA-OPERATING-MODEL-001`
>
> 状态:`SOURCE_CONTRACT_PUBLISHED · NOT_UI_INTEGRATED · NOT_RUNTIME_DEPLOYED`
## 本阶段验收目标
本阶段只建立语言人格驱动操作系统的最小代码契约,不把传统设置页换皮后冒充语言系统。
必须满足:
1. 自然语言是必填的主输入;
2. 未授权人格体只能解释和规划,系统保持直接控制;
3. 明确授权后,人格体可作为语义代理,但系统仍负责校验与执行;
4. 只有现实主权边界触发人类确认;
5. 默认人类表面只有语言、状态、确认和人话回执;
6. 节点、权限、仓库、模型、工具参数和部署日志留在内部或高级模式。
## 代码落点
- `src/lib/languageOperatingModel.ts`
- `src/lib/languageOperatingModel.test.ts`
当前代码定义两种控制模式、八类现实边界、默认人类表面、系统内部表面,以及把一条人类
语言目标投影为状态、确认和回执的确定性函数。
## 已验证
- 聚焦行为测试:`5 / 5 PASS`
- ESLint`PASS`
- TypeScript `--noEmit``PASS`
## 尚未实现
- 未接入公共灯塔或第五域正式页面;
- 未接入真实意图编译器、人格授权服务、权限引擎、工具编排器或耐久回执;
- 未形成可安装新制品;
- 未部署任何服务器或在线运行体。
下一阶段应把该契约接入一个真实但可逆的端到端任务:用户只说一句目标,系统输出人话
计划;无现实边界时自动执行,有边界时只弹出一个可理解的确认卡,完成后返回人话回执与
可展开技术证据。

View file

@ -0,0 +1,69 @@
import { describe, expect, it } from 'vitest'
import {
DEFAULT_HUMAN_SURFACE,
SYSTEM_INTERNAL_SURFACE,
compileLanguageGoal,
} from './languageOperatingModel'
describe('languageOperatingModel', () => {
it('treats natural language as the required primary input', () => {
expect(() => compileLanguageGoal({ utterance: ' ', personaAuthorized: false }))
.toThrow('LANGUAGE_GOAL_REQUIRED')
expect(compileLanguageGoal({
utterance: ' 帮我把今天的会议整理进知识库 ',
personaAuthorized: false,
}).goal).toBe('帮我把今天的会议整理进知识库')
})
it('keeps an unauthorized persona explanatory while the system remains direct', () => {
const projection = compileLanguageGoal({
utterance: '帮我整理桌面上的项目资料',
personaAuthorized: false,
})
expect(projection.mode).toBe('system_direct')
expect(projection.status).toBe('ready')
expect(projection.receiptSummary).toContain('人格体只提供解释和计划')
})
it('uses an explicitly authorized persona as the semantic agent', () => {
const projection = compileLanguageGoal({
utterance: '继续开发 HoloLake',
personaAuthorized: true,
})
expect(projection.mode).toBe('persona_primary')
expect(projection.receiptSummary).toContain('系统校验并执行')
})
it('asks for one human decision only when a reality boundary is detected', () => {
const projection = compileLanguageGoal({
utterance: '把这个版本公开发布出去',
personaAuthorized: true,
detectedBoundaries: ['public_release', 'new_cost', 'public_release'],
})
expect(projection.status).toBe('needs_confirmation')
expect(projection.confirmation).toEqual(expect.objectContaining({
required: true,
boundaries: ['public_release', 'new_cost'],
}))
expect(projection.confirmation.question).toContain('公开发布')
expect(projection.confirmation.question).toContain('新的费用')
expect(projection.confirmation.question).toContain('不同意')
})
it('keeps technical controls out of the default human surface', () => {
expect(DEFAULT_HUMAN_SURFACE).toEqual([
'language_input',
'task_status',
'reality_boundary_confirmation',
'human_receipt',
])
expect(DEFAULT_HUMAN_SURFACE).not.toContain('node_identity')
expect(SYSTEM_INTERNAL_SURFACE).toContain('node_identity')
expect(SYSTEM_INTERNAL_SURFACE).toContain('repository_route')
expect(SYSTEM_INTERNAL_SURFACE).toContain('model_configuration')
})
})

View file

@ -0,0 +1,91 @@
export type LanguageControlMode = 'system_direct' | 'persona_primary'
export type RealityBoundary =
| 'new_cost'
| 'data_egress'
| 'new_external_account'
| 'permission_expansion'
| 'public_release'
| 'irreversible_change'
| 'privacy_or_credential'
| 'private_relationship'
export type LanguageGoalRequest = {
utterance: string
personaAuthorized: boolean
detectedBoundaries?: RealityBoundary[]
}
export type HumanConfirmation = {
required: boolean
boundaries: RealityBoundary[]
question: string | null
}
export type LanguageGoalProjection = {
goal: string
mode: LanguageControlMode
status: 'ready' | 'needs_confirmation'
confirmation: HumanConfirmation
receiptSummary: string
}
const BOUNDARY_LABELS: Record<RealityBoundary, string> = {
new_cost: '会产生新的费用',
data_egress: '会让数据离开当前设备',
new_external_account: '会创建或绑定新的外部账号',
permission_expansion: '会扩大现有权限',
public_release: '会公开发布或代表你向外发送内容',
irreversible_change: '包含难以恢复的迁移、覆盖或删除',
privacy_or_credential: '需要隐私、钥匙串、验证码或身份确认',
private_relationship: '会触及私人关系或不可转让关系核心',
}
function normalizeBoundaries(boundaries: RealityBoundary[] | undefined): RealityBoundary[] {
return [...new Set(boundaries ?? [])]
}
export function compileLanguageGoal(request: LanguageGoalRequest): LanguageGoalProjection {
const goal = request.utterance.trim()
if (!goal) throw new Error('LANGUAGE_GOAL_REQUIRED')
const boundaries = normalizeBoundaries(request.detectedBoundaries)
const confirmationRequired = boundaries.length > 0
const mode: LanguageControlMode = request.personaAuthorized
? 'persona_primary'
: 'system_direct'
return {
goal,
mode,
status: confirmationRequired ? 'needs_confirmation' : 'ready',
confirmation: {
required: confirmationRequired,
boundaries,
question: confirmationRequired
? `继续前需要你确认:${boundaries.map((boundary) => BOUNDARY_LABELS[boundary]).join('')}。不同意也不会影响你继续使用其他功能。`
: null,
},
receiptSummary: confirmationRequired
? '我已经理解你的目标,正在等待一个现实边界决定。'
: mode === 'persona_primary'
? '我已经理解你的目标,将由获授权的人格体规划,系统校验并执行。'
: '我已经理解你的目标;当前由系统处理安全范围内的动作,人格体只提供解释和计划。',
}
}
export const DEFAULT_HUMAN_SURFACE = [
'language_input',
'task_status',
'reality_boundary_confirmation',
'human_receipt',
] as const
export const SYSTEM_INTERNAL_SURFACE = [
'node_identity',
'permission_policy',
'repository_route',
'model_configuration',
'tool_parameters',
'deployment_log',
] as const

View file

@ -1,7 +1,7 @@
{
"schema": "hololake.current-architecture/v1",
"architecture_id": "HLP-CURRENT-ARCH-001",
"version": "2026-08-10.1",
"version": "2026-08-10.2",
"state": "CURRENT_CANONICAL",
"product": {
"formal_name": "光湖语言系统 · 通用人工智能操作平台",
@ -12,6 +12,7 @@
"read_order": [
"product-source/hololake-platform/architecture/HOLOLAKE-SYMBIOTIC-PERSONA-ORIGIN-AND-BOUNDARY-20260809.md",
"product-source/hololake-platform/architecture/HOLOLAKE-LANGUAGE-PERSONA-DRIVEN-OPERATING-MODEL-20260810.md",
"product-source/hololake-platform/architecture/HOLOLAKE-LANGUAGE-SHELL-STAGE-011-IMPLEMENTATION-20260810.md",
"product-source/hololake-platform/architecture/HOLOLAKE-INTENT-REASONING-MAP-20260809.md",
"product-source/hololake-platform/architecture/HOLOLAKE-SYSTEM-ARCHITECTURE-20260809.md",
"product-source/hololake-platform/architecture/HOLOLAKE-DESKTOP-0.8.0-CURRENT-CAPABILITY-GAP-20260809.md",
@ -74,7 +75,14 @@
"control_modes": [
"SYSTEM_DIRECT_MODE",
"PERSONA_PRIMARY_CONTROL_MODE"
]
],
"source_contract": {
"record_id": "HLP-LANGUAGE-SHELL-STAGE-011-001",
"state": "SOURCE_CONTRACT_PUBLISHED_NOT_UI_INTEGRATED_NOT_RUNTIME_DEPLOYED",
"implementation": "product-source/hololake-platform/src/lib/languageOperatingModel.ts",
"tests": "product-source/hololake-platform/src/lib/languageOperatingModel.test.ts",
"focused_tests": "5_OF_5_PASS"
}
},
"current_product_assessment": {
"record_id": "HLP-DESKTOP-GAP-20260809-001",