An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:recycle: Remove prerelease addressing mode metadata https://github.com/siyuan-note/siyuan/issues/20892
Daniel622362028e74
diff --git a/app/src/config/setting/window.ts b/app/src/config/setting/window.tsindex 82ddabf04f..6ba13e9250 100644--- a/app/src/config/setting/window.ts+++ b/app/src/config/setting/window.ts@@ -173,7 +173,6 @@ const initialize = async () => {return;}window.siyuan.config = systemConfig(response.data.conf);- window.siyuan.documentAddressingVersion = response.data.documentAddressingVersion;window.siyuan.isPublish = response.data.isPublish;await loadDesktopHostConnection();if (!isActive()) return;diff --git a/app/src/editor/rename.test.ts b/app/src/editor/rename.test.tsindex 017ec7fcf5..c769ab4cd6 100644--- a/app/src/editor/rename.test.ts+++ b/app/src/editor/rename.test.ts@@ -8,8 +8,7 @@ test("document titles preserve slash characters while notebook and file names reconst source = transpileModule(readFileSync(path.resolve(__dirname, "rename.ts"), "utf8").replace(/^import [\s\S]*?;\r?\n/gm, "").replace(/^export /gm, ""),{compilerOptions: {target: ScriptTarget.ES2021}}).outputText;- const runtime = {siyuan: {documentAddressingVersion: 2,- languages: {fileNameRule: "Invalid filename", _kernel: {106: "Title too long"}}}};+ const runtime = {siyuan: {languages: {fileNameRule: "Invalid filename", _kernel: {106: "Title too long"}}}};let messages = 0;const methods = new Function("window", "Constants", "showMessage", source + "\nreturn {normalizeDocumentTitle, replaceFileName, validateName};")(runtime, {SIZE_TITLE: 512}, () => messages++);@@ -23,8 +22,6 @@ test("document titles preserve slash characters while notebook and file names reassert.equal(methods.validateName("😀".repeat(512), undefined, true), true);assert.equal(methods.validateName("😀".repeat(513), undefined, true), false);assert.equal(methods.validateName("😀".repeat(512)), false);- runtime.siyuan.documentAddressingVersion = 1;- assert.equal(methods.normalizeDocumentTitle("Old/server"), "Old/server");});test("failed asset rename keeps the dialog open and does not update or reload editors", async () => {diff --git a/app/src/editor/rename.ts b/app/src/editor/rename.tsindex 6afcd07e57..1b3748b905 100644--- a/app/src/editor/rename.ts+++ b/app/src/editor/rename.ts@@ -22,7 +22,7 @@ export const validateName = (name: string, targetElement?: HTMLElement, document}return false;}- const length = documentTitle && window.siyuan.documentAddressingVersion === 2 ? Array.from(name).length : name.length;+ const length = documentTitle ? Array.from(name).length : name.length;if (length > Constants.SIZE_TITLE) {if (targetElement) {showTooltip(window.siyuan.languages["_kernel"]["106"], targetElement, "error");@@ -43,15 +43,11 @@ export const replaceFileName = (name: string) => {};export const truncateDocumentTitle = (name: string) => {- return window.siyuan.documentAddressingVersion === 2 ?- Array.from(name).slice(0, Constants.SIZE_TITLE).join("") : name.substring(0, Constants.SIZE_TITLE);+ return Array.from(name).slice(0, Constants.SIZE_TITLE).join("");};-// 文档标题与文件名分开处理;旧内核保留既有输入规则。+// 文档标题按 Unicode 字符计数,保留字面斜杠。export const normalizeDocumentTitle = (name: string) => {- if (window.siyuan.documentAddressingVersion !== 2) {- return replaceFileName(name);- }return truncateDocumentTitle(name.replace(/\r\n|\r|\n|\u2028|\u2029|\t/g, ""));};diff --git a/app/src/index.ts b/app/src/index.tsindex 0b8f20bc22..87352fd1f5 100644--- a/app/src/index.ts+++ b/app/src/index.ts@@ -339,7 +339,6 @@ export class App {await addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");window.siyuan.config = systemConfig(response.data.conf, () => structuredClone(Constants.SIYUAN_EMPTY_LAYOUT));- window.siyuan.documentAddressingVersion = response.data.documentAddressingVersion;await loadDesktopHostConnection();ensureUILayout();window.siyuan.isPublish = response.data.isPublish;diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.tsindex 8ab5adb2a9..5666c52a2e 100644--- a/app/src/mobile/index.ts+++ b/app/src/mobile/index.ts@@ -224,7 +224,6 @@ class App {await ensureLute({reloadOnFailure: false});addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");window.siyuan.config = systemConfig(confResponse.data.conf);- window.siyuan.documentAddressingVersion = confResponse.data.documentAddressingVersion;window.siyuan.isPublish = confResponse.data.isPublish;applyPlatformClasses();correctHotkey(siyuanApp);diff --git a/app/src/mobile/util/initFramework.test.ts b/app/src/mobile/util/initFramework.test.tsindex fb48f7ba76..dee6a80668 100644--- a/app/src/mobile/util/initFramework.test.ts+++ b/app/src/mobile/util/initFramework.test.ts@@ -19,7 +19,7 @@ test("mobile toolbar saves truncated Unicode titles on blur and Enter without dusetAttribute: (name: string, value: string) => attributes.set(name, value),addEventListener: (name: string, handler: (event?: object) => void) => listeners.set(name, handler),};- const runtime = {siyuan: {documentAddressingVersion: 2, config: {editor: {autoDirection: false}},+ const runtime = {siyuan: {config: {editor: {autoDirection: false}},languages: {fileNameRule: "Invalid filename", _kernel: {16: "Untitled", 106: "Title too long"}},mobile: {editor: {protyle: {notebookId: "box", path: "/root.sy", block: {rootID: "root"}}}}}};const constants = {SIZE_TITLE: 512};@@ -79,13 +79,6 @@ test("mobile toolbar saves truncated Unicode titles on blur and Enter without duassert.equal(requests.length, 5);assert.ok(input.value.includes("\n"));}- runtime.siyuan.documentAddressingVersion = 1;- input.value = "😀".repeat(512);- blur();- assert.equal(requests.length, 5);- assert.equal(input.value, "😀".repeat(256));-- runtime.siyuan.documentAddressingVersion = 2;input.value = "🚀".repeat(513);const keydown = listeners.get("keydown");const event = {key: "Enter", preventDefault: () => {}, stopPropagation: () => {}};diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.tsindex 50e5267047..1c5443e7c5 100644--- a/app/src/mobile/util/initFramework.ts+++ b/app/src/mobile/util/initFramework.ts@@ -461,7 +461,7 @@ const initEditorName = () => {if (!validateName(inputElement.value, undefined, true)) {const original = inputElement.value;inputElement.value = truncateDocumentTitle(inputElement.value);- if (window.siyuan.documentAddressingVersion !== 2 || inputElement.value === original ||+ if (inputElement.value === original ||!validateName(inputElement.value, undefined, true)) {return titleSavePromise;}diff --git a/app/src/protyle/header/Title.test.ts b/app/src/protyle/header/Title.test.tsindex 769719a8f3..c4da6f4fc6 100644--- a/app/src/protyle/header/Title.test.ts+++ b/app/src/protyle/header/Title.test.ts@@ -9,10 +9,8 @@ const compile = (file: string) => transpileModule(readFileSync(resolve(__dirnamecompilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},}).outputText;-const setup = (mode = 2) => {- const runtime = {siyuan: {documentAddressingVersion: 2,- languages: {fileNameRule: "Invalid filename", _kernel: {106: "Title too long"}}}};- runtime.siyuan.documentAddressingVersion = mode;+const setup = () => {+ const runtime = {siyuan: {languages: {fileNameRule: "Invalid filename", _kernel: {106: "Title too long"}}}};const timers = new Map<number, () => void>();const requests: Array<{url: string, data: any}> = [];let timerID = 0;@@ -97,13 +95,3 @@ test("invalid structured titles cancel saving when truncation cannot make them vassert.equal(requests.length, 0);}});--test("legacy title truncation preserves its existing validation behavior", () => {- const {title, timers, requests} = setup(1);- title.editElement.textContent = "😀".repeat(513);- assert.equal(title.rename(title.protyle), false);- assert.equal(title.editElement.textContent, "😀".repeat(256));- title.flushPendingInput();- assert.equal(timers.size, 0);- assert.equal(requests.length, 0);-});diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex 469f50fb37..c76af95dd5 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -353,7 +353,7 @@ export class Title {const offset = getSelectionOffset(this.editElement);this.setTitle(truncateDocumentTitle(this.editElement.textContent));focusByOffset(this.editElement, offset.start, offset.end);- if (window.siyuan.documentAddressingVersion !== 2 || this.editElement.textContent === original ||+ if (this.editElement.textContent === original ||!validateName(this.editElement.textContent, this.editElement, true)) {return false;}diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.tsindex 49696daf38..eff965f975 100644--- a/app/src/types/api/index.d.ts+++ b/app/src/types/api/index.d.ts@@ -1006,11 +1006,11 @@ export type DocVersionRefInput = { "id"?: string | null; "path"?: string | null;export type DocsInfoRequestInput = { "av": boolean; "ids": Array<string>; "refCount": boolean; };-export type DocumentAddressingFailure = { "reason": "invalidTitle" | "parentUnavailable" | "planChanged" | "documentIDConflict" | "legacyPathUnsupported" | "pathAmbiguous" | "indexUnavailable" | "unsupportedTitleFormat" | "targetModeUnsupported" | "modeConflict" | "writeFailed"; };+export type DocumentAddressingFailure = { "reason": "invalidTitle" | "parentUnavailable" | "planChanged" | "documentIDConflict" | "legacyPathUnsupported" | "pathAmbiguous" | "indexUnavailable" | "unsupportedTitleFormat" | "targetModeUnsupported" | "writeFailed"; };-export type DocumentCapabilities = { "addressingVersion": number; "indexState": "missing" | "building" | "ready" | "error"; "literalSlash": boolean; "minimumReaderVersion": string | null; "modeState": "legacy" | "structured" | "conflict" | "recovering"; "revision": string; "structuredPaths": boolean; "titleFormats": Array<string> | null; };+export type DocumentCapabilities = { "indexState": "missing" | "building" | "ready" | "error"; "literalSlash": boolean; "revision": string; "structuredPaths": boolean; "titleFormats": Array<string> | null; };-export type DocumentCreateFailure = { "commitState": "none" | "committed" | "unknown"; "completed": Array<string> | null; "id"?: string; "reason": "invalidTitle" | "parentUnavailable" | "planChanged" | "documentIDConflict" | "indexUnavailable" | "unsupportedTitleFormat" | "modeConflict" | "writeFailed"; "stage": string; };+export type DocumentCreateFailure = { "commitState": "none" | "committed" | "unknown"; "completed": Array<string> | null; "id"?: string; "reason": "invalidTitle" | "parentUnavailable" | "planChanged" | "documentIDConflict" | "indexUnavailable" | "unsupportedTitleFormat" | "writeFailed"; "stage": string; };export type DocumentCreatePlan = { "existingID"?: string; "notebook": string; "steps": Array<CreateDocByParentRequest>; "title": string; };@@ -1028,7 +1028,7 @@ export type DocumentNameCondition = { "expectedID": string | null; "parentID": sexport type DocumentNameConditionInput = { "expectedID": string | null; "parentID": string | null; "title": string; };-export type DocumentPath = { "addressingVersion": number; "depth": number; "displayPath": string; "id": string; "notebook": string; "parentID": string | null; "path": string; "revision": string; "segments": Array<DocumentPathSegment> | null; "title": DocumentTitle; };+export type DocumentPath = { "depth": number; "displayPath": string; "id": string; "notebook": string; "parentID": string | null; "path": string; "revision": string; "segments": Array<DocumentPathSegment> | null; "title": DocumentTitle; };export type DocumentPathSegment = { "empty": boolean; "id": string; "text": string; };@@ -2400,7 +2400,7 @@ export type SystemChangelogRequestInput = { "force"?: boolean | null; };export type SystemCheckUpdateRequestInput = { "showMsg": boolean; };-export type SystemConfData = { "conf": SystemAppConf | null; "documentAddressingVersion": number; "isPublish": boolean; "revision": number; "settingTasks"?: SettingTaskState; "start": boolean; };+export type SystemConfData = { "conf": SystemAppConf | null; "isPublish": boolean; "revision": number; "settingTasks"?: SettingTaskState; "start": boolean; };export type SystemCustomEmojiRequestInput = { "file"?: Blob; "name"?: string; "url"?: string; };@@ -5342,7 +5342,6 @@ export interface APIPOSTRoutes {* 文档 ID 路径检查传入内容及现有源的格式和标题;未知格式或标题冲突返回 -1,原文件和时间保持不变。* 新传入的标题含 ASCII / 时必须声明 Spec >= 6,否则返回 -1 和 document title requires spec 6;已有低 Spec 源仍可读取并由合法内容替换。* 实际文档写入在同一文件锁内重新校验现有源,保留请求字节;附件和插件文件不按文档格式解释。- * 不允许覆盖本机 conf/document-addressing.json,恢复设置时须使用 importConf 的逐身份合并流程。*/"/api/file/putFile": {request: PutFileRequestInput;@@ -6325,14 +6324,11 @@ export interface APIPOSTRoutes {authorization?: readonly ["authenticated","admin","writable"];};/**- * preserves existing configuration and permission filtering. Administrator- * responses also contain documentCapabilities: structuredPaths advertises the ID/segment APIs,- * not permission to open a closed or locked notebook. All notebooks use addressing version 2- * without a user setting or special build flags. literalSlash requires ready indexes. minimumReaderVersion stays null until the minimum compatible- * feature release is verified; it neither controls activation nor permits mixing with older clients.- * Revision identifies the fixed capability declaration, not a document path or retired record.- * Authentication, locking and network failures must- * never be interpreted as an absent capability object or as permission to retry a legacy write.+ * 保留配置与权限过滤;管理员响应包含 documentCapabilities。+ * structuredPaths 声明 ID 与标题段接口支持,literalSlash 仅在 indexState=ready 时为 true。+ * titleFormats 列出支持的标题格式;revision 标识能力声明,不是文档路径或配置版本。+ * 能力声明不授予关闭或锁定笔记本的访问权,也不表示允许与旧客户端混用。+ * 认证、锁定和网络失败不能解释为缺少能力对象,失败后不得回退到旧接口继续写入。*/"/api/notebook/getNotebookConf": {request: CloseNotebookRequestInput;@@ -8237,7 +8233,7 @@ export interface APIPOSTRoutes {* 主题、图标和代码片段内容等独立资源不随设置包迁移,外观资源列表使用目标工作空间的可用资源。* 账号、API token、同步、锁屏密码、数据仓库和加密笔记本密钥保持不变;沿用本机代理及更新通道。* ChatGPT 账户引用从本机工作空间绑定加载,忽略导入文件中的引用;本机绑定读取失败时中止导入。- * documentAddressing 按笔记本身份合并最高要求,缺失字段不清除本机记录;未知或损坏记录在采用设置前返回 -1。+ * 忽略设置备份中的寻址模式记录,不改变笔记本源格式或加密恢复材料。*/"/api/system/importConf": {request: SystemImportConfRequestInput;diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 6184d9de2a..736f3911b1 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -562,7 +562,6 @@ interface INotebook {interface ISiyuan {/** 当前内核的只读文档标题能力,普通构建默认为 2,不持久化为用户设置。 */- documentAddressingVersion?: number;zIndex: numberisReady?: booleanstorage?: {diff --git a/app/src/util/configuredDocument.test.ts b/app/src/util/configuredDocument.test.tsindex ab8f32db76..7f2351f0f8 100644--- a/app/src/util/configuredDocument.test.ts+++ b/app/src/util/configuredDocument.test.ts@@ -10,7 +10,7 @@ const plan = (): DocumentCreatePlan => ({notebook: "box", title: "Title", steps:{notebook: "box", parentID: null, id: "fixed", title: {format: "plain", text: "Title"}, markdown: ""},]});const location = (): DocumentPath => ({notebook: "box", id: "fixed", parentID: null, path: "/fixed.sy", depth: 1,- segments: [], displayPath: "/Title", revision: "saved", addressingVersion: 1,+ segments: [], displayPath: "/Title", revision: "saved",title: {format: "plain", text: "Title", empty: false}});const input: Omit<PlanDocCreateRequestInput, "id"> = {notebook: "box", contextID: null, purpose: "document"};diff --git a/app/src/util/documentCreationPlan.test.ts b/app/src/util/documentCreationPlan.test.tsindex 4dc985de92..bd4683cf36 100644--- a/app/src/util/documentCreationPlan.test.ts+++ b/app/src/util/documentCreationPlan.test.ts@@ -13,7 +13,7 @@ const fixture = (): DocumentCreatePlan => ({const document = (id: string): DocumentPath => ({id, notebook: "notebook", path: `/${id}.sy`, parentID: null, title: {format: "plain", text: id, empty: false},- segments: [], depth: 1, displayPath: `/${id}`, revision: `${id}-revision`, addressingVersion: 1,+ segments: [], depth: 1, displayPath: `/${id}`, revision: `${id}-revision`,});test("the original IDs and committed parent revision are used by the next step", async () => {diff --git a/app/src/window/index.ts b/app/src/window/index.tsindex 9fa8eeb07f..2992c01cbf 100644--- a/app/src/window/index.ts+++ b/app/src/window/index.ts@@ -244,7 +244,6 @@ class App {await addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");window.siyuan.config = systemConfig(response.data.conf, () => structuredClone(Constants.SIYUAN_EMPTY_LAYOUT));- window.siyuan.documentAddressingVersion = response.data.documentAddressingVersion;await loadDesktopHostConnection();ensureUILayout();setBodyHighlight();diff --git a/docs/API.ja.md b/docs/API.ja.mdindex fd0605d0e9..20665c7787 100644--- a/docs/API.ja.md+++ b/docs/API.ja.md@@ -298,7 +298,7 @@ if (response.code === 0 && response.data) {### ノートブック設定を取得-管理者向けレスポンスには、読み取り専用の `documentCapabilities` オブジェクトが含まれる場合があります。アドレス指定モード、構造化 API、タイトル機能、インデックス状態、検証済みの最低互換機能バージョンを示します。通常のビルドでは、設定の切り替えや追加のビルド引数なしに、既定で自動移行されます。`literalSlash` にはモード `2`、整合したモード記録、準備済みインデックスが必要です。この機能に対応する最低バージョンの配布版が検証されるまで、`minimumReaderVersion` は `null` です。このフィールドは情報の提供のみを目的とし、機能の有効化を制御せず、古いクライアントとの混在利用を許可するものでもありません。使用前に、すべての同期端末をこの機能に対応するバージョンへ更新してください。既存の権限によるフィルタリングは維持されます。+管理者向けレスポンスには、読み取り専用の `documentCapabilities` オブジェクトが含まれる場合があります。構造化 API、タイトル形式、インデックス状態、機能宣言のリビジョンを示します。すべてのノートブックで構造化タイトルの規則を使用し、モード設定や移行は不要です。`literalSlash` はインデックスが準備済みの場合にのみ `true` です。使用前に、すべての同期端末をこの機能に対応するバージョンへ更新してください。既存の権限によるフィルタリングは維持されます。* `/api/notebook/getNotebookConf`* パラメータ@@ -331,7 +331,7 @@ if (response.code === 0 && response.data) {}```-管理者への応答には、読み取り専用の省略可能な `documentCapabilities` オブジェクトも含まれます。`structuredPaths` は ID とパス要素の API への対応を示し、閉じたノートブックやロック中のノートブックへのアクセス権限は付与しません。`literalSlash` はモード `2` でモード記録が整合し、インデックスが準備済みの場合に `true` です。この機能に対応する最低バージョンの配布版が検証されるまで、`minimumReaderVersion` は `null` です。このフィールドは情報の提供のみを目的とし、機能の有効化を制御せず、古いクライアントとの混在利用を許可するものでもありません。使用前に、すべての同期端末をこの機能に対応するバージョンへ更新してください。旧サーバーにこのオブジェクトがない場合とリクエストの失敗は区別し、失敗後に従来のパス API で書き込みを再試行しないでください。+管理者への応答には、読み取り専用の省略可能な `documentCapabilities` オブジェクトも含まれます。`structuredPaths` は ID とパス要素の API への対応を示し、閉じたノートブックやロック中のノートブックへのアクセス権限は付与しません。`titleFormats` は対応するタイトル形式、`indexState` はインデックス状態、`revision` は機能宣言のリビジョンを示します。`literalSlash` はインデックスが準備済みの場合にのみ `true` です。使用前に、すべての同期端末をこの機能に対応するバージョンへ更新してください。旧サーバーにこのオブジェクトがない場合とリクエストの失敗は区別し、失敗後に従来のパス API で書き込みを再試行しないでください。### ノートブック設定を保存@@ -1487,9 +1487,7 @@ if (response.code === 0 && response.data) {* `/api/file/putFile`-ノートブックのアドレス指定モードが未対応の場合、ディレクトリの作成、内容の書き込み、更新日時の変更を行う前に `code: -1` を返します。この API ではローカルの機能要件記録 `conf/document-addressing.json` を上書きできません。--ノートブック ID とドキュメント ID で構成される `.sy` ドキュメントパスへの書き込みでは、入力内容と既存のドキュメントを検証します。未知の形式、不正なドキュメントデータ、互換モードと競合するタイトルは `code: -1` を返し、元のファイルと更新日時を保持します。成功時はタイトルを正規化せず、要求されたバイト列をそのまま保存します。アセットやプラグインのディレクトリ内にある `.sy` ファイルはドキュメントとして解析しません。+ノートブック ID とドキュメント ID で構成される `.sy` ドキュメントパスへの書き込みでは、入力内容と既存のドキュメントを検証します。未知の形式、不正なドキュメントデータ、`/` を含むのに必要な Spec 6 が宣言されていないタイトルは `code: -1` を返し、元のファイルと更新日時を保持します。成功時はタイトルを正規化せず、要求されたバイト列をそのまま保存します。アセットやプラグインのディレクトリ内にある `.sy` ファイルはドキュメントとして解析しません。新しく書き込むタイトルに ASCII `/` が含まれる場合、`Spec` は `6` 以上である必要があります。満たさない場合は `code: -1`、`msg: "document title requires spec 6"` を返し、入力内容を自動変更しません。既存の低い Spec のデータは引き続き読み取り可能で、正しいバージョンを指定した内容で置き換えられます。@@ -1513,7 +1511,7 @@ if (response.code === 0 && response.data) {* `/api/file/removeFile`-未対応のアドレス指定モードを使うノートブックの一部を削除すると `code: -1` を返します。ノートブック全体を削除しても、ローカルで確認済みの機能要件は保持されます。`conf/document-addressing.json` またはその親ディレクトリの削除は禁止され、暗号化ノートブックの既存の制限も引き続き適用されます。+削除では、正規パス、機密ファイル、暗号化ノートブックに関する既存の制限を維持します。検証に失敗すると `code: -1` を返します。廃止されたアドレス指定モードの記録は削除の判定に使用しません。* パラメータ```json@@ -1536,7 +1534,7 @@ if (response.code === 0 && response.data) {* `/api/file/renameFile`-移動先ディレクトリの作成やファイルの移動前に、操作全体のノートブックのアドレス指定互換性を検証します。未対応のモード、および `conf/document-addressing.json` の移動や上書きは `code: -1` を返します。+移動先ディレクトリの作成やファイルの移動前に、操作全体の正規パスと移動先のドキュメント形式の互換性を検証します。検証に失敗すると `code: -1` を返し、機密パスと暗号化ノートブックに関する既存の制限も維持します。移動先にノートブック ID とドキュメント ID で構成される `.sy` ドキュメントパスが含まれる場合、対象となるすべての入力ドキュメントも検証します。未知の形式、不正なドキュメントデータ、タイトルの競合は `code: -1` を返し、移動先ディレクトリを作成せず、移動元も変更しません。diff --git a/docs/API.md b/docs/API.mdindex 8c59695adf..237dbbc73a 100644--- a/docs/API.md+++ b/docs/API.md@@ -303,7 +303,7 @@ The close endpoint validates the notebook ID without trimming whitespace. Typed### Get notebook configuration-Administrator responses may also include the read-only `documentCapabilities` object. It reports addressing mode, structured API support, title capabilities, index state, and the verified minimum compatible feature release. Ordinary builds migrate notebooks automatically by default, without a user setting or extra build flags; `literalSlash` requires mode `2`, consistent records, and ready indexes. `minimumReaderVersion` remains `null` until the minimum compatible feature release is verified; this informational field neither controls activation nor permits mixing with older clients. All sync devices must upgrade to versions supporting this feature before use. Existing permission filtering still applies.+Administrator responses may also include the read-only `documentCapabilities` object. It reports structured API support, supported title formats, index readiness and a capability revision. All notebooks follow structured title rules without a mode setting or migration. `literalSlash` is true only when indexes are ready. All sync devices must upgrade to versions supporting this feature before use. Existing permission filtering still applies.* `/api/notebook/getNotebookConf`* Parameters@@ -336,7 +336,7 @@ Administrator responses may also include the read-only `documentCapabilities` ob}```-Administrator responses also include the optional read-only `documentCapabilities` object. `structuredPaths` advertises the ID and segment APIs; it does not grant access to closed or locked notebooks. `literalSlash` is `true` in mode `2` with consistent mode records and ready indexes. `minimumReaderVersion` remains `null` until the minimum compatible feature release is verified; this informational field neither controls activation nor permits mixing with older clients. All sync devices must upgrade to versions supporting this feature before use. An absent object on an older server differs from a failed request; failures must not trigger a fallback write through legacy path APIs.+Administrator responses also include the optional read-only `documentCapabilities` object. `structuredPaths` advertises the ID and segment APIs; it does not grant access to closed or locked notebooks. `titleFormats` lists supported title formats, `indexState` reports readiness and `revision` identifies the capability declaration. `literalSlash` is true only when indexes are ready. All sync devices must upgrade to versions supporting this feature before use. An absent object on an older server differs from a failed request; failures must not trigger a fallback write through legacy path APIs.### Save notebook configuration@@ -1495,9 +1495,7 @@ Block-writing APIs can return after their block-tree transaction is committed bu* `/api/file/putFile`-Unsupported notebook addressing modes return `code: -1` before creating directories, writing content, or changing timestamps. This endpoint cannot overwrite the local `conf/document-addressing.json` capability record.--For `.sy` document paths composed of notebook and document IDs, both the incoming content and any existing document are checked. Unknown formats, invalid document sources, or titles conflicting with compatibility mode return `code: -1`, preserving the original file and modification time. Successful writes retain the request bytes without normalizing titles. Files ending in `.sy` inside asset or plugin directories are not parsed as documents.+For `.sy` document paths composed of notebook and document IDs, both the incoming content and any existing document are checked. Unknown formats, invalid document sources, or slash-containing titles without the required Spec 6 declaration return `code: -1`, preserving the original file and modification time. Successful writes retain the request bytes without normalizing titles. Files ending in `.sy` inside asset or plugin directories are not parsed as documents.An incoming title containing ASCII `/` must declare `Spec` at least `6`; otherwise the endpoint returns `code: -1` and `msg: "document title requires spec 6"` without rewriting the input. Existing lower-spec sources remain readable and can be replaced with valid versioned content.@@ -1521,7 +1519,7 @@ An incoming title containing ASCII `/` must declare `Spec` at least `6`; otherwi* `/api/file/removeFile`-Partial deletion in a notebook with an unsupported addressing mode returns `code: -1`. Whole-notebook deletion retains its locally confirmed capability requirement. Deleting `conf/document-addressing.json` or its parent directory is rejected; existing encrypted-notebook restrictions still apply.+Deletion retains canonical-path, sensitive-file and encrypted-notebook restrictions; validation failures return `code: -1`. Retired addressing-mode records do not control deletion.* Parameters```json@@ -1544,7 +1542,7 @@ Partial deletion in a notebook with an unsupported addressing mode returns `code* `/api/file/renameFile`-The complete move is checked for notebook addressing compatibility before creating the destination directory or moving files. Unsupported modes and attempts to move or overwrite `conf/document-addressing.json` return `code: -1`.+The complete move is checked for canonical paths and destination document-source compatibility before creating the destination directory or moving files. Validation failures return `code: -1`; existing sensitive-path and encrypted-notebook restrictions still apply.When the destination includes `.sy` document paths composed of notebook and document IDs, all incoming documents are also checked. Unknown formats, invalid document sources, or conflicting titles return `code: -1` without creating the destination directory or moving the sources.diff --git a/docs/API.zh-CN.md b/docs/API.zh-CN.mdindex 27b6940db8..d774a6b010 100644--- a/docs/API.zh-CN.md+++ b/docs/API.zh-CN.md@@ -303,7 +303,7 @@ if (response.code === 0 && response.data) {### 获取笔记本配置-管理员响应还可包含只读的 `documentCapabilities` 对象,用于报告寻址模式、结构化接口支持、标题能力、索引状态及已验证的最低兼容功能版本。普通构建默认自动迁移笔记本,无需设置开关或额外编译参数;`literalSlash` 要求模式 `2`、模式记录一致且索引就绪。最低兼容功能发行版尚未验证时,`minimumReaderVersion` 为 `null`;该字段仅提供信息,不控制功能启用,也不表示允许与旧客户端混用。使用前须将所有同步设备统一升级到支持本次功能的版本。既有权限过滤保持不变。+管理员响应还可包含只读的 `documentCapabilities` 对象,用于报告结构化接口支持、标题格式、索引状态和能力摘要。所有笔记本使用结构化标题规则,无需模式设置或迁移;`literalSlash` 仅在索引就绪时为 `true`。使用前须将所有同步设备统一升级到支持本次功能的版本。既有权限过滤保持不变。* `/api/notebook/getNotebookConf`* 参数@@ -336,7 +336,7 @@ if (response.code === 0 && response.data) {}```-管理员响应还包含可选只读对象 `documentCapabilities`。`structuredPaths` 表示服务端支持 ID 与路径段接口,不授予关闭或锁定笔记本的访问权限。`literalSlash` 在模式 `2`、模式记录一致且索引就绪时为 `true`。最低兼容功能发行版尚未验证时,`minimumReaderVersion` 为 `null`;该字段仅提供信息,不控制功能启用,也不表示允许与旧客户端混用。使用前须将所有同步设备统一升级到支持本次功能的版本。旧服务端缺少此对象与请求失败含义不同,不能在请求失败后回退到旧路径接口继续写入。+管理员响应还包含可选只读对象 `documentCapabilities`。`structuredPaths` 表示服务端支持 ID 与路径段接口,不授予关闭或锁定笔记本的访问权限。`titleFormats` 列出支持的标题格式,`indexState` 报告索引状态,`revision` 标识能力声明。`literalSlash` 仅在索引就绪时为 `true`。使用前须将所有同步设备统一升级到支持本次功能的版本。旧服务端缺少此对象与请求失败含义不同,不能在请求失败后回退到旧路径接口继续写入。### 保存笔记本配置@@ -1493,9 +1493,7 @@ if (response.code === 0 && response.data) {* `/api/file/putFile`-笔记本寻址模式不受支持时返回 `code: -1`,不会创建目录、写入内容或更新时间。此接口不能覆盖本机 `conf/document-addressing.json` 能力记录。--写入由笔记本及文档 ID 组成的 `.sy` 文档路径时,同时检查传入内容和已有文档。未知格式、损坏的文档源或标题与兼容模式冲突时返回 `code: -1`,保留原文件及修改时间;成功写入保留请求中的原始字节,不规范化标题。附件或插件目录中的 `.sy` 文件不作为文档解析。+写入由笔记本及文档 ID 组成的 `.sy` 文档路径时,同时检查传入内容和已有文档。未知格式、损坏的文档源或标题含 `/` 但未声明所需的 Spec 6 时返回 `code: -1`,保留原文件及修改时间;成功写入保留请求中的原始字节,不规范化标题。附件或插件目录中的 `.sy` 文件不作为文档解析。新传入的标题含 ASCII `/` 时,必须声明 `Spec` 至少为 `6`,否则返回 `code: -1`、`msg: "document title requires spec 6"`,不自动改写内容。已有低 Spec 源仍可读取,也可以由版本标记合法的内容替换。@@ -1519,7 +1517,7 @@ if (response.code === 0 && response.data) {* `/api/file/removeFile`-笔记本寻址模式不受支持时,部分删除返回 `code: -1`;整本删除保留本机已确认的能力要求。禁止删除 `conf/document-addressing.json` 或其父目录,既有加密笔记本限制继续生效。+删除沿用规范路径、敏感文件和加密笔记本限制,校验失败返回 `code: -1`;已撤销的寻址模式记录不参与删除判定。* 参数```json@@ -1542,7 +1540,7 @@ if (response.code === 0 && response.data) {* `/api/file/renameFile`-创建目标目录或移动文件之前会检查完整操作的笔记本寻址兼容性。不支持的模式,以及移动或覆盖 `conf/document-addressing.json` 的操作,返回 `code: -1`。+创建目标目录或移动文件之前会检查完整操作的规范路径及目标文档源兼容性,校验失败返回 `code: -1`;既有敏感路径和加密笔记本限制继续生效。目标包含由笔记本及文档 ID 组成的 `.sy` 文档路径时,也会预检全部传入文档;未知格式、损坏的文档源或标题冲突返回 `code: -1`,不创建目标目录,也不移动来源。diff --git a/docs/DOCUMENT-ADDRESSING.md b/docs/DOCUMENT-ADDRESSING.mdindex 07d07fa87d..9fe35ff387 100644--- a/docs/DOCUMENT-ADDRESSING.md+++ b/docs/DOCUMENT-ADDRESSING.md@@ -12,7 +12,7 @@ The development branch implements a shared title reader, document metadata organCreation plans retain fixed IDs and never recreate confirmed ancestors. Desktop and mobile share failure handling: an uncertain response or a failure after source commit retains the plan until the user approves an identity check and continuation. Closing or locking a notebook clears its title and template caches. Local shorthands keep a recovery record containing only identities and digests, verify block identities in the actual source before consuming the input, and preserve unresolved input without automatically replaying the operation.-Administrators can read `documentCapabilities` from notebook configuration. The addressing version is fixed at `2`; availability follows index readiness and existing access boundaries. `minimumReaderVersion` is `null`, which does not permit older-client mixed use. Whole-notebook imports still remap notebook and anchor IDs, partial imports retain destination configuration, and encrypted creation targets retain authentication, password-change and backup recovery boundaries.+Administrators can read `documentCapabilities` from notebook configuration. It reports structured API support, title capabilities and index readiness; availability follows existing access boundaries. Whole-notebook imports still remap notebook and anchor IDs, partial imports retain destination configuration, and encrypted creation targets retain authentication, password-change and backup recovery boundaries.All notebooks use structured title rules without a mode switch, mode-1 migration or capability floors. New writes with ASCII `/` in a title use Spec 6; legacy string interfaces check each candidate ancestor chain. Every device must still upgrade together. Default support does not establish release-package, historical-data, performance or platform acceptance; inline-title extension requirements remain unchanged.@@ -99,7 +99,7 @@ Update document metadata and the block-tree document row in the same database tr### Structured path output-`DocumentPath` contains `notebook`, `id`, `parentID`, `path`, `title`, `segments`, `depth`, `displayPath`, `revision`, and `addressingVersion`. `title` is `{format, text, empty}`; `segments` contains `{id, text, empty}` entries from the root through the current document. `displayPath` starts with `/` and joins segments with `/`, displaying `/` for an empty array, for presentation only. The notebook name is returned separately or obtained by the caller, not inserted into the segment array. Here, `title` is a summary, not a complete copy of a future rich source that can be written back.+`DocumentPath` contains `notebook`, `id`, `parentID`, `path`, `title`, `segments`, `depth`, `displayPath`, and `revision`. `title` is `{format, text, empty}`; `segments` contains `{id, text, empty}` entries from the root through the current document. `displayPath` starts with `/` and joins segments with `/`, displaying `/` for an empty array, for presentation only. The notebook name is returned separately or obtained by the caller, not inserted into the segment array. Here, `title` is a summary, not a complete copy of a future rich source that can be written back.An ordinary root document has `depth: 1` and `parentID: null`. With notebook documents enabled, the notebook document has `depth: 0` and empty `segments`; ordinary root documents remain at level one, with no additional physical directory. Passing the notebook document ID as a creation parent is equivalent to the explicit root, retaining the existing logical-root mapping. Root child-name queries exclude the notebook document itself so it cannot be mistaken for an ordinary root document.@@ -317,8 +317,7 @@ Business errors use `code: -1` with a stable `data.reason`. `msg` is for human r| `pathAmbiguous` | Clean and unsupported candidates collide, or a single target has multiple clean matches; select an explicit identity || `indexUnavailable` | Structured metadata is not ready; wait for recovery without falling back to display paths || `unsupportedTitleFormat` | Client or endpoint cannot handle the title format; upgrade or use an endpoint supporting that format |-| `targetModeUnsupported` | The complete move, copy, import, or recovery set exceeds destination capabilities; upgrade the destination and complete automatic recovery before replanning |-| `modeConflict` | Historical error value retained for existing callers; retired addressing modes no longer use it for path ambiguity |+| `targetModeUnsupported` | Source document format validation failed; preserve the source, inspect the reported specification or representation error, and repair or upgrade before replanning the move || `writeFailed` | A write or later processing failed; recover using `commitState` and the reported stage |### Reading the effective creation target@@ -335,9 +334,9 @@ The caller submits each `createDocByParent` request in order, updating the next### Capability discovery-Administrator `getNotebookConf` responses include read-only `documentCapabilities`. `addressingVersion` is always `2`. `modeState` is `structured`, or `recovering` when required indexes are not ready; it never returns `legacy`. The existing `structuredPaths`, `literalSlash`, `titleFormats`, `indexState`, `minimumReaderVersion` and `revision` fields remain. The minimum reader release is `null` until an actual release has been verified, and `literalSlash` is true only with a ready index.+Administrator `getNotebookConf` responses include read-only `documentCapabilities` with `structuredPaths`, `literalSlash`, `titleFormats`, `indexState` and `revision`. `structuredPaths` advertises ID and title-segment APIs; `literalSlash` is true only with a ready index. `indexState` reports `missing`, `building`, `ready` or `error`. All notebooks follow the same structured rules.-Capability reads no longer write migration or floor records. `revision` summarizes the fixed capability declaration, not an individual document path. `getConf.documentAddressingVersion` stays `2` for desktop, browser and mobile input initialization. Existing closed-notebook, lock, publish-access and request-lease restrictions remain; capability metadata grants no additional access.+Capability reads do not write migration or floor records. `revision` summarizes the capability declaration, not an individual document path. Desktop, browser and mobile inputs use the same title rules without a runtime addressing-mode switch. Existing closed-notebook, lock, publish-access and request-lease restrictions remain; capability metadata grants no additional access.### Contract and declaration maintenance@@ -364,7 +363,7 @@ Prefer `resolveDocPath` with independent title segments, `createDocByParent` wit### Coordinated upgrades and older-client risks-Mode 1 is retired. Every notebook follows structured rules without migrating or rewriting document IDs, source files, ciphertext or keys. Ordinary configuration saves write the diagnostic `documentAddressingVersion: 2` marker. Missing notebook configuration or directories no longer cause capability reads to stat missing directories or recreate data.+Mode 1 is retired. Every notebook follows structured rules without migrating or rewriting document IDs, source files, ciphertext or keys. Configuration saves do not generate an addressing-version marker; an existing marker is ignored and omitted on the next ordinary save. Missing notebook configuration or directories do not cause capability reads to stat missing directories or recreate data.New writes with ASCII `/` in a title require at least Spec 6. Retain independent Spec detection, duplicate-property and single entity-decoding checks, and rejection of unknown title representations and future specifications. Supported historical low-Spec slash sources remain readable and recoverable; raw new writes must carry the required specification. Ordinary documents retain the specification required by body features, without bulk upgrades or version downgrades.@@ -414,7 +413,7 @@ Stages A through D are implementation and acceptance groups, not a requirement tRelease gates include migrated built-in consumers, replacement APIs and plugin guidance shipped with the feature, verified existing-data compatibility and format/capability rejection, interruptible ordinary and encrypted index migration, exports that do not overwrite files due to display-path collisions, consistent desktop/browser/mobile behavior, and user guides in all four bundled languages covering default behavior, plugin impact, coordinated upgrades, and the consequences of older-client mixed use. Safe mixed use with older clients is not a supported release scenario.-The implementation allocates `.sy` specification `6`. Performance measurements, compatibility results, and platform acceptance remain release evidence. No separate protective-release number or non-null `minimumReaderVersion` is required for this issue's completion. Any later assignment of a feature-release version must be supported by verification of the actual release and its capabilities. Completing documentation, passing isolated tests, or rebuilding an index once does not establish full feature acceptance.+The implementation allocates `.sy` specification `6`. Performance measurements, compatibility results, and platform acceptance remain release evidence. No separate protective-release number is required for this issue's completion. Feature-release compatibility claims must be supported by verification of the actual release and its capabilities. Completing documentation, passing isolated tests, or rebuilding an index once does not establish full feature acceptance.## Verification and acceptancediff --git a/docs/DOCUMENT-ADDRESSING.zh-CN.md b/docs/DOCUMENT-ADDRESSING.zh-CN.mdindex aeceff2667..83a00ab14a 100644--- a/docs/DOCUMENT-ADDRESSING.zh-CN.md+++ b/docs/DOCUMENT-ADDRESSING.zh-CN.md@@ -12,7 +12,7 @@创建计划采用固定 ID,已确认提交的祖先不会再次创建。桌面与移动端共用失败处理:响应不明或后续处理失败时保留计划,用户确认并按身份核对后才继续;关闭或锁定笔记本清除相应标题和模板缓存。本地速记使用仅含身份和摘要的恢复记录,核对实际源中的块身份后才清理输入,未确认的结果保留原速记并停止自动重放。-管理员读取笔记本配置时可获取 `documentCapabilities`。寻址版本固定为 `2`,可用性由索引状态和现有授权边界决定;`minimumReaderVersion` 为 `null`,不表示允许与旧版混用。原生整本导入继续重映射笔记本和锚点 ID,部分导入保留目标配置;加密目标载荷保持认证、改密及备份恢复边界。+管理员读取笔记本配置时可获取 `documentCapabilities`,用于报告结构化接口支持、标题能力和索引状态;可用性仍受现有授权边界约束。原生整本导入继续重映射笔记本和锚点 ID,部分导入保留目标配置;加密目标载荷保持认证、改密及备份恢复边界。所有笔记本统一采用结构化标题规则,不提供模式开关,不再执行模式 1 迁移或维护能力下界。含 ASCII `/` 的新写入标题使用 Spec 6,旧字符串接口按候选祖先链判断兼容性。所有设备仍须统一升级;默认支持不代替发行包、旧数据、性能及跨端验收。行级标题扩展约束不变。@@ -99,7 +99,7 @@### 结构化路径输出-`DocumentPath` 包含 `notebook`、`id`、`parentID`、`path`、`title`、`segments`、`depth`、`displayPath`、`revision` 和 `addressingVersion`。`title` 为 `{format, text, empty}`,`segments` 按从根到当前文档的顺序包含 `{id, text, empty}`。`displayPath` 以 `/` 开头并用 `/` 连接各段,空段数组显示为 `/`,仅作展示;笔记本名称单独返回或由调用方取得,不混入段数组。这里的 `title` 是标题摘要,不能作为未来富文本源内容的完整副本回写。+`DocumentPath` 包含 `notebook`、`id`、`parentID`、`path`、`title`、`segments`、`depth`、`displayPath` 和 `revision`。`title` 为 `{format, text, empty}`,`segments` 按从根到当前文档的顺序包含 `{id, text, empty}`。`displayPath` 以 `/` 开头并用 `/` 连接各段,空段数组显示为 `/`,仅作展示;笔记本名称单独返回或由调用方取得,不混入段数组。这里的 `title` 是标题摘要,不能作为未来富文本源内容的完整副本回写。普通根文档的 `depth` 为 `1`,`parentID` 为 `null`。启用笔记本文档功能时,笔记本文档本身的 `depth` 为 `0`、`segments` 为空,普通根文档仍为第一级;它不额外增加物理目录。创建时传入笔记本文档 ID 与显式根位置等价,沿用现有逻辑根映射。根位置的子文档名称查询排除笔记本文档自身,避免把它误当成普通根文档。@@ -317,8 +317,7 @@| `pathAmbiguous` | 干净与不兼容候选碰撞,或单目标存在多个干净候选,显式指定身份 || `indexUnavailable` | 结构化元数据未就绪,等待恢复,不回退到显示路径 || `unsupportedTitleFormat` | 客户端或接口不能处理标题格式,升级或改用对应格式接口 |-| `targetModeUnsupported` | 移动、复制、导入或恢复的完整操作集合超出目标支持能力;升级目标并完成自动恢复后重新规划 |-| `modeConflict` | 为既有调用方保留的历史错误值,撤销寻址模式后不再用于路径冲突 |+| `targetModeUnsupported` | 源文档格式校验失败;保留来源,按错误详情检查规格或表示,修复或升级后重新规划移动 || `writeFailed` | 写入或后续处理失败,依据 `commitState` 及阶段恢复 |### 读取有效创建目标@@ -335,9 +334,9 @@### 能力探测-管理员读取 `getNotebookConf` 时获得只读 `documentCapabilities`。`addressingVersion` 恒为 `2`;`modeState` 为 `structured` 或索引未就绪时的 `recovering`,不再返回 `legacy`。保留 `structuredPaths`、`literalSlash`、`titleFormats`、`indexState`、`minimumReaderVersion` 和 `revision` 字段;未验证真实发行包前最低读取版本为 `null`。`literalSlash` 只在索引就绪时为 `true`。+管理员读取 `getNotebookConf` 时获得只读 `documentCapabilities`,包含 `structuredPaths`、`literalSlash`、`titleFormats`、`indexState` 和 `revision`。`structuredPaths` 声明 ID 与标题段接口支持;`literalSlash` 只在索引就绪时为 `true`。`indexState` 报告 `missing`、`building`、`ready` 或 `error`。所有笔记本使用相同的结构化规则。-能力读取不再写入任何迁移或下界记录;`revision` 是固定能力声明的版本摘要,不是某篇文档的路径版本。`getConf.documentAddressingVersion` 继续为 `2`,用于桌面、浏览器和移动端输入初始化。关闭、锁定、发布访问及请求租约继续执行原有规则,能力信息不授予额外权限。+能力读取不写入迁移或下界记录;`revision` 是能力声明的版本摘要,不是某篇文档的路径版本。桌面、浏览器和移动端输入使用相同标题规则,不依赖运行时寻址模式开关。关闭、锁定、发布访问及请求租约继续执行原有规则,能力信息不授予额外权限。### 契约及声明维护@@ -364,7 +363,7 @@### 统一升级与旧版混用风险-模式 1 已撤销,所有笔记本按结构化规则解释,现有文档、ID、密文及密钥不需要迁移或批量改写。`conf.json` 的 `documentAddressingVersion` 在普通配置保存时固定写入 `2`,仅作诊断标记;缺失配置和笔记本目录不会使能力读取触发 syscall 错误或重新创建数据。+模式 1 已撤销,所有笔记本按结构化规则解释,现有文档、ID、密文及密钥不需要迁移或批量改写。配置保存不再生成寻址版本标记,现有标记被忽略,并在下一次普通配置保存时省略;缺失配置和笔记本目录不会使能力读取触发 syscall 错误或重新创建数据。新写入的标题包含 ASCII `/` 时必须声明至少 Spec 6。保留独立的规格检测、重复属性与实体解码校验、未知标题表示及未来 Spec 拒绝。支持的历史低 Spec 斜杠源仍可读取和恢复,原始新写入必须满足规格要求;普通文档保留正文所需规格,不因升级统一变为 Spec 6,也不降低原版本。@@ -414,7 +413,7 @@开放条件包括:所有内置消费者已迁移;替代接口和插件适配文档已发布;当前实现的 Spec 及写入前拒绝检查通过验证;普通与加密索引迁移可中断恢复;导入导出不会因显示路径冲突覆盖文件;桌面、浏览器和移动端行为一致;四种语言的用户指南说明默认行为、插件影响、全部设备统一升级及混用后果。对旧数据及旧协议的回归不构成与旧客户端混用的支持承诺。-实施已分配 `.sy` 规格 `6`;功能版本发布时附上已有性能测量与兼容测试结果,并如实说明验证限制。不再以先发布保护版本或登记其版本号作为本议题的验收前置条件,`minimumReaderVersion` 保留为经实际发行包验证后登记的信息字段。这些是发布证据,不是重新悬置身份、模板、插件边界或失败语义的决策。不能以完成文档、通过隔离测试或一次索引重建代替全部功能验收。+实施已分配 `.sy` 规格 `6`;功能版本发布时附上已有性能测量与兼容测试结果,并如实说明验证限制。不以先发布保护版本或登记其版本号作为本议题的验收前置条件;功能版本的兼容性声明须由实际发行包及其能力验证支持。这些是发布证据,不是重新悬置身份、模板、插件边界或失败语义的决策。不能以完成文档、通过隔离测试或一次索引重建代替全部功能验收。## 验证与验收diff --git a/kernel/api/contract_document_addressing_test.go b/kernel/api/contract_document_addressing_test.goindex 8b31d2742b..f79d7a2b3f 100644--- a/kernel/api/contract_document_addressing_test.go+++ b/kernel/api/contract_document_addressing_test.go@@ -321,7 +321,7 @@ func TestAPIContractDocumentAddressingDocumentCopies(t *testing.T) {func TestAPIContractDocumentAddressingSettingsBackup(t *testing.T) {addressingAPIWorkspace(t)addressingAPIWrite(t, filepath.Join(util.DataDir, addressingAPIBox, ".siyuan", "conf.json"), `{"documentAddressingVersion":3}`)- _ = documentaddressing.CheckBox(util.DataDir, util.ConfDir, addressingAPIBox)+ _ = documentaddressing.CheckBox(addressingAPIBox)recorder := systemContractRequest(t, "POST", "exportConf", exportConf, nil)var response struct {Code intdiff --git a/kernel/api/contract_document_capabilities_test.go b/kernel/api/contract_document_capabilities_test.goindex ed5d1b5e17..f91438a833 100644--- a/kernel/api/contract_document_capabilities_test.go+++ b/kernel/api/contract_document_capabilities_test.go@@ -24,6 +24,11 @@ func TestAPIContractDocumentCapabilities(t *testing.T) {read := func() *apicontract.DocumentCapabilities {t.Helper()data := documentPathAPIRequest(t, "/api/notebook/getNotebookConf", admin, map[string]string{"notebook": boxID})+ for _, field := range []string{"addressingVersion", "modeState", "minimumReaderVersion"} {+ if bytes.Contains(data, []byte(`"`+field+`"`)) {+ t.Fatalf("capabilities retained retired field %s: %s", field, data)+ }+ }var response struct {Code intData apicontract.NotebookConfData@@ -41,15 +46,14 @@ func TestAPIContractDocumentCapabilities(t *testing.T) {if bytes.Contains(public, []byte(`"documentCapabilities"`)) {t.Fatal("configuration permissions were widened by capability discovery")}- if !capabilities.StructuredPaths || capabilities.LiteralSlash || capabilities.AddressingVersion != 2 ||- capabilities.ModeState != "recovering" || capabilities.IndexState != "missing" || capabilities.MinimumReaderVersion != nil ||+ if !capabilities.StructuredPaths || capabilities.LiteralSlash || capabilities.IndexState != "missing" ||len(capabilities.TitleFormats) != 1 || capabilities.TitleFormats[0] != "plain" || capabilities.Revision == "" {t.Fatalf("capabilities claimed an unimplemented or unverified feature: %+v", capabilities)}if err := treenode.SetDocumentMetadataState(boxID, "ready"); err != nil {t.Fatal(err)}- if current := read(); current.IndexState != "ready" || !current.LiteralSlash || current.ModeState != "structured" || current.Revision != capabilities.Revision {+ if current := read(); current.IndexState != "ready" || !current.LiteralSlash || current.Revision != capabilities.Revision {t.Fatalf("ready metadata did not enable structured titles or changed the configuration revision: %+v", current)}name := filepath.Join(util.DataDir, boxID, documentaddressing.FloorPath)@@ -57,7 +61,7 @@ func TestAPIContractDocumentCapabilities(t *testing.T) {if err := os.WriteFile(name, []byte(record), 0600); err != nil {t.Fatal(err)}- if current := read(); current.AddressingVersion != 2 || current.ModeState != "structured" || !current.LiteralSlash || current.Revision != capabilities.Revision {+ if current := read(); current.IndexState != "ready" || !current.LiteralSlash || current.Revision != capabilities.Revision {t.Fatal("retired record changed fixed capabilities", current)}if data, err := os.ReadFile(name); err != nil || string(data) != record {diff --git a/kernel/api/contract_document_path_test.go b/kernel/api/contract_document_path_test.goindex 1155f181ce..b1831cfc28 100644--- a/kernel/api/contract_document_path_test.go+++ b/kernel/api/contract_document_path_test.go@@ -75,6 +75,9 @@ func TestAPIContractDocumentPaths(t *testing.T) {t.Fatal(err)}response = documentPathAPIRequest(t, "/api/filetree/getDocPaths", getDocPaths, request)+ if bytes.Contains(response, []byte(`"addressingVersion"`)) {+ t.Fatalf("document path retained retired addressing version: %s", response)+ }var result struct {Code intData apicontract.DocumentPathsDatadiff --git a/kernel/api/contract_structured_titles_test.go b/kernel/api/contract_structured_titles_test.goindex ac648a9e9b..a36878949d 100644--- a/kernel/api/contract_structured_titles_test.go+++ b/kernel/api/contract_structured_titles_test.go@@ -42,13 +42,13 @@ func TestStructuredTitlesAPIContracts(t *testing.T) {}return response.Data.DocumentCapabilities}- if current := read(); current.AddressingVersion != 2 || current.ModeState != "recovering" || current.LiteralSlash {+ if current := read(); current.IndexState != "missing" || current.LiteralSlash {t.Fatal("missing index was advertised as ready", current)}if err := treenode.SetDocumentMetadataState(box, "ready"); err != nil {t.Fatal(err)}- if current := read(); current.ModeState != "structured" || !current.LiteralSlash || current.MinimumReaderVersion != nil {- t.Fatal("automatic mode was not available", current)+ if current := read(); current.IndexState != "ready" || !current.LiteralSlash {+ t.Fatal("ready index did not enable slash titles", current)}}diff --git a/kernel/api/document_addressing.go b/kernel/api/document_addressing.goindex 9584896202..8c39558811 100644--- a/kernel/api/document_addressing.go+++ b/kernel/api/document_addressing.go@@ -28,7 +28,7 @@ func documentPathContract(document *treenode.DocumentPath) apicontract.DocumentPNotebook: document.Notebook, ID: document.ID, ParentID: document.ParentID, Path: document.Path,Title: apicontract.DocumentTitle{Format: document.Title.Format, Text: document.Title.Text, Empty: document.Title.Empty},Segments: segments, Depth: document.Depth, DisplayPath: document.DisplayPath,- Revision: document.Revision, AddressingVersion: document.AddressingVersion,+ Revision: document.Revision,}}diff --git a/kernel/api/notebook.go b/kernel/api/notebook.goindex d2712b693d..1126c1037e 100644--- a/kernel/api/notebook.go+++ b/kernel/api/notebook.go@@ -318,18 +318,14 @@ var getNotebookConf = contractHandler(apicontract.GetNotebookConf, func(c *gin.Cif !model.IsAdminRoleContext(c) {model.HideBoxConfSecret(boxConf)} else {- snapshot, err := documentaddressing.InspectBox(util.DataDir, util.ConfDir, notebook)+ snapshot, err := documentaddressing.InspectBox(notebook)if err != nil {return apicontract.Failure[apicontract.NotebookConfData](-1, err.Error())}- modeState := snapshot.StateindexState := treenode.DocumentMetadataState(notebook)- if modeState == "structured" && indexState != "ready" {- modeState = "recovering"- }- capabilities = &apicontract.DocumentCapabilities{AddressingVersion: snapshot.Mode,- ModeState: modeState, StructuredPaths: true, LiteralSlash: modeState == "structured", TitleFormats: []string{"plain"},- IndexState: indexState, MinimumReaderVersion: documentaddressing.MinimumReaderVersion(), Revision: snapshot.Revision}+ capabilities = &apicontract.DocumentCapabilities{StructuredPaths: true,+ LiteralSlash: indexState == "ready", TitleFormats: []string{"plain"},+ IndexState: indexState, Revision: snapshot.Revision}}return apicontract.Success(apicontract.NotebookConfData{Box: box.ID, Name: box.Name,diff --git a/kernel/api/system.go b/kernel/api/system.goindex bf261b0867..eba48eb990 100644--- a/kernel/api/system.go+++ b/kernel/api/system.go@@ -39,7 +39,6 @@ import ("github.com/siyuan-note/logging""github.com/siyuan-note/siyuan/kernel/apicontract""github.com/siyuan-note/siyuan/kernel/conf"- "github.com/siyuan-note/siyuan/kernel/documentaddressing""github.com/siyuan-note/siyuan/kernel/model""github.com/siyuan-note/siyuan/kernel/util""golang.org/x/mod/semver"@@ -824,7 +823,7 @@ var getConf = contractHandler(apicontract.SystemGetConf, func(c *gin.Context, rereturn apicontract.Failure[apicontract.SystemConfData](-1, "get conf failed: "+err.Error())}ret = apicontract.Success(apicontract.SystemConfData{Conf: config, Start: !util.IsUILoaded.Load(), IsPublish: isPublish,- SettingTasks: activeSettingTasks(), Revision: revision, DocumentAddressingVersion: documentaddressing.DefaultMode()})+ SettingTasks: activeSettingTasks(), Revision: revision})return})diff --git a/kernel/api/system_test.go b/kernel/api/system_test.goindex 306b9564ac..1919d749d9 100644--- a/kernel/api/system_test.go+++ b/kernel/api/system_test.go@@ -264,6 +264,9 @@ func TestGetConfUILayoutByRole(t *testing.T) {if response.Code != 0 {t.Fatalf("getConf failed: %s", recorder.Body.String())}+ if strings.Contains(recorder.Body.String(), `"documentAddressingVersion"`) {+ t.Fatal("getConf retained the retired addressing switch")+ }for _, sentinel := range sentinels {contains := strings.Contains(recorder.Body.String(), sentinel)diff --git a/kernel/apicontract/contracts.go b/kernel/apicontract/contracts.goindex 79afd41f64..faefc28473 100644--- a/kernel/apicontract/contracts.go+++ b/kernel/apicontract/contracts.go@@ -132,14 +132,11 @@ var ReorderNotebooks = define[ReorderNotebooksRequest, *ReorderData]("reorderNotvar (OpenNotebook = define[OpenNotebookRequest, Null]("openNotebook", "/api/notebook/openNotebook", AuthenticatedAccess|AdminAccess|WritableAccess, JSONBody, ResponseOptions{}, "POST")- // GetNotebookConf preserves existing configuration and permission filtering. Administrator- // responses also contain documentCapabilities: structuredPaths advertises the ID/segment APIs,- // not permission to open a closed or locked notebook. All notebooks use addressing version 2- // without a user setting or special build flags. literalSlash requires ready indexes. minimumReaderVersion stays null until the minimum compatible- // feature release is verified; it neither controls activation nor permits mixing with older clients.- // Revision identifies the fixed capability declaration, not a document path or retired record.- // Authentication, locking and network failures must- // never be interpreted as an absent capability object or as permission to retry a legacy write.+ // GetNotebookConf 保留配置与权限过滤;管理员响应包含 documentCapabilities。+ // structuredPaths 声明 ID 与标题段接口支持,literalSlash 仅在 indexState=ready 时为 true。+ // titleFormats 列出支持的标题格式;revision 标识能力声明,不是文档路径或配置版本。+ // 能力声明不授予关闭或锁定笔记本的访问权,也不表示允许与旧客户端混用。+ // 认证、锁定和网络失败不能解释为缺少能力对象,失败后不得回退到旧接口继续写入。GetNotebookConf = define[CloseNotebookRequest, NotebookConfData]("getNotebookConf", "/api/notebook/getNotebookConf", AuthenticatedAccess, JSONBody, ResponseOptions{}, "POST"))@@ -671,7 +668,6 @@ var CopyFile = define[CopyFileRequest, Null]("copyFile", "/api/file/copyFile", A// 文档 ID 路径检查传入内容及现有源的格式和标题;未知格式或标题冲突返回 -1,原文件和时间保持不变。// 新传入的标题含 ASCII / 时必须声明 Spec >= 6,否则返回 -1 和 document title requires spec 6;已有低 Spec 源仍可读取并由合法内容替换。// 实际文档写入在同一文件锁内重新校验现有源,保留请求字节;附件和插件文件不按文档格式解释。-// 不允许覆盖本机 conf/document-addressing.json,恢复设置时须使用 importConf 的逐身份合并流程。var PutFile = define[PutFileRequest, Null]("putFile", "/api/file/putFile", AuthenticatedAccess|AdminAccess|WritableAccess, FormBody, ResponseOptions{AdditionalCodes: []int{-3, 400, 403, 500}}, "POST")var GetFile = define[FilePathRequest, BinaryContent]("getFile", "/api/file/getFile", AuthenticatedAccess, JSONBody,@@ -1693,7 +1689,7 @@ var SystemGetWorkspaces = define[EmptyRequest, []*SystemWorkspace]("getWorkspace// 主题、图标和代码片段内容等独立资源不随设置包迁移,外观资源列表使用目标工作空间的可用资源。// 账号、API token、同步、锁屏密码、数据仓库和加密笔记本密钥保持不变;沿用本机代理及更新通道。// ChatGPT 账户引用从本机工作空间绑定加载,忽略导入文件中的引用;本机绑定读取失败时中止导入。-// documentAddressing 按笔记本身份合并最高要求,缺失字段不清除本机记录;未知或损坏记录在采用设置前返回 -1。+// 忽略设置备份中的寻址模式记录,不改变笔记本源格式或加密恢复材料。var SystemImportConf = define[SystemImportConfRequest, Null]("importConf", "/api/system/importConf", AuthenticatedAccess|AdminAccess|WritableAccess, MultipartBody, ResponseOptions{Setting: SettingWrite{Namespace: "*"}}, "POST")var SystemImportCustomFont = define[SystemImportFileRequest, *SystemCustomFont]("importCustomFont", "/api/system/importCustomFont", AuthenticatedAccess|AdminAccess|WritableAccess, MultipartBody, ResponseOptions{AdditionalCodes: []int{400, 413}}, "POST")var SystemImportTLSCABundle = define[SystemImportFileRequest, SystemMessageData]("importTLSCABundle", "/api/system/importTLSCABundle", AuthenticatedAccess|AdminAccess|WritableAccess, MultipartBody, ResponseOptions{}, "POST")diff --git a/kernel/apicontract/document_addressing.go b/kernel/apicontract/document_addressing.goindex de4a29fb64..8c0d25131e 100644--- a/kernel/apicontract/document_addressing.go+++ b/kernel/apicontract/document_addressing.go@@ -100,7 +100,7 @@ type CreatedDocumentData struct {}type DocumentCreateFailure struct {- Reason string `json:"reason" api:"enum=invalidTitle|parentUnavailable|planChanged|documentIDConflict|indexUnavailable|unsupportedTitleFormat|modeConflict|writeFailed"`+ Reason string `json:"reason" api:"enum=invalidTitle|parentUnavailable|planChanged|documentIDConflict|indexUnavailable|unsupportedTitleFormat|writeFailed"`CommitState string `json:"commitState" api:"enum=none|committed|unknown"`ID string `json:"id,omitempty" api:"optional"`Stage string `json:"stage"`@@ -143,16 +143,15 @@ type DocumentPathSegment struct {}type DocumentPath struct {- Notebook string `json:"notebook"`- ID string `json:"id"`- ParentID *string `json:"parentID"`- Path string `json:"path"`- Title DocumentTitle `json:"title"`- Segments []DocumentPathSegment `json:"segments"`- Depth int `json:"depth"`- DisplayPath string `json:"displayPath"`- Revision string `json:"revision"`- AddressingVersion int `json:"addressingVersion"`+ Notebook string `json:"notebook"`+ ID string `json:"id"`+ ParentID *string `json:"parentID"`+ Path string `json:"path"`+ Title DocumentTitle `json:"title"`+ Segments []DocumentPathSegment `json:"segments"`+ Depth int `json:"depth"`+ DisplayPath string `json:"displayPath"`+ Revision string `json:"revision"`}type GetDocPathsRequest struct {@@ -199,7 +198,7 @@ type ResolvedDocumentPathData struct {}type DocumentAddressingFailure struct {- Reason string `json:"reason" api:"enum=invalidTitle|parentUnavailable|planChanged|documentIDConflict|legacyPathUnsupported|pathAmbiguous|indexUnavailable|unsupportedTitleFormat|targetModeUnsupported|modeConflict|writeFailed"`+ Reason string `json:"reason" api:"enum=invalidTitle|parentUnavailable|planChanged|documentIDConflict|legacyPathUnsupported|pathAmbiguous|indexUnavailable|unsupportedTitleFormat|targetModeUnsupported|writeFailed"`}type DocumentPathsResult struct {diff --git a/kernel/apicontract/notebook.go b/kernel/apicontract/notebook.goindex d11dac5615..151ec3dc74 100644--- a/kernel/apicontract/notebook.go+++ b/kernel/apicontract/notebook.go@@ -55,14 +55,11 @@ type NotebookConfData struct {}type DocumentCapabilities struct {- AddressingVersion int `json:"addressingVersion"`- ModeState string `json:"modeState" api:"enum=legacy|structured|conflict|recovering"`- StructuredPaths bool `json:"structuredPaths"`- LiteralSlash bool `json:"literalSlash"`- TitleFormats []string `json:"titleFormats"`- IndexState string `json:"indexState" api:"enum=missing|building|ready|error"`- MinimumReaderVersion *string `json:"minimumReaderVersion"`- Revision string `json:"revision"`+ StructuredPaths bool `json:"structuredPaths"`+ LiteralSlash bool `json:"literalSlash"`+ TitleFormats []string `json:"titleFormats"`+ IndexState string `json:"indexState" api:"enum=missing|building|ready|error"`+ Revision string `json:"revision"`}type ImportNotebookCryptoBackupRequest struct {diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.jsonindex d80951b3c9..a970f81498 100644--- a/kernel/apicontract/schema.json+++ b/kernel/apicontract/schema.json@@ -23966,7 +23966,6 @@"indexUnavailable","unsupportedTitleFormat","targetModeUnsupported",- "modeConflict","writeFailed"]}@@ -23979,9 +23978,6 @@"DocumentCapabilities": {"type": "object","properties": {- "addressingVersion": {- "type": "integer"- },"indexState": {"type": "string","enum": [@@ -23994,25 +23990,6 @@"literalSlash": {"type": "boolean"},- "minimumReaderVersion": {- "anyOf": [- {- "type": "string"- },- {- "type": "null"- }- ]- },- "modeState": {- "type": "string",- "enum": [- "legacy",- "structured",- "conflict",- "recovering"- ]- },"revision": {"type": "string"},@@ -24034,11 +24011,8 @@}},"required": [- "addressingVersion","indexState","literalSlash",- "minimumReaderVersion",- "modeState","revision","structuredPaths","titleFormats"@@ -24081,7 +24055,6 @@"documentIDConflict","indexUnavailable","unsupportedTitleFormat",- "modeConflict","writeFailed"]},@@ -24283,9 +24256,6 @@"DocumentPath": {"type": "object","properties": {- "addressingVersion": {- "type": "integer"- },"depth": {"type": "integer"},@@ -24332,7 +24302,6 @@}},"required": [- "addressingVersion","depth","displayPath","id",@@ -53765,9 +53734,6 @@}]},- "documentAddressingVersion": {- "type": "integer"- },"isPublish": {"type": "boolean"},@@ -53783,7 +53749,6 @@},"required": ["conf",- "documentAddressingVersion","isPublish","revision","start"diff --git a/kernel/apicontract/system.go b/kernel/apicontract/system.goindex ee933b31a2..e01de2b0e0 100644--- a/kernel/apicontract/system.go+++ b/kernel/apicontract/system.go@@ -58,11 +58,9 @@ type SystemMessageData struct {Msg string `json:"msg"`}type SystemConfData struct {- // DocumentAddressingVersion 是当前内核的只读能力,普通构建默认为 2,不是持久化配置或可写开关。- DocumentAddressingVersion int `json:"documentAddressingVersion"`- Conf *SystemAppConf `json:"conf"`- Start bool `json:"start"`- IsPublish bool `json:"isPublish"`+ Conf *SystemAppConf `json:"conf"`+ Start bool `json:"start"`+ IsPublish bool `json:"isPublish"`// SettingTasks 为当前仍执行的设置维护任务,前端初始化和重连时恢复任务阻塞。SettingTasks *SettingTaskState `json:"settingTasks,omitempty"`// Revision 是读取开始前的配置提交序号,客户端据此丢弃已包含在本次读取中的通知。diff --git a/kernel/documentaddressing/capabilities.go b/kernel/documentaddressing/capabilities.goindex 98c5b6a896..edf20cd489 100644--- a/kernel/documentaddressing/capabilities.go+++ b/kernel/documentaddressing/capabilities.go@@ -10,8 +10,8 @@ type ModeSnapshot struct {// InspectBox reports the fixed capability without source reads or migration writes.// The API combines this with the independently tracked metadata index state.-func InspectBox(dataDir, confDir, boxID string) (*ModeSnapshot, error) {- mode, err := BoxMode(dataDir, confDir, boxID)+func InspectBox(boxID string) (*ModeSnapshot, error) {+ mode, err := BoxMode(boxID)if err != nil {return nil, err}diff --git a/kernel/documentaddressing/mode.go b/kernel/documentaddressing/mode.goindex 15df92a9a0..c5e255ff0e 100644--- a/kernel/documentaddressing/mode.go+++ b/kernel/documentaddressing/mode.go@@ -20,15 +20,16 @@ var (// BoxMode reports the fixed addressing version without reading or changing any files.// Notebook existence and source authentication belong to the caller's access boundary.-func BoxMode(dataDir, confDir, boxID string) (int, error) {+func BoxMode(boxID string) (int, error) {if !ast.IsNodeIDPattern(boxID) {return 0, ErrInvalid}return DefaultMode(), nil}-func CheckBox(dataDir, confDir, boxID string) error {- _, err := BoxMode(dataDir, confDir, boxID)+// CheckBox 仅校验笔记本 ID 格式,不检查目录、源格式或访问权限。+func CheckBox(boxID string) error {+ _, err := BoxMode(boxID)return err}@@ -61,7 +62,3 @@ func CheckPaths(upserts, removes []string) error {// DefaultMode is the fixed diagnostic addressing version, not a notebook setting.func DefaultMode() int { return 2 }--// MinimumReaderVersion is unset until an actual released reader has been verified.-// A nil value does not permit mixing structured-title notebooks with older clients.-func MinimumReaderVersion() *string { return nil }diff --git a/kernel/documentaddressing/mode_test.go b/kernel/documentaddressing/mode_test.goindex 68145b0f3d..1678439b88 100644--- a/kernel/documentaddressing/mode_test.go+++ b/kernel/documentaddressing/mode_test.go@@ -19,11 +19,11 @@ func TestFixedAddressingVersionDoesNotReadOrWriteRecords(t *testing.T) {t.Fatal(err)}}- mode, err := BoxMode(data, conf, box)- if err != nil || mode != 2 || DefaultMode() != 2 || MinimumReaderVersion() != nil {+ mode, err := BoxMode(box)+ if err != nil || mode != 2 || DefaultMode() != 2 {t.Fatal(mode, err)}- capability, err := InspectBox(data, conf, box)+ capability, err := InspectBox(box)if err != nil || capability.Mode != 2 || capability.State != "structured" {t.Fatal(capability, err)}@@ -41,7 +41,7 @@ func TestFixedAddressingVersionDoesNotReadOrWriteRecords(t *testing.T) {}}}- if _, err := BoxMode(data, conf, "../invalid"); err == nil {+ if _, err := BoxMode("../invalid"); err == nil {t.Fatal("invalid notebook identity accepted")}}diff --git a/kernel/filesys/document_addressing.go b/kernel/filesys/document_addressing.goindex f83df0e25e..b47b9d5446 100644--- a/kernel/filesys/document_addressing.go+++ b/kernel/filesys/document_addressing.go@@ -6,19 +6,18 @@ import ("github.com/88250/lute/parse""github.com/siyuan-note/siyuan/kernel/documentaddressing""github.com/siyuan-note/siyuan/kernel/treenode"- "github.com/siyuan-note/siyuan/kernel/util")-// CheckDocumentAddressing 在读取缓存或修改笔记本源数据之前检查寻址能力。+// CheckDocumentAddressing 仅校验笔记本 ID 格式;访问权限、源格式与认证由调用方检查。func CheckDocumentAddressing(boxID string) error {- return documentaddressing.CheckBox(util.DataDir, util.ConfDir, boxID)+ return documentaddressing.CheckBox(boxID)}func DocumentAddressingMode(boxID string) (int, error) {if boxID == "" {return documentaddressing.DefaultMode(), nil}- return documentaddressing.BoxMode(util.DataDir, util.ConfDir, boxID)+ return documentaddressing.BoxMode(boxID)}func CheckDocumentSpecJSON(boxID string, data []byte) error {diff --git a/kernel/model/box.go b/kernel/model/box.goindex 3ca575bf62..fc11d68c17 100644--- a/kernel/model/box.go+++ b/kernel/model/box.go@@ -18,7 +18,6 @@ package modelimport ("bytes"- "encoding/json""errors""fmt""io/fs"@@ -360,13 +359,6 @@ func (box *Box) saveConf(conf *conf.BoxConf, syncChange bool) error {return fmt.Errorf("prepare box conf [%s] failed: %w", confPath, err)}newData, err := gulu.JSON.MarshalIndentJSON(persisted, "", " ")- if err == nil {- var fields map[string]json.RawMessage- if err = json.Unmarshal(newData, &fields); err == nil {- fields["documentAddressingVersion"] = json.RawMessage("2")- newData, err = json.MarshalIndent(fields, "", " ")- }- }if err != nil {return fmt.Errorf("marshal box conf [%s] failed: %w", confPath, err)}diff --git a/kernel/model/document_legacy_cleanup_test.go b/kernel/model/document_legacy_cleanup_test.goindex 7345c030ac..b9936d71cd 100644--- a/kernel/model/document_legacy_cleanup_test.go+++ b/kernel/model/document_legacy_cleanup_test.go@@ -1,10 +1,12 @@package modelimport (+ "bytes""encoding/json""os""path/filepath""testing"+ "time""github.com/siyuan-note/siyuan/kernel/documentaddressing""github.com/siyuan-note/siyuan/kernel/util"@@ -34,16 +36,46 @@ func TestRetiredDocumentAddressingCleanupRespectsReadOnly(t *testing.T) {}}-func TestFixedDocumentAddressingMarkerPersists(t *testing.T) {+func TestRetiredDocumentAddressingMarkerIsNotPersisted(t *testing.T) {fixture := setupFileOperationTest(t)name := filepath.Join(util.DataDir, fixture.box.ID, documentaddressing.ConfigPath)configuration := fixture.box.GetConf()- if err := fixture.box.SaveConf(configuration); err != nil {+ data, err := os.ReadFile(name)+ if err != nil {t.Fatal(err)}var fields map[string]json.RawMessage- data, err := os.ReadFile(name)- if err != nil || json.Unmarshal(data, &fields) != nil || string(fields["documentAddressingVersion"]) != "2" {- t.Fatal("configuration lost fixed addressing marker", err)+ if err = json.Unmarshal(data, &fields); err != nil {+ t.Fatal(err)+ }+ fields["documentAddressingVersion"] = json.RawMessage("999")+ data, err = json.Marshal(fields)+ if err != nil {+ t.Fatal(err)+ }+ if err = os.WriteFile(name, data, 0600); err != nil {+ t.Fatal(err)+ }+ if err := fixture.box.SaveConf(configuration); err != nil {+ t.Fatal(err)+ }+ data, err = os.ReadFile(name)+ fields = nil+ if err != nil || json.Unmarshal(data, &fields) != nil || fields["documentAddressingVersion"] != nil {+ t.Fatal("configuration retained retired addressing marker", err)+ }+ modified := time.Unix(1700000000, 0)+ if err = os.Chtimes(name, modified, modified); err != nil {+ t.Fatal(err)+ }+ if err = fixture.box.SaveConf(configuration); err != nil {+ t.Fatal(err)+ }+ after, err := os.ReadFile(name)+ if err != nil || !bytes.Equal(data, after) {+ t.Fatal("unchanged save changed configuration bytes", err)+ }+ if info, err := os.Stat(name); err != nil || !info.ModTime().Equal(modified) {+ t.Fatal("unchanged save rewrote configuration", err)}}diff --git a/kernel/model/structured_titles_test.go b/kernel/model/structured_titles_test.goindex 9888bd263f..625dbb6b17 100644--- a/kernel/model/structured_titles_test.go+++ b/kernel/model/structured_titles_test.go@@ -47,7 +47,7 @@ func TestStructuredTitlesCreationAndIdentity(t *testing.T) {t.Helper()ret, err := CreateDocByParent(DocumentCreateRequest{Notebook: box.ID, ParentID: parent, ID: ast.NewNodeID(),TitleFormat: "plain", Title: title, Markdown: "body"})- if err != nil || ret.Title.Text != title || ret.AddressingVersion != 2 {+ if err != nil || ret.Title.Text != title {t.Fatalf("create %q: %+v %v", title, ret, err)}return retdiff --git a/kernel/model/structured_titles_upgrade_test.go b/kernel/model/structured_titles_upgrade_test.goindex 2cc9c850d9..82b7bee8d7 100644--- a/kernel/model/structured_titles_upgrade_test.go+++ b/kernel/model/structured_titles_upgrade_test.go@@ -110,7 +110,7 @@ func TestStructuredTitlesReleasedDataUpgradeAndRestart(t *testing.T) {if err != nil {t.Fatal(err)}- if err = documentaddressing.CheckBox(util.DataDir, util.ConfDir, box); err != nil {+ if err = documentaddressing.CheckBox(box); err != nil {t.Fatal(err)}after, err := os.ReadFile(configPath)@@ -243,10 +243,10 @@ func TestStructuredTitlesSyncAndSnapshotKeepFixedCapabilities(t *testing.T) {assertUpgraded := func() {t.Helper()for box := range boxes {- if err := documentaddressing.CheckBox(receiver.DataPath, util.ConfDir, box); err != nil {+ if err := documentaddressing.CheckBox(box); err != nil {t.Fatal(err)}- snapshot, err := documentaddressing.InspectBox(receiver.DataPath, util.ConfDir, box)+ snapshot, err := documentaddressing.InspectBox(box)if err != nil || snapshot.Mode != 2 {t.Fatal("sync or snapshot changed the fixed addressing version", snapshot, err)}diff --git a/kernel/treenode/document_metadata.go b/kernel/treenode/document_metadata.goindex 807d17a29a..624f81a0a6 100644--- a/kernel/treenode/document_metadata.go+++ b/kernel/treenode/document_metadata.go@@ -38,16 +38,15 @@ type DocumentPathSegment struct {// DocumentPath 的标题与段落边界来自同一个数据库快照,displayPath 仅用于展示。type DocumentPath struct {- Notebook string `json:"notebook"`- ID string `json:"id"`- ParentID *string `json:"parentID"`- Path string `json:"path"`- Title DocumentTitle `json:"title"`- Segments []DocumentPathSegment `json:"segments"`- Depth int `json:"depth"`- DisplayPath string `json:"displayPath"`- Revision string `json:"revision"`- AddressingVersion int `json:"addressingVersion"`+ Notebook string `json:"notebook"`+ ID string `json:"id"`+ ParentID *string `json:"parentID"`+ Path string `json:"path"`+ Title DocumentTitle `json:"title"`+ Segments []DocumentPathSegment `json:"segments"`+ Depth int `json:"depth"`+ DisplayPath string `json:"displayPath"`+ Revision string `json:"revision"`}func ensureDocumentMetadata(database *sql.DB) error {@@ -334,7 +333,7 @@ func documentPathInTx(tx *sql.Tx, boxID, id, notebookDocumentID string, mode int}leaf := chain[0]ret := &DocumentPath{Notebook: boxID, ID: id, ParentID: leaf.ParentID, Path: leaf.Path, Title: leaf.Title,- Segments: []DocumentPathSegment{}, AddressingVersion: mode}+ Segments: []DocumentPathSegment{}}var texts, revisions []stringfor i := len(chain) - 1; i >= 0; i-- {meta := chain[i]