Core
What a page, a package and an action are, how a package and the lock are built, and which rules the tool that installs packages follows.
关于该包
这段内容尚未翻译,下面是英文原文。
The core is three things: a page, a package and an action. This package explains them to a project and records, as norms, the rules that the tool shtuk follows.
The package puts:
/base/kernel.md— what a page, a package and an action are and what the tool does;/base/package-format.md— the format of a package (package.md) and of the lock (.shtukbase/packages.lock);/base/conventions.md— the page typeConvention: how a base package says what packages of its kind give, expect and may change, and a health check that only informs; the fieldfollows;/norms/rules/core/CORE-R01.md…CORE-R14.md— fourteen norms of the tool, one per rule.
The package has no checks (the conventions of the base packages have their health checks in those packages). The enforcer of each norm is the tool's code and its test; they live in the tool's repository (apps/shtuk/src/, apps/shtuk/test/), not in the project. The norms are derived from the code and tests of tool version 0, nothing beyond them is invented.
Where the boundary is
- Here: the core's concepts, the format of a package and the lock, the rules of install, update, version choice and check.
- The norm collections themselves and the checks of norm form are the package
norms-core. Without it the core's norm pages lie as ordinary pages. - The page
/base/packages.md(the package list) is written by the tool; this package does not put it.
规范 14
| ID | 规范 | 级别 | 模式 | Enforcer |
|---|---|---|---|---|
| CORE-R01 | 安装和更新只放置文件。之后,只有来自受信任来源、并且被标记为 on: install 或 on: update 的动作,包代码才会运行。包代码的其余部分只通过 check 和 run 命令运行。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/trust.ts shtuk:apps/shtuk/src/cli.ts shtuk:apps/shtuk/src/install.ts shtuk:apps/shtuk/src/check.ts shtuk:apps/shtuk/test/install-scripts.test.ts shtuk:apps/shtuk/test/e2e.test.ts |
| CORE-R02 | 包只写入简单的相对路径:不得含 "..",不得为绝对路径,也不得含隐藏文件夹(.git、.shtukbase、.github)。包内的 .git 与 .shtukbase 文件夹不被读取。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/manifest.ts shtuk:apps/shtuk/test/e2e.test.ts |
| CORE-R03 | 安装、初始化和更新先构建完整的计划,然后才写入。任何一步被拒绝,项目都保持不变。试运行(--dry-run)即同一计划,但不写入。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/install.ts shtuk:apps/shtuk/src/cli.ts shtuk:apps/shtuk/test/e2e.test.ts |
| CORE-R04 | 项目中的每个路径都属于一个包。若某个包要放置的页面已属于另一个包,或两个包放置同一页面,则安装整体拒绝。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/install.ts shtuk:apps/shtuk/test/new-style.test.ts |
| CORE-R05 | 项目中文本与包文本不同的页面,不会被工具覆盖。它在锁文件中被记为已编辑,并在报告中注明。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/install.ts shtuk:apps/shtuk/test/e2e.test.ts |
| CORE-R06 | 安装包的新版本时,自上次安装以来在项目中未被改动的页面,会被替换为新文本。已编辑的页面保持原样,报告中写明 "kept N edited"。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/install.ts shtuk:apps/shtuk/test/update.test.ts |
| CORE-R07 | 未在包的新版本中出现的页面,若未被编辑,由工具删除。已编辑的页面则保留,不再计入,并在报告中注明。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/install.ts shtuk:apps/shtuk/test/update.test.ts |
| CORE-R08 | 锁文件中状态为 removed 的页面不会被重新放置。仅仅消失了(missing)的页面,会在下次安装时被放置。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/install.ts shtuk:apps/shtuk/src/lock.ts shtuk:apps/shtuk/test/e2e.test.ts |
| CORE-R09 | 安装同一版本的同一个包,即使在另一天,也不写入任何内容。页面保留首次安装的日期。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/install.ts shtuk:apps/shtuk/test/e2e.test.ts shtuk:apps/shtuk/test/new-style.test.ts |
| CORE-R10 | 不使用求解器:每个包取满足其所有版本范围要求的最高版本。被撤回(yanked)的版本不予采用。若没有符合要求的版本,则报错,并写明是谁对什么提出了要求。依赖循环是错误。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/resolve.ts shtuk:apps/shtuk/test/resolve.test.ts |
| CORE-R11 | 不带包编号的 update,会让每个已安装的包取其记录来源所提供、且依赖它的包的版本范围所允许的最新版本。带编号时只更新该包。不带 update 的安装,只要已安装的版本仍然符合要求,就保留该版本。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/resolve.ts shtuk:apps/shtuk/src/cli.ts shtuk:apps/shtuk/test/update.test.ts shtuk:apps/shtuk/test/resolve.test.ts |
| CORE-R12 | 若新型包 includes(包含)的某个包不存在于任何来源中,安装即报错。缺失的依赖(requires)同样报错。仅对旧的集合(set)而言,消失的 include 才是警告。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/resolve.ts shtuk:apps/shtuk/test/new-style.test.ts shtuk:apps/shtuk/test/resolve.test.ts |
| CORE-R13 | 注册表中的某个包副本,若其树哈希与注册表 index.md 中记录的不一致,则不予安装。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/source.ts shtuk:apps/shtuk/test/e2e.test.ts |
| CORE-R14 | shtuk check 从项目根目录运行每个已安装包中所有带有 check: true 的动作。退出码为 0 表示规范成立,其他退出码表示规范被违反;标准输出的每一行都是一条发现。60 秒内未给出答复的检查视为失败。只要有一项检查失败,shtuk check 即以退出码 1 结束。 |
MUST | 拦截 | 检查 shtuk:apps/shtuk/src/check.ts shtuk:apps/shtuk/test/new-style.test.ts shtuk:apps/shtuk/test/e2e.test.ts |
“拦截”:enforcer 会阻止违规;“观察”:只记录违规。MUST 级别表示必须遵守;SHOULD 表示默认应当遵守。
页面 17
这些页面会放到项目中的以下路径。
- /base/
- Conventions of base packages 页面
- 核心:页面、包、动作 页面
- Package and lock format 页面
- /norms/rules/core/
- 包代码只从受信任的来源在安装时运行 CORE-R01
- 包只在项目内写入简单路径 CORE-R02
- 先出计划,再写入 CORE-R03
- 每个路径只有一个所属包 CORE-R04
- 已编辑的页面不被覆盖 CORE-R05
- 更新时,未改动的页面被替换,已编辑的页面保留 CORE-R06
- 新版本已删除的页面 CORE-R07
- 有意删除的页面不再恢复 CORE-R08
- 重复安装不改变任何内容 CORE-R09
- 每个包取符合要求的最高版本 CORE-R10
- update 取版本范围允许的最新版本 CORE-R11
- 缺失的 include 是错误 CORE-R12
- 被改动的注册表副本被拒绝 CORE-R13
- 检查是包的动作,其答复是退出码 CORE-R14
包文件 1
它们会放到 .shtukbase/packages/core/,动作从那里运行。