Repository navigation
✨ Workflow models: simulate an issue/PR against a model - #17686
Closed
clubanderson wants to merge 4 commits into
Closed
clubanderson wants to merge 4 commits into
clubanderson wants to merge 4 commits into
Conversation
Add POST /api/workflows/{name}/{version}/simulate. It loads a stored
model, compiles it, converts a JSON Facts mirror into stageengine.Facts
and runs the same deriver the engine uses, returning the decision
(state, column, stage, reason) and a per-rule trace from the new
stageengine.Explain. repo+number without facts best-effort fills from
the forge and reports which facts were filled vs unknown.
Refs #17620
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Settings → Workflows → model detail grows a Simulate section: pick a real owner/repo#N to fetch its facts, or describe one with a form generated from WF_SIM_FIELDS, then Run to see the decision chip (state · column · stage · reason), the ordered rule trace with the matched rule highlighted and each predicate's verdict, and the resulting state marked in the diagram. Refs #17620 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Refs #17620 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Refs #17620 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC phase 3c — Simulate of the workflow-models RFC (#17620), on v5, stacked on the Settings → Workflows tab PR #17681 (base
workflowmodel/v5-p3b-workflows-tab).What
API —
POST /api/workflows/{name}/{version}/simulate(read-only, any logged-in role)Request:
{ "kind": "issue"|"pr", "facts": { ...SimulateFacts... }, "repo": "owner/repo", "number": 123 }factsis a lowerCamel JSON mirror ofstageengine.Facts(labels, open, merged, draft, origin, author{login,kind,selfAuthored,role}, park{holds,needsHuman,…}, issue{bucket,…}, pr{checks,review,dco,conflicting,changesRequested,humanApprover,lane,…}). Enumerations use the engine's name helpers (author.kindhive|clanker|human|unknown,pr.checksgreen|red|pending|unknown,pr.reviewapproved|changes_requested|pending|unavailable|requires_human,pr.dcoyes|no|unknown); new exportedstageengine.ParseAuthorKind/ParseChecks/ParseReview/ParseDCOare their inverses, so a response'sfactscan be pasted back as a request.repo+numberwithoutfacts→ best-effort fill through the hive's GitHub client (newgithub.Client.WorkflowItemSnapshot: issue, PR, mergeable state, head check summary).kindmay be omitted (taken from the item; mismatch → 400). No client wired → 422, never invented.Response:
{ "decision": { "state", "column", "stage", "label", "reason", "abstain", "covered", "terminal" }, "trace": [ { "id", "state", "kind", "evaluated", "matched", "skipped", "builtin", "reason", "predicates": [ { "fact", "op", "value", "holds", "known", "actual" } ] } ], "facts": { …normalized echo… }, "filled": [...], "unknown": [...], "notes": [...] }stageengine.Explain(profile, kind, facts) (Decision, []RuleTrace)sharesholds()with the rules evaluator;Deriveis untouched. Rules mode: every rule in order, other-kind rulesskipped, evaluated until the first match (predicate verdicts + actual value), the restevaluated:false; uncovered →abstain:true, covered:false, reason "workflow: not covered…". Builtin mode: single{builtin:true, state, reason}entry.stageengine.SimulatedLanesynthesizes one from the other facts and says so innotes(passpr.laneto override).UI — Simulate panel on the model detail page
Collapsed Simulate
<details>in Settings → Workflows → detail:owner/repo#123picker + Fetch facts, issue/PR radio, facts form generated from the declarativeWF_SIM_FIELDStable, Run. Result: decision chip (state · column · stage/NNN · reason, or Not covered), the trace as an ordered list with the matched rule highlighted and each predicate asfact op value → ✓/✗/?, fetched/unknown lists, and the resulting state's chip highlighted in the diagram (.wf-dg-state.simulated). Tokens-only CSS, no raw px/colours, no downloads, notoLocaleString.Guards
dashboard/openapi.jsonpath +WorkflowSimulateRequest/Facts/Resultschemas (route-parity test).TestWorkflowSimulateHiveDefaultPR,TestWorkflowSimulateRulesTrace,TestWorkflowSimulateErrors,TestWorkflowSimulateFetchesItem(dashboard);TestExplainRulesTrace,TestExplainBuiltinTrace(stageengine).TestWorkflowsSimulateWiring,TestWorkflowsSimulateNode(form kind-awareness + round-trip, matched-rule highlight, predicate verdicts, Not covered, diagram marking).pkg/dashboard,pkg/dashboard/webstatic,pkg/stageengine,pkg/workflowmodel/...green locally (apart from the known macOS-onlyTestConfigExportReportsPersistedPath/TestKnowledgeDrainLegacyMemory); style/download/timezone/import ratchets unchanged;webstatic/gen -checkclean.Docs
docs/design/workflow-models.md→ new "Simulate (RFC phase 3c)" section (API shape, trace semantics, best-effort fill caveats).changelog.d/added-workflowmodel-simulate.md.Refs #17620