Skip to content
16 changes: 16 additions & 0 deletions .changeset/34726-enterprise-capability-advisory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@objectstack/cli': patch
---

feat(cli): `os validate`, `os verify` and `os serve` name a declared enterprise or cloud capability that no provider enforces

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

A stack that declares `requires: ['hierarchy-security']` and runs without the enterprise provider wired into `plugins[]` gets owner-only hierarchy scopes (`own_and_reports`, `unit`, `unit_and_below`), and before this nothing said so past `os validate`'s install hint.

- `os verify` now runs the capability-provider check `os validate` runs and reports every finding as an advisory: a `capabilities` array on the `--json` report (`token`, `message`, and `validate`: `error` when `os validate` refuses the stack over it, `warning` when it reports it), and one line each on the text face. It never changes `os verify`'s exit status, for any token.
- `os validate` and `os build` (and through the first, `os verify`) add a wiring check: an `enterprise`-edition token whose package resolves but which no `plugins[]` entry provides is a warning. Which tokens are `enterprise` is read from the capability registry's edition tags.
- `os validate --strict` (and `os validate --json --strict`), which already fails on any warning, now exits 1 for a stack whose `enterprise` capability package resolves but is not wired into `plugins[]`, or resolves but fails to load, while without `--strict`, and in `os build` (which has no flag that fails on warnings), the exit status is unchanged.
- The `enterprise` message names what happens without a provider (for `hierarchy-security`: the hierarchy scopes behave as owner-only) and its remedy reads "Install the package and add its plugin to `plugins[]`, or remove the token from `requires`".
- `os serve` prints the same sentence once at start-up for a declared enterprise or cloud token that nothing mounts. The boot itself is unchanged.
18 changes: 14 additions & 4 deletions content/docs/deployment/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2955,9 +2955,17 @@ os verify --dashboard-windows # Also prove each dashboard date
them, and `os validate` prints them. This stage is the rule registry, not all
of `os validate`: the `defineStack` provenance refusal (a config whose
default export `defineStack` did not build, `STACK_PROVENANCE_MISSING`), the
package-docs lint, the capability-provider check, the picklist-reference and
view-container-name checks and `--strict` stay `os validate`'s, so run it
too.
package-docs lint, the picklist-reference and view-container-name checks and
`--strict` stay `os validate`'s, so run it too.

The stage then runs `os validate`'s capability-provider check over every
declared `requires` token and reports each finding as an **advisory**, in
the sentence `os validate` prints: a cloud-only token, an `enterprise` token
whose package is not installed, and an `enterprise` token whose package
resolves but which no plugin in `plugins[]` provides (for
`hierarchy-security`, the hierarchy scopes then behave as owner-only). These
never change `os verify`'s exit status, including the cloud-only tokens
`os validate` refuses.
2. **Runtime.** Boot the app in-process and exercise it through the real HTTP
stack. The boot reads the project's `.env*` files first, the ones `os dev`
reads, from the directory holding the config (a variable already exported
Expand Down Expand Up @@ -3111,7 +3119,9 @@ document carries depends on where the run ended:
`path`, `message`, `hint`, plus `package` for a finding raised inside one
package of the artifact), or the schema issues when the stack does not parse.
- **Reached the runtime stage:** the report — `app`, `config`, `multiTenant`,
`seed` (the boot's seed: its `status`, per-source counts, `totals` and the
`capabilities` (the capability-provider advisories: `token`, `message`, and
`validate`, which is `error` when `os validate` refuses the stack over it and
`warning` when it reports it; `[]` when there are none), `seed` (the boot's seed: its `status`, per-source counts, `totals` and the
`hardFailures` it adds), `crud`, `rls` (with `--rls`), `referenceShapes` (with `--reference-shapes`),
`deleteBehaviors` (with `--delete-behaviors`), `uniqueScopes` (with
`--unique-scopes`; its `boot` names the legs the run could prove),
Expand Down
2 changes: 1 addition & 1 deletion content/docs/permissions/administrator-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Three similarly-named things, three different jobs — don't mix them up:

| Object | Job |
|:--|:--|
| **Business unit** (`sys_business_unit`) | The hierarchy. Drives visibility depth (`unit`, `unit_and_below`) and delegated-admin boundaries |
| **Business unit** (`sys_business_unit`) | The hierarchy. Drives visibility depth (`unit`, `unit_and_below`; enforced by the enterprise edition, owner-only on the open edition) and delegated-admin boundaries |
| **Team** (`sys_team`) | Flat collaboration group. Teams *receive* sharing; they never carry capability |
| **Organization** (`sys_organization`) | The tenant itself — your company's account, not a node inside it |

Expand Down
4 changes: 3 additions & 1 deletion content/docs/permissions/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ widens); **row-level security** is the expert escape hatch that narrows.
without a declared rule stay visible by default — see the
[FLS posture note](/docs/permissions/authorization#combination-semantics-the-fixed-order)).
Object access scopes go from `own` through `own_and_reports`, `unit`,
`unit_and_below`, to `org`. There is no Profile concept and the word "role"
`unit_and_below`, to `org`; the three hierarchy scopes in between are enforced by
the enterprise edition only and behave as `own` on the open edition (see
[Access depth](/docs/permissions/permission-sets#access-depth--readscope--writescope-adr-0057-d1)). There is no Profile concept and the word "role"
is reserved (D3) — if you knew the v1 model, start at
[Profiles (removed)](/docs/permissions/profiles) and
[Positions](/docs/permissions/positions).
Expand Down
7 changes: 6 additions & 1 deletion content/docs/permissions/permission-sets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ the anchor decides *which* unit `unit*` means.
> **Open-core boundary (ADR-0016).** `own` and `org` are open-source. The
> hierarchy-relative scopes (`own_and_reports` / `unit` / `unit_and_below`)
> require the enterprise hierarchy resolver; without it they **fail closed to
> `own`** (never fail-open).
> `own`** (never fail-open). Only the enterprise edition enforces them: the stack
> declares `requires: ['hierarchy-security']` (`defineStack` refuses a hierarchy
> scope without it) and wires `@objectstack/security-enterprise`'s plugin into
> `plugins[]`. When the token is declared but no plugin in `plugins[]` provides
> it, `os validate`, `os verify` (an advisory under `capabilities` in `--json`)
> and `os serve` at start-up each name the token and the owner-only fallback.

> **A depth axis beside the super-user bit that bypasses it is REFUSED.** The
> read-scope resolver answers `org` on the super-user bit *before* it consults
Expand Down
3 changes: 2 additions & 1 deletion content/docs/permissions/permissions-matrix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ graph TD
- **Scope depth** — grant a permission set `readScope: 'unit'` /
`'unit_and_below'`; the owner-match widens to the caller's unit (or its
subtree). A position assignment's `business_unit_id` anchor decides *which*
unit that means for multi-unit users (ADR-0090 Addendum).
unit that means for multi-unit users (ADR-0090 Addendum). Enterprise edition
only: on the open edition these scopes behave as owner-only.
- **Sharing-rule recipients** — share with
`{ type: 'unit_and_subordinates', value: 'east' }` to reach everyone in the
East subtree, or `{ type: 'position', value: 'sales_manager' }` to reach a
Expand Down
3 changes: 3 additions & 0 deletions content/docs/permissions/positions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ Visibility depth comes from two dedicated structures:
- the **manager chain** (`sys_user.manager_id`) — consumed by
`own_and_reports`.

The depth grants (`own_and_reports`, `unit`, `unit_and_below`) are enforced by
the enterprise edition only; on the open edition they behave as owner-only.

**There is no implicit "managers see subordinates' records" grant.** Upward
visibility is always an explicit opt-in: a sharing rule targeting a position
or BU subtree, or a scope-depth grant on the permission set. See
Expand Down
17 changes: 15 additions & 2 deletions packages/cli/src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import { stackFilterJudge } from '../utils/authoring-filter-judge.js';
import { buildAccessMatrix, diffAccessMatrix } from '@objectstack/lint';
import { runAuthoringRules, splitBySeverity, authoringRulesFor } from '@objectstack/lint';
import { resolveJsxGateManifest, printJsxGateNotices } from '../utils/sdui-manifest.js';
import { preflightDeclaredCapabilities, renderCapabilityMessage } from '../utils/capability-preflight.js';
import {
preflightDeclaredCapabilities,
preflightProviderWiring,
renderCapabilityMessage,
} from '../utils/capability-preflight.js';
import { collectAndLintDocs, placeCollectedDocs, type DocIssue } from '../utils/collect-docs.js';
import { buildRuntimeBundle, cleanupOldRuntimeBundles } from '../utils/build-runtime.js';
import {
Expand Down Expand Up @@ -1023,7 +1027,16 @@ export default class Compile extends Command {
// `{ token, message }` record beside its own preflight call, so
// mirroring it is what keeps the two commands from reporting
// different sets. One list cannot drift from itself.
capProviderWarnings = capPreflight.warnings.map((c) => ({
// An `enterprise` token whose package resolves but which no `plugins[]`
// entry provides is enforced by nothing (`preflightProviderWiring`), the
// same advisory `os validate` raises.
const capWiring = await preflightProviderWiring({
requires: (config as { requires?: unknown }).requires,
packages: packageEntries,
plugins: (config as { plugins?: unknown }).plugins,
projectDir: path.dirname(absolutePath),
});
capProviderWarnings = [...capPreflight.warnings, ...capWiring].map((c) => ({
token: c.token,
message: renderCapabilityMessage(c),
}));
Expand Down
32 changes: 30 additions & 2 deletions packages/cli/src/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import {
type SeedSettlementSnapshot,
type SeedSuppressionReason,
} from '@objectstack/spec/contracts';
import { missingProviderMessage } from '../utils/capability-preflight.js';
import { judgeDeclaredCapabilities, missingProviderMessage } from '../utils/capability-preflight.js';
import { composeSeedSettledMessage } from '../utils/seed-settled-message.js';
// The deployment's product name, for `AuthPlugin` — the same resolver the email
// capability's template context reads (`resolveEmailCapabilityArg`), so the two
Expand Down Expand Up @@ -5469,14 +5469,42 @@ export default class Serve extends Command {
const hasPluginMatching = (identities: readonly string[]) =>
Serve.providesCapability(plugins, identities) || Serve.providesCapability(resolverMounted, identities);

// A DECLARED token this resolver has no row for, and no tier block
// handles, is mounted by nothing here: an `enterprise` provider comes
// only from the app's own `plugins[]`, a cloud-only tier from a cloud
// runtime. The loop below stays quiet for those (they are known
// vocabulary, not typos), and the sharing layer then fails closed to
// owner-only without a word. Say it once at start-up, in the sentence
// `os validate` and `os verify` print for the same token, and only when
// nothing in `plugins[]` provides it. A warning, never a refusal: the
// boot is unchanged.
const unmountedKnownTokens = [...declaredRequires].filter(
(cap) =>
!CAPABILITY_PROVIDERS[cap] &&
!Object.prototype.hasOwnProperty.call(Serve.CAPABILITY_TO_TIER, cap) &&
PLATFORM_CAPABILITY_TOKENS.includes(cap),
);
if (unmountedKnownTokens.length > 0) {
const judged = await judgeDeclaredCapabilities({
requires: unmountedKnownTokens,
packages: [],
plugins,
projectDir: hostRoot,
});
for (const a of [...judged.errors, ...judged.warnings]) {
console.warn(chalk.yellow(` ⚠ ${a.message}`));
}
}

for (const cap of requires) {
const spec = CAPABILITY_PROVIDERS[cap];
if (!spec) {
// No provider in this runtime. Tier-gated tokens (ai/ai-studio/i18n/
// ui/auth) are handled by their dedicated blocks above; other KNOWN
// vocabulary tokens are provided elsewhere (`hierarchy-security` via
// an explicit enterprise plugin in `plugins[]`, `ai-seat`/`governance`
// by cloud's objectos-runtime) — stay quiet for those. An UNKNOWN
// by cloud's objectos-runtime) — this loop stays quiet for those; the
// start-up line above names any that nothing provides. An UNKNOWN
// declared token is a typo that was previously ignored SILENTLY
// (#3265) — warn loudly. Warn-first: intended to become a hard error
// once the vocabulary proves complete (Prime Directive #12).
Expand Down
17 changes: 15 additions & 2 deletions packages/cli/src/commands/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import { artifactPackages, runPerPackageAuthoringRules } from '../utils/artifact
import { stackFilterJudge } from '../utils/authoring-filter-judge.js';
import { runAuthoringRules, splitBySeverity, authoringRulesFor } from '@objectstack/lint';
import { resolveJsxGateManifest, printJsxGateNotices } from '../utils/sdui-manifest.js';
import { preflightDeclaredCapabilities, renderCapabilityMessage } from '../utils/capability-preflight.js';
import {
preflightDeclaredCapabilities,
preflightProviderWiring,
renderCapabilityMessage,
} from '../utils/capability-preflight.js';
import { collectAndLintDocs, type DocIssue } from '../utils/collect-docs.js';
import { collectSeedFiles } from '../utils/bundle-seed-files.js';
import { collectConnectorSpecFiles } from '../utils/bundle-connector-spec-files.js';
Expand Down Expand Up @@ -1035,7 +1039,16 @@ export default class Validate extends Command {
projectDir: dirname(absolutePath),
});
const capProviderErrors = capProviderPreflight.errors;
capProviderWarnings = capProviderPreflight.warnings.map((c) => ({
// An `enterprise` token whose package resolves is still enforced by
// nothing until a `plugins[]` entry provides it: no runtime mounts an
// enterprise provider from `requires` (`preflightProviderWiring`).
const capProviderWiring = await preflightProviderWiring({
requires: (config as { requires?: unknown }).requires,
packages: packageEntries,
plugins: (config as { plugins?: unknown }).plugins,
projectDir: dirname(absolutePath),
});
capProviderWarnings = [...capProviderPreflight.warnings, ...capProviderWiring].map((c) => ({
token: c.token,
message: renderCapabilityMessage(c),
}));
Expand Down
60 changes: 58 additions & 2 deletions packages/cli/src/commands/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ import { authoringRulesFor } from '@objectstack/lint';
import { loadConfig, resolveConfigPath } from '../utils/config.js';
import { loadProjectEnvFiles } from '../utils/schema-migrate.js';
import { judgeAuthorTimeRules, VERIFY_RULE_COMMAND } from '../utils/author-time-rules.js';
import { artifactPackages } from '../utils/artifact-packages.js';
import { judgeDeclaredCapabilities } from '../utils/capability-preflight.js';
import {
printError,
printStep,
printSuccess,
printWarning,
printAuthoringRuleErrors,
formatZodErrors,
JSON_FULL_LIST_REMEDY,
Expand Down Expand Up @@ -88,13 +91,26 @@ export function resolveVerifyMultiTenant(flags: { 'multi-tenant'?: boolean }): b
return Boolean(flags['multi-tenant']) || postureEnforcesWall(resolveTenancyPosture());
}

/**
* One capability finding on `os verify --json`'s `capabilities`: the sentence
* `os validate` prints for it, and that door's verdict on it. Advisory on this
* command whatever `validate` says.
*/
export interface VerifyCapabilityAdvisory {
readonly token: string;
readonly message: string;
readonly validate: 'error' | 'warning';
}

/**
* `objectstack verify` — two stages, in order:
*
* 1. the author-time rules — the registry `os validate` runs, over the stack
* prepared the way `os validate` prepares it (`utils/author-time-rules.ts`).
* A gating finding fails the run with those findings, and stage 2 never
* starts (#21323);
* starts (#21323). Then the capability provider check `os validate`
* runs, reported as advisories that never change the exit code
* (`capabilities` on the `--json` face);
* 2. boot the app in-process, with the project's `.env*` files loaded as
* `os dev` loads them, and exercise it through the real HTTP stack,
* asserting runtime behavior the static gates can't see:
Expand Down Expand Up @@ -280,6 +296,7 @@ export default class Verify extends Command {
// Stage 1 — the author-time rules, before anything boots. A failure here
// exits inside the call; see `runAuthorTimeStage`.
await this.runAuthorTimeStage(config as Record<string, unknown>, absolutePath, flags.json);
const capabilities = await this.runCapabilityAdvisories(config as Record<string, unknown>, absolutePath, flags.json);

const multiTenant = resolveVerifyMultiTenant(flags);

Expand Down Expand Up @@ -495,7 +512,7 @@ export default class Verify extends Command {
// `emitJson`, not `this.log`: stdout is reserved (see `run()`), so the
// report has to leave through the real stream — and awaiting the write
// drains a report larger than one pipe buffer before `this.exit` below.
await emitJson({ app: crud.app, config: absolutePath, multiTenant, seed, crud, rls, referenceShapes, deleteBehaviors, uniqueScopes, parentWriteReach, dashboardWindows, hardFailures });
await emitJson({ app: crud.app, config: absolutePath, multiTenant, capabilities, seed, crud, rls, referenceShapes, deleteBehaviors, uniqueScopes, parentWriteReach, dashboardWindows, hardFailures });
} else {
this.log(formatReport(crud));
this.log(formatSeedReport(seed));
Expand All @@ -519,6 +536,45 @@ export default class Verify extends Command {
this.exit(hardFailures > 0 ? 1 : 0);
}

/**
* Stage 1, second half — the capability provider check `os validate` runs,
* reported as ADVISORIES.
*
* `os verify` used to run none of it, so a stack declaring a capability no
* provider here enforces passed green: `requires: ['hierarchy-security']`
* with no enterprise provider (the hierarchy scopes then run owner-only,
* silently), and every cloud-only token `os validate` refuses. Each finding
* is the sentence `os validate` prints for it, with `validate` naming that
* door's verdict (`error`: it refuses the stack; `warning`: it reports it).
* Advisory here by decision: this stage never changes `verify`'s exit code,
* for any token. The text face prints them; the `--json` face carries them
* as `capabilities`.
*/
private async runCapabilityAdvisories(
config: Record<string, unknown>,
absolutePath: string,
json: boolean,
): Promise<VerifyCapabilityAdvisory[]> {
if (!json) printStep('Checking that every required capability has a provider in this edition...');
const judged = await judgeDeclaredCapabilities({
requires: config.requires,
packages: artifactPackages(config),
plugins: config.plugins,
projectDir: dirname(absolutePath),
});
const advisories: VerifyCapabilityAdvisory[] = [
...judged.errors.map((a) => ({ ...a, validate: 'error' as const })),
...judged.warnings.map((a) => ({ ...a, validate: 'warning' as const })),
];
if (!json) {
for (const a of advisories) {
printWarning(a.validate === 'error' ? `${a.message} (\`os validate\` refuses this stack.)` : a.message);
}
if (advisories.length > 0) this.log('');
}
return advisories;
}

/**
* Stage 1 — the author-time rule registry `os validate` runs, over the stack
* prepared the way `os validate` prepares it (#21323).
Expand Down
Loading
Loading