From dda5102340c6827ca553239f6cfdfc6fc951bcf1 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 04:12:51 +0000 Subject: [PATCH 1/2] refactor(metadata-protocol): move parseCommitItems out of protocol.ts into protocol-commit-items.ts Move-only cut 32 of the protocol.ts split. The body of the private parseCommitItems member moves unedited into a new module as a plain function; it reads no class member, so the class method's body calls it directly. CommitPlanItem gains `export` in place so the new module can import it as a type; index.ts does not re-export it. Claude-Session: https://claude.ai/code/session_01L6bhgVaAsaDVwT6XfwB5yk Co-authored-by: Claude --- .../src/protocol-commit-items.ts | 44 +++++++++++++++++++ packages/metadata-protocol/src/protocol.ts | 16 +++---- 2 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 packages/metadata-protocol/src/protocol-commit-items.ts diff --git a/packages/metadata-protocol/src/protocol-commit-items.ts b/packages/metadata-protocol/src/protocol-commit-items.ts new file mode 100644 index 00000000000..b07782fab34 --- /dev/null +++ b/packages/metadata-protocol/src/protocol-commit-items.ts @@ -0,0 +1,44 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * [#25467 cut 32] A stored commit row's `items` column read back as its revert + * plan, from `ObjectStackProtocolImplementation`, moved out of `protocol.ts` + * whole: `parseCommitItems`, which `listPackageCommits` and `revertCommit` + * call. An array is the plan as stored; a string is parsed as JSON; anything + * else, or a string that is not a JSON array, reads as no items. + * + * A MOVE, not a redesign. The function below is the body of the + * `ObjectStackProtocolImplementation` method of the same name as it stood, + * re-indented one level and otherwise unedited. + * + * ## How the moved body reaches the class + * + * The shape #23050 set for `rest-server.ts` (its `data-action-routes.ts` + * header carries the full reasoning), as `protocol-batch-data.ts` applies it. + * The class keeps the method — the published `dist/*.d.ts` lists its name + * and declared signature. The body reads no class member, so the method's + * body calls the plain function, with no host. Every caller keeps calling the + * class method. + * + * The plan item type is `protocol.ts`'s own, and is imported from there as a + * type. Nothing re-exports this module, so the published surface does not + * move. + */ + +import type { CommitPlanItem } from './protocol.js'; + +/** The body of `ObjectStackProtocolImplementation#parseCommitItems`. */ +export function parseCommitItems( + raw: unknown, +): CommitPlanItem[] { + if (Array.isArray(raw)) return raw as CommitPlanItem[]; + if (typeof raw === 'string') { + try { + const p = JSON.parse(raw); + return Array.isArray(p) ? p : []; + } catch { + return []; + } + } + return []; +} diff --git a/packages/metadata-protocol/src/protocol.ts b/packages/metadata-protocol/src/protocol.ts index 3349b4afde5..18b1a6d90eb 100644 --- a/packages/metadata-protocol/src/protocol.ts +++ b/packages/metadata-protocol/src/protocol.ts @@ -427,6 +427,8 @@ import { legacyOrganizationRowsOf, withoutLegacyOrganizationRows } from './proto import { foldObjectExtendersFromRegistry } from './protocol-object-extender-fold.js'; // [#25467 cut 31] The disabled-package face of the by-name item read. import { readMetaItemFace } from './protocol-meta-item-face.js'; +// [#25467 cut 32] A stored commit row's `items` column read back as its revert plan. +import { parseCommitItems } from './protocol-commit-items.js'; /** * Canonical Zod schema per metadata type lives in @@ -2748,7 +2750,7 @@ function mutationEventMember(type: string, member: string | null | undefined): { * timeline serves it on every item of a bundled type, the canonical member * spelled out ({@link ObjectStackProtocolImplementation.listCommits}). */ -type CommitPlanItem = { type: string; name: string; existedBefore: boolean; prevVersion: number | null; member?: string }; +export type CommitPlanItem = { type: string; name: string; existedBefore: boolean; prevVersion: number | null; member?: string }; /** [#22877] The identity of a plan item or a draft within one batch: two members of one name are two. */ function commitPlanKey(item: { type: string; name: string; member?: string }): string { @@ -26479,16 +26481,8 @@ export class ObjectStackProtocolImplementation implements private parseCommitItems( raw: unknown, ): CommitPlanItem[] { - if (Array.isArray(raw)) return raw as CommitPlanItem[]; - if (typeof raw === 'string') { - try { - const p = JSON.parse(raw); - return Array.isArray(p) ? p : []; - } catch { - return []; - } - } - return []; + // [#25467 cut 32] The body moved to `protocol-commit-items.ts`; it reads no member. + return parseCommitItems(raw); } /** From a09398108fec88c52087aad000b5158de8109539 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 04:59:15 +0000 Subject: [PATCH 2/2] docs(metadata-protocol): name listCommits as parseCommitItems' caller in the moved module's header Claude-Session: https://claude.ai/code/session_01L6bhgVaAsaDVwT6XfwB5yk Co-authored-by: Claude --- packages/metadata-protocol/src/protocol-commit-items.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/metadata-protocol/src/protocol-commit-items.ts b/packages/metadata-protocol/src/protocol-commit-items.ts index b07782fab34..410f7ef55d6 100644 --- a/packages/metadata-protocol/src/protocol-commit-items.ts +++ b/packages/metadata-protocol/src/protocol-commit-items.ts @@ -3,9 +3,9 @@ /** * [#25467 cut 32] A stored commit row's `items` column read back as its revert * plan, from `ObjectStackProtocolImplementation`, moved out of `protocol.ts` - * whole: `parseCommitItems`, which `listPackageCommits` and `revertCommit` - * call. An array is the plan as stored; a string is parsed as JSON; anything - * else, or a string that is not a JSON array, reads as no items. + * whole: `parseCommitItems`, which `listCommits` and `revertCommit` call. An + * array is the plan as stored; a string is parsed as JSON; anything else, or a + * string that is not a JSON array, reads as no items. * * A MOVE, not a redesign. The function below is the body of the * `ObjectStackProtocolImplementation` method of the same name as it stood,