Skip to content

Allow behavior-defined engines to default durable continuation on - #77058

Closed
lavaman131 wants to merge 3 commits into
mainfrom
engine-default-durable
Closed

lavaman131 wants to merge 3 commits into
mainfrom
engine-default-durable

Conversation

@lavaman131

@lavaman131 lavaman131 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

cc @pelikhan

Allow a behavior-defined engine definition to make artifact-backed durable continuation its default, so workflows using engines such as Atomic persist sessions and workflow journals on every eligible run without each workflow repeating engine.durable.

ADR: ADR-77058: Engine-Default Durable Continuation

What this adds

  • Add optional behaviors.durable.default-retention-days (1 to 90) to behavior-defined engine definitions (EngineDurableDefinition and main_workflow_schema.json). When set and the workflow neither configures engine.durable nor disables it, setupWorkflowBuildContext resolves WorkflowData.EngineConfig.Durable once so all existing Durable != nil paths apply unchanged.
  • Support engine.durable: false on workflow engine configurations to opt out of an engine default, and clear DurableDisabled / skip metadata when cloning detector engine configuration in threat_detection_helpers.go.
  • Attribute engine-default durability in the experimental-feature warning (Using experimental feature: engine.durable (from engine default)).
  • Skip implicit engine-default durability and emit a warning when a workflow uses workflow_call, tools.work-queue, explicit workflow or engine concurrency, or a custom engine.command, engine.driver, or engine.harness-script, while preserving hard errors when engine.durable is configured explicitly.
  • Update schema reference docs (make generate-schema-docs), engines.md, third-party-agent.md, a minor changeset, and an ADR.

Compatibility

  • Built-in engines and existing shared engine definitions omit default-retention-days, so existing workflows are unaffected and zero .lock.yml files change.
  • Explicit engine.durable retention values override default-retention-days.

Validation

  • make fmt, make fmt-check, make fmt-check-json, make generate-schema-docs, and make build passed.
  • ./gh-aw compile --validate --purge --schedule-seed github/gh-aw: 365 workflows compiled, 0 .lock.yml diffs.
  • go test ./pkg/parser/... -count=1 and go test ./pkg/workflow/... -count=1 passed (with commit.gpgsign=false for temp-repo fixtures; only TestKVMAccessExecutesAgainstFixtures failed locally because setfacl is not installed on this host).
  • make test-wasm-golden, go vet ./cmd/... ./pkg/..., make validate-cjs-syntax, make check-stale-lock-files, make check-skill-file-paths, make validate-model-alias-chains, and make check-stale-schema-binary passed. (golangci-lint, shellcheck, and specs/otel tsp are not installed locally.)

Add optional `behaviors.durable.default-retention-days` (1 to 90) so a
behavior-defined engine definition can enable artifact-backed durable
continuation by default without requiring each consuming workflow to set
`engine.durable`. Allow `engine.durable: false` to opt out, attribute
engine-default durability in the experimental-feature warning, and skip
implicit durability with a warning when a workflow uses `workflow_call`,
`tools.work-queue`, explicit concurrency, or a custom command, driver,
or harness override.
@lavaman131
lavaman131 force-pushed the engine-default-durable branch from c863dcf to 7e10d0b Compare November 12, 2026 04:28
data.EngineConfig.durableDefaultSkipReason = reason
return
}
data.EngineConfig.Durable = &DurableConfig{
data.EngineConfig.durableDefaultSkipReason = reason
return
}
data.EngineConfig.Durable = &DurableConfig{
@lavaman131
lavaman131 marked this pull request as ready for review November 12, 2026 05:09
Copilot AI adaptive review requested due to automatic review settings November 12, 2026 05:09
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Specification Reviewer · gpt56 · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

Generated by PR Specification Reviewer for #77058

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #77058

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. I found one actionable documentation correctness issue: the generated frontmatter reference shows engine.durable: true, but the schema and parser accept only false or an object, so following the example causes compilation to fail. The inline comment identifies the fix. The specialist pass was unavailable due to tool-permission rejection; findings were independently adjudicated from the pre-fetched diff and targeted source reads.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

retention-days: 1

# Format 2: Disable durable mode when the selected engine enables it by default.
durable: true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example uses durable: true, but the new schema explicitly accepts only an object or the boolean false; true is rejected by applyEngineDurableField. As generated reference documentation, this will direct users to a workflow that fails compilation. Please change the example to durable: false (and regenerate the repeated sections).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated schema-example generation so const values are honored, then regenerated the reference; the opt-out examples now use durable: false. Fixed in 573d122e.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate — ADR Verified

ADR reviewed: ADR-77058: Engine-Default Durable Continuation (link unavailable: invalid HTTPS URL) — implementation aligns with the stated decision. Great work! 🏗️

📋 Verification Summary

Why the gate applies: no implementation label, but the PR adds 598 lines under pkg/ (default business-logic directories), above the 100-line threshold.

Decision vs. diff:

  • Schema field: behaviors.durable.default-retention-days (1–90) on EngineDurableDefinition (pkg/workflow/engine_definition.go), range-checked in pkg/workflow/behavior_defined_engine_durable.go, and added to pkg/parser/schemas/main_workflow_schema.json.
  • Resolved once during setup: applyEngineDurableDefault runs in setupWorkflowBuildContext (pkg/workflow/compiler_orchestrator_workflow.go) and fills EngineConfig.Durable, so existing Durable != nil paths are unchanged. It runs before applyDefaults writes the generated concurrency, so the default is not mistaken for explicit concurrency.
  • Opt-out and precedence: engine.durable: false sets DurableDisabled (pkg/workflow/engine_durable.go). An explicit engine.durable object overrides the engine default.
  • Incompatible shapes: workflow_call, work-queue, explicit concurrency or engine.concurrency, and custom command, driver, or harness-script skip implicit durability with a warning (emitEngineDefaultDurableSkipWarning). Explicit engine.durable keeps its hard errors in validateEngineDurable.
  • Attribution: the experimental warning says (from engine default) for implicit durability.
  • Tests: pkg/workflow/engine_durable_test.go (+411 lines) covers default compilation, override and opt-out, range validation, and skipping of incompatible shapes.
📝 Non-blocking notes
  • The ADR does not mention two small guards the code adds: a definition that sets both default-retention-days and durable: false is rejected at registration, and threat_detection_helpers.go clears DurableDisabled when it clones detector config. A line in the Neutral consequences would cover them.
  • docs/src/content/docs/reference/frontmatter-full.md also changes router-model text and removes a # Array items: string line. Neither is part of the durable change, so confirm that the regeneration was intentional.
  • The ADR is still Draft. Per the ADR template, change it to Accepted after human review.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 8.5K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this change does: It lets behavior-defined engines enable durable continuation by default. Workflows can opt out, and incompatible workflow shapes skip the default.

Should fix: Reuse the existing trigger detection helper, as noted inline.

Verdict: Ship.
Lean: -15 lines possible.

Generated by ✂️ Ponytail Reviewer for #77058 · codex · routed: gpt61 medium · ~8 AIC · ⌖ ~1 AIC · ⊞ 181
Comment /ponytail to run again

Comment thread pkg/workflow/engine_durable.go Outdated
return data.RawFrontmatter != nil && c.extractConcurrencySection(data.RawFrontmatter) != ""
}

func frontmatterHasWorkflowCallTrigger(frontmatter map[string]any) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should fix: This repeats frontmatterHasTrigger in workflow_builder_steps.go for the same scalar, list, and map trigger forms, so changes to trigger parsing must be maintained twice. Reuse that helper here, adding support there for the extra whitespace and []string cases if needed, and delete this copy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reused frontmatterHasTrigger and added trimming plus []string support for the trigger forms handled here. Added regression coverage. Fixed in 573d122e.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The schema-docs generator ignores const, producing six durable: true opt-out examples that fail compilation because both the schema and engine parser reject that value.

1 open issue
What changed in this PR

This PR lets behavior-defined engines enable artifact-backed durable continuation by default, reusing gh-aw’s existing session persistence paths while preserving workflow-level control.

Changes:

  • Add default retention settings, explicit overrides, and engine.durable: false opt-out.
  • Skip implicit durability for incompatible workflows with a warning, while keeping explicit requests strict.
  • Add validation, regression tests, reference documentation, and an architectural decision record.
File Description
pkg/​workflow/​threat_detection_helpers.go Clear durability metadata when cloning detector configuration.
pkg/​workflow/​engine.go Track durability opt-out and skip reasons.
pkg/​workflow/​engine_durable.go Resolve defaults, check compatibility, and emit warnings.
pkg/​workflow/​engine_durable_test.go Cover defaults, overrides, opt-out, and incompatible workflows.
pkg/​workflow/​engine_definition.go Add the default retention field.
pkg/​workflow/​compiler_validators.go Integrate default-specific durability warnings.
pkg/​workflow/​compiler_orchestrator_workflow.go Apply durability defaults during workflow setup.
pkg/​workflow/​behavior_defined_engine.go Validate definitions and copy retention settings.
pkg/​workflow/​behavior_defined_engine_durable.go Validate retention consistency and reject inline-driver overrides.
pkg/​parser/​schemas/​main_workflow_schema.json Define default retention and boolean opt-out schema options.
docs/​src/​content/​docs/​reference/​third-party-agent.md Explain engine-defined durability defaults and restrictions.
docs/​src/​content/​docs/​reference/​frontmatter-full.md Regenerate configuration reference examples.
docs/​src/​content/​docs/​reference/​engines.md Document workflow overrides and compatibility behavior.
docs/​adr/​77058-engine-default-durable-retention.md Record the design rationale and tradeoffs.
.changeset/​minor-engine-default-durable.md Add a minor-release changelog entry.

Review effort: Balanced (auto)

},
{
"type": "boolean",
"const": false,

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /grill-with-docs (docs and vocabulary) and /codebase-design (scope of the explicit path). Requesting changes on one user-facing doc error and one unintended side effect.

📋 Key Themes & Highlights

Key Themes

  • Doc/schema mismatch: frontmatter-full.md documents engine.durable: true as valid, but the schema and applyEngineDurableField reject it. The root cause is scripts/generate-schema-docs.js ignoring const on boolean fields. The fix belongs in the generator, not in the generated file.
  • Explicit path scope creep: validateEngineDurable now also rejects work-queue and raw workflow_call for explicit engine.durable. That is broader than the PR describes.
  • Silent skip on parse error: validateEngineDefinitionDurableConsistency returns nil when the engine JSON fails to unmarshal. The error-message path is only covered by a bare require.Error.
  • Unrelated regen churn: the labels: [] comment removal and router text in frontmatter-full.md do not belong to this change.

Positive Highlights

  • ✅ Incompatible shapes skip with a warning for the implicit default, and explicit engine.durable keeps hard errors. The matrix test covers this well.
  • ✅ Resolving the default once in setupWorkflowBuildContext and reusing the existing Durable != nil paths keeps the change small.
  • ✅ The targeted durable tests pass (go test ./pkg/workflow/ -run Durable).

Not Duplicated

The two existing github-advanced-security comments on engine_durable.go:110 (session-history exposure in artifacts and prompt-injection via restored state) still apply. They are not repeated here.

Open Questions (not blocking)

  • The implicit path can still hard-fail through validateEngineDurable or GetDurableExecutionPlan (for example, a protected-session-capture mismatch). Should that surface as a warning like the other incompatible shapes?
  • pi_engine_config.go:173 clears Durable for the Pi sub-agent but not DurableDisabled or the skip reason. Is that intentional? This line is unchanged, so I did not comment inline.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~13 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again

retention-days: 1

# Format 2: Disable durable mode when the selected engine enables it by default.
durable: true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/diagnosing-bugs] The docs show durable: true as a valid "Format 2", but the schema (const: false) and applyEngineDurableField both reject it. Root cause is scripts/generate-schema-docs.js (~L147): every boolean sample renders as true and ignores const. The same wrong line appears in 6 places.

💡 Suggested fix

Make the generator honor const (use the const value when present), then run make generate-schema-docs. Hand-editing frontmatter-full.md will be overwritten on the next regen.

@copilot please address this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema-doc generator now uses a property's const value before its type sample and the reference has been regenerated; durable opt-outs are false. Fixed in 573d122e.

return nil
}
var raw map[string]any
if err := jsonutil.UnmarshalString(engineJSON, &raw); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] This returns nil on a JSON unmarshal error, so the durable: false + default-retention-days check is silently skipped. Fail closed instead.

💡 Suggested change

Return the error, for example return fmt.Errorf("engine definition %q: parse engine JSON: %w", def.ID, err). The existing case in engine_durable_test.go (~L626) only calls require.Error. Assert the specific message for the durable: false case (for example with require.ErrorContains), so an unrelated failure cannot satisfy it.

@copilot please address this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid engine JSON now returns a contextual parse error instead of being silently ignored; the regression test asserts that message. Fixed in 573d122e.

Comment thread pkg/workflow/engine_durable.go Outdated
}
if hasWorkflowCallTrigger(data.On) || data.WorkQueuePolicy != nil {
if hasWorkflowCallTrigger(data.On) || frontmatterHasWorkflowCallTrigger(data.RawFrontmatter) ||
data.WorkQueuePolicy != nil || isWorkQueueEnabled(data) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] This also changes the explicit engine.durable path, not only the engine default. isWorkQueueEnabled(data) and the raw-frontmatter workflow_call check are now enforced for explicit config too. The new skip rules are scoped to the default, so this looks like an unintended side effect.

💡 Suggested change

If the tightening is intended, document it in the changeset and add tests that pin the explicit error for work-queue and raw workflow_call shapes. If not, keep the old checks for the explicit path and gate the new ones on the implicit flag.

@copilot please address this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raw-frontmatter trigger and work-queue checks now apply only to engine-default durability. Explicit durability retains the prior checks, with regression tests for both paths. Fixed in 573d122e.

# Accepted formats:

# Format 1: Array of label names
labels: []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/grill-with-docs] The regen also includes unrelated churn. It drops # Array items: string under labels: [] and adds router-model text in several places. The schema hunks here do not introduce that text, so the base docs appear stale relative to the base schema.

💡 Suggested change

Split the unrelated regen into its own commit (or drop it), so this PR shows only the durable and default-retention changes. Confirm that make generate-schema-docs produces this exact diff from a clean base.

@copilot please address this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the unrelated router-model prose and restored the labels item hint while keeping the durable-reference updates. Fixed in 573d122e.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (docs/src/content/docs/reference/frontmatter-full.md:3631): address unresolved feedback - Review comment
  3. Review (pkg/workflow/engine_durable.go:140): address unresolved feedback - Review comment
  4. Review (docs/src/content/docs/reference/frontmatter-full.md:3631): address unresolved feedback - Review comment
  5. Review (pkg/workflow/behavior_defined_engine_durable.go:28): address unresolved feedback - Review comment
  6. Review (pkg/workflow/engine_durable.go:196): address unresolved feedback - Review comment
  7. Review (docs/src/content/docs/reference/frontmatter-full.md:10422): address unresolved feedback - Review comment

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "7e10d0bcb8ef22746b16fa0e58dc733ccbc79733",
  "kind": "requested",
  "schema_version": "1",
  "state": "3798c4550276e05f26e22f89142b7eef9a9b85e473ef951a03b7d6a688809b01",
  "work": [
    "27206f45d491d3960ddb519cd84d40dc21232e36c7658a60aeb7d045b538aea8",
    "52e36a48adb8a578f29e860a6bb3b2fd22e64162cb1e76627ae3ace25d75b234",
    "761e49c95bb727c4dbecbff5e616d5cff6708c08ba8555b2d8fd7c7b1b2b1272",
    "8cc3e36bc9e784247a8b35a235a02847cee4e488e5d0bdf96a49645a5c332c4c",
    "a7eb4770e9dd96a7e8e9a481c8ee3a57f8a69020f0a07aa996bed8091a82e441",
    "bb35fa47fdf056b4f9066834b487e1e308acb3f50348cf396dad9baae7175e1c"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

@pelikhan

Copy link
Copy Markdown
Collaborator

@lavaman131 i will roll back on this

  • we want to keep some level of uniformity
  • durable has implications and the user should have a clear mental model if it is enabled or not

@pelikhan pelikhan closed this Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants