From 22c5184fa35cd305a5e7383064f583f3959ddff6 Mon Sep 17 00:00:00 2001 From: doquanghuy Date: Thu, 28 May 2026 21:33:40 +0700 Subject: [PATCH] docs(workflows): restore runtime context section, clarify gate prompt Two Copilot findings on d0b9e00: 1. The `### Runtime Context` documentation for `{{ context.* }}` was lost during the rebase onto current main (the squash dropped the anchor where #2664 had added it). Restored under `## Expressions` so users can find `context.run_id` semantics and examples. 2. The continue_on_error example gate had message "Retry or skip?" but used the default `options: [approve, reject]` with `on_reject: skip`, which implied an automatic retry path that gates do not provide. Reworded the message to match the actual approve/reject semantics and added an explicit note that retry requires either custom gate options + downstream branching or a wrapper loop. Co-Authored-By: Claude Opus 4.7 (1M context) --- workflows/README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/workflows/README.md b/workflows/README.md index 9a61540b3..40c593fb6 100644 --- a/workflows/README.md +++ b/workflows/README.md @@ -246,13 +246,19 @@ steps can branch on it: then: - id: review type: gate - message: "Step failed (exit {{ steps.heavy-thing.output.exit_code }}). Retry or skip?" + message: "Step failed (exit {{ steps.heavy-thing.output.exit_code }}). Approve to continue, or reject to skip the rest of this branch." on_reject: skip else: - id: next-thing command: speckit.next-thing ``` +The gate's default `options: [approve, reject]` map directly to "continue +the run" vs. "skip the rest of this branch" — gates do not automatically +re-run the failed step. To express a retry path, either define custom +gate options and branch on the choice downstream, or wrap the failing +step in your own loop. + **Notes:** - The field must be a literal boolean (`true` / `false`); coerced @@ -284,6 +290,33 @@ message: "{{ status | default('pending') }}" Supported filters: `default`, `join`, `contains`, `map`. +### Runtime Context + +`{{ context.* }}` exposes engine-managed runtime metadata for the +current run: + +| Variable | Description | +|----------|-------------| +| `context.run_id` | The current workflow run id (the same value Spec Kit prints as `Run ID:` at the end of `workflow run`). Auto-generated runs are 8-character hex from `uuid4`; operator-supplied ids may be any alphanumeric string with hyphens or underscores. Empty string outside a run context. | + +```yaml +# Stamp telemetry events with the run id for cross-system join. +- id: emit-event + type: shell + run: 'echo "{\"run_id\":\"{{ context.run_id }}\",\"event\":\"started\"}" >> events.jsonl' + +# Per-run scratch directory. +- id: prep-scratch + type: shell + run: 'mkdir -p /tmp/run-{{ context.run_id }}' + +# Pass run id into a command for artifact metadata. +- id: tag-artifact + command: speckit.specify + input: + args: "{{ context.run_id }}" +``` + ## Input Types Workflow inputs are type-checked and coerced from CLI string values: