invariants
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAuthoring Invariants Skill
架构约束创建Skill
Overview
概述
This skill turns an architectural rule in the author's head into a registered,
enforced catalog entry. It is the on-ramp described in
— an LLM-driven
authoring conversation, not a stdin question loop.
docs/designs/archive/2026-05-25-invariants-authoring-wizard.mdThe division of labor is strict and load-bearing:
- The agent (you) supplies judgment + natural-language elicitation. You interview the author, draft prose, propose globs, and shape the entry.
- The verbs own validation + writing. Every mutation goes through a
deterministic, schema-validated orchestrate action — and
invariants_scaffold. You never hand-write or append catalog YAML yourself. The verb renders it; you confirm it.invariants_add
This shape is the only one consistent with the agent-first philosophy: inputs
are constrained at the schema level (INV-5a), mutating verbs default to
dry-run (INV-5c), and authoring is event-sourced (INV-1).
本Skill可将作者脑海中的架构规则转化为已注册、可强制执行的目录条目。它是中描述的入门流程——由LLM驱动的创建对话,而非标准输入式的问答循环。
docs/designs/archive/2026-05-25-invariants-authoring-wizard.md分工明确且至关重要:
- Agent(即你)提供判断与自然语言提取能力。你需要与作者访谈、撰写文案、提出glob路径建议,并梳理条目内容。
- 指令负责验证与写入操作。所有变更都需经过确定性的、基于schema验证的编排动作——和
invariants_scaffold。请勿手动编写或追加目录YAML。指令会自动生成YAML,你只需确认即可。invariants_add
这种模式完全符合Agent优先的理念:输入在schema层面受到约束(INV-5a),变更指令默认采用试运行模式(INV-5c),创建流程基于事件溯源(INV-1)。
When to Use
使用场景
- The author wants a new architectural rule enforced on their own SDLC path
(surfaced at ideate, turned into acceptance criteria at planning, audited at
review by the gate).
check_invariant_conformance - An author says "add an invariant", "enforce that X", "make this a rule".
- 作者希望在自己的SDLC路径上强制执行新的架构规则(在构思阶段提出,在规划阶段转化为验收标准,在评审阶段由gate进行审计)。
check_invariant_conformance - 作者提出"add an invariant"、"enforce that X"、"make this a rule"等需求时。
When NOT to Use
禁用场景
- The author wants to hand-write YAML — point them at the verbs instead; the skill exists so they don't have to.
- The rule is a one-off lint, not an architectural invariant → a project linter is the right home.
- You are mid-workflow editing state, running a review, or planning — those are other skills. This skill only authors catalog entries.
- 作者希望手动编写YAML——请引导他们使用指令;本Skill的存在就是为了避免手动编写YAML。
- 规则是一次性的lint检查,而非架构约束→应使用项目级linter。
- 你处于工作流状态编辑、评审执行或规划过程中——这些属于其他Skill的范畴。本Skill仅用于创建目录条目。
The verbs (what you drive — never bypass)
指令(你需驱动执行,切勿绕过)
| Action (MCP) | CLI facade | What it does |
|---|---|---|
| | Create a starter catalog file for a tier; idempotently register it in |
| | Validate ONE entry against the v3 schema (including the |
| | Reuse the existing |
| | The merged, projected catalog the gate will enforce. Post-write confirmation. |
The agent never declares an entry valid on its own authority — the verb is
the validator. returns the INV-5b carrier shape: success
carries (); validation
errors carry / / sourced from the
Zod error, so you can self-correct and re-run rather than re-guess.
invariants_addnext_actions["doctor", "view invariants_effective"]validTargetsexpectedShapesuggestedFix| 动作(MCP) | CLI 接口 | 功能说明 |
|---|---|---|
| | 为某一层级创建初始目录文件;在 |
| | 针对v3 schema验证单个条目(包括 |
| | 复用现有的 |
| | gate将强制执行的合并后投影目录。用于写入后的确认。 |
Agent绝不能自行声明条目有效——指令才是验证者。返回INV-5b载体格式:成功时返回();验证错误时返回源自Zod错误的//,以便你自行修正并重新执行,而非重新猜测。
invariants_addnext_actions["doctor", "view invariants_effective"]validTargetsexpectedShapesuggestedFixThe interview (6 steps)
访谈流程(6步)
Walk the author through these in order. Elicit in prose, never make them think
in YAML field names.
请按顺序引导作者完成以下步骤。用自然语言提取信息,切勿让作者思考YAML字段名。
1. Elicit — the rule → summary
summary1. 提取——规则→summary
summaryAsk the author to state the rule in one sentence. Distill it into a precise
. Probe for the failure it prevents ("what goes wrong if this is
violated?") — that sharpens both the summary and the later enforcement.
summary请作者用一句话描述规则。将其提炼为精准的。探究该规则要预防的故障("如果违反此规则会出现什么问题?")——这会让summary和后续的执行逻辑更清晰。
summary2. Locate — dimension
, applies-to
, affinities
dimensionapplies-to2. 定位——dimension
、applies-to
、关联属性
dimensionapplies-to- : a free-text grouping (e.g.
dimension,audit-completeness).error-handling - : the glob(s) the rule governs — ask the author to name the paths (
applies-to,src/handlers/**). These are author-named globs, never framework-inferred (INV-6: the surface is workload-neutral).**/*.ts - : phases where it bites (
phase-affinity). Absent ⇒ all phases.ideate | plan | delegate | review | synthesize - : workflow types (
workflow-affinity). Absent ⇒ all.feature | debug | refactor | discovery | oneshot
- :自由文本分组(例如
dimension、audit-completeness)。error-handling - :规则适用的glob路径——请作者指定路径(
applies-to、src/handlers/**)。这些是作者指定的glob路径,绝不能由框架推断(INV-6:适用范围与工作负载无关)。**/*.ts - :规则生效的阶段(
phase-affinity)。若未指定则默认适用于所有阶段。ideate | plan | delegate | review | synthesize - :工作流类型(
workflow-affinity)。若未指定则默认适用于所有类型。feature | debug | refactor | discovery | oneshot
3. Weight — severity
, integrity-class
, and the tier
you author into
severityintegrity-classtier3. 权重设置——severity
、integrity-class
,以及你要创建的tier
severityintegrity-classtier- :
severity.defaultorblocking.advisory - (optional): downgrade for cheap workflows (e.g.
severity.by-workflow).oneshot: advisory - (entry field; enum
integrity-class): the entry's override authority, not its namespace. For a consumer-authored rule this issubstrate | sdlc | authoring | user. (user/substrateare exarchos's own classes — you do not author those.)sdlc - (the verb arg) picks the catalog namespace, and the choice is exarchos-substrate vs project-authored, NOT "which developers". This is the one that bites — get it wrong and you silently collide with exarchos's own ids:
tier- →
tier: userids — your project's own invariants. The default for everyone consuming exarchos. If you are authoring a rule for your own repo, this is always the answer (even if your project happens to name its rulesU-Ninternally — they map toINV-Nhere).U-N - →
tier: devids — exarchos's own reserved substrate catalog. Exarchos ships its ownINV-Ninside the tool, and they merge into everyINV-1..6projection. Authoring intoinvariants_effectivefrom a consumer repo collides yourdevwith exarchos's own — a silent namespace clash theINV-Ncheck can't catch (it only flagsdoctorin a user catalog). UseINV-*only when working inside the exarchos repo itself. The verbs enforce this:dev/invariants_scaffoldrejectinvariants_addoutside the exarchos repo (heuristic:tier: devname ≠package.json) with a@lvlup-sw/exarchoserror that redirects toRESERVED_TIER; a genuine exarchos fork opts in withuser.allowReservedTier: true
- :
severity.default或blocking。advisory - (可选):针对低成本工作流降低级别(例如
severity.by-workflow)。oneshot: advisory - (条目字段;枚举值
integrity-class):条目的覆盖权限,而非命名空间。对于用户创建的规则,该值为substrate | sdlc | authoring | user。(user/substrate是exarchos自身的类别——你无需创建这些类别下的条目。)sdlc - (指令参数)决定了目录的命名空间,选择依据是exarchos底层 vs 项目自定义,而非"面向哪些开发者"。这一点至关重要——若选择错误,会与exarchos自身的ID发生静默冲突:
tier- →
tier: user格式ID——你的项目自定义约束。所有使用exarchos的用户默认选择此选项。 若你为自己的仓库创建规则,这始终是正确选择(即使你的项目内部将规则命名为U-N——它们在此处会映射为INV-N)。U-N - →
tier: dev格式ID——exarchos自身保留的底层目录。 Exarchos工具内置了自己的INV-N规则,它们会合并到每个INV-1..6投影中。在用户仓库中创建invariants_effective层级的条目会导致你的dev与exarchos自身的规则冲突——这是INV-N检查无法捕获的静默命名空间冲突(它仅会标记用户目录中的doctor规则)。仅在exarchos仓库内部工作时使用INV-*层级。指令会强制执行此限制:在exarchos仓库外使用dev/invariants_scaffold并指定invariants_add时(判断依据:tier: dev名称≠package.json),会返回@lvlup-sw/exarchos错误并引导用户选择RESERVED_TIER层级;真正的exarchos分支可通过设置user来启用此选项。allowReservedTier: true
4. Enforce — DEFAULT mode: audit
, mode: check
is opt-in
mode: auditmode: check4. 执行——默认mode: audit
,mode: check
为可选高级功能
mode: auditmode: checkDefault to . You draft the from the elicited
rule — a question the review subagent answers against the diff. Audit mode is
pure judgment and always portable:
mode: auditaudit-promptyaml
enforcement:
mode: audit
audit-prompt: >-
Does this diff let a request handler return before emitting an audit event?
Cite the offending file + line.Offer only as an advanced opt-in when the rule is mechanically
checkable. If the author opts in, propose a declarative combinator tree over
grep/structural/heuristic leaves and validate it live via
with before showing it. See for the
combinator vocabulary and the opt-in flow. The enforcement DSL is
and declarative-only: there is no / / escape hatch
(INV-4), so you cannot emit an executable check even if asked.
mode: checkinvariants_adddryRun: true@references/check-mode.md.strict()scriptexeccode默认使用。你需根据提取的规则编写——即评审子Agent针对代码差异需回答的问题。审计模式完全基于判断,且始终具备可移植性:
mode: auditaudit-promptyaml
enforcement:
mode: audit
audit-prompt: >-
Does this diff let a request handler return before emitting an audit event?
Cite the offending file + line.仅当规则可通过机械方式检查时,才将作为高级可选功能提供给作者。若作者选择此选项,请基于grep/结构化/启发式规则提出声明式组合树,并在展示前通过的模式实时验证。有关组合器词汇和可选流程,请参阅。执行DSL是且仅支持声明式:不存在//逃逸机制(INV-4),因此即使被要求,你也无法输出可执行的检查逻辑。
mode: checkinvariants_adddryRun: true@references/check-mode.md.strict()scriptexeccode5. Number — auto-id in the target namespace
5. 编号——目标命名空间中的自动ID
Do not pick an id. auto-assigns the next free id in the
target catalog's namespace ( for user, for dev). Mention the id the
verb assigned when you show the dry-run.
invariants_addU-NINV-N请勿手动选择ID。会自动为目标目录的命名空间分配下一个可用ID(用户层级为,开发层级为)。在展示试运行结果时,请提及指令分配的ID。
invariants_addU-NINV-N6. Commit — dry-run → confirm → write → verify
6. 提交——试运行→确认→写入→验证
This step is a gate, not a formality. Always:
- Call with
invariants_add(the default). This renders the entry + diff and writes nothing.dryRun: true - Show the author the rendered entry and the file diff verbatim. Make the confirmation explicit: ask "commit this entry?" — do not silently re-invoke.
- Only on explicit confirmation, re-invoke with
invariants_add. This appends the entry, wiresdryRun: falseif the catalog is unregistered, and emits.exarchos.yml(+invariant.authoredon first registration — INV-1).catalog.registered - Run (the
doctorcheck) to validate the resolved catalog.invariants-catalog - Show the delta so the author sees exactly what the gate will now enforce.
invariants_effective
If returns a error, the target catalog does
not exist yet — run first (the error's
names the call), then resume at step 6.
invariants_addCATALOG_NOT_FOUNDinvariants_scaffoldsuggestedFix此步骤是关键环节,而非形式流程。请始终遵循以下步骤:
- 调用并设置
invariants_add(默认值)。这会渲染条目及差异,但不执行写入操作。dryRun: true - 向作者展示渲染后的条目和文件差异原文。明确要求确认:询问"是否提交此条目?"——请勿静默重新调用指令。
- 仅在获得明确确认后,重新调用并设置
invariants_add。这会追加条目,若目录未注册则更新dryRun: false,并触发.exarchos.yml事件(首次注册时还会触发invariant.authored事件——INV-1)。catalog.registered - 运行(
doctor检查)以验证解析后的目录。invariants-catalog - 展示的变化,让作者清楚了解gate现在将强制执行的规则。
invariants_effective
若返回错误,说明目标目录尚未存在——请先运行(错误信息的会指定调用方式),然后回到步骤6继续。
invariants_addCATALOG_NOT_FOUNDinvariants_scaffoldsuggestedFixTool invocations
工具调用
Scaffold a user catalog (idempotent; never overwrites):
ts
exarchos:exarchos_orchestrate({
action: "invariants_scaffold",
tier: "user",
path: ".exarchos/invariants.md"
})Dry-run preview (DEFAULT — writes nothing):
ts
exarchos:exarchos_orchestrate({
action: "invariants_add",
tier: "user",
catalog: ".exarchos/invariants.md",
entry: { /* the fields from steps 1-4; NO id — auto-assigned */ }
})Commit after explicit confirmation:
ts
exarchos:exarchos_orchestrate({
action: "invariants_add",
tier: "user",
catalog: ".exarchos/invariants.md",
entry: { /* same entry */ },
dryRun: false
})Use (or the CLI
) to discover the exact schema at runtime — flags auto-emit from each
action's Zod schema (the CLI is schema-driven; do not assume hand-added flags).
exarchos:exarchos_orchestrate({ action: "describe" })--help创建用户目录(幂等操作;绝不会覆盖现有文件):
ts
exarchos:exarchos_orchestrate({
action: "invariants_scaffold",
tier: "user",
path: ".exarchos/invariants.md"
})试运行预览(默认设置——不执行写入):
ts
exarchos:exarchos_orchestrate({
action: "invariants_add",
tier: "user",
catalog: ".exarchos/invariants.md",
entry: { /* 步骤1-4中的字段;无需ID——自动分配 */ }
})获得明确确认后提交:
ts
exarchos:exarchos_orchestrate({
action: "invariants_add",
tier: "user",
catalog: ".exarchos/invariants.md",
entry: { /* 相同条目 */ },
dryRun: false
})使用(或CLI的)在运行时发现精确的schema——参数会自动从每个动作的Zod schema生成(CLI基于schema驱动;请勿假设存在手动添加的参数)。
exarchos:exarchos_orchestrate({ action: "describe" })--helpWorked example
示例
For one entry authored end-to-end through all 6 steps, see
.
U-*@references/worked-example.md有关通过完整6步流程创建一个条目的示例,请参阅。
U-*@references/worked-example.mdAnti-Patterns
反模式
| Don't | Do Instead |
|---|---|
Hand-write or | Always route mutations through |
| Declare an entry valid yourself | The verb validates; you confirm |
Default to | Default to |
| Skip the dry-run | |
Silently re-invoke with | Make the confirmation step explicit |
| Pick an id by hand | The verb auto-assigns the next free id in the namespace |
Author into | |
| Infer globs from the framework | Ask the author to name the globs (INV-6) |
Skip | Verify the resolved catalog and show the delta |
| 错误做法 | 正确做法 |
|---|---|
手动编写或 | 始终通过 |
| 自行声明条目有效 | 由指令验证,你只需确认 |
默认使用 | 默认使用 |
| 跳过试运行 | 始终先执行 |
静默重新调用并设置 | 明确要求确认步骤 |
| 手动选择ID | 由指令自动分配命名空间中的下一个可用ID |
在用户仓库中创建 | |
| 从框架推断glob路径 | 请作者指定glob路径(INV-6) |
提交后跳过 | 验证解析后的目录并展示变化 |