Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions changelog.d/added-workflowmodel-simulate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Workflow models, RFC phase 3c ([#17620](https://github.com/hivecommons/hive/issues/17620)): simulate an issue or PR against a model before binding it. New read-only `POST /api/workflows/{name}/{version}/simulate` takes `{kind, facts}` (a JSON mirror of the engine's `Facts`) or `{repo, number}` to best-effort fill the facts from the forge (the response lists what was fetched and what stayed unknown), runs the stored model's deriver through the new `stageengine.Explain`, and returns the decision (state, column, stage label, reason, covered/abstain) with a per-rule trace — every rule in order, the first match highlighted, each predicate's holds/known verdict — or a single built-in entry for `derivation: builtin` models. Settings → Workflows → model detail grows a **Simulate** panel: pick `owner/repo#123` and Fetch facts, or describe the item in a form, Run, and the matched state lights up in the diagram.
320 changes: 320 additions & 0 deletions dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -35898,6 +35898,70 @@
}
}
},
"/api/workflows/{name}/{version}/simulate": {
"post": {
"tags": [
"Workflows"
],
"summary": "Simulate an issue or PR against a workflow model",
"description": "Derives the state a stored model would put an item in, using the same stageengine Facts the engine uses, and returns a per-rule trace explaining why. Send `facts` directly, or `repo`+`number` to best-effort fill them from the forge (the response lists which facts were filled and which stay unknown). Read-only; RFC phase 3c of the workflow-models RFC.",
"parameters": [
{
"name": "name",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "version",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/WorkflowSimulateRequest"
}
}
}
},
"responses": {
"200": {
"description": "Decision, trace and normalized facts",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/WorkflowSimulateResult"
}
}
}
},
"400": {
"description": "Malformed body, unknown kind, or kind does not match the fetched item"
},
"404": {
"description": "Not found"
},
"422": {
"description": "Model does not compile, or no forge client is wired for repo+number fill"
},
"502": {
"description": "Forge fetch failed"
},
"503": {
"description": "No workflow store"
}
}
}
},
"/api/workflows/ingest": {
"post": {
"tags": [
Expand Down Expand Up @@ -36323,6 +36387,262 @@
}
}
},
"WorkflowSimulateRequest": {
"type": "object",
"description": "Either `facts` (with `kind`) or `repo`+`number` must be given. When both are present `facts` wins and `repo`/`number` only seed the item reference.",
"properties": {
"kind": {
"type": "string",
"enum": [
"issue",
"pr"
]
},
"repo": {
"type": "string",
"description": "owner/repo"
},
"number": {
"type": "integer"
},
"facts": {
"$ref": "#/components/schemas/WorkflowSimulateFacts"
}
}
},
"WorkflowSimulateFacts": {
"type": "object",
"description": "JSON mirror of stageengine.Facts. Enumerations are the engine's name helpers: author.kind hive|clanker|human|unknown; pr.checks green|red|pending|none|unknown; pr.review approved|changes_requested|pending|unavailable|requires_human; pr.dco yes|no|unknown.",
"properties": {
"labels": {
"type": "array",
"items": {
"type": "string"
}
},
"open": {
"type": "boolean"
},
"merged": {
"type": "boolean"
},
"draft": {
"type": "boolean"
},
"origin": {
"type": "string"
},
"author": {
"type": "object",
"properties": {
"login": {
"type": "string"
},
"kind": {
"type": "string"
},
"selfAuthored": {
"type": "boolean"
},
"role": {
"type": "string"
}
}
},
"park": {
"type": "object",
"properties": {
"holds": {
"type": "array",
"items": {
"type": "string"
}
},
"needsHuman": {
"type": "boolean"
},
"decisionLabel": {
"type": "string"
},
"possiblyExists": {
"type": "boolean"
},
"sentinel": {
"type": "boolean"
},
"humanOnlyReason": {
"type": "string"
},
"approvedDirection": {
"type": "boolean"
},
"decisionQuestion": {
"type": "string"
},
"decisionSuperseded": {
"type": "boolean"
}
}
},
"issue": {
"type": "object",
"additionalProperties": true,
"properties": {
"bucket": {
"type": "string"
}
}
},
"pr": {
"type": "object",
"additionalProperties": true,
"properties": {
"checks": {
"type": "string"
},
"review": {
"type": "string"
},
"dco": {
"type": "string"
},
"conflicting": {
"type": "boolean"
},
"changesRequested": {
"type": "boolean"
},
"humanApprover": {
"type": "boolean"
},
"lane": {
"type": "object",
"properties": {
"lane": {
"type": "string"
},
"reason": {
"type": "string"
}
}
}
}
}
}
},
"WorkflowSimulateResult": {
"type": "object",
"properties": {
"decision": {
"type": "object",
"properties": {
"state": {
"type": "string"
},
"column": {
"type": "string"
},
"stage": {
"type": "integer"
},
"label": {
"type": "string"
},
"reason": {
"type": "string"
},
"abstain": {
"type": "boolean"
},
"covered": {
"type": "boolean"
},
"terminal": {
"type": "boolean"
}
}
},
"trace": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"state": {
"type": "string"
},
"kind": {
"type": "string"
},
"evaluated": {
"type": "boolean"
},
"matched": {
"type": "boolean"
},
"skipped": {
"type": "string"
},
"builtin": {
"type": "boolean"
},
"reason": {
"type": "string"
},
"predicates": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fact": {
"type": "string"
},
"op": {
"type": "string"
},
"value": {
"type": "string"
},
"holds": {
"type": "boolean"
},
"known": {
"type": "boolean"
},
"actual": {
"type": "string"
}
}
}
}
}
}
},
"facts": {
"$ref": "#/components/schemas/WorkflowSimulateFacts"
},
"filled": {
"type": "array",
"items": {
"type": "string"
}
},
"unknown": {
"type": "array",
"items": {
"type": "string"
}
},
"notes": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"WorkflowBinding": {
"type": "object",
"properties": {
Expand Down
3 changes: 3 additions & 0 deletions src/cmd/hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,9 @@ func (b *boot) wireBootClosures() {
Config: b.cfg,
WorkflowStore: wfstore.Open(wfstore.Root(b.cfg.Data.WorkflowsDir)),
WorkflowRepoFiles: workflowRepoFiles(func() *github.Client { return b.ghClient }),
WorkflowItemSnapshot: func(ctx context.Context, repo string, number int) (github.WorkflowItemSnapshot, error) {
return b.ghClient.WorkflowItemSnapshot(ctx, repo, number)
},
AgentMgr: b.agentMgr,
CruxRuntimeHealth: cruxRuntimeHealthFunc(b.cruxSupervision),
// Provider gateways (#5565 slice 3): concrete openrouter/watsonx/
Expand Down
Loading
Loading