Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
203cf3f
wip(studio): one Studio address builder and its mapping table (#36895)
claude Nov 24, 2026
c1d671c
wip(studio): repoint app-shell and console producers to the address b…
claude Nov 24, 2026
03e5571
wip(studio): keep the console import apart from a sibling's edit (#36…
claude Nov 24, 2026
0e18172
wip(studio): move the console import clear of a sibling's hunk (#36895)
claude Nov 24, 2026
5600893
wip(studio): StudioDesignSurface's hand-built addresses call the buil…
claude Nov 24, 2026
417ecf0
wip(types): one shared spelling of the server's draft review links (#…
claude Nov 24, 2026
166725c
wip(studio): pin the builder's addresses and guard against hand-built…
claude Nov 24, 2026
ffe0516
wip(types): pin the review links and guard server packages; changeset…
claude Nov 24, 2026
947b96e
wip(types): name the module for links, not routes, so the route-envel…
claude Nov 24, 2026
a040c44
Merge remote-tracking branch 'origin/main' into claude/issue-36895-st…
claude Nov 24, 2026
fa0deb8
wip(studio): the package list's Studio link, landed on main meanwhile…
claude Nov 24, 2026
6b908b2
Merge remote-tracking branch 'origin/main' into claude/issue-36895-st…
claude Nov 24, 2026
2a9f6e9
wip(studio): the console's /studio route pattern stays a literal; the…
claude Nov 24, 2026
2fec7fb
wip(studio): declare Clause-② yes (widening); document that an empty …
claude Nov 24, 2026
b6e22ef
Merge remote-tracking branch 'origin/main' into claude/issue-36895-st…
claude Nov 24, 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
18 changes: 18 additions & 0 deletions .changeset/36895-studio-address-builder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'@objectstack/types': patch
'@objectstack/runtime': patch
'@objectstack/cli': patch
'@object-ui/app-shell': patch
'@object-ui/console': patch
---

refactor(studio): every Studio address comes from one builder; no address changes

Clause-②: yes (widening)
Metadata-protocol: none

Studio redesign groundwork (#36895, epic #36890). Every place that produced a `/studio...` URL now calls one builder, so a later change can move an item type to its metadata address in one place. Every address is byte-for-byte what it was: no link, bookmark or redirect changes.

- **Console.** `studioAddress.ts` in `@object-ui/app-shell` builds every Studio address: the landing, a package, a pillar, an item (`studioItemPath`), the "All metadata" area, and the draft review links. `studioAddressTable.ts` lists every address family, every `?surface=` spelling and every query parameter, with what each becomes on the metadata address. The retired `/interfaces` redirect keeps exactly the parameters that table marks. New exports from `@object-ui/app-shell`: `STUDIO_ROOT_PATH`, `STUDIO_HOME_PILLAR`, `studioLandingPath`, `studioPackagePath`. Existing exports keep their names and values.
- **Server.** `studioChangesReviewLink` and `studioItemReviewLink`, new in `@objectstack/types`, build the review links that `os meta register` prints and that the MCP authoring tools return after a draft save. The text an AI is handed is unchanged.
- **Guards.** A test under `ui/` refuses a hand-built Studio address in any ui source. A test in `@objectstack/types` refuses one in any server package, and holds the review links quoted by the `objectstack-mcp-build` skill's evals equal to what the builder returns.
3 changes: 2 additions & 1 deletion packages/cli/src/commands/meta/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { MetadataValidationResult } from '@objectstack/spec/kernel';
import { printError, printInfo, printSuccess, printWarning, emitJson, errorCodeFields } from '../../utils/format.js';
import { createApiClient, requireAuth } from '../../utils/api-client.js';
import { formatOutput } from '../../utils/output-formatter.js';
import { studioChangesReviewLink } from '@objectstack/types';

/**
* [#23350] The refusal an EMPTY `--package` earns, before anything reaches the
Expand Down Expand Up @@ -210,7 +211,7 @@ export function draftSaveLines(args: {
if (args.packageId) {
lines.push(
`Review and publish it in Studio's Changes for package ${args.packageId} `
+ `(/studio/${encodeURIComponent(args.packageId)}/data?changes=review).`,
+ `(${studioChangesReviewLink(args.packageId)}).`,
);
}
return lines;
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/src/domains/mcp-authoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ import type { AIToolDefinition } from '@objectstack/spec/contracts';
import type { HttpProtocolContext } from '../http-dispatcher.js';
import type { DomainHandlerDeps } from '../domain-handler-registry.js';
import { readEffectiveTenancyPosture } from './activation-gate.js';
import { studioChangesReviewLink, studioItemReviewLink } from '@objectstack/types';

/** The read tools' names, in the order the registry lists them. */
export const OPEN_AUTHORING_READ_TOOL_NAMES = ['list_metadata_items', 'get_metadata_item', 'list_drafts'] as const;
Expand Down Expand Up @@ -1288,10 +1289,9 @@ function verdictOf(judgement: OpenAuthoringDraftJudgement): {
* and the item's draft review on Studio's metadata area (`?review=1`).
*/
function reviewRoutes(packageId: string, type: string, name: string): { changes: string; item: string; note: string } {
const pkg = encodeURIComponent(packageId);
return {
changes: `/studio/${pkg}/data?changes=review`,
item: `/studio/${pkg}/metadata/${encodeURIComponent(type)}/${encodeURIComponent(name)}?review=1`,
changes: studioChangesReviewLink(packageId),
item: studioItemReviewLink(packageId, type, name),
note: 'Console routes. A person reviews and publishes the draft there; this server cannot publish.',
};
}
Expand Down
4 changes: 4 additions & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ export * from './summary-recompute-answer.js';
// action or flow. Its producers (objectql, service-automation) cannot import
// each other; both already depend on this package.
export * from './packaged-item-turned-off.js';
// [#36895] The Studio addresses a server hands out for a saved draft's review.
// Its producers (cli's `os meta register`, runtime's MCP authoring tools)
// cannot depend on the Console; both already depend on this package.
export * from './studio-review-links.js';

// Placeholder for Kernel interface to avoid circular dependency
// The actual Kernel implementation will satisfy this interface.
Expand Down
170 changes: 170 additions & 0 deletions packages/types/src/studio-review-links.callers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#36895 — no server package builds a Studio address by hand, and
* the review links the `objectstack-mcp-build` skill's evals quote are the
* ones this package builds.
*
* ── Why ──────────────────────────────────────────────────────────────────────
*
* The Studio redesign (epic #36890) moves Studio's addresses one item type at
* a time. A `/studio/...` string written out in a server package would keep
* the old address after the move, and an AI handed it would send a person to
* the wrong page. `studio-review-links.ts` is the one place a server spells
* one; the Console's builder (`studioAddress.ts` in the app-shell package)
* is held by the same kind of pin in the ui workspace.
*
* ── What it judges ───────────────────────────────────────────────────────────
*
* 1. Every `.ts` source under `packages/` (tests, declaration files and build
* output excepted), parsed: a string or template literal that starts with
* `/studio` (then its end, `/`, `?` or `#`) is a hand-built address. Prose
* in comments is free.
* 2. The eval file of the published skill (it is governed: it is read, never
* edited here): every Studio address it quotes equals what
* `studioChangesReviewLink` / `studioItemReviewLink` return for the
* package, type and name the address names, so the two cannot drift.
*
* ── Controls ─────────────────────────────────────────────────────────────────
*
* The walk must reach the two server producers, the matcher must fire on the
* one allowed file, and the eval file must yield its quoted addresses (seven
* on the commit this landed: five Changes links, two item reviews). Zero in
* any of them means the instrument is broken, not that the tree is clean.
*
* The radius: `packages/**` `.ts` (already this package's declared glob, the
* extension boundary is the one `driver-error-classification.callers.test.ts`
* records) plus the one eval file, declared beside it.
*/

import { describe, expect, it } from 'vitest';
import { existsSync, readdirSync, readFileSync } from 'node:fs';
import { dirname, join, relative, resolve, sep } from 'node:path';
import ts from 'typescript';
import { studioChangesReviewLink, studioItemReviewLink } from './studio-review-links.js';

/**
* This package is CJS-typed, so `import.meta` is not available: walk up from
* the CWD to this package's own manifest (`driver-error-classification.callers.test.ts`
* says why), then reach the repo root by arithmetic.
*/
function findUp(marker: (dir: string) => boolean, what: string): string {
let dir = process.cwd();
for (;;) {
if (marker(dir)) return dir;
const parent = dirname(dir);
if (parent === dir) throw new Error(`could not locate ${what} walking up from ${process.cwd()}`);
dir = parent;
}
}

const PACKAGE_ROOT = findUp((dir) => {
const manifest = join(dir, 'package.json');
if (!existsSync(manifest)) return false;
const { name } = JSON.parse(readFileSync(manifest, 'utf8')) as { name?: string };
return name === '@objectstack/types';
}, 'the @objectstack/types package root');

const REPO_ROOT = resolve(PACKAGE_ROOT, '../..');

const SCANNED_TREE = join(REPO_ROOT, 'packages');

/** The skill eval whose quoted review links must equal the builder's. */
const EVAL_FILE = join(REPO_ROOT, 'skills/objectstack-mcp-build/evals/draft-door-procedure.json');

/** The one server file that spells a Studio address. */
const ALLOWED = 'packages/types/src/studio-review-links.ts';

const SKIP_DIRS = new Set(['node_modules', 'dist', 'build', 'coverage', '.turbo', '.next', '__tests__']);

const SOURCE_FILE = (name: string): boolean =>
name.endsWith('.ts') && !name.endsWith('.d.ts') && !/\.(?:test|spec)\.ts$/.test(name);

const STUDIO_LITERAL = /^\/studio(?:$|[/?#])/;

function sourceFilesUnder(root: string): string[] {
const out: string[] = [];
const walk = (dir: string): void => {
for (const entry of readdirSync(dir, { withFileTypes: true })) {
if (entry.isDirectory()) {
if (!SKIP_DIRS.has(entry.name)) walk(join(dir, entry.name));
continue;
}
if (entry.isFile() && SOURCE_FILE(entry.name)) out.push(join(dir, entry.name));
}
};
walk(root);
return out;
}

function handBuiltStudioAddresses(fileName: string, text: string): string[] {
if (!text.includes('/studio')) return [];
const source = ts.createSourceFile(fileName, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
const hits: string[] = [];
const visit = (node: ts.Node): void => {
const literalText =
ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)
? node.text
: ts.isTemplateExpression(node)
? node.head.text
: null;
if (literalText !== null && STUDIO_LITERAL.test(literalText)) {
const { line } = source.getLineAndCharacterOfPosition(node.getStart(source));
hits.push(`${line + 1}: ${node.getText(source).replace(/\s+/g, ' ').slice(0, 120)}`);
}
ts.forEachChild(node, visit);
};
visit(source);
return hits;
}

/** Every Studio address quoted in a text, up to the first quote, space, backtick or paren. */
function quotedStudioAddresses(text: string): string[] {
return [...text.matchAll(/\/studio\/[^\s"'`)]+/g)].map((m) => m[0]);
}

/** What the builder returns for the package, type and name an address names. */
function rebuilt(address: string): string | null {
const changes = /^\/studio\/([^/?#]+)\/data\?changes=review$/.exec(address);
if (changes) return studioChangesReviewLink(decodeURIComponent(changes[1]));
const item = /^\/studio\/([^/?#]+)\/metadata\/([^/?#]+)\/([^/?#]+)\?review=1$/.exec(address);
if (item) {
return studioItemReviewLink(decodeURIComponent(item[1]), decodeURIComponent(item[2]), decodeURIComponent(item[3]));
}
return null;
}

describe('no server package builds a Studio address by hand (objectstack#36895)', () => {
it('the matcher sees each spelling and spares prose and look-alikes', () => {
const scan = (text: string) => handBuiltStudioAddresses('x.ts', text);
expect(scan("const a = '/studio';")).toHaveLength(1);
expect(scan('const b = `/studio/${pkg}/data?changes=review`;')).toHaveLength(1);
expect(scan("const c = 'see (/studio/x)';")).toEqual([]);
expect(scan("const d = '/api/v1/studio/runtime-config';")).toEqual([]);
expect(scan('// links to /studio/crm/data\nconst e = 1;')).toEqual([]);
expect(scan("const f = '/studios';")).toEqual([]);
});

it('only the shared module spells one', () => {
const files = sourceFilesUnder(SCANNED_TREE);
const rel = (file: string) => relative(REPO_ROOT, file).split(sep).join('/');
const names = new Set(files.map(rel));
// Controls: the walk reaches both server producers, and the matcher fires
// on the allowed module.
expect(names.has('packages/runtime/src/domains/mcp-authoring.ts')).toBe(true);
expect(names.has('packages/cli/src/commands/meta/register.ts')).toBe(true);
expect(handBuiltStudioAddresses(ALLOWED, readFileSync(join(REPO_ROOT, ALLOWED), 'utf8')).length).toBe(2);

const offenders = files
.filter((file) => rel(file) !== ALLOWED)
.flatMap((file) => handBuiltStudioAddresses(file, readFileSync(file, 'utf8')).map((hit) => `${rel(file)}:${hit}`));
expect(offenders).toEqual([]);
});

it("the skill evals quote the builder's review links, byte for byte", () => {
const quoted = quotedStudioAddresses(readFileSync(EVAL_FILE, 'utf8'));
// Control: the eval file still quotes its review links.
expect(quoted.length).toBeGreaterThanOrEqual(7);
for (const address of quoted) expect(rebuilt(address), address).toBe(address);
});
});
24 changes: 24 additions & 0 deletions packages/types/src/studio-review-links.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

import { describe, expect, it } from 'vitest';
import { studioChangesReviewLink, studioItemReviewLink } from './studio-review-links.js';

/**
* objectstack#36895 — the server's draft review links, byte for byte as the CLI
* and the MCP authoring tools spelled them before this module existed. The
* Console's `studioChangesReviewPath` / `studioItemReviewPath` are pinned to
* the same literals in the Console's app-shell package (`studioAddress.test.ts`).
*/
describe('the Studio review links a server hands out (objectstack#36895)', () => {
it("a package's Changes drawer on its Studio home", () => {
expect(studioChangesReviewLink('com.acme.crm')).toBe('/studio/com.acme.crm/data?changes=review');
expect(studioChangesReviewLink('a b/c')).toBe('/studio/a%20b%2Fc/data?changes=review');
});

it("an item's draft review in the All metadata area", () => {
expect(studioItemReviewLink('com.acme.crm', 'flow', 'crm_lead_created_notify')).toBe(
'/studio/com.acme.crm/metadata/flow/crm_lead_created_notify?review=1',
);
expect(studioItemReviewLink('p q', 'object', 'a/b')).toBe('/studio/p%20q/metadata/object/a%2Fb?review=1');
});
});
29 changes: 29 additions & 0 deletions packages/types/src/studio-review-links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* The two Studio addresses a server hands out (objectstack#36895): where a
* person reviews a draft that the CLI's `os meta register` or the MCP authoring
* tools saved. Both producers (`packages/cli`, `packages/runtime`) already
* depend on this package, and neither may depend on the Console, so the
* shared spelling lives here.
*
* The Console builds the same two addresses with `studioChangesReviewPath`
* and `studioItemReviewPath` (`studioAddress.ts` in the Console's app-shell package),
* which does not depend on this package; both sides are pinned to the same
* literals, and to the literals the `objectstack-mcp-build` skill's evals
* quote (`studio-review-links.test.ts`).
*
* ⛔ A changed byte here changes the review link an AI is handed and repeats to
* a person. The addresses move only when the Studio redesign moves them, and
* then on both sides together.
*/

/** A package's Changes drawer on its Studio home: `/studio/<package>/data?changes=review`. */
export function studioChangesReviewLink(packageId: string): string {
return `/studio/${encodeURIComponent(packageId)}/data?changes=review`;
}

/** An item's draft review in Studio's "All metadata" area: `/studio/<package>/metadata/<type>/<name>?review=1`. */
export function studioItemReviewLink(packageId: string, type: string, name: string): string {
return `/studio/${encodeURIComponent(packageId)}/metadata/${encodeURIComponent(type)}/${encodeURIComponent(name)}?review=1`;
}
3 changes: 2 additions & 1 deletion packages/types/vitest.repo-tests.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[
"src/driver-error-classification.callers.test.ts"
"src/driver-error-classification.callers.test.ts",
"src/studio-review-links.callers.test.ts"
]
8 changes: 7 additions & 1 deletion scripts/cross-package-test-inputs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,13 @@ export const CROSS_PACKAGE_TEST_INPUTS = {
// to a workspace-root marker file, so it names no root-level path and this
// entry adds no new top-level root for `check-ci-filter-parity.mjs` to want
// in ci.yml's `crosspkg:` filter. Its own header records that trade.
globs: ['packages/**/*.ts'],
//
// src/studio-review-links.callers.test.ts (#36895) walks the same `.ts`
// population for hand-built Studio addresses, and reads the one skill eval
// that quotes the server's draft review links, to hold each quoted link
// equal to what this package builds. That file sits under the published
// skills root, which ci.yml's `crosspkg:` filter already covers whole.
globs: ['packages/**/*.ts', 'skills/objectstack-mcp-build/evals/draft-door-procedure.json'],
},
'@objectstack/organizations': {
// src/no-framework-dependents.pin.test.ts is ADR-0132 D3's mechanical half.
Expand Down
3 changes: 2 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,8 @@
"!coverage/**",
"!.turbo/**",
"!**/node_modules/**",
"$TURBO_ROOT$/packages/**/*.ts"
"$TURBO_ROOT$/packages/**/*.ts",
"$TURBO_ROOT$/skills/objectstack-mcp-build/evals/draft-door-procedure.json"
]
},
"@objectstack/runtime#test:repo": {
Expand Down
5 changes: 3 additions & 2 deletions ui/apps/console/src/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { LocalizationFetchProvider } from './LocalizationFetchProvider';
import { FirstRunChecklist } from './pages/settings/FirstRunChecklist';
import { InAppFormRoute } from './components/InternalFormRoute';
import { APPROVAL_ACTION_OBJECT, APPROVAL_REQUEST_OBJECT, routeApprovalRecordReads } from './services/approvalRequestsDataSource';
import { studioLandingPath } from '@object-ui/app-shell';

const AppManagementPage = lazy(() => import('./pages/system/AppManagementPage').then(m => ({ default: m.AppManagementPage })));
const ProfilePage = lazy(() => import('./pages/system/ProfilePage').then(m => ({ default: m.ProfilePage })));
Expand Down Expand Up @@ -65,7 +66,7 @@ function ObjectRedirect() {
// objectstack ADR-0146 D1 — straight to Studio's "All metadata" area, the
// page Setup's `…/metadata/object` route opens there.
const target = setupMetadataStudioPath(objectName ? `object/${objectName}` : 'object', location.search, location.hash);
return <Navigate to={target ?? '/studio'} replace />;
return <Navigate to={target ?? studioLandingPath()} replace />;
}

/**
Expand Down Expand Up @@ -175,7 +176,7 @@ function SystemObjectRedirect({ objectName }: { objectName: string }) {
function SystemCatalogRedirect({ type }: { type: 'position' | 'permission' }) {
// objectstack ADR-0146 D1 — the catalog is Studio's, in the "All metadata"
// area's cross-package leg.
return <Navigate to={setupMetadataStudioPath(type, ENVIRONMENT_SCOPE_QUERY) ?? '/studio'} replace />;
return <Navigate to={setupMetadataStudioPath(type, ENVIRONMENT_SCOPE_QUERY) ?? studioLandingPath()} replace />;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions ui/apps/console/src/components/StudioRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ import {
LoadingFallback,
LoadingScreen,
STUDIO_ALL_PACKAGES_SEGMENT,
STUDIO_HOME_PILLAR,
STUDIO_METADATA_AREA,
STUDIO_ORG_SCOPE_PILLAR,
STUDIO_ORG_SCOPE_SEGMENT,
studioMetadataAreaPath,
studioPackagePath,
useHomePath,
useRecentItems,
} from '@object-ui/app-shell';
Expand Down Expand Up @@ -282,7 +284,7 @@ function StudioPackageBuilder({ area }: { area?: typeof STUDIO_METADATA_AREA })
id: `package:${packageId}`,
type: 'package',
name: packageId,
href: `/studio/${encodeURIComponent(packageId)}`,
href: studioPackagePath(packageId),
});
// Driven by the package alone. `addRecentItem` is a `useCallback` result,
// whose identity is not a dependency (AGENTS.md #10), as in
Expand Down Expand Up @@ -345,7 +347,7 @@ export const studioRoutes = (
path={`${STUDIO_ALL_PACKAGES_SEGMENT}/*`}
element={<Navigate to={studioMetadataAreaPath(STUDIO_ALL_PACKAGES_SEGMENT)} replace />}
/>
<Route path=":packageId" element={<Navigate to="data" replace />} />
<Route path=":packageId" element={<Navigate to={STUDIO_HOME_PILLAR} replace />} />
<Route
path={`:packageId/${STUDIO_METADATA_AREA}/*`}
element={<StudioPackageBuilder area={STUDIO_METADATA_AREA} />}
Expand Down
Loading
Loading