@stigmer/server 3.23.0 → 3.24.0
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/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/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.map +1 -1
- package/dist/domain/plugin/controller.js +1 -3
- 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/controller.d.ts.map +1 -1
- package/dist/domain/skill/controller.js +0 -2
- package/dist/domain/skill/controller.js.map +1 -1
- package/dist/domain/workflow/agent-call-references.d.ts +81 -0
- package/dist/domain/workflow/agent-call-references.d.ts.map +1 -0
- package/dist/domain/workflow/agent-call-references.js +117 -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 +3 -3
- 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-labels.d.ts +10 -9
- package/dist/pipeline/apiresource-labels.d.ts.map +1 -1
- package/dist/pipeline/apiresource-labels.js +10 -9
- package/dist/pipeline/apiresource-labels.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 +204 -20
- package/dist/pipeline/steps/references.d.ts.map +1 -1
- package/dist/pipeline/steps/references.js +356 -43
- package/dist/pipeline/steps/references.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/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/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 +1 -8
- 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/controller.ts +0 -7
- package/src/domain/workflow/__tests__/agent-call-references.test.ts +373 -0
- package/src/domain/workflow/agent-call-references.ts +204 -0
- package/src/domain/workflow/controller.ts +28 -10
- package/src/domain/workflow/registry/data/task-kind-registry.json +3 -3
- 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-labels.ts +10 -9
- 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 +737 -0
- package/src/pipeline/steps/authorization-tuples.ts +9 -11
- package/src/pipeline/steps/references.ts +622 -70
- 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/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,38 +1,222 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* References — the two shared steps every chain that stores a spec with
|
|
3
|
+
* `ApiResourceReference` fields runs, and the ONE rule that decides whether
|
|
4
|
+
* a reference may be written.
|
|
5
5
|
*
|
|
6
6
|
* NormalizeReferences fills EMPTY org fields in ApiResourceReference
|
|
7
7
|
* messages inside the spec from the resource's own metadata.org, so stored
|
|
8
|
-
* references are absolute; explicit
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* ValidateReferences
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* references are absolute; an explicit org is preserved. Only the spec is
|
|
9
|
+
* walked — status is system-generated and already absolute. Runs after
|
|
10
|
+
* BuildNewState/BuildUpdateState, before Persist.
|
|
11
|
+
*
|
|
12
|
+
* ValidateReferences runs directly after it and asks `checkReference` for
|
|
13
|
+
* every reference the walk finds. The rule has three clauses, in the
|
|
14
|
+
* order they are asked:
|
|
15
|
+
*
|
|
16
|
+
* (i) A reference with no organization is refused. After the normalize
|
|
17
|
+
* step the only way an org is still empty is a resource that has
|
|
18
|
+
* none itself; a slug looked up with no org matches any
|
|
19
|
+
* organization's row (helpers.ts), which is the cross-tenant read
|
|
20
|
+
* the reference lane's `requireOrgForReference` exists to forbid.
|
|
21
|
+
* (ii) Same organization as the resource: the target must exist, and,
|
|
22
|
+
* when the target's kind is one the RUN reads as the person
|
|
23
|
+
* (`readByRun` in the table below), its visibility must be at least
|
|
24
|
+
* the resource's on the order private < org < platform — the FLOOR.
|
|
25
|
+
* What a person can run they must also be able to read: an
|
|
26
|
+
* org-visible agent over a private MCP server would run for every
|
|
27
|
+
* member and be readable by one. Environments, OAuth apps and
|
|
28
|
+
* channel apps are resolved by the server on the run's behalf and
|
|
29
|
+
* never read by the person, so their level is not a leak the floor
|
|
30
|
+
* closes, and an org-visible instance may hold a private personal
|
|
31
|
+
* environment as it always has. A RELATIVE reference (below) is
|
|
32
|
+
* compared against the resource's level capped at org.
|
|
33
|
+
* (iii) Another organization: the target must exist AND be
|
|
34
|
+
* platform-visible, answered with ONE sentence that does not say
|
|
35
|
+
* which failed. The caller has no standing to learn what another
|
|
36
|
+
* organization holds (the anti-probe posture the AgentShare lane set
|
|
37
|
+
* first). The rule reads the target's LEVEL, not tenancy: whether
|
|
38
|
+
* the writer's organization is one the target's identity provider
|
|
39
|
+
* links is the run-time authorizer's question, asked when the run
|
|
40
|
+
* reads the target, and the copy here claims no more than the rule
|
|
41
|
+
* checks. No Environment, OAuth app or channel app is ever
|
|
42
|
+
* platform-visible, so every cross-organization reference to one is
|
|
43
|
+
* refused here.
|
|
44
|
+
*
|
|
45
|
+
* The kind a reference names is the kind its FIELD declares
|
|
46
|
+
* (`reference_kind`, the contract's word for what the field points to),
|
|
47
|
+
* never the `kind` value a client happened to put on the message: the
|
|
48
|
+
* runtime resolves `skill_refs` as skills whatever the message says, and
|
|
49
|
+
* the rule must agree with the runtime. A reference with an empty slug is
|
|
50
|
+
* unset and skipped (the field-level CEL rules own "required").
|
|
51
|
+
*
|
|
52
|
+
* A reference is RELATIVE when it names no organization of its own and
|
|
53
|
+
* the runtime resolves it in the organization the resource RUNS in, not
|
|
54
|
+
* the one it is stored in. Exactly one exists: a workflow `agent_call`
|
|
55
|
+
* task's bare slug (domain/workflow/agent-call-references.ts), which the
|
|
56
|
+
* runner resolves in the execution's organization; any workflow a person
|
|
57
|
+
* may execute can run from another organization by id. The rule judges
|
|
58
|
+
* it in the resource's own organization — the one its author can see, so
|
|
59
|
+
* the target must exist there — and caps its floor at org: only the
|
|
60
|
+
* running organization's own people ever read a target through it, and
|
|
61
|
+
* they can read an org-visible one. The cap changes nothing for a
|
|
62
|
+
* private or org resource and lets a platform-visible workflow call its
|
|
63
|
+
* organization's org-visible agent. A value fixed only at run (an
|
|
64
|
+
* `agent_call` agent holding a runtime expression) is not a reference at
|
|
65
|
+
* all: the collector yields nothing for it, and the run reads the
|
|
66
|
+
* resolved target as the person the run acts as, as it reads every
|
|
67
|
+
* id-bound binding.
|
|
68
|
+
*
|
|
69
|
+
* The floor has a second door. Raising a resource's level through
|
|
70
|
+
* updateVisibility could open the same gap a create cannot, so
|
|
71
|
+
* GuardReferenceFloorOnEscalation runs on the two chains whose rows carry
|
|
72
|
+
* run-read references (agent, workflow) after ValidateVisibilityUpdate:
|
|
73
|
+
* when the requested level is above the stored one, every run-read
|
|
74
|
+
* reference the STORED row carries must be at least the requested level
|
|
75
|
+
* (a relative one, at least the requested level capped at org), judged by
|
|
76
|
+
* the same function over the same collectors, else the escalation is
|
|
77
|
+
* refused naming the dependencies. Only the floor is asked at
|
|
78
|
+
* that door — a dependency that has since left or stopped being shared was
|
|
79
|
+
* judged when the row was written and is the run's to refuse.
|
|
80
|
+
*
|
|
81
|
+
* REFERENCE_TARGET_KINDS is the one explicit table of kinds a spec may
|
|
82
|
+
* reference, with each kind's schema and its `readByRun` flag: the
|
|
83
|
+
* composition-root idiom (query/search/registry.ts) — an explicit list a
|
|
84
|
+
* test pins against the protos, so a new `reference_kind` in the contract
|
|
85
|
+
* fails the pin until this table says how it is read.
|
|
86
|
+
*
|
|
87
|
+
* Cost: one `listResources` scan per referenced KIND per write (not per
|
|
88
|
+
* reference), decoded once into a (org, slug) index; the same scan every
|
|
89
|
+
* runtime path already pays per reference when it resolves the target at
|
|
90
|
+
* run start. A store read by (kind, org, slug) is the follow-on that
|
|
91
|
+
* removes the scan everywhere, and is not this module's.
|
|
92
|
+
*
|
|
93
|
+
* The refusal copy is exported below. The MCP-server sentence predates the
|
|
94
|
+
* rule and is wire contract (byte-pinned by pipeline/__tests__/steps.test.ts
|
|
95
|
+
* and the agent conformance suite); its siblings for the other kinds take
|
|
96
|
+
* the same shape. `collectSpecReferences` is the walk exported for the
|
|
97
|
+
* readers that ask the reverse question ("who references this?").
|
|
16
98
|
*/
|
|
17
|
-
import type { DescMessage } from "@bufbuild/protobuf";
|
|
99
|
+
import type { DescMessage, Message } from "@bufbuild/protobuf";
|
|
18
100
|
import { reflect } from "@bufbuild/protobuf/reflect";
|
|
19
101
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
102
|
+
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
103
|
+
import type { UpdateVisibilityInputSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
20
104
|
import type { Store } from "../../store/interface.js";
|
|
105
|
+
import { failedPreconditionError } from "../errors.js";
|
|
21
106
|
import type { PipelineStep } from "../pipeline.js";
|
|
22
|
-
|
|
23
|
-
export
|
|
24
|
-
|
|
107
|
+
/** One kind a spec may reference, and how the rule reads it (the module header). */
|
|
108
|
+
export interface ReferenceTargetKind {
|
|
109
|
+
readonly kind: ApiResourceKind;
|
|
110
|
+
readonly schema: DescMessage;
|
|
111
|
+
/** Whether the run reads the target AS THE PERSON — the kinds the floor applies to. */
|
|
112
|
+
readonly readByRun: boolean;
|
|
113
|
+
/** The kind in the refusal copy's words, singular with the plural marker: "MCP server(s)". */
|
|
114
|
+
readonly label: string;
|
|
115
|
+
/** The CLI command a refusal points at, or undefined where the CLI has no verb for the kind. */
|
|
116
|
+
readonly listHint: string | undefined;
|
|
117
|
+
}
|
|
118
|
+
export declare const REFERENCE_TARGET_KINDS: ReadonlyArray<ReferenceTargetKind>;
|
|
119
|
+
export declare function referenceTargetKind(kind: ApiResourceKind): ReferenceTargetKind | undefined;
|
|
120
|
+
/** One reference a spec carries, as the walker reads it; `kind` is the field's declared kind. */
|
|
25
121
|
export interface SpecReference {
|
|
26
122
|
readonly kind: ApiResourceKind;
|
|
27
123
|
readonly slug: string;
|
|
28
124
|
readonly org: string;
|
|
125
|
+
/**
|
|
126
|
+
* Present only on a RELATIVE reference (the module header): `org` is the
|
|
127
|
+
* resource's own, filled by the collector, and the runtime resolves the
|
|
128
|
+
* slug in the organization the resource runs in. The generic walker
|
|
129
|
+
* never sets it; only the `agent_call` collector does.
|
|
130
|
+
*/
|
|
131
|
+
readonly resolvesIn?: "running-organization";
|
|
132
|
+
}
|
|
133
|
+
/** The resource the references belong to, as the rule needs it. */
|
|
134
|
+
export interface ReferenceParent {
|
|
135
|
+
readonly org: string;
|
|
136
|
+
readonly visibility: ApiResourceVisibility;
|
|
137
|
+
}
|
|
138
|
+
/** What the rule found for one reference; the collectors turn it into copy. */
|
|
139
|
+
export type ReferenceVerdict = {
|
|
140
|
+
readonly kind: "ok";
|
|
141
|
+
}
|
|
142
|
+
/** Clause (i): the reference names no organization. */
|
|
143
|
+
| {
|
|
144
|
+
readonly kind: "no-org";
|
|
29
145
|
}
|
|
146
|
+
/** Clause (ii): the same-organization target does not exist. */
|
|
147
|
+
| {
|
|
148
|
+
readonly kind: "missing";
|
|
149
|
+
}
|
|
150
|
+
/** Clause (ii): the target exists and is less visible than the resource. */
|
|
151
|
+
| {
|
|
152
|
+
readonly kind: "below-floor";
|
|
153
|
+
readonly targetVisibility: ApiResourceVisibility;
|
|
154
|
+
}
|
|
155
|
+
/** Clause (iii): the other-organization target is missing or not platform-visible — one answer. */
|
|
156
|
+
| {
|
|
157
|
+
readonly kind: "not-available";
|
|
158
|
+
};
|
|
159
|
+
/** The visibility of every referenced row the rule may need, one scan per kind (the module header). */
|
|
160
|
+
export interface ReferenceTargets {
|
|
161
|
+
visibilityOf(ref: SpecReference): ApiResourceVisibility | undefined;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Loads the rows the given references could name: one `listResources` per
|
|
165
|
+
* distinct kind, decoded once, indexed by (org, slug). A row that does not
|
|
166
|
+
* decode is skipped as the slug helpers skip it — it is not a row a
|
|
167
|
+
* reference can reach. A reference whose kind is not in the table is a
|
|
168
|
+
* contract the pin test has not admitted yet and is an internal fault.
|
|
169
|
+
*/
|
|
170
|
+
export declare function loadReferenceTargets(store: Store, refs: ReadonlyArray<SpecReference>): Promise<ReferenceTargets>;
|
|
171
|
+
/** The three clauses of the module header, for one reference. */
|
|
172
|
+
export declare function checkReference(targets: ReferenceTargets, parent: ReferenceParent, ref: SpecReference): ReferenceVerdict;
|
|
173
|
+
/** Clause (i)'s sentence. */
|
|
174
|
+
export declare function noOrgReferenceMessage(entry: ReferenceTargetKind, slug: string): string;
|
|
175
|
+
/**
|
|
176
|
+
* Clause (ii)'s sentence for the targets not found, one per kind. The MCP
|
|
177
|
+
* server form is the wire contract that predates the rule; the others are
|
|
178
|
+
* its siblings.
|
|
179
|
+
*/
|
|
180
|
+
export declare function missingReferencesMessage(entry: ReferenceTargetKind, handles: ReadonlyArray<{
|
|
181
|
+
readonly slug: string;
|
|
182
|
+
readonly org: string;
|
|
183
|
+
}>): string;
|
|
184
|
+
/** Clause (ii)'s floor sentence: the dependency and its level, against the resource's. */
|
|
185
|
+
export declare function belowFloorMessage(entry: ReferenceTargetKind, ref: SpecReference, targetVisibility: ApiResourceVisibility, parentVisibility: ApiResourceVisibility): string;
|
|
186
|
+
/** Clause (iii)'s one sentence — the same whether the target is missing or not platform-visible. */
|
|
187
|
+
export declare function notAvailableReferenceMessage(entry: ReferenceTargetKind, ref: SpecReference): string;
|
|
188
|
+
/**
|
|
189
|
+
* The refusal for a set of verdicts, or undefined when every one is ok.
|
|
190
|
+
* Missing same-organization targets are grouped per kind into one sentence
|
|
191
|
+
* (the contract's shape); every other refusal is its own sentence; the
|
|
192
|
+
* sentences are joined in the order the references were read. A no-org
|
|
193
|
+
* reference is malformed input (INVALID_ARGUMENT); everything else is a
|
|
194
|
+
* precondition the store does not meet (FAILED_PRECONDITION), the code the
|
|
195
|
+
* MCP-server contract already answers.
|
|
196
|
+
*/
|
|
197
|
+
export declare function referenceRefusal(parent: ReferenceParent, verdicts: ReadonlyArray<{
|
|
198
|
+
readonly ref: SpecReference;
|
|
199
|
+
readonly verdict: ReferenceVerdict;
|
|
200
|
+
}>): ReturnType<typeof failedPreconditionError> | undefined;
|
|
201
|
+
export declare function newNormalizeReferencesStep<Desc extends DescMessage>(): PipelineStep<Desc>;
|
|
202
|
+
export declare function newValidateReferencesStep<Desc extends DescMessage>(store: Store): PipelineStep<Desc>;
|
|
203
|
+
/** The rule over a collected list: load once, check each, render the refusal. */
|
|
204
|
+
export declare function checkReferences(store: Store, parent: ReferenceParent, refs: ReadonlyArray<SpecReference>): Promise<ReturnType<typeof referenceRefusal>>;
|
|
205
|
+
/** The references a stored row carries, for the escalation door; a chain passes one collector per place its row keeps them. */
|
|
206
|
+
export type ReferenceCollector = (row: Message) => ReadonlyArray<SpecReference>;
|
|
207
|
+
/**
|
|
208
|
+
* The floor's second door (the module header): on an updateVisibility chain,
|
|
209
|
+
* after the loaded row is on the context under `targetKey` and after
|
|
210
|
+
* ValidateVisibilityUpdate, refuses raising the level while a run-read
|
|
211
|
+
* reference the row carries would end below it.
|
|
212
|
+
*/
|
|
213
|
+
export declare function newGuardReferenceFloorOnEscalationStep(store: Store, targetKey: string, collectors: ReadonlyArray<ReferenceCollector>): PipelineStep<typeof UpdateVisibilityInputSchema>;
|
|
30
214
|
/**
|
|
31
|
-
* Every ApiResourceReference in a resource's spec
|
|
32
|
-
*
|
|
33
|
-
* question ("who references this?"): the plugin delete
|
|
34
|
-
* organization's agents and workflows for references to a
|
|
35
|
-
* about to remove.
|
|
215
|
+
* Every ApiResourceReference in a resource's spec, each with the kind its
|
|
216
|
+
* field declares — the walk both steps run, exported for the readers that
|
|
217
|
+
* ask the reverse question ("who references this?"): the plugin delete
|
|
218
|
+
* guard scans an organization's agents and workflows for references to a
|
|
219
|
+
* member it is about to remove.
|
|
36
220
|
*/
|
|
37
221
|
export declare function collectSpecReferences(schema: DescMessage, msg: Parameters<typeof reflect>[1]): SpecReference[];
|
|
38
222
|
//# sourceMappingURL=references.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../../src/pipeline/steps/references.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../../src/pipeline/steps/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,OAAO,KAAK,EAAa,WAAW,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAQrD,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AACtH,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAE/F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAC;AAGxG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EACL,uBAAuB,EAGxB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAWnD,oFAAoF;AACpF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,uFAAuF;IACvF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gGAAgG;IAChG,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,eAAO,MAAM,sBAAsB,EAAE,aAAa,CA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