spec 1.0 · 规范性
Leji 上下文索引
AI 智能体辅助翻译。如有出入,以英文页面为准。如果你发现文本有任何问题,欢迎提交议题或发起拉取请求。
上下文层的生成地图。绝不手工维护;有变更时重新生成。
字段
- #
schemaVersionstring必填 本产物所依据撰写的 Leji 规范版本系列,例如 "1.0"。
匹配模式
^\d+\.\d+$- #
generatedAtstring必填 索引生成时的 ISO 8601 时间戳。
匹配模式
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])[T ].+$- #
generatorobject 生成本索引的工具。
namestring生成工具的名称,例如 "leji"。
versionstring生成工具的版本。
- #
rootPathstring必填 本索引所针对的上下文层根目录;与清单的 rootPath 一致。条目路径相对仓库根目录,不会以它为基准重设。
匹配模式
^(?!/)(?!\./)(?!.*(^|/)\.\.(/|$))(?!.*\\).*$- #
entries对象数组必填 上下文层中每一份被索引的文档对应一条条目。每个
id与每个path在所有条目中都唯一;这一点由参考校验器强制执行(JSON Schema 做不到,因为该约束作用在子字段上,而不是整个对象上)。idstring必填稳定的标识符;重命名与移动更新的是 path,绝不是 id。
pathstring必填相对仓库根目录的文档路径。
titlestring必填人类可读的标题,取自文档的第一个标题或 frontmatter。
category"domain" · "system" · "practice" · "governance" · "decisions"必填本文档所属的内容类别。
kind"intent" · "record"本文档是持续维护的当下真实(intent),还是带日期的证据(record)。缺失即表示 intent。
datestring记录的日期,只取自合法的 frontmatter date。
summarystring文档的一行摘要,用于路由与导航。
tags字符串数组可选的自由形式标签。
owners字符串数组本文档的可选负责人。
lastModifiedstring文档最后一次变更的 ISO 8601 日期,在可用时取自版本控制系统。
contentHashstring文档内容的哈希,用于检测漂移和保留内容的移动。
freshnessobject本文档的复核期限。
reviewAfterstringISO 8601 日期,在此之后应当复核本文档是否过期。
links字符串数组本文档可选的外向引用。
- #
mounts对象数组 联邦同级上下文层的路由记录,由清单的 federation.mounts 推导而来(规范:distribution.md、machine-readable-surface.md)。仅为路由元数据:工具不得把某个同级层的索引条目或散文复制到这里。挂载记录绝不披露宿主层受众不该看到的内容。
namestring必填同级层的名称;与该同级层自身清单中的 name 一致。
sourcestring必填同级层的归一化仓库定位符。
pinstring必填宿主层所读取的同级层修订版的完整不可变提交 id(SHA-1 或 SHA-256)。
trackingRefstring声明时,可达性与过期状态都相对这个全限定见证 ref 来比较。
ownerobject必填同级层的负责人。
namestring必填contactstringrolestring用散文描述这个同级层承载什么。
categories由 "domain" · "system" · "practice" · "governance" · "decisions" 构成的数组这个同级层可以应答的内容类别范围。
topics字符串数组用于相关性路由的简短主题标签。
requiredWhen字符串数组在这些任务条件下,读取者必须解析这个挂载;否则必须停止并报告上下文不完整(失败即关闭)。
Schema 与示例
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://leji.org/schemas/v1.0/context-index.schema.json",
"title": "Leji context index",
"description": "Generated map of the context layer. Never hand-maintained; regenerate on change.",
"type": "object",
"required": [
"schemaVersion",
"generatedAt",
"rootPath",
"entries"
],
"additionalProperties": false,
"properties": {
"$schema": {
"description": "Optional pointer to this schema, for editor validation and tooling.",
"type": "string"
},
"schemaVersion": {
"description": "The Leji spec line this artifact was written against, e.g. \"1.0\".",
"type": "string",
"pattern": "^\\d+\\.\\d+$"
},
"generatedAt": {
"description": "ISO 8601 timestamp when the index was generated.",
"type": "string",
"pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])[T ].+$"
},
"generator": {
"description": "The tool that generated this index.",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"description": "Name of the generating tool, e.g. \"leji\".",
"type": "string"
},
"version": {
"description": "Version of the generating tool.",
"type": "string"
}
}
},
"rootPath": {
"description": "The context layer root this index was generated for; mirrors the manifest's rootPath. Entry paths are repository-root-relative, not re-based under it.",
"type": "string",
"pattern": "^(?!/)(?!\\./)(?!.*(^|/)\\.\\.(/|$))(?!.*\\\\).*$"
},
"entries": {
"description": "One entry per indexed document in the context layer. Each `id` and each `path` is unique across entries; the reference validator enforces this (JSON Schema cannot, since the constraint is on a sub-field, not the whole object).",
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"path",
"title",
"category"
],
"additionalProperties": false,
"properties": {
"id": {
"description": "Stable identifier; renames and moves update the path, never the id.",
"type": "string",
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
},
"path": {
"description": "Repository-root-relative path to the document.",
"type": "string",
"pattern": "^(?!/)(?!\\./)(?!.*(^|/)\\.\\.(/|$))(?!.*\\\\).+$"
},
"title": {
"description": "Human-readable title, from the document's first heading or frontmatter.",
"type": "string",
"minLength": 1
},
"category": {
"description": "Which content category this document belongs to.",
"enum": [
"domain",
"system",
"practice",
"governance",
"decisions"
]
},
"kind": {
"description": "Whether the document is maintained present truth (intent) or dated evidence (record). Absent means intent.",
"enum": [
"intent",
"record"
]
},
"date": {
"description": "A record's date, sourced only from valid frontmatter date.",
"pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
"type": "string"
},
"summary": {
"description": "One-line summary of the document, for routing and navigation.",
"type": "string"
},
"tags": {
"description": "Optional free-form tags.",
"type": "array",
"items": {
"type": "string"
}
},
"owners": {
"description": "Optional owners of this document.",
"type": "array",
"items": {
"type": "string"
}
},
"lastModified": {
"description": "ISO 8601 date the document last changed, from version control where available.",
"type": "string",
"pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])([T ].*)?$"
},
"contentHash": {
"description": "Hash of the document's contents, used to detect drift and stable moves.",
"type": "string"
},
"freshness": {
"description": "Review horizon for this document.",
"type": "object",
"additionalProperties": false,
"properties": {
"reviewAfter": {
"description": "ISO 8601 date after which the document should be reviewed for staleness.",
"type": "string",
"pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$"
}
}
},
"links": {
"description": "Optional outbound references from this document.",
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"mounts": {
"description": "Routing records for federated sibling context layers, derived from the manifest's federation.mounts (spec: distribution.md, machine-readable-surface.md). Routing metadata only: tooling MUST NOT copy a sibling's index entries or prose here. A mount record never discloses what the host's audience may not see.",
"type": "array",
"items": {
"type": "object",
"required": [
"name",
"source",
"pin",
"owner"
],
"additionalProperties": false,
"properties": {
"name": {
"description": "The sibling layer's name; matches the name in the sibling's own manifest.",
"type": "string",
"minLength": 1
},
"source": {
"description": "Normalized repository locator of the sibling layer.",
"type": "string",
"minLength": 1
},
"pin": {
"description": "Full immutable commit id (SHA-1 or SHA-256) of the sibling revision the host reads.",
"type": "string",
"pattern": "^([0-9a-f]{40}|[0-9a-f]{64})$"
},
"trackingRef": {
"description": "Fully qualified witness ref reachability and staleness are compared against, when declared.",
"type": "string",
"pattern": "^refs/(heads|tags)/.+$"
},
"owner": {
"description": "The owner of the sibling layer.",
"type": "object",
"required": [
"name"
],
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"contact": {
"type": "string"
}
}
},
"role": {
"description": "Prose description of what the sibling carries.",
"type": "string"
},
"categories": {
"description": "Content-category scopes this sibling can answer for.",
"type": "array",
"items": {
"enum": [
"domain",
"system",
"practice",
"governance",
"decisions"
]
}
},
"topics": {
"description": "Short topic labels for relevance routing.",
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
},
"requiredWhen": {
"description": "Task conditions under which a reader must resolve this mount or fail closed.",
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
}
}
}
}
}
}一份生成的上下文索引,CLI 会在有变更时重新生成它。
{
"$schema": "https://leji.org/schemas/v1.0/context-index.schema.json",
"schemaVersion": "1.0",
"generatedAt": "2026-07-31T12:23:37.412Z",
"generator": {
"name": "leji",
"version": "1.3.1"
},
"rootPath": "docs/",
"entries": [
{
"id": "adopt-leji",
"path": "docs/decisions/0001-adopt-leji.md",
"title": "接入 Leji 上下文层",
"category": "decisions",
"kind": "record",
"date": "2026-06-10",
"lastModified": "2026-06-17",
"contentHash": "sha256:9680ba24ad268894"
},
{
"id": "glossary",
"path": "docs/domain/glossary.md",
"title": "术语表",
"category": "domain",
"kind": "intent",
"summary": "invoice、credit note 和 settlement 在 Acme 的含义。",
"lastModified": "2026-06-17",
"contentHash": "sha256:22d9bcc4fe0ce860"
},
{
"id": "system-invariants",
"path": "docs/system/invariants.md",
"title": "系统不变量",
"category": "system",
"kind": "intent",
"summary": "资金处理、账本仅可追加规则、服务边界。",
"lastModified": "2026-06-17",
"contentHash": "sha256:6e179b4fa71bd5ad",
"freshness": {
"reviewAfter": "2026-12-10"
}
}
]
}