Files
lou 0827b2399c 内核框架 v0.1 首次提交: 引导器 / 内核 / 驱动 + 日志系统
引导器 UEFI.boot.py (纯 stdlib, 内核的管家)
  体检 6 项 (解释器/venv/包/驱动目录/PG) / venv 重建 / 包台账 / 内核进程启停记账 / 参数原样透传
  内核日志 / 引导器日志 / 内核 stdio 三条道的查看入口都归它

内核 内核/ (常驻调度 = 甲)
  命令消费 (PG commands + LISTEN/NOTIFY) / 驱动调用仲裁六条 (越权·成环·无人提供·按需拉起·同锁排队·超时收权)
  依赖链巡检 10s / 心跳 300s / 独一份调度锁 (pg_try_advisory_lock 0x65666901)
  扫描: 9 条校验 + 契约匹配 + 拓扑排序; 状态: 快照原子写 + 断电收尸判定
  db.py 是唯一碰 SQL 的文件 (drivers/driver_state/events/scans/commands/calls/kernel_env/kernel_runs)

日志系统 (2026-09-16 完整化, 设计/04-日志系统.md)
  三条道一个文件一种内容: 内核.log (结构化行) / 内核.out.log (命令输出 + 崩溃原文) / 引导器.log (引导器动作)
  驱动日志每轮启动前插分隔头; 门槛 log_level / 轮转 log_max_mb + log_keep / -n · -f · --级别 · -g · --json · --全部
  实现 内核/日志.py (内核与引导器共用一份); 修掉"命令输出混进日志文件" (实证存档 归档/20260916-日志系统重做前/)

驱动样板 (也是写驱动的示范): Json解码 (oneshot) / 样板常驻 (provides 样板:心跳) / 样例消费器 (needs 只发契约名)

代码标点统一为 ASCII (保留界面用的框线 ─│◄▶ 与表格占位符 —); 已用 AST 等价对比证明逻辑零改动

自测 (真机, 不 mock): 进程 (真起进程真收子树) / 内核 58 项 / 配置 / db 182 项 / 日志 86 项
验收: 试跑引导器.py PASS 11 / FAIL 0 / 残留无; uvx pyright 与 uvx basedpyright 均 0 errors 0 warnings
2026-09-16 21:03:48 +08:00

123 lines
12 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<mxfile host="app.diagrams.net">
<diagram name="第 1 页" id="d1">
<mxGraphModel dx="900" dy="600" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1160" pageHeight="1120" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="hdr" parent="1" value="内核项目 总览 / 用户级虚拟操作系统框架&#10;四层:引导器(UEFI) → 内核 → 驱动 → 程序(Skill)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontStyle=1;" vertex="1">
<mxGeometry height="54" width="960" x="100" y="20" as="geometry" />
</mxCell>
<mxCell id="C1" parent="1" value="用户 / CLI(人敲命令)" style="swimlane;html=1;startSize=30;fillColor=#f5f5f5;strokeColor=#666666;fontStyle=1;" vertex="1">
<mxGeometry height="110" width="1040" x="60" y="100" as="geometry" />
</mxCell>
<mxCell id="C2" parent="1" value="① 引导器 UEFI.boot.py(短命 CLI · 零第三方依赖)" style="swimlane;html=1;startSize=30;fillColor=#f5f5f5;strokeColor=#666666;fontStyle=1;" vertex="1">
<mxGeometry height="140" width="1040" x="60" y="240" as="geometry" />
</mxCell>
<mxCell id="C3" parent="1" value="② 内核(常驻 · 总调度 · 纯 CLI 命令 + PG 当内存)" style="swimlane;html=1;startSize=30;fillColor=#f5f5f5;strokeColor=#666666;fontStyle=1;" vertex="1">
<mxGeometry height="160" width="1040" x="60" y="410" as="geometry" />
</mxCell>
<mxCell id="C4" parent="1" value="③ 驱动(互不认识 · 零通道 · 只声明「我要什么 / 我产出什么」)" style="swimlane;html=1;startSize=30;fillColor=#f5f5f5;strokeColor=#666666;fontStyle=1;" vertex="1">
<mxGeometry height="140" width="600" x="60" y="600" as="geometry" />
</mxCell>
<mxCell id="C6" parent="1" value="④ 程序 / Skill(声明式 · v0.2 占位)" style="swimlane;html=1;startSize=30;fillColor=#f5f5f5;strokeColor=#666666;fontStyle=1;" vertex="1">
<mxGeometry height="140" width="380" x="720" y="600" as="geometry" />
</mxCell>
<mxCell id="C5" parent="1" value="PostgreSQL efi_kernel = 内存 / 总线(唯一通道)" style="swimlane;html=1;startSize=30;fillColor=#f5f5f5;strokeColor=#666666;fontStyle=1;" vertex="1">
<mxGeometry height="180" width="1040" x="60" y="770" as="geometry" />
</mxCell>
<mxCell id="cli" parent="C1" value="UEFI.boot.py &lt;子命令&gt;&#10;列表 / 启动 / 停止 / 状态 / 日志" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="50" width="480" x="20" y="44" as="geometry" />
</mxCell>
<mxCell id="out" parent="C1" value="答案与日志直接打终端(纯 CLI,没有 TUI)" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="50" width="480" x="540" y="44" as="geometry" />
</mxCell>
<mxCell id="env" parent="C2" value="管内核环境&#10;解释器 / venv 健康 / 路径" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="68" width="320" x="20" y="46" as="geometry" />
</mxCell>
<mxCell id="pkg" parent="C2" value="管包状态&#10;缺什么 / 版本不符 / 索引源" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="68" width="320" x="360" y="46" as="geometry" />
</mxCell>
<mxCell id="kpr" parent="C2" value="管内核进程&#10;拉起 / 判活 / 日志 / 记账" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="68" width="320" x="700" y="46" as="geometry" />
</mxCell>
<mxCell id="kcmd" parent="C3" value="命令循环&#10;commands + LISTEN/NOTIFY" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="70" width="240" x="20" y="46" as="geometry" />
</mxCell>
<mxCell id="kmatch" parent="C3" value="契约匹配与排序&#10;provides ↔ needs 拓扑" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="70" width="240" x="280" y="46" as="geometry" />
</mxCell>
<mxCell id="karb" parent="C3" value="转发仲裁&#10;锁 / 超时 / 越权 / 成环" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="70" width="240" x="540" y="46" as="geometry" />
</mxCell>
<mxCell id="kproc" parent="C3" value="驱动进程与状态&#10;/proc 判活 · 快照" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="70" width="220" x="800" y="46" as="geometry" />
</mxCell>
<mxCell id="r1" parent="C4" value="主驱动 resident&#10;常驻等活 · LISTEN driver_&lt;名&gt;" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="70" width="270" x="15" y="46" as="geometry" />
</mxCell>
<mxCell id="r2" parent="C4" value="副驱动 oneshot&#10;按需拉起 · 跑完收尸" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="70" width="270" x="315" y="46" as="geometry" />
</mxCell>
<mxCell id="skill" parent="C6" value="web.json = {html, css, js}&#10;由驱动解释执行(样本:Json解码)" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1">
<mxGeometry height="80" width="340" x="20" y="46" as="geometry" />
</mxCell>
<mxCell id="t1" parent="C5" value="drivers" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1">
<mxGeometry height="46" width="190" x="20" y="46" as="geometry" />
</mxCell>
<mxCell id="t2" parent="C5" value="driver_state" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1">
<mxGeometry height="46" width="190" x="230" y="46" as="geometry" />
</mxCell>
<mxCell id="t3" parent="C5" value="events" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1">
<mxGeometry height="46" width="190" x="440" y="46" as="geometry" />
</mxCell>
<mxCell id="t4" parent="C5" value="calls" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1">
<mxGeometry height="46" width="190" x="650" y="46" as="geometry" />
</mxCell>
<mxCell id="t5" parent="C5" value="commands" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1">
<mxGeometry height="46" width="160" x="860" y="46" as="geometry" />
</mxCell>
<mxCell id="t6" parent="C5" value="scans" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1">
<mxGeometry height="46" width="190" x="20" y="108" as="geometry" />
</mxCell>
<mxCell id="t7" parent="C5" value="kernel_env" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1">
<mxGeometry height="46" width="190" x="230" y="108" as="geometry" />
</mxCell>
<mxCell id="t8" parent="C5" value="kernel_runs" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1">
<mxGeometry height="46" width="190" x="440" y="108" as="geometry" />
</mxCell>
<mxCell id="t9" parent="C5" value="契约数据表(驱动产出 / 取用,表名由内核约定并注入)" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1">
<mxGeometry height="46" width="370" x="650" y="108" as="geometry" />
</mxCell>
<mxCell id="sum" parent="1" value="一句话:引导器管内核(环境 / 包 / 进程)→ 内核管驱动(总调度 / 转发 / 反打架)→ 驱动互不认识、零通道。&#10;所有状态与请求都落在 PostgreSQL 里 —— 零 socket、零自造协议。" style="shape=note;whiteSpace=wrap;html=1;size=15;fillColor=#fff2cc;strokeColor=#d6b656;align=left;spacingLeft=6;" vertex="1">
<mxGeometry height="80" width="1040" x="60" y="1000" as="geometry" />
</mxCell>
<mxCell id="e1" edge="1" parent="1" source="C1" target="C2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;horizontal=1;labelBackgroundColor=#ffffff;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" value="命令 + 参数">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e2" edge="1" parent="1" source="C2" target="C3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;horizontal=1;labelBackgroundColor=#ffffff;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" value="启动并看住内核进程">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e3" edge="1" parent="1" source="C3" target="C4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;horizontal=1;labelBackgroundColor=#ffffff;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;startArrow=classic;endArrow=classic;" value="启停 / 转发 / 判活">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e4" edge="1" parent="1" source="C3" target="C5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;horizontal=1;labelBackgroundColor=#ffffff;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;startArrow=classic;endArrow=classic;">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="1120" y="570" />
<mxPoint x="1120" y="770" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="e5" edge="1" parent="1" source="C4" target="C6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;horizontal=1;labelBackgroundColor=#ffffff;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;dashed=1;strokeColor=#888888;fontColor=#888888;" value="v0.2">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e6" edge="1" parent="1" source="C6" target="C5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;horizontal=1;labelBackgroundColor=#ffffff;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.85;entryY=0;entryDx=0;entryDy=0;dashed=1;strokeColor=#888888;fontColor=#888888;" value="v0.2 加载">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e7" edge="1" parent="1" source="C4" target="C5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;horizontal=1;labelBackgroundColor=#ffffff;exitX=0.35;exitY=1;exitDx=0;exitDy=0;entryX=0.35;entryY=0;entryDx=0;entryDy=0;dashed=1;strokeColor=#888888;fontColor=#888888;" value="只写 calls / events,读契约表">
<mxGeometry relative="1" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>