Project Policy Reference¶
Project policies control how assets are mapped to projects. When a new asset is discovered, project policies determine which project it belongs to — or trigger the creation of a new auto-project.
Package¶
Required output¶
| Variable | Type | Description |
|---|---|---|
project |
string | The project name to assign the asset to |
Optional outputs:
| Variable | Type | Description |
|---|---|---|
sub_project |
string | Sub-project name within the project |
create |
boolean | If true, create the project if it doesn't exist (default: true) |
Input schema¶
{
"asset": {
"name": "string — short asset name",
"source": "string — github|upload|api",
"full_name": "string — e.g., acme/backend-api",
"language": "string — primary language (if detected)",
"languages": ["string — all detected languages"],
"topics": ["string — GitHub topics or tags"],
"visibility": "string — public|private|internal",
"default_branch": "string — e.g., main",
"created_at": "string — ISO 8601 timestamp",
"org": "string — GitHub organization name"
},
"organization": {
"id": "string",
"name": "string"
}
}
Examples¶
Group by GitHub organization¶
Group by topic¶
package mayo.project
import rego.v1
# Assign based on the first matching topic
project := "payments" if {
"payments" in input.asset.topics
}
project := "platform" if {
"platform" in input.asset.topics
}
project := "mobile" if {
"mobile" in input.asset.topics
}
default project := "uncategorized"
Strip org prefix from repo name¶
package mayo.project
import rego.v1
project := name if {
input.asset.source == "github"
parts := split(input.asset.full_name, "/")
count(parts) == 2
name := parts[1]
}
Map specific repos to projects¶
package mayo.project
import rego.v1
repo_map := {
"acme/payments-api": "payments",
"acme/payments-web": "payments",
"acme/auth-service": "identity",
"acme/auth-ui": "identity",
"acme/mobile-ios": "mobile",
"acme/mobile-android": "mobile"
}
project := repo_map[input.asset.full_name]
Group by language with sub-projects¶
package mayo.project
import rego.v1
project := "backend" if {
input.asset.language in ["go", "java", "python", "rust"]
}
project := "frontend" if {
input.asset.language in ["javascript", "typescript"]
}
sub_project := input.asset.name
default project := "other"
Evaluation behavior¶
- Project policies are evaluated once when an asset is first discovered.
- If you change a project policy, existing assets are not automatically re-evaluated. Use the Re-evaluate action in the assets view to re-run the policy.
- If no project policy matches and auto-projects are enabled, a new project is created using the asset name. If auto-projects are disabled, the asset goes to the Default Project.
Interaction with auto-projects¶
| Policy match | Auto-projects enabled | Result |
|---|---|---|
| Yes, project exists | N/A | Asset assigned to existing project |
| Yes, project doesn't exist | Yes | New project created with policy name |
| Yes, project doesn't exist | No | Asset goes to Default Project |
| No match | Yes | Auto-project created with asset name |
| No match | No | Asset goes to Default Project |
Tip
Set create := false in your policy output to prevent automatic project creation even when auto-projects are enabled globally.
Testing¶
Test project policies in the playground with different asset inputs:
{
"asset": {
"name": "payments-api",
"source": "github",
"full_name": "acme/payments-api",
"language": "go",
"topics": ["payments", "backend", "production"],
"visibility": "private",
"org": "acme"
}
}
Next steps¶
- Auto-created projects — how auto-projects work
- Sub-projects — organizing within a project
- Policy scoping — scope policies to projects