神赐

神赐

Authorized local rules · v0.9

Speech already reaches the brain slot. The round trip is too slow, and the uplink is too fat. 神赐 is a grant the main brain issues so this body can wash a stream or emit menu steps locally — without rewriting Body OS.

This page is the public spec. It is not a second organ protocol, not a second ISA, and not a start-code order. Frame stays 0xAA … 0x55. Action names stay menu ASCII. Empty steps still mean silence.

Read Body OS first — the organ bus lives there · Leo · WhatsApp +86 17052886709

Status

What it is for

A cloud consult takes seconds. IMU and speech should not wait on that every tick. The kernel stays a post office.

Wash the uplink

A type-1 rule dedupes and snapshots a stream so the main brain sees what is new this tick — for example a fresh heard_text. It does not emit steps.

Act inside a written bound

A type-2 rule may emit menu steps only inside the grant: named fields, named actions, min / max. Out of bounds it hands off. It does not invent names.

Same identity, permission mask

One rule slot, not two instances fighting over the same IMU. CAN_WATCH, CAN_ACT, or both. The main brain sets the bits. Change bits = a new grant.

Five layers. Keep this map

LayerWhoDoesMust not
1 DriverHumanSlow intent: walk forward, what can you doCare how a step reaches a motor
2 Main brainBrain-slot controllerRead the contract and the wash; emit steps / memory; issue and revoke grantsTouch UART; invent unlisted names; run a millisecond loop
3 Local rule神赐 — authorized assistantFast loop: wash a stream, or emit params inside the grantWire organs privately; self-declare jurisdiction; become a second controller
4 KernelBusRegister organs; copy named fields; forward by the main-brain table; send stepsParse Chinese; understand “balance”; write motors from events
5 OrganHardwareExecute ASCII names; clamp min / max; optional on-organ loopParse user speech; invent abilities

Main brain is slow. Rules are fast. Don’t-fall and current clamp stay on the organ closed loop — not in the rule, and not in the kernel.

What a grant writes down

To change subscribe, priority, or revoke: the main brain issues a new table. A rule cannot tell the kernel to give it the chassis. Quota is the main brain’s; today it can be zero.

The grant is runtime JSON

The brain-slot language is already JSON. A blessing is one more envelope into a rule slot. It does not ride the organ UART.

LayerSees
Main brain → rule slotJSON. Swap an IMU by changing field names, not by rebuilding firmware
RAMA C cache of that JSON. Implementation, not the contract
KernelSlot id, field names to copy, priority number, whether this slot may emit steps. It does not read the word “balance”
Organ UARTThe table never appears. Frame stays 0xAA … 0x55

Algorithm vs binding

Grant shape (v0.9)

rule must be a registered kind. actions[].name must already be on the live menu.

{
  "blessing_id": "bal_1",
  "rule": "balance_v1",
  "priority": 80,
  "perm": ["watch", "act"],
  "fields": [{"mod": "IMU_001", "n": "pitch"}],
  "actions": [{"name": "wheel_left", "min": -1, "max": 1}],
  "bounds": {"pitch_abs_max": 35}
}

Watch and act on one identity

MaskWatchAct
watch onlyDedupe, snapshot, uplink washMust not emit steps
act onlyMay read granted fields (not a wash for the main brain)Emit steps inside bounds
bothSame tick: wash may go up, compensation may emit stepsOut of bounds → handoff

How data moves — balance

Preempt rules, not the organ bus

Today one busy flag holds the whole consult. USB, heard_text, and self-glance wait. That is a single-thread consult, not a rule scheduler. Split three kinds of busy:

BusyWhoWhen a higher grant arrives
Rule computeRule micro-schedulerDrop this tick of the lower rule. No suspend stack on C6
Cloud consultBrain-slot HTTPSDo not pause TLS. If the same consult stimulus was already taken locally, drop the returned steps by heard_req / req_id. An IMU tick_id must not kill a speech reply
Organ executingKernel UART forwardDo not cut a frame. New steps wait behind the current step, including needs_completion_ack

Balance interrupting speech: speech is the organ pipe. Default is let the speaker finish; motor compensation uses other granted names. To stop playback, the rule may only emit a halt-class name already on the menu and on the grant. The kernel does not invent stop_speak. ISA still: priority / depends_on do not reorder organ forward.

C6 is one HP core

Tick budget by kind

Kindbudget_msTypical
Balance / other closed-loop act≤ 10PID, attitude compensation
Uplink wash (watch-heavy)≤ 50Dedupe, snapshot
Unspecified10 if CAN_ACT else 50Default

Timeout skips the tick: no half steps, hold the last issued command (do not zero — that is the jerk), freeze the integrator this tick. Organ closed loop still runs. Repeated overruns → handoff_why over, no per-tick log spam.

Empty steps stay silence. Handoff is a sibling field

EnvelopeMeans
steps: [] and no handoffThis tick has no motion. Already balanced, or nothing to say. Kernel silent
handoff: brain + handoff_why codeThis tick the rule does not take. Kernel consults the main brain. Not “job done”
steps with menu names, no handoffExecute inside the grant
Non-empty steps and handoff togetherForbidden. Drop the packet

Do not put need_brain as a steps[].action. Do not add a UART msg_type. handoff is an additive envelope key; until the bible takes it, today’s cloud path is unchanged.

Drop stale cloud steps by consult id

Cold start: provisional grant, not a naked kernel

A bad grant is rejected whole

Check live registry: module, field name, actions[].name, rule kind. Any miss → do not load. Keep the previous good table. Reply to the main brain in brain-slot JSON, not a new UART type:

{
  "blessing_rejected": true,
  "blessing_id": "bal_1",
  "why": "miss",
  "ref": "IMU_001.pitch"
}

handoff_why — ≤ 4 ASCII

CodeMeans
oobOutside the grant bound
unkUnknown intent / this sentence is not taken
missGranted field or module is not present
overRule tick overran repeatedly
rejGrant failed the existence check

Rule kinds: compiled table, one closed door

Rejected on purpose

  • A sub-brain that boots and tells the kernel what it owns
  • Kernel FIELD_CLASS_BALANCE / RESOURCE_CHASSIS hard routes
  • kernel_inject_action into chassis, or writing motors from pitch in the kernel
  • A vitals matrix as a world model. Vitals stay named-field copies
  • Frame 0x55 0xAA. Live frame is 0xAA … 0x55
  • Action names that are not on the menu

中文

神赐

神赐

主脑授权的本地规则 · v0.9

说话已经能进大脑槽。来回太慢,上行太肥。神赐是主脑签发给这具身体的授权:本地洗流,或在边界内出菜单 steps——不是重写 Body OS。

这一页是公开规格。不是第二份器官协议,不是第二份 ISA,也不是开工令。帧仍是 0xAA … 0x55。动作名仍是菜单 ASCII。空 steps 仍是沉默。

先读 Body OS — 器官总线在那一页 · Leo · WhatsApp +86 17052886709

地位

  • v0.9 大脑层规格。这些槽位尚未写进现行固件
  • 不是协议圣经。信封追加键(handoff、blessing_rejected)在追加进圣经之前,不下器官 UART
  • 不是把 C6 内核拆成策划器的开工令
  • 云咨询已经在跑:heard_text → 大脑槽 → steps → speak。神赐接在这条环之后,不是替代它

要解什么

一次云咨询要数秒。IMU 和说话不该每拍都等。内核仍是邮局。

帮主脑看

类型 1:去重、收快照,标出这一拍真正新的东西(例如刚到的 heard_text),再上传。自己不出 steps。

帮主脑做

类型 2:只在授权边界内出菜单 steps:字段名、动作名、min / max。越界就交还。不发明名字。

一个身份,权限掩码

一个规则槽,不拆成两个实例去抢同一颗 IMU。CAN_WATCH、CAN_ACT,或两者。主脑点位。改位 = 再签一张表。

五层。只留这张图

做什么不做什么
1 驾驶员慢意图:向前走、你都会什么不关心步进怎么接到电机
2 主脑大脑槽里的控制器读合同与摘要;出 steps / memory;签发、收回赐福不碰 UART;不发明未登记动作名;不做毫秒环
3 本地规则神赐 — 主脑授权的助手高速循环:洗流,或在授权内出执行参数不私接器官;不自报管辖;不当第二主脑
4 内核总线登记器官;按字段名抄流;按主脑的表转发;下发 steps不解析中文;不懂「平衡」;不按事件写电机
5 器官硬件按 ASCII 名执行;min / max;可选器官闭环不解析用户原话;不发明能力

主脑慢,规则快。摔倒、电流钳位留在器官闭环——不进规则层,更不进内核。

授权表写清什么

  • 规则身份(给人看、给主脑看;内核可以只记槽位号)
  • 这具身体上哪些器官、哪些字段名——来自当前描述符,不是内核枚举的 CHASSIS / BALANCE
  • 优先级数字,给规则微调度用
  • 权限掩码 CAN_WATCH / CAN_ACT。越界走 handoff,不用空 steps 假装已经做完

改订阅、改优先级、收回:再出一张主脑授权。规则不能对内核说「把底盘也给我」。配额由主脑定,今天可以是 0。

授权表是运行时 JSON

大脑槽的语言已经是 JSON。赐福是主脑写进规则槽的一张表。不下器官 UART。

看到什么
主脑 → 规则槽JSON。换 IMU 只改字段名,不重烧固件
RAM解析后的 C 缓存。那是实现,不是合同
内核槽位号、要抄的字段名、优先级数字、本槽可否出 steps。不读「平衡」二字
器官 UART不出现这张表。帧仍是 0xAA … 0x55

算法和绑定要分开

  • 绑定(器官、字段名、菜单名、min / max、掩码、优先级)= 运行时表
  • 算法(balance_v1 这类已登记种类)= 固件里的处理函数。主脑只点名启用,不在 JSON 里塞 PID 源码
  • 授权表可写 period_ms,但必须 ≥ 该种类的 budget_ms。主脑不能把平衡改成 200ms 去挤 UART

授权表形状(v0.9)

rule 必须是固件已登记的种类。actions[].name 必须已在当前菜单。

{
  "blessing_id": "bal_1",
  "rule": "balance_v1",
  "priority": 80,
  "perm": ["watch", "act"],
  "fields": [{"mod": "IMU_001", "n": "pitch"}],
  "actions": [{"name": "wheel_left", "min": -1, "max": 1}],
  "bounds": {"pitch_abs_max": 35}
}

看和做叠在同一个身份上

掩码
只有 watch洗流、去重、上行摘要禁止出 steps
只有 act仍可读授权字段(不算给主脑洗包)边界内出 steps
两者都有同一拍:摘要可上主脑,补偿可出 steps越界走 handoff

数据怎么走 — 以平衡为例

  • 主脑授权「平衡」,并列出这具身体上的字段名
  • 器官 → 内核按名抄一份 → 按主脑的表送给该规则
  • 看:意见回上传。做:只能经内核下发菜单里的 steps
  • 规则不私接 UART,不占 GPIO。换了陀螺仪器官,主脑改下一张表里的字段名

抢占发生在规则之间,不掐器官总线

今日一个 busy 占住整次咨询。USB、heard_text、自省都要等。那是咨询单工,不是规则调度。三件忙必须拆开:

高优来了怎么办
规则计算规则微调度丢弃本拍低优计算。C6 不堆挂起栈
云咨询大脑槽 HTTPS不暂停 TLS。同一咨询刺激已被本地收掉 → 按 heard_req / req_id 丢掉回来的 steps。IMU 拍号不作废语音咨询
器官在执行内核按数组转发 UART不中途掐帧。新 steps 排在当前步之后(含 needs_completion_ack)

平衡打断正在说话:说话是器官管道。默认喇叭说完;电机补偿走已授权的别的菜单名。若必须停播,只能出菜单上已有、授权表里点过名的停止类能力。内核不发明 stop_speak。ISA:priority / depends_on 仍不改变器官转发顺序。

C6 是单核,用任务分时

  • ESP32-C6:本工程一颗 HP RISC-V(unicore)。LP 核不给规则用
  • 器官 UART / 收帧:最高 FreeRTOS 优先级
  • 规则拍:中等,时限按种类写死,超时跳过
  • 云咨询:最低。TLS 已经占 AI worker
  • 以后换双核宿主只换移植层绑核,不改这张表

规则拍时限按种类

种类budget_ms典型
平衡 / 其它闭环执行≤ 10PID、姿态补偿
数据梳理(watch 为主)≤ 50去重、摘要
未声明有 CAN_ACT 则 10,否则 50缺省

超时 = 本拍跳过:不出半截 steps,保持上一拍已发出的命令(不要清零——那才抖),积分本拍冻结。器官闭环仍在跑。连续超时过多 → handoff_why over,不打每拍超时日志。

空 steps 仍是沉默;交还主脑必须另写

信封意思
steps: [] 且无 handoff本拍无动作。已平衡,或无话可说。内核静默
handoff: brain + handoff_why 短码本拍规则不收。内核去咨询主脑。不是「已做完」
steps 里是菜单名,无 handoff边界内执行
同时有非空 steps 和 handoff禁止。整包丢弃

不把 need_brain 写成 steps[].action。也不发明 UART 新 msg_type。handoff 是信封追加键;未写入圣经之前,现行云咨询路径不变。

作废云端 steps:对咨询身份,不对 IMU 拍号

  • 丢弃键用现行 req_id / heard_req。不要用全局 tick_id ≤ N——那会误杀说话回复
  • 本地类型 2 已收掉同一句 → 云回来静默丢弃
  • 本地能收的刺激尽量根本不上云。只有已经在飞的 TLS 才走这条作废

冷启动:临时授权,不是裸奔

  • 摔倒反射在器官闭环。规则层仍应加载上次已接受的表,免得主脑还没连上时补偿环是空的
  • NVS 只存校验通过且已接受的表。被拒绝的不写
  • 上电:字段都在 → 加载并标 provisional: true。校验失败 → 空槽
  • 临时表原样继承。上电代码不得改优先级、不得加能力、不得加字段
  • 主脑第一次有效会话必须确认、换表或收回

坏表整表拒绝

按当前登记做存在性校验:模块、字段名、actions[].name、rule 种类。任何一项失败 → 整表不加载。旧的有效表保持。回主脑一封大脑槽 JSON,不是新 UART 类型:

{
  "blessing_rejected": true,
  "blessing_id": "bal_1",
  "why": "miss",
  "ref": "IMU_001.pitch"
}

handoff_why — ≤ 4 字节短码

意思
oob超出授权边界
unk不认识的意图 / 收不了这句
miss授权字段或模块当前不在
over规则拍连续超时
rej赐福校验拒绝

规则种类:今天编译表,留一个空门

  • 新增 balance_v2 这类要重编译 + OTA。C6 现在不做动态装载、TinyML、通用字节码解释器
  • 预留种类名 custom_v0。今天签发它 = blessing_rejected / why unk
  • 将来若有轻量决策树,仍必须吃 actions[] 白名单,不能私接 UART,不能发明菜单外的名。内核永远不解释脚本

明确不采用

  • 副脑启动后向内核自报「哪些归我管」
  • 内核硬编码 FIELD_CLASS_BALANCE / RESOURCE_CHASSIS
  • kernel_inject_action 往底盘灌,或按 pitch 在内核写电机
  • 体征矩阵当世界模型。体征仍是按字段名拷贝
  • 帧头 0x55 0xAA。现行是 0xAA … 0x55
  • 菜单上没有的能力名