Skip to content

Commit a705be0

Browse files
refactor(service-knowledge)!: retire SPLIT_ALGORITHM_VERSION (#38452)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XPpqjfjwZCAyAm71ZUE2yhz)_ Fixes #38377 Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no published skill, doc page or example names the retired constant (git grep over `skills`, `content/docs`, `docs`, `examples`, `apps`, `ui`, `.claude` at 4fa2f8e: 0 hits); the ADR text is item 2, carried by the lander ## 维护者速读 - 用户能看到什么变化:用户无感;只有直接引用知识服务包里那个旧常量的宿主代码,升级后编译会提示删掉这行引用。 - 为什么做:知识平台「切分版本按策略计」之后的收尾,撤掉一个已经没有任何运行代码读取的公开常量,免得作者和 AI 以为改它有效。 - 出错会怎样:最坏是某个宿主仍引用它而编译失败,删掉那行引用即可;可直接撤回本改动,不会触发任何索引重建。 - 要你做的:无。 ## What changes `SPLIT_ALGORITHM_VERSION` leaves `@objectstack/service-knowledge` at once, with no alias (the card's stage posture). Since the per-strategy split version landed, the index fingerprint (ADR-0161 K7) reads `SPLIT_ALGORITHM_VERSION_BY_STRATEGY` for the source's resolved strategy, and the global constant was read by no runtime code. - `src/split/splitter.ts`: the constant and its docblock are deleted. The per-strategy table's docblock linked to it ("Every entry started at" the constant); it now says every entry started at 1, the one split version the fingerprint read before the table, which names no retired symbol and stays true. - `src/split/index.ts`, `src/index.ts`: both re-exports are deleted. - `src/__tests__/index-fingerprint.test.ts`: the version pin keeps the two remaining constants (`INDEX_FINGERPRINT_VERSION`, `ASSEMBLY_RULE_VERSION`), and a new case pins the retirement: neither the split barrel nor the package entry has the property, with a positive control on the entry. - Area-ordered additions (the sibling split card's L2 nit, comment text only, no assertion, value or snapshot changed): two comments now name both changes `markdown` version 2 carries, the body-less heading as its own passage and a fitting section as one passage whatever `minChars` is. One is the `markdown: 2` entry comment in `SPLIT_ALGORITHM_VERSION_BY_STRATEGY` (`splitter.ts`); the other is the `PINNED` docblock in `index-fingerprint.test.ts`. The second clause is true only once PR #38439 merges; the seat lands this PR after it. The table's docblock does not tie version 2 to one change, so it needed no edit. - `.changeset/38377-retire-split-algorithm-version.md`: `patch` (kind `none`), BREAKING banner, FROM/TO table, a sentence saying this retirement replaces the still-pending 38349 changeset's note that the constant keeps its name and value (that changeset is not edited), ADR-0087 disposition `not-required (runtime-export-retired @objectstack/service-knowledge#SPLIT_ALGORITHM_VERSION)`. Item 2 of the card (the ADR-0161 K7 revisions row) is not in this PR: no `docs/adr/**` edit. The landing seat appends it to the weekly ADR revisions card (`carrier:` PR #38375). `Fixes` stays because that row is landing bookkeeping. Landing: a narrowing of a published surface. It owes one contract-review-tier L2 on its final head before the queue. Read first: (1) `src/split/splitter.ts` — the reworded docblock is the only prose a reader of the table keeps; (2) the changeset — it ships as the CHANGELOG line an upgrader greps; (3) the new test case. Two-minute check: `pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/index-fingerprint.test.ts` — expect 9 tests passing, including "publishes no global split version beside the per-strategy table". ## Tests Package suite at `f76ba9c9`. At `987b09ca`, the last commit that touched code or tests, `index-fingerprint.test.ts` alone under the verify lock: Test Files 1 passed (1), Tests 9 passed (9), VERDICT command-exit 0. <details><summary>service-knowledge test + typecheck (lock VERDICT command-exit 0)</summary> ``` pnpm --filter @objectstack/service-knowledge test Test Files 21 passed (21) Tests 727 passed (727) pnpm --filter @objectstack/service-knowledge typecheck check:test-typecheck: OK, the test layer compiles under tsconfig.test.json; 0 file(s) / 0 error(s) held in test-typecheck-debt.json ``` </details> <details><summary>Ablation of the new retirement pin</summary> With `export const SPLIT_ALGORITHM_VERSION = 1;` appended to `src/index.ts` on disk, `index-fingerprint.test.ts` went red: `publishes no global split version beside the per-strategy table` failed with `expected ... to not have property "SPLIT_ALGORITHM_VERSION"` (1 failed, 8 passed). Restored with `git checkout HEAD`, tree clean. </details> <details><summary>Full dogfood (the narrowing arm), at `4fa2f8ee`</summary> `pnpm turbo run build --filter='@objectstack/dogfood^...'` then `pnpm --filter @objectstack/dogfood test` under the verify lock: VERDICT command-exit 0, Test Files 495 passed, 3 skipped (498), Tests 4183 passed, 68 skipped (4251). `987b09ca` differs from `4fa2f8ee` by comments only (`git diff --stat 4fa2f8e..HEAD`: 2 files changed, 4 insertions, 1 deletion; one hunk in `splitter.ts`, one in `index-fingerprint.test.ts`, both comment lines). The final head `42214359` adds one changeset sentence. So the battery was not re-run. </details> ## Acceptance notes - Whole-tree search before deleting, at `d751790c`: `git grep -n 'SPLIT_ALGORITHM_VERSION\b'` gave 13 lines. 5 were the declaration, the two re-exports and the pin's import and assertion (all removed here); 1 was the per-strategy docblock link (reworded); the other 7 are history: `.changeset/38349-split-version-per-strategy.md`, `.changeset/pre/37100-knowledge-pgvector.md` and five generated `CHANGELOG.md` files. They are left alone: existing changesets are never edited, and CHANGELOGs are release-owned. No `skills`, `content/docs`, `docs`, `examples`, `apps`, `ui` or `.claude` hit. - The package has no API-surface baseline, so no generator was owed. ## Verification <details><summary>Local gates (derived with dispatch-gates --commands, reconciled with --ran: 63 derived, 63 run)</summary> - 60 of 63 exited 0 on the first pass. - `node scripts/check-adr-0087-registration.mjs --base origin/main` exit 1 on `0c4609e7` (the FROM column spelled an import statement, not the operand); after the fix, exit 0 on `4fa2f8ee`: `not-required (runtime-export-retired) -- verified: @objectstack/service-knowledge#SPLIT_ALGORITHM_VERSION`. - `node scripts/check-plugin-teardown-shape.mjs --self-test` exit 3 (shallow clone could not reach its pinned fixture commit); after fetching that commit, exit 0, 48 cases pass. - `pnpm check:dual-build-cjs-loads` exit 3, PREREQUISITE NOT MET (needs every package built). NOT MEASURED locally, CI runs it. - Re-run at `4fa2f8ee` after the changeset fix: check-changeset-no-major, check-empty-changeset, check:changeset-gate-self-tests, check:nul-bytes, check:doc-authoring, check:issue-citations: all exit 0. check:nul-bytes exit 0 again at `f76ba9c9` and at `987b09ca`. At `42214359` (changeset sentence only), check-adr-0087-registration, check-changeset-no-major, check-empty-changeset and check:nul-bytes: all exit 0. - `node scripts/check-platform-checklist.mjs --changed-from origin/main` exit 0: 0 anchored files in the change set. - `node scripts/pm/overlap-check.mjs` before each push: clean; at `f76ba9c9`, `987b09ca` and `42214359` it also merges cleanly with PR #38439. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5omA3kZCsWzBMMqF11 <!-- signed: repo:objectstack#5 · os-project-manager · session_01FEkQ5omA3kZCsWzBMMqF11 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 16f132f commit a705be0

5 files changed

Lines changed: 44 additions & 18 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@objectstack/service-knowledge': patch
3+
---
4+
5+
refactor(service-knowledge)!: `SPLIT_ALGORITHM_VERSION` is retired — the index fingerprint reads the split version per strategy
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (runtime-export-retired @objectstack/service-knowledge#SPLIT_ALGORITHM_VERSION) the retired operand is a numeric constant of the package's published entry that no runtime code reads; no packages/spec schema, no registered node type, no ADR-0087 conversion surface and no stored shape names it, so there is nothing for `objectstack migrate meta` to rewrite, and a host still importing it is told by its own compiler -->
11+
12+
**BREAKING** for a host that imports `SPLIT_ALGORITHM_VERSION` from `@objectstack/service-knowledge`. It leaves at once, with no alias. The index fingerprint (ADR-0161 K7) stopped reading it when the split version became per strategy: each strategy (`whole`, `recursive`, `markdown`) carries its own version inside the splitter, and the fingerprint reads the version of the source's resolved strategy. The constant changed nothing a host could observe, and bumping it rebuilt nothing.
13+
14+
This retirement replaces the earlier note in this same release that `SPLIT_ALGORITHM_VERSION` keeps its name and its value: it is removed.
15+
16+
No fingerprint changes and no index is rebuilt when this lands.
17+
18+
## What leaves, and what to write instead
19+
20+
| FROM | TO |
21+
|:--|:--|
22+
| `SPLIT_ALGORITHM_VERSION` | delete the import from `@objectstack/service-knowledge`; to tell whether a stored index is current, compare its fingerprint with `computeIndexFingerprint` or `indexExpectation`, which read the per-strategy version |
23+
24+
What to do: delete the import where a host has one. Nothing else.

‎packages/services/service-knowledge/src/__tests__/index-fingerprint.test.ts‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import {
1616
computeIndexFingerprint,
1717
computeRecipeHash,
1818
} from '../knowledge-index-fingerprint.js';
19-
import { SPLIT_ALGORITHM_VERSION, SPLIT_ALGORITHM_VERSION_BY_STRATEGY, resolveSplit } from '../split/index.js';
19+
import * as splitBarrel from '../split/index.js';
20+
import { SPLIT_ALGORITHM_VERSION_BY_STRATEGY, resolveSplit } from '../split/index.js';
21+
import * as packageEntry from '../index.js';
2022

2123
const source = (extra: Record<string, unknown> = {}): KnowledgeSource =>
2224
({
@@ -35,7 +37,8 @@ const split = splitFor('markdown');
3537
* The fingerprint of `source()` under `embedding`, per resolved strategy.
3638
* `whole`, `recursive` and no split stand as they did under one global split
3739
* version; `markdown` is at its version 2 (a heading with no body is a
38-
* passage of its own), and {@link MARKDOWN_V1} is the value it moved from.
40+
* passage of its own, and a section that fits the bounds is one passage
41+
* whatever `minChars` is), and {@link MARKDOWN_V1} is the value it moved from.
3942
*/
4043
const PINNED = {
4144
whole: 'fp1:02171c5bcf94ff5d951de321a1a7206b059e684e094d329c9674309d7e472ce3',
@@ -50,7 +53,7 @@ const MARKDOWN_V1 = 'fp1:1455ed0d278a0e58b26ccc2d423298c29d65162125032d76453847f
5053

5154
describe('index fingerprint (ADR-0161 K7)', () => {
5255
it('is pinned for a fixed input', () => {
53-
expect([INDEX_FINGERPRINT_VERSION, SPLIT_ALGORITHM_VERSION, ASSEMBLY_RULE_VERSION]).toEqual(['fp1', 1, 1]);
56+
expect([INDEX_FINGERPRINT_VERSION, ASSEMBLY_RULE_VERSION]).toEqual(['fp1', 1]);
5457
expect(SPLIT_ALGORITHM_VERSION_BY_STRATEGY).toEqual({ whole: 1, recursive: 1, markdown: 2 });
5558
expect(Object.isFrozen(SPLIT_ALGORITHM_VERSION_BY_STRATEGY)).toBe(true);
5659
expect(computeIndexFingerprint({ source: source(), embedding, split })).toBe(
@@ -59,6 +62,15 @@ describe('index fingerprint (ADR-0161 K7)', () => {
5962
expect(computeIndexFingerprint({ source: source(), embedding, split })).toMatchInlineSnapshot(`"fp1:08c130e59628942ccc73bee1ac654a37fb09b6368e3807467998bb2cf0ac9727"`);
6063
});
6164

65+
// The one global split version is retired, at once and with no alias: the
66+
// per-strategy table above is the only split version the fingerprint reads,
67+
// so neither the split barrel nor the package entry publishes another.
68+
it('publishes no global split version beside the per-strategy table', () => {
69+
expect(splitBarrel).not.toHaveProperty('SPLIT_ALGORITHM_VERSION');
70+
expect(packageEntry).not.toHaveProperty('SPLIT_ALGORITHM_VERSION');
71+
expect(packageEntry).toHaveProperty('INDEX_FINGERPRINT_VERSION', 'fp1');
72+
});
73+
6274
// The values the fingerprint had while one global split version was read:
6375
// the per-strategy table starts every strategy at that version, so no
6476
// stored index reads as built under another fingerprint when it lands.

‎packages/services/service-knowledge/src/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export {
2020
indexExpectation,
2121
} from './knowledge-index-fingerprint.js';
2222
export type { IndexFingerprintInput, RecipeHashInput } from './knowledge-index-fingerprint.js';
23-
export { SPLIT_ALGORITHM_VERSION } from './split/index.js';
2423
export {
2524
SEARCH_KNOWLEDGE_DEFAULT_TOP_K,
2625
SEARCH_KNOWLEDGE_MAX_TOP_K,

‎packages/services/service-knowledge/src/split/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
export {
44
DEFAULT_SPLIT_MAX_CHARS,
55
DEFAULT_SPLIT_MIN_CHARS,
6-
SPLIT_ALGORITHM_VERSION,
76
SPLIT_ALGORITHM_VERSION_BY_STRATEGY,
87
SPLIT_TOKEN_BUDGET_SHARE,
98
resolveSplit,

‎packages/services/service-knowledge/src/split/splitter.ts‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,6 @@ export const DEFAULT_SPLIT_MIN_CHARS = 200;
6161
/** The share of the embedder's input limit a passage may fill, by `estimateTokens`. */
6262
export const SPLIT_TOKEN_BUDGET_SHARE = 0.8;
6363

64-
/**
65-
* The version every split strategy started at (ADR-0161 K7). The index
66-
* fingerprint no longer reads it: each strategy carries its own version, in
67-
* the splitter's per-strategy table (not published), so a change to one
68-
* strategy's passages rebuilds only the sources that resolve to that strategy.
69-
* Kept, at its value, because the package publishes it; bumping it rebuilds
70-
* nothing.
71-
*/
72-
export const SPLIT_ALGORITHM_VERSION = 1;
73-
7464
/**
7565
* The version of this splitter's algorithm, per strategy. The index
7666
* fingerprint's split algorithm version (ADR-0161 K7) is the entry for the
@@ -84,15 +74,17 @@ export const SPLIT_ALGORITHM_VERSION = 1;
8474
*
8575
* A change shared by several strategies (`markdown` cuts each section as
8676
* `recursive` does) bumps every strategy whose passages it changes. Every
87-
* entry started at {@link SPLIT_ALGORITHM_VERSION}, so introducing this table
88-
* changed no fingerprint. Typed over every strategy, so a new strategy cannot
89-
* reach the fingerprint without a version.
77+
* entry started at 1, the one split version the fingerprint read before this
78+
* table, so introducing it changed no fingerprint. Typed over every strategy,
79+
* so a new strategy cannot reach the fingerprint without a version.
9080
*/
9181
export const SPLIT_ALGORITHM_VERSION_BY_STRATEGY: Readonly<Record<KnowledgeSplitStrategy, number>> = Object.freeze({
9282
whole: 1,
9383
recursive: 1,
9484
// 2: a heading with no text and no descendant after it is a passage of its
9585
// own, under its own path; it was carried into the next section as a line.
86+
// And a section that fits the bounds is one passage, whatever `minChars`
87+
// is; it was cut as `recursive` cuts and its pieces merged up to `minChars`.
9688
markdown: 2,
9789
});
9890

0 commit comments

Comments
 (0)