Skip to content

Commit 2653b6b

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-y06l31
2 parents 7a5a4f0 + 714dda8 commit 2653b6b

54 files changed

Lines changed: 3168 additions & 275 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/plugin-sharing': patch
3+
---
4+
5+
feat(plugin-sharing): list the objects a sharing rule can take effect on
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: none
9+
10+
`SharingServicePlugin` mounts a read-only route, `GET /api/v1/sharing/shareable-objects`, for Setup's sharing-rule object picker. It answers `{ success: true, data: { objects } }`, each object `{ name, label, system }`, business objects first and then platform objects, each group by label.
11+
12+
An object is listed exactly when a sharing rule saved on it would take effect: the list asks the same check the save doors already ask (`SharingService.sharingRuleObjectRefusal`), so every object it leaves out is one a save refuses with `SHARING_NOT_ENABLED`. The platform's credential and session objects (sessions, linked accounts, API keys, verification tokens, two-factor rows, OAuth applications, tokens and consents, signing keys, secrets) are not listed.
13+
14+
Who may ask: the sharing-rule administrators, as `/api/v1/sharing/rules` admits them (`manage_sharing`, or the legacy `manage_platform_settings`, with an active organization). Anyone else is answered `403 PERMISSION_DENIED`, anonymous `401`. The route takes no query parameter and refuses one with `400 VALIDATION_ERROR`. With record-sharing enforcement off (`enforce: false`) it answers `501 NOT_IMPLEMENTED`.
15+
16+
`SharingRuleService` gains `listShareableObjects(context)`, the same list for in-process callers.
17+
18+
Nothing stored or authored changes; the `sys_sharing_rule` object field keeps its `object-ref` picker until the console's filtered picker lands.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(console)!: the marketplace filters by business function, industry and solution type, and badges a beta package
7+
8+
Clause-②: yes (narrowing)
9+
Metadata-protocol: none
10+
11+
<!-- adr-0087: not-required (runtime-interface-only ui/packages/i18n/src/namespaces/marketplace/index.ts#MarketplaceCatalogue) the console's own translation catalogues, served as this type by the marketplace namespace loader and as `en`/`zh`/… of `@object-ui/i18n/locales`: no Zod schema, no spec declaration and no stored metadata reads a translation key, so `objectstack migrate meta` has nothing to rewrite and the compiler (for typed catalogue access) or the rendered key (for a `t()` string) reaches every caller -->
12+
13+
- **Facet filters.** The marketplace page's single row of category chips is replaced by three facet filters, read from the marketplace taxonomy in `@objectstack/spec/marketplace`: solution type (a segment with All), business function and industry (toggle rows, any number of values). Values inside one facet combine with OR, the facets combine with AND, and both combine with the search box. Each value shows the count of loaded listings that carry it under the other facets' selection. A listing that declares no solution type counts as `app`, the spec's default. A facet no loaded listing carries is not drawn, so a catalog that does not serve the taxonomy yet shows no filter at all. Filtering stays on the client, over the page the catalog read loads.
14+
- **Badges.** A catalog card shows the listing's primary business function (the first it lists) and a Beta badge when its `maturity` is `beta`. The package Details page shows every business function in the listing's order, the industries, the solution type and the Beta badge. A value outside the spec's vocabulary is drawn nowhere; the old fallback that showed an unknown category's raw value is gone.
15+
- **Strings.** `@object-ui/i18n`'s marketplace catalogues drop the `marketplace.category.*` labels, a copy of the retired category enum, and gain `marketplace.businessFunction.*`, `marketplace.industry.*`, `marketplace.solutionType.*`, `marketplace.maturity.beta` and three facet headings (`marketplace.facet.*`) in every language. The console keys the labels by the spec enums' own values, and a test fails when a spec value has no label, or a catalogue labels a value the spec does not list.
16+
- **Wire.** The console reads the catalog row's `business_functions`, `industries`, `solution_type` and `maturity` columns, and no longer reads `category` or sends `?category=`.
17+
18+
**BREAKING** (`@object-ui/i18n`, the marketplace catalogues served by `@object-ui/i18n/namespaces/marketplace` and held by `en`, `zh`, `zhHant`, `ja`, `ko`, `de`, `fr`, `es`, `pt`, `ru`, `ar` of `@object-ui/i18n/locales`): the `marketplace.category` group is removed from every language. It was a copy of the retired category enum, whose values the spec no longer declares.
19+
20+
- FROM: `marketplace.category.crm`, `.erp`, `.hr`, `.finance`, `.project`, `.collaboration`, `.analytics`, `.integration`, `.automation`, `.ai`, `.security`, `.developer-tools`, `.ui-theme`, `.storage`, `.other`.
21+
- TO: no one-for-one replacement. A listing is now labelled by its facets: `marketplace.businessFunction.<value>`, `marketplace.industry.<value>` and `marketplace.solutionType.<value>`, keyed by the values of `MarketplaceBusinessFunctionSchema`, `MarketplaceIndustrySchema` and `MarketplaceSolutionTypeSchema` in `@objectstack/spec/marketplace`. Which facets an old category value becomes is `LEGACY_CATEGORY_MAPPING` in the same module.
22+
- Fix: delete a `t('marketplace.category.…')` call or an `en.marketplace.category` read, or label the listing's `businessFunctions` / `industries` / `solutionType` with the facet keys instead. A `t()` call that still names a removed key compiles (its key is a `string`) and renders the key itself.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/spec': patch
3+
---
4+
5+
docs(spec): the semantic migration entry `cbp-optional-master-admitted` states the current write rule for an empty optional master, and the security-service contract names the `ownerMayEdit` owner leg
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- **Migration entry `cbp-optional-master-admitted`.** Its `replacement`, and its paragraph in the protocol upgrade guide, still said that a write leaving an optional `controlled_by_parent` master empty is refused with 422. The write gate admits such writes since the owner rule landed (ADR-0055 §3 as amended): an insert that names no master is admitted and its creator owns the row; its owner and a holder of Modify All on the detail update or delete a row whose master reference is empty, and everyone else, View All included, is refused `403 PERMISSION_DENIED`; an update that empties a named master asks edit access on the master it leaves. Only a required master's empty stored reference is still refused with `422 MISSING_REQUIRED_FIELD`. This supersedes the sentence "Writes are unchanged: an insert or update that leaves the master reference empty is still refused with 422" in the `@objectstack/plugin-security` note of `.changeset/30905-cbp-optional-master.md`: that was the state before the write gate followed, and the rule above is the one that ships. The entry's `id`, `surface`, `reason` and `acceptanceCriteria` are unchanged.
11+
- **`ISecurityService.checkControlledByParentWrite` and `ControlledByParentWriteOutcome` (JSDoc).** Both now name the `sharing.controlledByParent.ownerMayEdit: true` opt-in (ADR-0055 §3 as amended 2026-10-26): a by-id update by the record's owner, not on behalf of another user, that does not empty an optional master, needs only read access to the master the record names, so the check answers `allow` for such an owner who can read it. Every other caller and every other write keeps the master-edit rule.
12+
13+
Text only: no schema, type, export or runtime answer changes.

‎packages/lint/src/validate-ai-tool-references.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,24 @@ describe('validate-ai-tool-references', () => {
245245
expect(control[1].message).toContain('draft_record');
246246
});
247247

248+
/**
249+
* The build agent's package removal (cloud#3656), which only stages the
250+
* removal of a package built in the environment: a skill naming
251+
* `delete_package` resolves; a near name nobody registers does not.
252+
*/
253+
it('resolves the service-ai-studio package removal', () => {
254+
expect(validateAiToolReferences({ skills: [{ name: 's', tools: ['delete_package'] }] })).toEqual([]);
255+
256+
// The control: the plural registered by nobody is still reported, so this
257+
// pin fails on a universe widened too far.
258+
const control = validateAiToolReferences({
259+
skills: [{ name: 's', tools: ['delete_package', 'delete_packages'] }],
260+
});
261+
expect(control).toHaveLength(1);
262+
expect(control[0].path).toBe('skills[0].tools[1]');
263+
expect(control[0].message).toContain('delete_packages');
264+
});
265+
248266
it('reports stable paths and tolerates junk shapes', () => {
249267
const stack = {
250268
skills: [{ name: 's', tools: ['query_records', 'nope_tool'] }],
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import {
4+
ANONYMOUS_DENY_CODE,
5+
ANONYMOUS_DENY_MESSAGE,
6+
ANONYMOUS_DENY_STATUS,
7+
evaluateAuthGate,
8+
isApiKeyLifecycleRefusalError,
9+
isAuthzStoreUnavailableError,
10+
resolveRequestExecutionContext,
11+
shouldDenyAnonymous,
12+
type RequestAuthService,
13+
type TenancyServiceResolver,
14+
} from '@objectstack/core';
15+
import type { ErrorCode } from '@objectstack/spec/api';
16+
import type { IHttpRequest, IHttpResponse, IHttpServer } from '@objectstack/spec/contracts';
17+
import type { ExecutionContext } from '@objectstack/spec/kernel';
18+
import { sendError, sendOk, sendServerFault } from '@objectstack/types';
19+
import { SharingRulesNotRunningError, type ShareableObject } from './shareable-objects.js';
20+
21+
/**
22+
* The shareable-objects door: `GET /api/v1/sharing/shareable-objects`. It
23+
* answers the objects a sharing rule can take effect on, for Setup's
24+
* sharing-rule object picker (`shareable-objects.ts` says which objects and in
25+
* what order). It reads and never writes.
26+
*
27+
* ## Why plugin-sharing mounts it
28+
*
29+
* The sharing-rule administration routes (`/api/v1/sharing/rules*`) are
30+
* `@objectstack/rest`'s, served over the `sharingRules` service through a spec
31+
* contract. A list there would need a new member on that contract; this door
32+
* is the plugin's own, read straight off the `SharingRuleService` the plugin
33+
* constructs, at a path no other package serves. It reaches for the
34+
* `http.server` service and registers on `IHttpServer`, as the share-link
35+
* family does; `sharing-route-ledger.ts` records it.
36+
*
37+
* ## Who may ask — the sharing-rule administrators
38+
*
39+
* In order, before anything is read:
40+
*
41+
* 1. **The caller**, resolved by the platform's one request-to-context
42+
* composition (`resolveRequestExecutionContext`) from the request's session
43+
* or API key. A permission store that cannot be read answers its own
44+
* `SERVICE_UNAVAILABLE` / `503`, and an API key its lifecycle refuses its
45+
* own `403` and code: both relayed as declared, never folded into a denial.
46+
* 2. **A held sign-in** (ADR-0069: an expired password, enforced MFA not yet
47+
* enrolled): `403` with the authentication policy's own code.
48+
* 3. **Anonymous** — the platform's one anonymous floor (ADR-0056 D2):
49+
* `UNAUTHENTICATED` / `401`.
50+
* 4. **The request**: the route takes no query parameter, and a request that
51+
* carries one is refused `VALIDATION_ERROR` / `400` naming it (AGENTS.md,
52+
* route rule 5: the closed set here is empty), never ignored.
53+
* 5. **The administrator**: the sharing-rule surface's own admission
54+
* (`SharingRuleService.listShareableObjects` asks the check every verb of
55+
* that surface asks, ADR-0111 D6). A caller it refuses is answered
56+
* `PERMISSION_DENIED` / `403` with its sentence, so the list names nothing
57+
* the caller could not author a rule on.
58+
*
59+
* ## What the door answers
60+
*
61+
* - **Success:** `200` with `{ objects }` (`ShareableObject[]`), business
62+
* objects first.
63+
* - **Sharing rules not running on this kernel** (`enforce: false`, or the
64+
* rule subsystem did not start): `501` / `NOT_IMPLEMENTED`, the answer the
65+
* REST sharing-rule routes give for the same state.
66+
* - **An engine that cannot enumerate its objects** is a fault: `500` /
67+
* `INTERNAL_ERROR` with this door's sentence and the error in the fault log.
68+
* An empty list would read as "no object can take a rule", so it is never
69+
* served in place of the answer.
70+
*/
71+
72+
/** The route the door is mounted at. */
73+
export const SHAREABLE_OBJECTS_ROUTE = '/api/v1/sharing/shareable-objects';
74+
75+
/** What the door is composed over — every service read when a request arrives. */
76+
export interface ShareableObjectsRoutesDeps {
77+
/** The data engine the caller's grants are read through; `undefined` when none is registered. */
78+
getEngine(): unknown;
79+
/** The auth service the caller's session is read through; `undefined` when none is registered. */
80+
getAuth(): RequestAuthService | undefined;
81+
/** How this door reaches the `tenancy` service; `undefined` on a host with no async service accessor. */
82+
tenancy: TenancyServiceResolver | undefined;
83+
/**
84+
* The list, admitted for `context` — `SharingRuleService.listShareableObjects`.
85+
* Throws `PERMISSION_DENIED: …` for a caller the sharing-rule surface refuses,
86+
* and {@link SharingRulesNotRunningError} when no rule service runs.
87+
*/
88+
listShareableObjects(context: ExecutionContext): ShareableObject[];
89+
}
90+
91+
/** Mount the door on `http`. Nothing on `deps` is called until a request arrives. */
92+
export function registerShareableObjectsRoutes(http: IHttpServer, deps: ShareableObjectsRoutesDeps): void {
93+
http.get(SHAREABLE_OBJECTS_ROUTE, (req, res) => handleShareableObjects(req, res, deps));
94+
}
95+
96+
/** The sharing-rule surface's refusal idiom (`PERMISSION_DENIED: <sentence>`), read once. */
97+
const PERMISSION_DENIED_PREFIX = /^PERMISSION_DENIED:\s*/;
98+
99+
async function handleShareableObjects(
100+
req: IHttpRequest,
101+
res: IHttpResponse,
102+
deps: ShareableObjectsRoutesDeps,
103+
): Promise<void> {
104+
// ① The caller.
105+
let context: ExecutionContext | undefined;
106+
try {
107+
context = await resolveCaller(req, deps);
108+
} catch (err) {
109+
if (isAuthzStoreUnavailableError(err) || isApiKeyLifecycleRefusalError(err)) {
110+
sendError(res, err.status, err.code, err.message);
111+
return;
112+
}
113+
sendServerFault(res, 500, 'INTERNAL_ERROR', 'The caller of this request could not be resolved.', err, {
114+
method: 'GET',
115+
path: SHAREABLE_OBJECTS_ROUTE,
116+
});
117+
return;
118+
}
119+
120+
// ② A held sign-in.
121+
const gate = evaluateAuthGate(context, '');
122+
if (gate) {
123+
sendError(res, 403, gate.code as ErrorCode, gate.message);
124+
return;
125+
}
126+
127+
// ③ Anonymous.
128+
if (!context || shouldDenyAnonymous({ userId: context.userId, method: req.method })) {
129+
sendError(res, ANONYMOUS_DENY_STATUS, ANONYMOUS_DENY_CODE, ANONYMOUS_DENY_MESSAGE);
130+
return;
131+
}
132+
133+
// ④ The request: the closed query set is empty.
134+
const query = Object.keys(req.query ?? {});
135+
if (query.length > 0) {
136+
sendError(
137+
res,
138+
400,
139+
'VALIDATION_ERROR',
140+
`The shareable objects list takes no query parameter, and this request carries ${query.map((q) => `'${q}'`).join(', ')}. ` +
141+
'Ask for the list with no parameters: it always answers every object a sharing rule can take effect on.',
142+
);
143+
return;
144+
}
145+
146+
// ⑤ The administrator, then the list.
147+
let objects: ShareableObject[];
148+
try {
149+
objects = deps.listShareableObjects(context);
150+
} catch (err) {
151+
const message = err instanceof Error ? err.message : String(err);
152+
if (err instanceof SharingRulesNotRunningError) {
153+
sendError(res, 501, 'NOT_IMPLEMENTED', message);
154+
return;
155+
}
156+
if (PERMISSION_DENIED_PREFIX.test(message)) {
157+
sendError(res, 403, 'PERMISSION_DENIED', message.replace(PERMISSION_DENIED_PREFIX, ''));
158+
return;
159+
}
160+
sendServerFault(res, 500, 'INTERNAL_ERROR', 'The objects a sharing rule can take effect on could not be listed.', err, {
161+
method: 'GET',
162+
path: SHAREABLE_OBJECTS_ROUTE,
163+
});
164+
return;
165+
}
166+
sendOk(res, { objects });
167+
}
168+
169+
/**
170+
* Resolve the caller through the one composition. This door's differences, as
171+
* its named parameters: anonymous fails closed (the door answers its floor);
172+
* the held-sign-in posture is the one the resolver decided for the credential
173+
* that admitted the caller; an API key admits its owner with no session read;
174+
* no locale, bearer or OAuth token is carried — the list is the same in every
175+
* language, and nothing downstream acts as the caller.
176+
*/
177+
async function resolveCaller(req: IHttpRequest, deps: ShareableObjectsRoutesDeps): Promise<ExecutionContext | undefined> {
178+
const headers = new Headers();
179+
for (const [name, value] of Object.entries(req.headers ?? {})) {
180+
if (value == null) continue;
181+
headers.set(name, Array.isArray(value) ? value.join(',') : String(value));
182+
}
183+
return await resolveRequestExecutionContext({
184+
headers,
185+
ql: deps.getEngine(),
186+
authService: deps.getAuth(),
187+
tenancy: deps.tenancy,
188+
anonymous: 'fail-closed',
189+
authGate: 'resolved',
190+
credentials: 'api-key-and-session',
191+
sessionApi: 'optional',
192+
session: 'request',
193+
localization: 'withhold',
194+
requestLocale: undefined,
195+
accessToken: 'withhold',
196+
oauth: undefined,
197+
onAdmission: undefined,
198+
});
199+
}

0 commit comments

Comments
 (0)