@stigmer/server 3.22.1 → 3.23.1-dev.20260923075205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifactstorage/artifact-storage.d.ts +29 -31
- package/dist/artifactstorage/artifact-storage.d.ts.map +1 -1
- package/dist/artifactstorage/artifact-storage.js +5 -7
- package/dist/artifactstorage/artifact-storage.js.map +1 -1
- package/dist/artifactstorage/r2-storage.d.ts +12 -7
- package/dist/artifactstorage/r2-storage.d.ts.map +1 -1
- package/dist/artifactstorage/r2-storage.js +6 -14
- package/dist/artifactstorage/r2-storage.js.map +1 -1
- package/dist/authorization/authorizer.d.ts +4 -8
- package/dist/authorization/authorizer.d.ts.map +1 -1
- package/dist/authorization/authorizer.js +5 -9
- package/dist/authorization/authorizer.js.map +1 -1
- package/dist/authorization/derived-tuples.d.ts.map +1 -1
- package/dist/authorization/derived-tuples.js +10 -25
- package/dist/authorization/derived-tuples.js.map +1 -1
- package/dist/authorization/evaluator.d.ts +7 -8
- package/dist/authorization/evaluator.d.ts.map +1 -1
- package/dist/authorization/evaluator.js +4 -20
- package/dist/authorization/evaluator.js.map +1 -1
- package/dist/authorization/list-read-scope.d.ts.map +1 -1
- package/dist/authorization/list-read-scope.js +5 -9
- package/dist/authorization/list-read-scope.js.map +1 -1
- package/dist/authorization/model/agent.d.ts.map +1 -1
- package/dist/authorization/model/agent.js +4 -5
- package/dist/authorization/model/agent.js.map +1 -1
- package/dist/authorization/model/agent_instance.d.ts.map +1 -1
- package/dist/authorization/model/agent_instance.js +2 -2
- package/dist/authorization/model/agent_instance.js.map +1 -1
- package/dist/authorization/model/mcp_server.d.ts.map +1 -1
- package/dist/authorization/model/mcp_server.js +2 -2
- package/dist/authorization/model/mcp_server.js.map +1 -1
- package/dist/authorization/model/plugin.d.ts.map +1 -1
- package/dist/authorization/model/plugin.js +3 -4
- package/dist/authorization/model/plugin.js.map +1 -1
- package/dist/authorization/model/rewrite.d.ts +8 -10
- package/dist/authorization/model/rewrite.d.ts.map +1 -1
- package/dist/authorization/model/rewrite.js +0 -3
- package/dist/authorization/model/rewrite.js.map +1 -1
- package/dist/authorization/model/skill.d.ts.map +1 -1
- package/dist/authorization/model/skill.js +2 -2
- package/dist/authorization/model/skill.js.map +1 -1
- package/dist/authorization/model/workflow.d.ts.map +1 -1
- package/dist/authorization/model/workflow.js +2 -2
- package/dist/authorization/model/workflow.js.map +1 -1
- package/dist/authorization/model/workflow_instance.d.ts.map +1 -1
- package/dist/authorization/model/workflow_instance.js +2 -2
- package/dist/authorization/model/workflow_instance.js.map +1 -1
- package/dist/authorization/organization-directory.d.ts.map +1 -1
- package/dist/authorization/organization-directory.js +2 -3
- package/dist/authorization/organization-directory.js.map +1 -1
- package/dist/authorization/store-test-kit.d.ts +0 -6
- package/dist/authorization/store-test-kit.d.ts.map +1 -1
- package/dist/authorization/store-test-kit.js +16 -62
- package/dist/authorization/store-test-kit.js.map +1 -1
- package/dist/authorization/tuples.d.ts +13 -32
- package/dist/authorization/tuples.d.ts.map +1 -1
- package/dist/authorization/tuples.js +3 -11
- package/dist/authorization/tuples.js.map +1 -1
- package/dist/boot/compose.d.ts.map +1 -1
- package/dist/boot/compose.js +49 -24
- package/dist/boot/compose.js.map +1 -1
- package/dist/boot/config.d.ts +4 -3
- package/dist/boot/config.d.ts.map +1 -1
- package/dist/boot/config.js.map +1 -1
- package/dist/boot/skill-transfer-origin.d.ts +52 -0
- package/dist/boot/skill-transfer-origin.d.ts.map +1 -0
- package/dist/boot/skill-transfer-origin.js +54 -0
- package/dist/boot/skill-transfer-origin.js.map +1 -0
- package/dist/domain/agent/controller.d.ts.map +1 -1
- package/dist/domain/agent/controller.js +4 -4
- package/dist/domain/agent/controller.js.map +1 -1
- package/dist/domain/agentchannel/controller.d.ts.map +1 -1
- package/dist/domain/agentchannel/controller.js +3 -1
- package/dist/domain/agentchannel/controller.js.map +1 -1
- package/dist/domain/agentexecution/controller.d.ts.map +1 -1
- package/dist/domain/agentexecution/controller.js +3 -1
- package/dist/domain/agentexecution/controller.js.map +1 -1
- package/dist/domain/agentinstance/controller.d.ts.map +1 -1
- package/dist/domain/agentinstance/controller.js +3 -4
- package/dist/domain/agentinstance/controller.js.map +1 -1
- package/dist/domain/agentshare/constants.d.ts +6 -11
- package/dist/domain/agentshare/constants.d.ts.map +1 -1
- package/dist/domain/agentshare/constants.js +8 -16
- package/dist/domain/agentshare/constants.js.map +1 -1
- package/dist/domain/agentshare/controller.d.ts.map +1 -1
- package/dist/domain/agentshare/controller.js +3 -1
- package/dist/domain/agentshare/controller.js.map +1 -1
- package/dist/domain/agentshare/steps.d.ts +18 -25
- package/dist/domain/agentshare/steps.d.ts.map +1 -1
- package/dist/domain/agentshare/steps.js +41 -142
- package/dist/domain/agentshare/steps.js.map +1 -1
- package/dist/domain/environment/controller.d.ts.map +1 -1
- package/dist/domain/environment/controller.js +2 -3
- package/dist/domain/environment/controller.js.map +1 -1
- package/dist/domain/executioncontext/controller.d.ts.map +1 -1
- package/dist/domain/executioncontext/controller.js +2 -1
- package/dist/domain/executioncontext/controller.js.map +1 -1
- package/dist/domain/mcpserver/controller.d.ts.map +1 -1
- package/dist/domain/mcpserver/controller.js +3 -4
- package/dist/domain/mcpserver/controller.js.map +1 -1
- package/dist/domain/plugin/controller.d.ts +3 -7
- package/dist/domain/plugin/controller.d.ts.map +1 -1
- package/dist/domain/plugin/controller.js +9 -11
- package/dist/domain/plugin/controller.js.map +1 -1
- package/dist/domain/plugin/push.d.ts +7 -5
- package/dist/domain/plugin/push.d.ts.map +1 -1
- package/dist/domain/plugin/push.js +8 -14
- package/dist/domain/plugin/push.js.map +1 -1
- package/dist/domain/schedule/controller.d.ts.map +1 -1
- package/dist/domain/schedule/controller.js +3 -1
- package/dist/domain/schedule/controller.js.map +1 -1
- package/dist/domain/session/controller.d.ts.map +1 -1
- package/dist/domain/session/controller.js +3 -2
- package/dist/domain/session/controller.js.map +1 -1
- package/dist/domain/skill/constants.d.ts +26 -3
- package/dist/domain/skill/constants.d.ts.map +1 -1
- package/dist/domain/skill/constants.js +26 -3
- package/dist/domain/skill/constants.js.map +1 -1
- package/dist/domain/skill/controller.d.ts +6 -11
- package/dist/domain/skill/controller.d.ts.map +1 -1
- package/dist/domain/skill/controller.js +33 -24
- package/dist/domain/skill/controller.js.map +1 -1
- package/dist/domain/skill/push.d.ts +2 -2
- package/dist/domain/skill/push.d.ts.map +1 -1
- package/dist/domain/skill/push.js +2 -2
- package/dist/domain/skill/push.js.map +1 -1
- package/dist/domain/skill/transfer/handler.d.ts +17 -9
- package/dist/domain/skill/transfer/handler.d.ts.map +1 -1
- package/dist/domain/skill/transfer/handler.js +19 -8
- package/dist/domain/skill/transfer/handler.js.map +1 -1
- package/dist/domain/skill/transfer/slots.d.ts +26 -41
- package/dist/domain/skill/transfer/slots.d.ts.map +1 -1
- package/dist/domain/skill/transfer/slots.js +80 -87
- package/dist/domain/skill/transfer/slots.js.map +1 -1
- package/dist/domain/skill/transfer/staging.d.ts +48 -0
- package/dist/domain/skill/transfer/staging.d.ts.map +1 -0
- package/dist/domain/skill/transfer/staging.js +127 -0
- package/dist/domain/skill/transfer/staging.js.map +1 -0
- package/dist/domain/workflow/agent-call-references.d.ts +54 -0
- package/dist/domain/workflow/agent-call-references.d.ts.map +1 -0
- package/dist/domain/workflow/agent-call-references.js +97 -0
- package/dist/domain/workflow/agent-call-references.js.map +1 -0
- package/dist/domain/workflow/controller.d.ts.map +1 -1
- package/dist/domain/workflow/controller.js +14 -6
- package/dist/domain/workflow/controller.js.map +1 -1
- package/dist/domain/workflow/registry/data/task-kind-registry.json +1 -1
- package/dist/domain/workflow/validation/task-config-constraints.d.ts +10 -1
- package/dist/domain/workflow/validation/task-config-constraints.d.ts.map +1 -1
- package/dist/domain/workflow/validation/task-config-constraints.js +3 -2
- package/dist/domain/workflow/validation/task-config-constraints.js.map +1 -1
- package/dist/domain/workflowexecution/controller.d.ts.map +1 -1
- package/dist/domain/workflowexecution/controller.js +4 -2
- package/dist/domain/workflowexecution/controller.js.map +1 -1
- package/dist/domain/workflowinstance/controller.d.ts.map +1 -1
- package/dist/domain/workflowinstance/controller.js +3 -4
- package/dist/domain/workflowinstance/controller.js.map +1 -1
- package/dist/extensions/authorization-queries.d.ts +6 -5
- package/dist/extensions/authorization-queries.d.ts.map +1 -1
- package/dist/extensions/list-read-scope.d.ts +1 -1
- package/dist/extensions/resource-authorization.d.ts +3 -2
- package/dist/extensions/resource-authorization.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pipeline/apiresource-meta.d.ts +12 -3
- package/dist/pipeline/apiresource-meta.d.ts.map +1 -1
- package/dist/pipeline/apiresource-meta.js +21 -10
- package/dist/pipeline/apiresource-meta.js.map +1 -1
- package/dist/pipeline/steps/authorization-tuples.d.ts +9 -3
- package/dist/pipeline/steps/authorization-tuples.d.ts.map +1 -1
- package/dist/pipeline/steps/authorization-tuples.js +9 -11
- package/dist/pipeline/steps/authorization-tuples.js.map +1 -1
- package/dist/pipeline/steps/references.d.ts +178 -20
- package/dist/pipeline/steps/references.d.ts.map +1 -1
- package/dist/pipeline/steps/references.js +344 -43
- package/dist/pipeline/steps/references.js.map +1 -1
- package/dist/pipeline/steps/resolve-artifact-source.d.ts +11 -8
- package/dist/pipeline/steps/resolve-artifact-source.d.ts.map +1 -1
- package/dist/pipeline/steps/resolve-artifact-source.js +8 -4
- package/dist/pipeline/steps/resolve-artifact-source.js.map +1 -1
- package/dist/query/search/controller.js +0 -1
- package/dist/query/search/controller.js.map +1 -1
- package/dist/query/search/criteria.d.ts +1 -5
- package/dist/query/search/criteria.d.ts.map +1 -1
- package/dist/query/search/criteria.js +3 -13
- package/dist/query/search/criteria.js.map +1 -1
- package/dist/query/search/handler.d.ts +5 -4
- package/dist/query/search/handler.d.ts.map +1 -1
- package/dist/query/search/handler.js +7 -6
- package/dist/query/search/handler.js.map +1 -1
- package/dist/query/search/query-store.d.ts.map +1 -1
- package/dist/query/search/query-store.js +0 -2
- package/dist/query/search/query-store.js.map +1 -1
- package/dist/store/interface.d.ts +3 -6
- package/dist/store/interface.d.ts.map +1 -1
- package/dist/store/interface.js.map +1 -1
- package/dist/store/postgres/migrations.d.ts +3 -1
- package/dist/store/postgres/migrations.d.ts.map +1 -1
- package/dist/store/postgres/migrations.js +35 -1
- package/dist/store/postgres/migrations.js.map +1 -1
- package/dist/store/postgres/store.d.ts.map +1 -1
- package/dist/store/postgres/store.js +4 -9
- package/dist/store/postgres/store.js.map +1 -1
- package/dist/store/public-visibility-retired.d.ts +67 -0
- package/dist/store/public-visibility-retired.d.ts.map +1 -0
- package/dist/store/public-visibility-retired.js +55 -0
- package/dist/store/public-visibility-retired.js.map +1 -0
- package/dist/store/sqlite/migrations.d.ts +3 -1
- package/dist/store/sqlite/migrations.d.ts.map +1 -1
- package/dist/store/sqlite/migrations.js +36 -1
- package/dist/store/sqlite/migrations.js.map +1 -1
- package/dist/store/sqlite/store.d.ts.map +1 -1
- package/dist/store/sqlite/store.js +4 -8
- package/dist/store/sqlite/store.js.map +1 -1
- package/package.json +6 -6
- package/src/artifactstorage/__tests__/artifact-storage.test.ts +36 -33
- package/src/artifactstorage/__tests__/r2-storage.test.ts +11 -13
- package/src/artifactstorage/artifact-storage.ts +37 -33
- package/src/artifactstorage/r2-storage.ts +6 -15
- package/src/authorization/README.md +24 -26
- package/src/authorization/__tests__/authorizer.test.ts +10 -9
- package/src/authorization/__tests__/derived-tuples.test.ts +4 -11
- package/src/authorization/__tests__/evaluator.test.ts +14 -73
- package/src/authorization/__tests__/facts.test.ts +2 -2
- package/src/authorization/__tests__/fixtures/fga/agent-instance-creation.fga.yaml +19 -27
- package/src/authorization/__tests__/fixtures/fga/blueprint-private-visibility.fga.yaml +6 -98
- package/src/authorization/__tests__/fixtures/fga/default-instance-inheritance.fga.yaml +4 -61
- package/src/authorization/__tests__/fixtures/fga/mcp-server-authoring.fga.yaml +1 -15
- package/src/authorization/__tests__/fixtures/fga/org-admin-owner-inheritance.fga.yaml +1 -21
- package/src/authorization/__tests__/fixtures/fga/platform-visibility.fga.yaml +1 -25
- package/src/authorization/__tests__/fixtures/fga/workflow-execution-sharing.fga.yaml +1 -3
- package/src/authorization/__tests__/list-read-scope.test.ts +18 -17
- package/src/authorization/__tests__/store-tests.test.ts +2 -6
- package/src/authorization/__tests__/tuples.test.ts +12 -11
- package/src/authorization/authorizer.ts +4 -9
- package/src/authorization/derived-tuples.ts +14 -31
- package/src/authorization/evaluator.ts +8 -44
- package/src/authorization/list-read-scope.ts +5 -11
- package/src/authorization/model/agent.ts +2 -5
- package/src/authorization/model/agent_instance.ts +0 -2
- package/src/authorization/model/mcp_server.ts +0 -2
- package/src/authorization/model/plugin.ts +1 -4
- package/src/authorization/model/rewrite.ts +8 -13
- package/src/authorization/model/skill.ts +0 -2
- package/src/authorization/model/workflow.ts +0 -2
- package/src/authorization/model/workflow_instance.ts +0 -2
- package/src/authorization/organization-directory.ts +1 -3
- package/src/authorization/store-test-kit.ts +16 -75
- package/src/authorization/tuples.ts +16 -39
- package/src/boot/__tests__/skill-transfer-origin.test.ts +72 -0
- package/src/boot/compose.ts +62 -25
- package/src/boot/config.ts +4 -3
- package/src/boot/skill-transfer-origin.ts +76 -0
- package/src/domain/agent/__tests__/agent.test.ts +11 -4
- package/src/domain/agent/controller.ts +7 -7
- package/src/domain/agentchannel/__tests__/agentchannel.test.ts +223 -48
- package/src/domain/agentchannel/controller.ts +6 -1
- package/src/domain/agentexecution/controller.ts +6 -1
- package/src/domain/agentinstance/controller.ts +6 -12
- package/src/domain/agentshare/__tests__/agentshare.test.ts +196 -172
- package/src/domain/agentshare/__tests__/create-authorization.test.ts +16 -31
- package/src/domain/agentshare/constants.ts +14 -26
- package/src/domain/agentshare/controller.ts +6 -1
- package/src/domain/agentshare/steps.ts +41 -194
- package/src/domain/environment/controller.ts +5 -8
- package/src/domain/executioncontext/controller.ts +5 -1
- package/src/domain/mcpserver/__tests__/mcpserver.test.ts +115 -28
- package/src/domain/mcpserver/__tests__/oauth-handshake.test.ts +53 -18
- package/src/domain/mcpserver/controller.ts +6 -12
- package/src/domain/plugin/controller.ts +16 -25
- package/src/domain/plugin/push.ts +8 -16
- package/src/domain/schedule/controller.ts +6 -1
- package/src/domain/session/controller.ts +12 -4
- package/src/domain/skill/__tests__/skill.test.ts +5 -3
- package/src/domain/skill/__tests__/slots.test.ts +113 -60
- package/src/domain/skill/__tests__/staging.test.ts +304 -0
- package/src/domain/skill/constants.ts +28 -3
- package/src/domain/skill/controller.ts +44 -42
- package/src/domain/skill/push.ts +3 -3
- package/src/domain/skill/transfer/handler.ts +33 -15
- package/src/domain/skill/transfer/slots.ts +89 -100
- package/src/domain/skill/transfer/staging.ts +191 -0
- package/src/domain/workflow/__tests__/agent-call-references.test.ts +222 -0
- package/src/domain/workflow/agent-call-references.ts +157 -0
- package/src/domain/workflow/controller.ts +28 -10
- package/src/domain/workflow/registry/data/task-kind-registry.json +1 -1
- package/src/domain/workflow/validation/task-config-constraints.ts +7 -3
- package/src/domain/workflowexecution/controller.ts +7 -2
- package/src/domain/workflowinstance/controller.ts +6 -12
- package/src/extensions/__tests__/built-in-authorization-composed.test.ts +32 -19
- package/src/extensions/__tests__/extension-composition.test.ts +4 -4
- package/src/extensions/__tests__/list-read-scope-composed.test.ts +9 -6
- package/src/extensions/authorization-queries.ts +6 -5
- package/src/extensions/list-read-scope.ts +1 -1
- package/src/extensions/resource-authorization.ts +3 -5
- package/src/index.ts +0 -1
- package/src/pipeline/__tests__/supports-visibility.test.ts +112 -0
- package/src/pipeline/apiresource-meta.ts +21 -10
- package/src/pipeline/steps/__tests__/authorization-tuples.test.ts +18 -31
- package/src/pipeline/steps/__tests__/references.test.ts +703 -0
- package/src/pipeline/steps/authorization-tuples.ts +9 -11
- package/src/pipeline/steps/references.ts +578 -70
- package/src/pipeline/steps/resolve-artifact-source.ts +20 -13
- package/src/query/search/__tests__/criteria.test.ts +0 -4
- package/src/query/search/__tests__/query-store.test.ts +11 -40
- package/src/query/search/controller.ts +0 -1
- package/src/query/search/criteria.ts +0 -14
- package/src/query/search/handler.ts +6 -7
- package/src/query/search/query-store.ts +0 -2
- package/src/store/__tests__/public-visibility-retired.test.ts +127 -0
- package/src/store/__tests__/store-contract.ts +6 -51
- package/src/store/interface.ts +3 -6
- package/src/store/postgres/__tests__/migrations.test.ts +187 -6
- package/src/store/postgres/__tests__/store-contract.test.ts +0 -2
- package/src/store/postgres/migrations.ts +48 -1
- package/src/store/postgres/store.ts +4 -11
- package/src/store/public-visibility-retired.ts +119 -0
- package/src/store/sqlite/__tests__/migrations.test.ts +191 -5
- package/src/store/sqlite/migrations.ts +45 -1
- package/src/store/sqlite/store.ts +4 -10
- package/src/transport/registry/__tests__/lanes.test.ts +1 -1
- package/dist/pipeline/steps/visibility-gates.d.ts +0 -27
- package/dist/pipeline/steps/visibility-gates.d.ts.map +0 -1
- package/dist/pipeline/steps/visibility-gates.js +0 -139
- package/dist/pipeline/steps/visibility-gates.js.map +0 -1
- package/src/authorization/__tests__/fixtures/fga/cross-org-share-creation.fga.yaml +0 -98
- package/src/authorization/__tests__/fixtures/fga/public-visibility-setter.fga.yaml +0 -52
- package/src/pipeline/steps/__tests__/visibility-gates.test.ts +0 -187
- package/src/pipeline/steps/visibility-gates.ts +0 -174
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pins the PUBLIC-visibility operator gates (C2 Stage 3, the Java
|
|
3
|
-
* PublicVisibilityEscalationPolicy port): the create door fires only on a
|
|
4
|
-
* new state declaring PUBLIC, the update door only on an ESCALATION to
|
|
5
|
-
* public (re-asserting stored public passes), both answer the Java deny
|
|
6
|
-
* copy on denial and pass under the permissive default (OSS
|
|
7
|
-
* byte-identity), internal callers skip, and a missing loaded target is
|
|
8
|
-
* a loud wiring fault.
|
|
9
|
-
*/
|
|
10
|
-
import { describe, expect, it } from "vitest";
|
|
11
|
-
import { Code, ConnectError } from "@connectrpc/connect";
|
|
12
|
-
import { create } from "@bufbuild/protobuf";
|
|
13
|
-
|
|
14
|
-
import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
15
|
-
import { AgentCommandController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/command_pb";
|
|
16
|
-
import { UpdateVisibilityInputSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
17
|
-
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
18
|
-
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
19
|
-
import { IamPermission } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
|
|
20
|
-
|
|
21
|
-
import type { Authorizer, AuthzCheck } from "../../../extensions/authorizer.js";
|
|
22
|
-
import type { CallerIdentity } from "../../../extensions/identity.js";
|
|
23
|
-
import { RequestContext } from "../../request-context.js";
|
|
24
|
-
import { newPermissiveSingleTeamAuthorizer } from "../authorize.js";
|
|
25
|
-
import {
|
|
26
|
-
newAuthorizeVisibilityTransitionStep,
|
|
27
|
-
newGuardPublicVisibilityStep,
|
|
28
|
-
PUBLIC_VISIBILITY_DENY_MESSAGE,
|
|
29
|
-
} from "../visibility-gates.js";
|
|
30
|
-
|
|
31
|
-
const USER: CallerIdentity = {
|
|
32
|
-
identityId: "ida_alice",
|
|
33
|
-
callerClass: "user",
|
|
34
|
-
issuer: "stigmer",
|
|
35
|
-
rawToken: "tok",
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const TARGET_KEY = "updateVisibilityAgent";
|
|
39
|
-
|
|
40
|
-
function denying(observed?: AuthzCheck[]): Authorizer {
|
|
41
|
-
return {
|
|
42
|
-
authorize: (_caller, check) => {
|
|
43
|
-
observed?.push(check);
|
|
44
|
-
return Promise.resolve({ kind: "deny", reason: "" });
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function createCtx(
|
|
50
|
-
visibility: ApiResourceVisibility,
|
|
51
|
-
): RequestContext<typeof AgentSchema> {
|
|
52
|
-
return new RequestContext(
|
|
53
|
-
AgentSchema,
|
|
54
|
-
create(AgentSchema, { metadata: { name: "a", visibility } }),
|
|
55
|
-
USER,
|
|
56
|
-
ApiResourceKind.agent,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
type UvDesc = typeof AgentCommandController.method.updateVisibility.input;
|
|
61
|
-
|
|
62
|
-
function updateCtx(
|
|
63
|
-
requested: ApiResourceVisibility,
|
|
64
|
-
stored: ApiResourceVisibility | undefined,
|
|
65
|
-
): RequestContext<UvDesc> {
|
|
66
|
-
const ctx = new RequestContext(
|
|
67
|
-
AgentCommandController.method.updateVisibility.input,
|
|
68
|
-
create(UpdateVisibilityInputSchema, {
|
|
69
|
-
resourceId: "agt_1",
|
|
70
|
-
visibility: requested,
|
|
71
|
-
}),
|
|
72
|
-
USER,
|
|
73
|
-
ApiResourceKind.agent,
|
|
74
|
-
);
|
|
75
|
-
if (stored !== undefined) {
|
|
76
|
-
ctx.set(
|
|
77
|
-
TARGET_KEY,
|
|
78
|
-
create(AgentSchema, { metadata: { visibility: stored } }),
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
return ctx;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
describe("GuardPublicVisibility (the create door)", () => {
|
|
85
|
-
it("denies a PUBLIC create for non-operators with the Java copy", async () => {
|
|
86
|
-
const step = newGuardPublicVisibilityStep<typeof AgentSchema>(denying());
|
|
87
|
-
const error = await step
|
|
88
|
-
.execute(createCtx(ApiResourceVisibility.visibility_public))
|
|
89
|
-
?.catch((e: unknown) => e);
|
|
90
|
-
expect((error as ConnectError).code).toBe(Code.PermissionDenied);
|
|
91
|
-
expect((error as ConnectError).rawMessage).toBe(
|
|
92
|
-
PUBLIC_VISIBILITY_DENY_MESSAGE,
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("non-public creates never reach the Authorizer (the lazy contract)", async () => {
|
|
97
|
-
const observed: AuthzCheck[] = [];
|
|
98
|
-
const step = newGuardPublicVisibilityStep<typeof AgentSchema>(
|
|
99
|
-
denying(observed),
|
|
100
|
-
);
|
|
101
|
-
await step.execute(createCtx(ApiResourceVisibility.visibility_org));
|
|
102
|
-
expect(observed).toEqual([]);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("the permissive default allows public creates (OSS byte-identity)", async () => {
|
|
106
|
-
const step = newGuardPublicVisibilityStep<typeof AgentSchema>(
|
|
107
|
-
newPermissiveSingleTeamAuthorizer(),
|
|
108
|
-
);
|
|
109
|
-
await expect(
|
|
110
|
-
Promise.resolve(
|
|
111
|
-
step.execute(createCtx(ApiResourceVisibility.visibility_public)),
|
|
112
|
-
),
|
|
113
|
-
).resolves.toBeUndefined();
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe("AuthorizeVisibilityTransition (the update door)", () => {
|
|
118
|
-
it("denies escalation to public with the operator check", async () => {
|
|
119
|
-
const observed: AuthzCheck[] = [];
|
|
120
|
-
const step = newAuthorizeVisibilityTransitionStep<UvDesc>(
|
|
121
|
-
TARGET_KEY,
|
|
122
|
-
denying(observed),
|
|
123
|
-
);
|
|
124
|
-
const error = await step
|
|
125
|
-
.execute(
|
|
126
|
-
updateCtx(
|
|
127
|
-
ApiResourceVisibility.visibility_public,
|
|
128
|
-
ApiResourceVisibility.visibility_org,
|
|
129
|
-
),
|
|
130
|
-
)
|
|
131
|
-
?.catch((e: unknown) => e);
|
|
132
|
-
expect((error as ConnectError).code).toBe(Code.PermissionDenied);
|
|
133
|
-
expect((error as ConnectError).rawMessage).toBe(
|
|
134
|
-
PUBLIC_VISIBILITY_DENY_MESSAGE,
|
|
135
|
-
);
|
|
136
|
-
expect(observed).toEqual([
|
|
137
|
-
{
|
|
138
|
-
permission: IamPermission.can_set_public_visibility,
|
|
139
|
-
resourceKind: ApiResourceKind.platform,
|
|
140
|
-
resourceId: "stigmer",
|
|
141
|
-
},
|
|
142
|
-
]);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("re-asserting a stored PUBLIC is not an escalation", async () => {
|
|
146
|
-
const step = newAuthorizeVisibilityTransitionStep<UvDesc>(
|
|
147
|
-
TARGET_KEY,
|
|
148
|
-
denying(),
|
|
149
|
-
);
|
|
150
|
-
await expect(
|
|
151
|
-
Promise.resolve(
|
|
152
|
-
step.execute(
|
|
153
|
-
updateCtx(
|
|
154
|
-
ApiResourceVisibility.visibility_public,
|
|
155
|
-
ApiResourceVisibility.visibility_public,
|
|
156
|
-
),
|
|
157
|
-
),
|
|
158
|
-
),
|
|
159
|
-
).resolves.toBeUndefined();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("non-public targets never reach the Authorizer", async () => {
|
|
163
|
-
const observed: AuthzCheck[] = [];
|
|
164
|
-
const step = newAuthorizeVisibilityTransitionStep<UvDesc>(
|
|
165
|
-
TARGET_KEY,
|
|
166
|
-
denying(observed),
|
|
167
|
-
);
|
|
168
|
-
await step.execute(
|
|
169
|
-
updateCtx(
|
|
170
|
-
ApiResourceVisibility.visibility_org,
|
|
171
|
-
ApiResourceVisibility.visibility_public,
|
|
172
|
-
),
|
|
173
|
-
);
|
|
174
|
-
expect(observed).toEqual([]);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it("a missing loaded target is a loud wiring fault, never a silent pass", async () => {
|
|
178
|
-
const step = newAuthorizeVisibilityTransitionStep<UvDesc>(
|
|
179
|
-
TARGET_KEY,
|
|
180
|
-
denying(),
|
|
181
|
-
);
|
|
182
|
-
const error = await step
|
|
183
|
-
.execute(updateCtx(ApiResourceVisibility.visibility_public, undefined))
|
|
184
|
-
?.catch((e: unknown) => e);
|
|
185
|
-
expect((error as ConnectError).code).toBe(Code.Internal);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The PUBLIC-visibility operator gates — the two write doors a resource
|
|
3
|
-
* can become public through, both consulting the ONE composed Authorizer
|
|
4
|
-
* with the same platform-scoped check (the Java
|
|
5
|
-
* PublicVisibilityEscalationPolicy port; C2 Stage 3, 20260827.10).
|
|
6
|
-
*
|
|
7
|
-
* PUBLIC is the only level that crosses every org boundary (one flip
|
|
8
|
-
* lists a resource in every tenant's cross-org catalog), so entering it
|
|
9
|
-
* is a curation decision: the owner requests, the platform team grants.
|
|
10
|
-
* The answer is `can_set_public_visibility` on `platform:stigmer` — a
|
|
11
|
-
* named operator capability, never a bare operator lookup.
|
|
12
|
-
*
|
|
13
|
-
* - GuardPublicVisibility: the CREATE door, in the create chains of
|
|
14
|
-
* the kinds whose VisibilityConfig supports PUBLIC (agent, workflow,
|
|
15
|
-
* mcp_server, agent_instance, workflow_instance). After
|
|
16
|
-
* BuildNewState — it inspects the state that will persist — which
|
|
17
|
-
* keeps the pinned INVALID_ARGUMENT level-support rejections (the
|
|
18
|
-
* earlier ValidateVisibility) their precedence over this
|
|
19
|
-
* PERMISSION_DENIED.
|
|
20
|
-
* - AuthorizeVisibilityTransition: the UPDATE door, in every
|
|
21
|
-
* updateVisibility chain after ValidateVisibilityUpdate (the pinned
|
|
22
|
-
* FAILED_PRECONDITION default-instance rejection keeps precedence,
|
|
23
|
-
* the Java ordering the conformance suite depends on). Gates only
|
|
24
|
-
* the ESCALATION to public (stored level is anything else).
|
|
25
|
-
*
|
|
26
|
-
* Both run LAZILY — only requests that actually involve the PUBLIC level
|
|
27
|
-
* reach the Authorizer — and both pass for internal callers (server-side
|
|
28
|
-
* flows publish platform resources by design). The OSS permissive
|
|
29
|
-
* default allows, so the local posture keeps today's behavior
|
|
30
|
-
* byte-identically; the cloud's FGA Authorizer supplies the gate.
|
|
31
|
-
*
|
|
32
|
-
* DELIBERATE partial port, recorded owner-visibly (Stage-3 execution
|
|
33
|
-
* record): Java's transition step additionally lets operators WITHOUT
|
|
34
|
-
* resource can_edit publish and take down (its updateVisibility chains
|
|
35
|
-
* authorize post-load, transition-aware); this edition's position-1
|
|
36
|
-
* Authorize enforces can_edit on updateVisibility before any step here
|
|
37
|
-
* runs, so those operator-without-edit lanes require can_edit until the
|
|
38
|
-
* Stage-4 chain disposition addresses them. No conformance lane pins
|
|
39
|
-
* them.
|
|
40
|
-
*/
|
|
41
|
-
import { Code, ConnectError } from "@connectrpc/connect";
|
|
42
|
-
import type { DescMessage } from "@bufbuild/protobuf";
|
|
43
|
-
|
|
44
|
-
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
45
|
-
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
46
|
-
import type { UpdateVisibilityInput } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
47
|
-
import { IamPermission } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
|
|
48
|
-
|
|
49
|
-
import type { Authorizer, AuthzDecision } from "../../extensions/authorizer.js";
|
|
50
|
-
import type { CallerIdentity } from "../../extensions/identity.js";
|
|
51
|
-
import { internalError } from "../errors.js";
|
|
52
|
-
import type { PipelineStep } from "../pipeline.js";
|
|
53
|
-
import type { RequestContext } from "../request-context.js";
|
|
54
|
-
import { metadataOf } from "./shapes.js";
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The denial callers see at both doors (the Java policy copy verbatim).
|
|
58
|
-
* Deliberately not byte-pinned by the OSS conformance suite; the cloud
|
|
59
|
-
* gate itself is recorded via the clientPublicVisibilityWrites flag.
|
|
60
|
-
*/
|
|
61
|
-
export const PUBLIC_VISIBILITY_DENY_MESSAGE =
|
|
62
|
-
"Public visibility is granted by the platform team. " +
|
|
63
|
-
"Ask a platform operator to publish this resource.";
|
|
64
|
-
|
|
65
|
-
/** The CREATE door: a new state declaring PUBLIC needs the operator grant. */
|
|
66
|
-
export function newGuardPublicVisibilityStep<Desc extends DescMessage>(
|
|
67
|
-
authorizer: Authorizer,
|
|
68
|
-
): PipelineStep<Desc> {
|
|
69
|
-
return {
|
|
70
|
-
name: "GuardPublicVisibility",
|
|
71
|
-
async execute(ctx: RequestContext<Desc>): Promise<void> {
|
|
72
|
-
if (ctx.callerIdentity.callerClass === "internal") {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (
|
|
76
|
-
metadataOf(ctx.newState)?.visibility !==
|
|
77
|
-
ApiResourceVisibility.visibility_public
|
|
78
|
-
) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
await requireOperatorMaySetPublic(authorizer, ctx.callerIdentity);
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The UPDATE door: escalation to PUBLIC (the stored level is anything
|
|
88
|
-
* else) needs the operator grant. Reads the loaded target from the
|
|
89
|
-
* chain's own context key (every updateVisibility chain stores it —
|
|
90
|
-
* the RecordVisibilityBeforeUpdate pattern).
|
|
91
|
-
*/
|
|
92
|
-
export function newAuthorizeVisibilityTransitionStep<Desc extends DescMessage>(
|
|
93
|
-
targetKey: string,
|
|
94
|
-
authorizer: Authorizer,
|
|
95
|
-
): PipelineStep<Desc> {
|
|
96
|
-
return {
|
|
97
|
-
name: "AuthorizeVisibilityTransition",
|
|
98
|
-
async execute(ctx: RequestContext<Desc>): Promise<void> {
|
|
99
|
-
if (ctx.callerIdentity.callerClass === "internal") {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const requested = (ctx.input as unknown as UpdateVisibilityInput)
|
|
103
|
-
.visibility;
|
|
104
|
-
if (requested !== ApiResourceVisibility.visibility_public) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const target = ctx.get(targetKey);
|
|
108
|
-
if (target === undefined) {
|
|
109
|
-
// Wiring error, not a user error: without the loaded target there
|
|
110
|
-
// is no stored level, and a gate that silently passes un-guards
|
|
111
|
-
// the boundary it exists to protect.
|
|
112
|
-
throw internalError(
|
|
113
|
-
new Error(
|
|
114
|
-
"AuthorizeVisibilityTransition ran without a loaded target — step must be placed after the load step",
|
|
115
|
-
),
|
|
116
|
-
"visibility authorization requires the loaded resource",
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
const stored = metadataOf(target as typeof ctx.newState)?.visibility;
|
|
120
|
-
if (stored === ApiResourceVisibility.visibility_public) {
|
|
121
|
-
return; // Re-asserting a stored PUBLIC is not an escalation.
|
|
122
|
-
}
|
|
123
|
-
await requireOperatorMaySetPublic(authorizer, ctx.callerIdentity);
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* The single owner of "may this caller set public?" — both doors call it,
|
|
130
|
-
* and so does the plugin push chain, whose requested level rides the
|
|
131
|
-
* request (the level then flows to every member through the members' own
|
|
132
|
-
* create and updateVisibility doors, which run this check again).
|
|
133
|
-
*/
|
|
134
|
-
export async function requireOperatorMaySetPublic(
|
|
135
|
-
authorizer: Authorizer,
|
|
136
|
-
caller: CallerIdentity,
|
|
137
|
-
): Promise<void> {
|
|
138
|
-
let decision: AuthzDecision;
|
|
139
|
-
try {
|
|
140
|
-
decision = await authorizer.authorize(caller, {
|
|
141
|
-
permission: IamPermission.can_set_public_visibility,
|
|
142
|
-
resourceKind: ApiResourceKind.platform,
|
|
143
|
-
resourceId: "stigmer",
|
|
144
|
-
});
|
|
145
|
-
} catch (error) {
|
|
146
|
-
throw publicVisibilityCheckFailure(error);
|
|
147
|
-
}
|
|
148
|
-
switch (decision.kind) {
|
|
149
|
-
case "allow":
|
|
150
|
-
return;
|
|
151
|
-
case "deny":
|
|
152
|
-
case "not-found":
|
|
153
|
-
throw new ConnectError(
|
|
154
|
-
PUBLIC_VISIBILITY_DENY_MESSAGE,
|
|
155
|
-
Code.PermissionDenied,
|
|
156
|
-
);
|
|
157
|
-
case "unavailable":
|
|
158
|
-
throw publicVisibilityCheckFailure(decision.cause);
|
|
159
|
-
default: {
|
|
160
|
-
const exhaustive: never = decision;
|
|
161
|
-
throw publicVisibilityCheckFailure(
|
|
162
|
-
new Error(`unknown decision ${JSON.stringify(exhaustive)}`),
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/** Authorization infrastructure failure: fail closed, sanitized (#478). */
|
|
169
|
-
function publicVisibilityCheckFailure(error: unknown): ConnectError {
|
|
170
|
-
return internalError(
|
|
171
|
-
error instanceof Error ? error : new Error(String(error)),
|
|
172
|
-
"public-visibility authorization could not be completed",
|
|
173
|
-
);
|
|
174
|
-
}
|