Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
4001a5c
feat(scripts): codemod-split-registry, the registry.ts split as a re-…
claude Nov 15, 2026
6a0c994
refactor(objectql): split registry.ts into section modules by codemod…
claude Nov 15, 2026
0edc440
test(objectql): re-key the injected-column reader rows the registry s…
claude Nov 15, 2026
cee244c
chore(objectql): register SchemaRegistry as a facade, and the registr…
claude Nov 15, 2026
29dc77d
fix(scripts): codemod-split-registry keeps the ADR-anchored declarati…
claude Nov 15, 2026
c3015a9
Merge commit '86350e125d5773af80fee702766ef19447294557' into claude/a…
claude Nov 15, 2026
66b07ca
refactor(objectql): regenerate the registry split against fresh main
claude Nov 15, 2026
c92a4d3
fix(scripts): codemod-split-registry keeps REGISTRY_LOG_LEVELS where …
claude Nov 15, 2026
3683e1e
test(objectql): the tenant-index row stays keyed to registry.ts, wher…
claude Nov 15, 2026
5371214
merge origin/main 571cf9082a into the registry split
claude Nov 16, 2026
fc1f4b5
docs(changeset): the registry split changeset cites the count on fres…
claude Nov 16, 2026
5950858
merge origin/main 98a4449f87 into the registry split, and regenerate …
claude Nov 16, 2026
c27f4ab
merge origin/main f9120b8692 into the registry split, and regenerate …
claude Nov 16, 2026
b89e3e4
chore(gates): registry.ts carries its line ceiling, 6326 lines measur…
claude Nov 16, 2026
08a3d7a
chore(scripts): drop codemod-split-registry from the tree; the split …
claude Nov 16, 2026
e06e1a9
docs(objectql): the registry split's headers, changeset and exception…
claude Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/33949-registry-split.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/objectql': patch
---

refactor(objectql): `registry.ts` is split into section modules by codemod; a move only, with the public exports unchanged

Clause-②: no
Metadata-protocol: none

`packages/objectql/src/registry.ts` (12,577 lines) is split by codemod (the first pass of the `engine.ts` codemod; the script is kept in PR #34285's branch history and is not committed), as ruled on #33949 (item 1, split 1 of 8). `SchemaRegistry` keeps every member's signature and docblock, and each moved method forwards in one call to a facet module (`registry-SECTION.ts`). The top-level declarations ahead of the class move whole into `registry-top-level.ts`, and `registry.ts` re-exports every one it exported by name. The codemod's proof, recorded in PR #34285, shows that every moved body and declaration is byte-identical to the base, and that `registry.ts` still exports the same names, each a value or a type as before. No behaviour changes, and nothing an importer of `@objectstack/objectql` reads changes.
10 changes: 5 additions & 5 deletions packages/objectql/src/federated-injected-column-readers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ const READERS: Record<string, Row> = {
disposition: 'not-a-read',
why: 'the tenant index the registry declares on a provisioned tenant column',
},
'registry.ts#<module> :: owning_business_unit_id': {
'registry-top-level.ts#<module> :: owning_business_unit_id': {
disposition: 'not-a-read',
why: 'the name the injection writes the ADR-0117 D1 anchor under',
},
'registry.ts#<module> :: queue': {
'registry-top-level.ts#<module> :: queue': {
disposition: 'not-a-read',
why: 'the name the injection writes the ADR-0142 D3 ownership-queue column under',
},
Expand Down Expand Up @@ -502,17 +502,17 @@ const READERS: Record<string, Row> = {
disposition: 'not-a-read',
why: 'names the metadata type the boot refusal lists; it reads no row',
},
'registry.ts#declaresTenantIndex :: organization_id': {
'registry-top-level.ts#declaresTenantIndex :: organization_id': {
disposition: 'not-a-read',
why: 'reads an index declaration, not a row',
},
'registry.ts#applyDeploymentTenancy :: organization_id': {
'registry-platform-global.ts#applyDeploymentTenancy :: organization_id': {
disposition: 'not-a-read',
why:
"drops the platform's own injected definition from a declared object's schema (ADR-0131 D7); " +
'it reads a definition, never a row',
},
'registry.ts#setDeploymentPlatformGlobalObjects :: organization_id': {
'registry-platform-global.ts#setDeploymentPlatformGlobalObjects :: organization_id': {
disposition: 'not-a-read',
why:
'tells an authored organization_id from the injection while re-planning registered schemas ' +
Expand Down
216 changes: 216 additions & 0 deletions packages/objectql/src/registry-apps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* [#33949 codemod] The "Apps, navigation contributions and their diagnostics"
* section of `SchemaRegistry`: the bodies of `getApp`, `getAllApps`,
* `registerAppNavContribution`, `setPackageNavContributions`,
* `getAppNavContributions`, `applyNavContributions`, `findNavGroup`,
* `recordNavGroupMiss`, `getAppNavDiagnostics` moved out of `registry.ts` whole
* by the #33949 split codemod (PR #34285, kept in its branch history, not committed).
*
* A MOVE, not a redesign. {@link AppsFacet} is a stateless facet of `SchemaRegistry`
* (ruling 6624345766): each static method of it is the body of the `SchemaRegistry`
* method of the same name exactly as it stood: not re-indented, not
* formatted, not edited. The method stays on the class as a one-call stub with
* its signature, so the published surface, an instance spy and a subclass
* override are what they were. A public or protected method keeps its
* docblock on the class, the contract; a private method's docblock moved here
* with its body. The state stays on `SchemaRegistry`.
*
* The bodies reach the class through {@link AppsHost}: exactly the
* `SchemaRegistry` members they read, private ones included. Every stub hands
* its body, by a `.call`, the same host: `appsHost` in
* `registry-facet-hosts.ts`, built once per registry by the class's static
* block. Methods go as closures that call them on the registry at call time, so
* a subclass override or an instance spy is still the one reached; fields and
* accessors go as GETTERS, read when the body reads them, as they were on the
* class, and a field a body assigns goes with a SETTER that assigns it on the
* registry.
*
* The module imports `registry.ts` for types only, so the two modules form no
* evaluation cycle. `index.ts` re-exports nothing from this module.
*/

import { formatNavContributionGroupDiagnostic, navContributionGroupDiagnostic, findNavGroup as resolveNavGroup } from './nav-contribution-diagnostics.js';
import type { NavContributionGroupDiagnostic } from './nav-contribution-diagnostics.js';
import type { SchemaRegistry } from './registry.js';

/**
* The `SchemaRegistry` members the bodies of {@link AppsFacet} read — every one of
* them, and no other. Each is typed AS the class member (an indexed access on
* the class), so a change to a member's signature on the class is a change
* here too. `readonly` members are the getters; the others are fields a body
* assigns.
*/
export interface AppsHost {
readonly appNavContributions: SchemaRegistry['appNavContributions'];
applyNavContributions: SchemaRegistry['applyNavContributions'];
findNavGroup: SchemaRegistry['findNavGroup'];
isPackageDisabled: SchemaRegistry['isPackageDisabled'];
listItems: SchemaRegistry['listItems'];
log: SchemaRegistry['log'];
readonly navGroupDiagnostics: SchemaRegistry['navGroupDiagnostics'];
noteAppNavContributions: SchemaRegistry['noteAppNavContributions'];
recordNavGroupMiss: SchemaRegistry['recordNavGroupMiss'];
resolveItem: SchemaRegistry['resolveItem'];
warn: SchemaRegistry['warn'];
}

/** The bodies of the "Apps, navigation contributions and their diagnostics" section of `SchemaRegistry`: a stateless facet, called by the class's stubs. */
export class AppsFacet {
/** The body of `SchemaRegistry#getApp`; the method's docblock there is its contract. */
static getApp(this: Pick<AppsHost, 'applyNavContributions' | 'resolveItem'>, name: string, currentPackageId?: string): any {
const app = this.resolveItem<any>('app', name, currentPackageId);
if (!app) return app;
return this.applyNavContributions(app);
}

/** The body of `SchemaRegistry#getAllApps`; the method's docblock there is its contract. */
static getAllApps(this: Pick<AppsHost, 'applyNavContributions' | 'listItems'>): any[] {
return this.listItems('app').map((app: any) => this.applyNavContributions(app));
}

/** The body of `SchemaRegistry#registerAppNavContribution`; the method's docblock there is its contract. */
static registerAppNavContribution(this: Pick<AppsHost, 'appNavContributions' | 'log' | 'noteAppNavContributions'>, contribution: { app: string; group?: string; priority?: number; items?: any[] }, packageId?: string): void {
if (!contribution || !contribution.app) return;
this.noteAppNavContributions(contribution.app);
const list = this.appNavContributions.get(contribution.app) ?? [];
list.push({
packageId,
group: contribution.group,
priority: contribution.priority ?? 200,
items: Array.isArray(contribution.items) ? contribution.items : [],
});
this.appNavContributions.set(contribution.app, list);
this.log(
`[Registry] Navigation contribution: ${packageId ?? '(unknown)'} -> ${contribution.app}` +
(contribution.group ? `/${contribution.group}` : '') +
` (${list[list.length - 1].items.length} items)`,
);
}

/** The body of `SchemaRegistry#setPackageNavContributions`; the method's docblock there is its contract. */
static setPackageNavContributions(this: Pick<AppsHost, 'appNavContributions' | 'log' | 'noteAppNavContributions'>, packageId: string, contributions: ReadonlyArray<{ app: string; group?: string; priority?: number; items?: any[] }>): void {
const incoming = new Map<string, Array<{ packageId?: string; group?: string; priority: number; items: any[] }>>();
for (const contribution of contributions) {
if (!contribution || !contribution.app) continue;
const list = incoming.get(contribution.app) ?? [];
list.push({
packageId,
group: contribution.group,
priority: contribution.priority ?? 200,
items: Array.isArray(contribution.items) ? contribution.items : [],
});
incoming.set(contribution.app, list);
}
for (const [app, list] of this.appNavContributions) {
if (list.some((c) => c.packageId === packageId)) this.noteAppNavContributions(app);
}
for (const app of incoming.keys()) this.noteAppNavContributions(app);
for (const [app, list] of [...this.appNavContributions]) {
const at = list.findIndex((c) => c.packageId === packageId);
if (at === -1) continue;
const kept = list.filter((c) => c.packageId !== packageId);
kept.splice(at, 0, ...(incoming.get(app) ?? []));
incoming.delete(app);
if (kept.length > 0) this.appNavContributions.set(app, kept);
else this.appNavContributions.delete(app);
}
for (const [app, list] of incoming) {
this.appNavContributions.set(app, [...(this.appNavContributions.get(app) ?? []), ...list]);
}
for (const c of contributions) {
if (!c || !c.app) continue;
this.log(
`[Registry] Navigation contribution: ${packageId} -> ${c.app}` +
(c.group ? `/${c.group}` : '') +
` (${Array.isArray(c.items) ? c.items.length : 0} items)`,
);
}
}

/** The body of `SchemaRegistry#getAppNavContributions`; the method's docblock there is its contract. */
static getAppNavContributions(this: Pick<AppsHost, 'appNavContributions'>, appName: string): Array<{ packageId?: string; group?: string; priority: number; items: any[] }> {
return this.appNavContributions.get(appName) ?? [];
}

/** The body of `SchemaRegistry#applyNavContributions`; the method's docblock there is its contract. */
static applyNavContributions(this: Pick<AppsHost, 'appNavContributions' | 'findNavGroup' | 'isPackageDisabled' | 'recordNavGroupMiss'>, app: any): any {
const contributions = this.appNavContributions.get(app?.name);
if (!contributions || contributions.length === 0) return app;

const cloned = structuredClone(app);
const nav: any[] = Array.isArray(cloned.navigation) ? cloned.navigation : (cloned.navigation = []);

// Lower priority applied first — mirrors object extender ordering.
const sorted = [...contributions].sort((a, b) => a.priority - b.priority);
for (const c of sorted) {
if (!c.items.length) continue;
// [#28117] A disabled package's contributions leave the app, as its
// objects leave the data plane: "disabled" has one meaning (hidden +
// refused + data kept). Asked per read, never cached, so an enable
// restores them with nothing to invalidate; skipped BEFORE the group
// lookup, so a disabled contribution is not relocated or diagnosed either.
if (this.isPackageDisabled(c.packageId)) continue;
if (c.group) {
const group = this.findNavGroup(nav, c.group);
if (group) {
if (!Array.isArray(group.children)) group.children = [];
group.children.push(...c.items);
} else {
// [#14553] The relocation itself is UNCHANGED — the fold stays
// order-independent and contributions into optional groups keep
// working (option A, a refusal plus a registration-order rule, was
// weighed and not taken). What changed is that it is no longer
// silent: this used to be one `this.log(...)` gated at `info`, so a
// deployment at `OS_REGISTRY_LOG=warn` watched its information
// architecture change with nothing in the log at all.
this.recordNavGroupMiss(String(app.name), c);
nav.push(...c.items);
}
} else {
nav.push(...c.items);
}
}
return cloned;
}

/**
* Depth-first search for a `type: 'group'` nav item by id.
*
* [#14553] Delegates rather than implements: `os build` asks the identical
* question at compile time over a composed artifact, and two copies of this
* walk is exactly the drift that would let the build call an authoring error
* fine while this fold relocates it.
*/
static findNavGroup(items: any[], groupId: string): any | undefined {
return resolveNavGroup(items, groupId);
}

/**
* Record — and, the first time, announce — one relocated contribution.
*
* The entry is kept so a caller that is not reading the log
* ({@link getAppNavDiagnostics}: `os doctor`, a boot report, a test) can ask
* the app what happened to it.
*/
static recordNavGroupMiss(this: Pick<AppsHost, 'navGroupDiagnostics' | 'warn'>, appName: string, c: { packageId?: string; group?: string; items: any[] }): void {
const diagnostic = navContributionGroupDiagnostic({
app: appName,
group: String(c.group),
...(c.packageId === undefined ? {} : { packageId: c.packageId }),
items: c.items,
});
const perApp = this.navGroupDiagnostics.get(appName) ?? new Map<string, NavContributionGroupDiagnostic>();
const key = `${c.packageId ?? ''}|${c.group}`;
if (perApp.has(key)) return;
perApp.set(key, diagnostic);
this.navGroupDiagnostics.set(appName, perApp);
this.warn(formatNavContributionGroupDiagnostic(diagnostic));
}

/** The body of `SchemaRegistry#getAppNavDiagnostics`; the method's docblock there is its contract. */
static getAppNavDiagnostics(this: Pick<AppsHost, 'navGroupDiagnostics'>, appName: string): NavContributionGroupDiagnostic[] {
return [...(this.navGroupDiagnostics.get(appName)?.values() ?? [])];
}
}
Loading
Loading