Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
26 changes: 24 additions & 2 deletions src/security/host-execution-policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,33 @@ import {
} from "./host-execution-policy.ts";

describe("security/host-execution-policy operator override", () => {
it("treats the deprecated override as ignored in every runtime topology", () => {
it("lets an operator grant host execution to a shared runtime", () => {
// The platform's own rendering and executor runtime is shared, and no dedicated
// isolated runtime is provisioned for hosted project previews or agents. Without
// an honoured grant, tenant /api/* returns 503 PROJECT_EXECUTION_UNAVAILABLE and
// the Studio preview pane fails to load (veryfront-issue-inbox#848, #356).
//
// This re-accepts a known posture: tenant code runs in the shared process, where
// per-request separation is source scoping rather than a tenant boundary. It is
// the posture production already runs. Withdrawing it belongs with routing
// execution to a dedicated runtime, not ahead of it.
assertEquals(
resolveHostProjectExecutionPosture({ sharedRuntime: true, overrideConfigured: true }),
{ allowHostProjectCodeExecution: false, overrideIgnored: true },
{ allowHostProjectCodeExecution: true, overrideIgnored: false },
);
});

it("keeps a shared runtime fail-closed when no grant is configured", () => {
assertEquals(
resolveHostProjectExecutionPosture({ sharedRuntime: true, overrideConfigured: false }),
{ allowHostProjectCodeExecution: false, overrideIgnored: false },
);
});

it("reports the grant as ignored where it changes nothing", () => {
// A dedicated runtime already carries the capability, so the grant is redundant
// there. Reporting it lets startup surface stale operator configuration without
// implying it did any work.
assertEquals(
resolveHostProjectExecutionPosture({ sharedRuntime: false, overrideConfigured: true }),
{ allowHostProjectCodeExecution: true, overrideIgnored: true },
Expand Down
10 changes: 7 additions & 3 deletions src/security/host-execution-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function isHostProjectExecutionOverrideConfigured(
}
}

/** @deprecated The override no longer enables host execution. */
/** @deprecated Prefer isHostProjectExecutionOverrideConfigured. */
export const isHostProjectExecutionOverrideEnabled = isHostProjectExecutionOverrideConfigured;

/** Resolve the only two supported production execution topologies. */
Expand All @@ -43,7 +43,11 @@ export function resolveHostProjectExecutionPosture(options: {
overrideConfigured: boolean;
}): { allowHostProjectCodeExecution: boolean; overrideIgnored: boolean } {
return {
allowHostProjectCodeExecution: !options.sharedRuntime,
overrideIgnored: options.overrideConfigured,
// A dedicated runtime always carries the capability. A shared runtime carries it
// only where an operator has granted it at the host-owned entrypoint.
allowHostProjectCodeExecution: !options.sharedRuntime || options.overrideConfigured,
Comment thread
kwakayama marked this conversation as resolved.
Comment thread
kwakayama marked this conversation as resolved.
// Configured but redundant: a dedicated runtime already had the capability, so the
// grant did no work and startup can report it as stale operator configuration.
overrideIgnored: options.overrideConfigured && !options.sharedRuntime,
Comment thread
kwakayama marked this conversation as resolved.
};
}
Loading